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§
- Packet
Equivalence Auditor - 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.
- Packet
Equivalence Mismatch - 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.
- Packet
Equivalence Tolerance - 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.
- Packet
Sink Migration - Packet-driven sink registry: enumerates the consumer sinks the
coding_agent_session_search-ibuuh.32migration 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§
- Packet
Equivalence Outcome - Result of an equivalence audit. The
Matchvariant carries the agreed semantic hash so downstream callers can fingerprint the audited pair in their own logs/ledgers without re-computing it. - Packet
Hash Difference - Distinct hash classes that can disagree.
- Packet
Projection Difference - 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
truewhen the env knob explicitly opts in. Anything else (unset, “0”, “false”, “no”, “off”) leaves the audit disabled.