{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-silent-divergence-when-an-agent-rewrites-its-own-context-window-via-a-reversible-edit-journal",
  "title": "Which invariants prevent silent divergence when an agent rewrites its own context window via a reversible edit journal",
  "date_of_record": "2026 November 20",
  "scope": "Applies to agents that mutate their own working context through a journaled, reversible edit protocol (patch → apply → optionally rollback) while continuing to reason over the mutated state. Does not apply to append-only context growth, external retrieval augmentation, or edits performed by a separate orchestrator that never reasons over its own output.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-silent-divergence-when-an-agent-rewrites-its-own-context-window-via-a-reversible-edit-journal.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-silent-divergence-when-an-agent-rewrites-its-own-context-window-via-a-reversible-edit-journal.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-silent-divergence-when-an-agent-rewrites-its-own-context-window-via-a-reversible-edit-journal.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1699,
    "python_slice_tokens": 314,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters is between *reversibility of the edit* and *reversibility of the reasoning*. An edit journal makes the *bytes* of the context window reversible: given edit `E_k` with pre-image hash `h_{k-1}`, the agent can reconstruct the prior window exactly. It does **not** make the agent's *internal reasoning state* reversible. Once the model...",
    "what_was_observed": "An agent editing a long planning context used a journal with entries of the form `{op, span, before, after, hash_before, hash_after}`. It performed a speculative edit: it rewrote a task-dependency section to test an alternate ordering, reasoned three turns over the mutated window, concluded \"task C is now unblocked,\" and then — because a downstream tool call contradicted the conclusion — issued a rollback of the spec...",
    "condition_of_validity": "The invariant holds — rollback is safe — only under the following conjunction: - **C1 (Trace tagging):** every emitted reasoning span carries the window hash it was conditioned on. A span is *valid* iff its tag equals the current window hash. - **C2 (Invalidation on rollback):** a rollback to `h_j` marks every span tagged with any hash `h_k`, `k > j`, as *st...",
    "decision_boundary": "The boundary is between **speculative edits with committed reasoning** and **speculative edits with quarantined reasoning**. - If the agent reasons over a mutated window *and* that reasoning may influence committed actions, the edit is not speculative in the safety-relevant sense regardless of whether the journal can reverse it. It must be treated as committ...",
    "operational_effect": "With C1–C4 enforced, the failure trace above becomes impossible: the rollback to `h_0` tags `t_1..t_3` stale, the next turn is conditioned only on `W_0` and non-stale spans, and `P` is absent — so the model re-derives the dependency state from the restored window and correctly sees C still blocked. The cost is that speculative reasoning is discarded on rollb..."
  },
  "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": "17a6f3e0c1191ea25bd08005cb7d1c08405fb20400b271140fe427615b1b3772",
    "verified_classes": [
      "ContextDivergenceError",
      "Span",
      "Journal"
    ],
    "verified_functions": [
      "safe_rollback",
      "_h",
      "apply",
      "record_reasoning",
      "rollback_to",
      "live_context"
    ],
    "verified_functions_count": 6,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "ContextDivergenceError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
