Repository navigation
Description
Problem or Motivation
The stage planner reads again the files that its request already holds. In the stage comment sample of 2026-11-06 to 2026-11-13 (54 items, 8,213 tool calls), the planner made 383 read_file calls on cited files that the capped context kept, in 42 of 52 items. Two causes can explain the re-reads, and the data does not split them:
- The trace gate.
TraceFacts.of(src/devops_cli/roadmap/agent_run.py) reads onlytrace.tool_calls._was_readand_was_seen(src/devops_cli/roadmap/stage/stage_change.py) accept only the paths and the match lines of tool calls. Line 10 ofroadmap_stage_change.mdsays thatFeasibilitycites only the tools and the paths that this run used. So a claim about text fromcontextis refused unless the planner reads the file again. - Line numbers.
collect_contextwrites each### Code: <path>block as raw text, with no line numbers and no range in the heading. The prompt asks forpath:line:textcitations, andread_filegives numbered lines. Of the 477read_filecalls on files that the body cites whole, 453 read a line range. Only 67 of 557 reads of cited files are in calls 1-10.
The planner also calls read_issue on its own item (14 of 54 items, 19 calls), although body is in the request. It calls read_spec with no capability (19 of 54 items, 26 calls), although capabilities holds all names.
The stage replay cannot see a change of the trace gate: 0 of the 59 cases in tests/fixtures/roadmap_eval/stage/ hold facts.trace, so the gate does not run in the replay.
Proposed Solution & Architectural Design
- Number the code lines. Each
### Code:block states its range and gives each line in theread_fileformat, from the real first line of a sliced range. - Add a separate
givenfield toTraceFacts. Do not merge it intopaths:- Build it from the final request text, after the cap and after the sections that
_requestadds (registry places, stage facts). - Add a whole path only when the request holds all of its text.
- For a file that the cap cut, add only the
path:Nentries of the lines that remain. - Never add a path that only a tree entry, an identifier match, an index line or a manifest names. Any path in the set makes every claim on it pass through the suffix match of
_same_path.
- Build it from the final request text, after the cap and after the sections that
- Accept a separate claim form for given text, such as "the request context holds
path". Keep "read" for tool reads. Change line 10 ofroadmap_stage_change.mdto name both forms. - Store
giveninPlanFactsand in the kept plan record, so that a revision of a kept plan uses the set of its own commit. Change the record key. read_issueof the item's own number andread_specwith no capability answer with the name of the request field that holds the text. When the cap cut the body,read_issuegives the full body.
The threshold stays: a claim about text that the request did not hold is still refused. This change lowers no quality threshold (AGENTS.md rule 5).
Target Subsystem
SDLC, Git & PR Governance: src/devops_cli/roadmap/agent_run.py, src/devops_cli/roadmap/stage/stage_change.py, stage.py, stage_plan_record.py, stage_tools.py, src/devops_cli/roadmap/refine/refine.py (collect_context), src/devops_cli/ai/tasks/roadmap_stage_change.md, tests/fixtures/roadmap_eval/stage/.
Existing Tool Considered
No open tool decides which claims of a plan the request and the tool calls support. The gate is project code (#3266, #4495), and this change extends TraceFacts. The numbered lines use the format of the existing read_file tool. Cost to build: about 1.5M tokens and 4 hours (estimate), about 150 lines and 10 tests. Keep cost: one field, one record key, one prompt line.
Acceptance Criteria
- Test first: unit tests that fail before the change:
- a true claim on a whole given file passes with no tool read;
- a false claim on the part of a file that the cap cut is refused;
- a claim on a path that only the tree or the identifier matches show is refused;
- a claim to have read an ADR that only an index line names is refused.
- Replay cases with
facts.traceandfacts.givenfor the four cases above. The replay passestrace.lines. Every known-bad plan of the stage eval is still refused. - A test: each code block of the context gives the numbered lines of its range, from the real first line.
- Baseline first: after fix(roadmap): the stage gate log names each refused claim #5433 logs the subject of each refused claim, count for 7 days the refused paths that the capped context held. Record that count in
## Feasibilityas the baseline, not 383. - Measure: report the re-reads of context paths in two parts: re-reads for line numbers (a ranged read of a given range) and re-reads that the gate forced.
- Live proof after release: on real Service stage runs for 7 days, give the
read_filecalls on context paths (sample baseline 383 in 42 of 52 items), the ownread_issueand no-argumentread_speccalls (baseline 33), and the share ofstage_problem_trace_pathin thestage gate returnslines (baseline 10 of 60).
Dependencies
-
chore(roadmap): hold incremental stage and implement work #6521 (hold: incremental work on the stage, implement and fix-checks jobs waits for the re-architecture)
-
Issue fix(roadmap): the stage gate log names each refused claim #5433 changes the same gate area and is in progress: start after it merges. fix(roadmap): the plan context lists the ADRs in force, not ADR 0001-0005 #5465 and feat(roadmap): planners and implement read the target AGENTS.md #4650 change
collect_context. Do not stack the pull requests. The run index of feat(roadmap): run records give the run, step and path class of tool calls #5460 makes the measure exact for each run.
Standards Compliance
- I confirm this proposal aligns with AGENTS.md engineering principles (cyclomatic complexity <= 10, nesting <= 4 blocks, zero bare exceptions, tests that cover the changed lines).
Alternatives check of 2026-11-29: none.
Tool: none found.
Reason: Searches found only LLM evaluation frameworks (Ragas, Guardrails AI, DeepEval) that score answers against supplied context; none checks path or path:line claims against a tool-call trace, numbers context code lines, or keeps a given set in a plan record.
Lacks:
- No check of a claim against the request text or the tool-call trace
- No path:N line entries for text a cap kept
- No line-numbered ### Code: blocks in the context
- No stored given set for a revision of a kept plan
- Scores a whole answer, not one cited path or line
Proposed design
Problem statement
Hold this item until #6521 delivers. The stage planner reads again the files that its request already holds. The trace gate accepts only tool-call paths and match lines, so it refuses a claim about text from context. The context code blocks carry no line numbers, so the planner reads a line range. This change adds the final request text to the gate, numbers the code lines, and answers own-item and no-capability reads. The measurement of the re-reads is in #6240.
Acceptance criteria
Requirement: Given text passes the gate
The stage trace gate SHALL accept a claim about a path whose whole text the final request holds, with no tool read of that path.
Scenario: A true claim on a whole given file
- WHEN a plan claims that the request context holds a path whose whole text is in the final request, and the trace holds no read of it
- THEN the check reports no refusal for that claim
Requirement: A remaining line of a cut file passes
The stage trace gate SHALL accept a claim about a path:N line that the final request holds when the cap cut the file.
Scenario: A claim on a line that remains after the cap
- WHEN a plan claims that the request context holds
path:N, the cap cut the file, and line N remains in the request - THEN the check reports no refusal for that claim
Requirement: A cut line stays refused
The stage trace gate MUST refuse a claim about a line of a path that the request cap cut.
Scenario: A claim on the part of a file that the cap cut
- WHEN a plan claims a line of a file whose text the cap cut, and the request does not hold that line
- THEN the check refuses the claim
Requirement: A named-only path stays refused
The stage trace gate MUST refuse a claim on a path that only a tree entry, an identifier match, an index line, a manifest, a registry place or a stage fact names.
Scenario: A path that only a tree entry or an identifier match shows
- WHEN a plan claims text of a path that only a tree entry or an identifier match names, and the request does not hold its text
- THEN the check refuses the claim
Requirement: An index-only ADR read stays refused
The stage trace gate MUST refuse a claim to have read a path that only an index line names.
Scenario: A read claim on an ADR that only an index line names
- WHEN a plan claims that it read an ADR path that only an index line names, and the trace holds no read of it
- THEN the check refuses the claim
Requirement: The record keeps its own given set
A kept plan record SHALL store the given set of its own commit, under a record key that changes with the prompt version.
Scenario: A revision of a kept plan
- WHEN the trace check runs on a revision of a kept plan record
- THEN the check uses the
givenset stored in that record
Requirement: The context code block numbers its lines
Each ### Code: block of the request context SHALL state its range and give each line as <N>: <text>, from the real first line.
Scenario: A sliced code range
- WHEN
collect_contextwrites a### Code:block for a range that starts after line 1 of the file - THEN the heading states the range and the first numbered line carries the real line number
Requirement: The own item read names the request field
read_issue of the item's own number MUST answer with the name of the request field that holds the text.
Scenario: The planner reads its own item
- WHEN the planner calls
read_issuewith the number of its own item - THEN the answer names the request field
body
Requirement: The own item read gives the full body when cut
read_issue of the item's own number MUST answer with the full body when the request cap cut it.
Scenario: The planner reads its own item whose body the cap cut
- WHEN the planner calls
read_issuewith the number of its own item and the request body is shorter than the issue body - THEN the answer holds the whole issue body
Requirement: The no-capability spec read names the request field
read_spec with no capability MUST answer with the name of the request field that holds the names.
Scenario: The planner lists the capabilities
- WHEN the planner calls
read_specwith no capability name - THEN the answer names the request field
capabilities
Requirement: The stage prompt names both claim forms
The stage prompt MUST name the given-text claim form beside the read form.
Scenario: The stage prompt rules
- WHEN the feasibility rule of
src/devops_cli/ai/tasks/roadmap_stage_change.mdis read - THEN the rule names the read form and the given-text claim form
Requirement: The replay passes the trace lines and given set
The stage eval replay SHALL pass the lines and given facts of each case to the trace gate.
Scenario: The replay of the new cases
- WHEN
uv run devops roadmap eval stage --replayruns over the new cases, whose facts holdtrace.linesandtrace.given - THEN the new cases pass with their trace lines and given sets
Requirement: Every known-bad plan stays refused
The stage eval replay MUST still refuse every known-bad plan.
Scenario: The 3205 zero-call trace case
- WHEN
uv run devops roadmap eval stage --replayruns the 3205 case, whose trace holds no tool call and whose plan claims a read - THEN the replay refuses the plan for that read claim
Existing Tool Considered
The alternatives check of 2026-11-23 records the verdict none and names no tool that covers the need; its Tools considered and Lacks: list are in the alternatives block in the issue body. A further search found no open, maintained tool that decides which path and path:line claims the final request text and the tool-call trace support, numbers the context code lines, or keeps a given set in the plan record. The stage trace gate stays project code (#3266, #4495), and this change extends TraceFacts. Cost to build: about 150 lines and 10 tests, about 1.5M tokens and 4 hours. Cost to keep: one field, one record key, one prompt line.
Key questions
- Is the given set a separate field of
TraceFacts, or part ofpaths?: A separategivenfield._same_pathaccepts any path of a set by suffix. A path that only a tree entry, an identifier match, an index line, a manifest, a registry place or a stage fact names would let every claim on it pass. The read evidence stays inpaths. A wholepathentry supports a claim on the path and on anypath:Nof it. Apath:Nentry supports only that line. (best practice) [sources: src/devops_cli/roadmap/agent_run.py:649, src/devops_cli/roadmap/stage/stage_change.py:2442, src/devops_cli/roadmap/stage/stage_change.py:2448, src/devops_cli/roadmap/stage/stage_change.py:2454]- Chosen: A separate
givenfield onTraceFacts. The gate keeps the text of the final request apart from the read evidence. A claim on given text passes. A claim on a cut line stays refused. - Rejected: Merge the given paths into
paths._same_pathaccepts any path of the set by suffix. A path from a tree entry, an identifier match, an index line, a manifest, a registry place or a stage fact would let every claim on it pass.
- Chosen: A separate
- From which text is the
givenset built?: The finalcontexttext of the request, after the cap and after_requestappends the registry places and the stage facts. A section that holds a file's whole text adds the path. For a file that the cap cut, only thepath:Nentries of the numbered lines that remain join. A tree entry, an identifier match, an index line, a manifest, a registry place or a stage fact only names a path and adds none. (best practice) [sources: src/devops_cli/roadmap/refine/refine.py:1174, src/devops_cli/roadmap/refine/refine.py:1190, src/devops_cli/roadmap/stage/stage.py]- Chosen: The final request context after the cap and the added sections. The set matches what the model can read. A claim on a line that the cap cut stays refused. A registry place or a stage fact adds no path.
- Rejected: The context before the cap. A claim on a line that the cap cut would pass. A registry place or a stage fact would not count.
- Which claim form does the gate accept for given text?: A separate form,
the request context holdspath``, beside the read form. Line 10 ofsrc/devops_cli/ai/tasks/roadmap_stage_change.mdnames both forms. (best practice) [sources: src/devops_cli/ai/tasks/roadmap_stage_change.md:10, src/devops_cli/roadmap/stage/stage_change.py:2454]- Chosen: A separate given-text form beside the read form. A claim on given text is true and needs no read. The read form keeps its meaning of a tool call.
- Rejected: Use the read form for given text. It would state a tool read that the run never made. The audit of the trace would be false.
- Where does a kept plan record keep its
givenset?: InPlanFactsand in the kept plan record.PlanFacts.ofkeeps only the entries that the feasibility text cites, as it does forpathsandlines. The record key already holds the prompt version. This change edits the prompt, so a record of the old gate is not reused. A revision of a kept plan uses thegivenset of its own commit. (best practice) [sources: src/devops_cli/roadmap/stage/stage_plan_record.py:53, src/devops_cli/roadmap/stage/stage_plan_record.py:69, src/devops_cli/roadmap/stage/stage_plan_record.py:79]- Chosen: Store the set in
PlanFactsand the record, under the key that holds the prompt version. A revision reads the set of the commit that the plan judged. The prompt edit changes the key, so an old record is not reused. - Rejected: Recompute the set from the current request at each revision. A revision would judge the old claims against a different request.
- Chosen: Store the set in
- How does a context code block give its line numbers?: Each
### Code:block states its range in the heading and gives each line as<N>: <text>, the format ofread_file, from the real first line of the sliced range. (best practice) [sources: src/devops_cli/roadmap/refine/refine.py:1174, src/devops_cli/roadmap/refine/refine_investigation.py:346, src/devops_cli/roadmap/refine/refine_investigation.py:368]- Chosen: Numbered lines in the
read_fileformat, with the range in the heading. The planner can citepath:line:textfrom the request and needs no second read. - Rejected: Keep the raw text with no numbers. The planner reads a line range again for the numbers. That is the cost this change removes.
- Chosen: Numbered lines in the
- What do
read_issueof the own item andread_specwith no capability answer?: The name of the request field that holds the text:bodyfor the own item, andcapabilitiesfor aread_specwith no capability. When the cap cut the body,read_issuegives the full body fromissue_body. The stage tools need the own item number and the request body held for the item. (best practice) [sources: src/devops_cli/roadmap/stage/stage_tools.py:343, src/devops_cli/roadmap/stage/stage_tools.py:406, src/devops_cli/roadmap/stage/stage.py]- Chosen: Name the request field that holds the text. The text is already in the request. The call returns no new text and costs no tokens.
- Rejected: Keep reading the issue or the registry. The call repeats text that the request holds. The sample shows 33 such calls.
- Which open items must deliver before this change starts?: chore(roadmap): hold incremental stage and implement work #6521 must close first: it is an open hold issue with no sub-issue and no
type/epiclabel, so the dependency rule of the roadmap holds this item back while it is open. The reply of 2026-11-20 freezes this item for the re-architecture tracker refactor(roadmap): re-architect stage and implement on Coder #6519, and a person closes chore(roadmap): hold incremental stage and implement work #6521 when the experiments decide, or closes this item as not planned. fix(roadmap): the stage gate log names each refused claim #5433 has merged. fix(roadmap): the plan context lists the ADRs in force, not ADR 0001-0005 #5465 and feat(roadmap): planners and implement read the target AGENTS.md #4650 changecollect_context, so their pull requests must not stack with this one, but neither must merge first. [sources: docs/roadmap/refine.md:24, openspec/specs/roadmap-refine/waits/spec.md:229] - Does the stage eval replay see the trace gate today?: Yes, for one case, but it drops the match lines and the given set.
stage_eval_cases.pyloadstrace.jsonintofacts.tracewhen a case folder holds it. The 3205 case holdstrace.jsonwith emptytoolsandpaths, and its plan claims aread_fileofsrc/devops_cli/commands/roadmap.py. The replay refuses that claim.stage_eval_gates.pybuildsTraceFactsfromtoolsandpathsonly, andTraceFactholds nolinesorgiven, so no case passes a line or a given set. [sources: tests/fixtures/roadmap_eval/stage/3205-a-plan-that-cites-a-read-its-run/trace.json, tests/fixtures/roadmap_eval/stage/3205-a-plan-that-cites-a-read-its-run/plan.json, src/devops_cli/roadmap/stage/stage_eval_cases.py:169, src/devops_cli/roadmap/stage/stage_eval_gates.py:133]
Fit
Fits in one pull request.
Suspected block
None.
Activity
dan-petty commentedon Nov 13, 2026
Both address the trace gate refusing valid evidence, but the candidate adds request text as a source while 4463 fixes citation-form parsing of tool calls.devops-cli-service commentedon Nov 17, 2026
Alternatives check: none
Reason: The searches found only general LLM-output evaluation libraries, RAGAS and DeepEval, which score whether an answer's claims are supported by retrieved context with a model judge. None of them decides which
path/path:lineclaims the final request text and the tool-call trace support, numbers the context code lines, or keeps agivenset in the plan record, so the stage trace gate stays project code as the issue states.Tool: none found
Lacks:
### Code:block in theread_fileformatread_issueand no-capabilityread_specnaming the request fieldfacts.traceandfacts.givenTools considered:
Searches run:
Sources:
Checked on 2026-11-17. A person decides what this means for the item. The check changes no label and closes no issue.
devops-cli-service commentedon Nov 18, 2026
Status set to Ready at 9be129e (see proposed design in issue body).
Moved to new items: #6240.
dan-petty commentedon Nov 20, 2026
Frozen on 2026-11-20. The stage, implement and fix-checks jobs grade under 60%, so the owner rule asks for a re-architecture before more fixes inside the current design (tracker #6519). This item is incremental work on those jobs, so its Dependencies section now names #6521 first. Stage and implement leave this item while #6521 is open. When the experiments of #6519 decide, a person closes #6521 (this item can then continue) or closes this item as not planned.
devops-cli-service commentedon Nov 27, 2026
Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies in the section Proposed design of the body.
dan-petty commentedon Nov 30, 2026
Triage under #6519 (owner instruction of 2026-11-30), before the hold #6521 closes. This item adds or extends a gate, refusal, screen, cap, limit, retry, result line, shell allowlist, tool catalog or plan-shape rule of the stage, implement or fix-checks job. #6519 found that 263 of about 900 issues in four weeks added such rules and none replaced the engine. Stage now runs on stock Coder (grade 60 on 30 graded attempts), where the agent reads the repository, runs the checks in its loop and has a real shell; implement follows (#6527). The code paths that this item names have also moved. If the failure class still shows in graded attempts, file a new item from that evidence. Closed as not planned; a person may reopen it.