# Lab L17 self-check output: starter/
# Date: 2026-11-26T12:58:48Z  Host: macOS 27.2.1 arm64  uv 0.10.2
# Command: ./run.sh check starter   (uv sync --locked, then pytest with CAPSTONE_TARGET=starter)
# uv.lock sha256: e615583ddd54b6034d0a030b81f95699e844c4557219eb570d15421f6f29d50a
# Exit code: 1

..FFF.FFFFFFFFF.FF                                                       [100%]
=================================== FAILURES ===================================
________________________ test_exactly_three_named_tools ________________________

server = 'http://127.0.0.1:8765/mcp'

    @pytest.mark.criterion("C2")
    def test_exactly_three_named_tools(server):
        names = set(run(_tools(server)))
>       assert names == EXPECTED_TOOLS, f"tools are {sorted(names)}, expected {sorted(EXPECTED_TOOLS)}"
E       AssertionError: tools are ['get_plant', 'list_plants'], expected ['get_plant', 'list_plants', 'log_watering']
E       assert {'get_plant', 'list_plants'} == {'get_plant',...log_watering'}
E         
E         Extra items in the right set:
E         'log_watering'
E         Use -v to get more diff

selfcheck/test_capstone.py:75: AssertionError
______________ test_every_tool_has_description_and_output_schema _______________

server = 'http://127.0.0.1:8765/mcp'

    @pytest.mark.criterion("C2")
    def test_every_tool_has_description_and_output_schema(server):
        tools = run(_tools(server))
        for name in EXPECTED_TOOLS & set(tools):
            assert (tools[name].description or "").strip(), f"{name} has no description"
            assert tools[name].output_schema, f"{name} has no outputSchema (return a pydantic model)"
>       assert EXPECTED_TOOLS <= set(tools), f"missing tools: {sorted(EXPECTED_TOOLS - set(tools))}"
E       AssertionError: missing tools: ['log_watering']
E       assert {'get_plant',...log_watering'} <= {'get_plant', 'list_plants'}
E         
E         Extra items in the left set:
E         'log_watering'

selfcheck/test_capstone.py:84: AssertionError
_____________________ test_input_schemas_carry_constraints _____________________

server = 'http://127.0.0.1:8765/mcp'

    @pytest.mark.criterion("C2")
    def test_input_schemas_carry_constraints(server):
        tools = run(_tools(server))
        assert "get_plant" in tools, "get_plant missing"
        pid = tools["get_plant"].input_schema.get("properties", {}).get("plant_id", {})
>       assert pid.get("pattern") == PLANT_ID, f"get_plant.plant_id pattern is {pid.get('pattern')!r}, expected {PLANT_ID!r}"
E       AssertionError: get_plant.plant_id pattern is None, expected '^PLT-\\d{3}$'
E       assert None == '^PLT-\\d{3}$'
E        +  where None = <built-in method get of dict object at 0x10c92a300>('pattern')
E        +    where <built-in method get of dict object at 0x10c92a300> = {'title': 'Plant Id', 'type': 'string'}.get

selfcheck/test_capstone.py:92: AssertionError
_______________________ test_get_plant_returns_the_plant _______________________

server = 'http://127.0.0.1:8765/mcp'

    @pytest.mark.criterion("C3")
    def test_get_plant_returns_the_plant(server):
        r = run(_call(server, "get_plant", {"plant_id": "PLT-002"}))
>       assert not r.is_error, f"get_plant failed: {_text(r)}"
E       AssertionError: get_plant failed: Error executing tool get_plant
E       assert not True
E        +  where True = CallToolResult(meta={'io.modelcontextprotocol/serverInfo': {'name': 'greenhouse', 'version': '1.0.0'}}, content=[TextC...ecuting tool get_plant', annotations=None, meta=None)], structured_content=None, is_error=True, result_type='complete').is_error

selfcheck/test_capstone.py:117: AssertionError
_______________________ test_log_watering_changes_state ________________________

server = 'http://127.0.0.1:8765/mcp'

    @pytest.mark.criterion("C3")
    def test_log_watering_changes_state(server):
        async def go():
            async with Client(server) as client:
                before = (await client.call_tool("get_plant", {"plant_id": "PLT-004"})).structured_content
                r = await client.call_tool("log_watering", {"plant_id": "PLT-004", "ml": 150})
                after = (await client.call_tool("get_plant", {"plant_id": "PLT-004"})).structured_content
                return before, r, after
        before, r, after = run(go())
>       assert not r.is_error, f"log_watering failed: {_text(r)}"
E       AssertionError: log_watering failed: Unknown tool: log_watering
E       assert not True
E        +  where True = CallToolResult(meta={'io.modelcontextprotocol/serverInfo': {'name': 'greenhouse', 'version': '1.0.0'}}, content=[TextC...own tool: log_watering', annotations=None, meta=None)], structured_content=None, is_error=True, result_type='complete').is_error

selfcheck/test_capstone.py:130: AssertionError
____________________ test_unknown_plant_is_an_error_result _____________________

server = 'http://127.0.0.1:8765/mcp'

    @pytest.mark.criterion("C4")
    def test_unknown_plant_is_an_error_result(server):
        r = run(_call(server, "get_plant", {"plant_id": "PLT-999"}))
        assert r.is_error, "unknown id must return isError=true"
>       assert "No plant" in _text(r), f"error should say 'No plant ...', got {_text(r)!r}"
E       AssertionError: error should say 'No plant ...', got 'Error executing tool get_plant'
E       assert 'No plant' in 'Error executing tool get_plant'
E        +  where 'Error executing tool get_plant' = _text(CallToolResult(meta={'io.modelcontextprotocol/serverInfo': {'name': 'greenhouse', 'version': '1.0.0'}}, content=[TextC...ecuting tool get_plant', annotations=None, meta=None)], structured_content=None, is_error=True, result_type='complete'))

selfcheck/test_capstone.py:142: AssertionError
_________________________ test_invalid_input_rejected __________________________

server = 'http://127.0.0.1:8765/mcp'

    @pytest.mark.criterion("C4")
    def test_invalid_input_rejected(server):
        for name, args in [("get_plant", {"plant_id": "../etc"}), ("log_watering", {"plant_id": "PLT-001", "ml": 5000})]:
            r = run(_call(server, name, args))
            # The constraint must live in the inputSchema, so the SDK's argument validation rejects it
            # (not a missing tool, not NotImplementedError).
>           assert r.is_error and "validation error" in _text(r), \
                f"{name}{args} should be rejected by schema validation, got {_text(r)[:120]!r}"
E           AssertionError: get_plant{'plant_id': '../etc'} should be rejected by schema validation, got 'Error executing tool get_plant'
E           assert (True and 'validation error' in 'Error executing tool get_plant')
E            +  where True = CallToolResult(meta={'io.modelcontextprotocol/serverInfo': {'name': 'greenhouse', 'version': '1.0.0'}}, content=[TextC...ecuting tool get_plant', annotations=None, meta=None)], structured_content=None, is_error=True, result_type='complete').is_error
E            +  and   'Error executing tool get_plant' = _text(CallToolResult(meta={'io.modelcontextprotocol/serverInfo': {'name': 'greenhouse', 'version': '1.0.0'}}, content=[TextC...ecuting tool get_plant', annotations=None, meta=None)], structured_content=None, is_error=True, result_type='complete'))

selfcheck/test_capstone.py:151: AssertionError
__________________________ test_dormant_plant_refused __________________________

server = 'http://127.0.0.1:8765/mcp'

    @pytest.mark.criterion("C4")
    def test_dormant_plant_refused(server):
        r = run(_call(server, "log_watering", {"plant_id": "PLT-003", "ml": 100}))
>       assert r.is_error and "dormant" in _text(r).lower(), f"watering a dormant plant must be refused: {_text(r)!r}"
E       AssertionError: watering a dormant plant must be refused: 'Unknown tool: log_watering'
E       assert (True and 'dormant' in 'unknown tool: log_watering')
E        +  where True = CallToolResult(meta={'io.modelcontextprotocol/serverInfo': {'name': 'greenhouse', 'version': '1.0.0'}}, content=[TextC...own tool: log_watering', annotations=None, meta=None)], structured_content=None, is_error=True, result_type='complete').is_error
E        +  and   'unknown tool: log_watering' = <built-in method lower of str object at 0x10c9efc80>()
E        +    where <built-in method lower of str object at 0x10c9efc80> = 'Unknown tool: log_watering'.lower
E        +      where 'Unknown tool: log_watering' = _text(CallToolResult(meta={'io.modelcontextprotocol/serverInfo': {'name': 'greenhouse', 'version': '1.0.0'}}, content=[TextC...own tool: log_watering', annotations=None, meta=None)], structured_content=None, is_error=True, result_type='complete'))

selfcheck/test_capstone.py:158: AssertionError
_______________________________ test_annotations _______________________________

server = 'http://127.0.0.1:8765/mcp'

    @pytest.mark.criterion("C5")
    def test_annotations(server):
        tools = run(_tools(server))
        for name in ("list_plants", "get_plant"):
>           assert name in tools and tools[name].annotations and tools[name].annotations.read_only_hint is True, \
                f"{name} must be annotated read_only_hint=True"
E           AssertionError: get_plant must be annotated read_only_hint=True
E           assert ('get_plant' in {'list_plants': Tool(name='list_plants', title='List plants', description='List plants, optionally filtered by locatio...', 'location', 'dormant', 'watered_ml'], 'title': 'Plant', 'type': 'object'}, icons=None, annotations=None, meta=None)} and None)
E            +  where None = Tool(name='get_plant', title='Get plant', description='Get one plant by id.', input_schema={'type': 'object', 'propert...e', 'location', 'dormant', 'watered_ml'], 'title': 'Plant', 'type': 'object'}, icons=None, annotations=None, meta=None).annotations

selfcheck/test_capstone.py:167: AssertionError
______________________ test_resource_listed_and_readable _______________________

server = 'http://127.0.0.1:8765/mcp'

    @pytest.mark.criterion("C6")
    def test_resource_listed_and_readable(server):
        async def go():
            async with Client(server) as client:
                listed = [str(r.uri) for r in (await client.list_resources()).resources]
                if "garden://care-guide" not in listed:
                    return listed, None
                return listed, await client.read_resource("garden://care-guide")
        listed, content = run(go())
>       assert "garden://care-guide" in listed, f"resources listed: {listed}"
E       AssertionError: resources listed: []
E       assert 'garden://care-guide' in []

selfcheck/test_capstone.py:185: AssertionError
_________________________ test_foreign_origin_rejected _________________________

server = 'http://127.0.0.1:8765/mcp'

    @pytest.mark.criterion("C7")
    def test_foreign_origin_rejected(server):
        with httpx2.Client(timeout=5.0) as http:
            ok = http.post(server, json=DISCOVER, headers={**HEADERS, "Origin": f"http://127.0.0.1:{PORT}"})
            bad = http.post(server, json=DISCOVER, headers={**HEADERS, "Origin": "http://evil.example"})
        assert ok.status_code == 200, f"control request with own Origin got {ok.status_code}"
>       assert bad.status_code == 403, f"foreign Origin got HTTP {bad.status_code}, expected 403"
E       AssertionError: foreign Origin got HTTP 200, expected 403
E       assert 200 == 403
E        +  where 200 = <Response [200 OK]>.status_code

selfcheck/test_capstone.py:198: AssertionError
__________________________ test_foreign_host_rejected __________________________

server = 'http://127.0.0.1:8765/mcp'

    @pytest.mark.criterion("C7")
    def test_foreign_host_rejected(server):
        with httpx2.Client(timeout=5.0) as http:
            bad = http.post(server, json=DISCOVER, headers={**HEADERS, "Host": f"evil.example:{PORT}"})
>       assert bad.status_code == 421, f"foreign Host got HTTP {bad.status_code}, expected 421"
E       AssertionError: foreign Host got HTTP 200, expected 421
E       assert 200 == 421
E        +  where 200 = <Response [200 OK]>.status_code

selfcheck/test_capstone.py:205: AssertionError
_______________________ test_dependencies_pinned_exactly _______________________

    @pytest.mark.criterion("C8")
    def test_dependencies_pinned_exactly():
        project = tomllib.loads((TARGET / "pyproject.toml").read_text())["project"]
        deps = project.get("dependencies", [])
        assert deps, "no dependencies declared"
        loose = [d for d in deps if not re.fullmatch(r"[A-Za-z0-9_.\-\[\],]+==[A-Za-z0-9_.\-+]+", d.replace(" ", ""))]
>       assert not loose, f"not pinned with ==: {loose}"
E       AssertionError: not pinned with ==: ['mcp>=2']
E       assert not ['mcp>=2']

selfcheck/test_capstone.py:231: AssertionError
______________________ test_lock_file_present_and_current ______________________

    @pytest.mark.criterion("C8")
    def test_lock_file_present_and_current():
>       assert (TARGET / "uv.lock").is_file(), f"no uv.lock in {TARGET.name}/ (run `uv lock` there)"
E       AssertionError: no uv.lock in starter/ (run `uv lock` there)
E       assert False
E        +  where False = is_file()
E        +    where is_file = (PosixPath('/Users/majorproduction/turningpoint-course-exports/mcp-v2-20261126/lab-l17/starter') / 'uv.lock').is_file

selfcheck/test_capstone.py:237: AssertionError
================= Rubric evidence for starter/ (see RUBRIC.md) =================
C1  Demonstrated  2/2 checks passed      Server runs and is discoverable (2026-07-28 and legacy clients)
C2  Needs repair  0/3 checks passed      Exactly 3 tools, each with description, constrained inputSchema and outputSchema
C3  Needs repair  1/3 checks passed      Tools behave correctly on valid input (structured results, state change)
C4  Needs repair  0/3 checks passed      Errors come back as isError results (unknown id, invalid input, refused action)
C5  Needs repair  0/1 checks passed      Tool annotations distinguish read-only from state-changing tools
C6  Needs repair  0/1 checks passed      A resource is listed and readable
C7  Needs repair  1/3 checks passed      Transport security: loopback binding, foreign Origin 403, foreign Host 421
C8  Needs repair  0/2 checks passed      Supply chain: dependencies pinned exactly and locked
Self-assessment only: this is not an accredited assessment of competence.
=========================== short test summary info ============================
FAILED selfcheck/test_capstone.py::test_exactly_three_named_tools - Assertion...
FAILED selfcheck/test_capstone.py::test_every_tool_has_description_and_output_schema
FAILED selfcheck/test_capstone.py::test_input_schemas_carry_constraints - Ass...
FAILED selfcheck/test_capstone.py::test_get_plant_returns_the_plant - Asserti...
FAILED selfcheck/test_capstone.py::test_log_watering_changes_state - Assertio...
FAILED selfcheck/test_capstone.py::test_unknown_plant_is_an_error_result - As...
FAILED selfcheck/test_capstone.py::test_invalid_input_rejected - AssertionErr...
FAILED selfcheck/test_capstone.py::test_dormant_plant_refused - AssertionErro...
FAILED selfcheck/test_capstone.py::test_annotations - AssertionError: get_pla...
FAILED selfcheck/test_capstone.py::test_resource_listed_and_readable - Assert...
FAILED selfcheck/test_capstone.py::test_foreign_origin_rejected - AssertionEr...
FAILED selfcheck/test_capstone.py::test_foreign_host_rejected - AssertionErro...
FAILED selfcheck/test_capstone.py::test_dependencies_pinned_exactly - Asserti...
FAILED selfcheck/test_capstone.py::test_lock_file_present_and_current - Asser...
14 failed, 4 passed in 2.15s
