Windows: broker child processes leak and stale broker.json poisons setup tests on persistent machines
Two related Windows process-hygiene gaps found while running the suite repeatedly on a persistent (non-CI) Windows 11 box. Both are pre-existing (independent of any local change) and reproducible.
1. Stale broker.json poisons setup-family tests
%TEMP%\codex-companion\<repo-hash>\broker.json persists across runs and can point at a dead broker PID / stale named pipe. The setup-family tests key shared state on the real repo path (the test fixture's buildEnv() inherits process.env unmodified rather than using an ephemeral fixture dir), so a stale pointer makes every subsequent run report false "not ready" results. Symptom: ~6 spurious failures that vanish permanently after deleting that one directory. On ephemeral CI this is masked because the temp dir is always fresh.
Suggested fix: have the setup tests use an isolated $TEMP/HOME per run, or validate/ignore a broker.json whose PID is dead before treating it as authoritative.
2. Broker child processes leak on Windows
Repeated test runs accumulate orphaned app-server-broker.mjs node children (observed ~200 after a day of runs), each holding its temp workspace open. Same family as the known taskkill /T /F flake ("operation attempted is not supported" on a nested child). Correctness impact is low (each is isolated to a random temp workspace), but it blocks git worktree remove on any worktree a broker still holds open, and exhausts the process table over time.
Environment: Windows 11, codex-cli 0.144.1, plugin at current main. Happy to provide fuller repro details.
This issue conflates three axes: (1) the broker leak — stillborn/orphaned brokers = scenario 3 in the #163 map, not covered by PR #490 (the idle-timer never reaches stillborn brokers that never bind a socket); (2) stale broker.json poisoning tests — a separate validation problem (same PID-liveness family noted in #478); (3) env-inheritance / directory accumulation — the fixture spreads process.env (fake-codex-fixture.mjs:658), so tests write into the real plugin data dir, an orthogonal axis — see my stats in #163. Worth splitting. PR #490 closes only the "live-but-idle broker" subset.
Fixed in CBEPX/codex-plugin-cc v1.4.1 (https://github.com/CBEPX/codex-plugin-cc/releases/tag/v1.4.1); the stale broker.json validation was fixed in v1.3.0. The leaked children were left behind because Windows kills from a stored record were refused (identity-unavailable). Now a stale broker is replaced through a verified kill of its recorded process tree, and a failed broker start is killed the same way; its record is kept until the process has exited. Two racing broker starts no longer spawn two brokers. The CI leak check also runs on every OS.
/plugin marketplace add CBEPX/codex-plugin-cc
/plugin install codex@cbepx
This is a fork release, not an upstream fix, so I'm leaving this issue open for the maintainers here.