Codegen-equivalence gate: prove generated Cedar decides like the spec#1
Closed
pyrex41 wants to merge 1 commit into
Closed
Codegen-equivalence gate: prove generated Cedar decides like the spec#1pyrex41 wants to merge 1 commit into
pyrex41 wants to merge 1 commit into
Conversation
…spec generate.rs strict-validates the *shape* of the Cedar it renders from spec/authz.shen, but never checks that the PolicySet *decides the same way* as the spec it came from. Schema validation catches an ill-typed policy; it does not catch a closure bug, a rendering bug, or a hand-edit that drops a permit. This adds a native shen-derive-style differential gate that closes that gap. - examples/.../equiv.rs: loads spec/authz.shen into the served VM as the oracle (expand-all), renders the Cedar target, and asserts the two agree on every request over a finite grid; exit 1 on any divergence. `--inject-drift` drops one permit to prove the gate catches it. Generic over narrow Oracle/Target traits (ShenSpecOracle x CedarTarget), with the seam left open for future SBCL-oracle / shengen->Rust-target impls. - examples/.../reaches_equiv.rs: the same VM runs role reachability two ways -- functional `reaches` (defun, ported from verify.rs) and a real `defprolog prolog-reaches` -- both built from one edge table and differentially checked over all role pairs. - scripts/shen-cedar-equiv.sh + sb.toml + scripts/gates.sh: wired as Gate 8 (cedar-equiv) so it runs with the rest of the backpressure suite. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Owner
Author
|
✅ Full Resolves the caveat in the PR description — the full suite (not just the new gate) passes end-to-end. |
Owner
Author
|
Superseded by #5 — rebased onto current main (conflict in scripts/gates.sh resolved; cedar gate renumbered to Gate 10). Same changes, mergeable. |
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.
What
Adds a native, shen-derive-style codegen-equivalence gate to
examples/shen-cedar-authz, plus a Prolog/functional differential check, wired into the backpressure gate suite.Why
generate.rsrenders Cedar fromspec/authz.shenand strict-validates the shape of the result against the schema. It never checks that the generatedPolicySetdecides the same way as the spec it came from. Schema validation catches an ill-typed policy; it does not catch a closure bug, a rendering bug, or a hand-edit that quietly drops a permit. The only prior safeguard was the convention "never hand-edit the generated Cedar." This turns that convention into a red/green gate.Changes
examples/shen-cedar-authz/examples/equiv.rs— loadsspec/authz.sheninto the served VM as the oracle (expand-all), renders the Cedar target, and asserts they agree on every request over a finite grid (one user per role × resources incl. an ungrantedio). Exit1on any divergence;--inject-driftdrops one permit to prove it catches drift. Generic over narrowOracle/Targettraits (ShenSpecOracle×CedarTarget); the seam is documented so a future SBCL oracle or shengen→Rust target can drop in.examples/shen-cedar-authz/examples/reaches_equiv.rs— the same VM runs role reachability two ways: functionalreaches(defun, ported fromverify.rs) and a realdefprolog prolog-reaches, both built from one edge table and differentially checked over all role pairs.scripts/shen-cedar-equiv.sh+sb.toml+scripts/gates.sh— wired as Gate 8 (cedar-equiv).Verification
All run locally, real exit codes:
Note: the new gate and
fmt/clippyon the touched crate are verified; the full./scripts/gates.sh(kernel tests etc.) was not re-run end-to-end in this change.🤖 Generated with Claude Code