Commit Graph

6 Commits

Author SHA1 Message Date
Drew Ritter
ab25b904fe Fix companion stop metadata and token permissions 2026-06-11 10:25:19 -07:00
Drew Ritter
84217fba50 Fix companion lifecycle test ownership metadata 2026-06-10 19:12:17 -07:00
Drew Ritter
e3955d1cfa Harden companion stop ownership proof 2026-06-10 18:49:38 -07:00
Drew Ritter
d47489f9d0 Harden companion Windows lifecycle coverage 2026-06-10 18:21:51 -07:00
Jesse Vincent
8ca01594b6 fix(brainstorm-server): tie stop-server PID check to the session's port
The node+server.cjs command match (from the adversarial review) still matched any
unrelated node process running a file named server.cjs. When we recorded the
bound port (state/server-info) and lsof is available, additionally require the
PID to be the process actually LISTENING on this session's port — which rules out
a different project's server.cjs / editor task runner that recycled the stale
PID. Falls back to the command match when the port or lsof isn't available.

Test: a 'node server.cjs' process not listening on the recorded port is spared.

Refs #1703
2026-06-10 18:21:42 -07:00
Jesse Vincent
e357baca01 fix(brainstorm-server): verify PID ownership before stopping
stop-server.sh read server.pid and SIGKILL'd that PID with no checks. After a
reboot or PID wraparound the pid file can point at an unrelated, live process —
which we would then kill.

Verify the PID is actually our server (a running 'node ... server.cjs') before
signalling it. If ownership can't be proven, fail closed: remove the stale pid
file and report {status: stale_pid} without killing anything. Real servers still
stop ({status: stopped}); a missing pid file still reports not_running.

Adds stop-server.test.sh covering: an unrelated reused PID is left alone, a real
server is stopped, and a missing pid file.

Refs #1703
2026-06-10 18:21:42 -07:00