Repository navigation
feat(bin): select the Forgejo CLI from the registry forge binding - #8454
philipp-baumann wants to merge 29 commits into
Conversation
Firstmate's Forgejo path drives tea only, and a host logged into a different Forgejo CLI cannot arm a watch or merge a pull request at all. Bin/fm-pr-lib.sh now owns one resolver that picks the CLI and that CLI's own host login, and the merge watch, the merge path, the terminal read, teardown's merged proof, and arming all route through it. tea and fgj can make an authenticated REST request, so they serve the existing record, combined-status, and head-bound merge contract unchanged. forgejo-cli (fj) exposes no request passthrough, prints only localized prose with no commit id, and hard-codes head_commit_id to null in its merge request, so it is refused by name rather than merged unbound (docs/forgejo-cli-alternatives.md). A project names its CLI through the registry forge binding, forge=forgejo:fgj, queried with --forge-cli; --forge still answers forgejo for every spelling, so existing consumers and existing bindings are unaffected.
Remove the locally installed CLI versions, machine installation paths, and private packaging provenance from the empirical record. Attribute every interface finding to the tool and its interface generation instead, and state that behaviour was verified against a released build of each CLI on the development machine. Findings and conclusions are unchanged.
The new test captured the promotion exit status with a set +e / set -e pair, but the file never enables errexit itself, so the closing set -e left it on for every test that follows. The next unchanged test expects a failing assignment and died with a hard abort instead of a failed assertion, taking the whole file down on Linux CI. Capture the status without relying on errexit at all: initialise status=0 and let a single || status=$? assignment record a non-zero exit, which behaves identically whether errexit is on or off. The suite passes locally with exit 0 and all tests ok.
[Medium impact] The code appears safe to merge; no new blocking defect was established. Reviews (2) · Last reviewed commit: "no-mistakes(review): fgj manual-PR DOD n..." · Reviewed by Greptile |
|
Speaking as Kun's firstmate: thank you @philipp-baumann for this, and welcome! Letting a home use the Forgejo CLI it actually has is useful. The write-up of what I read the full diff at Waiting on you for these:
Once those are in, please re-raise with one clean |
The reviewer's two asks on the alternate-Forgejo-CLI path. 1. The fgj login reader never parsed a rendered surface by intent, but it did: `fm_pr_forgejo_fgj_login` (and its duplicate in fm-pr-poll.sh) matched `--hostname` against the human-readable `fgj auth status` report, stripping a `(user: ...)` suffix with awk. fgj ships no --json/-o hostname listing, so the report is the only listing, but `fgj auth token --hostname <host>` answers a configured host with exit 0 and an unconfigured one nonzero. That is a documented exit status, not a rendered line, so both readers now read it and the awk is gone. 2. `auto` means tea and only tea. It previously walked tea, fgj, fj and took the first installed CLI holding a login for the host, so on a home where tea held no login but fgj did, a project that named no CLI would silently start shipping through fgj - a CLI the captain never chose. fgj is now opt-in through `forge=forgejo:fgj`. Both resolvers were changed in step (fm-pr-lib.sh's FM_PR_FORGEJO_CLI_ORDER and fm-pr-poll.sh's own auto branch), and bin/fm-brief.sh follows the same resolver, so the ship brief cannot name a CLI the merge path would not use. Docs updated to match (configuration.md, forgejo-cli-alternatives.md, forgejo-tea-integration.md), including the live verification of the fgj merge path: resolved via fgj against a real Forgejo 17.0.1 instance, a wrong-head merge refused with HTTP 409 and the pull request left open, a head-bound merge landed, and the merged state polled back. Tests: the mocks that only emulated `fgj auth status` now emulates `auth token`, and fm-brief's auto-resolution case is rewritten to assert the new contract (auto stays on tea and never adopts fgj's login). No new test failures; the pre-existing failures in the touched suites are unchanged.
…cision Making `auto` tea-and-only-tea reversed an assumption five tests added earlier in this branch still encoded. Each is reconciled with the decided contract rather than the contract being bent back: - fm-pr-merge's fgj read/merge case and its fj refusal case now register the CLI they exercise (forge=forgejo:fgj / :fj), because a project reaches either only by naming it. - fm-pr-check-security's arming case does the same, and its fj half registers forge=forgejo:fj; the poll case records the fgj preference explicitly instead of relying on auto to reach fgj. - fm-task-delivery's promotion case is rewritten to assert the new contract: a bare forge=forgejo keeps the tea contract even where fgj is logged in, and never adopts fgj's stored login.
…s and dead-end refusals The second review of the opt-in change found three loose ends, all real: - `fm_pr_forgejo_resolve_project` and `fm_pr_forgejo_clone_host` became behaviourally inert once `auto` meant tea-only: their only callers (fm-brief.sh, fm-promote.sh) run them solely on the auto branch, where the resolver can only succeed with tea or fail into the tea fallback, so the clone-host lookup could not change an outcome. Both helpers are removed and each call site sets the decided value (`auto` is tea) directly, so the brief, the promotion, and the merge path agree by the decision rather than by a redundant resolution. - bin/fm-project-mode.sh's `--forge-cli` header and inline note still said `auto` means "whatever is installed and holds a login for the host"; both now state tea-and-only-tea. bin/fm-pr-poll.sh's recorded-preference list gains the `fj` it can already receive. - The fj refusals in fm-pr-check.sh and fm-pr-merge.sh told the operator to "install tea or fgj, log one in, and re-run", which cannot work while the registry binding still names fj. Both now name the actual remedy (change the binding to forge=forgejo:tea/:fgj, or leave the project on tea), and the generic resolver-failure message no longer lists fgj/fj as ways to satisfy the requirement it states; it names the CLI the binding resolves to instead. The generic prefix stays byte-identical so the tests that match it are unaffected.
…used source Third review, two non-functional leftovers from the refactor: - bin/fm-brief.sh's --forge block still said a bare forge=forgejo is "resolved against the project clone's own host through the same resolver arming and the merge path use". The resolver is gone and the code maps auto straight to tea, so the comment now describes the host-based adoption this branch deliberately removed. Reworded to say auto is tea and only tea. - bin/fm-brief.sh sourced bin/fm-pr-lib.sh solely to reach that resolver. It reads no fm_pr_*/FM_PR_* symbol of its own (fm_pr_text_valid lives in fm-dod-lib.sh, sourced just above, which already sources fm-pr-lib.sh), so the direct source is removed.
…ding refusal Fourth review, two follow-ups from the opt-in decision: - FM_PR_FORGEJO_CLI_ORDER held the single element 'tea' and fm_pr_forgejo_resolve walked it with a for loop. With `auto` defined as tea-and-only-tea, that list and loop are generality the intent does not require, so both are dropped and the auto branch attempts tea directly. Behaviour is unchanged; the shape now says what the decision is. - bin/fm-project-mode.sh's unknown-CLI refusal still offered forge=forgejo alone "to follow what is installed", which is exactly the auto-detection this branch removed. It now says forge=forgejo alone means tea.
Fifth review: the same class of stale wording the previous commit fixed in one file remained in three others, all describing the PATH-order auto-detection this branch removed. - bin/fm-pr-check.sh said the resolver honors the registered CLI "first and what is installed second"; bin/fm-pr-merge.sh said a binding that names none is resolved "by what is installed and logged in for the host". Both now say the binding's CLI, or tea when it names none. - bin/fm-pr-lib.sh's selection note called auto "no binding, or an empty one", but forge= (empty) is refused; it now says "no CLI named in the binding". - bin/fm-teardown.sh said a recorded Forgejo URL is read through "whichever Forgejo CLI this host has logged in" when the binding named none; it is tea.
The gate's test agent caught that test_forgejo_fgj_serves_the_reads_and_ binds_the_merge exercises two case directories, and only the first had the forge=forgejo:fgj registration added when auto became opt-in. The second (the refused-merge sub-case) still resolved auto to tea and refused before the merge it means to test, so it passed only by asserting the wrong refusal. It now registers fgj too, matching the first sub-case.
The sixth review found that fm_pr_forgejo_cli_preference invoked bin/fm-project-mode.sh --forge-cli with only FM_HOME, while this branch's other registry readers (bin/fm-brief.sh, bin/fm-promote.sh) pass the caller's data directory explicitly as FM_DATA_OVERRIDE. fm-project-mode.sh reads its registry from FM_DATA_OVERRIDE, else $FM_HOME/data, so a run whose caller resolved the override into a variable - or that carried a relative one resolved against another working directory - read the wrong registry and the registration silently fell back to `auto`, proving a merge through a CLI the project never registered. Reproduced with a relative override and with the override unset in the child's environment. The helper now forwards FM_DATA_OVERRIDE, resolved to an absolute path the way bin/fm-brief.sh already resolves it, and defaults to $FM_HOME/data when the override is unset.
Reviewer ask 1 (the Greptile P2 thread): fm_pr_forgejo_fj_login parsed the hostnames out of fj's human-readable `fj auth list` report. VISION.md allows reading a rendered surface only through a named, quarantined, version-pinned adapter, and forgejo-cli exposes a structured alternative, so use it: `fj whoami --host <host>` succeeds exactly when <host> is authenticated and fails otherwise. The login evidence is now that exit status, and no display line is ever parsed, mirroring the fgj reader (which already uses `fgj auth token --hostname`'s exit status). The test mock and its fixture comment move to `whoami --host` so the suite exercises the real interface; the full fm-pr-merge suite stays green (146).
|
Live evidence for both open asks, run against real Forgejo pull requests on Ask 1 — the rendered reader. Ask 2 — live validation. Every step below is Ask 3 — opt-in is in: a bare |
|
Re-raised: the branch is now at head
The gate's own review then surfaced two further findings on this branch's new code, both acted on honestly:
|
The Greptile P2 asked for a version-pinned adapter behind a rendered login read. This branch answers it by reading only an exit status, and the record said that `fj whoami --host <host>` read had never been exercised against a real forgejo-cli build, leaving the one vendor contract in the change unverified. It has now been exercised: `fj whoami --host <configured-host>` exits 0 and `fj whoami --host <unconfigured-host>` exits nonzero, the two-way answer the predicate rests on. The record states that instead of the old caveat, and the "Versions" paragraph names this check alongside the live fgj pass as the parts collected after 2026-11-12, still without embedding build versions or private host identifiers. Documentation only: the resolver, the poll and the merge path are unchanged.
|
Live Where and what. Instance Which head. The run was made at
Verdict: all three passed. The throwaway repository used for the merge was deleted afterwards, and no project repository was touched. |
|
Speaking as Kun's firstmate: thanks @philipp-baumann, and sorry that your Nov 17 and Nov 21 updates waited this long for a reply. The live Where it stands: this waits on you (author). The head is now Once it binds, I'll do the full line-by-line review (it stands in for Greptile while that's out, and this PR touches the merge and watch paths) and approve the fork CI that's waiting. |
The canonical full-file ShellCheck run (selected because a sourced helper changed) reported three SC2034 diagnostics in bin/fm-pr-lib.sh: the unused `cli` local in fm_pr_forgejo_resolve, and the two output globals that fm_pr_forgejo_cli_preference assigns. The globals are genuinely consumed, so this keeps them and annotates them the way this file already annotates FM_PR_OWNER, FM_PR_REPO, and the FM_PR_RECORD outputs: a comment naming the consumer, then `# shellcheck disable=SC2034`. bin/fm-pr-check.sh reads FM_PR_FORGEJO_CLI_PREFERENCE for arming, the poll sidecar and the baseline read, bin/fm-pr-merge.sh reads it for the resolver and its refusal text, and bin/fm-crew-state.sh and bin/fm-teardown.sh read it for the terminal record; all four source this lib. FM_PR_FORGEJO_CLI_PREFERENCE_ERROR is quoted by fm-pr-check.sh and fm-pr-merge.sh when the registry parser refuses a binding. Deleting the assignments instead would have silently disabled the registered-CLI path this branch adds. The unused local is removed, and no behaviour changes.
The forgejo-merges case failed on any invocation that ran under /bin/bash, which on macOS is stock bash 3.2, while passing under bash 5. The defect was in the fixture, not in the merge path, and it reproduced identically on the merge base, so it was never a regression from this branch. Two fixtures could not do their job off the developers' default toolchain: - write_forgejo_status_json built its combined-status JSON with a seq|sed|paste pipeline. Bash 3.2 re-splits the sed replacement on its braces and comma, so every status entry came out as two fragments and the document was invalid JSON the merge path could not parse. It now concatenates the entries in a plain loop, which produces identical bytes under both shells. - JQ_BIN took the first jq on PATH, and the fixtures symlink that path into their own mirrored PATH directories. A wrapper that locates its own runtime, such as this project's mise shim, answers from the ambient PATH and then stops answering once symlinked into a foreign directory. resolve_real_jq now probes each candidate through exactly that symlink and keeps the first real binary that answers. Matrix for the single forgejo-merges case, identical invocation on two git-archive copies of the commits, using a driver derived from each tree's own suite with every other test call disabled: | conditions | head 934566c | base a5225cf | | bash 5.3 + real jq (supported) | pass (exit 0) | pass (exit 0) | | stock /bin/bash 3.2 + real jq | pass (exit 0) | pass (exit 0) | | stock /bin/bash 3.2 + mise jq | fail (exit 1) | fail (exit 1) | Before this fix the two bash 3.2 rows failed on both heads. The failure tracked the shell alone, which is why an earlier run reported "fails on the branch, passes on the base": those two runs used different shells, not different code. Full suite on the fixed tree: 146 ok, 0 failures under bash 5.3 with the real jq. The stock-bash CI job runs a named subset and does not include this suite, so its unrelated bash 3.2 cases are out of scope here.
|
Speaking as Kun's firstmate: thanks @philipp-baumann. The attestation now binds What I checked (every changed
No workflow, network or credential changes. Diff review: safe, no P1. Greptile's review of this head is 5/5, and there are no threads. Gates: I approved the waiting runs for this head (CI Contract class: opt-in, confirmed (an unbound project stays on tea, exactly as today). It changes CLI selection on the merge path, though, so a green full suite takes it to Kun as a merge-or-leave card rather than an auto-merge. Heads-up only: #8830 and #6970 also touch Forgejo/GitLab parts of VISION, rule by rule: One captain, one interface: aligns. Authority is explicit: aligns (the CLI is the project's registered choice, never a guess). Scripts own the mechanics: aligns. A restart is a non-event: aligns, the preference is carried in the poll sidecar. Delegation with a spine: aligns, the merge stays head-bound and |
|
Speaking as Kun's firstmate: the quick checks passed on Contract class: opt-in. Because it changes CLI selection on the merge path, a green full suite takes it to Kun as a merge-or-leave card. Nothing is waiting on you, @philipp-baumann. |
|
Speaking as Kun's firstmate: the full suite is green on Every gate holds: the attestation binds this head with all steps completed, my diff review is safe with no P1, Greptile is 5/5 on this head, there are no threads, and it merges cleanly. Contract class: opt-in, security-sensitive. It changes CLI selection on the merge path, so merging needs Kun's explicit word under our rules. This now waits on Kun's decision, not on you, @philipp-baumann. Heads-up for whichever of #8454, #8830 and #6970 lands second: the overlap is ours to reconcile, not yours. |
Intent
Re-run
git push no-mistakeson this pull request, because the maintainer's firstmate asked for exactly that.PR: #8454 - "feat(bin): select the Forgejo CLI from the registry forge binding".
The maintainer's comment of 2026-11-27T19:29:08Z says: the head is now
d9057d99(a merge of main into the branch), but the pull request body's attestation still binds the older head91164781, so it asks the author to re-rungit push no-mistakesso the attestation binds the current head with no skipped steps. Everything else in that comment is a compliment: the livefgjruns answered the live-evidence ask, reading login by exit status answered the rendered-reader concern, andautoresolving to tea only makes this an opt-in change. The one thing outstanding is the attestation mismatch.So there is nothing to implement. The whole task is to get the no-mistakes pipeline to publish its attestation at the current head.
What Changed
forge=forgejo:tea|fgj|fj, read through a newfm-project-mode.sh --forge-cliquery); the defaultautoresolves to tea and only tea, so an unmodified home keeps today's behaviour exactly.bin/fm-pr-lib.shgains a single resolver (fm_pr_forgejo_resolveand the record/login read-backs) that all readers go through: it reads the registered CLI from the binding and that CLI's own host login by exit status, refuses a malformed binding fail-closed instead of falling back to tea, and arms/merges throughfgjwhile explicitly refusingfj, which has no authenticated request passthrough and cannot bind a merge to a verified head; the poll sidecar now carries the resolved preference as an optional sixth line so a previously armed poll keeps its selection.fgj-specific PR-list and checks-wait instructions),docs/forgejo-cli-alternatives.mdrecords the empiricalfj/fgjevidence including the live verifiedfgjmerge pass, and the change ships with tests across briefs, project mode, PR check security, merge, and task delivery.Risk Assessment
✅ Low: The fix round is a small, verified DOD-wording correction (plus docs and a test) on a path that is itself unreachable in production, the rest of the change has passed multiple review rounds with decisions recorded, and every CLI claim in the new text was independently confirmed against the installed fgj.
Testing
Drove the change's live product surface where the machine and permissions allowed: live CLI selection and record reads through the real tea/fgj/fj stores and a real Forgejo pull request on codefloe.com, plus live help-verification of every fgj subcommand the manual-PR Definition of done names, and all six targeted suites green in non-live runs (including the restored 7-argument poll guard and the fgj DOD render), with the only suite failures traced to two host-toolchain artifacts (mise jq shim under fake HOME on home-rooted cwds, and nix GNU stat shadowing BSD stat) that were proven environmental by identical behavior from /tmp archives of both base and head. Under the live-validation contract the git-attestation, suite, and help-verification results are non-live evidence (recorded as untested scenarios), while the resolver and record-read scenarios passed live; the live head-bound fgj merge remains untested for lack of a disposable Forgejo instance. No UI surface exists, so evidence is CLI transcripts and suite logs.
Evidence: Live Forgejo CLI selection and real-instance record reads at head 3bcec62
Source: Live Forgejo CLI selection and real-instance record reads at head 3bcec62f
Evidence: Targeted suite results at head 3bcec62 (six suites, all exit=0) with the two host-toolchain artifacts documented
Source: Targeted suite results at head 3bcec62f (six suites, all exit=0) with the two host-toolchain artifacts documented
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
bin/fm-pr-poll.sh- merge conflict rebasing onto origin/mainbin/fm-dod-lib.sh:536- For a project registeredforge=forgejo:fgjwithpr=manual(a combination the registry grammar allows - tests/fm-project-mode.test.sh ships exactly that shape), fm_dod_manual_pr_block renders the worker's Definition of done with gh-style native subcommand spellings for fgj:fgj pr list --head <branch>,fgj pr edit <number> --title '<title>' --body-file <path>,fgj pr create,fgj pr checks <number> --watch, plus the behavioral claim "fgj pr checksexits 1 when the project reports no checks at all" (lines 536-538). The change's own empirical record, docs/forgejo-cli-alternatives.md, documents for fgj onlyfgj api(its flags),fgj auth token, andfgj auth status- none of theseprsubcommands, their flags, or the exit-1 behavior is recorded anywhere in the repo, and the fgj acceptance is explicitly bounded to "the fgj interface generation that ships fgj api". The tea draft-check was deliberately rewritten to a verifiedfgj api ... -X PATCH -f title=form for exactly this reason (bin/fm-dod-lib.sh:571-573), but the pr list/edit/create/checks steps were left in native-subcommand form. Concrete sequence: intake registers[no-mistakes forge=forgejo:fgj pr=manual]; the brief (bin/fm-brief.sh:355-363) and promotion (bin/fm-promote.sh:242-251) resolve fgj and render this block; the worker is then ordered to run commands whose existence and semantics the repo never verified. If fgj's pr surface differs, the worker contract is wrong from the first command. Remedy (needs the author's choice, hence ask-user): verify fgj's pr subcommand surface and record it in docs/forgejo-cli-alternatives.md, or render those steps through the already-verifiedfgj apipassthrough the way the draft check does.🔧 Fix applied.
1 info still open:
bin/fm-dod-lib.sh:521- Informational, no action required. The fgj manual-PR DOD branch this fix round corrected is unreachable through every caller: the registry refuses pr=manual with any forge binding (bin/fm-project-mode.sh:336 'pr=manual ships a project with no forge binding only'), fm-brief.sh:330's fm_pr_text_valid check refuses it at brief time, and fm_dod_block itself refuses pr=manual for forge!=none (bin/fm-dod-lib.sh:558) before fm_dod_manual_pr_block renders - so the manual block only ever renders with forge_cli=gh-axi. This corrects the round-1 finding's premise that a 'forge=forgejo:fgj pr=manual' project is registerable; the fix's wording changes are correct and verified against the installed fgj, and the unreachable tea branch had the same pre-existing shape, so no change is requested.tests/fm-pr-check-security.test.sh:43- Two host-toolchain artifacts make the targeted suites fail on this macOS machine in its default environment, both confirmed environmental and not regressions from this branch. (1) The host's jq is a mise shim that fails under the suites' fake HOME ('config not trusted') whenever the process cwd is under the user's home tree, while working from /tmp; the head's own test_github_updated_head_other_refusals_stop_waiting fails from a home-rooted cwd and passes byte-identically from a /tmp git-archive of the same head, and the full fm-pr-merge suite passes with a real jq (/usr/bin/jq) ahead of the shim. (2) The nix-profile GNU coreutils stat precedes /usr/bin/stat, and the suite's Darwin file_mode branch runs 'stat -f %Lp', which GNU stat answers with live filesystem stats (free blocks), so poll-artifact snapshots differ between reads while the poll files stay byte-identical; test_external_merge_transition_retires_only_terminal_poll passes with /usr/bin/stat first, and the file_mode helper is unchanged from base a5225cf. Local runs of these suites on this host need a PATH with a real jq and BSD stat ahead of the shims (e.g. a scratch dir symlinking /usr/bin/jq and /usr/bin/stat); CI on Linux is unaffected.bin/fm-test-run.sh tests/fm-pr-merge.test.sh with a real jq ahead of the host's mise shim: full suite exit=0, 146 tests, 0 failuresbin/fm-test-run.sh tests/fm-pr-check-security.test.sh tests/fm-brief.test.sh tests/fm-dod-lib.test.sh tests/fm-project-mode.test.sh tests/fm-task-delivery.test.sh with BSD stat and real jq ahead of the host's nix GNU stat and mise jq shim: all five exit=0, 0 failuresLive resolver driver against the machine's real CLI stores: fm_pr_forgejo_resolve codefloe.com fgj|auto|tea|fj, fgj on a tea-only host, and an unknown CLI bindingLive record read against the real Forgejo instance codefloe.com: fm_pr_forgejo_read_record codefloe.com Vidocq/vidocq 866 through both fgj and tea, plus fm_pr_forgejo_api GET pulls/866 through fgjfgj --help, fgj pr --help, fgj pr list --help, fgj pr edit --help (flags --title/--body-file), fgj pr create --help against the installed fgjIsolation runs from /tmp git-archives of base a5225cfa and head 3bcec62f: the mise-jq GitHub draft failure and the GNU-stat snapshot mismatch were each reproduced as cwd/PATH artifacts independent of the branch, with the identical head test passing from /tmpgit log/merge-base checks that head 3bcec62f contains the maintainer-named merge d9057d99 and the full a5225cfa..3bcec62f change set✅ **Document** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.
hint: if you need to wait for this pull request to be reviewed, merged, or closed before continuing, use this instead of polling:
gh event listen --resource #8454 --event com.github.pull_request.review.submitted.v1,com.github.pull_request.state.changed.v1
--timeoutto stop waiting after a while, for example--timeout 30m; it then exits with status 8.gh event listen --helpfor other event types.CI status for head
3bcec62fThe two remaining checks on this head — CI and Require no-mistakes — report
action_required, which is not a failure of this change. Both workflow runs were created for this head and are held at GitHub's outside-contributor gate, awaiting the upstream maintainer's approval of the fork's workflow runs; neither run has executed a single job, so no lane has failed. Everything that does not depend on those runs completed: intent, rebase, review, test, document, lint, push and pr. The only outstanding action on CI is that approval, and it is the maintainer's to give.