Repository navigation
fix(test): agent session, worktree, and provider tests time out on loaded hosts while polling fixture files - #162545
Conversation
Replace JSONL, fixture-entry, PID, and teardown polling against 500 ms to 10 s deadlines with real append completion, retained child close events, stdout and IPC receipts, and joined owner cleanup. Keep foreign-PID and process-group extinction checks deadline-free and bound to the test signal. Bridge settings lock barriers through asynchronous child stdin and worker notifications so Vitest can abort synchronous lock tests. Share native fixture release-and-join cleanup with afterEach before deleting its inputs. Leave exec readiness and cold ACP initialization unchanged where existing product deadlines still precede the requested delayed-boot proof.
|
🦞👀 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, 4:33 AM ET / 08:33 UTC. ClawSweeper reviewWhat this changesThe PR replaces short polling deadlines in agent tests with owned completion signals, fixture receipts, and abortable process checks while preserving existing assertions. Merge readiness⛔ Needs changes before merge - 1 item remains Keep open: this remains useful test-reliability work, with convincing delay and cleanup evidence and no identified introduced defect. The merged predecessor supplies shared helpers but does not cover these conversions. Priority: P2 Review scores
Verification
How this fits togetherThese tests exercise agent settings, native execution, local provider services, and worktree cleanup through child processes. Fixture signals coordinate assertions and teardown so slow startup does not look like a product failure. flowchart TD
A[Agent test] --> B[Product operation]
B --> C[Fixture child]
C --> D[Readiness or completion signal]
D --> E[Assertions]
A --> F[Test cancellation]
F --> G[Joined process cleanup]
E --> G
Before merge
Agent review detailsSecurityNone. PR surfaceTests +402. Total +402 across 16 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep fixture synchronization tied to actual readiness and cleanup ownership, with existing product deadlines and regression assertions intact. Do we have a high-confidence way to reproduce the issue? Yes: current-main polling deadlines race healthy child startup, and matching before/after Testbox delay probes demonstrate the failure mechanism. This review inspected source and supplied execution records without running tests. Is this the best way to solve the issue? Yes: owned signals and durable-record fallbacks remove competing test deadlines while preserving cleanup and assertions; no production hook is added. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 83a449f8523c. 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
|
|
Landing notes:
|
…aded hosts while polling fixture files (openclaw#162545) Agent session, worktree, provider-service, MCP cleanup, and native-harness tests waited for fixture children and workers by polling files, PID files, and the process table against 1-10 s wall-clock deadlines, which a loaded host outlasts. Each wait now awaits its owning signal: retained promises and ChildProcess close handles, stdout readiness lines and an owned stdin release for test-spawned children, fixture receipts with a durable-record fallback for product-spawned children, and direct reads where an awaited product operation already guarantees the state. settings-storage moves its synchronous reader interception into a child so a held barrier cannot wedge the Vitest thread. Foreign-PID extinction without an owner join keeps a deadline-free check bound to the test signal. sessions/exec.real readiness and the native-harness cold-session wait stay unchanged because a product timeout races the same boot (follow-up). No product source, test timeout, product timeout, or assertion meaning changed. Part of the polling audit from openclaw#162274. Proof on Blacksmith Testbox: delayed-startup fault probes fail the original bytes and pass these bytes; forced-abort probes reach cleanup with no leaked PIDs; 20/20 standalone runs of all twelve files; 3/3 replays of all seven owning bundles; targeted tsgo; Codex autoreview and ClawSweeper (no findings). The red checks-windows-node-test-4 job is inherited from main (session-accessor creation worker; hourly runs 36827062752, 36831897385).
What Problem This Solves
Fixes: agent session, worktree, provider-service, MCP cleanup, and native-harness tests fail on a loaded host when a fixture child or worker takes longer than a short wall-clock deadline (1–10 s) to become ready, because the tests poll files, PID files, or the process table against those deadlines.
User Impact
No user-visible change. These suites stop failing spuriously on slow or busy machines, and a genuinely missing event now fails at its owning step or at the Vitest test timeout instead of racing a timer.
Why This Change Was Made
Part of the polling audit from #162274 (which added
test/helpers/fixture-receipts.tsand recorded the full census in its body). This batch converts the remainingsrc/agentssites to the signal that owns each event: retained promises andChildProcessclose handles, stdout readiness lines and an owned stdin release for test-spawned children, fixture receipts with a durable-record fallback for product-spawned children, and direct reads where an awaited product operation already guarantees the state (each ordering claim is cited in the table below). Foreign-PID extinction with no owner join keeps a deadline-free check bound to the test signal.settings-storage.test.tsmoves its synchronous reader interception into a child so a held barrier can never wedge the Vitest thread. No product source, test timeout, product timeout, or assertion meaning changed.Two sites stay unconverted on purpose:
sessions/exec.real.test.tsreadiness and the cold-session wait inharness/acp-native-execution.process.test.ts. In both, a product timeout (1 s / 3 s) already races the same child boot, so no test-side signal can make a slow boot pass without changing timeout ownership; they are follow-ups.Release-note context: test-only change, no user-visible behavior change.
Per-site conversions
Old lines are the work-order locations. Categories follow its preference order.
Stops, residuals, and deliberately unconverted sites
STOP
Evidence
All proof ran on Blacksmith Testbox through
node scripts/crabbox-wrapper.mjsone-shot runs; no local Vitest.Fault and forced-abort probes
timeout waiting for .../first-entered; fixed passes under the unchanged test deadline. Separate readiness and synchronous-barrier forced aborts both record first-finally and cleanup completion; all recorded child PIDs are absent.AssertionError: expected empty text to be yesandMatcher did not succeed in time.; fixed passes. The final cleanup revision reran both its forced-abort and delayed-start proof successfully.Timed out waiting for pid file:at 5,000 ms; fixed passes.PROCESS_RESIDUAL_NO_LEAK, and confirms both host/service dead.Initial failures were investigated rather than dismissed: Node publishes child-process diagnostics before PID assignment (fixed by retaining object identity); Linux spawned stdin is nonblocking (fixed with async input/SAB worker bridge); native timeout teardown deleted its release file too early (fixed with shared release-and-join lifecycle ownership). The initial native abort probe left a sleeping child parented by PID 1; the probe recorded that failure before rescuing only the exact fixture process. Final native abort evidence has
joined: true,in_test_child_gone: true, andpost_pnpm_process: null. Bash’s missing late console message was only an observation issue: external durable PID checks proved extinction without changing source.Key machine-readable proof records:
Standalone repetitions (flake-triage bar)
Each command was
CI=1 pnpm test <file> --maxWorkers=1; at most four different files ran concurrently, never two runs of the same file. No failing repetition was retried to erase a failure. Native macOS skips are reported separately.src/agents/embedded-agent-subscribe.raw-stream.test.tssrc/agents/harness/acp-native-execution.process.test.tssrc/agents/mcp-stdio-client.cleanup.real.test.tssrc/agents/provider-local-service.shutdown.test.tssrc/agents/provider-local-service.test.tssrc/agents/sessions/bash-executor.test.tssrc/agents/sessions/exec.real.test.tssrc/agents/sessions/settings-storage.test.tssrc/agents/sessions/tools/bash.test.tssrc/agents/worktrees/filesystem-native.test.tssrc/agents/worktrees/service.hooks.test.tssrc/agents/worktrees/service.provisioned.test.tsEvery per-run wall, exit code, and test-count summary is in [standalone-results.json]. Before walls came from fetched origin/main bytes; those matched the requested base byte-exactly. Full wall times include cold runtime-fixture builds and test launcher cost, so these measurements are evidence, not a claim of a general speedup.
Owning CI shard replays
Bundles were discovered with
createNodeTestShardBundles({ includeProofTests: true }), including release-only ownership; whole-config agents-support ownership was resolved through the canonical owner inventory. Exact[{shard_name, configs, includePatterns}]payloads are in [shards.json]. Every replay usesOPENCLAW_NODE_TEST_GROUPS_JSON=<group> CI=1 node --import tsx scripts/ci-run-node-test-shard.mts.agentic-agents-core-modelsagentic-agents-core-runtimeagentic-agents-core-subagentsagentic-agents-supportbundle-infra-small-runtime-11bundle-infra-small-runtime-12bundle-infra-small-runtime-7Types, lint, review
pnpm tsgo:core:test --changed-paths-json <all touched paths>passed all 27 selected core-test graphs in 1,073.786 s. The native cleanup-only follow-up passed the selectedagents-toolstype graph in 38.4 s; see [tsgo-final.log]. Local checks use the shared donor without modifying it: oxfmt --check on all touched paths; type-aware oxlint withconfig/tsconfig/oxlint.core.jsonon src files; plain oxlint for the excluded.mjsfixture; and git diff --check. See [lint.log]. The root test tsconfig excludes test/fixtures, hence no type-aware root fixture lane exists.Isolated Codex autoreview of the final candidate: see [autoreview-complete.txt] and [autoreview-complete.json]. The earlier candidate review was intentionally interrupted after the independent native abort probe proved a source defect; it is not claimed as a completed review. A second review produced no report after 50 minutes and was restarted with the same engine/model and streamed diagnostics, without changing source or isolation. Streamed diagnostics then showed HTTP 401 before any review report. The existing configured command-auth route was selected explicitly; the helper was invoked with the installed Python 3.14 because its system-Python 3.9 shebang could not parse that route. No credential was changed or printed.
Coordinator shard replays 2 and 3 (flake-triage bar: 3 clean replays of every owning bundle, with the lane's replay above)