diff --git a/pkgs/mcpx/internal/e2e/effect_test.go b/pkgs/mcpx/internal/e2e/effect_test.go index 37ef1185cc..ad56268ca6 100644 --- a/pkgs/mcpx/internal/e2e/effect_test.go +++ b/pkgs/mcpx/internal/e2e/effect_test.go @@ -71,6 +71,7 @@ var implementedEffectProbes = map[string]string{ "proto.askTTL": "TestAskTTLBoundsAnInterruptibleCallFromTheEnvironment", "proto.askTimeout": "TestAskTimeoutReleasesAHeldRequestFromTheEnvironment", "proto.stateTTL": "TestStateTTLExpiresAResumableRequestFromTheEnvironment", + "proto.sessionIdle": "TestSessionIdleReapsAnUnusedSessionFromTheEnvironment", "daemon.address": "TestDaemonAddressIsReachableFromTheEnvironment", "daemon.autostart": "TestDaemonAutostartIsReachableFromTheEnvironment", "http.bodyLimit": "TestHTTPBodyLimitsRejectOversizedBodies", @@ -129,6 +130,7 @@ var effectProbeFuncs = map[string]func(*testing.T){ "TestAskTTLBoundsAnInterruptibleCallFromTheEnvironment": TestAskTTLBoundsAnInterruptibleCallFromTheEnvironment, "TestAskTimeoutReleasesAHeldRequestFromTheEnvironment": TestAskTimeoutReleasesAHeldRequestFromTheEnvironment, "TestStateTTLExpiresAResumableRequestFromTheEnvironment": TestStateTTLExpiresAResumableRequestFromTheEnvironment, + "TestSessionIdleReapsAnUnusedSessionFromTheEnvironment": TestSessionIdleReapsAnUnusedSessionFromTheEnvironment, "TestDaemonAddressIsReachableFromTheEnvironment": TestDaemonAddressIsReachableFromTheEnvironment, "TestDaemonAutostartIsReachableFromTheEnvironment": TestDaemonAutostartIsReachableFromTheEnvironment, "TestHTTPBodyLimitsRejectOversizedBodies": TestHTTPBodyLimitsRejectOversizedBodies, @@ -568,6 +570,44 @@ func TestStateTTLExpiresAResumableRequestFromTheEnvironment(t *testing.T) { } } +// proto.sessionIdle is how long an unused legacy Streamable HTTP session +// is kept. Idle sessions are reaped when a new one is opened, so the probe +// opens a session, leaves it alone for three seconds, opens a second one +// and then asks to end the first. +// Oracle: at the default (30m) the first session still exists and DELETE +// ends it (204); with MCPX_PROTO_SESSION_IDLE=1s it was reaped and DELETE +// answers 404. +func TestSessionIdleReapsAnUnusedSessionFromTheEnvironment(t *testing.T) { + endStatus := func(env ...string) int { + t.Helper() + e := newEnv(t, oneServer) + e.setenv(env...) + e.run("ls") + ep := endpointOf(t, e) + first := mcpInit(t, ep) + time.Sleep(3 * time.Second) + _ = mcpInit(t, ep) + req, err := http.NewRequest(http.MethodDelete, ep+"/mcp", nil) + if err != nil { + t.Fatal(err) + } + req.Header.Set("Mcp-Session-Id", first) + resp, err := (&http.Client{Timeout: 30 * time.Second}).Do(req) + if err != nil { + t.Fatal(err) + } + _ = resp.Body.Close() + return resp.StatusCode + } + + if got := endStatus(); got != http.StatusNoContent { + t.Fatalf("at the default proto.sessionIdle a session idle for three seconds should still end with 204, got %d", got) + } + if got := endStatus("MCPX_PROTO_SESSION_IDLE=1s"); got != http.StatusNotFound { + t.Fatalf("proto.sessionIdle=1s should reap a session idle for three seconds, so DELETE should answer 404, 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 diff --git a/pkgs/mcpx/internal/e2e/feature_coverage_exemptions.txt b/pkgs/mcpx/internal/e2e/feature_coverage_exemptions.txt index 7c1d1a6c8b..1823a4cab9 100644 --- a/pkgs/mcpx/internal/e2e/feature_coverage_exemptions.txt +++ b/pkgs/mcpx/internal/e2e/feature_coverage_exemptions.txt @@ -67,7 +67,6 @@ setting proto.native no integration-test exercise yet; burn-down #8473 (settings 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 proto.sessionIdle 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 diff --git a/pkgs/mcpx/internal/settings/effect.go b/pkgs/mcpx/internal/settings/effect.go index 8862e2d769..5c804bf632 100644 --- a/pkgs/mcpx/internal/settings/effect.go +++ b/pkgs/mcpx/internal/settings/effect.go @@ -74,6 +74,7 @@ var EffectProbes = map[string]string{ "proto.askTTL": "TestAskTTLBoundsAnInterruptibleCallFromTheEnvironment", "proto.askTimeout": "TestAskTimeoutReleasesAHeldRequestFromTheEnvironment", "proto.stateTTL": "TestStateTTLExpiresAResumableRequestFromTheEnvironment", + "proto.sessionIdle": "TestSessionIdleReapsAnUnusedSessionFromTheEnvironment", "daemon.address": "TestDaemonAddressIsReachableFromTheEnvironment", "daemon.autostart": "TestDaemonAutostartIsReachableFromTheEnvironment", "http.bodyLimit": "TestHTTPBodyLimitsRejectOversizedBodies", @@ -172,7 +173,6 @@ var EffectExemptions = map[string]string{ "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", - "proto.sessionIdle": "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", "plumbing.allowTsJsOverlap": "plumbing switch: the branch it guards is read in its own package, but no e2e with/without probe exists yet - plumbing is the ratchet's expected bulk", "plumbing.sourceDirRecursive": "plumbing switch: the branch it guards is read in its own package, but no e2e with/without probe exists yet - plumbing is the ratchet's expected bulk", "plumbing.sourceDirAllowed": "plumbing switch: the branch it guards is read in its own package, but no e2e with/without probe exists yet - plumbing is the ratchet's expected bulk", @@ -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 = 189 // 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 = 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. // CheckEffectCoverage returns one violation per way the probe and // exemption maps fail to cover reg exactly: a setting with neither,