Skip to content

fix(orcad): answer host paths honestly and ship the watcher child - #16369

Merged
nwparker merged 1 commit into
mainfrom
nwparker/orcad-item1-honesty
Aug 25, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/orcad-item1-honesty

Conversation

@nwparker

@nwparker nwparker commented Aug 25, 2026 •

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

Plan item 1, stacked on #16368. Two symptoms, one cause: the host port answered plausibly-wrong instead of refusing, and something downstream believed it.

The port lied by omission

AppPathName has seven members. orcad implemented three and returned the userData directory for the other four — including 'exe'. A data directory is not an executable path. That is the bundler-shim anti-pattern the design explicitly rejects.

Now every name answers for a Node host or throws:

Name Answer
userData / home / temp unchanged
appData real per-platform app-data root
logs userData/logs — a headless deployment's whole state is one removable directory, and a service account often has no ~/Library to write into
exe process.execPath — the Node binary running the bundle; there is no app executable to point at
downloads XDG_DOWNLOAD_DIR, else the cross-platform default

The watcher was unreachable, and isPackaged was the wrong lever

resolveWatcherProcessEntryPath consulted the adjacent child only when !isPackaged. With orcad claiming packaged it skipped that and resolved a desktop-build path that does not exist in an orcad deployment — and build-orcad emitted one entry, so the child was never built either.

isPackaged: () => true is kept deliberately. Consumers read it as "production build, not a dev checkout": it gates HTTPS-only skill downloads, the real CLI command name, and shell-PATH hydration. Answering false to satisfy a path resolver would relax a security posture to fix a layout bug.

So the resolver now asks the question it actually means — is the app root an asar archive — rather than is this packaged. Only the asar layout nests the child under out/main; orcad is a packaged non-Electron host whose root holds orcad.js and the child side by side. build-orcad now ships the child, the same way it already ships the agent-browser binary.

Proof

Reverting the resolver fix fails three tests:

FAIL  orcad forked-child paths > forks the watcher child shipped beside orcad.js
FAIL  orcad forked-child paths > ignores a decoy child under the working directory
FAIL  resolveWatcherProcessEntryPath > uses the adjacent entry for a packaged host whose app root is not an asar

out/orcad/ now contains orcad.js, agent-browser-*, and parcel-watcher-process-entry.js. Ratchet 0, build-orcad green (including item 0's plain-Node smoke-load), smoke:orcad-terminal passes, typecheck and lint clean.

Trade-offs

Zero user-facing. The desktop path is unchanged — usesAsarArchive is isPackaged && appPath.includes('app.asar'), which is exactly the old condition for a real packaged Electron app.

@nwparker
nwparker force-pushed the nwparker/orcad-item0-guard branch from ccd8a67 to f1a4adc Compare August 25, 2026 04:22
@nwparker
nwparker force-pushed the nwparker/orcad-item1-honesty branch from 1930a92 to 96506e0 Compare August 25, 2026 04:22
@nwparker
nwparker changed the base branch from nwparker/orcad-item0-guard to main August 25, 2026 05:21
orcad's AppEnvironment implemented three of seven AppPathNames and returned the
userData directory for the rest — including 'exe', where a data directory is not
an executable. Every name now has a Node answer: 'appData' is the platform's
per-user application-data root, 'logs' lives inside the data root so a headless
deployment stays one removable directory, 'downloads' honours XDG_DOWNLOAD_DIR,
and 'exe' is the Node binary. getAppPath() is the directory orcad was launched
from rather than cwd, so children resolve against the bundle instead of wherever
the supervisor happened to be.

The watcher child was the load-bearing consequence: resolveWatcherProcessEntryPath
probed for the adjacent entry only when !isPackaged, so orcad resolved a desktop
out/main path that no deployment has — and build-orcad never emitted the child
anyway. isPackaged stays true (consumers read it as "production, not a dev
checkout" and it gates HTTPS-only skill downloads); the resolver now asks whether
the app root is an asar archive, which is the question it actually meant. The
child ships beside orcad.js, and the build forks it to prove it runs.
@nwparker
nwparker force-pushed the nwparker/orcad-item1-honesty branch from 96506e0 to 6b26520 Compare August 25, 2026 05:22
@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds centralized Orcad path resolution with environment and platform-specific fallbacks. The Orcad entry point now uses these resolvers for runtime paths and installation-root detection. Packaged non-asar hosts can resolve an adjacent watcher entry. The build bundles the watcher separately and smoke-tests it through a forked IPC child. Tests cover path resolution, deployment layouts, watcher entry selection, and watcher startup.

Merge Risk: 🔵 Low · up to 6b265

The build helper can currently report success if the watcher child exits before confirming startup, allowing a prematurely terminated child to be treated as healthy. This is a bounded startup-validation risk that warrants explicit owner follow-up but does not otherwise block merging.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description provides detailed context, change rationale, implementation details, trade-offs, and test results. However, it omits required template sections, including the mandatory linked issue, v… Add the missing required template sections. Provide a valid issue reference after Fixes #, add visual proof or write N/A with a reason, document testing and tested platforms, complete the AI Disclosure when applicable, confirm the Agent…
Docstring Coverage ⚠️ Warning Docstring coverage is 55.56% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 7 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies both primary changes: correcting Orcad host path handling and shipping the watcher child.
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.
Full details: Description check

Explanation

The description provides detailed context, change rationale, implementation details, trade-offs, and test results. However, it omits required template sections, including the mandatory linked issue, visual proof or an explicit N/A statement, Testing, Review, Notes, Agent skill upstream boundary, and Checklist.

Resolution

Add the missing required template sections. Provide a valid issue reference after Fixes #, add visual proof or write N/A with a reason, document testing and tested platforms, complete the AI Disclosure when applicable, confirm the Agent skill upstream boundary, address Notes, and complete the Checklist items.

✨ Finishing Touches 💡 1
📝 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.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 98216f8e-3bf1-4832-b723-0a453925cae8

📥 Commits

Reviewing files that changed from the base of the PR and between e217fdd and 6b26520.

📒 Files selected for processing (7)
  • config/scripts/build-orcad.mjs
  • src/main/ipc/parcel-watcher-entry-path.test.ts
  • src/main/ipc/parcel-watcher-entry-path.ts
  • src/main/orcad/orcad-app-paths.test.ts
  • src/main/orcad/orcad-app-paths.ts
  • src/main/orcad/orcad-entry.ts
  • src/main/orcad/orcad-forked-child-paths.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.

Comment on lines +216 to +218
child.on('exit', (code, signal) =>
settle(code === 0 ? null : `exit code=${code} signal=${signal}\n${stderr.slice(0, 2000)}`)
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Require subscribe-started before accepting a clean exit.

Line 217 returns success for any zero exit, including one before the acknowledgement. Track acknowledgement receipt and fail a clean exit until subscribe-started arrives. The IPC protocol defines subscribe-started as the startup acknowledgement.

@nwparker
nwparker merged commit 20c1a61 into main Aug 25, 2026
48 checks passed
paidaxingyo666 pushed a commit to paidaxingyo666/Manta that referenced this pull request Aug 25, 2026
…ablyai#16369)

orcad's AppEnvironment implemented three of seven AppPathNames and returned the
userData directory for the rest — including 'exe', where a data directory is not
an executable. Every name now has a Node answer: 'appData' is the platform's
per-user application-data root, 'logs' lives inside the data root so a headless
deployment stays one removable directory, 'downloads' honours XDG_DOWNLOAD_DIR,
and 'exe' is the Node binary. getAppPath() is the directory orcad was launched
from rather than cwd, so children resolve against the bundle instead of wherever
the supervisor happened to be.

The watcher child was the load-bearing consequence: resolveWatcherProcessEntryPath
probed for the adjacent entry only when !isPackaged, so orcad resolved a desktop
out/main path that no deployment has — and build-orcad never emitted the child
anyway. isPackaged stays true (consumers read it as "production, not a dev
checkout" and it gates HTTPS-only skill downloads); the resolver now asks whether
the app root is an asar archive, which is the question it actually meant. The
child ships beside orcad.js, and the build forks it to prove it runs.

(cherry picked from commit 20c1a61)
dallascrilley pushed a commit to dallascrilley/orca that referenced this pull request Aug 27, 2026
…ablyai#16369)

orcad's AppEnvironment implemented three of seven AppPathNames and returned the
userData directory for the rest — including 'exe', where a data directory is not
an executable. Every name now has a Node answer: 'appData' is the platform's
per-user application-data root, 'logs' lives inside the data root so a headless
deployment stays one removable directory, 'downloads' honours XDG_DOWNLOAD_DIR,
and 'exe' is the Node binary. getAppPath() is the directory orcad was launched
from rather than cwd, so children resolve against the bundle instead of wherever
the supervisor happened to be.

The watcher child was the load-bearing consequence: resolveWatcherProcessEntryPath
probed for the adjacent entry only when !isPackaged, so orcad resolved a desktop
out/main path that no deployment has — and build-orcad never emitted the child
anyway. isPackaged stays true (consumers read it as "production, not a dev
checkout" and it gates HTTPS-only skill downloads); the resolver now asks whether
the app root is an asar archive, which is the question it actually meant. The
child ships beside orcad.js, and the build forks it to prove it runs.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…ablyai#16369)

orcad's AppEnvironment implemented three of seven AppPathNames and returned the
userData directory for the rest — including 'exe', where a data directory is not
an executable. Every name now has a Node answer: 'appData' is the platform's
per-user application-data root, 'logs' lives inside the data root so a headless
deployment stays one removable directory, 'downloads' honours XDG_DOWNLOAD_DIR,
and 'exe' is the Node binary. getAppPath() is the directory orcad was launched
from rather than cwd, so children resolve against the bundle instead of wherever
the supervisor happened to be.

The watcher child was the load-bearing consequence: resolveWatcherProcessEntryPath
probed for the adjacent entry only when !isPackaged, so orcad resolved a desktop
out/main path that no deployment has — and build-orcad never emitted the child
anyway. isPackaged stays true (consumers read it as "production, not a dev
checkout" and it gates HTTPS-only skill downloads); the resolver now asks whether
the app root is an asar archive, which is the question it actually meant. The
child ships beside orcad.js, and the build forks it to prove it runs.
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