Repository navigation
refactor(workers): simplify environment lifecycle bookkeeping - #168747
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: needs real behavior proof before merge. What this changesThis PR removes redundant worker lifecycle guards and recovery bookkeeping while retaining effect-time authorization and durable settlement. Example: A placement read for session next-turn overlaps release of its preceding turn claim.
Review scores
ProductKind: Refactor · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 2 items remain Keep this maintainer-directed simplification open: its tradeoffs are explicitly accepted, and source review found no discrete introduced bug. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe Gateway coordinates session placement, provider allocation, node enrollment, and workspace recovery, using SQLite workers for durable writes and committed projections for reads. flowchart TD
A[Session requests] --> B[Placement coordinator]
B --> C[Environment lifecycle]
C --> D[Provider and node effects]
C --> E[SQLite worker]
E --> F[Committed projections]
F --> B
Technical reviewBest possible solution: Retain the smaller lifecycle owners and accepted best-effort behavior while preserving live authorization, FIFO ordering, and durable settlement. Do we have a high-confidence way to reproduce the issue? This PR proposes an intentional refactor rather than reporting a new reproducible defect; its retained boundaries were inspected without executing target code. Is this the best way to solve the issue? The simplification follows the existing owners and the maintainer's explicit tradeoffs, avoiding replacement state machines or new public options. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e7e3b949ae13. Provenance checked
TestingProof path: in-process harness. SecurityNeeds attention: No concrete authorization bypass was found, but the changed commit-admission sequence still requires final-effect evidence. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -741, Tests -1663. Total -2404 across 75 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 (9 earlier review cycles; latest 8 shown)
Reviewed October 11, 2026, 5:36 AM ET / 09:36 UTC (Revision 10). |
2fc286f to
fe91d44
Compare
|
|
FINAL: Exact-head CI 38128402802 Earlier completed run: 38113251109, exact head Current candidate Coordinator-approved conflict repair Newer completed run 38121563089, Current reviewed head: This run used merge
All jobs are terminal. No jobs were rerun. A named-failing-gate rebase incorporates Previous run: 38111177634, exact head
The test-only correction is signed head Historical CI attribution for head
These are not being claimed as inherited main failures. No job has been rerun and no proof-only branch update has been made. Coordinator-authorized follow-up at
The three caller files were explicitly approved by the coordinator. Conflict-only rebase round 2 preserves main's state-owner simplification and node-retention fix. All 74 post-rebase cases in six affected suites pass; fresh full-branch P2 review is clean, suppression tests pass, and Madge reports zero cycles. Hosted results on the new exact head will be attributed separately; earlier cancelled jobs are not relabeled as successful. |
e666948 to
5bce2ca
Compare
e8d2821 to
0b077c3
Compare
Treat plugin reloads during enrollment as best effort: an old archive may disappear and the next enrollment uses the current producer. Keep shared build completion, download authority and archive integrity checks unchanged. Remove only tests and assertions for the retired borrower lifetime.
0b077c3 to
d8749b0
Compare
…aw#168747) Simplify worker-environment preparation, placement recovery, store projections, and bootstrap artifact ownership under the approved best-effort policy. Remove speculative mid-operation config and plugin revalidation, recovery admission loans, borrower retirement tracking, redundant read checks, and same-process receipt machinery. Preserve live security checks at effects, workspace durability, ordinary shutdown settlement, and measured bounded caches. Retain one state check at provider destruction to prevent duplicate teardown. Remove synthetic-only tests with their mechanisms and align caller fixtures without weakening retained integrity, authorization, or settlement assertions. Net production reduction: 741 lines. Exact-head CI completed successfully.
The worker-access reference still said placement read preparation joins an overlapping publication's settlement and rereads fresh facts. #168747 removed that loop and accepted the tradeoff that an ordinary placement read racing a same-session mutation reports authority changed. Describe the current fail-closed contract and why rereading only the preparation read would not remove the window.
…law#171205) The worker-access reference still said placement read preparation joins an overlapping publication's settlement and rereads fresh facts. openclaw#168747 removed that loop and accepted the tradeoff that an ordinary placement read racing a same-session mutation reports authority changed. Describe the current fail-closed contract and why rereading only the preparation read would not remove the window.
The worker test checked its tarball after starting provider.close(), although b690de6 (#168747) deliberately removed enrollment-held artifact leases. That read races the provider's own temporary-root removal. Check readability before close, then await close and require ENOENT without first aborting the completed preparation's signal. Keep archive hashes, shared preparation, canceled-peer and off-caller-thread checks intact. Node installation and update behavior is unchanged: provider close still owns archive retirement under the accepted plugin-reload policy. Forced close-before-access reproduced the original ENOENT in 967 ms. With the frozen install restored, the four affected owner files pass all 69 tests under pinned Bun with --maxWorkers=1 (175.27 s wrapper wall; 127.05 s Vitest; affected worker case 508 ms). Gateway-other test types, typed and boundary lint, format, and P2 autoreview pass. The original 71-file Bun shard replay passed this case but hit a separate workspace-upload worker OOM before local dependency drift was corrected; it is retained as diagnostic evidence, not a full green shard claim. The remaining 15 gateway-client shard files pass all 135 tests on the corrected install (112.60 s wrapper wall). No CI reruns were requested.
First-parent upstream facdd3c..fd0fc62 (7 commits: openclaw#168789 subagent and runner bookkeeping, e65bd3b cold actor append retry, openclaw#168747 worker environment lifecycle, openclaw#169037, 7fb80f6, openclaw#168949, fd0fc62). openclaw#168789 removes retrySubagentCleanup: accepted-run termination is now a single attempt that resolves when the stop is confirmed (or the session provably belongs to a successor) and rejects when it is not. Conflicts: - subagent-spawn-cleanup.ts: took upstream's single-attempt form. Kept our hasFrozenSessionIdentity arms on both deletion paths: the abort-miss fallback rejects instead of deleting by key alone, and the waited provisional delete is skipped without a frozen identity. Dropped our retry option and isSettledAbortResponse (upstream's isDefinitiveAbortMiss already covers it in preserve mode); the continuation guard call-site contract still pins the identity guard. - Our boolean consumers adapted to the rejecting contract, keeping their pre-merge outcomes: the accepted-spawn sweep and spawn rollback map a rejection to "not terminated"; the collector's launch-failure path keeps rollback custody for the sweeper and settles once (pinned by subagent-registry.rollback-custody-restart.test.ts); its registration-changed path releases the acceptance hold in a finally. - subagent-spawn.test.ts: upstream's new "holds an unconfirmed collector slot for shutdown" expects no settlement; ported to the fork's custody contract (one abort, no second dispatch, settled once). - subagent-spawn-cleanup.test.ts: our cases ported to the new contract, plus two pins for the identity arms (RED with the arms removed). - subagent-registry-restore.ts: kept our armed-row skip next to upstream's restart-recovery/kill skip. - subagent-registry.test.ts: our extracted restore test kept; upstream's "reconcile on the next explicit restore" change ported into subagent-registry.restore-retry.test-support.ts. - worker-access inventory regenerated. Refs #1475 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The worker test checked its tarball after starting provider.close(), although 2736e3c (openclaw#168747) deliberately removed enrollment-held artifact leases. That read races the provider's own temporary-root removal. Check readability before close, then await close and require ENOENT without first aborting the completed preparation's signal. Keep archive hashes, shared preparation, canceled-peer and off-caller-thread checks intact. Node installation and update behavior is unchanged: provider close still owns archive retirement under the accepted plugin-reload policy. Forced close-before-access reproduced the original ENOENT in 967 ms. With the frozen install restored, the four affected owner files pass all 69 tests under pinned Bun with --maxWorkers=1 (175.27 s wrapper wall; 127.05 s Vitest; affected worker case 508 ms). Gateway-other test types, typed and boundary lint, format, and P2 autoreview pass. The original 71-file Bun shard replay passed this case but hit a separate workspace-upload worker OOM before local dependency drift was corrected; it is retained as diagnostic evidence, not a full green shard claim. The remaining 15 gateway-client shard files pass all 135 tests on the corrected install (112.60 s wrapper wall). No CI reruns were requested.
What Problem This Solves
Simplify worker-environment bookkeeping without removing worker features,
credential/approval checks, workspace durability, or ordinary shutdown settlement.
This is the p04 pragmatic-simplification lane, re-evaluated under the maintainer's
explicit best-effort policy for synthetic timing and mid-operation config changes.
The core change is ownership simplification: one check at an actual effect,
idempotent operations, and existing write settlement instead of repeated snapshot
comparisons, recovery loans, compensating cleanup chains, and reentrant guards.
User Impact
Normal worker setup, inference, workspace recovery, credentials and shutdown stay
supported. Rare mid-operation config/reload or artificial interleaving cases may
now return an error or need a later request/restart instead of being coordinated
through additional state machines. The accepted cases are listed below.
Why This Change Was Made
The removed machinery was justified by synthetic regressions rather than human
actual-use incidents. Retain the minimal effect and settlement boundaries instead
of paying their complexity cost on every normal operation.
What changed
self-validated receipts, and retry-until-stable reads. Per-session FIFO, final
node/run/tool authorization and workspace-result ownership remain.
policy and cosmetic metadata changes no longer trigger extra cancellation and
teardown. Paid allocation IDs, timeout settlement and normal expiry cleanup remain.
repeated read-time shape checks and reentrant cache fences. A failed readback
closes the projection; a new store or Gateway restart reloads durable SQLite.
handshake. The narrow shared lease-owner adjustment preserves first-write
preparation, live member/expiry checks, pre-commit authority and settlement.
are moved unchanged to preserve the heartbeat PR's test inventory.
Best-effort tradeoffs accepted
attempt uses the current producer. Borrower tracking in fix: cloud sessions fail when source builds and worker packages differ #133037 was separate
from its synthetic source-build reproduction.
second time. Initial build validation and archive/path/digest checks remain
(fix: cloud sessions fail when source builds and worker packages differ #133037; no human report for mid-build metadata mutation).
on the next request/pass. feat(workers): maintain bounded ready capacity for prepared projects #143372/feat(workers): reuse prepared public GitHub repositories #143410 introduced synthetic late-change guards,
not a human report requiring mid-request policy replacement.
objects. Private repository and setup authority remain live at their effects
(feat(workers): maintain bounded ready capacity for prepared projects #143372/fix(gateway): avoid blocking requests during worker inference persistence #157422; synthetic mutation/reentrancy cases).
Allocation still checks current human presence and source authorization (feat: prepare cloud workers for enterprise repositories #160108).
recovery can retry on a later pass while normal lifecycle operations retain FIFO
(fix(gateway): cloud worker Move and dispatch stall when a finished turn's result needs recovery #160535).
turn still validates live placement (fix: continue cloud provisioning after a Gateway restart #145068).
rather than maintaining phased discovery/reservation handoffs (fix(gateway): keep slow worker operations from blocking unrelated sessions #160299).
than loop through settlement notifications (fix(gateway): refresh placement reads after concurrent publication #165166).
immediately revalidated against a freshly generated receipt UUID (fix: preserve approval and workspace state after lost worker replies #168094).
checks rather than a second retained claim-authority loan (fix(cloud-workers): Stop can lose workspace edits across a Gateway restart or update #159484).
cosmetic state field after every await; exact epoch/lease/node checks remain
at credential and destruction effects (fix(worker): keep background servers alive after replies #130733; no human same-lock replacement report).
expiry and final node authorization remain (feat(workers): maintain bounded ready capacity for prepared projects #143372).
retention and provider settlement are unchanged (refactor(gateway): run placement transitions and drain settlement in workers #164252).
error instead of transparently retrying (feat(gateway): launch workers on paired nodes #123157).
the next operation sees completion (fix: re-adopt healthy cloud workers after Gateway restart #112928).
restart. SQLite data is preserved and authority fails closed; the removed retry
registry had synthetic provenance (perf(gateway): move worker inventory SQL off the main thread #154804).
or compared to captured copies. Initial decoding and real effect checks remain
(perf(gateway): move worker inventory SQL off the main thread #154804/fix(gateway): avoid blocking requests during worker inference persistence #157422; internal mutation and reentrancy, not external-input validation).
staged rollback latch. Nested initialization may repeat idempotent DDL within
one transaction (perf(gateway): move worker inventory SQL off the main thread #154804; no persisted schema change).
already sequence operations under their lease (perf(sandbox): persist workspace projections through worker commands #165534).
approach JavaScript's safe-integer limit (perf(sandbox): persist workspace projections through worker commands #165534).
that worker's summary can use the newer catalog's labels until it is replaced;
execution placement and credential authority do not use those labels (feat(control-ui): show cloud session machine specs #143864;
synthetic reload/config-change coverage, not a human incident).
two-stage message sequence; the final lease/member/expiry/authority check remains
(refactor(mcp): run OAuth writes and leases in the state worker #148859).
No PR or synthetic reproduction is being presented as evidence of a human incident.
Retained protections are justified by the explicit security, data-durability,
ordinary shutdown, public-contract, resource-bound, or measured-cache rules.
The warm placement read cache retains the measured 11.8 SQL-statement / 3.9 worker
request saving reported in #167194; its reentrant invalidation fence is removed.
Original KEEP ledger re-evaluation
Six of nine original KEEP rows are now partial removals; the previously deferred
profile-drift row is also implemented.
No remaining row relies solely on a PR narrative, harness failure or synthetic
test as a claimed real incident. Additional store/cache, presence and coordinator
mechanisms are listed with their individual tradeoffs above.
Scope and measurement
Aggregate production reduction: 741 lines (+338 / -1079), including the first
p04 commit. Tests: 1663 lines removed net (+554 / -2217), counted separately.
This uses the campaign's 500–999-line honest-pass exception; the whole-scope
KEEP re-evaluation above is the coverage log.
No schema, persisted data shape, config, dependency, or public Gateway
protocol change. No new lint suppressions, timeouts, retries or skips.
Heartbeat PR #167796's changed files are excluded. Three shared state-lease owner
files are a required caller cutover and are explicitly called out for p15–p17.
Evidence
enrollment-owner check and one combined forced-destroy reservation for durable,
attached and in-flight owners. No multi-phase handoff restored.
tbx_01m4ksbxde2y7qmmjc3d72heyh, workflowhttps://github.com/openclaw/openclaw/actions/runs/38085395330:
earlier candidate tree
39c606689e2dfd558ebfc9df753fdf818e80b41fverified beforeand after a frozen-lockfile install; 138 focused tests in five files passed,
then all 11 lease-owner tests passed. The full scope run reached approximately
3,000 passing cases but was cut off by the 60-minute Testbox workflow limit;
this is partial proof, not a passing suite. Its eight observed failures led to
removing stale cache/call-order expectations and retaining the small checks
described below. The focused runtime-tested tree is
4b174954fcf63824a4290b1b49e643a2e2190e74;the replacement lease timed out unallocated after 15 minutes and was stopped.
Per the coordinator's capacity fallback, exact-head hosted CI is the remaining
full Linux gate. Signed head:
original head
2fc286fbe6cdd2a77ad4b545071f34e1249e0fe8(the follow-up only removes an unusedtest import and renames a local variable; separately reviewed, linted and
typechecked; final tree
3f98af3ff44ed7fcd3e8fe12185a89c358edfcef).suite: all 3 passed, with no baseline changes.
checks, then stopped at the pre-existing UI graph budget (722 roots / limit 720).
The UI graph and its budget are untouched. Upstream fixed this with a real graph
split in
471035c7b7c8ea066ed302006ab3780994d27324; no budget bypass or baselineweakening is part of this PR. Direct production, Gateway-test and state-test
type graphs passed. All remaining targeted guards and lint passed. The script
Knip scan also found the inherited
tools/solid-lint/index.mjs: defaultexport;upstream
ad598152583models its real config consumer. Production/full-treeKnip scans each report zero unused exports. No affected file is named by either
inherited failure.
signed candidate: placement claims, paired devices, recovery admission, human
presence, node retention, allocation cleanup, pool lifecycle and pool expiry.
and its measured 18-SQL/7-request saving. The single-read replacement follows
the upstream extraction into
placement-read-authority.ts; no cache was discarded. Rebased headfe91d4453ff5257109a7b9e6ae3b854be6c98552passed fresh P2 review, productionand Gateway test types, all 73 cases in the four cache/authority suites,
targeted lint, both zero-cycle checks, and all three suppression tests.
Current heartbeat head
02b567f7446d48a928ab61a1f8ac746d3fa72637has 1,468changed paths and zero overlap with this PR.
implementation and passed after the minimal fix. One-worker command:
node scripts/run-vitest.mjs src/gateway/worker-environments/placement-dispatch-coordinator-destroy.test.ts --maxWorkers=1:four tests pass, 30.09 seconds wrapper / 12.72 seconds suite / 0.77 seconds tests
on the loaded shared Mac. It protects ordinary dispatch settlement before
destructive teardown; no sleeps, retries or new timeouts.
persisted reserve expiry at the start of maintenance, without restoring the
mid-operation retirement state machine. The held-presence regression failed
before this fix and passed unchanged afterward (12.34 seconds test time on the
loaded shared Mac; compiled-worker setup is additional).
checks-node-changed-compact-small-11-2pinned permanent setup supersessionfrom unimplemented/rejected fixture Stop/Move calls;
checks-node-changed-compact-large-2pinned mid-flight config-disable rejection while Git credentials and live human
presence remained valid. Four sibling shards were cancelled and are not counted
as passing proof. No jobs were rerun.
e666948a88acaed8ed6e90b5e332a9e0e26c8412removes thoseobsolete variants while retaining actual cancellation/authority denial and the
authorized private-Git transport, content and credential-hygiene case. Fresh P2
review, targeted lint and Gateway test types passed. The two affected files pass
all 18 cases with
node scripts/run-vitest.mjs src/gateway/worker-environments/worker-turn-launcher-initial-setup.test.ts src/gateway/worker-environments/prepared-pool-presence-effects.test.ts --maxWorkers=1(1185.46 seconds wrapper / 1158.65 seconds suite on the loaded shared host).
No runtime, timeout, retry or skip changed in this follow-up. Hosted CI on this
new head remains the final Linux gate; no reruns or proof-only pushes.
mechanisms and a duplicate provider-destroy defect. The latter is repaired by
one state check inside the queued destructive effect; the regression keeps
exactly one provider call and the destroyed durable row. Coordinator-approved
test-only alignment keeps automatic fallback, stored-session safety, grants
and shutdown settlement. All 22 device-dispatch tests pass (599.17 seconds
wrapper / 502.78 seconds Vitest on the loaded host; existing integration suite).
and node-retention async-context fix. The only manual conflict keeps once-only
first-write preparation, including commit-first calls, while preserving live
member/expiry/authority checks and settlement. Fresh full-branch P2 review is
scoped-clean. Reviewed rebase head:
5bce2ca567b028908596199d8b37947269cbaa63.provider teardown, placement projection, and both lease-owner suites
(
node scripts/run-vitest.mjs <six affected files> --maxWorkers=1, 572.64seconds wrapper). The existing integration suites exercise real SQLite,
compiled workers and startup/shutdown; test deadlines were unchanged. All three
suppression tests pass (20.99 seconds wrapper); Madge reports zero cycles.
formatting, API guards, wrapper ownership and early ratchets. It stops on
unrelated unused exports in CLI history, approval handlers and UI files; none
is changed by this PR. Current main
c2d584acd704363bee65131fd8ea439e38ac1bbfno longer exports any of the reported symbols. This is recorded as a failed
old-base local gate, not a claim of current-head hosted success. Direct changed
lint and both cycle checks pass (zero runtime/Madge cycles). Remaining guards
are being run directly after that fail-fast stop.
retry assertion: a successful simultaneous duplicate can acknowledge
in_flight, not onlystarted. The test-only follow-up preserves at least onestartedresponse, validates the duplicate's exact run identity, and retainsGoal identity, one durable user turn, replay and one model dispatch. All 24 Goal
cases passed (601.23 seconds wrapper); after moving unchanged assertions into
the existing test-support file to stay below the line cap, the affected case
passed again (281.00 seconds wrapper, 23 cases filtered). Fresh P2 review,
focused types and lint pass. No skip annotation or timeout changes were added.
Signed follow-up head:
257d9c8711374ac97ce57c8d663cbc39aba7099b.All five cancelled type stripes from that run are individually attributed in
the PR comment; all 28 graphs already passed locally. No CI job was rerun.
the database-worker project defaulted to jsdom, breaking native URLs and
cross-realm byte checks. Main fix
3367a12c6d08restores an explicit Nodedefault while keeping the UI integration's jsdom override. A named-gate rebase
incorporates that repair. Post-repair proof passes 109 tests across Visitor
publication, local workspace projection, repository checkpoint recovery and
worker media. The two existing non-runs are Podman-only and a filesystem that
refuses invalid UTF-8 filenames; no skips/timeouts were added (2903.27 seconds
wrapper on the heavily loaded shared Mac). Fresh P2 review, targeted lint,
Gateway/state type graphs and both zero-cycle checks pass. The production
graph reports the unrelated
run-loop-startup.test-support.ts:380fixturesupplying a retired
runtimeoption. The suppression check also identifiesmain's unlisted
session-actor-replica.tssuppression; neither file is changedby this PR, and no new suppression was added here. All eleven failed jobs are
individually listed in the attribution comment. New local head:
421b8e1ca44808f878bf679a87f348a18b9763b3.borrower block and a service test name/deletion. The third conflict repair
preserves main's new disconnected-worker shutdown test and this lane's removed
borrower mechanism. Signed head
b093938c9b3abc88103e98ca7412d0fcfb0959cfpasses all 55 bootstrap/service tests (106.79 seconds wrapper), production and
Gateway test types, targeted lint, all three suppression tests, both zero-cycle
checks, and fresh P2 review. Main also fixed the earlier unrelated CLI type and
suppression failures. The 109-case workspace/media proof remains valid.
still intercepted
cat-file blobafter main refactor(workers): unify staged workspace blob reads #168921 moved payload reads tocat-file --batch. The test-only fix updates its hooks/counter and requires apositive payload read, preserving tamper rejection and live-owner revocation.
All 12 file cases pass on Node (103.64 seconds wrapper) and local Bun 1.4.2
(155.00 seconds wrapper); the hosted pinned Linux Bun remains the exact-head
gate. Fresh P2 review, types, lint and three suppression tests pass. No
production code, timeout, retry or skip changed. Signed follow-up:
e8d2821c217ee50e31cfca03cd6554e953b8e408.inventory error while retaining the removed read-time shape checks. Current
signed head
0b077c37c27721532fec3592fff83c841d87ab93passes all 13 affectedprojection/recovery cases, production/Gateway types, lint, all three suppression
cases, both zero-cycle checks, and fresh P2 review. Prior unchanged proof is
retained. No ClawSweeper hold is treated as a campaign landing gate.
preserves its stronger payload-byte corruption test and our positive-read
assertion. Both Node and Bun pass all 12 repository-file cases; three
suppression cases, conflicted-graph types and both zero-cycle checks pass.
The typecheck also caught two stale captured-provider references introduced
by automatic merging. They now resolve by provider ID, without reload fences.
All 8 catalog cases and 25 service-lifetime cases pass, with fresh P2 review,
types, lint and suppression proof. Current signed head:
d8749b0d6859ab21e4c5c60cb8c3faadeb81476c.job. The separate cancelled ClawSweeper Dispatch is not a campaign landing
gate. Squash
b690de6fbb4288c425acc8ac4738be4345c82faais verified on main.