Skip to content

test(roadmap): roadmap tests take their store from one hook #3746

Closed
1 of 1 issue completed
Closed

Description

@dan-petty

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 in tests/support/roadmap.py: the session-wide refusal (line 35), the roadmap_store fixture (line 63) and unreadable_github_roadmap. 5 are in test_roadmap_dry_runs.py:61, test_roadmap_run.py:1990, test_roadmap_intake.py:1422, test_roadmap_refine.py:1132 and tests/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 runs gh. The floor already refuses gh (tests/support/refused_programs.py, fixture refuse_real_programs). So the refusal repeats a rule that the floor holds. Three tests use github_roadmap_factory: two in test_roadmap_github_store.py and one in test_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.py and tests/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, the gh process edge for one repository) is outside tests/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:108 and test_roadmap_run.py:141. Five are inside tests: test_roadmap_refine.py:1028, 1336, 1758 and test_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_issue and set_field of the store, rate_limiter.run_subprocess, build_intake_model, get_llm_client, subprocess.Popen, time.sleep and _run_mcp_cmd.
  • dry_runs: rate_limiter.run_gh, GitHubRoadmapStore._run, get_llm_client and get_task_model in three modules, firecrawl_search, is_dry_run, subprocess.Popen and the 5 seam sites.
  • refine: commands.roadmap._open_store, repository_is_private, path_changed_at, time.sleep and a constant.
  • github_store: DEFAULT_GH_MAX_PAGINATED_PAGES.
  • ci_cache: compute_workspace_fingerprint, save_ci_cache, print_warning and _run_all_checks_async. The private imports include _worktree_divergent_paths in test_ci_cache_fingerprint.py.

Proposed Solution & Architectural Design

The install hook

Follow the precedent of install_exporter and reset_tracer in telemetry/tracer.py.

  1. Add install_roadmap_store(factory) and reset_roadmap_store() to roadmap/store.py. get_roadmap_store(repo, ...) returns factory(repo, ...) when one is installed. Otherwise it returns the GitHub store.
  2. Register reset_roadmap_store with the floor. The floor resets every process-wide singleton after each test, from the table in tests/conftest.py (near line 134). The invariant that checks module-level state in src then passes. This edit of a conftest.py makes the narrowed test run cover the whole suite once (TESTING.md).
  3. The roadmap_store fixture installs the fake through the hook. It keeps roadmap_store_repos, which 17 files use.
  4. Delete the session-wide refusal and github_roadmap_factory. A test that wants the real store calls get_roadmap_store(repo). The floor fails a test that starts gh. The 3 users of github_roadmap_factory call the real function, or build GitHubRoadmapStore(repo, session=...) over the session fake.
  5. unreadable_github_roadmap installs a GitHubRoadmapStore through the hook.
  6. Fix the docstrings in roadmap/__init__.py and roadmap/store.py. Fix docs/TESTING.md line 195 in the same pull request (rule 8). Today it says the roadmap_store fixture is used "since the roadmap store factory is refused". After this part it names the install hook and the fake at tests/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 to ModelFake (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 to patch.object(store, "label_issue").
  • GitHub traffic goes to GitHubFake and GitHubApiFake (the session fake). No test patches rate_limiter.run_gh, run_subprocess or GitHubRoadmapStore._run.
  • Programs (subprocess.run, subprocess.Popen) go to ProcessFake.
  • time.sleep and 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 in ci/. Do not import a private name from a test.
  • Constants such as DEFAULT_DUE_TABLE are set through the config fixture 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.py to tests/support/fakes/github_repository.py. Update the 9 importers.
  • Replace the 8 CliRunner() builds with the cli fixture. Build items and candidates with make_item and make_candidate from tests/support/builders.py. 10 files in tests/roadmap/ call Item( or Candidate( directly.
  • Test the CLI of commands/roadmap.py for parsing, wiring, output and exit codes only. If a test finds a domain rule in one of its helpers, move the rule into roadmap/ 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.py tests github/projects.py. No roadmap code reaches it (ADR 0016). It stays.
  • The 5 seam sites in test_roadmap_dry_runs.py stay. 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.py stay. Only its get_roadmap_store site is in this part.

Acceptance criteria

  • A test first: after install_roadmap_store(factory), get_roadmap_store(repo) returns what factory returns. 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 gh command. The error names gh.
  • git grep -n "get_roadmap_store" -- tests shows no setattr, patch or patch.object. github_roadmap_factory is 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.md no longer says that the roadmap store factory is refused. It names the install hook and the fake path.
  • tests/roadmap_github_fake.py is deleted, and tests/support/fakes/github_repository.py exists.
  • The nine files hold no module-level CliRunner(). They hold no direct Item( or Candidate(.
  • uv run pytest tests/roadmap tests/ci tests/commands/test_github_milestones.py passes. The test count is the same as before, plus the new tests.
  • uv run devops ci passes. 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).

Sub-issues

Sub-issues

1 of 1 Issues completed
Loading 1 sub-issues

Activity

  1. added
    source/agent
    type/test
    scope/roadmap
    status/new
    value/medium
    effort/medium
    on Nov 6, 2026
  2. dan-petty commented on Nov 6, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/test. The test prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. Part 2 of a 6-part test-infrastructure plan; important for maintainability but not blocking.
    • Value: Medium. Replaces 8 patch sites with one seam hook, reducing test fragility for roadmap tests.
    • Effort: Medium. Requires adding two functions, registering a reset, updating a fixture, and editing five or more test files.
    • Related: refactor(roadmap): the in-memory store leaves src #3744, which asks for a different change. 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.
  3. added
    priority/p2-medium
    on Nov 6, 2026
  4. added
    status/in-progress
    and removed
    status/new
    on Nov 7, 2026
  5. added a commit that references this issue on Nov 7, 2026
    bdee642
  6. removed
    status/in-progress
    on Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/roadmapsource/agenttype/testvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions