Skip to content

fix(tests): run each unit test file in a process group of its own, and never signal pid 0 - #1864

Merged
devswha merged 1 commit into
mainfrom
fix/unit-test-process-groups
Oct 24, 2026
Merged

devswha merged 1 commit into
mainfrom
fix/unit-test-process-groups

Conversation

@devswha

@devswha devswha commented Oct 24, 2026

Copy link
Copy Markdown
Owner

What failed

bun run check fast's unit step sometimes ended right after server/skills/omo.test.ts with no failure reported: the check report says the step was terminated by SIGKILL (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 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 (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, and scripts/ci-tests.ts ran every test file in the one group that scripts/check.ts starts the step in: every file in flight, the runner and the step died at once, with nothing printed.

Fix

  • scripts/ci-tests.ts starts 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).
  • Since the files' groups no longer get an interrupt sent to the step's group, the runner passes SIGINT/SIGTERM/SIGHUP on to every file still running, stops starting new ones, and kills what is left of their groups once the files ended or after 5 s, then exits 130/143/129. Windows (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.

Proof

  • Deliberate reproduction with a scratch test file calling process.kill(0, "SIGKILL"), full unit suite: main's runner dies (wrapper Killed) after 448 of 455 files with no summary — the reported signature. This branch reports all 455, names the file as FAILED and NO 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.
  • Interrupts: SIGINT to the runner while 8 files ran: exit 130, 0 test processes left. SIGTERM with a test child that ignores TERM and INT: exit 143 in 1.2 s, the child gone.
  • bun run check fast: passed (6386 pass, 0 fail). Two earlier runs on this branch failed only in server/omp-process.test.ts and server/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).
  • Reviews: omo-native-code-reviewer (approve; its should-fix — no SIGKILL after forwarding an interrupt — is implemented as suggested) and Codex (codex review, one P2, the same point, fixed).

Part of the flaky-tests lane (check fast reliability).

…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.
@coderabbitai

coderabbitai Bot commented Oct 24, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 427f5d3 and 64a547a.

Files selected for processing: 4
  • scripts/check.test.ts
  • scripts/ci-tests.ts
  • server/shell-agent.test.ts
  • server/updater.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devswha

devswha commented Oct 24, 2026

Copy link
Copy Markdown
Owner Author

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 sh on PATH has no process groups — resolved by keeping the old spawn on win32.
Codex (codex review): one P2, the same interrupt point — resolved as above.

@devswha

devswha commented Oct 24, 2026

Copy link
Copy Markdown
Owner Author

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.

Lane Verdict
Code review (omo-native-code-reviewer, programming + remove-ai-slops) PASS (WATCH)
Merge pass's own check typecheck passes; git merge-tree is clean with #1863, which shares server/shell-agent.test.ts

What was checked

  • A file that kills its own group: the run continues, the file is reported (FAILED / NO RESULT, exit 137), and nothing is left running.
  • SIGINT mid-run:
    • 5 runs exit 130 about 5.0 s after the signal and leave nothing running, even with a file and a child that ignore the signal.
    • 20 more runs, where every file stopped promptly, exit 130.
  • Windows: without sh, the runner keeps the old serial path. With Git's sh, detached is off and the group kills fail harmlessly.
  • pid guards: the pid > 0 guards cover the only two places a pid is read from a file.
  • updater.test.ts: 2 of its cases timed out under the reviewer's machine load. Run alone, they pass on this PR and on main.

Follow-ups

  • MEDIUM: the runner and check.ts both wait exactly 5 s before killing (ci-tests.ts:74 and check.ts:1197). A shorter wait in the runner, about 4 s, would make sure it cleans up first.
  • LOW: the new runner behaviour has no automated test.

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.

@devswha
devswha merged commit 1d3407d into main Oct 24, 2026
17 checks passed
@devswha
devswha deleted the fix/unit-test-process-groups branch October 24, 2026 13:44
devswha added a commit that referenced this pull request Oct 24, 2026
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>
devswha added a commit that referenced this pull request Oct 24, 2026
…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>
devswha added a commit that referenced this pull request Oct 24, 2026
## 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>
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.

1 participant