portfolio-optimiser/docs
Kjell Tore Guttormsen 991131be3f feat(provenance): a run records which external service it actually called
The egress declaration (Trekk B3) says what a run MAY contact. It cannot say what
it DID: after the run, nothing distinguished "the agents queried the price
register" from "the agents ignored it", and a proposal resting on an external
service should be traceable to it.

ToolCallRecorder(FunctionMiddleware) mirrors BudgetMiddleware(ChatMiddleware) one
layer down — that one observes the debate's chat calls, this one its tool calls.
It observes only: call_next is always awaited, so a trace can never alter the run
it traces. The record lands on ProvenanceStamp.external_calls, read AFTER the
debate so it is a record rather than an intention.

MEASURED, not assumed, before any of it was written: FunctionMiddleware fires for
a tool served over a REAL MCP stdio subprocess, and context.function.name carries
the BARE tool name with no server prefix. That measurement decided the design —
MAF cannot tell us which server a tool came from, so attribution comes from our own
config, and a name allowed by two servers is recorded UNATTRIBUTED (server="")
rather than credited to the first match. Naming a service that may never have been
contacted is the one place a guess must not go.

Only CONFIGURED tools are recorded. The middleware fires for every function the
agents invoke, including the in-process retrieve_cost_docs on the road path;
logging those would turn the record into a false egress claim. An empty list is a
positive statement — nothing outside this process was contacted — which is why it
is always serialized rather than omitted.

Honesty limit, written on ExternalCall itself: this is the call and its source. It
is NOT evidence that the service's answer reached the proposal, nor a verified
rendering of that answer.

One finding, and it is the reason for measuring rather than trusting green: the
road-path negative test was VACUOUS. Its scripted tool call named an argument the
tool does not declare (code vs query), MAF rejected the call before invocation, and
the test asserted an empty record against a run where no tool ran at all — green
under the exact mutation it existed to catch. It now spies on the recorder and
asserts the invocation genuinely reached it before asserting it was not recorded.
This is last session's lesson again: a scenario that cannot distinguish two
implementations proves nothing.

The tool-call double is registered in test_scripted_client_consolidation.py's
_DELEGATING_OVERRIDES — it cannot live in the reply_selector seam, which returns a
reply STRING, and a response that is not text is its whole subject.

Load-bearing MEASURED (tests/test_b4_mcp_call_trace_loadbearing.py) against the
whole 755-test suite, four mutations all red: detach the recorder from the debate
middleware · record every function invocation · attribute an ambiguous name to the
first server · stop reading the recorder into provenance. Control: a run with no
configured servers records nothing, so the empty record is a real answer and not
the only one the seam can produce.

Ran it, not just tested it: the real recorder against a real MCP server subprocess
returns ExternalCall(server='prisregister', tool='lookup_unit_price'), and a
scripted CLI run's outbox artefact carries the empty list.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VtRd8y1PDPGwkrRXFhubqr
2026-08-05 21:37:29 +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(repo): meet the org repo-standard gate — 0 ERROR 2026-08-03 21:56:19 +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 chore(repo): planning artifacts become local-only; fixture builders become code 2026-08-05 10:08:17 +02:00
bestille-en-kjoring.md feat(provenance): a run records which external service it actually called 2026-08-05 21:37:29 +02:00
ekspert-svar.md feat(outbox): every evaluated approach becomes something an expert can judge 2026-08-05 21:12:09 +02:00
extending.md feat(mcp): concrete MCP servers become tools the agents can call during a run 2026-08-05 16:53:07 +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