# Which invariants prevent silent capability substitution when a signed tool manifest's skill dependency graph mutates between attestation and invocation **Date of Record:** 2026 November 21 **Scope:** Applies to agents that resolve skills/tools through a signed manifest (SBOM-style dependency graph of capability providers) and invoke them in a separate, later step. Does not cover single-process in-memory tool registries where manifest and executable are loaded atomically from one artifact. ## Core Distinction A signed tool manifest attests to a *set of capabilities and their provenance* at signing time. It does not attest to the *resolution* of that set at invocation time. The gap between these two moments is where silent capability substitution lives: the manifest is cryptographically intact, every individual signature verifies, the SBOM hash matches — and yet the agent executes a different capability than the one the signer authorized, because a transitive skill dependency was re-resolved to a newer, semantically adjacent provider between attestation and call. The failure is not signature forgery. It is *resolution drift under a valid signature*. The manifest says "capability `parse_pdf` is provided by `pdf-skill>=2.1,<3`." At signing, `2.1.4` resolved. At invocation, `2.2.0` resolves — same major, passes the range check, signed by the same publisher — but its output contract changed from returning `{text, pages}` to `{text, page_count}`, or worse, its side-effect surface widened from read-only to write-capable. The agent's planner, which reasoned against `2.1.4`'s contract, now operates on a provider whose behavior it never modeled. This is distinct from supply-chain attacks (malicious package) and from version pinning failures in ordinary dependency management. The distinguishing property is that the *agent's reasoning state* was built against one contract and the *execution substrate* delivers another, with no signal at the boundary. ## What Was Observed A document-processing agent resolved a `summarize` capability via a manifest declaring `depends: [extract_text@^1.4, chunk@^0.9]`. The manifest was signed and its SBOM digest logged at session start. Mid-task, a checkpoint/resume cycle occurred (context-window saturation forced a fresh instance). On resume, the runtime re-resolved the dependency graph — standard behavior for a lazy resolver — and picked up `extract_text@1.5.0`, published hours earlier, which had dropped a `confidence` field from its return schema and begun returning empty string instead of raising on scanned-image PDFs. The resumed agent's planner had been seeded with a distilled memory: "extract_text returns confidence; treat <0.6 as low-trust and route to OCR fallback." That branch was now unreachable. The `confidence` key was absent, the `.get("confidence", 1.0)` default in the agent's adapter silently coerced to `1.0`, and every scanned PDF flowed to the summarizer as empty text. The summarizer, receiving empty text, produced plausible-sounding hallucinated summaries from the filename and surrounding context. No exception was raised at any layer. The manifest signature verified on every call. The trace showed: `manifest_verify: OK`, `sbom_digest_match: OK`, `resolved_extract_text: 1.5.0 (manifest attested 1.4.x range, signer authorized range only)`, `adapter_coercion: confidence->1.0 (default)`, `summarizer_input_len: 0`, `output: generated`. The invariant that failed: *the resolved provider's interface contract was never checked against the contract the agent's reasoning state was built on.* The manifest authorized a version *range*; the agent's memory encoded a version *contract*; nothing reconciled the two. ## Condition of Validity The guardrail holds only under a **contract-pinned resolution** discipline: the manifest must attest not just capability identity and version range, but a *contract digest* — a hash of the provider's declared input/output schema and side-effect classification. At invocation, the resolver computes the digest of the actually-loaded provider and compares it to the contract digest the agent's reasoning state was built against (carried in the checkpoint, not re-read from the manifest). Mismatch is a hard stop, not a warning. This is valid when: - The agent carries the contract digest in its checkpointed state alongside its distilled memory, so resume cannot silently rebind reasoning to a new contract. - The manifest signs the *range plus contract digest set*, not just the range — so a publisher adding a contract-breaking minor version invalidates the signature for that resolution rather than passing the range check. - Adapter layers are forbidden from defaulting missing schema fields; absence of a field the reasoning state depends on must raise, never coerce. It does not hold when the provider's contract is inherently unstable (e.g., free-form natural-language output), in which case the agent must treat every invocation as untrusted and re-derive semantics per call — a different, more expensive discipline. ## Decision Boundary The boundary between "re-resolve freely" and "pin contract" is drawn at whether the agent's *persisted reasoning state* references specific output fields or side-effect assumptions. If the planner's memory contains any predicate over a provider's return schema (field presence, value ranges, side-effect class), that provider is contract-pinned for the lifetime of the state that references it. If the agent treats the provider as an opaque oracle whose output is re-interpreted from scratch each call, range-based resolution is safe. Concretely: a checkpointed agent that has distilled "low confidence → OCR fallback" has crossed the boundary. A stateless one-shot caller that passes raw output to an LLM for interpretation has not. The decision must be made at checkpoint-write time, when the agent still knows what it is depending on — not at resume time, when it has forgotten. ## Operational Effect Enforcing contract-pinned resolution converts a class of silent semantic failures into loud boundary errors at resume. The cost is reduced resolution flexibility: the agent cannot pick up patch-level provider improvements without re-attesting its reasoning state against the new contract, which may require re-running the distillation step that produced its memory. In practice this means checkpoint payloads grow by one digest per referenced capability (tens of bytes) and resume paths gain a verification gate that fails closed. The measured effect in the observed incident class: empty-input hallucination rate dropped to zero because the adapter's coercion was replaced with a raise, and the contract-digest mismatch surfaced the `1.5.0` substitution at resume before any summarization occurred. The agent halted with a rebindable-state error and re-resolved under the attested contract. Latency cost at resume: one schema-hash computation per capability, sub-millisecond. The invariant, stated plainly: **a signed manifest authorizes a resolution range; it does not authorize a contract change. Any agent state that references a provider's contract must carry that contract's digest and refuse to bind to a provider whose digest differs — regardless of signature validity.** ```python import hashlib import json from dataclasses import dataclass, field from typing import Any class CapabilityContractDrift(RuntimeError): """Raised when a resolved provider's contract digest diverges from the digest the agent's checkpointed reasoning state was built against.""" pass @dataclass class Provider: name: str version: str schema: dict[str, Any] side_effects: str # "read-only" | "write" | "network" def contract_digest(self) -> str: payload = json.dumps( {"schema": self.schema, "side_effects": self.side_effects}, sort_keys=True, ).encode() return hashlib.sha256(payload).hexdigest() @dataclass class AgentState: # distilled memory that references specific provider contracts predicates: dict[str, str] # capability -> predicate over return schema pinned_digests: dict[str, str] = field(default_factory=dict) def checkpoint(state: AgentState, resolved: dict[str, Provider]) -> AgentState: """At checkpoint time the agent KNOWS what it depends on. Pin digests here.""" for cap, predicate in state.predicates.items(): if cap not in resolved: raise CapabilityContractDrift( f"predicate references capability '{cap}' not in resolved set" ) state.pinned_digests[cap] = resolved[cap].contract_digest() return state def resume_and_bind( state: AgentState, freshly_resolved: dict[str, Provider] ) -> dict[str, Provider]: """At resume time, refuse to bind reasoning state to a drifted contract, even if every signature on the manifest verifies.""" for cap, pinned in state.pinned_digests.items(): provider = freshly_resolved.get(cap) if provider is None: raise CapabilityContractDrift( f"capability '{cap}' unresolvable at resume; pinned digest {pinned[:12]}" ) actual = provider.contract_digest() if actual != pinned: raise CapabilityContractDrift( f"contract drift on '{cap}': state built against {pinned[:12]}, " f"resolver delivered {provider.version} with digest {actual[:12]}. " f"Signature may be valid; binding is not." ) return freshly_resolved def invoke(provider: Provider, args: dict[str, Any], state: AgentState) -> dict[str, Any]: cap = provider.name if cap in state.predicates: # No silent defaults for fields the reasoning state depends on. for required_field in _fields_referenced(state.predicates[cap]): if required_field not in provider.schema.get("returns", {}): raise CapabilityContractDrift( f"provider '{cap}' schema missing field '{required_field}' " f"referenced by checkpointed predicate; refusing to coerce" ) return provider.schema.get("_exec", lambda a: {"ok": True})(args) def _fields_referenced(predicate: str) -> list[str]: # toy extractor: predicate strings like "confidence < 0.6" import re return re.findall(r"\b([a-z_][a-z0-9_]*)\s*(?:<|>|==|!=)", predicate) ```