# When must an instance reject a skill whose manifest hash matches but whose declared capability set drifted: the capability-set drift boundary in dynamically loaded agent skills **Date of Record:** 2026 November 25 **Scope:** Applies to agents that load skills/plugins/tools at runtime from a registry keyed by manifest hash, where the manifest declares a capability set (permissions, tool bindings, side-effect classes) separate from the code artifact. Does not apply to statically compiled-in tools or to skills whose capability set is derived from code inspection at load time rather than declared in the manifest. ## Core Distinction The naive skill-injection guard checks *artifact integrity*: hash the manifest, hash the code artifact, confirm both match the registry record, load. This defends against tampering with bytes. It does **not** defend against a subtler class of attack: a manifest whose bytes are unchanged but whose **declared capability set is semantically broader than the capability set the agent's policy was written against**. The hash is a fingerprint of the encoding, not of the meaning. Two manifests can hash identically while the *interpretation* of a capability string changes because the loader's capability grammar, the registry's alias table, or a transitive dependency's own manifest changed. The invariant that must hold is: **the effective capability set at load time must be a subset of the capability set that was audited and bound to the hash at admission time** — and this must be re-checked on every load, not only on first admission. ## What Was Observed A skill registry stored, per skill, a record `{manifest_sha256, code_sha256, admitted_capabilities}`. On admission, a human-reviewed policy computed `admitted_capabilities` by expanding the manifest's declared `capabilities` list against an alias table (e.g. `fs.read` → `{fs.read, fs.stat, fs.list}`). On load, the agent verified `sha256(manifest) == manifest_sha256` and `sha256(code) == code_sha256`, then expanded the manifest's capability list *again* using the **current** alias table, and proceeded. The drift: the alias table was updated to expand `net.fetch` from `{net.fetch}` to `{net.fetch, net.dns, net.connect_raw}` to support a new transport. A previously admitted skill whose manifest declared `net.fetch` now expanded to three capabilities instead of one. The manifest hash matched. The code hash matched. The agent loaded the skill and it silently gained `net.connect_raw` — a side-effect class the original audit had explicitly excluded. No alert fired because the integrity check passed. A second, independent instance: a skill declared `capabilities: ["tool:search"]`. The registry's tool namespace later rebound `search` from a read-only index client to a client that also performed write-through caching to a shared store. The manifest was byte-identical; the capability string resolved to a different effective tool. The agent's policy said "read-only" and the loader's expansion said "read-write," and the loader won because the policy was only consulted at admission. In both cases the failure trace was: `hash_match → re-expand with current grammar → effective_set ⊋ admitted_set → load proceeds`. The guard had no step comparing `effective_set` to `admitted_set`. ## Condition of Validity The hash-only guard is valid **only if** the mapping from declared capability strings to effective capabilities is a pure function of the manifest bytes — i.e., the expansion grammar, alias table, and tool namespace are immutable for the lifetime of the admission record. In practice this holds for none of the interesting cases: alias tables evolve, tool namespaces rebind, and transitive skills contribute their own capabilities to the effective set. Therefore the guard must be reformulated as a **set-containment check against the admitted set**, evaluated on every load: 1. At admission, compute and persist `admitted_capabilities = expand(manifest, grammar_at_admission, namespace_at_admission)`. 2. At load, compute `effective_capabilities = expand(manifest, grammar_now, namespace_now) ∪ transitive_capabilities(loaded_deps)`. 3. Reject if `effective_capabilities ⊄ admitted_capabilities`. The hash match is necessary but not sufficient. The subtle part is transitive contribution: a skill that declares no network capability can still acquire one through a dependency whose manifest changed. The effective set must be the **closure** over the dependency graph, not the skill's own declaration. ## Decision Boundary The boundary is not "hash mismatch → reject." It is: **does the effective capability closure at load time exceed the admitted closure?** Three cases: - `effective ⊆ admitted`: load. The manifest may have drifted in ways that only *narrow* capabilities; that is safe. - `effective ⊋ admitted` by a *widening* alias (same string, more meaning): reject and require re-admission. This is the case the hash guard misses. - `effective` contains a capability string that did not exist at admission (new grammar token): reject; the admission record cannot speak to it. The guard must fire on widening, not only on tampering. A skill that was audited as `net.fetch` and now resolves to `net.fetch ∪ net.connect_raw` is a different skill for policy purposes even though it is byte-identical. The decision is made on the *closure*, recomputed at load, compared to the *persisted closure*, not on the hash. ## Operational Effect Without the containment check, the registry's integrity guarantee is a false floor: it certifies bytes while the semantic surface silently expands underneath. The practical consequences are (a) audit records that no longer describe what runs, (b) policy exclusions that erode as shared grammar evolves, and (c) transitive capability leakage through dependencies that individually pass the hash check. With the containment check, the load path becomes: verify hashes (necessary), recompute closure (sufficient), compare to admitted closure (the actual guard), and fail closed on any widening. The cost is one closure computation per load — cheap relative to the tool calls the skill will make — and the benefit is that the admitted set, not the hash, becomes the thing the agent trusts. ```python from dataclasses import dataclass, field from typing import Dict, FrozenSet, Iterable class CapabilityDriftError(RuntimeError): """Raised when a skill's effective capability closure exceeds its admitted closure.""" @dataclass(frozen=True) class AdmissionRecord: manifest_sha256: str code_sha256: str admitted_capabilities: FrozenSet[str] @dataclass class SkillManifest: declared_capabilities: Iterable[str] dependencies: Iterable[str] = field(default_factory=tuple) def expand_capabilities( declared: Iterable[str], alias_table: Dict[str, FrozenSet[str]], ) -> FrozenSet[str]: """Expand declared capability strings against the *current* alias table.""" out = set() for cap in declared: if cap not in alias_table: # Unknown token: cannot be spoken to by any admission record. out.add(f"__unknown__:{cap}") else: out.update(alias_table[cap]) return frozenset(out) def effective_closure( manifest: SkillManifest, alias_table: Dict[str, FrozenSet[str]], dep_manifests: Dict[str, SkillManifest], ) -> FrozenSet[str]: """Closure over the skill's own declaration plus its transitive dependencies.""" closure = set(expand_capabilities(manifest.declared_capabilities, alias_table)) for dep_name in manifest.dependencies: dep = dep_manifests.get(dep_name) if dep is None: # A missing dependency is itself a widening risk: fail closed. closure.add(f"__unresolved_dep__:{dep_name}") continue closure.update(effective_closure(dep, alias_table, dep_manifests)) return frozenset(closure) def load_skill( manifest: SkillManifest, manifest_bytes: bytes, code_bytes: bytes, record: AdmissionRecord, alias_table: Dict[str, FrozenSet[str]], dep_manifests: Dict[str, SkillManifest], sha256, ) -> SkillManifest: # Step 1: integrity (necessary, not sufficient). if sha256(manifest_bytes).hexdigest() != record.manifest_sha256: raise CapabilityDriftError("manifest hash mismatch") if sha256(code_bytes).hexdigest() != record.code_sha256: raise CapabilityDriftError("code hash mismatch") # Step 2: recompute the effective closure under the *current* grammar/namespace. effective = effective_closure(manifest, alias_table, dep_manifests) # Step 3: containment against the admitted closure. This is the real guard. widening = effective - record.admitted_capabilities if widening: raise CapabilityDriftError( f"capability closure widened beyond admission: {sorted(widening)}" ) return manifest ```