22 Commits
Author SHA1 Message Date
Pavlo Ratushnyi 8b34c9506e Format the control-plane, engine-host and library crates at 120 columns (rustfmt.toml) and drop stale docs/ references 2026-11-23 09:34:30 +01:00
Pavlo Ratushnyi 94592f4fa0 wip: rename strata-next/strata-control/strata-desktop-core (to be squashed in the final rename commit) 2026-11-14 20:30:41 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 13742421bb gateway-domain, gateway-text, backend-api, runtime-client, npu-service: env_settings readers, no dyn in the budget loop, no blanket unused-import allows, doc headers and renamed modules
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 19:40:19 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 e03bedc3b1 Debt rework: doc headers everywhere, two import ratchets with the baseline, process-global counts uses and not import lists, 400-line fixes, docs
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-13 19:48:44 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 a6f36378cf Explicit imports and generated doc headers for the small and mid-size crates (obs, gateway-*, tokenizer, context, backend-api, harmony, runtime-client, serving-policy, experimental-ref, cuda-model, engine-core, model-format, control-plane, desktop-core, deploy, npu-service, cpu-sys, native-cpu-expert headers)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-13 19:27:40 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 b686f6ab75 STRA-338: rename the 854 mechanically named modules (impl_*, *_fn, *_<N>) after what they hold; mechanical_names census 854 -> 0
git mv of the files and of the module directories next to them, mod declarations, #[path] attributes and
the paths that name the modules, rewritten by scripts/dev/rename_mechanical.py from a reviewed name table.
Two files lost one to two lines so the 400-line limit holds again (qsa_prompt_index, original_verify_expert_probe).
limits-baseline.json: test fn_lines 0 -> 1 is --allow-increase for crates/deploy builtin_profiles.rs:149 (37 lines,
the speed-vs-strata session's file, not touched here); the prod params census falls 108 -> 1 (w_launch, extern C ABI).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 13:43:56 +01:00
Pavlo Ratushnyi df15e7afd5 STRA-338 size6 r01: split oversized tests and example, wrap wide lines in small crates 2026-11-07 17:04:17 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 c4e99d2ca6 STRA-338: rustfmt of the merged size-gw files
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 09:41:44 +01:00
Pavlo Ratushnyi a830d8f110 STRA-338 size-fn2: check_* that act are named for what they do (cancel_stalled_generation, probe_host, fail_if_api_exited, fail_if_engine_exited, read_assistant_text, detach_if_unattached), helpers named verb + object (report_stopping / report_engine_lost leave the Flow to the caller, count_failed_start, answer_refused_start, require_free_endpoint + spawn_worker_process, pin_engine_gpu, describe_load_verdict, run_worker_action, open_watch_stream, ...), the cold path reuses catalog_changed, the three Supervisor types are AttachLoop, SessionSupervisor and ServiceSupervisor; behaviour unchanged 2026-11-06 23:07:59 +01:00
Pavlo Ratushnyi 3140224119 STRA-338 size-fn2: check_ functions that mutate or compute become predicates plus an explicit step (trace_items check_call / record_call_id, runtime-client verify_still_attached over a pure check_snapshot_is_attached, service_switch catalog_changed_during_cold_preparation / abort_cold_preparation, check_context_budget returns nothing and the caller takes remaining_tokens, origins_and_sampling -> read_origins / read_sampling); spawn_engine keeps within 30 lines (admit_gpu) 2026-11-06 21:31:21 +01:00
Pavlo Ratushnyi be12cf5f15 STRA-338 size-fn2: leleka-runtime-client lines within 120 columns (wide 3 -> 0; doc comments re-filled) 2026-11-06 20:26:25 +01:00
Pavlo Ratushnyi b99d890439 STRA-338 size-fn: runtime-client: split snapshot validation, generation frames, backend probe/start/reconfigure, pump, conversions and tests (fn>30 15 -> 0); gateway-domain: item writer, doc comments 2026-11-06 17:56:01 +01:00
Pavlo Ratushnyi 0ad203f7d7 STRA-338 size-rest: tokenizer, gateway-text, gateway-domain, runtime-client, cpu-worker and experimental-ref within 400 lines per file
Oversize files before/after: tokenizer 1 -> 0 (lib.rs 840 into construction, encoding, decoding, bpe_merge, vocabulary),
gateway-text 1 -> 0, runtime-client 1 -> 0, cpu-worker 1 -> 0, experimental-ref 1 -> 0 (test files split by topic),
gateway-domain 1 -> 0: render_request_with (385 lines, complexity 93) became an entry function plus one function per
system message and one method per input item kind; messages, check order and rendered text unchanged (gateway-domain 17
tests and strata-control responses 72 tests pass).

Census prod/test (fn>30 / cx>10 / nesting>4 / wide lines): gateway-domain 16/3, 13/0, 6/0, 53/1 -> 16/3, 12/0, 5/0, 45/1;
runtime-client test 9 -> 6 long functions; experimental-ref test wide lines 58 -> 37; tokenizer, gateway-text and
cpu-worker unchanged. Test ids and outcomes unchanged.
2026-11-06 16:28:25 +01:00
Pavlo Ratushnyi 6b5fcd242e STRA-338 S12b: fns and impl blocks of 59 cold oversize modules move into child modules (model-format, gateway, desktop-core, leaf libraries)
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.
2026-11-05 15:29:39 +01:00
Pavlo Ratushnyi f78b89757c STRA-338 S12a: inline unit-test modules move to sibling tests.rs files in 118 oversize files
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.
2026-11-05 15:00:09 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 72fc3b0820 style: cargo fmt on strata-control, strata-desktop-core, leleka-runtime-client; clear Clippy lints and two red tests on main
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>
2026-11-03 00:30:27 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 fb10bf0e70 observability: structured bounded logs, per-request record, metrics, leleka logs / report
* 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>
2026-11-02 23:25:24 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 60b48d8225 runtime reconfiguration: reopen the serve stack with new context/cache/resource settings without reloading the model
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>
2026-10-25 03:01:53 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 08e2c78761 runtime telemetry: GPU load/VRAM (NVML), RAM, CPU cores, prefill/decode tok/s, cache hits, context
leleka-memory::telemetry (sampler + per-request records) -> Backend::telemetry_report -> Snapshot.telemetry_json
(gRPC) -> control plane /v1/status machine -> leleka status.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 19:58:28 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 5ebd939b6f feat(memory): wire the governor into the runtime, the gRPC status and the control plane
- 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>
2026-10-18 01:33:34 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 8af18396b8 feat(prefix-cache): pool protocol (summary through runtime gRPC, /v1/status, /v1/prefix_match), --prefix-cache-mib/--prefix-cache-block, laptop profile in the smoke, docs
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-17 19:47:53 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 c9aad38caa refactor: extract the runtime gRPC client into leleka-runtime-client and add GrpcBackend
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>
2026-10-16 02:42:11 +02:00