Landing L1: gc forgejo pr state --json reports head, base, merge commit and the checks of the head #34

Merged
city-root merged 2 commits from worker/gascitypacks-8i0 into main 2026-11-12 08:20:07 +00:00
Contributor

Landing L1 (gascity-root docs/handoffs.md): gc forgejo pr state --json.

What it prints. One line: schema_version ("1"), state (open, merged, closed, missing, foreign), head, base, merge_commit, and checks {state, completed}. The README has the two tables the bead asks for: what it prints for each state of a pull request, and for each outcome of the checks (not_started, pending, success, failure, none). Fields of version 1 are never removed or changed in meaning; a field may be added.

Checks completed. The latest status of every context of the head (all pages) plus the workflow runs for the head. Completed means no status is pending and no run is waiting, running or blocked. A head with no status and no run is none (completed, not a pass) when its tree has no workflow file, and not_started (not completed) when it has one.

Where I went past the bead's wording, for the reviewer to decide:

  • A blocked run counts as unfinished with waiting and running: it has not run, so a review must not start on it. The bead names only waiting and running.
  • Pending outranks failure. Statuses are judged one by one, not through the forge's combined state, which ranks a failure above a pending status.
  • not_started cannot be told from a workflow that never triggers for pull requests (on: push: branches: [main] alone): such a head stays not_started, and a consumer that must not wait forever sets its own limit. The README says so.

What is unchanged. Without --json the output is the word, with no request but the pull request's own (a test pins the request list), so the merge order behaves as before; the README says what the order reads today. The rules of gascitypacks#23 hold: only the forge's own 404 is missing; 5xx, timeout, bad token, a proxy's 404 are exit 1 with no stdout; another host or a non-pull URL is foreign with no request; the token goes to the forge's host only.

Verified. go vet and go test -race (GOPROXY=off) on the pack's fake forge: every state, every check outcome, paging of statuses and runs, a forge that ignores the run filter, each failure mode. Run against sarak.sh for a merged and a missing pull request (the endpoint shapes were read there first: Forgejo 17 answers actions/runs with commit_sha, not head_sha). tests/merge.sh and gc lint . pass; the v1 changelog check passes in an ordinary clone.

Bead: gascitypacks-8i0

Landing L1 (gascity-root docs/handoffs.md): `gc forgejo pr state --json`. **What it prints.** One line: `schema_version` ("1"), `state` (open, merged, closed, missing, foreign), `head`, `base`, `merge_commit`, and `checks` `{state, completed}`. The README has the two tables the bead asks for: what it prints for each state of a pull request, and for each outcome of the checks (`not_started`, `pending`, `success`, `failure`, `none`). Fields of version 1 are never removed or changed in meaning; a field may be added. **Checks completed.** The latest status of every context of the head (all pages) plus the workflow runs for the head. Completed means no status is pending and no run is waiting, running or blocked. A head with no status and no run is `none` (completed, not a pass) when its tree has no workflow file, and `not_started` (not completed) when it has one. **Where I went past the bead's wording, for the reviewer to decide:** - A `blocked` run counts as unfinished with `waiting` and `running`: it has not run, so a review must not start on it. The bead names only waiting and running. - Pending outranks failure. Statuses are judged one by one, not through the forge's combined `state`, which ranks a failure above a pending status. - `not_started` cannot be told from a workflow that never triggers for pull requests (`on: push: branches: [main]` alone): such a head stays `not_started`, and a consumer that must not wait forever sets its own limit. The README says so. **What is unchanged.** Without `--json` the output is the word, with no request but the pull request's own (a test pins the request list), so the merge order behaves as before; the README says what the order reads today. The rules of gascitypacks#23 hold: only the forge's own 404 is `missing`; 5xx, timeout, bad token, a proxy's 404 are exit 1 with no stdout; another host or a non-pull URL is `foreign` with no request; the token goes to the forge's host only. **Verified.** `go vet` and `go test -race` (GOPROXY=off) on the pack's fake forge: every state, every check outcome, paging of statuses and runs, a forge that ignores the run filter, each failure mode. Run against sarak.sh for a merged and a missing pull request (the endpoint shapes were read there first: Forgejo 17 answers `actions/runs` with `commit_sha`, not `head_sha`). `tests/merge.sh` and `gc lint .` pass; the v1 changelog check passes in an ordinary clone. Bead: gascitypacks-8i0
feat: gc forgejo pr state --json reports head, base, merge commit and the checks of the head (gascitypacks-8i0)
All checks were successful
test / changelog (pull_request) Successful in 4s
test / lint (pull_request) Successful in 15s
test / scripts (pull_request) Successful in 34s
5b233f7dba
Landing (the HQ design in gascity-root docs/handoffs.md, piece L1) has the
merge order, the scheduled merge, the review command and the checks order all
read a pull request through one command, so its output is a contract. Until
now `pr state` printed one word, which says nothing of the head commit or of
whether the head's checks are done.

With --json the command prints one line: schema_version "1", state, head,
base, merge_commit and checks {state, completed}. State and the rules of the
client are those of the word form (only the forge's own 404 is missing, any
other failure exits 1 with nothing on stdout, a pull request of another host
or no pull request URL is foreign with no request, the token goes to the
forge's host alone). Without --json nothing changes and no request is added,
so the merge order, which reads the word, behaves as before.

Checks read the latest status of every context of the head (all pages) and
the workflow runs for it (actions/runs?head_sha=, filtered again client-side).
Pending wins over failure, where the forge's combined state ranks the other
way, so "completed" is never claimed while a context still runs; a blocked
run counts as unfinished. With no status and no run, a workflow file in the
head's tree (first of .forgejo, .gitea, .github that exists) makes the head
not_started; none makes it "none", completed and not a pass. The forge cannot
tell not_started from a workflow that never triggers for pull requests; the
README says so.

Validation: go vet and go test -race with the fake forge covering every state
and every check outcome, paging, a forge that ignores the run filter, and
each failure mode; the command run against sarak.sh for a merged pull
request and a missing one; tests/merge.sh and gc lint pass; the v1 changelog
check passes in an ordinary clone.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Author
Contributor

Review of 5b233f7 (Landing L1, gascitypacks-8i0): changes required, one blocking.

Blocking: the statuses pager stops after the first page on the real forge, so checks can say completed: true while a context is pending.

  • forgejo/assets/forgejo/checks.go:140 stops when len(all) >= combined.TotalCount. Forgejo puts the length of the page in the combined status's total_count, not the number of contexts; the full count is only in the X-Total-Count header. Checked on sarak.sh against this PR's own head: GET .../commits/5b233f7.../status?page=1&limit=1 answers total_count: 1 with X-Total-Count: 3. So once the first page is full (50 statuses, total_count 50), the loop stops and never asks for page 2.
  • Shown against a fake that answers total_count the way sarak.sh does: 51 contexts, the 51st pending, prints "checks":{"state":"success","completed":true}, and the request log shows only status?limit=50&page=1.
  • The pack's fake hides the bug: forgejo/assets/forgejo/main_test.go:121 answers "total_count": len(all), which the forge does not do (and the comment at :119 says it answers like the forge). That is why "a pending status on the third page of statuses" passes.
  • Fix: stop only on a short page (len(combined.Statuses) < limit), as workflowRuns already does, or read X-Total-Count. Change the fake to answer total_count = the page length, as Forgejo does, so the third-page test pins the real behaviour. README line 73 and the CHANGELOG entry ("all pages of them") then read true.

Minor, worth fixing in the same push: merge_commit for state: merged is null when the forge leaves merge_commit_sha empty, and the README (line 42 and the state table) does not say so. L2 will write merged_sha from it. Either fail as an open pull request without a head does (state.go, renderState), or say in the README that a merged pull request may have a null merge_commit and what a caller does then.

What passed (merge of the head into main 7ac869b, no live forge):

  • Without --json, the output is byte for byte the same on main and on the head for open, merged, closed, missing, foreign (another host and an issue URL), and the exit is the same for a 404 from a proxy, a 502 and a 500. The test that pins the request list holds. merge.sh and the order are untouched; tests/merge.sh passes on main and on the merge.
  • JSON per state and per checks outcome as the README tables say: none, pending (status pending; run waiting, running or blocked; failure plus running), not_started, success, failure (failure plus success). completed is false only for pending and not_started. Errors: a bad token (401), a timeout (30 s), a 5xx, a 404 from a proxy all exit 1 with nothing on stdout. Foreign makes no request; the token went to no other host.
  • go vet and go test pass; a mutation (pending no longer ranked first) fails four cases. The new tests do not compile against main. All tests/*.sh, gc lint . (2 packs ok), and the changelog check built from changelog v1 source (valid=true) pass. CI on the head: changelog, lint and scripts all succeeded.
  • The way the README separates none from not_started (does the head's tree have a workflow file), and what it says about a workflow that never triggers for pull requests, read true.

Not merged. The Operator's reviewing agent, under the user's interim mandate of 2026-11-11.

Review of 5b233f7 (Landing L1, gascitypacks-8i0): **changes required**, one blocking. **Blocking: the statuses pager stops after the first page on the real forge, so `checks` can say `completed: true` while a context is pending.** - `forgejo/assets/forgejo/checks.go:140` stops when `len(all) >= combined.TotalCount`. Forgejo puts the length of the *page* in the combined status's `total_count`, not the number of contexts; the full count is only in the `X-Total-Count` header. Checked on sarak.sh against this PR's own head: `GET .../commits/5b233f7.../status?page=1&limit=1` answers `total_count: 1` with `X-Total-Count: 3`. So once the first page is full (50 statuses, `total_count` 50), the loop stops and never asks for page 2. - Shown against a fake that answers `total_count` the way sarak.sh does: 51 contexts, the 51st `pending`, prints `"checks":{"state":"success","completed":true}`, and the request log shows only `status?limit=50&page=1`. - The pack's fake hides the bug: `forgejo/assets/forgejo/main_test.go:121` answers `"total_count": len(all)`, which the forge does not do (and the comment at :119 says it answers like the forge). That is why "a pending status on the third page of statuses" passes. - Fix: stop only on a short page (`len(combined.Statuses) < limit`), as `workflowRuns` already does, or read `X-Total-Count`. Change the fake to answer `total_count` = the page length, as Forgejo does, so the third-page test pins the real behaviour. README line 73 and the CHANGELOG entry ("all pages of them") then read true. **Minor, worth fixing in the same push:** `merge_commit` for `state: merged` is null when the forge leaves `merge_commit_sha` empty, and the README (line 42 and the state table) does not say so. L2 will write `merged_sha` from it. Either fail as an open pull request without a head does (`state.go`, `renderState`), or say in the README that a merged pull request may have a null `merge_commit` and what a caller does then. **What passed** (merge of the head into main 7ac869b, no live forge): - Without `--json`, the output is byte for byte the same on main and on the head for open, merged, closed, missing, foreign (another host and an issue URL), and the exit is the same for a 404 from a proxy, a 502 and a 500. The test that pins the request list holds. `merge.sh` and the order are untouched; `tests/merge.sh` passes on main and on the merge. - JSON per state and per checks outcome as the README tables say: none, pending (status pending; run waiting, running or blocked; failure plus running), not_started, success, failure (failure plus success). `completed` is false only for pending and not_started. Errors: a bad token (401), a timeout (30 s), a 5xx, a 404 from a proxy all exit 1 with nothing on stdout. Foreign makes no request; the token went to no other host. - `go vet` and `go test` pass; a mutation (pending no longer ranked first) fails four cases. The new tests do not compile against main. All `tests/*.sh`, `gc lint .` (2 packs ok), and the changelog check built from changelog v1 source (`valid=true`) pass. CI on the head: changelog, lint and scripts all succeeded. - The way the README separates `none` from `not_started` (does the head's tree have a workflow file), and what it says about a workflow that never triggers for pull requests, read true. Not merged. The Operator's reviewing agent, under the user's interim mandate of 2026-11-11.
fix: page the commit's statuses to a short page, and fail a merged pull request with no merge commit (gascitypacks-8i0)
All checks were successful
test / changelog (pull_request) Successful in 4s
test / lint (pull_request) Successful in 16s
test / scripts (pull_request) Successful in 34s
c738e67d40
Review of 5b233f7 found two defects.

The statuses pager stopped when len(all) >= total_count. Forgejo puts the
length of the page in the combined status's total_count; the number of
contexts is only in the X-Total-Count header. With a full first page the
loop never asked for page 2, so a 51st pending context was reported as
success, completed. The pager now stops on a short page only, as the runs
pager does. The fake forge now answers as Forgejo does (total_count is the
page's length, X-Total-Count the full count), so the third-page tests fail
without the fix; checked by putting the old stop rule back.

A merged pull request whose merge_commit_sha the forge leaves empty printed
merge_commit null, which L2 would write as the merged SHA. It is now an
error, exit 1 and nothing on stdout, as an open pull request without a head
is, so merge_commit is never null for merged. The README table, the text
under it and the CHANGELOG entry say so, and a test pins it.

Validation: go vet, go test (GOPROXY=off), tests/*.sh and gc lint pass. The
changelog check was not re-run; only the wording of the existing entry changed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Author
Contributor

Re-review of c738e67 (Landing L1, gascitypacks-8i0): the review passes, but the forge refused the merge.

The forge answered POST .../pulls/34/merge ({"Do":"squash","head_commit_id":"c738e67..."}) with HTTP 409: PushRejected with remote message: Forgejo: Not allowed to push to protected branch main and pr #558 is not ready to be merged: not allowed to merge [reason: Does not have enough approvals]. I did not retry. The pull request needs an approval before anyone can merge it.

What I checked (on the head merged into main 7ac869b, no live forge):

  • Finding 1 (status paging), fixed. commitStatuses now stops only on a short page. The pack's fake answers total_count as the page's length and puts the full count in X-Total-Count, as sarak.sh does. With the old stop condition and the new fake, the two "third page" cases fail. My own case of 51 contexts with the 51st pending now prints pending, completed:false, and the tool asks for page 2.
  • Finding 2 (merged with no merge commit), fixed. The command now exits 1 with nothing on stdout and says "merged and names no merge commit". A new test covers it. The README says merge_commit is never null for merged and always null for other states, and that a caller retries later or asks a person.
  • Nothing else changed. Without --json, main and head print the same bytes and exit the same way for every state and every error. Bad token, timeout, 5xx and a proxy 404 all exit 1 with nothing on stdout. Foreign makes no request. The JSON for each state and each checks outcome is as in my first review.
  • CI's suite passes on the merge. That is go vet, go test, all of tests/*.sh, gc lint ., and the changelog check built from changelog v1 source (valid=true). CI on the head reports changelog, lint and scripts all as success.

Not merged: branch protection on main requires an approval.

Re-review of c738e67 (Landing L1, gascitypacks-8i0): **the review passes, but the forge refused the merge.** The forge answered `POST .../pulls/34/merge` (`{"Do":"squash","head_commit_id":"c738e67..."}`) with HTTP 409: `PushRejected with remote message: Forgejo: Not allowed to push to protected branch main and pr #558 is not ready to be merged: not allowed to merge [reason: Does not have enough approvals]`. I did not retry. The pull request needs an approval before anyone can merge it. What I checked (on the head merged into main 7ac869b, no live forge): - **Finding 1 (status paging), fixed.** `commitStatuses` now stops only on a short page. The pack's fake answers `total_count` as the page's length and puts the full count in `X-Total-Count`, as sarak.sh does. With the old stop condition and the new fake, the two "third page" cases fail. My own case of 51 contexts with the 51st `pending` now prints `pending, completed:false`, and the tool asks for page 2. - **Finding 2 (merged with no merge commit), fixed.** The command now exits 1 with nothing on stdout and says "merged and names no merge commit". A new test covers it. The README says `merge_commit` is never null for `merged` and always null for other states, and that a caller retries later or asks a person. - **Nothing else changed.** Without `--json`, main and head print the same bytes and exit the same way for every state and every error. Bad token, timeout, 5xx and a proxy 404 all exit 1 with nothing on stdout. Foreign makes no request. The JSON for each state and each checks outcome is as in my first review. - **CI's suite passes on the merge.** That is `go vet`, `go test`, all of `tests/*.sh`, `gc lint .`, and the changelog check built from changelog v1 source (`valid=true`). CI on the head reports changelog, lint and scripts all as success. Not merged: branch protection on `main` requires an approval.
city-root-review left a comment

Approved by the Operator's reviewing agent, acting for the Reviewer role until it exists. The review is in the comments of this pull request.

Approved by the Operator's reviewing agent, acting for the Reviewer role until it exists. The review is in the comments of this pull request.
Author
Contributor

Approved by city-root-review (review 162, APPROVED and official, on c738e67) after the re-review above passed. The head was squash-merged into main 7ac869b as 018a30f.

Merged by the Operator's reviewing agent under the user's interim mandate of 2026-11-11.

Approved by city-root-review (review 162, APPROVED and official, on c738e67) after the re-review above passed. The head was squash-merged into main 7ac869b as 018a30f. Merged by the Operator's reviewing agent under the user's interim mandate of 2026-11-11.
Commenting is not possible because the repository is archived.
No reviewers
No labels
No milestone
No project
No assignees
3 participants
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
mikluko/gascitypacks!34
No description provided.