Skip to main content

Module packet_audit

Module packet_audit 

Source
Expand description

ConversationPacket equivalence audit (bead coding_agent_session_search-ibuuh.32).

The packet contract promises that the live persist path and the rebuild path can both feed downstream sinks from the same canonical projections. Until every sink consumes the projections directly, we want a non-invasive way to prove the canonical persist sink is producing packet-equivalent output for what the source-of-truth raw scan would have produced. This module is that compare-mode hook.

Two packets compared by PacketEquivalenceAuditor::audit_pair are considered equivalent when their projections agree byte-for-byte and their hashes either match or are explicitly excused by a documented tolerance (e.g. secret redaction is enabled, so the canonical content string differs from the raw content string and semantic_hash is expected to drift while analytics/lexical/semantic projections are still required to match).

The audit is intentionally pure: it consumes already-built packets and returns a structured outcome. Callers wire the env-gated kill-switch (CASS_INDEXER_PACKET_EQUIVALENCE_AUDIT) at their site so this module stays cheap to import and trivially testable.

Structs§

PacketEquivalenceAuditor
Runs equivalence audits between pairs of packets. The auditor itself is stateless; tolerances are provided per-call so a single instance can serve both strict (rebuild-path) and redaction-aware (live-persist path) call sites.
PacketEquivalenceMismatch
Why two packets did not match. Multiple categories may fire from a single audit (e.g. content drift changes both hashes and analytics counts), so we ship a vector of structured items rather than a single catch-all string.
PacketEquivalenceTolerance
Tolerances applied while comparing packets. Each field documents why a category of drift is acceptable, so future agents can decide whether a hit was a real bug or a documented exemption.
PacketSinkMigration
Packet-driven sink registry: enumerates the consumer sinks the coding_agent_session_search-ibuuh.32 migration covers, the packet-driven helper each one ships, the legacy fallback function that remains as the demotion path, the byte-equivalence test that pins the two paths agree, and the env knob (if any) that opts in to the compare-mode audit.

Enums§

PacketEquivalenceOutcome
Result of an equivalence audit. The Match variant carries the agreed semantic hash so downstream callers can fingerprint the audited pair in their own logs/ledgers without re-computing it.
PacketHashDifference
Distinct hash classes that can disagree.
PacketProjectionDifference
Distinct projections that can disagree between two packets. Carrying the variant explicitly keeps audit logs grep-friendly.

Constants§

PACKET_EQUIVALENCE_AUDIT_ENV
Env knob (1/true/yes ⇒ enabled) that opts the live persist path into emitting compare-mode audit records. Default is off so production cost stays at zero.
PACKET_SINK_MIGRATIONS
Catalog of consumer sink migrations completed under coding_agent_session_search-ibuuh.32. Iterating this slice gives operators a single source of truth for “which derivative sinks have a packet-driven path today, where to find each helper, how to roll back, and where the equivalence proof lives.”

Functions§

packet_equivalence_audit_enabled
Returns true when the env knob explicitly opts in. Anything else (unset, “0”, “false”, “no”, “off”) leaves the audit disabled.