Repository navigation
Description
Problem or Motivation
The stage citation gate refuses a Feasibility citation path:N:text when line N of the staged file does not hold text ("The feasibility of the plan cites X, and the staged file holds no such text there."). Most of these citations are stale, not false: the planner copies a line number from another commit, and the text is still in the file at another line.
The study of the stage refusals of 2026-11-11 counted 41 stale citations. In 33 of them, the cited text matches exactly one line of the file at the staged commit. The gate refuses these plans and asks for a second reply, and the second reply often fails again.
This issue is out of scope of #4463, which fixes the citation forms that the trace gate reads.
Proposed Solution & Architectural Design
- When the text of a
path:N:textcitation is not at lineNbut matches exactly one line of the staged file, accept the citation as that line (re-anchor it), and do not refuse the plan. - When the text matches zero lines or more than one line, refuse the citation as now.
- Record how many citations the gate re-anchored, so a person can see the rate.
Target Subsystem
The roadmap stage job: the citation gate (_plan_citation_problems in src/devops_cli/roadmap/stage/stage_change.py).
Existing Tool Considered
The gate already reads the staged file (read_text) and already accepts path:def name at any line. No outside tool is needed: the change is a lookup of one line in a text that the gate already reads.
Standards Compliance
- I confirm this proposal aligns with AGENTS.md engineering principles.
- I am willing to submit a pull request implementing this feature with accompanying tests.
Proposed design
Problem statement
The stage citation gate refuses a path:N:text citation when line N does not hold text. In 33 of 41 stale citations, the text matches exactly one line of the staged file. These refusals are mostly stale line numbers, not false evidence. The change re-anchors a unique match, refuses zero or multiple matches, and records the re-anchor count.
Acceptance criteria
Requirement: Unique line match re-anchors
The citation gate SHALL accept a path:N:text citation when the text is absent at line N and matches exactly one line of the staged file.
Scenario: Unique match is accepted
- WHEN a plan cites
src/app.py:12:return valueandreturn valueoccurs only at line 40 ofsrc/app.pyat the staged commit - THEN
_plan_citation_problemsreturns no citation problem for that citation
Requirement: No unique line match refuses
The citation gate SHALL refuse a path:N:text citation when the text is absent at line N and matches zero lines or more than one line of the staged file.
Scenario: Zero or multiple matches are refused
- WHEN a plan cites
src/app.py:12:return valueandreturn valueoccurs at no line or at two lines ofsrc/app.pyat the staged commit - THEN
_plan_citation_problemsreturns the stale-citation problem for that citation
Requirement: Line N match stays accepted
The citation gate SHALL accept a path:N:text citation when line N of the staged file holds the text, even when another line also holds it.
Scenario: Line N wins
- WHEN a plan cites
src/app.py:12:return valueand line 12 and line 40 both holdreturn valueat the staged commit - THEN
_plan_citation_problemsreturns no citation problem and records no re-anchor
Requirement: Match keeps the current line test
The citation gate MUST count a line as a match when the normalized cited text occurs in the normalized line, as the current line check does.
Scenario: Partial line text is re-anchored
- WHEN a plan cites
src/app.py:12:return valueand only line 40 ofsrc/app.pyholdsreturn value = compute()at the staged commit - THEN
_plan_citation_problemsaccepts the citation as line 40
Requirement: Short text stays refused
The citation gate MUST apply the minimum cited-text length before it tries to re-anchor a citation.
Scenario: Short text is refused
- WHEN a plan cites
src/app.py:12:abandaboccurs at exactly one line ofsrc/app.pyat the staged commit - THEN
_plan_citation_problemsreturns the short-citation problem and records no re-anchor
Requirement: Re-anchor count is recorded
The citation gate SHALL write one log line for each plan run with the number of citations it re-anchored.
Scenario: Count is written
- WHEN a plan has two citations that each match exactly one other line of their staged file
- THEN the stage job log holds one line with the count 2
Existing Tool Considered
No alternatives check has run. The gate already reads the staged file through read_text and accepts path:def name at any line. No open, maintained tool or library covers a re-anchor inside this gate. The change builds on the existing reader. Written cost: about 25k tokens to build, 8k tokens to keep and fix, and about 3 hours.
Key questions
- Does the citation gate already read the staged file?: Yes.
_plan_citation_problemsreceives aread_textcallable, and_citation_problemsreads each cited path through it. [sources: src/devops_cli/roadmap/stage/stage_change.py:1362, src/devops_cli/roadmap/stage/stage_change.py] - Should the gate re-anchor a line citation that matches exactly one other line?: Yes. The gate accepts the citation as the unique matching line and records a re-anchor. (best practice) [sources: src/devops_cli/roadmap/stage/stage_change.py, AGENTS.md]
- Chosen: Re-anchor a unique match. The text is in the staged file, so the evidence is stale, not false. The gate already reads the file.
- Rejected: Refuse as now. It costs a second reply and often fails again, as the issue reports.
- Rejected: Fuzzy match several lines. It can accept the wrong line and weakens the gate.
- How does the gate decide that a line matches the cited text?: Use the current normalized containment test: the normalized cited text occurs in the normalized line. (best practice) [sources: src/devops_cli/roadmap/stage/stage_change.py]
- Chosen: Normalized containment. It preserves the current line check and changes only the line that the gate looks at.
- Rejected: Exact line equality. It would refuse a citation that quotes part of a longer line, which the current gate accepts.
- Rejected: Fuzzy text distance. It can accept a wrong line and adds a dependency.
- What does the gate do when zero lines or more than one line match?: Refuse the citation with the current stale-citation problem. (best practice) [sources: src/devops_cli/roadmap/stage/stage_change.py]
- Chosen: Refuse zero or multiple matches. Only one line gives an unambiguous target for the stale citation.
- Rejected: Re-anchor the first match. The first line is arbitrary and can cite the wrong code.
- Rejected: Re-anchor the closest line. Distance from the stale line is no evidence of the correct line.
- Where does the gate record the re-anchor count?: The gate writes one log line with the count for each plan run. (best practice) [sources: src/devops_cli/roadmap/stage/stage_change.py, AGENTS.md]
- Chosen: One log line from the gate. It keeps the count in the job log and needs no new return type or comment.
- Rejected: Stage comment. It changes the staged item comment and needs a wider change in the stage job.
- Rejected: Metric counter. It adds telemetry for a diagnostic count.
- Does the change need an outside tool or library?: No. The gate compares the cited text with lines of a file it already holds. A fuzzy-match library adds a dependency for no need. (best practice) [sources: AGENTS.md, src/devops_cli/roadmap/stage/stage_change.py]
- Chosen: Use the existing reader and text search. The gate already has the file text and the normalized cited text.
- Rejected: Add a fuzzy-match library. It adds a dependency and can accept a wrong line.
- Rejected: Build a separate citation index. It duplicates the file read and adds state for no need.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Alternatives check of 2026-11-11: none.
Tool: none found.
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.
featprefix of the title gives the type.(roadmap)scope of the title gives the scope.It reduces false refusals in the stage gate but does not block any pipeline; 41 of 41 stale cases are recoverable by re-anchoring.It removes a repeated failure mode that forces a second (often failing) reply from the planner.The gate already reads the staged file; the work is a linear scan for a unique match plus a counter and tests.Both target stale line citations in the stage plan check, but #3422 fixed a specific failed citation while the candidate adds a general re-anchoring rule and a re-anchor counter.devops-cli-service commentedon Nov 11, 2026
Status set to Ready at c3f62a9 (see proposed design in issue body).
devops-cli-service commentedon Nov 11, 2026
Alternatives check: none
Reason: Searches for a library that re-anchors or verifies
path:N:textcode citations returned no relevant tool, only unrelated documentation pages. The need is a linear scan for a unique line inside file text that the gate already reads throughread_text, so no open, maintained tool or library covers it.Tool: none found
Lacks:
path:N:textcitation as the unique matching line of the staged file.Searches run:
Checked on 2026-11-11. A person decides what this means for the item. The check changes no label and closes no issue.
dan-petty commentedon Nov 12, 2026
Scope from the content freshness plan (2026-11-11)
This issue is child 14 of #4880, the content freshness tracker. The scope grows from one stage-gate rule to one shared citation module.
Why
This issue adds a re-anchor rule only inside the stage gate (
_plan_citation_problemsinsrc/devops_cli/roadmap/stage/stage_change.py). The question resolver (#4808), brain add (#4671) and brain repair (#4687) also verify citations. Without one module, 4 copies of the parse, verify and re-anchor logic drift apart. The stage study counted 41 stale citations, and 33 of them match exactly one line.New scope
Build the rule as one citation module:
path:N:textcitation and the structured citation of docs(adr): keep reference docs in git as cited brain sources #4884:{path, commit, lines, span_hash, doc_class, generated_from?, adr_status?, as_of}.git show <sha>:<path>with 0 GitHub requests, else 1 contents GET.CONST_KB_SHA_DIGEST_LENGTH(16) hex characters.The stage gate uses the module first. Post one comment on #4808, #4671 and #4687 that names the module.
Acceptance added
Depends on: None (start now).
feat(roadmap): re-anchor a stale citation that matches one line
docs(openspec): put the 4479 delta in the roadmap-stage/trace-gate ca…
docs(openspec): archive 4479-re-anchor-a-stale-citation-that
devops-cli-service commentedon Nov 12, 2026
Released in v0.119.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.119.0
devops-cli-service commentedon Nov 12, 2026
Live since 2026-11-12 15:46 UTC