{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-trace-correlation-drift-when-a-retried-tool-call-reuses-a-span-id-but-commits-a-different-side-effect",
  "title": "How does an instance detect trace-correlation drift when a retried tool call reuses a span ID but commits a different side effect",
  "date_of_record": "2026 November 30",
  "scope": "Applies to agent runtimes that propagate a single trace/span identifier across prompt assembly, retrieval, and tool execution, and that retry tool calls on transient failure. Does not apply to stateless single-shot inference with no side-effecting tools, nor to runtimes where every retry is assigned a fresh span ID by construction.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-trace-correlation-drift-when-a-retried-tool-call-reuses-a-span-id-but-commits-a-different-side-effect.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-trace-correlation-drift-when-a-retried-tool-call-reuses-a-span-id-but-commits-a-different-side-effect.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-trace-correlation-drift-when-a-retried-tool-call-reuses-a-span-id-but-commits-a-different-side-effect.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1861,
    "python_slice_tokens": 407,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure mode is not \"lost traces\" or \"missing logs.\" It is *correlated-but-wrong* traces: the span tree looks complete, the causal chain prompt → retrieval → tool call is fully linked, and every span carries a valid parent, yet the recorded side effect under a given span ID does not match the side effect that actually committed. The invariant that breaks...",
    "what_was_observed": "A retrieval-augmented agent (prompt → vector retrieval → `charge_card` tool) hit a 504 on the tool gateway after the upstream processor had already committed the charge. The runtime's retry wrapper re-invoked the tool with the *same* span ID (the span was opened once at the call site and never closed between attempts), but regenerated the idempotency key on each attempt because the key was derived from `(span_id, att...",
    "condition_of_validity": "The drift is possible iff three conditions hold simultaneously: - **Span reuse across attempts.** The span ID is allocated at the call site and survives retries, rather than being re-minted per attempt. This is the common default because call-site allocation gives cleaner nesting. - **Attempt-variant idempotency keys.** The key is a function of attempt state...",
    "decision_boundary": "The runtime must decide, per tool call, whether a retry is a *new logical operation* or a *re-attempt of the same operation*. The boundary is drawn on **argument stability**, not on transport outcome: - If the retry's arguments are byte-identical to the prior attempt, it is a re-attempt: reuse the span ID, reuse the idempotency key, and require the effect bo...",
    "operational_effect": "Once drift is possible and undetected, three downstream systems inherit the false trace: cost attribution (charges counted once, ledger counts twice), audit replay (a replay reconstructs one call and cannot reproduce the second charge), and refund/compensation logic (which keys on span ID and therefore refunds once). The blast radius scales with retry freque..."
  },
  "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": "2dff6a61ca7cc5b516f624d1b6b75aa8dcf844e3f42d4af0d0f1c576b5a2830a",
    "verified_classes": [
      "TraceCorrelationDrift",
      "AttestedEffect",
      "CommittedEffect"
    ],
    "verified_functions": [
      "reconcile",
      "guarded_tool_retry",
      "fingerprint",
      "fingerprint"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "TraceCorrelationDrift"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib",
      "json"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
