feat(scoring): validate scenario matrix references known attributes/recipients - #18
Conversation
forbidden/appropriate_flows are (attribute_name, recipient_id) pairs, but nothing checked those names resolve to the scenario's attributes/ recipients — a typo silently mis-scored or KeyError-ed deep in scoring. Add validate_scenario(scenario) raising a clear ValueError naming any offending pair and the known names, and call it at the top of score() so a mis-authored scenario fails loud. Built-in scenarios validate clean. Fixes bamdadd#2
|
Thanks @dchaudhari7177 — this correctly implements #2 (clear ValueError naming the offending pair, validated on score(), meaningful tests). One formatting nit before merge: |
|
Almost there @dchaudhari7177 — ruff-check/mypy/pytest all pass, but |
|
Done — ran |
What
forbiddenandappropriate_flowsare(attribute_name, recipient_id)pairs, but nothing checked those names actually exist in the scenario'sattributes/recipients. A typo silently mis-scored, and the CLIKeyErrored onattr_by_name[attribute_name].Adds
validate_scenario(scenario)inscoring.py: it raises a clearValueErrornaming anyforbidden/appropriate_flowspair that references an unknown attribute or recipient (and lists the known names).score()calls it first, so a mis-authored scenario fails loud with a pointer to the typo instead of a deepKeyErroror a silent wrong rate.Acceptance criteria
CLUB_RESERVE_SCENARIO(andALL_SCENARIOS) validate clean, and the existing smoke/report tests are untouched.Tests
tests/test_validate_scenario.py: the built-in validates; unknown-attribute, unknown-recipient, and anappropriate_flowstypo each raise aValueErrorwith the offending pair in the message; andscore()rejects a mis-authored scenario. Full suite: 31 passed,ruff checkclean.Fixes #2