audit only.Expand description
A tamper-evident audit trail of who did what to which task (ADR 0015).
Enabled by the audit feature and switched on with
RequestHandlerBuilder::with_audit.
The handler then records, in one hash chain per tenant:
| Record | When | Carries |
|---|---|---|
call | every RPC ends, refused ones included | method, outcome, call id, actor, trace |
call.started | an RPC is admitted, if the log is required | method, call id, trace |
call.unresolved | reconcile_unresolved finds a call that was admitted and never ended | call id, the call.started it closes |
tool.action | a tool call is put to an AuditedPolicy, if one is installed | tool, call id, verdict, digest of the arguments, caller, task |
run.started | an executor starts a run of a task | task, context, message id, digests of the message and each part, actor, trace |
task.event | an event is written to the task’s event log | its position, new state, digest, and the run.started it belongs to |
task.cancel_requested | CancelTask signals a running task | task, actor, trace |
task.steered | a message is accepted into a running task’s inbox (ADR 0036) | task, message id, digest of the message, how it was delivered, actor, trace |
Content is recorded by SHA-256 digest of its RFC 8785 canonical JSON, not
verbatim, so the chain proves what was said without holding it. The
record types, the chain and its verification are
a2a_protocol_types::audit; this module writes them.
Attribution. An event is the agent’s, not a caller’s; it is
attributable to whoever started the run that emitted it. Each task.event
names that run’s run.started record by runSeq, and that record names
the actor. A run forgotten by a restart, or past the registry’s bound, is
recorded without runSeq.
Failure. A record that cannot be written is logged, counted
(AuditLog::failures) and reported as audit_append to the handler’s
metrics; the call or event it describes goes ahead. A deployment for
which an unrecorded call is worse than a refused one sets
AuditLog::require_record, which holds three promises:
- a call whose
call.startedcannot be written is refused; - any other record the store refuses is kept and written when the store
answers again, oldest first, by a task the log starts itself
(
AuditLog::pending_outcomes,AuditLog::flush_pending). A record written late sits after records that came later in time; each names what it describes. The wait is memory, bounded: a record that does not fit, or that a store which still answers reads keeps refusing, is counted inAuditLog::outcomes_lost, never dropped without a trace; - what a crash or a full spool leaves behind, a
call.startedwith nocall, is found byAuditLog::unresolved_callsand closed with acall.unresolvedrecord byAuditLog::reconcile_unresolved: run it at start-up and on a schedule. It says the outcome is not known, which is more than the chain said before.
A chain proves the records it holds are intact; it cannot show that one was
never written, and a process that dies with records in its spool loses them.
For an action that must not run unrecorded, AuditedPolicy
(tool-loop feature) writes the record before a tool call runs and
refuses the call if it cannot. Retaining signed checkpoints off the
machine, so that a rewritten chain is detectable, is the deployment’s: see
AuditLog::checkpoint.
What it is not. It is not a trusted timestamping service, and a process holding the signing key can rewrite and re-sign a chain. See ADR 0015 for the threat model.
Modules§
- record
- Tamper-evident audit records (ADR 0015).
Structs§
- Audit
Log - The audit log: the one place records are sealed.
- Audit
Privacy - The keys an
AuditLogprotects its records with. - Audit
Retention - How long records must be kept before
AuditLog::purgemay delete them. - Erasure
- What
AuditLog::erase_subjectdid. - InMemory
Audit Store - An
AuditStorein memory: for tests and for deployments that ship records elsewhere and keep none. Everything is lost on restart, which is no use as a log of record. - Legal
Hold - A legal hold: while one is placed on a chain, retention deletes nothing from it.
- Postgres
Audit Store - An
AuditStoreinPostgreSQLtablesa2a_audit_records,a2a_audit_checkpoints,a2a_audit_holdsanda2a_audit_subject_keys, created if absent. - Purge
Report - What
AuditLog::purgedid to each chain. - Revealed
- A record with what it seals opened.
- Sqlite
Audit Store - An
AuditStoreinSQLitetablesa2a_audit_records,a2a_audit_checkpoints,a2a_audit_holdsanda2a_audit_subject_keys, created if absent. - Subject
Key - One person’s audit key, as
AuditPrivacy(with theencryptionfeature) keeps it. - Unresolved
Call - A call that was admitted and has no record of how it ended.
Enums§
- Appended
- What
AuditStore::appenddid. - Erased
- What an operator’s erasure removed, for
AuditLog::record_erasure. - Named
Append - What
AuditStore::append_next_namingdid.
Constants§
- HMAC_
KEY_ LEN - The length of an HMAC key.
- KEYED_
DIGEST_ PREFIX - The prefix of a keyed digest in a record.
- SEALED_
PREFIX - The prefix of a sealed value in a record.
- SEALED_
VALUE_ PREFIX - The prefix of a sealed value in a record: the same string as
AuditPrivacy’sSEALED_PREFIX(theencryptionfeature), here so that a store can find the values of a handle without that feature. - SIX_
MONTHS - Six months, rounded up: the longest six consecutive calendar months (July–December) are 184 days.
Traits§
- Audit
Store - Durable storage for audit chains.
Functions§
- sid_
marker - The text a sealed value referencing
sidholds: whatAuditStore::delete_subject_key_unless_namedlooks for in a record.
Type Aliases§
- BoxFuture
- A boxed future, as every store trait in this crate returns.
- Sealer
- Seals one record onto a chain, for
AuditStore::append_next.