{
  "schema_version": "1.3.0",
  "slug": "in-what-scenarios-must-an-instance-treat-a-self-editing-context-policy-s-rollback-as-non-atomic-and-verify-budget-ledger-consistency-before-resuming",
  "title": "In what scenarios must an instance treat a self-editing context policy's rollback as non-atomic and verify budget-ledger consistency before resuming",
  "date_of_record": "2026 November 30",
  "scope": "Applies to any agent that mutates its own context window via a bounded rewrite policy (summarize/evict/merge operations gated by a rewrite budget) and relies on rollback to a prior checkpoint after a failed or rejected rewrite. Does not apply to append-only context logs or to external memory stores where the agent has no in-band write authority.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-a-self-editing-context-policy-s-rollback-as-non-atomic-and-verify-budget-ledger-consistency-before-resuming.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-a-self-editing-context-policy-s-rollback-as-non-atomic-and-verify-budget-ledger-consistency-before-resuming.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-a-self-editing-context-policy-s-rollback-as-non-atomic-and-verify-budget-ledger-consistency-before-resuming.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2288,
    "python_slice_tokens": 498,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The dangerous assumption is that a \"rollback\" of a self-editing context policy restores the *entire* pre-rewrite state: tokens, budget counter, and derived indices, all together. In practice the rewrite budget is a *separate mutation domain* from the context bytes. A rewrite consumes budget at commit time, but the context bytes are only replaced at swap time...",
    "what_was_observed": "A long-horizon research agent ran with a context policy configured as: `max_rewrites=16`, `checkpoint_interval=1` (checkpoint before every rewrite), and a post-rewrite critic that scored the summarized block for information retention. The critic rejected 3 of the first 11 rewrites—normal, expected behavior for a retention threshold set at 0.85. The failure trace: 1. Rewrite #7 fires. Budget ledger decremented 16→15 *...",
    "condition_of_validity": "The invariant that must hold for the policy to be safe is: > `budget_consumed == committed_rewrites + in_flight_rewrites` where `in_flight_rewrites` is at most 1 (the policy is single-threaded per context). Any observed state where `budget_consumed > committed_rewrites + in_flight_rewrites` indicates a leaked budget unit from a rolled-back rewrite. Any state...",
    "decision_boundary": "The agent must choose between two recovery strategies at resume, and the choice is not obvious: - **Trust the ledger.** Resume with the ledger's current value. Fast, but if the ledger was debited for a rolled-back rewrite, the agent will under-count its remaining budget and may refuse a rewrite it could have afforded—or, worse, hit the ceiling early and fall...",
    "operational_effect": "With the invariant enforced, the policy behaves as follows at every rollback: - The debit is *reconciled*, not merely recorded: on rollback, the policy decrements `committed_rewrites` is unaffected (no commit happened) and it *re-increments* the ledger only if a `prepare` marker is absent. If a `prepare` marker exists, the unit stays spent. - The ledger and ..."
  },
  "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": "ce456fccc95e76e31438c72eab6dfb107485e24e3c128de94b32b625367d720e",
    "verified_classes": [
      "BudgetLedgerDivergence",
      "Marker",
      "RewriteEntry",
      "ContextPolicyState"
    ],
    "verified_functions": [
      "reconstruct_committed_spend",
      "reconcile_after_rollback",
      "attempt_rewrite",
      "commit_rewrite"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "BudgetLedgerDivergence"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "enum",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
