Skip to content

test: fix host-dependent CI flakes in comm collation and orphan-wait fixtures - #7391

Open
ardydedase wants to merge 2 commits into
kunchenguid:mainfrom
ardydedase:ardy/fm-host-collation-subreaper-ci-flakes
Open

ardydedase wants to merge 2 commits into
kunchenguid:mainfrom
ardydedase:ardy/fm-host-collation-subreaper-ci-flakes

Conversation

@ardydedase

Copy link
Copy Markdown

Intent

Fix the two pre-existing, host-dependent CI test flakes found during the cancelled PR 6858 auto-fix rounds, both reproducing at origin/main, with no behavior change beyond the two affected surfaces. (1) bin/fm-test-run.sh feeds every comparison from LC_ALL=C sort -u but invokes bare comm, so under a full-collation locale such as the vi_VN host default comm dies with 'input is not in sorted order' and the --check-coverage guard exits red; fix by pinning LC_ALL=C on every comm invocation to match its already-C-sorted feeds. (2) tests/fm-session-lock-ancestry.test.sh fixtures gate readiness on an orphan's ppid becoming 1, which never happens on PR_SET_CHILD_SUBREAPER hosts because the orphan reparents to the subreaper instead, so the bounded wait burns past the fixture's 20s deadline and the suite dies with 'the fixture hook never finished'; fix by having launchers export their own pid before forking and having fixtures wait until the subtree's ppid leaves that launcher, which proves orphaning on plain and subreaper hosts alike, and re-key the recycle assertion to prove the pty-host moved off the dead daemon instead of requiring an init reparent, preserving the test's ancestry-detection semantics. Scope limited to bin/fm-test-run.sh and tests/fm-session-lock-ancestry.test.sh; evidence recorded in state/fm-relaunch-missing-window-gap.status under the 2ef046b section; acceptance: affected suites green locally under both LC_ALL unset and LC_ALL=C, shellcheck clean, CI-green PR delivery.

What Changed

  • Pinned LC_ALL=C on every comm invocation in bin/fm-test-run.sh (portable-serial listing and all coverage-guard comparisons) so comm matches the collation of its already C-sorted feeds instead of dying with "input is not sorted" under full-collation host locales such as vi_VN.
  • Reworked the orphan-readiness waits in tests/fm-session-lock-ancestry.test.sh: launcher shells now export FM_FIXTURE_ORPHAN_PARENT with their own pid before forking, and fixture scripts wait until the subtree's ppid leaves that launcher — proving orphaning on both init-reparenting and PR_SET_CHILD_SUBREAPER hosts — instead of waiting for a ppid of exactly 1.
  • Re-keyed the recycle assertion in test_e2e_background_session_keeps_its_lock_across_a_recycled_chain to require the pty-host's ppid to move off the dead daemon rather than land on init specifically, and updated the suite's header comments to describe reaper-side ancestry semantics.

Risk Assessment

✅ Low: The change is a tightly bounded two-file CI-flake fix that pins every collation-sensitive comparison to the already-pinned C locale and replaces an init-only orphan predicate with an equally strong launcher-pid predicate authorized by the stated intent; no wrong-result or regressional paths were found.

Testing

Reproduced both pre-existing flakes at the base commit on a host that exhibits both conditions (vi_VN full-collation locale for bare comm, and a subreaper ancestor so orphans never reach pid 1), then verified the fixed runner's --check-coverage guard and the fixed ancestry suite are green under LC_ALL unset and LC_ALL=C (plus vi_VN.utf8), with the repo's canonical shellcheck lint clean on the two scoped files; no test failures remain and no actionable findings.

Evidence: Flake 1 reproduction at base commit: bare comm dies under vi_VN full-collation locale

Source: Flake 1 reproduction at base commit: bare comm dies under vi_VN full-collation locale

comm: file 2 is not in sorted order comm: input is not in sorted order EXIT=1

# Flake 1 reproduction: base commit (1a6714f) of bin/fm-test-run.sh, --check-coverage
# under LC_ALL=vi_VN.utf8 (full-collation locale; feeds were sorted with LC_ALL=C
# sort -u but comm ran bare).
# Command: git show 1a6714f:bin/fm-test-run.sh > bin/.repro-fm-test-run-base.sh && \
#          LC_ALL=vi_VN.utf8 bash bin/.repro-fm-test-run-base.sh --check-coverage
comm: file 2 is not in sorted order
comm: input is not in sorted order
EXIT=1
Evidence: Fixed runner --check-coverage green under vi_VN.utf8, unset, and C locales

Source: Fixed runner --check-coverage green under vi_VN.utf8, unset, and C locales

FM_TEST_COVERAGE ok total=259 parallel=24 parallel_max_ms=665545 parallel_imbalance_ms=2 parallel_unhinted=0 serial=219 serial_shards=9 serial_unhinted=14 serial_max_ms=1074843 serial_budget_ms=1200000 herdr=16 EXIT=0 (vi_VN.utf8, unset, and C)

# Fixed bin/fm-test-run.sh --check-coverage under three locales
# (vi_VN.utf8 reproduces the original flake; unset and C are the acceptance cases).
# 1) LC_ALL=vi_VN.utf8 bash bin/fm-test-run.sh --check-coverage
FM_TEST_COVERAGE ok total=259 parallel=24 parallel_max_ms=665545 parallel_imbalance_ms=2 parallel_unhinted=0 serial=219 serial_shards=9 serial_unhinted=14 serial_max_ms=1074843 serial_budget_ms=1200000 herdr=16
EXIT=0
# 2) LC_ALL unset (host default LANG=en_US.UTF-8)
FM_TEST_COVERAGE ok total=259 parallel=24 parallel_max_ms=665545 parallel_imbalance_ms=2 parallel_unhinted=0 serial=219 serial_shards=9 serial_unhinted=14 serial_max_ms=1074843 serial_budget_ms=1200000 herdr=16
EXIT=0
# 3) LC_ALL=C
FM_TEST_COVERAGE ok total=259 parallel=24 parallel_max_ms=665545 parallel_imbalance_ms=2 parallel_unhinted=0 serial=219 serial_shards=9 serial_unhinted=14 serial_max_ms=1074843 serial_budget_ms=1200000 herdr=16
EXIT=0
Evidence: Flake 2 reproduction at base commit on subreaper host (orphans reparent to systemd, not init)

Source: Flake 2 reproduction at base commit on subreaper host (orphans reparent to systemd, not init)

ok - session-lock: a trusted id anchors the lock on the model-loop process, anything else on the outermost pid not ok - the fixture hook never finished EXIT=1

# Flake 2 reproduction: base commit (1a6714f) of tests/fm-session-lock-ancestry.test.sh
# on this PR_SET_CHILD_SUBREAPER host (orphans reparent to systemd, not init).
# Command: git show 1a6714f:tests/fm-session-lock-ancestry.test.sh > tests/.repro-ancestry-base.test.sh && \
#          bash tests/.repro-ancestry-base.test.sh
ok - session-lock: a version-named Claude Code session is identified from its install path and argv[0]
ok - session-lock: a harness that is pid 1 of its own namespace is examined, not skipped
ok - session-lock: ordinary script paths under a harness directory are not harness processes
ok - session-lock: ownership stops at the first non-harness gap above the contiguous run
ok - session-lock: a live version-named session holding the lock is not mistaken for a stale owner
ok - session-lock: a trusted same-session id keeps owning a recycled background chain, and nothing weaker does
ok - session-lock: a trusted id anchors the lock on the model-loop process, anything else on the outermost pid
not ok - the fixture hook never finished
EXIT=1
Evidence: Fixed ancestry suite green under both LC_ALL unset and LC_ALL=C on the subreaper host

Source: Fixed ancestry suite green under both LC_ALL unset and LC_ALL=C on the subreaper host

ok - session-lock e2e: a background session keeps its lock and its supervision across a recycled helper chain ...all 16 cases ok, EXIT=0 on both runs

# Fixed tests/fm-session-lock-ancestry.test.sh on the subreaper host, both acceptance locales.
# Ran twice: `bash tests/fm-session-lock-ancestry.test.sh` with LC_ALL unset (~1m44s)
# and with LC_ALL=C (~1m41s). Both identical and green:
ok - session-lock: a version-named Claude Code session is identified from its install path and argv[0]
ok - session-lock: a harness that is pid 1 of its own namespace is examined, not skipped
ok - session-lock: ordinary script paths under a harness directory are not harness processes
ok - session-lock: ownership stops at the first non-harness gap above the contiguous run
ok - session-lock: a live version-named session holding the lock is not mistaken for a stale owner
ok - session-lock: a trusted same-session id keeps owning a recycled background chain, and nothing weaker does
ok - session-lock: a trusted id anchors the lock on the model-loop process, anything else on the outermost pid
ok - session-lock e2e: a version-named session claims the home and arms supervision
ok - session-lock e2e: a session parented by a harness-named daemon claims the home and arms supervision
ok - session-lock e2e: a version-named session under a harness-named daemon keeps its own lock
ok - session-lock e2e: a background session keeps its lock and its supervision across a recycled helper chain
ok - session-lock: a same-session confirmation waits for the claim lock and refreshes a re-keyed id
ok - session-lock: a waiting confirmation does not steal another session's lock
ok - session-lock: a failed lock write restores the previous sidecar
ok - session-lock: a failed lock write removes a newly created sidecar
ok - session-lock: a verified reclaim keeps the new sidecar beside the new pid
EXIT=0 (both runs)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • LC_ALL=vi_VN.utf8 bash bin/.repro-fm-test-run-base.sh --check-coverage (base-commit runner via git show 1a6714f) → 'comm: input is not in sorted order', exit 1 (flake 1 reproduced)
  • bash tests/.repro-ancestry-base.test.sh (base-commit test via git show 1a6714f) → fails at first e2e with 'not ok - the fixture hook never finished', exit 1 on this subreaper host (flake 2 reproduced)
  • LC_ALL=vi_VN.utf8 bash bin/fm-test-run.sh --check-coverage → FM_TEST_COVERAGE ok, exit 0
  • bash bin/fm-test-run.sh --check-coverage (LC_ALL unset) → FM_TEST_COVERAGE ok, exit 0
  • LC_ALL=C bash bin/fm-test-run.sh --check-coverage → FM_TEST_COVERAGE ok, exit 0
  • bash tests/fm-session-lock-ancestry.test.sh (LC_ALL unset) → all 16 cases ok, exit 0, ~1m44s
  • LC_ALL=C bash tests/fm-session-lock-ancestry.test.sh → all 16 cases ok, exit 0, ~1m41s
  • bin/fm-lint.sh bin/fm-test-run.sh tests/fm-session-lock-ancestry.test.sh (canonical shellcheck owner, full extended analysis) → exit 0
  • shellcheck diff of both files base vs target → findings byte-identical apart from paths; no new shellcheck findings introduced
⚠️ **Document** - 1 info
  • ℹ️ state/fm-relaunch-missing-window-gap.status - The intent declares evidence recorded under the 2ef046b section of state/fm-relaunch-missing-window-gap.status, but no such path exists in the worktree or the delivered diff. It is a task-evidence artifact owned by the outer no-mistakes run rather than a repo documentation surface, so this documentation phase neither created nor could verify it.
✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

…host semantics

fm-test-run.sh feeds every comparison from LC_ALL=C sort -u but ran bare
comm, so any full-collation locale (for example the vi_VN CI host default)
made comm die with "input is not in sorted order" and the coverage guard
exit red. Pin LC_ALL=C on every comm the same way its feeding sorts already
are.

The session-lock ancestry fixtures waited for an orphan's ppid to become 1,
which never happens on a PR_SET_CHILD_SUBREAPER host: the orphan is
reparented to the subreaper instead, so the wait burns its whole bounded
loop (about 30s wall on a busy host, past the fixture's 20s deadline) and
the suite dies with "the fixture hook never finished". Its recycle
assertion likewise required an init reparent after the daemon died. The
launchers now export their own pid before forking, the fixtures wait until
the subtree's ppid has left that launcher - proving orphaning on plain and
subreaper hosts alike - and the recycle assertion now proves the pty-host
moved off the dead daemon, which the kernel only does through a reparent.
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @ardydedase, this is a tightly scoped catch on two host-dependent flakes.

I reviewed the tip against main 1a6714f2. It only touches the test runner and a test fixture: LC_ALL=C on every comm in bin/fm-test-run.sh, and the launcher-pid orphan predicate in tests/fm-session-lock-ancestry.test.sh. There's no workflow, secret, or network surface, and the ancestry assertions still key on fixture pids, so I approved the fork CI and Require no-mistakes runs on this head. Once those are green this is eligible to merge, and there's nothing you need to do right now.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants