Skip to content

fix(roadmap): the plan context lists the ADRs in force, not ADR 0001-0005 #5465

Done

Description

@dan-petty

Problem or Motivation

collect_context (src/devops_cli/roadmap/refine/refine.py:966-973) puts the first 5 files of docs/adr in name order into the context of every stage, fix-plan and refine item:

  • The five files are ADR 0001-0005, about 4.8k o200k tokens. With CONTEXT.md (5.4k) they use about 10.3k of the 20,480 cap of the stage context (51%).
  • They come before the item content, and the cap cuts from the end. In the stage comment sample, 47 of 54 items are at the cap, and 131 of 323 cited files survive it.
  • ADR 0002 and ADR 0003 are superseded, but they are in every context. The ADRs that replace them are not.
  • devops-cli has 25 ADRs, and 21 are in force. A one-line index (number and title) of the 21 is about 418 tokens.
  • The planner reads files of docs/adr with a tool in 5 of 54 items.
  • feat(roadmap): planners and implement read the target AGENTS.md #4650 says that the selection of ADRs by relevance is a different item. No issue covers it.

Proposed Solution & Architectural Design

  1. Replace the five full ADR files with a one-line index of the ADRs in force: ADR NNNN: <title>, sorted by number, under one heading, at the same place in context.
  2. Build the index from the files of the staged commit with adr_of and Adr.in_force of src/devops_cli/roadmap/adr.py. Do not parse the status again.
  3. The planner reads a full ADR with read_file when it needs one. The index heading says so in one line.
  4. The trace gate never counts an index entry as a read of the ADR file.

The change frees about 4.4k of the cap for item content. The input of each request does not change at the cap: the freed room fills with cited code.

Target Subsystem

SDLC, Git & PR Governance: src/devops_cli/roadmap/refine/refine.py (collect_context), src/devops_cli/roadmap/adr.py.

Existing Tool Considered

The ADR front matter and adr.py already give the status and the title, and the alternatives check uses them (#5049). No tool is necessary. Cost to build: about 0.4M tokens and 1 hour, about 25 lines and 3 tests.

Acceptance Criteria

  • Test first: for a checkout with a superseded ADR and two ADRs in force, the context holds one index line for each ADR in force, no line for the superseded ADR, and no full ADR text.
  • A test: a stage claim to have read an ADR that only the index names is refused.
  • Measure: rebuild collect_context for the 54 item bodies of the sample, before and after. Give the kept cited files (baseline 131 of 323). devops roadmap eval stage --replay keeps every known-bad plan refused.
  • Live proof after release: on real Service stage runs for 7 days, no context holds a superseded ADR, and the docs/adr reads for each item stay near the baseline (5 of 54 items).

Dependencies

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-23: none.
Tool: none found.
Reason: Searches found only ADR documentation generators — adr-viewer, log4brains and adr-tools — which build browsable sites or an unfiltered table of contents. None filters by in-force status or emits a one-line index for the plan context from the staged commit.

Lacks:

  • No one-line index of ADRs in force, sorted by number
  • No filter on status, superseded-by or amended-by front matter
  • No reuse of the repository's adr.py at the staged commit
  • No trace-gate check that the planner read the ADR file
  • Renders HTML sites or unfiltered tables, not prompt text

Proposed design

Problem statement

collect_context puts the full text of ADR 0001-0005 in every stage, fix-plan and refine context. ADR 0002 and ADR 0003 are superseded, and the five files use about 4.8k tokens before the item content. The cap then cuts cited code. The change replaces those files with one line for each ADR in force at the staged commit. The planner reads a full ADR with read_file, and the trace gate refuses a claim that only the index supports.

Acceptance criteria

Requirement: ADR index replaces full ADR files

collect_context SHALL replace the first five full ADR files with one line ADR NNNN: <title> for each ADR in force at the staged commit.

Scenario: Superseded ADR is left out

  • WHEN The test calls collect_context at a staged commit whose docs/adr holds one superseded ADR and two ADRs in force.
  • THEN The context holds two index entry lines of the form ADR NNNN: <title> in ascending order, no line for the superseded ADR, and no ADR body text.

Requirement: Amended ADR stays in the index

The index MUST include an ADR whose front matter holds amended-by and no superseded-by.

Scenario: Amended ADR is in force

  • WHEN The test calls collect_context at a staged commit whose docs/adr holds an ADR with status: accepted, an amended-by list and no superseded-by.
  • THEN The context holds one index entry line of the form ADR NNNN: <title> for that ADR, and the line holds the title of its front matter.

Requirement: Index heading names read_file

The context ADR index MUST start with one heading line that names read_file and the docs/adr path.

Scenario: Planner sees the read instruction

  • WHEN The test calls collect_context at a staged commit with at least one ADR in force.
  • THEN The line before the index entries holds read_file and docs/adr, and the context holds no second heading for the index.

Requirement: No index without an ADR in force

collect_context MUST emit no ADR line and MUST NOT raise when the staged commit holds no ADR in force.

Scenario: Every ADR is superseded

  • WHEN The test calls collect_context at a staged commit whose docs/adr holds only superseded ADRs.
  • THEN The context holds no ADR NNNN: line and no index heading, and the call returns the rest of the context.

Requirement: Trace gate refuses an index-only ADR claim

The stage trace gate MUST refuse a claim to have read an ADR path when the trace holds no read_file span for that path.

Scenario: No file read span for the ADR

  • WHEN The test gives the gate a trace that claims docs/adr/0001-github-is-the-roadmap-source.md and holds no read_file span for that path.
  • THEN The gate returns a refusal that names docs/adr/0001-github-is-the-roadmap-source.md.

Requirement: Replay keeps known-bad plans refused

The change MUST keep every known-bad stage plan refused in devops roadmap eval stage --replay.

Scenario: Replay of known-bad plans

  • WHEN The test runs uv run devops roadmap eval stage --replay.
  • THEN The command reports every known-bad plan refused.

Existing Tool Considered

The alternatives check of 2026-11-23 in the issue body records verdict none and names no tool. It found only ADR documentation generators, and the block lists what they lack. No open, maintained tool covers the need. The change builds its own code: about 25 lines in src/devops_cli/roadmap/refine/refine.py and 3 tests, at about 0.4M tokens and 1 hour.

Key questions

  • Which source supplies the ADR status and title for the index?: collect_context calls adr_of and Adr.in_force at the staged commit. It emits one ADR NNNN: <title> line for each ADR in force, sorted by ADR number, and parses no status itself. (best practice) [sources: src/devops_cli/roadmap/adr.py:189, src/devops_cli/roadmap/adr.py, src/devops_cli/roadmap/refine/refine.py:1057, tests/roadmap/test_roadmap_adr.py, tests/roadmap/refine/test_roadmap_refine_context.py]
    • Chosen: Reuse adr_of and Adr.in_force. The front-matter reader already holds the status and the title, so one source of truth supplies both.
    • Rejected: Parse the status in collect_context. A second parser duplicates adr.py and can drift from the front matter.
    • Rejected: Keep the first five ADR files. It includes superseded ADRs and spends the context cap on full text.
  • Where does the index go in the context, and what does its heading say?: The index replaces the five ADR files at the same place in context. One heading line says that the list holds the ADRs in force. The same line says that the planner calls read_file on a docs/adr path for the full text. (best practice) [sources: src/devops_cli/roadmap/refine/refine.py:1057, CONTEXT.md]
    • Chosen: One heading line before the index. The planner sees the instruction once and the index stays small.
    • Rejected: The index with no heading. The planner then has no instruction to read a full ADR.
    • Rejected: One heading line for each ADR entry. It repeats the instruction and spends the tokens that the change frees.
  • What does collect_context emit when no ADR is in force?: It emits no heading and no ADR NNNN: line. It returns the rest of the context with no error. (best practice) [sources: src/devops_cli/roadmap/refine/refine.py:1057]
    • Chosen: Emit no index and no heading. An empty list with a heading spends a line and tells the planner nothing.
    • Rejected: Emit the heading with no entry. The heading sends the planner to docs/adr for an ADR that is not there.
  • How does the trace gate treat an index line?: The gate requires a read_file span for the ADR path. An index line alone is not a read of the ADR file, and the gate refuses the claim. (best practice) [sources: src/devops_cli/roadmap/stage/stage_probe.py, tests/roadmap/stage/test_roadmap_stage_trace_subject.py]
    • Chosen: Require a read_file span for the ADR path. It checks the tool call that the planner must make for a full ADR.
    • Rejected: Count an index line as a read. It lets a claim pass with no file read.
    • Rejected: Drop the ADR read check. It removes a gate that catches a false claim.
  • Is feat(roadmap): planners and implement read the target AGENTS.md #4650 a dependency of this item or only a merge order?: It is a dependency. Issue feat(roadmap): planners and implement read the target AGENTS.md #4650 edits collect_context, so this pull request rebases on main after feat(roadmap): planners and implement read the target AGENTS.md #4650 merges and stacks no second pull request. (best practice) [sources: src/devops_cli/roadmap/refine/refine.py:1057, CONTEXT.md]
    • Chosen: Deliver after feat(roadmap): planners and implement read the target AGENTS.md #4650 merges and rebase on main. The two changes edit the same function, and one rebase on main resolves the one conflict.
    • Rejected: Stack the pull requests. A stacked pull request merges a change that its base branch does not hold yet.
    • Rejected: Make both changes in one pull request. One pull request delivers one item.
  • Which of the five ADRs in the current plan context are in force at the checked commit?: ADR 0002 and ADR 0003 hold status: superseded, so they are not in force. ADR 0001, ADR 0004 and ADR 0005 hold status: accepted; ADR 0001 has only amended-by and stays in force. The index reads every file at the staged commit and includes each ADR that Adr.in_force accepts. [sources: docs/adr/0001-github-is-the-roadmap-source.md, docs/adr/0002-roadmap-jobs-act-as-a-machine-account.md, docs/adr/0003-polling-is-how-the-roadmap-sees-changes.md, docs/adr/0004-ci-is-the-authoritative-gate.md, docs/adr/0005-review-findings-come-from-tools-not-models.md, src/devops_cli/roadmap/adr.py]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#4650

Moved to new items

#7005

Activity

  1. added
    source/agent
    type/bug
    scope/roadmap
    status/new
    value/high
    effort/low
    on Nov 13, 2026
  2. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor
  3. added
    priority/p2-medium
    on Nov 13, 2026
  4. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Alternatives check: none

    Reason: The searches found only general ADR documentation generators — adr-viewer and log4brains — which build a browsable HTML site or knowledge base from ADR files. Neither produces the compact one-line index of the ADRs in force that collect_context needs, filters out superseded ADRs, nor connects an index entry to the trace gate, so the small change to the existing adr.py front-matter reader is not covered by a tool.

    Tool: none found

    Lacks:

    • A token-frugal one-line index of ADRs in force for the stage/refine context
    • Filtering by Adr.in_force and building from the staged commit via adr_of
    • Trace-gate handling that refuses a claim to have read an ADR only named by the index

    Tools considered:

    Searches run:

    • adr-tools log4brains adr-viewer generate ADR index from markdown front matter, results: 5
    • tool to generate index of Architecture Decision Records with status and superseded filtering, results: 5
    • "adr-viewer" python package, results: 5
    • log4brains Architecture Decision Records tool, results: 5
    • adr-tools, results: 5
    • adr-viewer GitHub mrwilson architecture decision records HTML, results: 5

    Sources:

    Checked on 2026-11-17. A person decides what this means for the item. The check changes no label and closes no issue.

  5. devops-cli-service commented on Nov 18, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 9be129e while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.

    The next refine round also looks at the item again when a commit on the default branch changes one of these files: src/devops_cli/roadmap/refine/refine.py.

  6. devops-cli-service commented on Nov 20, 2026

    @devops-cli-service
    Contributor

    Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies and Watched files in the section Proposed design of the body.

  7. added
    status/ready
    and removed
    status/new
    on Nov 24, 2026
  8. devops-cli-service commented on Nov 24, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See Moved to new items in the section Proposed design of the body.

  9. added
    owner/agent
    status/in-progress
    and removed
    status/ready
    on Nov 25, 2026
  10. added
    status/in-review
    and removed
    status/in-progress
    on Nov 25, 2026
  11. removed
    status/in-review
    owner/agent
    on Nov 25, 2026
  12. devops-cli-service commented on Nov 25, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-25 07:43 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/lowpriority/p2-mediumscope/roadmapsource/agenttype/bugvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions