Skip to content

feat: add opt-in terminology register guards - #2013

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

gerchowl merged 6 commits into
devfrom
feature/1994-glossary

Conversation

@gerchowl

@gerchowl gerchowl commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

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 feature
  • test -- Adding or updating tests
  • docs -- Documentation

Modifiers

  • Breaking change (!)

Changes Made

  • Ship the JSON Schema with vig-utils, expose glossary-guard schema|terms, and document a release-tagged schema URL for editors.
  • Reject duplicate YAML keys, duplicate IDs, ambiguous registered names, cross-entry forbidden aliases, unknown replacements, invalid regex/flags, empty-matching patterns, and numbers inconsistent with their own pattern.
  • Preserve registered term/alias spans and handle casing corrections separately; compile forbidden variants into one alternation per case mode. Match across Unicode whitespace and hard wraps, with underscore prose boundaries.
  • Scan only tracked Markdown/Typst sources selected by Git pathspecs; exclude hidden/generated paths, report non-UTF-8 files individually, and support file-type-specific end-of-line suppression markers. Code spans and fences are scanned.
  • Scope known part numbers to entries sharing an identical pattern, deduplicate unknown-token reports, and exclude URL spans.
  • Add reversible docs-module hooks through the shared hook definition and scaffold reconciler; preserve register/source settings across upgrades.
  • Include jsonschema and its runtime dependencies in every image/toolchain through vig-utils, sharing the editor/hook structural-validation contract. Hook activation and scanning remain opt-in.
  • Verify image venv isolation directly even when the toolchain already supplies the probe package.

Changelog Entry

Added

  • Opt-in terminology register checks (#1994)
    • Validate glossary YAML and reject forbidden names and unknown part numbers in document sources.
    • Preserve registered names and casing corrections, scan tracked prose across whitespace, and reject ambiguous registers.
    • Include jsonschema and its runtime dependencies in all images/toolchains via vig-utils, sharing the editor and hook schema validator; docs hooks remain opt-in.

Testing

  • Targeted tests pass locally: 123 passed (exit 0).
  • Main CI and Test Summary pass on head 838b5e9f4d3fa4dd55badc49cb548f6375e66065: 3,556 project tests passed, 80% coverage; image, integration, security, consumer, BATS, and flake gates passed.
  • Glossary tests after strengthening the suffix regression: 70 passed (exit 0).
  • Manual testing performed (see below).

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-r3

Manual 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

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly
  • I have updated CHANGELOG.md under Unreleased
  • My changes generate no new warnings or errors
  • I have added tests that prove the feature works
  • New and existing targeted tests pass locally
  • Any dependent changes have been merged and published

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

@gerchowl
gerchowl merged commit 2f919a8 into dev Nov 3, 2026
17 of 18 checks passed
@gerchowl
gerchowl deleted the feature/1994-glossary branch November 3, 2026 15:30
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
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