/** * @fileoverview Pure core for FOREIGN tmux sessions, the ones a human started * by hand, which Codeman neither created nor owns. * * Everything here is a string in / structure out, so all three locations (local, * inside a container, across ssh) go through ONE probe script, ONE parser and ONE * classifier. Writing a second copy per location is exactly how the two would * drift into disagreeing about what a session is. * * ## Why the probe script is dumb * * It runs two commands and prints them: `tmux list-panes` per socket, and one * `ps` snapshot. No filtering, no logic. All judgement happens in Node, where it * is pure and unit-testable, instead of in a shell string that is embedded three * different ways and can only be debugged against a real host. * * The one thing the script does decide is whether a server is safe to ask, because * only the script can. A tmux server that stopped answering holds its client * forever, and from outside a container or across ssh no signal reaches that * client: a timeout kills `docker exec` or `ssh`, never what they started. So each * server gets a bounded ping first, and one that misses it costs its own rows and * a `CMFH` line, not the whole scan. * * ⚠️ The ping exists because a watchdog around `list-panes` cannot work. A tmux * client hands dups of its stdout to the server, so a stopped server keeps our * stdout pipe open after the client is dead (measured: SIGTERM ended the client at * once and no EOF came in the 2.5 s that were watched, while the server stayed * stopped). Nothing reading that pipe can finish, and the same hold would keep * `docker exec` and `ssh` waiting on it. The ping's stdout is /dev/null, so only a * server that just answered ever gets the real one. * * ⚠️ The script MUST NOT contain a single quote. It is wrapped in single quotes * to cross `ssh '