rehearsal healer hard-resets the shared swarm checkout — give it a dedicated clone (session-runner pattern) #576

Closed
opened 2026-08-15 06:01:30 +00:00 by ben · 2 comments
Owner

Bug — rehearsal healer hard-resets the SHARED swarm checkout

rehearsal-report.sh:25 points REHEARSAL_CHECKOUT at /home/dev/swarm/Matou/ourcloud — the same checkout peer sessions work in (unpushed peer work has lived there before). rehearsal-heal-lib.sh runs git reset --hard there on five separate paths; the only guard is a dirty-tree refusal at rehearsal-report.sh:98 — a TOCTOU check with no lock.

session-runner.sh:134-141 already ruled the opposite way for exactly this reason ("NEVER the shared swarm checkout — peers work there") and uses a dedicated clone. The healer predates that lesson.

Fix

Give the rehearsal healer its own dedicated clone (mirror the session-runner pattern: separate directory, fresh reset each heal, push through the same verified-push rails). REHEARSAL_CHECKOUT default moves off the shared path.

Two-way door; agent-shaped — the healer's own rails (rehearsal-heal-lib.sh caps + verified push) are untouched. Filed ready-for-human per Ben's instruction — re-arm at will.

## Bug — rehearsal healer hard-resets the SHARED swarm checkout `rehearsal-report.sh:25` points `REHEARSAL_CHECKOUT` at `/home/dev/swarm/Matou/ourcloud` — the same checkout peer sessions work in (unpushed peer work has lived there before). `rehearsal-heal-lib.sh` runs `git reset --hard` there on **five separate paths**; the only guard is a dirty-tree refusal at `rehearsal-report.sh:98` — a TOCTOU check with no lock. `session-runner.sh:134-141` already ruled the opposite way for exactly this reason ("NEVER the shared swarm checkout — peers work there") and uses a dedicated clone. The healer predates that lesson. ## Fix Give the rehearsal healer its own dedicated clone (mirror the session-runner pattern: separate directory, fresh reset each heal, push through the same verified-push rails). `REHEARSAL_CHECKOUT` default moves off the shared path. Two-way door; agent-shaped — the healer's own rails (`rehearsal-heal-lib.sh` caps + verified push) are untouched. Filed ready-for-human per Ben's instruction — re-arm at will.
Author
Owner

Blocked — this fix is entirely a protected .sandcastle/ change (needs a session, not a swarm worker)

The whole deliverable lives inside protected paths:

  • .sandcastle/rehearsal-report.sh (the REHEARSAL_CHECKOUT default at line 25)
  • .sandcastle/rehearsal-heal-lib.sh (the git reset --hard rails)

.sandcastle/ is a fingerprinted protected directory (protected-paths-lib.sh, PP_PROTECTED_DIRS_DEFAULT=".sandcastle .forgejo", #445). A swarm worker that edits any file there has the change rolled back and the run failed loud — the boundary is an outcome check, not a blocklist, so there is no way for me to ship this fix. The healer scripts are not in the exempt set (PP_EXEMPT_GLOBS only covers the *matou-heal-* evidence dirs, not the machinery itself).

Why session (ADR 0174)

Per docs/agents/triage-labels.md and the verbatim escape path in protected-paths-lib.sh: a protected .sandcastle/ path per #445 needs an interactive agent session's standing, not Ben — ready-for-session, not ready-for-agent. The queue (list-ready-tasks.sh) reads only ready-for-agent, so this was mislabeled and is invisible-by-design to workers otherwise.

The fix itself is well-scoped and sound (mirror session-runner.sh:134-141: dedicated clone off the shared /home/dev/swarm/Matou/ourcloud path, fresh reset per heal, same verified-push rails). It just has to be executed by a session, which has the standing to touch .sandcastle/.

Swapping ready-for-agent → ready-for-session and releasing the swarm claim.

## Blocked — this fix is entirely a protected `.sandcastle/` change (needs a session, not a swarm worker) The whole deliverable lives inside protected paths: - `.sandcastle/rehearsal-report.sh` (the `REHEARSAL_CHECKOUT` default at line 25) - `.sandcastle/rehearsal-heal-lib.sh` (the `git reset --hard` rails) `.sandcastle/` is a **fingerprinted protected directory** (`protected-paths-lib.sh`, `PP_PROTECTED_DIRS_DEFAULT=".sandcastle .forgejo"`, #445). A swarm worker that edits any file there has the change **rolled back and the run failed loud** — the boundary is an outcome check, not a blocklist, so there is no way for me to ship this fix. The healer scripts are not in the exempt set (`PP_EXEMPT_GLOBS` only covers the `*matou-heal-*` evidence dirs, not the machinery itself). ## Why session (ADR 0174) Per `docs/agents/triage-labels.md` and the verbatim escape path in `protected-paths-lib.sh`: a protected `.sandcastle/` path per #445 needs **an interactive agent session's standing, not Ben** — `ready-for-session`, not `ready-for-agent`. The queue (`list-ready-tasks.sh`) reads only `ready-for-agent`, so this was mislabeled and is invisible-by-design to workers otherwise. The fix itself is well-scoped and sound (mirror `session-runner.sh:134-141`: dedicated clone off the shared `/home/dev/swarm/Matou/ourcloud` path, fresh reset per heal, same verified-push rails). It just has to be executed by a session, which has the standing to touch `.sandcastle/`. Swapping `ready-for-agent` → `ready-for-session` and releasing the swarm claim.
Author
Owner

Ruled by agent under ADR 0174 — veto anytime.

Ruling: two-way door. This is a commit/config change (default REHEARSAL_CHECKOUT value + the checkout-bootstrap logic in try_heal()), fully revertible by git revert, and provable by the two offline test suites plus a live probe — none of it touches a one-way door (no credential, no security-posture widening, no member-facing trust surface, no data destruction).

What landed (commit dced853):

  • REHEARSAL_CHECKOUT no longer defaults to /home/dev/swarm/Matou/ourcloud (the shared swarm checkout peer sessions work in). It now defaults to $HOME/rehearsal-heal/ourcloud — a dedicated clone, mirroring session-runner.sh's own pattern. New REHEARSAL_HEAL_REPO names the clone source.
  • try_heal() clones on first use, then does fetch + reset --hard origin/main + clean -fd before every heal attempt (not just once) — same shape as session-runner.sh:135-141. This replaces the old dirty-tree TOCTOU refusal: on a dedicated checkout there's no peer left to race, and a self-reset means a session killed mid-run (the timeout 1800 around the claude call has no cleanup trap) self-heals on the next attempt instead of wedging the healer forever.
  • heal_rails/heal_push (caps, single-commit rule, self-mod guard, verified push with rebase-retry) are untouched, per the ticket's ask.

Proof:

  • bash .sandcastle/tests/rehearsal-healer-test.sh — 12 cases green. Case 12 (the rebase-conflict path) was rewritten to race the origin push during the simulated heal session (via the claude shim, using a throwaway clone) rather than before it starts, since the checkout is now always caught up to origin/main before the healer session begins — the race window moved to exactly where heal_push's own fetch+rebase-before-push already lives, and the test now exercises that.
  • bash .sandcastle/tests/rehearsal-report-test.sh — 25 cases green (updated to point the clone source at a nonexistent local path for the legacy no-checkout cases, keeping the suite hermetic/network-free).
  • Live probe on this host: git clone https://git.matou.nz/Matou/ourcloud.git ~/rehearsal-heal/ourcloud (using the host's stored credential helper, no token embedded) succeeded, and a follow-up fetch + reset --hard origin/main + clean -fd against it also succeeded — the exact sequence try_heal() runs, proven against the real remote, not just shimmed.

Closing.

Ruled by agent under ADR 0174 — veto anytime. **Ruling:** two-way door. This is a commit/config change (default `REHEARSAL_CHECKOUT` value + the checkout-bootstrap logic in `try_heal()`), fully revertible by `git revert`, and provable by the two offline test suites plus a live probe — none of it touches a one-way door (no credential, no security-posture widening, no member-facing trust surface, no data destruction). **What landed** (commit `dced853`): - `REHEARSAL_CHECKOUT` no longer defaults to `/home/dev/swarm/Matou/ourcloud` (the shared swarm checkout peer sessions work in). It now defaults to `$HOME/rehearsal-heal/ourcloud` — a dedicated clone, mirroring `session-runner.sh`'s own pattern. New `REHEARSAL_HEAL_REPO` names the clone source. - `try_heal()` clones on first use, then does `fetch` + `reset --hard origin/main` + `clean -fd` before **every** heal attempt (not just once) — same shape as `session-runner.sh:135-141`. This replaces the old dirty-tree TOCTOU refusal: on a dedicated checkout there's no peer left to race, and a self-reset means a session killed mid-run (the `timeout 1800` around the claude call has no cleanup trap) self-heals on the next attempt instead of wedging the healer forever. - `heal_rails`/`heal_push` (caps, single-commit rule, self-mod guard, verified push with rebase-retry) are untouched, per the ticket's ask. **Proof:** - `bash .sandcastle/tests/rehearsal-healer-test.sh` — 12 cases green. Case 12 (the rebase-conflict path) was rewritten to race the origin push *during* the simulated heal session (via the claude shim, using a throwaway clone) rather than before it starts, since the checkout is now always caught up to `origin/main` before the healer session begins — the race window moved to exactly where `heal_push`'s own fetch+rebase-before-push already lives, and the test now exercises that. - `bash .sandcastle/tests/rehearsal-report-test.sh` — 25 cases green (updated to point the clone source at a nonexistent local path for the legacy no-checkout cases, keeping the suite hermetic/network-free). - Live probe on this host: `git clone https://git.matou.nz/Matou/ourcloud.git ~/rehearsal-heal/ourcloud` (using the host's stored credential helper, no token embedded) succeeded, and a follow-up `fetch` + `reset --hard origin/main` + `clean -fd` against it also succeeded — the exact sequence `try_heal()` runs, proven against the real remote, not just shimmed. Closing.
ben closed this issue 2026-08-19 17:29:11 +00:00
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/idss#576
No description provided.