Hold backup and remote-train host output and pulls to a size #200

Merged
aluminum-ice merged 1 commit from cap-host-output into main 2026-11-17 09:56:31 +00:00
Owner

What this PR does

backup and remote-train now hold what a backup or training host sends back to a size.

New hostrun plugin library (plugins/_lib_hostrun.py, API 0.1, provisional)

  • run(cmd, input=, timeout=, limit=) runs a command in its own session and keeps at most 64 KB of each of stdout and stderr.
  • Past that, it kills the command and everything it started (an ssh under rsync, say), and truncated is set.
  • A process left holding a pipe after the command exits is stopped the same way.
  • It raises what subprocess.run raises, so callers keep their except clauses.

remote-train

  • Every ssh and rsync goes through hostrun. A truncated result is a failure ("the host sent more output than expected").
  • A pull is one regular file with rsync -tz --max-size (64 KB for a sidecar, 256 MB for a model) instead of -az, so a directory or link in its place is skipped.
  • _read_json opens without blocking and reads only a regular file within its size: 64 KB for a pulled sidecar, 1 MB for the plugin's own files.

backup

  • rsync, scp and the ssh mkdir go through hostrun. A truncated result is a failure on the card.

Checklist

  • Lint passes — the Lint workflow runs this on the PR (the real-data check passes locally; the lint tools aren't installed on the machine this was written on).
  • Tests pass
    • New tests/test_hostrun_lib.py (real child processes):
      • a flood on either stream is cut at the limit and stopped;
      • a grandchild's flood is stopped;
      • a grandchild left holding the pipe doesn't hang the call;
      • timeout, missing command, stdin, undecodable bytes.
    • New plugin tests:
      • both plugins treat a truncated result as a failure;
      • the pull command is bounded and non-recursive;
      • _read_json refuses large files, FIFOs and folders;
      • neither plugin calls subprocess.run or capture_output any more.
    • Changed existing tests: the existing plugin tests now stub hostrun.run instead of subprocess.run.
    • Suite: the full suite passes apart from the 5 potfile-import tests in test_web.py that fail locally on main too (local werkzeug).
  • Nothing real: no secrets, no personal information, no real data.
  • Consent gates intact. Untouched.
  • Docs updated in the same PR — plugin-libraries.md (table and a hostrun section), remote-training.md (bounded pulls), CLAUDE.md.
  • Commit messages are short and imperative.

Release impact

  • App-layer-safe — plugins/*.py only (the new library is a plugins/_lib_*.py file, which the engine installs like any plugin), plus tests and docs.
  • Reflash-class

Notes for review

Nothing changes for a working host: status lines, error messages and rsync's --stats are far below 64 KB, and a Kestrel model is a few MB. The 256 MB model limit is generous on purpose.

🤖 Generated with Claude Code

## What this PR does `backup` and `remote-train` now hold what a backup or training host sends back to a size. **New `hostrun` plugin library** (`plugins/_lib_hostrun.py`, API 0.1, provisional) - `run(cmd, input=, timeout=, limit=)` runs a command in its own session and keeps at most 64 KB of each of stdout and stderr. - Past that, it kills the command and everything it started (an `ssh` under `rsync`, say), and `truncated` is set. - A process left holding a pipe after the command exits is stopped the same way. - It raises what `subprocess.run` raises, so callers keep their `except` clauses. **`remote-train`** - Every `ssh` and `rsync` goes through `hostrun`. A truncated result is a failure ("the host sent more output than expected"). - A pull is one regular file with `rsync -tz --max-size` (64 KB for a sidecar, 256 MB for a model) instead of `-az`, so a directory or link in its place is skipped. - `_read_json` opens without blocking and reads only a regular file within its size: 64 KB for a pulled sidecar, 1 MB for the plugin's own files. **`backup`** - `rsync`, `scp` and the `ssh mkdir` go through `hostrun`. A truncated result is a failure on the card. ## Checklist - [ ] **Lint passes** — the Lint workflow runs this on the PR (the real-data check passes locally; the lint tools aren't installed on the machine this was written on). - [x] **Tests pass** - **New `tests/test_hostrun_lib.py`** (real child processes): - a flood on either stream is cut at the limit and stopped; - a grandchild's flood is stopped; - a grandchild left holding the pipe doesn't hang the call; - timeout, missing command, stdin, undecodable bytes. - **New plugin tests:** - both plugins treat a truncated result as a failure; - the pull command is bounded and non-recursive; - `_read_json` refuses large files, FIFOs and folders; - neither plugin calls `subprocess.run` or `capture_output` any more. - **Changed existing tests:** the existing plugin tests now stub `hostrun.run` instead of `subprocess.run`. - **Suite:** the full suite passes apart from the 5 potfile-import tests in `test_web.py` that fail locally on main too (local werkzeug). - [x] **Nothing real: no secrets, no personal information, no real data.** - [x] **Consent gates intact.** Untouched. - [x] **Docs updated in the same PR** — `plugin-libraries.md` (table and a `hostrun` section), `remote-training.md` (bounded pulls), CLAUDE.md. - [x] Commit messages are short and imperative. ## Release impact - [x] **App-layer-safe** — `plugins/*.py` only (the new library is a `plugins/_lib_*.py` file, which the engine installs like any plugin), plus tests and docs. - [ ] **Reflash-class** ## Notes for review Nothing changes for a working host: status lines, error messages and rsync's `--stats` are far below 64 KB, and a Kestrel model is a few MB. The 256 MB model limit is generous on purpose. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Hold backup and remote-train host output and pulls to a size
All checks were successful
Lint / lint (pull_request) Successful in 31s
Test / test (pull_request) Successful in 1m1s
Lint / lint (push) Successful in 29s
Test / test (push) Successful in 55s
ed26725423
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
aluminum-ice deleted branch cap-host-output 2026-11-17 09:56:31 +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!200
No description provided.