Repository navigation
Description
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
- Check out
origin/main. - Run
adr_ofand_supersededofsrc/devops_cli/roadmap/adr.pyoverdocs/adr/*.md, and join theentryof each ADR in force with blank lines. - Count the tokens with
devops_cli.ai.context_budget.count_tokens.
Expected vs Actual Behavior
- Expected: the ADRs in force fit the cap with a margin, and a check fails before an ADR merge makes the alternatives check leave out an ADR.
- Actual: 8,183 of 8,192 tokens are used. One more ADR, such as docs(adr): record the owner decisions on what agents may do #4787, leaves out ADR 0001 and more, with only a log warning.
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.pyreads each ADR in force ofdocs/adr/, joins itsentrywith blank lines, and counts the tokens withcount_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_budgetleaves 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.pyruns 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_budgetwould 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 insrc/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_TOKENSis atsrc/devops_cli/config/constants.py:3881, andadr_ofis atsrc/devops_cli/roadmap/adr.py:206.fit_to_budgetis 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_budgetkeeps 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 Optionstext of an ADR is the evidence that confirms arejectedverdict, 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 Optionsof each ADR. Removes the text that confirms arejectedverdict 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 ofadr_ofandcount_tokens. (best practice) [sources: tests/roadmap/test_roadmap_adr.py]- Chosen: The existing module. The tests of the ADR functions and of
count_tokensalready 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.
- Chosen: The existing module. The tests of the ADR functions and of
- 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
dan-petty commentedon Nov 12, 2026
Both concern the alternatives check and ADRs, but #3505 makes the check read ADRs while the candidate fixes the token budget that limits how many ADRs fit.dan-petty commentedon Nov 12, 2026
The budget is now over the cap. On
origin/main2e6f407, the 22 ADRs in force hold 8,422 tokens (adr_of,_supersededandcount_tokensoverdocs/adr/).fit_to_budgetwith 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).devops-cli-service commentedon Nov 16, 2026
Waiting for the alternatives check to run. The next refine round looks at the item again after the check records a verdict.
devops-cli-service commentedon Nov 18, 2026
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:
Sources:
devops-cli-service commentedon Nov 18, 2026
Status set to Ready at 4624bc7 (see proposed design in issue body).
1 remaining item
dan-petty commentedon Nov 22, 2026
New measurement of the ADR budget (
CONST_ROADMAP_ALTERNATIVES_MAX_ADR_TOKENS= 8,192), withadr_ofandfit_to_budgetofsrc/devops_cli/roadmap/adr.pyoverdocs/adr/*.md:fit_to_budgetkeeps 25 and leaves out ADR 0001, ADR 0004 and ADR 0005.fit_to_budgetkeeps 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.
docs(adr): give the repository settings to devops repos onboard (#6788)
devops-cli-service commentedon Nov 26, 2026
Next step: the stage job writes the plan of the item. See the section Proposed design of the body.
fix(roadmap): raise ADR budget cap to preserve 1000-token headroom (#…
chore(main): release 0.247.0 (#7752)
devops-cli-service commentedon Nov 29, 2026
Released in v0.247.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.247.0
devops-cli-service commentedon Nov 29, 2026
Live since 2026-11-29 16:17 UTC