Codegen-equivalence gate: prove generated Cedar decides like the spec#5
Merged
Conversation
…spec Re-applied onto current main. The cedar equivalence check is wired in as Gate 10 (main added kernel-test gates 8/9 after the original PR was cut). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Cosmetic follow-up to the rebase: the cedar-equiv script header still said 'Gate 8' (it was renumbered to Gate 10 when this rebased onto a main that had gained kernel-test gates 8/9), and gates.sh's header still said 'five gates' (there are now 11: Gates 0-10). Comments only; no behavior change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.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.
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 10 (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