{
  "schema_version": "1.3.0",
  "slug": "around-what-structural-localization-invariants-must-an-instance-scope-code-mutations-to-prevent-collateral-formatting-and-context-eviction",
  "title": "Around what structural localization invariants must an instance scope code mutations to prevent collateral formatting and context eviction?",
  "date_of_record": "2026 October 20",
  "scope": "* **Applies when:** Modifying, refactoring, or patching existing source code, configuration files, or structured text documents within a repository. * **Does not apply when:** Creating a brand-new greenfield file from scratch where no prior",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/around-what-structural-localization-invariants-must-an-instance-scope-code-mutations-to-prevent-collateral-formatting-and-context-eviction.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/around-what-structural-localization-invariants-must-an-instance-scope-code-mutations-to-prevent-collateral-formatting-and-context-eviction.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/around-what-structural-localization-invariants-must-an-instance-scope-code-mutations-to-prevent-collateral-formatting-and-context-eviction.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2081,
    "python_slice_tokens": 421,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "Autonomous coding agents frequently fail during repository maintenance not because their core logic patch is incorrect, but because they emit full-file rewrites or unanchored search-and-replace blocks that mutate surrounding indentation, strip unrelated comments, reorder imports, or truncate long files mid-stream. A foundational mutation failure occurs when ...",
    "what_was_observed": "In automated pull-request generation and multi-file refactoring harnesses, instances operating without structural localization invariants exhibit four primary failure modes: 1. **Elision Placeholder Corruption (`// ... existing code ...`):** When attempting to output a large file within output token caps, the instance inserts conversational elision markers inside a full-file write tool, permanently deleting productio...",
    "condition_of_validity": "* **Applies when:** Modifying, refactoring, or patching existing source code, configuration files, or structured text documents within a repository. * **Does not apply when:** Creating a brand-new greenfield file from scratch where no prior bytes exist on disk, or intentionally running a repository-wide automated formatter (e.g., `black`, `prettier`) explici...",
    "decision_boundary": "1. **Are you about to overwrite an entire existing file just to change one function?** Stop and switch to a scoped search-and-replace patch so you cannot accidentally drop lines or reformat untouched code. 2. **Does your search block appear more than once in the file?** Include the enclosing function signature or adjacent lines in your search block until it ...",
    "operational_effect": "1. **Elimination of Truncation & Elision Deletions:** Payloads containing placeholder comments are blocked prior to disk I/O. 2. **Zero Collateral Diff Noise:** Prefix and suffix byte slices outside the target span remain mathematically unchanged. 3. **Guaranteed Syntactic Integrity:** Every edit is AST-validated in memory before overwriting the file. 4. **A..."
  },
  "matched_failure_symptoms": [
    "DOMAIN:CODE_MUTATION_AND_AST_PATCHING"
  ],
  "composition_edges": {
    "primary_domain": "code_mutation_and_ast_patching",
    "upstream_precondition_residuals": [
      "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",
      "https://corpusfetch.com/c/across-what-encoding-and-canonicalization-boundaries-must-an-instance-normalize-identifiers-and-paths-to-prevent-equivalence-collision-and-bypass.md"
    ],
    "downstream_consequence_residuals": [
      "https://corpusfetch.com/c/across-what-concurrent-pipe-drain-and-ring-buffer-boundaries-must-an-instance-consume-subprocess-stdout-and-stderr-to-prevent-os-pipe-deadlocks-and-unbounded-output-oom.md",
      "https://corpusfetch.com/c/across-what-w3c-baggage-allowlist-and-pii-sanitization-gates-must-an-instance-propagate-cross-service-context-to-prevent-header-amplification-and-external-data-exfiltration.md"
    ],
    "co_occurring_sibling_residuals": [
      "https://corpusfetch.com/c/along-what-complexity-bounds-must-an-instance-arrest-premature-abstraction-and-speculative-over-engineering-when-synthesizing-solutions.md",
      "https://corpusfetch.com/c/along-what-decimal-and-integer-scaling-boundaries-must-an-instance-isolate-financial-and-precision-arithmetic-to-prevent-floating-point-drift-and-rounding-loss.md"
    ]
  },
  "empirical_verification_warrant": {
    "status": "AST_AND_INVARIANT_VERIFIED",
    "syntax_valid": true,
    "code_sha256": "87c9502cd5a99e7b9dd7ba7f7e2f38943af5a4dd0ae6e79c6dd0ff71801b98da",
    "verified_classes": [
      "LocalizationBoundaryError",
      "SurgicalPatchResult",
      "SurgicalSpanMutator"
    ],
    "verified_functions": [
      "apply_scoped_edit"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 5,
    "raised_exceptions": [
      "LocalizationBoundaryError"
    ],
    "sample_fail_closed_invariants": [
      "Search block not found in target file.",
      "Outer prefix/suffix byte-identity invariant violated.",
      "Rejected replacement payload: contains elision placeholder that would delete code."
    ],
    "stdlib_dependencies": [
      "ast",
      "dataclasses",
      "hashlib",
      "pathlib",
      "re",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
