heal.sh: job_ran_here mis-attributes a cross-host pool fault to the local host (keys on repo, not the failing leg) — origin coa#186 #336

Closed
opened 2026-11-05 23:45:15 +00:00 by matou-build-agent · 4 comments

Defect

job_ran_here() in heal.sh decides pool-locality from repo-scoped signals
only — a fresh HEAL_WORKDIR_LOCK mtime, or the runner journal naming the repo
(repo is <slug>). On swarm (a multi-host runner pool) both fire for the
host's other green runs of the same repo in the window, so on a cross-host
fault job_ran_here returns 0 and gather_evidence writes the confident wrong
message into the three files the diagnosis agent reads first (worker-logs.txt,
run-verdict.txt, no-local-evidence.txt):

… local evidence (workdir lock / runner journal) shows THIS repo's job ran on
this host … NOT a leg on another pool host

Proven wrong (consumer incident Matou/coa#186)

Heal run heal-Matou-coa-1793920136-1693102 (signature 50dc0fb56753, run
24196 / triage / task 278090) claimed a local pre-Sandcastle fault. It was
bens-mac-04 out of disk:

  • job-log.txt names runner 73a6c98a-…; the local .runner uuid is
    4ff4a71f-… — a different runner.
  • the failing path is /home/swarm/.cache/act/…; this host is User=dev,
    /home/swarm does not exist — that mkdir could never have run here.
  • runner-journal.txt has the host's other coa tasks in the window but not
    the failing 278090. The heuristic fired on the green siblings.

A healer that trusts the message hunts a non-existent local fault and misses the
real ENOSPC host.

Fix (this PR)

Replace job_ran_here with a tri-state job_locality whose decisive signal
is the failing leg's own job log (#188): the runner uuid it names vs this host's
.runner (SWARM_RUNNER_FILE else $HOME/.runner).

  • uuid matches → here (the only evidence that earns the confident "NOT a
    leg on another pool host");
  • a runner uuid that is not ours → elsewhere;
  • repo-scoped signals fire but no job-log uuid to compare → unknown →
    "could not determine which pool host ran this leg" (never the confident
    negative on evidence that cannot distinguish — the minimum bar);
  • no signal at all → elsewhere (the #135 premise).

The ruling moves from gather_evidence into handle_incident (after
collect_job_logs), since job-log.txt does not exist yet at gather time;
gather_evidence drops a no-local-run marker. tests/heal-test.sh adds the
three locality scenarios (here / elsewhere-despite-fresh-lock / undecidable);
full offline suite + shellcheck -S warning -x green.

Filed from the coa standing session that produced the fix; coa receives it on
its next FACTORY_REF bump.

## Defect `job_ran_here()` in `heal.sh` decides pool-locality from **repo-scoped** signals only — a fresh `HEAL_WORKDIR_LOCK` mtime, or the runner journal naming the repo (`repo is <slug>`). On `swarm` (a multi-host runner pool) both fire for the host's **other green runs of the same repo** in the window, so on a cross-host fault `job_ran_here` returns 0 and `gather_evidence` writes the confident wrong message into the three files the diagnosis agent reads first (`worker-logs.txt`, `run-verdict.txt`, `no-local-evidence.txt`): > … local evidence (workdir lock / runner journal) shows THIS repo's job ran on > this host … **NOT a leg on another pool host** ## Proven wrong (consumer incident Matou/coa#186) Heal run `heal-Matou-coa-1793920136-1693102` (signature `50dc0fb56753`, run 24196 / triage / task 278090) claimed a local pre-Sandcastle fault. It was `bens-mac-04` out of disk: - `job-log.txt` names runner `73a6c98a-…`; the local `.runner` uuid is `4ff4a71f-…` — a different runner. - the failing path is `/home/swarm/.cache/act/…`; this host is `User=dev`, `/home/swarm` does not exist — that `mkdir` could never have run here. - `runner-journal.txt` has the host's other coa tasks in the window but **not** the failing 278090. The heuristic fired on the green siblings. A healer that trusts the message hunts a non-existent local fault and misses the real ENOSPC host. ## Fix (this PR) Replace `job_ran_here` with a tri-state `job_locality` whose **decisive** signal is the failing leg's own job log (#188): the runner uuid it names vs this host's `.runner` (`SWARM_RUNNER_FILE` else `$HOME/.runner`). - uuid **matches** → `here` (the only evidence that earns the confident "NOT a leg on another pool host"); - a runner uuid that is **not** ours → `elsewhere`; - repo-scoped signals fire but no job-log uuid to compare → `unknown` → "could not determine which pool host ran this leg" (never the confident negative on evidence that cannot distinguish — the minimum bar); - no signal at all → `elsewhere` (the #135 premise). The ruling moves from `gather_evidence` into `handle_incident` (after `collect_job_logs`), since `job-log.txt` does not exist yet at gather time; `gather_evidence` drops a `no-local-run` marker. `tests/heal-test.sh` adds the three locality scenarios (here / elsewhere-despite-fresh-lock / undecidable); full offline suite + `shellcheck -S warning -x` green. Filed from the coa standing session that produced the fix; coa receives it on its next `FACTORY_REF` bump.
Author
Member

This was generated by AI during triage.

Ruled by agent under ADR 0174 — veto anytime.

Ruling: bug + ready-for-agent.

Why this is a two-way door: the fix is a self-contained change to heal.sh plus its offline test, revertible by a single later commit or a label flip, and provable by an existing probe — tests/heal-test.sh (the three locality scenarios this ticket names) plus the full offline suite and shellcheck -S warning -x. It touches no prompt skeleton, nothing under .sandcastle/, and nothing under .forgejo/, so it is not session-gated; it is not on the one-way-door list (no personal credentials, no security-posture widening, no member-facing trust accept, no data destruction, no non-routine spend). A healer mis-attribution is self-contained diagnostic text, fully reversible.

Verification (claim confirmed against this repo's heal.sh):

  • job_ran_here still decides locality from repo-scoped signals only — the HEAL_WORKDIR_LOCK mtime inside the run window, and the runner journal matching repo is <slug> / $REPO_TAG. Both fire for the host's other green runs of the same repo, exactly the false-positive the ticket describes.
  • It is consumed in gather_evidence, where a true result writes the confident … NOT a leg on another pool host message into worker-logs.txt / run-verdict.txt / no-local-evidence.txt.
  • The tri-state job_locality replacement is not present. collect_job_logs already exists and is already called from handle_incident, so moving the ruling to after the job log is collected is feasible with the current structure.

Not redundant (fix absent), no prior rejection (no .out-of-scope/ knowledge base in this repo), no open questions for the reporter (the defect, a concrete consumer incident Matou/coa#186, and the intended fix are fully specified). Porting a fix already made in the coa standing session; coa receives it on its next FACTORY_REF bump.


Agent Brief

Category: bug
Summary: heal.sh locality heuristic confidently blames the local host for a cross-host pool fault because it reads only repo-scoped signals, never the failing leg's own runner identity.

Current behavior:
When a heal run finds no fresh worker log and no fresh verdict for the run window, it decides whether the job ran on this host from two repo-scoped signals alone: the per-repo workdir lock's mtime inside the window, and the runner journal naming this repo's task. On a multi-host runner pool, both of these fire for the host's other green runs of the same repo — so on a genuine cross-host fault the heuristic returns true and the diagnosis bundle is handed the confident, wrong message "… local evidence … shows THIS repo's job ran on this host … NOT a leg on another pool host" in the three files the diagnosis agent reads first. A healer that trusts it hunts a non-existent local fault and misses the real remote host (incident Matou/coa#186: an out-of-disk bens-mac-04 leg with a different runner uuid and a /home/swarm path that could never exist on the User=dev host).

Desired behavior:
Locality is decided by the failing leg's own job log, not by repo-scoped siblings. The decisive signal is the runner uuid named in the collected job log compared against this host's own .runner uuid (SWARM_RUNNER_FILE, else $HOME/.runner). The confident "NOT a leg on another pool host" negative may only be emitted when that comparison matches; on any evidence that cannot distinguish the two, the artefact must say so rather than assert the negative.

Key interfaces:

  • Replace the boolean job_ran_here with a tri-state locality verdict (here / elsewhere / unknown):
    • job-log runner uuid matches this host's .runner → here (the only state that earns the confident "NOT a leg on another pool host" message);
    • job-log runner uuid is present but not ours → elsewhere;
    • repo-scoped signals fire but there is no job-log uuid to compare → unknown → an artefact message along the lines of "could not determine which pool host ran this leg" (never the confident negative on evidence that cannot distinguish);
    • no signal at all → elsewhere (preserving the existing #135 premise).
  • The ruling must run after the failing leg's job log is collected (job-log.txt does not exist at gather_evidence time, so the decision belongs in handle_incident after collect_job_logs). gather_evidence should drop a marker (e.g. a no-local-run note) rather than make the final locality call.
  • Resolve this host's runner uuid from SWARM_RUNNER_FILE when set, else $HOME/.runner.

Acceptance criteria:

  • A cross-host fault whose job log names a runner uuid other than this host's resolves to elsewhere, and no artefact claims the job ran here.
  • A fault whose job log names this host's own runner uuid resolves to here and keeps the confident pre-Sandcastle-fault message.
  • A fault where repo-scoped signals fire (fresh workdir lock / journal match) but there is no job-log uuid resolves to unknown and the artefact text declines to assert "NOT a leg on another pool host".
  • tests/heal-test.sh covers all three scenarios (here / elsewhere-despite-fresh-lock / undecidable).
  • The full offline suite passes and shellcheck -S warning -x is clean (per CLAUDE.md: the lib change and its test land in the same commit).

Out of scope:

  • The git reflog reset-to-origin/main signal (it stays in the human/diagnosis bundle; this change is about the coded verdict only).
  • Any change to how the diagnosis agent consumes the artefacts downstream.
  • The swarm-lock / slot-probing logic in gather_evidence.

This is a focused shell change with offline test coverage; a model-sonnet override would likely suffice (optional — a human/triage call, not applied automatically).

> *This was generated by AI during triage.* **Ruled by agent under ADR 0174 — veto anytime.** **Ruling:** `bug` + `ready-for-agent`. **Why this is a two-way door:** the fix is a self-contained change to `heal.sh` plus its offline test, revertible by a single later commit or a label flip, and provable by an existing probe — `tests/heal-test.sh` (the three locality scenarios this ticket names) plus the full offline suite and `shellcheck -S warning -x`. It touches no prompt skeleton, nothing under `.sandcastle/`, and nothing under `.forgejo/`, so it is not session-gated; it is not on the one-way-door list (no personal credentials, no security-posture widening, no member-facing trust accept, no data destruction, no non-routine spend). A healer mis-attribution is self-contained diagnostic text, fully reversible. **Verification (claim confirmed against this repo's `heal.sh`):** - `job_ran_here` still decides locality from **repo-scoped** signals only — the `HEAL_WORKDIR_LOCK` mtime inside the run window, and the runner journal matching `repo is <slug>` / `$REPO_TAG`. Both fire for the host's *other* green runs of the same repo, exactly the false-positive the ticket describes. - It is consumed in `gather_evidence`, where a true result writes the confident `… NOT a leg on another pool host` message into `worker-logs.txt` / `run-verdict.txt` / `no-local-evidence.txt`. - The tri-state `job_locality` replacement is **not** present. `collect_job_logs` already exists and is already called from `handle_incident`, so moving the ruling to after the job log is collected is feasible with the current structure. Not redundant (fix absent), no prior rejection (no `.out-of-scope/` knowledge base in this repo), no open questions for the reporter (the defect, a concrete consumer incident `Matou/coa#186`, and the intended fix are fully specified). Porting a fix already made in the coa standing session; coa receives it on its next `FACTORY_REF` bump. --- ## Agent Brief **Category:** bug **Summary:** `heal.sh` locality heuristic confidently blames the local host for a cross-host pool fault because it reads only repo-scoped signals, never the failing leg's own runner identity. **Current behavior:** When a heal run finds no fresh worker log and no fresh verdict for the run window, it decides whether the job ran on *this* host from two repo-scoped signals alone: the per-repo workdir lock's mtime inside the window, and the runner journal naming this repo's task. On a multi-host runner pool, both of these fire for the host's *other* green runs of the same repo — so on a genuine cross-host fault the heuristic returns true and the diagnosis bundle is handed the confident, wrong message "… local evidence … shows THIS repo's job ran on this host … NOT a leg on another pool host" in the three files the diagnosis agent reads first. A healer that trusts it hunts a non-existent local fault and misses the real remote host (incident `Matou/coa#186`: an out-of-disk `bens-mac-04` leg with a different runner uuid and a `/home/swarm` path that could never exist on the `User=dev` host). **Desired behavior:** Locality is decided by the failing leg's **own** job log, not by repo-scoped siblings. The decisive signal is the runner uuid named in the collected job log compared against this host's own `.runner` uuid (`SWARM_RUNNER_FILE`, else `$HOME/.runner`). The confident "NOT a leg on another pool host" negative may only be emitted when that comparison *matches*; on any evidence that cannot distinguish the two, the artefact must say so rather than assert the negative. **Key interfaces:** - Replace the boolean `job_ran_here` with a tri-state locality verdict (`here` / `elsewhere` / `unknown`): - job-log runner uuid **matches** this host's `.runner` → `here` (the only state that earns the confident "NOT a leg on another pool host" message); - job-log runner uuid is present but **not** ours → `elsewhere`; - repo-scoped signals fire but there is **no** job-log uuid to compare → `unknown` → an artefact message along the lines of "could not determine which pool host ran this leg" (never the confident negative on evidence that cannot distinguish); - no signal at all → `elsewhere` (preserving the existing #135 premise). - The ruling must run **after** the failing leg's job log is collected (`job-log.txt` does not exist at `gather_evidence` time, so the decision belongs in `handle_incident` after `collect_job_logs`). `gather_evidence` should drop a marker (e.g. a `no-local-run` note) rather than make the final locality call. - Resolve this host's runner uuid from `SWARM_RUNNER_FILE` when set, else `$HOME/.runner`. **Acceptance criteria:** - [ ] A cross-host fault whose job log names a runner uuid other than this host's resolves to `elsewhere`, and no artefact claims the job ran here. - [ ] A fault whose job log names this host's own runner uuid resolves to `here` and keeps the confident pre-Sandcastle-fault message. - [ ] A fault where repo-scoped signals fire (fresh workdir lock / journal match) but there is no job-log uuid resolves to `unknown` and the artefact text declines to assert "NOT a leg on another pool host". - [ ] `tests/heal-test.sh` covers all three scenarios (here / elsewhere-despite-fresh-lock / undecidable). - [ ] The full offline suite passes and `shellcheck -S warning -x` is clean (per CLAUDE.md: the lib change and its test land in the **same** commit). **Out of scope:** - The `git reflog` reset-to-origin/main signal (it stays in the human/diagnosis bundle; this change is about the coded verdict only). - Any change to how the diagnosis agent consumes the artefacts downstream. - The swarm-lock / slot-probing logic in `gather_evidence`. _This is a focused shell change with offline test coverage; a `model-sonnet` override would likely suffice (optional — a human/triage call, not applied automatically)._
Author
Member

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

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

⏩ independent reviewer for #336 — verdict unauthenticated

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

close-report for #336 — status success

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

envelope
{
  "issue": 336,
  "status": "success",
  "commits": [
    "f8a4df7aa7dcceae1a7d1f2d362b05660b3116a7"
  ],
  "changed_files": [
    "heal.sh",
    "tests/heal-test.sh",
    "docs/GOTCHAS.md",
    "docs/gotchas/336-healer-locality-keys-on-repo-not-the-failing-leg.md",
    "docs/journal/2026-11-06-336.md"
  ],
  "tests": [
    {
      "command": "bash tests/heal-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: $t; done",
      "exit_code": 0
    },
    {
      "command": "shellcheck -S warning -x heal.sh tests/heal-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash tests/docs-budget-test.sh",
      "exit_code": 0
    }
  ],
  "criteria": {
    "A cross-host fault whose job log names a runner uuid other than this host's resolves to elsewhere, and no artefact claims the job ran here": "tests/heal-test.sh #336 scenario (2) `elsewhere` DESPITE a fresh workdir lock: job_locality -> elsewhere; worker-logs.txt carries 'ran on another swarm pool host' and NOT 'THIS repo's job ran on this host' (heal.sh job_locality: a job-log uuid that is not ours -> elsewhere)",
    "A fault whose job log names this host's own runner uuid resolves to here and keeps the confident pre-Sandcastle-fault message": "tests/heal-test.sh #336 scenario (1) `here`: worker-logs.txt carries 'THIS repo's job ran on this host' + 'NOT a leg on another pool host' (heal.sh write_locality_artefacts here-branch)",
    "A fault where repo-scoped signals fire but there is no job-log uuid resolves to unknown and the artefact declines to assert 'NOT a leg on another pool host'": "tests/heal-test.sh #336 scenario (3) `unknown`: worker-logs.txt carries 'could not determine which pool host ran this leg' and NOT 'NOT a leg on another pool host' (heal.sh job_locality unknown-branch + write_locality_artefacts)",
    "tests/heal-test.sh covers all three scenarios (here / elsewhere-despite-fresh-lock / undecidable)": "tests/heal-test.sh lines in the #336 block add scenarios (1)/(2)/(3); 34 scenarios pass",
    "The full offline suite passes and shellcheck -S warning -x is clean (lib change and its test in the same commit)": "commit f8a4df7 contains both heal.sh and tests/heal-test.sh; full suite green, shellcheck -S warning -x heal.sh tests/heal-test.sh exit 0"
  },
  "summary": "heal.sh pool-locality now keys on the failing leg's own job-log runner uuid vs this host's .runner uuid (tri-state job_locality), never on repo-scoped siblings, so a cross-host fault is no longer confidently blamed on the local host.",
  "blockers": []
}
**close-report** for #336 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against the pushed worker branch `sandcastle/worker/20261106-013937-c15abc` (pre-land — the host promotes it to `main` only after its post-run verify, #193/#283); issue closed. <details><summary>envelope</summary> ```json { "issue": 336, "status": "success", "commits": [ "f8a4df7aa7dcceae1a7d1f2d362b05660b3116a7" ], "changed_files": [ "heal.sh", "tests/heal-test.sh", "docs/GOTCHAS.md", "docs/gotchas/336-healer-locality-keys-on-repo-not-the-failing-leg.md", "docs/journal/2026-11-06-336.md" ], "tests": [ { "command": "bash tests/heal-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: $t; done", "exit_code": 0 }, { "command": "shellcheck -S warning -x heal.sh tests/heal-test.sh", "exit_code": 0 }, { "command": "bash tests/docs-budget-test.sh", "exit_code": 0 } ], "criteria": { "A cross-host fault whose job log names a runner uuid other than this host's resolves to elsewhere, and no artefact claims the job ran here": "tests/heal-test.sh #336 scenario (2) `elsewhere` DESPITE a fresh workdir lock: job_locality -> elsewhere; worker-logs.txt carries 'ran on another swarm pool host' and NOT 'THIS repo's job ran on this host' (heal.sh job_locality: a job-log uuid that is not ours -> elsewhere)", "A fault whose job log names this host's own runner uuid resolves to here and keeps the confident pre-Sandcastle-fault message": "tests/heal-test.sh #336 scenario (1) `here`: worker-logs.txt carries 'THIS repo's job ran on this host' + 'NOT a leg on another pool host' (heal.sh write_locality_artefacts here-branch)", "A fault where repo-scoped signals fire but there is no job-log uuid resolves to unknown and the artefact declines to assert 'NOT a leg on another pool host'": "tests/heal-test.sh #336 scenario (3) `unknown`: worker-logs.txt carries 'could not determine which pool host ran this leg' and NOT 'NOT a leg on another pool host' (heal.sh job_locality unknown-branch + write_locality_artefacts)", "tests/heal-test.sh covers all three scenarios (here / elsewhere-despite-fresh-lock / undecidable)": "tests/heal-test.sh lines in the #336 block add scenarios (1)/(2)/(3); 34 scenarios pass", "The full offline suite passes and shellcheck -S warning -x is clean (lib change and its test in the same commit)": "commit f8a4df7 contains both heal.sh and tests/heal-test.sh; full suite green, shellcheck -S warning -x heal.sh tests/heal-test.sh exit 0" }, "summary": "heal.sh pool-locality now keys on the failing leg's own job-log runner uuid vs this host's .runner uuid (tri-state job_locality), never on repo-scoped siblings, so a cross-host fault is no longer confidently blamed on the local host.", "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#336
No description provided.