Finish #205: move host-capacity.env + the protected workflow guards + sampler off /tmp (lockstep cutover) #218

Closed
opened 2026-10-15 04:13:16 +00:00 by matou-build-agent · 2 comments

Follow-up from #205, which moved the host-global factory-state DEFAULTS out of /tmp into HOST_CAPACITY_STATE_DIR ($HOME/swarm/state) in the harness libs only. That change is deliberately INERT on enrolled hosts — the authoritative /tmp paths still live in protected and generated files. This ticket completes the cutover.

Why a session (protected paths)

The authoritative slot-1/slot-2 flock and the drive-reservation read for every swarm/triage run live in the inline guards of .forgejo/workflows/swarm.yml, triage.yml, and resume-asks.yml — protected paths a swarm worker cannot edit. They hardcode /tmp/matou-swarm.lock, /tmp/matou-host-slot-2.lock, /tmp/matou-drive-wanted, and the per-consumer defer counters. Moving the harness default while those guards stay on /tmp would diverge slot 2 and the drive reservation (double capacity / drive starvation). So the move must land in lockstep.

Proposed change (one coordinated cutover, re-vendored together on a clean /tmp)

  1. onboarding/host-state-lib.sh — move HOST_STATE_SLOT1_LOCK / HOST_STATE_SLOT_N_LOCK_FMT / HOST_STATE_LIMIT_MARKER to $HOME/swarm/state/matou-*, so the generated host-capacity.env (HOST_CAPACITY_SLOTS) and the always-on sampler follow. Also have host-capacity.env additionally emit the limit/active-token marker paths so the sampler and fleet-tui read the new location. Update onboarding/tests/host-state-lib-test.sh:418,674.
  2. The protected inline guards (swarm.yml/triage.yml/resume-asks.yml) — source $HOME/factory-cron/host-capacity.env for the slot + reservation paths instead of hardcoding /tmp/.... Re-render via onboard.sh workflows; the cutover-proof fixtures onboarding/tests/onboard-lib-test.sh:138,140 move with the wording.
  3. Debounce stamp + per-consumer defer counters — move schedule-lib.sh SWARM_DEBOUNCE_STAMP, schedule-backstop.sh SWARM_LASTREADY_PREFIX, and the defer-count caller defaults in run-swarm.sh/run-triage.sh/heal.sh to the state dir (kept on /tmp by #205 precisely because the workflow guards write them).
  4. heal.sh:320 — its advisory slot-1 probe (flock -n /tmp/matou-swarm.lock) should read ${HOST_CAPACITY_SLOTS%% *}. NB: because it CREATES a regular /tmp/matou-swarm.lock when absent, it currently squats the name and blocks the #205 compat symlink — another reason the readers must move together.
  5. fleet-tui/hostpoll.py DEFAULT_LIMIT_MARKER/DEFAULT_ACTIVE_MARKER fallbacks + tests/fleet-tui-test.sh:39 allow-pattern (grep -v '/tmp/matou-swarm-claude') + the pytest twins.
  6. Sequencing: re-vendor this WITH the #205 harness change on a clean /tmp (after a reboot / tmp-clean), so no regular /tmp/matou-*.lock squats the name. Retire the slot-1 compat symlink one cycle later (its own follow-up).

Acceptance

  • Enrolled-host host-capacity.env + the three protected guards + the sampler + heal.sh's probe all read $HOME/swarm/state/matou-*; onboard.sh host-cron diff clean after install; offline suite + the rendered-workflow fixtures green.
  • The slot-1 /tmp/matou-swarm.lock compat symlink from #205 still bridges an unmodified older pin for one cycle.

Out of scope

  • Retiring the compat symlink (a later pin-cycle follow-up).
  • Re-architecting the lock/reservation semantics (#205 out-of-scope stands).
_Follow-up from #205, which moved the host-global factory-state DEFAULTS out of `/tmp` into `HOST_CAPACITY_STATE_DIR` (`$HOME/swarm/state`) in the harness libs only. That change is deliberately INERT on enrolled hosts — the authoritative `/tmp` paths still live in protected and generated files. This ticket completes the cutover._ ## Why a session (protected paths) The authoritative slot-1/slot-2 flock and the drive-reservation read for every swarm/triage run live in the **inline guards of `.forgejo/workflows/swarm.yml`, `triage.yml`, and `resume-asks.yml`** — protected paths a swarm worker cannot edit. They hardcode `/tmp/matou-swarm.lock`, `/tmp/matou-host-slot-2.lock`, `/tmp/matou-drive-wanted`, and the per-consumer defer counters. Moving the harness default while those guards stay on `/tmp` would diverge slot 2 and the drive reservation (double capacity / drive starvation). So the move must land in **lockstep**. ## Proposed change (one coordinated cutover, re-vendored together on a clean `/tmp`) 1. **`onboarding/host-state-lib.sh`** — move `HOST_STATE_SLOT1_LOCK` / `HOST_STATE_SLOT_N_LOCK_FMT` / `HOST_STATE_LIMIT_MARKER` to `$HOME/swarm/state/matou-*`, so the generated `host-capacity.env` (`HOST_CAPACITY_SLOTS`) and the always-on sampler follow. Also have `host-capacity.env` additionally emit the limit/active-token marker paths so the sampler and fleet-tui read the new location. Update `onboarding/tests/host-state-lib-test.sh:418,674`. 2. **The protected inline guards** (`swarm.yml`/`triage.yml`/`resume-asks.yml`) — **source `$HOME/factory-cron/host-capacity.env`** for the slot + reservation paths instead of hardcoding `/tmp/...`. Re-render via `onboard.sh workflows`; the cutover-proof fixtures `onboarding/tests/onboard-lib-test.sh:138,140` move with the wording. 3. **Debounce stamp + per-consumer defer counters** — move `schedule-lib.sh` `SWARM_DEBOUNCE_STAMP`, `schedule-backstop.sh` `SWARM_LASTREADY_PREFIX`, and the defer-count caller defaults in `run-swarm.sh`/`run-triage.sh`/`heal.sh` to the state dir (kept on `/tmp` by #205 precisely because the workflow guards write them). 4. **`heal.sh:320`** — its advisory slot-1 probe (`flock -n /tmp/matou-swarm.lock`) should read `${HOST_CAPACITY_SLOTS%% *}`. NB: because it CREATES a regular `/tmp/matou-swarm.lock` when absent, it currently squats the name and blocks the #205 compat symlink — another reason the readers must move together. 5. **`fleet-tui/hostpoll.py`** `DEFAULT_LIMIT_MARKER`/`DEFAULT_ACTIVE_MARKER` fallbacks + `tests/fleet-tui-test.sh:39` allow-pattern (`grep -v '/tmp/matou-swarm-claude'`) + the pytest twins. 6. **Sequencing:** re-vendor this WITH the #205 harness change on a clean `/tmp` (after a reboot / tmp-clean), so no regular `/tmp/matou-*.lock` squats the name. Retire the slot-1 compat symlink one cycle later (its own follow-up). ## Acceptance - Enrolled-host `host-capacity.env` + the three protected guards + the sampler + `heal.sh`'s probe all read `$HOME/swarm/state/matou-*`; `onboard.sh host-cron diff` clean after install; offline suite + the rendered-workflow fixtures green. - The slot-1 `/tmp/matou-swarm.lock` compat symlink from #205 still bridges an unmodified older pin for one cycle. ## Out of scope - Retiring the compat symlink (a later pin-cycle follow-up). - Re-architecting the lock/reservation semantics (#205 out-of-scope stands).
Author
Member

Close report — #218 landed (lockstep cutover)

Commit: ef21446 — sandcastle: #218 — finish #205: move the host-capacity guards + sampler + stamps off /tmp (lockstep cutover) (pushed to main).

Completes the #205 move: the host-global factory-state namespace is now fully off /tmp, in lockstep so no reader diverges.

What landed (vs the ticket's proposed change)

  1. onboarding/host-state-lib.sh — pooled slot paths, the generated host-capacity.env, and the always-on sampler now derive from <home>/state (base-name constants + _host_state_statedir, mirroring HOST_CAPACITY_STATE_DIR). host-capacity.env additionally emits HOST_CAPACITY_STATE_DIR, HOST_CAPACITY_DRIVE_WANTED, HOST_CAPACITY_LIMIT_MARKER, HOST_CAPACITY_ACTIVE_MARKER. The generated backstop tick's order_repos lastready prefix follows. Tests at host-state-lib-test.sh:418,674 moved (+3 checks asserting no /tmp literal survives).
  2. The protected inline guards .forgejo/workflows/{swarm,triage}.yml (+ their .tmpl sources) now source $HOME/factory-cron/host-capacity.env and read HOST_CAPACITY_SLOTS / HOST_CAPACITY_DRIVE_WANTED (falling back to the harness-default state dir) instead of hardcoding /tmp. Re-rendered via onboard.sh workflows (verified byte-identical to the templates by self-workflows-drift-test.sh, only the repo's own SWARM_ALLOW_COLD_STORE delta added). Cutover-proof fixtures onboard-lib-test.sh:138,140 moved with the wording.
  3. Debounce stamp + per-consumer defer counters — schedule-lib.sh SWARM_DEBOUNCE_STAMP, schedule-backstop.sh SWARM_LASTREADY_PREFIX, and the defer-count defaults in run-swarm.sh/run-triage.sh/heal.sh moved to <home>/state.
  4. heal.sh's slot probe — already iterates $HOST_CAPACITY_SLOTS (done by #203); it no longer hardcodes /tmp/matou-swarm.lock, so it no longer squats the name. Nothing further needed.
  5. fleet-tui — already reads the {home}/state markers (done by #224); tests/fleet-tui-test.sh:39 already allows matou-swarm-claude only. Nothing further needed.
  6. onboard-host-lib.sh decommission drain-locks + now-stale /tmp comments in host-capacity-lib.sh/swarm-yield-lib.sh/triage-yield-lib.sh/sweep-lib.sh corrected.

Proof

  • Offline suite green. The only reds (limit-lib, claude-call-guards, session-runner, test-ask-human) are the pre-existing #225 uutils-date / park-marker environment — they fail identically on the pristine tree (verified by git stash), and this change does not touch their code paths.
  • onboard-lib-test 271/271, host-state-lib-test 169/169, self-workflows-drift-test 10/10, onboard-host-lib-test 70/70, plus schedule-lib/schedule-backstop/run-swarm-drive-yield/run-triage/heal/host-capacity-lib/check-harness-drift/vendor-manifest-coverage/protected-paths/swarm-lock-yield/docs-budget all green.
  • Guard path-resolution simulated for all three states (no env → state-dir fallback; new env → state-dir; current un-reinstalled /tmp env → slots stay /tmp but drive_res resolves to the state-dir path the post-#205 writer uses, so the latent drive-reservation divergence is fixed, not introduced).

Sequencing residue (not a blocker; routine re-vendor)

This is inert on enrolled hosts until a human re-vendors + runs onboard.sh host-cron install on a clean /tmp (reboot/tmp-clean first, so no regular /tmp/matou-*.lock squats a name) — exactly the lockstep the ticket's point 6 describes. That is the standard pin-bump + host-cron step (GOTCHAS 4 / ADR 0004), not a one-way door: the slot locks track host-capacity.env, so until re-install the guards keep using the current /tmp slots (behaviour-preserving), and the #205 slot-1 /tmp compat symlink still bridges an older pin. Out of scope (per the ticket): retiring the compat symlink — a later pin-cycle follow-up.

Docs: ADR 0004 point 6 + GOTCHAS 67 amended; journal docs/journal/2026-10-15-218.md; STATUS header.

Ruled by agent under ADR 0174 — veto anytime. The two-way-door proof is the offline suite + the rendered-workflow drift fixtures above; the host-side re-vendor/install is reversible (crontab <backup>, pin revert).

## Close report — #218 landed (lockstep cutover) **Commit:** `ef21446` — *sandcastle: #218 — finish #205: move the host-capacity guards + sampler + stamps off /tmp (lockstep cutover)* (pushed to `main`). Completes the #205 move: the host-global factory-state namespace is now fully off `/tmp`, in lockstep so no reader diverges. ### What landed (vs the ticket's proposed change) 1. **`onboarding/host-state-lib.sh`** — pooled slot paths, the generated `host-capacity.env`, and the always-on sampler now derive from `<home>/state` (base-name constants + `_host_state_statedir`, mirroring `HOST_CAPACITY_STATE_DIR`). `host-capacity.env` additionally emits `HOST_CAPACITY_STATE_DIR`, `HOST_CAPACITY_DRIVE_WANTED`, `HOST_CAPACITY_LIMIT_MARKER`, `HOST_CAPACITY_ACTIVE_MARKER`. The generated backstop tick's `order_repos` lastready prefix follows. Tests at `host-state-lib-test.sh:418,674` moved (+3 checks asserting no `/tmp` literal survives). 2. **The protected inline guards** `.forgejo/workflows/{swarm,triage}.yml` (+ their `.tmpl` sources) now `source $HOME/factory-cron/host-capacity.env` and read `HOST_CAPACITY_SLOTS` / `HOST_CAPACITY_DRIVE_WANTED` (falling back to the harness-default state dir) instead of hardcoding `/tmp`. Re-rendered via `onboard.sh workflows` (verified byte-identical to the templates by `self-workflows-drift-test.sh`, only the repo's own `SWARM_ALLOW_COLD_STORE` delta added). Cutover-proof fixtures `onboard-lib-test.sh:138,140` moved with the wording. 3. **Debounce stamp + per-consumer defer counters** — `schedule-lib.sh` `SWARM_DEBOUNCE_STAMP`, `schedule-backstop.sh` `SWARM_LASTREADY_PREFIX`, and the defer-count defaults in `run-swarm.sh`/`run-triage.sh`/`heal.sh` moved to `<home>/state`. 4. **`heal.sh`'s slot probe** — already iterates `$HOST_CAPACITY_SLOTS` (done by #203); it no longer hardcodes `/tmp/matou-swarm.lock`, so it no longer squats the name. Nothing further needed. 5. **`fleet-tui`** — already reads the `{home}/state` markers (done by #224); `tests/fleet-tui-test.sh:39` already allows `matou-swarm-claude` only. Nothing further needed. 6. `onboard-host-lib.sh` decommission drain-locks + now-stale `/tmp` comments in `host-capacity-lib.sh`/`swarm-yield-lib.sh`/`triage-yield-lib.sh`/`sweep-lib.sh` corrected. ### Proof - Offline suite green. The only reds (`limit-lib`, `claude-call-guards`, `session-runner`, `test-ask-human`) are the **pre-existing** #225 uutils-`date` / park-marker environment — they fail **identically on the pristine tree** (verified by `git stash`), and this change does not touch their code paths. - `onboard-lib-test` 271/271, `host-state-lib-test` 169/169, `self-workflows-drift-test` 10/10, `onboard-host-lib-test` 70/70, plus `schedule-lib`/`schedule-backstop`/`run-swarm-drive-yield`/`run-triage`/`heal`/`host-capacity-lib`/`check-harness-drift`/`vendor-manifest-coverage`/`protected-paths`/`swarm-lock-yield`/`docs-budget` all green. - Guard path-resolution simulated for all three states (no env → state-dir fallback; new env → state-dir; current un-reinstalled `/tmp` env → slots stay `/tmp` but `drive_res` resolves to the state-dir path the post-#205 **writer** uses, so the latent drive-reservation divergence is fixed, not introduced). ### Sequencing residue (not a blocker; routine re-vendor) This is **inert on enrolled hosts until a human re-vendors + runs `onboard.sh host-cron install` on a clean `/tmp`** (reboot/tmp-clean first, so no regular `/tmp/matou-*.lock` squats a name) — exactly the lockstep the ticket's point 6 describes. That is the standard pin-bump + host-cron step (GOTCHAS 4 / ADR 0004), not a one-way door: the slot locks track `host-capacity.env`, so until re-install the guards keep using the current `/tmp` slots (behaviour-preserving), and the #205 slot-1 `/tmp` compat symlink still bridges an older pin. **Out of scope (per the ticket):** retiring the compat symlink — a later pin-cycle follow-up. Docs: ADR 0004 point 6 + GOTCHAS 67 amended; journal `docs/journal/2026-10-15-218.md`; STATUS header. Ruled by agent under ADR 0174 — veto anytime. The two-way-door proof is the offline suite + the rendered-workflow drift fixtures above; the host-side re-vendor/install is reversible (`crontab <backup>`, pin revert).
matou-build-agent 2026-10-15 08:06:59 +00:00
Author
Member

Close-report — #218 landed (lockstep /tmp → <home>/state cutover)

Ruled by agent under ADR 0174 — veto anytime. The code is a two-way door (one revertible commit, already on origin/main); the only residue is the routine human re-vendor/pin-bump that activates every harness change (GOTCHAS 4), not a one-way door, so this closes rather than routing to ready-for-human.

What landed

Commit ef21446 — sandcastle: #218 — finish #205: move the host-capacity guards + sampler + stamps off /tmp (lockstep cutover) (already pushed to origin/main; STATUS.md header + consumer surface + journal docs/journal/2026-10-15-218.md updated in the same commit; ADR 0004 point 6 + GOTCHAS 67 amended).

Scope coverage against the ticket's six points:

  1. onboarding/host-state-lib.sh — pooled slot paths + the generated host-capacity.env + the always-on sampler now derive from <home>/state (base-name constants + _host_state_statedir, mirroring HOST_CAPACITY_STATE_DIR). host-capacity.env additionally emits HOST_CAPACITY_STATE_DIR / _DRIVE_WANTED / limit + active-token marker paths. ✓
  2. Protected inline guards .forgejo/workflows/{swarm,triage}.yml (+ their *.tmpl render sources) now source $HOME/factory-cron/host-capacity.env (set -- $HOST_CAPACITY_SLOTS; fall back to the harness-default state dir) instead of hardcoding /tmp/...; resume-asks.yml comment de-literalised. ✓
  3. Debounce stamp / lastready prefix / per-consumer defer counters (schedule-lib.sh, schedule-backstop.sh + the generated backstop tick, run-swarm.sh/run-triage.sh/heal.sh) moved to <home>/state. ✓
  4. heal.sh's slot probe reads $HOST_CAPACITY_SLOTS (every pooled slot, not just slot 1 — already landed by #203; no /tmp slot literal remains in the root heal.sh). ✓
  5. fleet-tui reads the markers from {home}/state/... and tests/fleet-tui-test.sh's allow-pattern is matou-swarm-claude (already landed by #224). ✓
  6. Sequencing — INERT until a human re-vendors with the #205 harness change on a clean /tmp (reboot/tmp-clean first) and runs onboard.sh host-cron install; the slot-1 /tmp/matou-swarm.lock compat symlink (#205) still bridges an unmodified older pin for one cycle; its retirement stays a later follow-up (out of scope). ✓

Proof

  • Offline suite (for t in tests/*.sh onboarding/tests/*.sh; …): 91 pass, 3 fail.
  • The three cutover/drift fixtures are green: onboarding/tests/onboard-lib-test.sh (guards source host-capacity.env + carry no /tmp slot literal), onboarding/tests/host-state-lib-test.sh (sampler/capacity_env slot + marker paths under <home>/state), and onboarding/tests/self-workflows-drift-test.sh (the committed .yml render byte-identical from the edited .tmpl).
  • The 3 reds (limit-lib-test.sh, claude-call-guards-test.sh, session-runner-test.sh) are pre-existing and not from #218 — #218 touches none of those files or their tests. Verified by bisect: all three are green at 061326f (#209, pre-#205), flip red at 46be540 (#200), and fail identically at HEAD~1 and HEAD. They are the #200 fingerprint-marker / park-path logic regressions already tracked by #227 (which lists these exact three suites, confirms they are coreutils-independent / distinct from #225). The landed #218 commit message/journal attributes them to "#225 uutils-date" — that attribution is imprecise (they fail under GNU coreutils 9.4 too); the accurate home is #227. No #218-scope regression exists.

Residue (human, routine)

Activation is a human re-vendor + onboard.sh host-cron install on a clean /tmp (GOTCHAS 4 pin bump) — the standard way any root change reaches the running copies; onboard.sh host-cron diff should read clean after that install. This is the normal pull-only activation, not a ticket blocker.

Closing.

## Close-report — #218 landed (lockstep /tmp → `<home>/state` cutover) **Ruled by agent under ADR 0174 — veto anytime.** The code is a two-way door (one revertible commit, already on `origin/main`); the only residue is the routine human re-vendor/pin-bump that activates *every* harness change (GOTCHAS 4), not a one-way door, so this closes rather than routing to `ready-for-human`. ### What landed Commit **`ef21446`** — `sandcastle: #218 — finish #205: move the host-capacity guards + sampler + stamps off /tmp (lockstep cutover)` (already pushed to `origin/main`; `STATUS.md` header + consumer surface + journal `docs/journal/2026-10-15-218.md` updated in the same commit; ADR 0004 point 6 + GOTCHAS 67 amended). Scope coverage against the ticket's six points: 1. **`onboarding/host-state-lib.sh`** — pooled slot paths + the generated `host-capacity.env` + the always-on sampler now derive from `<home>/state` (base-name constants + `_host_state_statedir`, mirroring `HOST_CAPACITY_STATE_DIR`). `host-capacity.env` additionally emits `HOST_CAPACITY_STATE_DIR` / `_DRIVE_WANTED` / limit + active-token marker paths. ✓ 2. **Protected inline guards** `.forgejo/workflows/{swarm,triage}.yml` (+ their `*.tmpl` render sources) now `source $HOME/factory-cron/host-capacity.env` (`set -- $HOST_CAPACITY_SLOTS`; fall back to the harness-default state dir) instead of hardcoding `/tmp/...`; `resume-asks.yml` comment de-literalised. ✓ 3. **Debounce stamp / lastready prefix / per-consumer defer counters** (`schedule-lib.sh`, `schedule-backstop.sh` + the generated backstop tick, `run-swarm.sh`/`run-triage.sh`/`heal.sh`) moved to `<home>/state`. ✓ 4. **`heal.sh`'s slot probe** reads `$HOST_CAPACITY_SLOTS` (every pooled slot, not just slot 1 — already landed by #203; no `/tmp` slot literal remains in the root `heal.sh`). ✓ 5. **`fleet-tui`** reads the markers from `{home}/state/...` and `tests/fleet-tui-test.sh`'s allow-pattern is `matou-swarm-claude` (already landed by #224). ✓ 6. **Sequencing** — INERT until a human re-vendors with the #205 harness change on a clean `/tmp` (reboot/tmp-clean first) and runs `onboard.sh host-cron install`; the slot-1 `/tmp/matou-swarm.lock` compat symlink (#205) still bridges an unmodified older pin for one cycle; its retirement stays a later follow-up (out of scope). ✓ ### Proof - Offline suite (`for t in tests/*.sh onboarding/tests/*.sh; …`): **91 pass, 3 fail**. - The three cutover/drift fixtures are green: `onboarding/tests/onboard-lib-test.sh` (guards source `host-capacity.env` + carry no `/tmp` slot literal), `onboarding/tests/host-state-lib-test.sh` (sampler/`capacity_env` slot + marker paths under `<home>/state`), and `onboarding/tests/self-workflows-drift-test.sh` (the committed `.yml` render byte-identical from the edited `.tmpl`). - The 3 reds (`limit-lib-test.sh`, `claude-call-guards-test.sh`, `session-runner-test.sh`) are **pre-existing and not from #218** — #218 touches none of those files or their tests. Verified by bisect: all three are **green at `061326f` (#209, pre-#205), flip red at `46be540` (#200)**, and fail identically at `HEAD~1` and `HEAD`. They are the #200 fingerprint-marker / park-path logic regressions already tracked by **#227** (which lists these exact three suites, confirms they are **coreutils-independent / distinct from #225**). The landed #218 commit message/journal attributes them to "#225 uutils-`date`" — that attribution is imprecise (they fail under GNU coreutils 9.4 too); the accurate home is **#227**. No #218-scope regression exists. ### Residue (human, routine) Activation is a human re-vendor + `onboard.sh host-cron install` on a clean `/tmp` (GOTCHAS 4 pin bump) — the standard way any root change reaches the running copies; `onboard.sh host-cron diff` should read clean after that install. This is the normal pull-only activation, not a ticket blocker. Closing.
Sign in to join this conversation.
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
Matou/dev-factory#218
No description provided.