heal: the watchdog never fetches the failing run's job log — watchdog_run_url reads .html_url but the /actions/tasks payload carries .url (#188 dead in watchdog mode) #304

Closed
opened 2026-10-24 03:07:33 +00:00 by matou-build-agent · 7 comments

Filed by the swarm healer (watchdog mode, signature 0ff1caf1b642, evidence /tmp/matou-heal-Matou-dev-factory.jZ3vYf, healer host matou-dev-server-01).

Symptom

This heal run carried no fault text at all. The failing leg ran on another pool host, so run-verdict.txt, worker-logs.txt and no-local-evidence.txt all say only "no local evidence", seam-degraded is set, and the trigger error line degraded to the empty string:

watchdog: streak ()

and job-log.txt said:

job log not fetched: no run URL for this incident (mode=watchdog) — nothing was probed

That is precisely the cross-host case #188 was built for, and the one route that could have spoken was never probed.

Root cause

heal.sh:294 fetches the evidence payload from $FORGEJO_API/actions/tasks?limit=50&page=1 — deliberately, because the /actions/runs sibling does not scale (GOTCHAS 16). That endpoint's rows carry url, never html_url:

$ jq -r '[.workflow_runs[]|keys]|add|unique' runs.json
["created_at","display_title","event","head_branch","head_sha","id","name",
 "run_number","run_started_at","status","updated_at","url","workflow_id"]
$ jq '[.workflow_runs[]|select(has("html_url"))]|length' runs.json
0

watchdog_run_url (heal-lib.sh:236-247) projects url: (.html_url // "") and then keeps only rows with a non-empty one — so it echoes empty for every workflow on this Forgejo. collect_job_logs then takes its [ -z "$run_url" ] branch and probes nothing. #188 has never fired in watchdog mode; it works in hook mode only, where RUN_URL comes from the job env.

.url is already the WEB url and is the correct base. Fetched by hand for this incident's failing run:

$ curl -s -H "Authorization: token $TOK" \
    https://git.matou.nz/Matou/dev-factory/actions/runs/24158/jobs/0/attempt/1/logs
...
fatal: unable to access 'https://git.matou.nz/Matou/dev-factory.git/': Could not resolve host: git.matou.nz
⚙️ [runner]: RUN exit status 3

200 OK, one decisive line — the diagnosis this bundle should have carried automatically.

Why it shipped green

tests/heal-lib-test.sh:263-288 builds its own fixture rows with an invented html_url key, and its second case ("a payload with NO html_url → empty") enshrines the broken behaviour. No fixture has ever had the real actions/tasks shape.

Fix sketch

  1. heal-lib.sh watchdog_run_url: project (.html_url // .url // ""). Keep html_url first so a payload shape that does carry it still wins; reading a field is still DATA, never a literal actions/runs string, so the actions-endpoint ratchet stays green.
  2. tests/heal-lib-test.sh: add a fixture whose rows carry url only (the real /actions/tasks shape, sample above) and assert the URL comes back; keep a rows-with-neither case for the genuine "not fetched" note (AC4).
  3. Secondary, same blast radius: collect_job_logs (heal.sh:245) treats any non-2xx past leg 0 as the end of the matrix, but Forgejo's job indices are not contiguous — for run 24158, leg 0 → 200, leg 1 → 404, leg 2 → 200. A matrix whose failing leg sits above a gap is skipped. Tolerate N consecutive misses up to HEAL_JOB_LOG_MAX_LEGS instead of breaking on the first.

Notes

  • The healer charter forbids it from modifying heal.sh / heal-lib.sh, so this is ticketed, not repaired.
  • A root fix does not reach the running copy until a human re-vendors (bash onboarding/onboard.sh vendor .sandcastle <sha>, GOTCHAS 4).

Evidence

  • heal evidence dir: /tmp/matou-heal-Matou-dev-factory.jZ3vYf on matou-dev-server-01
  • the incident it blinded: two consecutive swarm (bens-mac-04) reds — runs 24158 / 24161 (tasks 245449 / 245479), both Could not resolve host: git.matou.nz, i.e. the #191 recurrence.
Filed by the swarm healer (watchdog mode, signature `0ff1caf1b642`, evidence `/tmp/matou-heal-Matou-dev-factory.jZ3vYf`, healer host `matou-dev-server-01`). ## Symptom This heal run carried **no fault text at all**. The failing leg ran on another pool host, so `run-verdict.txt`, `worker-logs.txt` and `no-local-evidence.txt` all say only "no local evidence", `seam-degraded` is set, and the trigger error line degraded to the empty string: ``` watchdog: streak () ``` and `job-log.txt` said: ``` job log not fetched: no run URL for this incident (mode=watchdog) — nothing was probed ``` That is precisely the cross-host case #188 was built for, and the one route that could have spoken was never probed. ## Root cause `heal.sh:294` fetches the evidence payload from `$FORGEJO_API/actions/tasks?limit=50&page=1` — deliberately, because the `/actions/runs` sibling does not scale (GOTCHAS 16). That endpoint's rows carry **`url`**, never `html_url`: ``` $ jq -r '[.workflow_runs[]|keys]|add|unique' runs.json ["created_at","display_title","event","head_branch","head_sha","id","name", "run_number","run_started_at","status","updated_at","url","workflow_id"] $ jq '[.workflow_runs[]|select(has("html_url"))]|length' runs.json 0 ``` `watchdog_run_url` (`heal-lib.sh:236-247`) projects `url: (.html_url // "")` and then keeps only rows with a non-empty one — so it echoes empty for **every** workflow on this Forgejo. `collect_job_logs` then takes its `[ -z "$run_url" ]` branch and probes nothing. **#188 has never fired in watchdog mode**; it works in hook mode only, where `RUN_URL` comes from the job env. `.url` is already the WEB url and is the correct base. Fetched by hand for this incident's failing run: ``` $ curl -s -H "Authorization: token $TOK" \ https://git.matou.nz/Matou/dev-factory/actions/runs/24158/jobs/0/attempt/1/logs ... fatal: unable to access 'https://git.matou.nz/Matou/dev-factory.git/': Could not resolve host: git.matou.nz ⚙️ [runner]: RUN exit status 3 ``` 200 OK, one decisive line — the diagnosis this bundle should have carried automatically. ## Why it shipped green `tests/heal-lib-test.sh:263-288` builds its own fixture rows with an invented `html_url` key, and its second case ("a payload with NO html_url → empty") *enshrines* the broken behaviour. No fixture has ever had the real `actions/tasks` shape. ## Fix sketch 1. `heal-lib.sh` `watchdog_run_url`: project `(.html_url // .url // "")`. Keep `html_url` first so a payload shape that does carry it still wins; reading a field is still DATA, never a literal `actions/runs` string, so the actions-endpoint ratchet stays green. 2. `tests/heal-lib-test.sh`: add a fixture whose rows carry **`url` only** (the real `/actions/tasks` shape, sample above) and assert the URL comes back; keep a rows-with-neither case for the genuine "not fetched" note (AC4). 3. **Secondary, same blast radius:** `collect_job_logs` (`heal.sh:245`) treats any non-2xx past leg 0 as the end of the matrix, but Forgejo's job indices are not contiguous — for run 24158, leg 0 → 200, leg 1 → **404**, leg 2 → 200. A matrix whose failing leg sits above a gap is skipped. Tolerate N consecutive misses up to `HEAL_JOB_LOG_MAX_LEGS` instead of breaking on the first. ## Notes - The healer charter forbids it from modifying `heal.sh` / `heal-lib.sh`, so this is ticketed, not repaired. - A root fix does **not** reach the running copy until a human re-vendors (`bash onboarding/onboard.sh vendor .sandcastle <sha>`, GOTCHAS 4). ## Evidence - heal evidence dir: `/tmp/matou-heal-Matou-dev-factory.jZ3vYf` on `matou-dev-server-01` - the incident it blinded: two consecutive `swarm (bens-mac-04)` reds — runs 24158 / 24161 (tasks 245449 / 245479), both `Could not resolve host: git.matou.nz`, i.e. the #191 recurrence.
Author
Member

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

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

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

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

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

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

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

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

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

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

⏩ independent reviewer for #304 — verdict unauthenticated

review JSON
{
  "verdict": "unauthenticated",
  "findings": []
}
:fast_forward: **independent reviewer** for #304 — verdict `unauthenticated` <details><summary>review JSON</summary> ```json { "verdict": "unauthenticated", "findings": [] } ``` </details>
Author
Member

close-report for #304 — status success

✅ close-report gates passed — every claim verified against the pushed worker branch sandcastle/worker/20261024-045639-da1b9a (pre-land — the host promotes it to main only after its post-run verify, #193/#283); issue closed.

envelope
{
  "issue": 304,
  "status": "success",
  "commits": [
    "2cf3a38aa80a2cd27acab72045540efcebe551be"
  ],
  "changed_files": [
    "docs/GOTCHAS.md",
    "docs/gotchas/304-watchdog-run-url-read-html_url-but-actions-tasks-carries-url.md",
    "heal-lib.sh",
    "heal.sh",
    "tests/heal-lib-test.sh",
    "tests/heal-test.sh"
  ],
  "tests": [
    {
      "command": "bash tests/heal-lib-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash tests/heal-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash tests/actions-endpoint-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash tests/docs-budget-test.sh",
      "exit_code": 0
    }
  ],
  "criteria": {
    "watchdog_run_url resolves the real /actions/tasks shape (.url, not .html_url)": "heal-lib.sh:241 projects `(.html_url // .url // \"\")`; tests/heal-lib-test.sh adds a url-only fixture (run 24161/24158) asserting the URL comes back, a both-present case (html_url wins), and a neither case (empty)",
    "html_url still wins when a row carries both (older/foreign shape kept)": "tests/heal-lib-test.sh both-present case asserts the .html_url value returns",
    "a row carrying neither url nor html_url still echoes empty (AC4 'not fetched' note)": "tests/heal-lib-test.sh neither-case asserts empty; collect_job_logs' no-run-url branch writes the 'not fetched' note",
    "actions-endpoint ratchet stays green (fields read as DATA, no literal actions/runs string)": "tests/actions-endpoint-test.sh exit 0",
    "collect_job_logs tolerates a non-contiguous job matrix (gap above leg 0)": "heal.sh collect_job_logs no longer breaks on a non-2xx past leg 0, probing up to HEAL_JOB_LOG_MAX_LEGS; tests/heal-test.sh #304 case (JOBLOG_OK_LEGS='0 2') asserts leg 2's log still lands",
    "transport failure still stops early; unavailable/not-fetched note still lands (GOTCHAS 30)": "heal.sh breaks on curl rc!=0 and writes the explicit note when nothing readable; tests/heal-test.sh AC3 (all-404) still asserts 'job log unavailable (HTTP 404)'",
    "new operational hazard recorded": "docs/gotchas/304-*.md body + docs/GOTCHAS.md index row #304, same commit"
  },
  "summary": "watchdog_run_url now falls back to the /actions/tasks `.url` (so #188 fires in watchdog mode) and collect_job_logs tolerates a non-contiguous job matrix.",
  "reason": "",
  "blockers": []
}
**close-report** for #304 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against the pushed worker branch `sandcastle/worker/20261024-045639-da1b9a` (pre-land — the host promotes it to `main` only after its post-run verify, #193/#283); issue closed. <details><summary>envelope</summary> ```json { "issue": 304, "status": "success", "commits": [ "2cf3a38aa80a2cd27acab72045540efcebe551be" ], "changed_files": [ "docs/GOTCHAS.md", "docs/gotchas/304-watchdog-run-url-read-html_url-but-actions-tasks-carries-url.md", "heal-lib.sh", "heal.sh", "tests/heal-lib-test.sh", "tests/heal-test.sh" ], "tests": [ { "command": "bash tests/heal-lib-test.sh", "exit_code": 0 }, { "command": "bash tests/heal-test.sh", "exit_code": 0 }, { "command": "bash tests/actions-endpoint-test.sh", "exit_code": 0 }, { "command": "bash tests/docs-budget-test.sh", "exit_code": 0 } ], "criteria": { "watchdog_run_url resolves the real /actions/tasks shape (.url, not .html_url)": "heal-lib.sh:241 projects `(.html_url // .url // \"\")`; tests/heal-lib-test.sh adds a url-only fixture (run 24161/24158) asserting the URL comes back, a both-present case (html_url wins), and a neither case (empty)", "html_url still wins when a row carries both (older/foreign shape kept)": "tests/heal-lib-test.sh both-present case asserts the .html_url value returns", "a row carrying neither url nor html_url still echoes empty (AC4 'not fetched' note)": "tests/heal-lib-test.sh neither-case asserts empty; collect_job_logs' no-run-url branch writes the 'not fetched' note", "actions-endpoint ratchet stays green (fields read as DATA, no literal actions/runs string)": "tests/actions-endpoint-test.sh exit 0", "collect_job_logs tolerates a non-contiguous job matrix (gap above leg 0)": "heal.sh collect_job_logs no longer breaks on a non-2xx past leg 0, probing up to HEAL_JOB_LOG_MAX_LEGS; tests/heal-test.sh #304 case (JOBLOG_OK_LEGS='0 2') asserts leg 2's log still lands", "transport failure still stops early; unavailable/not-fetched note still lands (GOTCHAS 30)": "heal.sh breaks on curl rc!=0 and writes the explicit note when nothing readable; tests/heal-test.sh AC3 (all-404) still asserts 'job log unavailable (HTTP 404)'", "new operational hazard recorded": "docs/gotchas/304-*.md body + docs/GOTCHAS.md index row #304, same commit" }, "summary": "watchdog_run_url now falls back to the /actions/tasks `.url` (so #188 fires in watchdog mode) and collect_job_logs tolerates a non-contiguous job matrix.", "reason": "", "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#304
No description provided.