-
v0.6.0
Stablereleased this
2026-11-12 11:45:21 +00:00 | 48 commits to main since this releaseAdded
gc forgejo pr state --jsonprints a pull request's state as one JSON object on one line:schema_version("1"),state(open,merged,closed,missingorforeign),head(the head commit),base(the base branch),merge_commit(set for every merged pull request, null for the others; a merged pull request for which the forge names none is an error) andchecks, an object{"state", "completed"}for the checks of the head, whosestateisnot_started,pending,success,failureornone. The checks are the latest status of every context of the head, with all pages of them, and the workflow runs for the head: they have completed when no status is pending and no run iswaiting,runningorblocked. A head with no status and no run isnone, completed and no pass, when its tree holds no workflow file, andnot_started, not completed, when it holds one. The README says what the command prints for each state of a pull request and each outcome of the checks, and that no field of version 1 is removed or changes meaning. The rules of the other forms hold: only the forge's own "not found" ismissing, any other failure is an error with exit status 1 and nothing on stdout, a--pron another host or that is no pull request URL isforeignwithout a request, and the token goes to the forge's host only. Without--jsonthe command prints what it printed, with no further request, so themergeorder behaves as before.gc forgejo pr state --jsonalso printsmergeableandreviews, two fields added to version 1 (schema_versionstays"1"; the fields that existed keep their names and meaning, and an older caller ignores the new ones).mergeableismergeable,not_mergeableordraftfor an open pull request and null for the other states: Forgejo 17.0.1 answers a bare boolean that is false for a conflict, for a conflict check still running and for a failed one alike, sonot_mergeabledoes not say which, and the README says how a caller waits for a second read before it takes it as a conflict.reviewsis every review of the pull request, oldest first, for every state the forge has a pull request for (null formissingandforeign), each withid,account,team(the name of the team a review was requested of, where the forge gives no account),state(approved,request_changes,comment,pending,request_review,unknown, or another value the forge has, in lower case),commit,body,official,stale,dismissedandsubmitted_at. The README gives the two rules for deciding from them, with jq programs and a table of cases: whether the current head has an approval from the review account that counts, and whether a blocking review stands; it also says what a caller cannot know, since the branch protection and its whitelist are not readable with the city's token. The reviews are read to the end: Forgejo pages the list by row and then drops other accounts' pending reviews from each page, so a short page is not the last, and the tool reads on to an empty page that the forge'sX-Total-Countconfirms. The rules ofpr statehold: only the pull request's own "not found" ismissing, any other failure is an error with exit status 1 and nothing on stdout, a foreign--prgets no request, and the token goes to the forge's host only. With--jsonthe command now exits 1, with nothing on stdout, when the reviews of the pull request cannot be read or the forge gives an open pull request nomergeablefield, where the command before printed its object, since it asked for neither. Without--jsonthe command prints what it printed, so themergeorder behaves as before.gc forgejo pr merge --repo <worktree> --pr <url|number> --expect-head <sha> --target <branch>asks the forge to merge one head of a pull request when its checks succeed and its approvals are in, and prints what the forge answered. It posts{"Do": "squash", "head_commit_id": <sha>, "merge_when_checks_succeed": true}to the pull request's merge endpoint, so Forgejo lands it, as the account whose token the command uses, once the repository's required checks and approval are in; no agent merges. It refuses without calling the merge endpoint, with an exit status and areasonof its own for each case: 3head_moved(the head is not--expect-head, a full SHA), 4not_open, 5wrong_base(the base is not--target), 6no_diff(no changed file, no addition, no deletion), 7missingand 8foreign(no request is made). It printsscheduled,already_scheduled(the forge answered 409 for a pull request that has a scheduled merge) ormerged, with exit status 0, and exits 9 with outcomerejectedwhen the forge itself refuses with a 405 or 409.--jsonprints one object on one line, for a refusal too, withschema_version("1"),outcome,reason,state,head,base,merge_commit,forge_status,forge_messageandschedule_cancelled.--canceltakes a scheduled merge back and printscancelled, ornot_scheduledwhen there was none. The README says, from Forgejo 17.0.1's source, what the forge does with a scheduled merge: the schedule holds no head andhead_commit_idis ignored for it, a push does not remove it, so it merges whatever head the pull request has once the conditions are met, and the request never merges at once, so the command reads the pull request again after the forge's201and cancels its own schedule when the head has moved. The rules ofpr statehold: only the forge's own 404 ismissing, a 5xx, a timeout or a bad token is an error with exit status 1 and nothing on stdout, a foreign--prgets no request, and the token goes to the forge's host only.gc forgejo pr review --repo <worktree> --pr <url|number> --expect-head <sha> --event <APPROVED|REQUEST_CHANGES> [--body-file <path>]posts one review on one head of a pull request, as the account whose token the command uses, and checks that the forge recorded it as asked. It posts{"event": …, "body": …, "commit_id": <sha>}to the pull request's reviews endpoint, so the review is bound to the head the caller read. It refuses without posting, with an exit status and areasonof its own for each case: 3head_moved, 4not_open, 7missingand 8foreign(no request is made), aspr mergehas them, and 10own_pull_request(the pull request is by the account of the token, which the forge lets nobody review), 11empty_body(a request for changes needs a body). It reads the reviews back after the post, through the code ofpr state --json, and exits 12 with outcomenot_recorded, never a success, when the forge stored the review otherwise than asked: pending, a comment in place of a verdict, on another commit, stale, dismissed, an approval or request the forge does not count asofficial, or an approval after which an earlier request for changes of the same account still blocks. Asked again for the same head and event by the same account (its latest approval or request, on any page of the list), it posts nothing and printsalready_reviewed; otherwise it printsposted, both with exit status 0. A 422 from the forge is exit 9 with outcomerejected.--jsonprints one object on one line, for a refusal too, withschema_version("1"),outcome,reason,state,head,account,event,review,lifted,forge_statusandforge_message. The README answers question 7 of the city'sdocs/handoffs.mdfrom Forgejo 17.0.1's source, and says so inlifted: a new approval by an account clearsofficialon that account's earlier reviews, in the same transaction, so the approval of a newer head ends the account's own earlier request for changes by itself, and the command dismisses nothing (a dismissal takes a repository admin, and a push does not dismiss a request, only approvals). The rules ofpr statehold: only the forge's own 404 ismissing, a 5xx, a timeout or a bad token is an error with exit status 1 and nothing on stdout, a foreign--prgets no request, and the token goes to the forge's host only.- The Reviewer,
forgejo.reviewer, and its formulamol-forgejo-review(row L14 of the city'sdocs/handoffs.md): the pack's agent that reviews one head of one pull request of its rig and posts its verdict on the forge, a port of rexcity'smol-forgejo-pr-reviewless its wait for the checks. The agent is a rig's named session ([[named_session]]inforgejo/pack.toml,mode = "on_demand"),max_active_sessions = 1,session = "acp",permission_mode = "unrestricted", claiming withgc hook --claim --drain-ack --json; the city's own import makes none. The formula is one step of five parts, held from the claim to the close as the Worker's is. It works a review bead that namespr_url,review_headandwork_bead: it voids the bead (review_verdict=void, nothing posted) when the pull request is not open or its head is notreview_head, halts when the checks of the head have not completed, and otherwise reads the work bead and the pull request's description, the whole diff, the target branch'sREVIEW.md,AGENTS.md,CLAUDE.mdandREADME.md(from the target, never from the pull request), the merge of the head into the current target, what the repository's workflows run (in a clone of its own, with the city's variables removed withenv -i) and the head's own checks, of which a failed one is read, reported and never approved. It posts one review on that head withgc forgejo pr review --expect-head(APPROVED, orREQUEST_CHANGESwith its findings as the body; a pull request that does not merge cleanly gets a request that says it needs a rebase), and writesreview_verdict(pass,failorvoid),review_reviewed(the head),review_urland a note on the review bead, then closes it with the work outcomeno-op. The verdict is written after the review is on the forge and read back from it, so a restart posts nothing twice. It never merges, pushes or changes the work bead, writes only the review bead and its own step, and mails the Operator when it halts. The place where row L7's handoff check of the review bead belongs is marked in Part 1 and nothing calls it, since the check does not exist yet. The city needs a patch offorgejo.reviewerfor every rig (the acp provider, the model and effort its pin check demands,max_active_sessions = 1and the review account's token file asFORGEJO_TOKEN_FILE), which README section "The Reviewer" gives, and which the pull request that bumps the import carries. How a review bead reaches the session, by a sling or by an assignment, is question 4 of the city'sdocs/handoffs.mdand a trial's to settle; a bead assigned with no workflow makes the Reviewer mail the Operator and exit.tests/reviewer.sh, run by thelintjob, resolves the agent in a throwaway city, compiles the formula, checks its safety rules and the order of its writes in its text, and runs the lines that read and write the bead against a stubgcandcurl. gc roles view beadsleaves out a bead labelledservice, as it leaves out gc's other bookkeeping:bookkeepinginroles/assets/jq/view.jqtells it by the label, never by the id. The label is for a bead a pack makes for an agent and no person works, such as the review bead of a coming order, which carriesserviceandreview; a rework bead carriesreworkand is work, so the view's groups show it, queued or being worked, as they show any bead, and a convoy withgc.syntheticis left out whatever its labels. A bead with no such label reads as before. The three labels are spelt once, aslabelsinview.jq, for the orders that will put them on withgc bd create --labels, andtests/view-beads.shpins their values and shows with beads of the fixture that a service bead is left out whoever holds it, that a rework bead is queued and that a synthetic convoy is still left out. The Operator's skill says how to list a store without them:gc bd list --exclude-type convoy --exclude-label service. gc's own input convoys stay in a barebd list, which only gc can change.forgejo order merge, a subcommand of the forgejo pack's Go tool, is themergeorder's logic: the order's script is now one line that runs it asgo tool -C "$PACK_DIR" forgejo order merge. It settles both shapes of a bead that carries a pull request. An open bead with apr_urlis settled exactly as the script did: closed as shipped at the merge, whoever holds it, with no mail; handed to the Operator with a--notifymail andpr_closedwhen the pull request closed unmerged or is gone from the forge, once per URL; skipped with a line on stderr when the pull request is another forge's. A bead closed when its pull request opened, withmerge_result=pull_request(listed by--status closed --has-metadata-key merge_result), getsmerge_result=mergedandmerged_shaon it and on every bead of the same pull request when the pull request merged, and the Operator is mailed once for the merge (--notify,--dedup merge:<url>); when the pull request closed unmerged or is gone, the beads getmerge_result=closedand the Operator gets one bead (pr_url,pr_event=closed, assigned to it) and one mail for the pull request, whichever the number of beads. The order reads a pull request with the codepr stateruns on, once for each pull request in a run, with no request for its checks or reviews; it runsgcin the directory the order was started in, for which$GC_BINnames the binary. README section "The merge order" says what the order does, how a change to it reaches a running city, and what a city sees when the tool cannot be built. The cases oftests/merge.sh, which tested the script with stubs ofgcandgo, are Go tests inforgejo/assets/forgejo/order_test.go, with a fake ofgcand the forge behindhttptest;tests/merge.shnow tests the wrapper.- The
scheduleorder of the forgejo pack, built and not switched on. Every two minutes it reads the closed beads whosemerge_resultispull_requestand, for each, asks the forge to schedule the merge of its pull request asgc forgejo pr merge --expect-head <the bead's gc.work_commit> --target <the bead's target, else the repository's default branch>does, and handles each answer as the table of section 3.11 d of the city'sdocs/handoffs.mdsays: it writesauto_merge=scheduledon the bead at the firstscheduled,already_scheduledormergedand asks again every cycle, never cancels a schedule, leaves a pull request that is not open to themergeorder, and makes one bead for the Operator for a pull request that is not onto the target, is missing or foreign, that the forge refuses to schedule for a reason other than a conflict, that has a head no bead of the city holds, or that stays unscheduled for three cycles in a row of a 500 from the forge or ofno_diff, or for two hours for any reason; a bead with nopr_urlor no fullgc.work_commitis counted and, after three cycles in a row, is a bead for the Operator too. A bead for the Operator is the merge order's own kind (pr_url,pr_event, here alsopr_headandwork_bead; made by the code both orders share, looked up in any status before one is made, mailed once with--notify --dedup <event>:<url>:<head>), so the merge order does not take it for a bead of the old shape, and an event and a head get one. The order isforgejo order schedule, a subcommand of the pack's Go tool, started by a two-line script. It does nothing unlessFORGEJO_SCHEDULE=onis in its environment, which a city gives with the order's[[orders.overrides]]entry, besideFORGEJO_TOKEN_FILE: with the variable unset, or set to anything buton, it prints one line and reads no bead, asks the forge for nothing and calls gc for nothing. The README says how to turn it on, what it does with each answer and when it asks the Operator, and that the city must not turn it on beforedismiss_stale_approvalsis confirmed onmain. Nothing has been tried against the real forge: the pull request that added the order lists the trial the Operator runs first.
Changed
gc forgejo pr openrefuses to open a pull request without a description. It exits 2, with its usage and before it asks the forge for anything, when--summary-fileis missing, when the file holds only whitespace, or when it holds only<summary>, the placeholder Part 6 ofmol-worker-workleaves in the file. The bead id that the body ends with is no description, and the command used to open a pull request whose body was only that line.--allow-empty-summaryopens it anyway. Theupgradeorder passes a summary already. The formula is unchanged: its Part 6 already passes a summary file, the refusal says what to do, and an added sentence took the step past the size limittests/formula.shkeeps.- Part 1 of
mol-worker-workmarks the work bead taken once the Worker holds the step and has derived the bead:gc bd update "$WORK_BEAD_ID" --status in_progress --set-metadata worker_session="$GC_SESSION_NAME" --set-metadata worker_step="$STEP_BEAD_ID", so a rig's store says someone is on the bead (row L20 of the city'sdocs/handoffs.md, decision 10, option B). The bead gets no assignee and is not claimed (no--claim): gc reads an assignee as a claim and does more with it than record it, and nothing in gc's claim, wake or release paths reads a bead without a route or an assignee.worker_sessionnames the Worker's session andworker_stepthe step bead, written again by every Worker that takes the step, so a retry overwrites a dead Worker's; the keys are the pack's own and gc reads neither. A bead that is already closed is not marked and not reopened. A halt (Part 2's two and the Halting section) sets the beadopen, assigns the Operator and unsets both keys, and Part 6 sets itopen, assigns the user and unsets both keys, as the hand-over did without them.tests/formula.shruns the lines against a stubgcthat keeps one bead and checks its end state for the mark of an open bead, of a retry and of a closed bead, for each of the three halts, and for the hand-over. A bead slung before the release shows no change, since the formula is poured into the workflow at the sling. The trial that a restarted Worker'sgc hook --claimreturns its step while the work bead is in progress and unassigned is the Operator's, on a throwaway bead before the release reaches the city; it is written out in the pull request. The block stops with a clear failure, before it callsgc bd update, whenWORK_BEAD_IDis empty, as it is in a fresh shell that skipped step 2 (: "${WORK_BEAD_ID:?derive it as in 2}"). The step's text shrank to stay under the 28000 characterstests/formula.shallows agc bd showof it: Part 4's examples of strong and weak commit messages and the template's closing line about follow-ups are gone, and the commit template stays. - The Worker's skill says where scratch files go and what never to run: a directory made with
mktemp -dunder$TMPDIR, left where it is, and neverrm -rforrm -ron a path that comes from a command substitution or a variable, nor anyrmin the command that hands the bead over. Claude Code stops such anrm -rfwith a permission prompt, bypass mode or not ("Dangerous rm operation on statically-unresolvable target"), and a Worker that ran one held its hand-over behind the prompt until someone answered. On an acp box gc holds the request, thepermission-requestorder mails it to the Operator, who denies it; the denial reaches the Worker as a refusal that does not end its turn, and the skill tells it to run the hand-over again on its own, without therm. The skill's new section keeps a Worker from raising the prompt at all.mol-worker-workis unchanged, since its step is within a few dozen characters of the size a Worker's Bash call keeps. - The adapter that rexcity's
go.moddeclares as a tool is namedclaudeacp(it wasclaude-acpin rexcity 0.29.0 and 0.30.0, and has beenclaudeacpsince 0.31.0), and theapplyorder's header comment andtests/apply.shnow say so: the test's fixture declarescmd/claudeacp, so it shows what the order installs today. The order itself is unchanged, since it names each tool by the last element of its package path. - Part 2 of
mol-worker-worksays what its command does: it takes$GC_DIR, and the current directory only whereGC_DIRis unset. The text said$GC_DIR, "not$(pwd)", while the command passes${GC_DIR:-$(pwd)}. - The
mergeorder no longer needsjqor agcfound onPATHby its script: it is the Go tool, which runs$GC_BINor thegconPATH. A run is limited to ten minutes where the script had no limit, and agccall that fails now fails the bead it was for with gc's own message on stderr, asmerge: <bead>: <message>. What the script printed with the order's name (merge: <bead>: cannot read the state of <url>, the foreign-pull-request line) is kept, and the first now ends with the cause. A run with no bead to settle makes the two listings, one for each shape, where the script made one.
Fixed
- The shell tests no longer die of SIGPIPE at random, which failed
test / scriptson a pull request that touched neithertests/norroles/(run 104, exit 141).tests/gnu-tools.shread the first row withrows | head -n 1underset -euo pipefail:headexits after one line, the loop feeding it is killed by SIGPIPE on its next write, andpipefailmakes that the failure of the line. It reads the first line withsed -n 1pnow, which reads to the end. The same holds for every other test that stops reading early:grep -q,headand anawkthat callsexitat the end of a pipe now read all their input (grepthrough agrepqhelper that sends its output to/dev/null, intests/formula.sh,tests/view-beads.sh,tests/view-mail.sh,tests/worktree.shandtests/worktree-setup.sh), so none of them depends on how fast the writer is. Nothing a pack runs changes: no script underroles/orforgejo/stops reading early. gc roles permission denyaccepts the global flag--city <dir>and--city=<dir>, which gc passes on to a pack command run asgc --city <dir> roles permission deny ..., and ignores it, asgc roles view beadsandview maildo; it used to print its usage line and exit 2 without denying anything. The other global flags (--rig,--city-url,--context) are still refused, since ignoring one would deny the request in the wrong city.- The
mergeorder no longer fails at every run on a bead whose pull request the forge no longer has.gc forgejo pr stateprintsmissingwhen the forge answers "not found" in its own error object, and the order hands such a bead to the Operator once, as it does for a pull request closed unmerged: it assigns the bead, mails the Operator with--notify(subject "Pull request not found: BEAD", saying the pull request does not exist on the forge any more) and records the URL inmetadata.pr_closed. A 404 the forge did not write, a forge that cannot be reached, or any other error stays a failed run. gc forgejo pr statesends its token to no host but its forge's: the host ofFORGEJO_URLwhen that is set, otherwise the host of the worktree's origin. A--pron another host, or one that is not a pull request URL, printsforeignwithout any request being made, and themergeorder skips such a bead with one line on stderr instead of failing the run.
Downloads
-
Source code (ZIP)
1 download
-
Source code (TAR.GZ)
1 download