Skip to content

v0.3: YAML as source of truth for rule metadata (#1)#8

Merged
migmcc merged 2 commits into
mainfrom
feat/yaml-rules
Jun 21, 2026
Merged

v0.3: YAML as source of truth for rule metadata (#1)#8
migmcc merged 2 commits into
mainfrom
feat/yaml-rules

Conversation

@migmcc

@migmcc migmcc commented Jun 21, 2026

Copy link
Copy Markdown
Owner

Implements #1 — make the YAML the source of truth for rule metadata, with the detection logic staying in Python.

What changed

  • rules/pfmea_control_plan_rules.yaml now carries full metadata per rule: id, severity, title, message_template, description, rationale (version bumped to 1).
  • rules/__init__.py: parse_rule_specs() validates the metadata (clear RuleSpecError on missing id, missing required field, invalid severity, duplicate id, empty ruleset); load_rule_specs() reads + validates the packaged file.
  • modules/pfmea_control_plan.py: builds each Finding from the YAML severity + formatted message_template; the per-finding-type detection logic is unchanged. Not a generic rule engine.

Behaviour parity (hard requirement) ✅

Messages are byte-identical to v0.2; finding types, severities, count, score and verdict unchanged. Locked by new behaviour-parity tests:

  • seeded example → FAIL, score 43, 6 findings
  • clean case → PASS, score 100, no findings
  • warnings case → PASS-WITH-WARNINGS, 1 warning

Plus loader-validation tests (invalid severity, duplicate id, missing field/id, empty ruleset) and the existing consistency test.

Out of scope (unchanged)

No new rule engine, no change to scoring / matching / finding types / JSON schema; no CSV/UI/AI/PyPI/new modules.

Checklist

  • YAML carries full rule metadata
  • loader validates + fails clearly
  • checker reads severity + message from YAML
  • parity tests (example / clean / warnings) + loader tests
  • docs (ARCHITECTURE, FINDINGS, CHANGELOG)
  • ruff + pytest green (72 tests), CI green 4/4

Closes #1.

Scope v0.3 to making the YAML the source of truth for rule *metadata* (id,
severity, message template, description, rationale) while the per-finding-type
evaluation logic stays in Python. No generic rule engine; exact behaviour parity
required. ROADMAP gains a focused v0.3 section; ARCHITECTURE documents the
metadata-in-YAML / evaluation-in-Python split. No code or behaviour change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@migmcc migmcc added this to the v0.3 milestone Jun 21, 2026
Make rules/pfmea_control_plan_rules.yaml the single source of truth for rule
metadata (id, severity, title, message_template, description, rationale). The
checker now builds each Finding using the YAML severity and message template
instead of hardcoding them; the per-finding-type detection logic stays in Python
(not a generic rule engine).

Loader (rules/__init__.py) validates required fields and fails clearly on missing
id, missing field, invalid severity, duplicate id or empty ruleset. Messages and
behaviour are byte-identical to v0.2, locked by new behaviour-parity tests
(seeded example, clean case, warnings case) plus loader validation tests.

No change to scoring, matching, finding types or the JSON schema. Closes #1.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@migmcc migmcc marked this pull request as ready for review June 21, 2026 14:03
@migmcc migmcc merged commit 1d9331f into main Jun 21, 2026
4 checks passed
@migmcc migmcc deleted the feat/yaml-rules branch June 21, 2026 14:05
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.

Make YAML the source of truth for validation rules

1 participant