Skip to content

docs(headless-server): add upgrade SOP for orca serve on Linux - #9575

Merged
OrcaWin merged 3 commits into
stablyai:mainfrom
PannenetsF:yq/bold-goldwasser-76c373
Jul 21, 2026
Merged

OrcaWin merged 3 commits into
stablyai:mainfrom
PannenetsF:yq/bold-goldwasser-76c373

Conversation

@PannenetsF

Copy link
Copy Markdown
Contributor

What

Adds an Upgrade section (with a step-by-step SOP) to docs/reference/headless-linux-server.md, plus one Troubleshooting bullet. The guide previously covered install / foreground run / systemd but had no upgrade path, leaving operators to guess how to move to a new AppImage without losing state.

Why

orca serve never auto-updates in headless mode (the built-in updater only runs in the desktop GUI, and no paired client can trigger it remotely), so upgrading is always a manual step that deserves a documented, safe procedure.

Contents

  • State is independent of the binary. Persisted data lives under the service user's ~/.config/ (Orca uses both an orca and an Orca directory), independent of /opt/orca. orca-data.json is forward-migrated on load, so a forward upgrade needs no manual data step.
  • Atomic binary replace. Download to .new on the same filesystem, verify, then mv — never curl -o over the FUSE-mounted live binary (it can crash/corrupt the running process; a failed download can also clobber a working binary).
  • Rollback is not binary-only safe — called out explicitly. An older build silently strips newer orca-data.json fields it doesn't recognize, and the .bak.* ring is corruption-recovery, not a pre-upgrade copy. So the SOP backs up the whole .config before upgrading and requires restoring it (not just swapping the binary) to roll back cleanly.
  • No headless version command — documents tracking the release tag instead of a nonexistent --version.

Verification

Every technical claim in the SOP was verified against the codebase before writing (updater wiring in serve mode, Orca server ready: startup line, userData paths, migration/downgrade behavior, AppImage FUSE mount semantics), then the written SOP was adversarially reviewed for command correctness and data-loss traps.

Docs-only change; no code paths affected.

🤖 Generated with Claude Code

The headless Linux guide covered install/run/systemd but had no upgrade
section, leaving operators to guess how to move to a new AppImage without
losing state.

Add an "Upgrade" section documenting the manual SOP (serve mode never
auto-updates) and one troubleshooting bullet:

- State lives under the service user's ~/.config (orca + Orca dirs),
  independent of /opt/orca, and orca-data.json is forward-migrated on load,
  so a forward upgrade is safe.
- Replace the binary with an atomic same-filesystem rename (download to
  .new, verify, mv) — never curl -o over the FUSE-mounted live binary.
- Back up the whole .config before upgrading, because rollback is NOT
  binary-only safe: an older build strips newer orca-data.json fields it
  doesn't recognize, and the .bak.* ring is corruption-recovery, not a
  pre-upgrade copy.
- Note there is no headless version command; track the release tag instead.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds headless Linux documentation for prerequisites, dedicated service ownership, manual AppImage upgrades, persistent configuration migration, version recording, download validation, atomic installation, service verification, rollback of both configuration and binary, and troubleshooting for post-upgrade crash-loops.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the change, but it omits most required template sections, including Summary, Screenshots, Testing, AI Review Report, Security Audit, and Notes. Reformat it to the repo template and add the missing sections, or state 'No visual change' and document testing, AI review, security audit, and notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the doc-only change: adding an upgrade SOP for headless Linux server use.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

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: 3


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 03603ce2-d008-4635-a49f-66141955021b

📥 Commits

Reviewing files that changed from the base of the PR and between d9d939a and 92b3792.

📒 Files selected for processing (1)
  • docs/reference/headless-linux-server.md

Comment thread docs/reference/headless-linux-server.md Resolved
Comment thread docs/reference/headless-linux-server.md Resolved
Comment thread docs/reference/headless-linux-server.md Resolved
@AmethystLiang
AmethystLiang requested a review from Jinwoo-H July 20, 2026 18:25
@AmethystLiang AmethystLiang assigned OrcaWin and unassigned Jinwoo-H Jul 20, 2026
@AmethystLiang
AmethystLiang requested review from OrcaWin and removed request for Jinwoo-H July 20, 2026 18:35
hiBDFY11Qsa2a and others added 2 commits July 21, 2026 08:52
Address CodeRabbit review on stablyai#9575:

- Fail closed: run the upgrade block under `set -euo pipefail`, remove any stale
  `.new` file before download, and gate the atomic `mv` on an explicit ELF check
  so a failed/partial/non-ELF download can never be promoted.
- Keep /opt/orca/VERSION tied to the installed binary: a single `TAG` variable
  drives both the download URL and the recorded VERSION, saved as VERSION.prev on
  upgrade and restored on rollback so the audit file never drifts.
- Crash-loop troubleshooting now points to Roll back first (restores the
  pre-upgrade orca-data.json) instead of re-running Upgrade.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

@OrcaWin OrcaWin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for adding the missing headless upgrade path. I tightened the SOP before landing:

  • stage and validate the architecture-matched AppImage while the server remains online
  • keep /opt/orca root-owned and rollback generations private and self-contained
  • restore only Orca profile directories with guarded failure recovery and explicit retention
  • direct crash-looping upgrades to rollback instead of overwriting the known-good generation

The documented Bash paths and failure boundaries have been validated.

@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: 3

🧹 Nitpick comments (1)
docs/reference/headless-linux-server.md (1)

59-66: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Lock down the service user’s home directory explicitly.

The service state includes paired-device keys and other persistent data, but this setup relies on distro-specific useradd home permissions. Explicitly restrict /home/orca so local users cannot traverse or read the service profile.

Proposed hardening
 sudo useradd --system --create-home --shell /usr/sbin/nologin orca
+sudo chmod 700 /home/orca
 sudo chown root:root /opt/orca /opt/orca/orca-linux.AppImage

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 84d148e7-78e1-4841-ac6b-b97ae1954fe7

📥 Commits

Reviewing files that changed from the base of the PR and between 082aca3 and c3e5e2b.

📒 Files selected for processing (1)
  • docs/reference/headless-linux-server.md

Comment on lines +192 to +198
### Record the version you deploy

Orca has no headless version command: there is no `--version` flag or `version`
subcommand, and `orca serve` prints only its endpoint. Choose a release tag
explicitly instead of following the `latest` URL, and record it next to the
binary so upgrades are auditable. The steps below keep that record in
`/opt/orca/VERSION`.

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.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Initialize VERSION during the initial installation too.

The installation flow still downloads releases/latest at Lines 25-26 without writing /opt/orca/VERSION. Consequently, the first rollback bundle can contain the prior binary but no matching release metadata, weakening auditability and the documented rollback contract. Pin the initial install to the same explicit release-tag flow and create VERSION before starting the service.

Comment on lines +216 to +218
# Clear predictable staging names left by an older attempt after locking the directory
sudo rm -f /opt/orca/orca-linux.AppImage.new /opt/orca/VERSION.new \
/opt/orca/orca-linux.AppImage.recovering /opt/orca/VERSION.recovering

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.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

file='docs/reference/headless-linux-server.md'

echo '--- targeted ranges ---'
sed -n '200,245p' "$file"
echo
sed -n '390,415p' "$file"
echo
echo '--- search for locking / serialization mentions ---'
rg -n --hidden --no-ignore-vcs 'upgrade\.lock|flock|serialize|concurrent|staging paths|\.ready|\.new|recovering|rollback' docs/reference/headless-linux-server.md docs || true

Repository: stablyai/orca

Length of output: 20053


🏁 Script executed:

#!/bin/bash
set -euo pipefail

file='docs/reference/headless-linux-server.md'

echo '--- upgrade section around staging/rename ---'
sed -n '245,370p' "$file"

echo
echo '--- rollback section around bundle selection/restoration ---'
sed -n '400,520p' "$file"

Repository: stablyai/orca

Length of output: 8823


🏁 Script executed:

#!/bin/bash
set -euo pipefail

file='docs/reference/headless-linux-server.md'

echo '--- line-numbered excerpt around 216-231 ---'
nl -ba "$file" | sed -n '210,235p'

echo
echo '--- line-numbered excerpt around 402-407 ---'
nl -ba "$file" | sed -n '398,410p'

Repository: stablyai/orca

Length of output: 236


Serialize upgrade and rollback operations. Both scripts use fixed /opt/orca/*.new staging paths, so overlapping runs can clobber the in-flight binary/version pair and leave a mismatched deployment. Acquire an exclusive lock before cleanup/staging and hold it through the service restart in both scripts.

Proposed locking pattern
 set -euo pipefail
+exec 9>/opt/orca/.upgrade.lock
+flock -n 9 || {
+  echo 'Another Orca upgrade or rollback is already running' >&2
+  exit 1
+}

Comment on lines +379 to +387
```bash
shopt -s nullglob
ORCA_ROLLBACK_SETS=(/opt/orca/orca-rollback-*.ready)
((${#ORCA_ROLLBACK_SETS[@]} > 0))
ORCA_ROLLBACK=${ORCA_ROLLBACK_SETS[${#ORCA_ROLLBACK_SETS[@]} - 1]}
printf 'Removing rollback bundle: %s\n' "$ORCA_ROLLBACK"
sudo test -d "$ORCA_ROLLBACK"
sudo rm -rf -- "$ORCA_ROLLBACK"
```

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

Abort explicitly when no rollback bundle exists.

With nullglob, the array can be empty. The arithmetic expression only returns a nonzero status; this standalone cleanup snippet does not necessarily stop there, so it can continue with an empty ORCA_ROLLBACK and emit misleading failures. Add an explicit guard before indexing the array.

@OrcaWin
OrcaWin merged commit aad34cb into stablyai:main Jul 21, 2026
1 check passed
@AmethystLiang AmethystLiang added the orca-remote-server Remote Orca Server / orca serve / paired remote runtime label Jul 22, 2026
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…yai#9575)

* docs(headless-server): add upgrade SOP for orca serve on Linux

The headless Linux guide covered install/run/systemd but had no upgrade
section, leaving operators to guess how to move to a new AppImage without
losing state.

Add an "Upgrade" section documenting the manual SOP (serve mode never
auto-updates) and one troubleshooting bullet:

- State lives under the service user's ~/.config (orca + Orca dirs),
  independent of /opt/orca, and orca-data.json is forward-migrated on load,
  so a forward upgrade is safe.
- Replace the binary with an atomic same-filesystem rename (download to
  .new, verify, mv) — never curl -o over the FUSE-mounted live binary.
- Back up the whole .config before upgrading, because rollback is NOT
  binary-only safe: an older build strips newer orca-data.json fields it
  doesn't recognize, and the .bak.* ring is corruption-recovery, not a
  pre-upgrade copy.
- Note there is no headless version command; track the release tag instead.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* docs(headless-server): harden the orca serve upgrade/rollback runbook

Address CodeRabbit review on stablyai#9575:

- Fail closed: run the upgrade block under `set -euo pipefail`, remove any stale
  `.new` file before download, and gate the atomic `mv` on an explicit ELF check
  so a failed/partial/non-ELF download can never be promoted.
- Keep /opt/orca/VERSION tied to the installed binary: a single `TAG` variable
  drives both the download URL and the recorded VERSION, saved as VERSION.prev on
  upgrade and restored on rollback so the audit file never drifts.
- Crash-loop troubleshooting now points to Roll back first (restores the
  pre-upgrade orca-data.json) instead of re-running Upgrade.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* docs(headless): harden server upgrade SOP

---------

Co-authored-by: fanyunqian.1 <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Co-authored-by: OrcaWin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

orca-remote-server Remote Orca Server / orca serve / paired remote runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants