Skip to content

fix(keywords): fail loudly when a scanner tier is unregistered or contradicts grammar.js#38

Merged
dpezto merged 2 commits into
mainfrom
fix/tier-registration-check
Jul 25, 2026
Merged

fix(keywords): fail loudly when a scanner tier is unregistered or contradicts grammar.js#38
dpezto merged 2 commits into
mainfrom
fix/tier-registration-check

Conversation

@dpezto

@dpezto dpezto commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Adding a scanner tier without updating SYMBOL_TIER has broken the dictionary generator twice — KW_FILTER_IF, then KW_G_ARGV — both times on the very change that introduced the tier. The existing unmapped-symbol assert did catch it, but only after mining, and it named the affected keyword (unmapped scanner symbol for by) rather than the file to edit.

SYMBOL_TIER stays hand-written rather than derived. The tier genuinely is in grammar.jsalias($.kw_g_argv, "arg") is exactly the mapping — but kw_dt and kw_lt each carry two aliases (dt/opt and lt/opt), so deriving would have to guess, and a guess writes a plausible dictionary with a wrong tier instead of failing. Convention-based derivation fails too: KW_G_ARGV must map to arg, not argv.

Three checks, all running before mining so they fire at the source rather than downstream:

  • Missing symbol — every KW_* referenced by the scanner tables must appear in SYMBOL_TIER; the error names the file, the map's line, and the line to add.
  • Wrong tier — for any symbol with exactly one alias in grammar.js, SYMBOL_TIER must agree with it. The alias is authoritative, so a contradicting hand-written entry is a silent dictionary defect that nothing previously caught.
  • New multi-alias — the two deliberately multi-aliased tokens are listed explicitly rather than computed as "anything with more than one alias". A computed rule would silently absorb the next such token and weaken the check without a decision; instead a third one fails the build and forces the call. For the two listed, SYMBOL_TIER must still be one of that token's actual aliases, so a tier that is neither is caught.

All three failure modes were verified by deliberately breaking each in turn and confirming the message points at the fix. keywords.json regenerates byte-identical.

Runs inside the existing keywords CI job, whose first step is node scripts/gen-keywords.mjs — so these fire there, ahead of the git diff --exit-code keywords.json sync check.

Copilot AI review requested due to automatic review settings July 25, 2026 08:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added the size/l large — read carefully label Jul 25, 2026
@codecov

codecov Bot commented Jul 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@dpezto
dpezto merged commit 37de22d into main Jul 25, 2026
11 checks passed
@dpezto
dpezto deleted the fix/tier-registration-check branch July 25, 2026 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/l large — read carefully

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants