feat(rules): declarative recommendation rule pack#5
Open
primeobsession wants to merge 1 commit into
Open
Conversation
Shared rule pack consumed by both prx_spec's validator and prxhub's validate_bundle tool. YAML catalog is the cross-language source of truth for rule IDs, bands (warning vs recommendation), categories, and messages. Each implementation owns its check logic but emits the same IDs for the same conditions, so users get identical advice from every surface. Changes: - src/prx_spec/rules/recommendations.yaml — 17 rules across 5 categories (naming, optional_field, content, coverage, query_specificity). - src/prx_spec/rules/loader.py — YAML parser with a cached load + frozen Rule / RulePack / RuleHit dataclasses. - src/prx_spec/rules/checks.py — Python check implementations keyed by rule id. Pure functions over BundleData. - src/prx_spec/bundle/validator.py — LevelResult gains a third band (recommendations: list[str]) alongside errors and warnings. _validate_l1 runs the pack at the end and populates the bands. Additive — recommendations never flip passed; existing callers reading only errors keep working. - pyproject.toml — add pyyaml>=6.0 runtime dep. - tests/test_rule_pack.py — 21 tests covering loader, every rule trigger, clean-bundle noise floor, and backward-compat guarantees. Verified: 196 tests pass (175 existing + 21 new). Related: docs/AGENT-NATIVE-PATH.md in prx-ecosystem; the prxhub PR picks up the same rule pack via vendored YAML. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Shared rule pack consumed by both
prx_spec's validator and the upcomingvalidate_bundletool in prxhub. YAML catalog is the cross-language source of truth for rule IDs, bands, categories, and messages; each implementation owns its check logic and emits the same IDs for the same conditions.Part of the cross-repo initiative tracked in prx-ecosystem PR #5 / docs/AGENT-NATIVE-PATH.md. This is PR #1 of that sequence (spec §6 step 1).
Changes
src/prx_spec/rules/recommendations.yaml— 17 rules across 5 categories (naming, optional_field, content, coverage, query_specificity).src/prx_spec/rules/loader.py— YAML parser with cached load + frozenRule/RulePack/RuleHitdataclasses.src/prx_spec/rules/checks.py— Python check implementations keyed by rule id. Pure functions overBundleData.src/prx_spec/bundle/validator.py—LevelResultgains a third band (recommendations: list[str]) alongsideerrorsandwarnings._validate_l1runs the pack at the end and populates the bands. Additive — recommendations never flippassed; existing callers reading onlyerrorskeep working.pyproject.toml— addspyyaml>=6.0runtime dep.tests/test_rule_pack.py— 21 tests covering loader, every rule trigger, clean-bundle noise floor, and backward-compat guarantees.Test plan
uv run pytest tests/— 196 pass (175 existing + 21 new). Zero regressions.feat/draft-api) will consume the YAML via a vendored copy and emit the same rule IDs from its TS validator. Parity verified by fixture.🤖 Generated with Claude Code