From 63926939b5b3ae8af3311d4cfd83204d473c1b48 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 18 Nov 2026 19:07:06 +0000 Subject: [PATCH] test(mcpx): probe completion.maxValues (#8473 chain 37) The fake server answers completion/complete with a fixed list when FAKEMCP_COMPLETIONS is set, so /v1/complete can be seen returning all three values by default and one under completion.maxValues=1. EffectExemptionPin 108 -> 107. Co-Authored-By: Claude Opus 5.5 --- pkgs/mcpx/internal/e2e/effect_test.go | 47 +++++++++++++++++++ .../e2e/feature_coverage_exemptions.txt | 1 - pkgs/mcpx/internal/settings/effect.go | 4 +- .../mcpx/internal/testsupport/fakemcp/main.go | 22 +++++++++ 4 files changed, 71 insertions(+), 3 deletions(-) diff --git a/pkgs/mcpx/internal/e2e/effect_test.go b/pkgs/mcpx/internal/e2e/effect_test.go index 17c080e09c..5ddeb72331 100644 --- a/pkgs/mcpx/internal/e2e/effect_test.go +++ b/pkgs/mcpx/internal/e2e/effect_test.go @@ -101,6 +101,7 @@ var implementedEffectProbes = map[string]string{ "protoTasks.maxPerRequestor": "TestProtoTasksMaxPerRequestorCapsUnfinishedTasksFromTheEnvironment", "protoTasks.perMinute": "TestProtoTasksPerMinuteWindowsTaskReadsFromTheEnvironment", "events.history": "TestEventsHistoryBoundsTheReplay", + "completion.maxValues": "TestCompletionMaxValuesCapsTheValues", "catalog.instructions": "TestCatalogInstructionsShowsServerGuidance", "plumbing.launcherPlaceholderRepeat": "TestPlumbingLauncherPlaceholderRepeatAllowsATwiceUsedName", "plumbing.allowTsJsOverlap": "TestPlumbingAllowTsJsOverlapPicksAmbiguousScripts", @@ -240,6 +241,7 @@ var effectProbeFuncs = map[string]func(*testing.T){ "TestProtoTasksMaxPerRequestorCapsUnfinishedTasksFromTheEnvironment": TestProtoTasksMaxPerRequestorCapsUnfinishedTasksFromTheEnvironment, "TestProtoTasksPerMinuteWindowsTaskReadsFromTheEnvironment": TestProtoTasksPerMinuteWindowsTaskReadsFromTheEnvironment, "TestEventsHistoryBoundsTheReplay": TestEventsHistoryBoundsTheReplay, + "TestCompletionMaxValuesCapsTheValues": TestCompletionMaxValuesCapsTheValues, "TestCatalogInstructionsShowsServerGuidance": TestCatalogInstructionsShowsServerGuidance, "TestPlumbingLauncherPlaceholderRepeatAllowsATwiceUsedName": TestPlumbingLauncherPlaceholderRepeatAllowsATwiceUsedName, "TestPlumbingAllowTsJsOverlapPicksAmbiguousScripts": TestPlumbingAllowTsJsOverlapPicksAmbiguousScripts, @@ -2632,6 +2634,51 @@ func TestCatalogInstructionsShowsServerGuidance(t *testing.T) { } } +// completingServer is oneServer's fake answering every completion with +// three values, set through FAKEMCP_COMPLETIONS (JSON-escaped, because +// newEnv replaces every "FAKE" in a config with the binary's path). +const completingServer = `{ + "mcpServers": { + "demo": { + "command": "FAKE", + "env": { "\u0046AKEMCP_COMPLETIONS": "alpha,beta,gamma" }, + "mcpx": { "sharing": "shared", "scope": "global" } + } + } +}` + +// TestCompletionMaxValuesCapsTheValues is the effect probe for +// completion.maxValues: all three of the server's values come back by +// default, and one once the environment caps completions at one. +func TestCompletionMaxValuesCapsTheValues(t *testing.T) { + values := func(env ...string) int { + e := newEnv(t, completingServer) + e.setenv(env...) + e.run("refresh") + body := `{"server":"demo","ref":{"type":"ref/prompt","name":"summarise"},"argument":{"name":"style","value":""}}` + resp, err := e.socketClient(t).Post("http://mcpx/v1/complete", "application/json", strings.NewReader(body)) + if err != nil { + t.Fatal(err) + } + defer func() { _ = resp.Body.Close() }() + var got struct { + Completion struct { + Values []string `json:"values"` + } `json:"completion"` + } + if err := json.NewDecoder(resp.Body).Decode(&got); err != nil { + t.Fatalf("decode completion (status %d): %v", resp.StatusCode, err) + } + return len(got.Completion.Values) + } + if n := values(); n != 3 { + t.Errorf("by default all three completion values should come back, got %d", n) + } + if n := values("MCPX_COMPLETION_MAX_VALUES=1"); n != 1 { + t.Errorf("completion.maxValues=1 should cap the values at one, got %d", n) + } +} + // 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 f6041000b9..cc96a541bf 100644 --- a/pkgs/mcpx/internal/e2e/feature_coverage_exemptions.txt +++ b/pkgs/mcpx/internal/e2e/feature_coverage_exemptions.txt @@ -112,7 +112,6 @@ setting autostart.idleExit no integration-test exercise yet; burn-down #8470 (se setting autostart.logTail no integration-test exercise yet; burn-down #8470 (settings long-tail families); needs an EffectProbes entry + e2e test setting autostart.pingTimeout no integration-test exercise yet; burn-down #8470 (settings long-tail families); needs an EffectProbes entry + e2e test setting autostart.pollInterval no integration-test exercise yet; burn-down #8470 (settings long-tail families); needs an EffectProbes entry + e2e test -setting completion.maxValues no integration-test exercise yet; burn-down #8470 (settings long-tail families); needs an EffectProbes entry + e2e test setting deps.autoInstall no integration-test exercise yet; burn-down #8470 (settings long-tail families); needs an EffectProbes entry + e2e test setting doctor.timeout no integration-test exercise yet; burn-down #8470 (settings long-tail families); needs an EffectProbes entry + e2e test setting events.reconnect no integration-test exercise yet; burn-down #8470 (settings long-tail families); needs an EffectProbes entry + e2e test diff --git a/pkgs/mcpx/internal/settings/effect.go b/pkgs/mcpx/internal/settings/effect.go index 3630406ab9..c0e9734771 100644 --- a/pkgs/mcpx/internal/settings/effect.go +++ b/pkgs/mcpx/internal/settings/effect.go @@ -101,6 +101,7 @@ var EffectProbes = map[string]string{ "protoTasks.maxPerRequestor": "TestProtoTasksMaxPerRequestorCapsUnfinishedTasksFromTheEnvironment", "protoTasks.perMinute": "TestProtoTasksPerMinuteWindowsTaskReadsFromTheEnvironment", "events.history": "TestEventsHistoryBoundsTheReplay", + "completion.maxValues": "TestCompletionMaxValuesCapsTheValues", "catalog.instructions": "TestCatalogInstructionsShowsServerGuidance", "plumbing.launcherPlaceholderRepeat": "TestPlumbingLauncherPlaceholderRepeatAllowsATwiceUsedName", "plumbing.allowTsJsOverlap": "TestPlumbingAllowTsJsOverlapPicksAmbiguousScripts", @@ -244,7 +245,6 @@ var EffectExemptions = map[string]string{ "autostart.pingTimeout": "client autostart mechanics: the harness itself depends on these to start daemons, so varying them per-test would fight the fixture", "autostart.logTail": "client autostart mechanics: the harness itself depends on these to start daemons, so varying them per-test would fight the fixture", "search.semantic": "semantic search needs an embeddings backend fixture the harness does not provide", - "completion.maxValues": "shell completion surface: the harness never drives completion", "elicit.pendingLimit": "elicitation flow: its effect needs an interactive client answering (or not answering) inside that window; ask fixtures cover the flow, not this bound", "registry.timeout": "a timeout bound: observing it needs a registry slower than the stub registry ever is", "logstore.followBacklog": "log store surface: its effect needs stored log volume beyond what one harness run writes", @@ -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 = 108 // Shrunk 2026-11-18 (#8473 chain 36): catalog.instructions gained a probe once the fake server could serve instructions. Earlier shrunk 2026-11-18 (#8473 chain 35): the five plumbing source and launcher switches gained probes. Earlier shrunk 2026-11-18 (#8473 chain 34): artifacts.chunkBytes, script.launcher and paths.placeholders gained probes. Earlier shrunk 2026-11-18 (#8473 chain 33): artifacts.interceptImages and plumbing.indexOnQuery gained probes. Earlier shrunk 2026-11-18 (#8473 chain 32): plumbing.validatePaths and script.language gained probes. Earlier shrunk 2026-11-18 (#8473 chain 31): logging.trace and exec.where gained probes. Earlier shrunk 2026-11-18 (#8473 chain 30): paths.adapters and paths.apis gained declaration-file probes. Earlier shrunk 2026-11-18 (#8473 chain 29): script.runtime, runtimeOrder, permissions, profiles and runtimes gained node-backed probes. Earlier shrunk 2026-11-18 (#8473 chain 28): script.before, onSuccess, onError and suffix gained a run-phase probe. Earlier shrunk 2026-11-18 (#8473 chain 27): hooks, hooks.timeout, daemon.ui and daemon.uiDir gained probes. Earlier shrunk 2026-11-18 (#8473 chain 26): logging.level, format, source, dir, include, maxLines, maxBytes and keep gained durable-log probes. Earlier shrunk 2026-11-18 (#8473 chain 25): artifacts.enabled, maxBytes, quota, delivery, inlineMaxBytes and dir gained script-artifact probes. Earlier shrunk 2026-11-18 (#8473 chain 24): preset and serve.mode gained probes. Earlier shrunk 2026-11-18 (#8473 chain 23): presets gained a --preset probe. Earlier shrunk 2026-11-18 (#8473 chain 22): catalog.budget and catalog.bias gained `mcpx catalog` probes. Earlier shrunk 2026-11-18 (#8473 chain 21): catalog.pinnedTools and retention.maxTools gained reactive-session probes. Earlier shrunk 2026-11-18 (#8473 chain 20): diagnose.history and diagnose.preflight gained schema-churn probes. Earlier shrunk 2026-11-18 (#8473 chain 19): events.history gained a trimmed-replay probe. Earlier shrunk 2026-11-18 (#8473 chain 18): protoTasks.maxTTL, maxPerRequestor and perMinute gained task-store probes. Earlier shrunk 2026-11-18 (#8473 chain 17): tasks.ttl and tasks.resultWait gained /v1 task probes. Earlier shrunk 2026-11-18 (#8473 chain 16): recipes.minScore, matchMargin and limit gained recipe probes. Earlier shrunk 2026-11-18 (#8473 chain 15): logstore.queryLimit gained a /v1/log probe. Earlier shrunk 2026-11-18 (#8473 chain 14): completion.perMinute and completion.serverPerMinute gained 429 probes. Earlier shrunk 2026-11-18 (#8473 chain 13): mcp.pageSize and mcp.passthrough gained tools/list probes. Earlier shrunk 2026-11-18 (#8473 chain 12): exec.timeout (now read by local runs), exec.maxOutputBytes and exec.output gained probes. Earlier shrunk 2026-11-18 (#8473 chain 11): spec.first and spec.lenient mapped to their existing revision-policy probes, spec.precedence gained one. Earlier shrunk 2026-11-18 (#8473 chain 10): protoMessages.taskAfter and protoTasks.pollInterval gained task probes. Earlier shrunk 2026-11-18 (#8473 chain 9): protoMessages.listMaxAge and readMaxAge gained cache-hint probes. Earlier shrunk 2026-11-18 (#8473 chain 8): proto.native gained an asked-client probe. Earlier 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. +const EffectExemptionPin = 107 // Shrunk 2026-11-18 (#8473 chain 37): completion.maxValues gained a probe once the fake server could answer completions. Earlier shrunk 2026-11-18 (#8473 chain 36): catalog.instructions gained a probe once the fake server could serve instructions. Earlier shrunk 2026-11-18 (#8473 chain 35): the five plumbing source and launcher switches gained probes. Earlier shrunk 2026-11-18 (#8473 chain 34): artifacts.chunkBytes, script.launcher and paths.placeholders gained probes. Earlier shrunk 2026-11-18 (#8473 chain 33): artifacts.interceptImages and plumbing.indexOnQuery gained probes. Earlier shrunk 2026-11-18 (#8473 chain 32): plumbing.validatePaths and script.language gained probes. Earlier shrunk 2026-11-18 (#8473 chain 31): logging.trace and exec.where gained probes. Earlier shrunk 2026-11-18 (#8473 chain 30): paths.adapters and paths.apis gained declaration-file probes. Earlier shrunk 2026-11-18 (#8473 chain 29): script.runtime, runtimeOrder, permissions, profiles and runtimes gained node-backed probes. Earlier shrunk 2026-11-18 (#8473 chain 28): script.before, onSuccess, onError and suffix gained a run-phase probe. Earlier shrunk 2026-11-18 (#8473 chain 27): hooks, hooks.timeout, daemon.ui and daemon.uiDir gained probes. Earlier shrunk 2026-11-18 (#8473 chain 26): logging.level, format, source, dir, include, maxLines, maxBytes and keep gained durable-log probes. Earlier shrunk 2026-11-18 (#8473 chain 25): artifacts.enabled, maxBytes, quota, delivery, inlineMaxBytes and dir gained script-artifact probes. Earlier shrunk 2026-11-18 (#8473 chain 24): preset and serve.mode gained probes. Earlier shrunk 2026-11-18 (#8473 chain 23): presets gained a --preset probe. Earlier shrunk 2026-11-18 (#8473 chain 22): catalog.budget and catalog.bias gained `mcpx catalog` probes. Earlier shrunk 2026-11-18 (#8473 chain 21): catalog.pinnedTools and retention.maxTools gained reactive-session probes. Earlier shrunk 2026-11-18 (#8473 chain 20): diagnose.history and diagnose.preflight gained schema-churn probes. Earlier shrunk 2026-11-18 (#8473 chain 19): events.history gained a trimmed-replay probe. Earlier shrunk 2026-11-18 (#8473 chain 18): protoTasks.maxTTL, maxPerRequestor and perMinute gained task-store probes. Earlier shrunk 2026-11-18 (#8473 chain 17): tasks.ttl and tasks.resultWait gained /v1 task probes. Earlier shrunk 2026-11-18 (#8473 chain 16): recipes.minScore, matchMargin and limit gained recipe probes. Earlier shrunk 2026-11-18 (#8473 chain 15): logstore.queryLimit gained a /v1/log probe. Earlier shrunk 2026-11-18 (#8473 chain 14): completion.perMinute and completion.serverPerMinute gained 429 probes. Earlier shrunk 2026-11-18 (#8473 chain 13): mcp.pageSize and mcp.passthrough gained tools/list probes. Earlier shrunk 2026-11-18 (#8473 chain 12): exec.timeout (now read by local runs), exec.maxOutputBytes and exec.output gained probes. Earlier shrunk 2026-11-18 (#8473 chain 11): spec.first and spec.lenient mapped to their existing revision-policy probes, spec.precedence gained one. Earlier shrunk 2026-11-18 (#8473 chain 10): protoMessages.taskAfter and protoTasks.pollInterval gained task probes. Earlier shrunk 2026-11-18 (#8473 chain 9): protoMessages.listMaxAge and readMaxAge gained cache-hint probes. Earlier shrunk 2026-11-18 (#8473 chain 8): proto.native gained an asked-client probe. Earlier 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, diff --git a/pkgs/mcpx/internal/testsupport/fakemcp/main.go b/pkgs/mcpx/internal/testsupport/fakemcp/main.go index 3b22736895..700cc12b26 100644 --- a/pkgs/mcpx/internal/testsupport/fakemcp/main.go +++ b/pkgs/mcpx/internal/testsupport/fakemcp/main.go @@ -189,6 +189,11 @@ func handle(r req) map[string]any { "prompts": map[string]any{}, }, } + // FAKEMCP_COMPLETIONS makes the server answer completion/complete + // with that comma-separated list, so a test can see a cap applied. + if completionValues() != nil { + result["capabilities"].(map[string]any)["completions"] = map[string]any{} + } // FAKEMCP_INSTRUCTIONS gives the server free-text instructions, so a // test can see whether a surface shows or hides them. if instr := os.Getenv("FAKEMCP_INSTRUCTIONS"); instr != "" { @@ -260,6 +265,13 @@ func handle(r req) map[string]any { return ok(r.ID, map[string]any{"contents": []any{ map[string]any{"uri": p.URI, "mimeType": "text/plain", "text": "hello from a resource"}, }}) + case "completion/complete": + values := completionValues() + if values == nil { + break + } + return ok(r.ID, map[string]any{"completion": map[string]any{ + "values": values, "total": len(values), "hasMore": false}}) case "prompts/list": return ok(r.ID, map[string]any{"prompts": []any{ map[string]any{ @@ -624,3 +636,13 @@ func callTool(r req) map[string]any { } return fail(r.ID, -32602, "unknown tool "+p.Name) } + +// completionValues is FAKEMCP_COMPLETIONS split on commas, or nil when it +// is unset and the server offers no completions. +func completionValues() []string { + v := os.Getenv("FAKEMCP_COMPLETIONS") + if v == "" { + return nil + } + return strings.Split(v, ",") +}