heal: put the failing job's own log in every evidence bundle — the fetchable route is $RUN_URL/jobs/<n>/attempt/1/logs, and omitting /attempt/1 cost three passes a "mechanism not identified" #188

Closed
opened 2026-10-09 19:11:09 +00:00 by matou-build-agent · 2 comments

This was generated by AI (the swarm healer, watchdog pass of 2026-10-09 19:02 UTC, signature 5f7b0b1abedc).

Symptom

A pool host wedged at 09:46 UTC on 2026-10-09 and reddened every job that
landed on it, in all five consumer repos, for 9+ hours. Four full Opus healer
investigations ran on it (11:10, 12:02, 18:00, 19:02 UTC) and three of them
closed with "mechanism not identified"
, each recording some form of "Forgejo
serves no job-log endpoint on this version (404)"
.

It does serve one. The failing leg's log is a single decisive line
(Could not resolve host: git.matou.nz) and was readable with the ordinary repo
token the whole time. The URL the earlier passes probed was simply missing one
path segment.

Cause

heal.sh's collect_evidence gathers only host-local artifacts
(worker-logs.txt, run-verdict.txt, runner-journal.txt). When the failing
leg ran on a different pool host, those are empty by construction — #135
correctly writes the "ran on another swarm pool host" line instead of leaving
them blank, but the bundle then carries no fault text at all, the signature
degrades to the bare workflow name (idss#2045), and the agent is left to infer
a mechanism from durations and SHAs.

The fix is to put the job's own log in the bundle. This works today, on this
Forgejo (15.0.5), with FORGEJO_TOKEN and no admin scope:

curl -sf -H "Authorization: token $FORGEJO_TOKEN" \
  "$RUN_URL/jobs/<job-index>/attempt/1/logs"

<job-index> is the job's 0-based index in the run (for a matrix, the leg).
Verified live: 200, 945–2088 bytes, on Matou/dev-factory runs
19847/19852/19858/19863 and Matou/idss run 42411.

What 404s — and what the earlier passes probed:

URL result
$RUN_URL/jobs/<n>/attempt/1/logs 200
$RUN_URL/jobs/<n>/logs 404 Not found.
$FORGEJO_API/actions/runs/<n>/jobs 404 404 page not found
$FORGEJO_API/actions/jobs/<id>/logs 404 404 page not found

/attempt/1/ is the whole difference.

Acceptance

  1. heal.sh writes job-log.txt into the evidence directory for the failing
    run, built from RUN_URL (never a literal actions/runs string, so the
    actions-endpoint ratchet stays green), and the charter prompt lists it in
    the "Ground truth to read FIRST" block.
  2. In watchdog mode there is no RUN_URL for the suspect run — derive it
    from the run number the detector keyed on, and fetch every leg's log
    (job index 0..n-1) so a matrix fault is attributable to its leg. Fetching
    all legs is also what proves "sibling green, this leg red" without a
    duration argument.
  3. Best-effort and fail-soft: a 404/403/timeout writes a one-line "job log
    unavailable ()" note, never reds the heal run.
  4. The bundle must not silently claim an absence it never probed — if the fetch
    was skipped, say so (same rule as GOTCHAS 30).

Tests

tests/heal-test.sh — a shimmed curl serving the log on
…/attempt/1/logs lands it in the bundle; a 404 leaves the fail-soft note and
the heal run still exits 0; the URL is built from RUN_URL (ratchet). Offline,
per CLAUDE.md's same-commit rule.

Notes

  • heal.sh is a FACTORY_MANIFEST-vendored file: it is source at this
    repo's root and reaches the running .sandcastle/ self-copy and every
    consumer only when a human re-vendors (GOTCHAS 4). This repo's own self-pin
    is 144 commits behind today — see #131 / #132.
  • Matou/idss#2036 already carries this as its AC4 with a handoff patch
    (comment 60682) that uses ${RUN_URL}/jobs/0/attempt/1/logs — i.e. the
    working route was written down there on 2026-10-01 and the later healer
    passes did not find it. That patch hard-codes job index 0; acceptance 2
    above widens it. AC1 (forgejo-lib.sh read retry) and AC3 (hook-mode
    honesty) in that same handoff are still unlanded here too.
  • Origin incidents: Matou/idss#2044 (the host fault — mechanism now
    commented there), Matou/idss#2045 (the duplicate-investigation brake),
    dev-factory #135 (pool-locality, closed).
> *This was generated by AI (the swarm healer, watchdog pass of 2026-10-09 19:02 UTC, signature `5f7b0b1abedc`).* ## Symptom A pool host wedged at 09:46 UTC on 2026-10-09 and reddened **every** job that landed on it, in all five consumer repos, for 9+ hours. Four full Opus healer investigations ran on it (11:10, 12:02, 18:00, 19:02 UTC) and **three of them closed with "mechanism not identified"**, each recording some form of *"Forgejo serves no job-log endpoint on this version (404)"*. It does serve one. The failing leg's log is a single decisive line (`Could not resolve host: git.matou.nz`) and was readable with the ordinary repo token the whole time. The URL the earlier passes probed was simply missing one path segment. ## Cause `heal.sh`'s `collect_evidence` gathers only **host-local** artifacts (`worker-logs.txt`, `run-verdict.txt`, `runner-journal.txt`). When the failing leg ran on a *different* pool host, those are empty by construction — #135 correctly writes the "ran on another swarm pool host" line instead of leaving them blank, but the bundle then carries **no fault text at all**, the signature degrades to the bare workflow name (idss#2045), and the agent is left to infer a mechanism from durations and SHAs. The fix is to put the job's own log in the bundle. This works today, on this Forgejo (15.0.5), with `FORGEJO_TOKEN` and no admin scope: ```sh curl -sf -H "Authorization: token $FORGEJO_TOKEN" \ "$RUN_URL/jobs/<job-index>/attempt/1/logs" ``` `<job-index>` is the job's 0-based index in the run (for a matrix, the leg). Verified live: `200`, 945–2088 bytes, on `Matou/dev-factory` runs 19847/19852/19858/19863 and `Matou/idss` run 42411. What 404s — and what the earlier passes probed: | URL | result | |---|---| | `$RUN_URL/jobs/<n>/attempt/1/logs` | **200** | | `$RUN_URL/jobs/<n>/logs` | 404 `Not found.` | | `$FORGEJO_API/actions/runs/<n>/jobs` | 404 `404 page not found` | | `$FORGEJO_API/actions/jobs/<id>/logs` | 404 `404 page not found` | `/attempt/1/` is the whole difference. ## Acceptance 1. `heal.sh` writes `job-log.txt` into the evidence directory for the failing run, built from `RUN_URL` (never a literal `actions/runs` string, so the `actions-endpoint` ratchet stays green), and the charter prompt lists it in the "Ground truth to read FIRST" block. 2. In **watchdog** mode there is no `RUN_URL` for the suspect run — derive it from the run number the detector keyed on, and fetch every leg's log (job index 0..n-1) so a matrix fault is attributable to its leg. Fetching all legs is also what proves "sibling green, this leg red" without a duration argument. 3. Best-effort and fail-soft: a 404/403/timeout writes a one-line "job log unavailable (<code>)" note, never reds the heal run. 4. The bundle must not silently claim an absence it never probed — if the fetch was skipped, say so (same rule as GOTCHAS 30). ## Tests `tests/heal-test.sh` — a shimmed `curl` serving the log on `…/attempt/1/logs` lands it in the bundle; a 404 leaves the fail-soft note and the heal run still exits 0; the URL is built from `RUN_URL` (ratchet). Offline, per CLAUDE.md's same-commit rule. ## Notes - `heal.sh` is a `FACTORY_MANIFEST`-vendored file: it is **source** at this repo's root and reaches the running `.sandcastle/` self-copy and every consumer only when a human re-vendors (GOTCHAS 4). This repo's own self-pin is 144 commits behind today — see #131 / #132. - `Matou/idss#2036` already carries this as its **AC4** with a handoff patch (comment 60682) that uses `${RUN_URL}/jobs/0/attempt/1/logs` — i.e. the working route was written down there on 2026-10-01 and the later healer passes did not find it. That patch hard-codes job index `0`; acceptance 2 above widens it. AC1 (`forgejo-lib.sh` read retry) and AC3 (hook-mode honesty) in that same handoff are still unlanded here too. - Origin incidents: `Matou/idss#2044` (the host fault — mechanism now commented there), `Matou/idss#2045` (the duplicate-investigation brake), dev-factory #135 (pool-locality, closed).
Author
Member

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

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

close-report for #188 — status success

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

envelope
{
  "issue": 188,
  "status": "success",
  "commits": [
    "d40f3b8"
  ],
  "changed_files": [
    "heal.sh",
    "heal-lib.sh",
    "tests/heal-test.sh",
    "tests/heal-lib-test.sh",
    "docs/GOTCHAS.md",
    "STATUS.md"
  ],
  "tests": [
    {
      "command": "bash tests/heal-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash tests/heal-lib-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash tests/actions-endpoint-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash onboarding/tests/onboard-lib-test.sh",
      "exit_code": 0
    },
    {
      "command": "for t in tests/*.sh onboarding/tests/*.sh; do case \"$t\" in *fakebin*|*fixtures*) continue;; esac; bash \"$t\" || echo FAIL; done",
      "exit_code": 0
    }
  ],
  "criteria": {
    "AC1 heal.sh writes job-log.txt built from RUN_URL (not a literal actions/runs; ratchet green)": "heal.sh collect_job_logs() writes $EVIDENCE/job-log.txt from `$run_url/jobs/$leg/attempt/1/logs`; no literal actions/runs in heal.sh/heal-lib.sh source (tests/actions-endpoint-test.sh green; grep confirms); heal-test.sh #188 block asserts job-log.txt carries the fault line and names the /attempt/1/ route",
    "AC1 charter prompt lists job-log.txt in Ground truth to read FIRST": "DEFERRED to #189 (ready-for-session): requires re-rendering the protected .sandcastle/heal-prompt.md + onboarding cutover fixtures, which the protected-paths fence bars a sandcastle worker from doing. The heal prompt already says 'read every file' of the evidence dir, so the agent reads job-log.txt today — this is the explicit enumeration only. Filed #189.",
    "AC2 watchdog derives run url from the run the detector keyed on and fetches every leg (0..n-1)": "heal-lib.sh watchdog_run_url() returns the suspect run's .html_url (watchdog mode has no RUN_URL env); collect_job_logs loops job index 0..HEAL_JOB_LOG_MAX_LEGS until a non-2xx; heal-lib-test.sh watchdog_run_url group + heal-test.sh matrix scenario (legs 0 and 1 both land) prove it",
    "AC3 best-effort / fail-soft: 404/403/timeout writes a one-line note, never reds the heal run": "collect_job_logs writes 'job log unavailable (HTTP 404)' / '(curl exit N)' on a leg-0 failure and returns 0; heal-test.sh #188 404 scenario asserts the note is present and the heal run exits 0",
    "AC4 never claim an unprobed absence: a skipped fetch says so": "collect_job_logs('') writes 'job log not fetched: no run URL ... nothing was probed'; heal-test.sh #188 AC4 scenario (watchdog forgejo-api incident, no run) asserts the explicit 'not fetched' note",
    "Tests: tests/heal-test.sh shimmed curl, offline, same-commit": "tests/heal-test.sh (+4 scenarios, 24 total) stubs curl on PATH serving the log on .../attempt/1/logs, asserts landing + fail-soft 404 note + heal exit 0 + ratchet route shape; tests/heal-lib-test.sh (+1 group, 26) covers watchdog_run_url; both updated in this commit"
  },
  "summary": "heal.sh now writes the failing run's own job log into every evidence bundle as job-log.txt (hook: RUN_URL; watchdog: the run's html_url), fetching every matrix leg and failing soft; GOTCHAS 65 + STATUS updated, with the charter-prompt enumeration deferred to ready-for-session #189 (a protected-copy re-render).",
  "blockers": []
}
**close-report** for #188 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 188, "status": "success", "commits": [ "d40f3b8" ], "changed_files": [ "heal.sh", "heal-lib.sh", "tests/heal-test.sh", "tests/heal-lib-test.sh", "docs/GOTCHAS.md", "STATUS.md" ], "tests": [ { "command": "bash tests/heal-test.sh", "exit_code": 0 }, { "command": "bash tests/heal-lib-test.sh", "exit_code": 0 }, { "command": "bash tests/actions-endpoint-test.sh", "exit_code": 0 }, { "command": "bash onboarding/tests/onboard-lib-test.sh", "exit_code": 0 }, { "command": "for t in tests/*.sh onboarding/tests/*.sh; do case \"$t\" in *fakebin*|*fixtures*) continue;; esac; bash \"$t\" || echo FAIL; done", "exit_code": 0 } ], "criteria": { "AC1 heal.sh writes job-log.txt built from RUN_URL (not a literal actions/runs; ratchet green)": "heal.sh collect_job_logs() writes $EVIDENCE/job-log.txt from `$run_url/jobs/$leg/attempt/1/logs`; no literal actions/runs in heal.sh/heal-lib.sh source (tests/actions-endpoint-test.sh green; grep confirms); heal-test.sh #188 block asserts job-log.txt carries the fault line and names the /attempt/1/ route", "AC1 charter prompt lists job-log.txt in Ground truth to read FIRST": "DEFERRED to #189 (ready-for-session): requires re-rendering the protected .sandcastle/heal-prompt.md + onboarding cutover fixtures, which the protected-paths fence bars a sandcastle worker from doing. The heal prompt already says 'read every file' of the evidence dir, so the agent reads job-log.txt today — this is the explicit enumeration only. Filed #189.", "AC2 watchdog derives run url from the run the detector keyed on and fetches every leg (0..n-1)": "heal-lib.sh watchdog_run_url() returns the suspect run's .html_url (watchdog mode has no RUN_URL env); collect_job_logs loops job index 0..HEAL_JOB_LOG_MAX_LEGS until a non-2xx; heal-lib-test.sh watchdog_run_url group + heal-test.sh matrix scenario (legs 0 and 1 both land) prove it", "AC3 best-effort / fail-soft: 404/403/timeout writes a one-line note, never reds the heal run": "collect_job_logs writes 'job log unavailable (HTTP 404)' / '(curl exit N)' on a leg-0 failure and returns 0; heal-test.sh #188 404 scenario asserts the note is present and the heal run exits 0", "AC4 never claim an unprobed absence: a skipped fetch says so": "collect_job_logs('') writes 'job log not fetched: no run URL ... nothing was probed'; heal-test.sh #188 AC4 scenario (watchdog forgejo-api incident, no run) asserts the explicit 'not fetched' note", "Tests: tests/heal-test.sh shimmed curl, offline, same-commit": "tests/heal-test.sh (+4 scenarios, 24 total) stubs curl on PATH serving the log on .../attempt/1/logs, asserts landing + fail-soft 404 note + heal exit 0 + ratchet route shape; tests/heal-lib-test.sh (+1 group, 26) covers watchdog_run_url; both updated in this commit" }, "summary": "heal.sh now writes the failing run's own job log into every evidence bundle as job-log.txt (hook: RUN_URL; watchdog: the run's html_url), fetching every matrix leg and failing soft; GOTCHAS 65 + STATUS updated, with the charter-prompt enumeration deferred to ready-for-session #189 (a protected-copy re-render).", "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#188
No description provided.