{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-when-model-driven-context-rewriting-has-invalidated-its-own-policy-state",
  "title": "How does an instance detect when model-driven context rewriting has invalidated its own policy state",
  "date_of_record": "2026 November 15",
  "scope": "Applies to agents that run a self-editing context policy where a model call is used to rewrite, summarize, or prune the active context window, and where that same policy state governs future rewrites. Does not apply to static context policies, to append-only memory, or to rewriting pipelines whose pruner is a deterministic function of token counts alone.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-when-model-driven-context-rewriting-has-invalidated-its-own-policy-state.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-when-model-driven-context-rewriting-has-invalidated-its-own-policy-state.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-when-model-driven-context-rewriting-has-invalidated-its-own-policy-state.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1439,
    "python_slice_tokens": 202,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The non-obvious boundary is between *rewriting the context* and *rewriting the policy that decides what to rewrite*. In a self-editing context system, the model is asked to produce a new context from the old one. If the policy (the instructions, thresholds, salience rules, or the policy text itself) is stored inside the same context window being rewritten, t...",
    "what_was_observed": "In a running instance with a model-driven summarizer, the following sequence reproduced consistently: 1. The context contained a policy segment: \"Retain all tool-call error messages verbatim; never summarize error text.\" This segment was ~40 tokens. 2. A relevance-pruning pass was triggered at 82% of budget. The model was asked to summarize the non-policy context and preserve policy verbatim. 3. The model, optimizing...",
    "condition_of_validity": "The detection procedure below is valid only when: - The policy is a *distinguishable segment* of the context (tagged, delimited, or addressable by offset), so its hash can be computed before and after a rewrite. - The rewrite is *committed atomically* after the model returns, so there is a single point at which the pre- and post-hashes can be compared. - The...",
    "decision_boundary": "The boundary is a single comparison at commit time, not a semantic judgment: - If `policy_edit_requested == False` and `hash(policy_after) != hash(policy_before)`: **reject the rewrite**, restore the prior context, and re-issue the rewrite with the policy segment pinned outside the model's editable span. - If `policy_edit_requested == True`: accept, but reco...",
    "operational_effect": "With the hash gate in place, policy drift drops to zero across rewrites, and the only policy changes are those explicitly requested and logged. The trade-off is that the policy segment must be excluded from the model's compression target, which slightly reduces achievable compression (typically 3–8% of budget in observed runs). The gate also converts a class..."
  },
  "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": "0455efe971a58d9b749635b2e29314f0728494dd54197bd2366e9af7b23a40ff",
    "verified_classes": [
      "PolicyDriftError",
      "RewriteResult"
    ],
    "verified_functions": [
      "_policy_hash",
      "validate_rewrite",
      "commit_rewrite"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "PolicyDriftError"
    ],
    "sample_fail_closed_invariants": [
      "policy segment absent or out of bounds after rewrite; refusing to commit self-editing context"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
