Open
Conversation
Introduces a PolicyGate interface that allows enterprise or downstream code to gate MCP server creation without modifying the OSS codebase. The default allowAllGate returns nil for all operations, so existing OSS behavior is unchanged. Downstream binaries call RegisterPolicyGate at startup to install a real enforcement gate. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4614 +/- ##
==========================================
+ Coverage 68.85% 68.89% +0.04%
==========================================
Files 505 506 +1
Lines 52425 52437 +12
==========================================
+ Hits 36096 36126 +30
+ Misses 13536 13520 -16
+ Partials 2793 2791 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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
Enterprise and downstream deployments need to enforce policy at the point where MCP server containers are created, without forking or patching the OSS runner. Without an extension point, every policy check would require modifying upstream code.
PolicyGateinterface inpkg/runner/policy_gate.gowithCheckCreateServer(ctx, cfg) errorNoopPolicyGate(exported) for downstream implementations to embed for forward-compatibility as the interface growsallowAllGate) returns nil for all operations — zero behavior change for OSS usersRegisterPolicyGate(g PolicyGate)lets enterprise/downstream binaries install a real gate at startup (thread-safe viasync.Mutex)Runner.Runjust beforeruntime.Setupfor local workloads; a returned error blocks creation with"server creation blocked by policy: %w"Closes stacklok/stacklok-enterprise-platform#91
Type of change
Test plan
task test)Four unit tests in
pkg/runner/policy_gate_test.go:NoopPolicyGateembed returns nilRegisterPolicyGatereplaces the active gate; an error-returning gate propagates the sentinel errorallowAllGateEach test that mutates the package-level gate saves and restores the original via
t.Cleanup.Changes
pkg/runner/policy_gate.goRegisterPolicyGate,NoopPolicyGatepkg/runner/runner.goruntime.Setupin the local-workload branchpkg/runner/policy_gate_test.goDoes this introduce a user-facing change?
No. The default gate is a no-op; existing OSS behavior is unchanged.
Special notes for reviewers
The
NoopPolicyGateexported struct is intentional — it gives downstream implementations a safe embed target so that adding new methods toPolicyGatein future issues doesn't break their builds.Generated with Claude Code