Repository navigation
Conversation
A request's deadline was armed at enqueue, before the frame was handed to SshMultiplexerTransportWriter. While the writer is saturated the control lane is parked (pump() early-returns), so a pty.spawn frame could sit in the queue for its whole budget without ever reaching the wire, and the dead-link check that would otherwise rescue it is deliberately suppressed in exactly that state. The pane then settled the connect as timed out and retried a spawn that had never started. Add an opt-in `budgetStartsAtWire` request option instead of changing every caller: the queue wait gets its own bound (never below the caller's own budget, so opting in cannot shorten a call), and the response budget is armed fresh from the writer's per-request settlement callback. Per-request, so a stall that parks one frame cannot suspend the deadline of a request already out on the wire, and a writer that never drains still surfaces a timeout. pty.spawn opts in — a spawn that never reached the wire started nothing and retries safely — and so do the two pty.getCapabilities probes that gate it (supportsClaims, supportsCreateOperations). Without them the probe expires in the same queue first and pty.spawn is never enqueued at all, so the spawn's own wire-started budget never engages on the first spawn of a connection. The resulting worst case is a function of the caller's budget, so src/shared/ssh-relay-request-budget.ts exports sshRelayQueueWaitMs and sshRelayRequestWorstCaseMs rather than one fixed number. SSH_PTY_CONNECT_- WORST_CASE_MS sums the whole connect sequence — both probes, the spawn, and the shutdown that cleans up a spawn whose claim failed validation — because both probes have independent cache entries and a launch that asks for a claim and a create-operation sends both. The pane-connect backstops (DIRECT_SSH_PANE_RETRY_SETTLEMENT_TIMEOUT_MS, TRANSPORT_CONNECT_SETTLE_GRACE_MS) size themselves from that one number.
Greptile SummaryThe PR gives selected SSH relay RPCs separate queue and response budgets so
Confidence Score: 4/5The PR appears safe to merge, with a non-blocking maintainability issue in the hand-maintained capability-probe count used to size renderer deadlines. The two-phase multiplexer deadlines and current spawn sequence are coherently bounded and guarded against late settlement, but future probe additions require synchronized manual updates to avoid understating the connect window. Files Needing Attention: src/shared/ssh-relay-request-budget.ts
|
| Filename | Overview |
|---|---|
| src/main/ssh/ssh-channel-multiplexer.ts | Adds an opt-in two-phase request deadline with guarded timer rearming when each frame reaches the transport. |
| src/main/providers/ssh-agent-session-create-operation.ts | Applies wire-started budgets to create-operation capability detection and PTY spawning. |
| src/main/providers/ssh-agent-session-claim-validation.ts | Applies the queue-safe request budget to the claim-capability probe. |
| src/shared/ssh-relay-request-budget.ts | Centralizes request and connect limits, but the full-connect calculation depends on a manually synchronized probe count. |
| src/renderer/src/components/terminal-pane/pty-connection/pty-connect-limits.ts | Resizes retry settlement and input-recovery grace periods from the shared SSH connect bound. |
| src/main/ssh/ssh-channel-multiplexer-saturation-deadline.test.ts | Exercises queue saturation, per-request settlement, cancellation, connection loss, and long/short timeout behavior. |
| src/main/providers/ssh-pty-provider-saturated-writer-connect.test.ts | Covers first-connect capability gating and the complete claimed-spawn worst-case sequence under writer saturation. |
Reviews (1): Last reviewed commit: "fix(ssh): start the pty.spawn deadline w..." | Re-trigger Greptile
| // supportsClaims (agentSessionEnsure) then supportsCreateOperations | ||
| // (agentSessionCreateOperationId) — and a launch that asks for both sends both. | ||
| const SSH_PTY_CONNECT_CAPABILITY_PROBES = 2 | ||
|
|
There was a problem hiding this comment.
SSH_PTY_CONNECT_CAPABILITY_PROBES duplicates the number of probes in SshPtyProvider.spawn(), so adding another probe without updating this constant understates the renderer backstops and makes retry or recovery run while that connect is still active. Please derive the bound structurally from the connect sequence or otherwise keep the count coupled to it.
📝 WalkthroughWalkthroughThe changes add shared SSH relay request and PTY connection budgets. The channel multiplexer supports deadlines that start when frames reach the wire and reports bounded pre-wire flush timeouts. PTY capability probes and spawn requests use these deadlines and shared constants. New tests cover saturated writers, queue timing, connection loss, and PTY connection sequences. Renderer retry and transport grace limits now use the shared pane connect budget. Merge Risk: 🟡 Moderate · up to The PR changes PTY deadlines so a queued spawn can time out before transmission, but the original frame may still be sent later while cancellation is queued behind it. A retry could therefore create an untracked or duplicate remote PTY, so the change is not merge-ready until queued requests are suppressed or equivalent idempotency is enforced. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description gives detailed implementation, rationale, testing, trade-offs, and limitations. However, it omits required template sections, including Resolution Add all required template sections. Include a valid linked issue under
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: 03318c68-61e6-4e32-9d6d-0858a1258ac2
📒 Files selected for processing (10)
src/main/providers/ssh-agent-session-claim-validation.tssrc/main/providers/ssh-agent-session-create-operation.tssrc/main/providers/ssh-pty-provider-agent-session-create-operation.test.tssrc/main/providers/ssh-pty-provider-saturated-writer-connect.test.tssrc/main/ssh/ssh-channel-multiplexer-saturation-deadline.test.tssrc/main/ssh/ssh-channel-multiplexer.tssrc/renderer/src/components/terminal-pane/pty-connection-direct-ssh-reattach-retry.test.tssrc/renderer/src/components/terminal-pane/pty-connection-direct-ssh-spawn-retry.test.tssrc/renderer/src/components/terminal-pane/pty-connection/pty-connect-limits.tssrc/shared/ssh-relay-request-budget.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review.
| expire( | ||
| budgetStartsAtWire | ||
| ? sshMuxWriteFlushTimeoutError(method, queueWaitMs) | ||
| : sshMuxRequestTimeoutError(method, timeoutMs) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Suppress or revoke the queued request on a pre-wire timeout.
When budgetStartsAtWire expires, the pending state is removed and rpc.cancel is enqueued, but the original pty.spawn frame remains in the FIFO control lane. The relay can therefore receive cancellation before the spawn exists and later execute the spawn after the caller has already timed out. A retry can create an untracked or duplicate PTY.
Make writer entries cancellable or tombstone them before rejecting the request, and add a regression that drains a timed-out queue and verifies that no pty.spawn frame is sent.
📍 Affects 2 files
src/main/ssh/ssh-channel-multiplexer.ts#L309-L312(this comment)src/main/providers/ssh-agent-session-create-operation.ts#L75-L75
There was a problem hiding this comment.
ℹ️ One rough edge worth a look — the fix logic is sound and the coverage is strong, but a generic connect grace is now sized to a direct-SSH-specific worst case.
Reviewed changes
- Relay budget module —
ssh-relay-request-budget.tscentralizes the request/flush timeouts and thesshRelayQueueWaitMs/sshRelayRequestWorstCaseMshelpers. - Split request deadline —
SshChannelMultiplexer.request()gains opt-inbudgetStartsAtWire: the queue wait is bounded separately from the response budget, with a distinct... without reaching the wireerror. - Spawn/probe opt-in —
pty.spawnand both gatingpty.getCapabilitiesprobes (supportsClaims,supportsCreateOperations) opt in, so a saturated writer no longer expires the spawn before its frame is written. - Widened pane-connect backstops —
DIRECT_SSH_PANE_RETRY_SETTLEMENT_TIMEOUT_MSandTRANSPORT_CONNECT_SETTLE_GRACE_MSnow derive fromSSH_PTY_CONNECT_WORST_CASE_MS(160 s). - Fake-timer saturation suites — two new test files pin the per-request wire-started budget and the whole claimed-connect worst case.
I verified the core mechanism end to end against ssh-multiplexer-transport-writer.ts: the settlement.ok signal re-arms the deadline only once the frame is out of the writer (the stream flush callback on the real transport, write()===true/drain on the test transport), the timer/cleanup closure is safe across re-arm, and the two capability probes are independently cached so a both-flags launch really sends both. The 160 s worst-case accounting (2×35 s probes + 60 s spawn + 30 s shutdown) checks out, and the tests assert exact values rather than loose bounds.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
| export const TRANSPORT_CONNECT_SETTLE_GRACE_MS = 60_000 | ||
| // Sized to the whole connect sequence — both capability probes, spawn, cleanup | ||
| // shutdown — not spawn alone, so a connect past it cannot still be live. | ||
| export const TRANSPORT_CONNECT_SETTLE_GRACE_MS = SSH_PTY_CONNECT_WORST_CASE_MS |
There was a problem hiding this comment.
TRANSPORT_CONNECT_SETTLE_GRACE_MS is not SSH-scoped: pty-input-recovery.ts fences the #8104-class fossil-pane recovery for every transport, fresh-spawn-start.ts / deferred-session-reattach-connect.ts set transportConnectInFlightSince on local, WSL, and remote-runtime connects alike, and the pre-existing comment above even names the "wedged daemon call" (local) class as a target. Sizing it to the direct-SSH SSH_PTY_CONNECT_WORST_CASE_MS (160 s) widens that suppression window from 60 s to 160 s for transports that settle in seconds and gain nothing from the extra 100 s. If the original 60 s was a deliberate generic bound, keep it and only derive the direct-SSH retry settlement from the worst case.
Technical details
# Generic connect grace widened to a direct-SSH worst case
## Affected sites
- `src/renderer/src/components/terminal-pane/pty-connection/pty-connect-limits.ts:24` — `TRANSPORT_CONNECT_SETTLE_GRACE_MS = SSH_PTY_CONNECT_WORST_CASE_MS` (was `60_000`)
- `src/renderer/src/components/terminal-pane/pty-connection/pty-input-recovery.ts:283-288` — `connectStillSettling` gate suppresses `requestRecoveryForUndeliverableInput` for every transport
- `src/renderer/src/components/terminal-pane/pty-connection/fresh-spawn-start.ts:70` and `deferred-session-reattach-connect.ts:40` — set `transportConnectInFlightSince` on generic connects
## Required outcome
- Non-SSH transports keep a connect grace commensurate with their real settle time (seconds), or the widening is an explicitly accepted choice rather than a side effect.
## Suggested approach (optional)
- Leave `TRANSPORT_CONNECT_SETTLE_GRACE_MS` at `60_000` (its pre-change value) and keep only `DIRECT_SSH_PANE_RETRY_SETTLEMENT_TIMEOUT_MS` derived from `SSH_PTY_CONNECT_WORST_CASE_MS`; or introduce a separate SSH-only grace.
## Open questions for the human (optional)
- Was the original `60_000` sized on purpose, or was it already a proxy for the direct-SSH connect worst case that should scale with it?
Confirming review (post-cap)The adversarial loop hit its 4-round cap, so an independent agent ran a confirming pass on the final tree. Result: 9/9 prior findings verified genuinely fixed (not just claimed), no correctness defect found in the multiplexer change itself, nothing wire-facing. Tests proven load-bearing. Neutering only the core change ( The 5 survivors are the intentional regression guards (opt-out default, short fail-fast budget, saturation flap, unsaturated dead-link) — they are supposed to pass under old behavior. Budget ladder is internally consistent (rebuilt from source): Residual findings — flagged, not fixed here
ScopeThe reviewer explicitly recommended against narrowing this to just "don't charge parked time + named budget": dropping the probe opt-in reintroduces R4 verbatim (the 5s probe expires in the queue and the spawn it gates is never enqueued, so the fix does nothing on a connection's first spawn), and dropping the backstop resize reintroduces R4's second half. Those pieces are load-bearing for the core fix, not scope creep. |
|
Superseded — recommending we close this in favour of #17817, which fixes the cause this PR works around. The premise this PR names is itself the bugFrom the description above: a That suppression is unbounded, and it is the actual defect. #17817 removes the suppression. A wedged writer now disposes in ~20s and reconnects. A reproduction test ( Three concrete reasons not to land this on top
Two independent reviews reached this conclusion separately, including the observation that a parked frame's Worth salvaging
Closing is the recommendation, not a decision — happy to be overruled if you see a case #17817 leaves open. |
|
Closing note, for the record: superseded by #17817. This PR's own description names the defect #17817 fixes — the dead-link check being "deliberately suppressed" while the writer is saturated. That suppression was unbounded, which is why a wedged link never reconnected. With it removed, a link that stops draining is declared lost in ~20s and reconnects, rather than a The "several minutes to connect" half of that report was never a writer problem — it was #14830: an unanswered native-deps probe read as "all deps missing", triggering an eight-minute npm install + rebuild that looped to the 900s deploy cap. Also fixed in #17817. Nothing is lost. #17882 tracks the two pieces worth keeping: porting the saturated-writer connect harness to assert the new behaviour, and dequeue-on-timeout in the writer — the one real hazard this PR identified and did not fix. The diagnosis here is what pointed at the right layer, even though the fix landed a level down. |

What
A relay RPC's timeout was armed at enqueue, not when its frame actually reached the wire.
SshChannelMultiplexer.request()calledsetTimeout(timeoutMs)and then handed the frame toSshMultiplexerTransportWriter. While that writer is saturated the control lane is parked (pump()early-returns), and the dead-link check that would otherwise rescue a stuck request is deliberately suppressed in exactly that state. So apty.spawnframe could burn its entire 30 s budget sitting in the queue, never having been written. The pane settled the connect as timed out and re-armed a retry for a spawn that had never started.The change:
budgetStartsAtWireonSshChannelMultiplexer.request(). Opt-in rather than default, so callers that deliberately chose a short fail-fasttimeoutMskeep it.sshRelayQueueWaitMs(timeoutMs) = max(timeoutMs, 30_000)— never below the caller's own budget, so opting in can never shorten a call.timed out after Nms without reaching the wirevs. the existingtimed out after Nms.pty.spawnopts in (a spawn that never reached the wire started nothing and retries safely), and so do bothpty.getCapabilitiesprobes that gate it —supportsClaims(agentSessionEnsure) andsupportsCreateOperations(agentSessionCreateOperationId). Without that, the 5 s probe expires in the same queue first,pty.spawnis never enqueued, and the spawn's wire-started budget never engages on the first spawn of a connection.src/shared/ssh-relay-request-budget.tsexportssshRelayQueueWaitMs/sshRelayRequestWorstCaseMs(functions of the caller's budget) rather than one fixed constant, plusSSH_PTY_CONNECT_WORST_CASE_MS, which sums the whole connect sequence: two probes + spawn + thepty.shutdownthat cleans up a spawn whose claim failed validation. The renderer backstopsDIRECT_SSH_PANE_RETRY_SETTLEMENT_TIMEOUT_MSandTRANSPORT_CONNECT_SETTLE_GRACE_MSnow derive from that one number.Fix evidence
All output below is verbatim from this worktree.
Before — the new tests fail against pre-change
ssh-channel-multiplexer.tssrc/main/ssh/ssh-channel-multiplexer.tsrestored to its merge-base blob (git show 872bd51d479:...), everything else at the branch tip:The core assertion — a parked request must not be charged the response budget:
And the whole-connect case, driving the real
SshPtyProviderover a saturatedMultiplexerTransport, produced an unhandledexecution_owner_unavailablebecause the gating probe died in the queue and the spawn was never dispatched:Before — the perf-audit finding, reproduced independently
The perf audit claimed
SSH_PTY_CONNECT_WORST_CASE_MScounted only one capability probe whileSshPtyProvider.spawn()issues two (ssh-pty-provider.ts:84and:107, independently cached inSshAgentSessionCapabilities, andorca-runtime.ts:31058-31072sets both launch flags together). I extended the worst-case test to set both flags and ran it against the branch tip before touching the constant:Confirmed the audit's exact numbers (
159994measured vs.125000claimed). Fixed by summing two probe worst cases:After — final runs at the committed tree
Full surrounding suites:
Gates:
Evidence I do NOT have
write()returnsfalse; I did not congest an actual relay link.ELI5
Imagine mailing a letter that must be answered in 30 minutes. The old code started the 30-minute clock the moment you dropped the letter in your outbox — not when the mail carrier actually picked it up. If the outbox was jammed (the network write buffer was full), the letter sat there, the 30 minutes ran out, and you declared "no reply!" and mailed a duplicate — even though the first letter had never left the house.
Now, for the letters where a duplicate would be dangerous (starting a terminal on a remote machine), the clock starts when the carrier picks it up. The time spent jammed in the outbox has its own separate, bounded limit — so a permanently jammed outbox still fails, it just fails saying "never got picked up" instead of pretending it was ignored. Every letter is timed individually, so one jammed letter can't freeze the clock on letters already in transit.
Trade-offs
Real, user-facing, and worth reading:
Worst-case SSH pane connect goes from ~31 s to ~161 s before the renderer gives up and retries.
DIRECT_SSH_PANE_RETRY_SETTLEMENT_TIMEOUT_MSmoves from31_000toSSH_PTY_CONNECT_WORST_CASE_MS + 1_000=161_000. On a genuinely dead-but-not-closed link where the writer is saturated, a user now stares at a connecting pane for up to ~2m40s instead of ~30s. That is the direct cost of not retrying a spawn that may have actually started: the old fast failure was fast because it was wrong. There is no cheaper way to distinguish "never sent" from "sent, unanswered" while the writer is parked and the dead-link detector is standing down.TRANSPORT_CONNECT_SETTLE_GRACE_MSgrows the same way (60 s → 160 s), and its slack shrank to zero. It is now set exactly equal to the connect worst case rather than exceeding it. It is still a correct upper bound (the measured worst path is159994 msagainst a160000 msbound), but it is a 6 ms margin, not a comfortable one. Practical effect: input-triggered recovery on a wedged pane is suppressed for up to 160 s instead of 60 s.The two gating capability probes now wait out the writer queue too. Each
pty.getCapabilitiescan now take up to 35 s (30 s queue + 5 s response) instead of 5 s flat. This only bites when the writer is saturated — on a healthy link the frame is written synchronously and the response budget is still 5 s — but it does mean a relay that is reachable-but-congested delays capability detection rather than falling back to legacy behavior quickly.Two new latency knobs that can drift.
SSH_PTY_CONNECT_CAPABILITY_PROBES = 2is a hand-maintained count of probe call sites inSshPtyProvider.spawn(). If a third gating probe is ever added and that constant is not bumped, the backstops silently understate the worst case again — exactly the bug fixed in this PR. The worst-case test inssh-pty-provider-saturated-writer-connect.test.tsassertsexpect(probeIds).toHaveLength(2)and drives the real provider, so a third probe should fail it, but that is a test-level guard, not a structural one.budgetStartsAtWireis opt-in. Every other relay caller keeps the old enqueue-started deadline and remains vulnerable to the same class of premature timeout. That is deliberate — making it the default silently gave every short fail-fast caller up to +30 s (this was caught and rejected in adversarial round 2) — but it means the fix is scoped to the spawn path, not to the multiplexer generally.Adversarial review
4 rounds. This hit the round cap; it did not converge to a clean round. Round 4 still returned two majors (both fixed), and a separate perf audit afterwards returned a further confirmed major that was also fixed here — so the last review pass over this code found real defects, and no reviewer has since signed off on the current tree.
Round 1 —
[blocker]ssh-channel-multiplexer.ts: the original design usedparkRequestDeadlines()/resumeRequestDeadlines(), which suspended every pending request's deadline (including requests whose frame had already reached the wire), and the 120 s bound was per saturation episode — a writer flapping saturated/drained (the normal state under sustainedpty.data) re-armed the grace on every cycle, so deadlines could be suspended without limit. Reproduced with a probe: agit.statusrequest already on the wire, then 200 × {saturate → advance 30 s → drain} gavesettled=false, disposed=falseafter 6,000,000 ms simulated.[major]ssh-agent-session-create-operation.ts: raising thepty.spawnbudget to 120 s broke the documented coupling with the renderer'sDIRECT_SSH_PANE_RETRY_SETTLEMENT_TIMEOUT_MS = 31_000, which had been left untouched. → Both confirmed. The global park/resume design was abandoned and rewritten as a per-request wire-started budget; the renderer backstop was made to derive from the same shared budget module.Round 2 —
[blocker]: the new queue-wait bound was a fixed 30 s even when the caller asked for a much larger budget, so any request withtimeoutMs > 30_000would newly fail at 30 s if parked — a failure mode that did not exist before.[major]: the wire-started behavior was the default, withhardDeadlineas an opt-out that only teardown ever passed, so every caller that deliberately chose a short fail-fasttimeoutMssilently gained up to +30 s. → Both confirmed, neither rejected. One root cause. Inverted to opt-in (budgetStartsAtWire), and made the queue bound scale with the caller's budget:sshRelayQueueWaitMs(t) = max(t, 30_000).Round 3 —
[major]ssh-relay-request-budget.ts:SSH_RELAY_REQUEST_WORST_CASE_MSwas hardcoded atFLUSH + REQUEST = 60_000, but for an opted-in caller with a non-defaulttimeoutMsthe true worst case ismax(timeoutMs, 30s) + timeoutMs— e.g.130_000fortimeoutMs: 130_000— and the change's own test blessed exactly that shape.[major]: the branch's HEAD commit still contained the abandoned round-1 design and described it in its message, while the real fix was uncommitted and its new module untracked. → Both valid, both fixed. The fixed constant became the functionsshRelayRequestWorstCaseMs(timeoutMs); the commit was rewritten to match the shipped design.Round 4 —
[major]ssh-pty-provider.ts: the gatingpty.getCapabilitiesprobe (5 s, not opted intobudgetStartsAtWire) failed first under the very saturation the fix targets, sopty.spawnwas never enqueued and the wire-started budget never engaged on the first spawn of a connection. Reproduced verbatim by driving the realSshPtyProviderover a saturatedMultiplexerTransport:{ e: 'execution_owner_unavailable' }with frames['pty.data', 'pty.getCapabilities#1', 'rpc.cancel']— nopty.spawn.[major]pty-connect-limits.ts:TRANSPORT_CONNECT_SETTLE_GRACE_MS(60 s) was strictly less than the connect worst case it claimed to cover (5 s probe + 60 s spawn = 65 s), and the new comment asserted the opposite. → Both valid and reproduced, both fixed. Nothing rejected. The probes opt in, andSSH_PTY_CONNECT_WORST_CASE_MSwas introduced to size the grace from the whole sequence.What remains open at the cap
2(trade-off Add Ctrl+Click to open links in terminal #4). Structurally, the worst case should be derived from the provider rather than hand-counted.TRANSPORT_CONNECT_SETTLE_GRACE_MShas ~0 ms of engineered slack (trade-off Fix Ctrl+Backspace not deleting word in terminal #2). It is correct but brittle; a future call added anywhere in the connect sequence invalidates it.Perf review
A performance audit was run over the worktree (branch
e31e7e167e5+ the then-uncommitted work), with all measurements taken in-tree and scratch files removed afterwards.F1 — CONFIRMED, and fixed in this PR.
SSH_PTY_CONNECT_WORST_CASE_MSunderstated the real connect by 35 s.src/shared/ssh-relay-request-budget.ts:43summed one capability probe, butSshPtyProvider.spawn()issues two independentpty.getCapabilitiescalls —supportsAgentSessionClaims()(ssh-pty-provider.ts:84, gated onagentSessionEnsure) andsupportsAgentSessionCreateOperations()(ssh-pty-provider.ts:107, gated onagentSessionCreateOperationId) — andorca-runtime.ts:31058-31072sets both flags on the same launch. Both now opt intobudgetStartsAtWire, so each can spendsshRelayRequestWorstCaseMs(5_000)= 35 s. Measured by extending the worst-case test with both flags set (two probe ids observed on the wire):At the audited state
DIRECT_SSH_PANE_RETRY_SETTLEMENT_TIMEOUT_MSwas 126,000 ms, so it would fire ~34 s before the connect settled — the pane settlestimed-out, the retry re-arms, and a second spawn is dispatched. That is precisely the defect this PR exists to remove; at the audited state it had been moved from 31 s to 126 s, not eliminated.Resolution in this PR: I independently reproduced F1 (identical
159994/125000numbers, quoted verbatim under Fix evidence), then fixed it by counting both probes inSSH_PTY_CONNECT_WORST_CASE_MS(now 160,000 ms, backstop 161,000 ms) and by permanently strengtheningssh-pty-provider-saturated-writer-connect.test.tsto set both launch flags and assertprobeIdshas length 2 — so the audit's exact scenario is now a standing regression test rather than a one-off probe. The suite passes.Net perf posture: this change adds no per-frame CPU or allocation work on the hot path. The only per-request cost is one extra
clearTimeout+setTimeoutfor opted-in requests when the writer settles their frame, and a closure capture on the settlement callback — both bounded by the number of in-flightpty.spawn/pty.getCapabilitiescalls, which is at most a handful per connection. It does not touchpty.data, the writer'spump()loop, or any streaming path. The cost is entirely in latency budgets under an already-degraded link, quantified in Trade-offs #1–#3.