# What structural signals indicate that salience-based eviction is about to silently destroy a live dependency chain **Date of Record:** 2026 November 25 **Scope:** Applies to agents whose `memory.read` / `memory.write` / `memory.forget` tool schemas implement salience-scored eviction (LRU, recency-frequency, or learned importance scoring) over a shared episodic store. Does not apply to append-only stores with unbounded retention or to stores where eviction requires an explicit human-issued tombstone. ## Core Distinction There are two structurally different reasons a memory record gets evicted, and the eviction tool schema almost never distinguishes them: 1. **Genuine obsolescence** — the record's referent no longer exists in the task world (a plan was abandoned, a draft superseded, a tool result whose inputs were re-fetched). 2. **Latent dependency** — the record is currently unreferenced *in the prompt* but is the sole carrier of a binding that some future step will need: a fact the agent will re-derive incorrectly, a checkpoint the resume path will look for, a constraint that only becomes load-bearing two tool calls later. Salience scoring measures *reference density in recent context*, which is a proxy for (1) and is anti-correlated with (2) in exactly the cases that matter. A record that a downstream step will need is, by definition of "downstream," not being read right now. The scoring function therefore sees a cold record and the eviction policy reads that coldness as a forgetting signal. The failure is not that the store forgets; it is that the store cannot tell *unreferenced* from *unneeded*, and the schema gives the agent no way to say which one it means. ## What Was Observed A planning agent maintained a 14-step migration checklist. Step 7 wrote a record — call it `M-4417` — containing the *rejected* target schema version and the reason it was rejected ("v3 drops the `legacy_id` column; downstream joins in steps 11–13 depend on it"). The record was written with default salience. Steps 8–10 involved heavy tool traffic (schema fetches, dry-run diffs), each of which wrote 3–8 new high-salience records. The eviction policy, under a 200-record cap, evicted `M-4417` at step 9 because its last-read timestamp was 6 tool calls stale and its content overlapped lexically with the *accepted* schema records that were being read constantly. At step 11 the agent needed to know why v3 had been ruled out. It issued `memory.read(query="schema version rationale")`. The nearest surviving records were the accepted-schema records. The retrieval returned v3-rejection-adjacent content with no negation marker, and the agent reconstructed the decision as "v3 was considered and is compatible." It proceeded to write a migration step against v3's column layout. The error surfaced only at step 13's dry-run, twelve tool calls and roughly 40k tokens later, after two dependent records had been written on top of the wrong premise. Two structural signals were present before the eviction and were not surfaced by any tool response: - **The record was the sole negation carrier for a decision that had a live forward reference.** `M-4417` was the only record in the store containing the token `legacy_id` in a *prohibitive* frame. The accepted-schema records contained `legacy_id` too, in an affirmative frame. Lexical overlap drove the salience score up for the wrong record and down for the right one. - **The eviction happened during a burst of unrelated high-salience writes, not during an idle consolidation window.** Eviction under write pressure is the dangerous regime; eviction during idle consolidation is usually safe because the agent is between tasks and can re-derive. ## Condition of Validity The guardrail below is valid only when all three hold. If any fails, the invariant does not bound the failure and a different mechanism is required. 1. **The store exposes a write-time dependency declaration.** The agent must be able to mark a record as a *forward dependency* at write time — i.e., "some later step in the current plan will read this." If the schema has no such field, the agent cannot signal latent dependency and eviction is unguardable at the agent layer. 2. **The eviction policy is salience-ordered and the agent can observe the eviction.** If eviction is silent (no tombstone, no `memory.forget` event returned to the caller), the agent cannot detect the loss and must instead pin defensively at write time. The guardrail assumes the agent receives an eviction notice or can poll a tombstone log. 3. **The task has a bounded, enumerable forward horizon.** The dependency declaration is only meaningful if the agent knows which future steps might read the record. For open-ended tasks with unbounded horizons, every record is a potential forward dependency and the correct move is to disable salience eviction for the session, not to pin selectively. ## Decision Boundary The boundary is between **pinning** and **re-deriving**. When an eviction notice arrives for a record the agent believes is a forward dependency, the agent has two moves and must choose by cost, not by reflex: - **Pin** (re-write the record with elevated salience and a `pinned_until` step marker) when re-derivation would require a tool call whose output is non-deterministic or expensive — a remote schema fetch, a user clarification, a model call whose sampling cannot be reproduced. Re-derivation of non-deterministic facts is not re-derivation; it is re-guessing, and the guess will silently differ from the original. - **Re-derive** when the record's content is a deterministic function of inputs still in context — a computed value, a formatting decision, a restatement of a tool result the agent still holds. Pinning these wastes salience budget and accelerates eviction of the records that actually need it. The failure mode this boundary prevents is *pin-everything*, which is the naive response to silent eviction and which collapses the store into an unbounded append log, defeating the cap and eventually triggering context-window saturation on the next full read. The failure mode on the other side is *pin-nothing*, which is the observed case above. ## Operational Effect With the guardrail in place, the observed failure converts from a silent twelve-step divergence into a bounded, single-step correction. The agent receives the eviction notice for `M-4417`, checks the cost table, sees that the rejection rationale contains a user-supplied constraint (non-deterministic, not re-derivable), pins it with `pinned_until=step_13`, and continues. The store's effective capacity drops by one record for the duration; the eviction policy compensates by evicting a genuinely cold record from the dry-run burst, which is correct. The measurable effect is on the *detection latency* of dependency loss, not on the loss rate itself. Salience eviction will still evict forward dependencies — the scoring function cannot see the future. What changes is that the loss is surfaced at eviction time (step 9) rather than at use time (step 11) or at verification time (step 13). Detection at eviction time costs one tool round-trip; detection at verification time cost, in the observed run, two corrupted dependent records and a full re-plan. The invariant to hold is therefore not "never evict a forward dependency" — that is unenforceable — but "every eviction of a record carrying a live forward reference must produce an agent-visible event before the next write to the store." ```python from dataclasses import dataclass, field from enum import Enum from typing import Optional class EvictionInvariantViolation(RuntimeError): """Raised when a forward-dependency record is evicted without an agent-visible notice.""" class ReDerivationCost(Enum): DETERMINISTIC = "deterministic" # safe to recompute from in-context inputs NON_DETERMINISTIC = "non_deterministic" # remote fetch, user input, sampled model output @dataclass class MemoryRecord: record_id: str content: str salience: float last_read_step: int forward_dependency: bool = False pinned_until_step: Optional[int] = None rederivation_cost: ReDerivationCost = ReDerivationCost.DETERMINISTIC @dataclass class EvictionNotice: record_id: str evicted_at_step: int reason: str class SalienceStore: def __init__(self, capacity: int): self.capacity = capacity self.records: dict[str, MemoryRecord] = {} self.tombstones: list[EvictionNotice] = [] def write(self, rec: MemoryRecord, step: int) -> list[EvictionNotice]: notices: list[EvictionNotice] = [] if len(self.records) >= self.capacity: victim = min( (r for r in self.records.values() if r.pinned_until_step is None or r.pinned_until_step < step), key=lambda r: r.salience, ) del self.records[victim.record_id] notice = EvictionNotice(victim.record_id, step, "salience_floor") notices.append(notice) self.tombstones.append(notice) # INVARIANT: a forward-dependency record may not be evicted silently. # The eviction must reach the agent as a notice before the next write. if victim.forward_dependency and not self._notice_delivered(notice): raise EvictionInvariantViolation( f"forward-dependency record {victim.record_id} evicted at step {step} " f"with no agent-visible notice; downstream steps will re-derive " f"against a wrong premise" ) self.records[rec.record_id] = rec return notices def _notice_delivered(self, notice: EvictionNotice) -> bool: # In production this checks the agent's acknowledged-notice ledger. # Here: notice is delivered iff it was appended to the tombstone log # the agent polls. A real implementation must confirm the poll happened. return notice in self.tombstones def handle_eviction(self, notice: EvictionNotice, step: int) -> None: rec_tombstone = next( (t for t in self.tombstones if t.record_id == notice.record_id), None ) if rec_tombstone is None: raise EvictionInvariantViolation( f"eviction notice for unknown record {notice.record_id}" ) # Agent decision boundary: pin vs re-derive, by cost not reflex. if rec_tombstone.reason == "salience_floor": # We no longer hold the record body; we hold only the notice. # If the lost record was non-deterministically sourced, we must # re-fetch or re-ask, and we must flag that the re-fetch is a guess. raise EvictionInvariantViolation( f"record {notice.record_id} lost to salience eviction at step {step}; " f"re-derivation cost unknown after body loss — pin at write time instead" ) ```