diff --git a/pkgs/mcpx/internal/e2e/effect_test.go b/pkgs/mcpx/internal/e2e/effect_test.go index ddf9094de7..37ef1185cc 100644 --- a/pkgs/mcpx/internal/e2e/effect_test.go +++ b/pkgs/mcpx/internal/e2e/effect_test.go @@ -70,6 +70,7 @@ var implementedEffectProbes = map[string]string{ "proto.askRounds": "TestAskRoundsLimitIsReachableFromTheEnvironment", "proto.askTTL": "TestAskTTLBoundsAnInterruptibleCallFromTheEnvironment", "proto.askTimeout": "TestAskTimeoutReleasesAHeldRequestFromTheEnvironment", + "proto.stateTTL": "TestStateTTLExpiresAResumableRequestFromTheEnvironment", "daemon.address": "TestDaemonAddressIsReachableFromTheEnvironment", "daemon.autostart": "TestDaemonAutostartIsReachableFromTheEnvironment", "http.bodyLimit": "TestHTTPBodyLimitsRejectOversizedBodies", @@ -127,6 +128,7 @@ var effectProbeFuncs = map[string]func(*testing.T){ "TestAskRoundsLimitIsReachableFromTheEnvironment": TestAskRoundsLimitIsReachableFromTheEnvironment, "TestAskTTLBoundsAnInterruptibleCallFromTheEnvironment": TestAskTTLBoundsAnInterruptibleCallFromTheEnvironment, "TestAskTimeoutReleasesAHeldRequestFromTheEnvironment": TestAskTimeoutReleasesAHeldRequestFromTheEnvironment, + "TestStateTTLExpiresAResumableRequestFromTheEnvironment": TestStateTTLExpiresAResumableRequestFromTheEnvironment, "TestDaemonAddressIsReachableFromTheEnvironment": TestDaemonAddressIsReachableFromTheEnvironment, "TestDaemonAutostartIsReachableFromTheEnvironment": TestDaemonAutostartIsReachableFromTheEnvironment, "TestHTTPBodyLimitsRejectOversizedBodies": TestHTTPBodyLimitsRejectOversizedBodies, @@ -510,6 +512,62 @@ func TestAskTimeoutReleasesAHeldRequestFromTheEnvironment(t *testing.T) { } } +// proto.stateTTL is how long a requestState handed to a modern client +// stays resumable. The client is asked for a repository, waits three +// seconds, then resumes with its answer. +// Oracle: at the default (30m) the resumed call completes with the answer; +// with MCPX_PROTO_STATE_TTL=1s the resume is refused as expired. +func TestStateTTLExpiresAResumableRequestFromTheEnvironment(t *testing.T) { + resume := func(env ...string) string { + t.Helper() + e := askEnv(t) + e.setenv(env...) + e.run("refresh") + ep := e.endpoint(t) + params := map[string]any{ + "name": "mcpx_call", + "arguments": map[string]any{"namespace": "ask", "tool": "need_repo"}, + "_meta": map[string]any{ + "io.modelcontextprotocol/protocolVersion": "2026-07-28", + "io.modelcontextprotocol/clientCapabilities": map[string]any{ + "elicitation": map[string]any{"form": map[string]any{}}, + }, + }, + } + post := func(id int) map[string]any { + resp := mcpPost(t, ep, "", map[string]any{"jsonrpc": "2.0", "id": id, "method": "tools/call", "params": params}) + defer func() { _ = resp.Body.Close() }() + var frame map[string]any + if err := json.NewDecoder(resp.Body).Decode(&frame); err != nil { + t.Fatal(err) + } + return frame + } + first := post(1) + result, _ := first["result"].(map[string]any) + state, _ := result["requestState"].(string) + requests, _ := result["inputRequests"].(map[string]any) + if result["resultType"] != "input_required" || state == "" || len(requests) != 1 { + t.Fatalf("expected one resumable question, got %s", dumpJSON(t, first)) + } + answers := map[string]any{} + for id := range requests { + answers[id] = map[string]any{"action": "accept", "content": map[string]any{"repo": "me/late"}} + } + time.Sleep(3 * time.Second) + params["requestState"] = state + params["inputResponses"] = answers + return dumpJSON(t, post(2)) + } + + if got := resume(); !strings.Contains(got, `"resultType":"complete"`) || !strings.Contains(got, "me/late") { + t.Fatalf("at the default proto.stateTTL a resume after three seconds should complete, got %s", got) + } + if got := resume("MCPX_PROTO_STATE_TTL=1s"); !strings.Contains(got, "requestState expired") { + t.Fatalf("proto.stateTTL=1s should refuse a resume after three seconds, got %s", 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 3aa950bb00..7c1d1a6c8b 100644 --- a/pkgs/mcpx/internal/e2e/feature_coverage_exemptions.txt +++ b/pkgs/mcpx/internal/e2e/feature_coverage_exemptions.txt @@ -68,7 +68,6 @@ setting proto.samplingPerMinute no integration-test exercise yet; burn-down #847 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 proto.stateTTL 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 5d6d547486..8862e2d769 100644 --- a/pkgs/mcpx/internal/settings/effect.go +++ b/pkgs/mcpx/internal/settings/effect.go @@ -73,6 +73,7 @@ var EffectProbes = map[string]string{ "proto.askRounds": "TestAskRoundsLimitIsReachableFromTheEnvironment", "proto.askTTL": "TestAskTTLBoundsAnInterruptibleCallFromTheEnvironment", "proto.askTimeout": "TestAskTimeoutReleasesAHeldRequestFromTheEnvironment", + "proto.stateTTL": "TestStateTTLExpiresAResumableRequestFromTheEnvironment", "daemon.address": "TestDaemonAddressIsReachableFromTheEnvironment", "daemon.autostart": "TestDaemonAutostartIsReachableFromTheEnvironment", "http.bodyLimit": "TestHTTPBodyLimitsRejectOversizedBodies", @@ -171,7 +172,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.stateTTL": "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.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", @@ -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 = 190 // 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 = 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. // CheckEffectCoverage returns one violation per way the probe and // exemption maps fail to cover reg exactly: a setting with neither,