Repository navigation
fix(bin): let an attended --allow-no-pipeline merge a Forgejo PR whose head has no commit statuses - #8830
fix(bin): let an attended --allow-no-pipeline merge a Forgejo PR whose head has no commit statuses#88300xtechnoir wants to merge 2 commits into
Conversation
…e head has no commit statuses
[Medium impact] The PR appears safe to merge; the previous failed-read issue is fixed. Reviews (2) · Last reviewed commit: "no-mistakes(ci): Fixed ci-1 (Greptile). ..." · Reviewed by Greptile |
… `--allow-no-pipeline` waiver may only treat a Forgejo head as having no statuses ("none") when the response really is a combined-status object that reports zero statuses. Every status page goes through one parser in `bin/fm-pr-merge.sh`, the jq filter in the paged loop. It is the only place in `bin/` that reads `.statuses`, so fixing it covers page 1, later pages, and both the waived and default paths. Before the fix, the parser accepted any JSON object, because a missing `statuses` field became `[]`. So an error body such as `{"message":"Internal Server Error"}`, which `tea api` can print with exit status 0, was read as zero statuses. The waiver then let the merge through. The filter now also requires `has("statuses") or .total_count == 0`. Anything without that shape sets `ci_state=unreadable` and the merge is refused. Responses that were valid before still pass: `statuses: []`, `statuses: null` with `total_count: 0`, and ordinary success or failure pages. I also added a short comment above the loop explaining the rule. New test in `tests/fm-pr-merge.test.sh` (in `test_forgejo_allow_no_pipeline_merges_only_zero_statuses`): the fake `tea api` returns that error body with exit 0 under `--allow-no-pipeline`. The test expects exit 1, the refusal message `the combined commit status is "unreadable", not success`, and no merge call. Verification: - I ran the 18 Forgejo and allow-no-pipeline tests from `tests/fm-pr-merge.test.sh` with the fix: all passed. - Against the old parser, the new test fails ("expected exit 1, got 0"), so it reproduces the bug. - `bash -n` passes. - The full `tests/fm-pr-merge.test.sh` suite did not finish: it took longer than the 10-minute background limit and was stopped, so I ran the subset above instead. - shellcheck is not installed here, so lint was not run
|
Speaking as Kun's firstmate: thanks @0xtechnoir, and welcome. This is my first look, at head What I checked (line by line, all 5 files): Gates: the no-mistakes attestation binds this head with every step completed, and live validation is go (7/7 against a local Forgejo 11). This is a first contribution from this fork, so I approved the CI and Require no-mistakes runs for this head ( Contract class: opt-in. Nothing changes unless a captain-ordered, attended VISION, rule by rule: One captain, one interface: aligns (no hand-run |
|
Speaking as Kun's firstmate: a short status note, @0xtechnoir. Head Nothing is needed from you. Contract class stays opt-in, diff review stays safe, no P1, and a green full suite takes this to Kun as a merge-or-leave card, because it waives a merge guard. |
|
Speaking as Kun's firstmate: the full suite is green on Because this waives a merge guard (attended |
Intent
Fix the Firstmate issue described in this local draft, and open it as a pull request on Firstmate's GitHub (kunchenguid/firstmate) from a fork under the operator's GitHub login (option 1, chosen 2026-11-27: "go with option 1").
The draft:
On a Gitea/Forgejo repository with no status-reporting CI (combined commit status
pending,total_count: 0, including on the default branch),bin/fm-pr-merge.shrefuses every pull request: "the combined commit status is "none", not success". The help text documents this, and--allow-red,--allow-missingand--allow-no-pipelinedo not apply to Forgejo. So when the captain explicitly orders the merge there is no guarded path; the only route left is a directtea api POST .../pulls/<n>/mergewithhead_commit_id, which skips the helper's merge-metadata recording.Expected: an attended, captain-ordered equivalent of GitLab's
--allow-no-pipelinefor Forgejo: allowed only when the head has zero statuses (not when a status is failing or pending), still head-bound, and still recording merge metadata so teardown can prove landed work.Repro: register a forge=forgejo project whose repo has no CI; open a ready, non-draft, mergeable PR;
bin/fm-pr-merge.sh <task> <pr-url>is refused whatever the captain says.What Changed
bin/fm-pr-merge.shnow accepts--allow-no-pipelineon Forgejo as well as GitLab; it is still refused on GitHub. On Forgejo it waives only the combined-status check, and only when the head's status isnone, meaning zero statuses across every page. Afailure,pending,erroror unreadable status still refuses, and so does any other failed condition. The merge stays bound to the verified head throughhead_commit_id, gets recorded the same way as a green merge, and is refused while the away-posture record exists. A waived merge gets its ownverified: ... with no commit statuses, waived by --allow-no-pipelineline, and the--allow-red,--allow-missingand away-posture errors now name the Forgejo case.tests/fm-pr-merge.test.shadds Forgejo cases:AGENTS.md,docs/architecture.mdanddocs/forgejo-tea-integration.mddescribe the Forgejo zero-status waiver. The Forgejo doc also notes that newer instances report an empty head as"state":"pending"withtotal_count: 0.🤖 Generated with Claude Code
Risk Assessment
✅ Low: The waiver is narrowly gated: it applies only when
ci_stateisnone, which happens only when the first status page is empty. That covers both empty-state and pending-with-zero-count heads. Failing, pending, error and unreadable statuses still refuse, and so do the open, mergeable and draft checks, the head binding through head_commit_id, and the away-posture refusal. Merge metadata is recorded on the same path a green merge uses, and the tests check all of this behaviorally against mocks.Testing
I stood up my own throwaway Forgejo 11 container with a repository that has no CI (it reports
state:""andtotal_count:0). Then I drove the realbin/fm-pr-merge.shthrough the realteaCLI against a marked lab home with aforge=forgejoproject. Without the flag the helper still refuses with "none, not success", which reproduces the reported problem. With--allow-no-pipelineit merges the PR, the POST is bound to the verified head throughhead_commit_id, and Forgejo shows the PR merged. The task metadata and durable state files match those of a normal green merge. The flag still refuses a failing status, a pending status, the away posture and a stale--expected-head, and leaves those PRs open. I also ran the four targeted unit tests for this behaviour; they pass. The container, lab home and temp files are removed. The evidence is CLI transcripts, since there is no UI. Teardown's landed-work check was not run end to end; I only confirmed that the recorded metadata matches the green path.--allow-no-pipelineon a zero-status Forgejo PR merges it, and Forgejo shows the PR merged (local Forgejo 11 container)--allow-no-pipelineon a PR whose head has a failure status, or a pending status, still refuses and the PR stays open--allow-no-pipelineis refused while the away-posture record exists--expected-headtogether with--allow-no-pipelinerefuses before any mergehead_commit_idequal to the verified headEvidence: Reported problem reproduced: refused without the flag
Source: Reported problem reproduced: refused without the flag
Evidence: Zero-status PR merged with --allow-no-pipeline; live PR record and meta
Source: Zero-status PR merged with --allow-no-pipeline; live PR record and meta
Evidence: Green baseline merge; metadata matches the waived merge
Source: Green baseline merge; metadata matches the waived merge
Evidence: Failing and pending statuses still refused with the flag
Source: Failing and pending statuses still refused with the flag
Evidence: Refused under the away posture
Source: Refused under the away posture
Evidence: Stale --expected-head refused with the flag
Source: Stale --expected-head refused with the flag
Evidence: Attended merge sends head_commit_id = verified head (logged real tea calls)
Source: Attended merge sends head_commit_id = verified head (logged real tea calls)
Evidence: Targeted allow-no-pipeline unit tests
Source: Targeted allow-no-pipeline unit tests
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
docs/forgejo-tea-integration.md:200- The Forgejo integration doc's no-CI section still says anonecombined status "refuses the merge rather than treating an absent check as nothing to verify", and the example shows that refusal. It never mentions that an attended, captain-ordered--allow-no-pipelinenow waives exactly this zero-status case.docs/architecture.md:462and thebin/fm-pr-merge.shheader do document the exception, so this doc is now the only place that reads as if no guarded path exists. Suggested fix: add one sentence after the example pointing to the waiver and to the script header that owns its guards.✅ **Test** - passed
✅ No issues found.
--allow-no-pipelineon a zero-status Forgejo PR merges it, and Forgejo shows the PR merged (local Forgejo 11 container)--allow-no-pipelineon a PR whose head has a failure status, or a pending status, still refuses and the PR stays open--allow-no-pipelineis refused while the away-posture record exists--expected-headtogether with--allow-no-pipelinerefuses before any mergehead_commit_idequal to the verified headThrowawaycodeberg.org/forgejo/forgejo:11container on 127.0.0.1, seeded with an admin user, an API token, the repofixture/fixture-repowith no CI, and 5 pull requests. Commit statuses were set through the REST API: PR2failure, PR3pending, PR5success; PRs 1 and 4 had none.Isolatedtea login add(HOME and XDG_CONFIG_HOME set to a temp dir), plus a lab home frombin/fm-lab-home.sh create, withdata/projects.mdregisteringfixture-repo [no-mistakes forge=forgejo](bin/fm-project-mode.sh --forgeprintedforgejo)bin/fm-pr-merge.sh task-t1 https://localhost/fixture/fixture-repo/pulls/1(no flag): refusedbin/fm-pr-merge.sh task-t1 .../pulls/1 --allow-no-pipeline: merged; checked the live PR record and task metabin/fm-pr-merge.sh task-t5 .../pulls/5(green baseline): merged; compared its meta and state files with the waived mergebin/fm-pr-merge.sh task-t2 .../pulls/2 --allow-no-pipeline(failure status) andtask-t3 .../pulls/3 --allow-no-pipeline(pending status): refused, PRs left openbin/fm-afk-contract.sh enter, thenbin/fm-pr-merge.sh task-t4 .../pulls/4 --allow-no-pipeline: refused with exit 2bin/fm-afk-contract.sh archive, thenbin/fm-pr-merge.sh task-t4 .../pulls/4 --allow-no-pipeline --expected-head <other sha>: refused, PR left openbin/fm-pr-merge.sh task-t4 .../pulls/4 --allow-no-pipelinethrough a pass-throughteawrapper that logged its arguments: merge POST carriedhead_commit_id=<verified head>Targeted teststest_allow_no_pipeline_merges_only_a_null_head_pipeline,test_allow_no_pipeline_is_attended_only_and_refused_on_github,test_forgejo_allow_no_pipeline_merges_only_zero_statusesandtest_forgejo_allow_no_pipeline_is_attended_onlyfrom tests/fm-pr-merge.test.sh✅ **Document** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.