fix(host): explain update permissions and add opt-in automatic updates

Merged
KI
2mo ago
+263-3

What & why

A host installed at /opt/kinro/superset can fail updating with EACCES on /opt/kinro/superset.update-lock when the service user cannot write/search the install parent. Both the host updater and CLI acquire this shared sibling lock; staging and atomic replacement need the same parent permissions, so relocating only the lock cannot solve the update failure.

Check parent access and replace raw permission/read-only failures with install path, lock path, UID, and repair/reinstall guidance. Preserve the shared lock and parent-child borrowing behavior. This does not change ownership automatically. /opt/kinro was absent on the investigation machine; the reporter's exact ownership remains unverified.

Add opt-in superset start --daemon --auto-update, passed as a launcher-owned runtime setting. Starting after one hour, hourly checks install newer CLI-channel releases through the existing health-check/restart/rollback flow. Checks do not overlap or downgrade hosts, and a release recorded as failed/rolled back is skipped until manually retried. Default remains disabled. Document usage and permission recovery in docs/host-updates.md.

How I tested it

  • 47 focused tests passed: shared install locking (including a real non-writable parent), host self-update and rollback, automatic checks, CLI spawn wiring, login-shell filtering, and atomic replacement.
  • Biome check on all changed TypeScript files passed; git diff --check passed.
  • bun run check:plugins passed.
  • Attempted bun run lint: blocked by nested root Biome configs in existing .claude/worktrees.
  • Attempted bun run typecheck, including affected package checks: blocked by missing workspace/external dependencies (including Cloudflare types, Lingui, and integration SDKs). No diagnostics reference changed files.
  • Attempted bun run test: shared package tests fail during preload in this checkout's incomplete dependency setup.
  • Attempted bun run check:i18n: missing local Lingui CLI causes the fallback npm lookup to return 404. No catalogs changed.
  • Did not run an actual update/restart on the user's live host. Lifecycle behavior was exercised through the existing dependency-injected updater tests; filesystem permissions were exercised with temporary directories.

Draft pending full validation in a provisioned checkout.

Checklist

  • PR title follows conventional commits (type(scope): subject)
  • bun run lint and bun run typecheck pass (CI fails on lint warnings too)
  • "Allow edits from maintainers" is checked on fork PRs (same-repository branch)

Summary by cubic

Explains host update permission errors and adds an opt-in automatic updater for standalone hosts.

  • Automatic updates - superset start --daemon --auto-update enables hourly checks that install newer CLI-channel releases through the existing health-check/restart/rollback flow. Default remains off; desktop installs skip checks; checks never downgrade and skip releases that previously failed or rolled back until manually retried.

  • Permission errors - The shared install-update-lock now checks parent-directory access and reports the install path, lock path, UID, and recovery guidance on EACCES/EPERM/EROFS. The lock stays outside the install because staging and replacement need the same parent permissions. No ownership is changed automatically.

Summary by CodeRabbit

  • New Features

    • Standalone hosts can now check for updates hourly and automatically install newer releases, restarting as needed. Automatic updates are off by default and can be enabled when starting the host.
    • Failed update checks are retried later; previously rolled-back releases and desktop installs are skipped.
  • Bug Fixes

    • Update-lock permission problems now produce clearer errors when the install directory lacks the required access.
  • Documentation

    • Added guidance on configuring automatic updates, retries, rollback behavior, and resolving update-lock permission errors.