Repository navigation
Description
Ready: implementation plan (refined 2026-10-17 at 3dd7fa6)
This section supersedes any text below that conflicts with it.
Decisions
- Whether this item waits for all of refactor(github): the github session owns transport, ledger, error classes and link pagination #983: no. It needs only refactor(github): the github session owns transport, ledger, error classes and link pagination #983's PR 1 (
session.rest(), the not-found, unread and scope error classes, the origin hook, pacing and ledger feed) and PR 2 (session.paginate()). refactor(github): the github session owns transport, ledger, error classes and link pagination #983's later PRs (gh-output classifier,run_ghpaging, roadmap store, ETag cache, fake promotion) touch nothing this item calls. - How responses are typed: pydantic models of only the fields each caller reads, validated from gidgethub's JSON, per the owner's 2026-10-08 refactor(github): the github session owns transport, ledger, error classes and link pagination #983 decision. They live in
src/devops_cli/github/client.pybesideRepoInfo(:29):PullRequest(title, and head and base as aCommitRefwith sha, ref and repository full name),PullRequestFile(filename, status, previous filename, additions, changes). - Whether the
GitHubClientname stays: yes, as the typed facade over the session. It is built asGitHubClient(session)bysession.client(src/devops_cli/github/session.py:52-57) and holds the real calls, so it is not a shim. - What a pull request read sends:
GET /repos/{repo}/pulls/{n}forget_pull, and a newget_pull_files(repo, n)that pagespulls/{n}/files?per_page=100withsession.paginate(). A head repository that GitHub returns asnull(a deleted fork) isNonein the model, and callers fall back to the base repository as today'sor repodoes (src/devops_cli/ai/review/runner.py:873-874). - How
get_file_atreads a file: the JSON contents endpoint,GET /repos/{repo}/contents/{path}?ref={ref}, base64-decoded. It returnsNonefor a 404, a directory listing, anencodingother thanbase64(a file over 1 MB) or bytes that are not UTF-8, and raises the session'sGitHubUnreadErrorfor any other failure. That keeps today's contract (absent, binary or too large,client.py:105-114) and stops a failed read from looking like a missing file. - How
get_merge_basereads:GET /repos/{repo}/compare/{base}...{head}?per_page=1, returningmerge_base_commit.sha,Noneonly on a 404. - How an org's repositories are listed:
GET /orgs/{org}/repos?type=all(ortype=public). OnGitHubNotFoundErrorwithorg == session.login,GET /user/repos?affiliation=owner&visibility=all(orpublic).repos clone-org <login>then clones the repositories the account owns into that login's directory; PyGithub'suser.get_repos()also returned collaborator and organization repositories, which belong under other owners. - Whether the review's posting changes: no.
devops review prposts one issue comment withPOST /repos/{repo}/issues/{n}/comments, and a dry run posts nothing. - What happens to the label methods: deleted with
_get_github_client(src/devops_cli/commands/gh.py:141-148).GhCliClientalready implementsLabelClient(src/devops_cli/github/labels.py:111-119), sogh labels syncusesGhCliClient(target_repo)and_get_repo_labelsdrops its PyGithub fallback (commands/gh.py:165-170). Two implementations of one protocol become one. - How SSH keys are registered: one path, on the session.
register_key_on_githublists/user/keysand/user/ssh_signing_keyswithpaginate()and posts only the keys that are missing. The gh path (_register_with_gh,_gh_auth_ok,_gh_list_keys,_gh_add_key,src/devops_cli/github/ssh.py:51-145) is deleted, because since refactor(github): one github session per identity owning token, quota and transport #767 both paths act as the same identity. A 422 after the list is a failure, not "already registered": GitHub reports a duplicate key only in message text (error codecustom), and the list decides that structurally. - What a missing scope says: a
GitHubScopeErrorfrom either SSH call becomesSSHRegistrationErrorwith today's hint,gh auth refresh -h github.com -s admin:public_key,write:ssh_signing_key(ssh.py:139-143). SSHRegistrationError's base:GitHubOperationErrorinstead ofRuntimeError(ssh.py:20). AGENTS.md requires domain errors to inheritDevOpsCLIError, andcommands/ssh.py:161and:250catch it by name, so nothing else changes.- Which methods go as dead:
create_pr_review_comment(client.py:150-167),delete_user_ssh_key(:96-97),get_issues,create_issue,edit_issue(:202-263),get_pages_infoandget_pages_builds(:267-279).rgfinds no caller of any of them insrc(thecreate_issuehits are the roadmap store's own method). The milestone methods are already gone (refactor(github): roadmap store that reads and writes items, releases and board fields behind one interface #768), so fix(github):gh milestones editwithout--statecloses the milestone #777's default no longer applies here. get_pr_diffand_add_signing_key: already on the session after refactor(github): the github session owns transport, ledger, error classes and link pagination #983's PR 1; this item does not touch them except that the signing key joins the one SSH path.- Whether removing PyGithub drops anything else: no.
pyjwtstays throughmcp,pynaclis declared directly (pyproject.toml:41, fix(deps): pyproject.toml declares every package src imports, and a deptry step in devops ci keeps it that way #1120), andrequestsandurllib3stay through other packages (checked inuv.lock). - What happens to the other PyGithub mentions in
src: the docstrings atcommands/repos.py:60,commands/gh.py:142,github/session.py:7,:54,github/client.py:1,:40,:102andgithub/ssh.py:38,:47go with the code they describe, and the reset-margin comment atsrc/devops_cli/config/constants.py:1036-1039keeps its reason (GitHub reportsresetin whole seconds) but no longer cites PyGithub's source; the 1 s margin itself is unchanged. The criterionrg -i pygithub srcthen holds without an exception. - How the docs change:
ai/knowledge_base/devops_cli/libraries/pygithub.mdis deleted with its row in the knowledge-base README (src/devops_cli/ai/knowledge_base/README.md:50);python_packages.md(:39,:171-172) names gidgethub and the session instead; AGENTS.md:85 drops "PyGithub" from its deprecation list, edited in place;docs/KNOWLEDGE_BASE.mdis regenerated withuv run devops docs generate --sync-readme.
Delivery
- PR 1 (M): pull requests, files, merge base and repositories on the session.
GitHubClient(session), the two models,get_pull,get_pull_files,get_file_at,get_merge_base,get_org_reposand acreate_issue_comment(repo, n, body); the review runner,devops review pr,devops analyze pranddevops repos clone-orguse them; the dead methods, the label methods and_get_github_clientare deleted. Tests first, all over refactor(github): the github session owns transport, ledger, error classes and link pagination #983'sgithub_apifake: a recorded PR payload with two pages of files (the second reached throughLink) givesanalyze prand the review's PR fetch the same title and changed-file list as before;get_file_atreturnsNonefor a 404, a directory,encoding: noneand non-UTF-8 bytes, and raisesGitHubUnreadErroron a 500 after the retries;get_merge_basereturnsNoneon a 404 and raises on a 500;devops review prsends exactly onePOST /repos/{repo}/issues/{n}/comments, and none with--dry-run;repos clone-orglists/orgs/{org}/repos, and falls back to/user/repos?affiliation=owneronly when the org is a 404 and the name is the session's login; every request carries the session's token;gh labels sync --dry-runruns onGhCliClient. Files:src/devops_cli/github/client.py,src/devops_cli/github/session.py,src/devops_cli/github/labels.py,src/devops_cli/ai/review/runner.py,src/devops_cli/commands/review.py,src/devops_cli/commands/analyze.py,src/devops_cli/commands/repos.py,src/devops_cli/commands/gh.py, newtests/fixtures/github/payloads,tests/test_github_client.py,tests/test_github_session.py,tests/test_analyze.py,tests/test_repos.py,tests/test_review_pr_post.py,tests/test_review_scope.py,tests/test_review_runner.py,tests/test_review_path_routing.py,tests/test_batch_2_review_defects.py,tests/test_gh_cmd.py,tests/test_github_milestones.py. Refs refactor(github): pull request, repository and ssh key calls move from pygithub onto the github session #891. - PR 2 (S): SSH keys on the session, and PyGithub removed. One registration path,
SSHRegistrationErrorunderGitHubOperationError, the key methods onGitHubClient, then PyGithub out ofpyproject.toml:16anduv.lock, the knowledge-base page and the AGENTS.md mention. Tests first: over the fake,register_key_on_githublists both endpoints and posts only the missing key; a key present in both lists sends no POST; a 422 on the POST raisesSSHRegistrationError; a 403 whosex-accepted-oauth-scopesnameswrite:ssh_signing_keyraises it with the refresh hint; no gh subprocess runs. Files:src/devops_cli/github/ssh.py,src/devops_cli/github/client.py,src/devops_cli/github/session.py,src/devops_cli/config/constants.py,pyproject.toml,uv.lock,src/devops_cli/ai/knowledge_base/devops_cli/libraries/pygithub.md(deleted),src/devops_cli/ai/knowledge_base/README.md,src/devops_cli/ai/knowledge_base/devops_cli/python_packages.md,AGENTS.md,docs/KNOWLEDGE_BASE.md,tests/test_github_ssh.py,tests/test_ssh.py,changelog.d/891.md. Closes refactor(github): pull request, repository and ssh key calls move from pygithub onto the github session #891.
Acceptance criteria
-
rg -n "^\s*(from github( |\.)|import github$)" src testsprints nothing. -
rg -n -i pygithub pyproject.toml uv.lock src AGENTS.mdprints nothing. - Review, analyze,
repos clone-organd SSH key registration run overhttpx2.MockTransportin their tests, every request carries the session's token, and no test patches PyGithub, httpx2 or gidgethub. -
get_file_atreturnsNoneon a 404, a directory, a file over 1 MB and non-UTF-8 bytes, and raisesGitHubUnreadErroron a 500 after the retries;get_merge_basereturnsNoneonly on a 404. - For the recorded PR payload,
analyze prand the review's PR fetch build the same title and changed-file list as before, including the files on the second page. -
devops review prposts exactly one issue comment throughPOST /repos/{repo}/issues/{n}/comments, and a dry run posts none. -
register_key_on_githubruns no gh subprocess, posts only missing keys, and treats a 422 as a failure. -
rg -n "_get_github_client|create_pr_review_comment|delete_user_ssh_key|get_pages_builds|_register_with_gh|_gh_add_key" src testsprints nothing. -
uv run devops cipasses within its 5-minute budget; each new test runs in under 1 s and opens no socket. -
changelog.d/891.mdlists the PyGithub removal under### Removedand the typed client under### Changed;CHANGELOG.mdis untouched. - Pending a person (live GitHub, read-only): from the repository root,
uv run devops analyze pr <an open PR number> --no-enhancedlists that PR's changed files.
Current references
PyGithubpin:pyproject.toml:16;pynaclpin:pyproject.toml:41RepoInfo,GitHubClient.__init__:src/devops_cli/github/client.py:29,:39-46get_org_repos:src/devops_cli/github/client.py:48-85- SSH key methods:
src/devops_cli/github/client.py:87-97 get_pull,get_file_at,get_merge_base:src/devops_cli/github/client.py:101-129create_pr_review_comment:src/devops_cli/github/client.py:150-167- Label, issue and Pages wrappers:
src/devops_cli/github/client.py:171-279 GitHubSession.client:src/devops_cli/github/session.py:52-57register_key_on_github,_register_with_token_api, gh path,_add_signing_key:src/devops_cli/github/ssh.py:24,:37,:51-145,:148SSHRegistrationError:src/devops_cli/github/ssh.py:20LabelClient:src/devops_cli/github/labels.py:111-119_get_github_client,_get_repo_labels, labels sync:src/devops_cli/commands/gh.py:141-148,:151-171,:244- Review PR fetch:
src/devops_cli/ai/review/runner.py:793-833(_prepare_pr_content),:836(_pr_changed_file),:845(_pr_base_revision),:866(_materialize_pr_head) _resolve_pr_files,_post_pr_review_comment:src/devops_cli/commands/review.py:595,:608-635analyze_prPR read:src/devops_cli/commands/analyze.py:520-571_require_client,clone_org, itsget_org_reposcall:src/devops_cli/commands/repos.py:59-65,:148,:183- SSH command callers:
src/devops_cli/commands/ssh.py:161,:202,:250,:307 - Knowledge base:
src/devops_cli/ai/knowledge_base/devops_cli/libraries/pygithub.md,src/devops_cli/ai/knowledge_base/README.md:50,src/devops_cli/ai/knowledge_base/devops_cli/python_packages.md:39,:171-172,docs/KNOWLEDGE_BASE.md:32 - AGENTS.md PyGithub mention:
AGENTS.md:85 - Other PyGithub mentions:
src/devops_cli/commands/repos.py:60,src/devops_cli/commands/gh.py:142,src/devops_cli/github/session.py:7,:54,src/devops_cli/github/client.py:1,:40,:102,src/devops_cli/github/ssh.py:38,:47,src/devops_cli/config/constants.py:1036-1039
Dependencies and order
- refactor(github): the github session owns transport, ledger, error classes and link pagination #983 (open, P1, no milestone): this item starts after refactor(github): the github session owns transport, ledger, error classes and link pagination #983's PR 1 (REST transport, error classes, origin hook) and PR 2 (
session.paginate()) merge, and needs nothing else from it. Those two PRs merge in v0.2.37 ahead of this item. - fix(deps): pyproject.toml declares every package src imports, and a deptry step in devops ci keeps it that way #1120: closed;
pynaclis declared directly, so removing PyGithub keepsgithub/secrets.py:9working. - refactor(github): roadmap store that reads and writes items, releases and board fields behind one interface #768 and fix(github):
gh milestones editwithout--statecloses the milestone #777: closed; the milestone methods are already gone. - refactor(ai): delete the pass-through package facades and the two stagepipeline protocols nothing implements #1002 (v0.2.37): empties
src/devops_cli/github/__init__.py, which re-exportsGitHubClient,RepoInfo,SSHRegistrationErrorandregister_key_on_github(:27,:129). This item keeps those names, so the two do not depend on each other; whichever lands second rebases. - refactor(github): pr readiness is one verdict module that the pr commands, the monitor and mcp consume #998 (v0.2.37): shares no file with this item.
- test(github): github/ is tested through its public interface over the gh process and session fakes, with no internal patches or private imports #1321, test(cli): devops pr, gh and repos are thin adapters tested over edge fakes, and merge readiness is tested in its package #1324, test(ai): devops review, devops analyze and the devops ai commands are thin adapters tested over the model seam and edge fakes #1326, test(review): ai/review and review/ are tested through one public interface over the model, tool-executor and process fakes, with no mock detection in src #1328, test(ai): the remaining ai modules are tested through their public interfaces on edge fakes, and the legacy provider layer leaves src #1331 and test(security): scanner, secret and crypto tests run on the executor, process, http and keyring fakes, and scanners stop looking for mocks #1332 wait for this item, so that refactor(github): the github session owns transport, ledger, error classes and link pagination #983's fake answers every GitHub call.
Context & Rationale
GitHubClient wraps PyGithub: pyproject.toml:16 pins PyGithub==2.10.0, and the client is built at github/client.py:39-46. After #767, the client is built only from the session's token. Its calls still use PyGithub's own HTTP stack, retries and rate handling, so they bypass the session's quota ledger, retry policy and error classes. Checked at ef21785:
- Pull requests.
get_pullreturns a PyGithubPullRequest(client.py:136-138).ai/review/runner.py:1885-1889reads its title._materialize_pr_head(:1897-1940) readsheadandbasethroughgetattr, callsget_files(), and fetches files withget_file_at.commands/review.py:556lists the changed files, and:588posts withpull.create_issue_comment.commands/analyze.py:612-616and:663make the same reads.
- File reads.
get_file_at(client.py:140-149) returnsNoneon any exception, so a failed read looks like a missing file. - Repositories.
get_org_repos(:83-120) is used bycommands/repos.py:177. - SSH keys. The SSH key methods (
:122-132) are used bygithub/ssh.py:38-49. - Dead methods.
create_pr_review_comment(:170-189) anddelete_user_ssh_key(:131-132) have no callers. - Labels and milestones. These methods (
:191-312) are reached through_get_github_client(commands/gh.py:133-141) andcommands/release.py:1616, unless refactor(github): roadmap store that reads and writes items, releases and board fields behind one interface #768's Releases slice has already removed them.edit_milestonedefaults tostate="closed"(:276; see fix(github):gh milestones editwithout--statecloses the milestone #777). - Tests. PyGithub mocks are built in
tests/test_github_client.py,test_repos.py,test_analyze.py,test_ssh.py,test_github_ssh.py,test_review_pr_post.py,test_review_scope.py,test_review_runner.py,test_review.pyandtest_gh_cmd.py. - Agent guidance.
ai/knowledge_base/devops_cli/libraries/pygithub.mdteaches agents to use PyGithub, and AGENTS.md:109 lists it.
Scope & Deliverables
- Deliverable: the remaining
GitHubClientmethods callsession.rest()andsession.paginate()and return pydantic models. PyGithub is removed.- A
PullRequestmodel carries the title, the head and base SHA and repository, and the changed files frompulls/{n}/files. The review, analyze, repos and SSH callers use it. devops review prposts its single comment withPOST /repos/{repo}/issues/{n}/comments, as it does today.get_file_atreturnsNoneonly on a 404. Any other failure raises the session's unread error.create_pr_review_commentanddelete_user_ssh_keyare deleted. So are the label and milestone methods, if refactor(github): roadmap store that reads and writes items, releases and board fields behind one interface #768 hasn't already removed them.- Removed without shims: PyGithub from
pyproject.tomlanduv.lock,pygithub.md, and the PyGithub mention at AGENTS.md:109.
- A
- Acceptance criteria:
- Both of these print nothing; the reviewer runs them:
rg -n "^\s*(from github( |\.)|import github$)" src testsrg -n -i pygithub pyproject.toml uv.lock src AGENTS.md
- The rewritten tests run review, analyze,
repos clone-organd SSH key registration onhttpx2.MockTransport. Each asserts that every request carries the session's token. Verified by unit tests. get_file_atreturnsNoneon a 404 and raises the unread error on a 500 after retries. Verified by a unit test.- For a recorded PR payload,
analyze prand the review's PR fetch build the same title and changed-file list as before. Verified by a unit test with a fixture. uv run devops cistays within its 5-minute budget. Each new test runs in under 1 s, and no test opens a socket.- Person check (live GitHub, read-only). From the repo root,
uv run devops analyze pr <an open PR number> --no-enhancedlists that PR's changed files.
- Both of these print nothing; the reviewer runs them:
- Key questions:
- Does the
GitHubClientname stay? (proposed) Yes. It becomes the typed REST facade over the session and holds the real calls, so it is not a shim. - Do the review's posting semantics change? (proposed) No. It still posts one issue comment.
- How are an org's repositories listed? (proposed) With
GET /orgs/{org}/repos, as today. When the name is the signed-in user (session.login), they come fromGET /user/repos?affiliation=owner, which matches today'suser.get_repos()fallback.
- Does the
- Constraint: no new dependency. No request leaves the session.
Strategic Alignment
- Milestone: Backlog
- Depends on: refactor(github): one github session per identity owning token, quota and transport #767
- Related: refactor(github): roadmap store that reads and writes items, releases and board fields behind one interface #768 removes the label and milestone wrappers; fix(github):
gh milestones editwithout--statecloses the milestone #777 covers the milestonestatedefault.
Split off #767 during the v0.2.25/v0.2.26 readiness review (2026-10-01): Moving the PyGithub calls off it touches review, analyze, repos and SSH code and about ten test modules. That would push #767 past one PR. The roadmap service doesn't use these calls, and #767 already builds GitHubClient from the session's token, so the identity constraint holds without this. What it adds is one ledger, retry policy and error model for those calls.
Update 2026-10-08: refinement
Per the owner's #983 decision, gidgethub returns JSON and callers validate their fields; PyGithub stays until #983 lands. Depends on #983 and #1120 (PyNaCl). Five more methods have no caller (github/client.py:202-280).
-
get_merge_baseandget_file_atreturnNoneonly on a 404. - One SSH key path; only a 422 naming an existing key counts as registered (
github/ssh.py:150,:162).
Proposed design
Problem statement
The GitHubClient class currently wraps PyGithub, which bypasses the session's quota ledger, retry policy, and error classes. This issue refactors the client to use the GitHub session directly for all API calls, removing PyGithub dependency.
Acceptance criteria
- Criterion 1: PyGithub is completely removed from the codebase with no remaining imports or references
Verification: Runningrg -n "^\s*(from github( |\.)|import github$)" src testsprints nothing - Criterion 2: All GitHub API calls go through the session's REST transport and pagination methods
Verification: Tests verify that every request carries the session's token and runs overhttpx2.MockTransport - Criterion 3: The get_file_at method returns None only on a 404 and raises GitHubUnreadError on other failures
Verification: Unit tests check that get_file_at returns None for 404, directory, large file, and non-UTF-8 bytes, and raises GitHubUnreadError for 500 after retries - Criterion 4: Pull request data is fetched using typed Pydantic models instead of PyGithub objects
Verification: Tests verify that analyze pr and review PR fetch build the same title and changed-file list as before, including files from second page via pagination - Criterion 5: SSH key registration uses only one path through the session
Verification: Tests check that register_key_on_github lists both endpoints and posts only missing keys, with no gh subprocess calls - Criterion 6: The GitHubClient class no longer contains dead methods like create_pr_review_comment and delete_user_ssh_key
Verification: Runningrg -n "_get_github_client|create_pr_review_comment|delete_user_ssh_key|get_pages_builds|_register_with_gh|_gh_add_key" src testsprints nothing
Key questions
- Does the GitHubClient name stay?: Yes. It becomes the typed REST facade over the session and holds the real calls, so it is not a shim. (proposed) [sources: src/devops_cli/github/client.py:39-46]
- Do the review's posting semantics change?: No. It still posts one issue comment. (proposed) [sources: src/devops_cli/github/client.py:170-189]
- How are an org's repositories listed?: With GET /orgs/{org}/repos, as today. When the name is the signed-in user (session.login), they come from GET /user/repos?affiliation=owner, which matches today's user.get_repos() fallback. (proposed) [sources: src/devops_cli/github/client.py:83-120]
Fit
Needs splitting into 2 items:
- PR 1 (M): pull requests, files, merge base and repositories on the session
- PR 2 (S): SSH keys on the session, and PyGithub removed
Suspected block
None.
Dependencies
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
dan-petty commentedon Oct 8, 2026
Amendment from the 2026-10-08 client-library audit (at 05e9388):
session.rest()calls and pydanticPullRequest, file and repository models would replace a maintained SDK with home-grown client code; the version pinned, 2.10.0 (2026-08-20), is current. Take the typed models of the SDK refactor(github): the github session owns transport, ledger, error classes and link pagination #983 settles on instead, so this item becomes a caller migration with no new HTTP code. Keep PyGithub until refactor(github): the github session owns transport, ledger, error classes and link pagination #983's decision lands.nacl.github/secrets.py:9imports PyNaCl to seal Actions secrets (encrypt_secret,:49-56). PyNaCl is not in[project].dependencies; it arrives through PyGithub'spynacl>=1.4.0. fix(deps): pyproject.toml declares every package src imports, and a deptry step in devops ci keeps it that way #1120 declares it, and it has to land before this item, or removing PyGithub breaks secret sealing. Add fix(deps): pyproject.toml declares every package src imports, and a deptry step in devops ci keeps it that way #1120 to Depends on.get_merge_base(github/client.py:116-129) returns None on any exception, likeget_file_at(:105-114). Theget_file_atcriterion (None only on a 404, the unread error otherwise) should cover both.github/ssh.py:51-66), PyGithub (:37-48) and a barehttpx2.Clientfor the signing key (:148-163). After this item one path should remain, and only a 422 whose error names an existing key should count as "already registered" (:162accepts every 422 today).Found by the 2026-10-08 client-library audit.
dan-petty commentedon Oct 8, 2026
Owner decision on #983, 2026-10-08: the GitHub session's transport is gidgethub over the egress-checked httpx2 pool. gidgethub returns JSON, not typed models. So this item moves its callers onto the session and validates only the fields each one reads with pydantic models: response validation, not hand-written REST methods. PyGithub stays until #983's session lands. #1120 (declaring PyNaCl) still lands first.
dan-petty commentedon Oct 17, 2026
Moved to v0.2.37: v0.2.37 started with fewer than its 16 items and was topped up to 16 from Ready items, critical fixes and P0 features first. (devops roadmap reprioritize)
4 remaining items
dan-petty commentedon Oct 19, 2026
Amendment (2026-10-19): folded here by intake under the agent filing quota
The cycle's agent filing allowance (#1153) was used, so
devops roadmap intakefiled nothing and named this item as the nearest. The candidate below finishes moving gh failure handling onto #983's classifier, and it sits beside this item's move of the remaining GitHub calls onto the session. It can land with this item or be filed on its own in a later cycle. #983's task file names this amendment as its follow-up. Candidate title: "refactor(github): route the remaining gh-text matchers through the gh classifier".Friction
#983 (PR 3, #1682) gave gh's failures one classification, read from gh's exit status and stderr through one table (
src/devops_cli/github/error_classifier.py,gh_failure_detailsand its_GhClassifierrows). Four callers still decide what a gh failure means by matching gh's text themselves:#983's task file names this as follow-up work.
Evidence
At release/v0.2.37 20a0191:
_is_branch_unprotected_error(src/devops_cli/github/branch_protection.py:128) treats any output containing "404" and "branch" or "protection" as an unprotected branch. A 404 for a missing repository or a token without access also matches, so reading protection for a repository the token can't see reports "no protection" instead of a failure.create_repository_issue(src/devops_cli/github/issues.py:250) looks for "could not add to milestone" in stderr or stdout. It retries without the milestone only when that phrase appears, and otherwise reports the raw text._report_create_failure(src/devops_cli/commands/pr.py:865) looks for "must first push" to suggest pushing the branch.extract_retry_after(src/devops_cli/github/rate_limiter.py:606) reads a Retry-After value with a regex over any message, beside the classifier's ownparse_retry_afterandretry_after_seconds.Remedy
Acceptance criteria
rg -n '"404" in|must first push|could not add to milestone|retry\[- \]after' src/devops_cliprints only classifier table rows.uv run devops cipasses.test(github): the GitHub session's fake lives under tests/support/fak…
refactor(github): SSH keys register through the session alone and Git…
refactor(github): read pull requests, files and repositories through …
refactor(github): remove the PyGithub manual and make SSHRegistration…
dan-petty commentedon Oct 22, 2026
What changed
#1924, merged into
release/v0.2.39as d67d528.18 file(s) changed.
How it was verified
Check runs at 70b2d5e:
Acceptance Criteria of
docs/agent/tasks/task-891-ssh-keys-through-the-gidgethub-session.md:register_key_on_githubsends only session requests: one POST to/user/keysand one to/user/ssh_signing_keyswith the session's token, and no GET when GitHub accepts both (test_a_key_is_added_as_an_auth_key_and_a_signing_key_with_the_sessions_token). It runs nogh apiorgh auth status;get_github_session()still runsgh auth tokenonce to find the token.test_a_422_counts_as_registered_only_when_the_session_lists_the_key,test_a_key_listed_on_a_later_page_counts_as_registered).GitHubScopeErrorwith the refresh hint, at both endpoints (test_a_token_without_the_scope_is_a_registration_error_with_the_refresh_hint); a 5xx is a registration error caused byGitHubUnreadErrorand reads no listing (test_a_5xx_is_a_registration_error_with_the_sessions_error_as_its_cause); no login is a registration error that namesgh auth loginand sends nothing (test_registration_without_a_github_login_is_a_registration_error).POST /user/keysorPOST /user/ssh_signing_keysis a registration error caused byGitHubScopeError(itself caused by theGitHubNotFoundError) that names the endpoint's scope andgh auth refresh -h github.com -s admin:public_key,write:ssh_signing_key, and registration stops there (test_a_404_at_a_key_endpoint_names_the_scopes_and_the_command_that_adds_them); a 404 on the listing a 422 sends the session to read still counts as a listing that can't be read (test_a_422_counts_as_registered_only_when_the_session_lists_the_key,listing-not-found).devops ssh rotateremoves the key it generated when GitHub refuses it (test_a_rotation_github_refuses_removes_the_new_key).devops ssh rotateprints the scope command when GitHub answers 404, and removes the key it generated (test_a_rotation_github_answers_with_a_404_warns_with_the_scope_command_and_removes_the_new_key).GitHubClientandGhCliClienthave no attribute namedget_user_ssh_keys,add_user_ssh_key,delete_user_ssh_key,create_pr_review_comment,get_issues,create_issue,edit_issue,get_pages_infoorget_pages_builds, anddevops_cli.modelsexports noSSHKeyInfo;devops_cli.github.issueshas noedit_repository_issue,close_repository_issueor_build_issue_patch_payload.tests/test_github_session.pyhas no test that mocks PyGithub, andtest_the_client_is_built_only_by_the_sessionholds the one place that builds the client.admin:public_key, runuv run devops ssh register --key-file <private key path>and expect the failure to nameadmin:public_keyand thegh auth refresh -h github.com -s admin:public_key,write:ssh_signing_keycommand, because the 404 GitHub answers a token without the scope is recorded from gh's output, not from a live call.uv run devops ssh register --key-file <private key path of a key already on the account>and expectRegistered <title> on GitHub (auth + signing)., because GitHub answers 422 for each key it holds and the listing confirms it.get_pullreturns the title and both commits of the recorded pull request. The head has no repository, because the fork is deleted. The test asserts the token of the session on every request (test_a_pull_request_is_read_with_its_title_and_both_commits). An answer that is no pull request raisesGitHubUnreadError(test_a_pull_request_that_lacks_a_title_is_unread).get_pull_filesreads both pages of the recorded listing (test_the_files_of_a_pull_request_come_from_every_page).devops ai analyze prand the pull request fetch of the review give the recorded title and both changed files (test_analyze_pr_lists_the_title_and_the_files_of_every_page,test_a_pr_review_of_the_recorded_pull_request_reads_both_pages_of_files). The review reads the head files from the base repository when the fork is deleted.get_file_atreturns None for a 404, a directory, a link, a file over 1 MB and bytes that are not UTF-8 (test_a_file_that_is_absent_binary_or_too_large_is_none). It raises the error of the session for a 500, a refused token and a body that is not a file (test_a_file_that_could_not_be_read_raises_instead_of_reading_as_absent).test_a_path_and_a_ref_are_encoded_in_the_request,test_a_repository_name_is_encoded_in_the_request,test_an_organization_name_is_encoded_in_the_request).get_merge_basereturns the merge base of the recorded comparison and None for a 404 only. It raises for a 5xx and for a comparison without a merge base (test_the_merge_base_is_read_from_the_compare_endpoint,test_a_comparison_github_does_not_find_has_no_merge_base,test_a_comparison_that_could_not_be_read_raises).get_org_reposlists/orgs/{org}/repos. It falls back to/user/repos?affiliation=owneronly for a 404 and the login of the session. It leaves out forks, private repositories and archived repositories as asked (test_the_account_of_the_session_lists_the_repositories_it_owns_when_it_is_no_organization,test_another_account_that_is_no_organization_raises_the_not_found_error).devops repos clone-orgreports a missing organization as a GitHub error, without a traceback, and creates no directory (test_repos_clone_org_names_the_missing_organization).devops review prreports a GitHub failure as its error, without a traceback. This holds for the pull request (test_a_pr_review_ends_with_the_github_error_when_the_pull_request_cannot_be_read). It holds for a base file of a symbol delta and for.devops/review.tomlat the merge base (test_a_pr_review_ends_with_the_github_error_when_a_file_of_the_base_cannot_be_read).devops ai analyze prreports a GitHub failure on the pull request or on its files as its error, without a traceback (test_analyze_pr_ends_with_the_github_error_when_the_pull_request_cannot_be_read).test_a_pr_review_reads_the_merge_base_from_the_base_repository_the_pull_request_names).devops review pr --postsends exactly onePOST /repos/{repo}/issues/{n}/comments, and a dry run sends none (test_devops_review_pr_post_publishes_comment,test_devops_review_pr_post_dry_run_skips_comment,test_devops_review_pr_post_empty_diff_makes_zero_model_calls).test_devops_review_pr_post_names_the_files_the_pull_request_leaves_in_place). The command exits 1 and posts nothing when GitHub fails the read of the files (test_devops_review_pr_post_stops_when_the_files_of_the_pull_request_cannot_be_read).devops gh labels sync --dry-runlists the labels withGhCliClientand creates none (test_cli_labels_sync).GitHubClienthas no label method, and_get_github_clientis gone.rg --glob '*.py' -n "^\s*(from github( |\.)|import github$)" src testsprints nothing.uv run deptry srcpasses without PyGithub. The swallowed-failures ceilings ofgithub/client.pyandcommands/review.pyare gone. The ceiling ofcommands/gh.pyis 1, and the ceiling ofai/review/path_classes.pyis 2.uv run devops ai analyze pr <an open PR number> --no-enhancedand expect the changed files of that pull request. No test reads live GitHub.SSHRegistrationErroris aGitHubOperationErrorand aDevOpsCLIError, with the codeGITHUB_OPERATION_FAILEDand the exit status 1 (test_a_registration_failure_is_a_github_operation_error_of_the_domain_taxonomy).docs/ERRORS.mdlists it (test_configuration_and_error_catalog_docs_describe_real_surface).rg --glob '*.py' -n "^\s*(from github( |\.)|import github$)" src tests,rg -n -i pygithub pyproject.toml uv.lock src AGENTS.mdandrg -n "_get_github_client|create_pr_review_comment|delete_user_ssh_key|_register_with_gh|_gh_add_key" src tests. The last one leaves outget_pages_builds, because the module function of that name ingithub/pages.pyis in use.devops_clihas 39 of them, and 22 of those are library manuals.it_domainshas 40 (test_list_knowledge_base_articles_all,test_list_knowledge_base_articles_by_category,test_list_knowledge_base_articles_by_division,test_get_knowledge_base_stats,test_every_target_manual_has_valid_front_matter).uv run devops review pr <an open PR number> --pre-analysis-onlyand expect a review without an error.get_pullandget_pr_diffread one URL with two media types, and gidgethub keeps its cache by URL only.feat(release): v0.2.39 (#1947)