Skip to content

feat(glossary): discover candidates and refine terminology checks - #2014

Merged
gerchowl merged 10 commits into
devfrom
feature/1994-glossary-candidates
Nov 3, 2026
Merged

gerchowl merged 10 commits into
devfrom
feature/1994-glossary-candidates

Conversation

@gerchowl

@gerchowl gerchowl commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

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

  • feat -- New feature
  • fix -- Bug fix
  • docs -- Documentation
  • 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)
    • 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

  • Targeted tests: 231 passed (exit 0).
  • 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.
  • All seven forbidden spellings now return 1; each literal canonical spelling returns 0. The round-4 sentence/title-case examples still return 0.
  • 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.
  • 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

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented the non-obvious behavior
  • I have updated documentation (NIX.md is maintained directly)
  • I have updated CHANGELOG.md under Unreleased and pasted the entry above
  • My changes generate no unexpected warnings or errors
  • I have added tests proving the feature and fixes
  • New and existing targeted unit tests pass locally
  • Dependent changes have been merged (feat: add opt-in terminology register guards #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. 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

@gerchowl
gerchowl merged commit ecc70cd into dev Nov 3, 2026
16 checks passed
@gerchowl
gerchowl deleted the feature/1994-glossary-candidates branch November 3, 2026 17:58
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