Repository navigation
fix(gateway): prevent sessions from using unconfigured agents - #127661
Conversation
Validate the canonical configured owner before session and worktree side effects so dispatch, reclaim, and delete can manage every created session.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 21, 2026, 6:34 PM ET / 22:34 UTC. ClawSweeper reviewWhat this changesThe PR makes Gateway session creation reject explicit or key-derived agents that are absent from the configured agent roster before session or worktree side effects. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessNo blocking patch defect found. This remains the candidate fix for the linked Gateway lifecycle bug and needs protected maintainer review of its deliberate compatibility change. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: FAIL (partial) — step 2 Assertions:
How this fits togetherGateway session creation turns RPC requests into persisted session state and optional managed worktrees. Later dispatch, reclaim, and deletion use the same agent owner, so creation must select an owner those operations can manage. flowchart LR
Request[Session creation request] --> Resolve[Resolve configured owner]
Resolve --> Valid{Owner configured?}
Valid -->|No| Reject[Invalid request]
Valid -->|Yes| Create[Persist session and worktree]
Create --> Lifecycle[Dispatch, reclaim, delete]
Decision needed
Why: The implementation is internally consistent, but it intentionally changes the response for existing callers and the PR carries the protected maintainer label. Before merge
Agent review detailsSecurityNone. PR surfaceSource -52, Tests +100. Total +48 across 5 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the single configured-owner admission rule after confirming immediate rejection is the intended upgrade behavior, while retaining historical read access for removed-agent sessions. Do we have a high-confidence way to reproduce the issue? Yes—current main’s resolver explicitly permits the unconfigured owner only for creation, and the added Gateway-boundary test exercises the resulting worktree lifecycle path. Is this the best way to solve the issue? Yes—the patch removes the creation-only exception at the shared owner-resolution boundary rather than compensating after state or worktree allocation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against fd0c9f6f96f2. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Maintainer decision: accept the intentional fail-fast compatibility change. Creating a session for an unconfigured explicit or key-derived owner is invalid because the resulting session and managed worktree cannot be dispatched, reclaimed, or deleted through the normal lifecycle. The live team-server reproduction demonstrated that exact stranded state. Rejecting the request before durable session or worktree side effects is the intended behavior; historical reads for removed-agent sessions remain unchanged. Landing proof for exact head
The ClawSweeper terminal-output observer timed out while its Vitest command was still running; that observer timeout is not treated as a product-test failure because the exact-head CI and authored focused test runs completed successfully. |
|
Merged via squash.
|
Validate the canonical configured owner before session and worktree side effects so dispatch, reclaim, and delete can manage every created session.
Closes #127659
What Problem This Solves
Fixes an issue where creating a dashboard session with a stale or otherwise unconfigured explicit agent selection could succeed, but later dispatch, reclaim, and delete operations rejected that same session as owned by an unknown agent. Managed-worktree sessions could therefore become impossible to continue or clean up through the normal lifecycle.
Why This Change Was Made
Session creation now uses the same configured-agent ownership policy as the rest of the lifecycle and validates the canonical owner before filesystem, session-store, or managed-worktree side effects. Agent-qualified creation keys count as explicit ownership, while the separate historical-read contract for sessions whose agent was later removed remains intact.
The creation-only permissive resolver option and duplicate selection branches were removed. Production code is net negative: +22/-74 lines (net -52).
User Impact
Operators can no longer create sessions under an unconfigured agent owner. Invalid requests fail immediately with
Unknown agent id, while configured explicit owners and valid implicit owner selection remain fully manageable through create, dispatch, reclaim, and delete.Evidence
Pre-fix regression proof: the new worktree lifecycle test received
ok: trueand allocated anagent:main:dashboard:*worktree whereINVALID_REQUESTwas expected.Post-fix validation:
node scripts/run-vitest.mjs src/gateway/session-request-agent.test.ts— 20 passednode scripts/run-vitest.mjs src/gateway/server.sessions.delete-worktree-lifecycle.test.ts— 16 passednode scripts/run-vitest.mjs src/gateway/server.sessions.create.test.ts— 224 passednode scripts/check-changed.mjs -- src/gateway/session-request-agent.ts src/gateway/server-methods/sessions-create.ts src/gateway/session-create-service.ts src/gateway/server.sessions.delete-worktree-lifecycle.test.ts src/gateway/server.sessions.create.test.ts— passedgit diff --check— passedThis change was AI-assisted and reviewed. The implementation and owner boundary were inspected directly, and the regression test was demonstrated failing before the production fix.