Repository navigation
refactor(orcad): transport-neutral command channel and generic stdio bridge listener - #27689
Conversation
The orcad/remote-install transport now exposes exec as a neutral RemoteCommandChannel (a Duplex with stdin, stderr, close and exit/close events) instead of ssh2's ClientChannel, and drops sftp(): the only consumer was a fallback for doubles without writeFile/uploadDirectory, which the transport type already requires. SshConnection still satisfies the type structurally, so the SSH adapter keeps returning the connection itself and identity-keyed caches are unchanged. The stdio bridge provider is split: the loopback listener (admission, queueing, socket piping) now takes a channel factory and knows nothing of SSH; the SSH provider resolves and checks the bridge over the host transport and hands the listener a factory. No behavior or wire change.
44c8b9a to
c027013
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to This is a refactor with no stated user-facing behavior change, and the reported typecheck and tests passed. No concrete merge-blocking risk was identified in the supplied context. Pre-merge checks |
|
Stack: 2/2, based on #27686 (now merged; this PR targets
main)ELI5
After #27686, the code that runs Orca's remote helper (
orcad) talks to an interface instead of an SSH connection, but that interface still mentioned SSH library types. This PR removes them, so something other than SSH could fill the interface. For SSH users nothing changes.What Changed
orcadexactly as before.exec()on the transport now returns a neutralRemoteCommandChannel(a NodeDuplexplusstdin,stderr,close(); emitsexitthenclose) instead of ssh2'sClientChannel.SshConnectionstill satisfies it as is.sftp()is removed from the transport. Its only user was a relay-install fallback for test doubles lackingwriteFile/uploadDirectory, which the transport type already requires, so the fallback was unreachable and is deleted. Production uploads still go throughSshConnection's SFTP methods, with the existing exec-stdin fallback.listenOrcadStdioBridge(options, openChannel)inorcad-stdio-bridge-listener.tsowns the loopback listener, admission limit, queueing and teardown and knows nothing about SSH. The SSH provider resolves and checks the bridge over the transport and hands the listener a channel factory.No RPC, wire-protocol or persisted-format change.
Why
Prepares orcad to run on hosts reached without SSH (for example, a WSL distro over a
wsl.exestdio channel) without changing SSH behavior. Defining the channel by the Node stream contract the callers already rely on is smaller and safer than wrapping ssh2 channels in a new class, and keepsSshConnectionpassing through unwrapped.Linked Issue
None — preparatory refactor.
Visual Proof
N/A — no behavior change (refactor).
Testing
pnpm tc— passpnpm test src/main/ssh src/main/orcad src/main/ipc src/main/skills src/main/ai-vault src/main/wsl— 1082 files / 10966 tests passed (after rebase ontomain)oxlinton changed files — clean;pnpm run check:code-quality:changed— passedBridge unit tests drive the listener through a neutral test channel (
orcad-stdio-bridge-test-channel.ts).Real sshd, forwarding refused (local, Docker): a throwaway test (not committed) started the repo's Docker SSH fixture with
AllowTcpForwarding no, connected a realSshConnection, and ran the managed tunnel against an echo server standing in for orcad. Checked:execCommandover the neutral channel works; the forwarding probe returnsrefusedand the tunnel picks the stdio bridge; 4 MiB covering every byte value echoes back byte-exact; 12 concurrent sockets hold exactly 8 remote bridge processes, the other 4 stay queued with no data until sockets close, then echo correctly;close()takes the remote bridge processes to 0, the local port refuses connections, and the SSH connection still execs afterwards. 4/4 passed, run twice.CI, real Windows OpenSSH: the
SSH Windows hostslanes (x64/arm64, inbox and preview OpenSSH) passed. Their orcad cells use accounts whose sshd refuses forwarding, so the managed tunnel goes over the stdio bridge to a live orcad and getsHTTP/1.1 101.SSH hostile hosts(Linux containers, macOS loopback sshd) also passed.CI, app level over Docker: a targeted
e2erun ofssh-orcad-auto-convert.spec.tscovers "a host whose sshd refuses TCP forwarding runs a managed server over the stdio bridge": https://github.com/stablyai/orca/actions/runs/38193524263I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
exitfires beforeclose, and the listener relies onclosefor teardown. ssh2 channels already behave this way; any future transport must too.Agent skill upstream boundary
Notes
Security, cross-platform, SSH, mobile, backwards compatibility and performance: unaffected (no runtime change on SSH).
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)