portfolio-optimiser/docs
Kjell Tore Guttormsen 9dc3722161 fix(ingest): run the MCP stdio transport against a real server, and repair its error contract (kø-x)
`stdio_call_tool` shipped never having been executed end to end — docs said so
explicitly. Running it found a real defect: `stdio_client` and `ClientSession` are
each an anyio task group, and anyio re-packages anything leaving one in a
`BaseExceptionGroup`. Both errors the transport raises from inside the session
(`mcp_tool_error`, `mcp_non_text_content`) therefore reached callers as exception
groups, never as the `IngestError` the whole Door A path catches and switches on by
`code`. No canned-tool test could see this: they never enter a task group.

`_unwrap_ingest_error` recovers the owned error and re-raises it; anything unowned is
re-raised untouched, so this narrows an exception group rather than blanket-catching.
Duck-typed on `.exceptions` because `except*`/`ExceptionGroup` are 3.11+ and this
project supports >=3.10.

Verified against a REAL server subprocess (a local process costs no model tokens, so
the repo's cost discipline is untouched; the contract tests still spawn nothing):
`examples/ingest-golden-mcp/` + `tests/test_ingest_golden_mcp.py` — byte-identical
golden extraction mirroring the http/sql goldens, plus the tool-error and
missing-`server_ref` branches.

Also recorded: a server on the ingest path must expose a NULL-ARGUMENT tool, so
`datasource.build_mcp_server` cannot serve it (`retrieve_cost_docs(query)` has a
required parameter, verified to return an error result). The two are separate seams
by design.

Load-bearing MEASURED, five mutations all RED: detach the unwrap · detach
`initialize()` · make the error code generic · detach the `isError` branch · change
one byte of the served body.

612 -> 615 tests. ruff + format + mypy clean.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WiY53sm8JFqk7NN75g5wRS
2026-08-03 17:56:19 +02:00
..
fase1-spikes fix(fase1): spike B fan-out measures real conversation bleed, not a counter 2026-06-24 11:09:55 +02:00
plan docs(security): plan llm-ingestion-guard inclusion at ingest/inbox persist-gates 2026-07-16 07:43:30 +02:00
rapport docs(i7): reproduserbar grep i statusrapport rad #10/#11 (--exclude selv-referanse) 2026-07-04 23:34:26 +02:00
research docs(research): MAF 1.9.0 capability map — feature-utilization for Fase 2 [skip-docs] 2026-06-24 11:36:26 +02:00
2026-06-24-two-approaches-brief.md docs: plain-text brief — goal + two approaches (MAF vs Claude Agent SDK) + learning goal 2026-06-24 09:21:31 +02:00
2026-06-26-fot-i-bakken.md docs(fot-i-bakken): ground-truth-verifisert levert-vs-lovet — agentiske lag inerte 2026-06-26 15:25:03 +02:00
2026-07-15-foundry-auth-recipe.md docs(s41): verified Foundry auth recipe + necessary-but-not-sufficient note 2026-07-15 11:24:18 +02:00
extending.md fix(ingest): run the MCP stdio transport against a real server, and repair its error contract (kø-x) 2026-08-03 17:56:19 +02:00
knowledge-base-recipe.md docs(s53): knowledge-base recipe (D-H item 1) — team process, honest 1-2 week expectation, no wizard 2026-07-23 21:53:53 +02:00
review-2026-07.md docs(review): kryssmodell-review 2026-07 (14 funn, 11 detach-bevis) + revidert roadmap + sesjonsplan Fase 2-6 2026-07-10 06:28:11 +02:00