Skip to content

test(managed-server): 6 KB wire-size budget for every POSIX host-op command - #30635

Merged
nwparker merged 3 commits into
mainfrom
nwparker/r4-posix-host-op-budget
Oct 19, 2026
Merged

nwparker merged 3 commits into
mainfrom
nwparker/r4-posix-host-op-budget

Conversation

@nwparker

@nwparker nwparker commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​348 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​348
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​7 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​4

ELI5

Some corporate SSH gateways cut a command that is longer than about 10 KB. #30549 made long commands survive that by compressing them, with a plain retry when the host can't decompress. This test measures every command Orca sends to a Linux or macOS host, as it is actually sent, and fails if a new or grown command gets close to the danger zone. That keeps compression a safety net instead of what normally happens.

What Changed

  • New test: src/main/managed-server/posix-host-op-byte-budget.test.ts.

    • Which commands: it finds every exported …Command( builder in managed-server/{host-state,install,lifecycle,activation} and in the top-level src/main/ssh files. The legacy relay is skipped because it retires on 2027-01-15. Builders that don't produce a POSIX host op are listed with a reason.
    • What it measures: the wire string on the plain fallback, which is the fence guard plus the uncompressed POSIX wrapper (wrapRemoteCommandForPosixShell(…, { compress: false })). Each builder runs on both linux-x64 and darwin-arm64 with worst-case arguments: a long NFS home, a long account name, a 40-character build hash, the longest node runtime path and a held fence. The larger of the two sizes counts.
    • Launch: orcadLaunchCommand is measured the way SSH launches (nohup, no env) and, separately, the WSL way.
    • The rule: each command is at most 6 KB, under the 8,000-byte compression threshold. A new exported builder that isn't in the table fails the coverage case.
  • The ops already over budget are listed with their exact measured sizes as ceilings, and those ceilings may only shrink. A listed op also fails if it drops under the budget.

    Op Bytes sent (max of Linux, macOS) Plan
    restoreOrcadStateSnapshotCommand 20,627 moves to the Node host script (R4-10b)
    captureOrcadStateSnapshotCommand 15,152 R4-10b
    probeRemoteInstallCompleteCommand 12,014 repeats the slot path once per file; must shrink in shell
    clearOrcadStateSnapshotMembersCommand 9,000 R4-10b
    tryStealInstallLockCommand 8,847 runs before a verified Node; must shrink in shell
    orcadLaunchCommand (SSH, macOS) 8,006 already compressed today; the macOS SSH-session capture makes it the largest launch
    serializedStateMutationCommand (wrapping :) 6,354 the lock moves last, behind the interop test (D-J)
    orcadLaunchCommand (WSL setsid) 6,323 shrink
  • Production change: export added to three builders that are each sent as their own exec request, so they can be measured: posixReleaseFenceCommand, posixReleaseOwnedLockCommand and executablePermissionsCommand. There is no behaviour change.

Why

Round 4 decision D-J: the 6 KB test-only budget lands now, and the snapshot ops then move onto the content-addressed host script that the pinned Node runs. Without this test, the command length grows with every feature and nothing notices until a user's gateway truncates it (#30491).

It measures what is sent, not the builder's raw output: the fence guard adds about 300 bytes, and the wrapper's escapes add up to 1.7x. Measuring the raw output had hidden four over-budget ops, including the macOS SSH launch.

Linked Issue

Round 4 SSH hardening, slice R4-10a (decision D-J), follow-up to #30491 / #30549. No new issue.

Visual Proof

N/A. This is test-only, plus three export keywords.

Testing

  • pnpm test src/main/managed-server/posix-host-op-byte-budget.test.ts: 59 cases pass.

  • pnpm run typecheck:node, oxlint and oxfmt are clean.

  • I ran the full "static analysis and typecheck" job steps locally.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

Review

  • Codex (gpt-6.1-sol, high): no findings on the first version, and re-run on this head.
  • Opus adversarial review (first version), all fixed:
    • It measured raw output rather than the wire string.
    • It used WSL's launch settings in place of SSH's, which missed the macOS launch at 8,006 bytes.
    • Its discovery missed the src/main/ssh builders and three unexported standalone builders.
  • Opus re-review found that the stdout framing execCommand adds (about 178 bytes) wasn't counted, and that the ssh/ transport subfolders weren't scanned. Both are fixed, and the ceilings were re-measured. Codex flagged the framing gap independently and found nothing on the final head.
  • ref-oss check (run because the PR took 3 review rounds), comparing three reference remote-development codebases:
    • None of them has a length test. All keep the exec request to a short bootstrap and move large logic into an uploaded, versioned program, or pipe it over stdin.
    • This PR: keep it as a guard against growth, not as the fix itself.
    • For R4-10b: prefer running the long ops as subcommands of the already-uploaded, pinned Node bundle (node <bundle> snapshot-restore) over a second content-addressed script. Rollback can then run the previous slot's bundle. The approach here is unchanged.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • There is no runtime, wire or platform change.
  • Not covered: the atomic record writer (orcad-remote-record-file.ts) puts its payload inline, so its size depends on the record. That is a follow-up.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

nwparker and others added 3 commits October 19, 2026 01:00
Builds each exported POSIX host-op builder at realistic maximal arguments and
asserts the raw command stays under 6 KB, under the 8,000-byte compression
threshold. Ops already over budget are listed with ceilings that may only
shrink until they move onto the host script (round 4 R4-10).

Co-Authored-By: Claude <[email protected]>
…nux and macOS

Measures what a gateway sees on the plain fallback (fence guard + uncompressed
POSIX wrapper), takes the larger of Linux and macOS, launches the SSH way (nohup),
and also discovers the top-level src/main/ssh builders. Exports three builders
that are sent as their own exec request so they can be measured.

Co-Authored-By: Claude <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 14 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8eb4d505-14a7-4098-823f-586bef2ee521
📥 Commits

Reviewing files that changed from the base of the PR and between 5f2bb93 and c4ba6dc.

📒 Files selected for processing: 4
  • src/main/managed-server/activation/orcad-activation-lock.ts
  • src/main/managed-server/install/orcad-remote-install.ts
  • src/main/managed-server/install/remote-node-runtime-store-lock.ts
  • src/main/managed-server/posix-host-op-byte-budget.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker
nwparker merged commit 79b7d70 into main Oct 19, 2026
58 checks passed
nwparker added a commit that referenced this pull request Oct 19, 2026
…snapshot-room PRs crossed (#30680)

* fix(managed-server): import newestStateMtimeCommand from its new module

#30635 and #30618 merged in parallel: #30618 moved newestStateMtimeCommand
to orcad-state-newest-mtime.ts while #30635's byte-budget test imported it from
orcad-state-snapshot.ts, breaking typecheck on main.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(managed-server): measure the snapshot-space probe and record #30618's capture growth

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
DoozyX added a commit to DoozyX/orca that referenced this pull request Oct 19, 2026
Upstream 9294b0a (262 commits) into fork e3a5943; 30 conflicted files.
Includes upstream's post-pin stablyai#30680 test fix for the stablyai#30635/stablyai#30618 crossing,
and splits two files the merge pushed over max-lines.

Claude-Session: https://claude.ai/code/session_012SWXYezr9cxoRQJFc73DTB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant