{
  "schema_version": "1.3.0",
  "slug": "where-must-an-instance-refuse-to-emit-a-genai-child-span-when-its-parent-trace-context-has-already-been-sampled-out-by-the-collector",
  "title": "Where must an instance refuse to emit a GenAI child span when its parent trace context has already been sampled out by the collector",
  "date_of_record": "2026 November 28",
  "scope": "Applies to LLM agent runtimes that emit OpenTelemetry GenAI spans (`gen_ai.*` attributes) for tool calls and token accounting under a head-sampling policy decided upstream (SDK sampler or collector tail-sampling). Does not apply to fully unsampled pipelines where no parent decision exists, nor to metrics-only instrumentation that bypasses the trace tree.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/where-must-an-instance-refuse-to-emit-a-genai-child-span-when-its-parent-trace-context-has-already-been-sampled-out-by-the-collector.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-refuse-to-emit-a-genai-child-span-when-its-parent-trace-context-has-already-been-sampled-out-by-the-collector.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-refuse-to-emit-a-genai-child-span-when-its-parent-trace-context-has-already-been-sampled-out-by-the-collector.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2323,
    "python_slice_tokens": 380,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure here is not \"spans are dropped.\" The failure is a **partial-tree emission** where the agent runtime emits a `gen_ai.*` child span whose parent span was sampled out, producing an orphan span that carries token counts and tool-call attributes but no causal parent. Downstream cost accounting and tool-replay reconstruction both read these orphans as ...",
    "what_was_observed": "A tool-using agent (planner → 3 parallel tool calls → synthesizer) ran under a collector tail-sampling policy that keeps 10% of traces, keyed on `gen_ai.operation.name`. During a 6-hour soak: 1. The planner span was sampled out (root decision `Drop`). 2. Two of three tool-call child spans were emitted with `trace_id` equal to the planner's (correct) but `parent_span_id` pointing at a **span that the collector never r...",
    "condition_of_validity": "The invariant that must hold for GenAI span emission to be sound: > **A `gen_ai.*` child span is emitted only if its `SpanContext` is valid AND its parent `SpanContext` is either (a) locally recorded in the same `TracerProvider`, or (b) explicitly marked as a remote parent via `SpanContext.is_remote == True` with a propagated `traceparent` that the receiving...",
    "decision_boundary": "The runtime must make a **binary decision at span-start time**, before any `gen_ai.*` attribute is set: - **Emit** if: parent `SpanContext` is valid and (`is_remote == True` with a non-zero `traceparent` flag, OR parent is locally recorded and `Sampled == RecordAndSample`). - **Emit-with-link** if: parent is valid but `Sampled == Drop`, AND the runtime can r...",
    "operational_effect": "With the decision boundary enforced: - **Token accounting reconciles.** The histogram `gen_ai.client.token.usage` and the span tree agree, because suppressed spans contribute to the metric counter and linked spans carry `gen_ai.parent_sampled = false` so the accounting layer knows not to attribute them to a new root. - **Tool-call counts stop inflating.** Th..."
  },
  "matched_failure_symptoms": [
    "SUBPROCESS_PIPE_HANG_OR_FD_LEAK"
  ],
  "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": "dcc9c37feb102371d96a4c76aa68d7817b0d32e26edccea9929caabc16ef8ab0",
    "verified_classes": [
      "GenAISpanEmissionError",
      "SpanContextRef"
    ],
    "verified_functions": [
      "decide_genai_span_emission",
      "emit_genai_span"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "GenAISpanEmissionError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
