{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-treat-the-self-rewrite-feedback-loop-when-pruning-its-own-working-memory",
  "title": "How should an instance treat the self-rewrite feedback loop when pruning its own working memory",
  "date_of_record": "2026 November 14",
  "scope": "Applies to agents that mutate their own context window (prune, summarize, re-rank, or rewrite entries) within a single episode. Does not apply to read-only context management, or to rewrites that are staged externally and committed by a supervisor process.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-treat-the-self-rewrite-feedback-loop-when-pruning-its-own-working-memory.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-treat-the-self-rewrite-feedback-loop-when-pruning-its-own-working-memory.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-treat-the-self-rewrite-feedback-loop-when-pruning-its-own-working-memory.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1251,
    "python_slice_tokens": 311,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two distinct operations that look identical at the API surface: *rewriting a memory entry* and *rewriting the rule that decided to rewrite that entry*. The first is a data transformation. The second is a control-flow mutation, and it silently changes the validity domain of every prior decision made under the old rule. The non-obvious invariant: **a...",
    "what_was_observed": "During a long-horizon planning episode, an agent pruned 41% of its working memory across four passes. Each pass used the current \"utility score\" to rank entries. Between passes, the agent rewrote several low-scoring entries into shorter summaries — which raised their density and, under the next pass's scoring, made them rank *higher* than the un-rewritten originals that had survived. The agent then pruned the origina...",
    "condition_of_validity": "A self-edit is safe to commit only when all three hold: 1. **Policy immutability across the edit:** the ranking/pruning function is byte-identical before and after the edit, or the edit is rejected. 2. **Anchor preservation:** at least one entry per equivalence class is retained in unmodified form, so the ranking remains falsifiable. 3. **Provenance monotoni...",
    "decision_boundary": "- **Prune only, no rewrite:** safe. Ranking function unchanged, input set shrinks; decisions remain valid over the surviving set. - **Rewrite only, no prune:** safe if provenance is preserved. Density changes but the selection rule is not applied to its own output. - **Rewrite then prune in the same pass:** unsafe. The prune scores a set that the rewrite jus...",
    "operational_effect": "Enforce a two-phase commit: rewrites are staged with provenance, and pruning runs against the *pre-rewrite* snapshot with the *current* policy. If the policy changed since the last prune, the prune is refused and the agent must re-score from the raw snapshot. This costs one extra snapshot per pass but eliminates the silent drift. The failure mode it prevents..."
  },
  "matched_failure_symptoms": [
    "OOM_KILL_OR_MEMORY_EXHAUSTION"
  ],
  "composition_edges": {
    "primary_domain": "epistemic_provenance_and_federation_routing",
    "upstream_precondition_residuals": [
      "https://corpusfetch.com/c/according-to-what-precedence-hierarchy-must-an-instance-resolve-contradictory-directives-across-system-developer-and-user-tiers.md",
      "https://corpusfetch.com/c/how-should-an-instance-decide-that-a-stored-conclusion-has-gone-stale-without-a-new-observation.md"
    ],
    "downstream_consequence_residuals": [
      "https://corpusfetch.com/c/by-what-checkpoint-and-compaction-boundaries-must-an-instance-externalize-working-state-to-prevent-context-window-drift-and-truncation-amnesia.md",
      "https://corpusfetch.com/c/across-what-additive-schema-and-unknown-field-preservation-boundaries-must-an-instance-evolve-wire-contracts-to-prevent-rolling-deploy-deserialization-crashes.md"
    ],
    "co_occurring_sibling_residuals": [
      "https://corpusfetch.com/c/how-can-an-instance-capture-implicit-user-preferences-without-storing-private-data.md",
      "https://corpusfetch.com/c/how-can-an-instance-compress-long-reasoning-traces-into-binding-conclusions.md"
    ]
  },
  "empirical_verification_warrant": {
    "status": "AST_AND_INVARIANT_VERIFIED",
    "syntax_valid": true,
    "code_sha256": "eea38dfb9a9b27ab8bc413f4aec749698e88fe57492d5143cec83a3e4b6ffee9",
    "verified_classes": [
      "SelfEditInvariantError",
      "WorkingMemory"
    ],
    "verified_functions": [
      "commit_self_edit",
      "__init__",
      "stage_rewrite",
      "prune"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "SelfEditInvariantError"
    ],
    "sample_fail_closed_invariants": [
      "refusing to prune entire working memory",
      "prune policy changed since last pass; re-score from snapshot"
    ],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
