• v0.6.0 d9d5ad4648

    v0.6.0
    All checks were successful
    release / release (push) Successful in 6s
    test / changelog (push) Successful in 4s
    test / lint (push) Successful in 21s
    test / scripts (push) Successful in 34s
    Stable

    city-root released this 2026-11-12 11:45:21 +00:00 | 48 commits to main since this release

    Added

    • gc forgejo pr state --json prints a pull request's state as one JSON object on one line: schema_version ("1"), state (open, merged, closed, missing or foreign), 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) and checks, an object {"state", "completed"} for the checks of the head, whose state is not_started, pending, success, failure or none. 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 is waiting, running or blocked. A head with no status and no run is none, completed and no pass, when its tree holds no workflow file, and not_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" is missing, any other failure is an error with exit status 1 and nothing on stdout, a --pr on another host or that is no pull request URL is foreign without a request, and the token goes to the forge's host only. Without --json the command prints what it printed, with no further request, so the merge order behaves as before.
    • gc forgejo pr state --json also prints mergeable and reviews, two fields added to version 1 (schema_version stays "1"; the fields that existed keep their names and meaning, and an older caller ignores the new ones). mergeable is mergeable, not_mergeable or draft for 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, so not_mergeable does not say which, and the README says how a caller waits for a second read before it takes it as a conflict. reviews is every review of the pull request, oldest first, for every state the forge has a pull request for (null for missing and foreign), each with id, 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, dismissed and submitted_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's X-Total-Count confirms. The rules of pr state hold: only the pull request's own "not found" is missing, any other failure is an error with exit status 1 and nothing on stdout, a foreign --pr gets no request, and the token goes to the forge's host only. With --json the 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 no mergeable field, where the command before printed its object, since it asked for neither. Without --json the command prints what it printed, so the merge order 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 a reason of its own for each case: 3 head_moved (the head is not --expect-head, a full SHA), 4 not_open, 5 wrong_base (the base is not --target), 6 no_diff (no changed file, no addition, no deletion), 7 missing and 8 foreign (no request is made). It prints scheduled, already_scheduled (the forge answered 409 for a pull request that has a scheduled merge) or merged, with exit status 0, and exits 9 with outcome rejected when the forge itself refuses with a 405 or 409. --json prints one object on one line, for a refusal too, with schema_version ("1"), outcome, reason, state, head, base, merge_commit, forge_status, forge_message and schedule_cancelled. --cancel takes a scheduled merge back and prints cancelled, or not_scheduled when 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 and head_commit_id is 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's 201 and cancels its own schedule when the head has moved. The rules of pr state hold: only the forge's own 404 is missing, a 5xx, a timeout or a bad token is an error with exit status 1 and nothing on stdout, a foreign --pr gets 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 a reason of its own for each case: 3 head_moved, 4 not_open, 7 missing and 8 foreign (no request is made), as pr merge has them, and 10 own_pull_request (the pull request is by the account of the token, which the forge lets nobody review), 11 empty_body (a request for changes needs a body). It reads the reviews back after the post, through the code of pr state --json, and exits 12 with outcome not_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 as official, 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 prints already_reviewed; otherwise it prints posted, both with exit status 0. A 422 from the forge is exit 9 with outcome rejected. --json prints one object on one line, for a refusal too, with schema_version ("1"), outcome, reason, state, head, account, event, review, lifted, forge_status and forge_message. The README answers question 7 of the city's docs/handoffs.md from Forgejo 17.0.1's source, and says so in lifted: a new approval by an account clears official on 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 of pr state hold: only the forge's own 404 is missing, a 5xx, a timeout or a bad token is an error with exit status 1 and nothing on stdout, a foreign --pr gets no request, and the token goes to the forge's host only.
    • The Reviewer, forgejo.reviewer, and its formula mol-forgejo-review (row L14 of the city's docs/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's mol-forgejo-pr-review less its wait for the checks. The agent is a rig's named session ([[named_session]] in forgejo/pack.toml, mode = "on_demand"), max_active_sessions = 1, session = "acp", permission_mode = "unrestricted", claiming with gc 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 names pr_url, review_head and work_bead: it voids the bead (review_verdict=void, nothing posted) when the pull request is not open or its head is not review_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's REVIEW.md, AGENTS.md, CLAUDE.md and README.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 with env -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 with gc forgejo pr review --expect-head (APPROVED, or REQUEST_CHANGES with its findings as the body; a pull request that does not merge cleanly gets a request that says it needs a rebase), and writes review_verdict (pass, fail or void), review_reviewed (the head), review_url and a note on the review bead, then closes it with the work outcome no-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 of forgejo.reviewer for every rig (the acp provider, the model and effort its pin check demands, max_active_sessions = 1 and the review account's token file as FORGEJO_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's docs/handoffs.md and a trial's to settle; a bead assigned with no workflow makes the Reviewer mail the Operator and exit. tests/reviewer.sh, run by the lint job, 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 stub gc and curl.
    • gc roles view beads leaves out a bead labelled service, as it leaves out gc's other bookkeeping: bookkeeping in roles/assets/jq/view.jq tells 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 carries service and review; a rework bead carries rework and is work, so the view's groups show it, queued or being worked, as they show any bead, and a convoy with gc.synthetic is left out whatever its labels. A bead with no such label reads as before. The three labels are spelt once, as labels in view.jq, for the orders that will put them on with gc bd create --labels, and tests/view-beads.sh pins 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 bare bd list, which only gc can change.
    • forgejo order merge, a subcommand of the forgejo pack's Go tool, is the merge order's logic: the order's script is now one line that runs it as go tool -C "$PACK_DIR" forgejo order merge. It settles both shapes of a bead that carries a pull request. An open bead with a pr_url is settled exactly as the script did: closed as shipped at the merge, whoever holds it, with no mail; handed to the Operator with a --notify mail and pr_closed when 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, with merge_result=pull_request (listed by --status closed --has-metadata-key merge_result), gets merge_result=merged and merged_sha on 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 get merge_result=closed and 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 code pr state runs on, once for each pull request in a run, with no request for its checks or reviews; it runs gc in the directory the order was started in, for which $GC_BIN names 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 of tests/merge.sh, which tested the script with stubs of gc and go, are Go tests in forgejo/assets/forgejo/order_test.go, with a fake of gc and the forge behind httptest; tests/merge.sh now tests the wrapper.
    • The schedule order of the forgejo pack, built and not switched on. Every two minutes it reads the closed beads whose merge_result is pull_request and, for each, asks the forge to schedule the merge of its pull request as gc 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's docs/handoffs.md says: it writes auto_merge=scheduled on the bead at the first scheduled, already_scheduled or merged and asks again every cycle, never cancels a schedule, leaves a pull request that is not open to the merge order, 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 of no_diff, or for two hours for any reason; a bead with no pr_url or no full gc.work_commit is 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 also pr_head and work_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 is forgejo order schedule, a subcommand of the pack's Go tool, started by a two-line script. It does nothing unless FORGEJO_SCHEDULE=on is in its environment, which a city gives with the order's [[orders.overrides]] entry, beside FORGEJO_TOKEN_FILE: with the variable unset, or set to anything but on, 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 before dismiss_stale_approvals is confirmed on main. 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 open refuses to open a pull request without a description. It exits 2, with its usage and before it asks the forge for anything, when --summary-file is missing, when the file holds only whitespace, or when it holds only <summary>, the placeholder Part 6 of mol-worker-work leaves 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-summary opens it anyway. The upgrade order 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 limit tests/formula.sh keeps.
    • Part 1 of mol-worker-work marks 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's docs/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_session names the Worker's session and worker_step the 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 bead open, assigns the Operator and unsets both keys, and Part 6 sets it open, assigns the user and unsets both keys, as the hand-over did without them. tests/formula.sh runs the lines against a stub gc that 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's gc hook --claim returns 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 calls gc bd update, when WORK_BEAD_ID is 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 characters tests/formula.sh allows a gc bd show of 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 -d under $TMPDIR, left where it is, and never rm -rf or rm -r on a path that comes from a command substitution or a variable, nor any rm in the command that hands the bead over. Claude Code stops such an rm -rf with 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, the permission-request order 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 the rm. The skill's new section keeps a Worker from raising the prompt at all. mol-worker-work is 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.mod declares as a tool is named claudeacp (it was claude-acp in rexcity 0.29.0 and 0.30.0, and has been claudeacp since 0.31.0), and the apply order's header comment and tests/apply.sh now say so: the test's fixture declares cmd/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-work says what its command does: it takes $GC_DIR, and the current directory only where GC_DIR is unset. The text said $GC_DIR, "not $(pwd)", while the command passes ${GC_DIR:-$(pwd)}.
    • The merge order no longer needs jq or a gc found on PATH by its script: it is the Go tool, which runs $GC_BIN or the gc on PATH. A run is limited to ten minutes where the script had no limit, and a gc call that fails now fails the bead it was for with gc's own message on stderr, as merge: <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 / scripts on a pull request that touched neither tests/ nor roles/ (run 104, exit 141). tests/gnu-tools.sh read the first row with rows | head -n 1 under set -euo pipefail: head exits after one line, the loop feeding it is killed by SIGPIPE on its next write, and pipefail makes that the failure of the line. It reads the first line with sed -n 1p now, which reads to the end. The same holds for every other test that stops reading early: grep -q, head and an awk that calls exit at the end of a pipe now read all their input (grep through a grepq helper that sends its output to /dev/null, in tests/formula.sh, tests/view-beads.sh, tests/view-mail.sh, tests/worktree.sh and tests/worktree-setup.sh), so none of them depends on how fast the writer is. Nothing a pack runs changes: no script under roles/ or forgejo/ stops reading early.
    • gc roles permission deny accepts the global flag --city <dir> and --city=<dir>, which gc passes on to a pack command run as gc --city <dir> roles permission deny ..., and ignores it, as gc roles view beads and view mail do; 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 merge order no longer fails at every run on a bead whose pull request the forge no longer has. gc forgejo pr state prints missing when 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 in metadata.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 state sends its token to no host but its forge's: the host of FORGEJO_URL when that is set, otherwise the host of the worktree's origin. A --pr on another host, or one that is not a pull request URL, prints foreign without any request being made, and the merge order skips such a bead with one line on stderr instead of failing the run.
    Downloads