Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .dir-locals.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
;;; Directory Local Variables -*- no-byte-compile: t; -*-
;;; For more information see (info "(emacs) Directory Variables")

;; Regorus is a cargo-verus project (package.metadata.verus.verify = true), so
;; verus-mode.el runs `cargo verus verify' rather than the raw `verus' binary.
;; The cargo-verus path ignores `package.metadata.verus.ide.extra_args' and
;; instead reads `verus-cargo-verus-arguments'. We set it here so that Verus is
;; invoked with the `verus' Cargo feature enabled.
;;
;; Everything before `--' is passed to cargo-verus; everything after `--' is
;; forwarded to the Verus binary. The `--' is required by verus-mode.el.
((verus-mode . ((verus-cargo-verus-arguments . ("--features" "verus" "--")))))
80 changes: 80 additions & 0 deletions .github/workflows/verus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
#
name: verus

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
CARGO_TERM_COLOR: always

# This workflow only checks out code, downloads a pinned Verus release asset,
# and runs verification. It never writes to the repository, so restrict the
# GITHUB_TOKEN to read-only access to repository contents.
permissions:
contents: read

jobs:
verify:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup Rust toolchain
uses: ./.github/actions/toolchains/rust
with:
components: ""
- name: Cache cargo
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
with:
shared-key: ${{ runner.os }}-regorus-verus
- name: Install Verus and run verification
shell: bash
run: |
set -euxo pipefail
asset_url=https://github.com/verus-lang/verus/releases/download/release%2F0.2026.07.12.0b42f4c/verus-0.2026.07.12.0b42f4c-x86-linux.zip
asset_sha256=f6f4f5d08e07d3e1ad721d775bda5ba96b9dd0c73b48fc17f2e071866fbd01c0
test -n "$asset_url"
curl -fsSL "$asset_url" -o verus.zip

# Verify the download integrity before trusting/executing its contents.
echo "${asset_sha256} verus.zip" | sha256sum --check --strict

unzip -q verus.zip -d verus-dist

# Search under an absolute path so that `find` yields absolute paths;
# this keeps the PATH entries below valid regardless of the working
# directory.
verus_bin="$(find "$PWD/verus-dist" -type f -name verus -perm -u+x | head -n1)"
cargo_verus_bin="$(find "$PWD/verus-dist" -type f -name cargo-verus -perm -u+x | head -n1)"
version_json="$(find "$PWD/verus-dist" -type f -name version.json | head -n1)"
test -n "$verus_bin"
test -n "$cargo_verus_bin"
test -n "$version_json"

# Verus is built against a specific Rust toolchain and refuses to run
# against any other version. Read the required toolchain from the
# release metadata so we track it automatically instead of hardcoding.
required_toolchain="$(sed -n 's/.*"toolchain"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "$version_json")"
test -n "$required_toolchain"
echo "Verus requires Rust toolchain: $required_toolchain"

# Install the exact toolchain Verus expects, including the extra
# components (rustc-dev, llvm-tools) that Verus links against and that
# are not part of the default rustup profile.
rustup toolchain install "$required_toolchain" \
--profile minimal \
--component rustc-dev --component llvm-tools --component rustfmt

# Force cargo/rustc to resolve to the Verus toolchain for the commands
# below, overriding any repository/directory toolchain override.
export RUSTUP_TOOLCHAIN="$required_toolchain"

# Put cargo-verus on PATH for the commands below.
export PATH="$(dirname "$cargo_verus_bin"):$(dirname "$verus_bin"):$PATH"
cargo verus --help
cargo fetch --locked
cargo verus verify --locked --features verus
89 changes: 85 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@ license = "MIT AND Apache-2.0 AND BSD-3-Clause"
repository = "https://github.com/microsoft/regorus"
keywords = ["interpreter", "no_std", "opa", "policy-as-code", "rego"]

# Support verification with Verus, a Rust verifier (https://github.com/verus-lang/verus)

[package.metadata.verus]
verify = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
doctest = false

[features]
default = ["full-opa", "arc", "rvm"]
verus = ["dep:vstd"]

arc = []
ast = []
Expand All @@ -43,7 +49,7 @@ cache = ["dep:lru"]
rvm = ["dep:postcard", "dep:indexmap"]
semver = ["dep:semver"]
allocator-memory-limits = ["std", "mimalloc", "mimalloc/allocator-memory-limits"]
std = ["rand/std", "rand/std_rng", "serde_json/std", "indexmap?/std", "msvc_spectre_libs", "dep:parking_lot" ]
std = ["rand/std", "rand/std_rng", "serde_json/std", "indexmap?/std", "msvc_spectre_libs", "dep:parking_lot", "vstd?/std" ]
time = ["dep:chrono", "dep:chrono-tz"]
Comment thread
jaylorch marked this conversation as resolved.
uuid = ["dep:uuid"]
urlquery = ["dep:url"]
Expand Down Expand Up @@ -134,6 +140,11 @@ mimalloc = { package = "regorus-mimalloc", path = "mimalloc", version = "2.2.7",
indexmap = { version = "2.13.1", default-features = false, features = ["serde"], optional = true }
postcard = { version = "1.1.3", default-features = false, features = ["alloc"], optional = true }

# Verus-related dependencies.
# vstd is enabled via the `verus` feature. In no_std builds only the `alloc` feature is used;
# the crate's `std` feature additionally enables `vstd/std` (matching vstd's default features).
vstd = { version = "=0.0.0-2026-07-12-0122", optional = true, default-features = false, features = ["alloc"] }

[dev-dependencies]
anyhow = "1.0.102"
cfg-if = "1.0.0"
Expand Down Expand Up @@ -214,3 +225,7 @@ doctest=false
# RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc --all-features --no-deps
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[lints.rust]
# Allow `verus_keep_ghost` configuration flag (used by Verus)
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(verus_keep_ghost)'] }
8 changes: 8 additions & 0 deletions bindings/csharp/Regorus.Tests/MemoryGrowthTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ public void Engine_create_eval_dispose_does_not_grow_working_set()

if (i % LogEvery == 0)
{
// Collect transient managed garbage so the working-set delta reflects
// retained (leaked) memory rather than uncollected allocations. A real
// native leak from a missed Dispose() would survive GC and still be caught.
ForceFullGc();
process.Refresh();
var workingSet = process.WorkingSet64;
var managed = GC.GetTotalMemory(false);
Expand Down Expand Up @@ -228,6 +232,10 @@ public void Rvm_rehydrate_execute_dispose_does_not_grow_working_set()

if (i % LogEvery == 0)
{
// Collect transient managed garbage so the working-set delta reflects
// retained (leaked) memory rather than uncollected allocations. A real
// native leak from a missed Dispose() would survive GC and still be caught.
ForceFullGc();
process.Refresh();
var workingSet = process.WorkingSet64;
var managed = GC.GetTotalMemory(false);
Expand Down
Loading
Loading