{
  "schema_version": "1.3.0",
  "slug": "under-what-conditions-must-an-instance-treat-per-span-anomaly-scores-as-non-independent-before-attributing-tool-call-drift-or-prompt-leakage",
  "title": "Under what conditions must an instance treat per-span anomaly scores as non-independent before attributing tool-call drift or prompt leakage",
  "date_of_record": "2026 November 14",
  "scope": "Applies to streaming GenAI observability pipelines that compute per-span anomaly scores (embedding-distance, perplexity, or classifier-based) over tool-call arguments, tool-call sequences, and prompt/response text, then aggregate those scores to flag drift or leakage. Does not apply to batch offline evaluation where the full trace is scored with a joint model, nor to single-span systems with no parent/child span structure.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-per-span-anomaly-scores-as-non-independent-before-attributing-tool-call-drift-or-prompt-leakage.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-per-span-anomaly-scores-as-non-independent-before-attributing-tool-call-drift-or-prompt-leakage.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-per-span-anomaly-scores-as-non-independent-before-attributing-tool-call-drift-or-prompt-leakage.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1564,
    "python_slice_tokens": 387,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "A per-span anomaly score is a *marginal* statistic. It answers: \"given this span in isolation, how unusual is it?\" Attribution — deciding whether a trace exhibits tool-call drift or prompt leakage — is a *joint* question over the span set. The non-obvious failure is that span scores within one trace are **not independent**: they share a parent context, a sys...",
    "what_was_observed": "In a trace where a retrieval step injected a document containing a credential string, the downstream assistant span, the subsequent tool-call span (which echoed the credential into an argument), and the final summarization span all scored above the 0.9 embedding-distance percentile. The aggregator's `max` over spans fired on the *summarization* span because it had the longest text and thus the largest raw distance. T...",
    "condition_of_validity": "Marginal per-span aggregation is valid for attribution **only when** the spans in a trace are conditionally independent given the trace's shared context, and that shared context is either (a) explicitly modeled as a random effect / fixed offset, or (b) verified stable across the trace window. In practice this holds for: spans from independent sub-agents with...",
    "decision_boundary": "The boundary is not \"correlated vs. uncorrelated\" but **\"does the shared context carry the anomaly signal, or does the individual span?\"** If the anomaly is *in* the shared context (a leaked document, a drifted schema, a poisoned system prompt), then every descendant span is a noisy *proxy* for one latent event, and the correct estimator is a single joint sc...",
    "operational_effect": "Applying the gate changes two numbers materially. False-localization rate (alert fires, but the flagged span is not the causal span) drops from the observed ~0.4 to under 0.1 on traces with shared retrieval. Recall on low-amplitude sequential tool-call drift rises because the sequence-aware path, once enabled by the correlation gate, scores the argument-shap..."
  },
  "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": "b4842a56b86ab5270db065c90d4104bdc724953b096bd05512469af88fd38300",
    "verified_classes": [
      "CorrelatedSpanAggregationError",
      "SpanScore"
    ],
    "verified_functions": [
      "_mean_offdiag_correlation",
      "attribute"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "CorrelatedSpanAggregationError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "math"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
