swarm: healer-signature-fidelity — stage-aware signatures for swarm/triage; scope evidence to the triggering run; absorb Forgejo 5xx in triage preflight #235

Closed
opened 2026-07-31 20:26:40 +00:00 by ben · 1 comment
Owner

Why (evidence from 2026-07-31 evening)

Two healer escalations tonight (triage/59febfdb8d87, swarm/9621ee30cf36) were false-positive signatures: for every workflow except ci, error_line() (.sandcastle/heal.sh:96) greps the newest .sandcastle/logs/*.log for error|Error|ERR|failed|Failed|fatal and takes tail -1 — and Sandcastle worker chain-of-thought prose is saturated with those words. Both signatures were minted from a stale 03:38 worker narrating the already-closed #198 Go-toolchain gap ("no local Go to check"), unrelated to the failing runs. The healer's own dry-run diagnoses confirmed this twice, independently:

  • /tmp/matou-heal.5QlrRZ/diagnosis.md (18:30, triage run 1637) — real cause was a transient Forgejo 503 storm; signature pointed at the stale worker log.
  • /tmp/matou-heal.SXO13O/diagnosis.md (19:34, swarm run 1643) — real cause was the workdir flipped to core.bare = true (fixed by hand 2026-07-31 ~20:15 UTC, ledger entries retired to .state/healer/retired/); the healer reproduced compute_signature swarm "<prose line>" → 9621ee30cf36 exactly.

Consequences of the bad signatures: recurrence tracking keys on noise (the "same fault" is just the same stale log line), real distinct faults collapse into one thread, reply caps burn on phantom recurrences, and both incidents escalated to @ben with misleading fingerprints. This is the same defect #197 fixed for ci (seam-verdict stage marker) and explicitly deferred for the rest (heal.sh:86-87).

The healer cannot fix this itself: its charter forbids modifying heal.sh/heal-lib.sh, hence this ticket.

Acceptance criteria

  1. Stage-aware signatures for swarm and triage (extend #197 beyond ci): run-swarm.sh / run-triage.sh drop a machine-readable stage/exit marker on failure (mirroring the ci seam-verdict bridge), and error_line() keys the signature on that marker — never on a grep over worker chain-of-thought. When no marker exists, degrade to the workflow name and mark the signature degraded (the $EVIDENCE/seam-degraded honesty flag already exists for ci — reuse it), rather than scraping prose.
  2. Evidence scoped to the triggering run: gather_evidence currently tails EVERY .sandcastle/logs/*.log (heal.sh:56), so hours-old worker logs pollute incidents. Collect only logs newer than the triggering run's start (or the run's own log), keeping at most a bounded tail of older context clearly labelled as such.
  3. Triage preflight absorbs transient 5xx: preflight-triage.sh pages the issue list with bare curl -sf under set -euo pipefail (lines 26, 31) — one Forgejo 503 kills the whole triage job (root cause of run 1637). Add a small retry/backoff (e.g. 3 attempts, exponential) to the paged api() calls; a persistent outage should still fail the job.
  4. tests/limit-lib-test.sh-style offline tests pin the new signature path: a worker log full of "error"/"failed" prose plus a stage marker yields the marker-derived signature; prose alone yields the degraded workflow-name signature, flagged degraded.

Non-goals

  • No change to the escalation/reply-cap ledger logic itself — only to what feeds it.
  • The core.bare workdir flip is NOT in scope here (fixed by hand; if it recurs it deserves its own investigation).

Pointers

  • .sandcastle/heal.sh (error_line, gather_evidence, compute_signature), .sandcastle/heal-lib.sh, .sandcastle/preflight-triage.sh, .sandcastle/run-triage.sh, .sandcastle/run-swarm.sh
  • #197 (the ci stage-aware fix this extends), #198 (the closed gap the phantom signature narrated)
  • Healer diagnoses: /tmp/matou-heal.5QlrRZ/ and /tmp/matou-heal.SXO13O/ on matou-workstation
## Why (evidence from 2026-07-31 evening) Two healer escalations tonight (`triage`/`59febfdb8d87`, `swarm`/`9621ee30cf36`) were **false-positive signatures**: for every workflow except `ci`, `error_line()` (`.sandcastle/heal.sh:96`) greps the newest `.sandcastle/logs/*.log` for `error|Error|ERR|failed|Failed|fatal` and takes `tail -1` — and Sandcastle worker chain-of-thought prose is saturated with those words. Both signatures were minted from a stale 03:38 worker *narrating* the already-closed #198 Go-toolchain gap ("no local Go to check"), unrelated to the failing runs. The healer's own dry-run diagnoses confirmed this twice, independently: - `/tmp/matou-heal.5QlrRZ/diagnosis.md` (18:30, triage run 1637) — real cause was a transient Forgejo 503 storm; signature pointed at the stale worker log. - `/tmp/matou-heal.SXO13O/diagnosis.md` (19:34, swarm run 1643) — real cause was the workdir flipped to `core.bare = true` (fixed by hand 2026-07-31 ~20:15 UTC, ledger entries retired to `.state/healer/retired/`); the healer reproduced `compute_signature swarm "<prose line>"` → `9621ee30cf36` exactly. Consequences of the bad signatures: recurrence tracking keys on noise (the "same fault" is just the same stale log line), real distinct faults collapse into one thread, reply caps burn on phantom recurrences, and both incidents escalated to @ben with misleading fingerprints. This is the same defect #197 fixed for `ci` (seam-verdict stage marker) and explicitly deferred for the rest (`heal.sh:86-87`). The healer cannot fix this itself: its charter forbids modifying `heal.sh`/`heal-lib.sh`, hence this ticket. ## Acceptance criteria 1. **Stage-aware signatures for `swarm` and `triage`** (extend #197 beyond `ci`): `run-swarm.sh` / `run-triage.sh` drop a machine-readable stage/exit marker on failure (mirroring the `ci` seam-verdict bridge), and `error_line()` keys the signature on that marker — never on a grep over worker chain-of-thought. When no marker exists, degrade to the workflow name **and mark the signature degraded** (the `$EVIDENCE/seam-degraded` honesty flag already exists for `ci` — reuse it), rather than scraping prose. 2. **Evidence scoped to the triggering run**: `gather_evidence` currently tails EVERY `.sandcastle/logs/*.log` (`heal.sh:56`), so hours-old worker logs pollute incidents. Collect only logs newer than the triggering run's start (or the run's own log), keeping at most a bounded tail of older context clearly labelled as such. 3. **Triage preflight absorbs transient 5xx**: `preflight-triage.sh` pages the issue list with bare `curl -sf` under `set -euo pipefail` (lines 26, 31) — one Forgejo 503 kills the whole triage job (root cause of run 1637). Add a small retry/backoff (e.g. 3 attempts, exponential) to the paged `api()` calls; a persistent outage should still fail the job. 4. `tests/limit-lib-test.sh`-style offline tests pin the new signature path: a worker log full of "error"/"failed" prose plus a stage marker yields the marker-derived signature; prose alone yields the degraded workflow-name signature, flagged degraded. ## Non-goals - No change to the escalation/reply-cap ledger logic itself — only to what feeds it. - The `core.bare` workdir flip is NOT in scope here (fixed by hand; if it recurs it deserves its own investigation). ## Pointers - `.sandcastle/heal.sh` (`error_line`, `gather_evidence`, `compute_signature`), `.sandcastle/heal-lib.sh`, `.sandcastle/preflight-triage.sh`, `.sandcastle/run-triage.sh`, `.sandcastle/run-swarm.sh` - #197 (the `ci` stage-aware fix this extends), #198 (the closed gap the phantom signature narrated) - Healer diagnoses: `/tmp/matou-heal.5QlrRZ/` and `/tmp/matou-heal.SXO13O/` on matou-workstation
Author
Owner

Landed on main as 021be8e (sandcastle: swarm:healer-signature-fidelity #235).

What was done

  • AC1 — stage-aware signatures for swarm/triage: new shared .sandcastle/verdict-lib.sh (verdict_begin/verdict_stage/verdict_write, seam-smoke's exact format). run-swarm.sh and run-triage.sh drop a stage=/exit=/--- error lines --- verdict on failure at /tmp/matou-{swarm,triage}-verdict.txt via one EXIT trap (no-op on clean exit). run-swarm arms the trap before pnpm install/image-build so the #142 lockfile-class break verdicts too; the worktree sweep stays gated (SWEEP_ARMED, unchanged timing). heal.sh grows a verdict_path map + verdict_is_fresh guard, and error_line now keys the signature on the fresh marker for ci/swarm/triage alike — never worker chain-of-thought prose — degrading to the workflow name and setting $EVIDENCE/seam-degraded (the honesty flag) when no fresh verdict exists.
  • AC2 — evidence scoped to the run: gather_evidence windows worker logs to HEAL_RUN_WINDOW (default 2h); only fresh logs feed worker-logs.txt (and the degrade-path grep), older tails go to a clearly-labelled worker-logs-older.txt, never the signature. A stale verdict is ignored the same way.
  • AC3 — triage preflight absorbs 5xx: preflight-triage.sh's api() gains 3-attempt exponential backoff (root cause of run 1637's 503 storm); a persistent outage still fails the job.
  • AC4 — offline tests: tests/heal-test.sh now pins the swarm path (worker error-prose + stage marker → marker-derived signature; prose alone or a stale verdict → degraded workflow-name signature, flagged), plus a new tests/preflight-triage-test.sh (blip-within-budget survives, persistent outage fails). All healer offline tests green.

No change to the ledger/reply-cap policy — only to what feeds it. The core.bare workdir flip stayed out of scope (non-goal). STATUS.md updated (header + milestone log).

Landed on `main` as `021be8e` (`sandcastle: swarm:healer-signature-fidelity #235`). **What was done** - **AC1 — stage-aware signatures for `swarm`/`triage`:** new shared `.sandcastle/verdict-lib.sh` (`verdict_begin`/`verdict_stage`/`verdict_write`, seam-smoke's exact format). `run-swarm.sh` and `run-triage.sh` drop a `stage=/exit=/--- error lines ---` verdict on failure at `/tmp/matou-{swarm,triage}-verdict.txt` via one EXIT trap (no-op on clean exit). `run-swarm` arms the trap **before** `pnpm install`/image-build so the #142 lockfile-class break verdicts too; the worktree sweep stays gated (SWEEP_ARMED, unchanged timing). `heal.sh` grows a `verdict_path` map + `verdict_is_fresh` guard, and `error_line` now keys the signature on the fresh marker for `ci`/`swarm`/`triage` alike — never worker chain-of-thought prose — degrading to the workflow name and setting `$EVIDENCE/seam-degraded` (the honesty flag) when no fresh verdict exists. - **AC2 — evidence scoped to the run:** `gather_evidence` windows worker logs to `HEAL_RUN_WINDOW` (default 2h); only fresh logs feed `worker-logs.txt` (and the degrade-path grep), older tails go to a clearly-labelled `worker-logs-older.txt`, never the signature. A stale verdict is ignored the same way. - **AC3 — triage preflight absorbs 5xx:** `preflight-triage.sh`'s `api()` gains 3-attempt exponential backoff (root cause of run 1637's 503 storm); a persistent outage still fails the job. - **AC4 — offline tests:** `tests/heal-test.sh` now pins the swarm path (worker error-prose + stage marker → marker-derived signature; prose alone or a stale verdict → degraded workflow-name signature, flagged), plus a new `tests/preflight-triage-test.sh` (blip-within-budget survives, persistent outage fails). All healer offline tests green. No change to the ledger/reply-cap policy — only to what feeds it. The `core.bare` workdir flip stayed out of scope (non-goal). STATUS.md updated (header + milestone log).
ben closed this issue 2026-07-31 21:29:13 +00:00
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/idss#235
No description provided.