feat(prover): add native Rust policy prover with Z3 solver#741
Open
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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