latent.serve.verify_wire¶
Black-box wire-conformance verifier for a served agent (ADR-009 D7/D9).
Where a white-box protocol check reads a consumer's @agent classes (does the
Python signature satisfy AgentProtocol?), this is its black-box counterpart:
it points at a running pod URL and proves the bytes on the wire conform to
the published ai-sdk contract without importing the agent. A consumer's
RemoteAgentProxy decodes exactly this wire, so a pod that passes here is one
a proxy can drive in production.
What it checks against a live <url>:
POST /streamreturns a body framed as valid SSE (data: …\n\nrecords) — the frame contract every wire codec shares (latent.wire.core.sse).- Every part
typeis in the conformance-minimum vocabulary (ADR-009 D7) — an unknown part means the pod and the contract have drifted. *-start/*-endlifecycle parts are balanced (text-start↔text-end,reasoning-start↔reasoning-end), andstart/finishbracket the run exactly once.- A tool's
tool-input-availableprecedes itstool-output-available(you can't return a tool result the caller never requested). - The run terminates with a
finishpart followed by the literal[DONE]sentinel — clients block forever without it. - A terminal text step exists (ADR-009 D9): decoding the wire through the
real ai-sdk codec +
segment_streamyields a non-empty terminal-step text, so the customer-facing answer survived the round trip. GET /healthzandGET /readyzanswer 200 (process alive + can serve).- An unsigned
POST /streamis rejected with 401 — per-request auth is actually enforced (ADR-009 D1), not merely configured. - A replayed signed
POST /streamis rejected with 401 — the same signed request posted twice (fixed nonce) is accepted once and rejected the second time, so anti-replay (ADR-009 D1), the reason the served auth exists, is actually enforced. Runs only with a--secret(it must sign the probe).
The verifier also reports the observed fidelity tier (NFR-6): full when
the stream carries data-latent-* parts (the lossless fidelity envelope a
latent-native pod emits, so encode ∘ decode = identity), else partial
(a conformance-minimum producer whose lifecycle framing is intact but whose
otherwise-lossy events can't be reconstructed byte-for-byte).
Violations are collected, not fail-fast: one run reports every problem so an operator fixes them in a batch. Exit code is 0 on a clean pass, non-zero if any violation was found (the health/auth probes count as violations too).
Classes¶
WireReport¶
WireReport(url: str, violations: list[str] = list(), notes: list[str] = list(), tier: str = 'partial', healthz_ok: bool = False, readyz_ok: bool = False, unsigned_rejected: bool = False, replay_rejected: bool = False, parts_seen: list[str] = list())
Accumulated result of one black-box verification run.
violations is the source of truth for the exit code; tier and the
boolean probes are reported regardless so an operator sees the full picture
even on failure.
Functions¶
main¶
Standalone argparse entry point (python -m latent.serve.verify_wire).
Mirrors the latent verify-wire subcommand; kept so the verifier can run
without the full typer CLI (e.g. in a minimal pod image).
run¶
Verify url, print the report, and return the process exit code.
Shared entry point for both the latent verify-wire typer command and the
main argparse wrapper: 0 on a clean pass, 1 if any violation was found.
verify_wire¶
Run the full black-box conformance suite against url; return the report.
The orchestration is intentionally linear and collects every violation: the
stream probe, the SSE frame + grammar checks, the terminal-text decode, the
two health probes, and the unsigned-auth probe each contribute independently
to report.violations.