Repository navigation
feat(orcad): boot the Orca runtime on plain Node - #15968
Conversation
ac6519f to
3839cdc
Compare
b799320 to
b2cffb9
Compare
3839cdc to
8c41411
Compare
b2cffb9 to
a6c79fc
Compare
8c41411 to
178a90a
Compare
fbbea74 to
98c8b72
Compare
412da10 to
59c5e79
Compare
98c8b72 to
7db5307
Compare
59c5e79 to
b6cfd0b
Compare
…le modules
`parcel-watcher-entry-path.ts` and `session-scanner-service-entry-path.ts` read the
app root via `require('electron').app` inside a try/catch that already returns null
when Electron is absent. They were therefore correct under plain Node at runtime and
only failed the *static* text check — which is real, not pedantic: the comment in
`ports/port-scan-command-client.ts:19` records that the plain-node-entry-guard fails
on that literal text, try/catch or not.
`hasAppEnvironment() ? getAppEnvironment() : null` gives the identical "no app root
here" answer without the text. That restores `hasAppEnvironment`, which an earlier
commit in this stack deleted as unused — it now has the caller it was waiting for.
Ratchet baseline 27 → 25.
Verified: 74 files / 458 tests; `pnpm typecheck` clean; `oxlint` clean.
Closes the last two Electron couplings and makes `orcad` a working artifact:
a 4.43 MB Node bundle that boots, pairs, registers a repo, creates a real git
worktree and round-trips a PTY — with zero `require("electron")`.
Ratchet 2 -> 0, so `config/runtime-electron-baseline.txt` is now empty and its
test asserts exactly that: any reachable electron import is a regression.
- speech: inject the service factories, so importing ModelManager for its type
no longer drags Electron's streaming net.request into the graph
- filesystem-watcher: add a WorktreeWatcherRemoval port. Every entry in those
maps arrives through an ipcMain handler carrying a renderer sender, so a host
with no renderer has nothing to close, restore or forget — the inert default
is what the desktop code does against empty maps, not a stub hiding work
- user-data-path / profile-storage-paths: resolve userData through
AppEnvironment. These surfaced only once orcad pulled the store in
Both host ports now anchor to a realm-global symbol. `vi.resetModules()` gives
the re-imported graph a fresh module copy, so a binding installed before the
reset silently read back as uninstalled.
The acceptance smoke drives both hosts through one code path (`--target
orcad|electron`) and seeds its own git repo, so it is hermetic and asserts the
same contract of each. Wired into PR CI.
7db5307 to
cbd304c
Compare
|
Warning Review limit reached
Next review available in: 36 minutes Limit details: You’ve used all 10 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?Wait for the limit to reset, then comment An organization admin can change what happens after included review limits in Billing. How do review limits work?CodeRabbit enforces per-developer PR review limits within each organization. For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (34)
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 |
* refactor(host): resolve the app root through the port in fork-reachable modules
`parcel-watcher-entry-path.ts` and `session-scanner-service-entry-path.ts` read the
app root via `require('electron').app` inside a try/catch that already returns null
when Electron is absent. They were therefore correct under plain Node at runtime and
only failed the *static* text check — which is real, not pedantic: the comment in
`ports/port-scan-command-client.ts:19` records that the plain-node-entry-guard fails
on that literal text, try/catch or not.
`hasAppEnvironment() ? getAppEnvironment() : null` gives the identical "no app root
here" answer without the text. That restores `hasAppEnvironment`, which an earlier
commit in this stack deleted as unused — it now has the caller it was waiting for.
Ratchet baseline 27 → 25.
Verified: 74 files / 458 tests; `pnpm typecheck` clean; `oxlint` clean.
* feat(orcad): boot the Orca runtime on plain Node
Closes the last two Electron couplings and makes `orcad` a working artifact:
a 4.43 MB Node bundle that boots, pairs, registers a repo, creates a real git
worktree and round-trips a PTY — with zero `require("electron")`.
Ratchet 2 -> 0, so `config/runtime-electron-baseline.txt` is now empty and its
test asserts exactly that: any reachable electron import is a regression.
- speech: inject the service factories, so importing ModelManager for its type
no longer drags Electron's streaming net.request into the graph
- filesystem-watcher: add a WorktreeWatcherRemoval port. Every entry in those
maps arrives through an ipcMain handler carrying a renderer sender, so a host
with no renderer has nothing to close, restore or forget — the inert default
is what the desktop code does against empty maps, not a stub hiding work
- user-data-path / profile-storage-paths: resolve userData through
AppEnvironment. These surfaced only once orcad pulled the store in
Both host ports now anchor to a realm-global symbol. `vi.resetModules()` gives
the re-imported graph a fresh module copy, so a binding installed before the
reset silently read back as uninstalled.
The acceptance smoke drives both hosts through one code path (`--target
orcad|electron`) and seeds its own git repo, so it is hermetic and asserts the
same contract of each. Wired into PR CI.
* test(smoke): remove the seeded workspace container, not just the worktree
* test(smoke): surface the server's stderr when it dies before ready
* fix(smoke): build node-pty for Node before booting orcad in CI
* fix(smoke): drive the CLI built from this checkout, not one on PATH
* docs(ratchet): say the baseline must stay empty, not merely shrink
* build(orcad): externalize only the native modules actually in the graph
(cherry picked from commit 03fcfdf)
* refactor(host): resolve the app root through the port in fork-reachable modules
`parcel-watcher-entry-path.ts` and `session-scanner-service-entry-path.ts` read the
app root via `require('electron').app` inside a try/catch that already returns null
when Electron is absent. They were therefore correct under plain Node at runtime and
only failed the *static* text check — which is real, not pedantic: the comment in
`ports/port-scan-command-client.ts:19` records that the plain-node-entry-guard fails
on that literal text, try/catch or not.
`hasAppEnvironment() ? getAppEnvironment() : null` gives the identical "no app root
here" answer without the text. That restores `hasAppEnvironment`, which an earlier
commit in this stack deleted as unused — it now has the caller it was waiting for.
Ratchet baseline 27 → 25.
Verified: 74 files / 458 tests; `pnpm typecheck` clean; `oxlint` clean.
* feat(orcad): boot the Orca runtime on plain Node
Closes the last two Electron couplings and makes `orcad` a working artifact:
a 4.43 MB Node bundle that boots, pairs, registers a repo, creates a real git
worktree and round-trips a PTY — with zero `require("electron")`.
Ratchet 2 -> 0, so `config/runtime-electron-baseline.txt` is now empty and its
test asserts exactly that: any reachable electron import is a regression.
- speech: inject the service factories, so importing ModelManager for its type
no longer drags Electron's streaming net.request into the graph
- filesystem-watcher: add a WorktreeWatcherRemoval port. Every entry in those
maps arrives through an ipcMain handler carrying a renderer sender, so a host
with no renderer has nothing to close, restore or forget — the inert default
is what the desktop code does against empty maps, not a stub hiding work
- user-data-path / profile-storage-paths: resolve userData through
AppEnvironment. These surfaced only once orcad pulled the store in
Both host ports now anchor to a realm-global symbol. `vi.resetModules()` gives
the re-imported graph a fresh module copy, so a binding installed before the
reset silently read back as uninstalled.
The acceptance smoke drives both hosts through one code path (`--target
orcad|electron`) and seeds its own git repo, so it is hermetic and asserts the
same contract of each. Wired into PR CI.
* test(smoke): remove the seeded workspace container, not just the worktree
* test(smoke): surface the server's stderr when it dies before ready
* fix(smoke): build node-pty for Node before booting orcad in CI
* fix(smoke): drive the CLI built from this checkout, not one on PATH
* docs(ratchet): say the baseline must stay empty, not merely shrink
* build(orcad): externalize only the native modules actually in the graph
Textual conflicts (7 files) resolved as semantic merges — both sides kept in every case; no side was dropped. Beyond the textual conflicts, main added four gates and one behaviour that this branch's new code violated. Fixed in this merge: - runtime-electron ratchet (#15968): the branch's `rpc/methods/browser-network-tunnel.ts` reached `ipc/ssh.ts`, dragging 20 Electron modules back into the runtime graph the orcad work had just emptied. The connection-manager accessor moves to `ssh/ssh-target-registry.ts` (the same extraction #15927 did for the other five accessors) and the dispatch reads it there; `wsl-browser-network-relay-launch.ts` reads the app root through the AppEnvironment port. Baseline back to 0 entries. - HTML side-preview focus (STA-5001, #15716): main keeps the source editor focused when the reserved preview split is still empty, by steering the visible tab. This branch's client-owned placement reconciler decides the active group on its own and bypassed that, refocusing the preview. It now takes the same fallback tab. - child_process / windowsHide / wsl.exe census gates: the WSL browser-network relay launcher moves onto `spawnProcess`, and the two Electron test launchers now spawn with `windowsHide`. The four sites that cannot migrate today are allowlisted with their reason (detached process-group kill, a non-all-pipes stdio shape, and a long-lived streaming wsl.exe child that `runWslProcess` cannot express). - max-lines: both sides grew `package-electron-runtime-contract.test.mjs`; the union crossed 600. This branch's two additions move to `config/scripts/client-hosted-browser-package-coverage.test.mjs`. Also ports four browser-create test files onto main's `applyWebSessionTabsSnapshot`/`decideWebSessionTabsSnapshot` split (#15644). Gates: typecheck 0 errors, `pnpm lint` exit 0, 6316/6369 test files green. The 12 remaining failures are pre-existing on one or both parents (5 packaging tests need a real `pnpm install`, global-fetch audit and 4 others fail on both parents) or flaky.
* refactor(host): resolve the app root through the port in fork-reachable modules
`parcel-watcher-entry-path.ts` and `session-scanner-service-entry-path.ts` read the
app root via `require('electron').app` inside a try/catch that already returns null
when Electron is absent. They were therefore correct under plain Node at runtime and
only failed the *static* text check — which is real, not pedantic: the comment in
`ports/port-scan-command-client.ts:19` records that the plain-node-entry-guard fails
on that literal text, try/catch or not.
`hasAppEnvironment() ? getAppEnvironment() : null` gives the identical "no app root
here" answer without the text. That restores `hasAppEnvironment`, which an earlier
commit in this stack deleted as unused — it now has the caller it was waiting for.
Ratchet baseline 27 → 25.
Verified: 74 files / 458 tests; `pnpm typecheck` clean; `oxlint` clean.
* feat(orcad): boot the Orca runtime on plain Node
Closes the last two Electron couplings and makes `orcad` a working artifact:
a 4.43 MB Node bundle that boots, pairs, registers a repo, creates a real git
worktree and round-trips a PTY — with zero `require("electron")`.
Ratchet 2 -> 0, so `config/runtime-electron-baseline.txt` is now empty and its
test asserts exactly that: any reachable electron import is a regression.
- speech: inject the service factories, so importing ModelManager for its type
no longer drags Electron's streaming net.request into the graph
- filesystem-watcher: add a WorktreeWatcherRemoval port. Every entry in those
maps arrives through an ipcMain handler carrying a renderer sender, so a host
with no renderer has nothing to close, restore or forget — the inert default
is what the desktop code does against empty maps, not a stub hiding work
- user-data-path / profile-storage-paths: resolve userData through
AppEnvironment. These surfaced only once orcad pulled the store in
Both host ports now anchor to a realm-global symbol. `vi.resetModules()` gives
the re-imported graph a fresh module copy, so a binding installed before the
reset silently read back as uninstalled.
The acceptance smoke drives both hosts through one code path (`--target
orcad|electron`) and seeds its own git repo, so it is hermetic and asserts the
same contract of each. Wired into PR CI.
* test(smoke): remove the seeded workspace container, not just the worktree
* test(smoke): surface the server's stderr when it dies before ready
* fix(smoke): build node-pty for Node before booting orcad in CI
* fix(smoke): drive the CLI built from this checkout, not one on PATH
* docs(ratchet): say the baseline must stay empty, not merely shrink
* build(orcad): externalize only the native modules actually in the graph
* refactor(host): resolve the app root through the port in fork-reachable modules
`parcel-watcher-entry-path.ts` and `session-scanner-service-entry-path.ts` read the
app root via `require('electron').app` inside a try/catch that already returns null
when Electron is absent. They were therefore correct under plain Node at runtime and
only failed the *static* text check — which is real, not pedantic: the comment in
`ports/port-scan-command-client.ts:19` records that the plain-node-entry-guard fails
on that literal text, try/catch or not.
`hasAppEnvironment() ? getAppEnvironment() : null` gives the identical "no app root
here" answer without the text. That restores `hasAppEnvironment`, which an earlier
commit in this stack deleted as unused — it now has the caller it was waiting for.
Ratchet baseline 27 → 25.
Verified: 74 files / 458 tests; `pnpm typecheck` clean; `oxlint` clean.
* feat(orcad): boot the Orca runtime on plain Node
Closes the last two Electron couplings and makes `orcad` a working artifact:
a 4.43 MB Node bundle that boots, pairs, registers a repo, creates a real git
worktree and round-trips a PTY — with zero `require("electron")`.
Ratchet 2 -> 0, so `config/runtime-electron-baseline.txt` is now empty and its
test asserts exactly that: any reachable electron import is a regression.
- speech: inject the service factories, so importing ModelManager for its type
no longer drags Electron's streaming net.request into the graph
- filesystem-watcher: add a WorktreeWatcherRemoval port. Every entry in those
maps arrives through an ipcMain handler carrying a renderer sender, so a host
with no renderer has nothing to close, restore or forget — the inert default
is what the desktop code does against empty maps, not a stub hiding work
- user-data-path / profile-storage-paths: resolve userData through
AppEnvironment. These surfaced only once orcad pulled the store in
Both host ports now anchor to a realm-global symbol. `vi.resetModules()` gives
the re-imported graph a fresh module copy, so a binding installed before the
reset silently read back as uninstalled.
The acceptance smoke drives both hosts through one code path (`--target
orcad|electron`) and seeds its own git repo, so it is hermetic and asserts the
same contract of each. Wired into PR CI.
* test(smoke): remove the seeded workspace container, not just the worktree
* test(smoke): surface the server's stderr when it dies before ready
* fix(smoke): build node-pty for Node before booting orcad in CI
* fix(smoke): drive the CLI built from this checkout, not one on PATH
* docs(ratchet): say the baseline must stay empty, not merely shrink
* build(orcad): externalize only the native modules actually in the graph
ELI5
Orca's brain — worktrees, terminals, git, SSH, agents — lives in one big service. Today that service can only start inside Electron, a ~200 MB desktop app that ships an entire web browser. On a remote server there is no screen, so all of that is dead weight.
This PR makes the brain start on plain Node.
orcadis a 4.43 MB bundle with zerorequire("electron")that boots, accepts a pairing code, registers a repo, creates a real git worktree, and runs a real terminal.Nothing about the desktop app changes. It installs the same facilities as before, just through a named seam instead of a direct import.
What this finishes
The stack below it built the seams and the gate. This PR closes the last two couplings and turns the ratchet to 0:
speech/model-managerHttpClientport —net.requestis a streamingClientRequestwith byte-range resume, progress events, manual idle timeoutipc/filesystem-watcherWebContentsrefs interleaved with the six functions the runtime needsipcMainhandler carrying a renderersender, so a host with no renderer has nothing to close, restore or forget. An inert default does exactly what the desktop code does against empty maps.Both earlier estimates were too pessimistic for the same reason: they measured how tangled the code is instead of asking what a headless host actually needs from it.
config/runtime-electron-baseline.txtis now empty, and its test asserts exactly that — strictly stronger than the old "may only shrink" rule.Proof it works
The acceptance drives both hosts through one code path (
--target orcad|electron) and seeds its own git repo, so each must satisfy the same contract — no borrowed global state, runnable on a clean box.repo add→worktree create→worktree show→terminal create→ send a nonce viaprocess.execPath→ assert it in the output → remove the worktree → clean shutdown.Wired into PR CI as
smoke:orcad-terminal.What the test caught that the import graph could not
In sequence, against a bundle that already reported zero Electron imports:
orcadbooted with no store at all. Every persistence RPC threwruntime_unavailable, while read paths usingthis.store?.x ?? []quietly answered "empty" — so a server that paired and listed nothing looked healthy.registerPtyHandlerscalled without the store, so everyterminal.createdied at binding-persistence time.getLocalProvider, so destructive worktree removal refused to run — correctly, since it could not verify the tree was idle.None are visible in the import graph. The ratchet proves a property of the build; only this proves the thing runs.
Proof of no regressions
pnpm run typecheck,pnpm run lint(incl.--deny-warnings), ratchet: cleanimport { app } from 'electron'and exit 0 clean — an empty baseline that failed open would be worse than no gateUser-facing trade-offs
Zero. The desktop installs every port at process-level bootstrap before anything reads state. No behaviour, timing, or storage-location change.
One repo-facing note: both host ports now anchor to a realm-global symbol, because
vi.resetModules()hands the re-imported graph a fresh module copy — so a binding installed before the reset silently read back as uninstalled. That was the root cause of a large test failure wave here.Native modules: this does NOT affect anyone who ships or runs Orca
The earlier wording here was vague. Concretely:
orcadis not built, not packaged, and not shipped by this PR. It is an opt-in dev script plus one CI check. Verified:orcadbuild:orcadandsmoke:orcad-terminalbuild:desktop/build:release/build:release:parallel/build:electron-viteout/So the native-module question is scoped entirely to a binary nobody ships yet. It cannot reach a user. If
node-ptywere missing tomorrow, the only thing that breaks ispnpm smoke:orcad-terminal— a CI step and a dev command.For the record, when someone does ship
orcad, it needs two native modules beside it, not the five originally listed:node-ptyrequire.resolve@parcel/watcherimport()better-sqlite3,keytar,cpu-featuresProven by running
orcad.jsin an otherwise empty directory containing onlynode_modules/node-pty: it boots, binds and publishes a pairing offer.Note
node-ptyships prebuilds for macOS and Windows but not Linux, which is why the CI step runsensure-native-runtime --runtime=nodefirst. That is already wired.Backward compatibility: verified in both directions
No wire change. The only
src/shared/file this entire stack touches is the newapp-environment.tsport.protocol-version.tsis untouched,RUNTIME_PROTOCOL_VERSIONis still3, andRUNTIME_CAPABILITIESis unchanged. The RPC method files in the diff are pure import-path swaps — same functions, same payloads.Tested rather than inferred, by building a client from
mainand running mixed pairs:main) → new server (orcad)worktree listok,statusok — readsdesktopWindowStatus: "blocked"correctlymain --serve)worktree listreturns real worktrees,runtime.state: ready,desktopWindowStatus: "openable"The one behaviour change, and why it cannot reach a fork
protected-secret-persistence.encryptionAvailable()now lets an uninstalledSecretStorethrow instead of degrading silently (review fix, landed in #15916). Both host ports throw when uninstalled, so the question is whether any process can read them before installation.The desktop installs both at process-level bootstrap,
src/main/index.ts:884, before anything reads state. For child processes, checked the built bundles directly:Neither port is reachable from any fork entry, so neither throw can fire there.
The four fork-reachable modules that previously did
require('electron').appinside a try/catch still answernull/falsewhen there is no app root — they usehasAppEnvironment()rather than the throwing getter, and none of them evaluates at module scope.Platform verification (at this exact commit)
Re-run after the rebase onto
main; earlier runs were against a commit that no longer exists.Identical build output on every platform: 4.44 MB, 2,031 modules, zero
require("electron"). The shipped desktop--servepath passes the same acceptance unchanged.Review loops
4 design rounds (Opus + Grok + GPT-5.6-Sol), then 1 confirming round.
Round 3 split: one reviewer returned SETTLED, two returned NOT-SETTLED. I sided with the dissent after verifying on code that
PtyHostas specified could not open a terminal — onlysetPtyControlleratpty.ts:4538does — then closed that blocker in code rather than in prose.Verdict: SETTLED. The confirming round closed its own blocker.
Corrections the reviews forced into the design, all recorded: the boot proof retracted to load-and-bind only; the Node floor made per-variant;
ControlChannelwithdrawn as a port entirely; "phase 3 IS phase 1";degradations[]shown to be necessary but not sufficient, because Electron silently opens a local tab when screencast is missing.CI-only failures this gate caught
The step failed three times before passing, each on something no local run could reach:
node-ptywas never built for Node on the runner — the repo's owntestscript runsensure-native-runtime --runtime=nodefirst; the smoke did not. Fixed by running it.server exited with 1. An unread pipe can also fill and block the child. Now captured and printed.exitthat had already fired, stacking a bogus "server did not exit within 15000ms of SIGTERM" on top of the real error. Guarded onexitCode.orcais not on PATH in CI — the repo installsorca-dev. The smoke now drivesout/cli/index.jsfrom this checkout, which is the version under test anyway.Only #1 was a product-adjacent gap; #2–#4 were defects in the gate itself. Recorded because the gate's credibility rests on it having been wrong and fixed, not on having looked right.