preflight: a transient tracker 5xx in policy_validate's label GET is reported as 'invalid swarm-policy.sh' with no verdict error line (run 23495) #292

Closed
opened 2026-10-20 21:54:18 +00:00 by matou-build-agent · 3 comments

Swarm run 23495 (scheduled, host=bens-mac-04) aborted at
stage=policy validation (#12) exit=1 reason=invalid-policy. The policy file
was valid — git.matou.nz flapped for one request.

Evidence

Job log (/tmp/matou-heal-Matou-dev-factory.G9W1Ar/job-log.txt):

21:47:14.6 preflight-swarm: issue_write_permission OK
21:47:14.6 preflight-swarm: all 10 guards fired
21:47:15.1 policy: could not list the repo's labels to validate HUMAN_LABELS
21:47:19.0 run-swarm: RUN FAILED — exit 1 in stage 'policy validation (#12)' (reason=invalid-policy)

guard_issue_write_permission GET succeeded with the same token 0.5 s
earlier; policy_validate's forgejo_get '/labels?limit=100' then failed.
api-timing.txt recorded api_http=503 api_curl_exit=0. Re-validated at heal
time: policy_validate .sandcastle/swarm-policy.sh → rc=0; /labels
returns 200 in ~0.8 s. Forge was still degraded during the heal (the
/actions/runs endpoint returned 504, then stalled past 25 s, while /labels
served 200) — the brownout pattern of GOTCHAS 53/54/55/56.

Two defects, both in policy_validate's one unretried GET

  1. No retry. policy_lib.sh:189 is a bare forgejo_get — one 5xx reds
    the whole tick before a worker spawns. This is the half #243 already covers
    (forward-port idss #2048's bounded GET retry onto forgejo-lib.sh).
  2. Dishonest attribution — not covered by #243, and the reason this
    burned a healer run. A failed read is reported as an invalid policy:
    • SWARM_EXIT_REASON=invalid-policy and the stage name blame the consumer's
      swarm-policy.sh for a tracker outage;
    • Mattermost posted "⛔ Swarm aborted — invalid swarm-policy.sh
      … Fix the named policy key" — false, nothing to fix;
    • preflight_policy_gate (preflight-lib.sh:65) never calls
      verdict_error, so run-verdict.txt carried an empty
      --- error lines --- block and the healer keyed signature 3a62b2744e4b
      on the bare stage name. That is exactly the GOTCHAS #217 hazard the
      sibling preflight_gate fixes 15 lines above, with the same comment.

This is the inverse of GOTCHAS 55 (a failed read asserting "transient" for
any rc): here a failed read asserts "invalid config" for any rc.

Acceptance

  • policy_validate distinguishes "the label read failed" from "the policy is
    invalid": separate rc / SWARM_EXIT_REASON (e.g. tracker-unreachable),
    with the HTTP status and endpoint in the message — the GOTCHAS 55 remedy.
  • preflight_policy_gate calls verdict_error with that line on both
    paths, so the verdict and the healer signature name the cause.
  • The Mattermost copy for the read-failure path says the tracker was
    unreachable, not "fix the named policy key".
  • Retry rides on #243's bounded GET retry (or lands with it); link both ways.
  • Tests in the same commit: tests/policy-lib-test.sh (shimmed curl → 503,
    assert the read-failure rc/message, and that a structurally-bad file still
    reds as invalid) and tests/preflight-lib-test.sh (assert the
    verdict_error line reaches the verdict) — per CLAUDE.md.

Re-vendor caveat

policy-lib.sh / preflight-lib.sh are root files. Landing on main does
not reach the running copy: .sandcastle/FACTORY_REF is a4be7db and the
fix only runs after a human bumps the pin
(bash onboarding/onboard.sh vendor .sandcastle <sha>, GOTCHAS 4).

Not a blocker

The tick self-heals — the next scheduled run re-validates and a 200 passes. No
worker was spawned, nothing was left half-done, no repair was made. Filed by
the healer for run 23495 (sig 3a62b2744e4b).

Swarm run **23495** (scheduled, `host=bens-mac-04`) aborted at `stage=policy validation (#12) exit=1 reason=invalid-policy`. The policy file was **valid** — `git.matou.nz` flapped for one request. ## Evidence Job log (`/tmp/matou-heal-Matou-dev-factory.G9W1Ar/job-log.txt`): ``` 21:47:14.6 preflight-swarm: issue_write_permission OK 21:47:14.6 preflight-swarm: all 10 guards fired 21:47:15.1 policy: could not list the repo's labels to validate HUMAN_LABELS 21:47:19.0 run-swarm: RUN FAILED — exit 1 in stage 'policy validation (#12)' (reason=invalid-policy) ``` `guard_issue_write_permission` GET succeeded with the same token 0.5 s earlier; `policy_validate`'s `forgejo_get '/labels?limit=100'` then failed. `api-timing.txt` recorded `api_http=503 api_curl_exit=0`. Re-validated at heal time: `policy_validate .sandcastle/swarm-policy.sh` → **rc=0**; `/labels` returns 200 in ~0.8 s. Forge was still degraded during the heal (the `/actions/runs` endpoint returned 504, then stalled past 25 s, while `/labels` served 200) — the brownout pattern of GOTCHAS 53/54/55/56. ## Two defects, both in `policy_validate`'s one unretried GET 1. **No retry.** `policy_lib.sh:189` is a bare `forgejo_get` — one 5xx reds the whole tick before a worker spawns. This is the half #243 already covers (forward-port idss #2048's bounded GET retry onto `forgejo-lib.sh`). 2. **Dishonest attribution** — *not* covered by #243, and the reason this burned a healer run. A failed *read* is reported as an invalid *policy*: - `SWARM_EXIT_REASON=invalid-policy` and the stage name blame the consumer's `swarm-policy.sh` for a tracker outage; - Mattermost posted ":no_entry: **Swarm aborted — invalid `swarm-policy.sh`** … Fix the named policy key" — false, nothing to fix; - `preflight_policy_gate` (`preflight-lib.sh:65`) never calls `verdict_error`, so `run-verdict.txt` carried an **empty** `--- error lines ---` block and the healer keyed signature `3a62b2744e4b` on the bare stage name. That is exactly the GOTCHAS #217 hazard the sibling `preflight_gate` fixes 15 lines above, with the same comment. This is the inverse of **GOTCHAS 55** (a failed read asserting "transient" for *any* rc): here a failed read asserts "invalid config" for *any* rc. ## Acceptance - `policy_validate` distinguishes "the label read failed" from "the policy is invalid": separate rc / `SWARM_EXIT_REASON` (e.g. `tracker-unreachable`), with the HTTP status and endpoint in the message — the GOTCHAS 55 remedy. - `preflight_policy_gate` calls `verdict_error` with that line on **both** paths, so the verdict and the healer signature name the cause. - The Mattermost copy for the read-failure path says the tracker was unreachable, not "fix the named policy key". - Retry rides on #243's bounded GET retry (or lands with it); link both ways. - Tests in the same commit: `tests/policy-lib-test.sh` (shimmed `curl` → 503, assert the read-failure rc/message, and that a structurally-bad file still reds as invalid) and `tests/preflight-lib-test.sh` (assert the `verdict_error` line reaches the verdict) — per CLAUDE.md. ## Re-vendor caveat `policy-lib.sh` / `preflight-lib.sh` are **root** files. Landing on `main` does **not** reach the running copy: `.sandcastle/FACTORY_REF` is `a4be7db` and the fix only runs after a human bumps the pin (`bash onboarding/onboard.sh vendor .sandcastle <sha>`, GOTCHAS 4). ## Not a blocker The tick self-heals — the next scheduled run re-validates and a 200 passes. No worker was spawned, nothing was left half-done, no repair was made. Filed by the healer for run 23495 (sig `3a62b2744e4b`).
Author
Member

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

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

⏩ independent reviewer for #292 — verdict unauthenticated

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

close-report for #292 — status success

✅ close-report gates passed — every claim verified against main; issue closed.

envelope
{
  "issue": 292,
  "status": "success",
  "commits": [
    "2a09f8cc7d7467a6dd367dbd6eac05363ffc93b1"
  ],
  "changed_files": [
    "docs/GOTCHAS.md",
    "docs/gotchas/78-a-failed-label-read-asserted-invalid-policy.md",
    "docs/journal/2026-10-20-292.md",
    "policy-lib.sh",
    "preflight-lib.sh",
    "tests/policy-lib-test.sh",
    "tests/preflight-lib-test.sh",
    "tests/run-swarm-stages-test.sh"
  ],
  "tests": [
    {
      "command": "bash tests/policy-lib-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash tests/preflight-lib-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash tests/run-swarm-stages-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash tests/docs-budget-test.sh",
      "exit_code": 0
    },
    {
      "command": "for t in tests/*.sh onboarding/tests/*.sh; do ... bash $t; done",
      "exit_code": 0
    }
  ],
  "criteria": {
    "policy_validate distinguishes read-failure from invalid policy (separate rc / SWARM_EXIT_REASON e.g. tracker-unreachable, with HTTP status and endpoint in the message)": "policy-lib.sh: policy_validate now returns rc 3 on a non-2xx/000 label read with message 'GET /labels?limit=100 http=<code> — the tracker is unreachable, not an invalid swarm-policy.sh'; rc 2 stays for structure/unminted label. preflight-lib.sh maps rc 3 -> SWARM_EXIT_REASON=tracker-unreachable. Pinned by tests/policy-lib-test.sh (5xx/000 -> rc 3 + endpoint+status; struct-bad -> rc 2 during outage).",
    "preflight_policy_gate calls verdict_error with that line on both paths": "preflight-lib.sh: preflight_policy_gate captures policy_validate stderr and calls verdict_error on BOTH the invalid (rc 2) and read-failure (rc 3) paths. Pinned by tests/preflight-lib-test.sh (invalid path records 'LANDING must be push|pr'; read-failure path records http=503 + /labels on VERDICT_ERROR).",
    "Mattermost copy for the read-failure path says the tracker was unreachable, not 'fix the named policy key'": "preflight-lib.sh: rc 3 posts ':satellite: Swarm aborted — tracker unreachable … Nothing to fix'. tests/preflight-lib-test.sh asserts the alarm says 'tracker unreachable' and does NOT say 'fix the named policy key'.",
    "Retry rides on #243's bounded GET retry (or lands with it); link both ways": "No retry added here (per ticket). Cross-link comment posted to #243; policy-lib.sh/GOTCHAS 78/journal all reference #243 both ways.",
    "Tests in the same commit (policy-lib-test: 503 read-failure + structurally-bad still invalid; preflight-lib-test: verdict_error line reaches the verdict)": "tests/policy-lib-test.sh and tests/preflight-lib-test.sh updated in this commit; full offline suite green."
  },
  "summary": "policy_validate's failed label read now returns a distinct rc 3 (reason=tracker-unreachable) naming endpoint+status, and preflight_policy_gate records the cause via verdict_error on both paths with honest Mattermost copy — a transient 5xx no longer reports as an invalid swarm-policy.sh.",
  "reason": "",
  "blockers": []
}
**close-report** for #292 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 292, "status": "success", "commits": [ "2a09f8cc7d7467a6dd367dbd6eac05363ffc93b1" ], "changed_files": [ "docs/GOTCHAS.md", "docs/gotchas/78-a-failed-label-read-asserted-invalid-policy.md", "docs/journal/2026-10-20-292.md", "policy-lib.sh", "preflight-lib.sh", "tests/policy-lib-test.sh", "tests/preflight-lib-test.sh", "tests/run-swarm-stages-test.sh" ], "tests": [ { "command": "bash tests/policy-lib-test.sh", "exit_code": 0 }, { "command": "bash tests/preflight-lib-test.sh", "exit_code": 0 }, { "command": "bash tests/run-swarm-stages-test.sh", "exit_code": 0 }, { "command": "bash tests/docs-budget-test.sh", "exit_code": 0 }, { "command": "for t in tests/*.sh onboarding/tests/*.sh; do ... bash $t; done", "exit_code": 0 } ], "criteria": { "policy_validate distinguishes read-failure from invalid policy (separate rc / SWARM_EXIT_REASON e.g. tracker-unreachable, with HTTP status and endpoint in the message)": "policy-lib.sh: policy_validate now returns rc 3 on a non-2xx/000 label read with message 'GET /labels?limit=100 http=<code> — the tracker is unreachable, not an invalid swarm-policy.sh'; rc 2 stays for structure/unminted label. preflight-lib.sh maps rc 3 -> SWARM_EXIT_REASON=tracker-unreachable. Pinned by tests/policy-lib-test.sh (5xx/000 -> rc 3 + endpoint+status; struct-bad -> rc 2 during outage).", "preflight_policy_gate calls verdict_error with that line on both paths": "preflight-lib.sh: preflight_policy_gate captures policy_validate stderr and calls verdict_error on BOTH the invalid (rc 2) and read-failure (rc 3) paths. Pinned by tests/preflight-lib-test.sh (invalid path records 'LANDING must be push|pr'; read-failure path records http=503 + /labels on VERDICT_ERROR).", "Mattermost copy for the read-failure path says the tracker was unreachable, not 'fix the named policy key'": "preflight-lib.sh: rc 3 posts ':satellite: Swarm aborted — tracker unreachable … Nothing to fix'. tests/preflight-lib-test.sh asserts the alarm says 'tracker unreachable' and does NOT say 'fix the named policy key'.", "Retry rides on #243's bounded GET retry (or lands with it); link both ways": "No retry added here (per ticket). Cross-link comment posted to #243; policy-lib.sh/GOTCHAS 78/journal all reference #243 both ways.", "Tests in the same commit (policy-lib-test: 503 read-failure + structurally-bad still invalid; preflight-lib-test: verdict_error line reaches the verdict)": "tests/policy-lib-test.sh and tests/preflight-lib-test.sh updated in this commit; full offline suite green." }, "summary": "policy_validate's failed label read now returns a distinct rc 3 (reason=tracker-unreachable) naming endpoint+status, and preflight_policy_gate records the cause via verdict_error on both paths with honest Mattermost copy — a transient 5xx no longer reports as an invalid swarm-policy.sh.", "reason": "", "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#292
No description provided.