Landing L6: gc forgejo pr review posts a review on a head and checks the forge recorded it #41
No reviewers
Labels
No labels
No milestone
No project
No assignees
2 participants
Due date
No due date set.
Dependencies
No dependencies set
Reference
mikluko/gascitypacks!41
Loading…
Reference in a new issue
No description provided.
Delete branch "worker/gascitypacks-zhy"
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?
L6 of Landing (
docs/handoffs.md, "What Landing needs"):gc forgejo pr review, which posts one review on one head of a pull request and checks the forge recorded it. Builds onpr state --jsonas #36 left it (08a754e).What it does
{"event", "body", "commit_id": <expect-head>}as the account the token belongs to, and printsposted, oralready_reviewedwhen the account's latest approval or request is this event on this head (nothing is posted); with--json, one object withschema_version,outcome,reason,state,head,account,event,review,lifted,forge_status,forge_message.head_moved, 4not_open, 7missing, 8foreign(no request), 10own_pull_request, 11empty_body. A 422 from the forge is 9rejected; 1 a failure, 2 a mistake in the command line.not_recorded, never a success, when the forge stored it otherwise: pending, a comment, another commit, stale, dismissed, notofficial, or an approval after which the account's earlier request still blocks.pr statehold: only the forge's own 404 ismissing; a 5xx, a timeout, a bad token, or any other answer is exit 1 with nothing on stdout; a foreign--prgets no request; the token goes to the forge's host only.[Unreleased],commands/pr/review/{run.sh,help.md}.Question 7: does the same account's approval of a newer head lift its earlier "request changes"?
Yes, by itself; the command dismisses nothing. From Forgejo 17.0.1's source (tag
v17.0.1,363f3dc, read in a clean checkout), not tried on sarak.sh:officialand notdismissed, whatever its commit:models/issues/pull.go:923-939(MergeBlockedByRejectedReview). A push does not end one:DismissApprovalReviewshandles type approve only (services/pull/review.go:443-449, fromservices/pull/pull.go:395-408), so after the author's rework push the old request still blocks until the same account gives a new verdict.officialon every earlier review of the same account in the same transaction:UPDATE review SET official=false WHERE issue_id=? AND reviewer_id=?atmodels/issues/review.go:424(fresh review) and:454(from a pending one), for types approve and reject.CreatePullReview(routers/api/v1/repo/pull_review.go:432-554) goes through it (services/pull/review.go:384-440). So the earlier request stays listed asrequest_changes,official: false, and blocks nothing.dismissReviewchecksctx.IsUserRepoAdmin()first (pull_review.go:1102-1105; routesrouters/api/v1/api.go:1053-1054), the web form is behindreqRepoAdmin(routers/web/web.go:1451). So if the forge did keep the request blocking, the review account could dismiss it only if it is an admin, which the city's token cannot read.So no dismissal is built. The command instead reports
lifted(the ids of the account's requests that blocked before an approval and do not after), and if a request of the account is stillofficialafter the approval it exits 12 and says dismissing takes an admin, so a forge that differs from the source shows as a failure and not as a merge that waits for ever. The trial below is what settles it on sarak.sh.How I checked it
go vet ./...andgo test ./...(also-race) withGOPROXY=off: new tests on the fake forge for the success of both events, every refusal and its distinct exit status (the one table is shared withpr merge), the already-there rule (other event/head/account, dismissed, comment, pending, 60 reviews on 2 pages, a stored one that does not stand), eachnot_recordedcase (pending, comment ×2, not official ×2, unlisted, stale by a push in between), the 422, every failure that must be exit 1 with no stdout (5xx, 404 from a proxy, 403, 201, garbage, a failed read back, bad or missing token, forge gone, no author), question 7 (request on one head, push, approval of the new head lifts it, nothing dismissed; and a forge that does not clear it), usage, foreign hosts, the token going to the forge alone. I broke the official check and the author check once each and the tests failed.GET /userandPOST .../reviews, answering as the source cited does (own-pull 422, empty-body 422,officialby the rule's whitelist,staleby commit,officialcleared on the account's earlier reviews). One difference: the real forge decidesstaleby comparing diffs, the fake by commit.valid=true.gc lint .andtests/formula.shpass.origin/main(08a754e) right before the push; nothing ofgascitypacks-8g8was on it yet.The trial, for the Operator
On a throwaway repository on sarak.sh that has the same rule as the real
main(one approval needed fromcity-root-review, whitelisted; block on rejected reviews; the checks may be none), with a clone at$W, an author accountA(the city'sgascity-root) and the review accountR.gc forgejohere is this branch's tool, e.g.go tool -C <this checkout>/forgejo forgejowithFORGEJO_URL=https://sarak.sh.$RTis R's token file,$ATA's;forgejo() { go tool -C <checkout>/forgejo forgejo "$@"; }.What each answer of step 7 means for question 7:
outcomeposted,lifted[<id of the request>], and inpr statethe request listed asrequest_changes,official: false,dismissed: false, with the approvalofficial: true: the forge behaves as its source says. An approval of a newer head lifts the account's own request; L14 needs no dismissal step; this pull request stands as it is. With the checks green and a scheduled merge, the pull request merges (L12's trial).curl -sS -X POST -H "Authorization: token $(cat $RT)" -H 'Content-Type: application/json' -d '{"message":"superseded","priors":false}' https://sarak.sh/api/v1/repos/<o>/<r>/pulls/<n>/reviews/<id>/dismissals.200means the review account may dismiss its own request, and L6 gets a dismissal step before the approval (a follow-up bead, with this answer);403("Must be repo admin") means it may not, and the Reviewer cannot clear its own request, and the user is asked how it is cleared (an admin account dismisses it, or the review account is made an admin); L14 waits for that.official: falseon the approval itself): the review account is not on the rule's whitelist on this repository: that is L4's, not this command's.Clean up: close the pull request, and delete the throwaway repository.
🤖 Generated with Claude Code
Bead: gascitypacks-zhy
Reviewed
f398dfb: gc forgejo pr review (submit.go and tests), Q7 citations checked against Forgejo v17.0.1, go vet/test/-race and changelog check on the merge result.Reviewed head
f398dfb(main08a754e); squash-merged asbf3bee5.What I checked:
not_recorded(12) for pending, comment, other commit, stale, dismissed, not official, unlisted, or a request still blocking. Also the idempotence (latest verdict of the account, on any page),--jsonwith all fields, and the client rules (only the forge's own 404 is missing; 5xx, proxy 404, 401/403, bad bodies and a failed read-back are exit 1 with no stdout; foreign--prgets no request; the token goes to the forge's host only).merge.goonly gains three reasons and their exit statuses in the shared table;client.goonly decodesuser.login.pr mergeandpr statebehave as before, and their tests pass unchanged.run.shis the two-line exec of the Go tool, as forpr merge.models/issues/pull.go:923-939,models/issues/review.go:424and:454,services/pull/review.go:384-449,services/pull/pull.go:395-408,routers/api/v1/repo/pull_review.go:432-554,:644-691and:1102-1105,routers/api/v1/api.go:1053-1054,routers/web/web.go:1451. Every citation holds, and I agree: a new approval by the same account clearsofficialon its earlier request, so the request stops blocking; only a repo admin may dismiss; the command dismisses nothing and fails with 12 if a request still blocks. The fake answers as the source does (422 messages verbatim, official by whitelist, earlier reviews cleared), except that it decides stale by commit rather than by diff. The README says so.go vet,go testandgo test -racepass, offline; the changelog check (mikluko/changelog v1, built from its tag) gives valid=true; CI was green on all three checks.Follow-ups (not blocking):
gascity-root; it iscity-root.postedfor the old head, which is not stale and which Forgejo counts. This is Forgejo's own rule, and the README documents it.Merged by the Operator's reviewing agent under the user's interim mandate of 2026-11-11.
Trial run by the Operator's agent on 2026-11-12 on mikluko/scratch, tool built from v0.6.0.
Tool:
go build ./assets/forgejofrom v0.6.0 (d9d5ad4),FORGEJO_URL=https://sarak.sh. A =city-root, R =city-root-review. Pull request: mikluko/scratch#2, branchtrial-l6, H10c31b9f, H240019d4.pr openwas given--summary-file(the trial omits it; the tool requires it). Commits were pushed over ssh asmikluko; the pull request's author iscity-root, so nothing below changes because of that.Protection of scratch
main(R cannot read the rule, 403; found by refusals on mikluko/scratch#1): one approval required (405 not allowed to merge [reason: Does not have enough approvals]), checktest / test (pull_request)required (405 ... [reason: Not all required status checks successful]), and stale approvals are not dismissed: an approval of an earlier head stayedstale: true, dismissed: falseafter a push, and the merge then succeeded (200, #1 merged). "Block on rejected reviews" could not be isolated (the forge checks approvals first).pr review --event APPROVEDH1own_pull_requestrefused/own_pull_request,account: city-root, exit 10REQUEST_CHANGES, no bodyempty_bodyrefused/empty_body, exit 11REQUEST_CHANGES --body-fileH1;pr stateposted,official: trueposted, review 200official: true, stale: false, dismissed: false, exit 0;pr statelists it, checks successalready_reviewed, no second reviewalready_reviewed(review 200), exit 0;pr stateone reviewpr stateofficial: true, stale: true, dismissed: falseAPPROVEDH1head_movedrefused/head_moved, head40019d4, exit 3APPROVEDH2;pr stateposted,lifted [<id>]; requestrequest_changes, official: false, dismissed: false; approvalofficial: trueposted, review 201official: true,lifted: [200], exit 0;pr state: review 200request_changes, official: false, stale: true, **dismissed: true**, review 201approved, official: truedismissed: trueAPPROVEDH2 againalready_reviewedalready_reviewed(review 201), exit 0Question 7 on sarak.sh: yes: R's approval of the newer head lifted R's own request without any dismissal call (
lifted: [200], requestofficial: false), so L6 and L14 need no dismissal step. The one difference: Forgejo also flags the superseded requestdismissed: true, where the description (and the source reading) expecteddismissed: false; the tool's outcome is unaffected.Clean-up: #2 closed. The repository was not deleted (it is the user's, kept on purpose); no branch deleted.