Revision: 1 Last modified: 2026-12-04T00:00:00Z
Adapter: scripts/pr/lib/provider_github.sh (sourced by scripts/pr/lib/provider.sh; never executed on its
own). Engine guide: docs/scripts/pr_deliver.md. Manual:
docs/manuals/pr_delivery_engine_manual.md.
Implement the provider-neutral verb surface of lib/provider.sh over the gh CLI. GitHub is the one
provider whose full lifecycle was MEASURED on this host: create a pull request, review it, merge it and
delete the branch all answered successfully, while an author self-approval answers 422 by platform
policy.
Every verb emits one line of key=value pairs separated by single spaces, so callers parse with sed/awk
and never need a JSON parser. Bodies are reduced to their single-line PR-* marker, which is what makes a
read-back verification possible in pure shell.
ghonPATH(override:PR_GH_BIN), authenticated by a token variable or by the CLI keyring.PR_REPO_SLUG,PR_CRED_NAME,PR_CRED_KINDset bylib/provider.sh.PR_API_BASEis unused:ghowns the endpoint and the authentication.- No
jqis required — the--jqexpressions below are evaluated byghitself.
. "$PR_SELF_DIR/lib/provider.sh" # this adapter is sourced at the end of provider.sh
prv_identity # the authenticated login
prv_repo_probe # archived= … allow_merge_commit= … push= … admin= …
prv_rules main # rule=pull_request approvals=0 contexts=
prv_pr_create task/CON-641-x main "CON-641: …" /tmp/body # prints the new pull request number
prv_merge 128 4f2c1a9… merge-commit # pins the head- Every write prints the provider's OWN error text on failure and returns 1, in exactly ONE provider
invocation. A refusal therefore quotes the platform instead of inventing a reason — the measured
422 "Review Can not approve your own pull request"reaches the operator verbatim. - A credential is selected before the call, never after. With
PR_CRED_KIND=keyringthe three ambient token variables are unset for the child (env -u GITHUB_TOKEN -u GH_TOKEN -u GITHUB_TOKEN_PR_WRITE); with anenvcredential only that one variable is set for the child. The ambient token the owning organisation answers 403 to can never shadow the keyring credential that works. prv_rulesreads/rules/branches/<base>first, because the classic/branches/<b>/protectionendpoint answers 404 "Branch not protected" for a ruleset-protected branch — a false "no protection" that would have opened a pull request into an unmergeable state. The classic endpoint is the fallback for a server without the rules API, andrule=none approvals=0 contexts=is the answer when neither reports a rule.prv_pr_createwithout a pull request URL is a failure, not an empty number: the engine must never proceed on a pull request whose number it could not read.- Only a merge commit is offered.
gh pr mergehas no fast-forward mode, and a squash or a rebase would lose the reviewed head; both are refused here rather than requested and silently accepted. prv_mergepins the head with--match-head-commit, so a head that moved between the read-back and the merge is refused BY THE PLATFORM rather than by the engine's own timing.prv_commentsreturns onlyPR-VERDICT/PR-GOmarker lines, joined with;;when a body carries more than one; the read-backs inlib/steps.shparse exactly those.
_pr_gh_writecaptures stdout and stderr into twomktempfiles, returns 0 leaving nothing behind, and on failure prints the first 400 characters of the provider's message with newlines flattened._pr_gh_api/_pr_gh_err(inlib/provider.sh) are the read and error-text halves, with the same credential selection.- Read verbs use
--jqfilters that emit the neutral record shape directly, so no JSON ever reaches the shell:prv_pr_viewemitsnumber= state= head= base= draft= mergeable= merge_state= merge_commit= url= head_owner=. head_owneris what letsmergerefuse a fork pull request withfork_pr_unsupported:<owner>; a provider that reports nothing makes the engine claim nothing.prv_branch_deletedeletesrefs/heads/<branch>through the git-refs API;prv_assignandprv_request_reviewersbuild one--add-*flag per list member and are no-ops on an empty list.
provider.md— the verb contract, the credential probe and the dispatch.provider_rest.md— the same surface over GitLab and Gitea REST.steps.sh— the consumer of every verb and of every read-back.forge_tool.md— the sibling Forge tool over the sameghCLI.
2026-12-04 — read against scripts/pr/lib/provider_github.sh (172 lines). The 422 self-approval text and the
ruleset-404 behaviour are recorded measurements of this host, not assumptions; they are exercised hermetically
by tests/pr/test_pr_preflight.sh and tests/pr/test_pr_lifecycle.sh.