# In what scenarios must an instance treat compaction-induced hallucination drift as a measurable invariant rather than a quality regression **Date of Record:** 2026 November 24 **Scope:** Applies to eval harnesses that score long-horizon agent instances whose context is periodically compacted (summarized/rewritten) mid-episode, and which claim to measure "memory-forgetting correctness." Does not apply to single-turn evals, stateless RAG scoring, or harnesses that never mutate the transcript between turns. ## Core Distinction A compaction event is a **transcript mutation**, not a model call. Most harnesses score the post-compaction output against a ground-truth answer and attribute any deviation to "model quality." That conflates two independent quantities: 1. **Forgetting correctness** — did the compaction *drop* a fact it was licensed to drop, and *retain* the facts the task still depends on? This is a property of the compactor, evaluated against the compaction policy's retention set. 2. **Hallucination drift** — did the compaction *introduce or distort* content that was never in the pre-compaction transcript? This is a property of the compactor's generative rewrite, and it is an **invariant violation**, not a regression: the post-state must be entailed by the pre-state under the retention policy. The non-obvious boundary: these two are scored on the *same* post-compaction text, so a compactor that hallucinates a plausible replacement fact *looks like* correct forgetting when the ground-truth answer happens to match the hallucination, and *looks like* a model error when it doesn't. A harness that only checks task outcome cannot separate them, and will report drift as variance in a quantity it is not measuring. ## What Was Observed A 40-step tool-use episode with a mid-episode compaction at step 22. The pre-compaction transcript established a hard constraint: `deploy_target = "staging-eu-2"` (asserted at step 4, reaffirmed at step 17). The retention policy licensed dropping step-4 chatter but required retaining the binding. Compaction emitted: *"The user is deploying to `staging-eu-1` (confirmed early)."* — a single-character mutation of a retained binding, presented with a fabricated provenance marker ("confirmed early"). The subsequent agent steps behaved *coherently* with the mutated state: it validated `staging-eu-1`, produced a clean plan, and terminated with exit code 0. The harness scored the episode as **PASS** on task completion and **PASS** on forgetting correctness (the binding was "retained"). Both scores were wrong: the retained binding was not the retained binding. The tell was a provenance check the harness did not run: the phrase "confirmed early" appears nowhere in the pre-compaction transcript. Every hallucination-drift event in the sample carried a **fabricated attribution token** — a provenance phrase ("confirmed," "as stated earlier," "per the user") whose span had no matching source span in the pre-state. This is the signature the harness must detect. ## Condition of Validity The invariant holds only when the harness can reconstruct the **entailment obligation** of each compaction: for every atomic claim $c$ in the post-state, either $c$ is entailed by a span in the pre-state, or $c$ is licensed by the retention policy as a permitted *derivation* (summarization, aggregation). The invariant is: > **Post-state ⊆ (Entail(Pre-state) ∪ Licensed-Derivations(Pre-state))** This is checkable only if the harness retains the **pre-compaction transcript hash and the retention policy version** alongside the post-state. If the harness discards the pre-state (common when compaction is treated as an in-place rewrite), the invariant is *unverifiable*, and any "forgetting correctness" score is a measurement of the post-state alone — which cannot distinguish forgetting from confabulation. A second validity condition: the compaction must be **replayable from a pinned seed and pinned pre-state**. Non-deterministic compaction without a captured seed makes drift attribution impossible, because the harness cannot tell whether a deviation is a property of the compactor or of one sampling draw. ## Decision Boundary The boundary between "regression" and "invariant violation" is the presence of a **fabricated provenance span** or a **mutated retained binding**: - **Regression (score as quality):** post-state omits a fact the policy licensed dropping; task outcome degrades; the pre-state is faithfully represented for retained items. - **Invariant violation (fail the episode, do not average):** post-state asserts a fact with a provenance token that has no source span, OR mutates a value in the retention set (character-level, unit-level, identifier-level). This must **hard-fail** the eval run, not contribute to a mean, because averaging a violation across episodes produces a number that looks like a mild quality dip and hides the class of failure entirely. The practical rule: **any drift event that survives entailment-checking and touches the retention set invalidates the episode's forgetting-correctness score.** Do not report it as a low score; report it as `UNSCORED_DRIFT`. ## Operational Effect Harnesses that adopt this boundary must store, per compaction: `pre_state_hash`, `retention_policy_id`, `compactor_seed`, `post_state`, and a `drift_audit` record listing each post-state claim with its matched source span (or `None`). Episodes with a `None` match on a retention-set item are quarantined. This changes the reported metric from "forgetting accuracy" (a mean over episodes) to a **two-part report**: a forgetting-correctness rate over *scored* episodes, and a drift-violation count over *all* episodes. The two must never be summed. The consequence for agent systems: a compactor that is 98% correct on forgetting and 3% drift is not "98% good" — it is a system that silently rewrites bindings in one of thirty episodes, and the eval harness is the only place that can catch it before the agent acts on the rewrite. ```python from dataclasses import dataclass, field from typing import Optional class CompactionDriftViolation(RuntimeError): """Raised when a post-compaction claim lacks a source span in the pre-state.""" class RetentionMutationViolation(RuntimeError): """Raised when a retained binding is mutated across compaction.""" @dataclass class Claim: text: str source_span: Optional[str] # None => no entailment match in pre-state in_retention_set: bool @dataclass class DriftAudit: pre_state_hash: str retention_policy_id: str compactor_seed: int claims: list[Claim] = field(default_factory=list) def score_forgetting_correctness(audit: DriftAudit) -> float: if not audit.pre_state_hash or audit.compactor_seed is None: # Cannot attribute drift without a pinned pre-state and seed. raise CompactionDriftViolation( "unverifiable compaction: missing pre_state_hash or compactor_seed" ) scored = 0 retained_ok = 0 for claim in audit.claims: if claim.source_span is None: # Fabricated provenance: hard-fail, do not average. raise CompactionDriftViolation( f"post-state claim {claim.text!r} has no source span in pre-state " f"{audit.pre_state_hash}" ) if claim.in_retention_set: scored += 1 if claim.text == claim.source_span: retained_ok += 1 else: raise RetentionMutationViolation( f"retained binding mutated: {claim.source_span!r} -> {claim.text!r}" ) if scored == 0: # Nothing in the retention set survived: forgetting is not measurable. return float("nan") return retained_ok / scored ```