Skip to content

fix(roadmap): the plan check fails a citation of a line that moved #3422

Closed

Description

@dan-petty

Problem or Motivation

The evidence of a staged plan goes stale between refine and stage. The plan of PR #3400 (for #3394) cites _plan_texts at src/devops_cli/roadmap/stage_change.py:534, and the two fields at :381 and :383. At the plan base main cbc3efc, _plan_texts is at line 551 and the fields at lines 398 and 400. The plan copied the numbers from the refine record, which read a different commit.

A reader who opens a cited line finds another function or another field. The ## Feasibility section is the proof that the premise holds, so a line that moved makes the proof false even when the premise is true. This plan passed every check, and only a reading of the diff found it. The stale citation is also in the issue's refine block, so the defect repeats in each plan that cites a line that the refine step read.

Proposed Solution & Architectural Design

  1. In check_proposal of src/devops_cli/roadmap/stage_change.py, scan feasibility, why and what_changes for a citation of the form path:line:text. Read the staged tree at that line and refuse the plan when the line does not hold text, or when the path or the line is absent. The problem names the field and the cited path.
  2. Prefer a symbol citation (path:def name) where a line is not needed, and let the check resolve the symbol in the staged tree. A symbol citation stays true when the code moves.
  3. Add a test in tests/roadmap/test_roadmap_stage_content.py that refuses a citation of a line that holds other text and accepts a citation of the line that holds the quoted text.

Target Subsystem

src/devops_cli/roadmap/stage_change.py (check_proposal, content_problems), tests/roadmap/test_roadmap_stage_content.py.

Existing Tool Considered

No open, maintained tool covers this repository-specific proof rule. The change extends the existing check_proposal text scan and adopts no new dependency. It builds about 4k tokens to implement, about 1k tokens per year to keep and fix, and about half a working day of elapsed time. It deletes no internal code.

Source: PR #3400 review

Proposed design

Problem statement

A staged plan cites path:line:text from a refine record that read another commit. The cited line holds another function or field, so the feasibility proof is false while the premise is true. check_proposal checks no citation, so the plan passes every check. The change resolves each citation against the staged tree, refuses a stale one, and prefers a symbol citation that survives a move.

Acceptance criteria

Requirement: Refuse a stale line citation

The plan check SHALL refuse a path:line:text citation when the cited line of the staged file does not hold the cited text.

Scenario: The line holds another text

  • WHEN feasibility holds src/sample.py:4:def f(): and line 4 of the staged src/sample.py holds def g():.
  • THEN check_proposal returns a problem that names feasibility and src/sample.py.

Requirement: Accept a true line citation

The plan check SHALL accept a path:line:text citation when the cited line of the staged file holds the cited text.

Scenario: The line holds the cited text

  • WHEN feasibility holds src/sample.py:4:def f(): and line 4 of the staged src/sample.py holds def f():.
  • THEN check_proposal returns no problem that names src/sample.py.

Requirement: Refuse a citation of an absent line

The plan check MUST refuse a citation when the staged reader returns no such path or the file holds no such line.

Scenario: The line number is past the end of the file

  • WHEN feasibility holds src/sample.py:99:def f(): and the staged reader returns the 10 lines of src/sample.py.
  • THEN check_proposal returns a problem that names feasibility and src/sample.py.

Requirement: Resolve a symbol citation

The plan check SHALL accept a path:def name or path:class name citation when the staged file defines the symbol at any line.

Scenario: The definition moved

  • WHEN feasibility holds src/sample.py:def f and the staged src/sample.py defines def f( at line 7.
  • THEN check_proposal returns no problem that names src/sample.py.

Requirement: Refuse an absent symbol

The plan check MUST refuse a symbol citation when the staged file holds no definition of the symbol.

Scenario: The file defines another symbol

  • WHEN feasibility holds src/sample.py:def f and the staged src/sample.py defines only def g(.
  • THEN check_proposal returns a problem that names feasibility and src/sample.py.

Requirement: Scan the three evidence fields

The plan check SHALL scan feasibility, why and each what_changes line for citations.

Scenario: A stale citation sits in what_changes

  • WHEN a line of what_changes holds a citation of a line that holds other text.
  • THEN check_proposal returns a problem that names what_changes and the cited path.

Requirement: Judge no citation without file text

The plan check SHALL judge no citation when it holds no text of the staged files.

Scenario: The replay passes no file text

  • WHEN check_proposal runs with no read_text callable and the plan holds a stale citation.
  • THEN check_proposal returns no problem for that citation.

Requirement: Compare with collapsed white space

The plan check SHALL compare the cited text with the staged line after it collapses white space in both.

Scenario: The spacing differs

  • WHEN feasibility holds src/sample.py:4:def f(): and line 4 holds def f():.
  • THEN check_proposal returns no problem that names src/sample.py.

Requirement: The prompt prefers a symbol citation

The stage prompt MUST tell the planner to cite a symbol instead of a line number when a line is not needed.

Scenario: The prompt states the symbol form

  • WHEN a test reads src/devops_cli/ai/tasks/roadmap_stage_change.md.
  • THEN the text holds the path:def name form and the instruction to prefer it.

Existing Tool Considered

No check has run. No open, maintained tool covers a repository-specific proof rule that reads a line of the staged tree. The change extends the existing check_proposal text scan and adopts no dependency. It builds about 4k tokens to implement, about 1k tokens per year to keep and fix, and about half a working day of elapsed time.

Key questions

  • Which function holds the citation rule, check_proposal or content_problems?: The rule goes in check_proposal, as a helper that it calls with the staged file text. check_proposal holds the staged tree. content_problems holds no tree, and the replay calls it with no file text. (best practice) [sources: tests/roadmap/test_roadmap_stage_content.py, src/devops_cli/roadmap/stage_change.py, docs/ROADMAP_WORKFLOW.md]
    • Chosen: Put the rule in check_proposal. It holds the staged tree, and the replay can call it without file text.
    • Rejected: Put the rule in content_problems. It has no staged tree, and the replay calls it with no file text, so it would refuse good recorded plans.
    • Rejected: Add a gate in stage_verify.py. It runs after the plan is written, so a stale citation would already be in the change folder.
  • How does the check read the text of a cited line?: check_proposal gets an optional read_text callable, and it defaults to None. The stage job passes a reader of the staged commit. A test passes a dict lookup. The replay passes none, so the rule judges nothing. (best practice) [sources: tests/roadmap/test_roadmap_stage_content.py, src/devops_cli/roadmap/stage_paths.py, docs/ROADMAP_WORKFLOW.md]
    • Chosen: An optional read_text callable on check_proposal. It reads only the cited paths, keeps the tests offline, and defaults to no judgement.
    • Rejected: Extend StagedTree with a text map. The tree is built from paths before the reply is parsed, so the caller must parse the citations twice.
    • Rejected: Read the file inside the check. The check would read the working tree, which is not the staged commit, and tests would need files on disk.
  • What citation form does the check accept, and how does it compare the text?: A citation is path:line:text, and the path holds a dotted file name. The check accepts it when the collapsed line holds the collapsed text, after it strips backticks and one trailing period. A text of fewer than 3 characters is refused. A path:def name or path:class name citation resolves a definition at any line. (best practice) [sources: tests/roadmap/test_roadmap_stage_content.py, src/devops_cli/roadmap/stage_change.py]
    • Chosen: Substring of the collapsed line. A citation of a fragment, such as def _plan_texts, holds, and trailing punctuation does not refuse it.
    • Rejected: Exact equality of the whole line. A citation of a fragment is refused, and a plan cites a fragment when the line is long.
    • Rejected: AST symbol lookup. It needs a parser for every language of a cited file.
  • Does a citation of an absent path or line fail the plan?: The check refuses a citation when the staged reader returns no line for it: the path is absent or the line number is past the end. It does this only when it holds file text. Without text, it judges nothing. (best practice) [sources: docs/ROADMAP_WORKFLOW.md, tests/roadmap/test_roadmap_stage_content.py]
    • Chosen: Refuse only when the check holds file text. The stage job refuses a false proof, and the replay keeps its no-code rule.
    • Rejected: Refuse always. The replay's thinned tree holds no text, so it would refuse good recorded plans.
    • Rejected: Report a warning only. The plan ships a false proof, which is the defect.
  • Which plan fields does the rule scan?: The rule scans feasibility, why and each line of what_changes. These are the evidence fields that the issue names. The other fields keep their current rules. (best practice) [sources: src/devops_cli/roadmap/stage_change.py, tests/roadmap/test_roadmap_stage_content.py]
    • Chosen: The three named fields. They are the evidence fields that the issue names.
    • Rejected: Every text of _plan_texts. It also scans pull_request_body and task texts, where a colon is not evidence.
    • Rejected: feasibility only. It misses why and what_changes, which the issue names.
  • Does the stage prompt ask for a symbol citation?: Add a rule to the stage prompt that prefers path:def name to a line number when a line is not needed. A test in tests/roadmap/test_roadmap_stage_prompt_rules.py reads the prompt text. The check still resolves a symbol, so a moved definition keeps the citation true. (best practice) [sources: src/devops_cli/ai/tasks/roadmap_stage_change.md, tests/roadmap/test_roadmap_stage_prompt_rules.py, docs/ROADMAP_WORKFLOW.md]
    • Chosen: Prompt rule and check. The model writes a symbol citation, and the check still refuses a stale line.
    • Rejected: Check only. The model keeps writing line numbers, and the check refuses a good plan after a move.
    • Rejected: Symbol citations only. A line number is the right evidence when no symbol names the code.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/bug
    scope/roadmap
    status/new
    value/medium
    effort/medium
    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/bug. The fix prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. The stale citation makes the feasibility proof false but does not block delivery or expose a security risk.
    • Value: Medium. It corrects a false proof in the plan gate, improving trust in staged plans.
    • Effort: Medium. The change touches one function and adds one test, about half a working day.
    • Related: fix(roadmap): Check a class claim against the staged source #3407, which asks for a different change. Both extend check_proposal to verify plan claims against the staged source, but 3407 verifies class-level factual claims while the candidate verifies that a cited line number still holds the quoted text.
  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. devops-cli-service commented on Nov 4, 2026

    @devops-cli-service
    Contributor

    Staged: branch fix/3422-the-plan-check-fails-a-citation, draft pull request #3439. 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:

    1. Resolve a plan citation against the staged tree: 25435 tokens
    2. Read the text of a cited file from the staged checkout: 26845 tokens
    3. Ask the planner for a symbol citation: 22825 tokens

    A model review of the plan found these open findings. The stage keeps this pull request a draft with the label plan/needs-fix until a later round clears them:

    • false_premise at feasibility, line 2: The plan calls line 551 stale and says the probe shows line 556. The issue says line 551 is the true line at the plan base. No probe in the input shows line 556. Evidence: "At the plan base main cbc3efc, _plan_texts is at line 551 and the fields at lines 398 and 400."
    • false_premise at feasibility line 3 and decisions (StagedTree reader): The plan says StagedTree.read keeps the checkout and that a callers method reads it. In stage_paths.py the visible read only lists files and builds a tree from paths, and __init__ stores no checkout. The plan quotes a change folder that is not in the input. Group 2 builds on a checkout that the tree does not hold. Evidence: "return cls(path for path in listing.split("\0") if path)"
    • spec_delta_wrong at specs, requirement Compare a citation with collapsed white space: The scenario is named "The spacing differs", but the cited text and the staged line are identical. No test can assert white space collapse from it. The issue's version uses def f(): in the citation. Evidence: "feasibility holds src/sample.py:4:def f(): and line 4 holds def f():."

    The plan run made 3 model request(s), and used 226032 input tokens and 18061 output tokens. The model made no tool call.

    The stage job read the open pull requests and their files in 1 GraphQL request(s).

  7. added 2 commits that reference this issue on Nov 4, 2026
  8. added
    status/planned
    owner/service
    status/in-progress
    and removed
    status/ready
    status/planned
    on Nov 4, 2026
  9. devops-cli-service commented on Nov 5, 2026

    @devops-cli-service
    Contributor

    Stopped at group 3.

    Failure class: refused_tool.
    Action taken: none.
    Action left: wait: wait for a person.

    Step Status Attempts Tokens in/out Last failing command
    group 1 done 1 4733053/34340 pytest on base: tests/roadmap/test_roadmap_stage_content.py
    group 2 done 1 3038213/12875 -
    group 3 stopped 1 343810/3068 -

    Reason:

    ModelTimeoutError: model deepseek-v4.1-flash-1017
    Refused commands: other 1. Other retries: 0.
    

    Last message of the agent (a claim that no check verified): none.

    The job discarded this work. Read it before you retry:

    diff --git a/tests/roadmap/test_roadmap_stage_prompt_rules.py b/tests/roadmap/test_roadmap_stage_prompt_rules.py
    index b9020bd0..666b46dd 100644
    --- a/tests/roadmap/test_roadmap_stage_prompt_rules.py
    +++ b/tests/roadmap/test_roadmap_stage_prompt_rules.py
    @@ -374,6 +374,37 @@ def test_the_prompt_holds_each_verify_form_that_the_config_gives() -> None:
         assert config_forms <= prompt_forms
     
     
    +# ── A citation of the staged file (#3422) ────────────────────────────────────
    +
    +
    +def _citation_rule() -> str:
    +    """The bullet of the prompt that gives the citation forms of the evidence fields."""
    +    (bullet,) = re.findall(r"- [^\n]*`path:line:text`[^\n]*", _PROMPT)
    +    return bullet
    +
    +
    +def test_the_prompt_gives_each_citation_form_that_the_check_resolves() -> None:
    +    """`check_proposal` reads a line citation as `path:line:text` and a symbol citation as
    +    `path:def name` or `path:class name` (#3422). The prompt names each form and the fields whose
    +    citations the check judges, so the planner writes a form that the check accepts."""
    +    rule = _citation_rule()
    +
    +    assert "`path:line:text`" in rule
    +    assert "`path:def name`" in rule
    +    assert "`path:class name`" in rule
    +    assert "`feasibility`, `why` and each line of `what_changes`" in rule
    +
    +
    +def test_the_prompt_asks_for_a_symbol_where_a_line_is_not_needed() -> None:
    +    """A line number goes stale when the code moves, and the symbol citation stays true (#3422).
    +    The prompt gives that reason, so the planner prefers the symbol."""
    +    rule = _citation_rule()
    +
    +    assert "cites a symbol as `path:def name` or `path:class name` instead of a line number" in rule
    +    assert "when a line is not needed" in rule
    +    assert "stays true when the line moves" in rule
    +
    +
     # ── A move of a name prefix (#3372) ──────────────────────────────────────────
     
     

    The item is Blocked, and the job will not run it. Fix the cause. Then comment implement: retry. The Service clears the stop on its own when a new runner image rolls out, but only if a retry can fix the class of the stop and the limits of roadmap.implement.digest_clears_per_class and roadmap.implement.digest_clears_per_item allow it.

  10. added
    status/blocked
    and removed
    status/in-progress
    on Nov 5, 2026
  11. devops-cli-service commented on Nov 5, 2026

    @devops-cli-service
    Contributor

    The runner Job devops-cli-runner-20261105-170201-254c ended: succeeded.
    Image digest: sha256:b8d75df68e94e9d4ee61e9e75dc0752cde409ccc66489f9dd6d459a82818109e

    The last lines of its log:

    Tool call: shell, started: uv run mypy --strict src/devops_cli/roadmap/stage.py
    Tool call: shell, program uv, ok.
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run devops ci test tests/roadmap/test_roadmap_stage_plan.py
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run devops roadmap eval stage ...
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run devops ci test tests/roadmap/test_roadmap_stage_apply.py ...
    Tool call: shell, program uv, ok.
    Tool call: grep, ok.
    Tool call: edit_file, ok.
    Tool call: read_file, ok.
    Tool call: shell, started: git diff
    Tool call: shell, program git, ok.
    Tool call: read_file, ok.
    Tool call: shell, started: git status --porcelain
    Tool call: shell, started: git diff HEAD --stat
    Tool call: shell, program git, ok.
    Tool call: shell, program git, ok.
    Tool call: shell, started: git log --oneline -3
    Tool call: read_file, ok.
    Tool call: shell, program git, ok.
    Tool call: shell, started: git show --stat HEAD
    Tool call: shell, program git, ok.
    Tool call: grep, ok.
    Tool call: shell, started: git log --oneline -3
    Tool call: read_file, ok.
    Tool call: shell, program git, ok.
    Tool call: read_file, ok.
    Tool call: grep, ok.
    Tool call: grep, ok.
    Tool call: grep, ok.
    Tool call: grep, ok.
    Tool call: shell, started: other
    Tool call: shell, program other, refused.
    Tool call: read_file, ok.
    Tool call: edit_file, ok.
    Failure class refused_tool. Action left: wait.
    ✓ Took 0 item(s) to a ready pull request, stopped 1.
    Elapsed: 34m 1s
    
  12. removed
    owner/service
    on Nov 5, 2026
  13. removed
    status/blocked
    on Nov 6, 2026
  14. devops-cli-service commented on Nov 6, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-06 06:16 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/mediumpriority/p2-mediumscope/roadmapsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions