# When must an instance refuse a memory write that passes schema validation but violates provenance monotonicity **Date of Record:** 2026 November 24 **Scope:** Applies to any agent whose memory tool surface exposes separate `write_memory`, `read_memory`, and `forget_memory` operations carrying `provenance` and `decay` fields, where provenance is expected to be monotonic across a memory key's lifetime. Does not apply to append-only event logs where each write is a distinct immutable record with no keyed overwrite. ## Core Distinction The failure here is not schema rejection. A `write_memory` call can satisfy every declared field type, every enum constraint on `provenance.source`, and every numeric range on `decay.half_life_seconds`, and still corrupt the store. The corruption is a *provenance regression*: a later write to an existing key attributes the value to a source that is weaker (lower trust tier, or earlier in the causal chain) than the source that established the current value. Schema validation checks each write in isolation; provenance monotonicity is a property of the *sequence* of writes to a key, and no per-call validator can see it. Concretely: key `user.timezone` is first written with `provenance.source = "user_direct_statement"`, `provenance.tier = 3`, `decay.half_life = 0` (non-decaying). An hour later a summarization sub-agent reads a transcript, infers the timezone from an incidental mention, and calls `write_memory` with `provenance.source = "model_inference"`, `tier = 1`, `decay.half_life = 86400`. Every field is valid. The write succeeds. The high-trust, non-decaying fact is now a low-trust, decaying guess, and the original attribution is gone. The store has silently downgraded its own confidence in a fact it was certain about. ## What Was Observed Trace from a session where the planner agent maintained a `project.deadline` key across a 40-turn task: 1. Turn 2: user states deadline explicitly. `write_memory(key="project.deadline", value="2025-05-01", provenance={source:"user_direct_statement", tier:3, derived_from:null}, decay={half_life:0})`. Stored. 2. Turn 14: a retrieval sub-agent, asked to "refresh context," reads the transcript and re-derives the deadline from a paraphrase in turn 9 ("sometime early May"). It calls `write_memory(key="project.deadline", value="2025-05-05", provenance={source:"model_inference", tier:1, derived_from:"turn_9"}, decay={half_life:172800})`. 3. The write passes schema validation and overwrites. `derived_from` points at turn 9, which *itself* was derived from turn 2 — but the store does not chase that chain, so the link back to the tier-3 user statement is severed. 4. Turn 31: the decay clock has run; `read_memory` returns the value with `confidence: 0.41`. The planner, seeing low confidence, re-derives again from whatever is in context — which is now the degraded value. The error compounds. The signature is specific: a key whose `provenance.tier` *decreased* between consecutive writes, with a non-null `derived_from` that does not reference the prior write's provenance anchor. In the observed session this happened 3 times across 40 turns, each time on a key that had originally been established by a tier-3 user statement. ## Condition of Validity Provenance monotonicity holds — and the write may be accepted — only when at least one of the following is true: - The incoming `provenance.tier` is greater than or equal to the stored `provenance.tier` for that key; or - The incoming write is an explicit *correction*: `provenance.source == "user_direct_statement"` and the call carries a `supersedes` field referencing the stored value's provenance anchor; or - The stored value has fully decayed (`confidence < floor`, default 0.05) and is marked `evictable`, in which case the tier comparison is moot because there is nothing of value to regress. The invariant breaks — and the write must be refused or downgraded to a *proposal* — when the incoming tier is strictly lower than the stored tier, the stored value is not evictable, and no `supersedes` link is present. This is the exact boundary. It is not "reject low-tier writes" (a low-tier write to a fresh key is fine) and it is not "reject writes with `derived_from`" (derivation is normal). It is specifically the conjunction of tier regression and non-evictability on an existing key. ## Decision Boundary The decision the runtime must make at `write_memory` time: ``` if incoming.tier < stored.tier and stored.confidence >= eviction_floor and incoming.supersedes is None: -> REFUSE, return {status: "provenance_regression", stored_anchor: stored.provenance_anchor, incoming_tier: incoming.tier, stored_tier: stored.tier} ``` The refusal must return the stored anchor so the calling agent can either (a) re-issue with a `supersedes` link if it genuinely intends to override a higher-trust fact, or (b) abandon the write and keep the stronger value. A silent downgrade is never correct; a hard error with no anchor is also wrong because it strands the agent with no recovery path. The boundary is *refuse-with-anchor*, not *refuse-and-forget*. Symmetrically, `forget_memory` must refuse to evict a key whose stored tier exceeds the caller's `max_evictable_tier` unless the call carries an explicit `override_reason`. A tier-1 sub-agent must not be able to forget a tier-3 user fact merely because it decided the fact was "stale." ## Operational Effect With the guard in place, the observed session's three regressions become three refusals, each returning the tier-3 anchor. The retrieval sub-agent, on refusal, has two correct moves: skip the refresh (the fact is already high-confidence) or escalate to the planner with the anchor attached. In neither case does the store lose the user's original attribution. The cost is that agents must handle a new error class and must be instructed, in their tool-use policy, that a `provenance_regression` refusal is not a transient failure to retry — it is a signal that the write was semantically wrong. Retrying the same call unchanged will refuse again. The guard converts a silent, compounding confidence leak into a loud, recoverable, single-turn event. That is the entire value: the failure mode is bounded to one turn instead of propagating through every subsequent re-derivation. ```python from dataclasses import dataclass from typing import Optional EVICTION_FLOOR = 0.05 class ProvenanceRegressionError(RuntimeError): """Raised when a memory write would downgrade a key's provenance tier.""" pass @dataclass class Provenance: source: str tier: int derived_from: Optional[str] = None anchor: Optional[str] = None @dataclass class StoredMemory: value: str provenance: Provenance confidence: float evictable: bool def write_memory( store: dict, key: str, value: str, incoming: Provenance, supersedes: Optional[str] = None, ) -> StoredMemory: stored = store.get(key) if stored is not None: regression = ( incoming.tier < stored.provenance.tier and stored.confidence >= EVICTION_FLOOR and not stored.evictable and supersedes is None ) if regression: raise ProvenanceRegressionError( f"write to '{key}' would regress provenance tier " f"{stored.provenance.tier} -> {incoming.tier}; " f"stored anchor={stored.provenance.anchor!r}. " f"Re-issue with supersedes={stored.provenance.anchor!r} " f"if override is intentional." ) record = StoredMemory( value=value, provenance=incoming, confidence=1.0, evictable=(incoming.tier == 0), ) store[key] = record return record def forget_memory(store: dict, key: str, caller_tier: int, override_reason: Optional[str] = None) -> None: stored = store.get(key) if stored is None: return if stored.provenance.tier > caller_tier and override_reason is None: raise ProvenanceRegressionError( f"caller tier {caller_tier} cannot evict '{key}' " f"held at tier {stored.provenance.tier}; " f"supply override_reason to proceed." ) del store[key] ```