Skip to content

spec: JSON schema, CI validation, and doc rewrite#12

Merged
aaliboyev merged 1 commit into
mainfrom
spec-schema-and-docs
May 20, 2026
Merged

spec: JSON schema, CI validation, and doc rewrite#12
aaliboyev merged 1 commit into
mainfrom
spec-schema-and-docs

Conversation

@aaliboyev
Copy link
Copy Markdown
Member

Summary

  • Add schemas/symbol.spec.schema.json — strict draft-2020-12 schema for per-package spec.toml files, matching exactly what _load_package_spec accepts. additionalProperties: false everywhere so typos fail loudly.
  • Add 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).
  • Rewrite 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.
  • Add Makefilemake validate, make test, make lint, make audit, etc., so contributors don't have to memorize uv invocations.
  • Declare jsonschema in the dev extra (it was sitting in uv.lock since Add JSON schema for symbol config #9 but never in pyproject.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.filenames instead of patterns), and crashes on invalid severity strings (patterns.decoratorsSeverity("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)
  • Confirmed the schema rejects every issue in PR Add spec.toml for aiogram configuration #11 by path (name, category, checkers.orphan.filenames, checkers.side_effects.calls.patterns, checkers.side_effects.patterns.decorators)
  • make help lists targets cleanly

Follow-ups (not blocking)

  • Submit both symbol.spec.schema.json and symbol.config.schema.json to SchemaStore for editor autocomplete.
  • The header comment block in src/wyolet/symbol/data/spec.toml still mentions the legacy [packages.NAME] shape — small cleanup PR.

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).
@aaliboyev aaliboyev merged commit 2dc7f6c into main May 20, 2026
1 check passed
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