Skip to main content

activity_for_audit

Function activity_for_audit 

Source
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.

RecordKindEffectMeta
tool_call, decision denieddenialthe tool’s effect class
tool_call, decision approval_requiredheldthe tool’s effect class
approval, decision approved / rejectedapproval / rejection
harness.spendturnmodel_calls, tool_calls, tokens, prompt_tokens, cached_tokens, cost_micro_usd
harness.loop.detectedloop_guardidentical_calls, redundant_calls
any other recordauditits 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);