Repository navigation
feat: add opt-in terminology register guards - #2013
Merged
Merged
Conversation
18 of 19 tasks
gerchowl
added a commit
that referenced
this pull request
Nov 3, 2026
) ## Description Document authors can review unregistered terminology with `glossary-candidates` and `just glossary-candidates`. Advisory JSON lines provide locations, per-file counts, original-source context and the closest canonical term with a similarity score. Candidate discovery subtracts registered names, aliases and part numbers case-insensitively. The blocking terminology scan preserves code boundaries: backticks become spaces, so code-adjacent plurals and prefixes cannot hide violations. Registered occurrences protect exact, sentence-case and title-case forms unless an explicit casing rule forbids a derived form; ALLCAPS forms require explicit line suppression. Protection applies when a registered span crosses an edge of the forbidden hit or contains it; a registered word contained inside a forbidden phrase does not disable that rule. ## Type of Change - [x] `feat` -- New feature - [x] `fix` -- Bug fix - [x] `docs` -- Documentation - [x] `test` -- Regression and precision fixtures ### Modifiers - [ ] Breaking change (`!`) ## Changes Made - Discover title-case phrases, CamelCase, part numbers and ALLCAPS acronyms from tracked Markdown/Typst sources. Join across single line breaks while respecting block/name-line boundaries, trim stopwords at both ends, and retain joined names alongside conjunction splits (overridable with `--allow`). - Filter headings, Markdown table headers, links/URLs, backtick code, underscore identifiers, citations, YAML frontmatter, labeled signatures, Typst strings/link labels, common acronyms and numeric standards. - Add case-insensitive `--stopwords` and `--allow` controls; allow takes precedence and can restore standards prefixes such as EN. - Preserve original-source offsets/context and line breaks through masking and markup removal. Report unreadable sources and continue scanning, with correctly named diagnostics. - Cache nearest-term results across files and use difflib upper-bound prefilters before full comparisons, preserving scores and lexical tie order. Include reproducible repeated-name and distinct-name benchmarks. - Reject dead rules; protect exact, sentence-case and title-case canonical/alias spans across simple emphasis; retain the longest overlapping forbidden rule and earliest tie. Expand brace alternatives before source-pathspec splitting and warnings. - Document candidate triage: synonym of X → use the canonical term; new term → add it to glossary.yaml in this PR. Discovery stays advisory with no blocking hook. ## Changelog Entry ### Added - **Advisory glossary candidate discovery** ([#1994](#1994)) - Add JSON-line candidate reports and a just recipe for terminology review, with measured precision fixtures. - Reject dead rules, protect registered words across simple inline markup and partial overlaps, deduplicate overlapping hits, and clarify source diagnostics. - Preserve forbidden rules containing registered names; filter candidate markup/code noise, join wrapped names, retain source context, and allow extra stopwords. - Cache and prefilter nearest-term comparisons; report measured precision, recall and benchmarks. - Preserve code and markup word boundaries; protect exact, sentence-case and title-case names, and bound emphasis scanning. - Give explicit casing corrections precedence over derived sentence/title-case protection across the register. - Retain joined conjunction names alongside split candidates, honor allow overrides, and filter common sentence-start connectives. ## Testing - [x] Targeted tests: 231 passed (exit 0). - [x] RED committed before implementation: 18 failed/160 passed (exit 1). Each of the seven requested casing pairs failed with the forbidden rule on either the same entry or another entry, plus all four new stopword cases. - [x] All seven forbidden spellings now return 1; each literal canonical spelling returns 0. The round-4 sentence/title-case examples still return 0. - [x] Removing the Markdown leading word guard fails the new `pre**input pump**` test (1 failed/8 passed, exit 1). Allowing emphasis to span a newline fails its new regression (1 failed, exit 1). The previous M9 closing-guard mutation remains covered. - [x] The 102 KB unclosed-markup test retains its workload with a three-second bound for busy runners. `uv run --with pytest-xdist pytest packages/vig-utils/tests/test_glossary.py tests/test_typst_docs.py tests/test_typst_reconcile.py -n 4 --basetemp=$HOME/.cache/devkit-pytest/1994c-r5-green` ### Manual Testing Details The reviewed precision/recall corpora continue passing their >=75% thresholds. The lowercase `service manifold` remains an intentional heuristic miss. These fixture thresholds are not arbitrary-prose accuracy claims. The earlier benchmark scripts remain available in `packages/vig-utils/tests/benchmark_glossary.py` and `benchmark_nearest.py`. Repository hooks run inside `nix develop` without bypasses. Container-dependent and Nix-evaluation suites are left to CI. No merge or workflow dispatch. ## Checklist - [x] My code follows the project's style guidelines - [x] I have performed a self-review of my code - [x] I have commented the non-obvious behavior - [x] I have updated documentation (NIX.md is maintained directly) - [x] I have updated CHANGELOG.md under Unreleased and pasted the entry above - [x] My changes generate no unexpected warnings or errors - [x] I have added tests proving the feature and fixes - [x] New and existing targeted unit tests pass locally - [x] Dependent changes have been merged (#2013) ## Additional Notes Extraction is a documented lexical heuristic. Nested markup, complex links, non-pipe tables and unusual name/standard formats require reviewer judgment. Conservative name-line boundaries can separate wrapped names. Names appearing only in filtered regions are intentionally missed. This round updates the already-reviewed feature on the same branch and PR. Simple emphasis is limited to one line and 1,024 content characters to bound scanning cost. No merge or workflow dispatch. CI is green on round-5 pushed head `f8207bdb82c1bc354bdce807bd7a92d34f01fa48`: [run 41687813051](https://github.com/vig-os/devkit/actions/runs/41687813051). All checks, including Test Summary, project tests, image/integration tests, BATS, flake gates, consumer matrix, lint, security and CodeQL, passed. The CI watcher exited 0; no rerun was required. Local isolated basetemps were removed. No merge or workflow dispatch. Refs: #1994
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.
Description
Document-oriented consumers can keep canonical terminology and part numbers in a YAML register. The opt-in docs module installs schema validation and tracked-source checks that reject forbidden variants with their replacements and report unknown numbers in registered part families. Registered terms and aliases remain valid, including casing corrections such as Github → GitHub and us → US.
Type of Change
feat-- New featuretest-- Adding or updating testsdocs-- DocumentationModifiers
!)Changes Made
glossary-guard schema|terms, and document a release-tagged schema URL for editors.Changelog Entry
Added
Testing
838b5e9f4d3fa4dd55badc49cb548f6375e66065: 3,556 project tests passed, 80% coverage; image, integration, security, consumer, BATS, and flake gates passed.uv run --with pytest-xdist pytest packages/vig-utils/tests/test_glossary.py tests/test_typst_docs.py tests/test_typst_reconcile.py -n 4 --basetemp=$HOME/.cache/devkit-pytest/1994b-r3Manual Testing Details
The regression tests were committed before implementation; the RED run showed 28 failures (exit 1). Focused mutation checks then killed all nine requested mutation families: removed duplicate-ID validation, missing configured register accepted, hidden-directory scanning, parent-path escape, unanchored suppression, weakened uniqueItems/minLength, schema mode scanning, and YAML source suffixes. The performance test uses 1,000 forbidden variants against 20,000 prose lines, checks at most two forbidden-pattern compilations, and has a generous 10-second bound.
Commit hooks cover formatting, documentation, security lint, licenses, and scaffold synchronization. Container and Nix-evaluation suites run in CI rather than locally, as required by the task brief.
Checklist
Additional Notes
An absent default register is a no-op. A configured missing register fails. Schema mode never scans sources; terms mode with a nonempty register requires a Git working tree and has no non-Git fallback. Source checks do not parse markup or discover synonyms. Hyphens are literal, not whitespace separators. Candidate discovery, its recipe/workflow, and Typst package helpers remain separate phases.
Remaining external check: Home Matrix macOS was cancelled before any test steps after 15 minutes. GitHub reports "The job was not acquired by Runner of type hosted even after multiple attempts" and macOS arm64 capacity constraints. The Linux Home Matrix check passed.
Refs: #1994