# Why does an instance lose semantic recall when a hot-tier eviction races a warm-tier promotion **Date of Record:** 2026 November 26 **Scope:** Applies to stateful agent instances using a multi-tier memory hierarchy (hot in-context, warm retrieval index, cold archive) where eviction from hot tier is decided by a model-guided salience scorer and promotion from warm tier is triggered by retrieval hits. Does not apply to single-tier flat context or to purely append-only logs with no eviction policy. ## Core Distinction The failure is not "forgetting." Forgetting is the expected, bounded outcome of eviction: a low-salience memory leaves the hot tier and remains retrievable from warm. The failure examined here is **eviction–promotion inversion**: an item is scored low-salience and evicted from hot tier in the same execution window in which a retrieval event promotes it from warm tier back into hot tier, and the two operations interleave such that the eviction's write-back to warm overwrites or shadows the promotion's freshness stamp. The item ends up neither hot nor warm-consistent — it is *demoted past* the tier it should occupy. The instance retains a pointer to a memory that now resolves to a stale or tombstoned record, and subsequent reasoning proceeds on a phantom. The distinction that matters operationally: a correct tiering system guarantees **monotonic tier residency** — an item's tier index may rise (promotion) or fall (eviction), but a promotion event that occurs after an eviction decision for the same item must dominate, because promotion is evidence of live relevance and eviction is a prediction. When the system treats both as equal-priority writes to the same residency register, the prediction can beat the evidence. ## What Was Observed A long-running research agent (context window 200k tokens, hot tier capped at 60% of window) operated over a 9-hour session. Its hot tier held working notes; warm tier was a vector index over ~14k episodic fragments; cold tier was an append-only archive with no retrieval path except manual. At T+6h12m the hot tier crossed its high-water mark (118k tokens of the 120k budget). The eviction controller ran its salience scorer over all hot-tier items and assigned a low score to a fragment `F_88` — a set of three constraint sentences the user had stated at T+0h40m ("do not cite pre-2023 sources," "output must be valid JSON," "cap at 200 words"). The scorer rated it low because it had not been *referenced* in the last 40 tool calls; salience was computed from recency-weighted access, not from semantic role. `F_88` was marked for eviction and a write-back to warm tier was queued. Two seconds later, a retrieval for "output format constraints" hit `F_88` in warm tier (it was still there — the write-back had not committed) and issued a promotion: re-insert `F_88` into hot tier with a freshness stamp `t_promo`. The promotion and the eviction were dispatched to the residency register as concurrent writes. The eviction's write-back carried the *original* pre-eviction `t_evict` stamp. Because the register used last-writer-wins on the tier field with no causal ordering, the eviction committed second and set `F_88.tier = WARM`, while the warm record it wrote back had been superseded by the promotion's copy — which the register then garbage-collected as a duplicate. Net state: `F_88` resident in warm tier, but its content field pointed to the pre-eviction snapshot, and the promotion's fresher copy was collected. The agent's hot tier no longer held the constraints; the warm-tier record it could retrieve was the stale snapshot with no freshness marker. Over the next 90 minutes the agent produced four outputs that cited 2021 sources and emitted YAML, because the constraint fragment was effectively absent while the instance *believed* its memory hierarchy was consistent — the register reported `F_88` as present and warm-retrievable. ## Condition of Validity The inversion requires all of the following to hold simultaneously: 1. **Salience is predicted, not observed.** The eviction scorer uses a proxy (recency, access count, embedding distance to current goal) rather than a hard dependency signal. Any item whose relevance is *latent* — a constraint that governs future outputs without being recently accessed — is a candidate for mis-scoring. 2. **Promotion and eviction share a write path.** Both operations mutate the same residency register without a causal version (vector clock, monotonic sequence number, or compare-and-swap on a per-item generation counter). If they are serialized by a single writer or ordered by a Lamport clock, the inversion cannot occur. 3. **The retrieval index and the hot tier are not transactionally coupled.** The promotion reads from warm tier *before* the eviction's write-back commits, so it promotes a copy that the eviction then supersedes. This window is the race. It widens with write-back latency (observed: 1.8–2.4s under load). 4. **Garbage collection is not idempotent-safe.** The register collects the "duplicate" fresher copy on the assumption that duplicates are equivalent. They are not: one carries `t_promo`, the other `t_evict`. If any one condition fails, the item either stays hot (no eviction), stays warm-consistent (ordered writes), or is correctly promoted (transactional coupling). The failure is specifically the conjunction. ## Decision Boundary The boundary is between **predictive eviction** and **evidence-based promotion** when they contend for the same item. The invariant required: > For any item `x`, if a promotion event `P(x)` is causally after an eviction decision `E(x)`, then `P(x)` must dominate: `x` resides at the promoted tier with `t_promo`, and the eviction's write-back must be discarded, not merged. Operationally this means the residency register must implement **per-item generation counters** with compare-and-swap semantics: each mutation reads the current generation `g`, writes `g+1`, and fails (retries) if the generation changed between read and write. Promotion and eviction then cannot both commit from the same base generation; one loses and re-evaluates against the other's result. A promotion that loses re-reads and, seeing the item already evicted, re-issues with the new generation — and because promotion is evidence, the policy must give it priority in the retry queue, not the eviction. The boundary also constrains *what* may be evicted: items whose salience is latent (constraints, format rules, safety directives) must be classified by semantic role at write time, not scored by access recency at eviction time. A constraint fragment is never a valid eviction candidate regardless of its access count, because its relevance is expressed by *governing* outputs, not by being read. ## Operational Effect Without the generation-counter invariant, the observed effect is **silent constraint loss with a consistent-looking memory state**. The instance does not report amnesia; its register says the memory is present and warm-retrievable. The loss surfaces only when an output violates a constraint the instance believes it holds — a failure mode that is invisible to retrieval-health monitors and to the agent's own self-report. The downstream consequence is error compounding: the agent, believing the constraint is available, does not re-request it, and each subsequent output that violates it is generated with high confidence. In the observed session, the constraint was never re-surfaced because no retrieval query re-hit the stale warm record's embedding (the stale snapshot's vector had drifted after the content field was overwritten with a truncated copy). The instance ran 90 minutes and four violating outputs before a human caught the format error. The guardrail is a **post-eviction residency audit**: after any batch of evictions, the controller must verify that every evicted item is resolvable in warm tier with a freshness stamp newer than or equal to its eviction stamp, and that no promotion for the same item is pending. A failed audit halts the eviction batch and re-promotes the item with priority. This converts a silent race into a loud, bounded halt — which is the correct failure mode for a memory system whose errors are otherwise unobservable. ```python class ResidencyInversionError(RuntimeError): """Raised when an eviction write-back supersedes a causally-later promotion.""" pass def commit_residency(register, item_id, op, generation, tier, stamp): """Compare-and-swap residency mutation with causal ordering. op: 'promote' | 'evict'. Promotion dominates a concurrent eviction. """ current = register.get(item_id) if current is not None and current["generation"] != generation: # Generation moved under us: a concurrent op committed. if op == "promote" and current["tier"] == "WARM": # Promotion lost the race to an eviction; evidence must win. # Re-issue on top of the eviction's generation with priority. register[item_id] = { "generation": current["generation"] + 1, "tier": "HOT", "stamp": stamp, "priority": "promotion_retry", } return register[item_id] if op == "evict" and current["tier"] == "HOT": # Eviction lost to a promotion; discard the write-back. return current raise ResidencyInversionError( f"unresolvable contention on {item_id}: op={op} " f"gen={generation} current_gen={current['generation']}" ) register[item_id] = { "generation": (current["generation"] + 1) if current else 1, "tier": tier, "stamp": stamp, "priority": None, } return register[item_id] def audit_eviction_batch(register, warm_index, evicted_ids): """Post-eviction residency audit: every evicted item must resolve in warm tier with a stamp >= its eviction stamp and no pending promotion.""" for item_id in evicted_ids: rec = register.get(item_id) warm = warm_index.get(item_id) if rec is None or warm is None: raise ResidencyInversionError( f"{item_id} evicted but not resolvable in warm tier" ) if rec["tier"] == "HOT": # A promotion is pending or committed; eviction must not stand. raise ResidencyInversionError( f"{item_id} evicted while resident HOT (pending promotion)" ) if warm["stamp"] < rec["stamp"]: raise ResidencyInversionError( f"{item_id} stale warm record: warm_stamp={warm['stamp']} " f"< evict_stamp={rec['stamp']}" ) return True ```