Repository navigation
Description
What happened
17 of 37 plans ignore code, tests or specs that already exist: #2976 adds a failure path beside CheckFailure, #2978 duplicates ToolRun.config_digest, #2989 ignores split_offs, #2998 misses tests that pin the exact argv, #2971 breaks a test that forbids a lookup, #2870 refuses keys that install_tools sets. The stage input holds the issue, at most 10 cited files, at most 5 identifier greps of 20 lines and a tree of at most 50 files. It does not search tests/.
What should happen
- For each symbol the issue cites, the context lists the tests and callers that reference it (
git grep -l) and the cap of 20 lines grows to a stated bound. - The context also holds the names of the requirements of each base spec that a cited capability has.
Acceptance criteria
- A cited identifier brings the test files that reference it into the context.
- The refine job, which shares
collect_context, keeps passing its tests and stays inside its budget. - The token cost of the larger context is measured and stated.
Source
An evaluation on 2026-11-01 of the 37 docs(openspec): plan #N pull requests (35 merged, 2 open) found 34 that need fixes and 1 to reject. The per-PR reviews are in the comments of tracker #3005's thread and in .data/agent/scratch/plan-review.json of the owner's workstation. Related: #3005 (the kind of a task group: test for behavior, a repeatable check for other changes).
Proposed design
Problem statement
The stage context passed to the refine model holds at most 10 cited files, 5 identifier greps of 20 lines, and a tree of 50 files. It does not search tests/ or list callers of cited symbols. As a result, 17 of 37 plans ignore existing code, tests, or specs. The context must list the test files and callers that reference each cited symbol, and the requirement names of each base spec for a cited capability.
Acceptance criteria
Requirement: Cited symbol brings test files
The context SHALL include the test files that reference each cited identifier, found by git grep -l.
Scenario: A cited symbol has test references
- WHEN The issue body cites a symbol that is referenced in files under tests/
- THEN The context payload lists those test file paths
Requirement: Cited symbol brings caller files
The context SHALL include the source files that call or reference each cited identifier.
Scenario: A cited symbol has caller references
- WHEN The issue body cites a symbol that is referenced in source files outside tests/
- THEN The context payload lists those source file paths
Requirement: Line cap is stated
The context SHALL bound the number of file paths listed per cited symbol to a stated constant.
Scenario: A cited symbol has more references than the bound
- WHEN git grep -l returns more file paths than the stated bound for one symbol
- THEN The context lists at most the bound number of paths and notes the truncation
Requirement: Spec requirement names included
The context SHALL include the requirement names of each base spec for a capability that a cited file belongs to.
Scenario: A cited file maps to a capability with a base spec
- WHEN A cited file path maps to a capability that has openspec/specs//spec.md
- THEN The context lists the requirement names from that spec file
Requirement: Refine job stays in budget
The refine job SHALL keep passing its tests and stay inside its token budget after the context change.
Scenario: Refine job runs with the larger context
- WHEN The refine job calls collect_context with the new test-file and spec-name additions
- THEN All existing tests in tests/roadmap/test_refine.py pass and the total context tokens do not exceed the job budget
Requirement: Token cost is stated
The token cost of the larger context SHALL be measured and stated in the change record.
Scenario: Token cost is measured
- WHEN The implementation is complete and the context is generated for a representative issue
- THEN The change record states the token count of the added context sections
Existing Tool Considered
No check has run. No open, maintained tool or library assembles a bounded context payload from git grep results for an LLM prompt. The project builds its own code in collect_context (src/devops_cli/roadmap/refine.py). Written cost: approximately 150 to 300 lines of new or modified code for the grep, filter, and spec-read logic, plus 80 to 150 lines of tests. Ongoing cost: maintaining the bound constants and the path-filter patterns as the repository layout changes. Elapsed time: one to two days of implementation and review.
Key questions
- What bound replaces the 20-line cap on grep output per cited symbol?: 50 file paths per symbol. The current cap of 20 lines of code output becomes a cap of 50 file paths, because git grep -l outputs one path per line. This allows listing test files and callers without exceeding the token budget. (best practice) [sources: src/devops_cli/roadmap/refine.py]
- Rejected: Keep 20. Too small: a symbol referenced in 10 source files and 10 test files would be truncated, hiding the test references that this change aims to surface.
- Rejected: 50 file paths. Chosen. Captures a realistic number of callers and tests for a single symbol while keeping the per-symbol section under 500 tokens. Stated as a named constant in the code.
- Rejected: 100 file paths. Rejected. Doubles the token cost per symbol and is unlikely to be needed for the symbols that issues cite.
- How does the code identify test files among the grep results?: A file is a test file when its path starts with tests/ or matches the pattern test_*.py or *_test.py. All other files are callers. (proposed)
- Rejected: Path prefix tests/. Covers the project convention but misses test files in other locations.
- Rejected: Path prefix tests/ plus filename patterns test_*.py and *_test.py. Chosen. Matches the project layout and the common Python test naming convention. Stated as a list of patterns in the code.
- Rejected: Run pytest --collect-only to find test files. Rejected. Too slow for a context-assembly step and adds a dependency on the test runner being installed.
- How does the code extract requirement names from a base spec?: Read openspec/specs//spec.md and collect the text of each heading that starts with '### Requirement:'. The capability is derived from the cited file path using the same mapping the project already uses for spec deltas. (best practice) [sources: docs/adr/0010-openspec-is-the-spec-and-change-proposal-layer.md]
- Rejected: Parse ### Requirement: headings. Chosen. Matches the OpenSpec spec format. Simple string scan, no parser dependency.
- Rejected: Run openspec validate to get requirement names. Rejected. Adds a subprocess call and a dependency on the openspec binary being available in the Service image.
- What is the token cost of the added context sections?: To be measured during implementation. Estimate: 50 file paths at ~30 tokens each is 1500 tokens per symbol. With at most 5 cited symbols, the added cost is at most 7500 tokens for file references, plus the spec requirement names (typically 5 to 20 names at ~10 tokens each, so 50 to 200 tokens per capability). The total added cost is bounded and must be stated in the change record. [sources: src/devops_cli/roadmap/refine.py]
- Does the refine job share collect_context with the stage job?: Yes. The body states that the refine job shares collect_context. The change must keep the refine job inside its budget. [sources: src/devops_cli/roadmap/refine.py, openspec/changes/archive/2026-10-25-1440-git-nul-separated-output/proposal.md]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 1, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
featprefix of the title gives the type.(roadmap)scope of the title gives the scope.It fixes a systemic gap in 17 of 37 plans but is an enhancement, not a blocker.Plans that ignore existing tests and callers produce broken or duplicate work.Requires modifying collect_context, adding git grep calls, updating the line cap, and measuring token cost.Both improve the stage job input before the model call, but 3011 adds premise verification commands while this adds test and caller references to the context.devops-cli-service commentedon Nov 1, 2026
Status set to Ready at 1c20865 (see proposed design in issue body).
devops-cli-service commentedon Nov 2, 2026
Staged: branch
feat/3012-the-stage-context-holds-the-callers, draft pull request #3178. 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 40000 tokens:
The plan run made 6 model request(s), and used 286976 input tokens and 1510 output tokens. The tool calls, in order:
search_code({"text":"collect_context"})list_files({"directory":"src/devops_cli/roadmap"})read_file({"path":"src/devops_cli/roadmap/refine.py","start_line":560,"end_line":700})read_file({"path":"src/devops_cli/roadmap/stage.py","start_line":620,"end_line":680})list_files({"directory":"tests/roadmap"})read_spec({"capability":"roadmap-refine"})search_code({"text":"collect_context"})search_code({"text":"CONST_ROADMAP_REFINE_MAX_BLOCK_PATHS"})docs(openspec): plan the callers and tests in the stage context
test(roadmap): the stage context holds the callers and tests of each …
docs(openspec): shorten a requirement of the plan for #3012
docs(openspec): archive the change for #3012
test(roadmap): replay the defects whose gates exist now (#3214)