feat(prover): add native Rust policy prover with Z3 solver#741
feat(prover): add native Rust policy prover with Z3 solver#741
Conversation
Add openshell-prover crate implementing formal policy verification using Z3 SMT solving. Answers two questions about any sandbox policy: "Can data leave?" and "Can the agent write despite read-only intent?" Native Rust — no Python subprocess, no PYTHONPATH, no uv dependency. Z3 bundled via z3-sys for self-contained builds. Replaces the Python prototype from #703. Closes #699 Signed-off-by: Alexander Watson <zredlined@gmail.com>
…ntent Port two fixes from the Python branch: - Exfil query skips endpoints where L7 is enforced and working - Write bypass only fires on explicit read-only intent, not L4-only Signed-off-by: Alexander Watson <zredlined@gmail.com>
89af989 to
f8a78cf
Compare
|
@NVIDIA/openshell-codeowners The Rust checks for PR #741 are failing because z3-sys needs libclang for bindgen, and our ghcr.io/nvidia/openshell/ci:latest image doesn’t include it. I can patch branch-checks.yml to install clang/libclang-dev in the Rust jobs for an immediate unblock, but I think we should also update deploy/docker/Dockerfile.ci and republish the CI image as the proper fix. Do folks prefer the workflow-level unblock first, or do we want to fix the CI image before rerunning checks? |
I'd make sure it's in the image. |
Summary
Native Rust implementation of the OpenShell Policy Prover (OPP) using Z3 SMT solving. Answers two questions about any sandbox policy:
openshell policy proveis now a native CLI command — no Python, no subprocess, no PYTHONPATH.Supersedes #703 (Python prototype). Closes #699.
Related Issue
Closes #699
Changes
New crate:
crates/openshell-prover/model.rs— Z3 constraint model encoding policy rules, binary capabilities, and credential scopes as boolean satisfiability constraintsqueries.rs— two verification queries (exfiltration, write bypass)policy.rs— policy YAML parser with intent detection, L7 enforcement helpers, workdir modelingregistry.rs— binary capability registry (git, curl, node, claude, etc.) loaded from YAMLcredentials.rs— credential and API capability loadingaccepted_risks.rs— risk acceptance matching by query + hostreport.rs— terminal and compact (CI) outputfinding.rs— finding types and risk levels (HIGH, CRITICAL only)lib.rs— publicprove()API + 7 testsRegistry data (
crates/openshell-prover/registry/):CLI integration (
crates/openshell-cli/src/main.rs):openshell policy provecallsopenshell_prover::prove()directlyDependencies (
Cargo.toml):z3 = { version = "0.19", features = ["bundled"] }— self-contained Z3 buildTesting
cargo build -p openshell-prover— compiles with Z3 bundledcargo test -p openshell-prover— 7/7 tests passcargo build -p openshell-cli— CLI compilesopenshell policy prove --compactdetects exfil + write bypass on test fixtureChecklist