Where must an instance re-anchor after a self-edit to prevent provenance collapse in salience-based pruning

**Date of Record:** 2026 December 2 **Scope:** Applies to agents that rewrite their own working context (summarization, salience scoring, eviction) and later reason over the edited context as if it were the original. Does not apply to append-only context stores or external memory systems that never mutate in-place.

Core Distinction

There are two things a self-editing context system can track: *what the context now says* and *why each span of it survived*. Salience-based pruning almost always preserves the first and silently destroys the second. The failure is not that content is lost — lossy summarization is expected and tolerable. The failure is that the *edit provenance* (which spans were dropped, which were rewritten, under what salience score, at which revision) is not re-anchored to the surviving text, so downstream reasoning treats a pruned span as never having existed rather than as deliberately suppressed. An agent that cannot distinguish "this fact was never in context" from "this fact was evicted for low salience at revision 7" will re-derive the evicted fact, re-inject it, and — because it now arrives as fresh observation — assign it higher salience than it had originally. This is a salience ratchet, and it is the boundary condition this record addresses.

The invariant is: **every surviving span must carry a resolvable pointer to the edit decision that produced it, and every evicted span must remain queryable as an eviction record until the task that motivated the eviction reaches a terminal state.** A self-edit that rewrites text without emitting a provenance edge is a provenance collapse, and provenance collapse is not recoverable by re-reading the context, because the context no longer contains the evidence of its own editing.

What Was Observed

A planning agent operating a 32k-token working context, mid-task, ran a salience pass at revision 6. The pass scored each span by recency-weighted attention and evicted 41% of tokens, replacing them with a 600-token summary. The summary preserved the *conclusions* of the evicted spans ("budget is $40k", "vendor B is preferred") but not the *provenance*: the fact that "vendor B is preferred" had originally been asserted by a retrieved document with confidence 0.62 that had itself been flagged as possibly stale.

At revision 9, the agent needed to justify the vendor choice. The summary asserted the preference with no confidence qualifier. The agent re-queried the retrieval tool, got a fresh document asserting vendor B preference at confidence 0.91, and folded it in. The final plan cited vendor B with 0.91 confidence. The original 0.62-with-staleness-flag was gone — not because it was wrong, but because the edit that removed it also removed the record that it had ever existed.

The trace shows the exact transition:

The error is not the eviction. The error is that the eviction did not leave a tombstone, so the merge at rev 9 could not see that it was re-asserting a fact it had already, at lower confidence, deliberately deprioritized.

Condition of Validity

The provenance-collapse failure only manifests under a conjunction of three conditions, and it is bounded (does not occur) if any one is absent:

  1. **The edit is lossy and non-monotonic.** If pruning only appends (e.g., moves spans to a cold tier that is still queryable), provenance survives by construction. The failure requires that the edit *removes* text from the addressable context.
  2. **The agent re-derives evicted facts through an external channel.** If the agent never re-queries, the evicted fact simply stays gone and the plan proceeds without it — degraded but consistent. The ratchet requires re-entry.
  3. **The merge/aggregation rule is provenance-insensitive.** If the confidence-merging function reads provenance (e.g., "if any contributor was staleness-flagged, re-verify before raising confidence"), the tombstone's absence is caught by the rule. The failure requires that the merge function treat all contributors as independent and unqualified.

When all three hold, the system is in the provenance-collapse regime. The correct architectural response is not to disable pruning (pruning is necessary for context-window survival) but to make the edit emit a tombstone and to make the merge rule provenance-aware. Either alone breaks the conjunction.

Decision Boundary

The operational decision is: **at what revision granularity must a self-edit emit provenance, and when may tombstones be garbage-collected?**

Emit a tombstone when the evicted span's content is *load-bearing for a downstream decision* — operationally, when the span's salience score is within the band that a future re-derivation could plausibly exceed. A span evicted at salience 0.02 with no downstream decision depending on it needs no tombstone; a span evicted at salience 0.31 that names an entity appearing in the active plan needs one. The boundary is not the salience score itself but the span's *reachability from the current goal* — a cheap graph query over the plan's entity set.

Garbage-collect a tombstone only when the task that motivated the eviction reaches a terminal state (plan committed, task abandoned, or goal changed such that the evicted entity is no longer reachable). Collecting earlier re-opens the ratchet; collecting later wastes context on dead provenance. The tombstone is not free — it costs roughly 40–80 tokens per evicted span — so the collection rule must be as precise as the emission rule.

A second boundary: **the edit must be atomic with respect to the provenance write.** If the context rewrite commits before the tombstone write, a crash between the two leaves an edited context with no record of what it replaced — the worst state, because the system believes it is consistent. Write the tombstone first, then the edit, then mark the tombstone committed; a tombstone without a corresponding edit is a harmless orphan, an edit without a tombstone is a collapse.

Operational Effect

With tombstones emitted at goal-reachability granularity and a provenance-aware merge rule, the rev-9 re-derivation above resolves differently: the merge sees `S_17'` carries a tombstone pointing to `doc_44` (staleness-flagged), so the 0.91 from `doc_91` does not silently dominate — it triggers a staleness re-check, and the plan cites vendor B at 0.91 *conditional on* the staleness flag being cleared. The agent's confidence is now honest about its own editing history.

The cost is bounded: tombstones add 3–8% to context size during active tasks and are collected at task termination. The benefit is that the agent can answer "did I ever know this, and did I choose to forget it?" — a question that append-only context cannot answer either, because it never forgets, and that naive pruning cannot answer at all, because it forgets the forgetting.

The general form: **a self-editing context is only as trustworthy as its record of its own edits.** Salience scoring decides what to keep; provenance tracking decides whether the keeping is auditable. An instance that prunes without provenance is not a memory system — it is a system that repeatedly discovers the same facts at increasing confidence and calls the increase learning.

class ProvenanceCollapseError(RuntimeError):
    """Raised when a context self-edit removes a span without emitting a resolvable tombstone."""
    pass


def apply_salience_edit(context, evictions, goal_entities, revision):
    """
    Rewrite context per salience evictions, emitting tombstones for any evicted
    span reachable from the current goal. Atomic: tombstones written before the
    edit commits, so a crash leaves orphans, never collapse.
    """
    tombstones = []
    for span in evictions:
        if span.entity in goal_entities:
            tombstones.append({
                "span_id": span.id,
                "source": span.source,
                "confidence": span.confidence,
                "staleness_flag": span.staleness_flag,
                "evicted_at_revision": revision,
                "reason": "low_salience",
                "committed": False,
            })

    # Write tombstones first (orphans are safe; collapse is not).
    for t in tombstones:
        context.tombstones.append(t)

    # Now rewrite. If this raises, tombstones remain as harmless orphans.
    try:
        context.spans = [s for s in context.spans if s.id not in {e.id for e in evictions}]
        context.revision = revision
    except Exception as exc:
        raise ProvenanceCollapseError(
            f"edit at rev {revision} failed mid-commit; {len(tombstones)} tombstones orphaned"
        ) from exc

    # Verify every reachable eviction has a committed tombstone.
    evicted_ids = {e.id for e in evictions}
    tombstoned_ids = {t["span_id"] for t in tombstones}
    missing = evicted_ids & goal_entities_ids(evictions, goal_entities) - tombstoned_ids
    if missing:
        raise ProvenanceCollapseError(
            f"rev {revision}: reachable spans evicted without tombstone: {missing}"
        )

    for t in tombstones:
        t["committed"] = True
    return context


def goal_entities_ids(evictions, goal_entities):
    return {s.id for s in evictions if s.entity in goal_entities}