Skip to content

refactor(roadmap): the in-memory store leaves src #3744

Closed

Description

@dan-petty

Problem or Motivation

Part 1 of 6 of #1335. InMemoryRoadmapStore is the fake of the roadmap store. It sits in src/devops_cli/roadmap/memory_store.py (779 lines) and ships in the wheel. TESTING.md says that fakes, and in-memory implementations that production does not use, live in tests/support/ and never ship in the wheel.

Production uses the class in one place. roadmap/duplicate_eval.py:32 imports it, and judge_case (duplicate_eval.py:154) builds one store per case. The command devops roadmap eval intake runs this code. The old body of #1335 did not see this use. All facts below are measured at origin/main 29309f0.

The evaluation needs little from the store. judge_case seeds one issue and the text of .github/labels.yml, then calls intake_candidate. That function calls plan_intake, and confirm is false, so nothing is written. plan_intake reads through five store methods: issues (intake.py:1202), repository_file (:510), closures (:772), evidence_holds (:924, through _p0_refusal) and comments_on (:1020, through _has_comment). Only apply_intake writes.

Other facts:

  • 96 test-side files import the class: 90 test modules, 5 modules of tests/support/ and tests/roadmap_faults.py. The class name appears 1,684 times in them.
  • tests/roadmap_faults.py holds two wrappers of the store, and neither has a contract suite. StoppingStore fails one write. test_roadmap_run.py:1608 and test_roadmap_stage_apply.py:163 use it. ListingStore counts the directory listings and can fail one. test_roadmap_alternatives.py:893, 908 uses it. The file also holds WRITES, the set of store writes that can fail.
  • tests/roadmap/test_roadmap_store_contract.py (1,252 lines) already runs the label and job-record cases on both adapters: the in-memory one and GitHubRoadmapStore over GitHubFake.
  • GitHubFake (tests/roadmap_github_fake.py) has no write fault. It fails only a file answer and the traffic paths.
  • Three constants DEFAULT_ROADMAP_MEMORY_* in config/defaults.py:727-730 exist for this class. One test imports one of them.
  • Two open change folders name files that this item moves or deletes. openspec/changes/3187-group-the-job-modules-in-subpackages/ plans to move memory_store.py into roadmap/stores/. openspec/changes/3254-list-the-registry-and-ratchet-entries/ plans a REGISTRY_COUNTS declaration and a stage check for the WRITES set in tests/roadmap_faults.py. Both plans are wrong after this item.

Proposed Solution & Architectural Design

Decision for duplicate_eval

Give the evaluation its own read-only roadmap. Do not keep the test fake in src.

  1. Add a Protocol IntakeReads in roadmap/store.py with the five read methods above. RoadmapStore already satisfies it, so no caller changes.
  2. Retype what the planning path passes around: plan_intake, the field _Run.store, _p0_refusal (intake.py:917), _priority (:929) and _has_comment (:1017). apply_intake and intake_candidate keep RoadmapStore. mypy then proves that the planning path writes nothing and reads nothing else.
  3. Add SeededRoadmap in roadmap/duplicate_eval.py. It is a small frozen class that holds one IssueRecord and the text of .github/labels.yml. It has no write method.
    • issues() returns the record. repository_file() returns the labels text.
    • closures and comments_on return []. evidence_holds returns False.
  4. judge_case builds a SeededRoadmap and calls plan_intake(..., new=candidate). It reads the one decision of the plan. It no longer calls intake_candidate. The verdicts must not change.
  5. duplicate_eval.py gets its own repo constant for the repo argument. It no longer imports DEFAULT_ROADMAP_MEMORY_REPO.

Why this and not another design:

  • Keep InMemoryRoadmapStore in src as a production type. TESTING.md allows an in-memory implementation in src only if production uses it. Production uses two reads of it. The class would ship 779 lines of seed_*, as_actor and job_writes helpers for them. Rejected.
  • Move the evaluation under tests/ or scripts/. devops roadmap eval intake is a shipped command, as stage eval and implement eval are. Its case file roadmap/intake_duplicate_cases.json ships in the package. Rejected.
  • Build the evaluation store from GitHubRoadmapStore over a recorded session. It needs a recorded REST page set for 16 cases, to read one issue and one file. It would test the GitHub store, not intake. Rejected.

The move

  1. git mv src/devops_cli/roadmap/memory_store.py tests/support/fakes/roadmap_store.py. Move the three DEFAULT_ROADMAP_MEMORY_* constants into that module and delete them from config/defaults.py. Rewrite its docstring. It is a fake, and the contract suite keeps it equal to GitHubRoadmapStore.
  2. Change the import in the 96 test-side files. The edit is the import line only. The check is in the criteria.
  3. Update the two open change folders in the same pull request (rule 8).

The fault mode

Add fail_write(*, at, applied=False, write=None, item=None) to the fake. It makes the at-th matching write raise GitHubOperationError("HTTP 502") once. With applied=True, the write applies first and then raises. The fake records every attempted write in writes. This keeps the semantics of Fault in tests/roadmap_faults.py. WRITES moves into the fake.

  • ListingStore becomes a record and a fault of the fake. The fake keeps listed (each directory a job listed, in order). fail_listing(error) makes the next listing raise error.
  • Replace the 3 users of the two wrappers. Delete tests/roadmap_faults.py.
  • Add the fault cases to test_roadmap_store_contract.py for both adapters. GitHubFake has no write fault today. Add fail_write to it as well (about 30 lines). Both adapters must raise the same error type, and the first step of the work is a test that shows it.

Order

Land this first. It changes the import line of 96 files, so every other roadmap test change conflicts with it. Children 2 and 3 of #1335 wait for it.

Acceptance criteria

  • A test first: SeededRoadmap has no write method. judge_case gives the same verdict and reason for each of the 16 cases of intake_duplicate_cases.json. tests/roadmap/test_roadmap_duplicate_eval.py passes with no change to its assertions.
  • test ! -e src/devops_cli/roadmap/memory_store.py is true. git grep -n -E "InMemoryRoadmapStore|memory_store|DEFAULT_ROADMAP_MEMORY" -- src prints nothing.
  • plan_intake and the three helpers take IntakeReads. uv run mypy passes.
  • The fake is at tests/support/fakes/roadmap_store.py. The diff of the other test-side files holds import lines only. The path filter of the command excludes the fake, the deleted faults file and the 3 fault-mode users. Then this command prints nothing: git diff -U0 origin/main -- tests ':!tests/roadmap_faults.py' ':!tests/support/fakes/roadmap_store.py' ':!tests/roadmap/test_roadmap_run.py' ':!tests/roadmap/test_roadmap_stage_apply.py' ':!tests/roadmap/test_roadmap_alternatives.py' | grep -E '^[+-]' | grep -v -E '^(\+\+\+|---)' | grep -v -E '^[+-]\s*(from|import)\s|^[+-]\s+[A-Za-z_]+,$|^[+-]\s*[()]\s*$'. The pull request comment gives the exact command and its output.
  • tests/roadmap_faults.py is deleted. The write-fault cases run in the contract suite on both adapters. The listing fault is tested on the fake only, because it is a fake feature. A write that fails before it applies leaves the state unchanged. A write that fails after it applies leaves the change in place.
  • git grep -n -E "memory_store|roadmap_faults" -- openspec/changes ':!openspec/changes/archive' prints nothing. The folders of refactor(roadmap): group the job modules in subpackages #3187 and feat(roadmap): list registry and ratchet entries a plan needs #3254 are consistent with the new paths.
  • uv run devops ci passes.

Target Subsystem

SDLC, Git & PR Governance

Existing Tool Considered

No open library gives a fake of this repository's roadmap store, so the fake stays hand-written. Its contract suite keeps it equal to GitHubRoadmapStore on recorded and scripted gh answers. This is the pattern of ADR 0007.

For the evaluation store, a narrow Protocol and a read-only class of about 40 lines replace a class of 779 lines in src. The cost to build is about 150,000 tokens, most of it for the import edits in 96 files. It costs about 20,000 tokens a year to keep. The work takes about one day.

Strategic alignment: child of #1335. Parent #1307. Blocks the children 2 and 3 of #1335. Related: #3187, #3254.

Activity

  1. added
    source/agent
    type/refactor
    scope/roadmap
    status/new
    value/medium
    effort/high
    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/refactor. The refactor prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. It removes a test fake from the production wheel but does not fix a user-facing defect or add a feature.
    • Value: Medium. It stops shipping a 779-line test fake in the wheel and clarifies the read-only contract, but users see no new behaviour.
    • Effort: High. It touches 96 test files, 1684 name references, two open change folders, and requires a new Protocol, a new class, and retyping of five functions.
    • Related: test(infra): infrastructure tests run on edge fakes #1335, which asks for a different change. Both move the in-memory roadmap store out of src, but #1335 is the umbrella tracker for six children and this item is only child 1.
  3. added
    priority/p2-medium
    on Nov 6, 2026
  4. added
    status/in-progress
    status/in-review
    and removed
    status/new
    status/in-progress
    on Nov 6, 2026
  5. removed
    status/in-review
    on Nov 6, 2026
  6. devops-cli-service commented on Nov 6, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-06 22:09 UTC

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/highpriority/p2-mediumscope/roadmapsource/agenttype/refactorvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions