spec: JSON schema, CI validation, and doc rewrite#12
Merged
Conversation
The per-package spec format used by the 237 bundled specs had no schema and docs/spec-schema.md still described the old monolithic [packages.X] shape, leaving contributors to guess. Result: PRs like #11 ship specs that crash the loader (KeyError: 'name') or silently no-op on unknown keys. - schemas/symbol.spec.schema.json: strict draft-2020-12 schema matching what _load_package_spec actually accepts, with additionalProperties: false so typos fail fast. - tests/test_spec_schema.py: validates all 237 bundled specs on every PR plus parametrized negatives for the common contributor mistakes. - docs/spec-schema.md: full rewrite against the per-file format with an aiogram-shaped worked example, severity enum, legacy aliases, and how-to- validate instructions. - Makefile: make validate / test / lint / audit so contributors don't have to memorize uv invocations. - pyproject.toml: declare jsonschema in dev extras (was leaking from uv.lock).
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.
Summary
schemas/symbol.spec.schema.json— strict draft-2020-12 schema for per-packagespec.tomlfiles, matching exactly what_load_package_specaccepts.additionalProperties: falseeverywhere so typos fail loudly.tests/test_spec_schema.py— walks all 237 bundled specs through the schema on every PR, plus parametrized negatives for the common contributor mistakes (missing required fields, wrong key names, invalid severity).docs/spec-schema.md— the old doc described the long-retired monolithic[packages.X]shape. New doc covers the per-file format with a worked example, severity enum, legacy-alias notes, and validation instructions.Makefile—make validate,make test,make lint,make audit, etc., so contributors don't have to memorizeuvinvocations.jsonschemain thedevextra (it was sitting inuv.locksince Add JSON schema for symbol config #9 but never inpyproject.toml).Why
PR #11 (aiogram spec) made it visible: the spec loader crashes with
KeyError: 'name'if required fields are missing, silently drops data on unknown keys (checkers.orphan.filenamesinstead ofpatterns), and crashes on invalid severity strings (patterns.decorators→Severity("decorators")ValueError). The author wasn't being careless — the only spec doc we had still described the old format. This PR fixes the doc, makes the contract machine-checkable, and runs the check in CI so future broken specs fail before review.Test plan
make validate-specs— 11/11 tests pass (all 237 bundled specs validate; all 6 common-mistake negatives reject correctly)name,category,checkers.orphan.filenames,checkers.side_effects.calls.patterns,checkers.side_effects.patterns.decorators)make helplists targets cleanlyFollow-ups (not blocking)
symbol.spec.schema.jsonandsymbol.config.schema.jsonto SchemaStore for editor autocomplete.src/wyolet/symbol/data/spec.tomlstill mentions the legacy[packages.NAME]shape — small cleanup PR.