Repository navigation
fix(test): Gateway run-loop, update executor, hooks, and ClawHub CLI process tests fail on loaded hosts when fixture children outlast polling deadlines - #163044
Conversation
CLI, Gateway, updater, and cleanup fixtures polled readiness/PID files or raced IPC and process-close events against 1s-45s wall-clock deadlines. Healthy Node startup, lifecycle staging, and native retirement could lose those races on loaded hosts. Await owned IPC/stdout events and captured close promises, or fixture receipts written after durable markers. When an operation can settle before its independent receipt arrives, consult that durable marker. Bind body waits to the Vitest abort signal so finally cleanup can run. Preserve native shutdown duration assertions and TERM/KILL escalation. Keep one signal-bound, deadline-free process-group check where the owner has no completion receipt. Remove seven timeout-race baseline references. Shared termination-helper cutover and unavailable descendant exit receipts remain documented lane follow-ups.
|
🦞👀 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 changes before merge. Reviewed October 1, 2026, 6:33 PM ET / 22:33 UTC. ClawSweeper reviewWhat this changesThe branch replaces timing-sensitive CLI process-test waits with child events, fixture receipts, and test cancellation signals while preserving existing assertions and termination behavior. Merge readiness⛔ Needs changes before merge - 1 item remains This PR remains useful: current main retains the affected polling deadlines, and the related merged work covers different fixtures. No introduced correctness or security defect was found. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw's CLI process tests launch real child processes to verify Gateway shutdown, updater custody, hook relays, plugin discovery, and cleanup. The changed fixture coordination observes readiness and process settlement before assertions and temporary-state removal. flowchart TD
A[CLI process tests] --> B[Real fixture children]
B --> C[Readiness events and receipts]
B --> D[Process close events]
C --> E[Test assertions]
D --> E
F[Test cancellation] --> G[Owned cleanup]
G --> D
D --> H[Temporary state removal]
Before merge
Agent review detailsSecurityNone. PR surfaceTests +224, Other -3. Total +221 across 15 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep fixture observation tied to owned completion signals, with durable ordering checks and existing cleanup owners preserving the process contracts. Do we have a high-confidence way to reproduce the issue? Yes: current source exposes fixed observation deadlines over healthy child startup and retirement, and the recorded Testbox probes demonstrate matching original failures. This read-only review did not execute a current-main reproduction. Is this the best way to solve the issue? Yes: using existing child events and shared receipt/cancellation helpers repairs fixture coordination without extending deadlines, weakening assertions, or adding production test seams. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 48f475d65322. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Third Gateway E2E owner-shard replay on 450d937 (coordinator, Blacksmith Testbox): this branch's changed |
…process tests fail on loaded hosts when fixture children outlast polling deadlines (openclaw#163044) CLI process tests for the Gateway run loop (package helper/lifecycle, update respawn, direct stop with active work, forced cron, model acquisition), the hooks CLI, ClawHub plugin search, the update command executor (auxiliary/native) and service custody, cleanup-utils handle exclusion, and triage polled trace, PID, and readiness files or raced child close against 5-45 s timers, so a fixture child that outlasted the bound on a loaded host failed the test. Waits now await registered close promises, existing stdout readiness lines and close gates, fixture receipts with durable-record fallback where the product owns the child, and owned triage callbacks; existing rescue SIGKILLs remain for failure paths. The ClawHub search e2e consumes the fixture server's native { port } IPC readiness from openclaw#162848 instead of adding a second message shape. Twenty sites stay unchanged, mainly waits inside the shared stop-child-process TERM/KILL owner and product-owned scripts without a retained child handle or reap receipt. No product source, product grace, test timeout, or assertion meaning changed. Part of the polling audit from openclaw#162274. Proof on Blacksmith Testbox: delay and forced-abort probes, 220 standalone runs and 100/100 on the rebased head, Node owner shards 3/3, the Gateway E2E owner shard 3 replays with the changed ClawHub e2e passing in all three (the third replay's single failure was in the untouched test/cli-json-stdout.gateway.e2e.test.ts, tracked separately), targeted tsgo, OpenGrep, deadcode, type-aware lint, base-aware timeout-race ratchet; Codex autoreview clean.
What Problem This Solves
Fixes: CLI process tests for the Gateway run loop (package helper/lifecycle, update respawn, direct stop with active work, forced cron, model acquisition), the hooks CLI, ClawHub plugin search, the update command executor (auxiliary/native) and service custody, cleanup-utils handle exclusion, and triage fail on a loaded host when a fixture child outlasts a wall-clock wait (5–45 s
withTestTimeout/vi.waitFor/expect.poll), because they poll trace, PID, and readiness files or race child close against fixed timers.User Impact
No user-visible change. These suites stop failing spuriously on slow machines; a missing readiness or exit now fails at its owning step or the Vitest test timeout.
Why This Change Was Made
Part of the polling audit from #162274. Waits now await registered close promises, existing stdout readiness lines and close gates, fixture receipts with durable-record fallback where the product owns the child, and owned triage callbacks; existing rescue SIGKILLs remain for failure paths. The ClawHub search e2e consumes the fixture server's native
{ port }IPC readiness that #162848 added, rather than adding a second message shape.Deliberately unchanged (20 sites): waits inside the shared
test/helpers/stop-child-process.tsTERM/KILL owner (its grace and final-kill guard are coupled), product-owned scripts with no retained child handle or reap receipt, and similar cases listed below. No product source, product grace, test timeout, or assertion meaning changed.Release-note context: test-only change, no user-visible behavior change.
Per-site conversions
Old line numbers are the work-order identifiers. Categories: 1 existing owned signal; 2 fixture IPC/stdout; 3 product-child receipt with durable ordering; 4 direct assertion after an owner join; 5 deadline-free test-signal-bound residual. “Adjacent” marks an additional same-owner wait.
src/cli/cli-process-child.test-helpers.ts:52src/cli/gateway-cli/run-loop-package-helper.test-support.ts:232src/cli/gateway-cli/run-loop-package-lifecycle.test-support.ts:322src/cli/gateway-cli/run-loop-package-lifecycle.test-support.ts:537src/cli/gateway-cli/run-loop-package-lifecycle.test-support.ts:445src/cli/gateway-cli/run-loop-package-lifecycle.test-support.ts:313src/cli/gateway-cli/run-loop-package-lifecycle.test-support.ts:454src/cli/gateway-cli/run-loop-update-respawn.test-support.ts:253src/cli/gateway-cli/run-loop-update-respawn.test-support.ts:305src/cli/gateway-cli/run-loop-update-respawn.test-support.ts:312src/cli/gateway-cli/run-loop.direct-stop-active-work.process.test.ts:31src/cli/gateway-cli/run-loop.direct-stop-active-work.process.test.ts:216src/cli/gateway-cli/run-loop.direct-stop-active-work.process.test.ts:168src/cli/gateway-cli/run-loop.forced-cron.process.test.ts:106src/cli/gateway-cli/run-loop.forced-cron.process.test.ts:103src/cli/gateway-cli/run-loop.forced-cron.process.test.ts:86src/cli/gateway-cli/run-loop.forced-cron.process.test.ts:22src/cli/gateway-cli/run-loop.model-acquisition.process.test.ts:73src/cli/gateway-cli/run-loop.model-acquisition.process.test.ts:115src/cli/gateway-cli/run-loop.model-acquisition.process.test.ts:66 (adjacent)src/cli/hooks-cli.process.test.ts:387src/cli/hooks-cli.process.test.ts:398src/cli/hooks-cli.process.test.ts:401src/cli/plugins-search-command.clawhub.e2e.test.ts:119src/cli/plugins-search-command.clawhub.e2e.test.ts:21src/cli/runtime-cleanup-scope.windows.process.test.ts:32src/cli/runtime-cleanup-scope.windows.process.test.ts:43src/cli/update-cli/update-command-database-rollback.test.ts:544src/cli/update-cli/update-command-database-rollback.test.ts:123src/cli/update-cli/update-command-database-rollback.test.ts:501src/cli/update-cli/update-command-executor-auxiliary.test.ts:292src/cli/update-cli/update-command-executor-auxiliary.test.ts:111src/cli/update-cli/update-command-executor-native.test.ts:333src/cli/update-cli/update-command-executor-native.test.ts:405src/cli/update-cli/update-command-executor-native.test.ts:305src/cli/update-cli/update-command-executor-native.test.ts:347src/cli/update-cli/update-command-executor-native.test.ts:341src/cli/update-cli/update-command-executor.test.ts:965src/cli/update-cli/update-command-executor.test.ts:905src/cli/update-cli/update-command-handoff.test.ts:142src/cli/update-cli/update-command-handoff.test.ts:178src/cli/update-cli/update-command-service-custody.test.ts:336src/cli/update-cli/update-command-service-maintenance-native.test.ts:258src/cli/update-cli/update-command-service-maintenance-native.test.ts:454src/commands/cleanup-utils.handle-exclusion.test.ts:80src/commands/cleanup-utils.handle-exclusion.test.ts:154src/commands/cleanup-utils.handle-exclusion.test.ts:104src/commands/cleanup-utils.handle-exclusion.test.ts:161src/commands/cleanup-utils.handle-exclusion.test.ts:113src/commands/cleanup-utils.handle-exclusion.test.ts:167src/commands/cleanup-utils.handle-exclusion.test.ts:73 (adjacent)src/commands/doctor-config-preflight.process.test.ts:826src/commands/doctor-maintenance.serving-owner.test.ts:249src/commands/doctor-maintenance.serving-owner.test.ts:286src/commands/triage.test.ts:570Stops, residuals, and deliberately unconverted sites
Evidence
All proof ran on Blacksmith Testbox through
node scripts/crabbox-wrapper.mjsone-shot runs; no local Vitest.Fault and forced-abort probes
Error: timeoutCron restart child did not closeAbortError: The operation was abortedENOENT/child.pidexpected false to be truefixture server did not write a portEach delay was applied at the same healthy boundary to original and fixed bytes. Temporary mutations were restored byte-exactly; the final probe batch emitted
ALL_PROBES_RESTORED True. Proof recipes and executed results are in [gateway-probes.py], [commands-probes.py], [commands-receipt-abort-probe.py], [update-executor-probes.py], [custody-probes.py], [probes-standalone.log], and [resume-probes-standalone-v2.log].Forced-abort probes reached first-finally markers and verified exact PID extinction for owned IPC, stdout readiness, product-child receipts, and the residual process-group wait; the latter also verified group absence. The headless receipt probe captured the producer PID before suspension and verified that the existing cancellation result joined before checking PID absence externally.
Two temporary headless-probe instrumentation attempts were inconclusive: the first reread its PID file after Vitest had started temp cleanup, and the second observed a node spawn mock bypassed by the real broker/Execa path. The corrected producer-PID/owner-result probe passed without source changes. Vitest timeout sequencing (
node_modules/vitest/dist/chunks/run.C5UmxDPh.js:3273-3275,3879-3904),test/helpers/temp-dir.ts:54,86-90, andsrc/process/exec-runner.ts:562-570explain the observation race.Direct close-wait abort evidence: [close-abort-agentic-cli.log]; temporary recipe [gateway-close-abort-probe.py]. Its success marker and restoration receipt are recorded in that log.
Standalone repetitions (flake-triage bar)
Each command was
CI=1 pnpm test <file> --maxWorkers=1. ClawHub ran serially because its E2E preparation owns shared build artifacts; the other files ran up to four different files concurrently, with no overlapping runs of the same file.src/cli/gateway-cli/run-loop.test.tssrc/cli/gateway-cli/run-loop.direct-stop-active-work.process.test.tssrc/cli/gateway-cli/run-loop.forced-cron.process.test.tssrc/cli/gateway-cli/run-loop.model-acquisition.process.test.tssrc/cli/hooks-cli.process.test.tssrc/cli/plugins-search-command.clawhub.e2e.test.tssrc/cli/update-cli/update-command-executor-auxiliary.test.tssrc/cli/update-cli/update-command-executor-native.test.tssrc/cli/update-cli/update-command-service-custody.test.tssrc/commands/cleanup-utils.handle-exclusion.test.tssrc/commands/triage.test.tsThe ClawHub before measurement includes a cold QA runtime prebuild (14m55s); the candidate smoke reused that verified generation. That difference is not attributed to the conversion. Gateway/model-acquisition suites exercise real startup, native signals, shutdown ordering and the intentional native stop-budget contract; their cost is recorded rather than reduced by weakening those contracts.
Cross-file audit used
git grepon every changed basename. There are no emulated test-body consumers requiring context adaptations. The run-loop support registration is covered byrun-loop.test.ts. The existing triage support module has nine additional consumers, and the ClawHub server has three script-test consumers; these are included in the payload.Additional consumer results recorded: 12/12 completed commands (expected 12). See [standalone.sh] and [resume-probes-standalone-v2.log].
Owning CI shard replays
Bundles were derived from
createNodeTestShardBundles({ includeReleaseOnlyToolingShards: true, includeProofTests: true }). Their group JSON and runnable payloads are retained beside this report. Each replay usesOPENCLAW_NODE_TEST_GROUPS_JSON=<group> CI=1 node --import tsx scripts/ci-run-node-test-shard.mts. Passed verbose-case receipts must name the touched files; merely listing planned filenames is insufficient. The ClawHub E2E test has no node-bundle owner and is covered by standalone E2E repetitions.agentic-cliagentic-cli-processagentic-commands-status-toolscore-tooling-2agentic-clitest counts in each clean replay:agentic-cli-processtest counts in each clean replay:agentic-commands-status-toolstest counts in each clean replay:core-tooling-2test counts in each clean replay:Types, lint, review
pnpm tsgo:core:test --changed-paths-json <changed paths>— passed.node_modules/.bin/oxfmt --checkon final changed files, type-aware oxlint withconfig/tsconfig/oxlint.core.jsonandconfig/tsconfig/oxlint.scripts.json, andgit diff --check: passed. [local-final-checks.log] and final ClawHub checks [local-type-fix-checks.log].node --import ./scripts/tsx.mjs scripts/check-test-timeout-race-ratchet.mts --base origin/main: passed,154 files, 370 grandfathered sites; three rows removed, no increases.scripts/run-opengrep.sh --changed --sarif --error: passed, 106 rules, zero findings. The pinned 1.30.0 binary was downloaded into task scratch after PATH lacked opengrep; no global installation. [opengrep-final-after-type.log].The acting lead personally inspected sibling Codex
codex-rs/hooks/src/engine/command_runner.rs, including shell construction at 428-454, process/stdout ownership at 219-225, and timeout/child settlement at 285-286. That corroborates the existing timeout-owned shell PID contract; no Codex or product runtime behavior was changed.Coordinator follow-up
scripts/e2e/lib/clawhub-fixture-server.cjsconflict toward main's{ port }message and updating this lane's consumer. On the rebased head, throughnode scripts/crabbox-wrapper.mjs: 100/100 standalone runs, 9/9 Node owner-shard replays, Gateway E2E owner 2 clean replays (the third could not be admitted while Testbox was saturated; PR CI runs the changed e2e), targeted tsgo, OpenGrep, type-aware lint, oxfmt,pnpm deadcode:full, base-aware ratchet.scoped-clean.