Expand description
Verify - the Phase-3 live conformance smoke suite, sanitized failure
evidence, and the versioned model-health.json store (task sa-0).
Three cheap, non-destructive checks exercise the OpenAI-compatible Chat Completions surface exactly as the Hermes plugin uses it:
- text_completion - a non-streaming completion must return the exact
string
CF_HERMES_OKin under 30 seconds (feedback 0210-inferenceacceptance:content_exact+max_elapsed_ms). - streaming - a streaming completion must emit its first valid SSE
event within 20 seconds, deliver at least one content delta, reach a
terminal chunk (
finish_reasonnon-null), close without a protocol error, and never emit a duplicate terminal event (feedback 0220-streamingacceptance). SSE is hand-rolled (line-baseddata:parsing) because the workspace forbids extra dependencies. - tool_call - a single call to the harmless
get_project_sentinelfunction withscope=provider-conformanceexactly once (feedback 0230-tool-callingacceptance). - structured_output - a single JSON object with
sentinelexactlyCF_HERMES_OK, constrained prompt-only (feedback 0250-structured-outputacceptance). - parallel_tools - two distinct harmless tool calls in one assistant
turn (feedback 02
30-tool-callingacceptance).
Checks 4 and 5 are standalone: they are exposed as public functions and
are deliberately NOT part of run_smoke_suite (wiring them into the
suite or the CLI is a separate task).
Live gate: every HTTP-calling function refuses to run unless the
environment variable AUTH_CLOUDFLARE_LIVE_TESTS is exactly 1 -
live_tests_enabled() - returning a typed
CloudflareError::MissingEnv refusal that names the variable. This is
the guardrail against accidental paid inference (feedback 02: paid runs
are opt-in). AUTH_CLOUDFLARE_MAX_COST_USD is an optional documented
conformance budget: when present, the run report carries
cost_estimate_usd; the value is reported and documented but never
enforced - enforcement is the operator’s job.
Exit-code contract (feedback 02, binding table):
0- all three checks passed;1- the live gate is closed (operational refusal);2- credentials missing (resolved by the CLI before this module);3- the live API was unreachable at send time (no HTTP response was obtained - connect/DNS/TLS/overall-timeout), i.e. a remote Cloudflare API failure, not a conformance verdict;6- the suite ran to completion and at least one check failed acceptance (non-2xx status or a 200 that failed acceptance), with sanitizedFailureEvidencepersisted.
Security contract (feedback 02, CI-tested): the token travels exclusively
through crate::fetch::auth_header; every error text and every response
excerpt is scrubbed with redact_token; FailureEvidence::new caps
excerpts at 512 characters; prompts, tool outputs, Authorization headers
and tokens are never persisted. The health store records only
sanitized evidence.
Health store layout (under Config::cache_dir()):
model-health.json - { version: 1, updated_at, records: { <model_id>: ModelVerification } }, written atomically (sibling .tmp + rename,
0o600) via crate::cache::atomic_write.
Structs§
- Check
Outcome - Outcome of one check: passed + elapsed, with sanitized failure evidence when the check failed.
- Checks
Report - The three smoke checks, keyed for the CLI report.
- Health
Store - The versioned health store: one
ModelVerificationper model id, keyed bymodel_id. Lives atConfig::cache_dir()/model-health.json, written atomically (sibling.tmp+ rename,0o600). - Smoke
RunReport - Full smoke run report (the CLI adds
gateandexit_code).
Enums§
- Stream
Event - One parsed SSE event: a JSON
data:payload, the[DONE]sentinel, or a malformeddata:line (a protocol error). - Suite
Kind - The suites this runner knows.
smokeandtool-loopexist in Phase 3; the CLI rejects anything else as a usage error.
Constants§
- EXACT_
TEXT - The exact content the non-streaming check must deliver.
- HEALTH_
STORE_ FILE - File name of the health store, inside
Config::cache_dir(). - HEALTH_
STORE_ VERSION - Schema version of the health store file layout. Bump on layout change so older stores are rejected loudly instead of misread.
- LIVE_
TESTS_ ENV - Env var gating live inference: the suite runs only when this is exactly
"1"(feedback 02: paid runs are opt-in). - MAX_
COST_ ENV - Optional conformance budget env var. When present (a positive finite
number), the run report carries
cost_estimate_usd; the budget is documented and reported, never enforced. - PARALLEL_
TOOL_ CHECK_ TIMEOUT - Overall agent timeout for the parallel-tools check.
- PARALLEL_
TOOL_ NAME - The second harmless sentinel tool name (parallel-tools check).
- PARALLEL_
TOOL_ PROMPT - The parallel-tools check prompt (feedback 02
30-tool-calling): both harmless tools must be called in one assistant turn. - PARALLEL_
TOOL_ VALUE - The only permitted
markerargument value for the second tool. - SMOKE_
SUITE_ ESTIMATED_ COST_ USD - Conservative upper-bound cost estimate for one smoke run (three tiny
requests, roughly 80 tokens round-trip at the most expensive in-catalog
price). Reported as
cost_estimate_usdonly whenAUTH_CLOUDFLARE_MAX_COST_USDis set; the budget itself is documented, never enforced. - STREAM_
CHECK_ TIMEOUT - Overall agent timeout for the streaming check - the “configured timeout” capping total stream duration.
- STREAM_
FIRST_ EVENT_ MAX_ MS - Streaming acceptance: first valid SSE event within this many ms.
- STREAM_
FIRST_ EVENT_ TIMEOUT - Per-read timeout for the streaming check (a stalled upstream must not hold the first event past the 20 s acceptance window).
- STRUCTURED_
CHECK_ TIMEOUT - Overall agent timeout for the structured-output check.
- STRUCTURED_
PROMPT - The structured-output check prompt. Prompt-only JSON constraint (no
response_formatparameter) so models that reject that parameter as unsupported still exercise structured output. - STRUCTURED_
SENTINEL_ FIELD - The required field name in the structured-output object.
- STRUCTURED_
SENTINEL_ VALUE - The required field value in the structured-output object.
- TEXT_
CHECK_ TIMEOUT - Overall agent timeout for the non-streaming text check (enforces the 30 s acceptance at the transport level).
- TEXT_
COMPLETION_ MAX_ ELAPSED_ MS - Non-streaming acceptance:
elapsed_msmust stay under this (feedback 02). - TEXT_
PROMPT - The fixed user message for the text and streaming checks (feedback 02
10-inference). - TOOL_
CHECK_ TIMEOUT - Overall agent timeout for the tool-call check.
- TOOL_
NAME - The harmless sentinel tool name (feedback 02
30-tool-calling). - TOOL_
PROMPT - The tool-calling check prompt (feedback 02
30-tool-calling). - TOOL_
SCOPE - The only permitted
scopeargument value.
Functions§
- aggregate_
verification - Aggregate the three check outcomes into the canonical
ModelVerification(feedback 02). Status formula: 0 failures → Passing, 1 failure → Degraded, 2+ failures → Failing. Each check counts as one run (total_runs= 3), sodelivery_success_rate()is the fraction of smoke checks that delivered - the picker’s delivery metric.last_failureis the first failed check’s evidence (text, stream, tool order); failure counters map fromFailureClass. - check_
parallel_ tools - Check (e): parallel tool calls. Acceptance (feedback 02
30-tool-calling): exactly two tool calls in one assistant turn, oneget_project_sentineland oneget_project_marker(order-agnostic), both with valid JSON arguments. - check_
streaming_ completion - Check (b): streaming completion. Acceptance (feedback 02
20-streaming): first valid SSE event within 20 s, at least one content delta, a terminal chunk with non-nullfinish_reason, clean close with no protocol error, no duplicate terminal event, total duration under the configured timeout. - check_
structured_ output - Check (d): structured output. Acceptance (feedback 02
50-structured-output): the completion content parses as a JSON object withsentinelexactlyCF_HERMES_OK. Prompt-only constraint - noresponse_formatparameter, so the model must honor a natural-language shape instruction. - check_
text_ completion - Check (a): non-streaming exact-text completion. Acceptance: content
exactly
CF_HERMES_OK, elapsed under 30 000 ms. - check_
tool_ call - Check (c): one harmless tool call. Acceptance (feedback 02
30-tool-calling): exactly one standard tool call, name exactlyget_project_sentinel, argument JSON parses,scopeexactlyprovider-conformance. - classify_
completion_ failure - Classify a non-streaming completion body that failed acceptance: empty
content → EmptyCompletion, truncated (
finish_reason“length”) → TruncatedCompletion, invalid JSON → InvalidJson, wrong shape → InvalidChatCompletionShape, missing/nullfinish reason → MissingFinishReason, else Unknown. - classify_
http_ failure - Classify a non-2xx (or envelope-carrying 200) response: 401 → AuthRejected,
403 → AuthRejected or AccountNotFound per the Cloudflare error envelope,
429 → RateLimited, 5xx → ProviderServerError, and an envelope with
success: falseplus a cf-ray → CloudflareEdgeError. Everything else is Unknown - never guess a specific class without evidence. - classify_
parallel_ tools - Pure acceptance for the parallel-tools check (feedback 02
30-tool-calling): exactly two tool calls in one turn, one per expected name (get_project_sentinel+get_project_marker, order-agnostic), both with valid JSON arguments.Nonemeans acceptance holds; otherwise NoToolCall (fewer than two calls), DuplicateToolCall (more than two, or the same name twice), InvalidToolName (an unexpected name), or InvalidToolArguments (an argument string that is not valid JSON). - classify_
stream_ failure - Pure streaming acceptance over a fully read event stream.
Nonemeans every acceptance criterion holds: first valid event within 20 s, at least one content delta, a terminal chunk with a finish reason, no protocol error, total duration under the configured timeout. - classify_
structured_ output - Pure acceptance for the structured-output check (feedback 02
50-structured-output): the completion content must parse as a JSON object withsentinelexactlyCF_HERMES_OK.Nonemeans the criterion holds; otherwise the closest existing taxonomy class is returned (InvalidJson for unparsable/wrong-valueJSON, InvalidChatCompletionShape for a non-object, EmptyCompletion for empty content) - no new variant is introduced. - classify_
tool_ response - Classify a tool-call response that failed acceptance: no tool call →
NoToolCall, wrong name → InvalidToolName, unparsable/wrong arguments →
InvalidToolArguments, more than one call → DuplicateToolCall, malformed
envelope → InvalidJson/InvalidChatCompletionShape.
Nonemeans the response is a valid singleget_project_sentinel(scope=provider-conformance)call -FailureClass::Unknownmust never be conflated with “valid”. - classify_
transport_ message - Classify a ureq transport message into the failure taxonomy by keyword: timeouts → ReadTimeout, connection failures → ConnectTimeout, resets → ConnectionReset, TLS → TlsFailure, else Unknown.
- gate_
refusal - The typed refusal returned when the live gate is closed.
- inspect_
text_ completion - Pure acceptance for the non-streaming text check: content must be exactly
CF_HERMES_OKin a well-formed completion. Returns the failure class, orOk(())when the content criterion holds (latency is checked by the caller). - live_
tests_ enabled - True when the live gate is open:
AUTH_CLOUDFLARE_LIVE_TESTSis exactly"1". Pure and testable; every HTTP-calling function consults this first. - load_
health_ store - Load the health store from
dir/model-health.json. A missing file is an empty store; a present-but-corrupt file or an unsupported schema version is a typed error (never a panic). - max_
cost_ usd_ env - Optional
AUTH_CLOUDFLARE_MAX_COST_USDbudget: a positive finite number, when present. Reported ascost_estimate_usd; never enforced. - run_
smoke_ suite - Run the full smoke suite against the model id exactly as given - the catalog is never consulted, so a model absent from the catalog is still verified (the CLI contract: fall back to the id as passed).
- save_
health_ store - Persist the health store atomically under
dir(create dirs, sibling.tmp+ rename,0o600). Never leaves a half-written store behind. - save_
verification - Read-modify-write upsert of one verification record after a run: load the existing store (preserving every other model’s record), upsert, save.
- verification_
from_ tool_ loop - Aggregate one tool-loop outcome into a
ModelVerification(feedback 02 suite 40). The loop counts as one run:total_runs= 1,multi_turn_tool_success_rateis 1.0 when the loop converged, 0.0 otherwise; a non-converged loop isFailingwithtool_loop_failures= 1 and the loop’s ownFailureClassas sanitized evidence (no HTTP status, no excerpt - the loop carries no response body).