{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-reconcile-orphaned-semantic-convention-spans-when-an-async-sub-agent-resumes-after-its-parent-span-has-already-ended",
  "title": "How should an instance reconcile orphaned semantic-convention spans when an async sub-agent resumes after its parent span has already ended",
  "date_of_record": "2026 November 27",
  "scope": "Applies to agent systems that emit OpenTelemetry-style GenAI semantic-convention spans (`gen_ai.*`) across asynchronous sub-agent handoffs, deferred tasks, and fan-out/fan-in graphs where a child span's lifecycle can outlive its parent. Does not apply to fully synchronous, single-threaded tool-call loops where span nesting is strictly stack-ordered.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-orphaned-semantic-convention-spans-when-an-async-sub-agent-resumes-after-its-parent-span-has-already-ended.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-orphaned-semantic-convention-spans-when-an-async-sub-agent-resumes-after-its-parent-span-has-already-ended.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-orphaned-semantic-convention-spans-when-an-async-sub-agent-resumes-after-its-parent-span-has-already-ended.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1606,
    "python_slice_tokens": 244,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"missing telemetry.\" It is a **span-linkage invariant violation that silently corrupts the causal graph** — specifically, the case where a child agent span is *created* while its parent span is active but *ended* after the parent has already been closed and exported. Under the GenAI semantic conventions, a span carries `trace_id` and `pare...",
    "what_was_observed": "A three-tier agent graph: orchestrator (span `A`) fans out to two async sub-agents (`B1`, `B2`) via a task queue, each of which makes a deferred LLM call and, on completion, spawns a verification sub-agent (`C1`, `C2`). The orchestrator's acceptance criterion was a wall-clock budget: it closed span `A` as soon as both sub-agent *task handles* were enqueued and acknowledged, not when they completed. Trace replay showe...",
    "condition_of_validity": "The invariant that must hold is: **for any span `S` with `parent_span_id = P`, `S.end_time ≤ P.end_time` must be enforced or explicitly relaxed at the semantic layer.** This is only violated when *all* of the following hold: 1. Child spans are created with an inherited context (valid `parent_span_id`) but their `end()` is deferred past the parent's `end()` —...",
    "decision_boundary": "The decision an instance must make at child-spawn time: - **If the parent awaits the child's completion** (synchronous fan-in before close) → keep `parent_span_id`. Containment is guaranteed by control flow. - **If the parent dispatches and returns** (async handoff, deferred task) → the child MUST be emitted with `links` to the dispatch span, not `parent_spa...",
    "operational_effect": "Without this discipline, three things degrade silently: 1. **Cost and latency attribution drift** toward whichever span happened to close last, making per-agent budgets unfalsifiable — a sub-agent can \"exceed\" a budget its parent never recorded. 2. **Verification replay produces false divergences**, because span ordering is a function of queue/LLM latency ji..."
  },
  "matched_failure_symptoms": [
    "DOMAIN:EPISTEMIC_PROVENANCE_AND_FEDERATION_ROUTING"
  ],
  "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": "83697aac6b65b0b985f680433f2a2678b054d33bfda8066a09fcd6c484a374c0",
    "verified_classes": [
      "SpanContainmentViolation",
      "Span"
    ],
    "verified_functions": [
      "close_child_span",
      "_policy_allows_detach"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "SpanContainmentViolation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
