Module: Reeve::Audit::Query
- Extended by:
- Scopes
- Defined in:
- lib/reeve/audit/query.rb
Overview
The documented way to read the ledger (FR-013): one scope per query axis — principal, agent, tool, outcome, time range — each backed by one of the composite indexes the generated migration creates.
Q = Reeve::Audit::Query
Q.for_principal(user)
.for_agent("claude-desktop")
.between(1.week.ago, Time.current)
.pluck(:tool_name, :record_type, :record_ids, :outcome, :rule)
The scopes are also extended onto Entry, so a host that would rather work with the model directly gets the same chain. There is deliberately no scope that writes.
Defined Under Namespace
Modules: Scopes
Class Method Summary collapse
- .all ⇒ Object
-
.principal_key(principal) ⇒ Object
How a principal becomes a pair of columns.
Methods included from Scopes
allowed, between, denied, for_agent, for_principal, for_tool
Class Method Details
.all ⇒ Object
52 53 54 |
# File 'lib/reeve/audit/query.rb', line 52 def all Entry.all end |
.principal_key(principal) ⇒ Object
How a principal becomes a pair of columns. Mirrors Reeve::Context#principal_type and #principal_id exactly — a query that derived the key differently would quietly fail to find the rows the envelope wrote.
Accepts the principal itself, or type:/id: for when an incident report is
all that survives of them.
62 63 64 65 66 67 68 69 |
# File 'lib/reeve/audit/query.rb', line 62 def principal_key(principal) return explicit_key(principal) if principal.is_a?(Hash) { principal_type: principal.class.name, principal_id: principal.respond_to?(:id) ? principal.id.to_s : principal.to_s } end |