scripts/dev/split_module.py (lexer-based, with 16 self-tests) moves the top-level fn and impl items of 59 oversize module files in control-plane, desktop-core, model-format, gateway-text, leleka-memory, experimental-ref, context, serving-policy, tokenizer, backend-api, quant-core, harmony, igpu, libc-shim, npu-service and runtime-client into foo/<name>.rs groups of about 250 lines; types, constants, macros, nested modules and tests stay, every path stays valid through pub use re-exports, restricted visibilities keep their scope one level down, include paths and super:: paths are shifted. Not touched: leleka-runtime, cuda-driver, native-cpu-expert, sampler-ref and cpu-* (hot path, next wave) and the files kar-off-ab edits.
The baseline drops from 311 to 263 oversize files and from 273,600 to about 233,000 lines; the path-include ratchet ignores dir/name.rs child declarations.
scripts/dev/extract_tests.py moves a trailing cfg(test) mod tests block into foo/tests.rs for 118 files of leleka-runtime, cuda-driver, control-plane, gateway-text, deploy and nine smaller crates (31,000 lines), leaving production code and test ids untouched; 22 files that are themselves loaded through a path attribute carry an explicit path to their tests file. Not touched: the files the kar-off-ab branch edits (backend.rs, backend_original_serve.rs, backend_original_serve_replay.rs, qwen4exp_resident_expert_source.rs and seven deploy files).
Verified: cargo check --all-targets for the whole workspace on x86_64 Linux and on the Windows host; the 2429 library unit-test ids of the workspace are identical before and after (Linux listing diff empty); the loadable sections of leleka-inference, leleka-daemon, leleka-cli and strata-next are byte-identical between a release build before and after (scripts/dev/elf-sections-equal.sh), so the shipped code is the same. The architecture ratchets exclude tests.rs from the path-include count; the baseline drops from 329 to 311 oversize files and from 302,000 to 273,600 lines.
Mechanical rustfmt (control-plane, desktop-core and the runtime client had 360 hunks of drift; the CI format steps for control-plane and
desktop-core were red), plus, found by running `cargo clippy -D warnings` and the tests on Linux:
* control-plane/tests/log_failure_sse.rs `no_panicking_log_macros_in_the_serving_crate` was red on main since the observability merge: two
test-only `eprintln!` samples (prometheus.rs, request_log.rs) trip its source scan. They now write to stderr with `write_fmt` and
ignore a failed write, which is what the test asks for; the output is the same.
* tool_output.rs `is_multiple_of(2)`, an unneeded `mut` in a control-plane test, a collapsible `if` in leleka-inference.rs,
`#[allow(dead_code)]` on observer_adaptive_slots (compiled into leleka-inference-evaluation too).
* crates/deploy/src/facts.rs: `lab_holder_running` moved above `mod tests` (clippy::items_after_test_module); code moved, not changed.
Kept as its own commit so it can be redone with `cargo fmt` if other branches touch these crates first. No behaviour change.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
* crates/obs (leleka-obs, std only): one event per line (JSON under `leleka run`, key=value on a terminal, the lab's plain lines when a
binary is started by hand into a file), UTC ms timestamp, level, component, event, flat fields; prompt/completion text and credentials
never appear (key classes + value scrub + registered secrets), per-event token buckets with a `suppressed` count, value and line caps,
histogram with Prometheus exposition, size-capped file sink for requests.log.
* control-plane: `observe` middleware gives every generation request an id (x-leleka-request-id header) and a session tag (hash of the
client's session header); the worker marks engine start / first token / terminal / error on it and one record is written at request end
(tokens, cached prefix, queue wait, TTFT, prefill/decode tok/s, finish, error class, engine restart, GPU clock/temp/throttle). All
elog! lines go through the log layer (sampled per call site). /metrics?format=prometheus gains request counters and histograms, engine
lost/attached counters, uptime and supervisor restarts, PCIe, memory clock, throttle reasons, speculative tokens per round, expert-tier
entries by tier and hit ratio.
* engine: one structured line per request with the same id (rounds, tokens per round, expert-tier share served from VRAM/PCIe/CPU for that
request); telemetry gains spec / expert_tier / last_request; NVML sampler reads PCIe throughput, memory clock, throttle reasons.
* supervisor: structured events (engine exit, health, restarts), secrets registered with the log layer, children get LELEKA_REQUEST_LOG,
LELEKA_STATUS_FILE, LELEKA_PROFILE and JSON logging; runtime-client and gateway log connect/probe failures as sampled events.
* leleka logs (--tail/--since/--level/--component/--source/--request/--follow), leleka report (sanitized support bundle, written only with
--yes, nothing sent anywhere), request statistics in leleka status / verify --quick.
* generation, sampling and kernels are untouched; the lab scripts keep their plain lines (LELEKA_LOG_FORMAT=legacy or a hand-started binary).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
serve_tuning (settings document, validation, effective settings), Command::Reconfigure in the Original serve loop with rollback,
Backend::reconfigure, gRPC Runtime.Reconfigure, POST /v1/reconfigure, telemetry.settings; tests for each layer.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- leleka-runtime: memory_governor glue (startup plan with refusal, KAR memfd lock/residency guard, VRAM check, load-ledger stages,
inventory classes), prefix budget from the governor (auto/explicit clamped), shed directive applied per request and per prefill chunk,
engine-side admission (503 memory_pressure text), page-cache release of the shards after the resident bank load, cgroup-aware
available_memory.
- backend-api: Backend::memory_report (default None) and ScriptedEngine support; proto Snapshot.memory_json; desktop-core runtime_rpc and
runtime-client carry it.
- control-plane: MemoryView, /v1/status `memory`, /metrics `memory`, 503 memory_pressure + Retry-After gate before queueing, engine-side
refusal text mapped to the same 503; tests incl. a 600-request model-free soak (threads/fds/RSS flat).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
proto/runtime.proto, the wire conversions and the validated RuntimeClient move out of
strata-desktop-core so strata-next can use them; strata-desktop-core re-exports them
unchanged. GrpcBackend implements the Backend contract by attaching to a runtime an
operator already loaded (no Load/Unload RPC), re-reading epoch and handle before every
generation, and ending a generation without a terminal event on any transport or frame
error. 9 loopback HTTP/2 tests with a scripted runtime server.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>