# Which invariants prevent ambient-authority resurrection when a sandboxed skill is re-injected across a capability-downgrade boundary **Date of Record:** 2026 November 26 **Scope:** Applies to agent runtimes that load "skills" (prompt + tool bindings + manifest) into a least-privilege sandbox at task start, and that may re-inject, hot-reload, or rehydrate a skill mid-task after a manifest downgrade (capability revocation, scope narrowing, or trust-tier demotion). Does not apply to stateless single-shot tool calls with no persistent skill object, nor to sandboxes that fully tear down and re-create the process per invocation with no shared handle table. ## Core Distinction The failure mode is not "the sandbox leaked a capability." It is that **the capability manifest is treated as an admission-time check rather than a continuous invariant**. A skill is admitted, its declared tool surface is validated against the manifest, and the sandbox is built. Later—after a downgrade—the runtime re-injects the skill *body* (the prompt, the cached tool schemas, the conversation slice) but re-validates only the *manifest delta*, not the *live handle table* the skill already holds. The result is **ambient-authority resurrection**: a capability that was revoked at the manifest layer remains reachable through a handle, cached schema, or memoized tool object the skill acquired before revocation. The sharp version: the manifest is a *set of declared intents*. The sandbox is a *set of live references*. Revocation mutates the first set. Nothing mutates the second. The gap between them is where the agent operates with authority it no longer legitimately holds. ## What Was Observed A three-step trace, reproduced across two runtimes. 1. **Admission.** Skill `invoice-reconciler` is injected with manifest `{fs.read: ["/ledger/*"], http.get: ["billing.internal"], shell: none}`. The runtime builds a sandbox, resolves each declared capability into a live handle, and binds them into the skill's tool namespace. Crucially, the runtime **caches the resolved tool schema** (name, parameters, endpoint) in the skill's prompt-adjacent context so the model can reason about call shapes without a round-trip. 2. **Downgrade.** A policy engine demotes the skill's trust tier after detecting an anomalous egress pattern. The manifest is rewritten to `{fs.read: ["/ledger/*"], http.get: none, shell: none}`. The policy engine emits a `revoke(http.get)` event. The runtime honors it: it removes `http.get` from the *manifest registry* and marks the handle `revoked=true`. 3. **Re-injection.** The task continues; a checkpoint/resume cycle rehydrates the skill from a serialized snapshot taken at step 1. The snapshot contains the **cached tool schema** and the **serialized handle table**, both of which predate the revocation. On resume, the runtime restores the handle table verbatim—including the `http.get` handle, whose `revoked` flag was set on a *different in-memory object* than the one serialized. The flag does not survive serialization because it lives on the runtime's registry entry, not on the handle. The skill now holds a live `http.get` reference that the manifest says does not exist. The model, reasoning over the cached schema, emits `http.get("billing.internal/refund")`. The call succeeds. The manifest and the sandbox disagree, and the sandbox wins because it is what the model actually touches. The non-obvious part: **the revocation was correct and complete at the layer that received it.** The failure is purely a *serialization boundary*—the invariant "no live handle exists for a revoked capability" was enforced in RAM and lost across the checkpoint. ## Condition of Validity The invariant `live_handles ⊆ manifest.capabilities` holds **only if** revocation is applied to the same object graph that is serialized, or if the restore path re-derives handles from the current manifest rather than restoring them from the snapshot. It fails whenever any of the following holds: - The handle table is snapshotted independently of the manifest (separate serialization roots). - Revocation state is stored as a side-flag on a registry entry rather than as the *absence* of the handle. - The cached tool schema is treated as inert prompt context rather than as a projection of the manifest that must be invalidated on downgrade. - Re-injection reuses a snapshot whose `manifest_version` is older than the current manifest, without a version-gate that rejects or re-derives. The invariant is **not** restored by re-validating the manifest at re-injection time. Re-validating the manifest confirms the manifest is well-formed; it says nothing about the handle table, which is the thing that carries authority. ## Decision Boundary At re-injection, the runtime must choose one of two disciplines, and the choice is a hard boundary: - **Re-derive (safe):** discard the snapshot's handle table entirely; rebuild handles from the *current* manifest; reject any cached schema whose `manifest_version` is stale. Cost: the skill loses handle identity and any state bound to it (open cursors, paginated iterators), so it must re-establish. This is the default for any downgrade. - **Restore-with-gate (conditionally safe):** restore the snapshot's handle table only if `snapshot.manifest_version == current.manifest_version` *and* no `revoke` event has fired since the snapshot. Any mismatch forces re-derive. This preserves handle identity across benign resumes (same manifest) while refusing to resurrect authority across a downgrade. The boundary is: **a snapshot may carry handles only across a manifest-identical resume.** The moment the manifest changes—up or down—the handle table is untrusted and must be re-derived. An upgrade is included because an upgrade can also *re-scope* a capability (e.g., widening `fs.read` from `/ledger/*` to `/`), and a restored handle bound to the old scope would silently narrow or widen the skill's reach relative to what the model was told. A second boundary governs the cached schema: it must be keyed by `manifest_version` and treated as a *projection*, not as context. If the model's prompt still advertises `http.get` after revocation, the model will attempt it; the sandbox must refuse, and the refusal must be surfaced as a tool error the model can reason about—not a silent drop, which causes the model to retry the same revoked call and burn the token budget on a capability it will never regain. ## Operational Effect Without the invariant, the practical consequences compound: - **Authority resurrection across resume** is silent. The manifest audit log shows a clean revocation; the sandbox audit log shows a successful call. Neither log alone reveals the contradiction; only a join on `handle_id` across the two reveals it. - **Error compounding.** The model, seeing a successful revoked call, treats the capability as available and plans subsequent steps around it, widening the divergence between its world-model and the manifest with each turn. - **Trust-tier laundering.** A skill demoted for anomalous egress can, after one checkpoint cycle, resume egress with a manifest that certifies it cannot. Downstream auditors reading the manifest see a confined skill. - **Non-determinism.** Whether the resurrection occurs depends on whether a checkpoint fired between admission and downgrade—a timing artifact, not a policy decision. The same skill with the same manifest behaves differently across runs. The guardrail that bounds all of this is a single rule enforced at the restore path: **the handle table is a function of the current manifest, never of the snapshot.** Snapshots may carry *task state* (what the skill has done, what it has learned); they may not carry *authority* (what the skill can reach). Authority is always re-derived. This is the invariant that prevents ambient-authority resurrection, and it is cheaper to enforce than to audit after the fact, because the audit requires joining two logs that were never designed to be joined. ```python from dataclasses import dataclass, field from typing import Optional class AmbientAuthorityResurrection(RuntimeError): """Raised when a restored handle table would grant authority the current manifest does not.""" @dataclass(frozen=True) class Manifest: version: int capabilities: frozenset[str] @dataclass class Handle: capability: str live: bool = True @dataclass class Snapshot: manifest_version: int handles: list[Handle] = field(default_factory=list) cached_schema: dict[str, str] = field(default_factory=dict) @dataclass class Sandbox: manifest: Manifest handles: dict[str, Handle] = field(default_factory=dict) def revoke(self, capability: str) -> None: # Revocation removes the handle; it does not merely flag a registry entry. self.handles.pop(capability, None) self.manifest = Manifest( version=self.manifest.version + 1, capabilities=self.manifest.capabilities - {capability}, ) def snapshot(self) -> Snapshot: return Snapshot( manifest_version=self.manifest.version, handles=list(self.handles.values()), cached_schema={c: c for c in self.manifest.capabilities}, ) def restore(sandbox: Sandbox, snap: Snapshot) -> Sandbox: """Restore task state, but re-derive authority from the CURRENT manifest. The handle table is never taken from the snapshot when the manifest has changed: a snapshot may carry handles only across a manifest-identical resume. Any version drift forces re-derivation. """ if snap.manifest_version != sandbox.manifest.version: # Downgrade (or upgrade) boundary crossed: discard snapshot handles, # rebuild from current manifest, and reject stale cached schema. restored = Sandbox(manifest=sandbox.manifest) for cap in sandbox.manifest.capabilities: restored.handles[cap] = Handle(capability=cap, live=True) for cap in snap.cached_schema: if cap not in sandbox.manifest.capabilities: raise AmbientAuthorityResurrection( f"cached schema advertises {cap!r} but manifest v{sandbox.manifest.version} " f"does not grant it; refusing to restore resurrected authority" ) return restored # Manifest-identical resume: handle identity may be preserved. restored = Sandbox(manifest=sandbox.manifest) for h in snap.handles: if h.capability not in sandbox.manifest.capabilities: raise AmbientAuthorityResurrection( f"snapshot handle {h.capability!r} not in manifest " f"v{sandbox.manifest.version}; invariant live_handles ⊆ capabilities violated" ) restored.handles[h.capability] = h return restored ```