summaryrefslogtreecommitdiff
path: root/tests/brainstorm-server/stop-server.test.sh
AgeCommit message (Collapse)Author
2026-06-16Fix companion stop metadata and token permissionsDrew Ritter
2026-06-16Fix companion lifecycle test ownership metadataDrew Ritter
2026-06-16Harden companion stop ownership proofDrew Ritter
2026-06-16Harden companion Windows lifecycle coverageDrew Ritter
2026-06-16fix(brainstorm-server): tie stop-server PID check to the session's portJesse Vincent
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-16fix(brainstorm-server): verify PID ownership before stoppingJesse Vincent
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