Skip to content

refactor(sessions): give a session entry a host and a transport-supplied handle - #225

Merged
devsuitup merged 1 commit into
mainfrom
refactor/session-handle-seam
Sep 8, 2026
Merged

devsuitup merged 1 commit into
mainfrom
refactor/session-handle-seam

Conversation

@devsuitup

Copy link
Copy Markdown
Owner

Closes #220.

activeSessions and getPtyForSession assumed every session is a local
node-pty: a pid signalable with process.kill(pid, 0) and a write() on a
local handle. Nothing in that shape can represent a session whose process runs on
another machine, so every remote capability above observation needs this resolved
first.

This opens the seam and nothing else. No remote implementation here.

An entry keeps the session id as its key and gains host (null for local) and
kind. getPtyForSession returns a handle — { write, isAlive } — deduced from
the node-pty for a local entry, taken as given for a non-local one. The
watcher no longer calls ptyProcess.write or process.kill directly.

Local behaviour is unchanged. No existing test was modified; the suite passes as
written.

Verification

Three mutations, each with the changed line printed before the run and the file
restored from an md5-verified copy:

  1. Local handle write made a no-op → 48 existing watcher tests red. The seam is
    on the real injection path, not beside it.
  2. Local handle isAlive forced true → the new liveness test red.
  3. Injection path reopened to the raw node-pty → the new seam test red.

Worth naming: no pre-existing test isolated the liveness branch, because every
hand-built ctx in trigger-watcher.test.js supplies its own isPtyAlive, which
takes precedence over the handle. A test was added rather than an existing one
adjusted.

The new seam test is the one that proves the seam is worth having: it drives a
session through the real createTriggerContext, against a real activeSessions
map, with an entry carrying only a test-supplied handle — no pty field
anywhere.

task check: 1124 tests, 1116 passed, 0 failed, 8 pre-existing skips. Lint 0
errors.

…on handle

activeSessions entries and getPtyForSession assumed every session was a local
node-pty: trigger-watcher wrote into ptyProcess.write() and probed liveness
with process.kill(pid, 0), neither of which makes sense for a session whose
process lives on another host. getPtyForSession now attaches a handle --
{ write(data), isAlive() } -- to each entry: for a local one (session.host ==
null) it's deduced from session.pty exactly as before (same write, same
signal-0 probe, now named createLocalSessionHandle); a non-null host would
take session.handle as supplied instead, with no remote implementation added
here. trigger-watcher.js no longer touches ptyProcess.write or process.kill
directly, only the handle. activeSessions entries also carry host (null for
local) and kind, descriptive metadata nothing reads yet.

Refs #220
@devsuitup
devsuitup enabled auto-merge (squash) September 8, 2026 12:11
@devsuitup
devsuitup merged commit 3ca7c9d into main Sep 8, 2026
9 checks passed
@devsuitup
devsuitup deleted the refactor/session-handle-seam branch September 8, 2026 12:16
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.

refactor(sessions): activeSessions must carry a host and a kind

1 participant