Update symcc opt path to use pre-compiled schema - #989
Draft
john-h-kastner-aws wants to merge 1 commit into
Draft
Conversation
Signed-off-by: jkastner <jkastner@amazon.com>
There was a problem hiding this comment.
Pull request overview
This PR refactors the Lean SymCCOpt compilation API to take a pre-compiled schema (CompiledSchema) plus a request type, so symbolic entities can be reused across multiple policy/policyset compilations. It also updates the corresponding SymCCOpt correctness theorems to use the new API shape.
Changes:
- Introduces
Cedar.SymCC.CompiledSchema(schema + precomputedSymEntities) with helpers to deriveSymEnv/TypeEnvfor aRequestType. - Updates
CompiledPolicy.compile/CompiledPolicySet.compileto accept(s : CompiledSchema)and(reqty : RequestType)and reuses.entities. - Adjusts SymCCOpt proof layers and theorems to thread
CompiledSchema/reqtyinstead of a rawTypeEnv.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| cedar-lean/Cedar/Validation/Types.lean | Derives Inhabited for Schema to support new compiled-schema structures. |
| cedar-lean/Cedar/Thm/SymCC/Opt/Verifier.lean | Updates verifier equivalence theorems to use CompiledSchema + reqty. |
| cedar-lean/Cedar/Thm/SymCC/Opt/Extractor.lean | Updates extractor theorem hypotheses for new compile signatures. |
| cedar-lean/Cedar/Thm/SymCC/Opt/Enforcer.lean | Updates enforcer equivalence theorems to use s.typeEnv reqty / s.symEnv reqty. |
| cedar-lean/Cedar/Thm/SymCC/Opt/CompiledPolicies.lean | Updates compiled-policy correctness theorems for new compile API. |
| cedar-lean/Cedar/Thm/SymCC/Opt.lean | Bridges old Γ-based theorems to new compiled-schema API; updates many lemmas accordingly. |
| cedar-lean/Cedar/SymCCOpt/CompiledSchema.lean | Adds CompiledSchema and its compile, symEnv, and typeEnv helpers. |
| cedar-lean/Cedar/SymCCOpt/CompiledPolicies.lean | Changes public compilation API to accept pre-compiled schema + request type, reusing symbolic entities. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
61
to
65
| /-- | ||
| Compile a policy `p` for the given environment `Γ`. | ||
| This function calls the Cedar typechecker to obtain a policy `p'` that is | ||
| semantically equivalent to `p` and well-typed with respect to `Γ`. | ||
| Then, it runs the symbolic compiler to produce a compiled policy. |
Comment on lines
93
to
97
| /-- | ||
| Compile a set of policies `ps` for the given environment `Γ`. | ||
| This function calls the Cedar typechecker on each `p ∈ ps` to obtain a policy `p'` | ||
| that is semantically equivalent to `p` and well-typed with respect to `Γ`. | ||
| Then, it runs the symbolic compiler to produce a compiled policy. |
Comment on lines
+67
to
+70
| def CompiledPolicy.compile (p : Policy) (s : CompiledSchema) (reqty : Validation.RequestType) : Except CompiledPolicyError CompiledPolicy := do | ||
| let Γ := s.typeEnv reqty | ||
| let policy ← wellTypedPolicy p Γ |>.mapError .validationError | ||
| let εnv := SymEnv.ofEnv Γ | ||
| let εnv := s.symEnv reqty |
john-h-kastner-aws
marked this pull request as draft
July 22, 2026 17:59
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.
Draft PR since we'll also want to make the change to the Rust, and I need to fix up some FFI/CLI parts here. The main change to the Lean model is done and can be reviewed.
Makes the API change proposed here cedar-policy/cedar#2467 (comment)
This PR adds the
CompiledSchemastructure to Lean, and changes theCompiledPolicyto use it in its constructor.Proof are updated to show we can reuse this the compiled schema