Commit Graph
815 Commits
Author SHA1 Message Date
Pavlo Ratushnyi 730d05d4e0 STRA-338 size: engine more helper splits (verify_parts, finish_parts, serve_tuning, direct_parts, mtp prefill) 2026-11-06 14:43:22 +01:00
Pavlo Ratushnyi 5df0c8b7fc STRA-338 size: engine split the new helpers further (decode_parts, serve_parts, open_parts, run_parts, generate_fn, generate_mtp); no dyn added 2026-11-06 14:34:18 +01:00
Pavlo Ratushnyi d259125d88 STRA-338 size: engine original_mtp_prefill/scalar_prefill: shared check_final_sources/shifted_next_ids/finish_draft_kv helpers (fn_lines 140 -> ~30, 110 -> ~35) 2026-11-06 14:16:39 +01:00
Pavlo Ratushnyi 8fde3e93c8 STRA-338 size: engine original_serve_host: run_window helpers (window_ple, run_pool_group, report_window) (fn_lines 109 -> ~55) 2026-11-06 14:14:15 +01:00
Pavlo Ratushnyi 907c177a9f STRA-338 size: engine serve_tuning::apply and CpuExpertPool::run_direct split into named steps (fn_lines 124 -> ~25, 130 -> ~35) 2026-11-06 14:12:31 +01:00
Pavlo Ratushnyi 9d146e9459 STRA-338 size: engine original_serve_verifier: assemble split into assemble_parts (fn_lines 142 -> ~45) 2026-11-06 14:08:52 +01:00
Pavlo Ratushnyi 22951a7459 STRA-338 size: engine backend/generate_mtp: generate_mtp_resume split into begin_decoder/prefill_tiles/verified_window/commit_window (fn_lines 216 -> ~85) 2026-11-06 14:06:33 +01:00
Pavlo Ratushnyi 0d659c7598 STRA-338 size: engine original_spec_controller: verify_commit and finish_round split into verify_parts/finish_parts (fn_lines 253 -> ~75, 167 -> ~30) 2026-11-06 14:04:47 +01:00
Pavlo Ratushnyi 1f9948d70f STRA-338 size: engine backend_original_serve runner: run and generate split into run_parts helpers (fn_lines 344 -> ~85, 164 -> ~85) 2026-11-06 13:52:28 +01:00
Pavlo Ratushnyi cdb02d527f STRA-338 size: engine original_serve_stack: OriginalServeStack::open split into open_parts helpers (fn_lines 385 -> ~120) 2026-11-06 13:47:57 +01:00
Pavlo Ratushnyi 6abab96174 STRA-338 size: engine original_serve_stack: decode_phase split into decode_parts/serve_parts helpers (fn_lines 364 -> ~160) 2026-11-06 13:42:17 +01:00
Pavlo Ratushnyi ad87e5b57d STRA-338 size: scripts/dev/split_types.py moves the types, consts and statics of oversize files into child modules (12 more files split; width census +750 and test census +10 are the restored compact data tables and the reflow, nothing added); 1793 tests listed before and after 2026-11-06 13:16:11 +01:00
Pavlo Ratushnyi ab4280a3df STRA-338 size: data tables keep their compact form (rustfmt::skip: 1719/2051/1905 -> 933/259/360 lines), kernel_ab example becomes a directory example split into 13 modules (3992 -> 1635 in main.rs) 2026-11-06 13:05:10 +01:00
Pavlo Ratushnyi cdfec56460 STRA-338 size: the engine crates are rustfmt-clean at 120 columns (per-crate rustfmt.toml: max_width 120, Max heuristics); width violations 6869 -> 2862 prod, 1273 -> 717 test; files that grew are re-split. Reasons for the raised census numbers: fn_lines +119 and complexity +14 are functions that cross 30 lines / 10 branches only because rustfmt put their one-line bodies on several lines (nothing was added); test lists identical (1793), 800 tests pass, the same 5 known failures; bring-up print gate lookback 20 -> 30 lines for the same reason 2026-11-06 13:03:51 +01:00
Pavlo Ratushnyi a9d80333b4 STRA-338 size: large inline modules of 15 engine-crate files move to files (extract_modules.py now emits #[path] only for files that are themselves loaded through #[path]); test lists identical (1793). Ratchets raised with reason: path-include +3 cuda-driver, +4 engine, +7 model-format... are the child declarations of files that sit under a #[path]-loaded parent (their children cannot be found otherwise); the follow-up that removes them is turning those parents into directory modules 2026-11-06 12:53:35 +01:00
Pavlo Ratushnyi 7a752b6d92 STRA-338 size: mock_driver, preflight probe, conversation tests, qwen artifact fixtures, obs lib and backend_original_serve split into child modules (94 oversize files left) 2026-11-06 12:44:05 +01:00
Pavlo Ratushnyi adf65a53b9 STRA-338 size: 28 oversize test files of the engine crates split by topic with scripts/dev/split_tests.py (tests keep their names, gain a topic module; 1793 tests listed before and after, same leaf names; baseline tightened: 121 -> 98 oversize files) 2026-11-06 12:41:45 +01:00
Pavlo Ratushnyi a4ceeab69c STRA-338 S22: the Qwen3.5 CUDA engine moves to the adapter crate leleka-engine-qwen35-cuda (L3, edges to cuda-driver, model-format, native-cpu-expert declared); leleka-runtime is a one-line facade over it; scripts, CI and the baseline follow the path. Test fixes found on the way: the digest pin test reads backend/config.rs, the bring-up print gate understands rustfmt-split cfg attributes and the settings snapshot guards 2026-11-06 11:34:15 +01:00
Pavlo Ratushnyi e049e24fe3 STRA-338 S20: EngineFamily seam in leleka-engine-core, Qwen35Cuda family in leleka-runtime, the scripted engine as leleka-engine-fake; the inference binary and the full-chain test start their engines through spawn::<F>. Ratchets raised by the Box<dyn Backend> signatures of the seam (core +2, fake +1, runtime +1) and 2 test lines: the Backend trait object is the process boundary the gRPC server already held 2026-11-06 11:20:57 +01:00
Pavlo Ratushnyi 58e3d864e1 STRA-338 S19e: admission, the stop set, ServeError<E> and the sequencing of one request (run_request over Lifecycle, generic, no trait object) move to leleka-engine-core::request; the runtime's owners reach it through a thin adapter 2026-11-06 11:12:25 +01:00
Pavlo Ratushnyi 8987e9ab06 STRA-338 S19d: the draft policy and the adaptive window policy move to leleka-engine-core::spec; LELEKA_SPEC_* parsing stays in the runtime (free function), SpecError converts to contract::Error 2026-11-06 11:05:47 +01:00
Pavlo Ratushnyi 93afb07bfb STRA-338 S19c: the conversation policy (cache, manager, snapshot, kv, state, model, binding) moves to leleka-engine-core::conversation; the 17 dyn-trait uses and 3 oversize test files move with it (runtime 68 -> 51, core 0 -> 17: a transfer, not growth); SessionDevice::available_memory becomes required, OriginalDevice reads the governor as before 2026-11-06 11:02:14 +01:00
Pavlo Ratushnyi d717c69777 STRA-338 S19b: the Original prompt plan moves to leleka-engine-core::prompt; the serving-context cell bound is a separate constructor the runtime calls 2026-11-06 10:57:41 +01:00
Pavlo Ratushnyi 38eb771a44 STRA-338 S19a: the cross-session prefix cache and the pure memory admission move to the new leleka-engine-core crate (L2); leleka-runtime re-exports them under the old paths 2026-11-06 10:54:33 +01:00
Pavlo Ratushnyi fc591f4e96 STRA-338: integrate the gateway G track (S21 protocol in gateway-domain, S6 rest, S7 serve phases) into the hexagonal integration 2026-11-06 01:46:01 +01:00
Pavlo Ratushnyi c0f6888310 STRA-338 S21: the pure part of the Anthropic Messages adapter moves to leleka-gateway-domain
messages/request.rs (the Messages request types and Request::into_responses, CountRequest, text and block helpers) and
messages/reply.rs (message, stop reason, tool_use block, usage, the error type table and envelope as functions of the
status number) are in crates/gateway-domain. strata-control keeps the route layers, the SSE adaptation and the HTTP errors;
error_value(StatusCode, ..) is a wrapper over the domain function. The adapter tests stay where they are and pass on the
moved code (same test ids). The long functions are added to docs/architecture/tech-debt.md, the continuation is recorded in
docs/experiments/stra-338-gateway-track.md (90 golden cases; an earlier commit message says 96, which was a miscount).
2026-11-06 01:29:57 +01:00
Pavlo Ratushnyi 4394ac3337 STRA-338 S21: the Harmony prompt of a gpt-oss request moves to leleka-gateway-domain
harmony_conversation (the Responses input as Harmony messages), harmony_render (developer message, tools, rendering through
leleka-harmony, the date given by the caller) and prompt_date (PromptDate, its parser, civil_date) are in
crates/gateway-domain/src/responses/. strata-control keeps the process-wide prompt date, today() and render(request) in
responses/harmony_prompt.rs with the inline tests, so the byte-exact Harmony prompt tests keep their ids and pass on the
moved code. render_at lost its cfg(test) because the tests live in the other crate. Function texts are unchanged; the long
ones are added to docs/architecture/tech-debt.md.
2026-11-06 01:21:16 +01:00
Pavlo Ratushnyi 3aa96fbf0e STRA-338 S21: the pure Responses protocol moves from strata-control to leleka-gateway-domain
CreateRequest, TextOptions, TextFormat, its validation and tool-choice rules, OutputItem, Usage, ResponseTrace with its
event stream, the prompt rendering (render_request_with), the output parsing and reasoning split (parse_output_items_with,
decode_generation_noted), reasoning_effort and the schema checks now live in crates/gateway-domain/src/responses/.
strata-control re-exports the types under responses::* and keeps thin wrappers with the old signatures for the places that
need a process flag, a stage span or a log line. The text of the moved functions is unchanged; the edits are listed in
docs/architecture/tech-debt.md (S21 wider).

Evidence: the golden fixture committed just before this (control-plane/tests/fixtures/golden/responses_pure.json, recorded
from the old code, 96 cases of render, validate, trace and parse) passes on the new code, and the Linux test ids of
strata-control, strata-desktop-core, leleka-gateway-text and leleka-gateway-domain are unchanged (0 changed, 0 missing).

Gate: --update-baseline --allow-increase was used for two entries. process-global:leleka-gateway-domain 0 -> 3 is the
memo of tool_schema_accepted moving with its function (process-global:strata-control fell 14 -> 11, the sum is unchanged).
render.rs is a new moved file of 405 lines (one 385-line legacy function), listed as debt.
2026-11-06 00:50:30 +01:00
Pavlo Ratushnyi 17296a58fd STRA-338: integrate engine S18 (WeightSource port, one migrated load phase) into the hexagonal integration 2026-11-06 00:30:15 +01:00
Pavlo Ratushnyi e0b4757683 STRA-338 S18: KarInspection and the sealed archive as WeightSource, WeightRange for the KAR stager, S18 notes in tech-debt.md 2026-11-06 00:29:31 +01:00
Pavlo Ratushnyi f8f6d780e2 STRA-338 S18: WeightSource port in leleka-model-format (borrowed regions, identity, digest), file, GGUF shard and resident-tensor adapters, in-memory double; the ranked profile is read through it 2026-11-06 00:15:11 +01:00
Pavlo Ratushnyi 18b4647d4d STRA-338: integrate engine S15 (ServeDevice seam, fake request-lifecycle device) into the hexagonal integration 2026-11-06 00:01:28 +01:00
Pavlo Ratushnyi c3aa7c2703 STRA-338 S15: ServeDevice seam for the request layer, scripted FakeDevice and lifecycle tests on the real generate and run_request
generate takes any ServeDevice (the stack delegates to its own methods, once per request); FakeStack/FakeDevice implement RequestOwners, ServeDevice, OriginalServePort and PrefixDevice over a ManualClock script. 14 lifecycle tests: completion, length, eos, partial acceptance, cancel, deadline, device errors, refusal, timing, prefix reuse. S15 notes and the S19 design in tech-debt.md.
2026-11-06 00:00:42 +01:00
Pavlo Ratushnyi b262abbc2c STRA-338: integrate engine S14 (Clock and MemoryPressure ports) into the hexagonal integration 2026-11-05 23:34:06 +01:00
Pavlo Ratushnyi b19b83dff3 STRA-338 S14: Stopwatch for the prefix cache retention scale, PrefixServe::new keeps its size, S14 notes in tech-debt.md 2026-11-05 23:32:14 +01:00
Pavlo Ratushnyi 2cc7b11fb3 STRA-338 S14: admission tests on the scripted host 2026-11-05 23:24:12 +01:00
Pavlo Ratushnyi e4340f077d STRA-338 S14: the GPU ordinal reaches the telemetry sampler through Run, not a process static 2026-11-05 23:23:01 +01:00
Pavlo Ratushnyi 1d94c7b378 STRA-338 S14: request, sweep and retention timing read an injected Clock in leleka-runtime
Generation (generate, generate_mtp), the terminal and event publication, the source verification, the measurement
recorder, the Original serve loop (request deadline, idle sweep, reconfigure), the TTFT marks, the seed plan, the prefix
device phases and the prefix cache (retention scale and phase timers, now per cache instead of a process OnceLock) take a
Clock; the composition roots hand them SystemClock. emit_event is one function in utf8.rs instead of two copies. Hot
loops keep comparing against the reading taken at the start of the request. Tests on a manual clock: terminal and event
backpressure limits, prefill/decode accounting, source verification reads, the idle sweep cadence and the prefix
retention.
2026-11-05 23:21:04 +01:00
Pavlo Ratushnyi 117378198b STRA-338 S14: Clock port in leleka-obs and MemoryPressure port in leleka-memory
Clock (SystemClock, ManualClock, AnyClock) lives in leleka_obs::time. The governor reads the host through MemoryPressure
(ProcPressure over the real /proc or Win32 text, ScriptedPressure for tests) and times itself, its ledger, the
telemetry window and the nvidia-smi rate limit on a Clock. Governor::new and the telemetry entry points keep their
signatures. Tests: rising, falling and flapping pressure, the one-second shed step and the stale-sampler fallback on
a manual clock.
2026-11-05 22:59:48 +01:00
Pavlo Ratushnyi 3179309127 STRA-338: integrate engine S13 (Settings port, EnvSource) into the hexagonal integration 2026-11-05 22:49:10 +01:00
Pavlo Ratushnyi 348e52bb1e STRA-338 S13: merge claude/hexagonal-integ, tighten the architecture baseline after the Settings port 2026-11-05 22:43:29 +01:00
Pavlo Ratushnyi fe6fc3313a STRA-338 S13: CPU pool settings grouped, golden tests for the strict parsers, S13 notes in tech-debt.md
The CPU pool fields of the memory topic move into MemorySettings::pool (CpuPoolSettings) so each constructor
stays short; no key and no spelling changes.

Golden tests for the parsers that read the captured namespace: the speculative engine (the numeric and the
set-ness reading of LELEKA_SPEC, clamps, the adaptive switch, arm lists, adaptive constants, legacy policy),
the NaN guard, the conversation cache policy (including a value that is not unicode), and the memory
governor keys. Long test tables carry #[rustfmt::skip] so each test stays within 30 lines.

docs/architecture/tech-debt.md: what S13 left outside the port and why (settings::process(), the other crates'
readers), the keys whose spellings differ on purpose, the reads that became snapshots, the functions this step
touched that were already over the limits.
2026-11-05 22:41:13 +01:00
Pavlo Ratushnyi c347d46b80 STRA-338 S13: diagnostics settings, and the ratchets follow modules declared inside test-only files
Diagnostics topic of Settings: the bring-up trace, the driver-error trace (the nine driver_error functions
share crate::driver_errors_traced), the PLE, prefill-residual, seed and prefix traces, the serve profile
and the prefill profile sync. A set-ness switch is on for any value, as before; the serve profile and the
spec traces stay off for 0 and the empty string. The OnceLock readers are gone.

measure.py: a module declared inside a file that is itself compiled only for tests (for example
fivecase_frames.rs under native_down_candidate_only.rs, through #[path]) is test-only too. Unit test added.
Accounting only; env-read of leleka-runtime is now 1 (ProcessEnv::get_os, the one place that calls std::env),
instant-now 45 to 42, path-include 102 to 101, process-global 69 to 61.
2026-11-05 22:41:12 +01:00
Pavlo Ratushnyi 5119cc812a STRA-338 S2: round transcripts of the speculative controller through the fake device as goldens (5 scenarios)
Test-only: crates/leleka-runtime/src/qwen_forward/original_spec_controller/tests/golden.rs and golden/*.txt. Each scenario records the port operations, draft plans, max_end and the emitted tokens; re-record with LELEKA_UPDATE_GOLDEN=1. All 5 pass in a second run without the flag (Linux). No production code changed. Baseline raised by 2 lines (--allow-increase): the one oversize tests.rs gained the declaration of the golden child module.
2026-11-05 22:34:51 +01:00
Pavlo Ratushnyi ecc774a530 STRA-338 S17: inline modules of the cuda-driver root and FFI files move to files, lib.rs and ffi/enabled.rs split by responsibility
lib.rs 3508 -> 938 lines, ffi.rs 1897 -> small, qwen_dispatch.rs 2003 and qwen_ffi.rs 1696 lose their inline test and installed-proof modules (scripts/dev/extract_modules.py, 5 self-tests; split_module.py --allow-root for lib.rs). Module paths, visibility and test ids are unchanged: 544 test ids before and after, cuda-driver tests 433 passed / 78 ignored before and after (Linux), host check clean. GPU identity and A/B follow with the combined batch 1+2 gate.
2026-11-05 22:28:30 +01:00
Pavlo Ratushnyi dd584a09d6 STRA-338 S13: prefill, cache and prefix settings
Kv topic of Settings: the prefill switches (stream, stream threshold, MoE span cache, GDN pool and mirror,
staged input), the dense slab, the prompt embedding alias, the legacy footprint, the PLE read-ahead and its
verification, the prefix retention and the checkpoint re-read. Every on-by-default switch keeps its own
spelling: on unless exactly 0 for the prefill group, packed unless 0 or off for the dense slab, trimmed
words for the footprint, an explicit word or the platform default for the read-ahead.

alias_requested, legacy_footprint_from and the draft-after-commit check remain as test-only helpers over
the same spelling tables that Settings uses, so the tests that exist for them still pin the production
spellings. The OnceLock readers of these keys are gone.
2026-11-05 22:23:05 +01:00
Pavlo Ratushnyi 4e6a9c6c24 STRA-338 S13: memory and expert-tier settings
Memory topic of Settings: tail-skip rank and its cache limit, span cache, refill defer, swap wait, PCIe
locked-only and auto modes, the adaptive tier numbers (min count, margin, decay text), routing dump, per-layer
sizing, the fault-injection count of the expert cache, and the CPU pool switches (pool path, fence, lookahead,
open cache, prefetch word, eager admission, prefetch-off file).

ExpertTierConfig::from_environment keeps its signature and delegates to from_source(&impl EnvSource), the
strict parser (a value that does not parse is refused); tier_env_tests.rs pins its spellings, defaults and
refusals. LELEKA_ADAPT_DECAY stays text so its range check and log line still run, once, where they did.
LELEKA_CPU_PREFETCH_OFF_FILE keeps the path from the settings and still asks the file system on every call.

OnceLock readers of these keys are gone (process-global 93 to 81, env-read 59 to 37).
2026-11-05 22:19:05 +01:00
Pavlo Ratushnyi baf93de2e7 STRA-338 S13: serve and decode settings
Adds the Settings port to leleka-runtime (src/settings.rs): an EnvSource trait with a ProcessEnv adapter
(the only std::env user) and a MapEnv adapter for tests, and a Settings value that captures the operator
namespace (LELEKA_*, STRATA_*) once, parses the plain switches and numbers into typed topic structs, and
hands the captured namespace to the parsers that report errors themselves. settings::process() is the
instance of the process; the load path carries it as LoadEnv::settings.

Serve topic: GGUF-PLE switch, public evaluation, profile name and digest, capture dir, the GiB budgets of
the memory plan, CPU worker count and pool plan, prefill loan tiers. The conversation cache policy, the PLE
reader policy, the memory governor config and the sampler path read the captured namespace.

Decode topic: coupled, overlap, draft-after-commit, serial publish, adapt defer, suffix reset, spec trace
and stats, logprob/draft/residual traces. The speculative engine, arm list, adaptive config and NaN guard
parsers take the captured namespace instead of calling std::env. LELEKA_SPEC keeps both of its readings:
the numeric one (a malformed value is ignored) and the set-ness one that decides whether the adaptive
window is the default (a malformed value still counts as set).

Parse semantics are unchanged per key; settings/*_tests.rs pin each spelling with a MapEnv. The cached
OnceLock readers of these keys are gone (process-global 113 to 93, env-read 93 to 59).
2026-11-05 22:09:14 +01:00
Pavlo Ratushnyi eecbfce60d STRA-338: integrate the engine track (kar-off-ab base, S5a, S5b, S13 ratchets) into the hexagonal base; the baseline is recomputed on the merged tree (growth only in the seven kar-off-ab files) 2026-11-05 21:51:28 +01:00
Pavlo Ratushnyi 7699138a6e STRA-338 S5b: decompose serve_load into ordered phase functions
serve_load (about 1000 lines, 1170 after rustfmt) becomes load.rs (a 20-line order of
the phases) plus: load_admit (every refusal that needs no model byte, the memory
governor start), load_sources + load_bind (verify, bind, identity digest chain, expert
bank), load_identity, load_cuda (driver, context, probes, hand-over to the Original
serve stack), load_weights + load_moe + load_moe_gates (output head, KAR PLE, dense and
MoE caches; the adaptive and learned-main witness gates), serve_loop + serve_generate +
serve_run + serve_report (the command loop and one Generate), serve_close (teardown).
owner() is split the same way. Each phase takes a small context (LoadEnv, Bound,
Identity, Weights, Serving, Exchange) and returns a typed result.

Order and side effects are kept: the admission checks, the env reads
(LELEKA_ORIGINAL_SERVE_GGUF_PLE is still read in gguf_ple_load and in the refusal
detail line), the log texts (including the load-gate detail line and the
KAR_MTP_PROFILE / NATIVE_MTP_PROFILE logic of the kar-off-ab branch), the cancellation
checks, the lap marks, and the drop order of the CUDA objects (Weights drops dense, MoE,
KAR PLE, output head; the context is closed after the weights and outlives the binding).
The three conditions of the former execution gates are one match, the policy flags one
PolicyFlags::of. No GPU or numerical path was touched.

New tests (backend/load_tests.rs): PolicyFlags against the former expressions, the
execution gates against the former three sequential checks for all 6 executions x 8
boolean combinations, and the weight-cache log line against its exact text and the
saturating subtraction. Test ids: 689 before the S5 work, 694 now (the five added), the
same 2 environment-dependent failures and 58 ignored; cargo check --all-targets for
leleka-runtime and leleka-deploy gives the same warning counts, clippy reports nothing
in backend/. All new and changed functions are within 30 lines, complexity 10, nesting 4,
except one 127-column line that is a 119-character MoeWeightCache constructor name
(docs/architecture/tech-debt.md, which also lists what S5a moved verbatim and still misses
the limits). moe_weight_cache.rs gains three pub(crate) use lines for the witness types.
The architecture baseline loses the transient backend/load.rs entry.
2026-11-05 21:39:26 +01:00