Repository navigation
Description
Problem or Motivation
Part 2 of 6 of #1335. It starts after part 1, which moves the roadmap store fake to tests/support/fakes/roadmap_store.py.
Roadmap tests replace get_roadmap_store by patching a module attribute. roadmap/__init__.py:4-5 and the docstring of get_roadmap_store (roadmap/store.py:932-936) say that every caller looks the function up through its module "so that a test can patch it". TESTING.md says that no module is shaped so that a test can patch it, and that a fake is installed through a seam.
Measured at origin/main 29309f0, with the counting rules of #1335:
- 8 patch sites replace
get_roadmap_store. 3 are intests/support/roadmap.py: the session-wide refusal (line 35), theroadmap_storefixture (line 63) andunreadable_github_roadmap. 5 are intest_roadmap_dry_runs.py:61,test_roadmap_run.py:1990,test_roadmap_intake.py:1422,test_roadmap_refine.py:1132andtests/commands/test_github_milestones.py:186. - The session-wide refusal (
github_roadmap_factory,tests/support/roadmap.py:17) keeps tests off the real GitHub store, because that store runsgh. The floor already refusesgh(tests/support/refused_programs.py, fixturerefuse_real_programs). So the refusal repeats a rule that the floor holds. Three tests usegithub_roadmap_factory: two intest_roadmap_github_store.pyand one intest_github_milestones.py. - Nine files hold the other sites of this part. They are
tests/ci/test_ci_cache.py,test_ci_cache_fingerprint.py,test_ci_diagnostics.pyandtests/roadmap/test_roadmap_github_store.py,test_roadmap_store_contract.py,test_roadmap_intake.py,test_roadmap_run.py,test_roadmap_dry_runs.py,test_roadmap_refine.py. - Together they hold 14,229 lines and 523 tests. They hold 73 patch sites, of which 5 are seam sites (in
test_roadmap_dry_runs.py), and 7 private imports. tests/roadmap_github_fake.py(GitHubFake, theghprocess edge for one repository) is outsidetests/support/fakes/. Nine test files import it.CliRunner()is built 8 times in the nine files. Three are module-level:test_roadmap_dry_runs.py:39,test_roadmap_intake.py:108andtest_roadmap_run.py:141. Five are inside tests:test_roadmap_refine.py:1028, 1336, 1758andtest_ci_cache.py:367, 435.
The patch targets, by file:
run:_get_session_login,DEFAULT_DUE_TABLE,run_due_jobs,acts_as_github_app,subprocess.run(6),uvicorn.run(2) and_run_mcp_cmd.intake:label_issueandset_fieldof the store,rate_limiter.run_subprocess,build_intake_model,get_llm_client,subprocess.Popen,time.sleepand_run_mcp_cmd.dry_runs:rate_limiter.run_gh,GitHubRoadmapStore._run,get_llm_clientandget_task_modelin three modules,firecrawl_search,is_dry_run,subprocess.Popenand the 5 seam sites.refine:commands.roadmap._open_store,repository_is_private,path_changed_at,time.sleepand a constant.github_store:DEFAULT_GH_MAX_PAGINATED_PAGES.ci_cache:compute_workspace_fingerprint,save_ci_cache,print_warningand_run_all_checks_async. The private imports include_worktree_divergent_pathsintest_ci_cache_fingerprint.py.
Proposed Solution & Architectural Design
The install hook
Follow the precedent of install_exporter and reset_tracer in telemetry/tracer.py.
- Add
install_roadmap_store(factory)andreset_roadmap_store()toroadmap/store.py.get_roadmap_store(repo, ...)returnsfactory(repo, ...)when one is installed. Otherwise it returns the GitHub store. - Register
reset_roadmap_storewith the floor. The floor resets every process-wide singleton after each test, from the table intests/conftest.py(near line 134). The invariant that checks module-level state insrcthen passes. This edit of aconftest.pymakes the narrowed test run cover the whole suite once (TESTING.md). - The
roadmap_storefixture installs the fake through the hook. It keepsroadmap_store_repos, which 17 files use. - Delete the session-wide refusal and
github_roadmap_factory. A test that wants the real store callsget_roadmap_store(repo). The floor fails a test that startsgh. The 3 users ofgithub_roadmap_factorycall the real function, or buildGitHubRoadmapStore(repo, session=...)over the session fake. unreadable_github_roadmapinstalls aGitHubRoadmapStorethrough the hook.- Fix the docstrings in
roadmap/__init__.pyandroadmap/store.py. Fixdocs/TESTING.mdline 195 in the same pull request (rule 8). Today it says theroadmap_storefixture is used "since the roadmap store factory is refused". After this part it names the install hook and the fake attests/support/fakes/roadmap_store.py.
The floor must still fail a test that opens the real store and runs gh. The docs and refused_programs.py say so. The first test of this part proves it, and the error must name gh.
The other sites
- Model calls (
get_llm_client,get_task_model,build_intake_model) go toModelFake(refactor(ai): one model seam: llmclient over three wire adapters behind one factory, no second provider stack #1001, closed). - A write that fails goes to the fault mode of part 1 (
fail_write), not topatch.object(store, "label_issue"). - GitHub traffic goes to
GitHubFakeandGitHubApiFake(the session fake). No test patchesrate_limiter.run_gh,run_subprocessorGitHubRoadmapStore._run. - Programs (
subprocess.run,subprocess.Popen) go toProcessFake. time.sleepand clocks go to the clock fake (refactor(cli): tests control time: time-machine fakes wall-clock reads, and retry and rate-limit waits return at once and are recorded #1320, closed).- A private name that holds a domain rule becomes a public function of its package. That includes
_worktree_divergent_paths: if it is CI logic, make it public inci/. Do not import a private name from a test. - Constants such as
DEFAULT_DUE_TABLEare set through theconfigfixture or a public parameter. If no public parameter exists, test through the behaviour and do not patch the constant. - If a site has no fake today, add the fake with its contract test. If that is not possible, stop and return the part to New with the evidence (rule 2). Do not keep the patch.
- Move
tests/roadmap_github_fake.pytotests/support/fakes/github_repository.py. Update the 9 importers. - Replace the 8
CliRunner()builds with theclifixture. Build items and candidates withmake_itemandmake_candidatefromtests/support/builders.py. 10 files intests/roadmap/callItem(orCandidate(directly. - Test the CLI of
commands/roadmap.pyfor parsing, wiring, output and exit codes only. If a test finds a domain rule in one of its helpers, move the rule intoroadmap/behind a public function.
What stays out
- Splitting the large files is part 3. Do not split here, so the diff stays reviewable.
tests/project_board_fake.pytestsgithub/projects.py. No roadmap code reaches it (ADR 0016). It stays.- The 5 seam sites in
test_roadmap_dry_runs.pystay. The DNS and HTTP seams of refactor(cli): Unify HTTP and DNS seams with shared fakes #1314 replace them. - The other 6 patch sites of
tests/commands/test_github_milestones.pystay. Only itsget_roadmap_storesite is in this part.
Acceptance criteria
- A test first: after
install_roadmap_store(factory),get_roadmap_store(repo)returns whatfactoryreturns. After the floor resets, it returns the GitHub store again. - A test shows that the floor fails a test that opens the real store and runs a
ghcommand. The error namesgh. -
git grep -n "get_roadmap_store" -- testsshows nosetattr,patchorpatch.object.github_roadmap_factoryis gone. - The nine files hold no private import. They hold no patch site except the 5 seam sites. The pull request comment states the AST scan and its counts before and after. The counts before are 73 patch sites and 7 private imports.
-
docs/TESTING.mdno longer says that the roadmap store factory is refused. It names the install hook and the fake path. -
tests/roadmap_github_fake.pyis deleted, andtests/support/fakes/github_repository.pyexists. - The nine files hold no module-level
CliRunner(). They hold no directItem(orCandidate(. -
uv run pytest tests/roadmap tests/ci tests/commands/test_github_milestones.pypasses. The test count is the same as before, plus the new tests. -
uv run devops cipasses. Coverage stays at or above the floor.
Target Subsystem
SDLC, Git & PR Governance
Existing Tool Considered
pytest fixtures and monkeypatch are the usual tools, and ADR 0007 forbids monkeypatch on a devops_cli name. No open library gives an install hook for one function of this repository. The hook is about 15 lines and follows the install_exporter pattern. The cost to build is about 250,000 tokens, because 9 files change. It costs about 30,000 tokens a year to keep. The work takes about 2 days.
Strategic alignment: child of #1335. Parent #1307. Starts after part 1 of #1335. Part 3 of #1335 starts after this part. Related: #1336 (turns the counts into bans).
Activity
dan-petty commentedon Nov 6, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
testprefix of the title gives the type.(roadmap)scope of the title gives the scope.Part 2 of a 6-part test-infrastructure plan; important for maintainability but not blocking.Replaces 8 patch sites with one seam hook, reducing test fragility for roadmap tests.Requires adding two functions, registering a reset, updating a fixture, and editing five or more test files.Both are parts of #1335 and work on roadmap test infrastructure, but #3744 moves the in-memory store file while this candidate adds an install/reset hook.test(roadmap): install the roadmap store through one hook (#3889)
test(infra): infrastructure tests run on edge fakes (#4283)