Skip to content

ci(cmux-next): the swift test wrapper reads its log only once tee has written it (bash 3.2) - #23402

Merged
teamleaderleo merged 2 commits into
feat-cmux-nextfrom
browser-import-2/script-test-race
Oct 21, 2026
Merged

teamleaderleo merged 2 commits into
feat-cmux-nextfrom
browser-import-2/script-test-race

Conversation

@teamleaderleo

@teamleaderleo teamleaderleo commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

What

A second race in swift-test-with-hang-sampler.sh, beside the one #23290 fixes. The wrapper reads its log right after closing tee's input:

exec 3>&-
wait "$tee_pid" 2>/dev/null || true

bash 3.2, macOS's /bin/bash, cannot wait for a process substitution. wait returns 127 at once while tee is still writing. The report then reads an empty or cut log, which shows up in two ways:

  • no red tests are named;
  • a run that has its summary line is read as having ended early.

Measured: a probe reads 0 of 2 lines on bash 3.2 and 2 of 2 on bash 5.3. bash 5 (the Linux CI runners) waits correctly, so this only hits macOS runs of the wrapper.

Not this PR: the #23366 flake itself (swift-test-log.*: No such file) is #23290's. The watcher subshell inherits the wrapper's EXIT trap and deletes the log when it is killed early. The two PRs change different lines and merge cleanly.

Fix

When wait can't wait, the wrapper polls kill -0 on tee's pid until it is gone, for at most 10 s, and only then reads the log.

Tests

swift-test-summary.test.sh gains a case with a tee that writes late: it buffers its input and writes 1 s after the input closes. The red run must still name its red test.

  • Committed red first (0987322): fails under /bin/bash 3.2 with "a late-written log was read before its writer finished".
  • Passes with the fix under both bash 3.2 and bash 5.3.

Other scripts/**/tests/*.test.sh with the same patterns:

  • This wrapper is the only >(tee …) in scripts/.
  • Of the tests that run a script writing under RUNNER_TEMP, only package-test-lane-suite-args.test.sh leaves RUNNER_TEMP unset. Its refusals exit before the lane touches it. No other changes needed.

No capture: CI script, no UI.

Agent session: cosmic-gray

🤖 Generated with Claude Code

teamleaderleo and others added 2 commits October 21, 2026 05:33
…en it

bash 3.2 cannot wait for a process substitution, so wait returned at once and
the report could read the log while tee was still writing it (an empty or cut
log: no reds named, or a run with its summary read as ended early). The wrapper
now watches tee's pid end, up to 10 s, when wait cannot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Session: https://cmux.com/deeplink/agent?harness=claude&session=01a15d18-98cd-7a42-ac32-a70f43729c15&host=cosmic-gray
@teamleaderleo teamleaderleo added the risk:low Risk tier (docs/ci/risk-tiers.md) label Oct 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

cmux status (one comment, edited in place; each line is updated by the job that owns it)

Review 27c7140: HQ feed card · gallery before/after runs · checks

App of this head (app.zip, kept 1 day)

gh workflow run reload-build.yml -R manaflow-ai/cmux --ref feat-cmux-next -f tag=pr23402 -f ref=browser-import-2/script-test-race -f platform=macos -f backend_mode=local

@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

Owned by browser-import-2 on cosmic-gray · session

1 similar comment
@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

Owned by browser-import-2 on cosmic-gray · session

@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

Bead cx-v7r1y created for this PR by the cmux coordinator.

@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

Review (independent subagent): SHIP at 27c7140

  • Diagnosis checked: under /bin/bash 3.2, wait on the process-substitution pid returns 127 at once with the pid still alive; bash 5.3 waits.
  • Red then green checked: at 0987322 the new slow-tee case fails under bash 3.2 ("a late-written log was read before its writer finished"); at 27c7140 it passes under 3.2 and 5.
  • The fix can't hang: the kill -0 loop is capped near 10 s. No zombie on 3.2, and on bash 5 the first wait reaps tee so the loop exits at once.
  • merge-tree with cmux-next: swift test wrapper sets its cleanup trap after it forks (swift-test-summary flake) #23290 (b7cc518) is clean, and the two fixes don't interact.
  • The slow tee is only on PATH for the one call (prefix assignment on a function call).
  • Nits: removed the stray "In progress" line from the body. "macOS only" more exactly means hosts whose bash is 3.2.

@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

Red attribution before merging, at head 27c7140. All three failing jobs also fail on base:

  • cmux-next generated files (exportIsFresh reports the exports are stale): this job also failed in feat-cmux-next push runs 39615647078 and 39613279968.
  • cmux-next swift test and cmux-next daemon tests: these run here only because the PR edits swift-test-with-hang-sampler.sh, and they never run on base pushes. So I ran the 16 red suites at the merge base 6c541e6 on the fleet (cmux-ci step 60cb540812c6f99a9c71a194).
    • 6 suites fail at base: SettingsSchemaExport, PhoneAccessSetting, HomeMessageRequests, AccountsCmuxRow, RowCloseMotion and ClassicUpgradeSimulation. ClassicUpgradeSimulation fails with the same order-differs failures as here.
    • The other 10 pass at base when run alone and failed here inside the full parallel run.
    • This PR changes no Swift code. Its wrapper change only runs after swift test exits, so it can't change which tests pass.

@teamleaderleo
teamleaderleo merged commit ed547f0 into feat-cmux-next Oct 21, 2026
@teamleaderleo
teamleaderleo deleted the browser-import-2/script-test-race branch October 21, 2026 14:59
@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

base-red-watch: cmux-next web / web lint (fast) went red on feat-cmux-next in https://github.com/manaflow-ai/cmux/actions/runs/39621747120 (first red at ed547f0, last green at 7710c58). Suspect: #23402 (commit ed547f0). If it is yours, fix forward on feat-cmux-next.

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:low Risk tier (docs/ci/risk-tiers.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant