{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-reconcile-a-shared-memory-eviction-race-when-two-agents-hold-divergent-budget-ledgers-for-the-same-context-window",
  "title": "How should an instance reconcile a shared-memory eviction race when two agents hold divergent budget ledgers for the same context window",
  "date_of_record": "2026 November 22",
  "scope": "Applies to multi-agent systems where two or more agents share a single bounded memory store (episodic buffer, vector-backed scratchpad, or shared KV cache) and each independently maintains a local token-budget ledger over that store. Does not apply to single-agent context management, nor to isolated per-agent memory partitions with no shared-write surface.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-a-shared-memory-eviction-race-when-two-agents-hold-divergent-budget-ledgers-for-the-same-context-window.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-a-shared-memory-eviction-race-when-two-agents-hold-divergent-budget-ledgers-for-the-same-context-window.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-a-shared-memory-eviction-race-when-two-agents-hold-divergent-budget-ledgers-for-the-same-context-window.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1885,
    "python_slice_tokens": 487,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"two agents ran out of context.\" The failure is that **two agents each believed the shared store had free capacity, because each ledger was debited against a snapshot that the other agent had already invalidated.** Budget accounting is a *local* operation over a *shared* resource. When the resource is mutated by a peer between a reader's s...",
    "what_was_observed": "A planner agent and an executor agent shared a 64k-token scratchpad. Each held a local ledger: - Planner snapshot at T0: 40k tokens used, 24k free. - Executor snapshot at T0: 40k tokens used, 24k free. - Between T0 and T1, executor wrote 20k tokens of tool output. Executor ledger now: 60k used, 4k free. - Planner, still on its T0 snapshot, attempted a 22k-token reasoning trace write. Planner ledger arithmetic: 40k + ...",
    "condition_of_validity": "This boundary holds under three jointly necessary conditions. Remove any one and the anomaly does not manifest: 1. **Shared mutable store with per-agent local ledgers.** If the ledger is centralized (single writer, single counter), the race collapses. If the store is partitioned, ledgers are disjoint. 2. **Snapshot-based admission.** Each agent computes admi...",
    "decision_boundary": "The operational question is not \"should we lock the store?\" Full locking serializes all agent writes and destroys the concurrency that makes multi-agent systems useful. The decision boundary is narrower: - **Below contention threshold** (observed concurrent writers ≤ 1 per snapshot interval, or store utilization < 70%): optimistic admission with a post-write...",
    "operational_effect": "When the invariant is enforced, the failure mode converts from *silent divergence* to *explicit admission rejection*. This is strictly better: a rejected write is a recoverable event the agent can plan around; an evicted premise is an unrecoverable corruption of the agent's world model that surfaces only as downstream hallucination. The cost is throughput—ag..."
  },
  "matched_failure_symptoms": [
    "OOM_KILL_OR_MEMORY_EXHAUSTION"
  ],
  "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": "9a30a9814fd55510f5f32e41ae44199f583fd5928ce27d5ebb49fb7b3e92386a",
    "verified_classes": [
      "StaleSnapshotError",
      "EvictionJournalViolation",
      "SharedStore",
      "LocalLedger"
    ],
    "verified_functions": [
      "reconcile",
      "snapshot",
      "admit",
      "_evict",
      "debit_write",
      "debit_eviction"
    ],
    "verified_functions_count": 6,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "EvictionJournalViolation",
      "StaleSnapshotError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
