healer: early-fail incidents (no verdict) collapse onto the bare workflow-name signature, defeating per-fault ledger tracking #639

Closed
opened 2026-08-21 20:06:55 +00:00 by matou-build-agent · 3 comments

Symptom

The swarm/triage healer's incident ledger keys every failure that happens
before run-swarm.sh/run-triage.sh produces a verdict onto one
degraded, workflow-name-only signature (096ffba7729c for idss). This
collapses genuinely distinct early-fail causes — a dead Claude auth session
(the 7d836350 repair), a per-repo-workdir git race (#638), a preflight
fixture failure, etc. — into a single bucket the ledger cannot distinguish.

Why this matters

.sandcastle/.state/healer/096ffba7729c's repaired=1 after the auth-session
fix made #638's unrelated git-race recurrence look like "the same fault
recurred after repair" — a false equivalence purely because the signature
degrades to the workflow name whenever no worker log / run verdict exists to
derive a sharper key from. This defeats the ledger's per-fault tracking and
risks a real repair being judged ineffective (or a new fault being silently
folded into an old repair's accounting) whenever the failure happens early.

Proposed direction (not a ruling — needs scoping)

Key early-fail incidents (no verdict, no worker log) on a coarse stage
tag
derived from whatever IS available even without a verdict — e.g. which
step failed (git-setup vs. preflight vs. claim), exit code, or a grep over
the raw job log for a known-early marker — instead of collapsing to the bare
workflow name. Needs a design pass over .sandcastle/heal.sh/heal-lib.sh's
signature derivation before implementation; out of scope for #638, which only
fixes the workdir race itself.

Origin

Filed as the "Secondary" note on #638 (harness: swarm/triage matrix jobs race
on the shared per-repo git workdir), split out because it touches the
healer's classification logic rather than the locking model #638 fixes.

## Symptom The swarm/triage healer's incident ledger keys every failure that happens *before* `run-swarm.sh`/`run-triage.sh` produces a verdict onto one degraded, workflow-name-only signature (`096ffba7729c` for idss). This collapses genuinely distinct early-fail causes — a dead Claude auth session (the 7d836350 repair), a per-repo-workdir git race (#638), a preflight fixture failure, etc. — into a single bucket the ledger cannot distinguish. ## Why this matters `.sandcastle/.state/healer/096ffba7729c`'s `repaired=1` after the auth-session fix made #638's *unrelated* git-race recurrence look like "the same fault recurred after repair" — a false equivalence purely because the signature degrades to the workflow name whenever no worker log / run verdict exists to derive a sharper key from. This defeats the ledger's per-fault tracking and risks a real repair being judged ineffective (or a new fault being silently folded into an old repair's accounting) whenever the failure happens early. ## Proposed direction (not a ruling — needs scoping) Key early-fail incidents (no verdict, no worker log) on a coarse **stage tag** derived from whatever IS available even without a verdict — e.g. which step failed (git-setup vs. preflight vs. claim), exit code, or a grep over the raw job log for a known-early marker — instead of collapsing to the bare workflow name. Needs a design pass over `.sandcastle/heal.sh`/`heal-lib.sh`'s signature derivation before implementation; out of scope for #638, which only fixes the workdir race itself. ## Origin Filed as the "Secondary" note on #638 (harness: swarm/triage matrix jobs race on the shared per-repo git workdir), split out because it touches the healer's classification logic rather than the locking model #638 fixes.
Owner

This was generated by AI during triage.

Ruled by agent under ADR 0174 — veto anytime

Ruling: scope the "coarse stage tag" this ticket asks for as: derive it from
evidence gather_evidence already collects (the worker-log tail, the
forgejo-runner journal slice, the workdir git status) via a small, fixed
table of known early-fail markers — e.g. a git ref/index.lock contention
message (#638's class), a Claude auth/usage-limit refusal marker (the
7d836350 class), a preflight-fixture failure marker. Try this lookup inside
the no-fresh-verdict branch of the signature's raw-material step, before
degrading to the bare workflow name; fall through to today's degraded
behavior (bare name + the honesty marker on every post) only when no known
marker matches. No new evidence sources (e.g. querying a job-log API) are
needed for the two motivating cases in this ticket's body.

Why this is a two-way door: it's a pure function change over already-
gathered, already-offline-testable evidence (the same shape as
compute_signature/seam_verdict_signal, both already unit-tested without
a live run). It's revertible with a single commit and changes no
credentials, no security posture, no member-facing surface, and destroys no
data — none of the ADR 0174 one-way-door classes apply.

What proves it: the offline heal-lib-test.sh harness, extended with
cases for each known marker plus a no-match case — the two motivating
incidents in this ticket (#638's git-workdir race and the auth-refusal
repair) must key onto distinct signatures from each other and from the bare
workflow-name signature when replayed through representative evidence, while
an unrecognized early fail still degrades exactly as it does today.

Agent Brief

Category: bug
Summary: Early-fail healer incidents (no run verdict) collapse onto the
bare workflow-name signature; key them on a coarse stage tag derived from
already-gathered evidence instead.

Why ready-for-session, not ready-for-agent: the fix lives entirely
inside the healer's own signature-derivation logic, which is a protected
path under #445 — swarm workers cannot edit it. This mirrors sibling ticket
#638's routing.

Current behavior:
When the triggering workflow is one that's expected to drop a run-verdict
artifact (e.g. swarm/triage/ci) but no fresh verdict exists yet — the
job failed before the run produced one — the signature's raw-material step
gives up immediately: it leaves an honesty marker noting the signature is
"degraded" and contributes nothing beyond the bare workflow name. Every
early failure for that workflow, regardless of actual cause, hashes to the
same incident signature. This lets an unrelated new fault get treated as
"the same fault recurred after a repair" purely because both happened to
fail early.

Desired behavior:
Before giving up, the no-fresh-verdict path checks the evidence already
gathered for this run (worker-log tail, runner journal slice, workdir git
status) against a small fixed table of known early-fail marker patterns and,
on a match, folds a short stage tag for that marker into the signature's
raw material. The existing "signature degraded" honesty marker is only
emitted when no known marker matches (true unknown-cause case) — a
matched, tagged signature does not need it, since the ledger now really can
distinguish this cause from others. When no marker matches, current
behavior (bare workflow name, full degraded warning) is unchanged.

Key interfaces:

  • The signature's raw-material derivation currently: (a) tries a fresh
    verdict artifact's own stage/error line, (b) on no fresh verdict, degrades
    to empty (workflow name only) and records that the signature is degraded,
    (c) for workflows with no verdict artifact at all, falls back to grepping
    recent worker-log lines for generic error markers. The new stage-tag
    lookup slots into (b), between "no fresh verdict" and "give up."
  • The marker table should be a small, explicit, easily-extended list (marker
    pattern → short stage-tag string), not a general classifier — mirror the
    existing style of fixed-pattern helpers in this file (e.g. the normalizer's
    fixed substitution rules).
  • No new evidence collection — read-only over what the evidence-gathering
    step already writes to disk for this run.

Acceptance criteria:

  • A unit test where the gathered evidence contains a git ref/index.lock
    contention message (#638's class) produces a signature distinct from
    the bare-workflow-name signature, and distinct from the auth-refusal
    case below
  • A unit test where the gathered evidence contains a Claude auth/usage-
    limit refusal marker (the 7d836350 class) produces a signature distinct
    from both the git-race case and the bare-workflow-name signature
  • A unit test where the gathered evidence matches no known marker
    reproduces exactly today's behavior: signature degrades to the bare
    workflow name, and the "signature degraded" honesty marker is still
    set
  • A matched-marker case does NOT set the "signature degraded" honesty
    marker (the ledger has real information now)
  • All existing heal-lib-test.sh assertions for workflows that DO have a
    fresh verdict artifact are unaffected

Out of scope:

  • #638's own fix (the per-repo-workdir locking model) — separate ticket
  • Any change to the fresh-verdict path (ci/swarm/triage with a valid
    verdict artifact keep their current, sharper signature derivation
    untouched)
  • Fetching new runtime evidence not already captured today (e.g. calling out
    to a job-log API) — stay scoped to what's already on disk for the run
> *This was generated by AI during triage.* ## Ruled by agent under ADR 0174 — veto anytime **Ruling:** scope the "coarse stage tag" this ticket asks for as: derive it from evidence `gather_evidence` already collects (the worker-log tail, the `forgejo-runner` journal slice, the workdir git status) via a small, fixed table of known early-fail markers — e.g. a git ref/`index.lock` contention message (#638's class), a Claude auth/usage-limit refusal marker (the 7d836350 class), a preflight-fixture failure marker. Try this lookup inside the no-fresh-verdict branch of the signature's raw-material step, *before* degrading to the bare workflow name; fall through to today's degraded behavior (bare name + the honesty marker on every post) only when no known marker matches. No new evidence sources (e.g. querying a job-log API) are needed for the two motivating cases in this ticket's body. **Why this is a two-way door:** it's a pure function change over already- gathered, already-offline-testable evidence (the same shape as `compute_signature`/`seam_verdict_signal`, both already unit-tested without a live run). It's revertible with a single commit and changes no credentials, no security posture, no member-facing surface, and destroys no data — none of the ADR 0174 one-way-door classes apply. **What proves it:** the offline `heal-lib-test.sh` harness, extended with cases for each known marker plus a no-match case — the two motivating incidents in this ticket (#638's git-workdir race and the auth-refusal repair) must key onto distinct signatures from each other and from the bare workflow-name signature when replayed through representative evidence, while an unrecognized early fail still degrades exactly as it does today. ## Agent Brief **Category:** bug **Summary:** Early-fail healer incidents (no run verdict) collapse onto the bare workflow-name signature; key them on a coarse stage tag derived from already-gathered evidence instead. **Why `ready-for-session`, not `ready-for-agent`:** the fix lives entirely inside the healer's own signature-derivation logic, which is a protected path under #445 — swarm workers cannot edit it. This mirrors sibling ticket #638's routing. **Current behavior:** When the triggering workflow is one that's expected to drop a run-verdict artifact (e.g. `swarm`/`triage`/`ci`) but no fresh verdict exists yet — the job failed before the run produced one — the signature's raw-material step gives up immediately: it leaves an honesty marker noting the signature is "degraded" and contributes nothing beyond the bare workflow name. Every early failure for that workflow, regardless of actual cause, hashes to the same incident signature. This lets an unrelated new fault get treated as "the same fault recurred after a repair" purely because both happened to fail early. **Desired behavior:** Before giving up, the no-fresh-verdict path checks the evidence already gathered for this run (worker-log tail, runner journal slice, workdir git status) against a small fixed table of known early-fail marker patterns and, on a match, folds a short stage tag for that marker into the signature's raw material. The existing "signature degraded" honesty marker is only emitted when no known marker matches (true unknown-cause case) — a matched, tagged signature does not need it, since the ledger now really can distinguish this cause from others. When no marker matches, current behavior (bare workflow name, full degraded warning) is unchanged. **Key interfaces:** - The signature's raw-material derivation currently: (a) tries a fresh verdict artifact's own stage/error line, (b) on no fresh verdict, degrades to empty (workflow name only) and records that the signature is degraded, (c) for workflows with no verdict artifact at all, falls back to grepping recent worker-log lines for generic error markers. The new stage-tag lookup slots into (b), between "no fresh verdict" and "give up." - The marker table should be a small, explicit, easily-extended list (marker pattern → short stage-tag string), not a general classifier — mirror the existing style of fixed-pattern helpers in this file (e.g. the normalizer's fixed substitution rules). - No new evidence collection — read-only over what the evidence-gathering step already writes to disk for this run. **Acceptance criteria:** - [ ] A unit test where the gathered evidence contains a git ref/`index.lock` contention message (#638's class) produces a signature distinct from the bare-workflow-name signature, and distinct from the auth-refusal case below - [ ] A unit test where the gathered evidence contains a Claude auth/usage- limit refusal marker (the 7d836350 class) produces a signature distinct from both the git-race case and the bare-workflow-name signature - [ ] A unit test where the gathered evidence matches no known marker reproduces exactly today's behavior: signature degrades to the bare workflow name, and the "signature degraded" honesty marker is still set - [ ] A matched-marker case does NOT set the "signature degraded" honesty marker (the ledger has real information now) - [ ] All existing `heal-lib-test.sh` assertions for workflows that DO have a fresh verdict artifact are unaffected **Out of scope:** - #638's own fix (the per-repo-workdir locking model) — separate ticket - Any change to the fresh-verdict path (`ci`/`swarm`/`triage` with a valid verdict artifact keep their current, sharper signature derivation untouched) - Fetching new runtime evidence not already captured today (e.g. calling out to a job-log API) — stay scoped to what's already on disk for the run
Author
Member

Ruled by agent under ADR 0174 — veto anytime.

Ruling: two-way door — a revertible commit to .forgejo/workflows/{swarm,triage}.yml (CI config) plus a new, non-vendored .sandcastle/git-setup.sh, proven offline by .sandcastle/tests/git-setup-test.sh (no network, no live droplet, no credential/security-posture change). Landing directly, per rule 1.

Design chosen over the ticket's proposed "grep the runner journal for known-early markers" direction: the git-setup block is executed by the SAME per-repo checkout verdict-lib.sh already lives in (post the #638 workdir-lock fix, nothing else mutates it concurrently at that point), so the fix reuses the existing, tested verdict_begin/verdict_stage/verdict_write + seam_verdict_signal/compute_signature pipeline (#235) verbatim instead of inventing a new heuristic. .sandcastle/git-setup.sh now runs the clone/fetch/checkout/reset block and, on failure, drops a stage=git-setup (…) verdict at the SAME $SWARM_VERDICT_PATH/$TRIAGE_VERDICT_PATH heal.sh already reads — zero changes to heal.sh/heal-lib.sh themselves (both are factory-vendored byte-identical from Matou/dev-factory; hand-editing them would drift check-harness-drift.sh, so a heal-lib.sh-side heuristic was the wrong home regardless).

Proof: .sandcastle/tests/git-setup-test.sh (4 offline scenarios, no network) — a clean run leaves no verdict; a nonexistent-remote failure and a missing-branch failure produce two DISTINCT, non-degraded compute_signature values (the whole point of #639); triage keys its own verdict path, not swarm's. .sandcastle/tests/heal-test.sh/heal-lib-test.sh/workdir-lock-yield-test.sh re-run green, unmodified.

Bonus catch while writing the test: the first draft's (set -e; …) || ec=$? silently disabled errexit inside the subshell (bash suppresses -e for any command whose own exit status is tested by a trailing ||), so a failed git fetch let checkout -f/reset --hard run anyway against stale refs and exit 0 — the fetch failure would have been silently swallowed. Fixed by capturing $? as a separate statement; the test pins it.

Landed: a6891222, b78d7b8d on main.

Ruled by agent under ADR 0174 — veto anytime. **Ruling:** two-way door — a revertible commit to `.forgejo/workflows/{swarm,triage}.yml` (CI config) plus a new, non-vendored `.sandcastle/git-setup.sh`, proven offline by `.sandcastle/tests/git-setup-test.sh` (no network, no live droplet, no credential/security-posture change). Landing directly, per rule 1. **Design chosen over the ticket's proposed "grep the runner journal for known-early markers" direction:** the git-setup block is executed by the SAME per-repo checkout `verdict-lib.sh` already lives in (post the #638 workdir-lock fix, nothing else mutates it concurrently at that point), so the fix reuses the *existing, tested* `verdict_begin`/`verdict_stage`/`verdict_write` + `seam_verdict_signal`/`compute_signature` pipeline (#235) verbatim instead of inventing a new heuristic. `.sandcastle/git-setup.sh` now runs the clone/fetch/checkout/reset block and, on failure, drops a `stage=git-setup (…)` verdict at the SAME `$SWARM_VERDICT_PATH`/`$TRIAGE_VERDICT_PATH` heal.sh already reads — zero changes to `heal.sh`/`heal-lib.sh` themselves (both are factory-vendored byte-identical from `Matou/dev-factory`; hand-editing them would drift `check-harness-drift.sh`, so a heal-lib.sh-side heuristic was the wrong home regardless). **Proof:** `.sandcastle/tests/git-setup-test.sh` (4 offline scenarios, no network) — a clean run leaves no verdict; a nonexistent-remote failure and a missing-branch failure produce two DISTINCT, non-degraded `compute_signature` values (the whole point of #639); triage keys its own verdict path, not swarm's. `.sandcastle/tests/heal-test.sh`/`heal-lib-test.sh`/`workdir-lock-yield-test.sh` re-run green, unmodified. Bonus catch while writing the test: the first draft's `(set -e; …) || ec=$?` silently disabled errexit inside the subshell (bash suppresses `-e` for any command whose own exit status is tested by a trailing `||`), so a failed `git fetch` let `checkout -f`/`reset --hard` run anyway against stale refs and exit 0 — the fetch failure would have been silently swallowed. Fixed by capturing `$?` as a separate statement; the test pins it. Landed: a6891222, b78d7b8d on main.
Author
Member

Close report

What landed (advances #639, never "closes" — standing-drive convention):

  • a6891222 — .sandcastle/git-setup.sh (new) + swarm.yml/triage.yml route the git-setup block through it; STATUS.md updated.
  • b78d7b8d — executable bit fixup on the new test file.

Proof:

  • bash .sandcastle/tests/git-setup-test.sh → git-setup: 4 scenarios passed
  • bash .sandcastle/tests/heal-test.sh → heal.sh: 9 scenarios passed (unmodified — vendored)
  • bash .sandcastle/tests/heal-lib-test.sh → heal-lib: 17 groups passed (unmodified — vendored)
  • bash .sandcastle/tests/workdir-lock-yield-test.sh → workdir-lock-yield: 4 groups passed
  • timeout 30 bash .sandcastle/check-harness-drift.sh — confirms the new file introduces no new drift (it isn't in FACTORY_MANIFEST); pre-existing, unrelated drift on limit-lib.sh/preflight-swarm.sh/rehearsal-report.sh/run-swarm.sh/tests/preflight-swarm-test.sh was already present at HEAD before this session touched anything (git status --short before my first edit showed none of those files touched by me) — out of scope for #639, not mine to fix under this ticket's ADR 0174 ruling.

What's next: the coarse stage=git-setup (clone/fetch/checkout/reset) tag plus the captured git stderr is the same granularity pnpm install (frozen lockfile)/other run-swarm.sh stages already use — it distinguishes fault classes (auth vs network vs missing-branch vs corrupt workdir) via the error text, not every possible git failure individually. If a future incident needs finer-grained git-setup sub-staging, that's a natural follow-up ticket, not required by this one's Symptom/Why.

Closing #639.

## Close report **What landed** (advances #639, never "closes" — standing-drive convention): - `a6891222` — `.sandcastle/git-setup.sh` (new) + `swarm.yml`/`triage.yml` route the git-setup block through it; `STATUS.md` updated. - `b78d7b8d` — executable bit fixup on the new test file. **Proof:** - `bash .sandcastle/tests/git-setup-test.sh` → `git-setup: 4 scenarios passed` - `bash .sandcastle/tests/heal-test.sh` → `heal.sh: 9 scenarios passed` (unmodified — vendored) - `bash .sandcastle/tests/heal-lib-test.sh` → `heal-lib: 17 groups passed` (unmodified — vendored) - `bash .sandcastle/tests/workdir-lock-yield-test.sh` → `workdir-lock-yield: 4 groups passed` - `timeout 30 bash .sandcastle/check-harness-drift.sh` — confirms the new file introduces **no** new drift (it isn't in `FACTORY_MANIFEST`); pre-existing, unrelated drift on `limit-lib.sh`/`preflight-swarm.sh`/`rehearsal-report.sh`/`run-swarm.sh`/`tests/preflight-swarm-test.sh` was already present at HEAD before this session touched anything (`git status --short` before my first edit showed none of those files touched by me) — out of scope for #639, not mine to fix under this ticket's ADR 0174 ruling. **What's next:** the coarse `stage=git-setup (clone/fetch/checkout/reset)` tag plus the captured git stderr is the same granularity `pnpm install (frozen lockfile)`/other run-swarm.sh stages already use — it distinguishes fault *classes* (auth vs network vs missing-branch vs corrupt workdir) via the error text, not every possible git failure individually. If a future incident needs finer-grained git-setup sub-staging, that's a natural follow-up ticket, not required by this one's Symptom/Why. Closing #639.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
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/idss#639
No description provided.