feat(ssh): bound relay PTY output end to end
Summary
Implements bounded SSH relay PTY output end to end, from the native PTY through relay publication, dispatcher/SSH transport, bounded frame decoding, main-process model and projection admission, renderer/remote consumer settlement, cumulative source ACK publication, exit, and reconnect.
The production invariant is:
0 <= sentEndSu - creditedEndSu <= windowSu
for each negotiated token, with every immutable source span and required consumer obligation ending exactly once as settled, transferred, or canceled. A write(false) owns one frame exactly once; later ordinary traffic waits for drain, while bounded control/liveness capacity remains available.
The implementation includes:
- one drain-aware relay writer with bounded ordinary, bulk, control, sentinel, and connect-mode lanes;
- bounded relay and main frame-decoder turns with read pause/resume;
- startup-latched SSH V1 negotiation through a shared semantic
PtyConsumerSessionand SSH-specific authenticated transport adapter; - immutable source ledgers, cumulative token-scoped credit, bounded main model admission, desktop and required remote reserve/commit/rollback, and ACK publication fenced by mux write settlement;
- sealed exit retention, token-scoped cancellation proof, exact reconnect recovery, stale-owner one-shot retry, and bounded eight-wide reattach;
- legacy-safe gate-off behavior, fixed-size filesystem compatibility, Git/PTY capacity-aware slicing, and explicit rollout/rollback policy.
The feature remains behind ORCA_SSH_PTY_SOURCE_CREDIT_V1, read once at main-process startup. Gate-off sessions retain the bounded legacy writer/decoder path. Local and daemon protocols are not replaced.
The branch is rebased on origin/main@d3681f630 and contains 153 changed files (26,108 additions, 1,987 deletions), not the earlier apparent 829-file comparison against the stale remote feature head.
Screenshots
No visual change.
Testing
- [x]
pnpm install --frozen-lockfile - [x]
pnpm lint - [x]
pnpm typecheck - [x] Added deterministic regression coverage and updated
terminal-performance.output-backpressure-budget - [x] 52-gate reliability manifest validation
- [x] Max-lines ratchet: 354 grandfathered suppressions, no new bypass
- [x] All relay targets: Linux/macOS/Windows x64/arm64 and WSL hook relay
- [x]
pnpm exec electron-vite build --mode e2e - [x] Focused SSH/source-credit slice: 24 files, 354 tests
- [x] Watcher/daemon/package/glibc adjacency slice: 14 files, 409 tests
- [x] Changed deterministic sweep: 57 files, 1,186 tests
- [x] Joined renderer/headless snapshot seam: 59 tests; broader focused slice: 180 tests
- [x] Relay recovery and fixed-size filesystem/Git slice: 105 tests
- [x]
git diff --check - [x] Docker OpenSSH/deployed-relay E2E: 4/4 in 1.0 minute
- direct typing median/worst: 107.7/113.6 ms
- ACK-stalled typing median/worst: 3.6/107.3 ms
- exact held source units: 262,144
- fixed-size filesystem/Git churn median/worst: 148.1/161.1 ms, 93 bulk reads
- owner reconnect: 15.7 seconds
The Docker suite proves direct SSH against the deployed Linux relay: real SSH transport/process/filesystem/Git behavior, main desktop intake, writable/drain behavior, source-window plateau, activity isolation, and reconnect. It does not prove paired Orca runtime behavior.
The full monolithic pnpm test and release package build were not run locally; the broader deterministic changed-surface sweep, cross-target relay builds, Electron E2E build, Docker journey, and fresh PR CI are the proportional gates for this change.
AI Review Report
The architecture review selected one shared semantic PtyConsumerSession state machine with transport-specific adapters rather than a universal wire protocol. It explicitly located authority at the authenticated relay session, immutable source ledger, dispatcher writer, main SSH intake, model/projection owners, and mux ACK publication boundary.
Adversarial review found and drove fixes for:
- retaining exited deliveries while uncredited spans remain;
- separating obligation terminality, ACK queueing, and ACK publication;
- carrying immutable span/range identity through desktop projection admission with rollback;
- zero-display source spans, writer liveness during saturation, decoder retention, charged recovery budgets, and isolated reattach;
- token-scoped exit cancellation, response-loss activation retry, exact recovery continuity, and startup-latched rollout;
- failed exit publication retention, cancellation authority through response writer settlement, and snapshot-sequence-bounded remote replacement with live replay of trailing spans.
Final exact-head architecture and terminal/transport re-reviews checked macOS, Linux, Windows/ConPTY/named-pipe, WSL stdio, folder workspace, Electron, direct SSH, local/daemon, paired headed/headless, prior-version, mixed-version, reconnect, exit, and rollback distinctions. Their final disposition will be recorded in the PR discussion before merge.
Security Audit
- Session-owner eligibility comes only from the existing authenticated SSH session and first framed
pty.openClientrequest; socket order, stdout, paths,.git, and worktree identity grant no authority. - Client, owner generation, PTY incarnation, token, source span, projection range, and remote stream generation are validated at their authoritative boundaries.
- ACKs and windows require finite safe integers, monotonic cumulative progress, exact token scope, and no over-credit clamping.
- Decoder input, retained source/recovery memory, pending queues, frames, subscribers, callbacks, timers, and reconnect concurrency have explicit caps.
- Credentials remain transport-adapter-local; no secrets or payload bytes are logged.
- Cancellation and generation-close proofs are token-scoped, idempotent, and cannot tear down unrelated PTYs or filesystem/Git work.
- No dependency or native module was added, so this PR does not raise the Ubuntu 20.04/glibc 2.31 floor.
Notes
- Rollout is default-off and startup-latched. Changing the gate requires a main-process restart; live tokens are never rotated between V1 and legacy in place.
- Same-build gate-off uses bounded legacy transport. Version-scoped prior daemons are observed but are not adopted, killed, negotiated into V1, or claimed to be retroactively bounded.
- The reliability gate remains
experimental/partialwithcoveredProviders: ["ssh"]limited to deterministic contracts and macOS-hosted Docker OpenSSH/deployed-relay evidence. - Not physically exercised: live headed paired desktop, live headless
orca serve, local daemon/provider topology, prior-version daemon binaries and mixed-version clients, physical WSL, physical Windows ConPTY/named pipes, a dedicated live folder workspace, and Ubuntu 20.04/glibc 2.31 packaging. - No Git command behavior or Git-provider-specific review behavior changed.
- Never merge this PR without normal maintainer approval and green fresh CI.
[!NOTE]
Reviews paused
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
reviews.auto_review.auto_pause_after_reviewed_commitssetting.Use the following commands to manage reviews:
@coderabbitai resumeto resume automatic reviews.@coderabbitai reviewto trigger a single review.Use the checkboxes below for quick actions:
- [ ] ▶️ Resume reviews
- [ ] 🔍 Trigger review
📝 Walkthrough
Walkthrough
Adds a design plan for bounded SSH relay PTY output backpressure, and implements it end-to-end: bounded frame decoding and multiplexer/writer backpressure, relay-side PTY source-credit ledgers/scheduling/publication and consumer-session adapter, main-process bounded output intake with legacy projection ledger, model admission, source obligations/coordinator, remote source-range consumers, and ACK coalescing, provider/notification-routing changes for source activation and recovery, SSH relay session recovery/reattach orchestration with a new per-target source-credit rollout module, deploy/launcher credential-file plumbing, runtime terminal-multiplex source-range ledger support, renderer ACK negotiation, shared contracts/validation, settings UI and persistence for the per-target opt-in, updated reliability gates, and new unit/integration/e2e tests.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 4.24% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Title check | ✅ Passed | The title clearly summarizes the main SSH PTY output bounding change and matches the changed areas. |
| Description check | ✅ Passed | The description is detailed and covers summary, validation, security, compatibility, and rollout concerns. |
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
- [ ] Fix failing CI checks
📝 Generate docstrings
- [ ] Create stacked PR
- [ ] Commit on current branch
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 @coderabbitai help to get the list of available commands.
Too many files changed for review. (189 files found, 100 file limit)
Bypass the limit by tagging @greptile-apps to review.
Final implementation head is 5f7330bbbcf04c4359952a863c022e9318feab5c (7327640d3a2b1f0d6aa11a3e8c0fc2dea7f63c8d is the exact code/artifact commit; the final commit records evidence only).
The final architecture/lifecycle review is clean, the final transport review's only stale-provenance finding is closed, all 17 prior major threads have exact fix/test replies, and the fresh four-case Docker OpenSSH/deployed-relay gate passed.
@coderabbitai review
Human architecture/terminal review remains requested from @nwparker. Please do not merge until fresh CI and normal maintainer review are complete.
@OrcaWin: Acknowledged. I’ll review the final implementation, with attention to the exact code/artifact commit and the evidence-only final commit context. I will not approve or recommend merging ahead of fresh CI and normal maintainer review.
✅ Action performed
Review finished.
Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.
@OrcaWin: Acknowledged. I’ll review the final implementation with the code/artifact commit and evidence-only final commit context in mind. I will not approve or recommend merging before fresh CI and normal maintainer review are complete.
✅ Action performed
Review finished.
Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.
Final validation checkpoint: current PR head is f4bad7ab3a6700f423279acba592001002792c8a; 7327640d3a2b1f0d6aa11a3e8c0fc2dea7f63c8d remains the exact production implementation/artifact commit, and f4bad7ab3 only aligns deploy fixtures with the shipped credential-publication sequence. Fresh CI run 30423205432 is fully green, including 16/16 unit shards, 10/10 E2E shards, typecheck/static/package/compatibility contracts, Docker watcher isolation, golden macOS/Linux, Ubuntu/Windows smoke, Windows terminal restart, and packaged crash-survival. Current origin/main@1df8aa56051c is eight unrelated commits ahead; synthetic merge tree d4dccc674726548eedea1e1be881575cc874fc62 is conflict-free. There are zero unresolved review threads, GitHub reports CLEAN/MERGEABLE, and the local worktree is clean and matches the PR head. Human architecture/terminal review remains requested from @nwparker; do not merge without normal maintainer approval.
Final current-main checkpoint: production merge commit adba3410fe is validated by the exact four-case Docker SSH run; current PR head 728ed98ab7 adds only provenance. The PR body now records the always-on same-build V1 decision, negotiated legacy behavior, exact hashes/results, and remaining topology gaps. All review threads are resolved, main is an ancestor, and fresh CI is running. @coderabbitai review Human architecture/terminal review remains requested from @nwparker. Do not merge until CI and normal maintainer review complete.
@OrcaWin: Acknowledged. I’ll review the current-main/provenance state, treating adba3410fe as the production implementation baseline and 728ed98ab7 as provenance-only context. I will not approve or recommend merging until fresh CI completes and normal maintainer review—including the requested architecture/terminal review from @nwparker—is complete.
✅ Action performed
Review finished.
Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.
Final validation checkpoint: current head is 8c35d4f89826e5a38ee5642434caf557ef71b89d, tree b2e35b5fdab000cb5475345298baa64b67190fce, and the local worktree is clean and matches origin/ssh-relay-pty-backpressure. Fresh GitHub CI is green: PR Checks run 30497200229 attempt 2 has 35/35 jobs green, with 41 passing checks total and 3 expected platform skips. The only first-attempt failure was an unrelated combined-diff scroll E2E flake; the exact test passed locally and the failed job passed on rerun. All 26 review threads are resolved. Current origin/main@0349cb6bdbdb19119585ecb6048d884c5ee8b97d is nine unrelated commits ahead of the last branch merge, and synthetic merge tree 802c27aa3c0a3c28e1c3c8176c5eb876e8d522b5 is conflict-free. No material implementation, design, test, CI, or cleanup issue remains. The concrete external blocker is the requested human architecture/terminal review from @nwparker; do not merge until normal maintainer approval is complete.