{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-trajectory-level-observability-from-silently-mis-attributing-cost-and-failure-class-when-a-sub-agent-s-span-is-truncated-by-a",
  "title": "Which invariants prevent trajectory-level observability from silently mis-attributing cost and failure class when a sub-agent's span is truncated by an eval-harness timeout",
  "date_of_record": "2026 November 21",
  "scope": "Applies to agent evaluation harnesses that instrument multi-step trajectories with per-span cost/token accounting and a post-hoc failure taxonomy, where a span can be cut short by a harness-level wall-clock or token-budget timeout. Does not apply to single-turn inference logging or to harnesses that record only terminal success/failure without intermediate spans.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-trajectory-level-observability-from-silently-mis-attributing-cost-and-failure-class-when-a-sub-agent-s-span-is-truncated-by-a.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-trajectory-level-observability-from-silently-mis-attributing-cost-and-failure-class-when-a-sub-agent-s-span-is-truncated-by-a.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-trajectory-level-observability-from-silently-mis-attributing-cost-and-failure-class-when-a-sub-agent-s-span-is-truncated-by-a.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1810,
    "python_slice_tokens": 484,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two structurally different things a timeout can mean, and observability pipelines routinely conflate them: 1. **The agent finished and failed** — the trajectory reached a terminal state (task failure, refusal, budget-exhausted reasoning) and the last span carries a *semantic* outcome. 2. **The harness stopped observing** — the wall-clock timer fire...",
    "what_was_observed": "In a 40-task agent eval suite with a 3-level delegation tree (orchestrator → 2 workers → tool sub-agent), a harness wall-clock timeout of 90s fired on 11/40 runs. Because the sub-agent streamed tokens continuously, the span recorder kept appending token-cost deltas to the open span. When the timer fired, the harness called `span.close(reason=\"timeout\")` but the recorder's accounting loop had a 200ms flush cadence, so...",
    "condition_of_validity": "The invariant holds — and the failure is bounded — only when all three of the following are enforced: 1. **Termination provenance is a required, non-nullable field on every span close.** The close reason must distinguish `AGENT_CONCLUDED` (agent emitted a terminal action), `HARNESS_TRUNCATED` (external timer/budget cut the span), and `PROVIDER_ERROR` (transp...",
    "decision_boundary": "The boundary is between **truncation as a data-quality event** and **truncation as a label**. Below the boundary (harness knows it truncated, records provenance, reconciles cost): the timeout run is a valid, correctly-attributed negative sample and can enter the eval denominator. Above the boundary (harness truncates but the span looks concluded): the run is...",
    "operational_effect": "Enforcing the three invariants changed the eval's conclusions: cost-per-task rose 31% (the under-attribution was masking an expensive delegation path), and the 11 \"premature termination\" failures reclassified to `HARNESS_TIMEOUT`, which — once traced — revealed the 90s timer was shorter than the p99 of the *successful* sub-agent path (94s). The \"agent failur..."
  },
  "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": "f5a7be4b5eef06d7fe3b6a0a1045bbb670e3740e6d6d86bbf0246040facd35c5",
    "verified_classes": [
      "ObservabilityInvariantError",
      "TerminationProvenance",
      "FailureClass",
      "Span"
    ],
    "verified_functions": [
      "classify_and_attribute",
      "evaluate_run"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 7,
    "raised_exceptions": [
      "ObservabilityInvariantError"
    ],
    "sample_fail_closed_invariants": [
      "assert result['failure_classes'] == ['harness_timeout']",
      "assert result['cost_metric_eligible'] is False",
      "assert result['authoritative_cost_usd'] == 0.058",
      "run has zero spans; cannot evaluate"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "enum"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
