Repository navigation
fix(test): agent-exec, update candidate-state, handoff, and QA-lab Gateway tests fail on loaded hosts when fixture children outlast polling deadlines - #162945
Conversation
Selected CLI, update, plugin, TUI, and packaging tests polled PID files, marker files, and process death against wall-clock deadlines of 2 to 120 seconds. Healthy child startup and cleanup could outlast those deadlines. Await existing callbacks, retained child close events, IPC, and fixture receipts instead. Consult durable markers when operation settlement wins an independent receipt race, and read state once after an owner has already joined cleanup. Bind unavoidable foreign-PID observation to the Vitest test signal. Retain the negative lock-exclusion observation. Join candidate worker settlement before timed-out test teardown removes its fixture directory or restores mocks. Retain the plugin fixture through onTestFinished so timeout cannot abandon child-close and state cleanup. Join heartbeat fixture shutdown before outer runtime and SQLite teardown. Preserve fake-clock boundaries, assertions, test timeouts, and product timeout and grace values.
|
🦞👀 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, 7:14 PM ET / 23:14 UTC (Revision 2). ClawSweeper reviewWhat this changesThe PR replaces deadline-based polling in CLI, update, plugin, TUI, and Gateway tests with fixture signals and cleanup joins that survive test cancellation. Merge readiness⛔ Needs changes before merge - 1 item remains The PR remains useful: current main retains the affected polling deadlines. Both previous cleanup findings are resolved, and no remaining blocking code defect was found. Likely related people: steipete and fuller-stack-dev (unverified routing candidates). Priority: P2 Review scores
Verification
How this fits togetherThese test fixtures exercise OpenClaw commands, update workers, and Gateway lifecycle behavior. Their readiness and process-exit observations determine when assertions run and when temporary state can safely be removed. flowchart TD
A[Test starts fixture] --> B[Command or Gateway runs]
B --> C[Readiness signal or durable receipt]
C --> D[Test assertions]
E[Test cancellation] --> F[Shared cleanup join]
D --> F
F --> G[Retire temporary state]
Before merge
Agent review detailsSecurityNone. PR surfaceTests +386. Total +386 across 11 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep fixture synchronization tied to existing readiness and settlement owners, with temporary state retained until cancellation cleanup completes. Do we have a high-confidence way to reproduce the issue? Yes, from source: healthy fixture startup or extinction can exceed the fixed polling deadlines retained on current main. This read-only review did not execute a current-main failure. Is this the best way to solve the issue? Yes. Existing callbacks, receipts with durable fallback, and shared cleanup joins repair synchronization without changing production behavior or extending deadlines. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f79a0e7ae99c. 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
HistoryReview history (1 earlier review cycle)
|
Converted budget readiness and transport-extinction waits can reject at the enclosing test timeout. Vitest may run afterEach while the body's finally still owns release writes and worker settlement, removing state too early. Share a memoized cleanup promise between finally, afterEach, and onTestFinished. Join it before removing temporary directories or restoring mocks. Cancel and join workers even if a release write fails, and keep transport receipts and the stop marker until the CLI and descendants settle. Preserve existing assertions and all test and product deadlines.
|
Third Gateway E2E 2/4 owner-shard replay on 334ea44 (Blacksmith Testbox): exit 0, 590.7 s, 67 files / 519 tests (513 passed, 6 skipped), no failures; both changed files ran and passed (agent-exec-plugin 3 passed; package-openclaw-for-docker 67 passed, 3 skipped). Gateway 2/4 is now 3/3 clean on the final head. |
…teway tests fail on loaded hosts when fixture children outlast polling deadlines (openclaw#162945) agent-exec (plugin e2e and construction), update candidate-state budget/cleanup, managed-service handoff boundary/process support, plugin install-record commit, the local TUI PTY e2e, and the QA Lab Gateway heartbeat-routing and package-for-Docker tests polled readiness/PID files or raced process exit against fixed timers, so a fixture child or preparation step that outlasted the bound on a loaded host failed the test. Waits now await existing owner callbacks (such as the command onOutputChunk readiness), retained child close promises, fixture receipts with a durable-record fallback where the product owns the child, and same-process fixture events registered before the Gateway starts. The rebase keeps openclaw#162694's managed-service triage receipts byte-for-byte, openclaw#162403's cleanup directory-retirement fault, and openclaw#162496's Bun preload settings, and layers this lane's receipts and joins on top. Thirteen sites stay unchanged where independent runner clocks, post-abort cleanup joins, a synchronously blocked host, out-of-scope producers, or killed helpers without a close handle leave no owned signal. The budget and agent-exec plugin tests keep their whole fixture lifetime until teardown joins it, so a timed-out body can no longer lose its release file or stop markers to afterEach (forced-abort probes reproduce the four defects before the fix). No product source, test timeout, product timeout, or assertion meaning changed. Follow-up to openclaw#162696 in the polling audit from openclaw#162274. Proof on Blacksmith Testbox: delay probes fail the original bytes and pass these bytes, forced-abort probes reach cleanup, 480 standalone runs, 120/120 on the rebased head, Gateway E2E shards 2/4 and 3/4 3/3 each (2/4 re-proven 3/3 on the final teardown-fix head), type-aware lint, deadcode, base-aware timeout-race ratchet; Codex autoreview clean.
What Problem This Solves
Fixes: agent-exec (plugin e2e and construction), update candidate-state budget/cleanup, managed-service handoff boundary/process support, plugin install-record commit, the local TUI PTY e2e, and the QA Lab Gateway heartbeat-routing and package-for-Docker tests fail on a loaded host when a fixture child or preparation step outlasts a wall-clock polling deadline, because they poll readiness/PID files or race process exit 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. No update, Doctor, or migration behavior changes: only their tests' synchronization changes.
Why This Change Was Made
Part of the polling audit from #162274 and the follow-up to #162696, covering files that lane had to skip. Waits now await existing owner callbacks (e.g. the command
onOutputChunkreadiness), retained child close promises, fixture receipts with a durable-record fallback where the product owns the child, and same-process fixture events registered before the Gateway starts. The rebase onto main keeps #162694's stronger managed-service triage receipts byte-for-byte, #162403's cleanup directory-retirement fault, and #162496's Bun preload settings, and layers this lane's receipts and joins on top.Deliberately unchanged (13 sites): runner guards whose independent 400/2000 ms clocks fire before readiness, cleanup joins that must still complete after test abort, a host blocked synchronously inside
DatabaseSync.prepareinterception, producers outside this lane's file set, and deliberately killed helpers with no retained close handle. No product source, test timeout, product timeout, or assertion meaning changed.Release-note context: test-only change, no user-visible behavior change.
Per-site conversions
Old line numbers identify the supplied inventory. Signal categories are the work order’s preference order: 1 existing owned signal; 2 test-owned child IPC; 3 fixture receipt with durable ordering; 4 direct assertion after guaranteed settlement; 5 justified deadline-free residual.
Stops, residuals, and deliberately unconverted sites
13 requested sites remain stopped/deferred: 12 explicit STOPs plus the native Windows site. The separate 500 ms negative exclusion interval is intentionally preserved. The table above contains the precise producer/caller and ordering boundaries; the following list makes the omissions explicit.
src/cli/cli-process-child.test-helpers.test.ts:367— Independent runner guard fires at 400/2000 ms before readiness; passing >5s fault requires changing coupled clock semantics.src/cli/update-cli/update-command-executor-legacy.test.ts:313— Cleanup releases an independently grouped leaf by file; aborted test signal cannot safely bound the final join.src/commands/agent-exec-plugin.e2e.test.ts:265— Final release marker must still be consumed after test abort; needs independent exit observer before replacing cleanup join.src/infra/device-identity.test.ts:299— Host blocks inside synchronous DatabaseSync.prepare interception. Async IPC/socket callbacks cannot execute; deadline-free Atomics wait cannot observe the same-thread Vitest abort. Requires independently supervised synchronous acknowledgement.src/infra/sqlite-worker-preparation.test.ts:42— Producer is unlisted sqlite-worker-store.test-support.ts:161-174; its input has only markerPath/gatePath.src/infra/sqlite-worker-preparation.test.ts:121— Same unlisted preparation producer must emit entry receipt.src/infra/tailscale.test.ts:435— Diagnostic flush writer is unlisted test/fixtures/tailscale-foreground-fixture.mjs:26-34; public claim exposes outcome, not this flush callback.src/infra/update-managed-service-handoff-boundary.test-support.ts:473— Partial-write producer is unlisted update-managed-service-native.test-support.ts:50; needs receipt in that generator.src/infra/update-managed-service-handoff.test-support.ts:148— Deliberately killed helper no longer retains orphan close handle; test-signal residual can abandon cleanup.src/infra/update-managed-service-handoff.test-support.ts:210— Same orphan cleanup needs independent supervisor or cleanup-safe residual contract.src/state/openclaw-agent-worker-store.test-support.ts:71— Unlisted openclaw-agent-worker-store.test.ts:155-182 passes and releases path-only gates; MessagePort cutover needs that consumer.src/state/openclaw-agent-worker-store.test-support.ts:86— Same unlisted consumer, including finally release at :201-204, must migrate.test/e2e/qa-lab/runtime/package-openclaw-for-docker.e2e.test.ts:515— Native Windows target exists, but requested Node bundles/Testbox proof are Linux-only. Original helper retained as waitForWindowsChildDeath.src/plugins/install-record-commit.sqlite.test.ts:297— Preserves full exclusion interval while first writer owns lease.No out-of-allowlist producer/consumer was edited to bypass these constraints. Native Windows has a CI owner, but this lane’s Blacksmith evidence is Linux only; the native helper retains its original semantics. Worker BroadcastChannel support already existed on the base, but the blocked worker sites require unlisted fixture/caller changes. The short socket-root fallback later appeared on
origin/mainas4dbd5fb85258; this lane did not edit or cherry-pick the shared helper.The cross-file import/consumer search is preserved in [final-consumer-search.json] and [support-consumers.json]. The 24-target inventory includes the owning handoff/triage consumers. No context-dependent body emulation required an unlisted edit.
Named full-owner blocker: Gateway 2/4 ran once in its earlier67-file envelope and failed only untouched base assertions already repaired on main by
9413ff9a0639b1bf7385e62153ff059723d3980a(model refresh wording) andfd74b3415fa9d985253be34434e5430eae5ef568(yielded requester history/private receipts). The changed agent-plugin file passed all three cases. The allowlist forbids changing those two test files; no remote patch or rerun merely to obtain green was used. The final weighted Gateway2 envelope has66 files and contains the same two stale tests; the prior failure remains attributable blocker evidence, not final execution of that66-file envelope. Three clean Gateway2 replays are therefore not claimed. Direct producer/source comparison: [gateway-2-blockers.md], [gateway-2-source-comparison.json], [gateway-2-failure-result.json].Final package-owner scope blocker: Gateway3/4 on final tree ran the exact67-file owner once and failed after985.547s:546 passed,6 skipped,1 failed. The changed package test had67 passing and3 skipped assertions, zero failed.
gateway-timeout-recovery-subagent.e2e.test.tsobserved a generic failure outbound. Related mainfix85f09d7ea34b80af6e79dc33807ce6780ccf2dd9(#162260) changes the exact failing test and the persisted-user callback owner, but the retained logs do not expose the underlying Gateway exception. Exact attribution is unproven; this is not labeled inherited merely because the file is untouched. Replays2/3 were not run, and three clean replays are not claimed. See [gateway-3-final-blockers.md], [gateway-3-final-failure-result.json], [gateway-3-final-source-comparison.json].Review STOP: the configured autoreview attempt returned HTTP 401 Unauthorized. Authentication recovery, credential lookup, and review retries were stopped exactly as instructed. An earlier review attempt had been interrupted after about 43 minutes without a verdict. No passing autoreview is claimed; coordinator review remains required. Evidence: [autoreview-stream.log] and [autoreview.log].
Evidence
All proof ran on Blacksmith Testbox through
node scripts/crabbox-wrapper.mjsone-shot runs; no local Vitest.Owning CI shard replays
agentic-cliagentic-commands-agent-channelbundle-infra-small-3bundle-infra-small-runtime-14bundle-infra-small-runtime-19bundle-infra-small-runtime-20core-runtime-tui-ptyEarlier release-envelope results retained as historical evidence after heartbeat source and weighted membership changed; these do not contribute to the final-byte owner count:
Passing logs explicitly confirm touched-file/consumer execution. The first CLI and infra-small-3 local log filters dropped prefixed total
Testslines; file totals (394+1 skipped and 52+2 skipped) and touched passing-case coverage (163 and 41 lines per replay) remain valid. These coverage-line counts are not full shard case totals. Successful shards were not rerun solely to recover missing summary text. Later owner payloads retained prefixed totals or Vitest JSON.Full ownership/source and replay artifacts: [owning-shard-coverage.json], [release-e2e-shards.json], [candidate-runtime19-results.json], [gateway-replays-evidence.json], [handoff-shard-agentic-commands-agent-channel-summary.json]
Types, lint, review
The candidate-owner typechecks precede the plugin/heartbeat lifecycle revisions and remain proof for unchanged inputs. Final plugin proof adds targeted core:test and final heartbeat proof adds root tsgo; current owner log/results below distinguish that new receipt.
pnpm tsgo:core:test --changed-paths-json '["src/commands/agent-exec-plugin.e2e.test.ts", "src/commands/agent-exec.construction.test.ts", "src/infra/update-candidate-state.budget.test.ts", "src/infra/update-candidate-state.cleanup.test.ts", "src/infra/update-managed-service-handoff-boundary.test-support.ts", "src/infra/update-managed-service-handoff-process.test-support.ts", "src/infra/update-managed-service-handoff.test-support.ts", "src/infra/update-managed-service-triage.test-support.ts", "src/plugins/install-record-commit.sqlite.test.ts", "src/tui/tui-pty-local.e2e.test.ts"]'pnpm tsgo:core:test --changed-paths-json '["src/plugins/install-record-commit.sqlite.test.ts"]'Final static commands:
node_modules/.bin/oxfmt --check <12 changed files>; type-awareoxlint --tsconfig config/tsconfig/oxlint.core.json <changed src files>; root test files through their owning config where recorded;git diff --check; andnode --import ./scripts/tsx.mjs scripts/check-test-timeout-race-ratchet.mts --base origin/main.Fresh final-source checks are recorded in [final-static-results.json] and [final-precommit-checks.log]. The collector verifies every recorded source hash against the final file bytes; all five checks passed, including root type-aware lint. This supersedes the older silent/raw local logs.
Ratchet origin/main at the final static run:
c1600bbf16614de4f72e3f59d158fedff3ea8959; timestamp2026-10-01T16:00:45.579184+00:00.[final-root-type-lint-result.json]
[final-static-results.json]
[final-precommit-checks.log]
Coordinator follow-up (supersedes the lane's owner-gate notes above)
node scripts/crabbox-wrapper.mjs: 120/120 standalone runs of the conflicted and changed files, Gateway E2E shards 2/4 and 3/4 3/3 clean each (sequential), base-aware ratchet, oxfmt, type-aware lint (src and test),pnpm deadcode:full,git diff --check.scoped-clean.Follow-up: ClawSweeper timeout-teardown findings (coordinator)
ClawSweeper found two real P2 defects in this conversion: in
src/infra/update-candidate-state.budget.test.tsandsrc/commands/agent-exec-plugin.e2e.test.ts, a converted wait can now run until the enclosing test aborts, and Vitest runs the file's teardown (mock restore, temp-directory removal) without awaiting the abandoned body, so the body'sfinallycould lose its release file or stop markers and skip worker cancellation or descendant cleanup. 334ea44 retains the complete fixture lifetime in one memoized cleanup that both the body and teardown await, keeps the directories and markers until that join, and makes a failed release write unable to bypass cancellation. Forced-abort probes reproduce all four teardown defects on the previous bytes and pass on the fix. Re-proof on Blacksmith Testbox: 20/20 standalone runs per file, Node owner 3/3, Gateway E2E 2/4 2 clean replays (the third could not be admitted while Testbox was saturated), targeted types, type-aware lint (including the CI lint wrapper's unused-directive check), oxfmt,pnpm deadcode:full, base-aware ratchet.