You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Pin the GitHub Host for the Write Guard's Branch-Rules Read #4501
host-setup/agent-safety/claude/gh-write-guard.py_live_branch_rules runs gh api on the rules/branches endpoint with no host and the inherited environment. So an exported GH_HOST moves the guard's branch-rules read to that other host.
Failure
With GH_HOST=other.example exported, a push to a github.com repository makes the guard read the branch rules from other.example. A 404 there fails closed. But a same-named repository on that host answers with its own rule set. The guard then judges a github.com push against rules that do not govern it.
Fix
Pin the host for this read, for example GH_HOST=github.com in the child environment, as #4489 does for the hub scripts. The hook is standalone and cannot import scripts/gh_graphql.py, so it needs its own pin. Add a test that runs the read with GH_HOST set to a constructed host and asserts the child still targets github.com.
Origin
Raised by the local strict review on the #4489 fix, against code that change did not touch. Filed under pr-review-conduct outcome 4 as a pre-existing correctness defect, since #4489's fix is claimed.
Do you approve pinning GH_HOST=github.com in the child environment of the write guard's branch-rules read, _live_branch_rules in host-setup/agent-safety/claude/gh-write-guard.py, plus a selftest case that proves the pin? Today that gh api repos/<owner>/<repo>/rules/branches/<branch> call names no host and inherits the session's environment. So an exported GH_HOST sends the read to another host. A 404 there fails closed. But a same-named repository on that host answers with its own rules, and requirement 4 then judges a github.com push against rules that do not govern it. That can let a push through that the real branch rules forbid. The file is under host-setup/agent-safety/, the agent's own guard, so a human approves every change to it. An approval here lets an attended run implement it and drive the pull request. The merge still waits on your go-ahead after you read the diff.
Options:
Approve the env pin with a selftest (recommended). The call passes env={**os.environ, "GH_HOST": "github.com"}, the same mechanism Pin the GitHub Host for Every gh Child the Hub Scripts Start #4502 gave the hub scripts through scripts/gh_graphql.pypinned_env(). The hook is standalone and cannot import that module, so it carries its own two-line copy. A selftest case runs the read under a constructed GH_HOST and asserts the child sees github.com. It is a small, fail-closed change to one function. Nothing is in flight on this file.
Approve, but pin with --hostname github.com instead.gh api takes --hostname, so this works here too. It is equally small. It diverges from Pin the GitHub Host for Every gh Child the Hub Scripts Start #4502, which chose the environment pin because --hostname exists on gh api alone, so the hub would hold two pin forms.
Decline and leave the read unpinned. No change to the guard. The bypass stays open for any session that exports GH_HOST, which is a fail-open path in a check whose README says it fails closed for a protected default.
Evidence:#4501 body, filed from the local review on #4502. #4502 (merged, on main) pinned every hub-script gh child and listed this site as out of its scope. host-setup/agent-safety/README.md requirement 4 states the live-rules read and its fail-closed contract. On main, _live_branch_rules still runs gh api with no host and no env. The guard's tests live in its own --selftest matrix.
Maintainer's answer, 2026-11-26 triage: option 1, approved as a design. _live_branch_rules passes GH_HOST=github.com in its child environment, as a standalone copy of #4502's pinned_env(), with a selftest case proving the pin. The edit is under host-setup/agent-safety/, so an attended run implements it and the merge waits on the maintainer reading the diff.
Activity
Pin the GitHub Host for Every gh Child the Hub Scripts Start (#4502)
Promote Develop to Main: Python Line Selector, Docker Lint Digest Pin…
ptr727 commentedon Nov 26, 2026
Triage question, 2026-11-26.
Do you approve pinning
GH_HOST=github.comin the child environment of the write guard's branch-rules read,_live_branch_rulesinhost-setup/agent-safety/claude/gh-write-guard.py, plus a selftest case that proves the pin? Today thatgh api repos/<owner>/<repo>/rules/branches/<branch>call names no host and inherits the session's environment. So an exportedGH_HOSTsends the read to another host. A 404 there fails closed. But a same-named repository on that host answers with its own rules, and requirement 4 then judges a github.com push against rules that do not govern it. That can let a push through that the real branch rules forbid. The file is underhost-setup/agent-safety/, the agent's own guard, so a human approves every change to it. An approval here lets an attended run implement it and drive the pull request. The merge still waits on your go-ahead after you read the diff.Options:
env={**os.environ, "GH_HOST": "github.com"}, the same mechanism Pin the GitHub Host for Every gh Child the Hub Scripts Start #4502 gave the hub scripts throughscripts/gh_graphql.pypinned_env(). The hook is standalone and cannot import that module, so it carries its own two-line copy. A selftest case runs the read under a constructedGH_HOSTand asserts the child seesgithub.com. It is a small, fail-closed change to one function. Nothing is in flight on this file.--hostname github.cominstead.gh apitakes--hostname, so this works here too. It is equally small. It diverges from Pin the GitHub Host for Every gh Child the Hub Scripts Start #4502, which chose the environment pin because--hostnameexists ongh apialone, so the hub would hold two pin forms.GH_HOST, which is a fail-open path in a check whose README says it fails closed for a protected default.Evidence: #4501 body, filed from the local review on #4502. #4502 (merged, on
main) pinned every hub-scriptghchild and listed this site as out of its scope.host-setup/agent-safety/README.mdrequirement 4 states the live-rules read and its fail-closed contract. Onmain,_live_branch_rulesstill runsgh apiwith no host and noenv. The guard's tests live in its own--selftestmatrix.ptr727 commentedon Nov 26, 2026
Maintainer's answer, 2026-11-26 triage: option 1, approved as a design.
_live_branch_rulespassesGH_HOST=github.comin its child environment, as a standalone copy of #4502'spinned_env(), with a selftest case proving the pin. The edit is underhost-setup/agent-safety/, so an attended run implements it and the merge waits on the maintainer reading the diff.Refuse a Blanket Stage in Any Checkout With an Origin and Pin the Rul…