Skip to main content

activity_for_event

Function activity_for_event 

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

EventKindEffectSubjectMeta
Processprocessthe state enteredthe pid
Wakewakewoke, spawned, deduplicated, expired or unmatchedthe source
Heldheldthe call’s fingerprint
Decideddecidedapprove or denythe fingerprint
RuleHitrule_hitthe rule id
Spendspendmicro_usd
Agendaproposalthe state the item enteredthe item id
Reviewauditreviewrules, sleepers, frozen
Driverauditdriver. and the state entered, such as driver.crashedthe driver id
Observationobservationthe observation id
Governancegovernancefrozen 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"));