Files
leleka/docs/delivery-gap-audit.md
T
Pavlo RatushnyiandClaude Sonnet 5.5 e03d97dd86 fix(runtime): production Original Load admits the routed-expert bank; deploy: operation polling, expert-source profile field
The Original serve Load never admitted an expert source (the serve smokes call
load_resident_expert_source themselves), so the stack's prompt arena failed with
InputRead on the first real Load through leleka-inference. leleka-inference gains
--expert-source resident|mapped; backend.rs admits the chosen bank before the
driver. leleka up passes it per profile and the supervisor stops waiting when the
load operation is FAILED/INDETERMINATE.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-17 15:18:02 +02:00

23 KiB

Delivery gap audit: control plane and packaging (M2)

Branch claude/m2-control-plane (base claude/port-gpu-bringup @ 6cd926d), audit of 2026-10-16. Host-side only: no model was loaded, no GPU context was created, and nothing here is a performance or model-quality result. File:line references are to this branch. The run recipe is rust-runtime-run.md.

0. Findings that decide the next work

Update 2026-10-16, branch claude/api-over-rust-engine: finding 1 and section 7 task 1 are addressed in software by api-over-rust-engine.md (the full strata-next API in front of the runtime, tested with a scripted engine; no real engine run). Findings 2-5 and the delivery tasks are unchanged. The lock flakes of section 1 are most likely a test artefact (a flock kept alive past drop by a child another test forked meanwhile); the reopen in those tests now waits, and 12 of 12 parallel runs of the strata-desktop-core lib suite passed afterwards (the mechanism itself was not isolated).

Update 2026-10-17, branch claude/deploy: the packaging half of finding 4 and tasks 3-4 of section 7 are addressed in software by deploy.md (leleka up: preflight incl. driver/cuBLAS//proc/RAM/disk, asset fetch+verify+archive with stamps, native sealed-memfd supervisor, auto-load and readiness, systemd unit, OCI recipe, release tarball with provenance). Still open there: the MTP pack has no automated producer, no clean-VM run on Ubuntu 24.04/26.04, the image was not built here (see deploy.md section 10), and SIGTERM handling of the daemon/engine is worked around by the supervisor (it sends SIGINT).

  1. Two serving stacks exist and the full API is wired to the wrong one. strata-next (control-plane/) has the Responses / Chat / Messages surface, text.format, custom tools, reasoning, drain, history, MCP hub, but it drives an engine process over the Original stdio wire protocol (READY/GEN <token ids>/T <id>/DONE, control-plane/src/wire.rs). The Rust engine (leleka-inference) speaks gRPC with a text prompt in, text deltas out (crates/backend-api/src/lib.rs:130-211) and is fronted only by leleka-daemon, whose /v1/responses is a narrow text subset. No adapter joins them. Codex cannot use the Rust engine directly today (section 4).
  2. The daemon rejects a Codex-shaped request. A body with reasoning, include, tool_choice or parallel_tool_calls gets 400 unsupported_request_field (desktop-core/src/runtime_gateway.rs:422-431, observed live, section 2); max_output_tokens defaults to 256 and is capped at 4096 (:442-443); tools are off unless experimental_native_tools is set (:642).
  3. Every Original-path request starts from an empty context (no conversation or prefix reuse is bound, docs/original-serve.md:97-104); the backend serves one generation at a time (backend.rs:759).
  4. Delivery of the Rust pair is absent: no image, no installer, no health/ready endpoint on the daemon, no SIGTERM handling, no readiness after restart without a manual load-mtp. Existing packaging (deploy/) ships strata-next plus the C++ engine only.
  5. Gate A evidence is synthetic. Every committed Responses fixture is marked synthetic (benchmarks/fixtures/responses/*.json); no recorded Codex session or comparison against the Python server exists (docs/roadmap.md P3 last item, charter backlog item 3).
  6. Found and fixed here: a dead log sink killed the worker supervisor and left readiness true (section 6, e743764); the static CLI image could not build (e5c7c32); three smoke/test expectations were stale (203b88f, 6ca48b8).

1. Host test suites (no GPU, no model)

Linux x86_64 (rnr5090: Ubuntu 26.04.1, Rust 1.99.0, own tree ~/work/leleka-m2, nice -n 15 cargo test --locked -j 8 --no-fail-fast, default workspace members):

run passed failed ignored targets note
1, base 6cd926d 898 6 1 72 see failures below
2, HEAD after the fixes 910 0 2 73 includes 4 leleka-seal-exec and 3 log_failure_sse tests

Failures of run 1:

test cause status
desktop-core/tests/native_tools_sdet.rs declarations_are_bounded_unique_and_closed_before_render stale: asserted temperature 0.4 is refused, valid since cce4333 fixed 203b88f
strata-desktop-core --lib operation_journal::tests::{append_failure_preserves_existing_evidence, terminal_history_survives_and_incomplete_is_not_replayed} (and recovered_uncertainty... in reruns) journal already owned or locking unavailable under the parallel lib run; pass alone and with --test-threads=1; 4 of 5 parallel reruns failed once, run 2 passed. Root cause not isolated (suspected: the flock of one test inherited by a concurrent child process until exec) open, flaky
strata-control --lib responses::tests::durable_history_roundtrip_delete_eviction_and_faults same message from history.lock; 3 of 3 reruns passed open, flaky
runtime_gateway_sdet daemon_http_disconnect_cancels_one_runtime_generation timed out (13 s) in the loaded run; 3 of 3 isolated runs passed load-sensitive

Other checks on Linux: cargo clippy -p strata-control --all-targets --no-deps -- -D warnings clean; with dependencies it stops at known debt in leleka-model-format (pinned_arena_plan.rs:325 type_complexity), so scripts/check-local.sh full mode fails at the control-plane Clippy step. cargo fmt -p strata-desktop-core --check also reports existing drift (leleka-inference.rs, untouched here).

HTTP/SSE smokes against strata-next with scripted engines (Python 3.14 as test driver only), debug binary: pass test-live-responses-replay (21 corrupt streams rejected, JSON+SSE tool continuation), smoke-tool-policy (216 cases), smoke-custom-tools, smoke-sse-keepalive, smoke-input-tokens, smoke-response-history (+--durable), smoke-native-drain, smoke-signal-drain, smoke-generation-deadline, smoke-worker-cancel, smoke-native-auth, smoke-queue-deadline, smoke-config-check, smoke-wait-ready, smoke-chat-completions, smoke-messages (the last two after 6ca48b8; before it they failed on stale expectations). replay-responses --sse on the structured-tool fixture ends in response.completed. Not run: smoke-static-cli, smoke-embedded-engine, packaging and container smokes, the live Python-oracle differentials.

Windows 11 (Rust 1.99.0): the 8 portable crates (leleka-backend-api, -tokenizer, -quant-core, -context, -sampler-ref, -experimental-ref, -serving-policy, -offline-tools): 341 passed, 0 failed. The default workspace does not build here: desktop-core pulls leleka-runtime -> leleka-cuda-driver (Linux-only items, 29 compile errors), strata-control lib tests use std::os::unix (vision.rs:499,513), leleka-model-format lib tests need the unix-only RangeSource for KarInspection (kar_levels.rs:582, used at tests/kar_ple/mod.rs:693). Windows is not a delivery target; use Linux.

2. Synthetic verification of the request path

layer what ran result
daemon gateway, mock backend, real HTTP/2 + gRPC runtime_gateway_sdet (8 tests): ordered SSE with one terminal, finish reason stop -> completed, length -> incomplete, missing terminal / tool reason / accepted fault -> response.failed without retry, disconnect cancels one generation pass
daemon process + leleka-inference process (real binaries, no Load) /runtime/status connected, model_ready: false; /v1/responses valid body -> 503 model_not_ready; unsupported field -> 400; no token -> 401 as expected; recipe in rust-runtime-run.md
strata-next over a scripted engine live SSE: created, in_progress, output_item.added, content_part.added, output_text.delta*, done events, output_item.done, function_call_arguments.delta*/done, ... completed; token budget -> response.incomplete (max_output_tokens); worker error -> response.failed (unit tests responses.rs:5428,5490) pass
log failure real binary, stderr consumer gone, protocol failure mid-stream stream ends response.failed; readiness drops (after e743764)

3. Python audit

Production serving path (what strata-next serve, leleka-daemon, leleka-inference start at run time): no Python.

item where class
external processes spawned by strata-next nvidia-smi (doctor.rs:50, cuda_memory.rs:134), systemctl (service_install.rs:543,627), operator engine.executable / @embedded memfd (worker.rs:441, embedded_engine.rs), operator strata-vision (vision.rs:222), operator before_load argv or sh (worker.rs:235-244), operator MCP server commands (mcp.rs:135), kill (mcp.rs:346,355) no Python hard-coded; an MCP server or before_load the operator configures may be anything
chat template include_str!(engine/strata/serve/chat_template.jinja) rendered by minijinja (prompt.rs:32) data file, not Python
leleka-inference / leleka-daemon / leleka-cli / leleka-seal-exec ldd: libc, libm, libgcc_s; dlopen libcuda.so.1, libcublas.so.12 none
error text only original_mtp_rt.rs:71 says "run tools/mtp_rt.py" (offline conversion; ported to crates/offline-tools) message
KAR sealing for the engine bring-up used operator scripts seal_exec.py / kar_holder.py (outside the repo) replaced by leleka-seal-exec (414169b)
offline-only tooling scripts/offline/diff_*.py (oracle differentials), engine/strata/tools/*.py (Original converters; Rust ports in native_pack.rs, offline-tools; mtp_pack producer still absent), scripts/gpu-bringup/*.py (compile/seal PTX), scripts/build-linux-package.py, build-runtime-image.py, bootstrap-cuda-toolkit.py, publish-gitea-release.py build / offline
test-only scripts/smoke-*.py, scripts/test-*.py (83 .py files in scripts/, including benches and installers), desktop/tests/*.py, control-plane/tests/mcp_hub.rs (spawns python3 for a fake MCP server) CI / test
client-side launchers scripts/install-qwen-native*.py, qwen_native_api.py, qwen_native_service.py (qwen-codex-ctl on the laptop) not serving
reference only engine/strata/serve/server.py (Original Python server): differential goldens (tests/fixtures/golden/*, http_surface.rs) not started by any Rust code
images Dockerfile.runtime is scratch-like plus the binary; Dockerfile.systemd-smoke installs python3 for its fixture test image only

Residual risk: CI itself (linux.yml, desktop.yml, port.yml) needs Python; production does not.

4. Codex-direct audit

"strata-next" = control-plane/; "daemon" = desktop-core/src/runtime_gateway.rs. Wire contract: docs/api-contract.md.

requirement strata-next daemon (Rust engine) gap / location
POST /v1/responses, bearer auth, SSE yes (responses.rs:1078, streams :1951,2122,2423) yes none
Codex-shaped body (include, reasoning, store:false, parallel_tool_calls, tool_choice:auto, prompt_cache_key, client_metadata) accepted (responses.rs:487-521, :709-722) 400 unsupported_request_field (runtime_gateway.rs:422-431; tool path runtime_tools.rs:393-418) daemon
unknown top-level or text fields rejected by deny_unknown_fields (responses.rs:486,524): service_tier, text.verbosity, max_tool_calls, user would 400 rejected decide accept-and-ignore for harmless fields
reasoning.effort / summary effort none..xhigh; summary only auto/null (:1361-1388); minimal and concise/detailed -> 400 thinking never enabled (Effort::None) strata-next: map minimal; daemon: absent
text.format text / json_object / json_schema prompt guidance + validation of the finished text; buffered until DONE; invalid -> response.failed (:684-707, render :1625-1640, api-contract.md "Live structured text") only {"format":{"type":"text"}} (runtime_tools.rs:432-437) no constrained decoding anywhere; daemon: absent
function tools yes, schema-validated before publication (:765-791); names [A-Za-z0-9_-] up to 64 bytes behind experimental_native_tools (default off, :642), buffered, one regeneration on invalid output, at most 128 tools (runtime_tools.rs:14) daemon: default-off, no streaming of arguments
custom tools (text) and regex format yes, validation-only (response_tools.rs:62-101) tool adapter covers namespaced custom regex (test native_tools_sdet) no grammar-constrained sampling
custom tools with Lark grammar rejected 400 (response_tools.rs:87-89) rejected a Codex that sends its freeform apply_patch as a Lark custom tool gets 400; needs the function variant or Lark support
hosted tools (web_search, local_shell, image_generation, file_search) rejected (response_tools.rs:65-67) rejected acceptable unless Codex config enables them
tool_choice auto / none / required / forced function or custom / allowed_tools yes (:589-652, :730-763, validate_live_subset :2684) adapter only forced namespaced selectors -> 501
parallel_tool_calls:false enforcement yes (:645) adapter none
streaming event order, sequence_number, one terminal tested (responses.rs:4851,5153,5369,5527) Trace (runtime_gateway.rs:519-594) none
terminal event on every failure worker error, DONE missing, store failure -> response.failed (:2098-2113, :2293, :2614); log-sink failure fixed e743764 stream error -> interrupted() response.failed no SIGTERM handler in the daemon: a stop cuts live SSE (leleka-daemon.rs:38, SIGINT only)
max output tokens default min(32768, context minus prompt) (:1135-1140) default 256, max 4096 (:442-443) daemon
long-prefill keep-alive : keep-alive after 15 s (native_events.rs:9-11) only in the tool path (:902-917) text path silent while prefilling
conversation / prefix reuse across turns engine-side (RESUME/REUSED lines) none: every request resets to position 0 (original-serve.md:97-104) full re-prefill per Codex turn
stored responses, previous_response_id, input_items, DELETE yes (api-contract.md, in-memory or durable) no daemon
/v1/responses/input_tokens, /v1/chat/completions, /v1/messages yes no daemon
MCP Codex executes MCP tools itself; the server only sees function tools named mcp__server__tool (accepted). Server MCP hub mcp.rs is tested (tests/mcp_hub.rs, 5 tests) but nothing executes tools for a client (api-contract.md:208) same as function tools the real Codex+LeaseVibe MCP episode is not recorded
approval / review turns developer messages coalesced into the system section (api-contract.md "Approval/review requests") untested no real capture
reasoning item replay requires raw reasoning_text content; encrypted_content or summary-only -> 400 (responses.rs:1660-1668) n/a unverified against what Codex actually re-sends
concurrency one generation at a time; admission 429 / drain 503 max_concurrent_generations: 1 (backend.rs:759) charter G8 later
transport HTTP on loopback, no TLS (use SSH forwarding) same rented server needs a tunnel
error body {"error":{"message","type","param","code"}} {"error":{"message":code,"type":code}} differing shapes
evidence all fixtures synthetic synthetic no recorded Codex session, no comparison with the Python server

5. Deployment audit (clean Ubuntu 24.04 / 26.04, NVIDIA driver >= 595)

item state evidence missing
driver floor doctor / gpu_requirement know only cuda-13.0-linux = 580.65.06 doctor.rs:27,44 the sealed PTX contains ISA 9.2 (36 .ptx files, nvcc 13.2) and the target floor is 595: a cuda-13.2-linux profile; no check for libcublas.so.12
cuBLAS the Rust engine dlopens CUDA 12 libcublas.so.12 by name ple_batch_ffi.rs:147 not packaged, not preflighted; deploy/README.md still says libcublas.so.13 for the C++ engine; version pin undecided (bring-up 12.9.1.4, Ubuntu 26.04 libcublas12 12.4.5.8)
binaries cargo build --release -p strata-desktop-core --bin leleka-inference ... needs only Rust + a C compiler ldd of the debug build no release job, no checksum/provenance for the Rust pair; linux.yml builds only strata-next + C++ engine; port.yml only type-checks
one-command install strata-next service-install (user unit, --start-ready) exists for strata-next deploy/README.md:77-130 nothing for leleka-inference + leleka-daemon; no asset fetch/verify chain for the KAR archive, MTP pack and shards of the Rust path
sealed KAR leleka-seal-exec (414169b) tests 55 GB RAM per engine start; no preflight of free RAM//proc/memfd
systemd templates deploy/rust-runtime/*.service pass systemd-analyze --user verify; strata-next has a user unit (service_unit.rs:44-63, Restart=no) never run with the real model; no system-wide unit; lingering is never configured (deploy/README.md:240-246), so a user unit does not start at boot without admin action
signals strata-next has shutdown grace; the Rust pair handles SIGINT only leleka-daemon.rs:38, leleka-inference.rs:211 observed on the daemon: SIGTERM ends the process with status 143, SIGINT exits 0; templates set KillSignal=SIGINT as a workaround
readiness / health strata-next: /health, /ready, /status, wait-ready; daemon: authenticated /runtime/status only runtime_gateway.rs:220 no unauthenticated probe, no wait-ready equivalent, no auto-load: after any engine restart the model is not loaded until leleka-cli load-mtp
OCI image Dockerfile.runtime = strata-next + embedded C++ engine on an Ubuntu 26.04 digest, non-root, NVIDIA_VISIBLE_DEVICES=void default deploy/Dockerfile.runtime, build-runtime-image.py no image for the Rust pair; Dockerfile.static-cli context was broken (fixed e5c7c32)
model volume / no re-download asset manifests with SHA-256, resumable fetch, atomic publish for strata-next deploy/README.md:646-770 not wired to the Rust path's inputs (shards + KAR + provenance + MTP pack)
observability JSON /metrics on strata-next (not Prometheus) api-contract.md:265 none on the daemon/engine; DBG arena eprintln! lines remain on the engine load path (cache_original_prompt.rs:31-62)
security loopback only, bearer tokens from env, 0700/0600 checks in strata-next; tokens for the Rust pair read from env leleka-inference.rs:112 systemd EnvironmentFile mode not enforced by tooling
clean-host test none for either stack (docs/roadmap.md P4 acceptance open)

6. Changes made on this branch

commit change
203b88f desktop-core/tests/native_tools_sdet.rs: stale temperature assertion corrected (accept 0.4, refuse 2.5)
e743764 control-plane: elog! replaces every eprintln! (it panics when stderr is unwritable); new tests/log_failure_sse.rs (control case plus dead-sink case on the real binary, and a source scan)
6ca48b8 smoke-chat-completions.py, smoke-messages.py: refusal cases use out-of-range values; picture block is countable
414169b desktop-core: leleka-seal-exec (sealed memfd launcher), rustix target dependency
e5c7c32 .dockerignore / Dockerfile.static-cli: carry chat_template.jinja
docs commit this page, rust-runtime-run.md, desktop-core/examples/daemon.original.json, deploy/rust-runtime/ templates

Not changed: engine/strata/, crates/cuda-driver, crates/leleka-runtime, the flaky tests, the Windows test portability.

# task acceptance
1 One API in front of the Rust engine. Add token-level generation to backend-api (prompt token ids in, TokenDelta out, versioned) and a worker trait in control-plane with the stdio and the gRPC/in-process implementations; or move the daemon onto the control-plane router the control-plane HTTP fixtures (tools, custom/regex, text.format, reasoning, cancel, drain, history, Chat, Messages) pass unchanged against a fake Backend; a Codex-shaped body returns 200 with the section-4 event order; leleka-daemon route set equals strata-next's
2 Record and sanitize real Codex sessions (plain turns, MCP tool turns with LeaseVibe, approval/review, long context) and replay them through strata-next and the Python server, then the Rust path N sessions, zero protocol errors, zero streams without a terminal event, unchanged tool arguments, a written diff against the Python server; fixtures free of credentials and prompts that are not public
3 Rust-pair delivery: one command that preflights (driver >= 595, libcublas.so.12, /proc, free RAM >= 56 GB, disk), verifies assets by SHA-256, seals, starts engine and gateway, loads, waits for readiness on a clean Ubuntu 24.04 and 26.04 VM with a GPU: one command -> authenticated /ready true -> one /v1/responses completes; a restart reaches ready again without re-download
4 OCI image for the Rust pair (pinned base digest, pinned CUDA 12 cuBLAS with SHA-256, four binaries, non-root) and a CI job building it loader test without GPU passes (ldd, --help, dlopen failure messages); docker run --gpus all smoke on the GPU runner; provenance file lists binary digests
5 Lifecycle of the daemon/engine: SIGTERM drain with terminal SSE events, unauthenticated /health + /ready, --autoload/wait-ready, readiness false after engine restart kill -TERM during a stream ends it with response.failed/completed; a killed engine flips /ready and returns to ready by itself
6 Conversation/prefix reuse on the Original path and a per-turn token budget default second turn of a 50K-token conversation re-prefills only the new suffix (token counts reported, greedy output equal to the full re-prefill)
7 Constrained decoding for text.format and tool arguments (regex first, then JSON schema) schema-valid output on a fixed adversarial schema set without retries; validation still runs
8 Compatibility edges: Lark custom tools or the function form of apply_patch, harmless-field policy (service_tier, text.verbosity), reasoning.effort=minimal each Codex request shape from task 2 accepted or refused with a documented reason
9 Linux CI job for the default workspace (cargo test), fix the lock-inheritance flakes (serialize lock-holding tests or isolate them), clear the Clippy debt so check-local.sh is green 10 consecutive green parallel runs; check-local.sh full exits 0
10 Driver profile cuda-13.2-linux (595) and cuBLAS check in doctor; remove DBG eprintln! from the engine load path; telemetry per charter G10 doctor fails on driver 580 and on missing libcublas.so.12; no stderr noise on a quiet load