Repository navigation
fix(scripts): refuse layer names that share a mermaid id, and mark the count-word tripwire a BUG invariant - #484
Merged
Conversation
…e count-word tripwire a BUG invariant
Contributor
File size check0 over a hard cap (fails), 1 warning(s).
Split the file, wrap the line, shorten or exempt the comment, or list the path in 5 managed file(s) skipped; repo-platform owns them. |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The validation is centralized, deterministic, and covered by focused tests.
Review effort: Balanced
Findings: None
What changed in this PR
Prevents Mermaid node-ID collisions during architecture parsing and clarifies countWord() overflow as a programming invariant.
Changes:
- Rejects layer names that normalize to the same Mermaid ID.
- Reuses one ID-normalization helper for validation and rendering.
- Prefixes count-word overflow errors with
BUG:and updates tests.
| File | Description |
|---|---|
.github/scripts/arch-lint.ts |
Adds Mermaid ID collision validation and shared normalization. |
.github/scripts/lib/count-word.ts |
Marks unsupported counts as BUG invariants. |
test/architecture/architecture.test.ts |
Tests colliding layer-name rejection. |
test/scripts/count-word.test.ts |
Updates invariant error expectations. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Before
Mermaid draws those two lines as one node. Nothing refused the declaration.
After
How
mermaidId()serves both the renderer and the refusal, so the two cannot drift apart.parseArchitecture()groups layer names by that id and returns one problem per shared id, beside the other declaration problems.countWord()keeps its throw with aBUG:prefix, and its header states that every caller counts a code-derived list.countWord()a number read from a page (the section registry's length,MAX_RETRIES,closed.length).Proof
test/architecture/architecture.test.tsandtest/scripts/count-word.test.ts, 27 green (1 new case), both changed cases seen red before the fix.lint:archon the committedarchitecture.yml, andbuild:docsidempotent.Technical details
build/markdown-regions,roundTrip()callsrender(parse(body)), so a page whose count sentence lists 21 code spans reachescountWord(21)through the parse path.parseCountSentence()ingen-action-docs.tsrefuses a count past the word table with a Result naming the line, before rendering reaches the throw.architecture.ymlholds no layer name with_, so no pair collides andreadArchitecture(ROOT)still parses.arch-lint.ts+26 / -8 (the two helpers and their use in the renderer),count-word.ts+4 / -3, tests +15 / -3..github/scripts/{arch-lint.ts,lib/count-word.ts},test/{architecture/architecture.test.ts,scripts/count-word.test.ts}.