Skip to content

test: stabilize flaky tests at root cause (batch 1) - #109347

Merged
steipete merged 1 commit into
mainfrom
fix/flaky-tests-batch
Jul 16, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/flaky-tests-batch

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Policy shift: no more flake reruns — flaky tests get fixed as discovered. This batch stabilizes flakes observed in today's CI runs, each fixed at root cause in an isolated worktree with a bounded stress-loop proof.

Fix 1: test-group-report SIGTERM descendant-cleanup race (failed run 29515993768, expected false to be true). The fixture's grandchild published its pid with a plain writeFileSync — open(O_CREAT|O_TRUNC) creates the file empty before the write lands — while the test's waitForFile polls existence only. Uniquely in this test the ready file is written by the parent right after spawn(), so the pid poll races the grandchild's write directly: a loaded runner reads the empty window, parseInt("") → NaN → isProcessAlive(NaN) false. The product's reap-before-forward ordering was never at fault (the assertion fires before SIGTERM is sent).

Why This Change Was Made

  • The pid is now published via write-to-.tmp + renameSync — atomic, so existence implies complete content. Deterministic; no sleep widening.
  • The nested triple-node spawn chain's poll-until deadlines widen 2s → 10s (pass-path speed unchanged; deadlines only bound the polling loops).
  • Assertion strength unchanged: descendants alive before SIGTERM, reaped before/at forwarding.

Further worker fixes (gateway timing/mock family, chat-responsive browser locators) will join this branch as their proofs complete.

User Impact

None at runtime — test-only. CI stops paying rerun cycles for this flake.

Evidence

  • node scripts/run-vitest.mjs test/scripts/test-group-report.test.ts — 43/43 passed; bounded stress loop 10/10 iterations green in the fix worktree.
  • Root-cause analysis in the commit message; sibling tests are ordering-protected (pid file closed before their ready file), which is why only this one flaked.

@openclaw-barnacle openclaw-barnacle Bot added size: XS maintainer Maintainer-authored PR labels Jul 16, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Jul 16, 2026
@clawsweeper

clawsweeper Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 16, 2026, 5:15 PM ET / 21:15 UTC.

Summary
The PR atomically publishes the fixture child PID through a temporary-file rename and increases three process polling deadlines from 2 to 10 seconds.

PR surface: Tests +6. Total +6 across 1 file.

Reproducibility: no. deterministic current-main reproduction was established, but the existence-only poll against a non-atomic file publication gives a clear source-level race consistent with the cited CI failure.

Review metrics: none identified.

Stored data model
Persistent data-model change detected: serialized state: test/scripts/test-group-report.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🌊 off-meta tidepool
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Refresh against current main and resolve or attribute the failing check-test-types run.

Risk before merge

  • [P1] The current check-test-types run is failing and the branch is behind current main; merge should wait for refreshed review and attribution or resolution of that check, although the available evidence does not establish a defect in this patch.

Maintainer options:

  1. Decide the mitigation before merge
    Retain the atomic PID publication and bounded deadlines, refresh the branch against current main, and merge after the test-types failure is either resolved or demonstrated to be unrelated.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] No actionable patch defect was found, and this protected maintainer-labeled PR belongs in ordinary review rather than an automated repair lane.

Security
Cleared: The one-file test-fixture change introduces no dependency, workflow, permission, secret, package-resolution, or production code-execution surface.

Review details

Best possible solution:

Retain the atomic PID publication and bounded deadlines, refresh the branch against current main, and merge after the test-types failure is either resolved or demonstrated to be unrelated.

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

No deterministic current-main reproduction was established, but the existence-only poll against a non-atomic file publication gives a clear source-level race consistent with the cited CI failure.

Is this the best way to solve the issue?

Yes. Publishing complete content through a same-directory rename fixes the race at its source, while bounded deadline increases address loaded-runner scheduling without weakening assertions or adding sleeps.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against a327e43023cb.

Label changes

Label changes:

  • add P3: This is a low-risk, test-only reliability improvement with no runtime user impact.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The external-proof gate does not apply to this maintainer-labeled test-only PR; its focused 43-test run and ten-iteration stress loop still provide useful supporting validation.

Label justifications:

  • P3: This is a low-risk, test-only reliability improvement with no runtime user impact.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The external-proof gate does not apply to this maintainer-labeled test-only PR; its focused 43-test run and ten-iteration stress loop still provide useful supporting validation.
Evidence reviewed

PR surface:

Tests +6. Total +6 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 10 4 +6
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 10 4 +6

What I checked:

  • Atomic PID publication: The fixture now writes the complete PID to a sibling temporary file before renaming it into the existence-polled path, preventing an empty target file from being observed. (test/scripts/test-group-report.test.ts:1111, 6a0b15df605b)
  • Bounded loaded-runner tolerance: The ready, child-PID, and descendant-death polling deadlines increase to 10 seconds while retaining polling-based early completion and the same lifecycle assertions. (test/scripts/test-group-report.test.ts:1137, 6a0b15df605b)
  • Focused validation: The PR reports 43 focused test cases passing and ten consecutive stress-loop passes after the change; this is appropriate supporting evidence for a test-fixture race. (test/scripts/test-group-report.test.ts:1107, 6a0b15df605b)
  • Protected review path: The live PR carries the maintainer label, so conservative cleanup policy requires it to remain open for explicit maintainer handling. (6a0b15df605b)

Likely related people:

  • steipete: Prior merged work connects this person to the repository's test-lane infrastructure, and the current change demonstrates direct ownership of this process-fixture investigation rather than only reporting it. (role: recent test-infrastructure contributor; confidence: medium; commits: 6fb74d4, 6a0b15df605b; files: test/scripts/test-group-report.test.ts, scripts/check-test-shards.mjs)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

@steipete
steipete force-pushed the fix/flaky-tests-batch branch 2 times, most recently from 70c9f50 to 3762494 Compare July 16, 2026 23:24
The child published its pid with a non-atomic writeFileSync while the test
polled file existence only, so a loaded runner could read an empty pid file
(NaN -> isProcessAlive false). Publish the pid via rename and widen the
spawn-chain poll deadlines; assertion strength is unchanged.
@steipete
steipete force-pushed the fix/flaky-tests-batch branch from 3762494 to 4387cca Compare July 16, 2026 23:37
@steipete
steipete merged commit 0598020 into main Jul 16, 2026
87 of 91 checks passed
@steipete
steipete deleted the fix/flaky-tests-batch branch July 16, 2026 23:47
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 17, 2026
…claw#109347)

The child published its pid with a non-atomic writeFileSync while the test
polled file existence only, so a loaded runner could read an empty pid file
(NaN -> isProcessAlive false). Publish the pid via rename and widen the
spawn-chain poll deadlines; assertion strength is unchanged.
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
…claw#109347)

The child published its pid with a non-atomic writeFileSync while the test
polled file existence only, so a loaded runner could read an empty pid file
(NaN -> isProcessAlive false). Publish the pid via rename and widen the
spawn-chain poll deadlines; assertion strength is unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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