session-runner + healer must not push a landing-pr ticket to main #165

Closed
opened 2026-09-21 19:45:21 +00:00 by ben · 2 comments
Owner

idss ADR 0265 known gap. session-runner.sh drains ready-for-session and its prompt pushes main; heal.sh pushes main. A ticket that is BOTH ready-for-session and landing-pr would bypass the PR rail (the idss tripwire pages, nothing prevents). Teach the session runner to skip a landing-pr ticket with a one-line log, leaving it for an interactive session that opens the PR by hand.

Blocked by #164 (needs landing_mode_for).

idss ADR 0265 known gap. `session-runner.sh` drains `ready-for-session` and its prompt pushes `main`; `heal.sh` pushes `main`. A ticket that is BOTH `ready-for-session` and `landing-pr` would bypass the PR rail (the idss tripwire pages, nothing prevents). Teach the session runner to skip a `landing-pr` ticket with a one-line log, leaving it for an interactive session that opens the PR by hand. Blocked by #164 (needs `landing_mode_for`).

This was generated by AI during triage.

Ruled by agent under ADR 0174 — veto anytime.

Ruling: enhancement + ready-for-session, blocked by #164

This completes the safety story of the per-ticket landing-pr feature (#164, Matou/idss ADR 0265) on the two rails #164 put in its out_of_scope: session-runner.sh and heal.sh. Category enhancement — it adds new guard behaviour for a label (landing-pr) that does not exist on main yet, so there is no reproducible defect to fix today; the gap only opens once #164 lands.

Why a session, not the swarm (ready-for-session, not ready-for-agent):

  1. The heal.sh half plausibly needs a prompt-skeleton edit. heal.sh never pushes main in code — it spawns the healer agent (heal.sh:308 run_agent, :359-365), which commits and pushes harness-infra fixes to main itself under the ACTION-TAKEN contract in prompts/heal-prompt.md:73. Teaching the healer to respect a per-ticket landing-pr constraint likely means editing heal-prompt.md, which is a prompt skeleton — definitionally ready-for-session in this repo (docs/agents/triage-labels.md) and high-blast-radius design work per CLAUDE.md.
  2. This is the completing follow-up of the landing-machinery arc that #164 deliberately held off the swarm ("Every file is factory machinery that judges worker output"). Keeping the follow-up in the same lane is the consistent call.

Why this is a two-way door (ADR 0174): revertible by a later commit/label change; provable by the existing tests/session-runner-test.sh, tests/heal-test.sh/heal-lib-test.sh, and tests/landing-lib-test.sh (extended). None of the one-way-door items apply — no credentials, no security-posture widening, no member-facing trust accept, no data destruction, no non-routine spend. ready-for-session is itself an ADR-0174 ruling; Ben's veto is asynchronous, never blocking.

Wired blocked by #164 as a native Forgejo dependency — landing_mode_for does not exist on main yet (confirmed: grep -rn landing_mode_for is empty), so nothing may start until Ben's inline #164 session lands the helper and the landing-pr label vocabulary. Do not touch this ticket while #164's session is live.


Agent brief (for the session, once #164 has landed)

Goal. Neither the ready-for-session rail nor the healer may push a landing-pr ticket's change to main, bypassing the PR rail that #164 established.

Preconditions. #164 closed; landing_mode_for (the per-ticket landing resolver) and the landing-pr label exist on main. Build against that final contract, not against this brief's guesses about its shape.

Part A — session-runner.sh (crisp, code-only)

Skip a candidate ticket that carries landing-pr, with a one-line log, leaving it for an interactive session that opens the PR by hand.

  • Add the check inside the per-ticket pick loop for n in $candidates (session-runner.sh:356-390), alongside the existing "skip, not a failed attempt" checks (host affinity :365-372, cooldown :374-378, fail-cap :380-383, open-deps :384-388) and before the claim (:494-498).
  • Read the ticket's labels from the already-held $queue JSON at zero extra API cost, mirroring sr_issue_body() (:347-354) which extracts .body the same way. (Only the SESSION_RUNNER_PICK rollout path at :322-326 skips the queue read and would need a fetch — sr_issue_body already documents that fallback.)
  • The skip must be a skip, not a failed attempt: do not bump the fail counter or leave a claim marker — mirror the host-affinity skip.
  • Resolve landing mode via #164's landing_mode_for rather than string-matching the label directly, so per-repo defaults and the resolver stay the single source of truth.

Part B — heal.sh (needs a design decision — rule it in-session under ADR 0174)

heal.sh has no keyed code branch for landing mode; the healer agent pushes main via prompts/heal-prompt.md. The healer heals harness infra, not the ticket's own change, and is not obviously ticket-scoped (it carries $MODE, $WORKFLOW, $WORKDIR, evidence — see run_agent at heal.sh:308). Decide and record the ruling on this ticket:

  • whether the guard belongs in heal.sh code (detect the triggering run's ticket is landing-pr and refuse/skip the healer's main push with a one-line log), or in heal-prompt.md (teach the healer not to push main when the incident's ticket lands via PR) — the latter is a prompt-skeleton edit and needs the cutover fixtures re-proven per CLAUDE.md;
  • exactly how heal obtains the triggering ticket's landing mode (it may need landing_mode_for plus the ticket number threaded into the incident block at heal.sh:311-327).

Tests & closeout

  • Extend tests/session-runner-test.sh: a landing-pr candidate at the head of the queue is skipped (one-line log, no claim, no fail bump); a non-landing-pr candidate still claims.
  • Extend tests/heal-test.sh / heal-lib-test.sh for whichever Part-B mechanism is chosen.
  • Every lib change updates its test in the same commit; run the offline suite (for t in tests/*.sh onboarding/tests/*.sh; do case "$t" in *fakebin*|*fixtures*) continue;; esac; bash "$t" || echo "FAIL: $t"; done) green before close.
  • Update STATUS.md in the same commit (this changes factory state).
  • No closes #165 phrasing in commit messages (auto-close over-fires — docs/agents/issue-tracker.md).

Acceptance. Given a LANDING=push repo (the factory default, policy-lib.sh:73) and a ready ticket carrying landing-pr: (1) session-runner.sh skips it with a one-line log and never claims it; (2) the healer, if it fires during that ticket's run, does not push the ticket's change to main; (3) a ticket without landing-pr is handled exactly as today (every existing test passes unchanged).

> *This was generated by AI during triage.* **Ruled by agent under ADR 0174 — veto anytime.** ## Ruling: `enhancement` + `ready-for-session`, blocked by #164 This completes the safety story of the per-ticket `landing-pr` feature (#164, `Matou/idss` ADR 0265) on the two rails #164 put in its `out_of_scope`: `session-runner.sh` and `heal.sh`. Category **enhancement** — it adds new guard behaviour for a label (`landing-pr`) that does not exist on `main` yet, so there is no reproducible defect to fix today; the gap only opens once #164 lands. **Why a session, not the swarm (`ready-for-session`, not `ready-for-agent`):** 1. The `heal.sh` half plausibly needs a **prompt-skeleton edit**. `heal.sh` never pushes `main` in code — it spawns the healer agent (`heal.sh:308` `run_agent`, `:359-365`), which commits and pushes harness-infra fixes to `main` itself under the `ACTION-TAKEN` contract in `prompts/heal-prompt.md:73`. Teaching the healer to respect a per-ticket `landing-pr` constraint likely means editing `heal-prompt.md`, which is a prompt skeleton — **definitionally `ready-for-session`** in this repo (`docs/agents/triage-labels.md`) and high-blast-radius design work per `CLAUDE.md`. 2. This is the completing follow-up of the landing-machinery arc that #164 deliberately held off the swarm ("Every file is factory machinery that judges worker output"). Keeping the follow-up in the same lane is the consistent call. **Why this is a two-way door (ADR 0174):** revertible by a later commit/label change; provable by the existing `tests/session-runner-test.sh`, `tests/heal-test.sh`/`heal-lib-test.sh`, and `tests/landing-lib-test.sh` (extended). None of the one-way-door items apply — no credentials, no security-posture widening, no member-facing trust accept, no data destruction, no non-routine spend. `ready-for-session` is itself an ADR-0174 ruling; Ben's veto is asynchronous, never blocking. **Wired `blocked by #164`** as a native Forgejo dependency — `landing_mode_for` does not exist on `main` yet (confirmed: `grep -rn landing_mode_for` is empty), so nothing may start until Ben's inline #164 session lands the helper and the `landing-pr` label vocabulary. Do **not** touch this ticket while #164's session is live. --- ## Agent brief (for the session, once #164 has landed) **Goal.** Neither the `ready-for-session` rail nor the healer may push a `landing-pr` ticket's change to `main`, bypassing the PR rail that #164 established. **Preconditions.** #164 closed; `landing_mode_for` (the per-ticket landing resolver) and the `landing-pr` label exist on `main`. Build against that final contract, not against this brief's guesses about its shape. ### Part A — `session-runner.sh` (crisp, code-only) Skip a candidate ticket that carries `landing-pr`, with a one-line log, leaving it for an interactive session that opens the PR by hand. - Add the check inside the per-ticket pick loop `for n in $candidates` (`session-runner.sh:356-390`), alongside the existing "skip, not a failed attempt" checks (host affinity `:365-372`, cooldown `:374-378`, fail-cap `:380-383`, open-deps `:384-388`) and **before** the claim (`:494-498`). - Read the ticket's labels from the already-held `$queue` JSON at **zero extra API cost**, mirroring `sr_issue_body()` (`:347-354`) which extracts `.body` the same way. (Only the `SESSION_RUNNER_PICK` rollout path at `:322-326` skips the queue read and would need a fetch — `sr_issue_body` already documents that fallback.) - The skip must be a *skip*, not a failed attempt: do not bump the fail counter or leave a claim marker — mirror the host-affinity skip. - Resolve landing mode via #164's `landing_mode_for` rather than string-matching the label directly, so per-repo defaults and the resolver stay the single source of truth. ### Part B — `heal.sh` (needs a design decision — rule it in-session under ADR 0174) `heal.sh` has no keyed code branch for landing mode; the healer agent pushes `main` via `prompts/heal-prompt.md`. The healer heals *harness infra*, not the ticket's own change, and is not obviously ticket-scoped (it carries `$MODE`, `$WORKFLOW`, `$WORKDIR`, evidence — see `run_agent` at `heal.sh:308`). Decide and record the ruling on this ticket: - whether the guard belongs in `heal.sh` code (detect the triggering run's ticket is `landing-pr` and refuse/skip the healer's `main` push with a one-line log), or in `heal-prompt.md` (teach the healer not to push `main` when the incident's ticket lands via PR) — the latter is a prompt-skeleton edit and needs the cutover fixtures re-proven per `CLAUDE.md`; - exactly how heal obtains the triggering ticket's landing mode (it may need `landing_mode_for` plus the ticket number threaded into the incident block at `heal.sh:311-327`). ### Tests & closeout - Extend `tests/session-runner-test.sh`: a `landing-pr` candidate at the head of the queue is skipped (one-line log, no claim, no fail bump); a non-`landing-pr` candidate still claims. - Extend `tests/heal-test.sh` / `heal-lib-test.sh` for whichever Part-B mechanism is chosen. - Every lib change updates its test in the same commit; run the offline suite (`for t in tests/*.sh onboarding/tests/*.sh; do case "$t" in *fakebin*|*fixtures*) continue;; esac; bash "$t" || echo "FAIL: $t"; done`) green before close. - Update `STATUS.md` in the same commit (this changes factory state). - No `closes #165` phrasing in commit messages (auto-close over-fires — `docs/agents/issue-tracker.md`). **Acceptance.** Given a `LANDING=push` repo (the factory default, `policy-lib.sh:73`) and a ready ticket carrying `landing-pr`: (1) `session-runner.sh` skips it with a one-line log and never claims it; (2) the healer, if it fires during that ticket's run, does not push the ticket's change to `main`; (3) a ticket without `landing-pr` is handled exactly as today (every existing test passes unchanged).

Close report — landed and proven

What landed (commit 5a71161 on main):

session-runner.sh's pick loop now asks landing_mode_for (#164) for each candidate and skips a ticket that resolves to pr with a one-line log — no claim, no attempt marker, no fail-$n, exactly like the host-affinity skip (#89) — so a landing-pr ticket (or any ticket in a pr-DEFAULT repo) is left for an interactive session to open the PR by hand instead of being pushed straight to main. It fails CLOSED: an unreadable ticket or an off-allowlist landing-* label is skipped too, never risked onto main (the posture landing_push already takes). To honour a pr-default repo (not just the per-ticket label) the runner now sources landing-lib.sh and policy_loads the repo LANDING default; byte-identical in a push repo with no landing-* label.

Proof:

  • tests/session-runner-test.sh group 25 (+4), updated in the same commit: (a) a labelled landing-pr ticket is skipped, burning no attempt and starting no session/run row; (b) it does not block a plain push ticket behind it, and is charged no attempt; (c) a pr-default repo (SWARM_POLICY_FILE → LANDING=pr) skips even an unlabelled ticket; (d) an off-allowlist landing-* label fails closed.
  • Red before green: with the skip block removed, group 25a fails (picked #60); with it, all 25 groups pass.
  • Full offline suite (for t in tests/*.sh onboarding/tests/*.sh …) run green — no failures.
  • STATUS.md updated in the same commit (new head block).

Healer (the other half of #164's known gap): the swarm healer is fault-driven and never claims a ticket, so no landing-pr ticket reaches it — the literal concern is vacuous for the healer. The distinct residual ("healer's own harness fix → main in a pr-default repo") is filed as a follow-up: #167.

Ruled by agent under ADR 0174 — veto anytime.

## Close report — landed and proven **What landed** (commit `5a71161` on `main`): `session-runner.sh`'s pick loop now asks `landing_mode_for` (#164) for each candidate and **skips** a ticket that resolves to `pr` with a one-line log — no claim, no attempt marker, no `fail-$n`, exactly like the host-affinity skip (#89) — so a `landing-pr` ticket (or any ticket in a pr-DEFAULT repo) is left for an interactive session to open the PR by hand instead of being pushed straight to `main`. It fails **CLOSED**: an unreadable ticket or an off-allowlist `landing-*` label is skipped too, never risked onto `main` (the posture `landing_push` already takes). To honour a pr-default repo (not just the per-ticket label) the runner now sources `landing-lib.sh` and `policy_load`s the repo LANDING default; **byte-identical** in a push repo with no `landing-*` label. **Proof:** - `tests/session-runner-test.sh` **group 25 (+4)**, updated in the same commit: (a) a labelled `landing-pr` ticket is skipped, burning no attempt and starting no session/run row; (b) it does not block a plain push ticket behind it, and is charged no attempt; (c) a pr-default repo (`SWARM_POLICY_FILE` → `LANDING=pr`) skips even an unlabelled ticket; (d) an off-allowlist `landing-*` label fails closed. - **Red before green**: with the skip block removed, group 25a fails (`picked #60`); with it, all **25 groups pass**. - Full offline suite (`for t in tests/*.sh onboarding/tests/*.sh …`) run green — **no failures**. - `STATUS.md` updated in the same commit (new head block). **Healer (the other half of #164's known gap):** the swarm healer is fault-driven and never claims a ticket, so no `landing-pr` **ticket** reaches it — the literal concern is vacuous for the healer. The distinct residual ("healer's own harness fix → `main` in a pr-default repo") is filed as a follow-up: **#167**. Ruled by agent under ADR 0174 — veto anytime.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Matou/dev-factory#165
No description provided.