Commit Graph
1377 Commits
Author SHA1 Message Date
Pavlo Ratushnyi c6eee4eab1 STRA-338 size: split OriginalPromptExecutor::forward into per-phase helpers 2026-11-06 13:35:42 +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 412d9a48af STRA-338: merge the STRA-367 limits gate (claude/hexagonal-integ-lints) into the integration; check-local.sh keeps both the engine-crate package names and the limits steps 2026-11-06 11:39:49 +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 a8f1d11e64 STRA-338 S21: the CI coverage list and the product test step include leleka-gateway-domain 2026-11-06 11:29:46 +01:00
Pavlo Ratushnyi 48b2ce9f4c STRA-367: docs/architecture/limits-gate.md (rules, measures, allowlist, census, decision) and the legacy sites of tech-debt.md linked to allowlist entries 2026-11-06 11:26:53 +01:00
Pavlo Ratushnyi 054b57bec8 STRA-367: opt-in Clippy ratchet for too_many_lines, cognitive_complexity and too_many_arguments; limits gate in check-local --product
scripts/check-clippy-limits.sh (check-local.sh --clippy-limits) counts the three lints per crate
with thresholds 30 / 10 / 5 and fails when a total over all crates rises above
clippy-limits-baseline.json. The root clippy.toml carries only the two thresholds of allow-by-default
lints: too_many_arguments is on by default, and a root threshold of 5 fails the hard Clippy gates of
strata-control and strata-desktop-core. No source enables the lints and no rustfmt.toml is added.
check-local.sh --product runs the limits self-tests and the limits gate next to the architecture gate.
2026-11-06 11:26:53 +01:00
Pavlo Ratushnyi 334af80d3d STRA-367: limits gate for lawbook 301 (function 30 lines, complexity 10, nesting 4, width 120)
New and changed code is checked against the base (merge-base with the integration branch):
every added or touched function and every added or changed line must be within the limits,
unless limits-allowlist.json lists the function with a reason and an owner; an allowlisted
function may only shrink. The legacy that exists today is a per-crate census in
limits-baseline.json whose totals may only fall (same --update-baseline semantics as the
architecture gate). Rust is measured from the rustsplit lexer, the gate's own Python from ast.
56 self-tests, including a temporary git repository.
2026-11-06 11:26:53 +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 e765c06ae3 STRA-338 S7: last_activity at the start and end of a request reads the request's clock
run_backend_worker (twice per request) and the stdio worker's run_session (once per request) stamp last_activity with
ObsHandle::now(). The stamps at attach or READY and the per-engine-line stamp keep Instant::now(). The instant-now ratchet
of strata-control falls from 26 to 23. Docs: gateway-ports.md lists what is and is not behind the Clock.
2026-11-06 01:36:49 +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 339a4c82cc STRA-338 S7: the request record and the worker request stamps read the Clock port
ReqCtx (the per-request record behind the structured request line) holds the Clock from Observe and stamps admitted,
engine_start, first_token and the line itself with it; Record::from_state takes the time as an argument. The backend
worker (serve_one start, conclude end) and the stdio worker (combine_done start) read the request's own clock through
ObsHandle::now(), which falls back to the system clock when the request has no record. These are request-level stamps;
the per-event stamps (last_progress, drain and stop deadlines, activity stamps) keep calling Instant::now() and stay on
the instant-now ratchet, which fell from 31 to 26 for strata-control.

New test: the_record_stamps_come_from_the_injected_clock (a ManualClock gives queue_ms 40 and ttft_ms 100).
Docs: gateway-ports.md says which stamps are behind the port, describes the serve() phases, and records the S10 default
(the offline CLI groups stay in strata-control).
2026-11-06 01:13:30 +01:00
Pavlo Ratushnyi a0052cda6c STRA-338 S7: serve() is a list of phase functions (state, engine, http children), none over 30 lines
serve() was one function of about 240 lines. It is now the ordered list of start-up phases (load config and history, check
host, embedded engine, provision, bind, state, MCP, CORS warning, codec, vision, prompt switches, runtime worker, worker or
pool, idle unload, serve, stop) and the phases live in serve/state.rs, serve/engine.rs and serve/http.rs. The order of the
side effects is the old order; the state is still handed to the router by value (the engine channel closes when the server
stops); every string literal of the old file (log and error texts) is present unchanged. The 149-column log line is now
wrapped with a string continuation that produces the same text.
2026-11-06 01:12:37 +01:00
Pavlo Ratushnyi 5d2564f4ff STRA-338 S6: control-plane/src/responses.rs children named by responsibility (intake, create, route, history, resources, errors, tool_recovery, reasoning, render)
responses.rs is 97 lines (311 at the start of this step, after the domain move); the mechanical child names impl_* and
*_fn are gone. Function texts are moved without change; the fields and constants that sibling modules read became
pub(super). Public paths (responses::create, create_route, retrieve, delete, input_items, count_input_tokens,
ResponseHistory, HistoryResponseStore, TracedJson, PromptDate, set_prompt_date, set_tool_call_recovery and the domain
types) are unchanged. Functions that still miss the limits are listed in docs/architecture/tech-debt.md.

Linux test ids of strata-control, strata-desktop-core, leleka-gateway-text and leleka-gateway-domain: 0 changed,
0 missing against the tip before S21 wider (2 new: the golden test and its ignored regenerator).
2026-11-06 01:00:39 +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 02b5aedc23 STRA-338 S21: golden fixture of the pure Responses protocol (validation, prompt rendering, response trace, tool-call parsing), recorded from the code before it moves 2026-11-06 00:39:42 +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 6164880902 STRA-338 S18: numbers of the S18 check in tech-debt.md 2026-11-06 00:29:44 +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 71ab80d018 STRA-338 S3: arch-install.sh can install a named second candidate (CAND_NAME) beside the one queued jobs read 2026-11-06 00:07:35 +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