Repository navigation
Description
Problem
devops roadmap eval stage --replay takes more than 10 minutes (615 seconds).
In stage_eval_gates.py, _path_gate calls check_proposal with registry=None.
When registry is None, check_gates defaults registry to registry_table(Path.cwd()).
registry_table searches all Python test modules and parses each file with ast.parse.
The replay suite runs 47 golden cases.
Each case parses 1,146 files, which causes 53,862 AST parses during one replay run.
AGENTS.md rule 5 states that any check that averages more than 5 minutes is a P0 bug.
Expected
Calculate registry_table(Path.cwd()) once and pass it to replay_case through PlanUnderTest.
Add an optional registry parameter to PlanUnderTest.of_case and store it on PlanUnderTest.
In _path_gate, pass registry=plan.registry to check_proposal.
Also cache registry_table(root) with functools.lru_cache in stage_registry.py.
Replaying 47 cases will parse the test files only once.
The replay duration will decrease from 10 minutes to less than 30 seconds.
Acceptance criteria
-
uv run pytest tests/roadmap/stage/test_roadmap_stage_eval_gates.py -k registry-registry_tableis called at most once during replay of multiple cases. -
uv run devops roadmap eval stage --replayfinishes in less than 60 seconds.
Feasibility
I read src/devops_cli/roadmap/stage/stage_eval_gates.py (_path_gate, PlanUnderTest, replay_case, replay_all) and src/devops_cli/roadmap/stage/stage_registry.py (registry_table).
PlanUnderTest accepts registry: Sequence[RegistryCount] | None = None.
_path_gate passes registry=plan.registry to check_proposal.
registry_table takes Path and returns tuple[RegistryCount, ...].
The change does not alter gate behavior or test results.
Existing tool considered
functools.lru_cache from the Python standard library. No new dependency is needed.
Cost
Build: about 20k tokens and 1 hour (add cache/parameter, update call sites, 2 tests). Keep: about 1k tokens per quarter. Fix: about 5k tokens and 0.25 hours.
Related
Proposed design
Problem statement
devops roadmap eval stage --replay takes 615 seconds. AGENTS.md rule 5 makes a check that averages more than 5 minutes a P0 bug. Each of the 47 golden cases walks every test module and parses it with ast.parse, so one replay parses 53,862 files. The change reads the registry table once and passes it to every case.
Acceptance criteria
Requirement: The replay reads the registry table once
The stage eval replay SHALL read the registry table at most once per call to replay_all.
Scenario: A replay of two cases with a counted table
- WHEN
replay_allruns on two recorded cases whileregistry_tableis replaced by a counter - THEN the counter reads one
Requirement: The plan under test holds the registry
PlanUnderTest.of_case MUST accept an optional registry and store it on the PlanUnderTest.
Scenario: A case built with a one-entry registry
- WHEN
PlanUnderTest.of_casebuilds a plan with a one-entry table - THEN
plan.registryis that table
Requirement: The path gate passes the plan's registry
_path_gate MUST pass the registry of the plan to check_proposal, and check_proposal MUST forward it to check_gates.
Scenario: A path gate on a plan that holds a registry
- WHEN the path gate runs on a
PlanUnderTestbuilt with a one-entry table - THEN
check_proposalreceives that table and no call reachesregistry_table
Requirement: The replay keeps every gate result
The replay MUST return the same problems and defect outcomes for every recorded case as it did before the change.
Scenario: The recorded golden set
- WHEN the replay runs on the loaded cases
- THEN
report.failuresis empty andreport.judged()is(69, 306)
Requirement: The replay finishes under one minute
The stage eval replay MUST finish in less than 60 seconds.
Scenario: A timed replay of the whole set
- WHEN the test loads the cases and times
replay_all - THEN the elapsed time is less than 60 seconds
Existing Tool Considered
No alternatives check has run. functools.lru_cache from the Python standard library covers the caching need. It lacks a per-run scope: its cache lives for the whole process and is keyed only by root, so it can return stale entries after the tests tree changes at the same path. The plan reads one table per replay instead, so it builds no library. Written cost: about 20k tokens and 1 hour to build, about 1k tokens per quarter to keep, and about 5k tokens and 0.25 hours to fix.
Key questions
- Where does the replay walk the tests tree?:
registry_tableinstage_registry.pywalks everytests/**/*.pywithrgloband parses each file withast.parseincounts_in. The replay passes no registry tocheck_proposal, so the default of the registry argument decides the read. [sources: src/devops_cli/roadmap/stage/stage_registry.py, src/devops_cli/roadmap/stage/stage_eval_gates.py] - Where does the default of the registry argument live?: The body names
check_gatesinstage_change.py, whose registry argument defaults toregistry_table(Path.cwd())._path_gatecallscheck_proposal, andcheck_proposalforwards tocheck_gates. Refine readsstage_change.pyto confirm both signatures. [sources: src/devops_cli/roadmap/stage/stage_change.py, src/devops_cli/roadmap/stage/stage_eval_gates.py] - Where must the single registry read happen?:
replay_allreads the table once and passes it to eachreplay_case, which passes it toPlanUnderTest.of_case. (best practice) [sources: src/devops_cli/roadmap/stage/stage_eval_gates.py]- Rejected: Read in
PlanUnderTest.of_case. Each of the 47 cases then walks the tree, which is the current cost. - Chosen: Read once in
replay_all. One walk serves every case of a replay, and a directreplay_casecall keeps an optional argument. - Rejected: Read in
replay_case. A caller that loops over cases still walks the tree once per case.
- Rejected: Read in
- How does the registry reach
check_gates?: The change adds aregistrykeyword tocheck_proposaland forwards it tocheck_gates. A plan with a registry then makes no walk. (best practice) [sources: src/devops_cli/roadmap/stage/stage_eval_gates.py, openspec/changes/3308-the-plan-check-compares-a-number/tasks.md]- Chosen: Add
registrytocheck_proposaland forward it._path_gatecallscheck_proposal, and the existingrequirementsandsearch_evidencekeywords show the pattern. - Rejected: Change only the default of
check_gates. The replay callscheck_proposal, so a change tocheck_gatesalone does not reach the plan.
- Chosen: Add
- Does
registry_tableget a process-widefunctools.lru_cache?: No. The plan reads the table once per replay and passes it throughPlanUnderTest. (best practice) [sources: src/devops_cli/roadmap/stage/stage_registry.py, src/devops_cli/roadmap/stage/stage_eval_gates.py]- Rejected:
functools.lru_cacheonregistry_table. The cache lives for the whole process and is keyed only byroot, so a later round on the same path can read stale entries. - Chosen: One read per replay. The read is scoped to one replay, and the gates stay pure functions of
PlanUnderTest. - Rejected: Both caches. Two caches hide which one serves a call and keep the stale-entry risk.
- Rejected:
- What does
PlanUnderTest.of_replypass for the registry?: It passes no registry, so the value stays unset. The stage job then keeps its current behavior and walks the tree only when the default reads it. (best practice) [sources: src/devops_cli/roadmap/stage/stage_eval_gates.py]- Chosen: Leave the registry of a reply unset. The stage job checks one plan per call, so a walk per call is not a performance problem, and the behavior does not change.
- Rejected: Compute a table for each reply. The reply path walks the tree for a gain that the stage job does not need.
- Does the acceptance command
-k registryselect a test today?: No. No test name in the file holdsregistry, so the command selects nothing. The plan addstest_the_replay_reads_the_registry_table_once. [sources: tests/roadmap/stage/test_roadmap_stage_eval_gates.py]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 7, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
perfprefix of the title gives the type.(roadmap)scope of the title gives the scope.A 10-minute replay blocks the development loop and the project rule marks it a top-priority defect.Reduces replay from 10 minutes to under 30 seconds, a 20x speedup for a core dev workflow.Add one lru_cache, one optional parameter, update two call sites, and two tests.Both concern the stage eval replay system; #3028 creates the golden set and command, this candidate speeds up its execution.devops-cli-service commentedon Nov 7, 2026
Status set to Ready at d6c2297 (see proposed design in issue body).
devops-cli-service commentedon Nov 7, 2026
Staged: branch
perf/4057-cache-registry-table-in-stage-eval, draft pull request #4095. The pull request plans the item and closes no issue.The task groups, with the tokens of the inputs of each step, for a budget of 64000 tokens:
A model review of the plan found these points. They stop no draft, and a person judges them:
contrived_testat group 1: The counting test monkeypatches onlystage_eval_gates.registry_table, butcheck_gatesinstage_changecalls its own importedregistry_table; the test therefore still reads one even when_path_gatestops passing the plan's registry and the per-case walk returns. Evidence: "replacesregistry_tableon thestage_eval_gatesmodule with a counter that wraps the real reader"false_premiseat feasibility: The plan treatsfunctools.lru_cacheas a repository path, while the issue asks to use it as the standard-library cache and the plan's own decisions and rejected alternatives treat it as a function. Evidence: "The pathfunctools.lru_cacheis no file of the staging commit."The runs of the planner and the review made 94 model request(s), and used 5664239 input tokens and 172683 output tokens. The tool calls, in order:
file_symbols({"path":"src/devops_cli/roadmap/stage/stage_eval_gates.py"})read_file({"path":"src/devops_cli/roadmap/stage/stage_registry.py"})read_file({"path":"src/devops_cli/roadmap/stage/stage_eval_gates.py","start_line":55,"end_line":230})read_file({"path":"src/devops_cli/roadmap/stage/stage_eval_gates.py","start_line":295,"end_line":470})git_log({"path":"src/devops_cli/roadmap/stage/stage_eval_gates.py"})search_code({"text":"registry_table("})search_code({"text":"replay_all"})git_log({"path":"src/devops_cli/roadmap/stage/stage_registry.py"})references({"name":"registry=plan.registry"})git_log({"path":"tests/roadmap/stage/test_roadmap_stage_eval_gates.py"})read_file({"path":"src/devops_cli/roadmap/stage/stage_change.py","start_line":1130,"end_line":1230})search_code({"text":"def check_proposal"})git_log({"path":"src/devops_cli/roadmap/stage_eval_gates.py"})read_issue({"number":4057})git_show({"commit":"1efa0578","path":"src/devops_cli/roadmap/stage_eval_gates.py"})git_show({"commit":"324a3a5c","path":"src/devops_cli/roadmap/stage/stage_eval_gates.py"})git_show({"commit":"84761630","path":"src/devops_cli/roadmap/stage/stage_eval_gates.py"})search_code({"text":"monotonic()"})search_code({"text":"registry"})search_code({"text":"elapsed-upper-bound"})git_log({})read_issue({"number":3027})read_issue({"number":3254})find_issues({"terms":"registry_table eval stage replay"})file_symbols({"path":"src/devops_cli/roadmap/stage/stage_eval_gates.py"})search_code({"text":"registry=plan.registry"})search_code({"text":"registry_table"})search_code({"text":"test-elapsed-upper-bound"})read_file({"path":"src/devops_cli/roadmap/stage/stage_eval_gates.py","start_line":60,"end_line":135})read_file({"path":"src/devops_cli/roadmap/stage/stage_eval_gates.py","start_line":160,"end_line":185})read_file({"path":"src/devops_cli/roadmap/stage/stage_eval_gates.py","start_line":300,"end_line":320})read_file({"path":"src/devops_cli/roadmap/stage/stage_eval_gates.py","start_line":410,"end_line":440})search_code({"text":"registry"})read_file({"path":"src/devops_cli/roadmap/stage/stage_change.py","start_line":1150,"end_line":1215})git_log({"path":"src/devops_cli/roadmap/stage/stage_eval_gates.py"})read_issue({"number":3027})read_issue({"number":3254})find_issues({"terms":"registry_table replay"})git_show({"commit":"84761630","path":"src/devops_cli/roadmap/stage/stage_eval_gates.py"})read_file({"path":"src/devops_cli/roadmap/stage/stage_change.py","start_line":1215,"end_line":1250})read_file({"path":"src/devops_cli/roadmap/stage/stage_registry.py","start_line":80,"end_line":110})file_symbols({"path":"tests/roadmap/stage/test_roadmap_stage_eval_gates.py"})read_file({"path":"src/devops_cli/roadmap/stage/stage_eval_gates.py","start_line":60,"end_line":200})read_file({"path":"src/devops_cli/roadmap/stage/stage_eval_gates.py","start_line":290,"end_line":460})search_code({"text":"registry"})read_file({"path":"src/devops_cli/roadmap/stage/stage_change.py","start_line":1150,"end_line":1260})search_code({"text":"registry"})read_file({"path":"tests/roadmap/stage/test_roadmap_stage_eval_gates.py","start_line":100,"end_line":400})file_symbols({"path":"tests/roadmap/stage/test_roadmap_stage_eval_gates.py"})list_files({"directory":".ast-grep/rules"})git_log({"path":"src/devops_cli/roadmap/stage/stage_eval_gates.py"})read_file({"path":".ast-grep/rules/test-elapsed-upper-bound.yml"})search_code({"text":"replay_all"})search_code({"text":"--replay"})git_show({"commit":"84761630","path":"src/devops_cli/roadmap/stage/stage_eval_gates.py"})search_code({"text":"ci test"})search_code({"text":"def test"})read_file({"path":"src/devops_cli/roadmap/stage/stage_criteria.py"})read_issue({"number":4057})read_issue({"number":3981})git_log({})git_show({"commit":"d6c2297b18253669bd835e791af12aa789874cf2","path":"src/devops_cli/roadmap/stage/stage_eval_gates.py"})search_code({"text":"registry_table"})search_code({"text":"PlanUnderTest.of_case(case, registry"})search_code({"text":"class GroupKind"})search_code({"text":"test_the_replay_reads_the_registry"})read_file({"path":"src/devops_cli/roadmap/stage/stage_change.py","start_line":370,"end_line":400})search_code({"text":"registry"})read_file({"path":"tests/roadmap/stage/test_roadmap_stage_eval_run.py","start_line":380,"end_line":420})read_issue({"number":3027})read_issue({"number":3254})search_code({"text":"registry_table"})search_code({"text":"registry=plan.registry"})read_file({"path":"src/devops_cli/roadmap/stage/stage_eval_gates.py","start_line":55,"end_line":200})read_file({"path":"src/devops_cli/roadmap/stage/stage_eval_gates.py","start_line":290,"end_line":440})git_log({"path":"src/devops_cli/roadmap/stage/stage_eval_gates.py"})search_code({"text":"registry"})read_file({"path":"src/devops_cli/roadmap/stage/stage_registry.py","start_line":60,"end_line":110})read_file({"path":"src/devops_cli/roadmap/stage/stage_change.py","start_line":1170,"end_line":1230})list_files({"directory":".ast-grep/rules"})read_file({"path":".ast-grep/rules/test-elapsed-upper-bound.yml"})git_show({"commit":"84761630","path":"src/devops_cli/roadmap/stage/stage_eval_gates.py"})read_file({"path":"src/devops_cli/roadmap/stage/stage_eval_run.py"})search_code({"text":"--replay"})search_code({"text":"replay_all("})read_file({"path":"src/devops_cli/commands/roadmap_eval_stage.py","start_line":1,"end_line":60})read_file({"path":"tests/roadmap/stage/test_roadmap_stage_registry.py","start_line":1,"end_line":80})read_file({"path":"src/devops_cli/roadmap/stage/stage_registry.py","start_line":1,"end_line":60})search_code({"text":"the_registry"})read_file({"path":"src/devops_cli/roadmap/stage/stage_eval_gates.py","start_line":60,"end_line":200})git_log({"path":"src/devops_cli/roadmap/stage/stage_eval_gates.py"})read_file({"path":"src/devops_cli/roadmap/stage/stage_eval_gates.py","start_line":280,"end_line":460})git_show({"commit":"84761630"})git_show({"commit":"84761630","path":"src/devops_cli/roadmap/stage/stage_eval_gates.py"})search_code({"text":"def check_proposal"})search_code({"text":"registry_table(Path.cwd())"})read_file({"path":"src/devops_cli/roadmap/stage/stage_change.py","start_line":1130,"end_line":1240})list_files({"directory":".ast-grep/rules"})search_code({"text":"pending-person"})read_file({"path":".ast-grep/rules/test-elapsed-upper-bound.yml"})read_file({"path":"src/devops_cli/commands/roadmap_eval_stage.py","start_line":1,"end_line":60})search_code({"text":"registry"})read_file({"path":"tests/roadmap/stage/test_roadmap_stage_eval_gates.py","start_line":1,"end_line":400})read_file({"path":"tests/roadmap/stage/test_roadmap_stage_eval_gates.py","start_line":198,"end_line":400})search_code({"text":"def test_the_replay_reads_the_registry"})search_code({"text":"changes no path under src/"})search_code({"text":"def _kind_rules"})read_file({"path":"src/devops_cli/roadmap/stage/stage_change.py","start_line":400,"end_line":520})read_file({"path":"src/devops_cli/roadmap/stage/stage_form.py"})read_file({"path":"src/devops_cli/roadmap/stage/stage.py","start_line":1000,"end_line":1040})search_code({"text":"def registry_problems"})read_file({"path":"tests/roadmap/stage/test_roadmap_stage_eval_gates.py","start_line":386,"end_line":0})read_file({"path":"src/devops_cli/roadmap/stage/stage_change.py","start_line":1250,"end_line":1320})read_file({"path":"AGENTS.md","start_line":1,"end_line":30})search_code({"text":"REGISTRY_COUNTS"})search_code({"text":"\"registry_table\""})search_code({"text":"def test("})search_code({"text":"ci test"})search_code({"text":"def _what_changes_problems"})read_file({"path":"src/devops_cli/roadmap/stage/stage_change.py","start_line":1050,"end_line":1130})search_code({"text":"SECURITY_TRIGGER_WORDS"})search_code({"text":"def _message_file_problems"})read_file({"path":"src/devops_cli/roadmap/stage/stage_change.py","start_line":180,"end_line":200})read_file({"path":"src/devops_cli/roadmap/stage/stage_change.py","start_line":800,"end_line":850})search_code({"text":"def tree"})read_file({"path":"src/devops_cli/roadmap/stage/stage_eval_cases.py","start_line":1,"end_line":120})read_file({"path":"src/devops_cli/roadmap/stage/stage_eval_cases.py","start_line":180,"end_line":240})read_file({"path":"src/devops_cli/roadmap/stage/stage_criteria.py"})search_code({"text":"registry_table"})read_file({"path":"tests/roadmap/stage/test_roadmap_stage_registry.py","start_line":1,"end_line":80})read_file({"path":"src/devops_cli/roadmap/stage/stage.py","start_line":1125,"end_line":1160})read_file({"path":"src/devops_cli/roadmap/stage/stage_change.py","start_line":900,"end_line":980})search_code({"text":"def code_span_paths"})read_file({"path":"src/devops_cli/roadmap/stage/stage_paths.py","start_line":1,"end_line":160})read_file({"path":"src/devops_cli/roadmap/stage/stage_paths.py","start_line":158,"end_line":210})search_code({"text":"contrived"})read_file({"path":"docs/TESTING.md","start_line":1,"end_line":80})search_code({"text":"Sentence ="})search_code({"text":"class StageProposal"})read_file({"path":"src/devops_cli/roadmap/stage/stage_change.py","start_line":300,"end_line":400})read_file({"path":"src/devops_cli/roadmap/stage/stage_change.py","start_line":524,"end_line":620})search_code({"text":"def verification_problem"})read_file({"path":"src/devops_cli/roadmap/implement/implement_shell_policy.py","start_line":1,"end_line":120})read_file({"path":"src/devops_cli/roadmap/implement/implement_shell_policy.py","start_line":480,"end_line":560})search_code({"text":"(\"ci\", \"test\")"})read_file({"path":"src/devops_cli/ai/tasks/roadmap_stage_verify.md","start_line":1,"end_line":60})search_code({"text":"criterion_dropped"})search_code({"text":"\"criterion_dropped\""})read_file({"path":"tests/fixtures/roadmap_eval/stage/2163-coverage-measures-branches-and-ci-keeps/case.json","start_line":1,"end_line":70})search_code({"text":"ast-grep/rules"})search_code({"text":"test-elapsed-upper-bound"})read_file({"path":"src/devops_cli/commands/ci.py","start_line":1945,"end_line":2050})search_code({"text":"def _resolve_test_targets"})read_file({"path":"src/devops_cli/commands/ci.py","start_line":1838,"end_line":1945})Tool calls: file_symbols=4 (empty=0), find_issues=2 (empty=0), git_log=10 (empty=0), git_show=9 (empty=1), list_files=3 (empty=0), read_file=61 (empty=0), read_issue=9 (empty=0), references=1 (empty=0), search_code=55 (empty=3)
The stage job read the open pull requests and their files in 1 GraphQL request(s).
docs(openspec): plan #4057 Lock the single registry read in the replay
docs(openspec): plan #4057 Lock the single registry read in the replay (
devops-cli-service commentedon Nov 8, 2026
Pull request #4117 is ready for review. The checks passed.
Spend: 30 model requests, 1051071 input tokens, 6067 output tokens.
devops-cli-service commentedon Nov 8, 2026
The runner Job devops-cli-runner-20261108-030559-bed9 ended: succeeded.
Image digest: sha256:1553d88dcb89e7c579b747c7eaf8e542da38934bed7fa133a260f0520b0d7996
The last lines of its log: