Skip to content

fix(regenerate): stop writing ADR counts into the generated files - #26

Merged
kompiro merged 1 commit into
mainfrom
fix/drop-aggregate-counts
Aug 8, 2026
Merged

kompiro merged 1 commit into
mainfrom
fix/drop-aggregate-counts

Conversation

@kompiro

@kompiro kompiro commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Problem

regenerate writes aggregate ADR counts into the files it generates. A count is a property of the whole set, so two PRs that each regenerate against their own base produce headers that are individually correct and jointly wrong.

Git never flags it: the per-ADR rows sit on separate lines and merge cleanly. The stale count only shows up on the default branch after the merge, as a drift-check failure needing a fix-up commit.

Observed downstream in kompiro/karasu — two ADR PRs landed within a day of each other and main went red on adr regenerate --check, with a two-line diff that was purely the counts (karasu#2396).

Change

Drop the three counts that reach committed output:

where before after
effective.md header Auto-generated by …. 302 of 311 ADRs are currently status: accepted… Auto-generated by …. Lists the ADRs that are status: accepted…
graph.md header 311 ADRs across 15 topics. Clusters group by topic… Clusters group by topic…
graph.md per-topic links - [\renderer`](graph/renderer.md) — 70 ADRs` - [\renderer`](graph/renderer.md)`

Each sentence still says what the file is; only the numbers go. renderOverview no longer needs a per-topic tally, so its counting map becomes a plain sorted set of topics.

adr visualize keeps its count — that output goes to stdout as a query result, not into a versioned file, so it cannot drift.

Why not keep the counts and fix the race another way

  • Regenerating post-merge needs a bot writing to the default branch, which the downstream repo has deliberately avoided.
  • A merge queue would test the real merge result, but it requires an organization-owned repository, and the downstream repo is owned by a personal account.

Removing the only global value is the change proportional to the failure: the per-ADR rows were never the problem.

Tests

The replaced test now pins the absence of a count rather than its wording, so the header can be reworded later without letting a count quietly back in, plus a new one covering graph.md and its per-topic links.

pnpm test 142 passed, lint and typecheck clean.

Downstream

Needs a release before kompiro/karasu can pick it up (currently on ^0.0.10). Adopting it there is one dependency bump plus one pnpm adr:regenerate commit.

A count is a property of the whole ADR set, so two pull requests that each
regenerate against their own base produce headers that are individually correct
and wrong once merged. Git sees no conflict -- the per-ADR rows sit on separate
lines and merge cleanly -- so the stale count only surfaces on the default
branch afterwards, as a drift-check failure that needs a fix-up commit.

Drop the three counts that reach committed output: the 'N of M ADRs' header in
effective.md, the 'N ADRs across M topics' header in graph.md, and the '— N
ADRs' suffix on its per-topic links. The sentences still say what each file is.
Nothing global is written any more, so the drift cannot recur.

`adr visualize` keeps its count: that output goes to stdout as a query result,
not into a versioned file.

Tests pin the absence rather than the wording, so the header can be reworded
without silently letting a count back in.

Co-Authored-By: Claude Fable 5 <[email protected]>
@kompiro
kompiro merged commit 079625b into main Aug 8, 2026
1 check passed
@kompiro kompiro mentioned this pull request Aug 8, 2026
kompiro added a commit that referenced this pull request Aug 8, 2026
Releases #26 — regenerate stops writing ADR counts into effective.md and
graph.md, so two PRs regenerating against their own base can no longer leave a
stale aggregate on the default branch.

Co-authored-by: Claude Fable 5 <[email protected]>
kompiro added a commit to kompiro/karasu that referenced this pull request Aug 8, 2026
adr-tools 0.0.11 stops writing aggregate counts into the files `adr regenerate`
produces. A count is a property of the whole ADR set, so two PRs that each
regenerated against their own base left main with a header that was wrong in a
way git had no reason to flag -- it only surfaced afterwards as a drift-check
failure (#2396).

Regenerating removes the count from the effective.md header, the graph.md
header, and the '— N ADRs' suffix on graph.md's per-topic links. The links
themselves stay.

Progress is tracked outside these files, so nothing is lost by not storing the
numbers; `adr extract effective | wc -l` and `adr validate` still report them
on demand, and `adr visualize` keeps its count because that output is a query
result rather than a versioned file.

Refs kompiro/adr-tools#26

Co-authored-by: Claude Fable 5 <[email protected]>
kompiro added a commit that referenced this pull request Aug 9, 2026
#26 said it dropped "the three counts that reach committed output". There
were four. renderTopicMarkdown() still wrote "N ADRs in this topic" into
every docs/adr/graph/<topic>.md, and regenerate commits those, so they drift
the same way: two branches regenerating against different bases each write a
locally correct number and the merge keeps whichever landed last.

karasu already hit it — its PR #2406 conflicted on graph/build.md with
71 / 70 / 72, the #26 scenario verbatim, after 0.0.11. Fifteen committed
files there still carried a count.

`adr visualize` keeps its count, unchanged: that output is a stdout query
result, not a versioned file.

The tests missed it because they pinned absence file by file, for the two
files someone thought of. Replaced with a sweep over everything
buildGeneratedFiles returns, so a new output is covered by default rather
than by remembering, with a length guard so the sweep cannot pass vacuously.

Closes #29

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
@kompiro kompiro mentioned this pull request Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant