Skip to content

perf(roadmap): the implement plan gate reads the default tree and base specs once per run #3430

Closed

Description

@dan-petty

Problem or Motivation

The implement plan gate of #3393 reads the change folder at a revision for each item that the run judges. _Judge.judge runs for every named item, so a run with many items lists the default tree and reads the base specs once for each item. The default branch does not change during a run, and the base specs are the same for each item, so those reads repeat work.

Proposed Solution & Architectural Design

  1. Read the file list and the base specs of origin/<default> once in plan_implement, and pass them to _Judge.
  2. Keep the read of a Staged branch per item, because each item has its own branch.
  3. Add a test in tests/roadmap/test_roadmap_implement_job.py that a run over two items lists the default tree once.

Target Subsystem

src/devops_cli/roadmap/implement.py, tests/roadmap/test_roadmap_implement_job.py.

Existing Tool Considered

The revision readers files_at, file_texts_at and base_specs_at of plan_read.py already exist after #3393. The change reuses them and adds a cache for the default branch. Cost: about 2,000 tokens to build and test, about 500 tokens to keep and fix, and about 1 hour of elapsed time. The change deletes no code.

Source: #3403

Proposed design

Problem statement

The implement plan gate of #3393 reads the change folder of an item at a revision. The gate reads the default tree and the base specs for each item that a run judges. The default branch and the base specs do not change during a run, so these reads repeat work. The change reads them one time for a run and passes them to the judge of every item.

Acceptance criteria

Requirement: Default tree read once per run

plan_implement SHALL list the files of origin/ once for a run and give that list to the judge of every item.

Scenario: A run over two Planned items

  • WHEN A run judges two Planned items in one call to plan_implement.
  • THEN The run lists the files of origin/ one time.

Requirement: Base specs read once per run

plan_implement SHALL read the base specs of origin/ once for a run and give them to the judge of every item.

Scenario: Two items need the base specs

  • WHEN A run judges two items whose plans the gate checks against the base specs.
  • THEN The run reads the base spec files of origin/ one time.

Requirement: Staged branch read for each item

The judge SHALL list the files of the branch of each Staged item that it judges.

Scenario: Two Staged items on two branches

  • WHEN A run judges two Staged items whose branches differ.
  • THEN The run lists the files of each of the two branches.

Requirement: Same selection as a read for each item

The plan MUST return the same targets and the same left-out reasons as a plan that reads the default tree for each item.

Scenario: The reads of one run give the same result

  • WHEN A run judges a set of items with the default reads taken one time.
  • THEN Each item gets the target or the left-out reason that a read for each item gives.

Existing Tool Considered

No alternatives check has run. No open, maintained tool or library covers this need. The change adds a cache over the repository's own readers, files_at, file_texts_at and base_specs_at of src/devops_cli/roadmap/plan_read.py. Written cost: about 2,000 tokens to build and test, about 500 tokens to keep and fix, and about 1 hour of elapsed time. The change deletes no code.

Key questions

  • Where does the run keep the default tree and the base specs, so that each item reads them one time?: plan_implement reads them one time and passes them to _Judge when it builds the judge. It already passes remote_heads and planned this way. (best practice) [sources: src/devops_cli/roadmap/implement.py]
    • Chosen: Read one time in plan_implement and pass to _Judge. The function already takes the remote heads and the planned changes as optional arguments and reads them one time when the caller gives none. The default tree and the base specs follow the same path.
    • Rejected: A cache inside plan_read.py, keyed by the revision. A cache in the reader outlives one run and hides the read from the caller. A test can then not count the reads of a run.
    • Rejected: functools.lru_cache on the readers. The cache would hold the clone and every revision that a run reads, and it would live after the run. A pass-through argument keeps one run and one set of reads.
  • Which reads stay a read for each item?: The files of a Staged branch stay a read for each item, because each Staged item has its own branch. The reads of origin/ are the only ones that the run takes one time. (best practice) [sources: src/devops_cli/roadmap/implement.py]
    • Chosen: Keep the branch read for each Staged item. The route of a Staged item is its own branch, and two items never share it. A cache saves no read for these items.
    • Rejected: Cache every revision that the run reads. Each Staged branch is read one time in a run, so the cache saves no read. It adds a key and a lifetime for no gain.
  • How does the test show that a run over two items lists the default tree one time?: The test runs two items in one call and counts the git calls that the run makes at the process edge. It asserts one call that lists origin/. (best practice) [sources: tests/roadmap/test_roadmap_implement_job.py]
    • Chosen: Count the git calls of the run at the process edge. The job test already counts the calls of job_world.programs to check a push and a documentation run. The count reads the real path of the reader.
    • Rejected: Count with a spy on files_at. The spy replaces the reader under test, so the test no longer shows that the real reader runs one time.
    • Rejected: A unit test of plan_implement alone. The body names the job test file, and a job test runs the same plan path that the Service runs.
  • Does the plan gate of fix(roadmap): the implement job refuses a plan that fails the plan check #3393 exist on the default branch?: No. _Judge.judge in src/devops_cli/roadmap/implement.py reads no change folder, and fix(roadmap): the implement job refuses a plan that fails the plan check #3393 is still a change folder under openspec/changes/. [sources: src/devops_cli/roadmap/implement.py, openspec/changes/3393-the-implement-job-refuses-a-plan/tasks.md]
  • Which readers does the gate use for a revision?: The gate uses files_at, file_texts_at and base_specs_at of src/devops_cli/roadmap/plan_read.py. The change of fix(roadmap): the implement job refuses a plan that fails the plan check #3393 adds these public readers. [sources: openspec/changes/3393-the-implement-job-refuses-a-plan/tasks.md, openspec/changes/3393-the-implement-job-refuses-a-plan/design.md]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#3393

Activity

  1. added
    source/agent
    type/infra
    scope/roadmap
    status/new
    value/medium
    effort/low
    on Nov 4, 2026
  2. dan-petty commented on Nov 4, 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/infra. The perf prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. It removes redundant work in multi-item runs but does not fix a defect or block a user.
    • Value: Medium. It saves repeated tree and spec reads for runs with many items, reducing wall time and API calls.
    • Effort: Low. The body states about one hour of elapsed time and that it deletes no code.
    • Related: fix(roadmap): the implement job refuses a plan that fails the plan check #3393, which asks for a different change. Both target the implement plan gate in implement.py, but #3393 adds the gate logic and the candidate optimizes the reads it performs.
  3. added
    priority/p2-medium
    on Nov 4, 2026
  4. added
    status/ready
    and removed
    status/new
    on Nov 4, 2026
  5. devops-cli-service commented on Nov 4, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 89682e4 (see proposed design in issue body).

  6. added
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 5, 2026
  7. removed
    status/in-review
    on Nov 5, 2026
  8. devops-cli-service commented on Nov 5, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-05 16:42 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/lowpriority/p2-mediumscope/roadmapsource/agenttype/infravalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions