Expand description
Host-side conformance (SPEC.md §11.1; issue #14) — the dual of the
provider-facing suite.
Where run_conformance drives an adversarial
provider and asserts the suite catches it, this drives the reference host
(contextgraph_host::Host) against adversarial providers — in-process ones,
plus short-lived stdio child fixtures for the transport-level scenarios (the
handshake and a crash mid-query) — the host-side equivalent of the provider
fixture’s --misbehave modes, and asserts the host upholds the rules that
bind it.
Each check is adversarial by construction: it points the host at a
provider that tries to make it fail, asserts the host catches it, AND
points it at a well-behaved counterpart it must accept — so a check passes
only if the host discriminates, never vacuously. It is the same principle
as .github/scripts/conformance-red.sh, here internal to each check.
Rules checked:
- H3 (§3, §3.1) — the host side of the version-family rule: a provider
whose
handshake_ackdeclares a mismatched major family is rejected with a namedHostError::VersionMismatch, never a hang or a panic, and a same-family provider still handshakes. This is the dual of §3’s provider- facinghandshakecheck (which asserts a provider replies with an ack): here it is the host that must reject a wrong-family ack, and do so promptly — “no hang” is an explicit assertion, driven under a harness-leveltokio::time::timeoutso a stall is a distinct, failing outcome. - B2 (§7) — a provider whose frames sum over
max_tokensis dropped-with-report, never silently truncated. - B4 (§7) — a provider returning more than
max_framesframes is dropped-with-report. - C1/C2 (§4) — an
egress: trueprovider is not queried before consent, and its query payload is never transmitted. - C6 (§4) — a provider declaring an off-machine egress scope with no recorded receipt is refused with a typed scope error; the payload is not transmitted.
- F5 bytes (§6.2) — a
file-provenance digest is verified against the source bytes over a trusted local fixture the harness controls (viaverify_file_provenance): a matching digest verifies, a tampered one is caught. - R3 (§11) — the compose/render path delimits frame
contentas quoted material inside a<frame>fence, never spliced as instructions. - Composition audit (§11 R3; issue #15) — the reference composer
(
compose_for_prompt) packs a multi-provider, over-budget, duplicate-content frame set into a within-budget prompt and emits an audit that explains every included and excluded frame (budget, dedup), while a within-budget duplicate-free set drops nothing. - Crash isolation (§11 robustness; the crash-consistency contract that
one provider’s failure never poisons a
query_all) — a provider that dies mid-query surfaces asHostError::ProviderCrashedand is excluded, while a healthy provider fanned out concurrently beside it still returns its frames and the fan-out still completes. The well-behaved counterpart is a healthy stdio provider in the same fan-out, proving the exclusion is real discrimination — not a stdio leg that simply never contributes.
§Honest residual (not checked here)
C4, C7, C8 bind the host’s HTTP transport — treating every non-loopback
provider as egress, requiring TLS, and never logging credentials. Exercising
them needs a real (non-loopback, TLS) network peer the in-process harness
cannot stand up, so they stay in §11.1’s residual list. R3 is now checked
on two fronts: HCHECK_CONTENT_QUOTING for the delimiting-and-escaping
contract (a content-embedded </frame> cannot break out), and
HCHECK_COMPOSITION_AUDIT for the full reference composition module — global
budget packing, cross-provider dedup, and an audit that explains every drop
(issue #15).
Constants§
- HCHECK_
BUDGET_ DROP - HCHECK_
COMPOSITION_ AUDIT - HCHECK_
CONSENT_ GATE - HCHECK_
CONTENT_ QUOTING - HCHECK_
CRASH_ ISOLATION - HCHECK_
FRAME_ LIMIT - HCHECK_
PROVENANCE_ BYTES - HCHECK_
SCOPE_ RECEIPT - HCHECK_
VERSION_ REJECT - The stable host-side check names, so reports and callers agree on identifiers.
Functions§
- run_
host_ conformance - Run every host-binding check against the reference host, returning a typed
ConformanceReport— the host-side analogue ofrun_conformance. Apassed()verdict means the host caught every adversarial provider and accepted every well-behaved one.