1414import sys
1515import textwrap
1616
17+ import pytest
18+
1719from mcp .server .mcpserver import MCPServer
1820
1921from mcp_server .__main__ import register_all
@@ -85,10 +87,10 @@ def test_the_docker_smoke_floor_follows_the_surface() -> None:
8587
8688
8789def test_the_verifier_imports_without_the_mcp_sdk () -> None :
88- """The mcp-host-config CI job installs the host CLIs, not the SDK .
90+ """The verifier can bootstrap before artifact dependencies are installed .
8991
90- Importing `mcp_server.tool_surface` at module scope pulled the SDK
91- through the registries and broke that job (issue #597) .
92+ Importing registries at module scope previously broke this boundary
93+ (issue #597); full candidate verification loads them only when needed .
9294 """
9395 result = subprocess .run (
9496 [sys .executable , "-c" , _SDK_FREE_IMPORT_PROBE ], capture_output = True , text = True
@@ -98,43 +100,44 @@ def test_the_verifier_imports_without_the_mcp_sdk() -> None:
98100 assert "imported" in result .stdout
99101
100102
101- def test_the_sdk_less_job_never_binds_a_release_to_this_checkouts_bounds () -> None :
102- """Importability is not enough: a full-profile case in the SDK-less job
103- still *calls* `full_tool_bounds()` and dies on the same missing SDK.
104-
105- Codex stopped shipping a lean profile (PR #620), so mcp-host-config's
106- codex-cli case had to move to `--profiles full`, and it broke that way.
107- `--published-surface` is what keeps the call unreachable there, and it is
108- correct beyond the SDK: that command resolves a released artifact whose
109- surface is its own release's, not this checkout's (ADR-1077, revision
110- 2026-09-22).
111- """
103+ def test_candidate_job_installs_dependencies_and_checks_its_full_surface () -> None :
104+ """The candidate wheel supplies the SDK; exact checkout bounds must run."""
112105 import pathlib
113106 import re
114107
115108 workflow = pathlib .Path (".github/workflows/ci.yml" ).read_text (encoding = "utf-8" )
116109 job = workflow .split ("\n mcp-host-config:\n " , 1 )
117- assert len (job ) == 2 , "the mcp-host-config job is no longer declared as expected"
118- # Up to the next top-level job key.
110+ assert len (job ) == 2
119111 body = re .split (r"\n [a-z][a-z-]*:\n" , job [1 ], maxsplit = 1 )[0 ]
120-
121- # Per invocation, not over the whole job: a second --profiles full case
122- # added later that legitimately needs no flag would otherwise satisfy a
123- # job-wide substring check on behalf of the one that does need it.
124- invocations = [
125- # From the script name to the `--` that ends the flags.
126- match .group (0 )
127- for match in re .finditer (
128- r"verify_mcp_hosts\.py(?:[^\n]*\\\n)*[^\n]*" , body , flags = re .MULTILINE
129- )
130- ]
131- assert invocations , (
132- "the job no longer drives the verifier; drop this test or re-point it"
112+ commands = body .replace ("\\ \n " , " " )
113+ invocations = re .findall (
114+ r"uv run[^\n]*scripts/verify_mcp_hosts\.py[^\n]*" , commands
133115 )
116+ assert invocations , "candidate verification must install its wheel dependencies"
117+ assert 'uv build --wheel --out-dir "$RUNNER_TEMP/cortex-codex-wheel"' in body
134118 for invocation in invocations :
135- if "--profiles full" in invocation :
136- assert "--published-surface" in invocation , (
137- "this full-profile case in the SDK-less job must pass "
138- "--published-surface, or it calls full_tool_bounds() and dies "
139- f"on ModuleNotFoundError: No module named 'mcp':\n { invocation } "
140- )
119+ assert '--no-project --with "$candidate_wheel" -- env' in invocation
120+ assert 'UV_FIND_LINKS="$RUNNER_TEMP/cortex-codex-wheel"' in invocation
121+ assert "--profiles full" in invocation
122+ assert "--published-surface" not in invocation , (
123+ "candidate bounds cannot be bypassed"
124+ )
125+ assert "--artifact-surface" not in invocation , (
126+ "candidate bounds cannot be bypassed"
127+ )
128+
129+
130+ def test_candidate_verifier_rejects_lean_only_discovery (tmp_path ) -> None :
131+ """A candidate claiming full must fail when only the lean tools survive."""
132+ from mcp_server .tool_profiles import LEAN_TOOL_NAMES
133+ from scripts .mcp_host_client import ContractCase , ContractError
134+ from scripts .verify_mcp_hosts import _verify_tool_surface
135+
136+ case = ContractCase ("codex-cli" , "full" , (), tmp_path , 180 , False , "auto" )
137+ responses = {2 : {"result" : {"tools" : [{"name" : n } for n in LEAN_TOOL_NAMES ]}}}
138+ with pytest .raises (ContractError , match = "discovered .* full tools; expected" ):
139+ _verify_tool_surface (case , responses , published = False )
140+ responses [2 ]["result" ]["tools" ] = [{"name" : n } for n in standalone_tool_names ()]
141+ assert _verify_tool_surface (case , responses , published = False ) == len (
142+ standalone_tool_names ()
143+ )
0 commit comments