Go SDK: Align mode with SEP (#40)

<!-- Provide a brief summary of your changes -->

## Motivation and Context
The SEP-2624 spec defines interceptor modes as "active" | "audit". This
change aligns the Go SDK's interceptor `Mode` value with the SEP spec.

## How Has This Been Tested?
- go test ./... from go/sdk — all packages pass (chain, extension,
integrations/gomiddleware).
- gofmt -l . — clean.
- go vet ./... — clean.

## Breaking Changes
Yes:
- The exported constant interceptors.ModeEnforce is removed and replaced
by interceptors.ModeActive. Callers referencing ModeEnforce must rename.
- The serialized mode value changes from "enforce" to "active". Any
config expecting "enforce" must be updated.

## Types of changes
<!-- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [x] Breaking change (fix or feature that would cause existing
functionality to change)
- [x] Documentation update

## Checklist
<!-- Go over all the following points, and put an `x` in all the boxes
that apply. -->
- [x] I have read the [MCP
Documentation](https://modelcontextprotocol.io)
- [x] My code follows the repository's style guidelines
- [x] New and existing tests pass locally
- [ ] I have added appropriate error handling
- [x] I have added or updated documentation as needed

## Additional context
<!-- Add any other context, implementation notes, or design decisions
-->

Signed-off-by: monikaicampbell <mcampbell350@bloomberg.net>
This commit is contained in:
monikaicampbell 2026-08-21 15:56:07 +01:00 • committed by GitHub
commit bd57572579
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -155,7 +155,7 @@ func TestChain_ExecutionHandler(t *testing.T) {
wantNoPayload bool
}{
{
name: "audit-to-enforce validator override aborts chain",
name: "audit-to-active validator override aborts chain",
interceptor: &interceptors.Validator{
Metadata: interceptors.Metadata{
Name: "v",
@ -169,18 +169,18 @@ func TestChain_ExecutionHandler(t *testing.T) {
}, nil
},
},
directive: &chain.Directive{Mode: modePtr(interceptors.ModeEnforce)},
directive: &chain.Directive{Mode: modePtr(interceptors.ModeActive)},
phase: interceptors.PhaseRequest,
wantStatus: chain.ChainValidationFailed,
wantAborted: true,
},
{
name: "enforce-to-audit validator override does not abort",
name: "active-to-audit validator override does not abort",
interceptor: &interceptors.Validator{
Metadata: interceptors.Metadata{
Name: "v",
Hooks: []interceptors.Hook{{Events: []string{"test/event"}, Phase: interceptors.PhaseRequest}},
Mode: interceptors.ModeEnforce,
Mode: interceptors.ModeActive,
},
Handler: func(_ context.Context, _ *interceptors.Invocation) (*interceptors.ValidationResult, error) {
return &interceptors.ValidationResult{
@ -199,7 +199,7 @@ func TestChain_ExecutionHandler(t *testing.T) {
Metadata: interceptors.Metadata{
Name: "m",
Hooks: []interceptors.Hook{{Events: []string{"test/event"}, Phase: interceptors.PhaseResponse}},
Mode: interceptors.ModeEnforce,
Mode: interceptors.ModeActive,
},
Handler: func(_ context.Context, _ *interceptors.Invocation) (*interceptors.MutationResult, error) {
modified, _ := json.Marshal(map[string]any{"value": "mutated"})
@ -217,7 +217,7 @@ func TestChain_ExecutionHandler(t *testing.T) {
Metadata: interceptors.Metadata{
Name: "v",
Hooks: []interceptors.Hook{{Events: []string{"test/event"}, Phase: interceptors.PhaseRequest}},
Mode: interceptors.ModeEnforce,
Mode: interceptors.ModeActive,
},
Handler: func(_ context.Context, _ *interceptors.Invocation) (*interceptors.ValidationResult, error) {
return &interceptors.ValidationResult{
@ -275,7 +275,7 @@ func TestChain_ExecutionHandler_ShortCircuit(t *testing.T) {
Metadata: interceptors.Metadata{
Name: "v",
Hooks: []interceptors.Hook{{Events: []string{"test/event"}, Phase: interceptors.PhaseRequest}},
Mode: interceptors.ModeEnforce,
Mode: interceptors.ModeActive,
},
Handler: func(_ context.Context, _ *interceptors.Invocation) (*interceptors.ValidationResult, error) {
invoked = true
@ -320,7 +320,7 @@ func TestChain_FailOpenRecordsExecutionResult(t *testing.T) {
Events: []string{"test/event"},
Phase: interceptors.PhaseRequest,
}},
Mode: interceptors.ModeEnforce,
Mode: interceptors.ModeActive,
FailOpen: true,
},
Handler: func(_ context.Context, _ *interceptors.Invocation) (*interceptors.ValidationResult, error) {
@ -334,7 +334,7 @@ func TestChain_FailOpenRecordsExecutionResult(t *testing.T) {
Events: []string{"test/event"},
Phase: interceptors.PhaseRequest,
}},
Mode: interceptors.ModeEnforce,
Mode: interceptors.ModeActive,
},
Handler: func(_ context.Context, _ *interceptors.Invocation) (*interceptors.ValidationResult, error) {
return &interceptors.ValidationResult{Valid: true}, nil
@ -368,7 +368,7 @@ func TestChain_FailOpenRecordsExecutionResult(t *testing.T) {
Events: []string{"test/event"},
Phase: interceptors.PhaseResponse,
}},
Mode: interceptors.ModeEnforce,
Mode: interceptors.ModeActive,
FailOpen: true,
PriorityHint: interceptors.NewPriority(10),
},
@ -383,7 +383,7 @@ func TestChain_FailOpenRecordsExecutionResult(t *testing.T) {
Events: []string{"test/event"},
Phase: interceptors.PhaseResponse,
}},
Mode: interceptors.ModeEnforce,
Mode: interceptors.ModeActive,
PriorityHint: interceptors.NewPriority(20),
},
Handler: func(_ context.Context, _ *interceptors.Invocation) (*interceptors.MutationResult, error) {
@ -468,7 +468,7 @@ func TestChain_AuditModeErrorsDoNotAbort(t *testing.T) {
Events: []string{"test/event"},
Phase: interceptors.PhaseResponse,
}},
Mode: interceptors.ModeEnforce,
Mode: interceptors.ModeActive,
PriorityHint: interceptors.NewPriority(20),
},
Handler: func(_ context.Context, _ *interceptors.Invocation) (*interceptors.MutationResult, error) {