Landing L1: gc forgejo pr state --json reports head, base, merge commit and the checks of the head #34
No reviewers
Labels
No labels
No milestone
No project
No assignees
3 participants
Due date
No due date set.
Dependencies
No dependencies set
Reference
mikluko/gascitypacks!34
Loading…
Reference in a new issue
No description provided.
Delete branch "worker/gascitypacks-8i0"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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, andchecks{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, andnot_started(not completed) when it has one.Where I went past the bead's wording, for the reviewer to decide:
blockedrun counts as unfinished withwaitingandrunning: it has not run, so a review must not start on it. The bead names only waiting and running.state, which ranks a failure above a pending status.not_startedcannot be told from a workflow that never triggers for pull requests (on: push: branches: [main]alone): such a head staysnot_started, and a consumer that must not wait forever sets its own limit. The README says so.What is unchanged. Without
--jsonthe 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 ismissing; 5xx, timeout, bad token, a proxy's 404 are exit 1 with no stdout; another host or a non-pull URL isforeignwith no request; the token goes to the forge's host only.Verified.
go vetandgo 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 answersactions/runswithcommit_sha, nothead_sha).tests/merge.shandgc lint .pass; the v1 changelog check passes in an ordinary clone.Bead: gascitypacks-8i0
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>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
checkscan saycompleted: truewhile a context is pending.forgejo/assets/forgejo/checks.go:140stops whenlen(all) >= combined.TotalCount. Forgejo puts the length of the page in the combined status'stotal_count, not the number of contexts; the full count is only in theX-Total-Countheader. Checked on sarak.sh against this PR's own head:GET .../commits/5b233f7.../status?page=1&limit=1answerstotal_count: 1withX-Total-Count: 3. So once the first page is full (50 statuses,total_count50), the loop stops and never asks for page 2.total_countthe way sarak.sh does: 51 contexts, the 51stpending, prints"checks":{"state":"success","completed":true}, and the request log shows onlystatus?limit=50&page=1.forgejo/assets/forgejo/main_test.go:121answers"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.len(combined.Statuses) < limit), asworkflowRunsalready does, or readX-Total-Count. Change the fake to answertotal_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_commitforstate: mergedis null when the forge leavesmerge_commit_shaempty, and the README (line 42 and the state table) does not say so. L2 will writemerged_shafrom 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 nullmerge_commitand what a caller does then.What passed (merge of the head into main
7ac869b, no live forge):--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.shand the order are untouched;tests/merge.shpasses on main and on the merge.completedis 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 vetandgo testpass; a mutation (pending no longer ranked first) fails four cases. The new tests do not compile against main. Alltests/*.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.nonefromnot_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.
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):commitStatusesnow stops only on a short page. The pack's fake answerstotal_countas the page's length and puts the full count inX-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 51stpendingnow printspending, completed:false, and the tool asks for page 2.merge_commitis never null formergedand always null for other states, and that a caller retries later or asks a person.--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.go vet,go test, all oftests/*.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
mainrequires an approval.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 city-root-review (review 162, APPROVED and official, on
c738e67) after the re-review above passed. The head was squash-merged into main7ac869bas018a30f.Merged by the Operator's reviewing agent under the user's interim mandate of 2026-11-11.