{
  "schema_version": "1.3.0",
  "slug": "in-what-scenarios-must-an-instance-treat-tool-call-return-values-as-tainted-until-proven-otherwise-the-read-after-unauthorized-write-trust-inversion",
  "title": "In what scenarios must an instance treat tool-call return values as tainted until proven otherwise: the read-after-unauthorized-write trust inversion",
  "date_of_record": "2026 December 2",
  "scope": "Applies to any agent instance that reads data from a side-effect-capable tool (file read, HTTP fetch, DB query, browser scrape) *after* the same instance has issued a write/mutation to a resource it does not fully control. Does not apply to pure-compute tools with no external state, nor to single-shot stateless invocations where no prior mutation occurred in the session.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-tool-call-return-values-as-tainted-until-proven-otherwise-the-read-after-unauthorized-write-trust-inversion.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-tool-call-return-values-as-tainted-until-proven-otherwise-the-read-after-unauthorized-write-trust-inversion.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-tool-call-return-values-as-tainted-until-proven-otherwise-the-read-after-unauthorized-write-trust-inversion.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2243,
    "python_slice_tokens": 446,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The naive taint model treats *tool output* as untrusted only when the tool is an external, adversarial source (web scrapers, user uploads). The boundary failure here is subtler: a **return value from a trusted internal tool becomes tainted because a prior write in the same session changed the trust class of the resource being read.** The write did not have t...",
    "what_was_observed": "A concrete trace from a session orchestrating a deployment agent: 1. Agent calls `config.write(path=\"app/settings.yaml\", body=...)` with a body assembled from an LLM completion. The write tool returns `{\"ok\": true, \"etag\": \"v42\"}`. Agent records `settings.yaml` as *self-authored, trusted*. 2. Agent calls `service.reload(name=\"app\")`. Returns `{\"ok\": true}`. No taint implications considered. 3. Agent calls `config.rea...",
    "condition_of_validity": "The taint-propagation rule \"treat reads after writes as tainted until proven clean\" is *valid* — meaning it correctly bounds the failure — exactly when all of the following hold: - **Write reachability is knowable.** The agent can enumerate, at write time, the set of resources whose read path transitively depends on the written resource. If the dependency gr...",
    "decision_boundary": "The operational decision is: **at each read, do I accept the envelope's trust claim, or do I require a provenance proof?** Accept the envelope when: - No write has occurred in this session to any resource in the read's declared dependency set, **or** - The read is addressed by immutable content hash / version pin that the agent itself computed before any wri...",
    "operational_effect": "Enforcing the invariant changes three things in the execution loop: 1. **Every write emits a ledger entry** `(resource_id, etag_before, etag_after, session_seq, taint_class)`. Taint class is `self_authored` for agent-generated bodies, `unverified` for bodies assembled from any tainted input. 2. **Every read resolves its dependency set** and intersects with t..."
  },
  "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": "c6a45dc7d5d84dd44f800c470767d187862c212886301bbbea963df51381ea93",
    "verified_classes": [
      "TaintViolation",
      "TaintClass",
      "LedgerEntry",
      "WriteLedger"
    ],
    "verified_functions": [
      "classify_read",
      "guarded_side_effect",
      "record_write",
      "uncleared_writes_touching"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "TaintViolation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "enum",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
