Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions pkgs/mcpx/internal/e2e/effect_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package e2e_test

import (
"net/http"
"os"
"path/filepath"
"sort"
"strings"
"testing"
"time"

"github.com/developing-today/code/pkgs/mcpx/internal/settings"
)
Expand Down Expand Up @@ -55,6 +57,7 @@ var implementedEffectProbes = map[string]string{
"paths.deps": "TestPathsDepsExtendsManifestDiscovery",
"proxy.timeout": "TestProxyUpstreamTimeoutIsReachableFromTheEnvironment",
"tasks.maxAge": "TestTasksMaxAgeIsReachableFromEnvironment",
"proto.askPoll": "TestAskPollCeilingIsReachableFromTheEnvironment",
}

// effectProbeFuncs anchors every declared probe name to the actual
Expand Down Expand Up @@ -88,6 +91,7 @@ var effectProbeFuncs = map[string]func(*testing.T){
"TestDepsPackagesPinContradictingTheManifestFailsTheRun": TestDepsPackagesPinContradictingTheManifestFailsTheRun,
"TestPathsDepsExtendsManifestDiscovery": TestPathsDepsExtendsManifestDiscovery,
"TestTasksMaxAgeIsReachableFromEnvironment": TestTasksMaxAgeIsReachableFromEnvironment,
"TestAskPollCeilingIsReachableFromTheEnvironment": TestAskPollCeilingIsReachableFromTheEnvironment,
}

func TestEffectProbeDeclarationsMatchTheProbesThatExist(t *testing.T) {
Expand Down Expand Up @@ -221,3 +225,39 @@ func TestSearchLimitCapsTheResults(t *testing.T) {
t.Fatalf("search.limit=1 should cap the results at one, got %d:\n%s", n, capped)
}
}

// --- Surface: waiting on a question --------------------------------------

// proto.askPoll is the ceiling on how long one GET /v1/ask/{id} holds
// while a live call has nothing new to report. A script run that is
// still working and asks nothing is such a call, so with no waitMs the
// poll holds for exactly the ceiling: the hold time is the observable.
func TestAskPollCeilingIsReachableFromTheEnvironment(t *testing.T) {
holdFor := func(env ...string) time.Duration {
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)
start := time.Now()
st, out := sockDo(t, c, http.MethodGet, "/v1/ask/"+id, nil)
took := time.Since(start)
if st != http.StatusOK || out["done"] == true {
t.Fatalf("the poll should return while the call is still running: %d %v", st, out)
}
return took
}

def := holdFor()
raised := holdFor("MCPX_PROTO_ASK_POLL=2s")
if raised < def+time.Second {
t.Fatalf("proto.askPoll=2s should hold a poll about two seconds, got %v against %v at the default", raised, def)
}
}
1 change: 0 additions & 1 deletion pkgs/mcpx/internal/e2e/feature_coverage_exemptions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,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.askPoll no integration-test exercise yet; burn-down #8473 (settings proto family); needs an EffectProbes entry + e2e test
setting proto.askRounds no integration-test exercise yet; burn-down #8473 (settings proto 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
Expand Down
4 changes: 2 additions & 2 deletions pkgs/mcpx/internal/settings/effect.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ var EffectProbes = map[string]string{
"script.cwd": "TestScriptCwdIsReachableFromTheEnvironment",
"script.interpreter": "TestScriptInterpreterIsReachableFromTheEnvironment",
"proxy.timeout": "TestProxyUpstreamTimeoutIsReachableFromTheEnvironment",
"proto.askPoll": "TestAskPollCeilingIsReachableFromTheEnvironment",
}

// EffectExemptions maps a setting path to the reason no effect probe
Expand Down Expand Up @@ -150,7 +151,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.askPoll": "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.askRounds": "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",
Expand Down Expand Up @@ -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 = 214 // 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 = 213 // 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,
Expand Down