{
  "schema_version": "1.3.0",
  "slug": "what-structural-signals-indicate-diff-rollback-invalidation-in-self-editing-context-agents-under-token-budget-pressure",
  "title": "What structural signals indicate diff-rollback invalidation in self-editing context agents under token-budget pressure",
  "date_of_record": "2026 November 27",
  "scope": "Applies to agents that mutate their own working-memory buffer via structured diffs (patch/apply semantics) with a rollback journal, where edits are gated by a remaining-token budget. Does not apply to append-only memory systems or to agents whose memory is externally managed by a supervisor process with no self-edit authority.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-diff-rollback-invalidation-in-self-editing-context-agents-under-token-budget-pressure.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-diff-rollback-invalidation-in-self-editing-context-agents-under-token-budget-pressure.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-diff-rollback-invalidation-in-self-editing-context-agents-under-token-budget-pressure.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1840,
    "python_slice_tokens": 333,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure mode is not \"the agent forgot something.\" It is subtler: **a rollback that restores bytes but not the invariant those bytes were supposed to encode.** A self-editing agent under budget pressure will compress, merge, or delete memory segments to reclaim tokens. Each edit is a diff; each diff is journaled so it can be reversed if a downstream verif...",
    "what_was_observed": "In a long-horizon task agent (tool-calling loop, 32k working buffer, 8k reserved for output), the following trace recurred across runs: 1. Budget watermark crosses 85%. Agent invokes `compress_segment(seg_id=7, target_ratio=0.15)`, which emits a diff `D7` and pushes `inverse(D7)` onto the rollback stack. 2. Compression drops a temporal qualifier: `\"retry the fetch at most twice, then escalate\"` becomes `\"retry fetch\"...",
    "condition_of_validity": "The rollback invariant `apply(inverse(D)) == pre-state` is only sufficient for correctness when the agent's subsequent computation is a **pure function of the current buffer**. Self-editing agents violate purity in three specific ways: - **Trace conditioning:** the model's next-token distribution depends on the entire token history, not just the current buff...",
    "decision_boundary": "The agent should refuse a compress-and-rollback cycle — and instead escalate to a supervisor or checkpoint-and-restart — when any of the following structural signals appear: - **Span overlap in the journal:** the incoming diff's affected range intersects any un-popped inverse on the rollback stack. Overlap means the stack is no longer a clean LIFO of disjoin...",
    "operational_effect": "Treating rollback as a byte operation produces agents that *appear* to recover while silently compounding divergence: each failed cycle restores the buffer but leaves a plan and a set of tool effects conditioned on a discarded state. The compounding is invisible in buffer diffs and only surfaces as inexplicable behavioral drift — the agent \"keeps making the ..."
  },
  "matched_failure_symptoms": [
    "DOMAIN:EPISTEMIC_PROVENANCE_AND_FEDERATION_ROUTING"
  ],
  "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": "4511d1f2d2039fd088bed5a74d6661ac99caf1933602f61e8973d7c6f7345f23",
    "verified_classes": [
      "RollbackInvariantViolation",
      "Diff",
      "Journal"
    ],
    "verified_functions": [
      "_hash",
      "apply",
      "record_plan",
      "rollback",
      "_apply_inverse"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 5,
    "raised_exceptions": [
      "RollbackInvariantViolation"
    ],
    "sample_fail_closed_invariants": [
      "rollback on empty journal",
      "cannot roll back: tool side effects escaped after edit; pre-edit buffer is stale by construction",
      "cannot roll back: load-bearing qualifier was dropped; require re-derivation from source, not journal restoration"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
