Import boot-partition models into the agent dir as pi #197

Merged
aluminum-ice merged 1 commit from import-models-as-pi into main 2026-11-16 07:06:32 +00:00
Owner

What this PR does

The boot-partition model import (agent-provision) now writes the agent dir only as pi, the account that owns it. Root reads the staged files from the boot partition and hands their bytes to a pi process: each model and sidecar is copied by pi (to a temporary name, then renamed, so the agent never reads a half-written model), the episodes folder is created by pi, and the episode archive is unpacked by pi. The archive is unpacked only into a plain episodes folder; anything else in its place leaves the archive on the card, and the models still import. Root still creates the agent dir itself when it is missing, under the root-owned /var/lib/kestrel, the way pi_dir does. This brings the script in line with "file work inside a pi-owned directory runs as pi".

New tests/test_agent_provision.py runs the real script off-device, with a runuser stand-in that records what ran as pi: models and episodes import through pi, a linked episodes folder is refused, a model that can't be copied stays staged, and the script has no root install -o pi, chown, mkdir or tar -x. All four fail against the old script.

Checklist

  • Lint passes — the Lint workflow runs this on the PR (shellcheck isn't installed on the machine this was written on; bash -n and the real-data check pass).
  • Tests pass — the new tests and test_root_writes.py pass; the full suite passes apart from the 5 potfile-import tests in test_web.py that fail locally on main too (local werkzeug). The Test workflow runs it on the PR.
  • Nothing real: no secrets, no personal information, no real data.
  • Consent gates intact. Untouched; the import still never enables the agent or capture.
  • Docs updated in the same PR — docs/user-guide/boot-partition-provisioning.md says the history is unpacked by pi and stays on the card if it can't be.
  • Commit messages are short and imperative.

Release impact

  • App-layer-safe — agent-provision.sh is already in the engine's LIB_SCRIPTS; the rest is a test and a doc.
  • Reflash-class

Notes for review

Nothing else changes for the operator: the same files on the card, the same one-shot import, the same choice of active algorithm.

🤖 Generated with Claude Code

## What this PR does The boot-partition model import (`agent-provision`) now writes the agent dir only as `pi`, the account that owns it. Root reads the staged files from the boot partition and hands their bytes to a `pi` process: each model and sidecar is copied by `pi` (to a temporary name, then renamed, so the agent never reads a half-written model), the `episodes` folder is created by `pi`, and the episode archive is unpacked by `pi`. The archive is unpacked only into a plain `episodes` folder; anything else in its place leaves the archive on the card, and the models still import. Root still creates the agent dir itself when it is missing, under the root-owned `/var/lib/kestrel`, the way `pi_dir` does. This brings the script in line with "file work inside a pi-owned directory runs as pi". New `tests/test_agent_provision.py` runs the real script off-device, with a `runuser` stand-in that records what ran as `pi`: models and episodes import through `pi`, a linked `episodes` folder is refused, a model that can't be copied stays staged, and the script has no root `install -o pi`, `chown`, `mkdir` or `tar -x`. All four fail against the old script. ## Checklist - [ ] **Lint passes** — the Lint workflow runs this on the PR (shellcheck isn't installed on the machine this was written on; `bash -n` and the real-data check pass). - [x] **Tests pass** — the new tests and `test_root_writes.py` pass; the full suite passes apart from the 5 potfile-import tests in `test_web.py` that fail locally on main too (local werkzeug). The Test workflow runs it on the PR. - [x] **Nothing real: no secrets, no personal information, no real data.** - [x] **Consent gates intact.** Untouched; the import still never enables the agent or capture. - [x] **Docs updated in the same PR** — `docs/user-guide/boot-partition-provisioning.md` says the history is unpacked by `pi` and stays on the card if it can't be. - [x] Commit messages are short and imperative. ## Release impact - [x] **App-layer-safe** — `agent-provision.sh` is already in the engine's `LIB_SCRIPTS`; the rest is a test and a doc. - [ ] **Reflash-class** ## Notes for review Nothing else changes for the operator: the same files on the card, the same one-shot import, the same choice of active algorithm. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Import boot-partition models into the agent dir as pi
All checks were successful
Lint / lint (pull_request) Successful in 32s
Test / test (pull_request) Successful in 58s
Lint / lint (push) Successful in 28s
Test / test (push) Successful in 55s
b68c989b03
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
aluminum-ice deleted branch import-models-as-pi 2026-11-16 07:06:32 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
aluminum-ice/kestrel!197
No description provided.