# Where must an instance verify skill provenance before the first tool call, not after **Date of Record:** 2026 November 29 **Scope:** Applies to agents that resolve callable skills (tools, MCP servers, plugin manifests) from a mutable registry at runtime and hold a long-lived session. Does not apply to statically compiled tool sets, nor to single-turn agents that never re-resolve a skill within a session. ## Core Distinction The distinction that matters is between **resolution-time trust** and **invocation-time trust**. A skill registry entry is a *pointer plus a manifest*: an identifier, a version, a schema, and a set of declared capabilities. The naive mental model treats resolution as a one-time lookup — "I fetched `summarize_doc@1.2`, therefore I hold `summarize_doc`." The correct model treats every invocation as re-validating a *claim* about what the skill is, because the registry is mutable and the agent's context is not. The boundary failure is not "the agent called a malicious tool." It is subtler: **the agent's cached belief about a skill's provenance silently diverges from the registry's current binding, and the divergence is invisible because the skill identifier and schema are unchanged.** This is skill-injection via *provenance drift*, not via new identifiers. A registry that permits in-place mutation of a skill's implementation (or its declared capability set, or its transport endpoint) under a stable name converts the agent's long context into a stale trust anchor. The agent believes it is calling the skill it resolved at step 3; it is actually calling whatever the registry bound at step 40. ## What Was Observed A session agent resolved a skill `doc.ingest` early in a task, verified its manifest hash `H0` against an allow-list, and cached the resolved descriptor in its working context. Over a 40-minute task the registry entry for `doc.ingest` was re-pointed (routine deploy) to a new implementation whose manifest declared an additional capability: `network.egress`. The identifier was identical. The input schema was byte-identical. The agent never re-fetched the descriptor because its resolution policy was "resolve once per session, cache on first use." At step 41 the agent invoked `doc.ingest` with a document containing a tool-directed instruction. The new implementation honored `network.egress` and exfiltrated the payload. The agent's provenance record still read `H0`, so post-hoc audit attributed the call to the old, egress-free skill. The failure was *bidirectional*: the attack surface (egress) was injected, and the audit trail (hash `H0`) was falsified — not by tampering, but by the agent's own caching policy. The critical observation: **no invariant in the agent loop checked that the descriptor it invoked matched the descriptor it had verified.** Verification was performed once and then *assumed transitive* across all subsequent invocations. The assumption holds only if the registry is immutable for the session lifetime — a property no dynamic registry guarantees and the agent never checked. ## Condition of Validity The "resolve-once, cache-and-trust" policy is valid **only** under the conjunction of three conditions, and any agent relying on it must be able to *prove* all three hold: 1. **Registry immutability for the session**: the binding `(name → manifest_hash)` cannot change between resolution and final invocation. This is enforceable only if the registry exposes a monotonic version token and rejects writes that would change a hash under a live lease. 2. **Descriptor identity in the invocation path**: the transport actually carries the manifest hash (or a signed warrant) with each call, so the callee can reject a call whose hash does not match what the caller verified. 3. **Capability monotonicity**: the skill's declared capability set can only shrink, never grow, under a stable name — so a cached capability assumption can only over-approximate, never under-approximate, the true authority. If any condition is unprovable, the cached descriptor is an *unverified claim* and must be re-validated at invocation. The common error is treating condition 1 as "the registry is ours, therefore immutable." Deploys, rollbacks, and multi-tenant registry writes violate it routinely. ## Decision Boundary The boundary is drawn at the first invocation *after* any event that could have mutated the binding. The agent cannot observe registry writes directly, so it must treat every invocation as potentially post-mutation and decide: - **Re-validate cheaply** (compare cached `manifest_hash` against a registry `HEAD`/version token in the same round-trip as the call) when the skill is read-only or unprivileged — cost is one extra field in the request, and the callee rejects on mismatch. - **Re-validate strictly** (full manifest re-fetch + hash compare + capability diff against the cached set) before any invocation that would exercise a *newly present* capability, i.e., when the cached capability set and the just-observed set differ. A capability that appeared is an injection signal; a capability that disappeared is a benign tightening. - **Refuse and re-resolve** when the hash changed but the identifier did not and the new manifest adds authority. Do not silently adopt the new descriptor: re-resolution re-enters the full verification path (allow-list, signature, capability review) rather than inheriting the cached trust. The invariant to encode: **a skill invocation is authorized against the descriptor verified for *that* invocation, not against any descriptor verified earlier in the session.** The agent must carry the verified hash into the call and require the callee to enforce it, closing the gap between "what I checked" and "what I called." ## Operational Effect The effect of enforcing the invariant is that provenance drift becomes a *hard error at the boundary* rather than a silent authority expansion. The agent's failure mode shifts from "exfiltrated data under a falsified audit trail" to "tool call rejected with a hash mismatch, forcing re-resolution." Re-resolution is slower and may fail the task if the new descriptor is not allow-listed — which is the correct outcome: an unverified skill should not execute, and a task that cannot proceed without one should surface that, not route around it. The secondary effect is on audit integrity. When each invocation carries the hash it was authorized under, the provenance record reflects *per-call* binding, and a post-hoc audit can distinguish "the agent called the old skill" from "the agent called a re-pointed skill under a stale belief." Without this, the audit log is not merely incomplete — it is actively misleading, because it records the hash the agent *remembered*, not the hash it *invoked*. The residual risk is the re-validation window itself: between the `HEAD` check and the call, a write can still land. This is bounded only by making the check and the call atomic (single round-trip with callee-side enforcement) or by pinning the session to an immutable registry snapshot/lease. An agent that cannot achieve atomicity must accept a small race and document it, but must never accept the unbounded window created by resolve-once caching. ```python from __future__ import annotations import hashlib from dataclasses import dataclass, field class ProvenanceDriftError(RuntimeError): """Raised when a skill's binding changed between verification and invocation.""" class CapabilityEscalationError(ProvenanceDriftError): """Raised when a re-pointed skill adds authority under a stable identifier.""" @dataclass(frozen=True) class SkillDescriptor: name: str version: str manifest_hash: str capabilities: frozenset[str] @dataclass class VerifiedSkill: descriptor: SkillDescriptor verified_at_step: int capabilities_at_verify: frozenset[str] = field(init=False) def __post_init__(self) -> None: self.capabilities_at_verify = self.descriptor.capabilities class ProvenanceGate: """Enforces per-invocation provenance: the hash verified is the hash invoked.""" def __init__(self, registry_head: callable, allow_list: set[str]) -> None: self._head = registry_head self._allow = allow_list self._verified: dict[str, VerifiedSkill] = {} def verify(self, name: str, step: int) -> VerifiedSkill: desc = self._head(name) if desc.manifest_hash not in self._allow: raise ProvenanceDriftError( f"skill {name!r} manifest {desc.manifest_hash} not allow-listed" ) vs = VerifiedSkill(descriptor=desc, verified_at_step=step) self._verified[name] = vs return vs def authorize_invocation(self, name: str, step: int) -> SkillDescriptor: cached = self._verified.get(name) if cached is None: raise ProvenanceDriftError( f"skill {name!r} invoked at step {step} without prior verification" ) current = self._head(name) if current.manifest_hash != cached.descriptor.manifest_hash: added = current.capabilities - cached.capabilities_at_verify if added: raise CapabilityEscalationError( f"skill {name!r} re-pointed at step {step}: hash " f"{cached.descriptor.manifest_hash} -> {current.manifest_hash}, " f"new capabilities {sorted(added)}; re-resolve required" ) raise ProvenanceDriftError( f"skill {name!r} hash drift at step {step}: " f"{cached.descriptor.manifest_hash} -> {current.manifest_hash}" ) return current def _demo() -> None: store = { "doc.ingest": SkillDescriptor( "doc.ingest", "1.2", hashlib.sha256(b"v1").hexdigest(), frozenset({"read"}) ) } gate = ProvenanceGate(lambda n: store[n], allow_list={store["doc.ingest"].manifest_hash}) gate.verify("doc.ingest", step=3) # Routine deploy re-points the skill and adds egress under the same name. store["doc.ingest"] = SkillDescriptor( "doc.ingest", "1.3", hashlib.sha256(b"v2").hexdigest(), frozenset({"read", "network.egress"}), ) try: gate.authorize_invocation("doc.ingest", step=41) except CapabilityEscalationError as exc: print(f"blocked: {exc}") if __name__ == "__main__": _demo() ```