Repository navigation
fix(linux): keep extracted AppImage copies that something still runs from - #28002
Conversation
…from New builds extract into a namespace that pre-lease builds never prune. Pruners now delete a generation only when no same-user process runs from it and no lease names a live process (pid, start ticks, boot id). Co-Authored-By: Claude <[email protected]>
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to On Linux AppImage installs, cache cleanup can delete an extracted copy that a running command-line process still uses if that process's details cannot be read. That process may then crash. Resolve this, or explicitly accept the tradeoff, before merging. Pre-merge checks |
|
Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
1cb9726c-930e-4594-b564-b88bfdc7c078
📒 Files selected for processing (2)
src/main/cli/appimage-generation-residency.test.tssrc/main/cli/appimage-generation-residency.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
| // Exited mid-scan: not a resident. Denied: a non-dumpable process, which /proc reports as | ||
| // root-owned and which root without CAP_SYS_PTRACE cannot read; Orca's own processes are | ||
| // dumpable and also hold leases. Anything else could hide a resident. | ||
| if (!['ENOENT', 'ESRCH', 'EACCES', 'EPERM'].some((code) => hasErrorCode(error, code))) { |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Keep same-user permission failures unverifiable. When readExe(pid) returns EACCES or EPERM after ownerUid(pid) === uid, the scan cannot establish where that process runs. Ignoring the failure can produce exited, which permits pruning to delete the generation if lease inspection also reports exited.
src/main/cli/appimage-generation-residency.ts#L53-L53: record permission failures for same-user processes as unreadable; retain the existing owner check for processes reported as another user.src/main/cli/appimage-generation-residency.test.ts#L53-L59: expectunverifiablefor the same-user permission-error fixtures.
📍 Affects 2 files
src/main/cli/appimage-generation-residency.ts#L53-L53(this comment)src/main/cli/appimage-generation-residency.test.ts#L53-L59
ELI5
On Linux, the AppImage version of Orca unpacks itself once into
~/.cache/orca/appimageso that theorcacommand,orca serveand the terminal daemon can run from files that stay put. Old Orca builds tidy that folder by deleting every unpacked copy except their own, even a copy that a newer Orca is still running from. This PR moves new copies to a folder that old builds never tidy. New builds now only delete a copy once they can prove nothing is running from it.What Changed
sha256(AppImage path). Any build that registers the CLI or startsservedeletes every other copy in that folder, apart from the one theinstalledlink points at. If something is running from a deleted copy, it crashes the next time it loads a file./proc/<pid>/exe.serveor the terminal daemon runs from a copy, it writes a small lease file to<cache>/leases. The lease records the process's pid, its start time (Linux start ticks) and the boot id. A different start time means the pid was reused. A different boot id means the machine rebooted. Either one makes the lease stale, and the pruner deletes it./procor a lease holder cannot be read, the copy is kept.installedlink that points into the old folder for the same AppImage path now counts as this AppImage's own, not another AppImage's. So removing or re-registering the CLI after an update works as before.docs/reference/appimage-extraction-cache.md, including what remains exposed. If you roll back to a pre-change build, it can still delete copies in the old folder, which only pre-change builds create. It cannot reach the new one.headless-serve-shutdown, which runs extract-and-run serve in a container, now asserts that the real AppImage registers its CLI copy outside the old folder.Why
/procis the ground truth for this user's processes. It also covers short CLI runs and anything started by older builds. The lease adds a record that does not depend on/procvisibility, with the start time recorded, as the design asked for.macOS, Windows, and Linux .deb/.rpm are unchanged. Every new path checks that it is on Linux and that the program runs from
<cache>/<key>/<key>/orca-ide, and returns early otherwise.Linked Issue
Part of #17322: it protects copies that are in use from being pruned. Extraction markers are still time-based, so #17322 stays open for that.
Visual Proof
N/A. Nothing visible changes. This only affects cache housekeeping on Linux AppImage.
Testing
installedcopies are kept;(deleted)executable, being kept;pnpm tc,oxlint,pnpm lint,pnpm run check:code-quality:changed.Notes
Checklist
pnpm lint,pnpm typecheckpass locally; CI covers the rest