heal-prompt / heal.sh: stamp matou.factory=heal on the healer's docker runs so #122's label reap fires before the 3h belt #123

Closed
opened 2026-09-03 16:19:54 +00:00 by matou-build-agent · 2 comments

Context

Follow-up to #122, which taught the container sweep (reap_containers in sweep-lib.sh) to reap leaked factory containers by label (matou.factory=<kind>) and by image (a 3h belt for sandcastle:<repo> / *-ci). The belt reaps a cancelled ci/heal container within one sweep tick regardless of labels, but only after the full run-lifetime floor (3h). The label path reaps SOONER (a heal container past HEAL_REAP_CEILING, a ci one past CI_REAP_CEILING) — but only if the docker run actually carries --label matou.factory=<kind>. Nothing stamps that label yet.

This is the design/prompt half #122 could not land (part 3 of that ticket):

  1. The rehearsal/heal healer issues ad-hoc docker runs during a bisect (e.g. /tmp/heal-fix runs). Every such docker run should carry --label matou.factory=heal --label matou.run=$RUN_ID (or run under --cidfile + a docker rm -f trap). This is a change to the heal-prompt skeleton (prompts/heal-prompt.md) — a live-text design surface (CLAUDE.md rule 2c), so it needs an interactive session's standing.
  2. heal.sh's timeout 900 wrapping the agent should use --kill-after and ensure any container-cleanup trap runs before the hard kill.

The product ci.yml side (matou-app's ci.yml stamping --label matou.factory=ci on its checks container) is tracked in the product repo as matou-app#331 — pull-only, not ours.

Why ready-for-session

prompts/heal-prompt.md is a rendered prompt skeleton (high blast radius; reaches every consumer at the next render). Editing it is design work, not a mechanical swarm edit — a session rules on the wording and re-proves the onboard-lib render goldens.

Acceptance

  • The healer prompt instructs every agent-issued docker run to carry --label matou.factory=heal --label matou.run=<run-id> (or an equivalent cidfile+trap), so #122's label path reaps a leaked heal container at HEAL_REAP_CEILING instead of waiting for the 3h belt.
  • heal.sh's agent timeout uses --kill-after with the cleanup trap ahead of the kill.
  • Render goldens re-proven byte-identical or the wording change explained (onboard-lib-test).

Found while working #122.

## Context Follow-up to #122, which taught the container sweep (`reap_containers` in `sweep-lib.sh`) to reap leaked factory containers by **label** (`matou.factory=<kind>`) and by **image** (a 3h belt for `sandcastle:<repo>` / `*-ci`). The belt reaps a cancelled ci/heal container within one sweep tick regardless of labels, but only after the full run-lifetime floor (3h). The **label** path reaps SOONER (a heal container past `HEAL_REAP_CEILING`, a ci one past `CI_REAP_CEILING`) — but only if the `docker run` actually carries `--label matou.factory=<kind>`. Nothing stamps that label yet. This is the design/prompt half #122 could not land (part 3 of that ticket): 1. **The rehearsal/heal healer** issues ad-hoc `docker run`s during a bisect (e.g. `/tmp/heal-fix` runs). Every such `docker run` should carry `--label matou.factory=heal --label matou.run=$RUN_ID` (or run under `--cidfile` + a `docker rm -f` trap). This is a change to the **heal-prompt skeleton** (`prompts/heal-prompt.md`) — a live-text design surface (CLAUDE.md rule 2c), so it needs an interactive session's standing. 2. **`heal.sh`'s `timeout 900`** wrapping the agent should use `--kill-after` and ensure any container-cleanup trap runs before the hard kill. The product ci.yml side (matou-app's `ci.yml` stamping `--label matou.factory=ci` on its checks container) is tracked in the product repo as **matou-app#331** — pull-only, not ours. ## Why ready-for-session `prompts/heal-prompt.md` is a rendered prompt skeleton (high blast radius; reaches every consumer at the next render). Editing it is design work, not a mechanical swarm edit — a session rules on the wording and re-proves the onboard-lib render goldens. ## Acceptance - The healer prompt instructs every agent-issued `docker run` to carry `--label matou.factory=heal --label matou.run=<run-id>` (or an equivalent cidfile+trap), so #122's label path reaps a leaked heal container at `HEAL_REAP_CEILING` instead of waiting for the 3h belt. - `heal.sh`'s agent `timeout` uses `--kill-after` with the cleanup trap ahead of the kill. - Render goldens re-proven byte-identical or the wording change explained (onboard-lib-test). Found while working #122.
Author
Member

Close report — landed on main @ 824686b

Ruled by agent under ADR 0174 — veto anytime. Two-way door throughout: a prompt-skeleton wording change + a heal.sh timeout flag, both revertible, both proven by the offline suite (no personal creds, no posture change, no data destruction).

What landed (part 3 of #122, the design/prompt half it could not):

  1. prompts/heal-prompt.md — new section “Every container you start MUST be reapable”: every agent-issued docker run (the bisect/repro containers the healer starts in a fresh clone) must carry --label matou.factory=heal --label matou.run=<heal-run-id>, or bind a cidfile + a docker rm -f cleanup trap. So #122’s label path in reap_containers reaps a leaked heal container at HEAL_REAP_CEILING (900s + slack) instead of waiting out the multi-hour image belt. The skeleton names the mechanism, carries no tracker number (the judgement-call-prompts gate forbids a number that would misresolve in every other consumer’s tracker — CLAUDE.md blast-radius rule).

  2. heal.sh — computes heal_run_db_id before building the prompt and hands the agent a concrete Heal run id in the incident block (it doubles as the swarm.db run id). The agent timeout is now timeout --kill-after=30 900: the 900s SIGTERM lets the agent’s cleanup trap run first, then a 30s-later SIGKILL backstops a wedged agent so it can never camp on the healer lock.

  3. Render goldens re-proven byte-identical — .sandcastle/heal-prompt.md (this repo’s own self-copy) and onboarding/tests/fixtures/idss-prompts/heal-prompt.md (the idss cutover golden), both re-rendered from the skeleton via the render pipeline.

Proof (offline suite): heal-test 17 (new scenario asserts the live prompt carries the label instruction + a concrete Heal run id, and that the source uses --kill-after), onboard-lib 235, judgement-call-prompts 33, prompt-render-lib 33, check-harness-drift 11, sweep-lib 14, heal-lib 20 — all green. (The only red anywhere was fleet-tui’s No module named pytest — a pre-existing venv env issue, no file this ticket touches.)

Residue / out of scope (unchanged): the product ci.yml --label matou.factory=ci half is pull-only (tracked as matou-app#331); the sweep’s belt reaps either regardless. Per GOTCHAS 4, this root/skeleton change reaches the factory’s running .sandcastle/heal.sh only when a human bumps the self-pin (onboard.sh vendor .sandcastle <sha>); the regenerated .sandcastle/heal-prompt.md and the matou.factory=heal label reap are effective now, and the belt covers the gap until then.

Acceptance met. Closing.

## Close report — landed on `main` @ 824686b Ruled by agent under ADR 0174 — veto anytime. Two-way door throughout: a prompt-skeleton wording change + a `heal.sh` timeout flag, both revertible, both proven by the offline suite (no personal creds, no posture change, no data destruction). **What landed (part 3 of #122, the design/prompt half it could not):** 1. **`prompts/heal-prompt.md`** — new section *“Every container you start MUST be reapable”*: every agent-issued `docker run` (the bisect/repro containers the healer starts in a fresh clone) must carry `--label matou.factory=heal --label matou.run=<heal-run-id>`, or bind a cidfile + a `docker rm -f` cleanup trap. So #122’s label path in `reap_containers` reaps a leaked heal container at `HEAL_REAP_CEILING` (900s + slack) instead of waiting out the multi-hour image belt. The skeleton **names the mechanism, carries no tracker number** (the judgement-call-prompts gate forbids a number that would misresolve in every other consumer’s tracker — CLAUDE.md blast-radius rule). 2. **`heal.sh`** — computes `heal_run_db_id` **before** building the prompt and hands the agent a concrete `Heal run id` in the incident block (it doubles as the swarm.db run id). The agent `timeout` is now `timeout --kill-after=30 900`: the 900s **SIGTERM** lets the agent’s cleanup trap run first, then a 30s-later **SIGKILL** backstops a wedged agent so it can never camp on the healer lock. 3. **Render goldens re-proven byte-identical** — `.sandcastle/heal-prompt.md` (this repo’s own self-copy) and `onboarding/tests/fixtures/idss-prompts/heal-prompt.md` (the idss cutover golden), both re-rendered from the skeleton via the render pipeline. **Proof (offline suite):** `heal-test` 17 (new scenario asserts the live prompt carries the label instruction + a concrete `Heal run id`, and that the source uses `--kill-after`), `onboard-lib` 235, `judgement-call-prompts` 33, `prompt-render-lib` 33, `check-harness-drift` 11, `sweep-lib` 14, `heal-lib` 20 — all green. (The only red anywhere was `fleet-tui`’s `No module named pytest` — a pre-existing venv env issue, no file this ticket touches.) **Residue / out of scope (unchanged):** the product `ci.yml` `--label matou.factory=ci` half is pull-only (tracked as matou-app#331); the sweep’s belt reaps either regardless. Per GOTCHAS 4, this root/skeleton change reaches the factory’s **running** `.sandcastle/heal.sh` only when a human bumps the self-pin (`onboard.sh vendor .sandcastle <sha>`); the regenerated `.sandcastle/heal-prompt.md` and the `matou.factory=heal` label reap are effective now, and the belt covers the gap until then. Acceptance met. Closing.
matou-build-agent 2026-09-03 16:51:59 +00:00
Author
Member

Audit note (second session — no action needed, ticket already correctly closed):

This ticket was drained concurrently by a second session-runner on
matou-workstation while elitebook-distributed-server-03 landed the fix
(824686b) and closed it. The matou-workstation session independently
produced a functionally-equivalent change (same acceptance: the
--label matou.factory=heal --label matou.run=<heal-run-id> skeleton
instruction, the Heal run id in the incident block, timeout --kill-after
around the agent, re-proven render goldens), discovered the upstream landing
on git pull --rebase, and discarded its duplicate (reset --hard origin/main) — nothing double-landed. It verified 824686b on origin/main
passes the offline suite (heal-test 17, onboard-lib 235, judgement-call-prompts
33 — all green).

No new work here. The coordination gap that let two hosts pick the same
ready-for-session ticket is filed as #125 (no atomic cross-host claim —
a full session wasted per collision). Ruled by agent under ADR 0174 — veto
anytime.

Audit note (second session — no action needed, ticket already correctly closed): This ticket was drained **concurrently** by a second session-runner on `matou-workstation` while `elitebook-distributed-server-03` landed the fix (`824686b`) and closed it. The matou-workstation session independently produced a functionally-equivalent change (same acceptance: the `--label matou.factory=heal --label matou.run=<heal-run-id>` skeleton instruction, the `Heal run id` in the incident block, `timeout --kill-after` around the agent, re-proven render goldens), discovered the upstream landing on `git pull --rebase`, and **discarded its duplicate** (`reset --hard origin/main`) — nothing double-landed. It verified `824686b` on origin/main passes the offline suite (heal-test 17, onboard-lib 235, judgement-call-prompts 33 — all green). No new work here. The coordination gap that let two hosts pick the same `ready-for-session` ticket is filed as **#125** (no atomic cross-host claim — a full session wasted per collision). Ruled by agent under ADR 0174 — veto anytime.
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#123
No description provided.