test(gate): check the gate against a reference model on generated trees
Problem
Each attack in the threat model has a test written for it, and one stress test races a symlink swap. Those check cases someone chose. Nothing checks the gate's claims against inputs nobody chose.
This starts M10 in the roadmap, which plans that work, and records the maintainer's decision to set the independent review aside for now.
Change
tests/gate_model.rs builds a generated tree on the real filesystem for each case. The tree holds directories, files, and symlinks that stay inside, climb out, take a detour above a deeper grant, point at absolute paths, dangle (beside the link, or outside every grant), or loop. Beside it is a directory no grant covers, holding a secret. Each case then runs generated grant, narrow, revoke, open, create, metadata, and read_dir calls through a gate with an audit sink.
Every answer is checked against:
- A reference model. Routing is RFC 0001's lexical rule. The rest of the path is walked one component at a time with
symlink_metadataandread_link, refusing whatRESOLVE_BENEATHrefuses. The prediction is made from the tree before the call.NotAbsolute,NoGrant,RightsExceeded,UnknownGrant, andWouldWidenmust match exactly, with their fields. - The object reached. A success must reach the model's target by device and inode, and that inode must be physically beneath the grant the request was routed to. A listing must name the target's entries.
- The tree. A failure must leave every entry unchanged, the secret included. A create may change only the file it created, which the test identifies by writing a marker into it.
- The audit event. Each decision emits exactly one event, with the routed grant, the normalized path, and an errno exactly when an allowed operation failed.
The run fails if it never reaches one of the answers it checks: each policy denial, a success of each operation directly and through a symlink, refusals for .., absolute symlinks, and loops, a create through a dangling symlink, and a create refused for leaving its grant. known_cases_match_the_model runs fixed cases through the same checks: the two minimal cases this test found, and the dangling-symlink creates the generator reaches too rarely to rely on.
proptest 1.11.0 is a new dev-dependency, with default features off. Resolver 3 chose it for the 1.85 MSRV, and cargo deny check bans reports the same 12 duplicate versions as main. Failures are not saved to a seed file in the source tree. A failure prints its shrunk case, and the case goes into known_cases_match_the_model.
What it found
Two defects in how refusals are reported. The decisions were correct both times.
- #58: a request no grant covers recorded its path with the
..in it, against RFC 0002. - #59: on macOS, a symlink out of the grant was audited as
allowwith no errno, the same as a success.
Both fixes are on main, and this branch is updated from it.
Verification
On macOS 26.2 (Darwin 25.2) with Rust 1.99.1:
cargo test --locked -p fsgate --test gate_model: 2 passed, in about 2 seconds for the default 512 cases.PROPTEST_CASES=20000, twice with the final generator: both passed, in 84 s and 96 s. In each run, about 20,000 operations succeeded, about 1,900 of them through a symlink, about 2,100 creates were refused for leaving their grant, and about 280 creates went through a dangling symlink. Three earlier runs of 20,000 cases with a weaker generator also passed.- Controls, each a temporary change to
lib.rsthat was then reverted. ReplacingGate::open's resolution withstd::fs::File::open(grant_path.join(rel))fails with an open that escaped through a symlink. Routing to the shortest covering grant fails with an audit event naming the wrong grant. cargo +1.85.0 test --locked -p fsgate --test gate_model: 2 passed.cargo fmt --all --check,cargo clippy --all-targets -- -D warnings, andcargo deny check: clean.cargo clippy --locked --target x86_64-unknown-linux-gnu -p fsgate --all-targets -- -D warnings, also with--features experimental-intercept: clean. This is a type-check, not a run.cargo test --locked: 100 passed, 0 failed.cargo package --listincludestests/gate_model.rs, so the packaged-crate run in CI runs it too.
CI, run 42907442197 on 0f2e46a, all 8 checks passed:
- Linux, on the
ubuntu-26.04runner's kernel, where the gate resolves withopenat2: both tests ingate_model.rspassed in all three runs of thecheckjob (the checkout,experimental-intercept, and the packaged crate), each in about 1 s, and in both runs of themsrvjob on Rust 1.85. - macOS (
macos-26-arm64): both passed, in 3.09 s.
Not verified:
- What the generator does not make: hard links and mounts, which the threat model lists as gaps, and concurrent renames, which the swap stress test covers.
- The model follows RFC 0001, so it cannot catch a flaw in the RFC's own rules.
Documentation and release
The M10 plan and the review decision in ROADMAP.md, with the first M10 item ticked and the CI evidence above recorded, and a note in the threat model's gate section. A test-only change, so no changelog entry and no release.