{
  "schema_version": "1.3.0",
  "slug": "what-structural-signals-indicate-span-tree-collapse-when-memory-read-spans-are-reparented-across-async-agent-turns",
  "title": "What structural signals indicate span-tree collapse when memory-read spans are reparented across async agent turns",
  "date_of_record": "2026 November 24",
  "scope": "Applies to distributed-tracing observability pipelines instrumenting LLM agent runtimes where memory operations (vector reads, episodic writes, KV-cache hydration) are emitted as spans and joined to prompt/tool spans via propagated trace context. Does not apply to single-process, synchronous, single-turn inference where the trace tree has no cross-task reparenting.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-span-tree-collapse-when-memory-read-spans-are-reparented-across-async-agent-turns.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-span-tree-collapse-when-memory-read-spans-are-reparented-across-async-agent-turns.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-span-tree-collapse-when-memory-read-spans-are-reparented-across-async-agent-turns.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2003,
    "python_slice_tokens": 294,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"a missing span.\" A missing span is loud: the parent's child count drops, the trace validator flags an orphan, and the dashboard shows a gap. The failure here is **silent reparenting**: a memory-read span that logically belongs to turn *N* of agent task *T* is emitted with a trace context whose `parent_span_id` resolves to a *different* sp...",
    "what_was_observed": "A multi-turn agent executing a tool-use loop emitted, per turn, a `prompt.render` span (parent = turn span), one or more `tool.call` spans (parent = turn span), and a `memory.retrieve` span. The memory client used `asyncio` and, on a cache miss, dispatched the embedding + vector query to a `ThreadPoolExecutor`. The tracing integration propagated context via a `contextvars` copy taken at executor submission time. Unde...",
    "condition_of_validity": "The invariant holds only when the following are simultaneously true, and the guardrail is only sound under these conditions: - **Context propagation is snapshot-at-submit, not snapshot-at-execute.** The bug requires that the tracing context be captured when a task is *queued* rather than when it *runs*. If your integration re-reads ambient context at executi...",
    "decision_boundary": "The boundary is **whether to trust the tree or the attributes when they disagree.** A mis-parented span is a legal tree node; therefore the tree is not authoritative for causality. The decision rule: - If `parent.turn_index != span.turn_index` for a memory/tool span → **quarantine the span from cost aggregation and flag the trace as causally-degraded.** Do n...",
    "operational_effect": "Without the guardrail, the pipeline produces a trace that passes every structural check while systematically mis-attributing memory latency and retrieved-context cost to the preceding turn. Downstream effects compound: per-turn cost dashboards drift toward the earlier turn, so a memory-heavy turn *N* looks cheap and its predecessor looks expensive; a regress..."
  },
  "matched_failure_symptoms": [
    "OOM_KILL_OR_MEMORY_EXHAUSTION"
  ],
  "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": "656ebc6a71e157da3b0b7fd4937f3975c9118dbdc0c3e1dc78c89a4166d7e2d4",
    "verified_classes": [
      "SpanAttributionError"
    ],
    "verified_functions": [
      "reconcile_turn"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "SpanAttributionError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
