Skip to content

desk-hub deploy: an interrupted run removes its lock, the prompt stays interruptible, the staging stop line names its cause, production-run.sh's default path - #308

Merged
SSFSKIM merged 5 commits into
masterfrom
p5-o13-run-lock-signals
Oct 28, 2026

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Oct 28, 2026

Copy link
Copy Markdown
Owner

desk-hub deploy: an interrupted run removes its own lock; the prompt stays interruptible; the staging stop line names its cause; production-run.sh's default checkout path.

These are follow-ups to P5 O13 M7. All four were found during the owner's staging sitting and production rollout.

1. A run ended by a signal removes its own lock (deploy/run-lock.ts)

Before: an admin pair interrupted during its 600 s pending wait, by Ctrl-C or a closed terminal, died through Node's default signal action. That skips finally, so keys.json.org.json.lock stayed behind and the owner had to remove it by hand.

Now: while any lock is held, withRunLock installs one set of SIGINT, SIGHUP and SIGTERM handlers. They remove every lock this process holds, matched by token, and exit with 128 plus the signal number. The handlers come off when the last lock is released. A stale lock is still never taken over.

The refusal message: when the holder is on this host and its pid is gone, the refusal says so: pid N on H is gone: remove the file once you've checked no run is going. Removal stays manual.

The blocking prompt. The concern was a confirmation that read /dev/tty with a blocking readSync. A python pty experiment confirmed it:

  • Once JS handlers are installed, libuv restarts the blocked read. A signal at the y/N prompt was held until a byte arrived, so Ctrl-C did nothing until Enter.
  • Before the handlers, the default action killed the process, and the lock leaked.
  • A hangup returned EOF and was fine.
  • Async fs.read was rejected: with a threadpool read pending, process.exit hangs.

The fix, in the new deploy/terminal.ts, which admin.ts now imports:

  • A terminal is read through its own non-blocking descriptor on /dev/tty, polled every 50 ms. This covers the deployment's /dev/tty and a TTY on the local hub's stdin.
  • End of input waits one poll, so a hangup is handled as a signal and not as an empty answer.
  • SIGINT, ^C, SIGHUP, SIGTERM and a hangup now exit at once (130, 130, 129, 143, 129) with the lock removed.
  • A pipe or file on stdin keeps the original blocking byte-by-byte read of fd 0. It reads through one line only, leaves the rest on the descriptor for the next reader, and changes no flags on the shared open-file description.
  • Accepted limit: a signal during a piped local prompt whose pipe is empty is handled only once input arrives. This affects only the loopback local hub.

2. The staging run's stop line names its cause (test/endpoint/staging/run.ts)

Before: the first owner run, own1, stopped on a bare the run stopped: fetch failed.

Now: stopLine follows the cause chain up to four levels, showing each level's code and message, then …. URLs and query strings are stripped at every level, and no headers or bodies are printed.

3. production-run.sh's default checkout path (deploy/production-run.sh:75)

This was found in the owner's production rollout. The owner is working around it by passing the path explicitly.

  • The bug: P=${${1:-$HOME/.local/share/maws-desk-deploy}:A}. Under zsh 5.9, when the default word is used, the nested :A keeps zsh's internal Dash token (0x9b) in place of each -. git worktree add then fails with "Illegal byte sequence".
  • The fix: two steps, P=${1:-…}; P=${P:A}.
  • Tests: one evaluates the extracted expansion under /bin/zsh and checks the bytes, and one guards the scripts against the nested shape. Neither runs production-run.sh. This was the only nested default with a modifier in apps/desk-hub/deploy/*.sh and test/endpoint/staging.

Validation Evidence

  • Local tests:
    • apps/desk-hub/test/deploy/run-lock.test.ts: 25/25, three runs in a row. It covers spawned children holding the lock and signalled, the pty prompt cases on a deployment terminal and a local TTY, a piped prompt leaving the next reader's bytes on fd 0, O_NONBLOCK still clear on the inherited pipe, and the empty-pipe limit.
    • desk-hub test/deploy/ without production-scripts: 215/215.
    • test/endpoint/staging/pieces.test.ts: 19/19.
    • pnpm typecheck and eslint on the touched files are clean.
  • ci-gate on 2836a6d: --gates static,unit,probes --class1a pool --label o13-runlock-3, GREEN, run 40739163857. On Linux, run-lock.test.ts ran 25 tests and production-scripts.test.ts ran 52.
  • Earlier gate runs:
    • 4ff671d, run 40731943899: green.
    • 04ef404, run 40737336170: red on src/mawsd/cli-prompt.test.ts:131, outside this branch. That is a race in that test: hiddenPrompt writes the question before setRawMode(true), and the test reads stty -a as soon as the question appears. It passed on the next run.
  • Review: doperpowers:reviewer-medium, 3 rounds.
    • Round 1, one P2: the local hub's stdin prompt still held signals. Fixed.
    • Round 2, two P2s, both on the piped path: input past the line was lost to the next reader, and O_NONBLOCK was set on the shared pipe. Fixed by restoring the blocking fd-0 read for pipes.
    • Round 3: correct.

Residue

  • src/mawsd/cli-prompt.test.ts:131 races its own prompt. It reads stty -a before setRawMode(true) has run. The fix is to set raw mode before writing the question, or to have the test wait for -echo.

Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)

…min prompt reads /dev/tty without blocking the loop; the lock refusal says when its holder is gone; the staging run's stop line names the cause

withRunLock installs SIGINT, SIGHUP and SIGTERM handlers while any lock is held: each lock still this process's (by its token) is removed and the process exits 128+n; the handlers go once no lock is held. Node's default action had skipped the finally, so an admin pair interrupted in its pending wait left keys.json.org.json.lock behind.

With a handler installed, a signal at a blocking readSync of /dev/tty was held until a byte came (libuv's SA_RESTART), so Ctrl-C at the approve prompt did nothing until Enter. The terminal (now deploy/terminal.ts) reads /dev/tty through its own non-blocking descriptor, polled every 50 ms.

A refused lock whose holder is on this host and whose pid no longer exists says so; removal stays manual. The staging phone run's stop line follows the error's cause chain (code and message, four levels), cutting every URL and query string.

Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
…p, so its dashes stay dashes

Under zsh 5.9, ${${1:-$HOME/.local/share/maws-desk-deploy}:A} leaves zsh's internal Dash token (0x9b) for every '-' of the default word, so checkout with no path named .../maws\x9bdesk\x9bdeploy and git worktree add refused it (Illegal byte sequence). Found in the production rollout, where the owner works around it by passing the path explicitly. The only such shape in the repository; a test evaluates the step's own assignment under zsh byte for byte, and another reads every deploy script for a nested default given a modifier.

Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
openTerminal(false) still passed stdin to a blocking readSync, so with the run lock's handlers installed a Ctrl-C or SIGTERM at a local admin prompt waited for input and the lock stayed (review round 1, P2). A terminal on stdin is now read as /dev/tty through its own non-blocking descriptor, as a deployment's is; a pipe or a file through Node's stream, what follows a line unshifted for the next reader. The end of input waits one poll before it returns, so a hung-up terminal's SIGHUP is handled before an empty answer is acted on.

Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
…again

Review round 2 (two P2s): reading a pipe through process.stdin set O_NONBLOCK on the open file description a parent or sibling shares, and the unshifted rest of a chunk stayed inside this process, out of the next reader's reach. A pipe or file on the local hub's stdin goes back to the blocking byte-by-byte readSync of fd 0; terminals keep /dev/tty through a non-blocking descriptor of their own. The accepted limit, in terminal.ts: a signal while a piped prompt waits on an empty pipe is handled at the run's next turn of the loop once input comes.

Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T17:56:47.425871Z 2836a6d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

…, docs)

Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
@SSFSKIM
SSFSKIM merged commit 4374ae8 into master Oct 28, 2026
SSFSKIM added a commit that referenced this pull request Oct 28, 2026
…s cancel flake fixed (O8)

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
SSFSKIM added a commit that referenced this pull request Oct 28, 2026
Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
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.

1 participant