From 352f03d3d4988d405f86db62fc3d1cc3951e0b25 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 18 Nov 2026 18:11:05 +0000 Subject: [PATCH] test(mcpx): probe preset and serve.mode preset: with j defined as --json, status prints text until MCPX_PRESET=j selects it. serve.mode: plain `mcpx serve` lists code-mode tools, and MCPX_SERVE_MODE=reactive serves request_tools instead. The reactive stdio helper now takes any serve arguments. Pin 154 -> 152. Refs #8473 Co-Authored-By: Claude Opus 5.5 --- pkgs/mcpx/internal/e2e/effect_test.go | 42 ++++++++++++++++++- .../e2e/feature_coverage_exemptions.txt | 2 - pkgs/mcpx/internal/settings/effect.go | 6 +-- 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/pkgs/mcpx/internal/e2e/effect_test.go b/pkgs/mcpx/internal/e2e/effect_test.go index 4bb653dafa..756d11a0b8 100644 --- a/pkgs/mcpx/internal/e2e/effect_test.go +++ b/pkgs/mcpx/internal/e2e/effect_test.go @@ -100,6 +100,8 @@ var implementedEffectProbes = map[string]string{ "protoTasks.maxPerRequestor": "TestProtoTasksMaxPerRequestorCapsUnfinishedTasksFromTheEnvironment", "protoTasks.perMinute": "TestProtoTasksPerMinuteWindowsTaskReadsFromTheEnvironment", "events.history": "TestEventsHistoryBoundsTheReplay", + "preset": "TestPresetSelectsADefinedBundle", + "serve.mode": "TestServeModeSelectsTheServedSurface", "presets": "TestPresetsDefinesNamedFlagBundles", "catalog.budget": "TestCatalogBudgetFitsTheSignatures", "catalog.bias": "TestCatalogBiasPicksWhatATightBudgetShows", @@ -193,6 +195,8 @@ var effectProbeFuncs = map[string]func(*testing.T){ "TestProtoTasksMaxPerRequestorCapsUnfinishedTasksFromTheEnvironment": TestProtoTasksMaxPerRequestorCapsUnfinishedTasksFromTheEnvironment, "TestProtoTasksPerMinuteWindowsTaskReadsFromTheEnvironment": TestProtoTasksPerMinuteWindowsTaskReadsFromTheEnvironment, "TestEventsHistoryBoundsTheReplay": TestEventsHistoryBoundsTheReplay, + "TestPresetSelectsADefinedBundle": TestPresetSelectsADefinedBundle, + "TestServeModeSelectsTheServedSurface": TestServeModeSelectsTheServedSurface, "TestPresetsDefinesNamedFlagBundles": TestPresetsDefinesNamedFlagBundles, "TestCatalogBudgetFitsTheSignatures": TestCatalogBudgetFitsTheSignatures, "TestCatalogBiasPicksWhatATightBudgetShows": TestCatalogBiasPicksWhatATightBudgetShows, @@ -1508,7 +1512,13 @@ console.log("script ran");` // tools/list could be answered before the request_tools it follows. func reactiveTools(t *testing.T, e *env, query string) map[string]bool { t.Helper() - cmd := exec.Command(e.mcpx, "serve", "--mode", "reactive") + return servedTools(t, e, query, "--mode", "reactive") +} + +// servedTools is reactiveTools for any `mcpx serve` arguments. +func servedTools(t *testing.T, e *env, query string, args ...string) map[string]bool { + t.Helper() + cmd := exec.Command(e.mcpx, append([]string{"serve"}, args...)...) cmd.Dir = e.dir cmd.Env = e.envVars stdin, err := cmd.StdinPipe() @@ -1656,6 +1666,36 @@ func TestPresetsDefinesNamedFlagBundles(t *testing.T) { } } +// TestPresetSelectsADefinedBundle is the effect probe for preset: with j +// defined as ["--json"], plain `mcpx status` prints text, and naming j in +// MCPX_PRESET applies it without the flag. +func TestPresetSelectsADefinedBundle(t *testing.T) { + e := newEnv(t, oneServer) + e.setenv(`MCPX_PRESETS={"j":["--json"]}`) + if out := e.run("status"); json.Valid([]byte(strings.TrimSpace(out))) { + t.Errorf("with no preset selected, status should print text:\n%s", out) + } + e.setenv("MCPX_PRESET=j") + if out := e.run("status"); !json.Valid([]byte(strings.TrimSpace(out))) { + t.Errorf("preset=j should make status print JSON:\n%s", out) + } +} + +// TestServeModeSelectsTheServedSurface is the effect probe for serve.mode: +// plain `mcpx serve` is code mode and lists no request_tools; with +// MCPX_SERVE_MODE=reactive the same command serves the reactive surface. +func TestServeModeSelectsTheServedSurface(t *testing.T) { + e := newEnv(t, oneServer) + e.run("ls") + if got := servedTools(t, e, ""); got["request_tools"] || !got["mcpx_exec"] { + t.Errorf("the default serve.mode should serve code mode: %v", got) + } + e.setenv("MCPX_SERVE_MODE=reactive") + if got := servedTools(t, e, ""); !got["request_tools"] || got["mcpx_exec"] { + t.Errorf("serve.mode=reactive should serve the reactive surface: %v", 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 809c740d98..d5cfb4c927 100644 --- a/pkgs/mcpx/internal/e2e/feature_coverage_exemptions.txt +++ b/pkgs/mcpx/internal/e2e/feature_coverage_exemptions.txt @@ -161,13 +161,11 @@ setting plumbing.sourceDirRecursive no integration-test exercise yet; burn-down setting plumbing.sourceProbePaths no integration-test exercise yet; burn-down #8470 (settings long-tail families); needs an EffectProbes entry + e2e test setting plumbing.validatePaths no integration-test exercise yet; burn-down #8470 (settings long-tail families); needs an EffectProbes entry + e2e test setting policy.write no integration-test exercise yet; burn-down #8470 (settings long-tail families); needs an EffectProbes entry + e2e test -setting preset no integration-test exercise yet; burn-down #8470 (settings long-tail families); needs an EffectProbes entry + e2e test setting registry.timeout no integration-test exercise yet; burn-down #8470 (settings long-tail families); needs an EffectProbes entry + e2e test setting repair.autonomy no integration-test exercise yet; burn-down #8470 (settings long-tail families); needs an EffectProbes entry + e2e test setting retention.stickyWindow no integration-test exercise yet; burn-down #8470 (settings long-tail families); needs an EffectProbes entry + e2e test setting sampling.answerLocally no integration-test exercise yet; burn-down #8470 (settings long-tail families); needs an EffectProbes entry + e2e test setting search.semantic no integration-test exercise yet; burn-down #8470 (settings long-tail families); needs an EffectProbes entry + e2e test -setting serve.mode no integration-test exercise yet; burn-down #8470 (settings long-tail families); needs an EffectProbes entry + e2e test setting session.releaseTimeout no integration-test exercise yet; burn-down #8470 (settings long-tail families); needs an EffectProbes entry + e2e test setting upstream.eraCache no integration-test exercise yet; burn-down #8470 (settings long-tail families); needs an EffectProbes entry + e2e test setting upstream.probeTimeout 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 56f1b7e9f5..dca8662587 100644 --- a/pkgs/mcpx/internal/settings/effect.go +++ b/pkgs/mcpx/internal/settings/effect.go @@ -101,6 +101,8 @@ var EffectProbes = map[string]string{ "protoTasks.maxPerRequestor": "TestProtoTasksMaxPerRequestorCapsUnfinishedTasksFromTheEnvironment", "protoTasks.perMinute": "TestProtoTasksPerMinuteWindowsTaskReadsFromTheEnvironment", "events.history": "TestEventsHistoryBoundsTheReplay", + "preset": "TestPresetSelectsADefinedBundle", + "serve.mode": "TestServeModeSelectsTheServedSurface", "presets": "TestPresetsDefinesNamedFlagBundles", "catalog.budget": "TestCatalogBudgetFitsTheSignatures", "catalog.bias": "TestCatalogBiasPicksWhatATightBudgetShows", @@ -247,7 +249,6 @@ var EffectExemptions = map[string]string{ "logstore.followBacklog": "log store surface: its effect needs stored log volume beyond what one harness run writes", "events.reconnect": "daemon event buffer/reconnect behaviour: needs disconnect/reconnect timing the harness does not drive", "daemon.idleExit": "daemon lifecycle, binding, or timing: its effect is a bound, an interval, or a network identity the isolated harness cannot vary deterministically", - "serve.mode": "serve mode selection: needs a client driving the alternate mode end-to-end, which no fixture does", "retention.stickyWindow": "retention window: its effect appears across call history and time, not within one run", "embeddings.backend": "embeddings backend: needs a live embeddings service or a wasm model fixture the harness does not provide", "embeddings.url": "embeddings backend: needs a live embeddings service or a wasm model fixture the harness does not provide", @@ -284,13 +285,12 @@ var EffectExemptions = map[string]string{ "upstream.probeTimeout": "upstream protocol detection: its effect needs a peer whose era must be probed, beyond what the fake server presents", "upstream.eraCache": "upstream protocol detection: its effect needs a peer whose era must be probed, beyond what the fake server presents", "logging.trace": "log pipeline bound or rendering choice: its effect appears only across log volume, rotation, or time, none of which a single harness run produces deterministically", - "preset": "preset bundling with no dedicated with/without probe yet", } // 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 = 154 // 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 = 152 // 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,