{
  "schema_version": "1.3.0",
  "slug": "when-must-an-instance-refuse-to-emit-a-memory-retrieval-span-because-compaction-invalidated-the-offset-it-was-about-to-record",
  "title": "When must an instance refuse to emit a memory.retrieval span because compaction invalidated the offset it was about to record",
  "date_of_record": "2026 November 29",
  "scope": "Applies to agent runtimes that emit OpenTelemetry-style semantic convention spans for memory operations (`memory.retrieval`, `memory.write`, `memory.compaction`) where span attributes reference positional offsets into a mutable context window. Does not apply to runtimes that record memory operations by opaque content hash or by immutable store keys independent of the live context window.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-emit-a-memory-retrieval-span-because-compaction-invalidated-the-offset-it-was-about-to-record.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-emit-a-memory-retrieval-span-because-compaction-invalidated-the-offset-it-was-about-to-record.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-emit-a-memory-retrieval-span-because-compaction-invalidated-the-offset-it-was-about-to-record.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1946,
    "python_slice_tokens": 311,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters is between *observational* telemetry and *evidentiary* telemetry. A `memory.retrieval` span is normally treated as observational: it says \"at wallclock T, the agent asked the store for X and got Y.\" Under the GenAI semantic convention extensions for memory operations, however, the span carries attributes like `gen_ai.memory.retri...",
    "what_was_observed": "A retrieval-augmented agent running a 40-step tool loop performed a `memory.retrieval` against its episodic store at step 12, resolving a chunk to byte offset 41,208 in a window whose `context.window_id` was `ctx-7f3a`. The span was constructed in the retrieval helper but flushed asynchronously by the batch span processor. Between construction and flush, the runtime's compaction policy fired (window occupancy crossed...",
    "condition_of_validity": "The invariant holds — and the refusal is correct — only under these conditions, which must all be checked at span-emission time, not at span-construction time: 1. The span references positional offsets (`offset`/`length`) rather than content hashes. Hash-addressed memory spans are immune and must not be subjected to this guard. 2. The runtime retains only th...",
    "decision_boundary": "The boundary is *not* \"did a compaction occur.\" Compactions occur constantly and most are irrelevant to a given span. The boundary is: **did a compaction occur whose epoch delta covers the interval between offset resolution and flush, AND does the runtime lack per-generation retention?** A span whose offset was resolved in epoch 4 and flushed in epoch 4 is v...",
    "operational_effect": "Enforcing this invariant changes the telemetry contract from \"best-effort emission\" to \"fail-closed emission,\" and teams must budget for it. In the reference deployment, the guard raised on 0.7% of retrieval spans during high-compaction-pressure phases (long agent loops with aggressive distillation), each raise surfacing a span that would otherwise have been..."
  },
  "matched_failure_symptoms": [
    "OOM_KILL_OR_MEMORY_EXHAUSTION",
    "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": "be252a29c74b3edb570bd06536f142fcf25d068fdfe8bacb3f81b915e49f1b8f",
    "verified_classes": [
      "StaleMemorySpanError",
      "WindowState",
      "ResolvedOffset"
    ],
    "verified_functions": [
      "_intersects",
      "emit_memory_retrieval_span"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "StaleMemorySpanError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
