HTTP + SSE client for the oxe engine and the pure request builder. Depends on oxa-proto. Used by oxa-core and oxa-cli; HTTP couples oxa to the local engine (O-135).
| Module | Task | Provides |
|---|---|---|
lib.rs |
architect (frozen) | re-exports; Engine, ChatRequest, Hints, EngineInfo come from oxa-proto |
http.rs, sse.rs |
A1 | Url, http_request, SseParser, post_sse |
chat.rs, info.rs, hints.rs |
A2 | build_body, ReplyAssembler, HttpEngine, build_headers, new_idem_key, fetch_info, count_tokens |
embedded.rs |
#289 | EmbeddedEngine, the injected EmbeddedGateway interface |
Contracts
build_body/build_headersare pure and are the only request builders. Body layout is fixed in the doc comment ofbuild_body; W6 fields are always present.- Liveness: comments count; one silence limit; no wall-clock limit.
- Retry only before the first data byte, same idempotency key. A cut reply is an
Errand never reaches the wire (W2). - Engine contract table (M1-M3, H1-H6): plan sec. 3.
oxa-fakeimplements the same table. - Comments (F2, S2 / F10):
: prefill <done>/<total> [<s>s]->StreamEvent::Prefill(the engine's seconds when given);: queued [pos=<n>] wait_s=<s>(key=value, unknown keys ignored) and the legacyqueued <n>(position) /queued <n>s(seconds) ->StreamEvent::Queued. - Errors (F3): a non-2xx reply and an in-stream error object (the controller's
event: errorafter early headers, the engine's plaindata: {"error":..}) share one mapping:exceed_context_size_error->context_overflow; 503 (also typelocal_backend_busy) ->engine_busy, messageHTTP 503plusretry after <n> swhen aRetry-Afterheader came (SseEnd::retry_after); other statuses ->engine_httpnamingHTTP <status>; an in-stream error without a status ->stream_broken. An error object after reply data is a cut reply (stream_broken).HttpEngine::chatnever retriesengine_busyitself (the core waits). - Info (F4, F14): capabilities from
/_local/statusmodel_limits[limits_for].capabilities(before the model loads), else/propsoxe_hints; a/props503 is no error; a controller instate: loadingwithout a context isengine_busy. HttpEngine::clear_hint(EG5):POST /_local/cache/clear {"scope":"hint","hint":h}, 404 ->POST /state-cache/clear; 409 ->busy; other non-2xx ->engine_http/engine_busy.- Contract tests against the fake:
tests/fit_engine_contract.rs.
EmbeddedEngine::new(Arc<dyn EmbeddedGateway>) explicitly opts into in-process
cloud chat. It shares the request builder, discovery parser and reply assembler
with HTTP. The binary supplies a gateway implementation that uses the same
admission, key, budget and ledger pipeline as the daemon. Neither the adapter
nor its caller owns provider credentials or implements those policies again.
No default engine selection changes in this slice.
Gateway completion includes ledger settlement; a Done event alone cannot make
an assistant turn succeed. Offline and pre-cancelled requests stop before any
gateway call. Mid-stream failures cannot produce a committed turn, and the
adapter never retries. Exact cloud tokenization is unsupported and prompt counts
remain client estimates. tests/embedded_gateway.rs exercises the socket-free
interface; wiring the real shared gateway and CLI selection is the next slice.