Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions pkgs/mcpx/internal/e2e/effect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ var implementedEffectProbes = map[string]string{
"proto.askTimeout": "TestAskTimeoutReleasesAHeldRequestFromTheEnvironment",
"proto.stateTTL": "TestStateTTLExpiresAResumableRequestFromTheEnvironment",
"proto.sessionIdle": "TestSessionIdleReapsAnUnusedSessionFromTheEnvironment",
"proto.mcpPath": "TestMCPPathMovesTheEndpointFromTheEnvironment",
"proto.serveMCP": "TestServeMCPUnmountsTheEndpointFromTheEnvironment",
"daemon.address": "TestDaemonAddressIsReachableFromTheEnvironment",
"daemon.autostart": "TestDaemonAutostartIsReachableFromTheEnvironment",
"http.bodyLimit": "TestHTTPBodyLimitsRejectOversizedBodies",
Expand Down Expand Up @@ -131,6 +133,8 @@ var effectProbeFuncs = map[string]func(*testing.T){
"TestAskTimeoutReleasesAHeldRequestFromTheEnvironment": TestAskTimeoutReleasesAHeldRequestFromTheEnvironment,
"TestStateTTLExpiresAResumableRequestFromTheEnvironment": TestStateTTLExpiresAResumableRequestFromTheEnvironment,
"TestSessionIdleReapsAnUnusedSessionFromTheEnvironment": TestSessionIdleReapsAnUnusedSessionFromTheEnvironment,
"TestMCPPathMovesTheEndpointFromTheEnvironment": TestMCPPathMovesTheEndpointFromTheEnvironment,
"TestServeMCPUnmountsTheEndpointFromTheEnvironment": TestServeMCPUnmountsTheEndpointFromTheEnvironment,
"TestDaemonAddressIsReachableFromTheEnvironment": TestDaemonAddressIsReachableFromTheEnvironment,
"TestDaemonAutostartIsReachableFromTheEnvironment": TestDaemonAutostartIsReachableFromTheEnvironment,
"TestHTTPBodyLimitsRejectOversizedBodies": TestHTTPBodyLimitsRejectOversizedBodies,
Expand Down Expand Up @@ -608,6 +612,69 @@ func TestSessionIdleReapsAnUnusedSessionFromTheEnvironment(t *testing.T) {
}
}

// initializeStatus posts an initialize to path on the daemon and returns
// the HTTP status, so a probe can tell where MCP is mounted.
func initializeStatus(t *testing.T, ep, path string) int {
t.Helper()
body := `{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"t","version":"1"}}}`
req, err := http.NewRequest(http.MethodPost, ep+path, strings.NewReader(body))
if err != nil {
t.Fatal(err)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Accept", "application/json, text/event-stream")
resp, err := (&http.Client{Timeout: 30 * time.Second}).Do(req)
if err != nil {
t.Fatal(err)
}
_ = resp.Body.Close()
return resp.StatusCode
}

// proto.mcpPath is where the daemon mounts MCP.
// Oracle: at the default an initialize to /mcp succeeds and one to
// /tools/mcp does not; with MCPX_PROTO_MCP_PATH=/tools/mcp it is the
// other way round.
func TestMCPPathMovesTheEndpointFromTheEnvironment(t *testing.T) {
statuses := func(env ...string) (atMCP, atMoved int) {
t.Helper()
e := newEnv(t, oneServer)
e.setenv(env...)
e.run("ls")
ep := endpointOf(t, e)
return initializeStatus(t, ep, "/mcp"), initializeStatus(t, ep, "/tools/mcp")
}

if atMCP, atMoved := statuses(); atMCP != http.StatusOK || atMoved == http.StatusOK {
t.Fatalf("at the default proto.mcpPath MCP should answer at /mcp only, got /mcp=%d /tools/mcp=%d", atMCP, atMoved)
}
if atMCP, atMoved := statuses("MCPX_PROTO_MCP_PATH=/tools/mcp"); atMoved != http.StatusOK || atMCP == http.StatusOK {
t.Fatalf("proto.mcpPath=/tools/mcp should move MCP there, got /mcp=%d /tools/mcp=%d", atMCP, atMoved)
}
}

// proto.serveMCP mounts mcpx's own MCP server on the daemon.
// Oracle: at the default an initialize to /mcp succeeds; with
// MCPX_PROTO_SERVE_MCP=false the daemon still answers /v1 but not /mcp.
func TestServeMCPUnmountsTheEndpointFromTheEnvironment(t *testing.T) {
status := func(env ...string) int {
t.Helper()
e := newEnv(t, oneServer)
e.setenv(env...)
e.run("ls")
got := initializeStatus(t, endpointOf(t, e), "/mcp")
t.Logf("serveMCP env=%v status=%d", env, got)
return got
}

if got := status(); got != http.StatusOK {
t.Fatalf("at the default proto.serveMCP the daemon should answer MCP at /mcp, got %d", got)
}
if got := status("MCPX_PROTO_SERVE_MCP=false"); got == http.StatusOK {
t.Fatalf("proto.serveMCP=false should leave /mcp unmounted, got %d", got)
}
}

// TestDaemonAddressIsReachableFromTheEnvironment is the effect probe
// for daemon.address (#8468 chain 1). The exemption it replaced said
// a bind address is a network identity the harness cannot vary
Expand Down
2 changes: 0 additions & 2 deletions pkgs/mcpx/internal/e2e/feature_coverage_exemptions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,9 @@ setting script.runtimeOrder no integration-test exercise yet; burn-down #8474 (s
setting script.runtimes no integration-test exercise yet; burn-down #8474 (settings script family); needs an EffectProbes entry + e2e test
setting script.suffix no integration-test exercise yet; burn-down #8474 (settings script family); needs an EffectProbes entry + e2e test
setting proto.elicitationPerMinute no integration-test exercise yet; burn-down #8473 (settings proto family); needs an EffectProbes entry + e2e test
setting proto.mcpPath no integration-test exercise yet; burn-down #8473 (settings proto family); needs an EffectProbes entry + e2e test
setting proto.native no integration-test exercise yet; burn-down #8473 (settings proto family); needs an EffectProbes entry + e2e test
setting proto.samplingPerMinute no integration-test exercise yet; burn-down #8473 (settings proto family); needs an EffectProbes entry + e2e test
setting proto.samplingSessionPerMinute no integration-test exercise yet; burn-down #8473 (settings proto family); needs an EffectProbes entry + e2e test
setting proto.serveMCP no integration-test exercise yet; burn-down #8473 (settings proto family); needs an EffectProbes entry + e2e test
setting protoMessages.listMaxAge no integration-test exercise yet; burn-down #8473 (settings proto family); needs an EffectProbes entry + e2e test
setting protoMessages.readMaxAge no integration-test exercise yet; burn-down #8473 (settings proto family); needs an EffectProbes entry + e2e test
setting protoMessages.taskAfter no integration-test exercise yet; burn-down #8473 (settings proto family); needs an EffectProbes entry + e2e test
Expand Down
6 changes: 3 additions & 3 deletions pkgs/mcpx/internal/settings/effect.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ var EffectProbes = map[string]string{
"proto.askTimeout": "TestAskTimeoutReleasesAHeldRequestFromTheEnvironment",
"proto.stateTTL": "TestStateTTLExpiresAResumableRequestFromTheEnvironment",
"proto.sessionIdle": "TestSessionIdleReapsAnUnusedSessionFromTheEnvironment",
"proto.mcpPath": "TestMCPPathMovesTheEndpointFromTheEnvironment",
"proto.serveMCP": "TestServeMCPUnmountsTheEndpointFromTheEnvironment",
"daemon.address": "TestDaemonAddressIsReachableFromTheEnvironment",
"daemon.autostart": "TestDaemonAutostartIsReachableFromTheEnvironment",
"http.bodyLimit": "TestHTTPBodyLimitsRejectOversizedBodies",
Expand Down Expand Up @@ -168,8 +170,6 @@ var EffectExemptions = map[string]string{
"catalog.bias": "catalog ranking/truncation: the fake server's tool set is too small for a budget or bias change to alter the listing observably",
"catalog.instructions": "the fake MCP server serves no server instructions, so `types` output cannot differ either way until a fixture gains instructions",
"proto.native": "protocol negotiation/wire behaviour between mcpx and a peer: era fixtures cover negotiation end-to-end, but no per-setting with/without probe exists yet",
"proto.serveMCP": "protocol negotiation/wire behaviour between mcpx and a peer: era fixtures cover negotiation end-to-end, but no per-setting with/without probe exists yet",
"proto.mcpPath": "protocol negotiation/wire behaviour between mcpx and a peer: era fixtures cover negotiation end-to-end, but no per-setting with/without probe exists yet",
"proto.elicitationPerMinute": "daemon proto rate limit: its effect appears only when an upstream server exceeds the per-minute elicitation bound, a flood the e2e harness's fake server does not drive deterministically; the limiter itself is covered by internal/mcpclient and internal/daemon ratelimit tests",
"proto.samplingPerMinute": "daemon proto rate limit: its effect appears only when an upstream server exceeds the per-minute sampling bound, a flood the e2e harness's fake server does not drive deterministically; the limiter itself is covered by internal/mcpclient and internal/daemon ratelimit tests",
"proto.samplingSessionPerMinute": "daemon proto rate limit: its effect appears only when one session exceeds the per-minute sampling bound, a flood the e2e harness's fake server does not drive deterministically; the limiter itself is covered by internal/mcpclient and internal/daemon ratelimit tests",
Expand Down Expand Up @@ -290,7 +290,7 @@ var EffectExemptions = map[string]string{
// EffectExemptionPin is the ratchet: the exemption count at the time
// the guard landed. It may only ever be lowered, and only in the PR
// that removes an exemption by adding the probe that replaces it.
const EffectExemptionPin = 188 // Shrunk 2026-11-18 (#8473 chain 6): proto.sessionIdle gained a reaped-session probe. Earlier shrunk 2026-11-18 (#8473 chain 5): proto.stateTTL gained a late-resume probe. Earlier shrunk 2026-11-18 (#8473 chain 4): proto.askTimeout gained a held-request probe. Earlier shrunk 2026-11-18 (#8473 chain 3): proto.askTTL gained a /v1/ask deadline probe. Earlier shrunk 2026-11-18 (#8473 chain 2): proto.askRounds gained a two-round MCP e2e probe. Earlier shrunk 2026-11-18 (#8468 chain 2): daemon.autostart gained its probe. Earlier shrunk 2026-11-17: (#8467 settings core-paths burn-down) paths.plugins gained its probe. Earlier shrunk 2026-11-17: (#8469) 14 http.* and transport.* settings gained their probes. Earlier shrunk 2026-11-17: (#8470 burn-down) stats.top gained its probe. Earlier shrunk 2026-11-17 (#8467 settings core-paths burn-down): paths.cache gained its probe. Earlier shrunk 2026-11-17 (#8467 settings core-paths burn-down): paths.scripts gained its probe. Earlier shrunk 2026-11-17 (#8468 chain 1): daemon.address gained its probe. Earlier shrunk 2026-11-17 (#8473 chain 1): proto.askPoll gained its probe. Deliberate +1 (2026-11-14, #1917 remainder shepherd of PR #7818) for script.language: covered by deterministic internal/runner tests (TestEffectiveScriptLanguage, TestExplicitPythonLanguageRunsInlineSnippet); the e2e harness script fixtures are TypeScript-only. Earlier deliberate +3 (2026-11-09, #2716) for proto.elicitationPerMinute, proto.samplingPerMinute and proto.samplingSessionPerMinute: daemon rate limits whose effect needs an over-limit sampling/elicitation flood no e2e fixture drives deterministically; the limiter is covered by internal/mcpclient and internal/daemon ratelimit tests. Earlier deliberate raises: +1 for daemon.roots and +8 for model.*: model settings are covered by internal/model and daemon unit tests; settings-driven e2e probes are not yet present. Deliberate +1 (2026-11-03, #1925 slice 3) for sampling.answerLocally: same model-layer coverage, daemon unit tests in internal/daemon/sampling_local_test.go. Deliberate +1 (2026-11-03, #5242) for plugin.disabledTools: read by the opencode plugin host (JS side); the Go e2e harness does not drive the plugin host, the same basis as every other plugin.* exemption. Deliberate +5 (2026-11-04, #1915 stage 2): import graph, missing, dynamic, cross-project and network policies are covered by deterministic internal/preflight tests, but the e2e harness has no isolated Deno graph fixture yet. Deliberate +2 (2026-11-05, #1911): checker error and unsupported-runtime policies are covered by deterministic internal/preflight stub-runtime tests; the e2e harness has no isolated Deno checker fixture.
const EffectExemptionPin = 186 // Shrunk 2026-11-18 (#8473 chain 7): proto.mcpPath and proto.serveMCP gained mount probes. Earlier shrunk 2026-11-18 (#8473 chain 6): proto.sessionIdle gained a reaped-session probe. Earlier shrunk 2026-11-18 (#8473 chain 5): proto.stateTTL gained a late-resume probe. Earlier shrunk 2026-11-18 (#8473 chain 4): proto.askTimeout gained a held-request probe. Earlier shrunk 2026-11-18 (#8473 chain 3): proto.askTTL gained a /v1/ask deadline probe. Earlier shrunk 2026-11-18 (#8473 chain 2): proto.askRounds gained a two-round MCP e2e probe. Earlier shrunk 2026-11-18 (#8468 chain 2): daemon.autostart gained its probe. Earlier shrunk 2026-11-17: (#8467 settings core-paths burn-down) paths.plugins gained its probe. Earlier shrunk 2026-11-17: (#8469) 14 http.* and transport.* settings gained their probes. Earlier shrunk 2026-11-17: (#8470 burn-down) stats.top gained its probe. Earlier shrunk 2026-11-17 (#8467 settings core-paths burn-down): paths.cache gained its probe. Earlier shrunk 2026-11-17 (#8467 settings core-paths burn-down): paths.scripts gained its probe. Earlier shrunk 2026-11-17 (#8468 chain 1): daemon.address gained its probe. Earlier shrunk 2026-11-17 (#8473 chain 1): proto.askPoll gained its probe. Deliberate +1 (2026-11-14, #1917 remainder shepherd of PR #7818) for script.language: covered by deterministic internal/runner tests (TestEffectiveScriptLanguage, TestExplicitPythonLanguageRunsInlineSnippet); the e2e harness script fixtures are TypeScript-only. Earlier deliberate +3 (2026-11-09, #2716) for proto.elicitationPerMinute, proto.samplingPerMinute and proto.samplingSessionPerMinute: daemon rate limits whose effect needs an over-limit sampling/elicitation flood no e2e fixture drives deterministically; the limiter is covered by internal/mcpclient and internal/daemon ratelimit tests. Earlier deliberate raises: +1 for daemon.roots and +8 for model.*: model settings are covered by internal/model and daemon unit tests; settings-driven e2e probes are not yet present. Deliberate +1 (2026-11-03, #1925 slice 3) for sampling.answerLocally: same model-layer coverage, daemon unit tests in internal/daemon/sampling_local_test.go. Deliberate +1 (2026-11-03, #5242) for plugin.disabledTools: read by the opencode plugin host (JS side); the Go e2e harness does not drive the plugin host, the same basis as every other plugin.* exemption. Deliberate +5 (2026-11-04, #1915 stage 2): import graph, missing, dynamic, cross-project and network policies are covered by deterministic internal/preflight tests, but the e2e harness has no isolated Deno graph fixture yet. Deliberate +2 (2026-11-05, #1911): checker error and unsupported-runtime policies are covered by deterministic internal/preflight stub-runtime tests; the e2e harness has no isolated Deno checker fixture.

// CheckEffectCoverage returns one violation per way the probe and
// exemption maps fail to cover reg exactly: a setting with neither,
Expand Down