Skip to main content

Module audit

Module audit 

Source
Available on crate feature 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:

RecordWhenCarries
callevery RPC ends, refused ones includedmethod, outcome, call id, actor, trace
call.startedan RPC is admitted, if the log is requiredmethod, call id, trace
call.unresolvedreconcile_unresolved finds a call that was admitted and never endedcall id, the call.started it closes
tool.actiona tool call is put to an AuditedPolicy, if one is installedtool, call id, verdict, digest of the arguments, caller, task
run.startedan executor starts a run of a tasktask, context, message id, digests of the message and each part, actor, trace
task.eventan event is written to the task’s event logits position, new state, digest, and the run.started it belongs to
task.cancel_requestedCancelTask signals a running tasktask, actor, trace
task.steereda 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.started cannot 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 in AuditLog::outcomes_lost, never dropped without a trace;
  • what a crash or a full spool leaves behind, a call.started with no call, is found by AuditLog::unresolved_calls and closed with a call.unresolved record by AuditLog::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§

AuditLog
The audit log: the one place records are sealed.
AuditPrivacy
The keys an AuditLog protects its records with.
AuditRetention
How long records must be kept before AuditLog::purge may delete them.
Erasure
What AuditLog::erase_subject did.
InMemoryAuditStore
An AuditStore in 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.
LegalHold
A legal hold: while one is placed on a chain, retention deletes nothing from it.
PostgresAuditStore
An AuditStore in PostgreSQL tables a2a_audit_records, a2a_audit_checkpoints, a2a_audit_holds and a2a_audit_subject_keys, created if absent.
PurgeReport
What AuditLog::purge did to each chain.
Revealed
A record with what it seals opened.
SqliteAuditStore
An AuditStore in SQLite tables a2a_audit_records, a2a_audit_checkpoints, a2a_audit_holds and a2a_audit_subject_keys, created if absent.
SubjectKey
One person’s audit key, as AuditPrivacy (with the encryption feature) keeps it.
UnresolvedCall
A call that was admitted and has no record of how it ended.

Enums§

Appended
What AuditStore::append did.
Erased
What an operator’s erasure removed, for AuditLog::record_erasure.
NamedAppend
What AuditStore::append_next_naming did.

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’s SEALED_PREFIX (the encryption feature), 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§

AuditStore
Durable storage for audit chains.

Functions§

sid_marker
The text a sealed value referencing sid holds: what AuditStore::delete_subject_key_unless_named looks 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.