Repository navigation
fix(gateway): prevent workspace adoption during active session work - #157259
Conversation
Reject existing-session workspace preparation before allocation when admitted work or an embedded/reply run is active. Keep idle adoption on the original session and transcript, and hold queued work through commit or rollback using canonical, alias, and session ID lifecycle identities. Extract target admission policy into an internal helper so the oversized creation owner does not grow. Preparation callbacks, including worktree replay, return retryable busy until idle; unchanged bindings without a callback remain available. Validate active-owner rejection, identity drift, transcript preservation, queued admission ordering, and unrelated session progress. Focused tests: 16 passed. Exact-base changed checks, pinned formatting, core and test typechecks, lint, and owner guards passed.
|
🦞👀 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. |
|
@clawsweeper automerge |
|
🦞👀 Approver: I left the PR open for the remaining gate instead of bypassing it. Automerge progress:
|
|
Codex review: blocked before merge. Reviewed September 24, 2026, 11:18 AM ET / 15:18 UTC (Revision 4). ClawSweeper reviewWhat this changesGateway session creation returns a retryable busy result before changing an active session’s workspace, while preserving idle adoption and adding session lifecycle tests. Merge readiness⛔ Blocked before merge - 2 items remain Current main still allows workspace preparation to begin for an existing session with active work. The PR addresses that gap without an actionable code finding. Its explicit human-review pause remains the merge blocker. Priority: P1 Review scores
Verification
How this fits togetherGateway session creation receives chat and session requests, prepares workspace resources, and persists the session. Session work admission tracks turns that must finish before an existing workspace binding changes. flowchart LR
A[Session request] --> B[Existing session lookup]
B --> C[Lifecycle custody]
C --> D{Active work?}
D -->|Yes| E[Retryable busy result]
D -->|No| F[Workspace preparation]
F --> G[Session commit]
Decision needed
Why: The requested measurements are in the PR body, but the explicit human-review hold still requires a maintainer to resolve it. Before merge
Agent review detailsSecurityNone. PR surfaceSource +82, Tests +289. Total +371 across 3 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep workspace changes inside the session creation owner’s lifecycle custody, reject active targets before preparation, and preserve the existing session identity and transcript on idle adoption. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main can prepare a workspace for an existing active target without checking its admitted work. This read-only review did not execute the baseline. Is this the best way to solve the issue? Yes. The creation owner already holds lifecycle custody through preparation and rollback, so checking active work there is a narrow repair. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 86192cd70df7. 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 |
|
🦞✅ Source: Why human review is needed: What the maintainer can do as a next step: I added |
|
@clawsweeper automerge |
|
🦞👀 Command router queued. I will update this comment with the next step. |
|
@clawsweeper approve |
|
🦞👀 Command router queued. I will update this comment with the next step. |
* commit '9ccfc7d1bea21e34da48edbd54afd2e1be57db40': (89 commits) fix(exec): avoid gateway stalls during background task writes (#157177) test(cli): isolate preaction title setter state fix(test): synchronize Git backoff cancellation readiness (#157315) fix: validate Codex model references in Docker (#157175) fix(state): tolerate brief WAL coordinator contention (#157121) fix: unblock conversations after recovery preparation fails (#157214) test(telegram): avoid wall-clock pacing in HTTP conformance (#157281) fix: keep independent database work responsive under load (#157230) refactor(sqlite): centralize WAL checkpoint execution (#157263) improve(android): show tool outcomes in collapsed work (#156950) fix: remove tracked release scratch blocking source capture (#157308) test(update): remove legacy probe stream ordering race fix: preserve steering across reconnects and show queued input (#157135) fix(ui): keep typing focus when the GitHub reader opens (#157202) fix(ios): keep screenshot logs outside capture evidence test(codex): await startup teardown in lifecycle fixtures chore(ui): refresh control ui locales (#157311) refactor(memory): deslop memory plugins (#156867) refactor(test): share CLI diagnostics fixture setup (#157201) fix(release): retry notarization submit/wait on transport failures and name the resume command (#157116) ...
|
@clawsweeper approve |
|
Merged via squash.
|
* commit '02ad6b76b1a2ee2b414b170072e6e3e606fda3d4': (134 commits) fix(build): scope normalization declarations to package sources (#157174) fix: exit after validating Codex model references (#157323) fix(gateway): guard workspace adoption during active work (#157259) fix(update): rebuild stale Git runtimes when source is already current (#156996) fix: require a click before diagnosing failed updates (#157359) test(release): provide sealed artifact inputs to writer fixtures fix(ios): preserve chat state and adapt layout when iPad windows resize (#156683) fix(test): prepare native UI fixtures before compilation fix(test): await outbound delivery readiness before assertions fix: clarify deferred Codex catalog refresh warnings (#157352) fix(skills): refresh skills after watched directories are replaced (#156324) ci: reduce Node fixture overhead and defer seven release matrices (#157341) chore(test): stop Codex Computer Use and Signal batching tests flaking under load (#157334) fix(gateway): retain owned suspension status during restart (#157258) fix(ci): scope desktop status assertions to the selected worker chore(i18n): refresh native locales (#157337) test(daemon): use the native PowerShell probe budget (#157289) fix(exec): avoid gateway stalls during background task writes (#157177) test(cli): isolate preaction title setter state fix(test): synchronize Git backoff cancellation readiness (#157315) ...
* commit 'c4333da677cbdfe1bbaf783ed01c363ff39e93b8': (100 commits) fix(test): stop preflight mocks leaking into shared workers (#157207) fix(build): scope normalization declarations to package sources (#157174) fix: exit after validating Codex model references (#157323) fix(gateway): guard workspace adoption during active work (#157259) fix(update): rebuild stale Git runtimes when source is already current (#156996) fix: require a click before diagnosing failed updates (#157359) test(release): provide sealed artifact inputs to writer fixtures fix(ios): preserve chat state and adapt layout when iPad windows resize (#156683) fix(test): prepare native UI fixtures before compilation fix(test): await outbound delivery readiness before assertions fix: clarify deferred Codex catalog refresh warnings (#157352) fix(skills): refresh skills after watched directories are replaced (#156324) ci: reduce Node fixture overhead and defer seven release matrices (#157341) chore(test): stop Codex Computer Use and Signal batching tests flaking under load (#157334) fix(gateway): retain owned suspension status during restart (#157258) fix(ci): scope desktop status assertions to the selected worker chore(i18n): refresh native locales (#157337) test(daemon): use the native PowerShell probe budget (#157289) fix(exec): avoid gateway stalls during background task writes (#157177) test(cli): isolate preaction title setter state ...
* commit '02ad6b76b1a2ee2b414b170072e6e3e606fda3d4': (122 commits) fix(build): scope normalization declarations to package sources (#157174) fix: exit after validating Codex model references (#157323) fix(gateway): guard workspace adoption during active work (#157259) fix(update): rebuild stale Git runtimes when source is already current (#156996) fix: require a click before diagnosing failed updates (#157359) test(release): provide sealed artifact inputs to writer fixtures fix(ios): preserve chat state and adapt layout when iPad windows resize (#156683) fix(test): prepare native UI fixtures before compilation fix(test): await outbound delivery readiness before assertions fix: clarify deferred Codex catalog refresh warnings (#157352) fix(skills): refresh skills after watched directories are replaced (#156324) ci: reduce Node fixture overhead and defer seven release matrices (#157341) chore(test): stop Codex Computer Use and Signal batching tests flaking under load (#157334) fix(gateway): retain owned suspension status during restart (#157258) fix(ci): scope desktop status assertions to the selected worker chore(i18n): refresh native locales (#157337) test(daemon): use the native PowerShell probe budget (#157289) fix(exec): avoid gateway stalls during background task writes (#157177) test(cli): isolate preaction title setter state fix(test): synchronize Git backoff cancellation readiness (#157315) ...
* test(ui): cover stack-free tooltip disconnect cleanup * fix(build): scope normalization declarations to package sources Give normalization-core its own TypeScript project so declaration generation does not load the repository-wide source set. Preserve the existing DTS build command and compiler policy. * Merge normalization declaration scope for tooltip proof * commit '81aeccb3db80136a118d6d2f98b67d836ec25e51': fix(build): scope normalization declarations to package sources * fix(ui): avoid retaining tooltip anchors in abort reasons * Merge main to include native wrapper source inventory repair * commit '02ad6b76b1a2ee2b414b170072e6e3e606fda3d4': (134 commits) fix(build): scope normalization declarations to package sources (#157174) fix: exit after validating Codex model references (#157323) fix(gateway): guard workspace adoption during active work (#157259) fix(update): rebuild stale Git runtimes when source is already current (#156996) fix: require a click before diagnosing failed updates (#157359) test(release): provide sealed artifact inputs to writer fixtures fix(ios): preserve chat state and adapt layout when iPad windows resize (#156683) fix(test): prepare native UI fixtures before compilation fix(test): await outbound delivery readiness before assertions fix: clarify deferred Codex catalog refresh warnings (#157352) fix(skills): refresh skills after watched directories are replaced (#156324) ci: reduce Node fixture overhead and defer seven release matrices (#157341) chore(test): stop Codex Computer Use and Signal batching tests flaking under load (#157334) fix(gateway): retain owned suspension status during restart (#157258) fix(ci): scope desktop status assertions to the selected worker chore(i18n): refresh native locales (#157337) test(daemon): use the native PowerShell probe budget (#157289) fix(exec): avoid gateway stalls during background task writes (#157177) test(cli): isolate preaction title setter state fix(test): synchronize Git backoff cancellation readiness (#157315) ... Co-authored-by: Vincent Koc <[email protected]>
…57259) Reject existing-session workspace preparation before allocation when admitted work or an embedded/reply run is active. Keep idle adoption on the original session and transcript, and hold queued work through commit or rollback using canonical, alias, and session ID lifecycle identities. Extract target admission policy into an internal helper so the oversized creation owner does not grow. Preparation callbacks, including worktree replay, return retryable busy until idle; unchanged bindings without a callback remain available. Validate active-owner rejection, identity drift, transcript preservation, queued admission ordering, and unrelated session progress. Focused tests: 16 passed. Exact-base changed checks, pinned formatting, core and test typechecks, lint, and owner guards passed.
* test(ui): cover stack-free tooltip disconnect cleanup * fix(build): scope normalization declarations to package sources Give normalization-core its own TypeScript project so declaration generation does not load the repository-wide source set. Preserve the existing DTS build command and compiler policy. * Merge normalization declaration scope for tooltip proof * commit '81aeccb3db80136a118d6d2f98b67d836ec25e51': fix(build): scope normalization declarations to package sources * fix(ui): avoid retaining tooltip anchors in abort reasons * Merge main to include native wrapper source inventory repair * commit 'f11e16cd65951f284264bd202b49984e21091cf5': (134 commits) fix(build): scope normalization declarations to package sources (openclaw#157174) fix: exit after validating Codex model references (openclaw#157323) fix(gateway): guard workspace adoption during active work (openclaw#157259) fix(update): rebuild stale Git runtimes when source is already current (openclaw#156996) fix: require a click before diagnosing failed updates (openclaw#157359) test(release): provide sealed artifact inputs to writer fixtures fix(ios): preserve chat state and adapt layout when iPad windows resize (openclaw#156683) fix(test): prepare native UI fixtures before compilation fix(test): await outbound delivery readiness before assertions fix: clarify deferred Codex catalog refresh warnings (openclaw#157352) fix(skills): refresh skills after watched directories are replaced (openclaw#156324) ci: reduce Node fixture overhead and defer seven release matrices (openclaw#157341) chore(test): stop Codex Computer Use and Signal batching tests flaking under load (openclaw#157334) fix(gateway): retain owned suspension status during restart (openclaw#157258) fix(ci): scope desktop status assertions to the selected worker chore(i18n): refresh native locales (openclaw#157337) test(daemon): use the native PowerShell probe budget (openclaw#157289) fix(exec): avoid gateway stalls during background task writes (openclaw#157177) test(cli): isolate preaction title setter state fix(test): synchronize Git backoff cancellation readiness (openclaw#157315) ... Co-authored-by: Vincent Koc <[email protected]>
What Problem This Solves
Fixes an existing chat's workspace being changed while its current turn still owns active work.
User Impact
Workspace adoption now returns a retryable busy result until existing work finishes. Idle adoption preserves the session identity and conversation history. A preparation callback, including a repeated worktree request, waits until idle; an unchanged binding without a callback remains available.
Why This Change Was Made
The lifecycle fence queued new work but did not stop work that had already been admitted. The creation owner now checks that work before filesystem preparation can allocate anything, revalidates the target identity after acquiring custody, and fences the canonical key, aliases, and session ID through commit or rollback. Target admission lives in a small internal helper so the oversized creation service does not grow.
Evidence
The measurements below are from the original
41d076f→a6b119fecandidate. Headf5bb75425f7816f0d3339ba528e160ca8c26ef7fpreserves that exact three-file patch and merges main at9ccfc7d1bea21e34da48edbd54afd2e1be57db40. The affected creation/admission owners, test file, and lockfile are unchanged between those bases. Fresh PR-head CI is required for the incorporated main context.node scripts/run-vitest.mjs src/gateway/session-create-preparation.test.ts: 16/16 passed; 50.93 seconds including the wrapper. Covers acquired work by canonical key, alias, and session ID; an embedded owner without an admission lease; target identity drift; unchanged-binding adoption; nonempty transcript preservation; queued work through successful commit and rollback; unrelated-session progress; and the existing creation cases.41d076f30b32737723a3410af395d43c1b6dd00c. Current PR-head CI and native landing checks remain required. Live chat migration and deployment are separate operator steps.Test cost
The required before/after one-worker measurement passed on a fresh Blacksmith Testbox (workflow run), Linux x64, Node 24.19.0, pnpm 12.4.2:
41d076f30b32737723a3410af395d43c1b6dd00ca6b119fe1e36f4003da5188c3d93acda1a9d2aa4Command on each revision:
corepack pnpm test src/gateway/session-create-preparation.test.ts --maxWorkers=1 --reporter=json --outputFile=<temporary-report>.These are sequential single samples, baseline first, using identical frozen dependency inputs, separate physical installs, and fresh per-revision Node compile and Vitest filesystem module caches. The machine and OS page cache were shared; this is measured test cost, not a statistical performance claim. Wall time includes compilation and worker setup. The additional cases cost 16.167 s wall / 11.405 s file time in this pair.
The measured one-worker file interval is below the 30 s test-time explanation threshold, though above the 5 s target. It exercises real session creation, persistence, transcript preservation, and admission ordering through preparation, commit, and rollback. Explicit deferred gates coordinate the races without sleeps; a mocked predicate would not prove those owner-ordering contracts.
Hosted CI on original head
a6b119fealso passed all 16 cases in checks-node-changed-compact-large-28. Its 16 reported case durations sum to 37.356 s; the entire shared job took 194 s, which is not attributable to this file alone. The hosted case-time sum exceeds 30 s, so the owner-level persistence and lifecycle-ordering contracts above justify retaining this coverage. It does not start a Gateway per test or use real sleeps. The three changed source/test files are unchanged, and the benchmark Testbox has been stopped.The two original attached CI attempts timed out in the central hosted typecheck row without a TypeScript diagnostic. The refreshed base includes the landed hosted-profile stripe fix; no CI source changes are added by this PR.
Production delta: +82 lines, including the internal extraction and active-work invariant. Test delta: +289 lines.