Repository navigation
fix(tests): run each unit test file in a process group of its own, and never signal pid 0 - #1864
Conversation
…d never signal pid 0 `bun run check fast`'s unit step sometimes died right after server/skills/omo.test.ts with no failure reported (SIGKILL in the check report, 3 of 5 runs on one lane). The file queued next, server/shell-agent.test.ts, kills the probe shell's pid in a finally. That pid stays 0 when the shell's pid file never appears (its fs.watch can fail on a PC near its inotify limit, or the 5 s bound can pass under load), and kill(0, SIGKILL) ends the caller's whole process group. ci-tests.ts ran every file in one group, so this ended every file in flight, the runner and the step at once. - ci-tests.ts starts each file in a process group of its own: a file that signals its own group now fails by that signal and is named (FAILED, NO RESULT), and the run goes on. What a file leaves running in its group is ended when it exits, and an interrupt (Ctrl+C, or check.ts ending the step) is passed on to every file still running, since their groups no longer receive it; what is left of them after 5 s, or once each file's process ended, is killed before the runner exits. Windows, which has no process groups, keeps the old spawn. - shell-agent.test.ts, check.test.ts and updater.test.ts no longer signal a pid or group that a missing or half-written pid file left at 0.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 24 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
CodeRabbit's review was rate-limited ("Review limit reached"), so no CodeRabbit review ran on this PR. The reviews below stand in for it. omo-native-code-reviewer: APPROVE. Should-fix: after forwarding an interrupt the runner exited at once, so a test child that ignores the signal outlived it (check.ts can no longer reach the per-file groups). Resolved: the runner forwards the signal, stops starting files, waits for the files or 5 s, then SIGKILLs every file group before exiting (QA: a TERM/INT-ignoring child is gone, exit 143 in 1.2 s). Nits: the "ended processes the file left running" note can also print for a group holding only unreaped dead processes (cosmetic); Windows with Git's |
|
Merge pass review-work report. Overall: PASSED. This PR changes test tooling and tests only, so under the maintainer's token rule it merges on the code review, the merge pass's own check and CI, without the gate reviewer.
What was checked
Follow-ups
All required checks are green, and no review thread is open. CodeRabbit did not review this PR (rate-limited or skipped). The reviews above stand in for it. |
Fixes #1882. ## What failed Three `server/shell-agent.test.ts` tests failed together in `bun run check fast` on the maintainer's PC with `EMFILE: too many open files, watch '<tmp>/ovis-shell-agent-path-*/home'`: "hung or oversized login probe is killed and reaped…", "answers a shell SIGKILL does not end within the bound…" and "stop cancels refresh without leaking a child". ## Root cause They waited for a fixture shell's pid file with `fs.watch` on its directory. Every watching process needs an inotify instance, and `fs.inotify.max_user_instances` (128 by default) is shared by every process of the user: with many agent sessions and their watchers, 119 to 126 of 128 were in use on that PC, and the watch was refused. Before #1864 the same refusal left a pid of 0, and the test's `kill(0)` ended the whole unit step with no failure reported. ## Fix (test only) - The three waits read a FIFO that the shell writes its pid into, made before the shell starts and bounded at 5 s (the bound opens the write end itself, so the pending read ends; a bound before the read opened rejects cleanly). - The reads after the probe has answered read the file directly (the shell writes it first thing). - Pids read are asserted to be > 0, so an empty file cannot pass as "not running". ## Proof - **Reproduction:** with every `fs.watch` refused (an injected EMFILE, and the PC's own exhausted limit at the time), main fails exactly those three tests with `EMFILE`; this passes all 18. - 32 runs, 8 at a time: 0 failures. - `bun run check fast`: passed (6396 pass, 0 fail) while the PC was at 126/128 inotify instances. - Reviewed by omo-native-code-reviewer (approve; its three low notes applied: read the FIFOs in the shell's write order, reject cleanly on ENXIO, assert pids > 0). Test-only: no Codex review, per the lane's policy. Part of the flaky-tests lane. Co-authored-by: mp <mp@local>
…1872) ## Change `isolate()` in `scripts/check.ts` dropped only the variables that point at the live herdr (its socket and pane). An inherited `HERDR_CONFIG_PATH` still reached every `bun run check` command. So the run's herdr, and any server a check script started without its own `herdrConfigPath`, read the developer's real herdr config. #1810's review hit this: with `copy_on_select = false` in the user's config, `terminal-copy-regression.ts`'s "herdr's default copies on release" tested the wrong thing. #1810 patched that one script. This PR closes the gap for every run: `HERDR_CONFIG_PATH` is now dropped with the live-herdr variables, so an isolated run finds herdr's config only under its own `XDG_CONFIG_HOME`. It is one of the merge pass's follow-ups. It changes test tooling only, and users see nothing, so there is no changelog fragment. ## Validation - `scripts/check.test.ts` ("refuses to run in the herdr the user works in…") now passes `HERDR_CONFIG_PATH` in the base env. It fails on the old `check.ts` (one extra key, `HERDR_CONFIG_PATH`) and passes with the fix. `bun test scripts/check.test.ts scripts/disposable-config.test.ts`: 60 pass. `tsc -p tsconfig.tools.json` is clean. - Run through the real surface: `HERDR_CONFIG_PATH=~/.config/herdr/config.toml bun run check run sh -c 'echo ${HERDR_CONFIG_PATH-unset}'` prints `unset`, with `XDG_CONFIG_HOME` in the run's own directory. The run directory was removed afterwards. - `bun run check fast`: workflow syntax, generated files, typecheck and build are ok. Every unit test file reports 0 fail, but the unit step ends with `check: ended processes left running in step process group`. That failure is **pre-existing**: the same `check fast` on untouched origin/main 427f5d3 fails the same way on this PC. #1864 addresses it. - Code review (omo-native-code-reviewer): APPROVE, no blockers. Of its two LOW notes, the stale comment beside the env copy is updated. Keeping the `LIVE_HERDR` name is deliberate: its doc comment now names both kinds. Co-authored-by: mp <mp@local>
## Change Follow up on #1817's native Web Push review: - Reject `rs < 18` in both aes128gcm decryptors, including an otherwise authenticated empty payload at `rs = 17`. - Add rejection coverage for truncated headers and bodies, a wrong key-ID length, a compressed point marker, a record exceeding `rs`, and authenticated missing/non-final delimiters. Keep the RFC 8291 known-answer test and exercise valid zero padding at the minimum record size. - Recover damaged iOS keychain data only when the app subscribes: delete the damaged item, generate fresh keys, and save them. Invalid private scalars now become the same damaged-store error as wrong-length items. Other keychain errors, including a locked keychain, still propagate without deleting keys. - Mirror recovery on Android for malformed Base64, wrong lengths, partial keys, invalid scalars and mismatched key halves. Replace the three stored fields together and refuse to return keys after a failed save, including cached keys left by a failed SharedPreferences commit. The FCM receiver now only reads; it never generates or rotates keys. - Return no subscription when a saved key store is damaged rather than exposing unusable keys. An `endpointOnly` option lets removal read the retained endpoint without loading keys, so turning alerts off still deletes the PC subscription. A failed PC deletion retains the endpoint. The relay endpoints stay intact. `src/lib/push.ts` already calls native `subscribe` and posts its returned keys to the open PC on every load; `server/push.ts` replaces the record for that endpoint, preserving alert preferences. No PC HTTP/WS contract change is needed. The user opens each PC in the app to refresh its subscription after recovery, without reinstalling. Until a PC has been opened, pushes encrypted with its old keys may show only the fallback notification text. A changelog fragment records that behavior. ## Validation - Copied the unpushed Swift package to the test MacBook Air (`ssh eamac`) and ran `swift test`: **20 tests, 0 failures** (13 decryption/key-generation tests and 7 key-store tests). - Swift guard mutations in disposable copies: all six mutants built and failed their tests. Removing the length guard failed the short-body assertion and trapped on the truncated header; removing key-ID length, point marker, minimum `rs`, record-size bound, or delimiter checks failed the corresponding rejection tests. - Eamac cleanup receipt: `CLEANUP removed /tmp/ovis-pushcore.fKkobw`. - Android: `:ovis-push:testDebugUnitTest` passed with the local JDK 21 and Android SDK: **22 tests, 0 failures** (13 decryptor/key-generation tests and 9 recovery-store tests). - Android mutation baseline passed all 13 decryptor tests. Removing each of the same six guards in isolated Java source copies made the corresponding tests fail; no mutant survived. - The first Codex review (`gpt-6.1-sol`, fast tier, xhigh reasoning) found two P2 bugs: damaged-key alert removal skipped the PC deletion, and Android returned cached unpersisted keys after a failed save. Both were reproduced before fixes. Two client removal tests and the Android failed-save test failed before the fixes; all pass afterwards. The native plugins now support endpoint-only reads for removal, and failed saves clear the cached key fields before throwing. The SharedPreferences stand-in now models memory updates on failed commits. - After the review fixes, `bun test src/lib/push-removal.test.ts src/lib/push.test.ts` passed: **28 tests, 0 failures**. Android's full 22-test module suite passed again. The Swift package source is unchanged from the eamac test and mutation runs. - Final Codex review of commit `b5c8634dcd86e2ac304d9530afb8a775ea24dadd`, with the requested model/settings and `Review origin/main...HEAD for crypto and key-recovery bugs`: **"No actionable crypto or key-recovery bugs found in `origin/main...HEAD`."** The reviewer independently passed 28 client and 22 Java tests; its iOS review was static. - Final `UNIT_TEST_WORKERS=2 dori heavy merge-followups -- bun run check fast` on that same head exited **1**, with **unchanged source**. Workflow syntax, generated types/themes, typecheck and build passed. The unit lane printed no failing assertions, then ended with `check: ended processes left running in step process group 1762541`; the report records `unit tests terminated by SIGKILL` and does **not** claim successful verification. This is being handed off under the maintainer's explicit allowance for the pre-existing origin/main process-group failure (#1864), as in #1872; it is **not a clean fast-check pass**. Report: `node_modules/.cache/check/b956557d-d78a-40db-aba5-4e0f95568288/report.json`. Earlier interrupted/invalidated attempts are retained locally but are not claimed as final verification. An earlier complete pass preceded the two review fixes. - Native language servers are unavailable locally; Swift compilation on eamac and the Android Gradle compilation/test run supplied compiler diagnostics. - Not verified: physical-device APNs/FCM delivery or an installed app's full recovery flow. - Per the maintainer's instruction, the `omo-native-code-reviewer` review is deferred to the maintainer after opening this PR because this session cannot spawn it at the nesting limit. Guard-removal receipts (each mutant compiled; all exited nonzero): | Guard removed | Swift result | Android result | | --- | --- | --- | | Minimum header/body length | Short-body assertion failed; truncated header trapped | 2 tests failed | | Key-ID length | 1 test failed | 1 test failed | | Uncompressed-point marker | 1 test failed | 1 test failed | | `rs >= 18` | 1 test failed | 1 test failed | | Body length bounded by `rs` | 1 test failed | 1 test failed | | Final delimiter | 2 tests failed | 2 tests failed | Local receipts are retained under `/tmp/ovis-push-recovery.MbdzIf/`: `swift-tests.log`, `mutants/*.log`, `java-mutants/*/result.log`, `android-after-fix.log`, and `removal-before.log` / `removal-after.log`. --------- Co-authored-by: mp <mp@local>
What failed
bun run check fast's unit step sometimes ended right afterserver/skills/omo.test.tswith no failure reported: the check report says the step was terminated bySIGKILL(3 of 5 runs on one lane, #1855's worktree), the log stops mid-run with no summary.Root cause
The file queued next,
server/shell-agent.test.ts("answers a shell SIGKILL does not end within the bound"), kills the probe shell's pid in afinally. That pid stays0when the shell's pid file never appears: itsfs.watchcan fail on a PC near its inotify limit (this one: 119 of 128 instances in use), or the 5 s bound can run out under load.process.kill(0, "SIGKILL")ends the caller's whole process group, andscripts/ci-tests.tsran every test file in the one group thatscripts/check.tsstarts the step in: every file in flight, the runner and the step died at once, with nothing printed.Fix
scripts/ci-tests.tsstarts each unit test file in a process group of its own. A file that signals its own group now fails by that signal and is named (FAILED/NO RESULT), and the run goes on. What a file leaves running in its group is ended when it exits (as check.ts's step cleanup did before).shell-agent.test.ts,check.test.tsandupdater.test.tsno longer signal a pid or group that a missing or half-written pid file left at 0.Proof
process.kill(0, "SIGKILL"), full unit suite: main's runner dies (wrapperKilled) after 448 of 455 files with no summary — the reported signature. This branch reports all 455, names the file asFAILEDandNO RESULT(exit 137, "ended by SIGKILL"), and exits 1.shell-agent.test.ts: 32 runs, 8 at a time: 0 failures.check.test.ts: 54 pass.bun run check fast: passed (6386 pass, 0 fail). Two earlier runs on this branch failed only inserver/omp-process.test.tsandserver/rpc-diagnostics.test.ts, flakes fixed separately (fix(tests): read omp-process test targets only once they are up #1862 and a follow-up PR).codex review, one P2, the same point, fixed).Part of the flaky-tests lane (
check fastreliability).