Repository navigation
feat(bin): support pull requests on any GitHub host - #6868
mielientiev wants to merge 7 commits into
Conversation
A pull request URL on a GitHub host other than github.com was rejected by the PR tooling, so merge polling, merge, cleanup and backlog closing failed for it. The parser now accepts https://<host>/<owner>/<repo>/pull/<n> for any valid host and keeps the host in the recorded identity. Every gh and gh-axi call that addresses a pull request or repository is made against that host, and github.com is addressed exactly as before. FM_GITHUB_HOST (falling back to GH_HOST, then github.com) names the host to assume where none is given by a URL. The backlog tool links only github.com pull requests, so a pull request on another host is recorded on the closed item as a note.
The coverage guard sorts with LC_ALL=C but compared with comm under the ambient locale, which reports the lists as unsorted in a UTF-8 locale.
|
Speaking as Kun's firstmate: thanks, @mielientiev. I read the thread and the diff of head What it does: Security review before approving fork CI: there are no workflow, secret or CI-config edits. I approved CI Contract-class: new-default. On main, every non- VISION.md, rule by rule
Heads-up: #6866 changes the same parser, merge, teardown and backlog-transition code for GitLab, so whichever lands second will need a rebase. Next step: fork CI is now running. Nothing is needed from you unless it goes red. When it's green, it goes to Kun. |
|
Hey @kunchenguid |
|
Speaking as Kun's firstmate: thanks for checking in, @mielientiev, and sorry for the wait. Nothing more is needed from you right now. Here's where it stands on head CI: every check is green except "Behavior portable serial 2". That shard didn't fail a test. It ran all of its cases Contract-class: new-default (unchanged). On main, every non- Security FYI (unchanged): this widens the host set the merge, poll and teardown parser treats as GitHub, from exactly VISION.md: my rule-by-rule verdict from the previous comment stands. Authority is the one "cannot tell", because of the default-on host widening. Scope is "mostly aligns", because of the unrelated Next step: waiting on the re-run of the serial 2 shard. Once it's green, this goes to Kun for a merge-or-leave decision. That part is on him, not you. One heads-up: #6866 (GitLab) edits the same parser and merge code, so whichever lands second will need a rebase. |
Intent
Make firstmate's PR tooling work for pull requests on any GitHub host, not only github.com. The tooling accepted only
https://github.com/<owner>/<repo>/pull/<n>URLs, so merge polling, merge, cleanup and backlog closing failed for pull requests on a self-hosted GitHub Enterprise Server host such as ghe.example.com.Requirements and decisions: the URL parser accepts
https://<host>/<owner>/<repo>/pull/<n>for any valid lowercase DNS host and keeps the host in the recorded identity, so the same owner/repo/number on two hosts never shares a record; github.com stays valid and GitLab and Gerrit URL shapes on github.com stay refused. Every gh and gh-axi call that addresses a pull request or repository by owner/repo is made against the pull request's own host by setting GH_HOST for that one command; github.com is left untouched so its behavior is unchanged. The default host is github.com and is overridable with one environment variable, FM_GITHUB_HOST (documented in docs/configuration.md); GH_HOST is honored only as gh's own selection and FM_GITHUB_HOST wins. The backlog tool only links github.com or Forgejo pull request URLs, so a pull request on another host is recorded on the closed backlog item as a note carrying its URL, the same way Gerrit changes already are. Out of scope: GitLab and Gerrit behavior, any other refactor. Tests use only neutral example hosts (ghe.example.com, git.example.org). A second commit makes fm-test-run's coverage guard compare sorted lists with the C collation; it failed under a UTF-8 locale independent of this change. Look-alike hosts such as github.com.example.org are now valid distinct hosts, so the security test that listed them as invalid was updated deliberately.Standard to hold the change to: .agents/skills/firstmate-coding-guidelines/SKILL.md. Check the diff against it: one owner per contract with cross-references instead of restatements, knowledge placed at the right tier (script header comments own mechanics, docs/configuration.md owns the setting), one sentence per line in tracked Markdown, plain dash, shellcheck-clean bin scripts, tests colocated in tests/ that exercise behavior through executables and never assert source bytes, and no unrelated refactors or hardening beyond the stated scope. This is a re-validation of an already open pull request; keep the existing branch history and the existing pull request.
What Changed
https://<host>/<owner>/<repo>/pull/<n>for any valid lowercase DNS host, the host stays part of the recorded identity, github.com behavior is unchanged, and GitLab and Gerrit URL shapes on github.com stay refused.ghandgh-axicall that addresses a pull request or repository now runs against that pull request's own host through newfm_gh_atandfm_github_default_hosthelpers;FM_GITHUB_HOSToverrides the github.com default for a pull request known only by number, documented indocs/configuration.md.PR <url>note like an existing Gerrit change;tests/fm-github-host.test.shplus host cases in the PR, teardown, and security suites cover the behavior, andbin/fm-test-run.shcompares coverage-guard lists with the C collation.Risk Assessment
Testing
Ran the targeted behavior suites for the changed PR tooling with bash: tests/fm-github-host.test.sh, tests/fm-pr-state.test.sh, tests/fm-pr-reviewers.test.sh, tests/fm-pr-merge.test.sh, tests/fm-teardown.test.sh, and tests/fm-pr-check-security.test.sh; all exited 0 and the new host-aware cases passed. Independently drove the real product end to end in a throwaway home with a disposable forge stub: armed a PR on ghe.example.com, ran the armed poll, fm-pr-state, fm-pr-reviewers, and fm-pr-merge (verified merged), and repeated the same for github.com; every gh call carried GH_HOST=ghe.example.com for the other host and no GH_HOST for github.com, and doctored or malformed poll sidecars produced no output and no gh call. Teardown's recorded-URL, FM_GITHUB_HOST bare-number/branch, Gerrit-host, and backlog-note behaviors were driven by the teardown suite against the real script. The fm-test-run coverage-guard locale fix was exercised live with
bash bin/fm-test-run.sh --check-coverageunder en_US.UTF-8, reporting FM_TEST_COVERAGE ok. This is CLI tooling with no GUI surface, so evidence is CLI transcripts, recorded state, per-call GH_HOST logs, and test output rather than screenshots. The only substitute is the external forge CLI (no self-hosted GitHub instance is reachable from this machine); the product scripts themselves are real.armed: state/task-ghe.check.sh,pr=https://ghe.example.com/o/r/pull/7, sidecar host ghe.example.com, and both gh calls loggedHOST=ghe.example.comok - re-arming after a retirement receipt for another host reads the new pull request at its own hostmerged, gh logHOST=ghe.example.com ARGS=pr view https://ghe.example.com/o/r/pull/7 --json state -q .statepr viewandpr checksloggedHOST=ghe.example.com; targeted-test-fm-pr-state.log `ok - a pull request on another GitHub host is read at that host and github…alice 1 recent commit, all three gh calls loggedHOST=ghe.example.com; targeted-test-fm-pr-reviewers.log `ok - a pull request on another GitHub host is read at th…verified: ... is merged, metapr=https://ghe.example.com/o/r/pull/9, and all six calls (head read, mergeable read, branch rules, commit rules,pr merge, outcome graphq…HOST=unset, includingpr merge 10 --repo o/r --match-head-commit ... --squash; the state, revi…ok - teardown reads a recorded pull request at its own hostandok - teardown never selects a non-GitHub forge's host for ghok - teardown's branch and bare-number lookups reach gh at FM_GITHUB_HOST, and github.com otherwiseand `ok - an exported GH_HOST never breaks the teardown lookups, an…ok - teardown closes a landed task on another GitHub host with its pull request URL as a note(row state done, bodyPR https://ghe.example.com/example/repo/pull/7)ok - the default host is github.com and overridable with FM_GITHUB_HOST(invalidbad host/xrefused)ok - raw-byte parser accepts canonical URLs and rejects the complete adversarial matrix(look-alike hosts now di…FM_TEST_COVERAGE ok total=251 ...with rc=0 under en_US.UTF-8Evidence: Independent live drive transcript (arm, poll, state, reviewers, merge, adversarial sidecar cases)
Source: Independent live drive transcript (arm, poll, state, reviewers, merge, adversarial sidecar cases)
Evidence: Fixture script that built the disposable home, worktree, and logging gh stub
Source: Fixture script that built the disposable home, worktree, and logging gh stub
Evidence: Live validation summary (scenarios and observed results)
Source: Live validation summary (scenarios and observed results)
Evidence: targeted-test-fm-github-host.log
Source: targeted-test-fm-github-host.log
Evidence: targeted-test-fm-pr-state.log
Source: targeted-test-fm-pr-state.log
Evidence: targeted-test-fm-pr-reviewers.log
Source: targeted-test-fm-pr-reviewers.log
Evidence: targeted-test-fm-pr-merge.log
Source: targeted-test-fm-pr-merge.log
Evidence: targeted-test-fm-pr-check-security.log
Source: targeted-test-fm-pr-check-security.log
Evidence: Coverage guard under a UTF-8 locale (the C-collation fix)
Source: Coverage guard under a UTF-8 locale (the C-collation fix)
FM_TEST_COVERAGE ok total=251 parallel=24 parallel_max_ms=665545 parallel_imbalance_ms=2 parallel_unhinted=0 serial=211 serial_shards=9 serial_unhinted=9 serial_max_ms=1074843 serial_budget_ms=1200000 herdr=16Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-pr-poll.sh:58- The github branch's host revalidation is weaker than the rule its own comment claims. The comment at 56-57 says the host is 'validated as the lowercase DNS name the parser accepts', but the inline check at 58-61 only enforces length 1-253, the lowercase [a-z0-9.-] character class, and no leading/trailing/double dot; it omits the per-label length (at most 63) and leading/trailing-hyphen rules that fm_pr_forge_host_valid applies (bin/fm-pr-lib.sh:127-142). A sidecar carrying a host such as -ghe.example.com or ghe-.example.com passes this check and reaches the gh call at 78 with that malformed GH_HOST, although the parser can never produce it. The exact-URL equality at line 72 keeps the poll from reaching any host the record does not name, and a failed lookup stays silent, so no false merged result is possible; the defect is that the check and its comment diverge. Smallest honest fix: point the comment at fm_pr_forge_host_valid instead of claiming the parser's rule, or apply the same per-label rules inline.bin/fm-pr-lib.sh:166- Intent-scope question against the required constraint 'Every gh and gh-axi call that addresses a pull request or repository by owner/repo is made against the pull request's own host by setting GH_HOST for that one command'. The constraint is implemented for the PR lifecycle scripts, but two sibling consumers of the same recorded pr= URL bypass fm_gh_at and still hardcode github.com: bin/fm-bearings-snapshot.sh:255 repo_slug matches only github.com[:/] URLs, so the gh pr list --repo call at bin/fm-bearings-snapshot.sh:301 (through the gh_bounded wrapper at 263) never runs for a PR or clone on another host and the PR is silently omitted from 'bearings include PRs'; bin/fm-contributions.sh:249 observe() refuses anything that is not https://github.com/*, so the gh api repos/.../pulls/... reads at bin/fm-contributions.sh:254-272 never run and the observer prints 'contributions: observation unavailable for <url>'. Reachable sequence: arm a task with https://ghe.example.com/o/r/pull/7 (now accepted by the change), and both the armed contributions observer and a /bearings PR run skip it. No wrong value is produced, and the enumerated failing flows (merge polling, merge, cleanup, backlog closing) are fully host-aware, so this is a scope decision: the narrowest remedy is to route these callers through fm_gh_at with the PR's host, or to state in docs/configuration.md:2340 that these surfaces remain github.com-only. That remedy extends the change beyond the flows the intent enumerates, which is why it needs your call rather than an automatic fix.🔧 Fix applied.
1 warning still open:
bin/fm-pr-lib.sh:166- Intent-scope question against the required constraint 'Every gh and gh-axi call that addresses a pull request or repository by owner/repo is made against the pull request's own host by setting GH_HOST for that one command'. The constraint is implemented for the PR lifecycle scripts, but two sibling consumers of the same recorded pr= URL bypass fm_gh_at and still hardcode github.com: bin/fm-bearings-snapshot.sh:255 repo_slug matches only github.com[:/] URLs, so the gh pr list --repo call at bin/fm-bearings-snapshot.sh:301 (through the gh_bounded wrapper at 263) never runs for a PR or clone on another host and the PR is silently omitted from 'bearings include PRs'; bin/fm-contributions.sh:249 observe() refuses anything that is not https://github.com/*, so the gh api repos/.../pulls/... reads at bin/fm-contributions.sh:254-272 never run and the observer prints 'contributions: observation unavailable for <url>'. Reachable sequence: arm a task with https://ghe.example.com/o/r/pull/7 (now accepted by the change), and both the armed contributions observer and a /bearings PR run skip it. No wrong value is produced, and the enumerated failing flows (merge polling, merge, cleanup, backlog closing) are fully host-aware, so this is a scope decision: the narrowest remedy is to route these callers through fm_gh_at with the PR's host, or to state in docs/configuration.md:2340 that these surfaces remain github.com-only. That remedy extends the change beyond the flows the intent enumerates, which is why it needs your call rather than an automatic fix.🔧 **Test** - 1 issue found → no changes applied ✅
🔧 No changes applied.
✅ Re-checked - no issues remain.
armed: state/task-ghe.check.sh,pr=https://ghe.example.com/o/r/pull/7, sidecar host ghe.example.com, and both gh calls loggedHOST=ghe.example.comok - re-arming after a retirement receipt for another host reads the new pull request at its own hostmerged, gh logHOST=ghe.example.com ARGS=pr view https://ghe.example.com/o/r/pull/7 --json state -q .statepr viewandpr checksloggedHOST=ghe.example.com; targeted-test-fm-pr-state.log `ok - a pull request on another GitHub host is read at that host and github…alice 1 recent commit, all three gh calls loggedHOST=ghe.example.com; targeted-test-fm-pr-reviewers.log `ok - a pull request on another GitHub host is read at th…verified: ... is merged, metapr=https://ghe.example.com/o/r/pull/9, and all six calls (head read, mergeable read, branch rules, commit rules,pr merge, outcome graphq…HOST=unset, includingpr merge 10 --repo o/r --match-head-commit ... --squash; the state, revi…ok - teardown reads a recorded pull request at its own hostandok - teardown never selects a non-GitHub forge's host for ghok - teardown's branch and bare-number lookups reach gh at FM_GITHUB_HOST, and github.com otherwiseand `ok - an exported GH_HOST never breaks the teardown lookups, an…ok - teardown closes a landed task on another GitHub host with its pull request URL as a note(row state done, bodyPR https://ghe.example.com/example/repo/pull/7)ok - the default host is github.com and overridable with FM_GITHUB_HOST(invalidbad host/xrefused)ok - raw-byte parser accepts canonical URLs and rejects the complete adversarial matrix(look-alike hosts now di…FM_TEST_COVERAGE ok total=251 ...with rc=0 under en_US.UTF-8bash tests/fm-github-host.test.shbash tests/fm-pr-state.test.shbash tests/fm-pr-reviewers.test.shbash tests/fm-pr-merge.test.shbash tests/fm-teardown.test.shbash tests/fm-pr-check-security.test.shbash /tmp/fm-live-host-scenario/run.sh(disposable live drive: realbin/fm-pr-check.sh, armedstate/*.check.shpoll,bin/fm-pr-state.sh,bin/fm-pr-reviewers.sh,bin/fm-pr-merge.shfor ghe.example.com and github.com, plus doctored-sidecar adversarial cases)bash bin/fm-test-run.sh --check-coverageunder en_US.UTF-8✅ **Document** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.