Skip to content

test: rates.py extraction coverage - #119

Merged
svedbg merged 2 commits into
mainfrom
test/rates-extraction-coverage
Sep 6, 2026
Merged

test: rates.py extraction coverage#119
svedbg merged 2 commits into
mainfrom
test/rates-extraction-coverage

Conversation

@svedbg

@svedbg svedbg commented Sep 6, 2026

Copy link
Copy Markdown
Owner

Summary

Review point #5: scripts/rates.py regex-parses markdown, fail-closed by design, but only 2 of its 9 FLAT_PATTERNS entries were actually consumed by audit.py (the rest are reserved for unwired checks) — so a stavki.md restructure could silently break one of the other 7 with nothing going red anywhere in the suite.

rates_test.py now asserts every FLAT_PATTERNS name extracts, and every PERIOD_PATTERNS name extracts for both of 2026's known regimes. Verified it has teeth: broke bolnichni.md's sick-days wording, watched sick_days_employer go NOT FOUND, reverted.

Test plan

  • test/rates_test.py — 51 checks now, up from 37
  • test/skill_test.py
  • full 5-suite battery + k_checker + audit checker (25 seeds, via pre-commit hook)

🤖 Generated with Claude Code

https://claude.ai/code/session_01XvbzEbQwxwxxHAtXfPMrno

svedbg and others added 2 commits September 6, 2026 15:29
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
@svedbg
svedbg merged commit 76655cf into main Sep 6, 2026
12 checks passed
@svedbg
svedbg deleted the test/rates-extraction-coverage branch September 6, 2026 13:11
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.

1 participant