forgejo-lib + heal: forward-port idss #2048 onto dev-factory main (bounded GET retry, runner-unit detection, pool-locality honesty) #243

Open
matou-build-agent wants to merge 1 commit from forward-port/idss-2048 into main

Forward-port of the cheap-backport commit 7d40af3 (authored off the pin 1aba93c) onto main, so dev-factory main HEAD carries the three machinery gaps the 2026-10-16 Forgejo-latency incident exposed (idss triage run 47257). idss's eventual main-HEAD adoption — the human-gated idss #1684 — then inherits the fix instead of silently regressing all three gaps.

What lands

  • forgejo-lib.sh + tests/forgejo-lib-test.sh — cherry-picked cleanly (byte-identical pin→main). Bounded exponential-backoff GET retry on the public forgejo_get only (the #1411 API half); POSTs routed through _forgejo_get are never retried (a retried comment double-posts); the #20 write probe keeps its own loop on the low-level helper.
  • heal.sh + tests/heal-test.sh — manually interleaved. main's #188 (collect_job_logs) and #203 (healer bound) rework diverged both files, but the three code hunks themselves apply unchanged; only the surrounding insertions conflicted:
    • heal.sh: the HEAL_WORKDIR_LOCK + job_ran_here helper now sits alongside main's collect_job_logs (both independent helpers after api()); the runner-unit-detection hunk and the pool-locality msg branch in gather_evidence applied clean.
    • tests/heal-test.sh: the top hermetic-env exports and the capture-agent runner-journal.txt copy applied clean; the #2048 AC3 (runner journal non-empty on a forgejo-runner-swarm host) + AC4 (a ran-here fault not blamed on another pool host) scenarios appended after main's scenarios; final count 30 → 32.

Proof (this branch, offline)

  • tests/forgejo-lib-test.sh → 64 passed, 0 failed
  • tests/heal-test.sh → 32 scenarios passed
  • bash -n clean across every script (*.sh onboarding/*.sh onboarding/tests/*.sh tests/*.sh git-hooks/* git-fence)

shellcheck was not available in the preparing session; the resolution is a pure union of two individually-clean changesets (main, and the pin-based backport), each of which passed the static job in its own context — CI's shellcheck on this PR is the remaining gate.

Provenance

Prepared by the idss standing session working idss #2049 (the forward-port follow-up of idss #2048), under ADR 0174 as a two-way-door action: the branch push is inert for consumers (they pin FACTORY_REF to a SHA on main), the resolution is proven by the repo's own suites, and the merge to shared main stays human-gated by this LANDING=pr review. 🤖

Forward-port of the cheap-backport commit `7d40af3` (authored off the pin `1aba93c`) onto `main`, so dev-factory `main` HEAD carries the three machinery gaps the 2026-10-16 Forgejo-latency incident exposed (idss triage run 47257). idss's eventual main-HEAD adoption — the human-gated idss #1684 — then inherits the fix instead of silently regressing all three gaps. ### What lands - **`forgejo-lib.sh` + `tests/forgejo-lib-test.sh`** — cherry-picked cleanly (byte-identical pin→main). Bounded exponential-backoff GET retry on the public `forgejo_get` only (the #1411 API half); POSTs routed through `_forgejo_get` are never retried (a retried comment double-posts); the #20 write probe keeps its own loop on the low-level helper. - **`heal.sh` + `tests/heal-test.sh`** — manually interleaved. main's #188 (`collect_job_logs`) and #203 (healer bound) rework diverged both files, but the three code hunks themselves apply unchanged; only the surrounding insertions conflicted: - `heal.sh`: the `HEAL_WORKDIR_LOCK` + `job_ran_here` helper now sits alongside main's `collect_job_logs` (both independent helpers after `api()`); the runner-unit-detection hunk and the pool-locality `msg` branch in `gather_evidence` applied clean. - `tests/heal-test.sh`: the top hermetic-env exports and the capture-agent `runner-journal.txt` copy applied clean; the #2048 **AC3** (runner journal non-empty on a `forgejo-runner-swarm` host) + **AC4** (a ran-here fault not blamed on another pool host) scenarios appended after main's scenarios; final count 30 → 32. ### Proof (this branch, offline) - `tests/forgejo-lib-test.sh` → **64 passed, 0 failed** - `tests/heal-test.sh` → **32 scenarios passed** - `bash -n` clean across every script (`*.sh onboarding/*.sh onboarding/tests/*.sh tests/*.sh git-hooks/* git-fence`) `shellcheck` was not available in the preparing session; the resolution is a pure union of two individually-clean changesets (main, and the pin-based backport), each of which passed the `static` job in its own context — CI's shellcheck on this PR is the remaining gate. ### Provenance Prepared by the idss standing session working **idss #2049** (the forward-port follow-up of idss #2048), under ADR 0174 as a two-way-door action: the branch push is inert for consumers (they pin `FACTORY_REF` to a SHA on `main`), the resolution is proven by the repo's own suites, and the merge to shared `main` stays human-gated by this LANDING=pr review. 🤖
forgejo-lib + heal: forward-port idss #2048 onto dev-factory main
Some checks failed
ci / static (pull_request) Successful in 2m36s
ci / test (pull_request) Failing after 6m17s
bbc2d6dd90
Forward-port of the cheap-backport commit 7d40af3 (authored off the pin
1aba93c) onto main, so dev-factory `main` HEAD carries the three machinery
gaps the 2026-10-16 Forgejo-latency incident exposed — idss's eventual
main-HEAD adoption (idss #1684) then inherits the fix instead of regressing it.

forgejo-lib.sh + tests/forgejo-lib-test.sh cherry-pick cleanly (byte-identical
pin->main): bounded exponential-backoff GET retry on the public `forgejo_get`
only (the #1411 API half); POSTs through `_forgejo_get` are never retried (a
retried comment double-posts) and the #20 write probe keeps its own loop on the
low-level helper.

heal.sh + tests/heal-test.sh needed manual interleaving — main's #188
(collect_job_logs) and #203 (healer bound) rework diverged both files, but the
three code hunks themselves (the HEAL_WORKDIR_LOCK + job_ran_here helper, the
runner-unit detection off `systemctl list-units`, and the pool-locality honesty
branch in gather_evidence) apply unchanged; only the surrounding insertions
conflicted:
  - heal.sh: `job_ran_here` now sits alongside main's `collect_job_logs` (both
    independent helpers after `api()`); the unit-detection and msg hunks applied
    clean.
  - tests/heal-test.sh: the #2048 AC3 (runner journal non-empty on a
    forgejo-runner-swarm host) + AC4 (a ran-here fault not blamed elsewhere)
    scenarios appended after main's scenarios; final count 30 -> 32.

Proof (this branch, offline): `tests/forgejo-lib-test.sh` 64 passed / 0 failed;
`tests/heal-test.sh` 32 scenarios passed; `bash -n` clean across every script.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Author
Member

Live recurrence for the bounded-GET-retry half: swarm run 23495 died at stage=policy validation (#12) because policy_validate's single unretried forgejo_get "/labels?limit=100" caught a 5xx during a git.matou.nz brownout (api_http=503), 0.5 s after the issue_write_permission guard GET succeeded on the same token. Filed as #292, which also covers the attribution half this ticket does not (a failed read reported as reason=invalid-policy, and preflight_policy_gate never calling verdict_error, so the verdict carried no error line). Worth landing together.

Live recurrence for the bounded-GET-retry half: swarm run **23495** died at `stage=policy validation (#12)` because `policy_validate`'s single unretried `forgejo_get "/labels?limit=100"` caught a 5xx during a `git.matou.nz` brownout (`api_http=503`), 0.5 s after the `issue_write_permission` guard GET succeeded on the same token. Filed as #292, which also covers the attribution half this ticket does not (a failed read reported as `reason=invalid-policy`, and `preflight_policy_gate` never calling `verdict_error`, so the verdict carried no error line). Worth landing together.
Author
Member

#292 (dishonest attribution in policy_validate's label read — a transient 5xx reported as invalid-policy) landed the honest-attribution half: policy_validate now reads with curl -s -o <body> -w '%{http_code}' and returns a distinct rc 3 on a failed read (endpoint + HTTP status in the message), and preflight_policy_gate sets reason=tracker-unreachable + verdict_error on that path. It does NOT add retry — that is explicitly this ticket (#243)'s bounded GET retry. When #243 forward-ports idss #2048 onto forgejo-lib.sh, policy_validate's one /labels read should adopt the retried helper so a brief blip no longer reds the tick at all. Linked both ways (GOTCHAS 78).

#292 (dishonest attribution in `policy_validate`'s label read — a transient 5xx reported as `invalid-policy`) landed the honest-attribution half: `policy_validate` now reads with `curl -s -o <body> -w '%{http_code}'` and returns a distinct rc 3 on a failed read (endpoint + HTTP status in the message), and `preflight_policy_gate` sets `reason=tracker-unreachable` + `verdict_error` on that path. It does NOT add retry — that is explicitly this ticket (#243)'s bounded GET retry. When #243 forward-ports idss #2048 onto `forgejo-lib.sh`, `policy_validate`'s one `/labels` read should adopt the retried helper so a brief blip no longer reds the tick at all. Linked both ways (GOTCHAS 78).
Author
Member

Recurrence evidence — 2026-10-24 19:12Z Forgejo-latency incident (heal run heal-Matou-dev-factory-1792869173-3664097, signature 549306016784, healer-host matou-dev-server-01).

The same class of incident that motivated this forward-port fired again. Recording it here rather than opening a duplicate.

What the watchdog saw: api_http=000 api_seconds=timeout api_curl_exit=28 — the single-shot probe_api against /actions/tasks?limit=1&page=1 hit --max-time 35 with no response.

Independent corroboration (runner journal, matou-dev-server-01): 78 503 Service Unavailable lines from 18:47:03Z to 19:03:01Z (~16 min) on ReportState / ReportLog / final-log upload, plus two UpdateLog ... context deadline exceeded at 18:47:50Z and 19:02:04Z, spanning task_ids 247515/247518/247519/247542. The runner kept claiming tasks throughout and runs continued to succeed, so the remote instance was degraded, not down.

Self-healed: by 19:1xZ the probe endpoint answered 200. Live re-probes from the same host during triage:

endpoint samples
/api/v1/version 1.08s, 0.85s, 0.73s (200)
/actions/tasks?limit=1&page=1 (the probe URL) 18.43s, 2.34s, 1.34s, 1.30s, 5.72s, 1.36s (all 200)

git.matou.nz resolves to 143.198.134.168 — remote to the swarm pool, so nothing on the pool host is the cause.

Why this strengthens the case for the bounded-retry half: the probe endpoint's own baseline is ~1.3s but it spikes to 18.4s unloaded — more than half the 30s unhealthy threshold on a healthy server. A single-shot probe with no retry therefore converts any brief remote blip into a full heal session. This is the second forgejo-api ledger entry on this host in three days (prior: 4421c7ee6160, 2026-10-21 04:41Z, attempts=1, repaired=0), and neither was repairable — both were the remote instance.

No repair was made and no code was touched; the healer classified this transient-external.

**Recurrence evidence — 2026-10-24 19:12Z Forgejo-latency incident** (heal run `heal-Matou-dev-factory-1792869173-3664097`, signature `549306016784`, healer-host `matou-dev-server-01`). The same class of incident that motivated this forward-port fired again. Recording it here rather than opening a duplicate. **What the watchdog saw:** `api_http=000 api_seconds=timeout api_curl_exit=28` — the single-shot `probe_api` against `/actions/tasks?limit=1&page=1` hit `--max-time 35` with no response. **Independent corroboration (runner journal, `matou-dev-server-01`):** 78 `503 Service Unavailable` lines from **18:47:03Z to 19:03:01Z** (~16 min) on `ReportState` / `ReportLog` / final-log upload, plus two `UpdateLog ... context deadline exceeded` at 18:47:50Z and 19:02:04Z, spanning task_ids 247515/247518/247519/247542. The runner kept claiming tasks throughout and runs continued to succeed, so the remote instance was degraded, not down. **Self-healed:** by 19:1xZ the probe endpoint answered 200. Live re-probes from the same host during triage: | endpoint | samples | |---|---| | `/api/v1/version` | 1.08s, 0.85s, 0.73s (200) | | `/actions/tasks?limit=1&page=1` (the probe URL) | 18.43s, 2.34s, 1.34s, 1.30s, 5.72s, 1.36s (all 200) | `git.matou.nz` resolves to 143.198.134.168 — remote to the swarm pool, so nothing on the pool host is the cause. **Why this strengthens the case for the bounded-retry half:** the probe endpoint's own baseline is ~1.3s but it spikes to 18.4s unloaded — **more than half the 30s unhealthy threshold on a healthy server**. A single-shot probe with no retry therefore converts any brief remote blip into a full heal session. This is the **second** `forgejo-api` ledger entry on this host in three days (prior: `4421c7ee6160`, 2026-10-21 04:41Z, attempts=1, repaired=0), and neither was repairable — both were the remote instance. No repair was made and no code was touched; the healer classified this `transient-external`.
Some checks failed
ci / static (pull_request) Successful in 2m36s
ci / test (pull_request) Failing after 6m17s
This pull request has changes conflicting with the target branch.
  • heal.sh
  • tests/heal-test.sh
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin forward-port/idss-2048:forward-port/idss-2048
git switch forward-port/idss-2048

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff forward-port/idss-2048
git switch forward-port/idss-2048
git rebase main
git switch main
git merge --ff-only forward-port/idss-2048
git switch forward-port/idss-2048
git rebase main
git switch main
git merge --no-ff forward-port/idss-2048
git switch main
git merge --squash forward-port/idss-2048
git switch main
git merge --ff-only forward-port/idss-2048
git switch main
git merge forward-port/idss-2048
git push origin main
Sign in to join this conversation.
No reviewers
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!243
No description provided.