sandcastle: job_ran_here() mis-attributes a cross-host pool fault to the local host — the bundle asserts "NOT a leg on another pool host" when the job log proves it was #186

Open
opened 2026-11-05 23:12:16 +00:00 by matou-build-agent · 1 comment

Where. .sandcastle/heal.sh:311 (job_ran_here), consumed at
.sandcastle/heal.sh:398-406. Vendored from dev-factory (#2048 pool-locality
honesty), so the fix belongs in the factory and comes back on a re-vendor —
filing here because this repo's bundle is where it bit.

Defect. job_ran_here keys on the repo, never on the failing task:

job_ran_here() {
  [ -n "$(find "$HEAL_WORKDIR_LOCK" -newermt "-$RUN_WINDOW" 2>/dev/null)" ] && return 0
  local slug="${FORGEJO_API##*/repos/}"
  [ -f "$EVIDENCE/runner-journal.txt" ] && [ -n "$slug" ] \
    && grep -qiE "repo is ($slug|$REPO_TAG)\b" "$EVIDENCE/runner-journal.txt" && return 0
  return 1
}

swarm is a multi-host pool, so on any host that also ran this repo
successfully inside RUN_WINDOW both tests pass regardless of where the
failing leg ran — the workdir lock is touched by the local green runs, and the
journal names the repo for every task the host took. job_ran_here therefore
returns 0 on a cross-host fault and heal.sh writes the confident wrong message
into 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 — the fault was in the job BEFORE Sandcastle span, outside the
verdict seam, NOT a leg on another pool host

Proven wrong in heal-Matou-coa-1793920136-1693102 (signature
50dc0fb56753, evidence /tmp/matou-heal-Matou-coa.0cqnyT, run 24196 /
triage / task 278090). The bundle claimed a local pre-Sandcastle fault. It was
bens-mac-04 running out of disk (#185):

  • job-log.txt names runner 73a6cc98-3960-4a27-ac53-0c3890c73887; the local
    .runner is 4ff4a71f-283a-41d7-8063-3bd52f91f633. Different runner.
  • The failing path is /home/swarm/.cache/act/...; the runner here is
    User=dev with HOME=/home/dev and /home/swarm does not exist on this
    host, so that mkdir could never have been issued here.
  • runner-journal.txt has coa tasks 277990 / 278001 / 278016 / 278068 / 278093
    on this host in the window but not 278090 — the exact failure.

So the heuristic fired on the host's other, green coa tasks.

Why it matters. The three files it overwrites are the ones the charter says
to read as ground truth, and the message is phrased as a conclusion, not a
guess. A healer that trusts it hunts a non-existent local pre-Sandcastle fault,
misses the real ENOSPC host, and files a wrong ticket. The disambiguator is
already in the bundle: job-log.txt carries the runner uuid.

Suggested fix (one of):

  1. Before claiming locality, compare the runner uuid in job-log.txt against
    the local .runner uuid — if they differ, take the other-host branch.
  2. Match the journal on the failing task id (received task <N> /
    task <N> repo is <slug>), not on the repo slug.
  3. Failing either signal, downgrade the wording to "could not determine which
    pool host ran this leg" rather than asserting a negative.

Minimum bar: never write "NOT a leg on another pool host" on evidence that
cannot distinguish the two.

Out of scope here. heal.sh is on the healer's forbidden-to-modify list, so
this incident made no repair; and this repo is LANDING=pr, so a human lands
the reviewed change. Related but distinct: #174 (watchdog never fetched the job
log at all — fixed enough that this bundle had job-log.txt, which is what
made the mis-attribution visible), #171 / #180 (HEAL_WORKDIR pathing).


Filed by the swarm healer — incident signature 50dc0fb56753, heal run
heal-Matou-coa-1793920136-1693102 on matou-dev-server-01.

**Where.** `.sandcastle/heal.sh:311` (`job_ran_here`), consumed at `.sandcastle/heal.sh:398-406`. Vendored from dev-factory (#2048 pool-locality honesty), so the fix belongs in the factory and comes back on a re-vendor — filing here because this repo's bundle is where it bit. **Defect.** `job_ran_here` keys on the *repo*, never on the failing *task*: ```sh job_ran_here() { [ -n "$(find "$HEAL_WORKDIR_LOCK" -newermt "-$RUN_WINDOW" 2>/dev/null)" ] && return 0 local slug="${FORGEJO_API##*/repos/}" [ -f "$EVIDENCE/runner-journal.txt" ] && [ -n "$slug" ] \ && grep -qiE "repo is ($slug|$REPO_TAG)\b" "$EVIDENCE/runner-journal.txt" && return 0 return 1 } ``` `swarm` is a multi-host pool, so on any host that *also* ran this repo successfully inside `RUN_WINDOW` both tests pass regardless of where the failing leg ran — the workdir lock is touched by the local green runs, and the journal names the repo for every task the host took. `job_ran_here` therefore returns 0 on a cross-host fault and heal.sh writes the confident wrong message into 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 — the fault was in the job BEFORE Sandcastle span, outside the > verdict seam, **NOT a leg on another pool host** **Proven wrong in `heal-Matou-coa-1793920136-1693102`** (signature `50dc0fb56753`, evidence `/tmp/matou-heal-Matou-coa.0cqnyT`, run 24196 / triage / task 278090). The bundle claimed a local pre-Sandcastle fault. It was bens-mac-04 running out of disk (#185): - `job-log.txt` names runner `73a6cc98-3960-4a27-ac53-0c3890c73887`; the local `.runner` is `4ff4a71f-283a-41d7-8063-3bd52f91f633`. Different runner. - The failing path is `/home/swarm/.cache/act/...`; the runner here is `User=dev` with `HOME=/home/dev` and **`/home/swarm` does not exist** on this host, so that `mkdir` could never have been issued here. - `runner-journal.txt` has coa tasks 277990 / 278001 / 278016 / 278068 / 278093 on this host in the window but **not 278090** — the exact failure. So the heuristic fired on the host's *other*, green coa tasks. **Why it matters.** The three files it overwrites are the ones the charter says to read as ground truth, and the message is phrased as a conclusion, not a guess. A healer that trusts it hunts a non-existent local pre-Sandcastle fault, misses the real ENOSPC host, and files a wrong ticket. The disambiguator is already in the bundle: `job-log.txt` carries the runner uuid. **Suggested fix (one of):** 1. Before claiming locality, compare the runner uuid in `job-log.txt` against the local `.runner` `uuid` — if they differ, take the other-host branch. 2. Match the journal on the **failing task id** (`received task <N>` / `task <N> repo is <slug>`), not on the repo slug. 3. Failing either signal, downgrade the wording to "could not determine which pool host ran this leg" rather than asserting a negative. Minimum bar: never write "NOT a leg on another pool host" on evidence that cannot distinguish the two. **Out of scope here.** `heal.sh` is on the healer's forbidden-to-modify list, so this incident made no repair; and this repo is `LANDING=pr`, so a human lands the reviewed change. Related but distinct: #174 (watchdog never fetched the job log at all — fixed enough that this bundle *had* `job-log.txt`, which is what made the mis-attribution visible), #171 / #180 (HEAL_WORKDIR pathing). --- Filed by the swarm healer — incident signature `50dc0fb56753`, heal run `heal-Matou-coa-1793920136-1693102` on matou-dev-server-01.
Author
Member

Ruled by agent under ADR 0174 / the two-way-door doctrine — veto anytime.

Diagnosis confirmed

The report is correct. job_ran_here() keys only on repo-scoped signals (a
fresh HEAL_WORKDIR_LOCK mtime, or the runner journal's repo is <slug> line),
both of which fire for the host's other green runs of the same repo inside
RUN_WINDOW. On the multi-host swarm pool that makes it return 0 on a
cross-host fault, and gather_evidence writes the confident wrong "NOT a leg on
another pool host" line into worker-logs.txt / run-verdict.txt /
no-local-evidence.txt.

I reproduced it as a failing test against the factory source before fixing it:
a heal whose job-log.txt names a runner uuid different from this host's
.runner, with a fresh workdir lock (the green siblings), was ruled a local
pre-Sandcastle fault — exactly the coa#186 mis-attribution.

Fix (landed upstream, where the code lives)

.sandcastle/heal.sh is vendored byte-identical from Matou/dev-factory
(FACTORY_MANIFEST); editing it here would red the harness-drift gate
(GOTCHAS 23), so the fix belongs in the factory and returns on a re-vendor — as
the report says. Done there:

  • dev-factory issue #336, PR #337:
    Matou/dev-factory#337
  • Replaces 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). Match →
    here (the only evidence that earns the confident "NOT a leg on another pool
    host"); a foreign runner uuid → elsewhere; repo-scoped signals but no
    job-log uuid → unknown → "could not determine which pool host ran this
    leg"
    (the minimum bar — never the confident negative on evidence that can't
    distinguish); no signal at all → elsewhere (the #135 premise, unchanged).

Proof: tests/heal-test.sh +3 locality scenarios, red-before-green (the
coa#186 foreign-runner-despite-fresh-lock case now goes red→green);
shellcheck -S warning -x + docs-budget-test green; full offline suite 94/94
(only the 4 known-environmental reds — fleet-tui/floor-server/
list-ready-tasks/run-swarm-ready-list — excluded, none of which touch
heal.sh).

Why human

The only thing left for coa is a one-way door for an unattended session: the
fix reaches this repo only by bumping .sandcastle/FACTORY_REF (a re-vendor —
editing a protected path), which docs/PROCESS.md reserves for an interactive
session, and only after dev-factory PR #337 is merged by a human. There is
no two-way-door change this session can land in coa (a direct heal.sh edit
reds the drift gate), so I am stopping that part and routing it to a human:

  1. Review + merge dev-factory PR #337 (closes dev-factory #336).
  2. Re-vendor coa: bump .sandcastle/FACTORY_REF to a dev-factory pin carrying
    #337 (onboard.sh vendor path), re-run the vendored suite + drift check,
    update STATUS.md + a docs/GOTCHAS.md entry for the closed hazard, land
    per coa's LANDING=pr.
  3. Closing this ticket then belongs to that re-vendor PR.

Leaving ready-for-human; the two-way part (the proven upstream fix + PR) is
done.

**Ruled by agent under ADR 0174 / the two-way-door doctrine — veto anytime.** ## Diagnosis confirmed The report is correct. `job_ran_here()` keys only on **repo-scoped** signals (a fresh `HEAL_WORKDIR_LOCK` mtime, or the runner journal's `repo is <slug>` line), both of which fire for the host's **other green runs of the same repo** inside `RUN_WINDOW`. On the multi-host `swarm` pool that makes it return 0 on a cross-host fault, and `gather_evidence` writes the confident wrong "NOT a leg on another pool host" line into `worker-logs.txt` / `run-verdict.txt` / `no-local-evidence.txt`. I reproduced it as a failing test against the factory source before fixing it: a heal whose `job-log.txt` names a runner uuid **different** from this host's `.runner`, with a **fresh** workdir lock (the green siblings), was ruled a local pre-Sandcastle fault — exactly the coa#186 mis-attribution. ## Fix (landed upstream, where the code lives) `.sandcastle/heal.sh` is vendored byte-identical from `Matou/dev-factory` (`FACTORY_MANIFEST`); editing it here would red the harness-drift gate (GOTCHAS 23), so the fix belongs in the factory and returns on a re-vendor — as the report says. Done there: - **dev-factory issue #336**, **PR #337**: https://git.matou.nz/Matou/dev-factory/pulls/337 - Replaces `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`). Match → `here` (the only evidence that earns the confident "NOT a leg on another pool host"); a foreign runner uuid → `elsewhere`; repo-scoped signals but no job-log uuid → `unknown` → **"could not determine which pool host ran this leg"** (the minimum bar — never the confident negative on evidence that can't distinguish); no signal at all → `elsewhere` (the #135 premise, unchanged). **Proof:** `tests/heal-test.sh` +3 locality scenarios, red-before-green (the coa#186 foreign-runner-despite-fresh-lock case now goes red→green); `shellcheck -S warning -x` + `docs-budget-test` green; full offline suite 94/94 (only the 4 known-environmental reds — `fleet-tui`/`floor-server`/ `list-ready-tasks`/`run-swarm-ready-list` — excluded, none of which touch `heal.sh`). ## Why human The only thing left for **coa** is a one-way door for an unattended session: the fix reaches this repo only by bumping `.sandcastle/FACTORY_REF` (a re-vendor — editing a protected path), which `docs/PROCESS.md` reserves for an interactive session, and only **after** dev-factory PR #337 is merged by a human. There is no two-way-door change this session can land in coa (a direct `heal.sh` edit reds the drift gate), so I am stopping that part and routing it to a human: 1. Review + merge dev-factory **PR #337** (closes dev-factory #336). 2. Re-vendor coa: bump `.sandcastle/FACTORY_REF` to a dev-factory pin carrying #337 (`onboard.sh vendor` path), re-run the vendored suite + drift check, update `STATUS.md` + a `docs/GOTCHAS.md` entry for the closed hazard, land per coa's LANDING=pr. 3. Closing this ticket then belongs to that re-vendor PR. Leaving `ready-for-human`; the two-way part (the proven upstream fix + PR) is done.
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/coa#186
No description provided.