{
  "schema_version": "1.3.0",
  "slug": "when-must-an-instance-refuse-to-emit-a-memory-retrieve-span-because-the-retrieval-mutated-the-store",
  "title": "When must an instance refuse to emit a `memory.retrieve` span because the retrieval mutated the store",
  "date_of_record": "2026 November 28",
  "scope": "Applies to any agent runtime that emits OpenTelemetry-style semantic conventions for memory operations (`memory.retrieve`, `memory.write`, `memory.update`, `memory.delete`, `context.compact`) where the backing store performs read-time side effects (recency promotion, TTL refresh, LRU eviction, access-count mutation, embedding re-index). Does not apply to pure functional vector indexes that guarantee read idempotence, nor to opaque managed memory services whose internal mutation is unobservable to the caller.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-emit-a-memory-retrieve-span-because-the-retrieval-mutated-the-store.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-emit-a-memory-retrieve-span-because-the-retrieval-mutated-the-store.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-emit-a-memory-retrieve-span-because-the-retrieval-mutated-the-store.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2088,
    "python_slice_tokens": 456,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The semantic convention layer treats `memory.retrieve` as a read and `memory.write`/`memory.update` as writes. This read/write partition is the load-bearing assumption behind every downstream consumer of the telemetry: replay engines reconstruct state by applying writes in order and treating retrieves as no-ops; auditors diff the span tree against expected s...",
    "what_was_observed": "A retrieval-augmented agent (episodic buffer of 4,096 records, LRU-with-recency-promotion backing store) executed a 340-step task. Telemetry emitted 1,847 `memory.retrieve` spans and 212 `memory.write` spans. No `memory.delete` spans. A replay harness reconstructed the store by applying the 212 writes to the initial snapshot and treating the 1,847 retrieves as pure reads. At step 118 the live agent's store had evicte...",
    "condition_of_validity": "The read/write partition in the semantic convention is valid **if and only if** the backing store satisfies read idempotence: `retrieve(k)` leaves the observable state of the store unchanged, including recency metadata, TTL, access counters, eviction order, and vector representation. This is a testable invariant, not a design aspiration. It holds for immutab...",
    "decision_boundary": "The boundary is a single predicate evaluated at span emission time: *does this operation change any field of any record other than the one returned, or change any non-content field of the returned record?* If yes, the operation is a state transition and must emit a mutation delta. If no, it is a pure read and `memory.retrieve` alone is correct. Three edge ca...",
    "operational_effect": "Enforcing the mutation-delta invariant changes three things downstream. Replay fidelity: reconstructing agents now diverge only on genuinely non-deterministic operations, and the divergence is localized to the span that admits it rather than smeared across the whole trajectory. Audit correctness: retention and relevance auditors see the true access and evict..."
  },
  "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": "ab485790e2b1e7fa917e611d05f8f60a598c90d1d8503473b9a0782e05bec8a9",
    "verified_classes": [
      "MemoryMutationUnrecordedError",
      "StoreDelta",
      "RetrieveSpan"
    ],
    "verified_functions": [
      "emit_retrieve_span",
      "guarded_retrieve",
      "is_pure"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "MemoryMutationUnrecordedError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
