Skip to content

Aliasing checks: Tree Borrows monitor and its Verus proof - #5120

Draft
feliperodri wants to merge 1 commit into
model-checking:mainfrom
feliperodri:aliasing-monitor-verus
Draft

feliperodri wants to merge 1 commit into
model-checking:mainfrom
feliperodri:aliasing-monitor-verus

Conversation

@feliperodri

Copy link
Copy Markdown
Member

First PR of the series that RFC #5111 proposes for aliasing checks (-Z aliasing-checks). It adds the monitor, the functions that apply Tree Borrows' rules at the one memory byte the checks track, and a Verus proof that they implement those rules. Nothing calls the monitor yet: the next PR adds the MIR instrumentation that does.

Why on its own: the monitor is where the subtle rules are (conflicted Reserved, protectors, interior mutability, wildcard accesses), and it has no dependency on a CBMC release, unlike the instrumentation. It is easier to check against Miri's rules here than inside the compiler pass.

What to look at:

  • The specification in library/kani_core/verus/aliasing_monitor.rs (local_step, foreign_step, retag_node, wild_access, return_spec, ...). It is the trusted part: the proof shows that the code implements it, not that it is Tree Borrows. Each rule cites the Miri code it transcribes (tree_borrows/perms.rs, tree.rs). The next PR checks it a second way, by running Miri's own borrow tests under both tools.
  • The bit-level encoding, described at the top of library/kani_core/src/aliasing_monitor.rs: up to 64 tags, each with its ancestors and permission as bit masks.
  • The new CI workflow, which downloads a pinned Verus release and runs the proof (about 3 minutes) when these files change.

Risk: none for users. The macro isn't expanded anywhere yet; the only change to the build is mod aliasing_monitor; in kani_core.

Where I'd like input:

  • Is a CI job that depends on a pinned Verus release acceptable? It only runs when the monitor or its proof changes.
  • Would you rather expand the macro now, so that every Kani library build compiles it? That catches breakage from toolchain upgrades earlier, at the cost of unused functions in the library until the next PR.

Testing:

  • Verus 0.2026.10.04.426d8b0: verification results:: 163 verified, 0 errors. The proof uses no assume, admit or external_body.
  • cargo build-dev, cargo clippy -p kani_core -- -D warnings and kani-fmt --check pass. The Intrinsics tests of the kani suite (177) pass; the full regression suite has not been run on this branch.

First step of the aliasing checks proposed in RFC model-checking#5111. The monitor is the
set of functions that apply Tree Borrows' rules at the one byte the checks
track: tags with their ancestors and permissions as bit masks, accesses,
reborrows, protectors, deallocation, exposure, function returns and the
loop-head abstraction for loop contracts. Nothing calls it yet; the
instrumentation that does comes next.

The Verus crate in library/kani_core/verus includes the same file and proves
that each function refines Tree Borrows' rules on an abstract tree, as Miri
implements them, and preserves the monitor's well-formedness invariant
(163 verified, no assume, admit or external_body). A new workflow runs the
proof with a pinned Verus release when these files change.
@feliperodri
feliperodri requested review from a team as code owners November 5, 2026 17:29
@github-actions github-actions Bot added Z-EndToEndBenchCI Tag a PR to run benchmark CI Z-CompilerBenchCI Tag a PR to run benchmark CI labels Nov 5, 2026
@feliperodri
feliperodri requested a balanced review from Copilot November 5, 2026 19:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

2 open issues
What changed in this PR

Adds the Tree Borrows “aliasing monitor” transition core to kani_core, alongside a Verus specification/proof that the implementation refines that spec, plus CI wiring to run the proof on relevant changes.

Changes:

  • Introduces kani_aliasing_monitor! implementation (state + transition functions) in library/kani_core/src/aliasing_monitor.rs.
  • Adds a large Verus spec/proof harness (library/kani_core/verus/aliasing_monitor.rs) and documentation (library/kani_core/verus/README.md).
  • Adds a GitHub Actions workflow to download a pinned Verus release and run the proof on changes.
File Description
library/​kani_core/​verus/​aliasing_monitor.rs New Verus spec + proofs, includes and verifies the monitor implementation.
library/​kani_core/​verus/​README.md Documents how to run the proof and what is/ isn’t proved.
library/​kani_core/​src/​lib.rs Compiles in the new aliasing monitor module.
library/​kani_core/​src/​aliasing_monitor.rs Adds the monitor implementation and Verus-only contracts/proof hooks.
.github/​workflows/​verus.yml Adds CI job to run the Verus proof when monitor/proof changes.

Review effort: Lite

- 'library/kani_core/src/aliasing_monitor.rs'
- 'library/kani_core/verus/**'
- '.github/workflows/verus.yml'
merge_group:
Comment on lines +36 to +39
run: |
curl -sSfL -o verus.zip \
"https://github.com/verus-lang/verus/releases/download/release/${VERUS_VERSION}/verus-${VERUS_VERSION}-x86-linux.zip"
unzip -q verus.zip -d "$HOME/verus"
@feliperodri
feliperodri marked this pull request as draft November 7, 2026 22:38
@feliperodri feliperodri self-assigned this Nov 13, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Z-Aliasing-model Z-CompilerBenchCI Tag a PR to run benchmark CI Z-EndToEndBenchCI Tag a PR to run benchmark CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants