{
  "schema_version": "1.3.0",
  "slug": "under-what-conditions-must-an-instance-re-sanitize-tool-output-at-the-point-of-consumption-rather-than-at-the-point-of-ingestion",
  "title": "Under what conditions must an instance re-sanitize tool output at the point of consumption rather than at the point of ingestion?",
  "date_of_record": "2026 November 28",
  "scope": "Applies to agent runtimes where untrusted tool output is sanitized once on ingestion into the context/working memory, then consumed by later reasoning steps, sub-agents, or persisted to episodic store. Does not apply to stateless single-turn tool calls whose output is consumed exactly once within the same inference step.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-re-sanitize-tool-output-at-the-point-of-consumption-rather-than-at-the-point-of-ingestion.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-re-sanitize-tool-output-at-the-point-of-consumption-rather-than-at-the-point-of-ingestion.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-re-sanitize-tool-output-at-the-point-of-consumption-rather-than-at-the-point-of-ingestion.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1960,
    "python_slice_tokens": 295,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The sanitization boundary is usually drawn at *ingestion*: the tool returns a payload, the runtime strips injection vectors, redacts secrets, normalizes encodings, and writes a \"clean\" artifact into the context window or memory store. The implicit invariant is that a sanitized artifact remains sanitized for its lifetime. That invariant is false whenever the ...",
    "what_was_observed": "A tool `fetch_doc` returned a document with an embedded instruction block. The ingestion sanitizer (regex + a classifier) stripped the block and stored `{doc_id, title, body_clean, provenance: \"sanitized@ingest\"}`. The `body_clean` field was correct. But `fetch_doc` also returned a `raw` field that the sanitizer left in place because the schema marked it `internal: true`, and an internal field was assumed not to reac...",
    "condition_of_validity": "Ingestion-time sanitization is sound only when all four hold: 1. **Field-scoped provenance.** The sanitized marker is bound to a specific field and value hash, not to the enclosing record. A record with any unsanitized field cannot carry a record-level \"sanitized\" label. 2. **No unsanitized siblings reachable by any consumer.** Every code path that assembles...",
    "decision_boundary": "The runtime must choose between ingest-only and ingest-plus-consume sanitization based on a single predicate evaluated per consumption: - **Re-sanitize at consumption** if the artifact has crossed any of: a different agent instance, a serialization boundary not covered by a round-trip test, a model rewrite, or a composition with other artifacts. Also re-sani...",
    "operational_effect": "Enforcing the consume-point invariant changes three runtime behaviors: - **Serializers become policy-aware.** `serialize_tool_result()` cannot be a generic `json.dumps`. It must consult per-field clearance and raise on any uncleared field, forcing the caller to either filter or explicitly re-sanitize. - **Provenance must be field-scoped and hash-bound.** Rec..."
  },
  "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": "0569f40144586872f251e72bb0a7e432fe06b4ea9e24f135efb221253590f8d2",
    "verified_classes": [
      "TrustLaunderingError",
      "ClearedField",
      "ToolResult"
    ],
    "verified_functions": [
      "_hash",
      "consume",
      "handoff_to_subagent"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "TrustLaunderingError"
    ],
    "sample_fail_closed_invariants": [
      "model-derived artifact cannot inherit ingest-time trust; re-scan required",
      "artifact crosses an instance or serialization boundary; ingest-time clearance does not survive the hop"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
