pub fn activity_for_audit(draft: &AuditRecordDraft) -> Option<Activity>Expand description
The row an audit record becomes (spec 3.2 §7.10), or None when another source writes
it: an allowed tool call (the harness writes its tool_call row with the duration) and
the kernel’s own kernel.* and governance.* records (its events write those).
Every row keeps the actor’s agent and invocation and, as its subject, the action and the arguments’ digest; reasons and every other extension field but the counts below are dropped.
| Record | Kind | Effect | Meta |
|---|---|---|---|
tool_call, decision denied | denial | the tool’s effect class | |
tool_call, decision approval_required | held | the tool’s effect class | |
approval, decision approved / rejected | approval / rejection | ||
harness.spend | turn | model_calls, tool_calls, tokens, prompt_tokens, cached_tokens, cost_micro_usd | |
harness.loop.detected | loop_guard | identical_calls, redundant_calls | |
| any other record | audit | its action, such as harness.mode.changed |
§Example
use adk_core::audit_log::{AuditRecordDraft, AuditRecordKind};
use adk_kernel::proc::{LedgerKind, activity_for_audit};
let draft = AuditRecordDraft::new(AuditRecordKind::Other("harness".into()), "harness.spend")
.ext("modelCalls", serde_json::json!(3))
.ext("cost", serde_json::json!(1250));
let activity = activity_for_audit(&draft).unwrap();
assert_eq!(activity.kind, LedgerKind::Turn);
assert_eq!(activity.meta["cost_micro_usd"], 1250);