fix(rules): bugs fuzzing found in fits and distributions; property tests and a weekly fuzz #33
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.48) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.48 · 515 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.374
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #33"
general
weight: 0.35
hakuturu583
🔍 What
Property-based fuzzing of the rule fitting from #32 and of the distributions it fits. The fuzzing used Hypothesis in Python, plus randomized Rust tests through the editor's document. It found 11 bugs; this PR fixes them all. Each is kept as a unit test, and the properties now run in CI.
🐛 Bugs found and fixed
Distributions (
src/rules.rs)| Input | Symptom | Fix |
|---|---|---|
| Normal, mean 38 sd from its range (a fit can leave it so) | NaN quantile, cdf, pdf and mean: the mass underflowed | Truncated normal worked in logarithms (
Truncated): an asymptotic tail series beyond z = 35, differences from their own series or Taylor's, a Newton inverse, and a value placed by its offset from the range's near end || Normal, a range 1e-6 wide, 153 sd away |
cdf(quantile(p))off by 1e-6 (mean + sd*zand the log differences cancelled) | Same || Normal, range starting 4 sd into the tail | quantile not monotone near the end | Taylor step for small offsets |
| Normal,
a = -38in the central case |quantile(0)NaN:inverse_phi's Halley step overflowed | Skip the step when it isn't finite || Triangular,
low/modetiny next tohigh| quantile belowlow, or falling asprose (high - sqrt(...)cancelled) | Right branch computed from the mode up || Triangular, subnormal side | cdf 0/0 | Ratios rather than a product's quotient |
Fit (
src/rules_fit.rs)| Input | Symptom | Fix |
|---|---|---|
| One row on a triangular's end | The fit ended below the rules as written | End at the best of the fit, its start, and the rules as written |
| One row on a normal's end | The mean ran off the range, squeezing the distribution into a spike
min_spreaddidn't stop | A normal's spread is its truncated one (interquartile range / 1.349) || Two
max-joined parts tied at the row | The report wasn't the written file's log-likelihood: rounding flipped which part decides | The report describes the values as written |Editor (
crates/openodd-editor/src/rules_doc.rs)| Input | Symptom | Fix |
|---|---|---|
| Small values |
tidykept digits after the point capped at 15, so 1e-14 kept one significant digit | 11 significant digits at any size || Values ≥ 1e15 | Written as huge integers the reader rejects | Written with an exponent |
| A distribution whose points an extended file gives | Written flat; a fit overwrote the base's points at 11 digits |
DistDoc.shapekeeps the nesting, and the base's points stay as written |✅ Tests in CI
tests/test_rules_fit_properties.py(Hypothesis, derandomized in CI, about 2 s).- What a fit promises: it never ends below the rules as written; held values don't move; the fitted file reads back alone and extending; the report matches the written file; everything stays finite.
- Any rows, holds and JSON either work or fail with
RulesError, never a panic.- Distributions: the quantile is monotone and inside the range,
cdfundoesquantile, and summaries are finite.- Every case fuzzing found is kept as an
@example.- Against the unfixed code, 5 of its 8 tests fail.
-
random_distributions_read_everywhere(2000 seeds)-
random_fits_round_trip_through_the_document: random fits written into the editor's document and read back (120 seeds).github/workflows/fuzz.yml: weekly and on demand, the same tests with random cases at length (OPENODD_FUZZ_EXAMPLES, default 3000;OPENODD_FUZZ_SEEDS, default 20000).Locally:
cargo fmt --check, clippy (native and wasm32), andcargo test --workspacepass.- Python properties: 3 random rounds of 5000 examples.
- Distributions: 200,000 Rust seeds.
- Editor round trip: 20,000 seeds.
⚠️ Note
min_spreadfor a normal now bounds its spread as truncated rather than itssdparameter. The two are the same unless the mean sits near or outside the range. The docs are updated.---
_Generated by Claude Code_