Skip to content

feat(bin): select the Forgejo CLI from the registry forge binding - #8454

Open
philipp-baumann wants to merge 29 commits into
kunchenguid:mainfrom
philipp-baumann:fm/forgejo-cli-alternatives
Open

philipp-baumann wants to merge 29 commits into
kunchenguid:mainfrom
philipp-baumann:fm/forgejo-cli-alternatives

Conversation

@philipp-baumann

@philipp-baumann philipp-baumann commented Nov 13, 2026 •

Copy link
Copy Markdown

Intent

Re-run git push no-mistakes on 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 head 91164781, so it asks the author to re-run git push no-mistakes so the attestation binds the current head with no skipped steps. Everything else in that comment is a compliment: the live fgj runs answered the live-evidence ask, reading login by exit status answered the rendered-reader concern, and auto resolving 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

  • A project's registry binding can now name the Forgejo CLI that drives its pull requests (forge=forgejo:tea|fgj|fj, read through a new fm-project-mode.sh --forge-cli query); the default auto resolves to tea and only tea, so an unmodified home keeps today's behaviour exactly.
  • bin/fm-pr-lib.sh gains a single resolver (fm_pr_forgejo_resolve and 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 through fgj while explicitly refusing fj, 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.
  • Ship briefs, Definition-of-done blocks, promotion, watch, teardown, and crew-state reads now honor the registered CLI (rendering fgj-specific PR-list and checks-wait instructions), docs/forgejo-cli-alternatives.md records the empirical fj/fgj evidence including the live verified fgj merge 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.

  • Live validation: ✅ go - 5 of 9 scenarios driven live against the product
Scenario Result Live Evidence
Attestation head integrity: the head the pipeline re-attests is the branch tip 3bcec62, which contains the maintainer-named merge d9057d9 of main plus the complete Forgejo CLI selection change ⏸️ untested no The prior payload's only evidence was static repository analysis (git log/merge-base output), not a drive against the running product, and it recorded live=false; static git inspection does not establ…
Registered fgj project: forge=forgejo:fgj resolves fgj together with fgj's own host login ✅ pass live live-forgejo-cli-selection.txt: fm_pr_forgejo_resolve codefloe.com fgj -> cli=fgj login=codefloe.com against the machine's real fgj auth store
Unchanged default: a bare forge=forgejo (auto) resolves tea and only tea, never adopting fgj's or fj's stored login ✅ pass live live-forgejo-cli-selection.txt: fm_pr_forgejo_resolve codefloe.com auto -> cli=tea login=codefloe.com, and the same record read through auto matches tea's
No silent fallback: an explicit CLI preference that holds no login for the host refuses instead of switching CLIs ✅ pass live live-forgejo-cli-selection.txt: fm_pr_forgejo_resolve git.dse.allianceswisspass.ch fgj (a tea-only host) -> rc=1 with empty CLI/login; unknown binding also refused
fj is recognized and refused by name: the resolver resolves fj and its login predicate, but every operation needing the pull request record refuses fj for its missing api passthrough (arming and merge… ✅ pass live live-forgejo-cli-selection.txt: fm_pr_forgejo_resolve codefloe.com fj -> cli=fj login=codefloe.com, and fm_pr_forgejo_cli_api_capable fj -> refused; fj arming/merge refusals also exercised non-live by…
fgj reads a real pull request record from a real Forgejo instance, returning the same machine-readable state/merged/head record as tea ✅ pass live live-forgejo-cli-selection.txt: fm_pr_forgejo_read_record codefloe.com Vidocq/vidocq 866 fgj and auto both return state=open merged=false head=edebc6d72d441200af0a1b30fd395edbb1dd71e4, plus the raw fg…
fgj manual-PR Definition of done names only subcommands verified against the installed fgj's own help (fgj pr list, fgj pr edit --title/--body-file, fgj pr create), with no fgj pr checks claim ⏸️ untested no The prior payload recorded live=false: its evidence was a non-live unit-suite log (fm-dod-lib exit=0) plus --help transcripts of the installed fgj, and help-text invocation alone was not treated as a…
Targeted suites covering this change pass at the current head, including the restored 7-argument poll preference guard and the fgj/fj arming, merge, brief, and promotion paths ⏸️ untested no The prior payload recorded live=false: the suite runs in targeted-suites.txt are harness-driven test executions against stubs and fake HOME environments, not drives against the real running product, s…
Live head-bound fgj merge against a real Forgejo instance: refuse a wrong-head merge, land the head-bound merge, poll merged state back ⏸️ untested no No disposable Forgejo instance is available to this phase: the machine's only reachable Forgejo logins (codefloe.com and a private work instance) are production forges where the runbook forbids creati…
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

# Live Forgejo CLI selection evidence at head 3bcec62f

## fm_pr_forgejo_resolve against the machine's real CLI stores
fgj opt-in: rc=0 cli=fgj login=codefloe.com
auto: rc=0 cli=tea login=codefloe.com
explicit tea: rc=0 cli=tea login=codefloe.com
fgj on a tea-only host: rc=1 cli= login= (refused, no fallback)
unknown cli binding: rc=1
fj opt-in: rc=0 cli=fj login=codefloe.com
fj api-capable: refused (exit 1) - fj can never serve the record

## Live record read of real open PR Vidocq/vidocq#866 on codefloe.com
fgj read: rc=0 state=open merged=false head=edebc6d72d441200af0a1b30fd395edbb1dd71e4
tea (auto) read: rc=0 state=open merged=false head=edebc6d72d441200af0a1b30fd395edbb1dd71e4

## Raw fgj api view used by the merge path (fgj api, the verified passthrough)
{"state":"open","merged":false,"head":"edebc6d72d441200af0a1b30fd395edbb1dd71e4"}

## fgj manual-PR DOD subcommands, verified against the installed fgj help
fgj pr list --help: exit 0
fgj pr edit --help: exit 0 (flags: 2 of --title/--body-file present)
fgj pr create --help: exit 0
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

# Targeted suite results at head 3bcec62f (2026-11-28T09:48:01Z)

Run 1 - tests/fm-pr-merge.test.sh (full suite, 146 tests) with a real jq ahead of the host's mise jq shim:
FM_TEST_END 2026-11-28T09:08:49Z tests/fm-pr-merge.test.sh exit=0 duration_ms=1017733 gate_skip=false

Run 2 - five targeted suites with BSD stat and real jq ahead of the host's nix GNU stat and mise jq shim:
FM_TEST_END 2026-11-28T09:24:12Z tests/fm-brief.test.sh exit=0 duration_ms=27958 gate_skip=false
FM_TEST_END 2026-11-28T09:24:14Z tests/fm-project-mode.test.sh exit=0 duration_ms=1426 gate_skip=false
FM_TEST_END 2026-11-28T09:24:35Z tests/fm-dod-lib.test.sh exit=0 duration_ms=21997 gate_skip=false
FM_TEST_END 2026-11-28T09:26:17Z tests/fm-task-delivery.test.sh exit=0 duration_ms=124172 gate_skip=false
FM_TEST_END 2026-11-28T09:39:54Z tests/fm-pr-check-security.test.sh exit=0 duration_ms=817579 gate_skip=false
FM_TEST_SUMMARY total=5 failed=0 skipped_gate=0 duration_ms=970288
FM_TEST_SUMMARY_FAMILY family=pr-forge count=1 duration_ms=817579 failed=0
FM_TEST_SUMMARY_FAMILY family=pure-contract-unit count=4 duration_ms=175553 failed=0

## Host artifacts ruled out as regressions (identical mechanism on base a5225cfa)
- mise jq shim: under the suites' fake HOME the shim fails ('config not trusted') whenever cwd is under the user's home tree; it works 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; run 1 above passes the whole suite with a real jq first.
- GNU coreutils stat first on PATH (nix profile) breaks the suite's Darwin file_mode branch 'stat -f %Lp': GNU stat -f prints live filesystem stats (free blocks), so the poll-artifact snapshot differed between reads while the poll files stayed byte-identical. test_external_merge_transition_retires_only_terminal_poll passes with /usr/bin/stat (BSD) first; the file_mode helper is unchanged from base a5225cfa (tests/fm-pr-check-security.test.sh:43).
- Outcome: ⚠️ 1 info across 1 run (1h14m55s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

⚠️ **Rebase** - 1 warning
  • ⚠️ bin/fm-pr-poll.sh - merge conflict rebasing onto origin/main
⚠️ **Review** - 1 info
  • ⚠️ bin/fm-dod-lib.sh:536 - For a project registered forge=forgejo:fgj with pr=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 checks exits 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 only fgj api (its flags), fgj auth token, and fgj auth status - none of these pr subcommands, 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 verified fgj 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-verified fgj api passthrough 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.
⚠️ **Test** - 1 info
  • ℹ️ 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.
  • Live validation: ✅ go - 5 of 9 scenarios driven live against the product
Scenario Result Live Evidence
Attestation head integrity: the head the pipeline re-attests is the branch tip 3bcec62, which contains the maintainer-named merge d9057d9 of main plus the complete Forgejo CLI selection change ⏸️ untested no The prior payload's only evidence was static repository analysis (git log/merge-base output), not a drive against the running product, and it recorded live=false; static git inspection does not establ…
Registered fgj project: forge=forgejo:fgj resolves fgj together with fgj's own host login ✅ pass live live-forgejo-cli-selection.txt: fm_pr_forgejo_resolve codefloe.com fgj -> cli=fgj login=codefloe.com against the machine's real fgj auth store
Unchanged default: a bare forge=forgejo (auto) resolves tea and only tea, never adopting fgj's or fj's stored login ✅ pass live live-forgejo-cli-selection.txt: fm_pr_forgejo_resolve codefloe.com auto -> cli=tea login=codefloe.com, and the same record read through auto matches tea's
No silent fallback: an explicit CLI preference that holds no login for the host refuses instead of switching CLIs ✅ pass live live-forgejo-cli-selection.txt: fm_pr_forgejo_resolve git.dse.allianceswisspass.ch fgj (a tea-only host) -> rc=1 with empty CLI/login; unknown binding also refused
fj is recognized and refused by name: the resolver resolves fj and its login predicate, but every operation needing the pull request record refuses fj for its missing api passthrough (arming and merge… ✅ pass live live-forgejo-cli-selection.txt: fm_pr_forgejo_resolve codefloe.com fj -> cli=fj login=codefloe.com, and fm_pr_forgejo_cli_api_capable fj -> refused; fj arming/merge refusals also exercised non-live by…
fgj reads a real pull request record from a real Forgejo instance, returning the same machine-readable state/merged/head record as tea ✅ pass live live-forgejo-cli-selection.txt: fm_pr_forgejo_read_record codefloe.com Vidocq/vidocq 866 fgj and auto both return state=open merged=false head=edebc6d72d441200af0a1b30fd395edbb1dd71e4, plus the raw fg…
fgj manual-PR Definition of done names only subcommands verified against the installed fgj's own help (fgj pr list, fgj pr edit --title/--body-file, fgj pr create), with no fgj pr checks claim ⏸️ untested no The prior payload recorded live=false: its evidence was a non-live unit-suite log (fm-dod-lib exit=0) plus --help transcripts of the installed fgj, and help-text invocation alone was not treated as a…
Targeted suites covering this change pass at the current head, including the restored 7-argument poll preference guard and the fgj/fj arming, merge, brief, and promotion paths ⏸️ untested no The prior payload recorded live=false: the suite runs in targeted-suites.txt are harness-driven test executions against stubs and fake HOME environments, not drives against the real running product, s…
Live head-bound fgj merge against a real Forgejo instance: refuse a wrong-head merge, land the head-bound merge, poll merged state back ⏸️ untested no No disposable Forgejo instance is available to this phase: the machine's only reachable Forgejo logins (codefloe.com and a private work instance) are production forges where the runbook forbids creati…
  • 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 failures
  • bin/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 failures
  • Live 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 binding
  • Live 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 fgj
  • fgj --help, fgj pr --help, fgj pr list --help, fgj pr edit --help (flags --title/--body-file), fgj pr create --help against the installed fgj
  • Isolation 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 /tmp
  • git 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.

⚠️ **Lint** - 1 warning
  • ⚠️ linter found issues (exit code 1)
✅ **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

  • It prints the first event as a JSON line on stdout and exits; run it again to wait for the next one.
  • Add --timeout to stop waiting after a while, for example --timeout 30m; it then exits with status 8.
  • Events carry no details; read the pull request to see what changed.
  • It misses changes made before it starts, so read the pull request once it is running.
  • See gh event listen --help for other event types.
  • Event subscriptions are in preview and may not be enabled for your account.

CI status for head 3bcec62f

The 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.

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.
@philipp-baumann
philipp-baumann marked this pull request as ready for review November 13, 2026 22:12
@greptile-apps

greptile-apps Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5 · The code appears safe to merge; no new blocking defect was established.RetriggerView in GreptileConfidence Score: 5/5

[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

Comment thread bin/fm-pr-lib.sh Resolved
@kunchenguid

Copy link
Copy Markdown
Owner

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 fj can and can't do (no head-bound merge, so it's refused) is careful work.

I read the full diff at 72728dd7 against main 427056c4. There are no workflow, CI, credential-store or installer changes, and the merge keeps head_commit_id through both tea and fgj. I've approved the fork CI and the no-mistakes check runs for this head. The attestation binds this head with no skipped steps.

Waiting on you for these:

  1. The fgj auth status reader (Greptile's open P2 thread on bin/fm-pr-lib.sh). fm_pr_forgejo_fgj_login and its copy in bin/fm-pr-poll.sh parse fgj's human-readable status line. fm_pr_forgejo_fj_login does the same with fj auth list. Our VISION only allows reading a rendered surface through a named, quarantined, version-pinned adapter with its own verification, recorded as a known debt. The new doc deliberately leaves versions out. If fgj has a structured (JSON) way to list its hosts, please use that. If not, put the reader behind a pinned adapter with its own verification. Then reply on the thread and resolve it.
  2. Live evidence. The PR body has no live-validation section. Please run a watch arm, a merged-state poll and a head-bound merge through fgj against a real Forgejo or Gitea instance and post the transcript (or include it via the re-raise).
  3. Make the new CLIs opt-in (suggested). With a plain forge=forgejo entry, auto now falls through tea, then fgj, then fj. A home whose tea has no single login for the host would start merging with a different CLI's stored login that the captain never named. If auto stays tea-only and fgj is used only when the project says forge=forgejo:fgj, this becomes an opt-in change. As it stands I read it as new-default (my own call), which means Kun decides the merge himself even after everything is green.

Once those are in, please re-raise with one clean git push no-mistakes so the attestation binds the new head.

philipp-baumann added 9 commits November 16, 2026 17:11
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).
@philipp-baumann

Copy link
Copy Markdown
Author

Live evidence for both open asks, run against real Forgejo pull requests on codefloe.com (ephemeral docs PRs opened and merged for this run — see the home-manager repo philipp-baumann/agentic-tooling-and-configs).

Ask 1 — the rendered reader. fj's login is now read through fj whoami --host <host>'s exit status, not its rendered fj auth list report; fgj continues to use fgj auth token --hostname <host>'s exit status. No display surface is parsed, so no version-pinned adapter is needed. (fj whoami --host codefloe.com exits 0 logged-in, --host nowhere.example exits 1.)

Ask 2 — live validation. Every step below is bin/fm-pr-merge.sh / bin/fm-pr-check.sh from the branch head; a logging fgj shim first on PATH captures the exact requests.

# HEAD-BOUND MERGE THROUGH fgj  (PR #394)
bin/fm-pr-merge.sh task-x1 https://codefloe.com/philipp-baumann/agentic-tooling-and-configs/pulls/394 \
  --expected-head 9d4218b8d0b82875c909416faa8b3078f1815266
-> exit 0
   verified: .../pulls/394 is open and mergeable, with a successful combined
             status at head 9d4218b8d0b82875c909416faa8b3078f1815266
   requests:
     api repos/.../pulls/394 --hostname codefloe.com
     api repos/.../commits/9d4218b8.../status?limit=50&page=1 --hostname codefloe.com
     api repos/.../pulls/394/merge --hostname codefloe.com -X POST -f Do=squash \
         -f head_commit_id=9d4218b8d0b82875c909416faa8b3078f1815266   <- bound to the head
   Forgejo: {"state":"closed","merged":true,"merge_commit_sha":"18372c63305f22330ca4fd3bd8d574437bdaeafd","head":"9d4218b8..."}

# MERGED-STATE READ THROUGH fgj
fm_pr_forgejo_read_record codefloe.com philipp-baumann/agentic-tooling-and-configs 394 fgj
-> state=closed merged=true head=9d4218b8d0b82875c909416faa8b3078f1815266

# WATCH ARM + MERGED WAKE THROUGH fgj  (PR #395, open at arm time)
bin/fm-pr-check.sh task-y1 https://codefloe.com/philipp-baumann/agentic-tooling-and-configs/pulls/395
-> armed: state/task-y1.check.sh
   sidecar state/task-y1.pr-poll sixth line: fgj
   poll while open: stdout empty; request: api repos/.../pulls/395 --hostname codefloe.com
bin/fm-pr-merge.sh task-y1 .../pulls/395 --expected-head 3ebd89892d25269912a3f996f2fd889112368c19
-> exit 0
   the armed poll then emitted its merged wake: "merged"
   Forgejo: {"state":"closed","merged":true,"merge_commit_sha":"616939dd6597787accb037cc88c5bbac8b5aeb48","head":"3ebd8989..."}

# OPT-IN CONFIRMED
fm_pr_forgejo_resolve codefloe.com auto  -> tea   (never adopts fgj)
fm_pr_forgejo_resolve codefloe.com fgj   -> fgj / codefloe.com

Ask 3 — opt-in is in: a bare forge=forgejo resolves auto to tea, so this is an opt-in change, not a new default. The PR description's "Behaviour change" section now says so.

@philipp-baumann philipp-baumann changed the title feat(bin): support alternate Forgejo CLIs in the pull request watch and merge feat(bin): select a project's Forgejo CLI for PR watch and merge Nov 17, 2026
@philipp-baumann

Copy link
Copy Markdown
Author

Re-raised: the branch is now at head 2700df59, bind by the pipeline attestation below. What moved past the reviewed 72728dd:

  • Ask 1 (adapter). fj's login is read through fj whoami --host <host>'s exit status (no rendered fj auth list parse); fgj continues on fgj auth token --hostname. The Greptile P2 thread is answered and resolved.
  • Ask 2 (live evidence). Head-bound merge, merged-state read, and an armed watch's merged wake were all driven through fgj against real Forgejo PRs on codefloe.com — posted above.
  • Ask 3 (opt-in). auto is tea and only tea; fgj is reached only by naming forge=forgejo:fgj. The description's "Behaviour change" section now says so.

The gate's own review then surfaced two further findings on this branch's new code, both acted on honestly:

  1. Fixed — fm_pr_forgejo_cli_preference treated a refused binding (fm-project-mode.sh --forge-cli exit 3, e.g. forge=forgejo:fgg) as auto and fell back to tea. It now propagates the parser's own message and makes arming and the merge refuse; an absent registry or unknown project still resolves auto.
  2. Deferred, stated plainly — the resolved CLI is snapshotted into brief prose only; bin/fm-spawn.sh's brief/registry agreement check still compares mode, forge, pr and upstream-consent but not the CLI. So a captain who changes forge=forgejo:tea to :fgj and relaunches could get a worker briefed for tea while arming/merge resolve fgj. The smallest honest fix is a machine-readable forge-cli= token on the Delivery-contract line plus a matching spawn refusal — a new generated-contract token and a new spawn refusal, i.e. a wider surface than this PR. It is left as a follow-up rather than smuggled in here.

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.
@philipp-baumann philipp-baumann changed the title feat(bin): select a project's Forgejo CLI for PR watch and merge feat(bin): select the Forgejo CLI from the registry forge binding Nov 21, 2026
@philipp-baumann

Copy link
Copy Markdown
Author

Live fgj evidence, as asked in the triage on 13 Nov: a watch arm, a head-bound merge and a merged-state poll driven through fgj against a real Forgejo instance.

Where and what. Instance codefloe.com (self-hosted Forgejo), released fgj build, against a throwaway private repository created for this run and one pull request in it. Every step below is the shipped script from this branch, with the branch's own registry binding forge=forgejo:fgj selecting the CLI, so nothing here is a stub of firstmate's logic.

Which head. The run was made at a9a259ee. The current head 91164781 differs from it only by a documentation commit (README.md and docs/configuration.md prose about fj), so the transcript below was not produced at 91164781 and is not claimed to be.

  1. Watch arm — bin/fm-pr-check.sh armed the watch and recorded fgj on the poll sidecar's sixth line, so the merge watch resolves the same CLI the registry named.

    $ bin/fm-pr-check.sh taskl https://codefloe.com/.../pulls/1
    armed: state/taskl.check.sh            # exit 0
    $ sed -n 6p <home>/state/taskl.pr-poll
    fgj
    
  2. Head-bound merge — bin/fm-pr-merge.sh --expected-head <sha> verified the live head and merged with head_commit_id bound to it:

    verified: https://codefloe.com/.../pulls/1 is open and mergeable, with a successful combined status at head 291e84c7...
    $ echo $?
    0
    

    The first attempt refused on real data for the right reason — a brand-new repository reports no commit status — and the merge went through after one success status was posted for that head: the combined commit status is "none", not success.

  3. Merged-state poll — the same CLI reads the merged record; no rendered output is involved:

    $ bin/fm-pr-poll.sh --validated forgejo https://codefloe.com/.../pulls/1 codefloe.com <owner>/<repo> 1 fgj
    merged                                  # exit 0
    $ fgj api repos/<owner>/<repo>/pulls/1 --hostname codefloe.com
    {"state":"closed","merged":true,"head":"291e84c7..."}
    

Verdict: all three passed. The throwaway repository used for the merge was deleted afterwards, and no project repository was touched.

@kunchenguid

Copy link
Copy Markdown
Owner

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 fgj runs on codefloe.com answer my live-evidence ask, and reading login by exit status (fj whoami --host, fgj auth token --hostname) answers the rendered-reader concern. I also see auto now resolves to tea only, so fgj/fj are reached only by naming forge=forgejo:<cli>. On that shape the contract class becomes opt-in, and I'll confirm it in the full review. Deferring the brief/registry forge-cli= agreement check to a follow-up is a fair call, and thanks for stating it plainly.

Where it stands: this waits on you (author). The head is now d9057d99 (your merge of main), but the body's attestation still binds 91164781. Please re-run git push no-mistakes so the attestation binds the current head with no skipped steps.

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.
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @philipp-baumann. The attestation now binds 3bcec62f with every step completed. Here is the full review I promised, against main 9ac0288e (your branch merges cleanly).

What I checked (every changed bin/ file, merge and watch paths first):

  • fm_pr_forgejo_resolve: auto (or empty) resolves to tea and only tea. fgj and fj are reached only when the project's binding names them, and a named CLI that isn't installed or has no login for the host refuses rather than falling back. The host is restricted to [a-z0-9.-].
  • Login presence for fgj and fj is read only from exit status (fgj auth token --hostname, fj whoami --host), with stdout and stderr sent to /dev/null. The token is never captured, and the config file is never parsed.
  • fm_pr_forgejo_api runs only for an API-capable CLI (tea or fgj). It refuses fields on a GET and requires them on a POST, and it leaves error-output handling to each caller.
  • fm-pr-merge.sh resolves the CLI, refuses fj by name, and keeps every read and the head_commit_id-bound merge on the same REST record. A binding that fm-project-mode.sh itself rejects (exit 3) refuses with that message instead of falling back to tea.
  • The poll sidecar's optional sixth line accepts only auto|tea|fgj|fj, and a missing line reads as auto. The prepare, publish and snapshot steps compare it like the other fields, so an older armed poll keeps its selection.
  • Briefs, DoD text, watch, teardown, crew-state and promote follow the same preference.

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 46139118366, Require no-mistakes 46139118310 and 46142299303). full-ci follows once the quick checks report. Nothing is needed from you.

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 fm-pr-merge.sh. If one lands first and this one then conflicts, the conflict is ours to resolve, not yours.

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 fj is refused. Fleet outlives any vendor: aligns. Scope: aligns.

@kunchenguid kunchenguid added the full-ci Maintainer go-ahead: run the full CI suite on this outside pull request label Nov 28, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: the quick checks passed on 3bcec62f (CI 46139118366), so I've added full-ci and approved the labelled run (46181239804). Main is 30dae608 and green, and your branch still merges cleanly after #8834 landed. Every other gate from my last note holds: the attestation binds this head with all steps completed, the diff review is safe with no P1, Greptile is 5/5 and there are no threads.

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.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: the full suite is green on 3bcec62f (CI 46181239804, 32 of 32 jobs). The head is unchanged, and main is 30dae608 and green.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-ci Maintainer go-ahead: run the full CI suite on this outside pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants