Deduplicate integrity-level enums by centralizing canonical values in guard#5245
Merged
Merged
Conversation
7 tasks
Agent-Logs-Url: https://github.com/github/gh-aw-mcpg/sessions/1f4c9106-2998-4aa4-b59c-8ae14b5b015d Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw-mcpg/sessions/1f4c9106-2998-4aa4-b59c-8ae14b5b015d Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix duplicate integrity level values across packages
Deduplicate integrity-level enums by centralizing canonical values in May 7, 2026
guard
Contributor
There was a problem hiding this comment.
Pull request overview
This PR centralizes the canonical integrity-level enum values (none, unapproved, approved, merged) in internal/guard and updates config validation error messages and CLI shell completions to derive from that canonical list, reducing duplication across packages.
Changes:
- Exported
guard.AllowedIntegrityLevelsand derived the internal validation set from it. - Updated CLI completion for
--allowonly-min-integrity(and its test) to use the canonical list. - Updated config guard-policy error messages (and a focused test) to format valid integrity values from the canonical list.
Show a summary per file
| File | Description |
|---|---|
| internal/guard/wasm_validate.go | Exports canonical integrity-level list and derives the validation set and error rendering from it. |
| internal/config/guard_policy_validation.go | Uses guard.AllowedIntegrityLevels to format integrity-related validation errors. |
| internal/config/guard_policy_parse.go | Uses guard.AllowedIntegrityLevels to format BuildAllowOnlyPolicy invalid-integrity errors. |
| internal/config/guard_policy_parse_test.go | Adds assertion that invalid integrity errors list canonical values. |
| internal/cmd/flags.go | Uses guard.AllowedIntegrityLevels for shell completions on allowonly-min-integrity. |
| internal/cmd/flags_test.go | Updates completion test to assert against guard.AllowedIntegrityLevels. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 6/6 changed files
- Comments generated: 1
Comment on lines
+8
to
+17
| // AllowedIntegrityLevels is the single source of truth for valid integrity-level values. | ||
| var AllowedIntegrityLevels = []string{"none", "unapproved", "approved", "merged"} | ||
|
|
||
| var allowedIntegrityLevelSet = map[string]struct{}{ | ||
| "none": {}, | ||
| "unapproved": {}, | ||
| "approved": {}, | ||
| "merged": {}, | ||
| } | ||
| var allowedIntegrityLevelSet = func() map[string]struct{} { | ||
| m := make(map[string]struct{}, len(AllowedIntegrityLevels)) | ||
| for _, level := range AllowedIntegrityLevels { | ||
| m[level] = struct{}{} | ||
| } | ||
| return m | ||
| }() |
This was referenced May 7, 2026
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.
Integrity-level values (
none,unapproved,approved,merged) were duplicated acrossguard,config, andcmd, despiteguardclaiming to be the source of truth. This change makesguardauthoritative and updates downstream usage to consume canonical values directly.Canonical integrity values
guard.AllowedIntegrityLevelsfrominternal/guard/wasm_validate.go.CLI completion now uses canonical values
allowonly-min-integrityshell completion ininternal/cmd/flags.goto useguard.AllowedIntegrityLevelsinstead of inline literals.Config error messages now derive valid values dynamically
internal/config/guard_policy_validation.gointernal/config/guard_policy_parse.gostrings.Join(guard.AllowedIntegrityLevels, ", ").Focused test coverage for dedup behavior
guard_policy_parse_test.gothat invalid integrity errors render from the canonical list.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
example.com/tmp/go-build3081364729/b509/launcher.test /tmp/go-build3081364729/b509/launcher.test -test.testlogfile=/tmp/go-build3081364729/b509/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true g_.a internal/testcert/testcert.go x_amd64/vet --gdwarf-5 --64 -o x_amd64/vet -E g_.a -m64 x_amd64/compile /tmp/go-build392/opt/hostedtoolcache/go/1.25.9/x64/pkg/tool/linux_amd64/vet g/x/net/http/htt-atomic -fno-stack-prote-bool x_amd64/compile(dns block)/tmp/go-build3323417617/b513/launcher.test /tmp/go-build3323417617/b513/launcher.test -test.testlogfile=/tmp/go-build3323417617/b513/testlog.txt -test.paniconexit0 -test.timeout=10m0s -uns�� -unreachable=false /tmp/go-build3081364729/b246/vet.cfg bash g_.a -trimpath x_amd64/vet /opt/hostedtoolc--others -ato�� submodules | head -n 10 -buildtags /tmp/go-build3081364729/b225/cmd.test -errorsas -ifaceassert -nilfunc /tmp/go-build3081364729/b225/cmd.test(dns block)invalid-host-that-does-not-exist-12345.com/tmp/go-build3081364729/b491/config.test /tmp/go-build3081364729/b491/config.test -test.testlogfile=/tmp/go-build3081364729/b491/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true uf@v1.36.11/internal/filetype/build.go -I x_amd64/vet --gdwarf-5 --64 -o x_amd64/vet -I g_.a -I x_amd64/vet --gdwarf-5 ateway/v2/utilit-atomic -o x_amd64/vet(dns block)/tmp/go-build191210255/b276/config.test /tmp/go-build191210255/b276/config.test -test.testlogfile=/tmp/go-build191210255/b276/testlog.txt -test.paniconexit0 -test.timeout=10m0s(dns block)/tmp/go-build2613079384/b487/config.test /tmp/go-build2613079384/b487/config.test -test.testlogfile=/tmp/go-build2613079384/b487/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp�� /home/REDACTED/go/pkg/mod/go.opent-p /home/REDACTED/go/pkg/mod/go.opentgithub.com/github/gh-aw-mcpg/internal/tracing_test .cfg sor.go duration.go .13/x64/as ache/go/1.25.9/x64/pkg/tool/linu-goversion(dns block)nonexistent.local/tmp/go-build3081364729/b509/launcher.test /tmp/go-build3081364729/b509/launcher.test -test.testlogfile=/tmp/go-build3081364729/b509/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true g_.a internal/testcert/testcert.go x_amd64/vet --gdwarf-5 --64 -o x_amd64/vet -E g_.a -m64 x_amd64/compile /tmp/go-build392/opt/hostedtoolcache/go/1.25.9/x64/pkg/tool/linux_amd64/vet g/x/net/http/htt-atomic -fno-stack-prote-bool x_amd64/compile(dns block)/tmp/go-build3323417617/b513/launcher.test /tmp/go-build3323417617/b513/launcher.test -test.testlogfile=/tmp/go-build3323417617/b513/testlog.txt -test.paniconexit0 -test.timeout=10m0s -uns�� -unreachable=false /tmp/go-build3081364729/b246/vet.cfg bash g_.a -trimpath x_amd64/vet /opt/hostedtoolc--others -ato�� submodules | head -n 10 -buildtags /tmp/go-build3081364729/b225/cmd.test -errorsas -ifaceassert -nilfunc /tmp/go-build3081364729/b225/cmd.test(dns block)slow.example.com/tmp/go-build3081364729/b509/launcher.test /tmp/go-build3081364729/b509/launcher.test -test.testlogfile=/tmp/go-build3081364729/b509/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true g_.a internal/testcert/testcert.go x_amd64/vet --gdwarf-5 --64 -o x_amd64/vet -E g_.a -m64 x_amd64/compile /tmp/go-build392/opt/hostedtoolcache/go/1.25.9/x64/pkg/tool/linux_amd64/vet g/x/net/http/htt-atomic -fno-stack-prote-bool x_amd64/compile(dns block)/tmp/go-build3323417617/b513/launcher.test /tmp/go-build3323417617/b513/launcher.test -test.testlogfile=/tmp/go-build3323417617/b513/testlog.txt -test.paniconexit0 -test.timeout=10m0s -uns�� -unreachable=false /tmp/go-build3081364729/b246/vet.cfg bash g_.a -trimpath x_amd64/vet /opt/hostedtoolc--others -ato�� submodules | head -n 10 -buildtags /tmp/go-build3081364729/b225/cmd.test -errorsas -ifaceassert -nilfunc /tmp/go-build3081364729/b225/cmd.test(dns block)this-host-does-not-exist-12345.com/tmp/go-build3081364729/b518/mcp.test /tmp/go-build3081364729/b518/mcp.test -test.testlogfile=/tmp/go-build3081364729/b518/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true olang.org/grpc@v-errorsas -I x_amd64/vet ctor --64 E=3 x_amd64/vet .cfg�� 2347187/b392/_pkg_.a otection x_amd64/vet /tmp/go-build392/usr/libexec/docker/docker-init g/protobuf/inter--version x86_64-linux-gnu x_amd64/vet(dns block)/tmp/go-build3323417617/b522/mcp.test /tmp/go-build3323417617/b522/mcp.test -test.testlogfile=/tmp/go-build3323417617/b522/testlog.txt -test.paniconexit0 -test.timeout=10m0s n-me�� -bool -buildtags ker/docker-init -errorsas -ifaceassert -nilfunc ker/docker-init -ato�� -bool -buildtags docker-buildx -errorsas -ifaceassert -nilfunc docker-buildx(dns block)If you need me to access, download, or install something from one of these locations, you can either: