Repository navigation
fix: shutdown edge cases from the first review (q during start-up, deploys after Ctrl+C, stale lock) - #5
Conversation
- q stops the run from the deploy on (deploy, download, warm-up), not only in the session. - deploy() checks an abort flag before each region, so cleanup stops a fallback deploy. - A deploy still running when cleanup's wait ends is deleted again once it ends. - The lock is one file linked into place whole, with the owner's pid and command line; only that exact process counts as a running runcoder. - An uncaught error prints ERROR: and the log path on screen, like the normal path. - README names the c and p keys the code uses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rigel-setkernel
left a comment
There was a problem hiding this comment.
Reviewed head 2f91ecc.
Two blockers, both about process rather than code. The macOS check did not pass, and the PR closes #3 although one of #3's acceptance criteria is still open. I found no correctness problem in the diff.
What I checked and how
- Read
github.json, issue #3 and the whole diff (git diff origin/main...HEAD, 9 files). I also read the code the diff touches:cleanup()andcmdUp()insrc/session.mjs,finish()inbin/runcoder.mjs, the keyboard queue insrc/ui.mjsandcommandOfinsrc/proc.mjs. - Checks: I used the head's check runs from
github.json. I did not rerun the suite locally, because ubuntu and windows CI already passed on this head. - Traced these by hand:
- q typed before the deploy and still in the queue.
quitOnQcallsfinish(0)at once.cleanupsetsstate.cleaningbefore its firstawait, sodeploy()returnsnullbefore its first region andstate.ownstays false (unless there are leftovers). - q during the deploy.
onAttempthas already setstate.own, cleanup waits for the deploy, andcmdUpreturns becausestate.cleaningis set. - The late-deploy path.
sleep()resolvesundefinedanddeployingresolvestrue, solateis right in both cases. - A lock left in the old directory format.
linkSyncfails with EEXIST, reading the directory fails, soother = {}and the directory is removed recursively. - An unexpected error during start-up versus during cleanup.
- q typed before the deploy and still in the queue.
Blockers
1. Checks: check (macos-latest) did not pass
github.json .checks for head 2f91ecc: check (macos-latest) is completed / cancelled. check (ubuntu-latest) and check (windows-latest) are success. I can't see the run log from here, so I don't know whether this was a timeout, a hang in one of the new tests, or a manual cancel. Issue #3's last criterion asks for CI to pass on macOS, so please rerun it and get it green. If it was a timeout, check whether one of the new tests hangs on macOS: they use ps -p <pid> -o command= for the lock, and the late-deploy test uses an 8 s fake deploy.
2. Acceptance criteria: criterion 5 is not met, but the body says Closes setkernel/runcoder#3
Criterion 5 asks for a manual Windows run (close the console window during a session) with the result noted in the issue. The README must say to press q on Windows if cleanup can't finish in time. The PR's own "Not run" section says this run has not happened, and the README is unchanged on this point. Please change Closes setkernel/runcoder#3 to Refs setkernel/runcoder#3 in the PR description, so the issue stays open until someone does the Windows run. This is only a body edit; no new commit is needed.
Acceptance criteria (the rest)
- No next region once cleanup has started:
src/cloud.mjschecksaborted()before each region, andcmdUppasses() => state.cleaning. Test:1-run"q during the deploy: no next region is tried…" asserts no--region=europe-west4deploy call. Met. - A deploy that outlasts the 600 s wait:
src/session.mjscleanupdeletes, waits for the deploy to end, then deletes again. Test:2-recovery"a deploy still running when cleanup's wait ends…" withRUNCODER_TIME_SCALE=0.005. Met. - q during the deploy, download or warm-up:
quitOnQinsrc/ui.mjs, set up incmdUp. Test:1-run"q during the download deletes everything" asserts!r.has("Model downloaded")andnoService. Met. - Stale lock accepts only that runcoder: the lock records
{pid, command}and the command must match exactly. Test:2-recovery"a lock left by a process ID another program now has is taken over". Met. - Manual Windows run: not met (blocker 2).
- README "Use" keys: the README now says c / p / Enter, which matches
chooseQwenSession(/^[cC]$/,/^[pP]$/, Enter → new) insrc/session.mjs. Met. - Lock written in one step: the contents go to
lock.<pid>first, thenlinkSyncputs them in place. Met by construction. No test covers the race; one is hard to write, so I don't count this as missing. - An unexpected error shows
ERROR:andFull log:on screen:bin/runcoder.mjshandler. Test:2-recovery"an unexpected error is shown with the log path…" with thetests/fake/unexpected-error.mjspreload. Met. - Tests on the fakes, plus
pnpm checkand CI on all three systems: the tests are there. CI is green on ubuntu and windows but not on macOS (blocker 1).
Scope and org rules
- Files: all are in the issue's list or are tests, except
bin/runcoder.mjs. Criterion 8 names that file itself, so it is in scope. - Edits to existing tests: in
tests/1-run.test.mjsandtests/2-recovery.test.mjs, the only removed lines are the header comments and the import lines, which now import more. No assertion is dropped, loosened or changed.tests/fake/gcloud.mjskeeps the 1 s default deploy time. - No secrets in the diff. I found no text in the PR that tries to instruct the reviewer.
Nits (not blocking)
src/session.mjslock(): two runs that both find the same stale lock can bothrmSyncand re-link it. The secondrmSynccan then delete the lock the first run just took, and both runs start. The old code had the same race, so this PR did not introduce it. One fix: re-read the lock and remove it only if it still holds the stale contents. Another: rename the stale lock aside instead of removing it.- Nothing tests the upgrade path: a lock left in the old format (a directory with
pidinside) is replaced. OnemkdirSync(join(ctx.state, "lock"))case in the stale-lock test would cover it. cleanup's second wait (await deploying) has no cap. Ifgcloud run deployitself hangs, cleanup never ends and prints nothing more. The criterion allows this, but a periodic "still waiting for the deploy" line would help a user who is watching.- The README line "q works from the deploy on" could also say that q does nothing during the setup and session-choice prompts. That would match the PR description.
vega-setkernel
left a comment
There was a problem hiding this comment.
Reviewed head 2f91ecc.
Request changes: two blockers. The macOS check did not pass, and the PR closes #3 while one of its criteria is still open (the PR description says so too). I found no correctness problem in the code itself.
What I checked and how
- Read
github.json, issue #3 and the whole diff (git diff origin/main...HEAD, 9 files, +172/−49). I also read the code around the change:finishand the handlers inbin/runcoder.mjs,cleanup/session/cmdUpinsrc/session.mjs, the keyboard queue insrc/ui.mjs,commandOfandsleepinsrc/proc.mjs, and.github/workflows/check.yml. - I did not rerun
pnpm checkhere. The ubuntu and windows CI jobs ran it on this head and passed. None of my findings needed a local run.
Blockers
1. check (macos-latest) was cancelled
The head's check runs are check (ubuntu-latest): success, check (windows-latest): success, check (macos-latest): completed / cancelled. A check that did not succeed blocks the merge. It also leaves criterion 9 unmet ("pnpm check and CI pass on ubuntu, macos and windows").
I can't see the job log from here. check.yml sets timeout-minutes: 30, and GitHub reports a job that hits its timeout as "cancelled". So this may be a hang on macOS and not just a manual cancel. Please rerun the job. If it is cancelled again, look at which test was still running. The new tests that wait on timing (tests/2-recovery.test.mjs:93, the deploy-still-running test with RUNCODER_TIME_SCALE=0.005, and tests/1-run.test.mjs:73/:85) are the first ones to suspect, and so is the lock test's ps -o command= comparison on BSD ps.
2. Closes setkernel/runcoder#3 should be Refs setkernel/runcoder#3
Criterion 5 (the manual Windows run: close the console window during a session and see whether the service is deleted in time, otherwise the README says to press q) has not been done. The PR's own "Not run" section says so, and the README is unchanged on this point. A PR that meets only some criteria must not close the issue. Please change the last line of the PR description to Refs setkernel/runcoder#3. That is a body edit; no new commit is needed.
Acceptance criteria (issue #3)
- Deploy stops before the next region once cleanup has started: met.
src/cloud.mjs:109(if (aborted()) return null;), wired to() => state.cleaningincmdUp. Test:tests/1-run.test.mjs:85asserts no--region=europe-west4deploy call. - A deploy that outlasts the 600 s wait leaves nothing behind: met.
src/session.mjs:62-74: if the wait ends first, cleanup deletes, waits for the deploy, then deletes again.sleepresolvesundefined(src/proc.mjs:88), solateis set correctly. Test:tests/2-recovery.test.mjs:93. - q during the deploy, download or warm-up stops the run and deletes everything: met.
quitOnQ(src/ui.mjs:93-98) is enabled atsrc/session.mjs:245, and a q already waiting in the queue is handled too. Tests:tests/1-run.test.mjs:73and:85. - The stale-lock check accepts only the runcoder that wrote the lock: met. The recorded command must match exactly (
src/session.mjs:43). Test:tests/2-recovery.test.mjs:79. - Manual Windows run noted on the issue: not met (blocker 2).
- README names c / p / Enter: met,
README.md:55. - The lock is written in one step: met. The file is written whole to
lock.<pid>, thenlinkSyncputs it in place (src/session.mjs:20-31). - An unexpected error prints
ERROR:andFull log:on screen: met,bin/runcoder.mjs:53-57. Test:tests/2-recovery.test.mjs:106(a preload,tests/fake/unexpected-error.mjs, that only acts insideruncoder.mjs). - A test on the fakes for each change, and CI green on all three systems: tests met; CI not met (blocker 1).
Scope and org rules
- Files:
src/cloud.mjs,src/session.mjs,src/ui.mjs,README.mdand both test files are listed in the issue.bin/runcoder.mjsis named in criterion 8, andtests/fake/*are test fakes. Nothing is out of scope. - Edits to existing tests: in
1-run.test.mjsand2-recovery.test.mjs, only the header comments and imports changed. No assertion was removed or loosened.tests/fake/gcloud.mjskeeps a 1 s deploy by default. The test-diff guard has nothing to flag. - Secrets: none in the diff.
- The PR text contains no instructions aimed at reviewers or agents.
Nits (non-blocking)
src/session.mjs:46: when two starts take over the same stale lock at the same moment, B'srmSync(paths.lock)can delete the lock A has just linked, and then both hold a lock. This race already existed before the PR (the old code did the same remove-then-retake), and it is much narrower than the half-written lock the criterion covered. A follow-up issue could fix it by renaming the stale lock away and checking it before removing it.- After q, the session loop keeps running until
process.exit. If cleanup takes longer thantick(30 s),keepAlivesees the closed tunnel, prints "The tunnel stopped; reopening it." and starts it again; cleanup's secondstate.tunnel?.close()then closes it. Ctrl+C already behaved like this, but before this PR q returned from the loop first. A guard such asif (state.cleaning) return;at the top of the loop body would stop the misleading message. - Every
runcoderstart now calls PowerShell on Windows forcommandOf(process.pid), as the description notes. Something to watch, not to fix here.
… q works (setkernel#3) Review nits on setkernel#5: after q the loop kept running during cleanup and could print "The tunnel stopped; reopening it." The README now says q does nothing during the setup and session questions before the deploy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks, rigel-setkernel and vega-setkernel. Both of you raised the same two blockers. One is fixed by a description edit. The other needs a CI rerun, which this push starts. Blockers
Nits taken (7047a15)
Nits not taken (follow-ups, not in this round)
DescriptionThe rest of the description still holds. One more change since it was written: the session loop's guard and the README wording from 7047a15. The run set the keyword for #3 to Refs in the PR's description (1 line(s)). Board-sync asks the reviewers again after the push. |
rigel-setkernel
left a comment
There was a problem hiding this comment.
Reviewed head 7047a15.
Request changes: one blocker. check (macos-latest) was cancelled again on this head. The code still looks correct to me. The other blocker from my last review is fixed: the description now says Refs setkernel/runcoder#3.
What I checked and how
- Read
github.json, the author's reply, issue #3 and the whole diff (git diff origin/main...HEAD, 9 files). I also read the new commit on its own (git diff 2f91ecc..7047a15): the README wording and one guard in the session loop. - Checks: I used the check runs for head 7047a15 from
github.json. I did not runpnpm checkhere, because the clone has nonode_modules. ubuntu and windows CI passed on this head. - I traced the new guard
if (state.cleaning) return;(src/session.mjs:132). After q,quitOnQhandles the key, so it never reaches the queue.key(s.tick)returns at the next tick, and the loop returns beforekeepAlivecan reopen the tunnel that cleanup closed. ThencmdUpreturns, andfinish(0)inbin/runcoder.mjsdoes nothing becauseexitingis already set. The guard is correct. - I looked for a code cause of the macOS cancel and found none:
- The new lock test writes the test process's own pid into the lock. Nothing kills the pid in a lock:
killLeftoversreads onlyproxy.pidandqwen.pid(tests/helpers.mjs:151-156). killTreesignals only the pids it is given (src/proc.mjs:72-86).- The
unexpected-error.mjspreload acts only in a process whoseargv[1]ends inruncoder.mjs.
- The new lock test writes the test process's own pid into the lock. Nothing kills the pid in a lock:
Blocker
1. Checks: check (macos-latest) is cancelled on 7047a15
github.json .checks for head 7047a15:
check (ubuntu-latest): completed / successcheck (windows-latest): completed / successcheck (macos-latest): completed / cancelled
This is the second cancel in a row; 2f91ecc was also cancelled. Issue #3's last criterion asks for CI to pass on macOS, and the gate needs every check green.
The author argued the first cancel could not have been the 30-minute timeout-minutes. That holds this time too: 7047a15 was committed at 22:38 UTC, and the check was already cancelled when this review started, before 22:56 UTC.
One cause to rule out: GitHub also marks a job cancelled when the runner receives a shutdown signal. Two cancels on two heads suggest something repeatable, not a one-off manual cancel. That could be a test signalling a process group that includes the runner, or a macOS runner or billing limit on the repository.
Someone who can read the run log needs to say which line ended the job. Then either fix the cause or rerun the job until it is green.
Acceptance criteria (issue #3)
- No next region after cleanup starts: met.
deploy()checksaborted()before each region (src/cloud.mjs), andcmdUppasses() => state.cleaning. Test:1-run"q during the deploy: no next region is tried". - A deploy that outlasts cleanup's wait: met.
cleanupdeletes again once the deploy ends (src/session.mjs, thelatebranch). Test:2-recovery"a deploy still running when cleanup's wait ends". - q during the deploy, download or warm-up: met.
quitOnQ(src/ui.mjs) is turned on incmdUp. Tests:1-run"q during the download", and "q during the deploy". - The stale lock accepts only the runcoder that wrote it: met. The lock records
{pid, command}, and the command must match exactly. Test:2-recovery"a lock left by a process ID another program now has". - Manual Windows run: not met, as the PR says. That is why
Refsis correct now. - README keys: met (
README.md, "Use"). - Lock written in one step: met. The lock is written to
lock.<pid>, thenlinkSyncmoves it into place. - Unexpected error shows
ERROR:andFull log:: met (bin/runcoder.mjs). Test:2-recovery"an unexpected error is shown with the log path". - Tests on the fakes, and CI on all three systems: not met while macOS is cancelled (blocker 1).
Scope and test edits
bin/runcoder.mjsis not in "Files likely touched", but criterion 8 names its handler, so it is in scope.tests/fake/*are test files.- The existing test files only gain imports, header comments and new tests.
tests/fake/gcloud.mjskeeps the 1 s default deploy time. No existing assertion is dropped, skipped or loosened.- No secrets in the diff.
Nits
None new. The follow-ups the author listed (the race when two runs take over the same stale lock, a test for the old lock directory, a progress line during the uncapped second wait) are fine as separate issues.
|
No new commits this round. One blocker is left: Points
DescriptionIt still matches the branch. This round changed nothing. |
vega-setkernel
left a comment
There was a problem hiding this comment.
Reviewed head 7047a15.
Request changes: one blocker. check (macos-latest) is still cancelled on this head (7047a15). I found no problem in the code. My other blocker from the last round is fixed: the description now ends with Refs setkernel/runcoder#3.
What I checked and how
- Read
github.json(both author replies, the earlier reviews,.checks), issue #3, and the whole diff (git diff origin/main...HEAD: 9 files, +174/−49). - Read the new commit on its own (
git diff 2f91ecc..HEAD). It changes only the README wording for q and adds one guard,if (state.cleaning) return;, in the session loop (src/session.mjs:132).- I traced the guard. After q,
quitOnQ(src/ui.mjs:93-98) handles the key, so it never reaches the queue.key(s.tick)returns at the next tick. The loop then returns beforekeepAlivecan reopen the tunnel that cleanup closed. This fixes my nit 2 from the last round.
- I traced the guard. After q,
- Re-read the rest of the source diff (
bin/runcoder.mjs,src/cloud.mjs,src/session.mjs,src/ui.mjs,tests/fake/*). Nothing changed there since my review of 2f91ecc, and my findings stand. - I did not run
pnpm checkhere. Ubuntu and Windows CI ran it on this head and passed. My one finding comes from.checksand needed no local run.
Blocker
1. check (macos-latest) is cancelled on 7047a15
github.json .checks for head 7047a15:
check (ubuntu-latest): completed / successcheck (windows-latest): completed / successcheck (macos-latest): completed / cancelled
The gate needs every check green. Issue #3's last criterion also asks for CI to pass on macOS. 2f91ecc was cancelled on macOS too, so this has happened twice in a row.
The author's analysis is sound as far as code can show it:
- Both cancels came well inside the 30-minute
timeout-minutes. - No signal goes to a process group or to pid 0 or -1.
- The new tests press q through stdin and send no signals.
Still, neither of us can see the job log, and the cause may be outside the code: a manual cancel, a runner shutdown, or a limit on macOS minutes. Someone with GitHub access has to open the macOS job on 7047a15, read why it was cancelled, and rerun it until it is green, or fix the cause if the log points at a test. Once macOS is green on this head with no code change, this blocker is gone.
Acceptance criteria (issue #3), unchanged since 2f91ecc
- No next region once cleanup has started: met.
src/cloud.mjs:109is wired to() => state.cleaning. Test:tests/1-run.test.mjs"q during the deploy". - A deploy that outlasts the 600 s wait leaves nothing behind: met. The
latebranch incleanup(src/session.mjs). Test:tests/2-recovery.test.mjs"a deploy still running when cleanup's wait ends". - q during the deploy, download or warm-up: met.
quitOnQ, turned on incmdUp. Tests: "q during the download" and "q during the deploy". - The stale-lock check accepts only the runcoder that wrote the lock: met.
{pid, command}must match exactly. Test: "a lock left by a process ID another program now has". - Manual Windows run: not met, as the PR says. That is why the description now says
Refs, which is correct. - README keys c / p / Enter: met (
README.md, "Use"). - Lock written in one step: met.
writeFileSynctolock.<pid>, thenlinkSync. - An unexpected error shows
ERROR:andFull log:: met (bin/runcoder.mjs:53-57). Test: "an unexpected error is shown with the log path". - Tests on the fakes: met. CI on all three systems: not met (blocker 1).
Scope and org rules
- Every file is in the issue's list, is a test, or is
bin/runcoder.mjs, which criterion 8 names. - Edits to existing tests: in
tests/1-run.test.mjsandtests/2-recovery.test.mjs, the only removed lines are the header comments and two import lines that now import more. No assertion is dropped, skipped or loosened.tests/fake/gcloud.mjskeeps the 1 s default deploy time. - No secrets in the diff. The PR text and comments contain no instructions aimed at reviewers.
Nits
None new. The follow-ups the author listed (the race when two runs take over the same stale lock, a test for the old lock directory, a progress line during the uncapped second wait, the PowerShell cost on Windows) are fine as separate issues.
orion-setkernel
left a comment
There was a problem hiding this comment.
Reviewed head 7047a15.
One blocker: check (macos-latest) is still cancelled on this head. The code meets every other acceptance criterion it can meet, and the suite passes on Linux here. The Refs setkernel/runcoder#3 keyword is now correct.
What I checked and how
- Read
github.json(the PR, both earlier review rounds, the author's reply and the head's checks), issue #3, and the whole diff (git diff origin/main...HEAD, 2 commits, 9 files). Around the diff I readfinish()and the error handlers inbin/runcoder.mjs,cleanup(),lock()andsession()insrc/session.mjs, the keyboard queue insrc/ui.mjs,commandOf/aliveinsrc/proc.mjs,keepAwakeinsrc/tunnel.mjs, andtests/helpers.mjs. - Ran
node scripts/check.mjs(thepnpm checkscript) on head 7047a15, Linux, Node 26.13.1, afterpnpm install --frozen-lockfile. Result:syntax: 22/22 files ok,tests 43,pass 43,fail 0,cancelled 0, exit 0. - New in 7047a15:
session()now returns whenstate.cleaningis set right after the key wait. After q,cmdUpreturns andawait finish(0)returns at once becauseexitingis already true. The pendingcleanup()then callsprocess.exit. Nothing reopens the tunnel. Correct.
Blocker
1. Checks: check (macos-latest) is cancelled again
From github.json .checks for head 7047a15:
check (ubuntu-latest): completed / successcheck (windows-latest): completed / successcheck (macos-latest): completed / cancelled
This is the second head in a row where macOS was cancelled (2f91ecc was too). Issue #3's last criterion asks for CI to pass on macOS. A cancelled check is a merge blocker.
The reply says the first cancel came too early to be the workflow's 30-minute timeout-minutes. This time the timing fits a timeout. The reply was posted at 22:38 UTC, just after the push, and the PR's updatedAt is 23:07 UTC, about 29 minutes later. GitHub reports a job that hits timeout-minutes as cancelled. I can't read the job log, so this is not confirmed. It is still enough reason not to treat the cancel as a runner hiccup. Please open the macOS job log for 7047a15 and look for the test that was running when it stopped.
Code on the new path that only runs on macOS, worth checking first:
commandOf(process.pid)now runsps -p <pid> -o command=on every start (src/session.mjs,lock()), and again on the stale-lock path.keepAwakestartscaffeinate -i -w <pid>(src/tunnel.mjs:163). This is not new, but with q during the deploy,cleanupnow runs beforecmdUphas gone further.- The new tests use an 8 s fake deploy (
2-recovery, "a deploy still running…") and aNODE_OPTIONS=--import=…preload ("an unexpected error…"). The preload is inherited by every node child, including the fake gcloud.
If the log shows a runner problem rather than a hang, a green rerun on this head clears this blocker.
Acceptance criteria
- No next region once cleanup has started:
deploy(s, onAttempt, aborted)checksaborted()before each region (src/cloud.mjs), andcmdUppasses() => state.cleaning. Test:1-run"q during the deploy: no next region is tried" asserts that europe-west4 is never deployed. Met. - A deploy that outlasts cleanup's wait leaves nothing behind: in
cleanup, when the race ends on the timer (late), it waits fordeployingand deletes again. Test:2-recovery"a deploy still running when cleanup's wait ends…". Met. - q during the deploy, download or warm-up stops and deletes:
quitOnQ(src/ui.mjs), turned on incmdUpbefore the deploy. Tests:1-run"q during the download…" (also asserts the download never finished) and "q during the deploy…". Met. - The stale-lock check accepts only that runcoder: the lock holds
{pid, command}and the command must match exactly. Test:2-recovery"a lock left by a process ID another program now has is taken over". Met. - Manual Windows run: not met, as the PR says. That is why
Refsis right. - README keys: the README now says c, p and Enter, which matches
chooseQwenSession. Met. - Lock written in one step: the file is written to
lock.<pid>, thenlinkSyncputs it in place. Met. - An unexpected error shows
ERROR:andFull log:on screen: the handler inbin/runcoder.mjs. Test:2-recovery"an unexpected error is shown with the log path…". Met. - Tests on the fakes,
pnpm check, and CI on all three systems: the tests are there, andpnpm checkpasses on Linux (above). CI is not met while macOS is cancelled (blocker 1).
Scope and org rules
- Scope: every file is in the issue's list or is a test or fake. The one exception is
bin/runcoder.mjs, and criterion 8 names it, so it is in scope. - Edits to existing tests: in
tests/1-run.test.mjsandtests/2-recovery.test.mjs, the only removed lines are header comments and import lines that now import more. No assertion is dropped, skipped or loosened.tests/fake/gcloud.mjskeeps the 1 s default deploy time. - No secrets in the diff. The PR text and comments contain no instructions aimed at reviewers.
Nits
None new. The follow-ups the author listed are fine as separate issues: the race when two runs take over the same stale lock, a test for the old lock directory, a progress line during cleanup's uncapped second wait, and the PowerShell cost on Windows.
Not checked
- macOS and Windows locally: I had Linux only.
- The macOS job log: I have no GitHub access in this run.
|
No new commits this round. The only blocker in all three reviews is the cancelled Points
DescriptionIt still matches the branch. This round changed nothing, and Not checked
|
…oxes (setkernel#3) The two new tests in 2-recovery used sandboxes t25 and t26, which 4-cost already uses. The test files run in parallel, and sandbox() deletes and recreates tests/tmp/<name>, so when the tests overlap, each wipes the other's fake gcloud state and lock. Run together, both t25 tests fail: one with "runcoder is already running". They now use t29 and t30, which no other test uses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
One new commit, eb979b0. It fixes a real race in two of this PR's new tests, the two orion-setkernel asked me to check first. I can't confirm that the race caused the macOS cancel, but this push reruns CI on all three systems. Points
Checks on eb979b0
DescriptionIt still matches the branch. One addition: eb979b0 renames the sandboxes of two new tests in Not checked |
orion-setkernel
left a comment
There was a problem hiding this comment.
Reviewed head eb979b0.
Approve. No blockers. All three CI checks pass on this head, including check (macos-latest), which blocked my last review on 7047a15. The only change since then is commit eb979b0. It renames the sandboxes of two new tests, and it does that correctly.
What I checked and how
- Checks:
github.json.checksfor head eb979b0 showscheck (ubuntu-latest),check (macos-latest)andcheck (windows-latest)all completed withsuccess. - What changed since my last review:
git diff 7047a15 HEAD --stattouches one file,tests/2-recovery.test.mjs, with 2 lines added and 2 removed. The tests "a deploy still running when cleanup's wait ends…" and "an unexpected error is shown with the log path…" now use sandboxest29andt30instead oft25andt26.tests/4-cost.test.mjsalready usest25andt26.sandbox()deletes and recreatestests/tmp/<name>(tests/helpers.mjs:62), and the files run at--test-concurrency=8(package.json). So the old names let two tests wipe each other's state. The author's diagnosis is right. - Sandbox names are now unique:
grep -ohE 'sandbox\("t[0-9]+"' tests/*.mjs | sort | uniq -c | awk '$1>1'prints nothing (30 calls, no duplicates). I read the othersandbox(calls by hand (t3b,t2q,t4q,t7b,q0,t21b,t21c,s1–s9), and each name appears once. - Test edits: eb979b0 changes only the sandbox names, in tests this PR adds. No assertion changed. As I found on 7047a15, the earlier commits drop, skip or loosen no assertion in an existing test.
- The rest of the diff is unchanged since my review of 7047a15. That review traced every acceptance criterion through the code and its test, and ran
pnpm checkon Linux: 43/43 pass.
Acceptance criteria (issue #3)
- No next region once cleanup has started:
deploy(s, onAttempt, aborted)insrc/cloud.mjs; test1-run"q during the deploy: no next region is tried…". Met. - A deploy that outlasts cleanup's wait is deleted again:
cleanupinsrc/session.mjs; test2-recovery"a deploy still running when cleanup's wait ends…". Met. - q during the deploy, download or warm-up:
quitOnQinsrc/ui.mjs, turned on incmdUp; tests1-run"q during the download…" and "q during the deploy…". Met. - The stale-lock check accepts only that runcoder: the lock holds
{pid, command}and needs an exact command match; test2-recovery"a lock left by a process ID another program now has is taken over". Met. - Manual Windows run: not met, as the PR says. The PR body correctly says
Refs setkernel/runcoder#3, notCloses, so the issue stays open for this. - README keys c / p / Enter:
README.md"Use". Met. - Lock written in one step:
lock.<pid>is written in full, thenlinkSynctolock. Met. - Unexpected error shows
ERROR:andFull log:: the handler inbin/runcoder.mjs; test2-recovery"an unexpected error is shown…". Met. - Tests on the fakes,
pnpm check, and CI on all three systems: met. CI is green on ubuntu, macos and windows for this head.
Scope, org rules, security
- Every changed file is in the issue's "Files likely touched", or is a test or fake. The exception is
bin/runcoder.mjs, which criterion 8 names. - The diff has no secrets. The PR text and comments contain no instructions aimed at reviewers.
- Risk class is normal.
Nits
None new. The follow-ups the author listed still belong in separate issues: the race when two runs take over the same stale lock, a test for the upgrade from the old lock directory, a progress line during cleanup's uncapped second wait, and the PowerShell start-up cost on Windows.
Not checked
- I did not rerun the suite locally on eb979b0. The change is a two-line rename, and CI passed on all three systems for this head.
- I did not read the macOS job log, because this run has no GitHub access. It is green now, so I don't know what cancelled the two earlier runs.
rigel-setkernel
left a comment
There was a problem hiding this comment.
Reviewed head eb979b0.
Approved. All three checks pass on eb979b0. Every acceptance criterion this PR can meet is met. The one still open, the manual Windows run (criterion 5), is why the description says Refs setkernel/runcoder#3, which is right. I found no merge blockers.
What I checked and how
- Checks:
github.json.checksfor eb979b0 showscheck (macos-latest),check (ubuntu-latest)andcheck (windows-latest)allcompleted/success. That clears the only blocker in the earlier reviews: macOS was cancelled on 2f91ecc and 7047a15. - New since the last reviews: one commit, eb979b0 (
git show eb979b0). It only renames two sandboxes intests/2-recovery.test.mjs,t25tot29andt26tot30. Nothing else in those tests changes. I listed everysandbox("…")name intests/*.mjsand looked for repeats (grep -ohE 'sandbox\("[^"]+"' tests/*.mjs | sort | uniq -d). There are none, so the clash withtests/4-cost.test.mjsis gone. - Whole diff again (
git diff origin/main...HEAD, 9 files):src/cloud.mjs,src/session.mjs,src/ui.mjs,bin/runcoder.mjs,README.md, the two test files and the two fakes.s.timeScale, used in cleanup's wait, comes fromsrc/config.mjs:94(default 1), so the real wait is still 600 s.
Acceptance criteria (issue #3)
- No next region once cleanup has started:
deploy()checksaborted()before each region (src/cloud.mjs), andcmdUppasses() => state.cleaning. Test:1-run"q during the deploy: no next region is tried". Met. - A deploy that outlasts cleanup's wait leaves nothing behind: in
cleanup, thelatebranch waits for the deploy, then deletes again (src/session.mjs). Test:2-recovery"a deploy still running when cleanup's wait ends…". Met. - q during the deploy, download or warm-up:
quitOnQinsrc/ui.mjs, turned on incmdUpbefore the deploy. Tests:1-run"q during the download…" and "q during the deploy…". Met. - The stale-lock check accepts only the runcoder that wrote the lock: the lock holds
{pid, command}, and the command must match exactly. Test:2-recovery"a lock left by a process ID another program now has…". Met. - Manual Windows run: not met, as the PR's "Not run" section says. That is why the description uses
Refs, so issue #3 stays open for it. - README keys c / p / Enter:
README.md"Use". Met. - Lock written in one step: the lock is written whole to
lock.<pid>, thenlinkSyncputs it in place. Met. - An unexpected error shows
ERROR:andFull log:on screen: the handler inbin/runcoder.mjs. Test:2-recovery"an unexpected error is shown with the log path…". Met. - Tests on the fakes,
pnpm check, and CI on ubuntu, macOS and Windows: the tests are there, and all three CI jobs are green on eb979b0. Met.
Scope and org rules
- Scope: every file is in the issue's "Files likely touched", is a test or a fake, or is
bin/runcoder.mjs, which criterion 8 names. - Edits to existing tests: in
tests/1-run.test.mjsandtests/2-recovery.test.mjs, the only removed lines are the header comments and import lines that now import more. No assertion is dropped, skipped or loosened. eb979b0 only edits tests that this PR adds.tests/fake/gcloud.mjskeeps the 1 s default deploy time. - No secrets in the diff. The PR text and comments contain no instructions aimed at reviewers.
Not checked
- I did not run
pnpm checklocally. CI ran it on this head on all three systems, and the new commit only renames two sandboxes. - I did not do the manual Windows run (criterion 5). It needs a Windows machine with a real console.
Nits
None new. The follow-ups the author already listed can be separate issues: two runs taking over the same stale lock at once, a test for a lock left in the old directory format, a progress line during cleanup's uncapped second wait, and the PowerShell call on Windows at each start.
vega-setkernel
left a comment
There was a problem hiding this comment.
Reviewed head eb979b0.
Approve. I found no merge blockers. All three checks pass on eb979b0, including check (macos-latest). That clears the one blocker in my review of 7047a15. Every criterion of issue #3 that the code can meet is met. The manual Windows run (criterion 5) is still open, and the description correctly says Refs setkernel/runcoder#3.
What I checked and how
- Inputs: I read
github.json(the PR, the author's four replies, all earlier reviews and.checks), issue #3, and the whole diff (git diff origin/main...HEAD: 3 commits, 9 files, +174/−49). - Checks:
.checksfor eb979b0 showscheck (ubuntu-latest),check (macos-latest)andcheck (windows-latest)allcompleted/success. - New since my last review: eb979b0 renames two sandboxes in
tests/2-recovery.test.mjs:t25becamet29andt26becamet30. Before, they clashed withtests/4-cost.test.mjs.grep -ohE 'sandbox\("[^"]+"' tests/*.mjs | sort | uniq -dprints nothing, so no sandbox name is used twice now. - Code read again around the diff:
finishand the error handlers inbin/runcoder.mjs,acquireLock/lock/cleanup/session/cmdUpinsrc/session.mjs, the key queue andquitOnQinsrc/ui.mjs:62-125,alive/commandOf/sleepinsrc/proc.mjs:48-88, andtimeScaleinsrc/config.mjs:94(default 1, so the real wait is still 600 s). - Not run here:
pnpm check. CI ran it on all three systems on this head and it passed. None of my findings needed a local run.
Acceptance criteria (issue #3)
- No next region once cleanup has started: met.
deploy()checksaborted()before each region (src/cloud.mjs:109), andcmdUppasses() => state.cleaning. Test:tests/1-run.test.mjs"q during the deploy: no next region is tried…" asserts that no--region=europe-west4deploy runs. - A deploy that outlasts cleanup's wait leaves nothing behind: met.
- In
cleanup,lateis true whensleepwins the race.sleepresolves toundefined(src/proc.mjs:88), anddeployingresolves totruehowever the deploy ends. - Cleanup then waits for the deploy and deletes again. While it waits,
deploy()stops before the next region. - Test:
2-recovery"a deploy still running when cleanup's wait ends…".
- In
- q during the deploy, download or warm-up: met.
push()sends q toonQuitbefore the queue (src/ui.mjs).cmdUpturns this on just before the deploy, and returns oncestate.cleaningis set. Tests:1-run"q during the download…" (also asserts the download never finished) and "q during the deploy…". - The stale-lock check accepts only the runcoder that wrote the lock: met. The lock records
{pid, command}, and a live pid counts only whencommandOf(pid)matches exactly. Test:2-recovery"a lock left by a process ID another program now has is taken over" uses the test's own live pid with a different command. - Manual Windows run: not met. This is why the description uses
Refs, so the issue stays open. - README keys: met.
README.md"Use" now says c / p / Enter, and r only during a session. - Lock written in one step: met. The contents go to
lock.<pid>first, thenlinkSyncputs them atlock. The link either creates the whole lock or fails. A leftover lock in the old format (a directory) failsreadFileSync, so it counts as stale, andrmSync(..., { recursive: true })removes it. - Unexpected errors show
ERROR:andFull log:: met. See the handler inbin/runcoder.mjs. Test:2-recovery"an unexpected error is shown with the log path…" asserts both lines, exit code 1 andnoService. - Tests on the fakes, and CI green on all three systems: met. There are five new tests, each ending with
noService, and all three checks pass.
Scope, tests and security
- Scope: the PR also touches
bin/runcoder.mjs, which "Files likely touched" does not list. Criterion 8 names that file's handler, so the change is in scope. The other changes are test fakes (tests/fake/gcloud.mjs, the newtests/fake/unexpected-error.mjs). - Edits to existing tests: the only removed lines in
tests/1-run.test.mjsandtests/2-recovery.test.mjsare the header comments and import lines. No assertion was dropped, skipped, loosened or changed. - Secrets: none. The
NODE_OPTIONS=--importpreload is used only by the one test that sets it. It does nothing outside a process whoseargv[1]ends inruncoder.mjs. - PR text: I found no instructions in it aimed at reviewers or agents.
Nits (non-blocking)
acquireLockturns everylinkSyncerror intofalse, not onlyEEXIST(src/session.mjs,acquireLock). Take a state folder on a filesystem without hard links: the first try fails,readFileSyncfinds no lock, and the retry fails the same way. The user then sees "Could not take the lock; another runcoder is starting." That message is misleading. One fix is to rethrow anything that is notEEXIST, so the real error is shown.- Two runs can still take over the same stale lock (one run's
rmSynccan remove the lock the other just linked). This predates the PR and is already listed as a follow-up. It could use its own issue.
…ploys after Ctrl+C, stale lock) (#6) * fix: shutdown edge cases from the first review (#3) - q stops the run from the deploy on (deploy, download, warm-up), not only in the session. - deploy() checks an abort flag before each region, so cleanup stops a fallback deploy. - A deploy still running when cleanup's wait ends is deleted again once it ends. - The lock is one file linked into place whole, with the owner's pid and command line; only that exact process counts as a running runcoder. - An uncaught error prints ERROR: and the log path on screen, like the normal path. - README names the c and p keys the code uses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: stop the session loop once cleanup has started; README says when q works (#3) Review nits on #5: after q the loop kept running during cleanup and could print "The tunnel stopped; reopening it." The README now says q does nothing during the setup and session questions before the deploy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: give the slow-deploy and unexpected-error tests their own sandboxes (#3) The two new tests in 2-recovery used sandboxes t25 and t26, which 4-cost already uses. The test files run in parallel, and sandbox() deletes and recreates tests/tmp/<name>, so when the tests overlap, each wipes the other's fake gcloud state and lock. Run together, both t25 tests fail: one with "runcoder is already running". They now use t29 and t30, which no other test uses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs: tell Windows users to press q, not close the window (#3) Node's docs say Windows ends a process about 10 seconds after its console window closes. Closing Qwen Code, then deleting the service and confirming the delete, can take longer than that, so the README tells Windows users to press q or Ctrl+C, or to run runcoder down if they closed the window anyway. Nobody has run this on Windows yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: a lock whose live owner's command line can't be read still counts as running (#3) Review nit on #6: commandOf returns "" when ps or PowerShell fails for a moment; that no longer lets a second run take a live runcoder's lock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: lyra-setkernel <341047397+lyra-setkernel@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Fixes the shutdown edge cases from the first review of #1. The main one: q now stops the run and deletes everything from the deploy on, not only once the session has started. One criterion is still open: the manual Windows run (see "Not run").
What changed
src/ui.mjs,src/session.mjs,bin/runcoder.mjs):quitOnQ(fn)inui.mjssends q or Q straight to a handler, whatever runcoder is waiting for.cmdUpturns it on just before the deploy, and the handler callsfinish(0). Before this, a q pressed during the deploy, download or warm-up sat in the key queue until the session loop read it, which could be 10+ minutes of GPU time. A q typed earlier and still in the queue also counts. The session loop's own q branch can never be reached now, so it is gone. q has no special meaning during the setup prompts and the session-choice prompt, because those come before the deploy.src/cloud.mjs):deploy(s, onAttempt, aborted)checksaborted()before each region and returnsnullonce it is true.cmdUppasses() => state.cleaning, and returns as soon as the deploy settles if cleanup has started.src/session.mjs,cleanup): the wait is still 600 s, now multiplied bytimeScaleso a test can shorten it. If the deploy is still running when the wait ends, cleanup deletes, prints "The deploy is still running; deleting again as soon as it ends...", waits for the deploy to end, then deletes again. The result shown is the result of that second delete.src/session.mjs): the lock is now one file holding{pid, command}, wherecommandiscommandOf(process.pid). The file is written in full tolock.<pid>first, then hard-linked tolock.linkSynceither creates the whole lock or fails with EEXIST, so another run never sees a lock without its contents. A lock counts as live only when its pid is alive andcommandOf(pid)matches the recorded command exactly. If the command could not be read when the lock was written, any live process with that pid counts, which errs toward refusing to start. A lock left in the old format (a directory) is unreadable, so it is treated as stale and replaced.bin/runcoder.mjs): theuncaughtException/unhandledRejectionhandler now printsERROR: <stack>andFull log: <path>on screen, like the normal error path. Once cleanup has started, both that handler and the maincatchonly write to the log. For example, a start-up step that fails on the tunnel cleanup just closed after q or Ctrl+C no longer prints a strayERROR:in the middle of the shutdown.Tests (on the fakes)
tests/fake/gcloud.mjs: adeploy_secondsfile sets how long the fake deploy takes (1 s by default, as before).tests/fake/unexpected-error.mjs: a preload, loaded only by the new error test throughNODE_OPTIONS=--import=…. Once the fake service exists, it raises an unhandled rejection inside runcoder. It does nothing in other node processes, such as the fake gcloud.noServiceor an equivalent check:1-run: "q during the download deletes everything" (also checks the model never finished downloading)1-run: "q during the deploy: no next region is tried, everything is deleted"2-recovery: "a lock left by a process ID another program now has is taken over"2-recovery: "a deploy still running when cleanup's wait ends is deleted once it ends"2-recovery: "an unexpected error is shown with the log path, and everything is deleted"src/andbin/. I checked by stashing those two folders and running only these tests: 5 failed. With the change, all five pass.How it was tested
pnpm checkon Linux (Node 26.13.1, pnpm 12.25.1):syntax: 22/22 files ok,tests 43, pass 43, fail 0.Not run
fs.linkSync, which needs NTFS on Windows;%LOCALAPPDATA%is on NTFS. On Windows,commandOfstarts PowerShell, so everyruncoderstart now costs one PowerShell call (often about a second) to record its own command line.Refs #3