Repository navigation
fix(cloud): keep source packaging and worker teardown reliable - #136084
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: blocked before merge. Reviewed September 2, 2026, 7:28 PM ET / 23:28 UTC. ClawSweeper reviewWhat this changesThe PR makes cloud-worker teardown, plugin-service shutdown, source-package archive handling, ACPX Doctor detection, and Windows process termination more reliable. Merge readiness⛔ Blocked before merge - 2 items remain Keep open for normal maintainer landing review: current main still lacks the lifecycle ownership fixes, while the branch keeps cleanup with its producer across replacement and shutdown deadlines. Focused owner-boundary regressions and reported exact-head CI support the patch; the cited Crabbox release schedule could not be independently re-fetched because this reviewer environment cannot resolve GitHub. Priority: P1 Review scores
Verification
How this fits togetherCloud workers and plugin services start local subprocesses and external worker resources for agent requests. Their lifecycle owners must settle those resources before replacement, shutdown, packaging, or diagnostics can safely proceed. flowchart LR
Request[Agent or service request] --> Worker[Cloud worker lifecycle]
Worker --> Heartbeat[Heartbeat subprocess]
Heartbeat --> Cleanup[Owner-managed cleanup]
Cleanup --> Replacement[Replacement or shutdown]
Package[Source package archive] --> Tar[Tar subprocess]
Tar --> Release[Release validation]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -17, Tests +519, Docs +2, Config 0, Other +8. Total +512 across 26 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one owner-managed cleanup operation and allow replacement, shutdown, and inspection callers to apply their own bounded wait policy without abandoning that cleanup. Do we have a high-confidence way to reproduce the issue? Yes for source-level reproduction: the ownership paths and regressions cover an active heartbeat or cleanup operation crossing strict replacement, final shutdown, and inspection loss. I did not execute tests in this read-only review. Is this the best way to solve the issue? Yes: retaining cleanup at the producing worker or service owner is preferable to sharing a caller's deadline or removing lifecycle state before an active subprocess settles. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 6dbf9c875c42. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (13 earlier review cycles; latest 8 shown)
|
Share dependency-free executable lookup with pnpm while preserving its launcher behavior. Resolve native tar before changing archive directories, including Windows native executables and Unix default/relative PATH rules. Use one validator tar flow with drive-safe and colon-safe archive operands and normalized Windows directory arguments. Preserve listing limits, extraction cleanup, frozen-source packaging, and strict artifact checks. Cover caller-relative lookup, missing PATH, neighboring Windows tar.exe, real isolated package validation, and copied Mac harness dependencies. Refs: #136084
c282def to
1f02943
Compare
Keep complete UTF-8 CLI stdout and wait for stdio closure instead of applying the Gateway diagnostic tail to machine-readable results. Preserve bounded diagnostic logs, exact child environments, and owned deadlines. Include bounded CLI diagnostics when the built artifact proof fails. Defer ACPX resource helpers behind the existing empty-record boundary so Doctor does not load the runtime graph when there is nothing to migrate. Move empty-state cases to the public doctor entrypoint; keep record, lease, archive, and recovery semantics unchanged. Verify real-child red/green regressions, 39 helper tests, 20 ACPX tests, and the original 18-file/194-case Doctor execution order. The real built CLI returns 297849 bytes for 151 plugins; the original helper truncates that JSON while the fixed helper matches direct capture byte for byte. Refs #136084
Share each service cleanup operation without sharing a caller's deadline. Retain failed-start cleanup for final Gateway shutdown and keep deferred service handles from replaying an expired strict-stop result. Join all Windows taskkill helpers before canceling the root, so a timed-out helper cannot kill the parent while its sibling enumerates descendants. Preserve existing deadlines, capability fencing, and once-only cleanup.
c9cd129 to
2eff0a2
Compare
|
@clawsweeper re-review Updated to The complete source review and owner regressions passed. Exact-head CI and the fresh local build checks are in progress; this is not a claim that those pending gates or the repeated cloud stress run passed. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
The final timing/rank-up request is now verified directly against both released Crabbox sources, with the version distinction recorded in the PR body. Retain 1,005 seconds for supported 0.48.0, not because 0.48.1 needs that duration. In 0.48.0, Resolve is 10s per call, optional guest cleanup is 35s, each release branch allows five 60s attempts plus 20s backoff, and pending observation has its own five-minute window. The admin branch is conditional on configured admin credentials and a final normal-release 401/404. The source-defined phase sum is 995s plus OpenClaw's 10s exit allowance; it is not a measured strict worst-case wall-clock bound. By contrast, 0.48.1 starts one shared five-minute context before Resolve, inherited by observation. The larger OpenClaw allowance neither overrides that cancellation nor delays an early successful exit. It preserves the documented older-CLI support instead of forcing an unrequested minimum-version change. Including existing warm capture and child settlement, the ordinary non-Machine0 destroy allowance is 28m05s (17m05s with warm images disabled). The retained 0.48.0 binary's SHA/version/VCS metadata match the released source. With a synthetic delayed-success broker, the old 310s owner killed pending cleanup at 310.436s; the revised owner returned exit 0 at 321.501s. That is real CLI/process proof, not AWS allocation proof or a full worst-case timing test. The data-model flag is a false positive: |
|
Merged via squash.
|
Record fixed-ID creation at the coordinator admission owner before preparation or quota checks, and let Stop cancel that exact owner/org/provider-bound attempt before allocation. Preserve the cancellation across restart and duplicate replay, including the post-reservation race, without inventing a lease row or treating unknown IDs as released. Reuse the existing attempt lifecycle and remove duplicate reservation construction. Version-2 fixed admissions stay fenced on older coordinators; confirming pre-allocation Stop after rollback requires upgrading the coordinator again. Canonical IDs never fall back to friendly-name lookup. Keep the Go checkpoint contracts and race detector intact while allowing fixture-isolated cases to run in parallel. No timeout, dependency, configuration, SQLite schema, or CLI release change. Verified: 2,069 Worker tests; released 0.48.0/0.48.1 CLI-to-authenticated-coordinator/SQLite proof (18 commands, 84 checks, synthetic provider boundary); exact-head CI 33694862559 with all 11 jobs successful; structured Codex reviews. Full live AWS stress remains separate from this coordinator proof. Related: #1561 Related: openclaw/openclaw#136084
…law#136084) * fix(cloud): join worker cleanup and stream package archives * test(ci): cover package validation on Windows * fix(ci): preserve CLI output and defer empty ACPX runtime loads Keep complete UTF-8 CLI stdout and wait for stdio closure instead of applying the Gateway diagnostic tail to machine-readable results. Preserve bounded diagnostic logs, exact child environments, and owned deadlines. Include bounded CLI diagnostics when the built artifact proof fails. Defer ACPX resource helpers behind the existing empty-record boundary so Doctor does not load the runtime graph when there is nothing to migrate. Move empty-state cases to the public doctor entrypoint; keep record, lease, archive, and recovery semantics unchanged. Verify real-child red/green regressions, 39 helper tests, 20 ACPX tests, and the original 18-file/194-case Doctor execution order. The real built CLI returns 297849 bytes for 151 plugins; the original helper truncates that JSON while the fixed helper matches direct capture byte for byte. Refs openclaw#136084 * test(cloud): verify strict service replacement joins heartbeat cleanup * fix: retain cleanup ownership across shutdown deadlines Share each service cleanup operation without sharing a caller's deadline. Retain failed-start cleanup for final Gateway shutdown and keep deferred service handles from replaying an expired strict-stop result. Join all Windows taskkill helpers before canceling the root, so a timed-out helper cannot kill the parent while its sibling enumerates descendants. Preserve existing deadlines, capability fencing, and once-only cleanup.
Give initialization, scheduled discovery, manual checkout refresh, and pre-handoff update work one abort-and-join lifecycle owner. Propagate cancellation through owned Git commands while keeping temporary-worktree cleanup independent, and keep automatic maintenance inside the process tree on both current and older Git versions. Remove duplicate refresh ownership and separate timers; leave managed-service handoff with its existing owner. Cloud stress exposed the shutdown tail while investigating #136084. Verified 502 focused tests, real held-fetch cancellation, temporary-worktree cleanup, and native Git 2.43 foreground maintenance. Full cloud stress follows the fresh committed build; no pass is claimed here. Refs #137071
Join update discovery and native-auth preparation before shared Gateway teardown. Capture scoped positive and negative auth facts before handing work to catalog workers, while retaining the synchronous plugin hook contract. Use generation-owned workspace allocations for remote skill inputs, derive one location for writes and mounts, and keep the private marker until payload cleanup succeeds. Surface bootstrap network and cleanup failures explicitly. Retain ownership through cancelled Git worktree creation and independent managed-update handoff. No configuration, database, or protocol changes. Refs: #137071, #136084, #136995.
* fix(gateway): own cloud startup and teardown resources Join update discovery and native-auth preparation before shared Gateway teardown. Capture scoped positive and negative auth facts before handing work to catalog workers, while retaining the synchronous plugin hook contract. Use generation-owned workspace allocations for remote skill inputs, derive one location for writes and mounts, and keep the private marker until payload cleanup succeeds. Surface bootstrap network and cleanup failures explicitly. Retain ownership through cancelled Git worktree creation and independent managed-update handoff. No configuration, database, or protocol changes. Refs: #137071, #136084, #136995. * test(auth): align OAuth fixture with async synthetic lookup Preserve the no-refresh assertions while following the async absence contract. Reproduced two missing-export failures before the one-line fixture repair; all 209 owning and sibling tests plus the changed-file gate pass. Refs: #137071.
What Problem This Solves
Source-built cloud sessions could fail while packing archives, and worker teardown could return before a heartbeat child settled or terminate legitimate provider cleanup too early. This follows the cloud-lifecycle refactor in #135583, the isolated-linking source-install repair in #135728, and provisioning cancellation on Stop in #133735.
Review and stress testing also exposed two connected shutdown bugs. On Windows, a timed-out graceful
taskkillcould kill the root while the forced helper still enumerated its descendants. At the service boundary, a cached strict-stop rejection made final Gateway shutdown skip its own cleanup grace; the opposite call order could suppress the strict deadline entirely.Why This Change Was Made
The package owner streams archives through inherited file descriptors while preserving the caller's working directory.
runPackageTarremains the single flow, with both default npm and explicit pnpm packing supported. Archive neighbors cannot supply tar's gzip executable, and native Windows paths do not pass through tar's remote-archive interpretation. There is no new resolver, archive-sized buffer, dependency, or fallback.The Crabbox heartbeat owner keeps cancellation and settlement together. Stopped entries remain owned until their child settles, concurrent disposal joins that lifetime, and late inspection cannot restart the heartbeat. The Stop budget retains the supported 0.48.0 CLI's request, backoff, observation, and process-settlement allowances; the released-version distinction and tradeoff are documented below. No retries or configuration options were added.
Windows termination now has one fallback owner: root cancellation follows settlement of every started
taskkill, including failed helpers. This removes result-shape inference and per-helper direct-root kills. Graceful and forced helpers still overlap; their timeouts are unchanged.Plugin cleanup belongs to each service startup attempt, including failed starts. Callers share that once-only operation but keep their own wait policy. Both the service handle and its deferred Gateway wrapper stop caching the first caller's deadline. Strict replacement still fences capabilities and rejects after its existing five-second deadline; final shutdown can join pending cleanup within its separate existing grace. Public plugin
start/stopsignatures are unchanged.The ACPX doctor detector loads runtime resources only when it has a session to inspect or migrate. Missing/empty-session tests exercise the public doctor contract with a runtime-load tripwire. No migration or stored representation changed.
The branch incorporates main through
8ea5c8f02b995ae052cbba7d22deee598159a9e2. Main's canonical command runner and tests supersede all three earlier helper-file changes (#136434, #136478, #135945); the duplicate collector and its incompatible unbounded pipe-drain test are removed. Main's dependency repair, Mac staging, and package-manager fixes remain intact. The archive validator stays selected alongside packaging in the first Windows CI shard, while the second shard retains main's new canonical command-helper coverage.User Impact
Creation retains both package-manager routes. Reclaim and shutdown retain ownership of pending work without replaying cleanup or publishing a replacement early. Model authentication stays on the Gateway. No new configuration, dependency pin, SQLite schema, protocol version, runtime fallback, or production UI change is introduced. The Control UI regression uses the actual deletion acknowledgement.
Production and build-tool code decreases by 9 lines (+163/−172); regression tests and test support increase by 519 lines (+731/−212). Documentation adds two lines net; package-script metadata is line-neutral. The test table reuses the existing replacement suite and supersedes the old promise-identity test. There is no generated-code or lockfile growth.
Evidence
Candidate:
2eff0a2ceb874cd5beb3ece7774a44d168c425e5, tree00729f29b773fa020f8716256326e5840306ac52.Exact-candidate local validation passed on Node 24.20.0 / pnpm 12.1.0: frozen-lockfile install; 523 tests (479 owner tests across seven files, 41 canonical-helper tests, two CI-selection regressions, and one built-CLI SQLite lifecycle test). One helper test is native-Windows-only and was skipped on macOS. The normal
pnpm build:packagepassed in 242.833s; the exact prebuilt SQLite lifecycle command passed in 68.036s using the current targetedplugins inspect openai --jsonpreflight. Source, dependency pins, build stamps, and UI bytes remained unchanged, and task-owned temporary state was removed.The changed-file gate also passed (format, lint, core/test types, dead exports, and repository guards). A complete 26-file structured Codex review found no P0–P2 findings, followed by a clean bounded review of the mechanical Windows-list resolution. All 25 non-package changed files stayed byte-identical through the rebase.
Exact-head CI run 33691964622 completed successfully on its first attempt, including the required openclaw/ci-gate. Both native Windows 2025 shards passed on Node 22.23.2: CI1 exercised archive validation (41 passed, 5 platform skips) and packaging (62 passed, 3 platform skips); CI2 exercised the 28 Windows termination regressions and real-process smoke. The
execCommandparent/descendant smoke is insrc/agents/sessions/exec.real.test.ts; the separate two-caseexec.windows.integration.test.tscovers the agent-core process-tree utility, not the changed controller. No CI rerun was needed for this candidate.Before repair, the retained regressions reproduced premature root termination, strict/ordinary wait interference in both call orders, dropped failed-start cleanup, the deferred-wrapper rejection, and premature final Gateway close. The same regression cases pass after repair. The service replacement test uses a real local child; deterministic Windows helper-ordering tests use the existing mocked process boundary. Neither is presented as live AWS proof or a universal successful Windows replacement within five seconds.
ClawSweeper follow-through: the unsafe per-helper root kill is removed, and the existing Windows CI2 selection includes the deterministic helper-failure regressions plus a real
execCommandparent/descendant cleanup smoke test. The request to guarantee successful cleanup inside every five-second strict replacement window is not adopted: a stalled helper may exhaust that window, so replacement must reject and fence old capabilities. Final shutdown independently joins the still-owned cleanup; no deadline or assertion is weakened to turn that failure into success. The process smoke checks eventual PID extinction after resolution and is not represented as exact settlement-order proof.No migration or upgrade fixture is applicable to these OpenClaw changes: persisted representations, configuration, plugin
start/stopsignatures, provider pins, and protocol shapes are unchanged.PluginServicesHandleis the internal orchestration owner, not a new plugin API. Released Crabbox CLI behavior is separately exercised in the coordinator wire proof below.Earlier packaging red/green used unmodified GNU tar 1.35 and captured executable lookup from the archive directory. Earlier native Windows packaging and validation passed with npm and pnpm.cmd. The prior exact-head CI at
27d1e739passed in run 33673206023. The laterc9cd1291manual run failed its merge-ref identity preflight, not tests: GitHub's merge ref still pointed at the previous head because three helper files conflicted with main. This rebase resolves those conflicts using main's canonical implementations. Earlier-head evidence is not substituted for the candidate's checks.Released Stop contract: ClawSweeper follow-through
Retain the 1,005-second allowance for the still-supported Crabbox 0.48.0 contract. This is not the effective Stop budget of 0.48.1. OpenClaw's requirements do not require 0.48.1; narrowing the allowance to that release would silently strand supported installations.
Direct inspection of released commit
26b735abbaf6571d5f46620e07514b7ce9ff0d7bestablishes these cancellation budgets:remoteConnectionCleanupTimeout.The phase sum is
2*10 + 35 + 2*(5*60 + 20) + 300 = 995seconds, plus OpenClaw's 10-second exit allowance. These are source-defined cancellation budgets, not a measured strict worst-case runtime; claim locking and local artifact finalization also exist. The OpenClaw process deadline remains bounded.Crabbox 0.48.1 instead starts a shared five-minute context before explicit Stop's Resolve; observation inherits it. Its phases therefore do not add independently. OpenClaw does not extend that CLI-owned deadline or impose a minimum wait on successful Stop operations.
The operational tradeoff is explicit: the ordinary non-Machine0 destroy allowance increases from 16m20s to 28m05s when including the existing 660-second warm-image capture budget and two 10-second child-settlement allowances; with warm images disabled it is 17m05s. This keeps the lifecycle owner alive for valid older-CLI cleanup instead of abandoning it early. No retries, version-based runtime fork, configuration, or dependency minimum were added.
A retained real-binary red/green run used released 0.48.0 (
44539a257aa51f885881aaf11f77ab800a48f72103e1072752f84dae3ab60a4e; version and unmodified Go VCS metadata bind it to the release commit above). Against a synthetic broker with a 35-second release response and cleanup completing at 320 seconds, the old 310-second deadline interrupted pending cleanup at 310.436s (exit 5); the expanded allowance let it finish normally at 321.501s (exit 0). The direct control completed at 321.498s. This used no cloud allocations or production credentials; it does not simulate every retry/admin maximum or establish 0.48.1 timing. These earlier-head observations supplement, rather than replace, the exact-head owner regressions and CI.The review's data-model flag is not applicable: the only
package.jsonchange addstest/scripts/check-openclaw-package-tarball.test.tsto Windows CI1. No data schema, migration, persisted value, dependency, or operator configuration changes.Cloud stress and upstream boundary
The original real AWS stress run failed. Its OpenClaw canary activated in 300.107s, ran a model-driven remote command without an explicit CWD, reconciled a file back to the Gateway, and reclaimed in 40.262s. The concurrent wave then hit the broker limit. Two accepted leases received clean release receipts, but the rejected fixed-ID candidate had no broker lease row and Stop returned 404. Forced Gateway termination and a post-driver process check also failed the run. A later read-only observation found no task processes; that does not turn the run into a pass or establish provider-side absence for the missing record.
The provider-owned repair is Crabbox #1749: cancellable fixed-ID creation before allocation. It is implemented under the approved persistent-lifecycle scope. Released 0.48.0 and 0.48.1 CLIs passed 84 checks against the actual local Worker/authentication/SQLite coordinator, including quota rejection → Stop, held preparation, restart, downgrade fencing, negative ownership checks, and normal cleanup. Its provider boundary is synthetic; this is not cloud-allocation proof.
A full repeated cloud/Codex/UI stress run remains unperformed: the upstream coordinator repair is not deployed, and the historical missing-record candidate still requires authoritative AWS inventory access. No quota increase, unrelated resource cleanup, or success-shaped handling of 404 was added. These upstream/operator prerequisites do not change the correctness of OpenClaw's package and process-ownership repairs, but the missing end-to-end proof remains an explicit limitation. The actual Control UI lifecycle recording is also still missing; the earlier readiness-only recording is not substituted for it.
Remaining named follow-ups: the existing Parallels escaped-pipe timeout fixture's readiness/clock control, the separate missing-base Git-fetch owner, and doctor discovery loading unrelated runtime graphs before phase filtering. This PR now covers the plugin-service final-shutdown grace rather than leaving it as a follow-up.