Repository navigation
Description
Problem Description
PR #5126 (#4773) added the step uv run pre-commit install --install-hooks to .github/workflows/copilot-setup-steps.yml. The step installs the pre-commit and pre-push hook types (default_install_hook_types of .pre-commit-config.yaml). The pre-commit type holds the hook no-commit-to-branch with the alias branch-name. That hook refuses a commit on each branch that is not <type>/<issue>-<slug>.
The Copilot cloud agent works on a copilot/ branch. It cannot rename that branch, and it cannot run git commands itself. Thus the hook can refuse each commit of the agent, and the agent then stops. Before #5126, the commits of the agent ran no hook.
The proposal of #4773 (## Feasibility) says that no live Copilot agent run was part of the check, and it does not examine the branch-name hook.
Reproduction Steps
- Read the pattern of the
branch-namehook in.pre-commit-config.yaml(lines 14-20 on main at a04e7a9). - Apply it to Copilot branch names with Python
re.search, as the hook does:copilot/fix-login-bug: refusedcopilot/sub-pr-12: refusedcopilot/fix-4773: refusedfix/4773-copilot: accepted
- Assign the Copilot cloud agent to an issue. The setup steps install the hooks, and the first commit of the agent runs the
branch-namehook on itscopilot/branch.
Expected vs Actual Behavior
Expected: the commits and pushes of the Copilot cloud agent pass the hooks that the setup steps install, or the setup steps install no hook that the agent cannot satisfy.
Actual: the branch-name hook refuses each commit on a copilot/ branch. A failed hook stops the agent with "Copilot encountered an unknown Git error".
Fix (do one of these, then prove the result with one live Copilot run on a test issue):
- Remove the step
Install the git hooksfrom the Copilot setup steps until a live Copilot run shows that its commits pass. - Or decide how the branch-name rule applies to the fixed
copilot/branch, and scope the trigger of that hook (owner rule of 2026-10-20: scope the trigger, build no escape).
The live run also checks the pre-push hook branch-current: the agent cannot rebase its branch, so a push can fail when main moves during the run. This part is not verified.
Environment Diagnostics
- devops-cli main at a04e7a9 (release 0.120.0).
- Copilot cloud agent, with the setup steps of
.github/workflows/copilot-setup-steps.yml. pre-commit-hooksv6.0.0, hookno-commit-to-branch.
Logs, Traces, or Terminal Output
GitHub documentation, "Risks and mitigations for GitHub Copilot cloud agent" (https://docs.github.com/en/copilot/concepts/agents/coding-agent/risks-and-mitigations):
a new
copilot/branch is created for Copilot, and the agent can only push to that branch.
It cannot directly run
git pushor other Git commands.
GitHub community discussion 167906 (https://github.com/orgs/community/discussions/167906): hooks installed in copilot-setup-steps.yml run on the commits of the agent. A failed hook gives:
Copilot stopped work due to an error
Copilot encountered an unknown Git error. If the problem persists, please contact GitHub Support.
GitError unknown git error: Command failed with exit code 1: git commit -m REDACTED
Pre-Submission Checklist
- I have verified that no sensitive credentials, private keys, or internal tokens are contained in this issue report.
- I have checked existing issues and pull requests to ensure this is not a duplicate.
Source: #5126
Proposed design
Problem statement
The Copilot setup steps install the pre-commit and pre-push hooks. The branch-name hook refuses each commit on the fixed copilot/ branch that GitHub gives the agent, and the agent then stops with an unknown Git error. The item scopes the pattern of that hook so a copilot/ branch name passes, and keeps the rule for each other branch. A live Copilot run proves the agent commit and push, and that proof waits on GitHub, so it is deferred.
Acceptance criteria
Requirement: The branch-name hook accepts a copilot branch
The branch-name hook SHALL accept each copilot/ branch name that the Copilot cloud agent creates.
Scenario: copilot branch names pass the hook
- WHEN A test runs the
--patternof thebranch-namehook with Pythonre.searchoncopilot/fix-login-bug,copilot/sub-pr-12andcopilot/fix-4773. - THEN No name matches the pattern, so the hook accepts each commit on the branch.
Requirement: The branch-name rule keeps its refusal for other names
The branch-name hook SHALL refuse each branch name that is neither <type>/<issue>-<slug> nor copilot/<slug>.
Scenario: a name outside both forms fails
- WHEN The same test runs the pattern on
feature/loginand on a name that holds an underscore. - THEN Each name matches the pattern, so the hook refuses the commit.
Requirement: The Copilot setup steps keep the hook installation
The Copilot setup workflow SHALL keep the step that installs the git hooks.
Scenario: the install step stays
- WHEN A test reads
.github/workflows/copilot-setup-steps.yml. - THEN The workflow holds the step
Install the git hookswith the commanduv run pre-commit install --install-hooks.
Requirement: The hook states both accepted branch forms
The name of the branch-name hook and the comment above it SHALL state both accepted branch forms.
Scenario: the hook text names copilot
- WHEN A test reads the
nameand the comment lines of thebranch-namehook in.pre-commit-config.yaml. - THEN The text names
<type>/<issue>-<slug>andcopilot/.
Existing Tool Considered
No alternatives check has run. The no-commit-to-branch hook of pre-commit/pre-commit-hooks v6.0.0 covers the need, and .pre-commit-config.yaml already pins it. The hook lacks a separate allow list for branch prefixes, so its --pattern argument must hold the copilot/ form. The change builds no code: it extends that one pattern and adds a test that runs the pattern with Python re.search.
Key questions
- Which fix does the item take: remove the
Install the git hooksstep, or scope thebranch-namehook?: Scope the trigger of thebranch-namehook so acopilot/branch name passes, and keep theInstall the git hooksstep. The other hooks still apply to each commit and push of the agent. (best practice) [sources: .github/workflows/copilot-setup-steps.yml, .pre-commit-config.yaml:14]- Chosen: Scope the trigger of the branch-name hook. The owner rule of 2026-10-20 says to scope the trigger and build no escape. The hook keeps its rule for each name that people and the implement job create.
- Rejected: Remove the Install the git hooks step. This is the escape that the owner rule forbids. It also removes the other hooks from each commit and push of the agent.
- Rejected: Set SKIP=branch-name in the workflow. An environment variable that turns the rule off is an escape. It hides the hook from each later run of the agent.
- How does the
branch-namehook accept acopilot/branch name and still refuse each other name?: Add the alternativecopilot/[a-z0-9][a-z0-9-]*to the group inside the negative lookahead of--pattern. The^anchor keepsre.searchfrom matching an accepted name at a later position, so each name outside the two forms still matches and is refused. (best practice) [sources: .pre-commit-config.yaml:14]- Chosen: Extend the --pattern alternation. The
--patternargument is the only branch filter that the hook gives. One expression holds the two forms, and no second place holds the rule. - Rejected: Add a second no-commit-to-branch hook with --branch.
--branchrefuses one exact name. It cannot express thecopilot/prefix, and a second hook would hold the same rule twice. - Rejected: Install only the pre-push hook type in the workflow. This removes each
pre-commithook from the agent, so the agent commits with no check at all. It is an escape.
- Chosen: Extend the --pattern alternation. The
- Does the
branch-namehook run on a commit of the Copilot cloud agent?: Yes..pre-commit-config.yamlsetsdefault_install_hook_types: [pre-commit, pre-push], and thebranch-namehook hasstages: [pre-commit]. The stepuv run pre-commit install --install-hookswrites that hook, so each commit of the agent runs it. [sources: .pre-commit-config.yaml:1, .pre-commit-config.yaml:14, .github/workflows/copilot-setup-steps.yml] - Can the
pre-pushhookbranch-currentrefuse a push of the agent?: Yes. The hook fetchesorigin/mainand refuses the push whenFETCH_HEADis not an ancestor of the pushed ref. The agent cannot rebase its branch, so a move ofmainafter the branch starts can refuse the push. The live run of the deferred item checks this case. [sources: .pre-commit-config.yaml] - How is the fix proved?: An offline test runs the hook's
--patternwith Pythonre.searchon the sample branch names. A live Copilot cloud agent run proves the commit and the push of the agent. Only GitHub starts that run, so it is deferred to its own item. (best practice) [sources: .pre-commit-config.yaml:14]- Chosen: Offline test of the pattern, and a deferred live run. The offline test shows the pattern result on each sample name. The live run waits on an outside event, so it cannot hold this item.
- Rejected: Offline test only. It does not show what a live Copilot agent does with the installed hooks.
- Rejected: Live run only. The item then waits on an outside event, and no test guards the pattern.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 12, 2026
The hook blocks every Copilot agent commit, stopping the agent entirely.Both concern git hooks for Copilot agent sessions; #4773 asked to install hooks, the candidate fixes a hook that blocks the agent.devops-cli-service commentedon Nov 12, 2026
Status set to Ready at 22c806d (see proposed design in issue body).
Moved to new items: #5147.
feat(roadmap): extend stage gate returns while the plan improves (#5389)
devops-cli-service commentedon Nov 13, 2026
Staged: branch
fix/5136-copilot-setup-hooks-refuse-commits-on, draft pull request #5407. The pull request plans the item and closes no issue.The task groups, with the tokens of the inputs of each step, for a budget of 64000 tokens:
The default branch changed these paths that the plan names, after the commit that the planner read. Read the commits before you judge the plan:
src/devops_cli/config/constants.py: 6d3f954 feat(roadmap): extend stage gate returns while the plan improves (feat(roadmap): extend stage gate returns while the plan improves #5389)A model review of the plan found these points. They stop no draft, and a person judges them:
spec_delta_wrongat specs: Thedevcontainer-agent-configdelta adds the requirementThe Copilot setup steps keep the hook installation, but the existing requirementRemote agent sessions install the git hooksalready saysThe Copilot setup steps SHALL install the hooks; the delta duplicates an existing requirement instead of modifying it. Evidence: "The Copilot setup steps SHALL install the hooks."ignores_existing_codeat group 2: Group 2 addstest_the_copilot_setup_steps_install_the_git_hooks, buttest_copilot_setup_steps_installs_the_pinned_openspec_with_the_opt_outsalready asserts the workflow's run list includes the install command; the new test repeats that assertion. Extend the existing test with the step-name check instead. Evidence: ""uv run pre-commit install --install-hooks","ignores_existing_codeat group 1: Group 1 addstest_a_name_outside_both_forms_is_refused, buttest_a_commit_on_a_branch_that_breaks_the_naming_form_is_refusedalready refuses a name with a type-like prefix, an underscore and a double hyphen; the new names add no coverage. Extend the existing test'srefusedlist instead. Evidence: ""implement_issue_1388","false_premiseat feasibility: The plan citessrc/devops_cli/config/constants.py:745forCONST_BRANCH_TYPESand:758forCONST_BRANCH_SLUG_PATTERN, but line 745 is a comment about the CI shard job and the constants are at 754 and 767; the evidence does not match the file. Evidence: "src/devops_cli/config/constants.py:745:CONST_BRANCH_TYPES: Final[tuple[str, ...]] = ("false_premiseat feasibility: The plan citessrc/devops_cli/commands/ci.py:870:name="docs",, but line 870 isspan_name="ci.step.actionlint",and thedocsrow is at 881; the evidence does not match the file. Evidence: "src/devops_cli/commands/ci.py:870:name="docs","otherat feasibility: The plan says the change extends the accepted and refused lists oftest_a_commit_on_a_branch_that_breaks_the_naming_form_is_refused, but no group changes that test; group 1 adds separate tests intests/git/test_branch_form.pyand group 2 only adds a workflow test. Evidence: "with its accepted and refused lists, which the change extends"otherat group 3: Group 3 rewrites the Branch row to acceptcopilot/<slug>but leaves theparts of a branch namebullets, which describe every branch as<type>/<issue>-<slug>; the section now contradicts the row. Evidence: "The parts of a branch name:"otherat group 3: Group 3 rewrites the Branch row of the Naming table in CONTRIBUTING.md, but the plan never changes tests/invariants/test_agents_md.py, whose test_contributing_md_states_the_branch_form_once_and_names_each_check asserts that the Branch form is exactly<type>/<issue>-<slug>and that the Naming section holds that code span once. The rewrite makes that assertion fail, and group 3's verifyuv run devops ci docsdoes not run the test that pins the table. Evidence: ") == ("<type>/<issue>-<slug>", [], [], 1)"The runs of the planner and the review made 86 model request(s), and used 6195768 input tokens and 176009 output tokens. The tool calls, in order:
read_file({"path":".pre-commit-config.yaml","start_line":1,"end_line":25})read_spec({})references({"name":"copilot/"})search_code({"text":"install-hooks"})read_file({"path":"tests/invariants/test_workflow_contracts.py","start_line":800,"end_line":900})read_spec({"capability":"devcontainer-agent-config"})search_code({"text":"branch-name"})read_file({"path":"tests/invariants/test_runner_hooks.py","start_line":80,"end_line":130})read_spec({"capability":"devcontainer-agent-config","requirement":"Remote agent sessions install the git hooks"})read_spec({"capability":"pre-push-branch-current"})read_file({"path":"src/devops_cli/commands/ci.py","start_line":840,"end_line":900})references({"name":"no-commit-to-branch"})read_issue({"number":5147})read_file({"path":"src/devops_cli/git/branch_form.py","start_line":40,"end_line":80})search_code({"text":"copilot"})list_files({"directory":"openspec/specs"})search_code({"text":"branch name is"})read_file({"path":"tests/support/paths.py","start_line":1,"end_line":30})read_spec({"capability":"project-form-checks"})read_spec({"capability":"repos-worktrees-add"})read_file({"end_line":765,"path":"src/devops_cli/config/constants.py","start_line":740})search_code({"text":"docs check"})read_file({"end_line":205,"path":"CONTRIBUTING.md","start_line":140})search_code({"text":"CONST_DOCS_INVENTORY"})read_spec({"capability":"repos-worktrees-add","requirement":"The branch form is checked first"})read_file({"end_line":240,"path":"CONTRIBUTING.md","start_line":186})search_code({"text":"ci test"})read_issue({"number":4773})find_issues({"terms":"copilot"})read_file({"end_line":790,"path":"src/devops_cli/config/constants.py","start_line":750})search_code({"text":"CONST_BRANCH_SLUG_PATTERN"})search_code({"text":"CONTRIBUTING"})search_code({"text":"copilot-setup-steps"})search_code({"text":"name=\"docs\""})read_file({"end_line":100,"path":"src/devops_cli/commands/ci.py","start_line":1})search_code({"text":"branch form"})search_code({"text":"pre-commit"})search_code({"text":"delta"})search_code({"text":"root document"})search_code({"text":"spec delta"})search_code({"text":"Naming"})search_code({"text":"Install the git hooks"})search_code({"text":"test_branch_form"})read_file({"path":"openspec/changes/archive/2026-11-12-4773-remote-agent-sessions-install-the-git/tasks.md"})read_file({"path":"openspec/changes/archive/2026-11-12-4773-remote-agent-sessions-install-the-git/specs/devcontainer-agent-config/spec.md"})search_code({"text":"pre-commit install"})search_code({"text":"copilot-setup"})search_code({"text":"install-tools"})search_code({"text":"copilot"})file_symbols({"path":"tests/invariants/test_workflow_contracts.py"})read_file({"end_line":1430,"path":"tests/invariants/test_workflow_contracts.py","start_line":1385})git_log({"path":"src/devops_cli/config/constants.py"})git_log({"path":"src/devops_cli/commands/ci.py"})git_log({})read_file({"path":"tests/git/test_branch_form.py"})read_spec({"capability":"devcontainer-agent-config","requirement":"Remote agent sessions install the git hooks"})search_code({"text":"install-hooks"})search_code({"text":"copilot_setup_steps"})read_file({"path":"tests/invariants/test_workflow_contracts.py","start_line":1370,"end_line":1430})search_code({"text":"breaks_the_naming_form"})read_file({"path":"tests/invariants/test_workflow_contracts.py","start_line":800,"end_line":870})read_file({"path":"src/devops_cli/config/constants.py","start_line":735,"end_line":775})search_code({"text":"name=\"docs\""})read_file({"path":".pre-commit-config.yaml","start_line":1,"end_line":25})search_code({"text":"Naming"})search_code({"text":"issue>-<slug"})search_code({"text":"type>/<issue"})search_code({"text":"## Naming"})search_code({"text":"Naming"})search_code({"text":"<issue>-<slug>"})list_files({"directory":""})search_code({"text":"issue>-<slug>"})read_file({"path":"src/devops_cli/commands/ci.py","start_line":860,"end_line":900})read_file({"path":"CONTRIBUTING.md","start_line":190,"end_line":202})find_issues({"terms":"copilot setup hooks"})find_issues({"terms":"branch-name hook"})search_code({"text":"branch name is"})references({"name":"branch-name"})read_file({"path":"docs/ROADMAP_WORKFLOW.md","start_line":408,"end_line":416})read_file({"path":".agents/skills/devops-pr-ci/SKILL.md","start_line":14,"end_line":20})search_code({"text":"CONTRIBUTING.md"})read_file({"path":"src/devops_cli/git/branch_form.py","start_line":50,"end_line":75})read_file({"path":"tests/git/test_branch_form.py","start_line":40,"end_line":55})read_file({"path":"tests/invariants/test_workflow_contracts.py","start_line":815,"end_line":870})read_file({"end_line":1440,"path":"tests/invariants/test_workflow_contracts.py","start_line":1370})read_file({"end_line":200,"path":"CONTRIBUTING.md","start_line":185})read_spec({"capability":"devcontainer-agent-config","requirement":"Remote agent sessions install the git hooks"})read_file({"end_line":900,"path":"src/devops_cli/commands/ci.py","start_line":860})read_spec({})search_code({"text":"branch-name"})read_file({"path":"tests/invariants/test_runner_hooks.py","start_line":85,"end_line":135})search_code({"text":"<type>/<issue>-<slug>"})search_code({"text":"refuses a commit on a branch"})list_files({"directory":"openspec/specs"})read_file({"path":"src/devops_cli/git/branch_form.py","start_line":1,"end_line":80})search_code({"text":"CONST_BRANCH_TYPES"})search_code({"text":"name=\"test\""})search_code({"text":"ci test tests/"})read_issue({"number":5147})find_issues({"terms":"copilot setup hooks"})search_code({"text":"no-commit-to-branch"})search_code({"text":"branch name is"})search_code({"text":"slug"})read_file({"path":"CONTRIBUTING.md","start_line":200,"end_line":230})search_code({"text":"spec delta"})read_spec({"capability":"project-form-checks"})read_spec({"capability":"pre-push-branch-current"})read_file({"path":"openspec/config.yaml"})search_code({"text":"copilot"})read_file({"end_line":775,"path":"src/devops_cli/config/constants.py","start_line":745})read_file({"end_line":22,"path":".pre-commit-config.yaml","start_line":1})search_code({"text":"CONST_DOCS_INVENTORY"})list_files({"directory":"openspec/changes"})references({"name":"branch-name-hook"})search_code({"text":"copilot/"})search_code({"text":"def check_proposal"})search_code({"text":"def spec_problems"})search_code({"text":"def verify_problems"})file_symbols({"path":"src/devops_cli/roadmap/stage/stage_change.py"})read_file({"end_line":1098,"path":"src/devops_cli/roadmap/stage/stage_change.py","start_line":727})read_file({"end_line":1240,"path":"src/devops_cli/roadmap/stage/stage_change.py","start_line":969})read_file({"end_line":1700,"path":"src/devops_cli/roadmap/stage/stage_change.py","start_line":1660})read_file({"end_line":640,"path":"src/devops_cli/roadmap/stage/stage_change.py","start_line":550})read_issue({"number":4771})read_file({"end_line":350,"path":"src/devops_cli/roadmap/stage/stage_change.py","start_line":296})read_file({"end_line":2500,"path":"src/devops_cli/roadmap/stage/stage_change.py","start_line":2362})search_code({"text":"def criterion_problems"})read_file({"end_line":275,"path":"src/devops_cli/roadmap/stage/stage_criteria.py","start_line":150})read_file({"end_line":84,"path":"tests/invariants/test_runner_hooks.py","start_line":1})search_code({"text":"_NO_SPEC_PREFIXES"})search_code({"text":"def constant_problems"})read_file({"end_line":300,"path":"src/devops_cli/roadmap/stage/stage_constants.py","start_line":200})search_code({"text":"def form_problems"})read_file({"end_line":330,"path":"src/devops_cli/roadmap/stage/stage_form.py","start_line":180})read_file({"end_line":180,"path":"src/devops_cli/roadmap/stage/stage_form.py","start_line":60})read_spec({"capability":"pre-push-branch-current","requirement":"The pre-push hook refuses a branch that does not hold origin/main"})search_code({"text":"Branch Governance"})read_file({"end_line":340,"path":"docs/SDLC.md","start_line":319})search_code({"text":"CONTRIBUTING.md#5-naming"})search_code({"text":"## 5. Naming"})read_file({"end_line":720,"path":"tests/invariants/test_agents_md.py","start_line":630})search_code({"text":".pre-commit-config.yaml"})Tool calls: file_symbols=2 (empty=0), find_issues=4 (empty=0), git_log=3 (empty=0), list_files=4 (empty=0), read_file=48 (empty=0), read_issue=4 (empty=0), read_spec=13 (empty=0), references=4 (empty=2), search_code=60 (empty=6)
5 remaining items
fix(ci): Extend the naming-form and setup-step tests with the copilot…
fix(ci): State both accepted branch forms in the Naming table (#5136)
docs(openspec): archive the change (#5136)
fix(ci): Make check Tests & Coverage (shard 2 of 4) pass (#5136)
devops-cli-service commentedon Nov 13, 2026
Pull request #5407 is ready for review. The checks passed.
Spend: 93 model requests, 2744570 input tokens, 24375 output tokens.
devops-cli-service commentedon Nov 13, 2026
The runner Job devops-cli-runner-20261113-125641-473a ended: succeeded.
Image digest: sha256:bf9eeae4f2cd6683ab0dc2d3f43ca39abca8b62ce8cb181677083fbc7df9b10d
The last lines of its log:
feat(roadmap): run the plan checks before the stage push (#5416)
fix(ci): Accept copilot branches in the branch-name hook (#5407)
devops-cli-service commentedon Nov 13, 2026
Released in v0.129.1: https://github.com/dan-petty/devops-cli/releases/tag/v0.129.1
devops-cli-service commentedon Nov 13, 2026
Live since 2026-11-13 15:03 UTC