Skip to main content

Module audit_log

Module audit_log 

Source
Expand description

Inference Audit Log

Provides an immutable, append-only audit trail for every distributed inference query: which peers were queried, which rules fired, what bindings were produced, and in what order. Designed for compliance and post-hoc debugging.

§Overview

InferenceAuditLog accumulates AuditEntry records in a bounded ring buffer (default cap 100 000 entries). Each entry carries a globally-monotonic sequence number, a trace_id that groups all events belonging to a single logical session, and an AuditEvent payload.

AuditStats tracks high-level counters (total appended/trimmed, queries started/completed/failed) using atomic operations so that stat reads never block appenders.

§Examples

use ipfrs_tensorlogic::audit_log::{AuditEvent, InferenceAuditLog};

let log = InferenceAuditLog::default();

let seq = log.append(
    "session-1",
    AuditEvent::QueryStarted {
        goal: "parent(X, alice)".to_string(),
        session_id: "session-1".to_string(),
        timestamp_ms: 1_000,
    },
).expect("example: should succeed in docs");

assert_eq!(seq, 0);
assert_eq!(log.entry_count(), 1);

let entries = log.entries_for_trace("session-1");
assert_eq!(entries.len(), 1);

Structs§

AuditEntry
A single record in the audit log.
AuditStats
Atomic counters tracking aggregate log activity.
AuditStatsSnapshot
A point-in-time snapshot of AuditStats counters.
InferenceAuditLog
Immutable, append-only audit trail for distributed inference queries.

Enums§

AuditError
Errors returned by InferenceAuditLog operations.
AuditEvent
A single observable event in the lifetime of a distributed inference query.