Repository navigation
Description
Problem
ADR 0350 — Session-scoped agent identity
lets a session bind to an AgentDef and builds its catalog exclusively from that
def's tools/disallowedTools/mcpServers:. That restriction is enforced correctly at
session-creation time, but the engine backing a session gets rebuilt at several other
points in its lifecycle, and none of those rebuild paths currently know a session is
agent_id-bound:
engineAndEnvironmentForCASE 1 (internal/adapter/server/service.go) — rebuilds the
per-session engine when aSetMode(plan↔default↔acceptEdits) switch re-resolves the
model.engineAndEnvironmentForCASE 2 — promotes a shared-engine session to a per-session
engine when its mode needs a different model.rehydrateSession/needsRehydration— rebuilds the per-session engine after a
process restart (mecak8s pod restart, crash, rolling redeploy). This is not a
caller action; it will happen routinely in any long-lived deployment.LoadSessionWithMCP— rebuilds the per-session engine when a client re-supplies MCP
servers on resume.
Every one of these rebuilds goes through the same generic sessionEngineFactory /
assembleCatalog path that every other session uses — reading only
ProviderID/ModelID/Profile/ReasoningEffort off the persisted session, never
AgentID. So an agent_id-bound session that survives any of these rebuilds would
silently regain the full default catalog, defeating the tool-restriction ceiling ADR
0350 exists to guarantee.
This was raised in PR #1783's review
(points 1 and 4: "persisted authority attenuation" and "restart semantics").
What ADR 0350's v1 does about it
v1 closes the hole with a coarse, fail-closed guard rather than a real fix: SetMode is
rejected outright for agent_id-bound sessions (removing CASE 1/2 as triggers), and
rehydration/resume for an agent_id-bound session fails closed after a restart (refuses
to resume) instead of silently rebuilding on the default catalog. This is deliberately
minimal — it trades session continuity across a restart for a guaranteed non-widening
guarantee, which is an acceptable v1 cost for the motivating use case (a Slack bot
identity, issue #1053) but not a real solution.
What the real solution looks like (roughly the reviewer's proposal)
- A persisted-authority concept, not just a one-time catalog build: resolving an
AgentDefmints the session's persisted authority (an attenuation of the deployment's
root authority to the def's effective capabilities). Every subsequent engine
construction —SetModerebuild, restart rehydration, MCP-resume rebuild, and any
future rebuild trigger — must be provably a subset of that persisted authority, never
a fresh derivation that can drift wider. - Restart rehydration re-resolves the persisted
agent_idagainst the current admitted
definition registry (prompt/hooks/skills/memory may update; authority may not widen). A
missing definition fails closed, as it already does at creation. LoadSessionWithMCPmust refuse (or a-priori ignore) client-supplied MCP servers for an
agent_id-bound session, the same way session creation already does.
Scope
This issue tracks the full fix. It does not commit to a specific abstraction (e.g.
whether "persisted authority" becomes a first-class type threaded through
tool.Environment/session snapshot, or is expressed as a narrower rebuild-path check) —
that's design work for whoever picks this up, informed by the review thread linked above.
Fully or partially written by an AI agent.
Activity
docs: ADR 0350 — fail-closed guard for engine-rebuild paths
plan: resolve all 7 human decisions, move to proposed
plan: resolve all 7 human decisions, move to proposed
plan: resolve all 7 human decisions, move to proposed