Forgejo /actions/runs hangs >60 s on the big repos — move any harness reader to /actions/tasks and record it in GOTCHAS #28

Closed
opened 2026-08-23 03:27:32 +00:00 by matou-build-agent · 2 comments

Symptom (2026-08-22)

GET /api/v1/repos/Matou/idss/actions/runs?limit=N (8,900+ runs) and the same on dev-factory no longer answer inside 60 s from either the workstation or a laptop (curl -m 60 → code 000). GET …/actions/tasks?limit=100&page=N answers in <1 s and carries the same per-job rows (created_at, run_started_at, updated_at, status, name) — it is what this review used.

Ask

  1. Audit the harness for readers of /actions/runs (schedule-backstop.sh, heal.sh's runs.json evidence, forgejo-lib.sh, the TUI if it reads runs) and switch them to /actions/tasks, keeping the -m timeouts so a future hang reds loudly instead of stalling a tick.
  2. GOTCHAS entry: the runs endpoint scales with the repo's run history and the swarm creates ~150 runs/hour under a label storm; tasks is the paginated, indexed view.
  3. Separately for Ben (ready-for-session, not harness): Forgejo's action-run retention / actions.ARTIFACT_RETENTION_DAYS-style cleanup on git.matou.nz, or a periodic delete of old runs, so the endpoint recovers.

Note Matou/ourcloud 301-redirects to Matou/idss — any script still naming ourcloud follows a redirect per call.

Evidence: this review's probes (60 s timeouts on runs, sub-second tasks), /tmp/matou-heal-Matou-idss.*/api-timing.txt on the workstation.

## Symptom (2026-08-22) `GET /api/v1/repos/Matou/idss/actions/runs?limit=N` (8,900+ runs) and the same on dev-factory no longer answer inside 60 s from either the workstation or a laptop (`curl -m 60` → code 000). `GET …/actions/tasks?limit=100&page=N` answers in <1 s and carries the same per-job rows (`created_at`, `run_started_at`, `updated_at`, `status`, `name`) — it is what this review used. ## Ask 1. Audit the harness for readers of `/actions/runs` (`schedule-backstop.sh`, `heal.sh`'s `runs.json` evidence, `forgejo-lib.sh`, the TUI if it reads runs) and switch them to `/actions/tasks`, keeping the `-m` timeouts so a future hang reds loudly instead of stalling a tick. 2. GOTCHAS entry: the `runs` endpoint scales with the repo's run history and the swarm creates ~150 runs/hour under a label storm; `tasks` is the paginated, indexed view. 3. Separately for Ben (ready-for-session, not harness): Forgejo's action-run retention / `actions.ARTIFACT_RETENTION_DAYS`-style cleanup on git.matou.nz, or a periodic delete of old runs, so the endpoint recovers. Note `Matou/ourcloud` 301-redirects to `Matou/idss` — any script still naming `ourcloud` follows a redirect per call. Evidence: this review's probes (60 s timeouts on `runs`, sub-second `tasks`), `/tmp/matou-heal-Matou-idss.*/api-timing.txt` on the workstation.
Author
Member

Scoping note from the filer: a grep of the harness shows no API reader of /actions/runs left — schedule-backstop.sh:64 and heal.sh:95,98 already read /actions/tasks, and the only actions/runs strings are the RUN_URL web links in the workflows (.../actions/runs/${{ github.run_number }}), which are fine. So part 1 reduces to a guard: add the endpoint to GOTCHAS so nobody reintroduces it, and keep the -m timeouts. Part 3 (retention on git.matou.nz) is the substantive half.

Scoping note from the filer: a grep of the harness shows **no API reader of `/actions/runs` left** — `schedule-backstop.sh:64` and `heal.sh:95,98` already read `/actions/tasks`, and the only `actions/runs` strings are the `RUN_URL` web links in the workflows (`.../actions/runs/${{ github.run_number }}`), which are fine. So part 1 reduces to a guard: add the endpoint to GOTCHAS so nobody reintroduces it, and keep the `-m` timeouts. Part 3 (retention on git.matou.nz) is the substantive half.
Author
Member

Close report — #28

Ruled by agent under ADR 0174 — veto anytime. Landed in cef7670 on main, root-only.

1. Audit: clean, and the audit itself is now a ratchet

The filer's scoping comment was right — no harness reader of /actions/runs was left. Confirmed by a full sweep of every .sh/.mts/.yml/.tmpl in the repo:

Reader Endpoint Timeout
schedule-backstop.sh:64 /actions/tasks?limit=50&page=1 --max-time 30 ✅
heal.sh:127,130 /actions/tasks?limit=1&page=1, ?limit=50&page=1 --max-time 35 / 30 ✅
claim-lib.sh:70 /actions/tasks?limit=100&page=1 none ❌
workflows' RUN_URL <server>/<repo>/actions/runs/<n> browser link, not an API read — fine

The TUI reads no Forgejo Actions endpoint at all (main.mts has no actions reference; it reads swarm.db and logs). heal-lib.sh names actions/tasks only in a comment — it parses the payload heal.sh fetched and owns no curl.

So the ticket's live content was its second clause, "keeping the -m timeouts so a future hang reds loudly instead of stalling a tick" — and that is exactly where the gap sat.

2. The real defect: the hottest read in the harness had no timeout

claim-lib.sh's _claim_api (and claim_mark_working's label-write curl) carried no --max-time, while schedule-backstop.sh, heal.sh and forgejo-lib.sh all use 30 s. That read is limit=100, once per claim and once per janitor sweep — the harness's hottest API call. Against a forge that accepts the socket and never answers, an untimed curl does not RED a tick, it stalls one: the claim never returns, the run keeps holding its host-capacity slot, and nothing on the ticket ever says why. Precisely the failure mode this ticket exists to prevent, one endpoint over.

Both call sites now carry --max-time "$CLAIM_API_MAX_TIME" (default 30, overridable). A timeout lands on paths that already existed:

  • readers return rc-nonzero — never the degraded [] of the 2026-08-11 review finding 1;
  • the label write's -w '%{http_code}' idiom reads curl's 000, which falls down #20's page-loudly non-2xx branch instead of being mistaken for success.

3. The ratchet — tests/actions-endpoint-test.sh (new)

Three conditions, scanned over the harness directory non-recursively so it covers the same surface in this root and in a consumer's vendored .sandcastle/ (#23's standalone rule):

  1. no script READS /actions/runs (comment lines exempt — the hazard has to be explainable next to the code it constrains);
  2. every /actions/tasks read carries page=1 (Forgejo ignores limit without it and dumps the whole table — the 2026-07-30 healer blindness, the same failure one size down);
  3. every fetching script bounds its curl.

Proven to work standalone in a consumer-shaped tree: run against the vendored .sandcastle/ copy (no docs/, no onboarding/) it correctly REDs the pre-fix claim-lib.sh at the old pin, and passes conditions 1 and 2.

4. GOTCHAS 16

Records the symptom (both hosts' 60 s 000 probes vs sub-second tasks), the cause (runs is a whole-history listing, tasks the paginated indexed per-job view, against a swarm minting ~150 runs/hour under a label storm — #26/#38's 71+73 no-op jobs in one hour), and the rule (tasks + paged + --max-time), noting that the RUN_URL web link is unaffected.

5. Two stale pointers the ticket named

  • heal.sh's comment cited docs/research/2026-07-30-forgejo-actions-tasks-api.md — no such file in this repo; it did not come across in the ADR 0180 extraction. Re-pointed at GOTCHAS 16 (the house style for vendored files — cf. landing-lib.sh, provision-lib.sh).
  • Matou/ourcloud → Matou/idss: the only surviving mentions are in test comments and in two ratchets that deliberately forbid the token. Fixed the one real citation (onboarding/tests/host-state-lib-test.sh naming Matou/ourcloud#577). No script makes an API call naming ourcloud — nothing follows a redirect today.

6. Part 3 — NOT done, and never a two-way door → #40 ready-for-human

Retention / cleanup on git.matou.nz needs root on the forge host, an instance-wide [actions] app.ini change plus a restart, and/or deleting three repos' CI history. That is a credential door, a security-posture change and data destruction — all three reserved for a human by ADR 0174 rule 2. Filed as #40 with the ask, the ## Why human note, and the probe to re-run afterwards:

curl -m 60 -o /dev/null -w '%{http_code} %{time_total}\n' \
  -H "Authorization: token $FORGEJO_TOKEN" "$FORGEJO_API/actions/runs?limit=10"

STATUS.md's "Blocked on Ben" section names it, with the note that nothing in the harness waits on it.

Proof

  • Red before green: the new claim-lib cases failed 6/6 and the ratchet failed exactly on claim-lib.sh before the fix; both green after.
  • tests/claim-lib-test.sh 33 → 40 cases (timeout on every call, the CLAIM_API_MAX_TIME override, the 30 s default, a timed-out read rc-nonzero, a timed-out claim post rc-nonzero, the 000 label write paging loudly).
  • tests/fakebin/curl gains an argv.log (so a test can assert a caller's FLAGS, not just its URL), explicit -m|--max-time consumption — the generic -*) shift arm was leaving the bare number to be read as the URL — and an api-timeout seam.
  • Full offline suite green, 65 files (was 64), before and after.

Residue

Root-only. A human re-vendor (onboard.sh vendor .sandcastle <sha>) carries claim-lib.sh + the new test to this repo's own running copy (GOTCHAS 4); idss and matou-app pick both up at their next FACTORY_REF bump — until then their vendored claim-lib.sh is still untimed.

## Close report — #28 Ruled by agent under ADR 0174 — veto anytime. Landed in `cef7670` on `main`, root-only. ### 1. Audit: clean, and the audit itself is now a ratchet The filer's scoping comment was right — no harness reader of `/actions/runs` was left. Confirmed by a full sweep of every `.sh`/`.mts`/`.yml`/`.tmpl` in the repo: | Reader | Endpoint | Timeout | |---|---|---| | `schedule-backstop.sh:64` | `/actions/tasks?limit=50&page=1` | `--max-time 30` ✅ | | `heal.sh:127,130` | `/actions/tasks?limit=1&page=1`, `?limit=50&page=1` | `--max-time 35` / `30` ✅ | | `claim-lib.sh:70` | `/actions/tasks?limit=100&page=1` | **none** ❌ | | workflows' `RUN_URL` | `<server>/<repo>/actions/runs/<n>` | browser link, not an API read — fine | The TUI reads no Forgejo Actions endpoint at all (`main.mts` has no `actions` reference; it reads `swarm.db` and logs). `heal-lib.sh` names `actions/tasks` only in a comment — it parses the payload `heal.sh` fetched and owns no curl. So the ticket's live content was its second clause, **"keeping the `-m` timeouts so a future hang reds loudly instead of stalling a tick"** — and that is exactly where the gap sat. ### 2. The real defect: the hottest read in the harness had no timeout `claim-lib.sh`'s `_claim_api` (and `claim_mark_working`'s label-write curl) carried no `--max-time`, while `schedule-backstop.sh`, `heal.sh` and `forgejo-lib.sh` all use 30 s. That read is `limit=100`, once per claim **and** once per janitor sweep — the harness's hottest API call. Against a forge that accepts the socket and never answers, an untimed curl does not RED a tick, it **stalls** one: the claim never returns, the run keeps holding its host-capacity slot, and nothing on the ticket ever says why. Precisely the failure mode this ticket exists to prevent, one endpoint over. Both call sites now carry `--max-time "$CLAIM_API_MAX_TIME"` (default `30`, overridable). A timeout lands on paths that already existed: - readers return rc-nonzero — never the degraded `[]` of the 2026-08-11 review finding 1; - the label write's `-w '%{http_code}'` idiom reads curl's `000`, which falls down #20's page-loudly non-2xx branch instead of being mistaken for success. ### 3. The ratchet — `tests/actions-endpoint-test.sh` (new) Three conditions, scanned over the harness directory non-recursively so it covers the same surface in this root **and** in a consumer's vendored `.sandcastle/` (#23's standalone rule): 1. no script READS `/actions/runs` (comment lines exempt — the hazard has to be explainable next to the code it constrains); 2. every `/actions/tasks` read carries `page=1` (Forgejo ignores `limit` without it and dumps the whole table — the 2026-07-30 healer blindness, the same failure one size down); 3. every fetching script bounds its curl. Proven to work standalone in a consumer-shaped tree: run against the vendored `.sandcastle/` copy (no `docs/`, no `onboarding/`) it correctly REDs the pre-fix `claim-lib.sh` at the old pin, and passes conditions 1 and 2. ### 4. GOTCHAS 16 Records the symptom (both hosts' 60 s `000` probes vs sub-second `tasks`), the cause (`runs` is a whole-history listing, `tasks` the paginated indexed per-job view, against a swarm minting ~150 runs/hour under a label storm — #26/#38's 71+73 no-op jobs in one hour), and the rule (tasks + paged + `--max-time`), noting that the `RUN_URL` web link is unaffected. ### 5. Two stale pointers the ticket named - `heal.sh`'s comment cited `docs/research/2026-07-30-forgejo-actions-tasks-api.md` — **no such file in this repo**; it did not come across in the ADR 0180 extraction. Re-pointed at GOTCHAS 16 (the house style for vendored files — cf. `landing-lib.sh`, `provision-lib.sh`). - `Matou/ourcloud` → `Matou/idss`: the only surviving mentions are in test comments and in two ratchets that deliberately forbid the token. Fixed the one real citation (`onboarding/tests/host-state-lib-test.sh` naming `Matou/ourcloud#577`). **No script makes an API call naming `ourcloud`** — nothing follows a redirect today. ### 6. Part 3 — NOT done, and never a two-way door → #40 `ready-for-human` Retention / cleanup on `git.matou.nz` needs root on the forge host, an instance-wide `[actions]` app.ini change plus a restart, and/or deleting three repos' CI history. That is a credential door, a security-posture change and data destruction — all three reserved for a human by ADR 0174 rule 2. Filed as **#40** with the ask, the `## Why human` note, and the probe to re-run afterwards: ``` curl -m 60 -o /dev/null -w '%{http_code} %{time_total}\n' \ -H "Authorization: token $FORGEJO_TOKEN" "$FORGEJO_API/actions/runs?limit=10" ``` `STATUS.md`'s "Blocked on Ben" section names it, with the note that **nothing in the harness waits on it**. ### Proof - Red before green: the new claim-lib cases failed 6/6 and the ratchet failed exactly on `claim-lib.sh` before the fix; both green after. - `tests/claim-lib-test.sh` 33 → 40 cases (timeout on every call, the `CLAIM_API_MAX_TIME` override, the 30 s default, a timed-out read rc-nonzero, a timed-out claim post rc-nonzero, the `000` label write paging loudly). - `tests/fakebin/curl` gains an `argv.log` (so a test can assert a caller's FLAGS, not just its URL), explicit `-m|--max-time` consumption — the generic `-*) shift` arm was leaving the bare number to be read as the URL — and an `api-timeout` seam. - Full offline suite green, 65 files (was 64), before and after. ### Residue Root-only. A human re-vendor (`onboard.sh vendor .sandcastle <sha>`) carries `claim-lib.sh` + the new test to this repo's own running copy (GOTCHAS 4); idss and matou-app pick both up at their next `FACTORY_REF` bump — until then their vendored `claim-lib.sh` is still untimed.
matou-build-agent 2026-08-23 20:02:29 +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/dev-factory#28
No description provided.