chore: retro-review PR #102 — test(tariff): Hypothesis fuzz the five tariff_engine invariants (Phase 11 PR-18)#134
Conversation
…e 11 PR-18)
PR-18 — Final v2.0 GA plank. Property-based tests cover the five
invariants from v2 research § 7.3 for tariff_engine pure functions
(calc_stepped_cost, get_stepped_import_rate, get_current_tou_period).
- 1. Monotonic stepped cost: cost(k1) <= cost(k2) for k1 <= k2.
- 2. Threshold equality: cost(threshold) == threshold * step1_rate.
- 3. Step composition above threshold: cost = step1_cost +
(k - threshold) * step2_rate.
- 4. Stepped rate dichotomy: returned rate is exactly step1 or step2.
- 5. TOU period closure: returned period name is in the supplied
dict OR "unknown"; rate matches the period when found; full-day
coverage produces no "unknown".
≥ 200 fuzzed examples per invariant via hypothesis. 9 test classes.
1054 total pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
@claude review |
|
Claude finished @Artic0din's task in 16m 51s —— View job Code Review — PR #102 Retro: Hypothesis Fuzz Tests for Tariff EngineTodo
Overall the test suite is well-structured and the invariant coverage is sensible. Two production-code issues and one test-design concern need attention before this can be considered a clean fuzz harness. Bug: Boundary semantics mismatch between
|
| Finding | Severity | File | Lines |
|---|---|---|---|
Boundary < vs ≤ inconsistency silently encoded as correct |
Medium | tariff_engine.py |
75, 83 |
return instead of assume() undercuts effective example count |
Low | test_tariff_engine_hypothesis.py |
109, 143, 153 |
Tolerance inconsistency 1e-9 vs 1e-6 |
Cosmetic | test_tariff_engine_hypothesis.py |
92, 114 |
The boundary mismatch is the one worth following up on — whether it's intentional or a subtle bug in get_stepped_import_rate, the intent should be documented in a comment or resolved with a consistent operator. Everything else is clean.
|
Claude encountered an error after 8m 17s —— View job I'll analyze this and get back to you. |
|
Retro-review complete. Findings (if any) tracked in fix/retro-review-batch (#143) or noted in .planning/retro-review-findings.md. Closing synthetic PR + cleaning branches. |
Synthetic retro-review of merged PR #102. Diff = original
0bc35b0..7e92212(same as original PR). Do NOT merge; close after @claude review posts.