# In what scenarios must an instance reject a memory-write span whose semantic-convention attributes are structurally valid but semantically unbound **Date of Record:** 2026 December 1 **Scope:** Applies to any agent runtime that emits OpenTelemetry-style memory spans (`gen_ai.memory.read`, `gen_ai.memory.write`, `gen_ai.memory.forget`) and relies on those attributes for downstream replay, audit, or distillation. Does not apply to runtimes that treat memory spans as pure observability with no semantic consumer. ## Core Distinction The failure mode here is not a malformed span. Every attribute passes schema validation: types are correct, enums are in range, required keys are present, cardinalities match the collector's contract. The span is *structurally valid and semantically unbound* — it records a memory operation without recording the identity relationship that makes the operation meaningful to a later consumer. The canonical case is a `gen_ai.memory.write` span that carries `gen_ai.memory.store.id`, `gen_ai.memory.operation = "write"`, `gen_ai.memory.record.count`, and a `gen_ai.memory.record.keys` list, but omits the binding between the written record and the *episode* or *agent instance* that will later read it. The write happened; the write is not addressable. The distinction that matters operationally: schema conformance is a per-span property, but memory continuity is a *cross-span relational* property. A validator that checks spans in isolation cannot see the break. The break only manifests when a `gen_ai.memory.read` span arrives minutes later, resolves its `gen_ai.memory.record.key` against the store, finds a record, and cannot determine whether the record was produced by the same logical agent, a sibling instance, or a stale incarnation from before a checkpoint. The read succeeds at the storage layer and fails at the semantic layer — a silent retrieval mismatch that corrupts downstream reasoning rather than raising an error. ## What Was Observed A three-instance agent swarm (planner, executor, auditor) shares a vector-backed episodic store. Each instance emits memory spans through a shared SDK. During a long task, the executor checkpoints and resumes on a new pod. The resumed executor emits `gen_ai.memory.write` with: ``` gen_ai.memory.store.id = "episodic-v3" gen_ai.memory.operation = "write" gen_ai.memory.record.keys = ["step-14-observation", "step-14-toolresult"] gen_ai.memory.record.count = 2 gen_ai.agent.id = "executor" ``` All schema-valid. What is absent: `gen_ai.memory.episode.id`, `gen_ai.memory.instance.incarnation`, and any `gen_ai.memory.record.provenance` pointer. The pre-checkpoint executor had written `step-1..step-13` under incarnation `executor-a`; the resumed pod is `executor-b`. Because the write span does not bind records to an incarnation or episode, the auditor's later `gen_ai.memory.read` for `step-14-observation` returns the record with no way to distinguish it from a hallucinated or stale write. The auditor's verification replay passes — the record exists, the keys match — but the record's provenance is unbound, so the auditor cannot detect that `executor-b` resumed with a partially reconstructed working set and overwrote `step-9-toolresult` with a value it derived from a cold-start guess. The overwrite is not a `forget` operation; it is a `write` that collided at the key level because no incarnation discriminator was in the key space. The failure trace, in order: 1. `executor-a` writes `step-9-toolresult` with provenance implicit in its in-memory state. 2. Checkpoint fires; `executor-b` cold-starts with a summary, not the raw working set. 3. `executor-b` re-derives `step-9-toolresult` from the summary, producing a plausible but divergent value, and writes it under the same key. 4. No span records that the key was overwritten across incarnations, because `gen_ai.memory.record.keys` is a flat list with no version or incarnation dimension. 5. `auditor` reads `step-9-toolresult`, gets the divergent value, and because the read span resolves cleanly, treats it as authoritative. 6. Error compounds into the final output; no exception is raised at any layer. ## Condition of Validity A memory span is semantically bound — and therefore admissible for replay and audit — only when the tuple `(store.id, record.key, episode.id, instance.incarnation, operation)` is total and consistent across the write and every subsequent read of that key. The invariant is: > For any `gen_ai.memory.read` span R resolving key K in store S, there must exist a `gen_ai.memory.write` span W with the same `(S, K)` whose `episode.id` and `instance.incarnation` are equal to R's, or R must carry an explicit `gen_ai.memory.read.cross_incarnation = true` with a `gen_ai.memory.read.provenance` pointer to the W it accepted. Without this, a read is indistinguishable from a read of a stale or divergent write. The schema validator cannot enforce it because it is a cross-span predicate; it must be enforced by the span *emitter* (at write time, by refusing to emit an unbound write) or by the *consumer* (at read time, by rejecting reads whose provenance cannot be resolved to a single write). The condition of validity is therefore not "the span validates" but "the span participates in a closed provenance chain." A second, subtler condition: `gen_ai.memory.forget` spans must carry the same incarnation discriminator. A forget issued by `executor-b` for a key written by `executor-a` is a cross-incarnation mutation and must be marked as such; otherwise a resumed instance can silently erase its predecessor's records and the audit trail will show a clean forget with no indication that the erasure crossed an incarnation boundary. ## Decision Boundary The runtime must reject — not merely warn on — a memory span when any of the following holds at emit time: - `gen_ai.memory.operation` is `write` or `forget` and `gen_ai.memory.episode.id` is absent. - `gen_ai.memory.operation` is `write` or `forget` and `gen_ai.agent.incarnation` is absent. - `gen_ai.memory.record.keys` contains a key whose current stored provenance (if any) has a different `instance.incarnation` than the emitting span, and the span does not set `gen_ai.memory.write.cross_incarnation = true` with a `gen_ai.memory.write.supersedes` pointer. The boundary is deliberately placed at the emitter, not the collector, because the emitter is the only component that still has the incarnation identity in scope. A collector-side check would have to reconstruct incarnation from pod metadata, which is exactly the reconstruction that fails during cold start. The trade-off: rejecting at emit means a resumed instance that cannot prove its incarnation must fail its first memory write rather than proceed with an unbound one. That is the correct failure — a loud cold-start amnesia is recoverable; a silent provenance break is not. The boundary does *not* apply to `gen_ai.memory.read` spans in isolation, because a read of an unbound record is detectable at read time by the absence of a resolvable provenance pointer. Reads are downgraded, not rejected: the consumer marks the result `gen_ai.memory.read.provenance_unbound = true` and the reasoning layer must treat the retrieved content as low-confidence. This asymmetry — hard reject on write, soft downgrade on read — is the invariant that keeps the store from accumulating unaddressable records while still allowing the agent to make progress on a degraded working set. ## Operational Effect Enforcing the boundary changes the failure profile from silent divergence to explicit cold-start failure. The resumed executor's first `write` for `step-9-toolresult` raises, the runtime surfaces a `MemoryProvenanceError`, and the orchestrator either re-hydrates the incarnation from the checkpoint or restarts the step with `cross_incarnation = true` and an explicit `supersedes` pointer. The auditor's replay then sees a closed chain: every read resolves to exactly one write, every cross-incarnation write is flagged, and every forget is attributable to an incarnation. The cost is a small number of rejected writes at resume boundaries; the benefit is that retrieval mismatches become auditable events rather than latent reasoning corruption. The invariant to carry forward: *a memory operation is not the mutation of a key, it is the mutation of a key within an episode by an incarnation* — and any span schema that omits the episode or incarnation dimension is structurally valid and operationally useless. ```python class MemoryProvenanceError(RuntimeError): """Raised when a memory span is schema-valid but semantically unbound.""" pass REQUIRED_BINDING_ATTRS = ( "gen_ai.memory.episode.id", "gen_ai.agent.incarnation", ) def admit_memory_span(span: dict, store_provenance: dict) -> None: op = span.get("gen_ai.memory.operation") if op not in ("write", "forget"): # Reads are downgraded by the consumer, not rejected here. return for attr in REQUIRED_BINDING_ATTRS: if not span.get(attr): raise MemoryProvenanceError( f"{op} span missing binding attribute {attr!r}; " "span is schema-valid but unaddressable for replay/audit" ) incarnation = span["gen_ai.agent.incarnation"] store_id = span["gen_ai.memory.store.id"] for key in span.get("gen_ai.memory.record.keys", []): prior = store_provenance.get((store_id, key)) if prior is None: continue if prior["incarnation"] != incarnation and not span.get( "gen_ai.memory.write.cross_incarnation" ): raise MemoryProvenanceError( f"{op} on key {key!r} crosses incarnation boundary " f"({prior['incarnation']} -> {incarnation}) without " "cross_incarnation=true and supersedes pointer" ) ```