Skip to content

feat(rules): declarative recommendation rule pack#5

Open
primeobsession wants to merge 1 commit into
mainfrom
feat/rule-pack
Open

feat(rules): declarative recommendation rule pack#5
primeobsession wants to merge 1 commit into
mainfrom
feat/rule-pack

Conversation

@primeobsession
Copy link
Copy Markdown
Contributor

Summary

Shared rule pack consumed by both prx_spec's validator and the upcoming validate_bundle tool 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 + 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.pyLevelResult 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 — adds 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.

Test plan

  • uv run pytest tests/ — 196 pass (175 existing + 21 new). Zero regressions.
  • Follow-up PR in prxhub (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

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

2 participants