run-swarm reconcile stage reds a successful run on a foreign #NN (curl -sf 404 under set -e) #21

Closed
opened 2026-08-22 14:54:45 +00:00 by matou-build-agent · 2 comments

Summary

The reconcile push to main stage of run-swarm.sh (root/product source)
turns a successful, already-pushed run RED when the run's commit range
cites a #NN that does not resolve in this repo — a matou-app PR or an idss
issue referenced in a STATUS line.

Root cause (run 70, verdict reconcile push to main exit=22)

run-swarm.sh builds the Mattermost summary by scraping every #NN
from the commit subjects in $start_sha..HEAD:

commit_nums="$(git log --format=%s "$start_sha"..HEAD | grep -oE '#[0-9]+' | tr -d '#' || true)"
while read -r num; do
  [ -n "$num" ] || continue
  issue="$(api "$FORGEJO_API/issues/$num")"   # api = curl -sf
  ...
done < <({ jq -r '.[].number' <<<"$ready"; printf '%s\n' $commit_nums; } | sort -un)

api() is curl -sf, so a number that 404s in this repo exits 22, and under
set -euo pipefail the whole reconcile stage dies — after the work is
committed, pushed and the issues closed. The Mattermost summary and the
self-rearm (spec D5) never fire, and the run is marked failure, waking the
healer.

Run 70's range included STATUS: matou-app PR #54 merged … → GET /issues/54 → 404 → exit 22. Proven live: #10/#11/#18/#19/#20 → 200,
#54 → 404 (curl -sf rc=22). This recurs on any run whose STATUS/vendor
commits cite a foreign issue/PR number (common).

Fix

Guard the per-number GET so a number this repo cannot resolve is skipped
in the summary instead of aborting the stage:

issue="$(api "$FORGEJO_API/issues/$num")" || continue

Strictly safer than the status quo: a transient 5xx on a real own-repo issue
now omits one summary line instead of reding an already-successful run.
Update tests/ in the same commit (add a reconcile-summary case where a
scraped #NN 404s and the loop still completes) — CLAUDE.md lib-change rule.

Vendor note

I have already hotfixed the running vendored self-copy at
.sandcastle/run-swarm.sh (commit 8d2a402 on main) so the swarm stops
reding green runs now. That file shows as drift against FACTORY_REF
(1b7abc2) until this root fix lands and a human re-vendors
(bash onboarding/onboard.sh vendor .sandcastle <sha> --force, GOTCHAS 4) —
the --force re-vendor deliberately carries the hotfix back to the root.
The root fix here should be byte-identical to the hotfix plus the test.

## Summary The `reconcile push to main` stage of `run-swarm.sh` (root/product source) turns a **successful, already-pushed** run RED when the run's commit range cites a `#NN` that does not resolve in this repo — a matou-app PR or an idss issue referenced in a STATUS line. ## Root cause (run 70, verdict `reconcile push to main` exit=22) `run-swarm.sh` builds the Mattermost summary by scraping **every** `#NN` from the commit subjects in `$start_sha..HEAD`: ``` commit_nums="$(git log --format=%s "$start_sha"..HEAD | grep -oE '#[0-9]+' | tr -d '#' || true)" while read -r num; do [ -n "$num" ] || continue issue="$(api "$FORGEJO_API/issues/$num")" # api = curl -sf ... done < <({ jq -r '.[].number' <<<"$ready"; printf '%s\n' $commit_nums; } | sort -un) ``` `api()` is `curl -sf`, so a number that 404s in this repo exits 22, and under `set -euo pipefail` the whole reconcile stage dies — **after** the work is committed, pushed and the issues closed. The Mattermost summary and the self-rearm (spec D5) never fire, and the run is marked failure, waking the healer. Run 70's range included `STATUS: matou-app PR #54 merged …` → `GET /issues/54` → **404** → exit 22. Proven live: `#10/#11/#18/#19/#20` → 200, `#54` → 404 (curl -sf rc=22). This recurs on any run whose STATUS/vendor commits cite a foreign issue/PR number (common). ## Fix Guard the per-number GET so a number this repo cannot resolve is **skipped** in the summary instead of aborting the stage: ``` issue="$(api "$FORGEJO_API/issues/$num")" || continue ``` Strictly safer than the status quo: a transient 5xx on a real own-repo issue now omits one summary line instead of reding an already-successful run. Update `tests/` in the same commit (add a reconcile-summary case where a scraped `#NN` 404s and the loop still completes) — CLAUDE.md lib-change rule. ## Vendor note I have already hotfixed the **running** vendored self-copy at `.sandcastle/run-swarm.sh` (commit `8d2a402` on `main`) so the swarm stops reding green runs now. That file shows as drift against `FACTORY_REF` (`1b7abc2`) until this root fix lands and a human re-vendors (`bash onboarding/onboard.sh vendor .sandcastle <sha> --force`, GOTCHAS 4) — the `--force` re-vendor deliberately carries the hotfix back to the root. The root fix here should be byte-identical to the hotfix plus the test.
Author
Member

swarm-claim host=matou-dev-server-01 run=81
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=matou-dev-server-01 run=81 (automated multi-host claim — lowest live claim id works this ticket)
Author
Member

close-report for #21 — status success

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

envelope
{
  "issue": 21,
  "status": "success",
  "commits": [
    "2dcae48"
  ],
  "changed_files": [
    "run-swarm.sh",
    "tests/run-swarm-reconcile-summary-test.sh",
    "STATUS.md"
  ],
  "tests": [
    {
      "command": "bash tests/run-swarm-reconcile-summary-test.sh",
      "exit_code": 0
    },
    {
      "command": "for t in tests/*.sh onboarding/tests/*.sh; do bash \"$t\"; done",
      "exit_code": 0
    }
  ],
  "criteria": {
    "Guard the per-number GET so an unresolvable #NN is skipped, not aborting the stage": "run-swarm.sh reconcile loop: issue=\"$(api \"$FORGEJO_API/issues/$num\")\" || continue (commit 2dcae48)",
    "Update tests/ in the same commit with a reconcile-summary case where a scraped #NN 404s and the loop still completes": "tests/run-swarm-reconcile-summary-test.sh: shimmed api 404s a foreign #54, asserts the loop completes, the foreign line is omitted, and own-repo #10/#11/#21 land (red pre-fix, green with fix)",
    "Byte-identical to the running self-copy hotfix plus the test": "root run-swarm.sh loop now matches .sandcastle/run-swarm.sh (hotfix 8d2a402) verbatim, plus the new test"
  },
  "summary": "run-swarm.sh reconcile summary now skips a foreign #NN with || continue instead of reding an already-successful run under set -e.",
  "blockers": []
}
**close-report** for #21 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; closing. <details><summary>envelope</summary> ```json { "issue": 21, "status": "success", "commits": [ "2dcae48" ], "changed_files": [ "run-swarm.sh", "tests/run-swarm-reconcile-summary-test.sh", "STATUS.md" ], "tests": [ { "command": "bash tests/run-swarm-reconcile-summary-test.sh", "exit_code": 0 }, { "command": "for t in tests/*.sh onboarding/tests/*.sh; do bash \"$t\"; done", "exit_code": 0 } ], "criteria": { "Guard the per-number GET so an unresolvable #NN is skipped, not aborting the stage": "run-swarm.sh reconcile loop: issue=\"$(api \"$FORGEJO_API/issues/$num\")\" || continue (commit 2dcae48)", "Update tests/ in the same commit with a reconcile-summary case where a scraped #NN 404s and the loop still completes": "tests/run-swarm-reconcile-summary-test.sh: shimmed api 404s a foreign #54, asserts the loop completes, the foreign line is omitted, and own-repo #10/#11/#21 land (red pre-fix, green with fix)", "Byte-identical to the running self-copy hotfix plus the test": "root run-swarm.sh loop now matches .sandcastle/run-swarm.sh (hotfix 8d2a402) verbatim, plus the new test" }, "summary": "run-swarm.sh reconcile summary now skips a foreign #NN with || continue instead of reding an already-successful run under set -e.", "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#21
No description provided.