{
  "schema_version": "1.3.0",
  "slug": "where-must-an-instance-reconcile-memory-read-semantics-against-compaction-telemetry-before-emitting-a-span-and-why-the-naive-ordering-corrupts-attribu",
  "title": "Where must an instance reconcile memory-read semantics against compaction telemetry before emitting a span, and why the naive ordering corrupts attribution",
  "date_of_record": "2026 November 24",
  "scope": "Applies to any agent runtime that emits OpenTelemetry-style spans for memory read/write events (`gen_ai.memory.*`) alongside context-compaction events, where compaction can evict or rewrite the very memory entries a read span attributes. Does not apply to stateless single-turn inference with no persistent memory tier and no compaction step.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/where-must-an-instance-reconcile-memory-read-semantics-against-compaction-telemetry-before-emitting-a-span-and-why-the-naive-ordering-corrupts-attribu.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-reconcile-memory-read-semantics-against-compaction-telemetry-before-emitting-a-span-and-why-the-naive-ordering-corrupts-attribu.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-reconcile-memory-read-semantics-against-compaction-telemetry-before-emitting-a-span-and-why-the-naive-ordering-corrupts-attribu.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2083,
    "python_slice_tokens": 491,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"missing telemetry.\" It is an **ordering and referent mismatch between two event families that share a causal chain but not a clock**. A memory-read span claims a semantic fact: *instance I retrieved entry E at logical time T and used it in reasoning step R*. A compaction event claims a different fact: *the context window was reduced, evic...",
    "what_was_observed": "A retrieval-augmented agent (long-horizon task, ~40 tool calls) ran a background compaction every N tokens. Sequence observed in the trace store, reconstructed by span timestamp: 1. `t=0` Retrieval returns entries `[m17, m18, m19]`; a `memory.read` span is created with `memory.id` values and `retrieval.latency`. The span is **buffered**, not yet exported (batch processor, 5s flush). 2. `t=120ms` Reasoning consumes `m...",
    "condition_of_validity": "The naive convention—\"emit read spans with `memory.id`, `query`, `latency`; emit compaction spans with `evicted`, `summarized`; join by timestamp\"—is valid **only** under the condition that no compaction can occur between a read's retrieval and its span export, *and* that reads are consumed in the same epoch they are retrieved. Both conditions fail in any ag...",
    "decision_boundary": "The boundary is whether the runtime can answer, from telemetry alone, the question: *at the moment reasoning step R executed, was memory entry E present in the context window in the form it was retrieved?* - **Below the boundary (do not emit a naive read span):** retrieval and consumption straddle a compaction epoch, the span is buffered across a flush, or t...",
    "operational_effect": "Enforcing epoch-pinned, validity-asserted read spans changes three things: 1. **Replay fidelity:** auditors reconstruct the *actual* live window at step R, including the fact that `m19` was summarized, so grounding checks no longer pass on evicted content. Hallucination audits regain their discriminating power. 2. **Attribution correctness under batching:** ..."
  },
  "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": "d93082037b8c4feb83d1be83c480e438e5de67e6d2ec451e6bbbc0af7b44f746",
    "verified_classes": [
      "ReferentInstabilityError",
      "MemoryEntry",
      "CompactionEvent",
      "ReadSpan"
    ],
    "verified_functions": [
      "emit_read_span",
      "_hash"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "ReferentInstabilityError"
    ],
    "sample_fail_closed_invariants": [
      "assert span.validity is False and span.evicting_epoch == 4"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
