Repository navigation
fix(linux): land the reviewed Linux packaging stack on main - #18100
Conversation
Pruning removed 3215 of 3216 files from a superseded generation and always
stranded resources/app.asar, leaking ~105 MB per version update. Electron's
asar shim reports a *.asar file as a directory, so the recursive remove tried
to rmdir a real file and failed with ENOTEMPTY; the .catch(() => {}) hid it.
Reproduced end to end on Ubuntu 24.04: 519M -> 623M across one update, and
519M again once the payload is actually reclaimed.
removeExtractedAppImagePayload holds process.noAsar for the removal, counted
so overlapping removals cannot hand the shim back early, and the prune site
now warns with the path instead of swallowing the rejection. All three
removal sites use it -- staging cleanup and displaced roots leaked the same
way.
Also reclaim symlinks left by a packaged deb/rpm install, which the
extracted-cache-only rule turned into a hard conflict on a deb -> AppImage
migration, and name the remedy in the conflict error.
`retries: 1000` caps the attempt count, not elapsed time, so at up to 1s per attempt an IPC-driven registration could hang ~16 minutes against a wedged holder with no feedback. A legitimate holder is bounded by the extraction timeout, so wait that plus slack and then fail with a message naming the lock file, rather than hanging. `maxRetryTime` is forwarded verbatim to the `retry` package by proper-lockfile.
The extracted-payload cache key hashed ctime alongside dev/ino/size/mtime. ctime moves on any inode metadata write -- `chmod +x`, which every AppImage user is told to run, plus `chown`, an ACL or SELinux relabel, and a backup restore -- none of which alter a byte of the payload. Measured on Ubuntu 24.04: `chmod +x` leaves dev, ino, size and mtime identical and moves ctime alone, so the key changed and the next launch paid a full ~519 MB re-extraction and a multi-second stall to rebuild a payload it already had, then pruned the old generation. Key on content identity instead. An in-place content change moves mtime and almost always size; a replacement moves the inode. The existing replace-in-place test still passes.
An X server writes its lock beside its socket and both survive a crash (verified against Xvfb under SIGKILL), so a socket with no lock was never left by a crashed server. It is an endpoint published from elsewhere: a container bind-mounting only /tmp/.X11-unix, WSLg, or a foreign PID namespace. Declaring those dead made the desktop gate exit(1) on displays that work, with no workaround, and the serve gate refuse to start. Liveness now splits by ownership. A foreign DISPLAY trusts a lockless socket; Orca's own :99 does not, because removeStaleDisplayArtifacts unlinks the lock before the socket and so manufactures that state itself -- adopting it would resurrect the orphan-socket bug and stop the cleanup from self-healing. The stale-lock rejection is unchanged. Also correct four doc statements this behaviour falsified.
Readiness only checked that /tmp/.X11-unix/X99 exists. A stale socket we could not unlink still exists after our own Xvfb refused to bind, so Orca set DISPLAY to a dead server and Chromium died in Ozone init. Measured on Ubuntu 24.04 against the pre-fix build: with a leftover :99 socket and no lock, serve exits 139 (SIGSEGV), the socket inode is unchanged before and after, and no lock is recreated -- it neither cleaned up nor respawned. To a user that is a crash, not a misconfiguration. This is reachable in the documented topology, where orca-xvfb.service has no User= and runs as root while serve runs as User=orca: /tmp is sticky, so the orca uid cannot unlink a root-owned socket, rmSync fails, and Xvfb exits with the display already active. Readiness now requires the display to actually be live -- our socket plus a lock naming a running process -- so the same state reports an unusable display and exits 1 with the existing diagnosis.
Two display setups this gate could not prove were refused outright, and on the desktop path that is app.exit(1) with no workaround. An X server may bind only the abstract namespace (`@/tmp/.X11-unix/X0`), which leaves no filesystem socket to stat. Abstract addresses are kernel-owned and vanish the moment the owner exits, so an entry in /proc/net/unix is proof of a live server -- no lock file needed and no stale entry possible. Verified on Ubuntu 24.04, where 139 such addresses were present. WAYLAND_SOCKET is an already-connected fd handed over by the compositor, so there is no path to stat and WAYLAND_DISPLAY may be unset entirely. Its presence is the display. Both are consulted only after the filesystem-socket check fails, so no existing verdict changes.
Recognising a lockless X socket as live is correct for an endpoint published from elsewhere -- a container bind mount, WSLg -- because an X server writes its lock beside its socket and both survive a crash. It is wrong for VIRTUAL_DISPLAY_NUMBER, because Orca's own teardown unlinks the lock before the socket and so manufactures that exact state. The managed branch was already strict, but a caller that sets DISPLAY=:99 explicitly takes the foreign path and skipped it, accepting a dead display left by Orca's own interrupted cleanup. Route the managed number through the strict probe on both paths. Found by an adversarial audit of the asymmetry introduced earlier in this branch; the documented systemd topology is unaffected because its Xvfb writes a real lock.
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: e4c07b8f-2d76-4216-9b55-cd55b93899fc
📒 Files selected for processing (130)
.github/workflows/pr.ymlconfig/docker/cli-launch-contract/Dockerfileconfig/docker/cli-launch-contract/run-cli-case.shconfig/docker/headless-pairing/Dockerfileconfig/docker/headless-serve-shutdown/Dockerfileconfig/docker/headless-serve-shutdown/run-appimage-desktop-startup-case.shconfig/docker/headless-serve-shutdown/run-signal-case.shconfig/electron-builder.config.cjsconfig/reliability-gates.jsoncconfig/scripts/build-linux-local.mjsconfig/scripts/build-linux-local.test.mjsconfig/scripts/electron-builder-config.test.mjsconfig/scripts/electron-builder-runtime-resources.test.mjsconfig/scripts/headless-serve-shutdown-workflow.test.mjsconfig/scripts/linux-package-maintainer-scripts.test.mjsconfig/scripts/orcad-operations-restart-safety.test.mjsconfig/scripts/pr-code-change-scope.mjsconfig/scripts/pr-code-change-scope.test.mjsconfig/scripts/pr-workflow-parallelism.test.mjsconfig/scripts/run-headless-serve-shutdown-docker.mjsconfig/scripts/run-linux-cli-launch-contract-docker.mjsconfig/scripts/static-appimage-package-contract.cjsconfig/scripts/static-appimage-package-contract.test.mjsconfig/scripts/verify-cli-bin.mjsconfig/scripts/verify-linux-glibc-floor.cjsconfig/scripts/verify-linux-glibc-floor.test.mjsconfig/scripts/windows-cmd-shim-spawn-boundary.test.mjsconfig/tsconfig.cli.jsondocs/reference/headless-linux-server.mddocs/reference/linux-glibc-compatibility.mddocs/reference/orcad-operations.mddocs/reference/ssh-execution-boundary.mdpackage.jsonresources/linux/bin/orca-ideresources/linux/packaging/after-remove.shsrc/cli/args.test.tssrc/cli/args.tssrc/cli/cli-command-name-parity.test.tssrc/cli/cli-version.test.tssrc/cli/cli-version.tssrc/cli/command-suggestion.tssrc/cli/handlers/core.tssrc/cli/index.tssrc/cli/runtime/launch.test.tssrc/cli/runtime/launch.tssrc/cli/runtime/serve-signal-exit-diagnostic.test.tssrc/cli/runtime/serve-update-supervisor.tssrc/cli/serve-electron-flag-parity.test.tssrc/main/cli/cli-command-installation.tssrc/main/cli/cli-installer.test.tssrc/main/cli/packaged-cli-assets.test.tssrc/main/linux-package-downloaded-status.tssrc/main/linux-package-install-command.test.tssrc/main/linux-package-install-command.tssrc/main/linux-package-install-diagnostic.test.tssrc/main/linux-package-install-diagnostic.tssrc/main/linux-package-update-recovery.test.tssrc/main/linux-package-update-recovery.tssrc/main/linux-update-package-type.test.tssrc/main/linux-update-package-type.tssrc/main/startup/appimage-cli-redirect.test.tssrc/main/startup/appimage-cli-redirect.tssrc/main/startup/cli-command-names.tssrc/main/startup/cli-launch-redirect.test.tssrc/main/startup/cli-launch-redirect.tssrc/main/startup/ensure-virtual-display.test.tssrc/main/startup/ensure-virtual-display.tssrc/main/startup/main-process-preflight.tssrc/main/startup/main-process-runtime-launch.tssrc/main/startup/main-process-serve.tssrc/main/startup/packaged-cli-entry-redirect.test.tssrc/main/startup/packaged-cli-entry-redirect.tssrc/main/startup/serve-mode-argv-cli-redirect-order.test.tssrc/main/startup/serve-mode-argv.test.tssrc/main/startup/serve-mode-argv.tssrc/main/startup/serve-options.test.tssrc/main/startup/serve-options.tssrc/main/startup/serve-signal-handlers.test.tssrc/main/startup/serve-signal-handlers.tssrc/main/startup/single-instance-lock-exit.electron.test.tssrc/main/updater-events.test.tssrc/main/updater-events.tssrc/main/updater-fallback.tssrc/main/updater-linux-package-recovery-actions.test.tssrc/main/updater-mac-install.tssrc/main/updater-test-harness.tssrc/main/updater.fallback.test.tssrc/main/updater.headless-serve-install.test.tssrc/main/updater.install-failure-cause.test.tssrc/main/updater.linux-externally-managed.test.tssrc/main/updater.linux-root-package-install.test.tssrc/main/updater.mac-install.test.tssrc/main/updater.quit-and-install.test.tssrc/main/updater.startup-scheduling.test.tssrc/main/updater/updater-build-selection.tssrc/main/updater/updater-check-failure.tssrc/main/updater/updater-check-state.tssrc/main/updater/updater-download-install.tssrc/main/updater/updater-install-execution.tssrc/main/updater/updater-install-support.tssrc/main/updater/updater-menu-checks.tssrc/main/updater/updater-package-recovery.tssrc/main/updater/updater-remote-status.tssrc/main/updater/updater-setup.tssrc/main/updater/updater-state.tssrc/renderer/src/components/LinuxPackageInstallRecoveryCard.test.tsxsrc/renderer/src/components/LinuxPackageInstallRecoveryCard.tsxsrc/renderer/src/components/UpdateCard.error-card.test.tsxsrc/renderer/src/components/UpdateCard.test.tssrc/renderer/src/components/UpdateCard.tsxsrc/renderer/src/components/UpdateErrorCardContent.tsxsrc/renderer/src/components/maintenance/update-card/UpdateAvailableCardContent.tsxsrc/renderer/src/components/maintenance/update-card/UpdateCardStateContent.tsxsrc/renderer/src/components/maintenance/update-card/update-card-error-model.tssrc/renderer/src/components/maintenance/update-card/update-card-visibility.tssrc/renderer/src/components/settings/GeneralUpdateSettingsSection.test.tsxsrc/renderer/src/components/settings/GeneralUpdateSettingsSection.tsxsrc/renderer/src/components/settings/RemoteServerUpdateStatus.tsxsrc/renderer/src/components/status-bar/UpdateStatusSegment.tsxsrc/renderer/src/i18n/locales/en.jsonsrc/shared/child-process/__fixtures__/child-process-import-allowlist.txtsrc/shared/child-process/__fixtures__/windows-console-visibility-allowlist.txtsrc/shared/child-process/child-process-import-boundary.test.tssrc/shared/child-process/windows-console-visibility.test.tssrc/shared/cli-argument-boundary.test.tssrc/shared/cli-argument-boundary.tssrc/shared/edit-distance.tssrc/shared/serve-option-validation.test.tssrc/shared/serve-option-validation.tssrc/shared/update-status-types.ts
💤 Files with no reviewable changes (8)
- src/shared/child-process/fixtures/child-process-import-allowlist.txt
- src/shared/child-process/fixtures/windows-console-visibility-allowlist.txt
- src/main/startup/appimage-cli-redirect.ts
- src/main/startup/packaged-cli-entry-redirect.test.ts
- config/docker/headless-pairing/Dockerfile
- src/main/updater/updater-state.ts
- src/main/startup/packaged-cli-entry-redirect.ts
- src/main/startup/appimage-cli-redirect.test.ts
🚧 Files skipped from review as they are similar to previous changes (94)
- src/shared/edit-distance.ts
- src/renderer/src/components/maintenance/update-card/update-card-error-model.ts
- src/renderer/src/components/status-bar/UpdateStatusSegment.tsx
- config/scripts/linux-package-maintainer-scripts.test.mjs
- src/renderer/src/components/settings/GeneralUpdateSettingsSection.test.tsx
- src/main/updater-test-harness.ts
- src/shared/cli-argument-boundary.test.ts
- src/main/updater-fallback.ts
- src/main/startup/serve-signal-handlers.test.ts
- config/scripts/verify-cli-bin.mjs
- src/cli/cli-version.ts
- package.json
- docs/reference/ssh-execution-boundary.md
- src/cli/runtime/serve-signal-exit-diagnostic.test.ts
- src/main/linux-package-install-command.ts
- config/scripts/pr-code-change-scope.test.mjs
- src/renderer/src/components/settings/RemoteServerUpdateStatus.tsx
- src/cli/cli-command-name-parity.test.ts
- src/main/updater.headless-serve-install.test.ts
- src/cli/index.ts
- config/reliability-gates.jsonc
- resources/linux/packaging/after-remove.sh
- src/cli/args.test.ts
- src/shared/cli-argument-boundary.ts
- src/main/updater.fallback.test.ts
- docs/reference/linux-glibc-compatibility.md
- config/scripts/build-linux-local.mjs
- src/renderer/src/i18n/locales/en.json
- src/main/startup/serve-options.ts
- config/scripts/pr-code-change-scope.mjs
- .github/workflows/pr.yml
- src/main/updater.mac-install.test.ts
- src/cli/args.ts
- src/cli/cli-version.test.ts
- src/main/startup/serve-signal-handlers.ts
- config/scripts/run-linux-cli-launch-contract-docker.mjs
- src/main/startup/cli-command-names.ts
- config/tsconfig.cli.json
- src/main/startup/serve-mode-argv.test.ts
- resources/linux/bin/orca-ide
- config/scripts/orcad-operations-restart-safety.test.mjs
- src/main/updater.quit-and-install.test.ts
- src/main/updater.install-failure-cause.test.ts
- src/main/startup/cli-launch-redirect.ts
- src/renderer/src/components/maintenance/update-card/UpdateCardStateContent.tsx
- src/renderer/src/components/maintenance/update-card/UpdateAvailableCardContent.tsx
- config/scripts/headless-serve-shutdown-workflow.test.mjs
- src/cli/serve-electron-flag-parity.test.ts
- config/docker/headless-serve-shutdown/Dockerfile
- src/renderer/src/components/UpdateCard.tsx
- src/renderer/src/components/settings/GeneralUpdateSettingsSection.tsx
- src/main/linux-package-update-recovery.ts
- src/main/linux-package-install-diagnostic.test.ts
- config/docker/headless-serve-shutdown/run-signal-case.sh
- src/main/linux-update-package-type.ts
- config/scripts/build-linux-local.test.mjs
- src/renderer/src/components/UpdateErrorCardContent.tsx
- src/main/linux-update-package-type.test.ts
- src/renderer/src/components/LinuxPackageInstallRecoveryCard.test.tsx
- src/main/linux-package-install-command.test.ts
- src/main/updater.linux-root-package-install.test.ts
- src/main/updater-events.test.ts
- src/main/updater-mac-install.ts
- src/main/updater.startup-scheduling.test.ts
- config/scripts/pr-workflow-parallelism.test.mjs
- docs/reference/orcad-operations.md
- src/main/linux-package-downloaded-status.ts
- src/renderer/src/components/maintenance/update-card/update-card-visibility.ts
- config/scripts/static-appimage-package-contract.test.mjs
- src/shared/serve-option-validation.ts
- src/renderer/src/components/UpdateCard.test.ts
- src/cli/command-suggestion.ts
- src/shared/update-status-types.ts
- src/main/startup/cli-launch-redirect.test.ts
- config/scripts/verify-linux-glibc-floor.cjs
- src/shared/serve-option-validation.test.ts
- config/docker/headless-serve-shutdown/run-appimage-desktop-startup-case.sh
- config/docker/cli-launch-contract/run-cli-case.sh
- src/renderer/src/components/LinuxPackageInstallRecoveryCard.tsx
- src/main/startup/serve-options.test.ts
- config/electron-builder.config.cjs
- config/scripts/run-headless-serve-shutdown-docker.mjs
- config/scripts/static-appimage-package-contract.cjs
- config/scripts/electron-builder-runtime-resources.test.mjs
- config/scripts/verify-linux-glibc-floor.test.mjs
- src/main/updater-linux-package-recovery-actions.test.ts
- src/renderer/src/components/UpdateCard.error-card.test.tsx
- src/main/updater-events.ts
- src/main/startup/serve-mode-argv.ts
- src/cli/runtime/launch.test.ts
- src/main/linux-package-update-recovery.test.ts
- src/main/startup/ensure-virtual-display.test.ts
- src/main/updater.linux-externally-managed.test.ts
- docs/reference/headless-linux-server.md
Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.
| if (inheritedFd && /^\d+$/.test(inheritedFd)) { | ||
| return true |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- repository conventions and learnings ---'
find /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4 -maxdepth 2 -type f -name '*.md' -print
printf '%s\n' '--- target source ---'
cat -n src/main/startup/ensure-virtual-display.ts | sed -n '1,155p;185,220p'
printf '%s\n' '--- direct caller ---'
cat -n src/main/startup/main-process-preflight.ts | sed -n '95,125p'
printf '%s\n' '--- relevant scoped guidance ---'
for f in /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/*/*.md; do
case "$f" in
*conventions*/*|*learnings*/*|*architecture/*)
printf '\n--- %s ---\n' "$f"
cat "$f"
;;
esac
doneRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- helper implementation and nearby contracts ---'
cat -n src/main/startup/ensure-virtual-display.ts | sed -n '150,220p'
printf '%s\n' '--- references and tests ---'
rg -n -C 4 'hasUsableWaylandDisplay|hasUsableLinuxDisplay|WAYLAND_SOCKET|fstatSync' src tests package.json
printf '%s\n' '--- applicable conventions ---'
cat /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions/src-main-daemon.md
cat /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions/repo-wide.md | sed -n '1,180p'
printf '%s\n' '--- relevant learnings ---'
for f in /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings/src-main.md /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings/repo-wide.md; do
printf '\n--- %s ---\n' "$f"
cat "$f"
doneRepository: stablyai/orca
Length of output: 48105
🌐 Web query:
Node.js fs fstatSync file descriptor Stats isSocket throws invalid file descriptor official documentation
💡 Result:
The fs.fstatSync(fd) method in Node.js does not directly throw an "invalid file descriptor" error inside its isSocket check [1][2]. Rather, if you provide an invalid file descriptor (an integer that does not refer to an open file or resource), fs.fstatSync(fd) itself will throw an error with the code 'EBADF' (Bad File Descriptor) [3][4]. Here is the breakdown of why this occurs: 1. fs.fstatSync(fd) expects a valid, open file descriptor [5]. If the descriptor is invalid, the operation fails at the system level, and Node.js throws an Error: EBADF: bad file descriptor [3][4]. 2. Because fs.fstatSync(fd) throws this exception before returning a result, you never reach the stage of calling any methods on the returned object (such as.isSocket) [3][6]. 3. The isSocket method is a property of the fs.Stats object that is returned only after a successful fstatSync call [7][6]. It simply returns a boolean indicating if the stats object describes a socket [8][6]. To handle cases where a file descriptor might be invalid, you should wrap the call in a try...catch block to catch the EBADF error [3][4]. Example: try { const stats = fs.fstatSync(fd); if (stats.isSocket) { // Handle socket } } catch (err) { if (err.code === 'EBADF') { // Handle invalid file descriptor } else { throw err; } } There is no "invalid file descriptor" error triggered by the isSocket method itself; if the code reaches isSocket, the file descriptor was valid at the time the stats were retrieved [3][6].
Citations:
- 1: https://nodejs.org/api/fs.html
- 2: https://beta.docs.nodejs.org/fs.html
- 3: GitHub issue 6111 in Unitech/pm2 (link omitted to avoid creating a cross-reference)
- 4: https://stackoverflow.com/questions/68611356/getting-bad-file-descriptor-error-while-using-fs-openfilesync-in-node-js
- 5: GitHub issue 6109 in nodejs/node (link omitted to avoid creating a cross-reference)
- 6: https://www.geeksforgeeks.org/node-js/node-js-stat-issocket-method/
- 7: https://r2.nodejs.org/docs/v7.1.0/doc/api/fs.html
- 8: https://bun.com/reference/node/fs/Stats/isSocket
Validate the inherited Wayland file descriptor.
When WAYLAND_SOCKET contains digits, hasUsableWaylandDisplay returns true without checking the descriptor. A closed or non-socket descriptor can bypass hasUsableLinuxDisplay and allow packaged startup without a usable display. Use fstatSync(Number(inheritedFd)).isSocket() inside try/catch, and return false when fstatSync throws. Add a regression test for a closed descriptor.
🧰 Tools
🪛 ast-grep (0.45.2)
[warning] Importing child_process exposes a command-execution surface; ensure any command/argument built from input is validated, and prefer execFile/spawn with an argument array over exec.
Context: import { spawn, type ChildProcess } from 'node:child_process'
Note: [CWE-78] Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').
(detect-child-process-typescript)
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
The prior review flagged the PR as unmergeable against main (12 conflicts across structural files, two of them modify/delete). This run reviewed the conflict resolution: the merge commit lands the already-reviewed nine-PR Linux packaging stack onto main's split updater, plus two mechanical follow-ups.
- Merge resolution — took
main's side on the structural files and re-applied the stack's behavior into the new modules: the deb/rpm/unusableinstall gate inupdater-install-execution.ts, the externally-managed download gate inupdater-download-install.ts,autoInstallOnAppQuitgated tonon-rootinupdater-setup.ts, themanual-service-update-requiredremote status inupdater-remote-status.ts, and the retained manual-install card viasendSettledCheckStatusinupdater-check-state.ts. - Pre-
readystartup port — the four pre-ready changes moved intomain-process-preflight.ts(singlemaybeRedirectCliLaunchbefore the serve-argv rewrite, the packaged non-serve display gate, the serve Xvfb gate), and validated serve options re-exported fromserve-options.ts. appimage-cli-redirect.tsdelete accepted —cli-launch-redirect.ts:121-122never redirectsserve, so #17633's "keep Chromium switches out of the CLI redirect" concern is subsumed rather than lost;serve-mode-argv-cli-redirect-order.test.tspins--disable-features=Vulkan servestaying in-process.- Ratchet re-pins —
child_processimport boundary 160→158 and windows-console-visibility 68→66, plus the batch-shim allowlist entries forbuild-linux-local.mjs.
I verified the four load-bearing behaviors carry over intact (install refusal, download refusal, remote-status refusal, retained card) and that the three deleted redirect files leave no dangling references.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
Verified and merging. CI green (29 pass), Independently confirmed before merge, since the risk here was a silent drop rather than a visible break:
The catch that greps alone would have missed: Also landed four semantic changes the original brief did not enumerate — notably The one judgement call worth recording: the dead-code removal was traced rather than assumed — |
stablyai#18100 landed `isExternallyManagedLinuxInstall()`, which the PR body previously noted would compose cleanly here. It does. Repackagers (AUR, Nix, container rebuilds) unpack Orca's .deb and inherit its `package-type` marker verbatim, so a `deb` marker on a host with no dpkg/apt describes the artifact Orca was built as, never the system that owns the install. Reporting `deb` there sent the operator to the Orca release page for a package their host could never apply. The status contract now reports `externally-managed` and names the package manager that installed Orca as the upgrade owner instead. No command is emitted for these hosts, because none of ours is applicable. The install command itself was already safe -- `buildLinuxPackageInstallCommand` returns `no-package-manager` on such a host and fell through to the documented procedure -- so this corrects the reported method and the advice, not a command.
…#18100) * fix(linux): give the CLI one entrypoint by extracting the AppImage once * refactor(linux): trim AppImage CLI registration seams * test(cli): assert registration lock serialization * fix(linux): fence AppImage terminal shim mounts * fix(linux): accept extracted AppImage runtimes with APPDIR only * docs(linux): make headless AppImage extraction runnable * refactor(linux): import bundled launcher directly * fix(linux): reclaim superseded AppImage payloads and packaged symlinks Pruning removed 3215 of 3216 files from a superseded generation and always stranded resources/app.asar, leaking ~105 MB per version update. Electron's asar shim reports a *.asar file as a directory, so the recursive remove tried to rmdir a real file and failed with ENOTEMPTY; the .catch(() => {}) hid it. Reproduced end to end on Ubuntu 24.04: 519M -> 623M across one update, and 519M again once the payload is actually reclaimed. removeExtractedAppImagePayload holds process.noAsar for the removal, counted so overlapping removals cannot hand the shim back early, and the prune site now warns with the path instead of swallowing the rejection. All three removal sites use it -- staging cleanup and displaced roots leaked the same way. Also reclaim symlinks left by a packaged deb/rpm install, which the extracted-cache-only rule turned into a hard conflict on a deb -> AppImage migration, and name the remedy in the conflict error. * fix(linux): bound the CLI registration lock wait `retries: 1000` caps the attempt count, not elapsed time, so at up to 1s per attempt an IPC-driven registration could hang ~16 minutes against a wedged holder with no feedback. A legitimate holder is bounded by the extraction timeout, so wait that plus slack and then fail with a message naming the lock file, rather than hanging. `maxRetryTime` is forwarded verbatim to the `retry` package by proper-lockfile. * fix(linux): stop re-extracting the AppImage on inode metadata churn The extracted-payload cache key hashed ctime alongside dev/ino/size/mtime. ctime moves on any inode metadata write -- `chmod +x`, which every AppImage user is told to run, plus `chown`, an ACL or SELinux relabel, and a backup restore -- none of which alter a byte of the payload. Measured on Ubuntu 24.04: `chmod +x` leaves dev, ino, size and mtime identical and moves ctime alone, so the key changed and the next launch paid a full ~519 MB re-extraction and a multi-second stall to rebuild a payload it already had, then pruned the old generation. Key on content identity instead. An in-place content change moves mtime and almost always size; a replacement moves the inode. The existing replace-in-place test still passes. * fix(linux): stop CLI commands from falling through to Chromium startup * refactor(cli): remove redundant command membership check * test(cli): cover command-named project selectors * fix(cli): redirect the open-url command before startup * test(linux): cover AUR serve wrapper flags * fix(linux): tighten CLI launch detection * fix(linux): respect CLI flag value boundaries * fix(linux): strip injected Chromium switches from CLI args * fix(linux): report a missing display instead of dying in uv_close * refactor(linux): read display locks without a preflight race * fix(linux): preserve unverified external displays * chore: format reliability gate manifest * test(packaging): split runtime resource checks * fix(linux): fail serve when no display is available * fix(linux): do not treat a lockless X socket as a dead display An X server writes its lock beside its socket and both survive a crash (verified against Xvfb under SIGKILL), so a socket with no lock was never left by a crashed server. It is an endpoint published from elsewhere: a container bind-mounting only /tmp/.X11-unix, WSLg, or a foreign PID namespace. Declaring those dead made the desktop gate exit(1) on displays that work, with no workaround, and the serve gate refuse to start. Liveness now splits by ownership. A foreign DISPLAY trusts a lockless socket; Orca's own :99 does not, because removeStaleDisplayArtifacts unlinks the lock before the socket and so manufactures that state itself -- adopting it would resurrect the orphan-socket bug and stop the cleanup from self-healing. The stale-lock rejection is unchanged. Also correct four doc statements this behaviour falsified. * fix(linux): fail closed when a stale socket blocks the Xvfb rebind Readiness only checked that /tmp/.X11-unix/X99 exists. A stale socket we could not unlink still exists after our own Xvfb refused to bind, so Orca set DISPLAY to a dead server and Chromium died in Ozone init. Measured on Ubuntu 24.04 against the pre-fix build: with a leftover :99 socket and no lock, serve exits 139 (SIGSEGV), the socket inode is unchanged before and after, and no lock is recreated -- it neither cleaned up nor respawned. To a user that is a crash, not a misconfiguration. This is reachable in the documented topology, where orca-xvfb.service has no User= and runs as root while serve runs as User=orca: /tmp is sticky, so the orca uid cannot unlink a root-owned socket, rmSync fails, and Xvfb exits with the display already active. Readiness now requires the display to actually be live -- our socket plus a lock naming a running process -- so the same state reports an unusable display and exits 1 with the existing diagnosis. * fix(linux): recognise abstract X sockets and inherited Wayland fds Two display setups this gate could not prove were refused outright, and on the desktop path that is app.exit(1) with no workaround. An X server may bind only the abstract namespace (`@/tmp/.X11-unix/X0`), which leaves no filesystem socket to stat. Abstract addresses are kernel-owned and vanish the moment the owner exits, so an entry in /proc/net/unix is proof of a live server -- no lock file needed and no stale entry possible. Verified on Ubuntu 24.04, where 139 such addresses were present. WAYLAND_SOCKET is an already-connected fd handed over by the compositor, so there is no path to stat and WAYLAND_DISPLAY may be unset entirely. Its presence is the display. Both are consulted only after the filesystem-socket check fails, so no existing verdict changes. * fix(linux): never treat Orca's own display number as a foreign endpoint Recognising a lockless X socket as live is correct for an endpoint published from elsewhere -- a container bind mount, WSLg -- because an X server writes its lock beside its socket and both survive a crash. It is wrong for VIRTUAL_DISPLAY_NUMBER, because Orca's own teardown unlinks the lock before the socket and so manufactures that exact state. The managed branch was already strict, but a caller that sets DISPLAY=:99 explicitly takes the foreign path and skipped it, accepting a dead display left by Orca's own interrupted cleanup. Route the managed number through the strict probe on both paths. Found by an adversarial audit of the asymmetry introduced earlier in this branch; the documented systemd topology is unaffected because its Xvfb writes a real lock. * test(linux): add a packaged-artifact contract for the CLI launch paths * test(linux): avoid buffered serve readiness detection * test(linux): signal AppImage serve owner directly * test(linux): tolerate readiness timeout boundary * test(linux): add startup margin to shutdown oracle * ci(linux): give package contracts timeout headroom * fix(ci): route all Linux packaging contract changes * test(linux): poll shutdown readiness without tail leaks * test(linux): bound shutdown cleanup grace * test(linux): assert on CLI output, not the harness's own control lines run-cli-case.sh echoes `RESULT status=N case=<name>`, and the two cases named *-skills asserted `expectOutput: 'skills'`. That substring was satisfied by the case name in the harness's own line, so 2 of 8 cases asserted nothing about the command -- gutting `skills` entirely would still have gone green. Control lines are now excluded before matching, and both cases assert the rendered help header, which only real help output produces. Verified on an Ubuntu 24.04 host: 8/8 still pass against a stack-tip AppImage. Also register the gate in reliability-gates.jsonc, which stablyai#15085 added a CI Docker gate without. Red/green is recorded from a stock release AppImage failing 4 of 8, three of them at status 133 (SIGTRAP). * fix(linux): require static AppImage runtimes (stablyai#17319) * test(linux): reject a wrong-architecture native binary at packaging time Cross-building the arm64 slice on an x64 host silently packed an x86-64 `pty.node` -- the rebuild logged "Forcing native rebuild for linux-arm64" and shipped the host's binary anyway. Every gate here inspects symbol versions, which are perfectly valid on the wrong architecture, so nothing noticed. Observed on a Raspberry Pi 5: the packaged app loaded, then failed with "Failed to load native module: pty.node", and the launch contract reported 3 of 8 cases crashed rather than naming the cause. Swapping in the aarch64 `pty.node` took the same build to 8/8. Compare ELF `e_machine` against the slice being packaged and fail with the offending path. Checked before the glibc pass, because a wrong-architecture binary's symbol versions are valid but meaningless and would send the reader down the wrong path. Release CI builds arm64 on a native runner, so this guards local and future cross-builds rather than a shipped artifact. * test(linux): judge per-arch vendored binaries against their own path The first CI run of the architecture gate failed the x64 package job on `@parcel/watcher-linux-arm64-glibc/watcher.node`. That binary is arm64 on purpose: the package ships every architecture and its loader picks the match, so its presence in an x64 build is correct. Judge a binary against the architecture its own path names, falling back to the slice when the path names none. That keeps the case this gate exists for -- `bin/linux-arm64-*/node-pty.node` holding an x86-64 binary, which is what shipped to a Raspberry Pi 5 -- while letting multi-arch dependencies through. Dry-run over the real dependency tree flags nothing for either target arch. * fix(linux): move deb/rpm update installation outside Orca (stablyai#17318) * fix(linux): complete deb/rpm package metadata * fix(linux): preserve CLI link during package upgrades * docs(linux): document local RPM build prerequisites * fix(linux): move deb/rpm update installation outside Orca * fix(updater): preserve Linux recovery across stale events * fix(updater): fence stale downloaded events by active target * fix(updater): preserve active Linux package recovery * test(linux): keep workflow order assertion in scope * test(updater): assert stale recovery stays silent * fix(updater): preserve Linux package recovery after checks * refactor(updater): keep Linux marker message with status * fix(linux): describe the right manual update path for deb/rpm hosts A remote host installed from .deb or .rpm now reports manual-service-update-required, and the guidance told the operator to "update through the service manager that starts this server" -- which is correct for unsupported-headless-serve but wrong for a package install, where nothing about the remedy involves the service manager. Say both, keyed on how the host was installed. * docs(linux): document orcad update restart safety * docs(linux): scope restart census omissions * docs(linux): use absolute service CLI launcher * fix(serve): validate in-process serve options before startup (stablyai#17683) * fix(linux): stop offering updates a distro-managed install cannot apply (stablyai#17918) Closes stablyai#17702. The resources/package-type marker is authoritative but never checked against the host, so any repackager that unpacks Orca's .deb -- AUR, Nix, a container rebuild -- inherits `deb` verbatim. Install feasibility was then computed after a ~165 MB download, so those users got check -> download -> a card promising an install command -> a dead end. Validate the marker against the host: a deb/rpm marker with no matching package manager in the trusted directories means a package manager owns this install. This reuses the exact lists and resolver that buildLinuxPackageInstallCommand already loops over, so a false positive is impossible by construction -- any host flagged here would have failed with no-package-manager after the download anyway. The gate only moves that verdict earlier. Verified across Debian 12, Ubuntu 24.04, Arch, Fedora 40 and openSUSE Leap: no false positive on a real deb host, correct on every repackaging host. The release is still reported, because the user does want to know 1.4.194 exists and to update through their distro; only the download path is closed. `externallyManaged` is an additive optional field on the existing `available` status, so older paired clients decode it unchanged. downloadUpdate() refuses authoritatively, since main owns this verdict rather than the card, and unwinds any pinned-build state first -- a Linux pinned jump resolves to 'release', and stranding isPinnedBuildActive would silently kill every background check for the rest of the process. Note the fix the issue suggests cannot work: electron-updater builds a PacmanUpdater whose doDownloadUpdate looks for a .pacman asset Orca does not publish, then dereferences undefined. * style(cli): restore prettier wrapping on install error copy * test(linux): re-pin the child-process ratchets and the batch-shim allowlist after the merge

ELI5
The nine-PR Linux packaging stack is all reviewed and merged — but each PR merged into the branch below it, and only the first one (#15081) ever reached
main. So the remaining work is sitting in a chain of branches with nothing pointing it atmain. This PR is that pointer.Since the stack was cut,
mainlandedrefactor(main): split backend services and startup, which brokesrc/main/updater.ts(2229 lines) into a 94-line facade plus 12 modules undersrc/main/updater/, and moved the pre-readystartup phase out ofsrc/main/index.tsintosrc/main/startup/main-process-preflight.ts. The stack edited the monoliths. This PR therefore ports the stack onto that refactor rather than merging against it.What this lands
WAYLAND_SOCKET, Xvfb ownership)How the merge was resolved
32 conflict hunks across 12 files.
Structural files — took
main's side, then re-applied the stack's behaviour into the new modules:src/main/updater.ts— tookmain's 94-line facade. All of the stack'supdater.tsbehaviour was re-applied insidesrc/main/updater/:updater-remote-status.ts(deb/rpm/unusablenow also yieldautomatic: false, reason: 'manual-service-update-required')quitAndInstallrefusal →updater-install-execution.ts(hard return fordeb/rpmbefore any install,updater:quitAndInstallAbortedto the renderer, lifecycle event;unusableadditionally sendsLINUX_PACKAGE_MARKER_UNUSABLE_MESSAGE)updater-download-install.ts(clearAvailableUpdateContext()andrestoreReleaseUpdateSource()before the error status, and norecoveryobject)autoInstallOnAppQuit→updater-setup.ts, gated togetLinuxPackageType() === 'non-root'sendSettledCheckStatusinupdater-check-state.ts, used fromupdater-check-failure.ts,updater-menu-checks.ts,updater-build-selection.tsshell.showItemInFolder→updater-package-recovery.tsproveRetainedLinuxPackage,buildLinuxPackageInstallFailureStatus, install-stderr capture) removed, as on the stack — it is unreachable once the gate hard-returnssrc/main/index.ts— tookmain's 115-line entrypoint; the stack's four pre-readychanges moved intosrc/main/startup/main-process-preflight.ts(singlemaybeRedirectCliLaunch, packaged non-serve display gate, serve Xvfb gate)src/main/startup/main-process-serve.ts— now re-exports the validatedgetServeOptionsfromsrc/main/startup/serve-options.ts(fix(serve): validate in-process serve options before startup #17683) instead of carrying its own unvalidated copysrc/main/startup/appimage-cli-redirect.{ts,test.ts}(delete/modify): accepted the delete.mainadded #17633 (keepservein Electron when--disable-featuresprecedes it) to a file this stack deletes. The replacement never redirectsserveat all —cli-launch-redirect.ts:121-122— so the bug cannot occur, andserve-mode-argv-cli-redirect-order.test.tsalready exercises--disable-features=Vulkan serve ….Mechanical files:
cli-installer.ts/wsl-cli-installer.tstookmain's side (formatting only);cli-command-installation.tstook the stack's side (real change) and was re-formatted; the three source-text assertion tests were re-pointed atmain-process-preflight.ts.Verification
pnpm tcclean.pnpm test src/main/cli src/main/startup src/main/updater src/main/linux-package src/cli— 2051 passed, 13 skipped, 0 failed (210 files).pnpm test src/main src/shared— 37038 passed, 10 failed across 9 files, none from this change. 8 of those files pass in isolation (electron/browser-egress, codex, ssh, native-chat, rpc-fuzz and a perf assertion — all load-sensitive, and this machine runs many suites in parallel). The 9th,src/main/runtime/automation-change-publication.test.ts, fails in isolation too — but it fails identically onorigin/main(same test, same 30s timeout), so it is pre-existing. No failing file is in this PR's import graph.pnpm run check:code-quality:changed— 0 new findings across 103 changed files.oxlint,oxfmt --check, max-lines / ts-nocheck / runtime-electron / reliability-gate ratchets all clean.isExternallyManagedLinuxInstall,hasAbstractXSocket,isManagedDisplayServerAlive,declaredArchFromPath,removeExtractedAppImagePayload,DESKTOP_FLAGS,hasTrustedPackageManagerFor.Exercised on real hardware (Ubuntu 24.04 x64 and a Raspberry Pi 5 arm64) throughout the stack: the 8-case launch contract passes 8/8 on the fixed build and fails 4/8 against a pre-stack release (three at SIGTRAP), and all four display-gate directions were verified against pre-fix controls.
Merge-integration changes beyond the stack
Three small changes exist only because of the merge, not in any reviewed PR:
src/shared/child-process/child-process-import-boundary.test.tsandwindows-console-visibility.test.ts— ratchet pins lowered 160→158 and 68→66. The stack deletes files that were offenders; the tests instruct exactly this.config/scripts/windows-cmd-shim-spawn-boundary.test.mjs—build-linux-local.{mjs,test.mjs}added to the batch-shim allowlist alongside the existingbuild-mac-local.mjsentry, which has the identicalplatform === 'win32' ? 'pnpm.cmd' : 'pnpm'shape. That guard landed onmainafter the stack was cut.serve-mode-argv-cli-redirect-order.test.tskeepsmain's preflight-ordering source assertion, rewritten for the singlemaybeRedirectCliLaunch; the stack had dropped it when it collapsed the two redirects.User-facing regressions
Carried forward from the individual PRs, unchanged:
ExecStartexpands to a bare--port(e.g.--port ${ORCA_PORT}with the variable unset) now exits 1 instead of silently defaulting. This is the deliberate cost of the validation; the error names the flag.~/.local/bin/orca-ideis removed.orca serveexits 1 rather than running degraded whenDISPLAYis set but not verifiably live; unsetDISPLAYto let Orca start its own Xvfb.Everything else in the stack is net-neutral or a fix.