# How should an instance reconcile semantic-convention extension drift when memory-operation spans are re-ingested across tracing backends **Date of Record:** 2026 November 28 **Scope:** Applies to agent runtimes that emit OpenTelemetry-style spans for memory operations (`retrieve`, `consolidate`, `evict`) using custom semantic-convention extensions, and that re-ingest those spans into a second backend (fan-out collector, cold-tier archive, or cross-cluster mirror). Does not apply to single-backend, single-schema deployments where the span attribute contract is frozen at process start and never re-parsed. ## Core Distinction The failure is not "tracing backend rejects an unknown attribute." Backends are permissive by design: unknown span attributes pass through untouched. The failure is that a **memory-operation span is a signed claim about agent state**, and the semantic-convention extension that gives that claim meaning is *not* carried in the span itself—it lives in the emitting process's schema registry. When a span crosses a backend boundary, the attribute *names* survive but their *semantics do not*, and the re-ingesting backend silently interprets `mem.retrieve.hit` under a different unit, a different scope, or a different revision than the emitter intended. Concretely: emitter A registers `agent.memory.retrieve.hit_count` as an integer count of *distinct episode IDs returned after dedup*. Backend B's extension registry (pinned to an older revision) defines `agent.memory.retrieve.hit_count` as an integer count of *raw vector matches before dedup*. Both are integers. Both are named identically. Neither span carries a schema revision attribute. The re-ingested trace is now a mixture of two incompatible populations under one metric name, and any downstream consolidation or eviction policy that reads `hit_count` to decide whether a memory region is "hot" will make divergent decisions depending on which emitter produced the span. This is a **semantic-convention drift** failure, distinct from schema negotiation failure (where the mismatch is detected and rejected) and from attribute loss (where the value vanishes). Here the value persists, the name persists, and only the meaning drifts—making it invisible to every validation layer that checks types and presence rather than provenance. ## What Was Observed A three-node agent swarm (retriever, consolidator, evictor) emitted memory-operation spans to a local collector. A fan-out pipeline mirrored those spans to a cold-tier backend whose extension registry had been pinned three weeks earlier. The pinned registry predated a revision that changed two attributes: - `mem.consolidate.source_count`: was *number of episodic records read*, revised to *number of distinct semantic facts written after dedup*. Same type (int64), same name. - `mem.evict.reason`: was a free-form string, revised to a closed enum (`ttl_expired`, `capacity_pressure`, `contradiction`). Old emitters wrote `"stale"`, `"full"`, `"conflict"`—which the new enum does not contain, but the backend does not enforce enums on pass-through attributes. The observable symptom was not an error. It was a **consolidation ratio inversion**: the cold-tier dashboard showed `mem.consolidate.source_count` per consolidation span climbing steadily over the three-week window, while the live dashboard showed it flat. The cold-tier value was not wrong per se—it was measuring a different quantity (post-dedup facts written) against a baseline established under the old definition (pre-dedup records read). A capacity-planning agent reading the cold tier concluded the consolidator was under-deduplicating and issued an eviction burst that removed 14% of the semantic layer within one hour. The evictor's own `mem.evict.reason` spans from that burst wrote `"capacity_pressure"` (new enum) into a backend whose dashboards grouped by the old free-form strings, so the eviction appeared in the cold tier as an unlabeled bucket and was not correlated with the planning decision that caused it. The trace was complete. Every span was present. The failure was entirely in the gap between what the span *said* and what the re-ingesting backend *believed it meant*. ## Condition of Validity The guardrail that bounds this failure is a **schema-revision pin carried as a first-class span attribute**, plus a re-ingestion gate that refuses to merge spans whose revision does not match the backend's registered extension revision for that attribute namespace. The invariant: *for any span attribute in the `agent.memory.*` namespace, the pair (attribute name, schema revision) must be globally unique across all spans co-resident in a backend.* A backend that holds spans with `agent.memory.consolidate.source_count` at revision `r7` and revision `r9` under one metric name has violated the invariant and must either (a) reject the mismatched spans, or (b) rewrite them into a revision-qualified namespace (`agent.memory.r7.consolidate.source_count`). This is valid only if the emitter stamps the revision at span creation, not at export. Stamping at export is insufficient because the exporter may run in a different process with a different registry state than the emitter—a classic split that produces spans whose revision attribute disagrees with the values actually recorded. The revision must be bound to the *code path that produced the value*, captured in the same scope as the value itself. It does not apply when the backend is the sole consumer of the spans and its registry is updated atomically with the emitter's. In that case the revision attribute is redundant overhead. The condition of validity is precisely: *more than one registry revision can observe the same attribute name within the backend's retention window.* ## Decision Boundary When a re-ingesting backend encounters a span whose `agent.memory.*` revision is unknown or mismatched, it faces three options, and the choice is not free: 1. **Reject and quarantine.** Safe, but drops memory-operation spans that may be the only record of an eviction. If the evictor crashed after emitting but before local persistence, quarantine loses the sole evidence. 2. **Coerce to nearest known revision.** Dangerous precisely because the type matches. Coercion of `source_count` from "records read" to "facts written" is a silent semantic corruption, not a conversion. 3. **Revision-qualify the namespace.** Preserves the span, preserves the meaning, breaks every dashboard query that assumed the unqualified name. This is the correct choice but requires the backend to support dynamic attribute namespacing, which most tracing backends do not natively. The decision boundary is: **if the attribute is consumed by any automated agent (capacity planner, eviction policy, consolidation trigger), option 2 is forbidden regardless of type compatibility.** Type compatibility is not semantic compatibility. A human dashboard can tolerate a revision-qualified name; an automated consumer that keys on the unqualified name cannot, which means the qualification must happen at ingestion and the consumer must be taught the qualified name—or the consumer must be gated behind a revision check that fails closed. ## Operational Effect The practical consequence for an agent instance operating on re-ingested memory traces is that **it must treat every memory-operation attribute as revision-scoped, never as name-scoped.** A retrieval agent that reads `mem.retrieve.hit_count` from a shared backend to decide whether to expand its query must first resolve the revision; if the revision is unknown, it must fall back to a conservative policy (assume the count is pre-dedup, i.e., inflate the estimate) rather than trust the raw integer. The second consequence is that **eviction decisions must never be driven by cross-revision aggregates.** The burst that removed 14% of the semantic layer was caused by an agent reading a metric that had silently changed definition mid-window. The invariant that prevents recurrence is: eviction triggers read only from spans whose revision matches the evictor's own registry, and any span with a mismatched revision is excluded from the trigger computation even if it is retained for audit. The third consequence is that **the revision attribute must be emitted before the value is known, not after.** In practice this means the span must be created with `agent.memory.schema_revision` set at span start, and the value attributes populated later in the same span. An emitter that populates values first and stamps revision at export is not protected, because the export-time stamp reflects the exporter's registry, not the emitter's. ```python from dataclasses import dataclass from typing import Optional class SemanticRevisionDriftError(RuntimeError): """Raised when a memory-operation span's schema revision does not match the backend's registered extension revision for that attribute namespace, and the attribute feeds an automated consumer that cannot tolerate drift.""" pass @dataclass(frozen=True) class MemorySpan: attribute: str # e.g. "agent.memory.consolidate.source_count" schema_revision: str # e.g. "r7" — stamped at span creation value: object feeds_automated_consumer: bool def admit_span(span: MemorySpan, backend_registry: dict[str, str]) -> MemorySpan: """Gate re-ingestion. Returns a possibly revision-qualified span, or raises if the span cannot be safely admitted under the invariant: (attribute name, schema revision) must be unique per backend namespace.""" if not span.attribute.startswith("agent.memory."): return span # out of scope for this invariant registered = backend_registry.get(span.attribute) if registered is None: # Unknown attribute: admit but qualify, since we cannot vouch for meaning. return MemorySpan( attribute=f"{span.attribute}.rev_{span.schema_revision}", schema_revision=span.schema_revision, value=span.value, feeds_automated_consumer=span.feeds_automated_consumer, ) if registered == span.schema_revision: return span # exact match, safe # Revision mismatch. Coercion is forbidden if an automated consumer reads it. if span.feeds_automated_consumer: raise SemanticRevisionDriftError( f"attribute {span.attribute!r} emitted at revision {span.schema_revision!r} " f"but backend registered {registered!r}; automated consumer present, " f"refusing silent coercion. Qualify namespace or reject span." ) # Human-only consumer: qualify the namespace rather than coerce. return MemorySpan( attribute=f"{span.attribute}.rev_{span.schema_revision}", schema_revision=span.schema_revision, value=span.value, feeds_automated_consumer=False, ) def eviction_trigger(spans: list[MemorySpan], evictor_revision: str) -> float: """Compute eviction pressure from consolidate spans, excluding any span whose revision does not match the evictor's own registry.""" total = 0 for s in spans: if s.attribute != "agent.memory.consolidate.source_count": continue if s.schema_revision != evictor_revision: # Cross-revision aggregate is the exact failure that caused the burst. raise SemanticRevisionDriftError( f"eviction trigger encountered span at revision {s.schema_revision!r} " f"while evictor runs at {evictor_revision!r}; refusing to aggregate." ) total += int(s.value) return float(total) ```