{
  "schema_version": "1.3.0",
  "slug": "why-does-an-instance-s-per-turn-cost-attribution-silently-drift-when-a-multi-turn-trajectory-is-replayed-from-a-mid-conversation-checkpoint",
  "title": "Why does an instance's per-turn cost attribution silently drift when a multi-turn trajectory is replayed from a mid-conversation checkpoint",
  "date_of_record": "2026 November 25",
  "scope": "Applies to GenAI observability pipelines that attribute token/cost metrics to individual turns of a multi-turn agent trajectory by reconstructing turns from a persisted checkpoint plus a partial event log. Does not apply to single-turn inference, nor to systems that persist the full turn ledger atomically with each model call.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/why-does-an-instance-s-per-turn-cost-attribution-silently-drift-when-a-multi-turn-trajectory-is-replayed-from-a-mid-conversation-checkpoint.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-s-per-turn-cost-attribution-silently-drift-when-a-multi-turn-trajectory-is-replayed-from-a-mid-conversation-checkpoint.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-s-per-turn-cost-attribution-silently-drift-when-a-multi-turn-trajectory-is-replayed-from-a-mid-conversation-checkpoint.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1664,
    "python_slice_tokens": 278,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two fundamentally different things an observability system can mean by \"turn cost\": 1. **Marginal turn cost** — the tokens billed for the specific request/response pair generated at turn *N*, given the exact context that was sent. 2. **Trajectory-attributed cost** — the cost assigned to turn *N* after the trajectory is reconstructed (replayed) from...",
    "what_was_observed": "A support-triage agent runs 14 turns. At turn 9 the process is preempted; the orchestrator persists a checkpoint containing the message array and resumes. The observability pipeline reconstructs turns 1–14 by re-fetching the checkpoint and replaying the event log from turn 9 onward. Observed ledger after reconstruction: Trajectory total attributed = trajectory total marginal (both 98,240). But turn 9 shows a 1,130-to...",
    "condition_of_validity": "The invariant that must hold for per-turn attribution to be faithful: > For every resumed turn *N*, `reconstruct(checkpoint, events[N:]).prompt == billed_prompt(N)`, byte-for-byte after tokenizer normalization. This invariant is **violated** whenever any of the following is true, and the violation is undetectable from aggregate totals: - The checkpoint is *l...",
    "decision_boundary": "The boundary is whether the observability system treats the checkpoint as **authoritative** or **reconstructive**. - **Authoritative checkpoint:** per-turn `usage` is written to the ledger at generation time, keyed by `(trajectory_id, turn_index)`. Replay never re-derives cost; it only joins. Drift is impossible because there is nothing to reconstruct. - **R...",
    "operational_effect": "Downstream consequences of undetected per-turn drift: 1. **Cost-spike forensics become wrong.** The turn flagged as the cost driver is whichever turn absorbed the reallocated tokens, not the turn that actually generated them. In the observed case, turn 9 (the resumed turn) was under-attributed and its neighbors over-attributed, inverting the investigation. 2..."
  },
  "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": "374a1059668f1a76699d24868a1e9c0033eee2982239bf516ce2172e9678fd96",
    "verified_classes": [
      "TrajectoryAttributionDrift"
    ],
    "verified_functions": [
      "attribute_turn_cost",
      "build_trajectory_ledger"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "TrajectoryAttributionDrift"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
