Repository navigation
Conversation
…econd interrupt still lets the terminal status land #1663 Signed-off-by: Nik Cubrilovic <[email protected]>
Contributor
Author
|
Landed on main as 381dbb1 (later commits there carry the review fixes). Closing this draft as superseded. nik |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1663.
The CLI audit (
createRunFinalizerinrun-tracker.ts) and the MCP server (RunLifecycle,closeRun, alifecyclesmap inmcp/billed-audit.ts) each drove a tracked run from register to terminal PATCH themselves and each reimplemented at-most-once terminal. There is one now.What
createRunLifecycle(registered, options)inlib/run-tracker.ts, returning{ registered, markRunning, close, isClosed }:closesends the terminal state at most once, whichever exit path calls it first; every later call (and a concurrent one) waits for that one PATCH. It waits for the register and for the in-flightmarkRunning, and stops the progress heartbeat first (the CLI's overlay-style: namespaced type selectors keep a cover rule silent (star-pipe iframe, pipe iframe, attribute namespace) #1583 behaviour; the MCP server passesstopHeartbeat: false, it has none).markRunningis sent once and is a no-op afterclosehas been called, including when the close arrived while the register was still in flight: the API applies whichever status lands last, so a laterunningwould flip a finished run back and have it reaped as stalled.createRunFinalizerstays (existing callers and tests) as thecloseof a lifecycle.lifecycle.closeasfinalizeTracked; the MCP server builds one per billed run. The server keeps its shutdown snapshot and map, but no terminal-state logic of its own.process.once, so the first signal removed the handler and a second Ctrl-C during the "cancelled" PATCH took the runtime default and killed the process under it.createInterruptHandlerstays installed (process.on): the first signal finalizes then re-raises, a later one waits for the PATCH already in flight, never starts a second, for at mostSECOND_INTERRUPT_WAIT_MS(3 s) and then exits. The first-signal messages and the crawl bookkeeping run once.Acceptance criteria
createRunLifecycle, pinned by a source test on both filesrun-lifecycle-1663.test.ts(sequential, concurrent, register still in flight, no run)createInterruptHandlertests (waits for the PATCH, one finalize; a PATCH that never lands is cut by the cap)Checks
New file 17 tests;
run-tracker(65 with the MCP billed-audit tests),audit-website-billing,server,audit-website-max-duration-1271pass. tsgo, root lint, cli format:check. Temp HOME. CHANGELOG bullet.Agent skill and docs