heal.sh watchdog mode dies on 'RUN_URL: unbound variable' (f035e4e) — every consumer pinned past #135 has a red hourly watchdog #147

Closed
opened 2026-09-15 20:02:09 +00:00 by ben · 2 comments
Owner

Symptom. healer.yml's hourly watchdog job fails in ~10 s on every consumer pinned at or after f035e4e (2026-09-10, #135): Matou/idss (pin 4149528) run 24710 red at 19:00Z today, Matou/pregnancy-navigator (pin 9055eb5) run 11 red at 19:57Z. Consumers on the older pin dc65bde (coa, matou-website) and this repo's own self-copy (2445159) are green. Reproduced by hand on matou-workstation in the pregnancy-navigator workdir:

$ . ~/swarm/host-env.sh; export FORGEJO_API=…/repos/Matou/pregnancy-navigator HEAL_MODE=watchdog; bash .sandcastle/heal.sh
heal: evidence at /tmp/matou-heal-Matou-pregnancy-navigator.hH5VC3 (mode=watchdog workflow=unknown)
.sandcastle/heal.sh: line 228: RUN_URL: unbound variable
rc=1

Cause. heal.sh runs under set -euo pipefail. #135's pool-locality honesty block (heal.sh lines ~227–232, git blame → f035e4e) does

local runid="${RUN_URL##*/}"
{ [ -n "$runid" ] && [ "$runid" != "${RUN_URL:-}" ]; } || runid="${SWARM_RUN_ID:-watchdog}"

The first line dereferences RUN_URL unguarded. RUN_URL is set only by the ci.yml healer step; healer.yml's watchdog job (template onboarding/templates/workflows/healer.yml.tmpl) does not set it — and the watchdog is exactly the mode where nfresh -eq 0 and no local verdict is the normal state, so the branch fires on every hourly sweep. The second line's ${RUN_URL:-} shows the guard was intended.

Fix. local runid="${RUN_URL:-}"; runid="${runid##*/}" (or "${RUN_URL:-}" inline). Add the case to tests/heal-test.sh (or heal-lib-test.sh, whichever owns this block): watchdog mode with RUN_URL unset and no fresh worker logs must reach the "no local evidence" artefact write and exit 0 with "all healthy" — the existing fixtures shim curl; today that path only runs with RUN_URL exported. Same commit: STATUS.md header + log; docs/GOTCHAS.md entry (a set -u script must never touch a workflow-conditional env var bare — the watchdog job's env is a subset of the ci healer step's).

Acceptance.

  • HEAL_MODE=watchdog bash heal.sh with RUN_URL unset exits 0 on a healthy runs.json (test proves it, offline).
  • The offline suite loop from CLAUDE.md is green.
  • After the pin bump, idss's and pregnancy-navigator's next hourly watchdog runs are green (residue for the human who bumps the pins; note it in the close-report).

Found 2026-09-15 while onboarding Matou/pregnancy-navigator (tracking issue pregnancy-navigator#1).

**Symptom.** `healer.yml`'s hourly `watchdog` job fails in ~10 s on every consumer pinned at or after `f035e4e` (2026-09-10, #135): `Matou/idss` (pin 4149528) run 24710 red at 19:00Z today, `Matou/pregnancy-navigator` (pin 9055eb5) run 11 red at 19:57Z. Consumers on the older pin `dc65bde` (coa, matou-website) and this repo's own self-copy (2445159) are green. Reproduced by hand on matou-workstation in the pregnancy-navigator workdir: ``` $ . ~/swarm/host-env.sh; export FORGEJO_API=…/repos/Matou/pregnancy-navigator HEAL_MODE=watchdog; bash .sandcastle/heal.sh heal: evidence at /tmp/matou-heal-Matou-pregnancy-navigator.hH5VC3 (mode=watchdog workflow=unknown) .sandcastle/heal.sh: line 228: RUN_URL: unbound variable rc=1 ``` **Cause.** `heal.sh` runs under `set -euo pipefail`. #135's pool-locality honesty block (`heal.sh` lines ~227–232, `git blame` → f035e4e) does ```sh local runid="${RUN_URL##*/}" { [ -n "$runid" ] && [ "$runid" != "${RUN_URL:-}" ]; } || runid="${SWARM_RUN_ID:-watchdog}" ``` The first line dereferences `RUN_URL` unguarded. `RUN_URL` is set only by the `ci.yml` healer step; `healer.yml`'s watchdog job (template `onboarding/templates/workflows/healer.yml.tmpl`) does not set it — and the watchdog is exactly the mode where `nfresh -eq 0` and no local verdict is the *normal* state, so the branch fires on every hourly sweep. The second line's `${RUN_URL:-}` shows the guard was intended. **Fix.** `local runid="${RUN_URL:-}"; runid="${runid##*/}"` (or `"${RUN_URL:-}"` inline). Add the case to `tests/heal-test.sh` (or `heal-lib-test.sh`, whichever owns this block): watchdog mode with `RUN_URL` unset and no fresh worker logs must reach the "no local evidence" artefact write and exit 0 with "all healthy" — the existing fixtures shim `curl`; today that path only runs with `RUN_URL` exported. Same commit: `STATUS.md` header + log; `docs/GOTCHAS.md` entry (a `set -u` script must never touch a workflow-conditional env var bare — the watchdog job's env is a subset of the ci healer step's). **Acceptance.** - `HEAL_MODE=watchdog bash heal.sh` with `RUN_URL` unset exits 0 on a healthy `runs.json` (test proves it, offline). - The offline suite loop from `CLAUDE.md` is green. - After the pin bump, idss's and pregnancy-navigator's next hourly `watchdog` runs are green (residue for the human who bumps the pins; note it in the close-report). Found 2026-09-15 while onboarding `Matou/pregnancy-navigator` (tracking issue pregnancy-navigator#1).

swarm-claim host=bens-mac-04 run=10384
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=bens-mac-04 run=10384 (automated multi-host claim — lowest live claim id works this ticket)

close-report for #147 — status success

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

envelope
{
  "issue": 147,
  "status": "success",
  "commits": [
    "624dc54"
  ],
  "changed_files": [
    "heal.sh",
    "tests/heal-test.sh",
    "docs/GOTCHAS.md",
    "STATUS.md"
  ],
  "tests": [
    {
      "command": "bash tests/heal-test.sh",
      "exit_code": 0
    }
  ],
  "criteria": {
    "HEAL_MODE=watchdog bash heal.sh with RUN_URL unset exits 0 on a healthy runs.json (test proves it, offline)": "heal.sh:228 now reads `local runid=\"${RUN_URL:-}\"; runid=\"${runid##*/}\"`; tests/heal-test.sh #147 case runs watchdog mode with RUN_URL and SWARM_RUN_ID env -u unset, asserts exit 0, no 'RUN_URL: unbound variable', the no-local-evidence artefact written, and the runid falls back to 'watchdog' — red-before-green verified by reintroducing the bare deref (failed on 'RUN_URL: unbound variable')",
    "The offline suite loop from CLAUDE.md is green": "bash tests/heal-test.sh -> 19 scenarios passed (exit 0); the two other suite failures (fleet-tui pytest not installed; onboard-lib rehearsal-heal-prompt render mismatch) are pre-existing on the clean tree (confirmed via git stash) and touch no file in this change",
    "After the pin bump idss's and pregnancy-navigator's next hourly watchdog runs are green (residue for the human who bumps the pins)": "noted in close-report and STATUS.md log as residue for the human who re-vendors — the fix is in the harness SOURCE (heal.sh); consumers pick it up at their next FACTORY_REF bump (GOTCHAS 4)"
  },
  "summary": "heal.sh watchdog mode reads RUN_URL through a default on first touch so the no-local-evidence block no longer dies on 'RUN_URL: unbound variable' under set -u.",
  "blockers": []
}
**close-report** for #147 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 147, "status": "success", "commits": [ "624dc54" ], "changed_files": [ "heal.sh", "tests/heal-test.sh", "docs/GOTCHAS.md", "STATUS.md" ], "tests": [ { "command": "bash tests/heal-test.sh", "exit_code": 0 } ], "criteria": { "HEAL_MODE=watchdog bash heal.sh with RUN_URL unset exits 0 on a healthy runs.json (test proves it, offline)": "heal.sh:228 now reads `local runid=\"${RUN_URL:-}\"; runid=\"${runid##*/}\"`; tests/heal-test.sh #147 case runs watchdog mode with RUN_URL and SWARM_RUN_ID env -u unset, asserts exit 0, no 'RUN_URL: unbound variable', the no-local-evidence artefact written, and the runid falls back to 'watchdog' — red-before-green verified by reintroducing the bare deref (failed on 'RUN_URL: unbound variable')", "The offline suite loop from CLAUDE.md is green": "bash tests/heal-test.sh -> 19 scenarios passed (exit 0); the two other suite failures (fleet-tui pytest not installed; onboard-lib rehearsal-heal-prompt render mismatch) are pre-existing on the clean tree (confirmed via git stash) and touch no file in this change", "After the pin bump idss's and pregnancy-navigator's next hourly watchdog runs are green (residue for the human who bumps the pins)": "noted in close-report and STATUS.md log as residue for the human who re-vendors — the fix is in the harness SOURCE (heal.sh); consumers pick it up at their next FACTORY_REF bump (GOTCHAS 4)" }, "summary": "heal.sh watchdog mode reads RUN_URL through a default on first touch so the no-local-evidence block no longer dies on 'RUN_URL: unbound variable' under set -u.", "blockers": [] } ``` </details>
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.

Dependencies

No dependencies set.

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