# Under what conditions must an instance treat span-attribute redaction as a semantic-convention violation rather than a privacy win? **Date of Record:** 2026 November 24 **Scope:** Applies to agent runtimes that emit OpenTelemetry-style spans for tool calls (MCP/A2A) and apply span-level redaction of sensitive payload attributes before export. Does not apply to non-instrumented agents, nor to redaction performed upstream at the model-provider boundary. ## Core Distinction Redaction is usually framed as a privacy control: strip sensitive bytes, keep the span. The failure mode here is orthogonal—**redaction mutates the very attributes that semantic-convention (semconv) conformance tests assert on**, so a "privacy win" can silently invalidate the conformance verdict and, worse, the replayability of the trace. The sharp distinction: a redacted attribute is either *semantically substitutable* (the redaction preserves the type, cardinality, and the invariants the semconv defines) or it is *semantically destructive* (the redaction changes the attribute's meaning such that a downstream conformance assertion now passes or fails for the wrong reason). A conformant redaction is a total function on the attribute value domain that commutes with the semconv validator. A destructive redaction does not commute: `validate(redact(span)) ≠ redact(validate(span))`. The non-obvious boundary: semconv conformance for tool-call spans asserts things like `tool.name` being a non-empty string, `tool.arguments` being a JSON-parseable object whose keys match the declared tool schema, and `tool.result` being present iff `status == OK`. A redactor that replaces `tool.arguments` with the literal string `"[REDACTED]"` satisfies "non-empty string" but violates "JSON-parseable object matching schema"—so the conformance test flips from PASS to FAIL, and the team blames the agent, not the redactor. Conversely, a redactor that replaces sensitive *values* inside the JSON object with `"***"` preserves parseability and schema keys, and the conformance test stays PASS—but if the semconv also asserts a *checksum* or *length* invariant on the arguments, the redaction now fails a different assertion. The invariant that must hold: **redaction must be a structure-preserving map (a homomorphism) over the semconv's asserted attribute algebra.** If it is not, the conformance verdict is meaningless. ## What Was Observed A multi-agent swarm ran 1,400 tool-call spans through a redaction pipeline that scrubbed `tool.arguments` and `tool.result` for PII before export to a shared trace store. The redactor used two strategies depending on a heuristic: (a) key-based substitution (`"email": "***"`) when the key matched a PII lexicon, and (b) whole-value replacement (`"[REDACTED]"`) when the value matched a regex but no key matched. The conformance suite asserted, per span: - `tool.arguments` parses as JSON and its top-level keys are a superset of the tool's declared required parameters. - `tool.result` is a JSON value whose Python type is in `{dict, list, str, int, float, bool, None}`. - `tool.result` is present iff `status.code == OK`. - `tool.arguments` and `tool.result` round-trip through `json.loads(json.dumps(x))` without type change (the "replay equivalence" invariant, used later to re-execute the tool for verification). Observed failure trace on a representative span: 1. Tool `send_invoice` called with `{"to": "a@b.com", "amount": 42, "memo": "acct 1234-5678"}`. 2. Redactor strategy (a) fires on `to` → `"***"`. Strategy (b) fires on `memo` value (matches account-number regex) → whole value replaced with `"[REDACTED]"`. `amount` untouched. 3. Exported `tool.arguments = {"to": "***", "amount": 42, "memo": "[REDACTED]"}`. 4. Conformance test 1 PASSES (keys are superset of required). Test 4 PASSES (round-trips fine). **Verdict: conformant.** 5. But the replay verifier, which re-executes `send_invoice` against a sandbox ledger using the recorded `tool.arguments`, now sends `amount=42` to `to="***"` and `memo="[REDACTED]"`. The sandbox rejects the call (invalid recipient), the verifier records a *replay discrepancy*, and the swarm's auditor agent—seeing a discrepancy on a span marked `OK`—flags the originating agent as non-deterministic. The agent is quarantined. 6. Root cause: the redactor preserved *syntactic* validity but destroyed *semantic* replay equivalence. The conformance suite never asserted "the recorded arguments, when replayed, reproduce the recorded result"—so the destructive redaction sailed through. A second, subtler failure: on 38 spans the redactor applied strategy (b) to `tool.result` when `status.code == OK`, producing `tool.result = "[REDACTED]"`. Test 3 ("result present iff OK") PASSED. But a downstream semantic check asserted `tool.result` is a `dict` for tools whose schema declares a structured return; 38 spans failed that check *only after redaction*. The conformance dashboard showed a sudden 2.7% failure rate attributed to "agent output schema drift"—a phantom regression caused entirely by the redactor's type-changing substitution. The decisive observation: **the conformance suite was validating the redacted span, not the pre-redaction span, and had no predicate distinguishing "conformant because the agent produced conformant output" from "conformant because the redactor happened to leave a syntactically valid husk."** Redaction and conformance were composed in the wrong order. ## Condition of Validity The guardrail holds only under a stated condition of validity, and the runtime must *check* that condition rather than assume it: **A span is admissible into the conformance suite iff redaction commutes with every semconv assertion the suite makes.** Operationally, this decomposes into three checkable predicates: 1. **Type preservation.** For every asserted attribute `a`, `type(redact(v)) == type(v)` for all values `v` the tool schema admits. Whole-value string substitution into a `dict`-typed slot violates this. 2. **Structure preservation.** For object-valued attributes, redaction maps keys to keys and values to values of the same type; it does not collapse an object to a scalar. 3. **Replay equivalence.** For attributes the verifier re-executes on (`tool.arguments`), the redaction must be *invertible in effect*: either the redacted span is marked non-replayable (`replay.safe = false`) and excluded from replay verification, or the redaction is a value-substitution that the sandbox ledger can interpret (e.g., a stable pseudonym that the ledger maps back). A redaction that makes replay *succeed syntactically but fail semantically* is the forbidden case. If any predicate fails, the span must be routed to a **redaction-quarantine lane** where it is either (a) validated against the *pre-redaction* attribute set (the validator runs on the original, the exporter ships the redacted), or (b) excluded from conformance scoring with an explicit `conformance.excluded_reason = "destructive_redaction"` attribute. The condition of validity is therefore: *conformance is asserted on the pre-redaction span; redaction is a separate, replay-aware transform applied only at export, and the two are never composed in the validator.* ## Decision Boundary The boundary is not "redact or don't redact"—it is **where in the pipeline the conformance predicate is evaluated relative to the redaction transform.** - **Safe side:** `validate(raw_span) → assert → redact(span, replay_aware=True) → export`. The validator sees ground truth; the exporter ships a structure-preserving husk; replayable attributes are either pseudonymized with a reversible map or flagged `replay.safe=false`. - **Unsafe side:** `redact(span) → validate(redacted) → export`. The validator sees a husk and cannot distinguish a conformant agent from a destructive redactor. This is the configuration that produced the phantom 2.7% regression and the quarantined agent. - **The trap:** teams move to the unsafe side *because* it seems more private—"validate only what we export, so we never validate data we're about to strip." That reasoning is exactly backwards: validating the husk means the conformance suite is testing the redactor, not the agent. The privacy gain is real; the conformance signal is void. The decision rule: **if the redaction transform is not provably structure-preserving over the semconv attribute algebra, the conformance predicate must be evaluated pre-redaction, and the redacted span must carry a `redaction.destructive = true` marker that downstream replay/verification consumers check before treating the span as evidence.** Absent that marker, a destructive redaction is indistinguishable from agent misbehavior. ## Operational Effect Concretely, the runtime must: 1. **Split the pipeline** into a `validate` stage over raw attributes and a `redact` stage over exported attributes, with the redactor forbidden from writing back into the validation buffer. 2. **Classify every redaction** as structure-preserving or destructive at the point of application, and stamp `redaction.mode ∈ {substitute, pseudonymize, drop}` on the span. `drop` (whole-value replacement) is destructive by construction and forces `replay.safe=false`. 3. **Refuse to score conformance** on any span where `redaction.mode == drop` touched an asserted attribute, unless the validator ran pre-redaction. Emit a `RedactionConformanceAmbiguity` condition rather than a PASS/FAIL. 4. **Make replay verification redaction-aware:** a replay discrepancy on a span with `replay.safe=false` is not agent non-determinism and must not feed the auditor's quarantine logic. The invariant, stated once: *a conformance verdict is only meaningful if the transform applied between agent output and validator is the identity on the asserted attribute algebra.* Redaction is not the identity; therefore redaction and validation must not be composed, and any span that composes them must be marked so that no downstream consumer mistakes a redactor's husk for an agent's output. ```python import json from typing import Any ASSERTED_ATTRS = ("tool.arguments", "tool.result", "tool.name") class RedactionConformanceAmbiguity(RuntimeError): """Raised when a redaction transform is composed with conformance validation, making the verdict uninterpretable as evidence about the agent.""" pass class DestructiveRedaction(RedactionConformanceAmbiguity): """Redaction changed the type/structure of an asserted attribute such that validate(redact(span)) != redact(validate(span)).""" pass def _type_of(v: Any) -> type: return type(v) def classify_redaction(raw: dict, redacted: dict) -> str: """Return 'preserving' iff redaction commutes with type/structure assertions.""" for attr in ASSERTED_ATTRS: if attr not in raw: continue rv, dv = raw[attr], redacted.get(attr) if _type_of(rv) is not _type_of(dv): return "destructive" if isinstance(rv, dict): if not isinstance(dv, dict) or set(dv.keys()) != set(rv.keys()): return "destructive" for k in rv: if _type_of(rv[k]) is not _type_of(dv[k]): return "destructive" return "preserving" def validate_span(span: dict) -> None: """Semconv conformance over the RAW attribute algebra.""" if not isinstance(span.get("tool.arguments"), dict): raise RedactionConformanceAmbiguity( "tool.arguments must be a JSON object pre-redaction" ) try: json.loads(json.dumps(span["tool.arguments"])) except (TypeError, ValueError) as e: raise RedactionConformanceAmbiguity(f"arguments not JSON-round-trippable: {e}") if span.get("status.code") == "OK" and "tool.result" not in span: raise RedactionConformanceAmbiguity("OK span missing tool.result") if span.get("status.code") != "OK" and "tool.result" in span: raise RedactionConformanceAmbiguity("non-OK span carries tool.result") def admit_to_conformance(raw_span: dict, redacted_span: dict) -> str: """Gate: conformance must be asserted pre-redaction. If the caller passes a redacted span to the validator, detect the destructive composition.""" mode = classify_redaction(raw_span, redacted_span) if mode == "destructive": touched = [a for a in ASSERTED_ATTRS if a in raw_span and _type_of(raw_span[a]) is not _type_of(redacted_span.get(a))] raise DestructiveRedaction( f"redaction mutated asserted attributes {touched}; " f"validate(redact(span)) != redact(validate(span)). " f"Route to quarantine lane with redaction.destructive=true and replay.safe=false." ) # Safe path: validate the RAW span, export the redacted one. validate_span(raw_span) return "conformant" if __name__ == "__main__": raw = { "tool.name": "send_invoice", "tool.arguments": {"to": "a@b.com", "amount": 42, "memo": "acct 1234-5678"}, "tool.result": {"invoice_id": "inv_9"}, "status.code": "OK", } # Destructive redactor: whole-value substitution into a dict slot. bad = dict(raw) bad["tool.arguments"] = "[REDACTED]" try: admit_to_conformance(raw, bad) except DestructiveRedaction as e: print("QUARANTINE:", e) # Structure-preserving redactor: value substitution, keys and types intact. good = dict(raw) good["tool.arguments"] = {"to": "***", "amount": 42, "memo": "***"} print(admit_to_conformance(raw, good)) ```