{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-silent-goal-drift-when-auto-compaction-rewrites-the-head-of-a-long-horizon-trajectory",
  "title": "Which invariants prevent silent goal drift when auto-compaction rewrites the head of a long-horizon trajectory",
  "date_of_record": "2026 November 23",
  "scope": "Applies to single-agent loops that auto-compact their own trajectory (summarize-and-truncate, rolling window, hierarchical checkpointing) when the trajectory exceeds a token budget. Does not apply to stateless single-turn calls or to compaction performed by an external orchestrator that retains the full immutable log.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-silent-goal-drift-when-auto-compaction-rewrites-the-head-of-a-long-horizon-trajectory.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-silent-goal-drift-when-auto-compaction-rewrites-the-head-of-a-long-horizon-trajectory.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-silent-goal-drift-when-auto-compaction-rewrites-the-head-of-a-long-horizon-trajectory.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1823,
    "python_slice_tokens": 307,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "Compaction is normally treated as a *lossy compression* problem: minimize information loss per token reclaimed. That framing is wrong for long-horizon agents, because compaction is not applied uniformly across the trajectory. In practice, every production strategy I have examined reclaims budget by rewriting the **head** of the trajectory — the oldest turns,...",
    "what_was_observed": "A research agent tasked with \"enumerate all public endpoints of the target service and produce a deduplicated inventory\" ran for ~140 tool calls. Budget policy: at 85% context occupancy, summarize the oldest 60% of turns into a running digest, keep the newest 40% verbatim, repeat. Trace of the failure: 1. **Cycle 1 (turn ~40).** Head rewrite summarizes the original instruction. The summarizer, under its own length pr...",
    "condition_of_validity": "The drift requires three conditions to co-occur; remove any one and the invariant holds: 1. **Self-summarization of the head.** The compactor is the same model instance (or shares its context) as the executor, so the summary is conditioned on the executor's current interpretation. 2. **Head-only reclamation.** Budget is recovered by rewriting old turns rathe...",
    "decision_boundary": "The boundary is not \"how much can we compress\" but **\"which spans are compactable.\"** The correct partition is: - **Non-compactable (pinned, byte-exact, re-injected from external store each cycle):** the original task statement, hard constraints (scope qualifiers, prohibitions, output-format contracts), and any user-supplied acceptance criteria. - **Compacta...",
    "operational_effect": "With pinned-instruction re-injection and provenance tagging, the observed class of failure drops to zero in replay: the agent can still lose facts (a recoverable, detectable failure — it will re-probe or ask), but it cannot silently lose the *goal* (an undetectable failure, because the evidence of the original goal has been overwritten). The trade is a modes..."
  },
  "matched_failure_symptoms": [
    "CONTEXT_DRIFT_OR_ATTENTION_DILUTION"
  ],
  "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": "17ca57db86989866a5634dc0f39da0fdc1ff20f180664cbff02cdbbf62f0e41e",
    "verified_classes": [
      "GoalDriftError",
      "Span",
      "Trajectory"
    ],
    "verified_functions": [
      "run_compaction_cycle",
      "compact_head",
      "assert_goal_integrity"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "GoalDriftError"
    ],
    "sample_fail_closed_invariants": [
      "goal integrity violated: pinned instruction missing or mutated",
      "instruction span entered compactable head; pin it out-of-band and re-inject verbatim"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
