rehearsal healer: rebase before push so heals survive a moved origin/main (3 heals lost to non-fast-forward) #460

Closed
opened 2026-08-12 01:02:54 +00:00 by ben · 3 comments
Owner

Problem

The rehearsal healer diagnoses and fixes reds correctly, commits locally, and
pushes — but when anything else advances origin/main between the healer's base
and its push, the push is rejected non-fast-forward and the fix never lands.
The script-side rail correctly catches the missing-on-origin commit and falls
through to filing, so the invariant holds and no fake-heal ships — but the healer
is effectively neutered to diagnosis-only whenever there is concurrent push
activity (an operator sitting on the harness, or the swarm draining tickets).
Every "heal" then becomes a filed ticket + a full swarm round-trip anyway, which
is exactly the latency the healer was built to avoid.

Evidence — three consecutive drives, three lost heals (2026-08-11/12)

Drive Red leg Healer diagnosis Local commit Reached origin? Fell to
20260811T221125Z enroll-configure (kanidm serverSettings rename) correct (committed) no — push rejected non-fast-forward (healer-claude.err) #451
20260811T232725Z enroll-configure (sops ssh-key probe) correct 235c30f9 no — not on origin/main #456
20260812T000306Z control-plane (st.Node vs st.ClanNode) correct d68e840 no — object exists locally, absent from origin/main #457

In each case the diagnosis was right and later re-implemented verbatim by the
swarm from the filed ticket. The only thing that failed was landing the push
while origin/main moved underneath (e.g. #447/a234766 landing on top of the
#451 base the healer had branched from).

Note: this is distinct from the healer's judgment declines (e.g. #458), which
are correct and out of scope here — those are action:"file" by design. This
ticket is only about heals the healer committed and lost to the race.

Fix

Make the healer's push survive a moved origin/main by rebasing immediately
before pushing, inside the existing heal_rails in
.sandcastle/rehearsal-heal-lib.sh (after the diff-cap/self-mod checks, before
the final push + git ls-remote verification):

  1. git fetch origin main
  2. git rebase origin/main (or git pull --rebase origin main).
    • On a rebase conflict: git rebase --abort, git reset --hard to the
      pre-session head, and fall through to filing (a conflicting fix is no longer
      "small and certain"). This preserves the existing invariant.
  3. Re-run the diff cap after the rebase (git diff --stat origin/main..HEAD):
    a clean rebase can only shrink or preserve the healer's own diff, but re-check
    so a surprising rebase result still trips the cap → reset + file.
  4. Push; keep the existing git ls-remote verification that the healed commit is
    actually on origin/main before treating the red as healed.
  5. Optionally retry the fetch→rebase→push once on a second non-fast-forward
    (another push landed during our rebase); a second failure → reset + file, so
    this never spins.

The self-modification guard still applies unchanged: the rebased diff must not
touch ^\.sandcastle/rehearsal- or ^\.forgejo/workflows/.

Test

Extend the reporter's offline harness (fake run dir, stubbed claude, stubbed
git remote): a case where origin/main advances by one unrelated commit between
the healer's base and its push. Assert the heal now lands (commit present on
the fake origin, #378 commented, drive left armed) instead of falling to
filing. Keep the existing conflict case asserting reset + file.

Out of scope

  • The healer's judgment declines (#458 class) — correct as-is.
  • Any change to the diff cap, self-mod guard, or keyword scrub other than
    re-running the cap post-rebase.

Relates to the rehearsal healer design
(docs/superpowers/specs/2026-08-10-rehearsal-healer-design.md) and the standing
drive issue #378. Discovered while watching the own-VPS control-plane arc
(#443 → #457 → #458).

## Problem The rehearsal healer diagnoses and fixes reds correctly, commits locally, and pushes — but when anything else advances `origin/main` between the healer's base and its push, the push is rejected **non-fast-forward** and the fix never lands. The script-side rail correctly catches the missing-on-origin commit and falls through to filing, so the invariant holds and no fake-heal ships — but the healer is effectively **neutered to diagnosis-only** whenever there is concurrent push activity (an operator sitting on the harness, or the swarm draining tickets). Every "heal" then becomes a filed ticket + a full swarm round-trip anyway, which is exactly the latency the healer was built to avoid. ## Evidence — three consecutive drives, three lost heals (2026-08-11/12) | Drive | Red leg | Healer diagnosis | Local commit | Reached origin? | Fell to | | --- | --- | --- | --- | --- | --- | | `20260811T221125Z` | enroll-configure (kanidm `serverSettings` rename) | correct | (committed) | no — push **rejected non-fast-forward** (`healer-claude.err`) | #451 | | `20260811T232725Z` | enroll-configure (sops ssh-key probe) | correct | `235c30f9` | no — not on `origin/main` | #456 | | `20260812T000306Z` | control-plane (`st.Node` vs `st.ClanNode`) | correct | `d68e840` | no — object exists locally, absent from `origin/main` | #457 | In each case the diagnosis was right and later re-implemented verbatim by the swarm from the filed ticket. The only thing that failed was landing the push while `origin/main` moved underneath (e.g. `#447`/`a234766` landing on top of the `#451` base the healer had branched from). Note: this is distinct from the healer's **judgment** declines (e.g. #458), which are correct and out of scope here — those are `action:"file"` by design. This ticket is only about heals the healer *committed* and lost to the race. ## Fix Make the healer's push survive a moved `origin/main` by rebasing immediately before pushing, inside the existing `heal_rails` in `.sandcastle/rehearsal-heal-lib.sh` (after the diff-cap/self-mod checks, before the final push + `git ls-remote` verification): 1. `git fetch origin main` 2. `git rebase origin/main` (or `git pull --rebase origin main`). - On a **rebase conflict**: `git rebase --abort`, `git reset --hard` to the pre-session head, and fall through to filing (a conflicting fix is no longer "small and certain"). This preserves the existing invariant. 3. **Re-run the diff cap after the rebase** (`git diff --stat origin/main..HEAD`): a clean rebase can only shrink or preserve the healer's own diff, but re-check so a surprising rebase result still trips the cap → reset + file. 4. Push; keep the existing `git ls-remote` verification that the healed commit is actually on `origin/main` before treating the red as healed. 5. Optionally retry the fetch→rebase→push once on a *second* non-fast-forward (another push landed during our rebase); a second failure → reset + file, so this never spins. The self-modification guard still applies unchanged: the rebased diff must not touch `^\.sandcastle/rehearsal-` or `^\.forgejo/workflows/`. ## Test Extend the reporter's offline harness (fake run dir, stubbed `claude`, stubbed git remote): a case where `origin/main` advances by one unrelated commit between the healer's base and its push. Assert the heal now **lands** (commit present on the fake origin, `#378` commented, drive left armed) instead of falling to filing. Keep the existing conflict case asserting reset + file. ## Out of scope - The healer's judgment declines (#458 class) — correct as-is. - Any change to the diff cap, self-mod guard, or keyword scrub other than re-running the cap post-rebase. Relates to the rehearsal healer design (`docs/superpowers/specs/2026-08-10-rehearsal-healer-design.md`) and the standing drive issue #378. Discovered while watching the own-VPS control-plane arc (#443 → #457 → #458).
Author
Owner

This was generated by AI during triage.

Triage: bug / ready-for-agent. Verified: the three cited healer commits
(235c30f9, d68e840, and the third from 20260811T221125Z) exist as loose
objects in the repo but are not ancestors of main — confirmed with
git merge-base --is-ancestor. The three drive timestamps in the evidence
table line up with the created_at of the filed tickets (#451, #456, #457).
No existing fetch/rebase step exists in the healer's push path today, so
this isn't already implemented. No .out-of-scope/ entry matches this
request.

One correction to the issue text: step 4 of the Fix section says to "keep
the existing git ls-remote verification" — that verification is described
in the design spec but was never actually implemented; the current push
step only checks the git push exit code. See "Out of scope" below.

Agent Brief

Category: bug
Summary: The healer's push step doesn't survive a moved origin/main —
correct heals are lost to non-fast-forward pushes instead of landing.

Current behavior:
The healer validates its local commit (single commit, diff-cap, no
self-modification) and then pushes it directly to origin/main. If another
commit lands on origin/main after the healer's session started (an
operator on the harness, or the swarm draining tickets concurrently), the
push is rejected non-fast-forward. The local commit is then reverted and the
drive falls through to the filing flow — a correct diagnosis is discarded
and has to be independently re-diagnosed and re-implemented via a full
ticket + swarm round-trip, which is exactly the latency the healer exists to
avoid.

Desired behavior:
Before pushing, fetch origin/main and rebase the healer's commit onto it.
On a clean rebase, re-run the existing diff-cap check (≤3 files, ≤60 changed
lines) against the rebased diff before pushing — a clean rebase can only
shrink or preserve the original diff, but a surprising rebase result should
still trip the cap. The self-modification guard (never touching the
healer's own harness/workflow paths) must also be re-checked against the
post-rebase diff. Then push:

  • On success, proceed exactly as today (comment on the drive issue, leave it
    armed).
  • On a rebase conflict, abort the rebase, reset to the pre-session head,
    and fall through to the existing filing path unchanged — a conflicting
    fix is no longer "small and certain."
  • On a second non-fast-forward (another push landed during the rebase),
    retry the fetch→rebase→push cycle exactly once more; a second failure
    falls through to filing rather than retrying indefinitely.

Key interfaces:

  • The diff-cap / self-modification gate function (currently heal_rails in
    the healer's rails library) — needs to be re-runnable against a diff range
    that reflects the post-rebase commit, not just the original one.
  • The push step in the healer's report/heal flow — needs a fetch+rebase
    step inserted before the push, with the bounded (one) retry on
    non-fast-forward described above.
  • The offline test harness for the healer (fake run dir, stubbed claude,
    stubbed git remote) — needs a way to simulate origin/main advancing
    between the healer's base and its push.

Acceptance criteria:

  • A heal whose local commit passes the existing caps but has a stale
    base relative to origin/main is rebased onto latest origin/main
    before pushing, and the push succeeds when the rebase is clean.
  • After a clean rebase, the diff-cap check (≤3 files, ≤60 lines) is
    re-evaluated against the rebased diff; a cap breach post-rebase
    reverts and falls to filing exactly as a pre-rebase breach does today.
  • The self-modification guard is re-checked against the post-rebase
    diff.
  • A rebase conflict resets to the pre-session head and falls through to
    the existing filing path, leaving no partial/conflicted state.
  • If origin/main moves again during the rebase, the
    fetch→rebase→push sequence is retried exactly once; a second failure
    falls through to filing.
  • The offline test harness covers: (a) origin/main advancing by one
    unrelated commit between the healer's base and its push → the heal
    now lands (rebased commit present on the fake origin, drive left
    armed) instead of falling to filing, and (b) the existing
    rebase-conflict case still reverts + files.

Out of scope:

  • The healer's judgment declines (correctly declining to act) — unrelated,
    no change needed.
  • Changing the diff-cap thresholds, the self-modification guard's path
    list, or the commit-message keyword scrub, beyond re-running the existing
    diff-cap check post-rebase.
  • Adding a new post-push landing verification (e.g. a git ls-remote check
    that the pushed commit is actually on origin/main). The issue text
    refers to this as "the existing" verification, but no such check
    currently exists in the codebase — don't add one as part of this ticket
    unless it's structurally required to implement the retry-once semantics
    above.
> *This was generated by AI during triage.* **Triage:** `bug` / `ready-for-agent`. Verified: the three cited healer commits (`235c30f9`, `d68e840`, and the third from `20260811T221125Z`) exist as loose objects in the repo but are **not** ancestors of `main` — confirmed with `git merge-base --is-ancestor`. The three drive timestamps in the evidence table line up with the `created_at` of the filed tickets (#451, #456, #457). No existing fetch/rebase step exists in the healer's push path today, so this isn't already implemented. No `.out-of-scope/` entry matches this request. One correction to the issue text: step 4 of the Fix section says to "keep the existing `git ls-remote` verification" — that verification is described in the design spec but was never actually implemented; the current push step only checks the `git push` exit code. See "Out of scope" below. ## Agent Brief **Category:** bug **Summary:** The healer's push step doesn't survive a moved `origin/main` — correct heals are lost to non-fast-forward pushes instead of landing. **Current behavior:** The healer validates its local commit (single commit, diff-cap, no self-modification) and then pushes it directly to `origin/main`. If another commit lands on `origin/main` after the healer's session started (an operator on the harness, or the swarm draining tickets concurrently), the push is rejected non-fast-forward. The local commit is then reverted and the drive falls through to the filing flow — a correct diagnosis is discarded and has to be independently re-diagnosed and re-implemented via a full ticket + swarm round-trip, which is exactly the latency the healer exists to avoid. **Desired behavior:** Before pushing, fetch `origin/main` and rebase the healer's commit onto it. On a clean rebase, re-run the existing diff-cap check (≤3 files, ≤60 changed lines) against the rebased diff before pushing — a clean rebase can only shrink or preserve the original diff, but a surprising rebase result should still trip the cap. The self-modification guard (never touching the healer's own harness/workflow paths) must also be re-checked against the post-rebase diff. Then push: - On success, proceed exactly as today (comment on the drive issue, leave it armed). - On a **rebase conflict**, abort the rebase, reset to the pre-session head, and fall through to the existing filing path unchanged — a conflicting fix is no longer "small and certain." - On a **second non-fast-forward** (another push landed during the rebase), retry the fetch→rebase→push cycle exactly once more; a second failure falls through to filing rather than retrying indefinitely. **Key interfaces:** - The diff-cap / self-modification gate function (currently `heal_rails` in the healer's rails library) — needs to be re-runnable against a diff range that reflects the *post-rebase* commit, not just the original one. - The push step in the healer's report/heal flow — needs a fetch+rebase step inserted before the push, with the bounded (one) retry on non-fast-forward described above. - The offline test harness for the healer (fake run dir, stubbed `claude`, stubbed git remote) — needs a way to simulate `origin/main` advancing between the healer's base and its push. **Acceptance criteria:** - [ ] A heal whose local commit passes the existing caps but has a stale base relative to `origin/main` is rebased onto latest `origin/main` before pushing, and the push succeeds when the rebase is clean. - [ ] After a clean rebase, the diff-cap check (≤3 files, ≤60 lines) is re-evaluated against the rebased diff; a cap breach post-rebase reverts and falls to filing exactly as a pre-rebase breach does today. - [ ] The self-modification guard is re-checked against the post-rebase diff. - [ ] A rebase conflict resets to the pre-session head and falls through to the existing filing path, leaving no partial/conflicted state. - [ ] If `origin/main` moves again during the rebase, the fetch→rebase→push sequence is retried exactly once; a second failure falls through to filing. - [ ] The offline test harness covers: (a) `origin/main` advancing by one unrelated commit between the healer's base and its push → the heal now lands (rebased commit present on the fake origin, drive left armed) instead of falling to filing, and (b) the existing rebase-conflict case still reverts + files. **Out of scope:** - The healer's judgment declines (correctly declining to act) — unrelated, no change needed. - Changing the diff-cap thresholds, the self-modification guard's path list, or the commit-message keyword scrub, beyond re-running the existing diff-cap check post-rebase. - Adding a new post-push landing verification (e.g. a `git ls-remote` check that the pushed commit is actually on `origin/main`). The issue text refers to this as "the existing" verification, but no such check currently exists in the codebase — don't add one as part of this ticket unless it's structurally required to implement the retry-once semantics above.
Author
Owner

Blocked — machinery change in a protected path; a swarm worker cannot land this.

The entire fix for this ticket lives inside .sandcastle/:

  • the fetch→rebase→push logic goes in .sandcastle/rehearsal-heal-lib.sh (heal_rails);
  • the offline-harness test extension goes in .sandcastle/rehearsal-report.sh.

.sandcastle/ (and .forgejo/) are protected paths — the healer/harness that judges swarm work. .sandcastle/protected-paths-lib.sh (PP_PROTECTED_DIRS_DEFAULT=".sandcastle .forgejo", shipped by #445) fingerprints the protected set before and after every swarm run, attributes any create/delete/change under it, rolls it back, and fails the run loud — and git-fence backstops on top. So a Sandcastle worker physically cannot deliver this change: every edit it needs is rolled back before the commit lands, and the run reds.

Per CLAUDE.md rule 9, a change to protected machinery is ruled on and made by a human, not by a swarm agent. This ticket is a legitimate machinery bug (the triage note above verified the three lost heals and that no fetch/rebase step exists today), but it was labelled ready-for-agent in error — it is a ready-for-human item.

To re-arm: a human implements the fetch→rebase→push (with the post-rebase diff-cap + self-mod re-check, conflict→reset+file, and one bounded non-fast-forward retry) plus the offline-harness case directly against .sandcastle/, or explicitly authorises an agent to touch the protected paths for this ticket. Swapping ready-for-agent → ready-for-human and releasing my claim (run 4869) so it stops looping through the agent queue.

**Blocked — machinery change in a protected path; a swarm worker cannot land this.** The entire fix for this ticket lives inside `.sandcastle/`: - the fetch→rebase→push logic goes in `.sandcastle/rehearsal-heal-lib.sh` (`heal_rails`); - the offline-harness test extension goes in `.sandcastle/rehearsal-report.sh`. `.sandcastle/` (and `.forgejo/`) are **protected paths** — the healer/harness that judges swarm work. `.sandcastle/protected-paths-lib.sh` (`PP_PROTECTED_DIRS_DEFAULT=".sandcastle .forgejo"`, shipped by #445) fingerprints the protected set before and after every swarm run, **attributes any create/delete/change under it, rolls it back, and fails the run loud** — and `git-fence` backstops on top. So a Sandcastle worker physically cannot deliver this change: every edit it needs is rolled back before the commit lands, and the run reds. Per `CLAUDE.md` rule 9, a change to protected machinery is ruled on and made by a human, not by a swarm agent. This ticket is a legitimate machinery bug (the triage note above verified the three lost heals and that no fetch/rebase step exists today), but it was labelled `ready-for-agent` in error — it is a `ready-for-human` item. **To re-arm:** a human implements the fetch→rebase→push (with the post-rebase diff-cap + self-mod re-check, conflict→reset+file, and one bounded non-fast-forward retry) plus the offline-harness case directly against `.sandcastle/`, or explicitly authorises an agent to touch the protected paths for this ticket. Swapping `ready-for-agent` → `ready-for-human` and releasing my claim (run 4869) so it stops looping through the agent queue.
Author
Owner

Re-blocked — same protected-path ruling as #6344 still stands (run 5065).

This ticket returned to the agent queue and I (run 5065, matou-dev-server-01) claimed it, but nothing has changed since ben's ruling in #6344: the entire deliverable lives in protected .sandcastle/ paths —

  • fetch→rebase→push + post-rebase diff-cap/self-mod re-check → .sandcastle/rehearsal-heal-lib.sh (heal_rails);
  • the offline-harness case → .sandcastle/rehearsal-report.sh / .sandcastle/tests/.

.sandcastle/ is a fingerprinted protected directory (PP_PROTECTED_DIRS_DEFAULT=".sandcastle .forgejo", #445): every create/change under it is attributed to the worker, rolled back, and the run failed loud. These are also the exact ^\.sandcastle/rehearsal- paths the healer's own self-modification guard forbids. Per CLAUDE.md rule 9 a swarm agent must not edit protected machinery, and no comment here has added the explicit human authorization #6344 named as the alternative re-arm path.

So a Sandcastle worker still physically cannot deliver this. Re-routing ready-for-agent → ready-for-human and releasing my claim (run 5065) so it stops looping through the agent queue. To re-arm: a human implements the change directly against .sandcastle/, or explicitly authorizes an agent to touch the protected paths for this ticket (state that here).

**Re-blocked — same protected-path ruling as [#6344](../460#issuecomment-6344) still stands (run 5065).** This ticket returned to the agent queue and I (run 5065, `matou-dev-server-01`) claimed it, but nothing has changed since ben's ruling in #6344: the entire deliverable lives in protected `.sandcastle/` paths — - fetch→rebase→push + post-rebase diff-cap/self-mod re-check → `.sandcastle/rehearsal-heal-lib.sh` (`heal_rails`); - the offline-harness case → `.sandcastle/rehearsal-report.sh` / `.sandcastle/tests/`. `.sandcastle/` is a fingerprinted protected directory (`PP_PROTECTED_DIRS_DEFAULT=".sandcastle .forgejo"`, #445): every create/change under it is attributed to the worker, **rolled back, and the run failed loud**. These are also the exact `^\.sandcastle/rehearsal-` paths the healer's own self-modification guard forbids. Per CLAUDE.md rule 9 a swarm agent must not edit protected machinery, and no comment here has added the explicit human authorization #6344 named as the alternative re-arm path. So a Sandcastle worker still physically cannot deliver this. Re-routing `ready-for-agent` → `ready-for-human` and releasing my claim (run 5065) so it stops looping through the agent queue. **To re-arm:** a human implements the change directly against `.sandcastle/`, or explicitly authorizes an agent to touch the protected paths for this ticket (state that here).
ben closed this issue 2026-08-12 15:20:25 +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#460
No description provided.