test(gate): run more cases when the model run misses a rare answer
Problem
the_gate_matches_the_model_and_never_leaves_its_grants in tests/gate_model.rs fails when its 512 generated cases never reach one of the answers it checks. That guard is there so a change to the generator cannot quietly make the test check nothing. Two of those answers are rare: a successful open through a symlink, and a create through a dangling symlink. Each comes up about six times in a run, so a run now and then misses one and fails with nothing wrong:
the run never reached: ["a create through a dangling symlink"]
Coverage { …, either_created: 0, either_refused: 0, … }
Mutation testing for M10 item 3 hit this twice in about 45 runs on macOS, once for each answer. CI runs this test about eight times per push.
Root cause
The answer counts per run are roughly Poisson. Over 30 runs on macOS, the rarest averaged 5.7 (an open through a symlink, at least 2) and 6.5 (a create through a dangling symlink, at least 2). That puts the chance that one run of 512 misses some answer at about 0.5%. The two misses in about 145 runs I saw (45 during mutation testing, 100 standalone with none) fit that.
Change
- A run that misses an answer goes on with another 512 cases, up to four runs (2,048 cases) in all. An answer the generator can no longer reach still fails, after four runs instead of one.
- A passing run costs the same as before, because almost every run reaches everything in its first 512.
- Each run takes a new
TestRunner, because a runner stops once it has passedcases. The new runners' generators come from the first one's, so a fixedPROPTEST_RNG_SEEDstill repeats the whole test. - The checks are unchanged. Their list moved into
Coverage::missingso that it runs after each batch.
Verification
On macOS 26.2 with Rust 1.99.1:
- To show the extra runs fix it, I shrank each run to
PROPTEST_CASES=64and ran the test binary 50 times per build:- before: 42 of 50 failed the coverage guard
- after: 6 of 50 failed
- At the default 512 cases, the rates above give about one false failure in 10⁸ to 10¹⁰ runs after the change. That's an estimate, not a measurement.
cargo fmt --all --check,cargo clippy --all-targets -- -D warnings,cargo clippy --target x86_64-unknown-linux-gnu -p fsgate --all-targets -- -D warnings, andcargo +1.85.0 check -p fsgate --tests: clean.cargo test --locked: 106 passed.
Not verified:
- The Linux rate. These answers depend on the same generator, and CI runs it here.
Documentation and release
Test-only, so no changelog entry and no release.
Summary by cubic
Fixes the model coverage test in crates/fsgate/tests/gate_model.rs so it no longer fails when a run's 512 cases miss a rare answer like a successful open through a symlink or a create through a dangling symlink.
A run that misses an answer now goes on with another 512 cases, up to four runs (2,048 cases) in all. An answer the generator can no longer reach still fails, after four runs instead of one. Each run takes a new TestRunner because a runner stops after passing its cases; new runners' generators come from the first one's, so a fixed PROPTEST_RNG_SEED still repeats the whole test. Test-only, so no changelog entry.