Repository navigation
fix(adr-index): read the whole ADR header block and fail when a regeneration drops a field - #31252
Merged
Merged
Conversation
The generator read `**Key**:` header fields only from a record's first 40 lines, so a status note grown past the window emptied the Supersedes cell of the regenerated index while every mode exited 0. - The header is now every line before the first heading after the title. A supersession blockquote counts only when `superseded` sits in a bold span, so ADR-0126's prose about a draft (line 44, hidden by the old window) does not become a Superseded-by cell. The regenerated index on main is byte-identical. - A Date, Supersedes or Superseded-by cell the committed index carried and the regeneration empties is a dropped field: --report and --check exit 1 on it, and the write mode writes the index and exits 1. Every other --report finding stays a warning with exit 0. - Two new self-test batteries (header block, dropped fields), the drift battery's report-exit pin rewritten; 60 assertions. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5of5Rharw5eu6Hvhes
Contributor
Author
|
domain:devx#3 · os-project-manager · session_01FEkQ5njkh3xbcDN6EtSfw7 席位核对Verdict: ACCEPT · head
Generated by Claude Code |
This was referenced Nov 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Leehom · project thread
domain:devx#3 · os-project-manager · session_01FEkQ5of5Rharw5eu6Hvhes
Fixes #30916
Clause-②: no
Metadata-protocol: none
维护者速读
scripts/adr-index.mjs不再只读 ADR 前 40 行找**Supersedes**:等字段,改为读到标题后第一个小节标题为止的整个头部;另外,若重新生成的目录会把已有的 Date / Supersedes / Superseded by 格子清空,--report、--check和写模式都以退出码 1 失败。其它发现(目录过期、状态行读不出)仍只警告、退出 0。Supersedes被挤到第 42 行,目录那一栏悄悄变成—,检查却照样通过。main上重新生成的目录逐字节不变。lint 的 ADR 步骤本来就由Lane verdict读结果,所以「清空一个格子」现在会让 CI 变红;回滚即还原本 PR。scripts/adr-index.mjs的headerBlock/isSupersessionNotice(解析)和droppedFields/reportExitCode(失败条件)。node scripts/adr-index.mjs --self-test && node scripts/adr-index.mjs --check,预期 60 条断言全绿、目录为最新。What changes
scripts/adr-index.mjsonly (+180 / −22). No other file;docs/adr/README.mdregenerates byte-identical.headerBlock(lines)is every line before the first heading after the title (the whole file when there is none).**Key**:fields (Date, Supersedes, Superseded by) and supersession blockquotes are read from it. A**Key**:line under a section heading is body prose.supersededin a bold span (isSupersessionNotice). Without that, the whole-block read misreads ADR-0126 (see Acceptance notes). The five cloud-owned notices and the ADR-0080/0081 amendment notes all state it in bold, so their cells stay as they are.droppedFields(committed, expected)compares the committed index's record rows with the regeneration, keyed by link target. A Date, Supersedes or Superseded-by cell that held a value and becomes—is a drop. A changed value, a filled cell and a removed row are not.verdict()now returnsdropped, and:--reportprints each drop as an::errorannotation and exits 1 (reportExitCode). A stale index, an unparsed record, unreadable registries and a red self-test still warn and exit 0 ([Decision] docs/adr: 143 ADRs with no index, four numbers used twice, 19 Proposed older than three months, three status-line spellings — how the registry gets put in order #26076, ruling A).--checkprints each drop; it already exits 1 on the stale index a drop implies.pnpm adr:index) writes the index, prints each drop and exits 1, so the author who regenerates sees it at once. A deliberate drop is one rerun away: the written index no longer carries the cell.return 0", is replaced by two pins: report exits 0 on every finding but a drop, andmodeReportexits only throughreportExitCode. The floor goes from 7 to 9 batteries; 46 → 60 assertions.Why
#30916: a status note grown past line 40 emptied ADR-0146's Supersedes cell, and every mode still exited 0. The card's Expected, first branch of each: read the whole header block, and fail when a regeneration would drop a field the previous index carried.
Tests
node scripts/adr-index.mjs --self-test→✓ adr-index --self-test: 60 assertions(headd8acb85f).Ablations: each new pin goes red when the old behaviour is put back (4 legs, all restored)
Run through
node scripts/ablation-replace.mjs(each leg: anchor x1 → x0, blob moved, thengit diff HEAD -- scripts/adr-index.mjsempty after restore; trap on EXIT restores fromHEAD):const header = headerBlock(lines);→lines.slice(0, 40)→ exit 1, 6 failures:supersedes-past-line-40-is-read,date-past-line-40-is-read,the-index-keeps-the-cell,a-supersession-notice-past-line-40-is-read,an-emptied-supersedes-cell-is-a-drop,verdict-carries-the-drop-and-report-exits-1.header.filter(isSupersessionNotice)→ the old/^>[ \t]*\*\*[^\n]*\bsuperseded\b/i→ exit 1,a-plain-prose-mention-is-not-a-notice.reportExitCode→return 0→ exit 1,verdict-carries-the-drop-and-report-exits-1.if (false)→ exit 1, 3 failures:an-emptied-supersedes-cell-is-a-drop,ui-date-and-superseded-by-drops-name-the-ui-file,verdict-carries-the-drop-and-report-exits-1.The card's incident replayed on the real registry (base vs this branch)
Copies of
docs/adr/andui/docs/adr/with seven lines added to ADR-0146's status note, which moves**Supersedes in part**from line 39 to line 46:5b22ee75): write mode exit 0, ADR-0146's Supersedes cell—(the card's failure).ADR-0126, ADR-0131, ADR-0005, ADR-0048, ADR-0141, ADR-0070, index unchanged.And the drop path on the real tree: hand-setting ADR-0123's Supersedes cell to
ADR-0099indocs/adr/README.mdgives--reportexit 1 (one::error file=docs/adr/0123-…mdline, plus the stale warning),--checkexit 1, write mode exit 1 naming the cell, and a rerun exit 0 with the index restored.Acceptance notes
docs/adr/andui/docs/adr/) were measured for where each**Key**:line and each supersession blockquote sits relative to line 40, the first heading and the first---:**Date**at line 43, before its first heading (53). It is now read. Its cell is unchanged because the status-line fallback already gave the same date, 2026-07-22.Supersedes the rev.9 …at line 216, under a heading. It is body prose and stays unread.---, says "A third draft of ADR-0131 marked this record Superseded". The old window hid it by accident. Read as a notice, it addsADR-0131to ADR-0126's Superseded-by cell, and the record says it is not superseded.---instead fixes ADR-0126 but dropsADR-0065from ADR-0080 and ADR-0081: their bold amendment notices ("superseded on styling") sit after---, at line 14.5b22ee75is byte-identical (node scripts/adr-index.mjs --check→ OK).docs/adr/README.md. A PR that regenerates and commits a drop passes the check, but the write mode already exited 1 for its author, and the emptied cell is in the README diff. Comparing against the base branch's index would need git history in the lint job; not done.ADR index is currentstep inlint.yml(idadr-index-current-report-only) iscontinue-on-error: true, andLane verdict(scripts/ci/lane-verdict.mjs) reads each gate step'soutcome. A drop's exit 1 therefore reds the lane andLint & Repo Gates. Rootci.ymlis untouched.lint.ymlgoes stale (outside this claim's file surface, so not edited). Lines 688–696 say "So the only red this step can show is a broken generator, never a record". After this PR, a dropped field also reds it. Named for the seat in the report'sopen_questions.Verification
Gate union derived by
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackon headd8acb85f(1 path, 31 commands), each exit captured before any pipe, reconciled with--ran:--ran: "31 derived famil(ies) accounted for — 31 run, 0 NOT-MEASURED". The slow ones:pnpm check:pm-dispatch-gates449 s,check-comment-mask-corpus.mjs205 s,check-self-test-workflow-commands.mjs144 s.pnpm check:adr-index(the step this PR hardens):✓ adr-index --self-test: 60 assertionsthenadr-index --report: OK — docs/adr/README.md is current, every record parsed.Plan Test Core shardsCI step and the type-check lanesdispatch-gatesnames as CI-only. This diff has no TypeScript. CI families are read from this PR's check-runs.pnpm lintscoped: no package touched;pnpm exec eslint --no-inline-config scripts/adr-index.mjsexit 0.skip-changeset:scripts/**ships in no package.Human Minimum
None; the seat lands it.
Generated by Claude Code