Repository navigation
fix(orchestration): keep a stopping worker from wedging dispatch, and certify legacy exits from the owner #19347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
4c60af3
fix(orchestration): keep a stopping worker from wedging dispatch and …
Jinwoo-H 8f26f90
fix(orchestration): certify a legacy worker exit from the owner, not …
Jinwoo-H 4caaa6c
test(orchestration): cover the settlement and recovery edges mutation…
Jinwoo-H cb0657a
docs(orchestration): correct why worker-stop coalesces concurrent cal…
Jinwoo-H 6dea9aa
fix(ssh): let the relay certify that one of its own PTYs exited
Jinwoo-H 1e89522
fix(orchestration): only re-issue a stop stranded by another runtime
Jinwoo-H 1dcae18
fix(relay): let the owner say why a PTY record disappeared
Jinwoo-H f0f8858
revert(ssh): take the SSH liveness readback out of this PR
Jinwoo-H 0be1813
docs(orchestration): correct the dedupe reason and the state-space floor
Jinwoo-H 30f3949
Revert "revert(ssh): take the SSH liveness readback out of this PR"
Jinwoo-H 03af416
test(relay): pin what the owner probe may never certify
Jinwoo-H 847912e
fix(relay): bind PTY exit evidence to the incarnation that earned it
Jinwoo-H 46a693a
test(relay): pin the live-record ownership fallback across owner-map …
Jinwoo-H File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| # PR #19347 round 2 — SSH exit certification moved to its owner | ||
|
|
||
| ## The defect | ||
|
|
||
| `probeSshPtyLiveness` inferred "absent from `pty.listProcesses` and minted by this relay's | ||
| generation, therefore exited". The implication is false. The relay has removal paths that never | ||
| observe the process end: `disposePtyForRelayShutdown` waits `IMMEDIATE_PTY_EXIT_TIMEOUT_MS` for a | ||
| physical exit, catches the timeout, and deletes the record anyway; `disposePtys` settles with | ||
| `Promise.allSettled`, so another PTY's failed kill rejects the aggregate while that record is | ||
| already gone; `relay-grace-lifecycle` then defers shutdown and the relay keeps serving under the | ||
| same mint epoch. A newly connected provider asked, was told `false`, and recovery queued a live | ||
| worker as exited. | ||
|
|
||
| Reproduced at `1e89522a9d` with the reviewer's test: 2 failed / 2 passed. | ||
|
|
||
| ## Census of record removals in `PtyHandler` | ||
|
|
||
| Every removal funnels through `removePty`, which has three callers plus the shared reap. | ||
|
|
||
| | Site | Path | Observed the process end? | | ||
| | --- | --- | --- | | ||
| | node-pty `onExit` handler | the process reported its own exit code | Yes | | ||
| | `reapPtyProvenExited` | pid probed, answered ESRCH from the owning host | Yes | | ||
| | `reapExitedPty(_, 'record-torn-down')` from `listProcesses` | tidies a record already disposed elsewhere | No | | ||
| | `disposePtyForRelayShutdown` | SIGKILL sent, exit wait timed out, record deleted regardless | No | | ||
|
|
||
| The two "yes" rows now write the id into `observedPtyExitIds`. Nothing else does, and the write | ||
| sits at the line that made the observation rather than inside the shared reap, so the reap's | ||
| bookkeeping caller cannot inherit it. | ||
|
|
||
| ## What the relay answers | ||
|
|
||
| `pty.probeLiveness` takes an exact id and answers from the handler's own state. | ||
|
|
||
| - A live record: `live`, or `exited` if probing its pid reaps it. | ||
| - A record mid-teardown, or an id with a revive in flight: `unknown`. | ||
| - Any other id: `exited` only if it is in the ledger, otherwise `unknown`. | ||
|
|
||
| Fail-closed by construction. A future removal path that forgets to record itself yields `unknown`, | ||
| which defers; it cannot yield a false death certificate. Eviction from the bounded ledger has the | ||
| same safe direction. | ||
|
|
||
| Two gates were considered and dropped as dead code, each confirmed by a surviving mutation that | ||
| changed no observable behaviour. A mint-epoch comparison is subsumed because ledger keys are whole | ||
| ids that already embed the generation. A blanket "a shutdown has been fenced" refusal masked the | ||
| ledger in the only path where teardown runs, made that path's correctness untestable, and withheld | ||
| exits the relay really did observe. | ||
|
|
||
| ## Boundary | ||
|
|
||
| **Invariant.** Only the execution host can distinguish a process that ended from bookkeeping that | ||
| stopped tracking it. A mint epoch proves who allocated an id; it says nothing about why that | ||
| owner's record disappeared. | ||
|
|
||
| **Owner.** `PtyHandler`. It holds the records, the physical-exit path, the pid probe, the shutdown | ||
| fence, and pending revives. | ||
|
|
||
| **Restores or compensates.** Restores. The previous version compensated at the client, rebuilding a | ||
| verdict from two projections that do not carry the missing evidence. The client now asks and | ||
| forwards; `SshPtyProvider.probePtyLiveness` maps three statuses to `true` / `false` / `null` and | ||
| does nothing else. | ||
|
|
||
| **Alternative rejected.** Keeping the inference and excluding the shutdown case client-side. It | ||
| needs the client to know which removals were bookkeeping, which is precisely the knowledge only the | ||
| owner has, and the next removal path would silently reopen the hole. | ||
|
|
||
| **Compatibility.** A relay too old to know the method answers JSON-RPC `-32601`, which arrives as a | ||
| rejection and maps to `null`, so no capability negotiation is needed and no discovery round trip is | ||
| spent. Old provider against a new relay is unaffected: the handler is additive. The `ptyIdMintEpoch` | ||
| capability and the shared id module stay because the relay still mints through them. | ||
|
|
||
| ## Mutation results | ||
|
|
||
| Eight mutations against the relay verdict and the two suites that drive it. | ||
|
|
||
| | Mutation | Result | | ||
| | --- | --- | | ||
| | Certify any id absent from the map | 9 failed | | ||
| | Record the shutdown teardown as an observed exit | 4 failed | | ||
| | Drop the node-pty `onExit` record | 2 failed | | ||
| | Drop the pid-probe record | 1 failed | | ||
| | Answer live instead of reaping a dead pid | 1 failed | | ||
| | Record the torn-down sweep as an observed exit | survives | | ||
| | Treat a disposed record as live | survives | | ||
| | Drop the pending-revive gate | survives | | ||
|
|
||
| The three survivors guard states no current path constructs, all in the safe direction. A disposed | ||
| record is never left in the map: all three `disposeManagedPty` callers remove it in the same | ||
| synchronous block, so neither the torn-down sweep nor the disposed branch can be driven. An id in | ||
| the ledger cannot be revived, because revive requires `process.kill(pid, 0)` to succeed and a | ||
| recorded id's process is gone. The revive gate is kept anyway because that coupling lives in | ||
| another function. | ||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: stablyai/orca
Length of output: 50370
🏁 Script executed:
Repository: stablyai/orca
Length of output: 2398
Correct the
Promise.allSettledfailure description.Promise.allSettledfulfills with rejected result entries.disposePtysexplicitly throwsrejected.reasonafter settlement, so state thatdisposePtysrejects rather than thePromise.allSettledaggregate.