diff --git a/pkgs/mcpx/internal/e2e/effect_test.go b/pkgs/mcpx/internal/e2e/effect_test.go index de04a418f5..321d3e0aba 100644 --- a/pkgs/mcpx/internal/e2e/effect_test.go +++ b/pkgs/mcpx/internal/e2e/effect_test.go @@ -67,6 +67,7 @@ var implementedEffectProbes = map[string]string{ "stats.top": "TestStatsTopLimitsTheRowsTheStatsAPIReports", "proto.askPoll": "TestAskPollCeilingIsReachableFromTheEnvironment", "proto.askRounds": "TestAskRoundsLimitIsReachableFromTheEnvironment", + "proto.askTTL": "TestAskTTLBoundsAnInterruptibleCallFromTheEnvironment", "daemon.address": "TestDaemonAddressIsReachableFromTheEnvironment", "daemon.autostart": "TestDaemonAutostartIsReachableFromTheEnvironment", "http.bodyLimit": "TestHTTPBodyLimitsRejectOversizedBodies", @@ -122,6 +123,7 @@ var effectProbeFuncs = map[string]func(*testing.T){ "TestStatsTopLimitsTheRowsTheStatsAPIReports": TestStatsTopLimitsTheRowsTheStatsAPIReports, "TestAskPollCeilingIsReachableFromTheEnvironment": TestAskPollCeilingIsReachableFromTheEnvironment, "TestAskRoundsLimitIsReachableFromTheEnvironment": TestAskRoundsLimitIsReachableFromTheEnvironment, + "TestAskTTLBoundsAnInterruptibleCallFromTheEnvironment": TestAskTTLBoundsAnInterruptibleCallFromTheEnvironment, "TestDaemonAddressIsReachableFromTheEnvironment": TestDaemonAddressIsReachableFromTheEnvironment, "TestDaemonAutostartIsReachableFromTheEnvironment": TestDaemonAutostartIsReachableFromTheEnvironment, "TestHTTPBodyLimitsRejectOversizedBodies": TestHTTPBodyLimitsRejectOversizedBodies, @@ -380,6 +382,52 @@ func TestAskRoundsLimitIsReachableFromTheEnvironment(t *testing.T) { } } +// proto.askTTL is the lifetime of an interruptible call begun on /v1/ask +// without its own ttl: the daemon cancels the call when it runs out. The +// call is a script that sleeps eight seconds, polled for up to four. +// Oracle: at the default (15m) the call is still running when the polls +// stop; with MCPX_PROTO_ASK_TTL=1s it has ended inside that window, its +// script stopped as timed out after about a second, not eight. +func TestAskTTLBoundsAnInterruptibleCallFromTheEnvironment(t *testing.T) { + outcome := func(env ...string) map[string]any { + t.Helper() + e := newEnv(t, oneServer) + e.setenv(env...) + e.run("ls") + c := e.longSocketClient(t) + _, begun := sockDo(t, c, http.MethodPost, "/v1/ask", + map[string]any{"kind": "exec", "source": "await new Promise((r) => setTimeout(r, 8000));"}) + id, _ := begun["callId"].(string) + if id == "" { + t.Fatalf("no call id: %v", begun) + } + defer sockDo(t, c, http.MethodPost, "/v1/ask/"+id+"/abandon", nil) + var out map[string]any + for stop := time.Now().Add(4 * time.Second); time.Now().Before(stop); { + var st int + st, out = sockDo(t, c, http.MethodGet, "/v1/ask/"+id+"?waitMs=500", nil) + if st != http.StatusOK { + t.Fatalf("poll: %d %v", st, out) + } + if out["done"] == true { + break + } + } + return out + } + + if def := outcome(); def["done"] == true { + t.Fatalf("at the default proto.askTTL the call should still be running after four seconds, got %v", def) + } + bounded := outcome("MCPX_PROTO_ASK_TTL=1s") + run, _ := bounded["result"].(map[string]any) + script, _ := run["result"].(map[string]any) + took, _ := script["durationMs"].(float64) + if bounded["done"] != true || script["timedOut"] != true || took <= 0 || took >= 4000 { + t.Fatalf("proto.askTTL=1s should stop the call at its deadline, got %v", bounded) + } +} + // 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 9ef945e988..893b6997fc 100644 --- a/pkgs/mcpx/internal/e2e/feature_coverage_exemptions.txt +++ b/pkgs/mcpx/internal/e2e/feature_coverage_exemptions.txt @@ -61,7 +61,6 @@ setting script.runtime no integration-test exercise yet; burn-down #8474 (settin setting script.runtimeOrder no integration-test exercise yet; burn-down #8474 (settings script family); needs an EffectProbes entry + e2e test 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.askTTL no integration-test exercise yet; burn-down #8473 (settings proto family); needs an EffectProbes entry + e2e test setting proto.askTimeout no integration-test exercise yet; burn-down #8473 (settings proto 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 diff --git a/pkgs/mcpx/internal/settings/effect.go b/pkgs/mcpx/internal/settings/effect.go index 5e3630c7a9..444d109d07 100644 --- a/pkgs/mcpx/internal/settings/effect.go +++ b/pkgs/mcpx/internal/settings/effect.go @@ -71,6 +71,7 @@ var EffectProbes = map[string]string{ "proxy.timeout": "TestProxyUpstreamTimeoutIsReachableFromTheEnvironment", "proto.askPoll": "TestAskPollCeilingIsReachableFromTheEnvironment", "proto.askRounds": "TestAskRoundsLimitIsReachableFromTheEnvironment", + "proto.askTTL": "TestAskTTLBoundsAnInterruptibleCallFromTheEnvironment", "daemon.address": "TestDaemonAddressIsReachableFromTheEnvironment", "daemon.autostart": "TestDaemonAutostartIsReachableFromTheEnvironment", "http.bodyLimit": "TestHTTPBodyLimitsRejectOversizedBodies", @@ -167,7 +168,6 @@ var EffectExemptions = map[string]string{ "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.askTimeout": "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.askTTL": "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", @@ -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 = 192 // 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 = 191 // 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,