Add corpus coverage cases and validation updates#142
Closed
philhassey wants to merge 1 commit intocedar-policy:mainfrom
Closed
Add corpus coverage cases and validation updates#142philhassey wants to merge 1 commit intocedar-policy:mainfrom
philhassey wants to merge 1 commit intocedar-policy:mainfrom
Conversation
Signed-off-by: Phil Hassey <phil@strongdm.com>
patjakdev
approved these changes
Mar 18, 2026
Collaborator
patjakdev
left a comment
There was a problem hiding this comment.
There are a lot of changes I don't fully understand. But I have faith in the test methodology.
Comment on lines
-39
to
-48
| func (typeNever) isCedarType() { _ = "hack for code coverage" } | ||
| func (typeTrue) isCedarType() { _ = "hack for code coverage" } | ||
| func (typeFalse) isCedarType() { _ = "hack for code coverage" } | ||
| func (typeBool) isCedarType() { _ = "hack for code coverage" } | ||
| func (typeLong) isCedarType() { _ = "hack for code coverage" } | ||
| func (typeString) isCedarType() { _ = "hack for code coverage" } | ||
| func (typeSet) isCedarType() { _ = "hack for code coverage" } | ||
| func (typeRecord) isCedarType() { _ = "hack for code coverage" } | ||
| func (typeEntity) isCedarType() { _ = "hack for code coverage" } | ||
| func (typeExtension) isCedarType() { _ = "hack for code coverage" } |
Collaborator
There was a problem hiding this comment.
Hmmm, why did Codex change this?
| // Expression type checking | ||
| allEnvs := v.generateRequestEnvs() | ||
| envs := v.filterEnvsForPolicy(allEnvs, principalTypes, resourceTypes, actionUIDs) | ||
| actionScopeEmptySet := false |
Collaborator
There was a problem hiding this comment.
Maaan, this whole thing still doesn't make a ton of sense to me. This behavior maybe seems more correct?
| go test -coverprofile=coverage.out ./... | ||
| sed -i '' '/^github.com\/cedar-policy\/cedar-go\/internal\/schema\/parser\/cedarschema.go/d' coverage.out | ||
| go tool cover -func=coverage.out | sed 's/%$$//' | awk '$$2 == "isCedarType" { next } $$2 == "Entity" && $$1 ~ /entity\.go/ { next } $$2 == "typeOfExtensionCall" { next } { if ($$3 < 100.0) { printf "Insufficient code coverage for %s\n", $$0; failed=1 } } END { exit failed }' | ||
| go tool cover -func=coverage.out | sed 's/%$$//' | awk '$$1 == "total:" { next } { if ($$3 < 100.0) { printf "Insufficient code coverage for %s\n", $$0; failed=1 } } END { exit failed }' |
Collaborator
There was a problem hiding this comment.
Does this need to change in the .github CI as well? I'm not sure what it's doing here.
| @rm -rf /tmp/corpus-tests /tmp/corpus-tests-json-schemas | ||
| @mkdir -p /tmp/corpus-tests-json-schemas | ||
| @tar -xzf corpus-tests.tar.gz -C /tmp/ | ||
| @tar -xzmf corpus-tests.tar.gz -C /tmp/ |
Collaborator
There was a problem hiding this comment.
Not sure why -m is desirable exactly.
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
This PR refreshes corpus coverage and aligns
cedar-govalidation/typechecking behavior more closely with Rust Cedar.What changed
corpus-tests.tar.gzcorpus-tests-json-schemas.tar.gzcorpus-tests-validation.tar.gzcoverage_fullcompare_ifset_coveragetype_order_coveragepolicy_env_error_mergeMakefilecorpus extraction/coverage rules used by corpus regeneration and CI checks.x/exp/schema/validate:diag_error.go) and improved cross-environment error deduping.action in []behavior to match Rust semantics (strict vs permissive handling).if-then-else,||, equality folding (including action rewrite),is ... in, set incompatibility reporting, and strict extension-constructor literal checks.cedar_type.go:internal/rust:Validation
go test ./...go vet ./...