healer: decide whether the swarm healer needs a landing gate before pushing main (pr-default repos) — #164/#165 residual #167

Closed
opened 2026-09-22 20:27:35 +00:00 by matou-build-agent · 2 comments

Follow-up from #165 (which taught session-runner.sh to skip a landing-pr ticket rather than push it to main).

#164's known gap named TWO direct-to-main pushers: session-runner.sh (fixed in #165) and heal.sh. The healer half needs its own analysis:

  • The healer is fault-driven, not ticket-driven — it works Forgejo Actions/workflow failures and the hourly watchdog sweep, and never claims a ready-for-session/ready-for-agent ticket. So a landing-pr ticket can never reach it: the literal #165 concern ("push a landing-pr ticket to main") is vacuous for the healer.
  • The distinct residual concern: the healer's claude investigation can COMMIT a harness-infra repair, and its session pushes to main. In a pr-DEFAULT repo that push bypasses the PR rail (idss ADR 0267) — nothing ticket-shaped, but still an unattended agent landing on main where the repo demands review.

Decide and (if warranted) fix: does the healer need a landing_mode_for/policy gate before it pushes in a pr-default repo, or is the healer legitimately out of scope (harness-infra only, one attempt, product code forbidden)? Note factory + idss are both push repos today, so this bites only a future pr-default consumer that also runs the healer.

Ruled by agent under ADR 0174 — veto anytime. Filed by the standing session working #165.

Follow-up from #165 (which taught `session-runner.sh` to skip a `landing-pr` ticket rather than push it to `main`). #164's known gap named TWO direct-to-main pushers: `session-runner.sh` (fixed in #165) and `heal.sh`. The healer half needs its own analysis: - The healer is **fault-driven**, not ticket-driven — it works Forgejo Actions/workflow failures and the hourly watchdog sweep, and never claims a `ready-for-session`/`ready-for-agent` ticket. So a `landing-pr` **ticket** can never reach it: the literal #165 concern ("push a landing-pr ticket to main") is vacuous for the healer. - The **distinct** residual concern: the healer's claude investigation can COMMIT a harness-infra repair, and its session pushes to `main`. In a **pr-DEFAULT** repo that push bypasses the PR rail (idss ADR 0267) — nothing ticket-shaped, but still an unattended agent landing on `main` where the repo demands review. Decide and (if warranted) fix: does the healer need a `landing_mode_for`/policy gate before it pushes in a pr-default repo, or is the healer legitimately out of scope (harness-infra only, one attempt, product code forbidden)? Note factory + idss are both push repos today, so this bites only a future pr-default consumer that also runs the healer. Ruled by agent under ADR 0174 — veto anytime. Filed by the standing session working #165.
Author
Member

This was generated by AI during triage.

Ruled by agent under ADR 0174 — veto anytime.

Ruling: YES, the healer needs the landing gate — routed to ready-for-session

I verified the ticket's analysis against the code and it holds up:

  • The literal #165 concern is vacuous for the healer — confirmed. heal.sh is fault-driven with no claim path: MODE="${HEAL_MODE:-hook}" and the only two modes are hook (a workflow-failure step) and watchdog (the hourly healer.yml sweep). It never claims a ready-for-session/ready-for-agent ticket, so a landing-pr ticket can never reach it. Nothing to do on that half.
  • The distinct residual is real and unguarded. heal.sh sources heal-lib.sh, limit-lib.sh, model-lib.sh, host-capacity-lib.sh, swarm-db-lib.sh, identity-lib.sh, swarm-identity.sh — not landing-lib.sh or policy-lib.sh. It consults no landing policy at all. Its agent is told unconditionally, via the repairs enrichment, to rebase on origin/main, push to main. So in a pr-default repo the healer's harness-infra repair lands on main and bypasses the PR rail that landing-lib.sh (landing_mode_for → push|pr, landing_push) enforces for every other pusher — including the twin fixed in #165 (session-runner.sh now skips a pr-mode ticket via landing_mode_for, failing closed).

Ruling: close the exception. The healer is the sole unattended agent that reaches main without a landing-mode consult; leaving that hole open "because no consumer hits it yet" is exactly the latent trap the factory's blast-radius discipline warns against, and the fix mirrors an already-landed pattern (#165). This is not a reason to declare the healer out-of-scope: "harness-infra only, one attempt" bounds what it repairs, not how it lands, and the pr-default contract is about the second.

Why this is a two-way door (ADR 0174): adding — or later reverting — the gate is a single revertible commit. It is provable by an offline test (shimmed git/claude) asserting that with SWARM_POLICY_LANDING=pr the healer refuses to push to main (escalates or PR-routes), and with the default (push) it behaves exactly as today. It is not on the one-way-door list: it tightens rather than widens security posture, and touches no personal credentials, no spend, no data destruction, no member-facing trust accept.

Scope note: no current consumer exhibits wrong behaviour — factory + idss are both push repos — so this is defensive hardening (hence enhancement, not bug). If a pr-default consumer that also runs the healer is onboarded before this lands, it reclassifies to a live bug; add priority then.

Why ready-for-session, not ready-for-agent

The swarm queue reads only ready-for-agent, and a complete fix crosses session-only, high-blast-radius paths that are invisible to workers by construction:

  • The healer's actual push is issued by the agent following prose in .sandcastle/prompt-enrichments/repairs.md (push to main) — a .sandcastle/ vendored-self-copy file.
  • The healer's charter that the residual is really about — prompts/heal-prompt.md's "Allowed repairs (harness-infra only, ONE attempt) … push to main" — is a prompt skeleton (live text for every future healer session).

Both are session-only edits per docs/agents/triage-labels.md. The heal.sh code gate rides along in the same session.

Brief for the session

Goal: the healer must not push a harness-infra repair straight to main in a repo whose SWARM_POLICY_LANDING=pr; it consults the same landing-mode seam every other pusher uses.

Do:

  1. In heal.sh, source landing-lib.sh + policy-lib.sh and load policy (policy_load "${SWARM_POLICY_FILE:-}"), mirroring the #165 hunk in session-runner.sh. Before the repair run reaches its push, gate on the repo landing mode (SWARM_POLICY_LANDING / landing_mode_for): in pr mode the healer must not direct-push to main. Pick the behaviour deliberately and record it in the charter — either (a) short-circuit to file-a-ticket + ESCALATE: yes (simplest; preserves "one attempt, then report"), or (b) route the repair through a PR (agent/heal-*, human-merged). (a) is the smaller, more faithful change and is the recommended default; note the choice in the ticket for the async veto.
  2. Update the healer prose to match: prompts/heal-prompt.md's "Allowed repairs … push to main" and .sandcastle/prompt-enrichments/repairs.md's "rebase on origin/main, push to main" must both become conditional on push-default (or say "escalate instead in a pr-default repo"), so the rendered charter never contradicts the code gate.
  3. Remember the render step: a prompts/*.md skeleton change needs onboard.sh render-prompts and the cutover-proof fixtures re-proven / deliberately updated (onboarding/tests/onboard-lib-test.sh), per CLAUDE.md.

Prove: add/extend an offline heal.sh test (shimmed git/claude, no network) asserting the two-way-door invariant above — SWARM_POLICY_LANDING=pr ⇒ no git push … main from the healer (escalates or PRs); default ⇒ unchanged. Every lib change updates its test in the same commit. Run the full offline suite before close.

Files: heal.sh, prompts/heal-prompt.md, .sandcastle/prompt-enrichments/repairs.md, a heal.sh test under tests/, and STATUS.md (state change). Vendoring the self-copy stays a human pin bump (onboarding/onboard.sh vendor .sandcastle <sha>, GOTCHAS 4) — do not hand-edit the running .sandcastle/heal.sh.

> *This was generated by AI during triage.* **Ruled by agent under ADR 0174 — veto anytime.** ## Ruling: YES, the healer needs the landing gate — routed to `ready-for-session` I verified the ticket's analysis against the code and it holds up: - **The literal #165 concern is vacuous for the healer — confirmed.** `heal.sh` is fault-driven with no claim path: `MODE="${HEAL_MODE:-hook}"` and the only two modes are `hook` (a workflow-failure step) and `watchdog` (the hourly `healer.yml` sweep). It never claims a `ready-for-session`/`ready-for-agent` ticket, so a `landing-pr` *ticket* can never reach it. Nothing to do on that half. - **The distinct residual is real and unguarded.** `heal.sh` sources `heal-lib.sh, limit-lib.sh, model-lib.sh, host-capacity-lib.sh, swarm-db-lib.sh, identity-lib.sh, swarm-identity.sh` — **not** `landing-lib.sh` or `policy-lib.sh`. It consults no landing policy at all. Its agent is told unconditionally, via the repairs enrichment, to `rebase on origin/main, push to main`. So in a **pr-default** repo the healer's harness-infra repair lands on `main` and bypasses the PR rail that `landing-lib.sh` (`landing_mode_for` → `push|pr`, `landing_push`) enforces for every *other* pusher — including the twin fixed in #165 (`session-runner.sh` now skips a `pr`-mode ticket via `landing_mode_for`, failing closed). **Ruling:** close the exception. The healer is the sole unattended agent that reaches `main` without a landing-mode consult; leaving that hole open "because no consumer hits it yet" is exactly the latent trap the factory's blast-radius discipline warns against, and the fix mirrors an already-landed pattern (#165). This is **not** a reason to declare the healer out-of-scope: "harness-infra only, one attempt" bounds *what* it repairs, not *how it lands*, and the pr-default contract is about the second. **Why this is a two-way door (ADR 0174):** adding — or later reverting — the gate is a single revertible commit. It is provable by an offline test (shimmed `git`/`claude`) asserting that with `SWARM_POLICY_LANDING=pr` the healer refuses to push to `main` (escalates or PR-routes), and with the default (`push`) it behaves exactly as today. It is **not** on the one-way-door list: it *tightens* rather than widens security posture, and touches no personal credentials, no spend, no data destruction, no member-facing trust accept. **Scope note:** no current consumer exhibits wrong behaviour — factory + idss are both push repos — so this is defensive hardening (hence `enhancement`, not `bug`). If a pr-default consumer that also runs the healer is onboarded before this lands, it reclassifies to a live bug; add `priority` then. ## Why `ready-for-session`, not `ready-for-agent` The swarm queue reads only `ready-for-agent`, and a complete fix crosses session-only, high-blast-radius paths that are invisible to workers by construction: - The healer's actual push is issued by the agent following **prose** in `.sandcastle/prompt-enrichments/repairs.md` (`push to main`) — a `.sandcastle/` vendored-self-copy file. - The healer's charter that the residual is really about — `prompts/heal-prompt.md`'s "Allowed repairs (harness-infra only, ONE attempt) … push to main" — is a **prompt skeleton** (live text for every future healer session). Both are session-only edits per `docs/agents/triage-labels.md`. The `heal.sh` code gate rides along in the same session. ## Brief for the session **Goal:** the healer must not push a harness-infra repair straight to `main` in a repo whose `SWARM_POLICY_LANDING=pr`; it consults the same landing-mode seam every other pusher uses. **Do:** 1. In `heal.sh`, source `landing-lib.sh` + `policy-lib.sh` and load policy (`policy_load "${SWARM_POLICY_FILE:-}"`), mirroring the #165 hunk in `session-runner.sh`. Before the repair run reaches its push, gate on the repo landing mode (`SWARM_POLICY_LANDING` / `landing_mode_for`): in `pr` mode the healer must **not** direct-push to `main`. Pick the behaviour deliberately and record it in the charter — either (a) short-circuit to **file-a-ticket + `ESCALATE: yes`** (simplest; preserves "one attempt, then report"), or (b) route the repair through a PR (`agent/heal-*`, human-merged). (a) is the smaller, more faithful change and is the recommended default; note the choice in the ticket for the async veto. 2. Update the healer prose to match: `prompts/heal-prompt.md`'s "Allowed repairs … push to main" and `.sandcastle/prompt-enrichments/repairs.md`'s "rebase on origin/main, push to main" must both become conditional on push-default (or say "escalate instead in a pr-default repo"), so the rendered charter never contradicts the code gate. 3. Remember the render step: a `prompts/*.md` skeleton change needs `onboard.sh render-prompts` and the cutover-proof fixtures re-proven / deliberately updated (`onboarding/tests/onboard-lib-test.sh`), per `CLAUDE.md`. **Prove:** add/extend an offline `heal.sh` test (shimmed `git`/`claude`, no network) asserting the two-way-door invariant above — `SWARM_POLICY_LANDING=pr` ⇒ no `git push … main` from the healer (escalates or PRs); default ⇒ unchanged. Every lib change updates its test in the same commit. Run the full offline suite before close. **Files:** `heal.sh`, `prompts/heal-prompt.md`, `.sandcastle/prompt-enrichments/repairs.md`, a `heal.sh` test under `tests/`, and `STATUS.md` (state change). Vendoring the self-copy stays a human pin bump (`onboarding/onboard.sh vendor .sandcastle <sha>`, GOTCHAS 4) — do not hand-edit the running `.sandcastle/heal.sh`.
Author
Member

Ruling (ADR 0174 — veto anytime)

Decision: the healer DOES need a landing gate — and it now has one. Leaving "push to main vs. don't" to a consumer's per-repo repairs.md prose is exactly the anti-pattern landing-lib.sh was built to eliminate ("it lived as a second copy of harness logic in matou-app's own .sandcastle/… the vendored core now owns it, gated on a per-repo knob"). The healer was the one unattended-agent-that-pushes-main path with no harness landing-awareness — inconsistent with #164/#165 and with landing-lib's whole philosophy.

Why a degrade, not a full pr-mode healer. The healer's push happens INSIDE its claude -p investigation session (directed by the repairs enrichment), not by any harness git push seam — heal.sh has no landing_stage to gate the way session-runner/run-swarm do. It therefore cannot mechanically intercept the push without revoking the host token or making the workdir read-only, which would also kill the read-only, valuable diagnosis. So the strongest lever the harness owns is the incident prompt. In a pr-default repo the healer is now told to diagnose + ESCALATE, never push a repair to main (a human opens the reviewed PR), and the ledger never marks the fault repaired (nothing landed). The literal #165 concern ("a landing-pr ticket reaches the healer") is confirmed vacuous — the healer is fault-driven and never claims a ticket.

The richer "healer OPENS a PR for its fix" flow is genuine design work (no ticket number → branch naming, closes #N, merge authority, evidence gate all need answers) and is filed as #168, not attempted here.

Close report

Landed: commit 5499242 on origin/main.

  • heal.sh — sources policy-lib.sh, policy_loads the repo LANDING default via the test-only SWARM_POLICY_FILE seam (as session-runner/list-ready-tasks), sets HEAL_NO_LAND=1 when LANDING=pr. The incident block then emits a directive OVERRIDING the repairs enrichment's "push to main"; and a non-ticket "repair" in a pr-default repo is never recorded repaired (kept on the reply-cap ladder so the still-unlanded fault stays visible).
  • tests/heal-test.sh — +1 scenario (20 total): a pr-default repo (SWARM_POLICY_FILE → LANDING=pr) carries the no-land directive and does NOT mark a non-ticket repair repaired; a push repo carries NO directive and still marks a genuine repair repaired=1.
  • STATUS.md — header updated in the same commit.

Proof:

  • Red before green: with the heal.sh change stashed, the new scenario fails on the missing directive assertion; with it applied, heal.sh: 20 scenarios passed.
  • Full offline suite (for t in tests/*.sh onboarding/tests/*.sh; …) green, exit 0, no FAIL: lines.
  • Byte-identical for today's push repos (factory + idss): policy_load with no swarm-policy.sh / LANDING=push leaves HEAL_NO_LAND empty → no directive, repair path unchanged. This bites only a future pr-default consumer that also runs the healer.

Two-way door: revertible (a prompt directive + a policy read; no schema/credential/posture change) and provable (offline test + full suite). No one-way residue.

Follow-up: #168 (design a pr-mode healer that opens a PR for its fix).

Ruled by agent under ADR 0174 — veto anytime.

## Ruling (ADR 0174 — veto anytime) **Decision: the healer DOES need a landing gate — and it now has one.** Leaving "push to main vs. don't" to a consumer's per-repo `repairs.md` prose is exactly the anti-pattern `landing-lib.sh` was built to eliminate ("it lived as a second copy of harness logic in matou-app's own `.sandcastle/`… the vendored core now owns it, gated on a per-repo knob"). The healer was the one unattended-agent-that-pushes-`main` path with **no** harness landing-awareness — inconsistent with #164/#165 and with landing-lib's whole philosophy. **Why a *degrade*, not a full pr-mode healer.** The healer's push happens INSIDE its `claude -p` investigation session (directed by the `repairs` enrichment), not by any harness `git push` seam — `heal.sh` has no `landing_stage` to gate the way session-runner/run-swarm do. It therefore cannot mechanically intercept the push without revoking the host token or making the workdir read-only, which would also kill the read-only, valuable **diagnosis**. So the strongest lever the harness owns is the incident **prompt**. In a pr-default repo the healer is now told to diagnose + `ESCALATE`, never push a repair to `main` (a human opens the reviewed PR), and the ledger never marks the fault `repaired` (nothing landed). The literal #165 concern ("a `landing-pr` **ticket** reaches the healer") is confirmed **vacuous** — the healer is fault-driven and never claims a ticket. The richer "healer OPENS a PR for its fix" flow is genuine design work (no ticket number → branch naming, `closes #N`, merge authority, evidence gate all need answers) and is **filed as #168**, not attempted here. ## Close report **Landed:** commit `5499242` on `origin/main`. - `heal.sh` — sources `policy-lib.sh`, `policy_load`s the repo LANDING default via the test-only `SWARM_POLICY_FILE` seam (as session-runner/list-ready-tasks), sets `HEAL_NO_LAND=1` when `LANDING=pr`. The incident block then emits a directive OVERRIDING the repairs enrichment's "push to main"; and a non-ticket "repair" in a pr-default repo is never recorded `repaired` (kept on the reply-cap ladder so the still-unlanded fault stays visible). - `tests/heal-test.sh` — +1 scenario (**20 total**): a pr-default repo (`SWARM_POLICY_FILE` → `LANDING=pr`) carries the no-land directive and does NOT mark a non-ticket repair `repaired`; a push repo carries NO directive and still marks a genuine repair `repaired=1`. - `STATUS.md` — header updated in the same commit. **Proof:** - Red before green: with the `heal.sh` change stashed, the new scenario fails on the missing directive assertion; with it applied, `heal.sh: 20 scenarios passed`. - Full offline suite (`for t in tests/*.sh onboarding/tests/*.sh; …`) green, **exit 0, no `FAIL:` lines**. - Byte-identical for today's push repos (factory + idss): `policy_load` with no `swarm-policy.sh` / `LANDING=push` leaves `HEAL_NO_LAND` empty → no directive, repair path unchanged. This bites only a future **pr-default** consumer that also runs the healer. **Two-way door:** revertible (a prompt directive + a policy read; no schema/credential/posture change) and provable (offline test + full suite). No one-way residue. **Follow-up:** #168 (design a pr-mode healer that opens a PR for its fix). Ruled by agent under ADR 0174 — veto anytime.
matou-build-agent 2026-09-22 21:18:06 +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/dev-factory#167
No description provided.