test: rates.py extraction coverage - #119
Merged
Merged
Conversation
audit.py reads rates through scripts/rates.py's own regex patterns, not trz_model.py's - a second, independent extraction layer against the same reference text that no suite exercised directly. Only 2 of its 9 FLAT_PATTERNS entries (employer_no_tzpb_pct, social_expense_threshold_eur) are actually consumed by audit.py today; the other 7 are reserved for checks not wired up yet, so a stavki.md restructure could break one of them with nothing going red - load_flat() fails closed by design (a broken pattern just makes the name absent from its result), so audit.py would never crash, and no other test reads those seven names at all. rates_test.py now asserts every FLAT_PATTERNS name extracts, and every PERIOD_PATTERNS name extracts for both of 2026's known regimes. Proved it has teeth by breaking bolnichni.md's sick-days wording and watching sick_days_employer go NOT FOUND, then reverting. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XvbzEbQwxwxxHAtXfPMrno
…l review Adversarial review of this branch before merge found two things: - employer_no_tzpb_pct had no value assertion anywhere - the new FLAT_PATTERNS loop only proves a pattern matches exactly once, never that the number is right, and this was the one FLAT_PATTERNS entry with no matching CHECKS entry to cross-check it (the comment in rates.py claiming otherwise was wrong for this one). Added a CHECKS entry against M.EMPLOYER_SOCIAL + M.EMPLOYER_UPF + M.EMPLOYER_HEALTH, which the reference file's own row states as the decomposition (18.52 = 10.92 + 2.80 + 4.80). - "nine FLAT_PATTERNS entries" was ten; the loop is an existence check only (a pattern matching the wrong row would still print `ok`); min_wage_month has one row per calendar year, not two regimes the way max_insurable does. All three now said explicitly in comments. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XvbzEbQwxwxxHAtXfPMrno
2 tasks
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
Review point #5:
scripts/rates.pyregex-parses markdown, fail-closed by design, but only 2 of its 9FLAT_PATTERNSentries were actually consumed byaudit.py(the rest are reserved for unwired checks) — so astavki.mdrestructure could silently break one of the other 7 with nothing going red anywhere in the suite.rates_test.pynow asserts everyFLAT_PATTERNSname extracts, and everyPERIOD_PATTERNSname extracts for both of 2026's known regimes. Verified it has teeth: brokebolnichni.md's sick-days wording, watchedsick_days_employergoNOT FOUND, reverted.Test plan
test/rates_test.py— 51 checks now, up from 37test/skill_test.py🤖 Generated with Claude Code
https://claude.ai/code/session_01XvbzEbQwxwxxHAtXfPMrno