Repository navigation
fix(worker): publish placement state after turn settlement - #170575
Conversation
|
🦞👀 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 SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesThis PR publishes a placement lifecycle event after committed settlement clears both the turn claim and pending workspace result. Example: A worker finishes reconciliation for agent:main:placement-claim-close after delivering its final reply.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR repairs a current settlement-notification gap at the existing owner boundary; no actionable correctness or security findings were identified. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherGateway placement workers commit turn settlement, install authoritative placement facts, and notify the lifecycle bridge that publishes session updates to authorized WebSocket subscribers. flowchart LR
A[Worker final reply] --> B[Workspace reconciliation]
B --> C[Committed turn settlement]
C --> D[Installed placement facts]
D --> E[Placement lifecycle event]
E --> F[Session WebSocket bridge]
F --> G[Authorized subscribers]
Technical reviewBest possible solution: Publish settled placement through the existing lifecycle bridge after committed claim and pending-result facts are installed. Do we have a high-confidence way to reproduce the issue? Source establishes that settlement publishes internal row changes while the WebSocket bridge listens to lifecycle events; no target code was executed during this review. Is this the best way to solve the issue? The patch fixes the missing signal at the committed placement owner and preserves early replies, recovery fences, and existing recipient authorization. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b1c08d51fab3. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +9, Tests +28. Total +37 across 2 files. Added test files: 0. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed October 12, 2026, 11:51 PM ET / October 13, 2026, 03:51 UTC (Revision 2). |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 38916dd50d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| projectionPublication?.release(); | ||
| } | ||
| } | ||
| if (close && receipt.placement.turnClaim === null && receipt.workspaceResult === null) { |
There was a problem hiding this comment.
Gate closure events on installed placement facts
For placementTurns.startReconcile and placementTurns.fail transitions that close a worker claim, notifySession above is false, but close is populated from closedClaim and workspaceResult is null, so this branch emits anyway. Because the runtime-scoped lifecycle path is display-only and no exact sessionChanges publication installs or invalidates the resident placement first, the Gateway can broadcast the pre-transition placement and stale turn claim until a later publisher corrects it. Require the exact placement publication before emitting, or restrict this event to operations where notifySession ran.
AGENTS.md reference: src/gateway/AGENTS.md:L36-L38
Useful? React with 👍 / 👎.
## What Problem This Solves Three selectively run node-worker E2Es assert ordering that #169484 intentionally retired by delivering the durable reply before workspace reconciliation. The skill-library E2E also exposed a retained-transcript regression during its sequential worker flow; its original assertions did not explicitly equate a final reply with settlement. ## User Impact The final diff is test-only. It verifies early replies while preserving claim release, workspace settlement, upgrade recovery, retained-session continuation, and skill-library behavior. ## Change - Native-slot waits on the existing session-change signal, then asserts that the claim and pending result are gone before proving physical-slot reuse. - Upgrade-wire checks its attempted upload after the existing durable recovery observation. - Required-native receives A's final while quiescence is held, preserves the queued-follow-up proof, and waits for B's settled placement. - Skill-library joins workspace settlement before sequential turns; its wire fixture exposes existing events. The updated waits uncovered two production defects: #169622 tied retained transcript facts to a writer that early final releases, and successful claim closure did not reach the existing lifecycle/WebSocket bridge. Those fixes landed separately in #170556 and #170575. Main is now integrated at 38033f1, and the final diff contains only the five test/fixture files. Production LOC: 0. No timers, polling, retries, budgets, or assertion weakening were added. ## Evidence [Integrated CI 38340516247](https://github.com/openclaw/openclaw/actions/runs/38340516247) at 7be861c passed all four E2Es and the required CI gate: | File | Test seconds | Runner seconds | | --- | ---: | ---: | | native-worker-slot | 36.141 | 45.72 | | paired-node-worker-upgrade-wire | 158.587 | 168.53 | | required-native-same-session | 82.785 | 94.17 | | skill-library-worker-wire | 41.308 | 67.21 | [Native/upgrade/same-session log](https://github.com/openclaw/openclaw/actions/runs/38340516247/job/115110480812) shows A and B claims clearing and all four same-session pairs settling on their retained environments. [Skill log](https://github.com/openclaw/openclaw/actions/runs/38340516247/job/115110480823) shows eight remote placements move from reconciling to clear; the complete authoring, continuation, cancellation, and reclaim flow passes. The [unchanged-main probe](https://github.com/openclaw/openclaw/actions/runs/38331787910/job/115083216251) reproduced the original four failures. [Control CI 38339534658](https://github.com/openclaw/openclaw/actions/runs/38339534658/job/115107577910), with only the test alignment and the extra active-run condition removed, still reached a reconciling placement twice and received no further event before the 300-second watchdog. No E2E artifacts were uploaded; the retained Vitest resource was watchdog cleanup evidence, not proof of a product child leak. Changed-file formatting, type-aware lint, and independent review pass with no actionable P0/P1 findings. Local diagnostic command `pnpm test:e2e:gateway test/e2e/qa-lab/runtime/native-worker-slot.e2e.test.ts --maxWorkers=1` took 179.68 seconds before test execution and refused to proceed because artifact separation could not be verified. The guard was preserved; subsequent proof used GitHub CI only, with no leases. The earlier skill local-first rejection with an unsettled database writer remains recorded for the session-actor campaign; this change does not alter that guard. Related credential-diagnostics PR: #170257. Final-head CI 38344788931 has the same inherited main-only TS2724 error as #170575: config-preflight-snapshot.test.ts:41 imports the function made private by main #170530. CI checkout 1e93e8ab merges this head into main 88e5ae8; this test-only PR does not change either config file. [Exact static failure](https://github.com/openclaw/openclaw/actions/runs/38344788931/job/115124083706). The config owner follow-up is recorded; no worker behavior failure is waived. Final test-only head 38033f1 passes all four selected E2Es in CI 38344788931: native-slot 45.28s Vitest / 46.69s runner; upgrade-wire 166.37s / 167.94s; required same-session 100.49s / 102.91s; skill-library 64.35s / 66.24s. Final diff is exactly five test/fixture files and zero production LOC. The only remaining failure is the documented inherited main TS2724 check; landing uses that scoped static-failure exception.
Complete the preflight reader migration in `config-preflight-snapshot.test.ts`. Commit 33a438a (#170530) intentionally made `readConfigPreflightSnapshot` private and moved reads behind `createConfigPreflightSnapshotReader`, which owns and disposes executable inspection caches. The remaining direct test import caused TS2724 in the commands test type project. The diagnostic was observed in run 38344022221/job 115121788481 on PR #170575's synthetic merge; source inspection confirms the same stale caller on main at fcb89a3. Use the existing factory with `await using` in the Doctor test branch and call its `read` method. All snapshot options and behavioral assertions stay unchanged. Disposal completes before the final config, backup, and SQLite-family byte-preservation assertions. The private helper stays private, with no compatibility wrapper or test-only production export. [Exact candidate proof](https://github.com/openclaw/openclaw/actions/runs/38345114058/job/115124606937) checked out `573774fd5d001f19983da243bf241df0bceb6530` and passed the complete `src/commands/config-preflight-snapshot.test.ts`: **19/19, no skips**, 103.81s Vitest / 108.07s runner wall. It also passed the exact failing commands TypeScript leaf: `node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.commands.json --incremental`. The [independent baseline job](https://github.com/openclaw/openclaw/actions/runs/38345114058/job/115124606702) checked out actual main `fcb89a331a1f59eedde59c4b3a338febdb199cb7` with the same setup and naturally reproduced `config-preflight-snapshot.test.ts:41` TS2724 (exit 2). The overall proof workflow is red because that separate baseline fails; the independent candidate test and type steps both pass. No failure was suppressed. [Ordinary CI](https://github.com/openclaw/openclaw/actions/runs/38345111705) completed successfully: **18 jobs passed, 29 skipped**, including the aggregate. Selected test types, lint, source contracts, and boundaries pass; Madge reports zero cycles. T1 live stays 455→455, compatibility stays 9→9, and dialect stays 0→0. Knip, build, update, and SDK-diff jobs were unselected and are not claimed as fresh passes. Scoped formatting, basic lint with warnings denied, whitespace checks, and native hooks passed. One isolated Codex P2 review completed scoped-clean with zero findings. No local suite was run. Scope: one test file, +3/-2 lines; no production, schema, update, or runtime behavior changes. SQL/T1 measurements and published-driver update proof do not apply to this test caller migration. No assertions or safety checks were removed.
…170575) ## What Problem This Solves After openclaw#169484 delivered worker final replies before workspace reconciliation, session subscribers could observe reconciliation in progress without receiving its later completion. The claim owner installed internal row-change facts on completion, but that notification does not reach the existing WebSocket lifecycle bridge. ## Change Publish the existing placement lifecycle event after an owned closure commits with both the turn claim and pending workspace result cleared. Subscribers receive the settled placement after its facts are installed. Retained recovery fences stay pending; ordinary local-turn receipts are excluded. Production LOC: +9, a bounded correctness fix. Three files change; the archive assertion now includes its response for diagnostics without changing the expected result. The existing owner boundary test proves acceptance stays silent and completion publishes already-cleared claim and result authority. No new RPC, lifecycle state, timer, or polling. ## Evidence Changed-file formatting, type-aware lint, and independent review passed with no actionable P0/P1 findings. `pnpm test src/gateway/worker-environments/placement-store.turn-claim-closure.test.ts --maxWorkers=1` was not run locally under the CI-only host constraint; local test wall time is unavailable. The integrated [CI run 38340516247](https://github.com/openclaw/openclaw/actions/runs/38340516247) at 7be861c selected and passed all four affected E2Es with both production fixes: native-slot 36.141 test seconds, upgrade-wire 158.587, same-session 82.785, and skill-library 41.308. Native A/B claims clear, and all four same-session pairs publish the settled placement. This PR runs the focused owner regression and required static gates independently. The four E2E contract updates are tracked separately in openclaw#170537. Release-note context: session subscriptions publish worker workspace settlement after an early final reply. Focused CI run 38341715059 passed all 42 tests in the owner group (21.40 seconds), including the new completion-publication assertion (665 ms), abort and lifecycle closure cases. All selected static gates passed. The prior head had a separate orphaned-provisioning archive failure. Current main passed all 10 archive tests in [probe CI](https://github.com/openclaw/openclaw/actions/runs/38343515030/job/115119831896), so no inherited-failure exception is claimed. This branch is refreshed against that main baseline, and the archive assertion now reports the response if it fails again. Final head 38916dd: [CI 38344022221](https://github.com/openclaw/openclaw/actions/runs/38344022221) passes the archive cases (successful orphan cleanup 2.261s, failing cleanup 2.280s) and all 42 owner-group tests (24.55s, new publication assertion 650ms). The earlier archive failure did not recur after main integration; it is not claimed as inherited proof. The sole remaining static failure is inherited from main openclaw#170530: `src/commands/config-preflight-snapshot.test.ts:41` imports `readConfigPreflightSnapshot`, which that main commit made private. The CI checkout is merge 137ab4a7c73d03c5d5cb1f2713e68b966cb3614c (main 33cbbd1 plus this head); neither config file is changed here. Both files are identical to current main: implementation blob afc97b5, test blob b85a1d9. [Exact TS2724 job](https://github.com/openclaw/openclaw/actions/runs/38344022221/job/115121788481). This is recorded for the config owner; landing uses the authorized inherited-static-failure exception. No behavioral failure is waived.
## What Problem This Solves Three selectively run node-worker E2Es assert ordering that openclaw#169484 intentionally retired by delivering the durable reply before workspace reconciliation. The skill-library E2E also exposed a retained-transcript regression during its sequential worker flow; its original assertions did not explicitly equate a final reply with settlement. ## User Impact The final diff is test-only. It verifies early replies while preserving claim release, workspace settlement, upgrade recovery, retained-session continuation, and skill-library behavior. ## Change - Native-slot waits on the existing session-change signal, then asserts that the claim and pending result are gone before proving physical-slot reuse. - Upgrade-wire checks its attempted upload after the existing durable recovery observation. - Required-native receives A's final while quiescence is held, preserves the queued-follow-up proof, and waits for B's settled placement. - Skill-library joins workspace settlement before sequential turns; its wire fixture exposes existing events. The updated waits uncovered two production defects: openclaw#169622 tied retained transcript facts to a writer that early final releases, and successful claim closure did not reach the existing lifecycle/WebSocket bridge. Those fixes landed separately in openclaw#170556 and openclaw#170575. Main is now integrated at 38033f1, and the final diff contains only the five test/fixture files. Production LOC: 0. No timers, polling, retries, budgets, or assertion weakening were added. ## Evidence [Integrated CI 38340516247](https://github.com/openclaw/openclaw/actions/runs/38340516247) at 7be861c passed all four E2Es and the required CI gate: | File | Test seconds | Runner seconds | | --- | ---: | ---: | | native-worker-slot | 36.141 | 45.72 | | paired-node-worker-upgrade-wire | 158.587 | 168.53 | | required-native-same-session | 82.785 | 94.17 | | skill-library-worker-wire | 41.308 | 67.21 | [Native/upgrade/same-session log](https://github.com/openclaw/openclaw/actions/runs/38340516247/job/115110480812) shows A and B claims clearing and all four same-session pairs settling on their retained environments. [Skill log](https://github.com/openclaw/openclaw/actions/runs/38340516247/job/115110480823) shows eight remote placements move from reconciling to clear; the complete authoring, continuation, cancellation, and reclaim flow passes. The [unchanged-main probe](https://github.com/openclaw/openclaw/actions/runs/38331787910/job/115083216251) reproduced the original four failures. [Control CI 38339534658](https://github.com/openclaw/openclaw/actions/runs/38339534658/job/115107577910), with only the test alignment and the extra active-run condition removed, still reached a reconciling placement twice and received no further event before the 300-second watchdog. No E2E artifacts were uploaded; the retained Vitest resource was watchdog cleanup evidence, not proof of a product child leak. Changed-file formatting, type-aware lint, and independent review pass with no actionable P0/P1 findings. Local diagnostic command `pnpm test:e2e:gateway test/e2e/qa-lab/runtime/native-worker-slot.e2e.test.ts --maxWorkers=1` took 179.68 seconds before test execution and refused to proceed because artifact separation could not be verified. The guard was preserved; subsequent proof used GitHub CI only, with no leases. The earlier skill local-first rejection with an unsettled database writer remains recorded for the session-actor campaign; this change does not alter that guard. Related credential-diagnostics PR: openclaw#170257. Final-head CI 38344788931 has the same inherited main-only TS2724 error as openclaw#170575: config-preflight-snapshot.test.ts:41 imports the function made private by main openclaw#170530. CI checkout 1e93e8ab merges this head into main 8526c5b; this test-only PR does not change either config file. [Exact static failure](https://github.com/openclaw/openclaw/actions/runs/38344788931/job/115124083706). The config owner follow-up is recorded; no worker behavior failure is waived. Final test-only head 38033f1 passes all four selected E2Es in CI 38344788931: native-slot 45.28s Vitest / 46.69s runner; upgrade-wire 166.37s / 167.94s; required same-session 100.49s / 102.91s; skill-library 64.35s / 66.24s. Final diff is exactly five test/fixture files and zero production LOC. The only remaining failure is the documented inherited main TS2724 check; landing uses that scoped static-failure exception.
…w#170619) Complete the preflight reader migration in `config-preflight-snapshot.test.ts`. Commit 33cbbd1 (openclaw#170530) intentionally made `readConfigPreflightSnapshot` private and moved reads behind `createConfigPreflightSnapshotReader`, which owns and disposes executable inspection caches. The remaining direct test import caused TS2724 in the commands test type project. The diagnostic was observed in run 38344022221/job 115121788481 on PR openclaw#170575's synthetic merge; source inspection confirms the same stale caller on main at 54a9df0. Use the existing factory with `await using` in the Doctor test branch and call its `read` method. All snapshot options and behavioral assertions stay unchanged. Disposal completes before the final config, backup, and SQLite-family byte-preservation assertions. The private helper stays private, with no compatibility wrapper or test-only production export. [Exact candidate proof](https://github.com/openclaw/openclaw/actions/runs/38345114058/job/115124606937) checked out `573774fd5d001f19983da243bf241df0bceb6530` and passed the complete `src/commands/config-preflight-snapshot.test.ts`: **19/19, no skips**, 103.81s Vitest / 108.07s runner wall. It also passed the exact failing commands TypeScript leaf: `node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.commands.json --incremental`. The [independent baseline job](https://github.com/openclaw/openclaw/actions/runs/38345114058/job/115124606702) checked out actual main `54a9df02cc64f5f466490dc7b76ae6bc7f2b2690` with the same setup and naturally reproduced `config-preflight-snapshot.test.ts:41` TS2724 (exit 2). The overall proof workflow is red because that separate baseline fails; the independent candidate test and type steps both pass. No failure was suppressed. [Ordinary CI](https://github.com/openclaw/openclaw/actions/runs/38345111705) completed successfully: **18 jobs passed, 29 skipped**, including the aggregate. Selected test types, lint, source contracts, and boundaries pass; Madge reports zero cycles. T1 live stays 455→455, compatibility stays 9→9, and dialect stays 0→0. Knip, build, update, and SDK-diff jobs were unselected and are not claimed as fresh passes. Scoped formatting, basic lint with warnings denied, whitespace checks, and native hooks passed. One isolated Codex P2 review completed scoped-clean with zero findings. No local suite was run. Scope: one test file, +3/-2 lines; no production, schema, update, or runtime behavior changes. SQL/T1 measurements and published-driver update proof do not apply to this test caller migration. No assertions or safety checks were removed.
What Problem This Solves
After #169484 delivered worker final replies before workspace reconciliation, session subscribers could observe reconciliation in progress without receiving its later completion. The claim owner installed internal row-change facts on completion, but that notification does not reach the existing WebSocket lifecycle bridge.
Change
Publish the existing placement lifecycle event after an owned closure commits with both the turn claim and pending workspace result cleared. Subscribers receive the settled placement after its facts are installed. Retained recovery fences stay pending; ordinary local-turn receipts are excluded.
Production LOC: +9, a bounded correctness fix. Three files change; the archive assertion now includes its response for diagnostics without changing the expected result. The existing owner boundary test proves acceptance stays silent and completion publishes already-cleared claim and result authority. No new RPC, lifecycle state, timer, or polling.
Evidence
Changed-file formatting, type-aware lint, and independent review passed with no actionable P0/P1 findings.
pnpm test src/gateway/worker-environments/placement-store.turn-claim-closure.test.ts --maxWorkers=1was not run locally under the CI-only host constraint; local test wall time is unavailable. The integrated CI run 38340516247 at 7be861c selected and passed all four affected E2Es with both production fixes: native-slot 36.141 test seconds, upgrade-wire 158.587, same-session 82.785, and skill-library 41.308. Native A/B claims clear, and all four same-session pairs publish the settled placement. This PR runs the focused owner regression and required static gates independently. The four E2E contract updates are tracked separately in #170537.Release-note context: session subscriptions publish worker workspace settlement after an early final reply.
Focused CI run 38341715059 passed all 42 tests in the owner group (21.40 seconds), including the new completion-publication assertion (665 ms), abort and lifecycle closure cases. All selected static gates passed. The prior head had a separate orphaned-provisioning archive failure. Current main passed all 10 archive tests in probe CI, so no inherited-failure exception is claimed. This branch is refreshed against that main baseline, and the archive assertion now reports the response if it fails again.
Final head 38916dd: CI 38344022221 passes the archive cases (successful orphan cleanup 2.261s, failing cleanup 2.280s) and all 42 owner-group tests (24.55s, new publication assertion 650ms). The earlier archive failure did not recur after main integration; it is not claimed as inherited proof.
The sole remaining static failure is inherited from main #170530:
src/commands/config-preflight-snapshot.test.ts:41importsreadConfigPreflightSnapshot, which that main commit made private. The CI checkout is merge 137ab4a7c73d03c5d5cb1f2713e68b966cb3614c (main 33a438a plus this head); neither config file is changed here. Both files are identical to current main: implementation blob afc97b54d6888c4a00957e0b8897f8e00332cc1a, test blob b85a1d913a82cb863c0fb13f7aaaf7b756c414d5. Exact TS2724 job. This is recorded for the config owner; landing uses the authorized inherited-static-failure exception. No behavioral failure is waived.