paperclip/server
Tycho 505da32def test(plugin-worker-manager): cover stdin command-channel supervision
Adds the missing test for the supervision added in this PR: a worker whose
host->worker stdin pipe dies while the process itself stays alive.

New suite server/src/__tests__/plugin-worker-stdin-supervision.test.ts, plus a
plugin-worker-persistent.cjs fixture that deliberately survives stdin EOF (ref'd
keep-alive timer, readline "close" is a no-op) so nothing but the host
supervision can end it. It spawns a real child through the existing fixture
pattern and captures it by wrapping node:child_process.fork with a
pass-through mock; the fork is real.

Two cases:

1. stdin destroyed with EPIPE while the process is alive -> the manager
   SIGKILLs the child and schedules a restart (crash event willRestart=true,
   status "backoff", diagnostics().nextRestartAt in the future). SIGKILL is the
   discriminator: this fixture never exits on its own inside the test window and
   exits 0 when asked politely, so only the supervision path can produce a
   signalled exit here.

2. Negative control for the risky arm: stdin destroyed *during* an intentional
   stop must not force-kill or restart. The fixture defers its exit after acking
   shutdown, which opens the window; the test waits for status "stopping" and
   for the shutdown to drain out of the host before killing the pipe, so it
   cannot pass by dropping the shutdown instead.

Verified by mutation, not just by going green:

- reverting plugin-worker-manager.ts to the pre-fix parent fails case 1 only
  ("worker was left alive and uncommandable after its command channel died")
  and leaves case 2 green;
- removing only the `intentionalStop ||` guard fails case 2 only
  ("expected 'SIGKILL' to be null") and leaves case 1 green.

Lives in its own file because vi.mock is file-scoped and the sibling
plugin-worker-manager.test.ts keeps an unmocked fork; that suite still passes
(30 tests across both files). Server typecheck clean. The suite is picked up by
the glob-based general-server sharding and lands in exactly one of the four
shards.
2026-08-05 12:50:11 -06:00
..
scripts fix(server): use stable tsx/cli entry point in dev-watch 2026-03-28 06:42:03 +07:00
src test(plugin-worker-manager): cover stdin command-channel supervision 2026-08-05 12:50:11 -06:00
CHANGELOG.md chore: release v0.3.1 2026-03-12 13:09:22 -05:00
package.json fix(server): export manual OpenTelemetry spans (#10565) 2026-07-31 12:47:57 -07:00
tsconfig.json Fix root TypeScript solution config 2026-03-09 14:09:30 -05:00
vitest.config.ts fix(test): stop flaky server-suite afterAll hook timeouts (#10024) 2026-07-22 11:51:30 -07:00