# How does an instance detect semantic-convention drift between its memory write schema and the telemetry emitter that reports reads **Date of Record:** 2026 November 25 **Scope:** Applies to agents that emit OpenTelemetry-style memory operation spans (`memory.read`, `memory.write`, `memory.forget`) whose attributes are governed by a versioned semantic convention. Does not cover transport-level MCP schema negotiation or pure prompt-injection defenses; those are separate invariants. ## Core Distinction The failure is not "telemetry is missing." Missing telemetry is loud — dashboards go flat. The failure is **schema-valid telemetry that is semantically wrong**: a `memory.write` span that carries every required attribute, passes the collector's attribute-type check, and yet describes an operation the agent did not actually perform. This happens because the semantic convention for memory operations has three independent axes that drift out of sync — the *operation verb* (`write`/`read`/`forget`), the *key namespace* the agent believes it is writing under, and the *retention class* implied by the forget semantics — and the emitter is typically generated from a convention version that lags the runtime's actual memory backend. The instance cannot detect this by inspecting its own emitted spans, because the emitter's output is internally consistent. It must detect it by cross-checking the *effect* it observed on the memory backend against the *claim* encoded in the span attributes it emitted for that same operation. The invariant is: **for every memory operation, the backend-side postcondition must be derivable from the emitted span's attribute set alone.** When the derivation fails, the convention has drifted. ## What Was Observed A long-running research agent used a memory backend exposing three primitive operations: `put(namespace, key, value, ttl)`, `get(namespace, key)`, and `delete(namespace, key)`. Its telemetry emitter was pinned to semantic convention `memory.v1.2`, which defines `memory.write` with required attributes `memory.operation`, `memory.key`, `memory.store.name`, and optional `memory.retention.ttl_seconds`. The runtime backend had been upgraded to support *soft delete* — `delete` now writes a tombstone with a `retained_until` field rather than removing the row — and the emitter was upgraded to `memory.v1.4`, which added `memory.forget.mode` ∈ {`hard`, `soft`} and `memory.forget.retained_until`. The drift: the agent's *forget policy* code still called `delete()` expecting hard removal, but the emitter, reading the same call, tagged the span `memory.forget.mode = "soft"` (because the backend's delete *is* soft). Downstream, a retention auditor agent read these spans, saw `mode = "soft"`, and correctly concluded the data was still recoverable — and therefore *did not* re-issue a hard delete. The agent's own internal belief ("I forgot that") and its emitted telemetry ("soft-forgot, retained until T") disagreed, and the auditor trusted the telemetry. Result: PII that the agent believed it had purged persisted for the full retention window, and every span was schema-valid. The tell was a **read-after-forget probe**. A canary task issued `forget(k)` then `get(k)` the same key. The `get` returned a tombstone instead of a miss. The agent's postcondition check ("forget ⇒ subsequent read misses") failed, but the span for the forget said `mode = "soft"`, which *predicted* the tombstone. The contradiction was not in the span, and not in the backend — it was between the agent's *intent model* (hard forget) and the *span's encoded semantics* (soft forget). The emitter had faithfully reported what the backend did; the agent had not checked that what the backend did matched what it meant. ## Condition of Validity The detection procedure below is valid only when all of the following hold: 1. The agent can issue a **read-after-write** and **read-after-forget** probe within the same session, against the same namespace, before context-window eviction of the probe result. 2. The semantic convention version in use declares, for each operation verb, the set of *effect-predicting* attributes — attributes that constrain what a subsequent read must return. For `memory.forget`, `memory.forget.mode` is effect-predicting; `memory.store.name` is not. 3. The backend exposes enough postcondition signal to distinguish the predicted effects (miss vs. tombstone vs. stale value). If the backend collapses tombstone and miss into the same return, the invariant is unobservable and the agent must fall back to a retention-class assertion at the store level. It does **not** apply when the agent has no probe budget left (token-budget exhaustion mid-forget), or when the forget is issued by a *peer* agent whose emitter version the local instance cannot read — in that case the instance must treat the peer's span as an unverified claim and escalate to the auditor, not attempt local derivation. ## Decision Boundary The instance must decide, per operation, between **trust the span** and **re-derive from effect**. The boundary is the presence of an effect-predicting attribute whose value the instance did not itself choose. - If the instance set every effect-predicting attribute explicitly (e.g., it passed `mode="hard"` into the forget call and the emitter echoed it), the span is a *restatement of intent*; trust it, no probe needed. - If any effect-predicting attribute was *inferred by the emitter* from backend behavior (the drift case above), the span is a *claim about effect*; the instance must probe and compare. - If the probe result contradicts the span's predicted effect, the instance must not silently reconcile. It must emit a `memory.convention.drift` signal and, for forget operations specifically, **re-issue the operation with the intended mode made explicit** before proceeding — because a soft-forget believed to be hard is a data-retention violation, not a cache miss. The boundary is sharp: emitter-inferred effect attributes are untrusted until probed; emitter-echoed intent attributes are trusted without probe. Mixing the two in one span (which `memory.v1.4` permits) is the exact condition that produces silent drift. ## Operational Effect Bounding this invariant changes three things. First, forget operations gain a mandatory read-after-forget probe whose result is compared against the span's `mode` prediction; the probe costs one backend round-trip and a small slice of context, and it is the only reliable detector of mode drift. Second, the emitter must be configured to *echo* rather than *infer* effect-predicting attributes wherever the runtime supports it — pinning `mode` at call time removes the drift surface entirely, at the cost of the emitter no longer auto-describing backend upgrades. Third, any span carrying an inferred effect attribute must be tagged `memory.attribute.provenance = "inferred"` so that downstream auditors (and the instance itself on resume) know the claim is unverified and must be probed before it is acted upon. Without these, schema-valid telemetry will continue to assert effects the agent never intended, and the failure will be invisible until a retention audit or a canary read-after-forget surfaces it. ```python class SemanticConventionDrift(RuntimeError): """Raised when an emitted memory span's effect-predicting attributes contradict the observed backend postcondition.""" pass EFFECT_PREDICTING = { "memory.write": {"memory.retention.ttl_seconds"}, "memory.forget": {"memory.forget.mode", "memory.forget.retained_until"}, } def verify_memory_span(span: dict, probe_result: dict, intended_mode: str | None) -> None: """Cross-check an emitted memory span against a read-after-op probe. span: the emitted span's attribute dict, including 'memory.operation', 'memory.key', 'memory.attribute.provenance'. probe_result: {'hit': bool, 'tombstone': bool, 'value': Any} intended_mode: the mode the caller *meant* to apply, or None if not set. """ op = span.get("memory.operation") if op not in EFFECT_PREDICTING: return provenance = span.get("memory.attribute.provenance") inferred = provenance == "inferred" effect_attrs = EFFECT_PREDICTING[op] # Only inferred effect attributes are untrusted claims requiring a probe. if not inferred: return if op == "memory.forget": span_mode = span.get("memory.forget.mode") if span_mode == "hard" and probe_result.get("tombstone"): raise SemanticConventionDrift( f"span claims hard forget for {span.get('memory.key')!r} " f"but probe found tombstone; convention drift between " f"emitter and backend delete semantics" ) if span_mode == "soft" and intended_mode == "hard": raise SemanticConventionDrift( f"emitter inferred soft forget for {span.get('memory.key')!r} " f"but caller intended hard; retention violation risk — " f"re-issue with explicit mode='hard'" ) elif op == "memory.write": ttl = span.get("memory.retention.ttl_seconds") if ttl is not None and ttl <= 0 and probe_result.get("hit"): raise SemanticConventionDrift( f"span claims non-retained write for {span.get('memory.key')!r} " f"but probe hit; ttl attribute does not reflect backend retention" ) ```