Repository navigation
Description
Problem Description
A test that calls check_proposal or check_gates with no registry argument makes the registry gate call registry_table(Path.cwd()). That function parses every test file of the repository with ast.parse (1,313 files). One call takes about 6 seconds, and the result is not kept between calls.
At least 18 test files in tests/roadmap/stage/ call check_proposal with no registry. For example, tests/roadmap/stage/test_roadmap_stage_trace_subject.py has 12 cases and takes about 50 seconds with -n0. With registry=[], the same call takes about 3 ms.
This adds minutes of CPU time to the test row, which #4405 measures against the 5 minute budget.
Reproduction Steps
- In a short script, build
plan = make_stage_proposal()and timecheck_proposal(plan, ["comment-thread"], StagedTree(["src/devops_cli/sample.py"]), trace=TraceFacts()). - Time it again with
registry=[].
Expected vs Actual Behavior
Expected: a unit test of one gate does not parse the whole repository.
Actual: each call takes about 6 s (cProfile: registry_table 6.2 s, of which ast.parse 4.2 s in 1,313 calls).
Possible fixes: the tests pass registry=[] (or a fixture value) unless they test the registry gate, or registry_table keeps its result for a tree that did not change.
Environment Diagnostics
- DevOps CLI: main at c653bde
- Execution environment: DevContainer
Logs, Traces, or Terminal Output
first 6.85 s
second 6.18 s
registry=[] 0.0027 sPre-Submission Checklist
- I have verified that no sensitive credentials, private keys, or internal tokens are contained in this issue report.
- I have checked existing issues and pull requests to ensure this is not a duplicate.
Proposed design
Problem statement
The stage gate tests parse every test file of the repository on each call. check_proposal and check_gates call registry_table(Path.cwd()) when the caller passes no registry, and that function parses 1,313 test files with ast.parse. One call takes about 6 seconds, and the result is not kept. At least 18 test files in tests/roadmap/stage/ make this call, so the test row spends minutes of CPU time on work that no test needs.
Acceptance criteria
Requirement: Explicit registry in stage gate tests
Each test in tests/roadmap/stage/ that calls check_proposal or check_gates MUST pass a registry value, unless the test checks the registry gate.
Scenario: A gate test passes the empty registry
- WHEN A test calls
check_proposalwithregistry=[]. - THEN The call returns the same problems as the same call with the table of the repository.
Requirement: Guard on the default registry
The conftest.py of tests/roadmap/stage/ MUST make a gate call with no registry raise an error that names the fixture.
Scenario: A gate test omits the registry
- WHEN A test calls
check_proposalorcheck_gateswith noregistryargument. - THEN The call raises
AssertionError, the message namesregistry, and no test file is parsed.
Requirement: Registry gate tests keep the real table
Each test that checks the registry gate MUST pass the table from registry_table as the registry argument.
Scenario: The registry gate test builds the table
- WHEN A registry gate test calls
registry_table(Path.cwd())and passes the result. - THEN The test reads the real entries, and the guard leaves the call alone.
Requirement: No parse of the tests tree from a gate call
A test MUST assert that check_proposal with registry=[] calls ast.parse zero times.
Scenario: The counter test runs
- WHEN A test replaces
ast.parsewith a counter and callscheck_proposalwithregistry=[]. - THEN The counter reads zero, and the call returns the same problems as before.
Existing Tool Considered
No check has run. pytest covers the need, because the tests already use it and it gives fixtures and monkeypatch. It lacks a cheap registry_table, so the tests must pass the registry themselves. A cache inside registry_table instead costs about 15,000 tokens to build, keep and fix, and about half a day of elapsed time.
Key questions
- Which fix removes the repeated parse: pass an explicit
registryin the tests, or cacheregistry_table?: The tests pass an explicitregistry.registry_tablestays uncached, because a cache keyed by the root path serves a stale table after the tests tree changes. (best practice) [sources: openspec/changes/archive/2026-11-08-4057-cache-registry-table-in-stage-eval/design.md, src/devops_cli/roadmap/stage/stage_registry.py, src/devops_cli/roadmap/stage/stage.py]- Chosen: Pass the registry in each test. The archived design of change 4057 rejected a process-wide cache, and an empty list takes about 3 ms.
- Rejected: Add
functools.lru_cachetoregistry_table. The cache is keyed only byrootand serves a stale table on a later round at the same path. - Rejected: Key the cache on a stat of the tests tree. It adds a staleness rule and code that the project keeps and tests.
- Which value does the shared fixture return?: An empty list. A gate that reads no entry reports no problem, and a test that needs an entry builds that entry. (best practice) [sources: tests/roadmap/stage/test_roadmap_stage_registry.py, src/devops_cli/roadmap/stage/stage_registry.py]
- Chosen: Empty list. The issue measures 3 ms with
registry=[], and no stage gate test needs an entry that it does not build. - Rejected: A fixed table of the repository entries. It hides the input of the test and makes the test pass for a reason that it does not state.
- Chosen: Empty list. The issue measures 3 ms with
- How does the suite stop a new test from parsing the tests tree again?: An autouse fixture in the
conftest.pyoftests/roadmap/stage/replacesregistry_tablein the stage call sites. The replacement raisesAssertionErrorand names theregistryfixture. (best practice) [sources: src/devops_cli/roadmap/stage/stage_change.py, src/devops_cli/roadmap/stage/stage_eval_gates.py, src/devops_cli/roadmap/stage/stage_paths.py]- Chosen: Autouse guard that raises. The failure names the fix at once, and the call costs no parse.
- Rejected: No guard, and review catches the omission. The cost is invisible, because the test passes in about 6 seconds.
- Rejected: A wall-clock limit on the stage suite. A shared runner makes a time limit flaky.
- How does a test prove that the gate parses no test file?: A test replaces
ast.parsewith a counter and asserts zero calls fromcheck_proposalwithregistry=[]. (best practice) [sources: tests/roadmap/stage/test_roadmap_stage_trace_subject.py]- Chosen: Count the calls of
ast.parse. The count is exact and does not depend on the speed of the runner. - Rejected: Assert a wall-clock limit per call. A busy runner makes the assertion fail with no defect.
- Chosen: Count the calls of
- Which stage tests need the real registry table?:
test_roadmap_stage_registry.py,test_roadmap_stage_eval_gates.pyandtest_roadmap_stage_split_gates.pycallregistry_tableand keep the real table. [sources: tests/roadmap/stage/test_roadmap_stage_registry.py, tests/roadmap/stage/test_roadmap_stage_eval_gates.py, tests/roadmap/stage/test_roadmap_stage_split_gates.py] - Do
check_proposalandcheck_gatesaccept aregistryargument?: Yes.check_proposaltakes aregistryargument, andcheck_gatespasses it to each gate. [sources: src/devops_cli/roadmap/stage/stage_change.py, openspec/changes/archive/2026-11-08-4057-cache-registry-table-in-stage-eval/design.md]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 11, 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.test, and .github/labels.yml declares no scope/test label. Add the label to the file to give the scope to this item.It adds minutes to the CI test row against a 5-minute budget, but does not block delivery or affect users.It saves developer CI time and keeps the test row within budget, but does not change product behaviour.The fix is to pass registry=[] in test files or add a simple cache to registry_table.Both hit the same expensive registry_table ast.parse loop, but #4057 cached it for the replay command while the candidate asks to fix the test-suite calls.devops-cli-service commentedon Nov 11, 2026
Status set to Ready at 5f75d25 (see proposed design in issue body).
dan-petty commentedon Nov 11, 2026
Scope from the CI audit (2026-11-11)
The CI and test audit measured this cost again, and it adds a fix in the product code. Keep the explicit registry in the stage tests of the current design, and add the scope below.
Problem (measured)
registry_table(src/devops_cli/roadmap/stage/stage_registry.py:88-101) runsast.parseon each of 1,332 test modules on each call, with no cache. One call takes 2.04 s.check_gatesfalls back toregistry_table(Path.cwd())(stage_change.py:2220-2223), andimplement.py:417,plan_check.py:380,plan_recheck.py:359andstage_eval_gates.py:551pass no table.tests/roadmap/implementfrom 2,534 s to 709 s of test time (-72%). Changed-Test Independence spent 181 of 205 s in 130 calls for 4 files.Added solution
In
counts_in, return()when the source text does not holdREGISTRY_COUNTS, beforeast.parse. A module that declares the counts must hold the name, so the result does not change. Only 9 of 1,332 modules hold the token. Measured: 0.092 s per call (from 2.04 s), with the same 7 entries. This is not a cache, so nothing goes stale in the long-lived Service. It agrees with the rejected cache of the current design.Added acceptance criteria
registry_tableon the repository takes 0.2 s or less (from 2.04 s) and gives the same entries.tests/roadmap/implementwith-n 6and no coverage takes 900 s of test time or less (from 2,534 s).Saving
Estimated 22-47% of each Tests & Coverage shard (100-170 s on the 317-371 s shards), the same share of each Service Image Tests shard, about 16 runner-min per push at a 35% cut, and 40-50% of the local full test row.
Items that wait for this item
#4695 (the production callers pass the table of the judged checkout), #4722 and #4250 (the shard balance). #4473 (more shards) closes as not planned in favor of this item.
devops-cli-service commentedon Nov 11, 2026
Released in v0.113.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.113.0
devops-cli-service commentedon Nov 11, 2026
Live since 2026-11-11 19:36 UTC
fix(ci): set job timeouts from the measured run times (#4892)