fix(install): add ownership rows for model-pull-jobs/ and activity.db - #1933
fix(install): add ownership rows for model-pull-jobs/ and activity.db#1933thinmintdev wants to merge 1 commit into
Conversation
hal0-api (User=hal0) failed every pull-job snapshot write and could not read an existing one after a restart, because model-pull-jobs/ had no row in the OwnershipStore table: the installer's root-run brain-model pull is the first writer on a fresh install, lazily mkdir-ing the dir root:root 0755 with no way for `doctor perms --fix` to heal it. The same O13 birth-ownership class applies to activity.db (+ its -wal/-shm WAL siblings), which the issue also calls out — no row existed for it either. Add a durable coverage test (test_every_hal0_api_write_path_has_an_ownership_row) parametrized over every var_lib() path hal0-api can be the first writer of, so a future service-writable path can't go unrowed the same way. Refs #1895
Independent review — APPROVE (0 blocking, 4 non-blocking notes)I did not write this code and verified every claim in the PR body against the tree rather than taking it on trust. 1. Does the diff fix #1895's exact repro?Yes. Traced the whole path:
After the change the backstop chowns the dir to 2. Root cause vs symptomFix is at the cause (the declarative table is the single source of truth; the O13/#1546 class), not a one-off 3. Revert-and-confirm-red (independently run, not taken from the PR body)Detached worktree at Exactly the 5 parametrized failures claimed. Restoring
The tests fail for the right reason (missing table row / 4. Modes
5.
|
Summary
Fixes #1895:
hal0-api(User=hal0) failed every pull-job snapshot write (model.pull_job_persist_failed, WARNING-only fail-soft) and could not read an existing snapshot after a restart, because/var/lib/hal0/model-pull-jobshad no row in theOwnershipStoredeclarative table (src/hal0/install/perms.py). The installer's root-run brain-model pull (installer/install.sh's bundle-tier auto-pull, before line 2809'sdoctor perms --fix --forcebackstop) is the first writer on a fresh install, lazilymkdir-ing the dirroot:root 0755under root's umask — the same O13 birth-ownership bug class as #1546 (hal0.db). No row meantdoctor perms --fixhad nothing to reconcile.The issue's "Expected" section also calls out
activity.db(+ its-wal/-shmWAL siblings,hal0.activity.AuditStorerunsPRAGMA journal_mode=WAL) as missing the identical row — added here too.install.shchange needed. The bundle-tier brain-model pull (line ~1967) runs well before thedoctor perms --fix --forcebackstop (line 2809), so the table-only fix is sufficient: the backstop now has a declared opinion to reconcile the root-owned dir against.runner-image-pull-jobs/(the sibling runner-image pull store) is NOT affected — it's never touched at install time as root, only ever created by theUser=hal0service itself, so it's born correctly already. Left out of scope.What changed
src/hal0/install/perms.py:model-pull-jobs/—hal0:hal0 2775,glob="*.json"children0600(matchestempfile.mkstemp's birth mode, same convention asregistry.toml/slots/*/state.json).activity.db/activity.db-wal/activity.db-shm—hal0:hal0 0644, mirroring the existinghal0.dbrows exactly.tests/install/test_perms.py:test_every_hal0_api_write_path_has_an_ownership_row— parametrized over everyvar_lib()pathhal0-apican be the first writer of (the two new ones +hal0.db/registry//slots//models/as regression anchors), so a future service-writable path can't go unrowed the same waymodel-pull-jobs/did. Confirmed RED againstmain(5 failures) before theperms.pychange, GREEN after.test_model_pull_jobs_dir_snapshot_files_get_hal0_owned_child_rows— asserts themodel-pull-jobs/row'schild_modematchespersist_pull_job's actualtempfile.mkstempbirth mode (0600).Sequencing note
Kept minimal and confined to the missing rows + the coverage test — #1896 (
doctor permsnever-converges) also touchesperms.pyin unrelated areas (STATE.md,secrets/, recursive-mkdir modes) and is deliberately held until this lands, so it can rebase cleanly.Test plan
env -u FORCE_COLOR HAL0_HOME=$(mktemp -d) uv run --extra dev pytest tests/install tests/installer -q→ 748 passed, 1 skippedmain(5 parametrized failures) before theperms.pyfix, GREEN aftermake lint→ cleanuv run ruff format --check src tests→ cleanrc-validaterepro (ls -ld /var/lib/hal0/model-pull-jobs && sudo -u hal0 test -w ...) on a fresh install to confirm the end-to-end fix🤖 Generated with Claude Code