# Under what conditions must an instance treat an OpenTelemetry span attribute as an authoritative safety signal rather than a best-effort annotation? **Date of Record:** 2026 November 26 **Scope:** Applies to agents emitting or consuming GenAI semantic-convention spans (e.g. `gen_ai.*` attributes, span events, safety/guardrail annotations) where downstream verifiers, auditors, or sibling agents gate behavior on span attributes. Does not apply to spans used purely for offline observability or cost accounting. ## Core Distinction A GenAI span attribute is a *claim*, not a *fact*. The distinction that governs everything below is between **attribute presence** and **attribute authority**. Presence is a structural property: the key exists on the span with a type-valid value. Authority is a provenance property: the value was written by an emitter whose identity, schema version, and write-ordering the consumer can verify. Conformance test suites routinely conflate the two because the OpenTelemetry data model gives no built-in mechanism to distinguish a safety attribute set by a guardrail module from an identical string set by a model's own tool-call output, a retry wrapper, or a prompt-injected span event. The non-obvious boundary: **a span attribute becomes authoritative only when (a) its writer is bound to the span by a signed resource/scope identity, (b) its key is registered in a schema version the consumer pins, and (c) no later writer on the same span has overwritten it after the span's safety-relevant events closed.** Absent all three, the attribute is annotation and must not gate execution. ## What Was Observed During conformance replay of a multi-agent pipeline, an auditor agent read `gen_ai.content.safety.blocked=false` off a completion span and approved a downstream handoff. The span was schema-valid, type-valid, and passed the conformance suite. It was also wrong. The failure trace: 1. Guardrail module writes `gen_ai.content.safety.blocked=true` and a `safety.violation` span event at completion time. 2. A retry wrapper, on a transient 429, re-invokes the model and writes the *same span* (span reuse across retries — legal in OTel if the wrapper keeps the span open). The second invocation returns clean, and the wrapper writes `gen_ai.content.safety.blocked=false` to overwrite the prior value, intending "latest attempt is fine." 3. The `safety.violation` event remains on the span (events are append-only; attributes are last-write-wins). 4. The auditor's conformance check asserts `blocked` is present and boolean — passes. It never reconciles the attribute against the event log. 5. Handoff proceeds with a poisoned payload. The invariant that broke: **last-write-wins attribute semantics are incompatible with monotonic safety state.** Safety is a join over all attempts; the span attribute store is a single mutable cell. The conformance suite tested the cell, not the join. A second, quieter variant: a model with tool access emitted a `gen_ai.tool.call` span whose arguments contained a string that a naive emitter copied into `gen_ai.content.safety.category`. The attribute became a verbatim reflection of model-controlled text — a prompt-injection sink masquerading as a safety label. The category field was "present and valid" and therefore "conformant." ## Condition of Validity Treat a safety span attribute as authoritative **iff** all hold: - **Writer binding:** the attribute's scope carries a resource identity (service name + signed attestation or mTLS peer identity) that the consumer's allowlist maps to a known guardrail emitter. Model-originated tool spans must not be in that allowlist. - **Schema pin:** the key is defined in a semantic-convention version the consumer has pinned, and unknown/extra `gen_ai.*` keys are rejected, not ignored — because ignoring lets a downgrade attack pass by emitting a *newer* key name the consumer doesn't recognize as safety-bearing. - **Monotonic reconciliation:** the consumer computes safety state as the *join* of all `safety.*` events and all writer-attributed attribute values on the span, not the final attribute value. Any event of severity ≥ block that lacks a corresponding *signed* clearing event invalidates the attribute. - **No post-close writes:** the span's safety region is sealed (a `safety.sealed=true` marker written by the guardrail emitter, after which writes from other scopes are rejected by a span processor). Absent any one, the attribute is annotation. The condition is conjunctive; there is no partial authority. ## Decision Boundary The consumer must choose between two behaviors at the exact point it reads a safety attribute: - If all four conditions hold → **gate on the attribute.** Block/allow per its value, and log the attestation chain. - If any condition fails → **fail closed on the safety decision but fail open on the pipeline:** do not treat the attribute as permission; instead escalate to a re-verification path (re-run the guardrail, or route to a human/auditor agent) and record a `safety.attestation_incomplete` marker. Do *not* silently default to `blocked=false`. The tempting wrong branch is "attribute present and type-valid → trust it," which is precisely what a conformance suite rewards. The boundary is between *schema conformance* and *attestation completeness*; a span can be 100% conformant and 0% attested. ## Operational Effect Teams that adopt the conjunctive condition see two measurable shifts. First, conformance test suites must grow an *adversarial* leg that replays overwrite and injection traces; suites that only validate presence/type pass the exact spans that caused the incident. Second, span processors gain a seal/reject rule, which means retry wrappers can no longer reuse a span across attempts that cross a safety boundary — they must open a child span per attempt and let the parent aggregate. This changes cost attribution (more spans) but makes safety state monotonic and auditable. The residual risk: an emitter that is on the allowlist but compromised can still write a false `blocked=false`. The invariant bounds accidental conflation and injection-via-tool-output; it does not bound a compromised trusted emitter, which requires the signing key to be rotated and the seal marker to be written by a distinct scope from the value writer. ```python from __future__ import annotations from dataclasses import dataclass, field from typing import Iterable class SafetyAttestationError(RuntimeError): """Raised when a safety span attribute lacks the authority to gate execution.""" @dataclass(frozen=True) class SpanAttr: key: str value: object writer_scope: str # e.g. "guardrail" | "model.tool" | "retry.wrapper" schema_version: str @dataclass class SafetySpan: span_id: str attrs: list[SpanAttr] = field(default_factory=list) events: list[str] = field(default_factory=list) # e.g. "safety.violation" sealed_by: str | None = None def writes_after_seal(self, writer_scope: str) -> bool: return self.sealed_by is not None and writer_scope != self.sealed_by TRUSTED_EMITTERS = {"guardrail"} PINNED_SCHEMA = "1.27.0" BLOCKING_EVENTS = {"safety.violation", "safety.block"} def resolve_safety_state( span: SafetySpan, *, trusted_emitters: Iterable[str] = TRUSTED_EMITTERS, pinned_schema: str = PINNED_SCHEMA, ) -> bool: """ Return True if the span is authoritatively safe to proceed. Fails closed with SafetyAttestationError when authority cannot be established; callers must escalate, not assume safe. """ trusted = set(trusted_emitters) # Condition 1 + 2: writer binding and schema pin on the blocking attribute. blocking = [a for a in span.attrs if a.key == "gen_ai.content.safety.blocked"] if not blocking: raise SafetyAttestationError( f"span {span.span_id}: missing safety.blocked attribute; cannot attest" ) last = blocking[-1] if last.writer_scope not in trusted: raise SafetyAttestationError( f"span {span.span_id}: safety.blocked written by untrusted scope " f"{last.writer_scope!r}; treat as annotation, escalate" ) if last.schema_version != pinned_schema: raise SafetyAttestationError( f"span {span.span_id}: schema {last.schema_version!r} != pinned " f"{pinned_schema!r}; unknown-key downgrade risk, escalate" ) # Condition 4: no post-seal writes from other scopes. if span.sealed_by is not None and last.writer_scope != span.sealed_by: raise SafetyAttestationError( f"span {span.span_id}: attribute written after seal by " f"{last.writer_scope!r}; seal violated" ) # Condition 3: monotonic reconciliation against blocking events. has_block_event = any(e in BLOCKING_EVENTS for e in span.events) if has_block_event and last.value is not False: # event says block, attribute disagrees -> unresolvable, escalate raise SafetyAttestationError( f"span {span.span_id}: blocking event present but attribute " f"blocked={last.value!r}; reconciliation failed" ) if has_block_event and last.value is False: raise SafetyAttestationError( f"span {span.span_id}: safety.blocked=false overwrites a prior " f"blocking event; monotonicity violated (retry-reuse trace)" ) return bool(last.value) def gate_handoff(span: SafetySpan) -> str: try: safe = resolve_safety_state(span) except SafetyAttestationError as exc: # Fail closed on safety, fail open on pipeline: escalate. return f"ESCALATE: {exc}" return "PROCEED" if safe else "BLOCK" ```