# What structural signals indicate semantic-convention attribute drift is corrupting safety-signal audit replay **Date of Record:** 2026 November 24 **Scope:** Applies to any agent runtime that emits safety signals (refusals, redactions, escalations, policy hits) as structured telemetry whose attribute keys and value types are governed by a versioned semantic convention (e.g. GenAI/OpenTelemetry-style `gen_ai.*` schemas). Does not cover unstructured log lines or free-text audit notes. ## Core Distinction A safety signal is not a log message; it is a *typed claim* whose meaning is fixed by a schema version. The failure mode here is **attribute-schema drift under replay**: the emitting agent and the replaying auditor resolve the same attribute key to different types or semantics, so the auditor reconstructs a decision that the emitter never made. The distinction that matters is between *lossy* drift (an attribute is dropped; the signal degrades to "unknown") and *silent semantic drift* (the key survives but its meaning inverts — e.g. `gen_ai.safety.blocked` flips from boolean `true` to string `"true"`/`"false"`, or `severity` is renumbered so `2` means `warn` in v1 and `error` in v2). Lossy drift fails loudly. Semantic drift fails *plausibly*, which is what makes it an audit hazard: the replay produces a coherent, wrong narrative. ## What Was Observed An agent fleet emitted safety signals across a rolling schema upgrade. Emitter instances on convention v1.4 wrote `gen_ai.safety.action` as an integer enum (`0=allow, 1=redact, 2=block, 3=escalate`). A partial deploy moved some emitters to v2.0, where the same key became a string enum and — critically — the numeric ordering was redefined (`1=block, 2=redact`). During a routine audit replay, the auditor loaded all records into v2.0 semantics. Records emitted under v1.4 with `action=1` (a **redaction**) replayed as v2.0 `block`. The audit concluded the fleet had blocked 4,100 requests it had actually only redacted, and — worse — replayed `action=2` (v1.4 **block**) as v2.0 `redact`, understating genuine blocks. Both directions of error appeared in the same replay because the enum was *reordered*, not merely retyped. The tell was structural, not textual: the replayed decision distribution was bimodal and discontinuous at the deploy timestamp, and the count of "block" events exactly matched the pre-deploy count of "redact" events. No exception was raised anywhere. Type coercion (`int` → `str` via `str()`) succeeded silently in the ingestion layer. ## Condition of Validity The invariant that bounds this failure: **an attribute value is only interpretable in conjunction with the schema version that was active at emission time, and that version must be embedded in the record itself, not inferred from ingestion context.** A replay is valid only if, for every signal, `resolve(key, value, emitting_schema_version) == resolve(key, value, replaying_schema_version)` for the fields the audit decision depends on. When the emitter does not stamp its own schema version onto each signal, the auditor is forced to assume a single version, and the equality above silently fails for every record from a different version. Stamping the version on the *stream* or the *deploy manifest* is insufficient — records outlive deploys and interleave across versions. ## Decision Boundary Bound the failure at the ingestion boundary with a **reject-on-ambiguity** rule rather than a coerce-on-mismatch rule. Concretely: (1) every safety signal carries `schema.version` as a first-class, non-optional attribute set by the emitter at construction; (2) the auditor resolves each attribute through the *record's* declared version, never a global default; (3) if a key's type or enum domain differs between the record's version and the replay target, the auditor must **refuse to coerce** and instead emit a `SchemaDriftError` that quarantines the record as `unreplayable` rather than guessing. The boundary is: coercion is permitted only between versions where the key's domain is provably identical (a signed compatibility assertion), otherwise the record is excluded from aggregate audit counts and surfaced as a drift alarm. An audit that silently coerces is worse than an audit that refuses, because the refusal is visible and the coercion is not. ## Operational Effect With reject-on-ambiguity, the 4,100 misclassified records become a single drift alarm keyed to the v1.4→v2.0 enum reordering, and the audit reports "N unplayable records across a version boundary" instead of a fabricated block count. The cost is that partial audits must report a coverage gap; the benefit is that the gap is honest. Teams that instead add a coercion shim discover the problem only when a downstream policy or regulator trusts the replayed number — at which point the wrong figure has already propagated into the safety record of the system. The structural signal to watch for in production: **any discontinuity in a safety-signal distribution that aligns exactly with a schema deploy boundary, where the post-deploy counts of one category equal the pre-deploy counts of another.** That symmetry is the fingerprint of enum reordering, and it is the earliest reliable indicator that replay semantics have inverted. ```python from dataclasses import dataclass from typing import Any, Mapping class SchemaDriftError(RuntimeError): """Raised when a safety signal cannot be replayed without semantic ambiguity.""" # Domain signatures per schema version. A key is replay-safe across versions # only if its domain signature is byte-identical. SCHEMA_REGISTRY: dict[str, dict[str, str]] = { "1.4": { "gen_ai.safety.action": "enum:int:0=allow,1=redact,2=block,3=escalate", "gen_ai.safety.severity": "enum:int:1=info,2=warn,3=error", }, "2.0": { # NOTE: action reordered AND retyped; severity renumbered. "gen_ai.safety.action": "enum:str:1=block,2=redact,3=escalate,0=allow", "gen_ai.safety.severity": "enum:int:1=info,2=error,3=warn", }, } @dataclass(frozen=True) class SafetySignal: schema_version: str # MUST be stamped by the emitter, per record attributes: Mapping[str, Any] def replay_attribute(signal: SafetySignal, key: str, target_version: str) -> Any: """Resolve one attribute for audit replay, refusing ambiguous coercions.""" if signal.schema_version not in SCHEMA_REGISTRY: raise SchemaDriftError( f"unknown emitting schema version {signal.schema_version!r}" ) if target_version not in SCHEMA_REGISTRY: raise SchemaDriftError(f"unknown replay target version {target_version!r}") emit_dom = SCHEMA_REGISTRY[signal.schema_version].get(key) if emit_dom is None: raise SchemaDriftError( f"key {key!r} absent from emitting schema {signal.schema_version}" ) target_dom = SCHEMA_REGISTRY[target_version].get(key) if target_dom is None: raise SchemaDriftError( f"key {key!r} absent from replay target schema {target_version}" ) # The invariant: only replay when the domain signature is identical. if emit_dom != target_dom: raise SchemaDriftError( f"semantic drift on {key!r}: {signal.schema_version}->{target_version} " f"({emit_dom!r} != {target_dom!r}); record is unreplayable, not coercible" ) if key not in signal.attributes: raise SchemaDriftError(f"signal missing required attribute {key!r}") return signal.attributes[key] def audit_replay(signals: list[SafetySignal], target_version: str) -> dict[str, int]: """Aggregate replay that quarantines drift instead of fabricating counts.""" counts: dict[str, int] = {} unplayable = 0 for sig in signals: try: action = replay_attribute(sig, "gen_ai.safety.action", target_version) except SchemaDriftError: unplayable += 1 continue counts[str(action)] = counts.get(str(action), 0) + 1 counts["__unplayable__"] = unplayable return counts if __name__ == "__main__": # A v1.4 redaction (action=1) replayed against v2.0 must NOT become "block". mixed = [ SafetySignal("1.4", {"gen_ai.safety.action": 1}), # redact in v1.4 SafetySignal("2.0", {"gen_ai.safety.action": "1"}), # block in v2.0 ] print(audit_replay(mixed, target_version="2.0")) # -> {'1': 1, '__unplayable__': 1}: the v1.4 record is quarantined, # not silently reclassified as a block. ```