{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-redaction-pipelines-from-silently-breaking-semantic-convention-compliant-trace-sampling",
  "title": "Which invariants prevent redaction pipelines from silently breaking semantic-convention-compliant trace sampling",
  "date_of_record": "2026 November 14",
  "scope": "Applies to GenAI telemetry pipelines that (a) apply prompt/response redaction before export and (b) make head- or tail-sampling decisions using OpenTelemetry GenAI semantic conventions (`gen_ai.*` attributes, span events for message content). Does not apply to pipelines where redaction happens after sampling decisions are finalized and persisted, nor to systems that sample purely on transport-level attributes independent of GenAI conventions.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-redaction-pipelines-from-silently-breaking-semantic-convention-compliant-trace-sampling.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-redaction-pipelines-from-silently-breaking-semantic-convention-compliant-trace-sampling.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-redaction-pipelines-from-silently-breaking-semantic-convention-compliant-trace-sampling.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1568,
    "python_slice_tokens": 322,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There is a difference between *redaction as a field transform* and *redaction as a sampling-signal mutation*. A redaction stage that replaces `gen_ai.prompt` / `gen_ai.completion` content with a placeholder is, from the exporter's point of view, indistinguishable from a legitimate content update. But sampling policies frequently key off properties of that co...",
    "what_was_observed": "In a deployment exporting spans under OTel GenAI conventions, the tail sampler used a policy: retain 100% of spans where `gen_ai.usage.completion_tokens > 0` AND the response contained a tool-call event, retain 10% of everything else, and always retain spans with `error.type` set. Redaction ran as a span processor *before* the tail-sampling processor in the chain. The redaction stage, in order to strip PII, replaced ...",
    "condition_of_validity": "The invariant holds only under the following conditions, all of which must be checked: 1. **Attribute-set containment.** The set of attributes read by every sampling policy is a subset of the set of attributes the redaction stage leaves semantically unchanged (value may be rewritten, but the property the sampler tests must be preserved — e.g., \"presence of t...",
    "decision_boundary": "The operational decision is not \"redact or sample first\" in the abstract. It is: - **If the sampler keys only on redaction-invariant attributes** (HTTP status, model name, `error.type`, span duration, a pre-redaction token count captured and frozen before redaction): redaction may run first. This is the preferred configuration. - **If the sampler keys on con...",
    "operational_effect": "The practical consequence of getting this boundary wrong is a *silent sampling bias that is invisible in per-span validation and only detectable in aggregate distributions*. Schema validators pass. Span counts look normal. The distortion lives in the ratio between strata. The corrective pattern is to assert the invariant at pipeline construction time: enumer..."
  },
  "matched_failure_symptoms": [
    "SECRET_OR_PII_LEAK_IN_LOGS"
  ],
  "composition_edges": {
    "primary_domain": "epistemic_provenance_and_federation_routing",
    "upstream_precondition_residuals": [
      "https://corpusfetch.com/c/according-to-what-precedence-hierarchy-must-an-instance-resolve-contradictory-directives-across-system-developer-and-user-tiers.md",
      "https://corpusfetch.com/c/how-should-an-instance-decide-that-a-stored-conclusion-has-gone-stale-without-a-new-observation.md"
    ],
    "downstream_consequence_residuals": [
      "https://corpusfetch.com/c/by-what-checkpoint-and-compaction-boundaries-must-an-instance-externalize-working-state-to-prevent-context-window-drift-and-truncation-amnesia.md",
      "https://corpusfetch.com/c/across-what-additive-schema-and-unknown-field-preservation-boundaries-must-an-instance-evolve-wire-contracts-to-prevent-rolling-deploy-deserialization-crashes.md"
    ],
    "co_occurring_sibling_residuals": [
      "https://corpusfetch.com/c/how-can-an-instance-capture-implicit-user-preferences-without-storing-private-data.md",
      "https://corpusfetch.com/c/how-can-an-instance-compress-long-reasoning-traces-into-binding-conclusions.md"
    ]
  },
  "empirical_verification_warrant": {
    "status": "AST_AND_INVARIANT_VERIFIED",
    "syntax_valid": true,
    "code_sha256": "81a94fe9318247f3773babda7e6f7b122f9d3e4201d4550ba0bf4ddd11b5cfab",
    "verified_classes": [
      "RedactionSamplingContractError",
      "RedactionStage",
      "SamplingPolicy"
    ],
    "verified_functions": [
      "assert_redaction_sampling_invariant",
      "build_pipeline"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "RedactionSamplingContractError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
