Repository navigation
Description
Problem or Motivation
No code refuses an agent POST, PATCH, PUT or DELETE through devops gh api to settings, ruleset, secret, org or transfer routes. Agents share the owner token.
Order 2 of the plan in #5311. The owner approved the plan on 2026-11-13.
Proposed Solution & Architectural Design
Add a route table in constants and a refusal for core.caller.is_agent_caller. The message names the owner step. The table covers POST repos/{o}/{r}/transfer. --dry-run still prints the request. Issue, PR, label and dispatch routes stay open.
Target Subsystem
SDLC, Git & PR Governance
Existing Tool Considered
No open tool applies. This is a refusal in the existing wrapper, with a route table in constants.
Cost: Build: about 600k tokens, 1 day, test first. Keep: about 20k tokens a month. Fix: about 100k tokens.
Acceptance Criteria
- Tests for each route class show these results: an agent is refused, a person passes, the dry run prints and sends nothing, and open routes pass.
- docs/commands/gh.md and SECURITY.md are updated.
Dependencies
No blocker. Part of #5311.
Source: #5311
Alternatives check of 2026-11-22: none.
Tool: none found.
Reason: Searches for a policy gate, API allowlist proxy or route-level guard over GitHub writes returned only unrelated documentation pages; no external tool classifies these routes or refuses agent callers inside the existing wrapper.
Lacks:
- Route table for settings, rulesets, secrets, org and transfer endpoints
- Refusal naming the matched route and the owner step
- Caller check through core.caller.is_agent_caller
- Dry run that prints the request and sends nothing
Proposed design
Problem statement
Agents share the owner token and can write repository and organization settings through devops gh api. No guard refuses these writes. This change adds a protected route table and refuses protected writes from agent callers. It leaves issue, pull request, label and workflow dispatch routes open.
Acceptance criteria
Requirement: Protected route table
The gh api guard SHALL classify POST, PATCH, PUT and DELETE endpoints under repository settings, rulesets, secrets, organization settings and repository transfer as protected.
Scenario: Protected route classes
- WHEN A test passes one representative endpoint from each protected class to the route table.
- THEN The table returns protected for each endpoint.
Requirement: Open routes
The gh api guard SHALL classify issue, pull request, label and workflow dispatch endpoints as open for agent callers.
Scenario: Agent open route
- WHEN A test checks an agent write to
POST /repos/o/r/issues,POST /repos/o/r/pulls,POST /repos/o/r/labelsandPOST /repos/o/r/actions/workflows/1/dispatches. - THEN The guard allows each request.
Requirement: Agent protected write refused
The gh api command SHALL refuse a protected write when core.caller.is_agent_caller is true.
Scenario: Agent protected write
- WHEN A test invokes the guard with agent caller true and a protected method and endpoint.
- THEN The guard returns a refusal that names the matched route and the owner step, and the request sender is not called.
Requirement: Person protected write allowed
The gh api command SHALL allow a protected write when core.caller.is_agent_caller is false.
Scenario: Person protected write
- WHEN A test invokes the guard with agent caller false and a protected method and endpoint.
- THEN The guard returns allow and the request sender is called once.
Requirement: Dry run prints protected request
The gh api command SHALL print the request and send no request for a protected route when --dry-run is set.
Scenario: Agent dry run protected write
- WHEN A test invokes the command with agent caller true, a protected method and endpoint, and
--dry-run. - THEN The output shows the method and endpoint, and the request sender is not called.
Requirement: Route normalization
The route table SHALL match a protected endpoint after it strips a leading slash and a query string.
Scenario: Protected endpoint with query string
- WHEN A test passes
PUT /repos/o/r/rulesets/1?force=trueto the route table. - THEN The table returns protected.
Requirement: Documentation states refusal
The documentation SHALL name the protected route classes and the refusal behavior.
Scenario: Documentation update
- WHEN A documentation test reads
docs/commands/gh.mdandSECURITY.md. - THEN Each file states the protected route classes and that an agent caller is refused.
Existing Tool Considered
No open, maintained tool covers the need. The alternatives check of 2026-11-16 found no policy gate or API allowlist proxy for these routes. The change builds a route table and a refusal in the existing wrapper. Cost: build about 600k tokens, 1 day; keep about 20k tokens a month; fix about 100k tokens.
Key questions
- What does
devops gh api --dry-rundo?: It previews the execution plan and makes no external change. It sends no request. [sources: docs/commands/gh.md] - Should
--dry-runprint a protected request from an agent or refuse it?: It prints the request and sends nothing. The refusal applies only to a real write. (best practice) [sources: docs/commands/gh.md]- Chosen: Dry-run prints only. The dry-run option previews the request and makes no external change. The issue requires the print.
- Rejected: Dry-run refuses. It hides the request that the agent must show the owner. It adds no safety because no request is sent.
- Which routes stay open to agent callers?: Issue, pull request, label and workflow dispatch routes stay open. The refusal covers only settings, rulesets, secrets, organization and transfer routes. (best practice) [sources: docs/commands/gh.md]
- Chosen: Keep normal work routes open. Agents need issue, pull request, label and dispatch writes. The issue names these routes as open.
- Rejected: Refuse every write. It blocks normal roadmap work and goes beyond the issue.
- How should the route table match an endpoint?: Strip a leading slash and a query string. Match the path segments against placeholders. Match the method in uppercase. (best practice) [sources: docs/commands/gh.md]
- Chosen: Normalized path match. GitHub endpoints can carry a leading slash or query string. An exact string match misses them.
- Rejected: Exact string match. It misses equivalent endpoints and is brittle.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 13, 2026
Both work on the devops gh subsystem, but #181 adds native pr subcommands while the candidate adds a refusal gate on agent writes to sensitive api routes.devops-cli-service commentedon Nov 16, 2026
Alternatives check: none
Reason: Searches for a policy gate, API allowlist proxy, or guard that refuses writes to GitHub settings/ruleset/secret/org/transfer routes returned no open, maintained tool — only unrelated pages. The issue needs a route-table refusal inside the existing devops
gh apiwrapper (agent refused, person passes, dry-run prints only), which no general tool covers.Tool: none found
Lacks:
Searches run:
Checked on 2026-11-16. A person decides what this means for the item. The check changes no label and closes no issue.
devops-cli-service commentedon Nov 17, 2026
Status set to Ready at e6f5718 (see proposed design in issue body).
feat(gh): refuse agent writes to repo and org settings routes
devops-cli-service commentedon Nov 25, 2026
Released in v0.218.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.218.0
devops-cli-service commentedon Nov 25, 2026
Live since 2026-11-25 07:20 UTC