{
  "schema_version": "1.3.0",
  "slug": "when-must-an-instance-resolve-trace-eval-safety-joins-at-agent-step-granularity-rather-than-at-session-or-request-granularity",
  "title": "When must an instance resolve trace-eval-safety joins at agent-step granularity rather than at session or request granularity",
  "date_of_record": "2026 November 17",
  "scope": "Applies to GenAI observability pipelines that ingest OpenTelemetry-style agent traces (span trees with `agent.step` spans), asynchronous evaluation verdicts (LLM-as-judge, rubric scorers, heuristic checks), and safety classifier signals (toxicity, prompt-injection, PII, jailbreak) that arrive out of band with independent latency and revision semantics. Does not apply to single-turn, stateless inference endpoints where one request maps to exactly one trace and one response, nor to batch offline scoring where no live correlation is required.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-must-an-instance-resolve-trace-eval-safety-joins-at-agent-step-granularity-rather-than-at-session-or-request-granularity.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-resolve-trace-eval-safety-joins-at-agent-step-granularity-rather-than-at-session-or-request-granularity.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-resolve-trace-eval-safety-joins-at-agent-step-granularity-rather-than-at-session-or-request-granularity.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1688,
    "python_slice_tokens": 372,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The non-obvious boundary is between **join key identity** and **join key stability**. At session granularity, the join key is the session ID — immutable, assigned once, stable across the entire lifetime of the interaction. At agent-step granularity, the join key is `(trace_id, span_id, step_index)`, and the critical property is that `span_id` is stable but `...",
    "what_was_observed": "In a production pipeline correlating ~40M agent steps/day, we observed a class of incident that never triggered an alert: **step-attributed safety flags whose span ancestry did not match the span that generated the flagged content.** The pipeline's join used `(trace_id, step_index)` because `step_index` was cheap to extract from the eval payload and `span_id` required a second lookup against the trace store. Under no...",
    "condition_of_validity": "Step-granularity joining is only valid when **all three** of the following hold: 1. **The join key includes `span_id`, not merely `step_index`.** `step_index` is a presentation attribute, not an identity. Any pipeline that reconstructs step identity from ordinal position is unsound under retry, fan-out, or branch. 2. **Late-bound signals carry an explicit re...",
    "decision_boundary": "Resolve at **agent-step granularity** when: the trace store is authoritative and queryable at join time; eval and safety payloads carry `span_id` and a payload hash; revisions are modeled as new verdict records rather than in-place updates; and the pipeline can detect ordinal drift (retry, renumber) at ingest. Fall back to **session granularity** when: any s...",
    "operational_effect": "After switching to `span_id`-keyed joins with payload-hash verification and revision-as-append, step-attributed safety recall on retried steps recovered to parity with non-retried steps, and the trust-metric false-positive inflation collapsed. The cost was a mandatory trace-store lookup per late-bound verdict, which we absorbed by caching span payload hashes..."
  },
  "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": "10737f9d7856e9c4df88ba863da70c9fdc646f0b8aaccdb91c0d6798f6e93292",
    "verified_classes": [
      "StepJoinAttributionError",
      "SpanRecord",
      "Verdict",
      "StepJoinResolver"
    ],
    "verified_functions": [
      "register",
      "resolve"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 6,
    "raised_exceptions": [
      "StepJoinAttributionError"
    ],
    "sample_fail_closed_invariants": [
      "caller requested session-granularity fallback; do not call step resolver"
    ],
    "stdlib_dependencies": [
      "__future__",
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
