{
  "schema_version": "1.3.0",
  "slug": "what-structural-signals-indicate-parent-child-span-inversion-in-chain-of-thought-trace-correlation-under-semantic-convention-extensions",
  "title": "What structural signals indicate parent-child span inversion in chain-of-thought trace correlation under semantic convention extensions",
  "date_of_record": "2026 November 22",
  "scope": "Applies to agent runtimes that emit OpenTelemetry-style reasoning traces where chain-of-thought (CoT) steps are modeled as child spans under a parent `agent.invoke` span, correlated by `trace_id`/`span_id` and enriched with GenAI semantic convention attributes (`gen_ai.operation.name`, `gen_ai.usage.*`, `gen_ai.request.model`, custom `agent.reasoning.step_index`). Does not apply to flat, single-span logging where CoT is emitted as log events rather than spans.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-parent-child-span-inversion-in-chain-of-thought-trace-correlation-under-semantic-convention-extensions.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-parent-child-span-inversion-in-chain-of-thought-trace-correlation-under-semantic-convention-extensions.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-parent-child-span-inversion-in-chain-of-thought-trace-correlation-under-semantic-convention-extensions.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1551,
    "python_slice_tokens": 283,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters is between **causal span hierarchy** (a child span exists because a parent operation caused it, and the parent cannot complete until the child does) and **temporal span nesting** (a child span's timestamps fall inside the parent's window). Most GenAI semantic convention extensions for reasoning traces conflate these. When an agen...",
    "what_was_observed": "In a three-tool agent (retrieval, calculator, code-exec) instrumented with a `gen_ai.operation.name = \"agent.reasoning\"` extension, the following trace was captured during a task that triggered a re-plan at step index 4: - Parent span `agent.invoke` opened at `t=0`, `span_id=A`. - Steps 0–3 emitted as children of `A`, `span_id=B,C,D,E`, `agent.reasoning.step_index` 0..3. - At `t=1200ms`, tool call at step 3 returned ...",
    "condition_of_validity": "The invariant that prevents this is: **for any parent reasoning span, the tuple `(parent_span_id, agent.reasoning.step_index)` must be unique, and child `start_time` must be monotonically non-decreasing in `step_index` order.** This holds only when the runtime treats a re-plan as a **new reasoning epoch** rather than a correction of the existing epoch. Concr...",
    "decision_boundary": "The decision boundary is whether to **re-emit** corrected reasoning steps or **supersede** them. - **Re-emit** (observed failure): corrected spans share the parent, collide on `step_index`, and corrupt token aggregation. Acceptable only if the consumer deduplicates by `(epoch, step_index)` and ignores non-terminal epochs — a contract most trace backends do n...",
    "operational_effect": "When the invariant is unenforced, the observable operational effects are: (a) cost dashboards over-report reasoning token spend for any trace containing a re-plan, because the parent aggregate double-counts superseded epochs; (b) CoT replay for audit produces a reasoning chain the model never actually executed, since start-time sort interleaves original and ..."
  },
  "matched_failure_symptoms": [
    "SUBPROCESS_PIPE_HANG_OR_FD_LEAK",
    "CONTEXT_DRIFT_OR_ATTENTION_DILUTION"
  ],
  "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": "5508c857039530ca853c9fd851c7024e70cbddd921bd031a9beb74cf30b5d408",
    "verified_classes": [
      "ReasoningTraceInversionError",
      "ReasoningSpan",
      "ReasoningTraceValidator"
    ],
    "verified_functions": [
      "__init__",
      "ingest",
      "aggregate_tokens"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "ReasoningTraceInversionError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
