{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-trace-to-payload-exemplar-linkage-from-leaking-pii-when-semantic-convention-hashes-are-computed-over-mutable-prompt-scaffolds",
  "title": "Which invariants prevent trace-to-payload exemplar linkage from leaking PII when semantic-convention hashes are computed over mutable prompt scaffolds",
  "date_of_record": "2026 November 25",
  "scope": "Applies to OpenTelemetry-style GenAI semantic conventions where a span emits a `gen_ai.prompt.hash` / `gen_ai.completion.hash` exemplar intended to link a trace to the exact prompt/response payload without storing the payload. Does not cover full-payload capture, redaction-in-transit, or storage-side encryption at rest.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-trace-to-payload-exemplar-linkage-from-leaking-pii-when-semantic-convention-hashes-are-computed-over-mutable-prompt-scaffolds.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-trace-to-payload-exemplar-linkage-from-leaking-pii-when-semantic-convention-hashes-are-computed-over-mutable-prompt-scaffolds.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-trace-to-payload-exemplar-linkage-from-leaking-pii-when-semantic-convention-hashes-are-computed-over-mutable-prompt-scaffolds.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1769,
    "python_slice_tokens": 268,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two ways to \"hash the prompt\": hash the *rendered bytes actually sent to the model*, or hash a *canonicalized semantic projection* of the prompt (template ID + slot values). These are not interchangeable, and the difference is the entire failure surface. The rendered-bytes hash is a faithful linkage key but is a **low-entropy oracle over PII**: any...",
    "what_was_observed": "A retrieval-augmented agent emitted `gen_ai.prompt.hash = sha256(rendered_prompt.encode())` on its `chat` span, and a downstream evaluator span tried to link its own re-rendered prompt back to the same exemplar to attach a quality score. Two classes of failure appeared in the same telemetry window: 1. **Linkage miss (false negative).** The agent's prompt-rendering layer injected retrieved context in nondeterministic ...",
    "condition_of_validity": "The construction is valid only when all of the following hold simultaneously: - **Domain separation.** The digest is `HMAC-SHA256(key = tenant_secret, msg = domain_tag || canonical_projection)`. The `domain_tag` distinguishes `prompt` from `completion` from `tool_result` so a completion cannot collide with a prompt. A bare `sha256` fails the oracle test the ...",
    "decision_boundary": "The boundary is not \"hash or don't hash.\" It is **who holds the secret, and what does the resolver need.** - If the resolver is the *same trust domain* as the emitter (same tenant, same secret custody), a keyed hash over the full canonical projection is safe and maximally linkable. Emit it. - If the resolver is *outside* the trust domain (a third-party evalu...",
    "operational_effect": "When the invariant holds, exemplar linkage recall is stable across re-renders (order-insensitive), template version bumps are visible as distinct exemplars rather than silent mismatches, and the digest is a non-oracle. When it breaks, the two failure modes trade off against each other: aggressive canonicalization buys recall at the cost of entropy, and faith..."
  },
  "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": "a6020381c35e74cc356f71401cd5e250af7315e6f5b75f7406b3cdd8aefa2dc6",
    "verified_classes": [
      "ExemplarInvariantError",
      "Slot",
      "PromptProjection"
    ],
    "verified_functions": [
      "_slot_digest",
      "canonical_projection",
      "emit_exemplar"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "ExemplarInvariantError"
    ],
    "sample_fail_closed_invariants": [
      "resolver outside secret-custody trust domain; emit opaque linkage token instead",
      "tenant secret too short for keyed exemplar"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib",
      "hmac"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
