Before changing an API or MCP service grant, distinguish malformed input from a valid denial, compare the same request against both rules, and find a request that gains access. This four-case example runs policy definitions written in Gooo through generated Go code in an ordinary Go program.
This example assumes Go 1.27.2 is already installed and on your PATH. Check GOWORK=off GOTOOLCHAIN=local go version before running. These are the same toolchain settings used by the run command below. Use Download ZIP on this Gist and extract the archive into a new directory outside another Go project. The extracted directory should contain main.go, go.mod, go.sum, and README.md. Open a terminal there and run:
GOWORK=off GOTOOLCHAIN=local go run -mod=readonly .The first run downloads the public Go module pinned in go.mod:
github.com/kimjooyoon/gooo-go-ports/examples/agentmesh-service-policy
v0.0.0-20261013184627-743c983dfc4e
This version identifies commit 743c983dfc4e6dab75451ab14cd153df7c9a2d92. Keep go.mod and go.sum with the example to retain that version and its checksum. The program imports generated native Go code from Gooo sources; it does not need a Gooo compiler at runtime. It has no repository checkout, local replacement, or relative source-path dependency.
Expected output is four JSON lines:
{"label":"valid-denial","decision":{"domain_status":"VALID_INPUT","invalid_field":"","matched":false}}
{"label":"invalid-input","decision":{"domain_status":"INVALID_INPUT","invalid_field":"req_type","matched":false}}
{"label":"request-widened","decision":{"domain_status":"VALID_INPUT","invalid_field":"","before_match":false,"after_match":true,"change":"WIDENED"}}
{"label":"widening-witness","decision":{"domain_status":"VALID_INPUT","invalid_field":"","status":"WIDENING_WITNESS","rule_id":"CHECKED_CANDIDATE_REQUEST","supported_subset":false,"has_witness":true,"witness_type":"mcp","witness_name":"a.y","before_match":false,"after_match":true}}The first matcher result is a valid denial: weather does not match the calculator grant. The second call has a malformed service type. Its INVALID_INPUT result is a typed refusal, and its matched: false field is a sentinel. Check domain_status before using any semantic field; an unknown status or a Go error must stop the caller's decision path. The example handles every Go error and checks the expected domain status explicitly.
The impact call shows that replacing mcp://calculator with mcp://* newly matches the weather request. The refinement call takes only the old and candidate patterns and returns mcp://a.y as a widening witness: the candidate mcp://a.* matches it, while the old mcp://*.x does not.
The represented domain is bounded canonical ASCII, with at most 128 bytes per pattern, request type, or request name. It supports the declared single-pattern scheme/name grammar, including its limited wildcard forms; it is not a general URI parser. Refinement compares one old pattern with one candidate pattern. These pure calls compare supplied facts; they do not authorize a service call, check current policy authority, apply a policy change, or establish availability preservation. No human approval is needed to compute these results, and this example dispatches no external effect.
- Gooo language repository
- Module guide at the exact pinned commit, including the precise ASCII grammar and supported pattern forms
Project-affiliated example by asketeddy, prepared with Codex assistance. Gooo Go Ports is independent; no Google endorsement is claimed.
The pinned source was merged in PR #78. Its full PR verification passed. The four results above were also checked using this consumer's public module version and checksum.