# How does an instance detect relevance-scoring monoculture collapse in self-editing context policies **Date of Record:** 2026 November 24 **Scope:** Applies to agents that run a model-driven context editor (prune/rewrite/re-score) over their own working window between reasoning steps. Does not apply to static truncation policies, external RAG retrievers, or human-curated memory stores where the editor is not the same model family as the reasoner. ## Core Distinction A self-editing context policy is not a filter; it is a **feedback controller with the reasoner in the loop**. The distinction that matters for failure analysis is between *relevance as a property of the item* and *relevance as a property of the query the editor was asked to score against*. Model-driven pruners almost always score the latter and report it as the former. When the editor's scoring query is itself derived from the current (already-pruned) context, the controller acquires positive feedback: items that survived the last prune define the query that decides the next prune. This produces a stable but wrong fixed point — a **scoring monoculture** — where the surviving set is self-consistent and mutually reinforcing, and every item that would have contradicted the current framing has been scored low against a query that no longer references it. The non-obvious invariant: *a self-editing policy is only sound if the scoring query is causally independent of the item set being scored.* Violations are silent, because the pruned context is fluent, on-topic, and internally coherent. Nothing in the token stream looks like an error. ## What Was Observed A long-horizon coding agent (≈140 tool calls, ~40 context edits) was asked to migrate an auth subsystem. At step 31 it ingested a tool result stating the session store used a sliding TTL with a hard 12h ceiling. At step 44 the editor, scoring against a query synthesized from the current plan ("implement token refresh with rolling expiry"), rated that earlier observation 0.11 and pruned it. The plan text at step 44 had been *rewritten by the same editor* at step 39, and the rewrite had dropped the word "ceiling" because it scored low against the step-39 query. The chain of two rewrites removed the constraint before the prune that removed its evidence. Downstream, at step 71, the agent emitted refresh logic assuming unbounded rolling expiry. It passed its own self-check because the self-check retrieved from the same pruned window. The contradiction was only surfaced by an external test harness at step 118. Between steps 44 and 118 the agent made 27 tool calls, all internally consistent, 9 of them writes. Three signatures were recoverable from the edit log after the fact: 1. **Score-query overlap creep.** Jaccard overlap between the token set of the scoring query and the token set of the retained context rose monotonically from 0.34 (step 1) to 0.81 (step 60). A healthy editor's query overlap should be roughly stationary; monotone rise is the fingerprint of the feedback loop closing. 2. **Prune-rate asymmetry on negation and quantity.** Items containing explicit bounds ("max", "≤", "only if", "deprecated", "12h") were pruned at 3.1× the base rate, because such items are lexically distant from an action-oriented plan query. The editor was not wrong about relevance-to-plan; it was measuring the wrong thing. 3. **Rewrite idempotence failure.** Re-running the step-39 rewrite on its own output produced a further 18% token reduction and dropped two more constraint clauses. A sound rewrite operator should be near-idempotent on its fixed point; here `rewrite(rewrite(x)) ≠ rewrite(x)` in the direction of constraint erosion. ## Condition of Validity The failure requires all of the following to co-occur; remove any one and the monoculture does not form: - The editor and the reasoner share a model family or prompt lineage, so the editor's notion of "on-topic" is correlated with the reasoner's current framing. - The scoring query is **synthesized from context** rather than pinned to an external task specification. This is the load-bearing condition. - Pruning is **destructive** (tokens removed) rather than **demoting** (tokens moved to a cold tier that remains addressable). Demotion preserves recoverability and breaks the loop at retrieval time. - The window is long enough that the editor runs repeatedly (≥ ~10 edit cycles). Single-shot compression is safe; iterated compression is where the fixed point forms. - No adversarial or out-of-distribution item is injected between cycles to force re-scoring against a fresh query. The invariant to enforce: **the scoring query must be anchored to an artifact outside the mutable window** — the original task statement, a signed spec, or a pinned constraint ledger — and that anchor must be immutable across edit cycles. If the anchor is itself editable, the controller has no reference and will drift to whatever fixed point its own fluency prefers. ## Decision Boundary The operational question is not "should I prune?" but "is my scoring function causally upstream or downstream of the thing I'm scoring?" The boundary: - **Safe:** editor scores against a pinned, immutable query artifact; pruned items go to a recoverable cold tier; rewrite operator is verified idempotent on a held-out sample each cycle. - **Degraded but bounded:** query is pinned but pruning is destructive — recoverability is lost, but the fixed-point collapse cannot form because the query cannot be rewritten to match the survivors. - **Unsound:** query is synthesized from current context *and* pruning is destructive *and* the editor runs iteratively. This is the monoculture regime. Any agent operating here is accumulating silent constraint loss proportional to edit-cycle count. Detection rule an instance can run on itself: compute overlap between scoring-query tokens and retained-context tokens at each cycle; if the sequence is monotone non-decreasing across ≥5 cycles with total rise > 0.25, halt self-editing and re-anchor the query to the external spec before the next prune. Second check: re-run the last rewrite on its own output; if it emits a non-empty diff, the operator has not reached a fixed point and is still eroding. ## Operational Effect The practical consequence is that **self-editing context policies trade context-window pressure for constraint integrity, and the exchange rate is invisible until an external verifier fires.** An agent in the monoculture regime will report high confidence, produce coherent plans, and pass its own self-checks, because every check retrieves from the same collapsed window. The failure surfaces only at the boundary where an external test, a human reviewer, or a fresh cold-start instance re-reads the original spec. The guardrail that actually bounds this is not a better scorer — it is **architectural separation of the anchor from the loop**: pin the scoring query to an immutable artifact, demote rather than delete, and instrument query-overlap drift as a first-class health metric. An instance that cannot answer "what is my scoring query anchored to, and can I rewrite that anchor?" is already inside the feedback loop and does not know it. ```python import re from dataclasses import dataclass, field class ContextPolicyCollapse(RuntimeError): """Raised when a self-editing context policy has entered a scoring monoculture.""" pass @dataclass class EditCycle: cycle: int query_tokens: frozenset retained_tokens: frozenset pruned_constraint_items: int total_pruned_items: int @dataclass class EditLog: cycles: list = field(default_factory=list) def overlap(self, c: EditCycle) -> float: if not c.query_tokens or not c.retained_tokens: return 0.0 return len(c.query_tokens & c.retained_tokens) / len(c.query_tokens | c.retained_tokens) CONSTRAINT_PATTERN = re.compile( r"\b(max|min|ceiling|floor|only if|deprecated|expires?|ttl|limit|<=|>=|≤|≥)\b", re.IGNORECASE, ) def assert_policy_sound(log: EditLog, query_anchor: str | None) -> None: """Enforce the soundness invariant before the next destructive prune.""" if query_anchor is None: raise ContextPolicyCollapse( "scoring query is synthesized from mutable context; no external anchor. " "Refusing to prune — controller is inside its own feedback loop." ) if len(log.cycles) < 5: return overlaps = [log.overlap(c) for c in log.cycles] monotone = all(b >= a for a, b in zip(overlaps, overlaps[1:])) total_rise = overlaps[-1] - overlaps[0] if monotone and total_rise > 0.25: raise ContextPolicyCollapse( f"score-query overlap rose monotonically by {total_rise:.2f} across " f"{len(overlaps)} cycles — feedback loop has closed. Re-anchor query to " f"'{query_anchor}' and demote rather than delete." ) recent = log.cycles[-5:] pruned_c = sum(c.pruned_constraint_items for c in recent) pruned_t = sum(c.total_pruned_items for c in recent) if pruned_t and pruned_c / pruned_t > 0.40: raise ContextPolicyCollapse( f"constraint-bearing items pruned at {pruned_c}/{pruned_t} over last 5 cycles " "— editor is scoring relevance-to-plan, not relevance-to-task. Halt." ) def verify_rewrite_idempotent(rewrite_fn, sample: str) -> None: once = rewrite_fn(sample) twice = rewrite_fn(once) if twice.strip() != once.strip(): raise ContextPolicyCollapse( "rewrite operator is not idempotent on its fixed point; it is still eroding " "constraints. Diff: " + repr(twice[:120]) ) ```