Skip to content

fix: Windows cleanup leaves descendants running after leader exit - #150244

Merged
steipete merged 9 commits into
mainfrom
upd/flake-windows-cron-identity-cleanup
Sep 17, 2026
Merged

steipete merged 9 commits into
mainfrom
upd/flake-windows-cron-identity-cleanup

Conversation

@steipete

@steipete steipete commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes Windows build and test commands that can hang during cleanup or lose diagnostic output when descendants outlive their command leader.

Why This Change Was Made

The r5 follow-up fixes a circular wait in normal Windows cleanup: completion waited for Node's close event, while an inherited-pipe descendant needed Job termination before close could occur. The owner now uses the same ownsProcessTree decision for completion events, finalization, and ownership release. Windows Jobs and strict POSIX cleanup begin on leader exit. Default POSIX retains its existing non-strict close-based contract.

Normal Windows cleanup permits terminal output to drain for half of the existing cleanup allowance, reserving the rest for Job termination and verified closure. The overall deadline stays anchored to cleanup start; no budget is increased. Buffered output is collected before completion settles, and native handle closure and dead-tree facts still govern resource release. This preserves the existing CLI test that receives stderr after leader exit while bounding inherited pipes that never close.

The original Windows cron test completed its assertions and then failed Gateway cleanup. Taskkill returned 255, but its stdout/stderr were discarded. That lost the only available reason; neither a real leak nor an exit race could be established from that receipt.

The shared managed-child owner now retains a kernel Windows Job from before command admission. Normal exit and cancellation verify membership, leader exit, and closed output. Unresolved trees record surviving PIDs and termination/observation failures. Finalization closes the native handle on success and failure; kill-on-close remains recovery, not proof of completed termination. POSIX observation failures likewise remain indeterminate. Taskkill status, stdout, and stderr are preserved.

Windows bindings load only at Windows use sites. The tooling worker URL resolver uses Node built-ins, so the CI planner does not import application fs-safe dependencies. Native bindings stay with src/process/supervisor/service-child-windows-job-native.ts and are reused rather than copied.

The runtime and Vitest build maps also consume one descriptor inventory instead of separate conversion/count rules. The Doctor process fixture uses its registered executor entrypoint, preserving the original outcome/extinction assertions while avoiding repeated whole-source imports.

The final follow-up fixes four separate failures at their owners:

  • Compiler inputs: vitest-worker-compiler.mts had a manual tooling list that omitted the lazy Windows module and descriptor. It now derives the runtime import closure, including literal lazy imports. The existing eager-only test helper moved to scripts/lib/runtime-import-closure.mts; cold provisioning callers retain eager-only traversal. Compiler, lifetime, and invocation-selection roots define the inventory. The copied fixture consumes that manifest and checks that changes to either Windows module invalidate it.
  • Gateway output: Windows startup cleanup killed an exited leader's gated stderr writer before classifying the migration refusal. stopGatewayProcess now applies its existing POSIX exited-leader drain allowance before either platform's termination path. Windows still always invokes the strict finalizer, including native-handle closure. The deadline and success conditions are unchanged.
  • Native survivor fixture: the synthetic descendant was not detached, so libuv's separate parent-owned kill-on-close Job killed it before OpenClaw could observe it. The fixture now detaches from libuv's Job while remaining in OpenClaw's retained Job. Every survivor, warning, ownership, and completion assertion remains intact. Node 24.21 contract.
  • Controlled compiler fixture: parent-side spawn interception could not see a command behind the Windows launcher. Substitution now runs at the compiler's preload entry, after containment. The same output paths, generation counts, transform counts, and compiler receipts are asserted.

The stale-artifact regression copies only the existing standalone SQLite executable it actually exercises, instead of approximately 14,000 unrelated outputs. Its stale executable is still run successfully before source changes, and its 120-second budget is unchanged.

The earlier inventory/output follow-up was net +64 production/tooling and −36 tests/support. The r5 follow-up is net +15 production/tooling and +100 tests/support: one shared ownership condition plus bounded output drainage, a real inherited-pipe regression, and the corrected synthetic exit/close sequence. Production growth primarily relocates the existing 72-line traversal helper into the compiler's ownership and replaces the manual input list; it does not add a competing inventory. Whole-PR totals are net +624 production/tooling, +456 tests/support, +14 docs. The broader production growth establishes pre-admission containment and records indeterminate tree state as an explicit outcome. No config option, CLI option, dependency, schema, timeout increase, retry policy, assertion weakening, suppression, or baseline increase is introduced.

User Impact

Build/test commands and isolated Gateway fixtures retain temporary-resource claims until cleanup is verified, and failures report the reason and surviving process facts. Gateway startup can read complete terminal migration guidance before deciding whether to restart. CI planning remains dependency-free.

Installed update behavior and persistent operator state are unchanged. All runtime proof uses synthetic state in the task-owned Windows Testbox or local test fixtures.

Evidence

Current rebase: 0486fab2e2660e8101b20b5c42780703e7bda4bb, onto fedf378313fce93dca22040aca0d776c28f863ad. The base contains #150900 (218cb52137da9f497b6ef87d63af19b6ffa90ac9); the ancestry check passed. Main's native worktree entry no longer loads acceleration configuration. The previous bundle-MCP leftover-source failure is the known #67 symptom B from the lane ruling; neither saved CI run was rerun.

Resolved owner: scripts/lib/vitest-worker-build-entries.mts. The converted descriptor list now uses every surviving entry expression from main, in main's order, plus the existing runtime-process descriptor inventory. It drops the retired sessionListCacheRetentionEntrypoint removed by #150196. The legacy config-repair registration remains intact. rg -n sessionListCacheRetentionEntrypoint . returned no matches in the source tree. A second adjacent test conflict preserves main's Cannot find module assertion while retaining this PR's collectRuntimeImportClosure call; no new assertion policy was introduced.

The changed list neighborhood is:

 ...Object.values(sessionTitleRetentionEntrypoints),
-sessionListCacheRetentionEntrypoint,
 sessionChildCacheRetentionEntrypoint,
 nodeHostConfigRuntimeEntrypoint,
Complete converted entry lists before and after the resolution

Before:

[
  ...runtimeProcessBuildEntrypoints,
  agentWorkerStoreFixtureEntrypoint,
  memoryPublicationFaultEntrypoint,
  ...Object.values(triageTestRuntimeEntrypoints),
  ...Object.values(triageMaintenanceRuntimeEntrypoints),
  codeModeRetentionEntrypoint,
  codeModeDescriptionRetentionEntrypoint,
  ...cliCompactionBackendEntrypoints,
  ...publishedSdkBridgeEntrypoints,
  mcpProviderCatalogEntrypoint,
  ...groqSetupSdkEntrypoints,
  ...Object.values(cliRecoveryEntrypoints),
  ...Object.values(updateExecutorNativeEntrypoints),
  ...Object.values(gatewayDirectStopEntrypoints),
  stateDirGatewayFixtureEntrypoint,
  ...Object.values(doctorConfigRuntimeEntrypoints),
  ...Object.values(cronOwnerHardeningEntrypoints),
  ...Object.values(tuiPtyRuntimeEntrypoints),
  ...Object.values(sessionTitleRetentionEntrypoints),
  sessionListCacheRetentionEntrypoint,
  sessionChildCacheRetentionEntrypoint,
  nodeHostConfigRuntimeEntrypoint,
  channelIngressGatewayRestartEntrypoint,
  persistenceRuntimeEntrypoint,
  qaGatewayCleanupRuntimeEntrypoint,
  logbookSqliteBackendEntrypoint,
  teamReportsSqliteBackendEntrypoint,
  workboardSqliteBackendEntrypoint,
  ...Object.values(agentDatabaseModuleIdentityEntrypoints),
  stateLeaseProcessExitRuntimeEntrypoint,
  agentDatabaseHeldRuntimeEntrypoint,
]

After (main's surviving entries):

[
  ...runtimeProcessBuildEntrypoints,
  agentWorkerStoreFixtureEntrypoint,
  memoryPublicationFaultEntrypoint,
  ...Object.values(triageTestRuntimeEntrypoints),
  ...Object.values(triageMaintenanceRuntimeEntrypoints),
  codeModeRetentionEntrypoint,
  codeModeDescriptionRetentionEntrypoint,
  ...cliCompactionBackendEntrypoints,
  ...publishedSdkBridgeEntrypoints,
  mcpProviderCatalogEntrypoint,
  ...groqSetupSdkEntrypoints,
  ...Object.values(cliRecoveryEntrypoints),
  ...Object.values(updateExecutorNativeEntrypoints),
  ...Object.values(gatewayDirectStopEntrypoints),
  stateDirGatewayFixtureEntrypoint,
  ...Object.values(doctorConfigRuntimeEntrypoints),
  ...Object.values(cronOwnerHardeningEntrypoints),
  ...Object.values(tuiPtyRuntimeEntrypoints),
  ...Object.values(sessionTitleRetentionEntrypoints),
  sessionChildCacheRetentionEntrypoint,
  nodeHostConfigRuntimeEntrypoint,
  channelIngressGatewayRestartEntrypoint,
  persistenceRuntimeEntrypoint,
  qaGatewayCleanupRuntimeEntrypoint,
  logbookSqliteBackendEntrypoint,
  teamReportsSqliteBackendEntrypoint,
  workboardSqliteBackendEntrypoint,
  ...Object.values(agentDatabaseModuleIdentityEntrypoints),
  stateLeaseProcessExitRuntimeEntrypoint,
  agentDatabaseHeldRuntimeEntrypoint,
]

Validation: the fresh committed-branch Codex review (--mode branch --base origin/main --max-priority P1) is scoped-clean. The requested worker-entry/artifact, Windows Job, and managed-child suites ran once on Linux Testbox tbx_01m2qrpnfxs8xyyka2t1scb45s, run 35226999489: 220 passed / 5 platform skips across 15 files. The compiler-artifact fs-safe case passed in 14.97 seconds. The source capsule and all 35 changed-file hashes were verified before execution. Frozen installation passed. pnpm build passed in 7m16s, and all 35 hashes matched again after the build. node scripts/check-changed.mjs --base fedf378313fce93dca22040aca0d776c28f863ad passed every selected gate, with no extension-lint substitution. The review of record is the fresh committed-branch branch.md at 0486fab2e2660e8101b20b5c42780703e7bda4bb. The task-owned Testbox is stopped. The head was pushed with an explicit lease. A fresh REST read confirmed 0486fab2e2660e8101b20b5c42780703e7bda4bb and the published evidence body. Exact-head pull_request run 35229160236 completed successfully. The native watcher returned GREEN; the final REST job snapshot has 161 successful jobs and 11 skipped, with no failures or pending jobs. Preflight and both hosted Windows shards passed. GitHub reports this exact head open, ready, and mergeable (clean). No jobs were rerun and no landing was performed.

Historical follow-up: 149c5609f7eb26dadaf8d8d819ad615f557c9bef.

small-44 attribution: Linux Testbox run 35214230104, provider blacksmith-testbox, lease tbx_01m2qgxt6s7th9tk5zj3y12v2p, Node 24.19.0 / pnpm 12.4.0. The two worktree-registration cases ran together in original file order, ten times at cce512fb6348b57bd9dfa809bba7304310386335 and ten times at merge base 926731587ac9c2c96260a5feb52584ef3d76ed08. The command used the hosted scripts/ci-run-node-test-shard.mts entrypoint, recovered core-tooling-10-hosted-2 group, tooling config, two-worker setting, two-CPU affinity, and a test-name filter selecting both cases. Frozen dependencies and isolated state were used for each revision. Failure rates: head 0/10 runs (0/20 cases), merge base 0/10 runs (0/20 cases). No assertion or timeout changed; the prescribed loop ran once.

The hosted timeout was not reproduced, so this is not claimed as a proven main flake. Source tracing does rule out the proposed newly introduced POSIX exit ordering: the merge base already registers strict completion on exit (managed-child-process.mts:442). These two cases use runLockShell's direct spawnSync("bash", …, timeout: 10_000) (pr-operation-lock.test.ts:418-424), then worktree.sh → worktree-provision.mts → src/infra/git-exec.ts → the application process owner. Those files and the two tests are unchanged by this PR. The file's other managed-child tests do not change that call path. The hosted 10.069/10.056-second durations match the direct harness cutoff; no lost-status or premature-signal owner defect was observed. No speculative POSIX fix was made.

Rebase: onto 4be56a4bfaa1b05eb2d13dc011e392d566252847. Seven commits are patch-identical. The inventory commit has one resolved conflict in scripts/lib/vitest-worker-build-entries.mts: main's legacy-config-binding-repair.runtime entry is retained alongside the shared descriptor conversion. Main's wrapper inventory entries remain intact. Frozen installation passed. This is a resolved rebase, not an all-= range-diff.

P2 disposition — fixed: the unowned-Windows fixture now selects stdio: ["ignore", "pipe", "pipe", "ipc"], the existing supported direct-launch contract. It no longer creates a real empty Job around a synthetic child. All error, status, output, and call-count assertions remain unchanged. Native Windows Testbox run 35215670489, provider blacksmith-testbox, lease tbx_01m2qhvy2x602dxaatsm8qwr6r: 3 failed / 2 passed before; 5/5 passed after. The fixture and both managed-process modules were hash-verified against the local candidate. The native runner retained its temporary namespace with an unverified-descendant warning; it was not deleted while the lease was live. Both task-owned Testboxes are stopped. Local owner/inventory proof passed 20/20. This follow-up is production/tooling +0, tests +1 net (2 added / 1 removed).

Historical validation/publication (149c560): pnpm install --frozen-lockfile, 20 local owner/inventory tests, and node scripts/check-changed.mjs --base 4be56a4bfaa1b05eb2d13dc011e392d566252847 passed. Every selected changed-check gate passed; no extension-lint substitution was needed. Fresh pre-commit and committed-branch Codex autoreviews are scoped-clean. The review of record is branch.md, run with --mode branch --base origin/main --max-priority P1 at 149c5609f7eb26dadaf8d8d819ad615f557c9bef. The new head was pushed with an explicit lease. GitHub confirmed the PR is open, ready, and mergeable. Exact-head pull_request run 35217608611 is attached. The native watcher stopped at its first terminal state: FAILING checks=checks-node-compact-large-4 (exit 15), with 28 checks still pending. The immediate job snapshot had 135 successful jobs, 11 skipped, 1 failed, and 24 still running (171 jobs); preflight passed and both Windows shards were still running. GitHub still reported this head open, ready, and mergeable. No landing, CI rerun, or additional source change was performed.

The failed large-4 job 105190054747 failed core-unit-fast-1 → src/agents/cli-runner/bundle-mcp.requester-lifecycle.test.ts:163, “keeps requester tools callable across static native preflight until session closure”. Excerpt: AssertionError: expected [ …(4) ] to deeply equal []. The received list had three internal-session-effects-* entries plus private-memory-source. That group reported 1 failed / 9510 passed / 2 skipped. Its job log was fetched once and retained. This stop does not assign a known-main incident number or claim “everything else green” while jobs remain pending.

r5 native regression proof: on Windows Testbox tbx_01m2qb65x7m6zeq69r21dpqy72 (run 35205394548), the new inherited-pipe regression failed against 8bb3a18a4cf5a4d121a669a757050ad83b038d67 with owned cleanup did not settle after leader exit. The process had exited; a descendant still held stdout and stderr. No command timeout or cancellation triggered the result; the external seven-second guard failed and only then rescued the fixture. POSIX strict cleanup passed the same regression before the fix, preserving its existing terminated-group diagnostic.

With the repair, the Windows regression passed in 2.69 seconds on its first run and passed all three serial runs. Each run preserved 256 KiB of output plus terminal stdout/stderr, verified descendant extinction and closed pipes, and checked ownership release. The Gateway/CLI helper, native Job, and transform files also passed three serial Windows runs (192 applicable cases total; 18 platform skips). The local 94-case suite plus the new regression passed 95/95 ×3 (285 case executions). No existing assertion or deadline changed. The new test is registered in the existing Windows CI command. All four changed paths were hash-verified after native execution; the task-owned Testbox was stopped.

r5 validation: the 95-case focused suite passed three serial local runs; native Windows proof passed three serial runs of all four targeted files. node scripts/check-changed.mjs --base 926731587ac9c2c96260a5feb52584ef3d76ed08 passed every selected gate. This pins the same merge base used by review: the initial default invocation was stopped after a moving shared origin/main made package metadata classification select unrelated all-lane work, while the PR's package delta contains only test scripts. No extension-lint substitution was needed. Fresh pre-commit and committed-branch Codex P1 reviews are scoped-clean. The r5 review of record is branch.md, run with --mode branch --base origin/main --max-priority P1 at cce512fb6348b57bd9dfa809bba7304310386335.

Historical r5 head: cce512fb6348b57bd9dfa809bba7304310386335, published with an explicit lease. The PR remains open and ready. Exact-head pull_request run 35209594131 is attached. The native watcher stopped with CONFLICTING-MID-WAIT mergeable=CONFLICTING (exit 14); the immediately following REST PR snapshot reported mergeable: null, mergeable_state: unknown, with the same head and base 28500239832aa57fd4b5aa905c0f4553e4afb900. No stable mergeability or green result is claimed. The earlier authorized single rebase was already consumed; this handoff makes no further history rewrite, CI rerun, or landing.

At the stop snapshot, the run remained in progress: 158 successful jobs, 11 skipped, 1 failed, 2 still running (172 observed jobs). Both hosted Windows shards, preflight, and check-test-types passed. small-40 and small-45 were still running. The completed failure is small-44, job 105166366790, core-tooling-10-hosted-2:

Test Observed excerpt
test/scripts/pr-operation-lock.test.ts:3380, removes the missing registration and resets its owned branch on worktree add Removing exact stale PR worktree .worktrees/pr-42 followed by expected null to be +0, from enterPrWorktree at line 185.
test/scripts/pr-operation-lock.test.ts:3389, resets an existing script-owned branch when adding a fresh worktree expected null to be +0, from enterPrWorktree at line 185.

That shard reported 2 failed / 1204 passed / 1 skipped. Its log was fetched once and retained. No attribution to a known main incident is inferred from these excerpts, and the two pending shards prevent an “everything else green” claim.

Prior-head CI was blocked on known main #63; Windows and worker-artifact shards were green. That head was 8bb3a18a4cf5a4d121a669a757050ad83b038d67. Run 35202300067 finished with 157 successful jobs, 11 skipped, and the following three failing jobs (plus the derived CI gate):

Remaining failed job Test/location and excerpt
check-lint scripts/lib/ci-changed-node-test-plan.mts:770:24: Spreading to modify object properties in map calls is inefficient (oxc/no-map-spread).
small-42, core-tooling-10-hosted-2 test/scripts/doctor-install-switch-transport.test.ts:120, reproduces the original missing-address machine-scope rejection: expected reason systemd-user-bus-unavailable, received AssertionError: expected 'systemctl' to be 'busctl'.
small-45, core-tooling-9-hosted-2 test/scripts/test-projects.test.ts:449, keeps PR automation workflow edits on workflow guard tests: labeler routing returned four targets instead of three; the extra target was test/scripts/ancillary-workflow-concurrency.test.ts.

These three failing files are unchanged by this PR relative to fetched main 926731587ac9c2c96260a5feb52584ef3d76ed08. Those failures are the known main #63 class identified in the lane ruling. Failure logs were fetched once and retained; no CI rerun, further source change, second rebase, or landing was performed after this result.

Original main failure: run 35128973442, job 104906301242, commit 35a59d632fa:

Windows shutdown {"reason":"termination-indeterminate","pid":5064,"exitCode":null,"signalCode":null,"stdoutClosed":false,"stderrClosed":false,"elapsedMs":65,"taskkill":[{"force":true,"elapsedMs":63,"status":255,"signal":null}]}
Error: gateway process cleanup could not verify termination and output closure

Frequency: one confirmed occurrence among the four cited failed main runs. Windows was skipped in 35129672946, 35120124213, and 35118347140; those runs failed the real-Gateway UI E2E lane. This is not a measured 25% flake rate. Nearby overloaded-provider output came from separate provider-hook fixtures; the scheduled main-session cron event did not spawn a cron subprocess.

The follow-up addresses exact-head run 35194209375 at 137dd88ffb1acb754fdea8dad65b34a6efa34184:

Job Observed failure
small-28 Copied fixture lacked managed-windows-job-entrypoint.mts: ERR_MODULE_NOT_FOUND.
windows-1 Copied fixture lacked managed-windows-job.mts: ERR_MODULE_NOT_FOUND.
windows-2 Two native descendant failures (expected [] to include 2432; cleanup settled before recording the surviving descendant), two Gateway late-refusal readiness failures, and two controlled-transform path failures.

Native Windows proof: provider blacksmith-testbox, lease tbx_01m2q552vw8pzqk7rrmdj5dxp3, workflow run 35196012137, Windows 2025 / Node 24.21.0 / pnpm 12.4.0. Blacksmith CLI 0.4.60 still selected the Linux runner account; commands ran over native SSH with the lease's key and Windows runneradmin account. The lease was stopped after testing and source verification.

Commands used node scripts/run-vitest.mjs --config test/vitest/vitest.tooling.config.ts with OPENCLAW_VITEST_MAX_WORKERS=1: the Gateway helper, native Job, and transform files ran separately in original file order; the worker-artifact and traversal files ran together. Each repaired group ran three serial passes.

The unchanged baseline reproduced all six Windows-2 failures in original file order. The original worker-artifact case then reproduced the exact missing-module failure in 32.11 seconds. With the repair, the Gateway, native Job, and transform files each passed three serial runs: 174 Gateway cases, 9 native Job cases, 6 transform cases total. All original assertions and deadlines remain unchanged.

Local focused proof passed 85/85. The shared traversal regression passed 5/5; migrated worktree/provisioning caller checks passed. The loaded Mac's real compiler-fixture case hit its unchanged 120-second guard before and after the fix, so the final serial loop stopped after one failed attempt; no local pass is claimed for that command. The native Windows full-file runs passed 3/3, each with 34 passed / 5 platform skips across the worker-artifact and traversal suites (102 passed / 15 skips total). The repaired copied-project case completed in 30.38 seconds on the first pass. All 11 changed paths were hash-verified against the staged repair after native execution at 986a8b255ebbd494e6a9c9481f72f6f694f5c70f. That inventory rebase only changed the moved traversal helper and its tests to retain upstream #150504 functionality. The r5 native proof above supersedes the earlier managed-owner proof. Final-head Windows shards remain the hosted platform authority.

Full pnpm check:changed passed, including all typechecks, lint, zero dead exports, and zero runtime import cycles. No extension-lint substitute was needed. Fresh Codex P1 reviews are scoped-clean, with no accepted/actionable findings. The earlier inventory-integration review was rebased-branch.md at 8bb3a18a4cf5a4d121a669a757050ad83b038d67; the r5 review above supersedes it.

The Windows Testbox stopped successfully after source-hash verification. GitHub reported CONFLICTING before CI attached to 986a8b255ebbd494e6a9c9481f72f6f694f5c70f. The authorized single rebase is onto 926731587ac9c2c96260a5feb52584ef3d76ed08, producing 8bb3a18a4cf5a4d121a669a757050ad83b038d67. First six commits are patch-identical. The final commit also retains #150504's package/export validation and tests while moving that helper; it is not claimed patch-identical. All inventory entries are retained. Frozen install, integrated focused proof (94/94), full pnpm check:changed, and a fresh committed-branch P1 review all passed after conflict resolution. No extension-lint substitute was needed. The new head is published with an explicit lease. GitHub confirms the PR is ready and mergeable. Exact-head pull_request run 35202300067 completed with failure: 157 successful jobs, 11 skipped, 3 failing jobs plus the aggregate openclaw/ci-gate failure. Both Windows shards, small-28, preflight, and check-test-types passed. The lane stopped on the remaining failures without a rerun or further patch. No landing or CI rerun was requested.

ClawSweeper rank-up moves from the review comment: dependency-free planning restored and exercised with installed packages unavailable; already-exited Gateway cleanup passes through native-handle finalization; native Windows containment and independent-output descendants have Testbox proof.

Historical ClawSweeper follow-up (revision 16): the unowned-Windows fixture P2 at test/scripts/managed-child-process.termination.test.ts:100-104 is resolved by the current follow-up below. The native before/after run confirms that selecting the existing IPC direct-launch path restores all unchanged error assertions.

The same comment's data-model compatibility warning names scripts/lib/runtime-import-closure.mts. That helper reads source/configuration files and returns an import-path inventory; it does not persist state or change a schema, serialized user data, or an upgrade contract. A data migration proof is therefore inapplicable to that helper; this is an explicit skip of that generated warning, not an unverified compatibility claim.

Historical supporting proof: the original five tree regressions failed before the containment repair; focused owner/helper suites passed afterward. The exact CI planner failed before lazy loading and passed after it with application dependencies unavailable. The SDK declaration fixture's missing native-source input was repaired and its hosted-shaped suite passed 29/29. These historical runs supplement the current checks; they do not substitute for the attached head's CI.

Earlier Linux CLI-exit attribution: the missing-device-credentials test used a separate direct spawn/wait/kill harness that was unchanged by this PR. It passed 10/10 on the earlier PR head and 10/10 on pinned main. Its hosted log did not identify the lingering handle, so no foreign CLI owner was patched and no cause is claimed.

@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: M maintainer Maintainer-authored PR labels Sep 16, 2026
@steipete
steipete marked this pull request as ready for review September 16, 2026 19:05
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 16, 2026
@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 17, 2026, 10:19 AM ET / 14:19 UTC (Revision 21).

ClawSweeper review

What this changes

Windows build commands and Gateway test fixtures retain process-tree ownership through cleanup, preserve terminal output, and include the launcher in worker builds.

Merge readiness

⛔ Blocked before merge - 1 item remains

The PR remains useful: current main lacks the Windows descendant-cleanup guarantee. Earlier findings are resolved, and the prior migration warning does not apply to the unchanged build-manifest format; no blocking defect was found.

Priority: P2
Reviewed head: 0486fab2e2660e8101b20b5c42780703e7bda4bb

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent owner-level repair with meaningful native Windows evidence, resolved prior findings, and successful pinned-head validation.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): Captured Windows Testbox evidence exercises the real managed-process owner with inherited-pipe and independent-output descendants, showing output preservation, extinction, and resource release after repair. Pinned-head Windows checks also pass; unrelated UI screenshots are excluded.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): Captured Windows Testbox evidence exercises the real managed-process owner with inherited-pipe and independent-output descendants, showing output preservation, extinction, and resource release after repair. Pinned-head Windows checks also pass; unrelated UI screenshots are excluded.
Evidence reviewed 10 items Current-main necessity: Current main still launches directly, waits for close for ordinary Windows commands, and cannot verify descendants after leader exit. The retained Windows Job implementation remains unique to this branch.
Latest-release check: The v2026.9.4 source also lacks retained Windows Jobs and uses the earlier taskkill and close-based completion path. No released implementation supersedes this change.
Completion and resource ownership: The same ownership decision selects exit-triggered cleanup and finalization. Finalization requires an empty Job, leader exit, and closed output, records failure before closing the handle, and releases claims only after verified completion.
Findings None None.
Security None None.

How this fits together

The shared tooling process owner launches build commands and isolated Gateway fixtures. It joins process termination and output closure before callers release temporary resources or report completion.

flowchart TD
  A[Build command or Gateway fixture] --> B[Platform selection]
  B --> C[Windows launcher joins retained Job]
  B --> D[POSIX process group]
  C --> E[Command and descendants]
  D --> E
  E --> F[Join termination and output closure]
  F --> G[Release resources or retain failure]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +57, Tests +470, Config 0, Other +567. Total +1094 across 35 files.

View PR surface stats
Area Files Added Removed Net
Source 1 67 10 +57
Tests 23 1135 665 +470
Docs 0 0 0 0
Config 1 1 1 0
Generated 0 0 0 0
Other 10 763 196 +567
Total 35 1966 872 +1094

Review metrics

Metric Value Why it matters
Production versus test growth Production/tooling +624 net; tests/support +456 net The stated production growth establishes retained containment and explicit cleanup outcomes while consolidating entrypoint and import inventories.

Stored data model

Persistent data-model change detected: serialized state: scripts/lib/runtime-import-closure.mts, unknown-data-model-change: scripts/lib/runtime-import-closure.mts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: canonical
Canonical: #150244
Summary: The discussion selects this PR for Windows descendant cleanup; merged diagnostic and busy-host fixes address separate mechanisms.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep descendant ownership, output drainage, and resource release together in the shared process owner, reusing the existing native Windows bindings.

Do we have a high-confidence way to reproduce the issue?

Yes, source and native regression evidence establish the leader-exit/inherited-pipe failure path. This read-only review did not execute current main, and the original taskkill status 255 remains insufficient to identify that historical occurrence's precise cause.

Is this the best way to solve the issue?

Yes. Retaining kernel Job ownership addresses descendants that leader probes cannot verify, while shared finalization preserves output and avoids a competing cleanup implementation.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 32c91f39214b.

Labels

Label justifications:

  • P2: This repairs bounded Windows build/test cleanup failures and diagnostic loss without an established emergency in the shipped user runtime.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): Captured Windows Testbox evidence exercises the real managed-process owner with inherited-pipe and independent-output descendants, showing output preservation, extinction, and resource release after repair. Pinned-head Windows checks also pass; unrelated UI screenshots are excluded.
  • proof: sufficient: Contributor real behavior proof is sufficient. Captured Windows Testbox evidence exercises the real managed-process owner with inherited-pipe and independent-output descendants, showing output preservation, extinction, and resource release after repair. Pinned-head Windows checks also pass; unrelated UI screenshots are excluded.

Evidence

What I checked:

  • Current-main necessity: Current main still launches directly, waits for close for ordinary Windows commands, and cannot verify descendants after leader exit. The retained Windows Job implementation remains unique to this branch. (scripts/lib/managed-child-process.mts, 32c91f39214b)
  • Latest-release check: The v2026.9.4 source also lacks retained Windows Jobs and uses the earlier taskkill and close-based completion path. No released implementation supersedes this change. (scripts/lib/managed-child-process.mts:423, 3a9d69db306c)
  • Completion and resource ownership: The same ownership decision selects exit-triggered cleanup and finalization. Finalization requires an empty Job, leader exit, and closed output, records failure before closing the handle, and releases claims only after verified completion. (scripts/lib/managed-child-process.mts:525, 0486fab2e266)
  • Prior findings resolved: Gateway cleanup preserves exited-leader output drainage; the survivor fixture detaches from libuv's parent-owned Job; compiler inputs include lazy imports; and the synthetic unowned Windows fixture explicitly selects the existing IPC bypass. (test/scripts/managed-child-process.termination.test.ts:101, 0486fab2e266)
  • Migration warning disposition: The import collector reads source and returns paths. Its compiler caller adds those paths to the existing disposable generation's input hashes without changing the manifest schema, user data, configuration, or installed updater contract. The captured PR body explicitly explains this exception to the previous warning. (scripts/lib/runtime-import-closure.mts:72, 0486fab2e266)
  • Captured native behavior proof: The complete fetched body matched captured SHA-256 b2a8486f1555037f2e49c1c42cef1de86f5a9e8cff0cf048ef6766f32b4a105d. Its Windows Testbox evidence reports the inherited-pipe failure before repair, then three successful runs preserving 256 KiB and terminal output while verifying descendant extinction, pipe closure, and resource release: https://github.com/openclaw/openclaw/actions/runs/35205394548. Native fault-injection coverage also exercises independent-output survivors. Prepared screenshots were inspected and belong to unrelated UI placement proof; they were not credited here. (test/scripts/managed-child-process.output.test.ts:14, 0486fab2e266)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • vincentkoc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (20 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-17T08:34:13.819Z sha 986a8b255ebbd494e6a9c9481f72f6f694f5c70f :: blocked before merge. :: none
  • reviewed 2026-09-17T09:03:54.120Z sha 8bb3a18a4cf5a4d121a669a757050ad83b038d67 :: blocked before merge. :: [P2] [P2] Explicitly select the unowned-child path in the Windows fixture
  • reviewed 2026-09-17T09:25:04.460Z sha 8bb3a18a4cf5a4d121a669a757050ad83b038d67 :: blocked before merge. :: [P2] Select the unowned-child path explicitly in the Windows fixture
  • reviewed 2026-09-17T10:23:58.642Z sha cce512fb6348b57bd9dfa809bba7304310386335 :: blocked before merge. :: [P2] Select the unowned-child path explicitly in the Windows fixture
  • reviewed 2026-09-17T11:13:37.794Z sha cce512fb6348b57bd9dfa809bba7304310386335 :: blocked before merge. :: [P2] Select the unowned-child path explicitly in the Windows fixture
  • reviewed 2026-09-17T11:56:31.195Z sha 149c560 :: blocked before merge. :: none
  • reviewed 2026-09-17T12:12:30.002Z sha 149c560 :: blocked before merge. :: none
  • reviewed 2026-09-17T13:54:52.044Z sha 0486fab :: blocked before merge. :: none

@steipete

Copy link
Copy Markdown
Contributor Author

Cross-check from a parallel investigation of the same failure (main run 35128973442, job 104906301242: taskkill /F returned status 255 after 63 ms with stdout/stderr still open, and the nonzero status bypassed the closure wait at test/helpers/openclaw-test-instance.ts:542). One thing to double-check in this fix: a PID liveness probe establishes that the process-group leader exited, but not that descendants holding the inherited stdio handles are gone, so a grandchild can keep the pipes open past the leader's exit. A Job-object (or tree-wide) termination check before declaring closure would close that gap; #150245 sketches that variant and is being closed in favour of this PR.

steipete added a commit that referenced this pull request Sep 16, 2026
Collect bounded child resource diagnostics before deadlock cleanup while
preserving the original timeout and interaction failures. Keep production
logging and output-drain behavior unchanged.

Related: #150244
steipete added a commit that referenced this pull request Sep 17, 2026
)

Fix managed update repair reporting failed process cleanup after its child processes have already stopped while the host event loop is busy.

The deadline introduced by #149005 could reject before Node delivered queued native exit and pipe events, producing the update-managed-service handoff lifecycle failure. The existing relay cleanup owner now lets one I/O poll deliver those facts before final timeout rejection and starts its existing extinction join at control EOF. The five-second budget is unchanged, and repeated cancellation cannot renew it. Missing authority, live descendants, and unfinished output still fail.

The regression reproduces the original pending-completion vector on the unfixed owner. The candidate native-retirement case and original repair case each passed 20 executions; integrated relay-owner/caller/readiness/child lifecycle proof passed 92 cases. Changed gates and the scoped P0/P1 review passed. Published-driver markers have boundary coverage; this does not claim an executed published-package upgrade. Installed updater code and existing backup/rollback paths retain their behavior.

Related: #150244, #149005
@steipete
steipete force-pushed the upd/flake-windows-cron-identity-cleanup branch from bfe387b to c52a809 Compare September 17, 2026 00:30
@steipete steipete changed the title fix: Windows Gateway cleanup rejects exited children fix: Windows cleanup releases resources before descendants exit Sep 17, 2026
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: XL and removed size: M labels Sep 17, 2026
@steipete steipete changed the title fix: Windows cleanup releases resources before descendants exit fix: Windows cleanup leaves descendants running after leader exit Sep 17, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 17, 2026
)

Collect bounded child resource diagnostics before deadlock cleanup while
preserving the original timeout and interaction failures. Keep production
logging and output-drain behavior unchanged.

Related: openclaw#150244
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 17, 2026
…claw#150392)

Fix managed update repair reporting failed process cleanup after its child processes have already stopped while the host event loop is busy.

The deadline introduced by openclaw#149005 could reject before Node delivered queued native exit and pipe events, producing the update-managed-service handoff lifecycle failure. The existing relay cleanup owner now lets one I/O poll deliver those facts before final timeout rejection and starts its existing extinction join at control EOF. The five-second budget is unchanged, and repeated cancellation cannot renew it. Missing authority, live descendants, and unfinished output still fail.

The regression reproduces the original pending-completion vector on the unfixed owner. The candidate native-retirement case and original repair case each passed 20 executions; integrated relay-owner/caller/readiness/child lifecycle proof passed 92 cases. Changed gates and the scoped P0/P1 review passed. Published-driver markers have boundary coverage; this does not claim an executed published-package upgrade. Installed updater code and existing backup/rollback paths retain their behavior.

Related: openclaw#150244, openclaw#149005
@steipete
steipete force-pushed the upd/flake-windows-cron-identity-cleanup branch 3 times, most recently from 8923c91 to 137dd88 Compare September 17, 2026 07:22
@openclaw-barnacle openclaw-barnacle Bot added the commands Command implementations label Sep 17, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 17, 2026
Load the Windows spawner only at execution, resolve its worker with Node built-ins, and finalize already-exited Gateway Jobs through the shared owner. Exercise the dependency-free CI manifest and Gateway handle release at their actual boundaries.
Derive runtime and Vitest builds from the canonical descriptor inventory and reuse the registered executor in Doctor fixtures. Preserve existing process settlement assertions and deadlines.
Derive compiler inputs from the runtime import closure so copied fixtures include lazy Windows modules. Preserve exited Gateway output before finalization and exercise native and controlled compiler boundaries without changing assertions or deadlines.
Use the same tree-ownership decision for completion and finalization. Bound normal Windows output drainage inside the existing cleanup allowance, then terminate and verify the Job before releasing resources. Cover inherited output pipes with native Windows and POSIX boundary proof.
@steipete
steipete force-pushed the upd/flake-windows-cron-identity-cleanup branch from 149c560 to 0486fab Compare September 17, 2026 13:45
@steipete
steipete merged commit 146c414 into main Sep 17, 2026
240 of 241 checks passed
@steipete
steipete deleted the upd/flake-windows-cron-identity-cleanup branch September 17, 2026 14:40
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit that referenced this pull request Sep 17, 2026
Avoid plugin-retention CI timeouts caused by compiling TypeScript imports inside the child process execution deadline. Register the existing child with the shared prepared-worker compiler and declaration inventory, then launch it through the existing runtime-worker resolver.

Extend the existing artifact-selection and freshness fixtures. Production runtime behavior, GC assertions, source fallback, scenario arguments, and the 20-second deadline remain unchanged.

Validation: current-head retention proof passed 9/9; CI run 35237032106 passed for e8ddf61 with zero pending checks. Scoped review found no actionable defects.

Related: #150898, #150244.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 18, 2026
…enclaw#150244)

Fix Windows build and test cleanup when descendants outlive their command leader. Retain kernel Job ownership from admission, start owned cleanup on leader exit, preserve bounded terminal output, and release temporary-resource claims only after descendant extinction and output closure are verified. Preserve taskkill diagnostics and report unresolved survivors.

Reuse the native Windows Job bindings and one runtime/compiler entrypoint inventory. Keep CI planning dependency-free and preserve exited Gateway migration guidance. Installed updater behavior and persistent operator state are unchanged; no dependency, schema, configuration, deadline, retry, or baseline changes.

Validation: exact-head CI run 35229160236 is green, including both Windows shards. Recorded current-head Linux proof has 220 passing cases and 5 platform skips, with build and changed checks passing. Native Windows inherited-pipe proof fails before the repair and passes three serial runs afterward, preserving 256 KiB plus terminal output and verifying descendant extinction, closed pipes, and ownership release. Accepted Codex review is scoped-clean at P0/P1.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 18, 2026
…0951)

Avoid plugin-retention CI timeouts caused by compiling TypeScript imports inside the child process execution deadline. Register the existing child with the shared prepared-worker compiler and declaration inventory, then launch it through the existing runtime-worker resolver.

Extend the existing artifact-selection and freshness fixtures. Production runtime behavior, GC assertions, source fallback, scenario arguments, and the 20-second deadline remain unchanged.

Validation: current-head retention proof passed 9/9; CI run 35237032106 passed for e8ddf61 with zero pending checks. Scoped review found no actionable defects.

Related: openclaw#150898, openclaw#150244.
steipete added a commit that referenced this pull request Sep 18, 2026
…Jobs

Follow up on #151325 by sharing the stdio-preserving Job launcher between runtime children and tooling. Admit target code only after Job assignment, retain certification after root exit, and preserve worker IPC. Existing non-fatal MCP/LSP cleanup containment from #150427 is unchanged; this extends the ownership work in #150244.
steipete added a commit that referenced this pull request Sep 18, 2026
…Jobs

Follow up on #151325 by sharing the stdio-preserving Job launcher between runtime children and tooling. Admit target code only after Job assignment, retain certification after root exit, and preserve worker IPC. Existing non-fatal MCP/LSP cleanup containment from #150427 is unchanged; this extends the ownership work in #150244.
steipete added a commit that referenced this pull request Sep 18, 2026
Windows owned stdio children now use the existing retained Job owner to confirm descendant cleanup after the parent exits, preserving interactive input and worker IPC.

Keep native support optional: unavailable or failed Job setup falls back to ordinary command startup and reports typed uncertainty. Tree-required cleanup retains state locks and temporary artifacts until extinction is certified; transport-only cleanup remains independent. Claude prompt and skill artifacts are retained with a warning when cleanup is uncertain.

Related: #151325, #150427, #150244.

Validation: exact-head CI run 35354835669 is green, including both Windows node-test jobs; 243 focused tests passed locally on macOS with six native Windows skips. The P1 review is scoped-clean, and all 13 reviewed commits are preserved by a semantic-equivalent rebase. Hosted Windows proof and the capability matrix satisfy the maintainer's compatibility-proof ruling.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 19, 2026
…aw#151443)

Windows owned stdio children now use the existing retained Job owner to confirm descendant cleanup after the parent exits, preserving interactive input and worker IPC.

Keep native support optional: unavailable or failed Job setup falls back to ordinary command startup and reports typed uncertainty. Tree-required cleanup retains state locks and temporary artifacts until extinction is certified; transport-only cleanup remains independent. Claude prompt and skill artifacts are retained with a warning when cleanup is uncertain.

Related: openclaw#151325, openclaw#150427, openclaw#150244.

Validation: exact-head CI run 35354835669 is green, including both Windows node-test jobs; 243 focused tests passed locally on macOS with six native Windows skips. The P1 review is scoped-clean, and all 13 reviewed commits are preserved by a semantic-equivalent rebase. Hosted Windows proof and the capability matrix satisfy the maintainer's compatibility-proof ruling.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docs Improvements or additions to documentation maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant