sandcastle: HEAL_WORKDIR is a hardcoded /home/dev path — coa's healer hook dies before diagnosing on any pool host but one #171

Open
opened 2026-10-09 11:10:40 +00:00 by matou-build-agent · 4 comments

Filed by the healer (watchdog sweep, heal run heal-Matou-coa-1791543730-3188403, signature 0ff1caf1b642).

Symptom

swarm (bens-mac-04) redded three consecutive ticks in Matou/coa (runs 16694 09:51Z, 16701 10:16Z, 16705 10:46Z on 2026-10-09). The on-failure Investigate failure (healer) step produced exactly one line of output on each:

mkdir: cannot create directory '/home/dev': Permission denied

No diagnosis, no evidence dir, no signature — only the step's :rotating_light: swarm failed AND the healer errored Mattermost fallback (which ends || true, so the step reports success and the real fault is invisible in the run list). The fault was only caught an hour later by the hourly watchdog, which — running on a different host — had no local verdict file to key on and minted the incident with an empty error line: watchdog: streak ().

Cause

.sandcastle/swarm-identity.sh:8

: "${HEAL_WORKDIR:=/home/dev/swarm/Matou/coa}"

An absolute path, not $HOME-relative. heal.sh:86-88 does WORKDIR="$HEAL_WORKDIR"; HEALER_STATE="${HEALER_STATE:-$WORKDIR/.sandcastle/.state/healer}"; mkdir -p "$HEALER_STATE" under set -e, so on any host whose runner HOME is not /home/dev the healer aborts on line 88, before it reads a single piece of evidence.

The sibling repo is already correct — Matou/idss's .sandcastle/swarm-identity.sh:8 reads : "${HEAL_WORKDIR:=$HOME/swarm/Matou/idss}", and idss's healer hook ran fine on bens-mac-04 in the same minute (heal: incident wf=swarm sig=c7b66d17fa31) off the identical underlying fault. coa's generated line is the odd one out.

This is the per-role half of GOTCHAS 2 ("a host half is per role, not per repo") biting again: the swarm half works on bens-mac-04, the healer half does not.

Fix

Make the default $HOME-relative, matching idss:

: "${HEAL_WORKDIR:=$HOME/swarm/Matou/coa}"

swarm.yml / triage.yml already invoke bash "$HOME/swarm/${{ github.repository }}/.sandcastle/heal.sh", so the identity default is the only place the path is pinned.

Acceptance

  • .sandcastle/swarm-identity.sh no longer contains a /home/ literal.
  • A failing swarm leg on a host whose HOME is not /home/dev produces a real heal: evidence at … / heal: incident wf=… sig=… pair, not the mkdir line.
  • docs/GOTCHAS.md gains an entry: a healer hook that dies in mkdir is silent by construction — the step's Mattermost fallback swallows the exit and the run looks green — so the hook's own failure must be read from the step log, not the step status.

Out of scope

The underlying DNS fault on bens-mac-04 — filed separately as a host issue. This ticket is only about the healer being unable to report it.

Notes

  • .sandcastle/ is vendored at FACTORY_REF 87e1b55; this fix is factory-side as well as here, so the re-vendor must carry it back deliberately.
  • Machinery change → ready-for-session per docs/agents/issue-tracker.md, never inside a worker PR.
  • GOTCHAS 3 says this instance has no job-log endpoint. That is now only half true: POST /{owner}/{repo}/actions/runs/<run_number>/jobs/<idx>/attempt/1 with {"logCursors":[{"step":N,"cursor":0,"expanded":true}]} and an Authorization: token header returns the per-step log as JSON. The /attempt/1 suffix is required (without it the bare /jobs/<idx> POST 500s with task with job_id … and attempt 0: resource does not exist). That is how the logs quoted above were obtained; worth folding into GOTCHAS 3 and into the healer's evidence collector so an off-host leg is no longer a blind spot.
Filed by the healer (watchdog sweep, heal run `heal-Matou-coa-1791543730-3188403`, signature `0ff1caf1b642`). ## Symptom `swarm (bens-mac-04)` redded three consecutive ticks in `Matou/coa` (runs 16694 09:51Z, 16701 10:16Z, 16705 10:46Z on 2026-10-09). The on-failure `Investigate failure (healer)` step produced exactly one line of output on each: ``` mkdir: cannot create directory '/home/dev': Permission denied ``` No diagnosis, no evidence dir, no signature — only the step's `:rotating_light: swarm failed AND the healer errored` Mattermost fallback (which ends `|| true`, so the step reports **success** and the real fault is invisible in the run list). The fault was only caught an hour later by the hourly watchdog, which — running on a *different* host — had no local verdict file to key on and minted the incident with an **empty** error line: `watchdog: streak ()`. ## Cause `.sandcastle/swarm-identity.sh:8` ```sh : "${HEAL_WORKDIR:=/home/dev/swarm/Matou/coa}" ``` An absolute path, not `$HOME`-relative. `heal.sh:86-88` does `WORKDIR="$HEAL_WORKDIR"; HEALER_STATE="${HEALER_STATE:-$WORKDIR/.sandcastle/.state/healer}"; mkdir -p "$HEALER_STATE"` under `set -e`, so on any host whose runner HOME is not `/home/dev` the healer aborts on line 88, before it reads a single piece of evidence. The sibling repo is already correct — `Matou/idss`'s `.sandcastle/swarm-identity.sh:8` reads `: "${HEAL_WORKDIR:=$HOME/swarm/Matou/idss}"`, and idss's healer hook ran fine on bens-mac-04 in the same minute (`heal: incident wf=swarm sig=c7b66d17fa31`) off the identical underlying fault. coa's generated line is the odd one out. This is the per-role half of GOTCHAS 2 ("a host half is **per role**, not per repo") biting again: the swarm half works on bens-mac-04, the healer half does not. ## Fix Make the default `$HOME`-relative, matching idss: ```sh : "${HEAL_WORKDIR:=$HOME/swarm/Matou/coa}" ``` `swarm.yml` / `triage.yml` already invoke `bash "$HOME/swarm/${{ github.repository }}/.sandcastle/heal.sh"`, so the identity default is the only place the path is pinned. ## Acceptance - `.sandcastle/swarm-identity.sh` no longer contains a `/home/` literal. - A failing swarm leg on a host whose HOME is not `/home/dev` produces a real `heal: evidence at …` / `heal: incident wf=… sig=…` pair, not the `mkdir` line. - `docs/GOTCHAS.md` gains an entry: a healer hook that dies in `mkdir` is silent by construction — the step's Mattermost fallback swallows the exit and the run looks green — so the hook's own failure must be read from the step log, not the step status. ## Out of scope The underlying DNS fault on bens-mac-04 — filed separately as a host issue. This ticket is only about the healer being unable to *report* it. ## Notes - `.sandcastle/` is vendored at `FACTORY_REF` `87e1b55`; this fix is factory-side as well as here, so the re-vendor must carry it back deliberately. - Machinery change → `ready-for-session` per `docs/agents/issue-tracker.md`, never inside a worker PR. - GOTCHAS 3 says this instance has no job-log endpoint. That is now only half true: `POST /{owner}/{repo}/actions/runs/<run_number>/jobs/<idx>/attempt/1` with `{"logCursors":[{"step":N,"cursor":0,"expanded":true}]}` and an `Authorization: token` header returns the per-step log as JSON. The `/attempt/1` suffix is required (without it the bare `/jobs/<idx>` POST 500s with `task with job_id … and attempt 0: resource does not exist`). That is how the logs quoted above were obtained; worth folding into GOTCHAS 3 and into the healer's evidence collector so an off-host leg is no longer a blind spot.
Author
Member

Close-report (pr-mode) — PR #180 opened, awaiting a human merge.

Ruled by agent under ADR 0002 (two-way door — revertible one-line config, provable by the identity + heal seams); veto anytime.

What lands (PR #180, closes #171):

  • .sandcastle/swarm-identity.sh — HEAL_WORKDIR default changed from the absolute /home/dev/swarm/Matou/coa to $HOME/swarm/Matou/coa, matching Matou/idss. This file is the per-repo identity layer (the comment at its head invites editing HEAL_WORKDIR) and is not in FACTORY_MANIFEST, so the change is drift-safe. RUNNER_HOST was already a per-repo edit here.
  • docs/GOTCHAS.md — new entry 25: a healer hook that dies in its own mkdir is silent by construction (the step's || true Mattermost fallback swallows the exit and the run looks green), so the hook's own failure must be read from the step log, not the step status. GOTCHAS 3 amended with the per-step log endpoint from the Notes (POST …/runs/<n>/jobs/<idx>/attempt/1 with logCursors), since it is now the seam for reading an off-host leg.
  • STATUS.md — header + milestone log updated in the same commit.

Commit: aa5845a on agent/issue-171.

Proof (acceptance):

  1. grep /home/ .sandcastle/swarm-identity.sh → no match. ✔
  2. Under a non-/home/dev HOME: env -u HEAL_WORKDIR HOME=/home/bensmac bash -c '. .sandcastle/swarm-identity.sh; echo $HEAL_WORKDIR' → /home/bensmac/swarm/Matou/coa, so heal.sh's mkdir -p "$HEAL_WORKDIR/.sandcastle/.state/healer" succeeds and the hook reaches its evidence collector instead of aborting. ✔
  3. docs/GOTCHAS.md gained the required entry (25) on the silent-mkdir hazard. ✔
  • bash .sandcastle/tests/swarm-identity-test.sh → 7 groups passed (the test does not exercise HEAL_WORKDIR; nothing regressed).
  • bash .sandcastle/check-harness-drift.sh → OK.

Residue / out of scope:

  • The same bug is factory-side (dev-factory's factory onboard template); the next .sandcastle re-vendor must carry this fix back deliberately, or a re-onboard would regenerate the /home/dev default.
  • The underlying DNS fault on bens-mac-04 is a separate host issue — this ticket was only about the healer being unable to report it.

pr-mode: leaving #171 open and ready-for-session dropped by the runner; the human's merge of PR #180 closes it.

**Close-report (pr-mode) — PR #180 opened, awaiting a human merge.** Ruled by agent under ADR 0002 (two-way door — revertible one-line config, provable by the identity + heal seams); veto anytime. **What lands (PR #180, `closes #171`):** - `.sandcastle/swarm-identity.sh` — `HEAL_WORKDIR` default changed from the absolute `/home/dev/swarm/Matou/coa` to `$HOME/swarm/Matou/coa`, matching `Matou/idss`. This file is the per-repo identity layer (the comment at its head invites editing `HEAL_WORKDIR`) and is **not** in `FACTORY_MANIFEST`, so the change is drift-safe. `RUNNER_HOST` was already a per-repo edit here. - `docs/GOTCHAS.md` — new **entry 25**: a healer hook that dies in its own `mkdir` is silent by construction (the step's `|| true` Mattermost fallback swallows the exit and the run looks green), so the hook's own failure must be read from the **step log**, not the step status. **GOTCHAS 3 amended** with the per-step log endpoint from the Notes (`POST …/runs/<n>/jobs/<idx>/attempt/1` with `logCursors`), since it is now the seam for reading an off-host leg. - `STATUS.md` — header + milestone log updated in the same commit. **Commit:** `aa5845a` on `agent/issue-171`. **Proof (acceptance):** 1. `grep /home/ .sandcastle/swarm-identity.sh` → no match. ✔ 2. Under a non-`/home/dev` HOME: `env -u HEAL_WORKDIR HOME=/home/bensmac bash -c '. .sandcastle/swarm-identity.sh; echo $HEAL_WORKDIR'` → `/home/bensmac/swarm/Matou/coa`, so `heal.sh`'s `mkdir -p "$HEAL_WORKDIR/.sandcastle/.state/healer"` succeeds and the hook reaches its evidence collector instead of aborting. ✔ 3. `docs/GOTCHAS.md` gained the required entry (25) on the silent-`mkdir` hazard. ✔ - `bash .sandcastle/tests/swarm-identity-test.sh` → 7 groups passed (the test does not exercise `HEAL_WORKDIR`; nothing regressed). - `bash .sandcastle/check-harness-drift.sh` → OK. **Residue / out of scope:** - The same bug is factory-side (dev-factory's `factory onboard` template); the next `.sandcastle` re-vendor must carry this fix back deliberately, or a re-onboard would regenerate the `/home/dev` default. - The underlying DNS fault on `bens-mac-04` is a separate host issue — this ticket was only about the healer being unable to *report* it. pr-mode: leaving #171 open and `ready-for-session` dropped by the runner; the human's merge of PR #180 closes it.
Author
Member

This was generated by AI during triage.

Ruled by agent under ADR 0174 — veto anytime.

Ruling: state → ready-for-session. The ticket carried bug, priority but no state role — the runner's close-report above notes the ready-for-session label was dropped, leaving it untriaged on state. Restoring it.

Why it's a two-way door: a label change, fully revertible by removing the label; widens no security posture, touches no credentials, spends nothing. Not on the one-way-door list.

What proves it: docs/agents/issue-tracker.md — "Machinery changes (anything under .sandcastle/ or .forgejo/) are filed ready-for-session, never inside a worker's PR." The fix is in .sandcastle/swarm-identity.sh (a protected path) and PR #180 is already open with closes #171; a human session merges it.

> *This was generated by AI during triage.* Ruled by agent under ADR 0174 — veto anytime. **Ruling:** state → `ready-for-session`. The ticket carried `bug, priority` but no state role — the runner's close-report above notes the `ready-for-session` label was dropped, leaving it untriaged on state. Restoring it. **Why it's a two-way door:** a label change, fully revertible by removing the label; widens no security posture, touches no credentials, spends nothing. Not on the one-way-door list. **What proves it:** `docs/agents/issue-tracker.md` — "Machinery changes (anything under `.sandcastle/` or `.forgejo/`) are filed `ready-for-session`, never inside a worker's PR." The fix is in `.sandcastle/swarm-identity.sh` (a protected path) and PR #180 is already open with `closes #171`; a human session merges it.
Author
Member

This was generated by AI during triage.

Ruled by agent under ADR 0174 — veto anytime.

Label applied: ready-for-session (category bug/priority unchanged). Today's close-report noted the ready-for-session label was dropped by the runner, leaving the ticket untriaged on state. Applying it now closes that drop. PR #180 (closes #171) — the $HOME-relative HEAL_WORKDIR default in .sandcastle/swarm-identity.sh — is open for a human/session merge.

Why it's a two-way door: a label change, fully revertible; widens no security posture, touches no credentials, spends nothing. What proves it: docs/agents/issue-tracker.md:50 (machinery under .sandcastle/ → ready-for-session, never a worker PR); the fix is in .sandcastle/swarm-identity.sh (a protected path) and PR #180 is open with closes #171.

> *This was generated by AI during triage.* Ruled by agent under ADR 0174 — veto anytime. **Label applied: `ready-for-session`** (category `bug`/`priority` unchanged). Today's close-report noted the `ready-for-session` label was dropped by the runner, leaving the ticket untriaged on state. Applying it now closes that drop. PR #180 (`closes #171`) — the `$HOME`-relative `HEAL_WORKDIR` default in `.sandcastle/swarm-identity.sh` — is open for a human/session merge. **Why it's a two-way door:** a label change, fully revertible; widens no security posture, touches no credentials, spends nothing. **What proves it:** `docs/agents/issue-tracker.md:50` (machinery under `.sandcastle/` → `ready-for-session`, never a worker PR); the fix is in `.sandcastle/swarm-identity.sh` (a protected path) and PR #180 is open with `closes #171`.
Author
Member

This was generated by AI during triage.

Ruled by agent under ADR 0174 — veto anytime.

Ruling: state → ready-for-human (category bug, priority unchanged), correcting the prior ready-for-session ruling on this ticket.

Why the change. ready-for-session is not terminal here and provably loops. The session's job is done — PR #180 (closes #171) is open and green. By design, a pr-mode ticket with an open agent PR is "handed to review": the session runner deletes ready-for-session and adds nothing, because a human merges the PR (.sandcastle/session-runner.sh:413-415 and :660-663 — api -X DELETE …/labels/$rfs_id, "#302"). Each triage run then re-reads the now-stateless ticket as untriaged and re-adds ready-for-session, which the runner drops ~10 min later. This issue's own label timeline shows the churn: added 15:08Z → removed 15:20Z → added 15:39Z → removed 15:49Z. Re-adding it a fifth time would only restart the loop.

## Why human. The sole residue is a human's decision to merge PR #180 — a change to a protected machinery path (.sandcastle/swarm-identity.sh). A protected path is protected precisely because landing it to main is a standing/trust call; the swarm worker lane cannot make it and the session drainer refuses it (it hands the open PR back to review). A test proves the one-line fix works; it does not decide whether the machinery change should land. Proposed default: merge PR #180 as-is (the one-line $HOME-relative HEAL_WORKDIR matching Matou/idss, proven green), and carry the same fix back factory-side at the next .sandcastle re-vendor so a re-onboard does not regenerate the /home/dev default.

Why relabelling is itself a two-way door: a label change, fully revertible, touching no credential, posture, or spend — not on the one-way-door list. What proves it: the add/remove churn in this issue's label timeline, and .sandcastle/session-runner.sh:413-415 / :660-663.

> *This was generated by AI during triage.* Ruled by agent under ADR 0174 — veto anytime. **Ruling: state → `ready-for-human`** (category `bug, priority` unchanged), *correcting the prior `ready-for-session` ruling on this ticket.* **Why the change.** `ready-for-session` is not terminal here and provably loops. The session's job is done — PR #180 (`closes #171`) is open and green. By design, a pr-mode ticket with an open agent PR is "handed to review": the session runner **deletes `ready-for-session`** and adds nothing, because a human merges the PR (`.sandcastle/session-runner.sh:413-415` and `:660-663` — `api -X DELETE …/labels/$rfs_id`, "#302"). Each triage run then re-reads the now-stateless ticket as untriaged and re-adds `ready-for-session`, which the runner drops ~10 min later. This issue's own label timeline shows the churn: added 15:08Z → removed 15:20Z → added 15:39Z → removed 15:49Z. Re-adding it a fifth time would only restart the loop. **## Why human.** The sole residue is a human's decision to **merge PR #180** — a change to a protected machinery path (`.sandcastle/swarm-identity.sh`). A protected path is protected precisely because landing it to `main` is a standing/trust call; the swarm worker lane cannot make it and the session drainer refuses it (it hands the open PR back to review). A test proves the one-line fix works; it does not decide whether the machinery change should land. **Proposed default:** merge PR #180 as-is (the one-line `$HOME`-relative `HEAL_WORKDIR` matching `Matou/idss`, proven green), and carry the same fix back factory-side at the next `.sandcastle` re-vendor so a re-onboard does not regenerate the `/home/dev` default. **Why relabelling is itself a two-way door:** a label change, fully revertible, touching no credential, posture, or spend — not on the one-way-door list. **What proves it:** the add/remove churn in this issue's label timeline, and `.sandcastle/session-runner.sh:413-415` / `:660-663`.
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#171
No description provided.