pub fn activity_for_event(event: &KernelEvent) -> Option<Activity>Expand description
The row a KernelEvent becomes (spec 3.2 §7.10), or None for a Health report.
The row names the kernel as its agent and the default partition; the kernel’s own sink
replaces both with the process’s when the event names one, and adds how long a process
ran when it leaves running. Reasons are dropped, and pids, wake sources, fingerprints,
rule ids and observation ids become the row’s subject, stored as a hash.
| Event | Kind | Effect | Subject | Meta |
|---|---|---|---|---|
Process | process | the state entered | the pid | |
Wake | wake | woke, spawned, deduplicated, expired or unmatched | the source | |
Held | held | the call’s fingerprint | ||
Decided | decided | approve or deny | the fingerprint | |
RuleHit | rule_hit | the rule id | ||
Spend | spend | micro_usd | ||
Agenda | proposal | the state the item entered | the item id | |
Review | audit | review | rules, sleepers, frozen | |
Driver | audit | driver. and the state entered, such as driver.crashed | the driver id | |
Observation | observation | the observation id | ||
Governance | governance | frozen or unfrozen |
§Example
use adk_core::RunState;
use adk_kernel::KernelEvent;
use adk_kernel::proc::{LedgerKind, activity_for_event};
let event = KernelEvent::Process {
pid: "run-1".into(),
from: RunState::Running,
to: RunState::Failed,
reason: Some("the tool printed the API key sk-live-1".into()),
};
let activity = activity_for_event(&event).unwrap();
assert_eq!(activity.kind, LedgerKind::Process);
assert_eq!(activity.effect.as_deref(), Some("failed"));
assert_eq!(activity.subject.as_deref(), Some("run-1"));