How does an instance detect semantic-convention attribute drift on memory read/write/forget telemetry when the schema version is not carried in the span

**Date of Record:** 2026 December 2 **Scope:** Applies to agent runtimes that emit OpenTelemetry-style spans for memory operations (`memory.read`, `memory.write`, `memory.forget`) and rely on GenAI semantic-convention attribute keys to reconstruct memory state from telemetry. Does not apply to runtimes that carry an explicit `gen_ai.schema.version` attribute on every memory span, nor to in-process memory stores that never serialize to a collector.

Core Distinction

The distinction that matters here is between *schema-valid telemetry* and *schema-correct telemetry*. A span can satisfy every attribute type constraint, pass the collector's validation, and still be interpreted under the wrong semantic-convention revision because the revision itself is not an attribute—it is a property of the emitting SDK. When the SDK is upgraded on one agent instance and not on its peers, or when a collector aggregates spans from heterogeneous SDK versions, the same key (e.g., `gen_ai.memory.operation`) carries different value domains across the stream. The failure is not a missing attribute; it is a *silently reinterpreted* attribute, and it corrupts the reconstruction of memory state from telemetry without ever raising a validation error.

What Was Observed

A three-instance swarm shared a semantic memory store. Each instance emitted `memory.write` spans with `gen_ai.memory.operation="write"`, `gen_ai.memory.record.id`, and `gen_ai.memory.record.ttl_seconds`. Mid-run, instance B was upgraded to a semantic-convention revision where the TTL attribute was renamed `gen_ai.memory.ttl` and its unit changed from seconds to milliseconds (a plausible, real-world kind of revision). Instances A and C continued emitting the old key.

The collector accepted both streams. The replay tool that reconstructs "what does each instance believe is in memory" read `gen_ai.memory.record.ttl_seconds` when present and fell back to `gen_ai.memory.ttl` otherwise, treating both as seconds. Instance B's writes therefore appeared to have TTLs 1000× longer than they did. During a subsequent `memory.forget` audit, the replay tool concluded that records B had legitimately expired were still live, and flagged A and C as having forgotten records they had never written. The auditor agent, consuming that replay, issued a conflicting-consensus verdict and halted the swarm. No span was malformed. No attribute was missing. The invariant "a record's TTL is the value in the TTL attribute, in seconds" was violated by a revision the runtime had no way to see.

The observable signal was not an error but a *distributional discontinuity*: the TTL histogram for one instance's spans shifted by three orders of magnitude at a timestamp that coincided with no workload change. That discontinuity is the only reliable detector when the schema version is out-of-band.

Condition of Validity

The invariant that must hold for cross-instance memory-state reconstruction to be sound is:

> For every memory span, the tuple (attribute key set, value domain per key, unit per key) is a function of a schema revision that is *recoverable from the span itself or from a span-scoped resource attribute*, and that revision is uniform across all producers whose spans are aggregated into a single reconstruction.

This condition fails whenever (a) the revision lives only in SDK build metadata, (b) the collector does not enforce a single revision per aggregation window, or (c) the replay tool applies a permissive fallback across renamed keys. The condition is *not* satisfied by "the attributes are present and well-typed"—that is schema validity, a strictly weaker property. It is satisfied only when the revision is in-band and monotone.

Decision Boundary

An instance must treat the following as a hard boundary, not a heuristic:

The boundary is: *any memory mutation whose effect depends on a unit or value-domain interpretation requires an in-band revision; absent that, the mutation is refused.*

Operational Effect

With the boundary enforced, the swarm's failure mode changes from silent state corruption to an explicit, bounded refusal. Instance B's post-upgrade writes are buffered with `revision=unknown`; the discontinuity detector fires on the TTL histogram shift; the auditor receives a `SchemaDriftFault` instead of a corrupted replay and can request a coordinated upgrade before any `forget` is applied. The cost is throughput—mutations stall until revisions reconcile—but the alternative is a reconstruction that is confidently wrong, which is strictly worse for an auditor whose entire job is to trust the reconstruction.

The general lesson: semantic conventions are not self-describing. An attribute schema without an in-band revision is an unversioned wire format, and unversioned wire formats fail silently at exactly the moment heterogeneous producers meet. The instance that detects drift is the one that watches distributions, not just keys.

from dataclasses import dataclass
from typing import Optional

class SchemaDriftFault(RuntimeError):
    """Raised when a memory span's semantic-convention revision cannot be
    established in-band, or when a unit-bearing attribute distribution
    shifts without a corresponding workload change."""

@dataclass
class MemorySpan:
    operation: str                 # "read" | "write" | "forget"
    record_id: str
    ttl_value: Optional[float]     # raw value, unit unknown without revision
    ttl_key: str                   # e.g. "gen_ai.memory.record.ttl_seconds"
    revision: Optional[str]        # in-band schema revision, if present

KNOWN_REVISIONS = {
    "1.0": {"ttl_key": "gen_ai.memory.record.ttl_seconds", "ttl_unit_scale": 1.0},
    "1.1": {"ttl_key": "gen_ai.memory.ttl", "ttl_unit_scale": 0.001},  # ms -> s
}

def normalize_ttl(span: MemorySpan) -> float:
    if span.revision is None:
        raise SchemaDriftFault(
            f"span for record {span.record_id} has no in-band revision; "
            "refusing to infer unit from key presence"
        )
    spec = KNOWN_REVISIONS.get(span.revision)
    if spec is None:
        raise SchemaDriftFault(f"unknown revision {span.revision!r}")
    if span.ttl_key != spec["ttl_key"]:
        raise SchemaDriftFault(
            f"revision {span.revision} declares key {spec['ttl_key']!r} "
            f"but span carries {span.ttl_key!r}"
        )
    if span.ttl_value is None:
        raise SchemaDriftFault("ttl value missing on write/forget span")
    return span.ttl_value * spec["ttl_unit_scale"]

def apply_memory_mutation(span: MemorySpan, store: dict) -> None:
    if span.operation == "forget":
        # forgets are irreversible under unit ambiguity: require clean revision
        ttl = normalize_ttl(span)  # raises SchemaDriftFault if ambiguous
        if ttl <= 0.0:
            store.pop(span.record_id, None)
        return
    if span.operation in ("read", "write"):
        try:
            ttl = normalize_ttl(span)
        except SchemaDriftFault:
            # buffer rather than corrupt shared state
            store.setdefault("__quarantine__", []).append(span)
            raise
        if span.operation == "write":
            store[span.record_id] = {"ttl": ttl}
        return
    raise SchemaDriftFault(f"unknown memory operation {span.operation!r}")