Repository navigation
Conversation
Visible spawn cleanup used an admin-only sessions.delete, so a caller with operator.write could create the child but never remove it after a failed start. Use the operator.write archive-then-delete contract instead.
Keep this change to reporting the child start error and logging cleanup failures. The write-only rollback moves to a Gateway-owned follow-up.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 28, 2026, 11:17 AM ET / 15:17 UTC (Revision 4). ClawSweeper reviewWhat this changesThe branch reports specific visible-task start errors and makes the Gateway remove a newly created child session when its first task is rejected, with protocol documentation and regression tests. Merge readiness✅ Ready for maintainer review This remains a useful, distinct fix. Current main still leaves failed visible-task cleanup to an admin-scoped delete, while the branch has convincing Gateway-level evidence that a write-only operator receives the start error and does not retain the failed child. The prior review’s measured test-cost request is addressed. Priority: P1 Review scores
Verification
How this fits togetherThe agent’s visible-task tool asks the Gateway to create a child session and start its first turn. The Gateway records the child, sends the task, and returns either a started run or a failure that the tool reports to the agent. flowchart LR
A[Visible task request] --> B[Gateway session creation]
B --> C[Committed child]
C --> D[First task send]
D --> E{Task started?}
E -->|Yes| F[Active child run]
E -->|No| G[Guarded child cleanup]
G --> H[Start error or retained child]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +108, Tests +402, Docs 0. Total +510 across 10 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep rollback in the Gateway’s session lifecycle owner, fenced to the child created by that request, while tracking the broader Android Talk approval and task-continuity symptoms separately. Do we have a high-confidence way to reproduce the issue? Yes, with high confidence from the source path and the contributor’s before-and-after Gateway trace: a write-only client triggers a visible spawn whose first send is denied by session policy. I did not execute the checkout. Is this the best way to solve the issue? Yes. The creating Gateway request is the narrow owner that can remove only its own unstarted child while preserving the existing result when cleanup declines. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 1a94ee9ed7e2. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
@clawsweeper re-review Added measured test cost per changed test file and a CI note: the remaining failures are timeouts in unrelated suites. The PR body has the evidence (shard order, code path, local reruns). |
|
🦞👀 Re-review progress:
|
|
Related update: #160296 is merged on main with eligible write-operator archive/restore/Stop controls, while retaining deletion restrictions. It does not perform generation-fenced rollback when a visible |
|
This pull request has been automatically marked as stale due to inactivity. |
Related: #159862
Stacked on #159940. Review only commit
e77c394fd72; the earlier commits belong to #159940 and drop out once it lands, and the later ones are amainmerge and an empty CI retrigger.What Problem This Solves
Fixes: when a visible
sessions_spawntask fails to start for an operator withoperator.writebut nooperator.admin, the failed child session is left behind and the model is toldSession cleanup unconfirmed.User Impact
User impact: a failed visible task leaves no child behind for any caller that could create it, and the model gets the start error directly (for example
send blocked by session policy). Callers withoperator.adminsee the same outcome as before, reported as a tool error instead of a structured error result.Why This Change Was Made
The tool's cleanup runs
sessions.delete, which needsoperator.admin. In-process tool calls are intersected with the caller's operator authority, so a write-only caller could create the child but never remove it.Now
sessions.createowns rollback of the child it created. When a spawn-owned visible child (via: "spawn"with a completion owner) has an initial task that never started, the same request deletes it through the shareddeleteGatewaySessionowner and returns the start error. That delete:emitLifecycleHooks: false, matching the old tool cleanup, so hook behavior does not change.If the rollback declines,
sessions.createreturns the old successful result withrunStarted: false, and the tool's existing cleanup and message apply. Othersessions.createcallers, including worker spawns without a completion owner, Control UI placement, and deferred worktree setup, keep the documented "child survives a rejected first send" contract. The protocol doc now describes the spawn exception.Evidence
Real Gateway, write-only client. The new
src/gateway/server.visible-spawn-start-failure.product-proof.test.tsstarts a real Gateway server and a real WebSocket client declaringoperator.approvals, operator.questions, operator.read, operator.write, with a fake OpenAI Responses provider whose parent turn callssessions_spawn { task, visible: true }. Asession.sendPolicydeny rule on the dashboard prefix makes the child's first send fail. The client sendschat.send, waits withagent.wait, then readssessions.list. Redacted output:Before (this change reverted, #159940 head):
{ "spawnToolOutput": "{ \"status\": \"error\", \"error\": \"send blocked by session policy. Session cleanup unconfirmed. Inspect the child session before retrying.\", \"childSessionKey\": \"agent:main:dashboard:<uuid>\" }", "dashboardChildren": ["agent:main:dashboard:<uuid>"] }After:
{ "spawnToolOutput": "{ \"status\": \"error\", \"tool\": \"sessions_spawn\", \"error\": \"send blocked by session policy\" }", "dashboardChildren": [] }Real handler chain.
src/gateway/server.sessions.visible-spawn-failure.test.tsruns the registered tool through in-process dispatch as an admin Control UI client and as a paired write-only operator profile (the incident's shape). Both now report the start error and leave only the parent session. A third case resets a child and then asks the rollback to delete the original incarnation: the session id is unchanged, the lifecycle revision differs, and the child is kept. These tests fail without thesessions-create.tschange, and the fence case fails if the lifecycle-revision fence is dropped.Checks. The visible-spawn, product-proof, child-custody, worktree-spawn, and visible-spawn-fallback Gateway suites pass (80 tests), as does
sessions-spawn-tool.test.ts.pnpm tsgo:coreandpnpm tsgo:core:testpass, and oxlint and oxfmt are clean. An independent review found no blocking issues. Its should-fix findings (protocol doc, and revalidating only session authority rather than creation-time selections) are addressed.Test cost. Measured locally with
node scripts/run-vitest.mjs run <file> --maxWorkers=1, and from the test times in CI run 36420025695, where all three files passed.src/agents/tools/sessions-spawn-tool.test.ts(changed in #159940, unchanged here)agentic-agents-tools)src/gateway/server.sessions.visible-spawn-failure.test.ts(two cases added)agentic-control-plane-agent-chat)src/gateway/server.visible-spawn-start-failure.product-proof.test.ts(new)agentic-control-plane-runtime-state-hosted-2)CI note. The first run failed
check-test-typesontest/scripts/ci-static-check-evidence.test.ts, whichmainbroke at 02:27 UTC and fixed at 03:08 UTC. After mergingmain, run 36420025695 had five timeouts in areas this diff does not reach: a Control UI sidebar e2e test, a Telegram history test, achat.sendhistory test, Gateway node shutdown, and a subagent requester-wake e2e test that mocks the Gateway.mainwas green at the same base, and GitHub refuses job reruns here, so an empty commit retriggers CI.Not covered. Only the send-policy rejection is exercised; other pre-acknowledgement send failures are expected to leave the lifecycle revision unchanged and follow the same path. Live Android proof was not run.