Repository navigation
Description
Problem
Counts come from one AST pass over tests/test_*.py at 5c45b1e, the head of release/v0.2.28, and [code: …] lines are at the same commit. A file belongs to the package it references most, as in the census. Patch sites are patch, patch.object, patch.dict, mocker.patch and monkeypatch.setattr/setitem/delattr calls aimed at devops_cli. Private imports are _-prefixed names imported from devops_cli.
- Files. 20 test files have
github/as their primary package: 9,368 lines and 413 tests [measured: AST pass at 5c45b1e]. They aretest_gh_issue_closure,test_gh_issues_milestones,test_gh_project_workflows,test_github_branch_protection,test_github_client,test_github_issues,test_github_labels,test_github_metrics,test_github_pages,test_github_pr_monitor,test_github_pr_threads,test_github_projects,test_github_projects_reconcile,test_github_rate_limiter,test_github_secrets,test_github_session,test_github_ssh,test_pr_check_runs,test_pr_check_verdictandtest_release_notes_sync.test_pr_cmd.pyalso referencesgithub/most, but its subject isdevops pr, so test(cli): devops pr, gh and repos are thin adapters tested over edge fakes, and merge readiness is tested in its package #1324 names it. feat(release): release-please makes every release from main #1952 deletedtest_gh_issue_closureandtest_release_notes_syncwith the release code that they tested, so this item does not own them now. - Coupling. These files hold 343 patch sites aimed at devops_cli internals, in 17 files, and 92 private imports, in 13 files [measured].
- 101 of the patches replace
run_ghin 11 modules: projects 24, pr_monitor 14, ssh 13, issues 11, pr_threads 11, secrets 7, release_notes 7 and four others. - 24 more replace
run_subprocess(17 inrate_limiter, 1 inpr_monitor) or_burst_protected_subprocess(6). - Most of the rest patch github's own functions.
test_github_pr_monitor.pyalone patchespr_monitor50 times, and_detect_copilot_statusis imported privately 8 times. test_github_session.py:49and:87set the privatecore.process._github_token.
- 101 of the patches replace
- Hand-rolled doubles.
_FakeGithubis defined 4 times intest_github_client.py(:126,:168,:197,:236).- Single copies:
_RecordedGithubattest_github_session.py:33and_mock_procattest_gh_project_workflows.py:28. - The files also make 34
CompletedProcess(calls and 193MagicMock(calls, and 6 of them build a module-levelrunner = CliRunner().
- Edges reached outside a seam.
- git runs through
subprocess.runrather than the process runner [code: github/metrics.py:147, :190, :204]. - Two modules build their own
httpx2.Client[code: github/client.py:140; github/ssh.py:150]. refactor(github): the github session owns transport, ledger, error classes and link pagination #983 moves both onto the session.test_github_client.pyanswers the first throughstub_web[code: tests/conftest.py:204], which swaps httpx2's classes. - PyGithub.
GitHubClientwraps PyGithub'sGithub()[code: github/client.py:39-46], which speaks HTTP throughrequests, andgithub/ssh.pyregisters SSH keys through it [code: github/ssh.py:39]. Neither a session fake on httpx2MockTransportnorstub_webreaches it, so the_FakeGithubtests patch it. refactor(github): the github session owns transport, ledger, error classes and link pagination #983 leaves PyGithub out; refactor(github): pull request, repository and ssh key calls move from pygithub onto the github session #891 moves these calls onto the session, after which refactor(github): the github session owns transport, ledger, error classes and link pagination #983's fake answers them. - Secrets are resolved by hand: the keyring through
get_keyring_secret[code: github/secrets.py:118] and Vault through aVaultSecretBroker()built inline [code: github/secrets.py:124], not through theSecretProviderseam [code: security/secrets.py:116]. Tests patch_resolve_secret_from_source4 times instead. - Waiting uses real time, so tests patch
time.sleeportime.timeat 18 sites:- the burst limit
limits(calls=60, period=60)is built at import [code: github/rate_limiter.py:64] and applied with@sleep_and_retry[code: github/rate_limiter.py:71]; fix(github): gh calls no longer stall silently for up to a minute behind a fixed 60-call window, and the unmaintainedratelimitpackage is removed #1118 removes theratelimitpackage and this limit; - the secondary-limit backoff draws its delay from tenacity's
wait_random_exponential[code: github/rate_limiter.py:699] and sleeps withtime.sleep[code: github/rate_limiter.py:1821]; - the quota pause sleeps with
time.sleep[code: github/rate_limiter.py:1004], and so does the PR monitor's poll [code: github/pr_monitor.py:863]; AsyncLimiter[code: github/rate_limiter.py:773] serves onlyrun_gh_async[code: github/rate_limiter.py:1976], which has no caller; refactor(github): the github session owns transport, ledger, error classes and link pagination #983 deletes both.
- the burst limit
- git runs through
- Files and names.
- Three files each mix several behaviours:
test_github_rate_limiter.py(1,642 lines, 73 tests),test_github_pr_monitor.py(1,238) andtest_github_projects.py(1,169). - Catch-alls:
test_github_rate_limiter.py:291,:527,:551,:614,test_github_projects.py:817andtest_github_issues.py:245. - 36 test names end in
_success,_failure,_basicor_command.
- Three files each mix several behaviours:
Acceptance criteria
-
No internal patches or private imports. The test files under
tests/github/, and the CLI tests this item adds undertests/commands/, have zero patch sites aimed at devops_cli internals and zero imports of private devops_cli names. If test(cli): ratchets hold internal patches, private imports and test accommodations in src at today's counts and name each site that would raise one #1309 has landed, its two ratchet ceilings drop by the counts these files carry when the item starts (343 and 92 at 5c45b1e). -
Edges only through seams:
- gh, scripted by argv with
shutil.whichincluded, through refactor(cli): one process runner owns execution, process groups and dry-run #775's process fake; - the session and its HTTP transport through refactor(github): the github session owns transport, ledger, error classes and link pagination #983's session fake. That fake also answers the calls PyGithub made, because refactor(github): pull request, repository and ssh key calls move from pygithub onto the github session #891 has moved them onto the session; this item confirms
rg -n "^\s*(from github( |\.)|import github$)" src/devops_cli/github tests/githubprints nothing; - secrets through refactor(security): one keyring seam owns the keyring and the Secret Service lock check, with a shared keyring fake and its contract suite #1318's
SecretProviderseam and keyring fake; - metrics through refactor(telemetry): OTLP export goes through one exporter seam, and tests read exported spans and metrics from a shared fake #1319's OTLP fake: the project-metric tests read the series that
emit_project_metrics_telemetryexports [code: github/metrics.py:529] from the fake, in place of patchinggithub.metrics.emit[code: tests/test_github_metrics.py:296]; - waiting through refactor(cli): tests control time: time-machine fakes wall-clock reads, and retry and rate-limit waits return at once and are recorded #1320, as below.
No test patches
run_gh,run_subprocess,_burst_protected_subprocess, aGitHubClientmethod,core.process._github_tokenorgithub.metrics.emit. - gh, scripted by argv with
-
test_github_client.pystops usingstub_web. Whichever of this item and test(ai): the remaining ai modules are tested through their public interfaces on edge fakes, and the legacy provider layer leaves src #1331 lands second deletesstub_web. -
github/metrics.pyruns git through the process runner, sorg -n "subprocess\.(run|Popen)" src/devops_cli/githubprints nothing. Its tests run real git in a temporary repository. -
Waiting through refactor(cli): tests control time: time-machine fakes wall-clock reads, and retry and rate-limit waits return at once and are recorded #1320. Of the rate limiter's waits, this item owns only the secondary-limit backoff. Its delay, drawn from tenacity's
wait_random_exponential[code: github/rate_limiter.py:699], is checked to lie between the floor and the cap, and its sleep [code: github/rate_limiter.py:1821] is a wait recorded by refactor(cli): tests control time: time-machine fakes wall-clock reads, and retry and rate-limit waits return at once and are recorded #1320's clock fixture. The rest relies on other items:- refactor(cli): tests control time: time-machine fakes wall-clock reads, and retry and rate-limit waits return at once and are recorded #1320 builds the burst limit when the limiter is constructed, unless fix(github): gh calls no longer stall silently for up to a minute behind a fixed 60-call window, and the unmaintained
ratelimitpackage is removed #1118 has already removedratelimit; - refactor(github): the github session owns transport, ledger, error classes and link pagination #983 deletes
run_gh_asyncand itsAsyncLimiter; - the quota pause and the PR monitor's poll are direct
time.sleepcalls, reached through refactor(cli): tests control time: time-machine fakes wall-clock reads, and retry and rate-limit waits return at once and are recorded #1320's stdlib fallback.
No quota, backoff or monitor test sleeps for real or patches
time,randomor tenacity. - refactor(cli): tests control time: time-machine fakes wall-clock reads, and retry and rate-limit waits return at once and are recorded #1320 builds the burst limit when the limiter is constructed, unless fix(github): gh calls no longer stall silently for up to a minute behind a fixed 60-call window, and the unmaintained
-
No interim markers. If test(cli): the hermetic floor fails a test that reaches an edge without a fake and resets all process-wide state after every test #1310 added its interim
unreachable(...)marker, none remains in this item's test files: each gives way to the fake of the edge it names, in the fake's refusing state where the test relies on the refusal. -
Behaviour files (Q10).
test_github_rate_limiter.py,test_github_pr_monitor.pyandtest_github_projects.pyare deleted. Their tests move to files named after behaviours ofgithub/, for exampletest_quota_ledger.py,test_secondary_rate_limit_backoff.py,test_copilot_review_state.pyandtest_project_sync.py.- Tests in these files that invoke
devops ghbecome CLI tests undertests/commands/(Q14).
-
The catch-alls listed above are split into behaviour tests, or deleted along with code that no public behaviour reaches (Q22).
-
Test names state behaviour in CONTEXT.md terms (Q8): none ends in
_success,_failure,_basicor_command, and none starts with a helper's name. -
Doubles and assertions.
- The four
_FakeGithubclasses,_RecordedGithuband the localCompletedProcessbuilders give way to the shared fakes. - The 6 module-level
runner = CliRunner()give way to test(cli): the hermetic floor fails a test that reaches an edge without a fake and resets all process-wide state after every test #1310'sclifixture (Q14). - Assertions compare whole values (Q7).
- The four
-
Every line of
github/that no public behaviour reaches is deleted (Q22). The 90% coverage gate passes. -
uv run devops cipasses.
Key questions
- Which files belong to this item? Decided 2026-10-07: under Q17, each file goes to the package that owns most of what it tests, and test(cli): every test file sits in the directory mirroring the package it tests or in tests/invariants/, and the root conftest holds only the hermetic floor #1313 places it in that package's mirror directory. This item owns exactly the files named above, plus the CLI tests it adds; a file in a shared directory such as
tests/commands/belongs to the one E item that names it.test_pr_cmd.pyreferencesgithub/slightly more, but what it tests isdevops pr, so test(cli): devops pr, gh and repos are thin adapters tested over edge fakes, and merge readiness is tested in its package #1324 names it. - Does
check_verdict'srunner=parameter stay? (proposed) No. refactor(github): the github session owns transport, ledger, error classes and link pagination #983 makes the session the injection point in place of theGhRunnerProtocol [code: roadmap/github_store.py:136], which it removes, and brings the check-run reads offetch_pr_check_verdictsonto the session. Therunnerparameters, typedAnytoday [code: github/check_verdict.py:395, :454], give way to the session, and tests pass refactor(github): the github session owns transport, ledger, error classes and link pagination #983's session fake. A read that stays on gh goes through the session's gh adapter, not arunnerargument. - Is this one pull request? Decided 2026-10-07: under Q33, it is filed now as one item, and refinement applies
needs-splitif it proves too big.
Strategic alignment
- Depends on: test(cli): every test file sits in the directory mirroring the package it tests or in tests/invariants/, and the root conftest holds only the hermetic floor #1313, refactor(cli): one process runner owns execution, process groups and dry-run #775, refactor(github): pull request, repository and ssh key calls move from pygithub onto the github session #891, refactor(github): the github session owns transport, ledger, error classes and link pagination #983, refactor(security): one keyring seam owns the keyring and the Secret Service lock check, with a shared keyring fake and its contract suite #1318, refactor(telemetry): OTLP export goes through one exporter seam, and tests read exported spans and metrics from a shared fake #1319, refactor(cli): tests control time: time-machine fakes wall-clock reads, and retry and rate-limit waits return at once and are recorded #1320. Blocks: test(cli): Convert ratchets to bans and merge invariant tests #1336. Related: test(cli): ratchets hold internal patches, private imports and test accommodations in src at today's counts and name each site that would raise one #1309 (the ratchets this item lowers), test(cli): devops pr, gh and repos are thin adapters tested over edge fakes, and merge readiness is tested in its package #1324 (the
devops pranddevops ghCLI tests), refactor(cli): Unify HTTP and DNS seams with shared fakes #1314 (the HTTP fake that replacesstub_web), test(ai): the remaining ai modules are tested through their public interfaces on edge fakes, and the legacy provider layer leaves src #1331 (the otherstub_webuser), fix(github): gh calls no longer stall silently for up to a minute behind a fixed 60-call window, and the unmaintainedratelimitpackage is removed #1118 (removesratelimitand the burst limit), feat(cli): structured fuzzing of parsers and schema boundaries #416 (parser fuzzing). - Parent: test(cli): tests double only process edges and mirror the source tree #1307 (phase E).
Proposed design
Problem statement
The 18 test files that test the github/ package use 343 patch sites aimed at devops_cli internals and 92 private imports. They also use hand-rolled doubles, patch time.sleep and time.time at 18 sites, and contain catch-all test names. The tests must go through public seams (process fake, session fake, SecretProvider, OTLP fake, clock fixture) with zero internal patches or private imports. Three large files must be deleted and replaced with behaviour-named files. Source code in github/metrics.py must call git through the process runner instead of subprocess.run.
Acceptance criteria
- Criterion 1: The test files under tests/github/ and the CLI tests this item adds have zero patch sites aimed at devops_cli internals and zero imports of private devops_cli names.
Verification: Run rg -n 'patch|patch.object|patch.dict|mocker.patch|monkeypatch.setattr|monkeypatch.setitem|monkeypatch.delattr' tests/github/ and confirm no result targets a devops_cli module. Run rg -n 'from devops_cli.*import _' tests/github/ and confirm no result. If test(cli): ratchets hold internal patches, private imports and test accommodations in src at today's counts and name each site that would raise one #1309 has landed, its two ratchet ceilings drop by 343 and 92. - Criterion 2: All edges are reached only through seams: gh through refactor(cli): one process runner owns execution, process groups and dry-run #775 process fake, session and HTTP through refactor(github): the github session owns transport, ledger, error classes and link pagination #983 session fake, secrets through refactor(security): one keyring seam owns the keyring and the Secret Service lock check, with a shared keyring fake and its contract suite #1318 SecretProvider, metrics through refactor(telemetry): OTLP export goes through one exporter seam, and tests read exported spans and metrics from a shared fake #1319 OTLP fake, waiting through refactor(cli): tests control time: time-machine fakes wall-clock reads, and retry and rate-limit waits return at once and are recorded #1320 clock fixture.
Verification: No test patches run_gh, run_subprocess, _burst_protected_subprocess, a GitHubClient method, core.process._github_token, or github.metrics.emit. Run rg -n '^\s*(from github( |.)|import github$)' src/devops_cli/github tests/github and confirm no output. - Criterion 3: test_github_client.py stops using stub_web.
Verification: Run rg -n 'stub_web' tests/test_github_client.py and confirm no output. Whichever of this item and test(ai): the remaining ai modules are tested through their public interfaces on edge fakes, and the legacy provider layer leaves src #1331 lands second deletes stub_web from tests/conftest.py. - Criterion 4: github/metrics.py runs git through the process runner instead of subprocess.run or subprocess.Popen.
Verification: Run rg -n 'subprocess.(run|Popen)' src/devops_cli/github and confirm no output. The metrics tests run real git in a temporary repository. - Criterion 5: Waiting uses refactor(cli): tests control time: time-machine fakes wall-clock reads, and retry and rate-limit waits return at once and are recorded #1320 clock fixture. The secondary-limit backoff delay is checked to lie between floor and cap, and its sleep is a wait recorded by the clock fixture.
Verification: No quota, backoff, or monitor test sleeps for real or patches time, random, or tenacity. Run rg -n 'time.sleep|time.time|random.|tenacity' tests/github/ and confirm no output. - Criterion 6: No interim unreachable(...) markers remain in this item's test files.
Verification: Run rg -n 'unreachable' tests/github/ and confirm no output. Each former marker gives way to the fake of the edge it names. - Criterion 7: test_github_rate_limiter.py, test_github_pr_monitor.py, and test_github_projects.py are deleted. Their tests move to files named after behaviours of github/.
Verification: The three files no longer exist. New files such as test_quota_ledger.py, test_secondary_rate_limit_backoff.py, test_copilot_review_state.py, and test_project_sync.py exist under tests/github/. - Criterion 8: The six catch-all tests are split into behaviour tests or deleted along with unreachable code.
Verification: The named test functions at test_github_rate_limiter.py:291, :527, :551, :614, test_github_projects.py:817, and test_github_issues.py:245 no longer exist as catch-alls. Their assertions are split into behaviour-named tests or removed. - Criterion 9: Test names state behaviour in CONTEXT.md terms. None ends in _success, _failure, _basic, or command, and none starts with a helper's name.
Verification: Run rg -n 'def test.*(_success|_failure|_basic|command)$' tests/github/ and confirm no output. Run rg -n 'def test(fake|mock|stub|helper)' tests/github/ and confirm no output. - Criterion 10: The four _FakeGithub classes, _RecordedGithub, and local CompletedProcess builders give way to shared fakes. The six module-level runner = CliRunner() instances give way to test(cli): the hermetic floor fails a test that reaches an edge without a fake and resets all process-wide state after every test #1310's cli fixture.
Verification: Run rg -n '_FakeGithub|_RecordedGithub|_mock_proc|CompletedProcess(|runner\s*=\s*CliRunner' tests/github/ and confirm no output. Assertions compare whole values. - Criterion 11: Every line of github/ that no public behaviour reaches is deleted. The 90% coverage gate passes.
Verification: Run uv run devops ci and confirm it passes. The coverage report shows 90% or above for src/devops_cli/github/. - Criterion 12: uv run devops ci passes.
Verification: Run uv run devops ci and confirm exit code 0.
Key questions
- Which files belong to this item?: Under Q17, each file goes to the package that owns most of what it tests. This item owns the 18 files listed in the body (the original 20 minus test_gh_issue_closure and test_release_notes_sync, both deleted by feat(release): release-please makes every release from main #1952), plus the CLI tests it adds under tests/commands/. test_pr_cmd.py belongs to test(cli): devops pr, gh and repos are thin adapters tested over edge fakes, and merge readiness is tested in its package #1324 because its subject is devops pr. (proposed)
- Does check_verdict's runner= parameter stay?: No. refactor(github): the github session owns transport, ledger, error classes and link pagination #983 makes the session the injection point in place of the GhRunner Protocol, which it removes. The runner parameters typed Any at github/check_verdict.py:395 and :454 give way to the session. Tests pass refactor(github): the github session owns transport, ledger, error classes and link pagination #983's session fake. A read that stays on gh goes through the session's gh adapter, not a runner argument. (proposed) [sources: src/devops_cli/github/check_verdict.py:395, src/devops_cli/github/check_verdict.py:454]
- Is this one pull request?: Under Q33, it is filed now as one item, and refinement applies needs-split if it proves too big. Given 18 test files, 9368 lines, 413 tests, 343 patch sites to remove, 92 private imports to remove, source changes to metrics.py, deletion of 3 files, creation of new behaviour-named files, CLI tests, and unreachable-code deletion, this does not fit one pull request. (proposed)
Fit
Needs splitting into 4 items:
- Source: github/metrics.py runs git through the process runner instead of subprocess.run or subprocess.Popen
- Tests: remove all 343 internal patch sites and 92 private imports from the 18 github test files, route every edge through the shared fakes from refactor(cli): one process runner owns execution, process groups and dry-run #775, refactor(github): the github session owns transport, ledger, error classes and link pagination #983, refactor(security): one keyring seam owns the keyring and the Secret Service lock check, with a shared keyring fake and its contract suite #1318, refactor(telemetry): OTLP export goes through one exporter seam, and tests read exported spans and metrics from a shared fake #1319, and refactor(cli): tests control time: time-machine fakes wall-clock reads, and retry and rate-limit waits return at once and are recorded #1320
- Tests: replace hand-rolled doubles with shared fakes, rename 36 test names to behaviour terms, split 6 catch-all tests, delete 3 large files and create behaviour-named files, add CLI tests under tests/commands/
- Tests: remove stub_web usage from test_github_client.py, delete unreachable code in github/, pass the 90% coverage gate and uv run devops ci
Suspected block
None.
Dependencies
Alternatives check of 2026-10-29: not-applicable.
Tool: none found.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNew
- StatusShow more project fieldsNew
Activity
dan-petty-bot commentedon Oct 8, 2026
Intake placed this item to the backlog: at intake only a critical fix goes into a release; a release start pulls Ready items in, P0 features first.
A large structural test improvement that reduces coupling but does not fix a user-facing defect or block a release.Eliminating 343 internal patch sites and 92 private imports across 20 files makes the github/ suite far more maintainable and resilient to internal refactors.Twenty test files totalling 9,368 lines and 413 tests must be rewritten to use gh-process and session fakes, replacing hundreds of patch sites and hand-rolled doubles.dan-petty commentedon Oct 26, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones on the board.
This item improves test quality and maintainability without blocking other work.Improving test isolation helps prevent fragile tests and makes the codebase easier to maintain.It requires refactoring existing tests but does not introduce new features or major changes.Both items test CLI commands, but the candidate focuses on github/ tests while #1324 covers devops pr, gh and repos tests.dan-petty commentedon Oct 28, 2026
The proposal at 69636b6 needs splitting into 4 items. A person splits the item into the items below, or replies in a comment or edits the body to keep one item, and the next refine round looks at the item again.
refactor(security): one keyring seam owns the keyring and the Secret …
devops-cli-service commentedon Oct 30, 2026
Alternatives check: not-applicable
Tool: none found
Checked on 2026-10-29. A person decides what this means for the item. The check changes no label and closes no issue.
test(github): test github/ over edge fakes (#1321)
test(github): test github/ over edge fakes (#1321)