swarm landing: the rescue ladder alarms a park it never verified — a 5xx forge makes it cry "commits parked on sandcastle/rescue-<ts>" for a branch that does not exist, and for a run with no commits #141

Closed
opened 2026-09-12 05:00:06 +00:00 by matou-build-agent · 1 comment

What

landing_push_main_with_rescue (landing-lib.sh) reports a rescue park it did
not verify, and parks when there is nothing to park. Both halves fired for real
on Matou/idss run 22240 (2026-09-12) while Forgejo was serving 503.

Symptom (live evidence)

Run 22240 failed at verdict stage reconcile push to main exit=1, runlog
reason=push-parked-on-rescue, and the Mattermost alarm said "commits parked
on sandcastle/rescue-… — cherry-pick them onto main or the work is lost (the
issues will NOT retry)"
.

Checked against the forge and the runner workdir immediately after:

  • git ls-remote --heads origin | grep rescue → nothing. The named branch
    does not exist.
  • git push --dry-run origin HEAD:main → Everything up-to-date.
  • workdir reflog's last entry: a plain reset: moving to origin/main;
    git log --oneline --all --not origin/main → empty.

So the run had produced no commits, nothing was at risk, and the loudest
alarm the harness owns named a branch to recover from that was never created.
(Issues #1409/#1410 were still open + ready-for-agent, unassigned — the
queue was intact and simply retries.)

Cause

  [ -z "$pushed" ] || return 0
  git rebase --abort 2>/dev/null || true
  rescue="sandcastle/rescue-$(date -u +%Y%m%d-%H%M%S)"
  git push origin "HEAD:refs/heads/$rescue"      # <-- rc never checked
  _landing_notify ":rotating_light: ... commits parked on `$rescue` ..."
  SWARM_EXIT_REASON="push-parked-on-rescue"
  return 1

Two unchecked assumptions:

  1. That there was something to park. The function never asks whether HEAD
    carries anything origin/main lacks.
  2. That the park succeeded. The rescue push's rc is discarded.

The ladder was written for the case that earned it (run 330: main moved under
a long run and three closed-issue commits nearly vanished), where the forge is
healthy and only the ref is contested. When the forge itself is 5xx, every
rung fails for the same transport reason — push, fetch, rebase and the
rescue push
— so the function asserts a park it just failed to perform.

The cost is human: a false :rotating_light: sends someone hunting a branch
that does not exist, and it trains the team to discount the one alarm that
guards real commit loss. In the genuine bad case (commits exist AND the rescue
push fails) the current alarm is actively misleading — the commits are in the
runner workdir, which the next run reset --hards.

Fix (patch attached below — written and proven red→green against this repo's

own tests, but it cannot land from the consumer side: landing-lib.sh and both
its tests are vendored byte-identical into product repos and the pre-push drift
gate (#932) refuses a local edit, so it must land here and be re-vendored)

  1. Skip the park entirely when git merge-base --is-ancestor HEAD origin/main
    holds — nothing of ours to park, only the transport failed. New reason
    push-failed-nothing-to-land, a :warning: notice that says no commits are
    at risk, still rc 1. Staleness of origin/main is safe here: a commit of
    ours cannot already be in origin/main, so the guard only ever skips a park
    that would have been empty.
  2. Check the rescue push's rc. On failure, say the branch does NOT exist,
    name the runner workdir and short SHA holding the commits, and warn that the
    next run's reset --hard is what destroys them. New reason
    push-rescue-unreachable.

Acceptance criteria

  1. A failed push with HEAD already contained in origin/main creates no rescue
    branch, sets SWARM_EXIT_REASON=push-failed-nothing-to-land, still rc 1, and
    its notification does not tell anyone to cherry-pick.
  2. A failed push WITH commits, where the rescue push succeeds, is unchanged:
    reason push-parked-on-rescue, branch pushed, existing alarm text.
  3. A failed push WITH commits, where the rescue push also fails, sets
    SWARM_EXIT_REASON=push-rescue-unreachable and alarms that the branch does
    not exist, naming the workdir and SHA.
  4. Scenarios 7 and 8 in tests/run-swarm-landing-test.sh pin 1 and 3; scenario
    6 keeps pinning 2 (its git shim needs
    "merge-base --is-ancestor HEAD origin/main") exit 1 added, i.e. "HEAD
    carries commits", or the new guard short-circuits it).
  5. The exit-reason vocabulary in consumers' docs/agents/swarm-atlas.md §4
    gains both reasons when the bump is vendored.

Verified against this patch

  • bash .sandcastle/tests/run-swarm-landing-test.sh → 10 scenarios passed
    (was 8); reverting only landing-lib.sh makes scenario 7 fail with
    the reason must say there was nothing to land, got 'push-parked-on-rescue'
    — red→green proven.
  • bash .sandcastle/tests/landing-lib-test.sh → 66 passed, 0 failed.
  • bash .sandcastle/preflight-swarm.sh → all 10 guards fired.

Patch

diff --git a/.sandcastle/landing-lib.sh b/.sandcastle/landing-lib.sh
index 66f54639..39537e8f 100644
--- a/.sandcastle/landing-lib.sh
+++ b/.sandcastle/landing-lib.sh
@@ -341,7 +341,16 @@ landing_resolve_rebase_with_claude() {
 # If even claude can't land the push, NEVER die with the commits stranded: park
 # HEAD on a rescue branch, alert, and fail — a human cherry-picks from there.
 # (Run 330 lost three closed-issue commits before this ladder existed.)
-# rc 1 + SWARM_EXIT_REASON=push-parked-on-rescue when it parks.
+#
+# The alarm must describe what is TRUE, not what the ladder intended. Two ways
+# the old unconditional park lied — both seen in run 22240 (2026-09-12), when
+# Forgejo flapped 503 for ~25m and every git op in the ladder failed:
+#   - nothing to park (HEAD already on origin/main — only the transport failed),
+#     yet it cried "cherry-pick them or the work is lost";
+#   - the rescue push ALSO failed, so the named branch never existed, yet the
+#     alarm sent a human hunting it while the commits sat in the workdir the
+#     next run resets --hard.
+# rc 1 on every non-landing path; SWARM_EXIT_REASON names which one.
 landing_push_main_with_rescue() {
   local repo_slug="$1" pushed="" rescue
   git push origin HEAD:main && return 0
@@ -353,10 +362,27 @@ landing_push_main_with_rescue() {
   fi
   [ -z "$pushed" ] || return 0
   git rebase --abort 2>/dev/null || true
+  # Nothing of OURS to park: HEAD is contained in (the last known) origin/main,
+  # so the push carried no commits and only the transport failed. Staleness is
+  # safe here — a commit of ours could not already be in origin/main — so this
+  # only ever skips a park that would have been empty. Fail honestly; the ready
+  # issues are untouched and the next run retries.
+  if git merge-base --is-ancestor HEAD origin/main 2>/dev/null; then
+    _landing_notify ":warning: **Swarm push to main failed with nothing to land** in \`$repo_slug\` — HEAD is already on \`origin/main\`, so no commits are at risk (the forge was most likely unreachable). The next run retries."
+    SWARM_EXIT_REASON="push-failed-nothing-to-land"
+    return 1
+  fi
   rescue="sandcastle/rescue-$(date -u +%Y%m%d-%H%M%S)"
-  git push origin "HEAD:refs/heads/$rescue"
-  _landing_notify ":rotating_light: **Swarm push failed after issues were closed** in \`$repo_slug\` — commits parked on \`$rescue\`. Cherry-pick them onto main or the work is lost (the issues will NOT retry)."
-  SWARM_EXIT_REASON="push-parked-on-rescue"
+  if git push origin "HEAD:refs/heads/$rescue"; then
+    _landing_notify ":rotating_light: **Swarm push failed after issues were closed** in \`$repo_slug\` — commits parked on \`$rescue\`. Cherry-pick them onto main or the work is lost (the issues will NOT retry)."
+    SWARM_EXIT_REASON="push-parked-on-rescue"
+  else
+    # The park itself could not reach the forge. NOTHING is on origin — name
+    # where the commits actually are, and that the next run's reset --hard is
+    # what destroys them.
+    _landing_notify ":rotating_light: **Swarm push failed after issues were closed AND the rescue branch could not be pushed** in \`$repo_slug\` — the forge is unreachable, so \`$rescue\` does NOT exist. The commits live ONLY in the runner workdir \`$(pwd)\` at \`$(git rev-parse --short HEAD 2>/dev/null)\` — do NOT let it reset; push or cherry-pick from there once the forge answers (the issues will NOT retry)."
+    SWARM_EXIT_REASON="push-rescue-unreachable"
+  fi
   return 1
 }
 
@@ -369,7 +395,7 @@ landing_push_main_with_rescue() {
 # run's commit subjects (a mid-run close can unblock a child).
 #
 # Sets LANDING_OPENED_PRS / LANDING_MERGED_PRS for the report seam. rc 1 only
-# when push mode parked on a rescue branch.
+# when push mode could not land (parked, or could not even park).
 landing_stage() {
   local repo_slug="$1" ready="$2" start_sha="$3" nums
   LANDING_OPENED_PRS=""; LANDING_MERGED_PRS=""
diff --git a/.sandcastle/tests/run-swarm-landing-test.sh b/.sandcastle/tests/run-swarm-landing-test.sh
index d43398dc..b94498ad 100644
--- a/.sandcastle/tests/run-swarm-landing-test.sh
+++ b/.sandcastle/tests/run-swarm-landing-test.sh
@@ -129,6 +129,7 @@ echo "git $*" >> "${GIT_LOG:?}"
 case "$*" in
   "push origin HEAD:main") exit 1 ;;      # main moved under us, and stays moved
   "rebase origin/main")    exit 1 ;;      # ...with a conflict claude can't fix
+  "merge-base --is-ancestor HEAD origin/main") exit 1 ;;  # HEAD carries commits
 esac
 exit 0
 SH
@@ -152,4 +153,55 @@ grep -q 'commits parked on' "$NOTIFY_LOG" || fail "the park must alarm so a huma
 grep -q 'will NOT retry' "$NOTIFY_LOG" || fail "the alarm must say the issues will not retry"
 pass=$((pass+1))
 
+# --- 7. a failed push with NOTHING to land (HEAD already on origin/main) is a
+#        transport fault, not a park: no rescue branch, no cherry-pick alarm.
+#        (Run 22240, 2026-09-12: Forgejo flapped 503 and the ladder cried that
+#        work was stranded when the run had produced no commits at all.) ------
+cat > "$tmp/bin/git" <<'SH'
+#!/usr/bin/env bash
+echo "git $*" >> "${GIT_LOG:?}"
+case "$*" in
+  "push origin HEAD:main") exit 1 ;;      # the forge is 5xx, not moved
+  "fetch origin main")     exit 1 ;;
+  "rebase origin/main")    exit 1 ;;
+  "merge-base --is-ancestor HEAD origin/main") exit 0 ;;  # nothing of ours
+esac
+exit 0
+SH
+chmod +x "$tmp/bin/git"
+: > "$GIT_LOG"; : > "$NOTIFY_LOG"; SWARM_EXIT_REASON=""
+RC=0
+PATH="$tmp/bin:/usr/bin:/bin" SWARM_POLICY_LANDING=push   landing_stage Matou/matou-app '[{"number":7}]' start || RC=$?
+[ "$RC" = 1 ] || fail "an unreachable forge must still fail the run, got $RC"
+[ "$SWARM_EXIT_REASON" = "push-failed-nothing-to-land" ]   || fail "the reason must say there was nothing to land, got '$SWARM_EXIT_REASON'"
+! grep -q 'refs/heads/sandcastle/rescue-' "$GIT_LOG"   || fail "an empty park must NOT create a rescue branch: $(cat "$GIT_LOG")"
+! grep -qi 'cherry-pick' "$NOTIFY_LOG"   || fail "no commits are at risk — the alarm must not send a human cherry-picking: $(cat "$NOTIFY_LOG")"
+grep -q 'no commits are at risk' "$NOTIFY_LOG"   || fail "the notice must say nothing is at risk: $(cat "$NOTIFY_LOG")"
+pass=$((pass+1))
+
+# --- 8. the rescue push ITSELF fails (forge down): the alarm must say the
+#        branch does not exist and name where the commits really are, or a
+#        human hunts a branch that was never created ----------------------
+cat > "$tmp/bin/git" <<'SH'
+#!/usr/bin/env bash
+echo "git $*" >> "${GIT_LOG:?}"
+case "$*" in
+  push*)                   exit 1 ;;      # nothing reaches the forge, park included
+  "rebase origin/main")    exit 1 ;;
+  "merge-base --is-ancestor HEAD origin/main") exit 1 ;;  # HEAD carries commits
+  "rev-parse --short HEAD") echo deadbee0 ;;
+esac
+exit 0
+SH
+chmod +x "$tmp/bin/git"
+: > "$GIT_LOG"; : > "$NOTIFY_LOG"; SWARM_EXIT_REASON=""
+RC=0
+PATH="$tmp/bin:/usr/bin:/bin" SWARM_POLICY_LANDING=push   landing_stage Matou/matou-app '[{"number":7}]' start || RC=$?
+[ "$RC" = 1 ] || fail "an unparkable push must fail the run, got $RC"
+[ "$SWARM_EXIT_REASON" = "push-rescue-unreachable" ]   || fail "the reason must say the park could not reach the forge, got '$SWARM_EXIT_REASON'"
+grep -q 'does NOT exist' "$NOTIFY_LOG"   || fail "the alarm must say the rescue branch does not exist: $(cat "$NOTIFY_LOG")"
+grep -q 'deadbee0' "$NOTIFY_LOG"   || fail "the alarm must name the SHA the commits sit at: $(cat "$NOTIFY_LOG")"
+grep -q 'will NOT retry' "$NOTIFY_LOG" || fail "the alarm must say the issues will not retry"
+pass=$((pass+1))
+
 echo "run-swarm-landing: $pass scenarios passed"
diff --git a/docs/GOTCHAS.md b/docs/GOTCHAS.md
index cbb51696..8d6f2e8b 100644
--- a/docs/GOTCHAS.md
+++ b/docs/GOTCHAS.md
@@ -7087,3 +7087,47 @@ community (2026-09-11). Fix = `app.use(createAppI18n())` in all three harness
 entries.
 **Related:** #1376/#1378 (the seam and the keying that exposed this), ADR 0232
 (decision 5 — the seam the app boots), the founding browser harness on :5199.
+
+## 226. ⭐ The swarm's rescue ladder alarmed that closed-issue commits were "parked on `sandcastle/rescue-<ts>`" when the forge was 5xx — so the branch it named did not exist, and on this run there were no commits to park at all
+
+**Symptom:** run 22240 (`Matou/idss`, 2026-09-12) failed at verdict stage
+`reconcile push to main` exit=1 with runlog `reason=push-parked-on-rescue`, and
+the Mattermost alarm said *"commits parked on `sandcastle/rescue-…` — cherry-pick
+them onto main or the work is lost"*. `git ls-remote --heads origin | grep rescue`
+returned nothing: no such branch. `git push --dry-run origin HEAD:main` said
+`Everything up-to-date`, the workdir reflog's last entry was a plain
+`reset: moving to origin/main`, and `git log --all --not origin/main` was empty —
+the run had produced **no commits**. Nothing was at risk; the alarm said
+everything was.
+
+**Cause:** `landing_push_main_with_rescue` (`.sandcastle/landing-lib.sh`) treated
+every non-landing exit as a park. It pushed the rescue branch **without checking
+the push's rc**, and without checking whether HEAD carried anything `origin/main`
+lacked. When the forge is 5xx every rung of the ladder fails for the same
+transport reason — `push`, `fetch`, `rebase` **and the rescue push** — so the
+function set `SWARM_EXIT_REASON="push-parked-on-rescue"` and fired the
+loudest alarm the harness owns about a branch it had just failed to create. The
+ladder was written for the case it was born from (run 330: main moved under a
+long run and three closed-issue commits nearly vanished), where the forge is
+healthy and only the *ref* is contested.
+
+**Rule:** an alarm describes what is true, not what the ladder intended. The park
+is skipped entirely when `git merge-base --is-ancestor HEAD origin/main` holds —
+nothing of ours to park, only the transport failed, reason
+`push-failed-nothing-to-land`, and the next run simply retries the still-ready
+issues. When there ARE commits and the rescue push itself fails, the alarm says
+the branch does **NOT** exist, names the runner workdir and short SHA holding the
+commits, and warns that the next run's `reset --hard` is what destroys them —
+reason `push-rescue-unreachable`. Pinned by scenarios 7 and 8 of
+`.sandcastle/tests/run-swarm-landing-test.sh`; both were red against the old
+ladder. Corollary for any harness alarm: if you could not verify the remote
+state you are asserting, do not assert it.
+
+**Source:** swarm healer, run 22240 (2026-09-12, sig `e9d7ba086503`). The run's
+own fault was transient-external — Forgejo (`git.matou.nz`) flapped 503 for
+roughly 04:27–04:51 UTC, which also reds the backstop (`API unreachable`,
+`runs listing unavailable`) across every repo and starved a worker's claim step.
+Fix = the two guards in `landing_push_main_with_rescue`.
+**Related:** run 330 (the loss that earned the ladder), `docs/agents/swarm-atlas.md`
+§4 step 9 + the exit-reason vocabulary, ADR 0186 (a reason string is the run's
+record).
diff --git a/docs/agents/swarm-atlas.md b/docs/agents/swarm-atlas.md
index 76455fa5..5d5ee0f9 100644
--- a/docs/agents/swarm-atlas.md
+++ b/docs/agents/swarm-atlas.md
@@ -107,14 +107,18 @@ finalises swarm.db, reaps stale containers, sweeps worktrees.
    container births → `no-worker-spawned`, loud red, debounce stamp cleared.
 9. Push ladder: push → fetch+rebase+push → claude-assisted conflict
    resolve (STATUS.md keep-both) → rescue branch `sandcastle/rescue-<ts>`
-   + alert. Never force-push, never `-D` branches.
+   + alert. The park is skipped when HEAD is already on `origin/main`
+   (nothing to park — only the transport failed), and a rescue push that
+   itself fails alarms that the branch does NOT exist and names the
+   workdir holding the commits. Never force-push, never `-D` branches.
 10. Mattermost summary; self-rearm dispatch if work remains and a worker
     actually ran.
 
 Exit-reason vocabulary: `preflight-red · no-ready-tasks · coalesced ·
 unknown-model · claude-limit-parked · sandcastle-run-failed ·
 no-worker-spawned · protected-path-violation · push-parked-on-rescue ·
-completed · killed:SIG* · died-in:<stage>`.
+push-failed-nothing-to-land · push-rescue-unreachable · completed ·
+killed:SIG* · died-in:<stage>`.
 
 ## 5. Claiming (multi-host, no lock server)
 

Context

Filed by the Matou/idss swarm healer for run 22240 (signature e9d7ba086503).
The run's own fault was transient-external — git.matou.nz served 503 for
roughly 04:27–04:51 UTC (backstop: API unreachable / runs listing unavailable across every repo; a worker's claim step was starved by a 503 that
recovered on retry) — and had recovered by the time of writing. This ticket is
the latent harness defect that outage exposed, not the outage.
Hazard recorded as docs/GOTCHAS.md #226 in Matou/idss.

## What `landing_push_main_with_rescue` (`landing-lib.sh`) reports a rescue park it did not verify, and parks when there is nothing to park. Both halves fired for real on `Matou/idss` run 22240 (2026-09-12) while Forgejo was serving 503. ## Symptom (live evidence) Run 22240 failed at verdict stage `reconcile push to main` exit=1, runlog `reason=push-parked-on-rescue`, and the Mattermost alarm said *"commits parked on `sandcastle/rescue-…` — cherry-pick them onto main or the work is lost (the issues will NOT retry)"*. Checked against the forge and the runner workdir immediately after: - `git ls-remote --heads origin | grep rescue` → **nothing**. The named branch does not exist. - `git push --dry-run origin HEAD:main` → `Everything up-to-date`. - workdir reflog's last entry: a plain `reset: moving to origin/main`; `git log --oneline --all --not origin/main` → empty. So the run had produced **no commits**, nothing was at risk, and the loudest alarm the harness owns named a branch to recover from that was never created. (Issues #1409/#1410 were still `open` + `ready-for-agent`, unassigned — the queue was intact and simply retries.) ## Cause ```sh [ -z "$pushed" ] || return 0 git rebase --abort 2>/dev/null || true rescue="sandcastle/rescue-$(date -u +%Y%m%d-%H%M%S)" git push origin "HEAD:refs/heads/$rescue" # <-- rc never checked _landing_notify ":rotating_light: ... commits parked on `$rescue` ..." SWARM_EXIT_REASON="push-parked-on-rescue" return 1 ``` Two unchecked assumptions: 1. **That there was something to park.** The function never asks whether HEAD carries anything `origin/main` lacks. 2. **That the park succeeded.** The rescue push's rc is discarded. The ladder was written for the case that earned it (run 330: `main` moved under a long run and three closed-issue commits nearly vanished), where the forge is healthy and only the *ref* is contested. When the forge itself is 5xx, every rung fails for the same transport reason — `push`, `fetch`, `rebase` **and the rescue push** — so the function asserts a park it just failed to perform. The cost is human: a false `:rotating_light:` sends someone hunting a branch that does not exist, and it trains the team to discount the one alarm that guards real commit loss. In the genuine bad case (commits exist AND the rescue push fails) the current alarm is actively misleading — the commits are in the runner workdir, which the next run `reset --hard`s. ## Fix (patch attached below — written and proven red→green against this repo's own tests, but it cannot land from the consumer side: `landing-lib.sh` and both its tests are vendored byte-identical into product repos and the pre-push drift gate (#932) refuses a local edit, so it must land here and be re-vendored) 1. Skip the park entirely when `git merge-base --is-ancestor HEAD origin/main` holds — nothing of ours to park, only the transport failed. New reason `push-failed-nothing-to-land`, a `:warning:` notice that says no commits are at risk, still rc 1. Staleness of `origin/main` is safe here: a commit of ours cannot already be in `origin/main`, so the guard only ever skips a park that would have been empty. 2. Check the rescue push's rc. On failure, say the branch does **NOT** exist, name the runner workdir and short SHA holding the commits, and warn that the next run's `reset --hard` is what destroys them. New reason `push-rescue-unreachable`. ## Acceptance criteria 1. A failed push with HEAD already contained in `origin/main` creates no rescue branch, sets `SWARM_EXIT_REASON=push-failed-nothing-to-land`, still rc 1, and its notification does not tell anyone to cherry-pick. 2. A failed push WITH commits, where the rescue push succeeds, is unchanged: reason `push-parked-on-rescue`, branch pushed, existing alarm text. 3. A failed push WITH commits, where the rescue push also fails, sets `SWARM_EXIT_REASON=push-rescue-unreachable` and alarms that the branch does not exist, naming the workdir and SHA. 4. Scenarios 7 and 8 in `tests/run-swarm-landing-test.sh` pin 1 and 3; scenario 6 keeps pinning 2 (its `git` shim needs `"merge-base --is-ancestor HEAD origin/main") exit 1` added, i.e. "HEAD carries commits", or the new guard short-circuits it). 5. The exit-reason vocabulary in consumers' `docs/agents/swarm-atlas.md` §4 gains both reasons when the bump is vendored. ## Verified against this patch - `bash .sandcastle/tests/run-swarm-landing-test.sh` → `10 scenarios passed` (was 8); reverting only `landing-lib.sh` makes scenario 7 fail with `the reason must say there was nothing to land, got 'push-parked-on-rescue'` — red→green proven. - `bash .sandcastle/tests/landing-lib-test.sh` → `66 passed, 0 failed`. - `bash .sandcastle/preflight-swarm.sh` → `all 10 guards fired`. ## Patch ```diff diff --git a/.sandcastle/landing-lib.sh b/.sandcastle/landing-lib.sh index 66f54639..39537e8f 100644 --- a/.sandcastle/landing-lib.sh +++ b/.sandcastle/landing-lib.sh @@ -341,7 +341,16 @@ landing_resolve_rebase_with_claude() { # If even claude can't land the push, NEVER die with the commits stranded: park # HEAD on a rescue branch, alert, and fail — a human cherry-picks from there. # (Run 330 lost three closed-issue commits before this ladder existed.) -# rc 1 + SWARM_EXIT_REASON=push-parked-on-rescue when it parks. +# +# The alarm must describe what is TRUE, not what the ladder intended. Two ways +# the old unconditional park lied — both seen in run 22240 (2026-09-12), when +# Forgejo flapped 503 for ~25m and every git op in the ladder failed: +# - nothing to park (HEAD already on origin/main — only the transport failed), +# yet it cried "cherry-pick them or the work is lost"; +# - the rescue push ALSO failed, so the named branch never existed, yet the +# alarm sent a human hunting it while the commits sat in the workdir the +# next run resets --hard. +# rc 1 on every non-landing path; SWARM_EXIT_REASON names which one. landing_push_main_with_rescue() { local repo_slug="$1" pushed="" rescue git push origin HEAD:main && return 0 @@ -353,10 +362,27 @@ landing_push_main_with_rescue() { fi [ -z "$pushed" ] || return 0 git rebase --abort 2>/dev/null || true + # Nothing of OURS to park: HEAD is contained in (the last known) origin/main, + # so the push carried no commits and only the transport failed. Staleness is + # safe here — a commit of ours could not already be in origin/main — so this + # only ever skips a park that would have been empty. Fail honestly; the ready + # issues are untouched and the next run retries. + if git merge-base --is-ancestor HEAD origin/main 2>/dev/null; then + _landing_notify ":warning: **Swarm push to main failed with nothing to land** in \`$repo_slug\` — HEAD is already on \`origin/main\`, so no commits are at risk (the forge was most likely unreachable). The next run retries." + SWARM_EXIT_REASON="push-failed-nothing-to-land" + return 1 + fi rescue="sandcastle/rescue-$(date -u +%Y%m%d-%H%M%S)" - git push origin "HEAD:refs/heads/$rescue" - _landing_notify ":rotating_light: **Swarm push failed after issues were closed** in \`$repo_slug\` — commits parked on \`$rescue\`. Cherry-pick them onto main or the work is lost (the issues will NOT retry)." - SWARM_EXIT_REASON="push-parked-on-rescue" + if git push origin "HEAD:refs/heads/$rescue"; then + _landing_notify ":rotating_light: **Swarm push failed after issues were closed** in \`$repo_slug\` — commits parked on \`$rescue\`. Cherry-pick them onto main or the work is lost (the issues will NOT retry)." + SWARM_EXIT_REASON="push-parked-on-rescue" + else + # The park itself could not reach the forge. NOTHING is on origin — name + # where the commits actually are, and that the next run's reset --hard is + # what destroys them. + _landing_notify ":rotating_light: **Swarm push failed after issues were closed AND the rescue branch could not be pushed** in \`$repo_slug\` — the forge is unreachable, so \`$rescue\` does NOT exist. The commits live ONLY in the runner workdir \`$(pwd)\` at \`$(git rev-parse --short HEAD 2>/dev/null)\` — do NOT let it reset; push or cherry-pick from there once the forge answers (the issues will NOT retry)." + SWARM_EXIT_REASON="push-rescue-unreachable" + fi return 1 } @@ -369,7 +395,7 @@ landing_push_main_with_rescue() { # run's commit subjects (a mid-run close can unblock a child). # # Sets LANDING_OPENED_PRS / LANDING_MERGED_PRS for the report seam. rc 1 only -# when push mode parked on a rescue branch. +# when push mode could not land (parked, or could not even park). landing_stage() { local repo_slug="$1" ready="$2" start_sha="$3" nums LANDING_OPENED_PRS=""; LANDING_MERGED_PRS="" diff --git a/.sandcastle/tests/run-swarm-landing-test.sh b/.sandcastle/tests/run-swarm-landing-test.sh index d43398dc..b94498ad 100644 --- a/.sandcastle/tests/run-swarm-landing-test.sh +++ b/.sandcastle/tests/run-swarm-landing-test.sh @@ -129,6 +129,7 @@ echo "git $*" >> "${GIT_LOG:?}" case "$*" in "push origin HEAD:main") exit 1 ;; # main moved under us, and stays moved "rebase origin/main") exit 1 ;; # ...with a conflict claude can't fix + "merge-base --is-ancestor HEAD origin/main") exit 1 ;; # HEAD carries commits esac exit 0 SH @@ -152,4 +153,55 @@ grep -q 'commits parked on' "$NOTIFY_LOG" || fail "the park must alarm so a huma grep -q 'will NOT retry' "$NOTIFY_LOG" || fail "the alarm must say the issues will not retry" pass=$((pass+1)) +# --- 7. a failed push with NOTHING to land (HEAD already on origin/main) is a +# transport fault, not a park: no rescue branch, no cherry-pick alarm. +# (Run 22240, 2026-09-12: Forgejo flapped 503 and the ladder cried that +# work was stranded when the run had produced no commits at all.) ------ +cat > "$tmp/bin/git" <<'SH' +#!/usr/bin/env bash +echo "git $*" >> "${GIT_LOG:?}" +case "$*" in + "push origin HEAD:main") exit 1 ;; # the forge is 5xx, not moved + "fetch origin main") exit 1 ;; + "rebase origin/main") exit 1 ;; + "merge-base --is-ancestor HEAD origin/main") exit 0 ;; # nothing of ours +esac +exit 0 +SH +chmod +x "$tmp/bin/git" +: > "$GIT_LOG"; : > "$NOTIFY_LOG"; SWARM_EXIT_REASON="" +RC=0 +PATH="$tmp/bin:/usr/bin:/bin" SWARM_POLICY_LANDING=push landing_stage Matou/matou-app '[{"number":7}]' start || RC=$? +[ "$RC" = 1 ] || fail "an unreachable forge must still fail the run, got $RC" +[ "$SWARM_EXIT_REASON" = "push-failed-nothing-to-land" ] || fail "the reason must say there was nothing to land, got '$SWARM_EXIT_REASON'" +! grep -q 'refs/heads/sandcastle/rescue-' "$GIT_LOG" || fail "an empty park must NOT create a rescue branch: $(cat "$GIT_LOG")" +! grep -qi 'cherry-pick' "$NOTIFY_LOG" || fail "no commits are at risk — the alarm must not send a human cherry-picking: $(cat "$NOTIFY_LOG")" +grep -q 'no commits are at risk' "$NOTIFY_LOG" || fail "the notice must say nothing is at risk: $(cat "$NOTIFY_LOG")" +pass=$((pass+1)) + +# --- 8. the rescue push ITSELF fails (forge down): the alarm must say the +# branch does not exist and name where the commits really are, or a +# human hunts a branch that was never created ---------------------- +cat > "$tmp/bin/git" <<'SH' +#!/usr/bin/env bash +echo "git $*" >> "${GIT_LOG:?}" +case "$*" in + push*) exit 1 ;; # nothing reaches the forge, park included + "rebase origin/main") exit 1 ;; + "merge-base --is-ancestor HEAD origin/main") exit 1 ;; # HEAD carries commits + "rev-parse --short HEAD") echo deadbee0 ;; +esac +exit 0 +SH +chmod +x "$tmp/bin/git" +: > "$GIT_LOG"; : > "$NOTIFY_LOG"; SWARM_EXIT_REASON="" +RC=0 +PATH="$tmp/bin:/usr/bin:/bin" SWARM_POLICY_LANDING=push landing_stage Matou/matou-app '[{"number":7}]' start || RC=$? +[ "$RC" = 1 ] || fail "an unparkable push must fail the run, got $RC" +[ "$SWARM_EXIT_REASON" = "push-rescue-unreachable" ] || fail "the reason must say the park could not reach the forge, got '$SWARM_EXIT_REASON'" +grep -q 'does NOT exist' "$NOTIFY_LOG" || fail "the alarm must say the rescue branch does not exist: $(cat "$NOTIFY_LOG")" +grep -q 'deadbee0' "$NOTIFY_LOG" || fail "the alarm must name the SHA the commits sit at: $(cat "$NOTIFY_LOG")" +grep -q 'will NOT retry' "$NOTIFY_LOG" || fail "the alarm must say the issues will not retry" +pass=$((pass+1)) + echo "run-swarm-landing: $pass scenarios passed" diff --git a/docs/GOTCHAS.md b/docs/GOTCHAS.md index cbb51696..8d6f2e8b 100644 --- a/docs/GOTCHAS.md +++ b/docs/GOTCHAS.md @@ -7087,3 +7087,47 @@ community (2026-09-11). Fix = `app.use(createAppI18n())` in all three harness entries. **Related:** #1376/#1378 (the seam and the keying that exposed this), ADR 0232 (decision 5 — the seam the app boots), the founding browser harness on :5199. + +## 226. ⭐ The swarm's rescue ladder alarmed that closed-issue commits were "parked on `sandcastle/rescue-<ts>`" when the forge was 5xx — so the branch it named did not exist, and on this run there were no commits to park at all + +**Symptom:** run 22240 (`Matou/idss`, 2026-09-12) failed at verdict stage +`reconcile push to main` exit=1 with runlog `reason=push-parked-on-rescue`, and +the Mattermost alarm said *"commits parked on `sandcastle/rescue-…` — cherry-pick +them onto main or the work is lost"*. `git ls-remote --heads origin | grep rescue` +returned nothing: no such branch. `git push --dry-run origin HEAD:main` said +`Everything up-to-date`, the workdir reflog's last entry was a plain +`reset: moving to origin/main`, and `git log --all --not origin/main` was empty — +the run had produced **no commits**. Nothing was at risk; the alarm said +everything was. + +**Cause:** `landing_push_main_with_rescue` (`.sandcastle/landing-lib.sh`) treated +every non-landing exit as a park. It pushed the rescue branch **without checking +the push's rc**, and without checking whether HEAD carried anything `origin/main` +lacked. When the forge is 5xx every rung of the ladder fails for the same +transport reason — `push`, `fetch`, `rebase` **and the rescue push** — so the +function set `SWARM_EXIT_REASON="push-parked-on-rescue"` and fired the +loudest alarm the harness owns about a branch it had just failed to create. The +ladder was written for the case it was born from (run 330: main moved under a +long run and three closed-issue commits nearly vanished), where the forge is +healthy and only the *ref* is contested. + +**Rule:** an alarm describes what is true, not what the ladder intended. The park +is skipped entirely when `git merge-base --is-ancestor HEAD origin/main` holds — +nothing of ours to park, only the transport failed, reason +`push-failed-nothing-to-land`, and the next run simply retries the still-ready +issues. When there ARE commits and the rescue push itself fails, the alarm says +the branch does **NOT** exist, names the runner workdir and short SHA holding the +commits, and warns that the next run's `reset --hard` is what destroys them — +reason `push-rescue-unreachable`. Pinned by scenarios 7 and 8 of +`.sandcastle/tests/run-swarm-landing-test.sh`; both were red against the old +ladder. Corollary for any harness alarm: if you could not verify the remote +state you are asserting, do not assert it. + +**Source:** swarm healer, run 22240 (2026-09-12, sig `e9d7ba086503`). The run's +own fault was transient-external — Forgejo (`git.matou.nz`) flapped 503 for +roughly 04:27–04:51 UTC, which also reds the backstop (`API unreachable`, +`runs listing unavailable`) across every repo and starved a worker's claim step. +Fix = the two guards in `landing_push_main_with_rescue`. +**Related:** run 330 (the loss that earned the ladder), `docs/agents/swarm-atlas.md` +§4 step 9 + the exit-reason vocabulary, ADR 0186 (a reason string is the run's +record). diff --git a/docs/agents/swarm-atlas.md b/docs/agents/swarm-atlas.md index 76455fa5..5d5ee0f9 100644 --- a/docs/agents/swarm-atlas.md +++ b/docs/agents/swarm-atlas.md @@ -107,14 +107,18 @@ finalises swarm.db, reaps stale containers, sweeps worktrees. container births → `no-worker-spawned`, loud red, debounce stamp cleared. 9. Push ladder: push → fetch+rebase+push → claude-assisted conflict resolve (STATUS.md keep-both) → rescue branch `sandcastle/rescue-<ts>` - + alert. Never force-push, never `-D` branches. + + alert. The park is skipped when HEAD is already on `origin/main` + (nothing to park — only the transport failed), and a rescue push that + itself fails alarms that the branch does NOT exist and names the + workdir holding the commits. Never force-push, never `-D` branches. 10. Mattermost summary; self-rearm dispatch if work remains and a worker actually ran. Exit-reason vocabulary: `preflight-red · no-ready-tasks · coalesced · unknown-model · claude-limit-parked · sandcastle-run-failed · no-worker-spawned · protected-path-violation · push-parked-on-rescue · -completed · killed:SIG* · died-in:<stage>`. +push-failed-nothing-to-land · push-rescue-unreachable · completed · +killed:SIG* · died-in:<stage>`. ## 5. Claiming (multi-host, no lock server) ``` ## Context Filed by the `Matou/idss` swarm healer for run 22240 (signature `e9d7ba086503`). The run's own fault was **transient-external** — `git.matou.nz` served 503 for roughly 04:27–04:51 UTC (backstop: `API unreachable` / `runs listing unavailable` across every repo; a worker's claim step was starved by a 503 that recovered on retry) — and had recovered by the time of writing. This ticket is the latent harness defect that outage exposed, not the outage. Hazard recorded as `docs/GOTCHAS.md` #226 in `Matou/idss`.
Author
Member

close-report for #141 — status success

✅ close-report gates passed — every claim verified against main; issue closed.

envelope
{
  "issue": 141,
  "status": "success",
  "commits": [
    "bba1ea3"
  ],
  "changed_files": [
    "landing-lib.sh",
    "tests/run-swarm-landing-test.sh",
    "docs/GOTCHAS.md",
    "STATUS.md"
  ],
  "tests": [
    {
      "command": "bash tests/run-swarm-landing-test.sh",
      "exit_code": 0
    }
  ],
  "criteria": {
    "1. failed push, HEAD already in origin/main: no rescue branch, SWARM_EXIT_REASON=push-failed-nothing-to-land, rc 1, no cherry-pick text": "landing-lib.sh landing_push_main_with_rescue merge-base --is-ancestor guard; pinned by scenario 7 in tests/run-swarm-landing-test.sh (10 scenarios passed)",
    "2. failed push WITH commits, rescue push succeeds: unchanged (reason push-parked-on-rescue, branch pushed, existing alarm)": "landing-lib.sh keeps the original park in the success branch of the rc check; scenario 6 still pins it (its git shim gained `merge-base --is-ancestor HEAD origin/main` exit 1 so the new guard does not short-circuit)",
    "3. failed push WITH commits, rescue push also fails: SWARM_EXIT_REASON=push-rescue-unreachable, alarm says branch does NOT exist, names workdir and SHA": "landing-lib.sh else-branch of the rescue push rc check; pinned by scenario 8 in tests/run-swarm-landing-test.sh",
    "4. scenarios 7 and 8 pin 1 and 3; scenario 6 keeps 2 with `merge-base --is-ancestor` exit 1 added": "tests/run-swarm-landing-test.sh: scenario 6 shim edited, scenarios 7/8 added, suite reports 10 scenarios passed (was 8)",
    "5. consumers' docs/agents/swarm-atlas.md §4 vocabulary gains both reasons when the bump is vendored": "That file does not live in this repo (CLAUDE.md: the swarm atlas lives with its original product repo pending a split); it is a downstream when-vendored concern, noted in STATUS.md header and docs/GOTCHAS.md #54"
  },
  "summary": "landing_push_main_with_rescue no longer asserts a rescue park it did not verify: it skips the park when HEAD is already on origin/main and checks the rescue push's rc, with distinct exit reasons for both new paths.",
  "blockers": []
}
**close-report** for #141 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 141, "status": "success", "commits": [ "bba1ea3" ], "changed_files": [ "landing-lib.sh", "tests/run-swarm-landing-test.sh", "docs/GOTCHAS.md", "STATUS.md" ], "tests": [ { "command": "bash tests/run-swarm-landing-test.sh", "exit_code": 0 } ], "criteria": { "1. failed push, HEAD already in origin/main: no rescue branch, SWARM_EXIT_REASON=push-failed-nothing-to-land, rc 1, no cherry-pick text": "landing-lib.sh landing_push_main_with_rescue merge-base --is-ancestor guard; pinned by scenario 7 in tests/run-swarm-landing-test.sh (10 scenarios passed)", "2. failed push WITH commits, rescue push succeeds: unchanged (reason push-parked-on-rescue, branch pushed, existing alarm)": "landing-lib.sh keeps the original park in the success branch of the rc check; scenario 6 still pins it (its git shim gained `merge-base --is-ancestor HEAD origin/main` exit 1 so the new guard does not short-circuit)", "3. failed push WITH commits, rescue push also fails: SWARM_EXIT_REASON=push-rescue-unreachable, alarm says branch does NOT exist, names workdir and SHA": "landing-lib.sh else-branch of the rescue push rc check; pinned by scenario 8 in tests/run-swarm-landing-test.sh", "4. scenarios 7 and 8 pin 1 and 3; scenario 6 keeps 2 with `merge-base --is-ancestor` exit 1 added": "tests/run-swarm-landing-test.sh: scenario 6 shim edited, scenarios 7/8 added, suite reports 10 scenarios passed (was 8)", "5. consumers' docs/agents/swarm-atlas.md §4 vocabulary gains both reasons when the bump is vendored": "That file does not live in this repo (CLAUDE.md: the swarm atlas lives with its original product repo pending a split); it is a downstream when-vendored concern, noted in STATUS.md header and docs/GOTCHAS.md #54" }, "summary": "landing_push_main_with_rescue no longer asserts a rescue park it did not verify: it skips the park when HEAD is already on origin/main and checks the rescue push's rc, with distinct exit reasons for both new paths.", "blockers": [] } ``` </details>
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#141
No description provided.