Skip to content

fix(bin): run the coverage guard's comm comparisons under the C collation - #7396

Open
babbarc wants to merge 1 commit into
kunchenguid:mainfrom
babbarc:fm/upstream-offer-test-run-locale-comm
Open

babbarc wants to merge 1 commit into
kunchenguid:mainfrom
babbarc:fm/upstream-offer-test-run-locale-comm

Conversation

@babbarc

@babbarc babbarc commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Intent

The captain approved this as its own fifth upstream offer. bin/fm-test-run.sh sorts with LC_ALL=C but runs every comm under the caller's locale, so on any host that is not on the C collation the coverage guard fails with "comm: input is not in sorted order" - a real pre-existing flaw on upstream's own main, reproducible on clean origin/main 1a6714f by running the coverage guard under LANG=en_US.UTF-8 (it passes under LC_ALL=C). Three separate validation runs across two other offers each independently produced this fix and each had to be told to drop it because those offers were deliberately narrow, so he wants it offered once, properly, on its own. FILE IT as its own fifth offer.

What Changed

  • bin/fm-test-run.sh now runs every comm call in the coverage guard and in portable_serial_unhinted under LC_ALL=C, the same collation used by the sort calls that build those lists. Before this, comm used the caller's locale, so on a host with a non-C collation (for example LANG=en_US.UTF-8) the guard failed with comm: input is not in sorted order even though the tree was fine. The header comment now notes this.
  • New regression test test_coverage_guard_survives_a_utf8_collation_locale in tests/fm-test-run.test.sh. It looks for an installed UTF-8 locale whose collation differs from C. If the host has none, it compiles en_US.UTF-8 into a private LOCPATH with localedef. It then checks that plain comm really rejects the C-ordered lists in that locale, and that --check-coverage still passes and prints FM_TEST_COVERAGE ok. If no such locale can be found or built, the test skips.

Risk Assessment

✅ Low: The change only adds LC_ALL=C to every comm call in bin/fm-test-run.sh, so the comparisons now use the same collation as the LC_ALL=C sorts that produce their inputs. No comm call in the file is left under the caller's locale. The new test reproduces the failure under a real non-C UTF-8 locale and checks the guard's actual result. It does not match source text, which satisfies the stated intent.

Testing

I reproduced the bug on base: the coverage guard fails with "comm: input is not in sorted order" under LANG=en_US.UTF-8 and passes under LC_ALL=C. On the target, the same command passes in both locales. The new regression test fails against the base script and passes against the fix. The full fm-test-run.test.sh still exits 1 because of one failure, and it is not caused by this change: a nested run of fm-session-lock-ancestry.test.sh expects orphaned processes to be reparented to PID 1, but this host uses a subreaper (PID 753). Evidence is a before/after CLI transcript. There is no UI surface.

Evidence: Coverage guard before/after transcript under a UTF-8 vs C locale

Source: Coverage guard before/after transcript under a UTF-8 vs C locale

BASE 5f2b81b LANG=en_US.UTF-8: comm: input is not in sorted order, exit=1 BASE 5f2b81b LC_ALL=C: FM_TEST_COVERAGE ok total=259 ..., exit=0 TARGET f1f123a LANG=en_US.UTF-8: FM_TEST_COVERAGE ok total=259 ..., exit=0 TARGET f1f123a LC_ALL=C: FM_TEST_COVERAGE ok total=259 ..., exit=0

$ # BASE 5f2b81b: LANG=en_US.UTF-8 bin/fm-test-run.sh --check-coverage
comm: file 2 is not in sorted order
comm: input is not in sorted order
exit=1

$ # BASE 5f2b81b: LC_ALL=C 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

$ # TARGET f1f123a: LANG=en_US.UTF-8 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

$ # TARGET f1f123a: LC_ALL=C 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
- Outcome: ⚠️ 1 info across 1 run (6m5s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

⚠️ **Test** - 1 info
  • ℹ️ tests/fm-session-lock-ancestry.test.sh:772 - This failure is not caused by this change. tests/fm-session-lock-ancestry.test.sh fails here with 'the pty-host was not reparented to init after the daemon ended', and it is run in a nested way from tests/fm-test-run.test.sh (the '--jobs on a proven family' case), so that whole file exits 1. The test expects orphaned processes to be reparented to PID 1, but on this host they are reparented to a subreaper (PID 753). That is a problem with this test environment. It is outside this deliberately narrow offer, so I left it unfixed.
  • env -u LC_ALL LANG=en_US.UTF-8 bash bin/fm-test-run.sh --check-coverage on a base 5f2b81b worktree (reproduced: exit=1, 'comm: input is not in sorted order')
  • LC_ALL=C bash bin/fm-test-run.sh --check-coverage on base 5f2b81b (exit=0, FM_TEST_COVERAGE ok)
  • env -u LC_ALL LANG=en_US.UTF-8 bash bin/fm-test-run.sh --check-coverage on target f1f123a (exit=0, FM_TEST_COVERAGE ok)
  • LC_ALL=en_US.UTF-8 bash bin/fm-test-run.sh --check-coverage and LC_ALL=C ... on target (both exit=0)
  • bash tests/fm-test-run.test.sh with base bin/fm-test-run.sh temporarily swapped in (new test fails with the comm sorted-order error; swap reverted)
  • bash tests/fm-test-run.test.sh on target (new test_coverage_guard_survives_a_utf8_collation_locale passes under en_US.utf8; one unrelated nested failure from tests/fm-session-lock-ancestry.test.sh)
  • bash tests/fm-session-lock-ancestry.test.sh run on its own plus an orphan-reparenting probe (orphans go to subreaper PID 753, not PID 1)
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

bin/fm-test-run.sh sorts its lane and inventory lists with LC_ALL=C but ran
every comm under the caller's locale, so on a host whose locale is not the C
collation the coverage guard rejected correctly ordered input with
"comm: input is not in sorted order" and failed on a healthy tree.

Prefix each of the nine comm calls with LC_ALL=C, matching the collation the
same code sorts under, and document the contract in the runner's header.

tests/fm-test-run.test.sh runs the real guard under a non-C UTF-8 locale,
resolved from the host or compiled into a private LOCPATH, and asserts plain
comm rejects those same lists there so the case cannot pass vacuously.

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @babbarc — this is a clean, narrow restore.

What I checked (tip f1f123a8 vs main 5f2b81bc): every comm in the coverage guard and in portable_serial_unhinted now runs under LC_ALL=C, matching the LC_ALL=C sort that builds those lists. The new regression test resolves a real non-C UTF-8 collation (installed or private LOCPATH), asserts plain comm rejects the C-ordered lists, then asserts --check-coverage still prints FM_TEST_COVERAGE ok. No .github/workflows changes. Attestation MATCH.

Contract-class: restore. The guard already promised set equality over C-sorted lists; the caller's locale was making a healthy tree look unsorted. Unconfigured product behavior is unchanged.

VISION.md, rule by rule

  • One captain, one interface: aligns (no new captain surface).
  • Authority explicit: aligns (no consent change).
  • Scripts own mechanics: aligns (locale is a scripted comparison contract).
  • Restart non-event: n/a.
  • Delegation with a spine: aligns (regression that fails on the old code).
  • Fleet outlives vendor: aligns.
  • Scope: aligns (field locale incident → coverage).

CI: fork runs were waiting on approval. Diff is test-runner + one test file only, so I approved CI 38873177885 and Require no-mistakes 38873177828. Waiting on those to go green.

Overlap: #7382 also carries an LC_ALL=C comm fix; this dedicated offer is the one to land for that slice.

Nothing needed from you. Auto-merge candidate once CI + no-mistakes are fully green.

babbarc pushed a commit to babbarc/firstmate that referenced this pull request Nov 22, 2026
…host

The test-runner bounds change already prefixes every comm call in
bin/fm-test-run.sh with LC_ALL=C, matching the collation its lists are sorted
under. This carries the rest of the change offered upstream as
kunchenguid#7396: the runner header's contract
note, and the regression test that runs the real coverage guard under a non-C
UTF-8 locale (resolved from the host or compiled into a private LOCPATH) and
asserts that plain comm rejects those same lists, so the case cannot pass
vacuously.
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