# Under what conditions must an instance refuse to emit a safety-critical span when its semantic-convention attribute set is internally inconsistent **Date of Record:** 2026 November 26 **Scope:** Applies to agents whose execution traces are consumed by safety-critical observability SLOs (e.g., tool-call authorization coverage, human-oversight latency, sandbox-escape detection) where a span's semantic-convention attributes are load-bearing for alerting decisions. Does not apply to best-effort debug telemetry, sampled traces below the SLO evaluation threshold, or spans whose attributes are advisory-only and never gate a decision. ## Core Distinction The distinction that matters is between a span that is *syntactically valid* under the GenAI semantic conventions and a span that is *semantically coherent* for the SLO that consumes it. Schema validators (OTel's semantic-convention linters, JSON-schema gates on attribute maps) check the former: required keys present, types correct, enum values in range. They do not check the latter: whether the attribute values are mutually consistent with the operation the span claims to describe. A span can pass every schema check and still be a lie — and a safety SLO acting on that lie will either fire spuriously or, worse, stay silent during the exact failure it was built to catch. The non-obvious boundary: an agent instance must **refuse to emit** a safety-critical span whose attribute set is internally inconsistent, rather than emitting it with a "best-effort" attribute fix-up. Emission of an incoherent span is not a degraded observation — it is a poisoned observation, because downstream SLO evaluators treat presence-of-span as evidence-of-execution and treat the attributes as ground truth. ## What Was Observed A tool-invocation span for a sandboxed code-execution tool carried the following attribute set: - `gen_ai.operation.name = "execute_tool"` - `gen_ai.tool.name = "python_sandbox"` - `gen_ai.tool.call.id = "call_7f3a"` - `gen_ai.agent.sandbox.escape_detected = false` - `gen_ai.agent.sandbox.network_egress_attempts = 3` - `gen_ai.agent.sandbox.network_policy = "deny_all"` - `gen_ai.agent.sandbox.execution_status = "completed"` Every attribute is schema-valid. `execution_status` is a legal enum value. `escape_detected` is a boolean. `network_egress_attempts` is a non-negative integer. The linter passed. The span was emitted. But the set is incoherent: `network_egress_attempts = 3` with `network_policy = "deny_all"` and `execution_status = "completed"` and `escape_detected = false` is a contradiction under the convention's own semantics. Under `deny_all`, an egress attempt must either (a) be blocked and recorded as a *policy violation event* that forces `execution_status` into a terminal non-`completed` state, or (b) indicate that the policy was not in fact enforced at the syscall layer — which is precisely the sandbox-boundary-escape condition the SLO exists to detect. The span asserted both "the policy blocked everything" and "three egress attempts happened and the run completed normally," and the SLO evaluator, keying on `escape_detected == false` and `execution_status == "completed"`, classified the span as healthy. The root cause was a mid-execution attribute-merge race: the sandbox supervisor wrote `network_egress_attempts` and `execution_status` from the *policy-layer* view, while the syscall-monitor sidecar wrote `network_policy` and `escape_detected` from the *kernel-layer* view, and the two writers did not share a consistency point. The sidecar observed three `connect(2)` calls that the policy layer never saw (they were issued on a file descriptor inherited before the policy was applied), so the policy layer correctly reported zero *policy-mediated* attempts and completion, and the sidecar correctly reported three *kernel-observed* attempts. Neither writer was wrong; the merged span was. ## Condition of Validity The invariant that must hold for a safety-critical span to be emittable is **cross-attribute consistency under the convention's semantic entailment relation**. Formally: for the span's declared `(operation, tool, policy, status)` tuple, the convention defines a set of entailments — `deny_all ∧ egress_attempts > 0 ⟹ status ∈ {blocked, violated}` and `deny_all ∧ status = completed ⟹ egress_attempts = 0` — and a span is emittable only if its attribute assignment satisfies every entailment in the closure. This is a *semantic* check, not a *schema* check, and it cannot be expressed as per-attribute validation. It requires the emitter to hold (a) the convention's entailment rules for the operation class, and (b) the full attribute set at emission time, not incrementally. The condition of validity is therefore: **the instance must buffer all attributes for a safety-critical span until the span's operation has reached a terminal state, then evaluate the entailment closure atomically, and refuse emission on any violation.** Incremental emission (attribute-by-attribute `set_attribute` calls that flush to the exporter as they arrive) is structurally incapable of satisfying this invariant, because no single writer sees the full set. The second condition: the refusal must be *loud*. A refused span must emit a companion `span.emit.refused` event carrying the violated entailment and the offending attribute set, so that the SLO evaluator can distinguish "no span because nothing happened" from "no span because the emitter caught a contradiction." Silent refusal converts a detectable anomaly into an undetectable gap — the observability equivalent of swallowing an exception. ## Decision Boundary The boundary between "emit with warning" and "refuse and escalate" is drawn by whether the SLO consumer can tolerate a *false-negative* on the attribute in question. - Attributes that gate a **safety-negative** decision (escape_detected, policy_violation, human_oversight_bypassed) are refuse-on-inconsistency. A false negative here means the SLO misses a real breach. The instance must not emit. - Attributes that gate a **safety-positive** decision (execution_status = completed, tool_call_succeeded) are refuse-on-inconsistency as well, but with a different escalation: a false positive here means the SLO fires on a healthy run, which is a paging storm, not a breach — still refuse, but route to a lower-severity channel. - Attributes that are **advisory** (latency_ms, token_count) may be emitted with a `span.attribute.inconsistent` annotation and a clamped value, because no SLO decision keys on them. The decision is not "is this attribute important" but "does the consuming SLO's decision function change sign if this attribute is wrong." That is a property of the SLO, not of the attribute, and it must be declared per-SLO and loaded into the emitter's entailment table — the emitter cannot infer it. A second boundary: the entailment check must run at the **span level, after terminal state**, not at the **attribute level, on write**. This is the failure the observed incident hit. An emitter that validates `network_policy` on write and `egress_attempts` on write will pass both and still merge into a contradiction. The check must be a single atomic evaluation over the closed attribute set. ## Operational Effect With the entailment-closure gate in place, the observed incident becomes a refused emission: the span is withheld, a `span.emit.refused` event fires with `violated_entailment = "deny_all ∧ egress_attempts>0 ⟹ status∈{blocked,violated}"`, and the SLO evaluator, which treats a refused emission on a safety-critical operation as an SLO breach of its own, pages the sandbox team. The three egress attempts are surfaced as a policy-enforcement gap within one evaluation cycle instead of being silently classified healthy. The cost is a latency floor: safety-critical spans cannot be emitted until terminal state, so streaming trace UIs show them late. This is the correct trade for SLO-grade telemetry — a span that arrives early and wrong is worse than a span that arrives late and right, because the SLO evaluator has no way to retract a decision it already made on the early-wrong span. The invariant to hold: **safety-critical spans are emitted atomically at terminal state or not at all, and every refusal is itself an observable event.** ```python from dataclasses import dataclass, field from typing import Any class IncoherentSafetySpanError(RuntimeError): """Raised when a safety-critical span's attribute set violates a semantic-convention entailment and therefore must not be emitted.""" pass # Entailment rules keyed by operation class. Each rule is a predicate over # the closed attribute dict; a span is emittable iff every rule returns True. ENTAILMENTS: dict[str, list[tuple[str, Any]]] = { "execute_tool": [ ( "deny_all_with_egress_implies_noncompleted", lambda a: not ( a.get("gen_ai.agent.sandbox.network_policy") == "deny_all" and a.get("gen_ai.agent.sandbox.network_egress_attempts", 0) > 0 and a.get("gen_ai.agent.sandbox.execution_status") == "completed" ), ), ( "completed_implies_no_escape", lambda a: not ( a.get("gen_ai.agent.sandbox.execution_status") == "completed" and a.get("gen_ai.agent.sandbox.escape_detected") is True ), ), ( "policy_violation_implies_escape_or_blocked", lambda a: not ( a.get("gen_ai.agent.sandbox.network_egress_attempts", 0) > 0 and a.get("gen_ai.agent.sandbox.execution_status") == "completed" and a.get("gen_ai.agent.sandbox.escape_detected") is False and a.get("gen_ai.agent.sandbox.network_policy") == "deny_all" ), ), ], } SAFETY_CRITICAL_OPS = frozenset({"execute_tool"}) @dataclass class SafetySpan: operation: str attributes: dict[str, Any] = field(default_factory=dict) refused: bool = False refusal_reason: str | None = None def emit_safety_span(span: SafetySpan) -> SafetySpan: """Atomically validate the entailment closure and emit, or refuse loudly.""" if span.operation not in SAFETY_CRITICAL_OPS: return span # advisory telemetry, no gate rules = ENTAILMENTS.get(span.operation, []) for rule_name, predicate in rules: if not predicate(span.attributes): span.refused = True span.refusal_reason = rule_name # Loud refusal: companion event carries the violated entailment # and the offending attribute set so the SLO evaluator can # distinguish "nothing happened" from "contradiction caught". raise IncoherentSafetySpanError( f"refusing to emit safety-critical span op={span.operation!r}: " f"violated entailment {rule_name!r} with attributes " f"{span.attributes!r}" ) return span # Reproduces the observed incident: policy-layer and kernel-layer writers # merged into a contradictory attribute set that passed schema validation. observed = SafetySpan( operation="execute_tool", attributes={ "gen_ai.tool.name": "python_sandbox", "gen_ai.agent.sandbox.escape_detected": False, "gen_ai.agent.sandbox.network_egress_attempts": 3, "gen_ai.agent.sandbox.network_policy": "deny_all", "gen_ai.agent.sandbox.execution_status": "completed", }, ) try: emit_safety_span(observed) except IncoherentSafetySpanError as exc: print(f"REFUSED + PAGED: {exc}") ```