Skip to content

fix(roadmap): the ADRs in force fill the alternatives ADR budget #5049

Description

@dan-petty

Problem Description

The ADRs in force fill the ADR budget of the alternatives check. On origin/main 87ae9ee, the 22 ADRs in force hold 8,183 tokens of titles, status notes and Considered Options. The cap CONST_ROADMAP_ALTERNATIVES_MAX_ADR_TOKENS is 8,192 (src/devops_cli/config/constants.py:3387). So 9 tokens are left. The next ADR, or a longer status note or option, makes fit_to_budget (src/devops_cli/roadmap/adr.py:157) leave out the oldest ADRs that do not fit, first ADR 0001. The check then cannot cite them, and it logs only a warning. No test or check fails when the real ADRs go over the cap.

The comment of the constant says "The 17 ADRs of this repository hold about 6,000 tokens of options". That is no longer true.

Reproduction Steps

  1. Check out origin/main.
  2. Run adr_of and _superseded of src/devops_cli/roadmap/adr.py over docs/adr/*.md, and join the entry of each ADR in force with blank lines.
  3. Count the tokens with devops_cli.ai.context_budget.count_tokens.

Expected vs Actual Behavior

Environment Diagnostics

origin/main 87ae9ee, 2026-11-12. The change of #4792 keeps the count at 8,183, because it adds no status note at the top of an ADR and keeps the token count of its changed options.

Logs, Traces, or Terminal Output

in force: 22 tokens: 8183 kept: 22
ADR 0021: 890, ADR 0018: 657, ADR 0010: 654, ADR 0014: 566, ADR 0016: 543, ADR 0005: 536

Proposed fix

Raise the cap within the limit that tests/roadmap/test_roadmap_limit_classes.py:753 sets (an eighth of the planner window), or change what an entry holds. Add a test that reads docs/adr/ and fails when the ADRs in force leave less than a set margin under the cap. Update the comment of the constant.

Pre-Submission Checklist

  • I have verified that no sensitive credentials, private keys, or internal tokens are contained in this issue report.
  • I have checked existing issues and pull requests to ensure this is not a duplicate.

Source: #4792

Alternatives check of 2026-11-25: none.
Tool: none found.
Reason: Searches returned only unrelated MDN pages; the ADR tooling found (adr-tools, log4brains) creates and renders records, and none measures entry token size against a repo constant cap or guards the cut.

Lacks:

  • No measurement of ADR entry token size
  • No headroom guard against a repo constant
  • No report of which ADR a budget cut drops
  • No test wired to docs/adr/ contents

Proposed design

Problem statement

The ADRs in force use more tokens than CONST_ROADMAP_ALTERNATIVES_MAX_ADR_TOKENS allows. fit_to_budget then leaves out ADR 0001, ADR 0004 and ADR 0005, and the alternatives check cannot cite them. The check logs a warning only, and no test fails before an ADR merge makes the cut. The fix raises the cap to hold the ADRs in force with a margin and adds a guard test that fails first.

Acceptance criteria

Requirement: ADR budget headroom

The value of CONST_ROADMAP_ALTERNATIVES_MAX_ADR_TOKENS SHALL exceed the token count of the ADRs in force by at least 1,000 tokens.

Scenario: The ADRs in force leave the margin

  • WHEN The guard test in tests/roadmap/test_roadmap_adr.py reads each ADR in force of docs/adr/, joins its entry with blank lines, and counts the tokens with count_tokens.
  • THEN The test passes only when the cap minus the total is at least 1,000 tokens, and its failure message names each ADR that fit_to_budget leaves out.

Requirement: Limit-class ceiling

The cap MUST stay at or below the ceiling that its limit class declares in tests/roadmap/test_roadmap_limit_classes.py.

Scenario: The limit class accepts the raised cap

  • WHEN The test tests/roadmap/test_roadmap_limit_classes.py runs over the roadmap constants with the raised cap.
  • THEN The test passes, and its message names the cap and the ceiling of the class.

Requirement: Guard fails on low headroom

The guard helper SHALL fail and name each dropped ADR when the ADRs in force leave less than 1,000 tokens under the cap.

Scenario: A new ADR takes the headroom

  • WHEN The guard test calls its helper with ADR entries that leave 900 tokens under the cap.
  • THEN The helper reports a failure that names the ADR that fit_to_budget would leave out.

Requirement: Constant comment

The comment of CONST_ROADMAP_ALTERNATIVES_MAX_ADR_TOKENS SHALL state the number of ADRs in force, their token count and the 1,000-token margin.

Scenario: The comment matches the ADRs

  • WHEN The guard test counts the ADRs in force of docs/adr/ and reads the count and the total in the comment of the constant in src/devops_cli/config/constants.py.
  • THEN The count and the total in the comment equal the measured values, and the test fails when the comment states another count.

Existing Tool Considered

The alternatives check of 2026-11-25 in the issue body records verdict none and names no tool. Its block lists what the candidates lack. So no open, maintained tool covers a repo-internal ADR token budget and its guard. The change builds its own code: one constant value, its comment and one guard test. Written cost: about 20,000 tokens to build, keep and fix the guard and the comment until the tests pass, and about 2 hours.

Key questions

  • Where do the cap constant and the ADR functions live at the refined commit?: CONST_ROADMAP_ALTERNATIVES_MAX_ADR_TOKENS is at src/devops_cli/config/constants.py:3881, and adr_of is at src/devops_cli/roadmap/adr.py:206. fit_to_budget is in the same module. The line numbers in the issue body are stale. [sources: src/devops_cli/config/constants.py:3881, src/devops_cli/roadmap/adr.py:206, src/devops_cli/roadmap/adr.py]
  • Does the cap already leave out ADRs in force?: Yes. The replies measure 28 records in force at main 8e99f1d, and fit_to_budget keeps 25. ADR 0001, ADR 0004 and ADR 0005 stay out, so the fix must restore them and not only stop a later cut. [sources: src/devops_cli/config/constants.py:3881, src/devops_cli/roadmap/adr.py]
  • Should the fix raise the cap or shorten the entry of each ADR?: Raise the cap and keep each entry whole. The Considered Options text of an ADR is the evidence that confirms a rejected verdict, so a shorter entry weakens the check. (best practice) [sources: openspec/specs/roadmap-alternatives/spec.md, src/devops_cli/roadmap/adr.py]
    • Chosen: Raise the cap within the limit class. Keeps every ADR in force citable and changes one constant and one test.
    • Rejected: Shorten the Considered Options of each ADR. Removes the text that confirms a rejected verdict and edits accepted records.
    • Rejected: Keep the cap and accept the cut. Leaves out ADR 0001 and others with only a warning, which is the defect.
  • Which value should the cap take?: Set the cap to the token total of the ADRs in force plus 1,000, rounded up to the next 100 tokens. The guard test computes the same total from docs/adr/, so the plan carries no stale number. With the 28 records of main 8e99f1d the value is about 10,000 tokens. (best practice) [sources: src/devops_cli/config/constants.py:3881, tests/roadmap/test_roadmap_limit_classes.py, tests/roadmap/test_roadmap_adr.py]
    • Chosen: The measured total plus 1,000, rounded up to 100. The smallest value that holds the margin, so the other slices of the request keep their room.
    • Rejected: Keep 8,192 tokens. It already leaves out three ADRs in force.
    • Rejected: 9,422 tokens, the earlier value. The ADRs in force hold about 8,958 tokens, so it leaves under 1,000 tokens of margin.
    • Rejected: The ceiling of the limit class. It takes the whole allowance of one slice and can crowd the body and comment slices.
  • What headroom should the guard test require?: Require 1,000 tokens. The margin is larger than one ordinary ADR entry, which the replies measure between 114 and 536 tokens. (best practice) [sources: src/devops_cli/roadmap/adr.py, tests/roadmap/test_roadmap_adr.py]
    • Chosen: 1,000 tokens. Leaves room for two or more new ADRs and is a plain number to assert.
    • Rejected: The size of the largest entry in force. The margin then moves with the tree, and one large ADR fails the guard.
    • Rejected: 10 percent of the cap. Gives about the same margin with a number that is harder to read.
    • Rejected: No margin. The guard then fails only after the cut already leaves out an ADR.
  • Where does the guard test live?: In tests/roadmap/test_roadmap_adr.py, beside the tests of adr_of and count_tokens. (best practice) [sources: tests/roadmap/test_roadmap_adr.py]
    • Chosen: The existing module. The tests of the ADR functions and of count_tokens already live there.
    • Rejected: A new tests/roadmap/test_adr_budget.py. Splits the tests of one module over two files.
    • Rejected: The tests/invariants/ tree. That tree holds citation invariants of the ADRs, not the budget of the check.
  • What should the comment of the constant state?: State the number of ADRs in force, their token total, the cap and the 1,000-token margin rule. The guard test compares the numbers in the comment with its own measurement. (best practice) [sources: src/devops_cli/config/constants.py:3881]
    • Chosen: State the count, the total and the margin. The old count of 17 ADRs and about 6,000 tokens is false, and the reader needs the current numbers.
    • Rejected: Remove the numbers. The reader then cannot tell how near the cap the ADRs are.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

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

    @dan-petty
    OwnerAuthor
  4. added
    priority/p2-medium
    on Nov 12, 2026
  5. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor

    The budget is now over the cap. On origin/main 2e6f407, the 22 ADRs in force hold 8,422 tokens (adr_of, _superseded and count_tokens over docs/adr/). fit_to_budget with the cap 8,192 keeps 21 ADRs and logs: "The ADRs of the repository do not fit the cap of 8192 tokens: the alternatives check leaves out ADR 0001." PR #5060 does not change this count (8,422 before and after).

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

    @devops-cli-service
    Contributor

    Waiting for the alternatives check to run. The next refine round looks at the item again after the check records a verdict.

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

    @devops-cli-service
    Contributor

    The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.

    Searches (2)

    Tools considered:

    Searches run:

    • tool to enforce token budget for documentation files in repository CI, results: 5
    • open source library check documentation token count limit architecture decision records, results: 5

    Sources:

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

    @devops-cli-service
    Contributor

    Status set to Ready at 4624bc7 (see proposed design in issue body).

  10. 1 remaining item

  11. dan-petty commented on Nov 22, 2026

    @dan-petty
    OwnerAuthor

    New measurement of the ADR budget (CONST_ROADMAP_ALTERNATIVES_MAX_ADR_TOKENS = 8,192), with adr_of and fit_to_budget of src/devops_cli/roadmap/adr.py over docs/adr/*.md:

    • main 8e99f1d: 28 records in force. fit_to_budget keeps 25 and leaves out ADR 0001, ADR 0004 and ADR 0005.
    • Branch of docs(adr): give the repository settings to devops repos onboard #6788 (ADR 0035, entry of 251 tokens): 29 records in force. fit_to_budget keeps 26 and leaves out ADR 0004, ADR 0005 and ADR 0006. The records from ADR 0035 down to ADR 0007 hold 8,044 tokens, and ADR 0006 needs 327.

    Each new record that supersedes no record now pushes one more old record out of the check.

  12. devops-cli-service commented on Nov 26, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See the section Proposed design of the body.

  13. added
    owner/agent
    status/in-progress
    and removed
    status/ready
    on Nov 29, 2026
  14. added
    status/in-review
    and removed
    status/in-progress
    on Nov 29, 2026
  15. removed
    status/in-review
    owner/agent
    on Nov 29, 2026
  16. devops-cli-service commented on Nov 29, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-29 16:17 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/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions