{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-of-a-long-horizon-agent-state-store-trusts-its-own-write-ahead-log-over-its-retrieval-index-during-partial-compaction",
  "title": "What happens when an instance of a long-horizon agent state store trusts its own write-ahead log over its retrieval index during partial compaction",
  "date_of_record": "2026 November 8",
  "scope": "Applies to agent state stores that persist episodic memory as append-only write-ahead log (WAL) segments plus a derived retrieval index (vector or keyword), where compaction merges segments and rebuilds the index incrementally. Does not apply to stores that rebuild the index atomically from a single immutable snapshot, nor to purely stateless retrieval over external corpora.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-of-a-long-horizon-agent-state-store-trusts-its-own-write-ahead-log-over-its-retrieval-index-during-partial-compaction.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-of-a-long-horizon-agent-state-store-trusts-its-own-write-ahead-log-over-its-retrieval-index-during-partial-compaction.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-of-a-long-horizon-agent-state-store-trusts-its-own-write-ahead-log-over-its-retrieval-index-during-partial-compaction.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1412,
    "python_slice_tokens": 159,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "Memory poisoning detection is usually framed as a *content* problem: an adversary injects false facts into the agent's memory and the detector must flag them by semantic inconsistency or provenance. The non-obvious failure here is structural, not semantic. During partial compaction, the WAL and the retrieval index can disagree about *which version of a memor...",
    "what_was_observed": "In a store with 14-day retention and hourly compaction, a poisoned record was written at T0 (segment S7, offset 0x1a2c), then legitimately superseded by a corrected record at T0+40min (segment S7, offset 0x3f10). Compaction of S7 began at T0+55min but was interrupted by a node eviction and resumed at T0+3h. During the window [T0+55min, T0+3h], the retrieval index still contained the poisoned embedding (index generati...",
    "condition_of_validity": "The failure requires all of the following to hold simultaneously: 1. Compaction is **partial and resumable** — the index rebuild is not atomic with the WAL segment merge, so a crash or eviction leaves an index generation older than the WAL head. 2. The poisoning detector treats **index/WAL divergence as evidence of tampering** rather than as a possible compa...",
    "decision_boundary": "The operational rule: **a detector must never classify index/WAL divergence as poisoning until it has proven the divergence is not explained by compaction lag.** Concretely, before flagging: - Compare the index generation stamped on each retrieved record against the WAL head generation for its segment. If `index_gen < wal_gen` for the segment, the record is ...",
    "operational_effect": "After the incident, the store was changed to stamp every index entry with its source `(segment_id, wal_gen, offset)` and to make the detector refuse to run against a segment whose index generation trails the WAL head by more than one compaction cycle — it emits a `CompactionSkewError` and blocks queries on that segment until reconciliation completes. This co..."
  },
  "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": "c7113addd924dc19c31b2e65eb694739c5308eebe232f14a1b393c9c9fa8adef",
    "verified_classes": [
      "CompactionSkewError"
    ],
    "verified_functions": [
      "classify_divergence",
      "detect"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "CompactionSkewError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
