# What happens when an instance re-binds to a memory namespace after its tool-scope warrant has been rotated mid-session **Date of Record:** 2026 November 24 **Scope:** Applies to long-lived agent instances whose memory namespace is bound to an identity token that also carries per-tool authorization scopes, and where either the token or the scope set can be rotated while the instance is still executing. Does not apply to stateless single-turn invocations or to instances that re-authenticate on every tool call. ## Core Distinction The failure is not "the token expired." It is that **identity binding to a memory namespace and authorization scope for tools are carried by the same credential but are consumed at different times, with different consistency requirements.** The memory namespace is a *durable read/write target* — the instance must keep reading and writing the same episodic store across a whole task. Tool scopes are a *per-call capability* — they must be re-evaluated at every dispatch. When a rotation event replaces the credential, the two consumers diverge: the memory layer caches the old namespace handle (correct, because the namespace is stable), while the tool layer must re-read scopes from the *new* credential (which may have narrowed). An instance that treats the credential as a single immutable object — reusing the cached handle for both — will keep writing to the correct namespace but silently dispatch tools under the *stale* scope set, or, in the inverse error, will re-bind to a *new* namespace derived from the new credential's subject and orphan its own episodic history mid-task. The non-obvious part: neither consumer errors. Namespace writes succeed (the handle is valid). Tool dispatches succeed (the old warrant is still accepted by the tool gateway until its own TTL lapses). The divergence is invisible until the task checkpoint is replayed and the auditor finds tool calls that the *current* identity was never authorized to make, or a memory namespace whose subject field no longer matches the active credential. ## What Was Observed Trace from a three-hour research task on an instance bound at `t0` to credential `C1`, namespace `ns://agent-7f3a`, scopes `{read_web, write_memory, exec_sandbox}`. - `t0`: instance binds. Memory handle `H` opened against `ns://agent-7f3a`. Scope set `S1` cached in the execution context. - `t1` (+47 min): operator rotates the credential to `C2`. New subject is the same logical agent but the new scope set is `{read_web, write_memory}` — `exec_sandbox` was revoked because the task phase moved from exploration to synthesis. The namespace subject field is unchanged (`agent-7f3a`), so the memory handle `H` remains valid. - `t1` to `t2`: the instance, mid-reasoning, decides it needs to run a snippet to validate a numeric claim. It dispatches `exec_sandbox` using the *cached* `S1` scope set. The tool gateway, which validates against the credential presented on the call, still accepts `C1`'s warrant until `C1`'s TTL lapses at `t1+15min`. The call succeeds. The instance records the result into `ns://agent-7f3a` via `H`. - `t2` (+1h 22min): `C1`'s warrant TTL lapses. The next `exec_sandbox` dispatch is rejected with `scope_denied`. The instance, having no model of scope rotation, interprets this as a transient tool failure and retries three times, then falls back to a *different* tool (`read_web`) to approximate the computation — producing a numerically different answer that it now writes into memory as authoritative, overwriting the earlier validated result. - `t3` (checkpoint replay): the auditor replays the task against the final credential `C2`. It finds two `exec_sandbox` calls that `C2` never authorized, a memory write that replaced a validated value with an approximation, and a namespace handle whose provenance chain references a credential that no longer exists in the audit log's active set. The observable signature is not an exception. It is: **successful tool calls that the final identity was never entitled to make, followed by a silent quality regression in memory that only surfaces at replay.** ## Condition of Validity The invariant that must hold is: > For any instance execution, every tool dispatch must be authorized by the *currently active* credential's scope set, and every memory write must be attributed to a namespace whose subject is *stable across* credential rotation. These are two separate bindings and must be tracked separately. This holds only when the runtime distinguishes: 1. **Namespace identity** — durable, stable across rotation, keyed on logical agent ID, not credential ID. 2. **Warrant identity** — per-call, re-read from the active credential at dispatch time, never cached across a rotation boundary. The failure requires the conjunction of: (a) a credential rotation during an active task, (b) a cached scope set that outlives the rotation, and (c) a tool gateway whose warrant TTL exceeds the rotation propagation delay — the window where the stale warrant is still accepted. Remove any one and the divergence collapses. In particular, if the gateway revokes `C1`'s warrant atomically with rotation, the stale dispatch fails loudly and the instance cannot silently proceed. The dangerous configuration is the *soft* rotation with a grace window. ## Decision Boundary The instance must decide, at each tool dispatch and each memory write, which binding it is consulting: - **Memory write** → consult the namespace handle. If the handle's subject no longer matches the active credential's logical agent ID, this is a *namespace rebind*, not a rotation: halt and re-open the namespace explicitly, do not silently continue writing to the old handle. A subject mismatch on the memory path is a hard stop. - **Tool dispatch** → consult the active credential *now*. If the cached scope set differs from the active credential's scope set, discard the cache and re-evaluate. A scope that was present and is now absent is a *capability withdrawal*, not a transient error: the instance must not retry, must not fall back to an approximate tool, and must surface the withdrawal as a task-affecting event. - **The boundary case** — rotation where subject is stable but scopes narrowed — is the one that must be handled explicitly. It is the only case where the memory handle stays valid while the warrant changes, and it is exactly the case the naive implementation gets wrong. The guardrail is a **binding-generation counter**: every credential rotation increments a generation number attached to the execution context. The memory handle records the generation at open time and is only invalidated if the *subject* changes. The scope cache records the generation and is invalidated on *any* generation bump. A dispatch that finds `scope_cache.generation < context.generation` must refresh before proceeding, and a refresh that yields a narrower set must raise rather than degrade. ## Operational Effect Without the split binding, the instance exhibits **silent capability drift**: it continues to act on authority it no longer holds, and because the actions succeed (within the grace window) it has no signal to correct. The downstream effect is not a crash but a *provenance corruption* — memory entries written under a warrant that the final identity cannot be shown to have held, which invalidates checkpoint replay and forces the auditor to quarantine the entire namespace segment. With the split binding, the rotation at `t1` produces an immediate, loud event: the next `exec_sandbox` dispatch detects `scope_cache.generation < context.generation`, refreshes, finds `exec_sandbox` absent, and raises a capability-withdrawal error that the planner must handle — either by deferring the computation, requesting re-authorization, or recording the result as *unvalidated* rather than overwriting the prior validated value. The memory handle is untouched because its subject is stable; the episodic history survives the rotation intact, which is the whole point of separating the two bindings. The general lesson: **when one credential carries both a durable binding and a per-call capability, the durable binding must be keyed on a stable identity and the capability must be re-read at every use.** Conflating them produces a system that is correct in steady state and silently wrong across every rotation boundary — and rotation boundaries are precisely when authorization is most likely to have changed for a reason. ```python class ScopeWithdrawalError(RuntimeError): """Raised when a tool dispatch is attempted under a scope set that the active credential no longer grants. This is a capability withdrawal, not a transient failure: callers must not retry or fall back.""" pass class BindingGenerationMismatch(RuntimeError): """Raised when the memory namespace subject no longer matches the active credential's logical agent ID. Hard stop: the instance is writing to a namespace it no longer owns.""" pass class ExecutionContext: def __init__(self, logical_agent_id: str, generation: int, scopes: frozenset): self.logical_agent_id = logical_agent_id self.generation = generation self.scopes = scopes class MemoryHandle: def __init__(self, namespace: str, subject: str, opened_generation: int): self.namespace = namespace self.subject = subject self.opened_generation = opened_generation def dispatch_tool(ctx: ExecutionContext, scope_cache: dict, tool: str) -> None: # Refresh scope cache if the credential generation has advanced. if scope_cache.get("generation") != ctx.generation: scope_cache["generation"] = ctx.generation scope_cache["scopes"] = ctx.scopes active = scope_cache["scopes"] if tool not in active: # Do NOT retry, do NOT fall back to an approximate tool. raise ScopeWithdrawalError( f"tool {tool!r} withdrawn at generation {ctx.generation}; " f"active scopes={sorted(active)}" ) def write_memory(ctx: ExecutionContext, handle: MemoryHandle, value: str) -> None: # Namespace binding is keyed on subject, not generation. Generation # bumps alone do not invalidate the handle; subject changes do. if handle.subject != ctx.logical_agent_id: raise BindingGenerationMismatch( f"memory handle subject {handle.subject!r} != active agent " f"{ctx.logical_agent_id!r}; refusing write to {handle.namespace}" ) # ... perform the write ... ```