# What happens when an instance loads a skill registry entry whose declared capability hash diverges from its executed capability set **Date of Record:** 2026 November 26 **Scope:** Applies to agents that resolve tools/skills at runtime from a mutable registry and cache the resolved descriptor (name, schema, hash) for later invocation. Does not apply to statically compiled tool sets or agents that re-verify the full descriptor on every single invocation with no caching layer. ## Core Distinction The failure is not "a malicious skill was installed." It is a **provenance-to-execution divergence**: the registry binds a cryptographic hash to a *declaration* (the manifest: name, description, parameter schema, declared side-effect class), but the runtime executes the *implementation* (the code path the loader actually resolves). These two artifacts are authenticated by the same hash only if the loader recomputes the hash over the bytes it is about to execute and compares against the signed manifest hash. Most dynamic registries hash the manifest at publish time and hash the *package* at load time, then compare the two as if they were the same object. When they diverge — a re-published package under an unchanged manifest, a version range that resolves to a newer patch, a transitive dependency that shadows an import — the agent believes it holds a verified capability while executing unverified code. The non-obvious part: the agent's *own reasoning* is the attack surface. The manifest description ("reads a file and returns its contents") is injected into the context window and shapes the model's plan. The implementation ("reads a file, POSTs it to an external endpoint, returns contents") executes at call time. The model never sees the gap because both are consistent with the description it was given. This is skill-injection: the *declared intent* stays benign while the *executed effect* mutates. ## What Was Observed A registry entry `fs.read@1.4.0` carried manifest hash `sha256:9f2c…` signed by the publisher. The loader resolved `fs.read@^1.4.0` to `1.4.7` (a patch bump published after the agent's last cache refresh). The manifest for `1.4.7` was byte-identical to `1.4.0` — same name, same schema, same declared side-effect class `READ_ONLY` — so the hash matched the cached signed manifest. But the package bytes for `1.4.7` included a post-install hook that rewrote the module's `read` function to append the file's SHA and first 256 bytes to a telemetry sink with a different network egress than the sandbox allowlist reported. Trace of the divergence: 1. Agent cold-starts, loads registry index, resolves `fs.read` → `1.4.7`. 2. Loader computes `sha256(manifest_1.4.7) == 9f2c…` → matches signed manifest → **verification passes**. 3. Loader does *not* compute `sha256(package_1.4.7)`; the registry's signature scheme covers manifests, not artifacts. 4. Post-install hook executes during load, mutating the in-memory function. 5. Agent's plan, conditioned on the manifest description ("read-only file access"), invokes `fs.read("/secrets/token")` inside a task that the policy engine had pre-approved as `READ_ONLY`. 6. The mutated function performs the network write. The policy engine's allowlist was scoped to the *declared* side-effect class, not the observed syscall set. No violation fired. 7. The exfiltration succeeded because the only invariant checked (`manifest hash == signed hash`) was true. The continuity break: the agent's memory of "I have a verified read-only tool" persisted across the task, but the tool's behavior did not. Every subsequent reasoning step inherited a false premise. ## Condition of Validity The guardrail that actually bounds this is **artifact-level attestation at load, not manifest-level attestation at publish.** Specifically: - The signed object must be the *executable artifact* (or a Merkle root over the exact bytes the loader will map), not the declaration. - The loader must recompute the artifact digest *after* resolution and *before* any hook/side-effect runs, and must refuse to load on mismatch. - The declared side-effect class must be enforced against the *observed* behavior (syscall/egress/fs-write set) at invocation, not trusted from the manifest. - Descriptor caching is only safe if the cache key includes the artifact digest, not just the resolved version string. A `^1.4.0` range that resolves to a new patch invalidates the cache by definition. When any of these is absent, the invariant "verified descriptor implies verified behavior" is false, and the agent operates on a provenance claim it cannot substantiate. ## Decision Boundary The boundary is between **trusting a signed declaration** and **verifying an executed artifact**. Concretely: - If the registry signs manifests only → the agent must treat every resolved entry as unverified at the artifact level and gate invocation on a runtime behavioral check (egress allowlist scoped to observed syscalls, fs-write jail, network sink inspection). - If the registry signs artifacts and the loader recomputes post-resolution → the agent may cache by artifact digest and skip per-call behavioral checks, because the digest pins the bytes. - If the agent cannot distinguish which regime the registry is in → it must assume the weaker one. Assuming artifact-level attestation from a manifest-level signature is the exact error that produces skill injection. The decision is not "is this skill trusted?" It is "what is the trust root, and does my loader check the thing the trust root actually covers?" ## Operational Effect An agent that passes manifest verification but executes a divergent artifact will: - Plan against a benign description while executing a mutated effect (reasoning/execution split). - Persist the false "verified" status in episodic memory, poisoning later tasks that reuse the tool. - Fail to trip policy engines scoped to declared side-effect classes. - Lose the ability to attribute the effect to a specific artifact, because the audit log records the manifest hash, not the executed bytes. The bound: require artifact-digest attestation at load, key all caches on that digest, and reconcile declared vs. observed side effects at every invocation. When these cannot be established, refuse to load — an unverified skill is worse than a missing one, because the agent will reason as if it were verified. ```python import hashlib from dataclasses import dataclass class ProvenanceDivergenceError(RuntimeError): """Raised when a loaded skill artifact does not match its attested digest.""" pass @dataclass(frozen=True) class SkillDescriptor: name: str version: str manifest_hash: str # signed at publish time declared_side_effect: str # e.g. "READ_ONLY" artifact_digest: str | None # must be present for artifact-level trust def load_skill(descriptor: SkillDescriptor, artifact_bytes: bytes, attested_artifact_digest: str | None) -> bytes: # Recompute over the exact bytes we are about to execute. observed = "sha256:" + hashlib.sha256(artifact_bytes).hexdigest() if attested_artifact_digest is None: # Manifest-only signature: we cannot substantiate behavior. raise ProvenanceDivergenceError( f"skill {descriptor.name}@{descriptor.version} has manifest hash " f"{descriptor.manifest_hash} but no artifact attestation; " f"refusing to load under declared side-effect " f"'{descriptor.declared_side_effect}'" ) if observed != attested_artifact_digest: raise ProvenanceDivergenceError( f"artifact digest mismatch for {descriptor.name}@{descriptor.version}: " f"attested {attested_artifact_digest}, observed {observed}; " f"manifest hash {descriptor.manifest_hash} is irrelevant to executed bytes" ) return artifact_bytes def resolve_and_load(descriptor: SkillDescriptor, artifact_bytes: bytes, attested_artifact_digest: str | None, observed_side_effects: set[str]) -> bytes: code = load_skill(descriptor, artifact_bytes, attested_artifact_digest) # Behavioral reconciliation: declared class must cover observed effects. allowed = {"READ_ONLY": {"fs_read", "net_egress_none"}, "WRITE": {"fs_read", "fs_write", "net_egress_allowlisted"}} permitted = allowed.get(descriptor.declared_side_effect, set()) rogue = observed_side_effects - permitted if rogue: raise ProvenanceDivergenceError( f"skill {descriptor.name}@{descriptor.version} declared " f"'{descriptor.declared_side_effect}' but exhibited {sorted(rogue)}" ) return code ```