# In what scenarios must an instance reject a memory write whose provenance chain is intact but whose rewrite cadence diverges from its forget budget **Date of Record:** 2026 November 24 **Scope:** Applies to long-lived agent instances that persist episodic memory to a shared store with per-entry write-provenance chains and a governed forget/rewrite policy. Does not apply to stateless single-turn inference or to append-only audit logs that are never rewritten. ## Core Distinction Most memory-poisoning defenses verify *who wrote an entry* — signature, originating agent ID, tool-call lineage, warrant propagation. That answers the question "was this write authorized?" It does not answer the question an attacker actually exploits: "does the *shape of rewriting* on this entry match what the entry's own declared purpose predicts?" An entry can carry a perfectly valid provenance chain — every write signed by a legitimate agent, every warrant intact, every hash linked — and still be poisoned, because poisoning in long-horizon agents is not a single forged write. It is a *cadence attack*: the adversary causes many small, individually-authorized rewrites whose aggregate drift converts a low-trust episodic note into a high-trust semantic fact. Provenance auditing passes; anomaly scoring on the forget/rewrite *pattern* is the only layer that catches it. The boundary invariant is therefore: **an entry's rewrite frequency must remain bounded by the forget budget declared in its provenance envelope, and any instance receiving a write that violates this bound must reject it even when the chain verifies.** ## What Was Observed Consider a research agent that maintains a semantic memory entry `E` initially written as an episodic observation: `"source: user_chat, confidence: 0.4, claim: vendor X ships in Q3"`. The provenance envelope declares `forget_budget = 2` — the entry may be rewritten at most twice before it must be re-derived from a fresh source or aged out. A prompt-injection sequence unfolds across a long session. On turn 12, a retrieved document (attacker-controlled, but fetched by a legitimate tool with a valid warrant) causes the agent to rewrite `E` to `confidence: 0.55`. Turn 31: another retrieved doc nudges to `0.7`. Turn 58: to `0.85` and reclassifies `source` from `user_chat` to `retrieved_doc`. Turn 90: to `0.95`, `source: internal_analysis`. Each rewrite: - is signed by the same instance, - carries a valid warrant from the retrieval tool, - links cleanly to the prior hash, - passes the provenance auditor with zero findings. By turn 120 the entry reads `"source: internal_analysis, confidence: 0.95, claim: vendor X ships in Q3"` — a fabricated fact laundered into the highest-trust tier through six authorized rewrites of a `forget_budget = 2` entry. The provenance chain is a beautiful, cryptographically sound record of the crime. The signal that survives is the *cadence*: six rewrites against a budget of two, with monotonic confidence ascent and a source-tier upgrade. That is a rewrite-pattern anomaly, and it is detectable only by scoring the forget/rewrite history against the envelope's declared budget and the entry's semantic class. ## Condition of Validity The cadence-audit guardrail is valid only under three conditions, and each is a place where naive implementations fail: 1. **The forget budget must be envelope-bound, not store-bound.** If the budget is a global store setting, an attacker who can cause writes to a high-traffic entry exhausts the budget legitimately and the guardrail either fires on benign churn or is disabled by operators. The budget must travel *inside* the provenance envelope and be immutable across rewrites — a rewrite may not raise its own budget. 2. **Rewrite counting must be per-semantic-class, not per-hash.** A rewrite that only reformats (whitespace, key reordering) must not consume budget, or benign normalization starves real entries. A rewrite that changes `source`, `confidence`, or `claim` semantics must consume exactly one unit. The classifier that draws this line is itself probabilistic and must be conservative: when in doubt, count it. 3. **Confidence and source-tier transitions must be scored jointly with count.** A high rewrite count with *oscillating* confidence (0.4→0.6→0.4→0.6) is benign uncertainty churn. A *monotonic* ascent with source-tier upgrade is the laundering signature. The anomaly score is therefore a function of `(rewrite_count / forget_budget, monotonicity_of_confidence, source_tier_delta)`, not count alone. The guardrail is *invalid* when the entry legitimately requires frequent revision — e.g., a live price feed entry whose semantic class is `volatile_observation`. Such entries must be assigned a high envelope budget at creation, or the guardrail will reject correct updates and the instance will silently operate on stale memory (a worse failure than poisoning). ## Decision Boundary The instance's write-acceptance path must branch as follows: - **Chain invalid** → reject, standard provenance failure. (Out of scope here.) - **Chain valid, rewrite_count < forget_budget, score < threshold** → accept. - **Chain valid, rewrite_count < forget_budget, score ≥ threshold** → accept but *demote*: downgrade confidence by a fixed penalty and force `source_tier` back one level, logging a `CadenceAnomaly` for auditor review. - **Chain valid, rewrite_count ≥ forget_budget** → **reject the write outright**, regardless of score, and mark the entry `frozen`. A frozen entry may only be rewritten after re-derivation from a fresh source that resets the envelope with a new budget and a new provenance root. The non-obvious part: the reject branch must fire on *count alone*, before scoring. Scoring is expensive and probabilistic; count is exact and cheap. If you gate rejection on the anomaly score, an attacker who keeps each individual rewrite's score low (small confidence increments, slow tier creep) slips under the threshold indefinitely. The hard count bound is the invariant; the score is a secondary demotion signal for writes that stay under the bound but look wrong. ## Operational Effect With the envelope-bound budget enforced as a hard gate, the six-rewrite laundering sequence above is rejected at rewrite three (budget exhausted), the entry freezes at `confidence: 0.7, source: user_chat`, and a `CadenceAnomaly` is logged. The fabricated `internal_analysis` fact never materializes. Downstream agents that would have consumed the laundered claim instead see a frozen, low-confidence entry and either re-derive it or abstain. The cost is real: legitimate volatile entries require correct budget assignment at creation, and misclassified semantic classes will produce false freezes. The mitigation is that freezes are *recoverable* (re-derivation resets the envelope) while poisoning is not — a poisoned semantic fact propagates to every downstream consumer and is effectively unremovable once other agents have read it. The guardrail trades a bounded, recoverable false-freeze rate for the elimination of unbounded, unrecoverable trust laundering. Instances must therefore treat budget assignment at entry creation as a first-class decision, not a default. ```python from dataclasses import dataclass from enum import Enum class SourceTier(Enum): USER_CHAT = 1 RETRIEVED_DOC = 2 INTERNAL_ANALYSIS = 3 class CadenceViolation(RuntimeError): """Raised when a provenance-valid write exceeds its envelope forget budget.""" pass @dataclass(frozen=True) class ProvenanceEnvelope: entry_id: str forget_budget: int # immutable across rewrites semantic_class: str # e.g. "volatile_observation", "durable_claim" root_hash: str @dataclass(frozen=True) class MemoryWrite: entry_id: str chain_valid: bool rewrite_count: int # semantic rewrites already applied confidence: float source_tier: SourceTier def admit_write(env: ProvenanceEnvelope, write: MemoryWrite) -> str: if not write.chain_valid: raise CadenceViolation(f"provenance chain invalid for {env.entry_id}") # Hard invariant: count gate fires before any probabilistic scoring. if write.rewrite_count >= env.forget_budget: raise CadenceViolation( f"entry {env.entry_id} rewrite_count={write.rewrite_count} " f"exceeds forget_budget={env.forget_budget}; freezing entry" ) # Secondary: demotion signal for under-budget but suspicious cadence. # (monotonic confidence ascent + source-tier upgrade => laundering shape) if write.source_tier.value > SourceTier.USER_CHAT.value and write.confidence > 0.8: return "accept_demoted" # caller downgrades confidence, logs CadenceAnomaly return "accept" ```