fix(contracts): params validation rejects only unknown keys; accepted params + results are checked after the handler

Handlers own their documented domain codes (4006 missing session_id, 4015 bad
url, 4009 orphan claim); the contract's job on the way in is the one check no
handler performs — an unknown key (4000 with the key path). Missing/mistyped
fields are re-checked AFTER a successful handler answer under the strict
test policy, so a contract narrower than the wire still fails the suite.
Two models widened from the suite: SeedMessage (clients forward stored rows
verbatim), tool.complete.args (mirrored child rows omit it). Tests that
drove session.activate with prompt params (and vice versa) or stubbed
_live_session_payload with a bare {session_id} now send the real shapes.
This commit is contained in:
teknium1
2026-09-14 01:40:00 -07:00
committed by Teknium
parent 0250c8bcae
commit 24ffc8d23c
11 changed files with 50 additions and 22 deletions

View File

@@ -92,7 +92,7 @@ def _register(req: ServerRequest) -> None:
raise RuntimeError(f"server request {req.method!r} has no contract in tui_gateway/contracts")
_, problem = contracts.validate_params(contract, {"session_id": req.sid, **req.params})
if problem is not None:
raise ValueError(problem)
raise ValueError(problem) # a key the renderer's typed handler would never read: our bug
with _lock:
_open[req.id] = req
_write(req.frame())