52 Commits
Author SHA1 Message Date
Pavlo Ratushnyi 75e28ca110 deploy: drop the HIDDEN flag of the supervisor, a process cell that was written by --hidden and never read (STRA-338)
The console is hidden by winsys::hide_console right where the flag was stored; nothing in the workspace loads supervisor::HIDDEN, so the cell and its exception entry go. cargo check -p leleka-deploy --all-targets passes.
2026-11-24 08:51:58 +01:00
Pavlo Ratushnyi 219238cd08 architecture gate: read the whole file after a cfg(test) mod declaration, find static cells by type, 64 new exceptions with reasons (STRA-338)
The scanner stopped at the first '#[cfg(test)] mod x;' of a file, so the code below was invisible. It now skips only the item under a test-only cfg (an inline mod body, a declaration, a fn, a use; any(test, feature) is not test-only) and reads on.

process-global counted the type name OnceLock/LazyLock/OnceCell, which also matched instance fields (six exceptions existed only for that) and missed Atomic*, Mutex, RwLock, Once, Cell and RefCell statics, thread_local! included. It now counts a static whose type is a cell or a workspace type that holds one (derived per crate and its dependencies), and static mut. Eight exceptions that only excused instance fields go; the rest of the file's hits are re-judged.

Newly visible: 123 static cells in 58 files, 15 allow(unused_imports) in 6 files and the engine settings::process() cell (read at about 78 sites). Each gets an exception whose reason starts kept: (the boundary that forces it) or debt: (what removes it); the settings cell is the largest debt and is not removed here because the engine does not compile on Windows. Entries 173 -> 229, baseline stays empty. 11 new self-tests (39 in all).
2026-11-24 08:51:58 +01:00
Pavlo Ratushnyi 4619a91367 architecture.json: the engine timer exceptions say what each reading is for (STRA-338)
Eight exceptions of the instant-now ratchet in leleka-engine-qwen35-cuda ended in a deferral ("which is the S14 follow-up"), and one of them was wrong: pcie_share_controllers.rs does not feed a log line, because PcieLag and PcieAuto read the wall-clock duration of the PCIe leg and of a round as the input of their control law. Seven reasons now say that the reading is a measurement that only feeds a log line or a counter, and the controller entry says that its timing is the control input, that both controllers are opt-in (LELEKA_PCIE_AUTO=lag|on, set by no shipped profile) and that their unit tests drive the control law through round() without the clock.
2026-11-24 03:56:38 +01:00
Pavlo Ratushnyi 4ef84275b1 cuda-driver: the VRAM allocation ledger belongs to the Context, not a process cell (STRA-338)
The per-call-site ledger of LELEKA_VRAM_LEDGER is now part of what a Context retains: Context::allocate and the DeviceBuffer free note into the ledger of their own context, and the engine reports through Context::report_vram_ledger, so the OnceLock singleton of vram_ledger.rs and its architecture.json exception are gone. The operator switch stays an EnvSwitch and the default is unchanged (off: one cached bool read per allocation); with the switch on, each context now accounts for its own allocations instead of every context of the process sharing one table.
2026-11-24 03:53:15 +01:00
Pavlo Ratushnyi 47d831ec62 engine: the adaptive-tier tuning is a field of the tier configuration, not a process cell (STRA-338)
ExpertTierConfig now carries AdaptTuning (minimum routed count, margin, decay) parsed once with the tier switches; the residency pool, the cross-layer estimate and the seed ranking take it as a value, so the OnceLock of split_group_pcie.rs and its architecture.json exception are gone. The production default is unchanged (the values still come from LELEKA_ADAPT_MIN_COUNT, _MARGIN and _DECAY with the same fallbacks), and the line for an invalid LELEKA_ADAPT_DECAY is now printed when the tier configuration is read instead of at the first adaptation.

Provenance of two comments that left ExpertTierConfig::off() so that the function stays within the 30-line limit. decode_reserve_mib 300: measured (jobs 989/990/988), the per-request verifier needs about 450 MiB, so 1024 left about 550 MiB idle (180k smoke included); 300 gives the auto-sized cache about 330 more slots. On the 5090, 5 x 245k session (speedtrain-ab), with 300 the card never had less than 563 MiB free (vanilla runs down to 315), so 130 would be safe on the card (+87 slots), but the first slots-footprint A/B showed the Context budget is a second ceiling the planner respects (usable_room); 130 stays an opt-in (LELEKA_ORIGINAL_SERVE_DECODE_RESERVE_MIB=130) until its own arm measures it. pcie_frac 0.45: the PCIe share that equalises the legs when the CPU pool and the DMA share the host's memory ceiling (P/(P+C) = 0.45, job 987-b/909; 0.45 against 0.55 gave +0.5 % / +4.7 % at the auto-sized cache and was equal at 2048 slots).
2026-11-24 03:50:37 +01:00
Pavlo Ratushnyi 51a4eceff0 control-plane: the request counters of /metrics belong to Services, not a process cell (STRA-338)
The request middleware, the backend worker and the metrics handler now share one RequestMetrics value that Services holds, so the LazyLock registry of request_log.rs and its architecture.json exception are gone. The middleware gets it through Observe, the worker through BackendWorkerConfig, and prometheus::render takes it as an argument; the counters, histograms, labels and log lines are unchanged, and the unit tests now count into a registry of their own instead of one shared by the whole test process.
2026-11-24 03:44:23 +01:00
Pavlo Ratushnyi c1fa88db87 architecture.json: every remaining process-global exception says why that site keeps its cell (STRA-338)
The 32 remaining process-global exceptions are classified: instance-local OnceCell/OnceLock fields
that the gate pattern only matches by type name, pure memos of constants or embedded sealed
images, ambient immutable environment read below the Settings owner, FFI and logger-facade
boundaries, diagnostics, and three entries marked "kept for now, NOT a boundary" (request_log
counters, split_group_pcie tuning, vram_ledger) that can still take the value by argument.
2026-11-24 01:04:59 +01:00
Pavlo Ratushnyi 52abe0a21a control-plane: the gpt-oss prompt date is a field of the model view, not a process cell (STRA-338)
PromptDate was set once by serve into a process OnceLock and read by harmony_prompt::render.
It is now ModelView::prompt_date, built from the config in build_state, and prepare_input_tokens
hands it to render_prompt/render. The default of a bare AppState is still Utc, as the unset cell was.
One process-global exception deleted.
2026-11-24 01:04:43 +01:00
Pavlo Ratushnyi 5951540336 native-cpu-expert: drop the process expert layout and the GPU-wait hook nobody installs (STRA-338)
install_layout/expert_layout (a process RwLock cell) and install_release_gpu_waits (a process
OnceLock hook read on a pool stall) have no caller anywhere in the workspace, so the cells were
never written and the hook never ran. They are deleted instead of injected; the origin of the
pool's diagnostic millisecond clock is now a field of the pool's shared state (Shared::origin)
instead of a process OnceLock. Three process-global exceptions deleted.
2026-11-24 01:00:07 +01:00
Pavlo Ratushnyi 79765ac804 engine: the serving context is a value from the composition root, not a process cell (STRA-338)
ServingContext::new(cells, rope) replaces configure_serving_context and the process cell of
cuda-model; serving_context() is gone. The backend spawn makes the value once (serving::
admit_context_tokens) and hands it down: OwnerThread -> LoadEnv -> ServedArtifact (the
model binding captures it, ModelBinding::serving()) and Device::create_context_serving
(every Context of the Load). Device::create_context stays the trained default for tools and
tests. contract::serving_cells, the QSA index context()/device_peak() reads, the
native-resources size read, the memory governor, the stack config and the RoPE constants
read the binding or the Context instead; the stack open refuses a binding and a Context
made for different serving contexts. The two laptop tools build their own value.

Five process-global exceptions deleted (cuda-model serving_context, engine contract,
binding_identity, qsa_index/context, qsa_native_resources).
2026-11-24 00:59:18 +01:00
Pavlo Ratushnyi 966c3fc233 cuda-driver: a Context captures the serving context it is created for, and the qsa sites read it from the Context (STRA-338)
Device::create_context_serving fixes the ServingContext (cell count and RoPE constants) of one Context in Retained.serving; create_context takes the process value once, at creation. Context::serving() / serving_geometry() replace the ~55 reads of cuda-model geometry() / serving_context() in qsa_prompt_index, qsa_prompt_kv, qsa_index_ffi (Arguments::for_launch takes the ServingContext), qsa_prompt_host_ffi (MappedAllocation::new takes the geometry), the resolver and qsa_fixed_kernels. cuda-model geometry() is deleted; the KV window file becomes context_serving.rs; ServingContext::resident_pages_for carries the window arithmetic. The engine call site OriginalQsaMappedPrefix::validate_retained(context) takes the Context (this signature change completes the call-site edit that commit 1 already carries, so commit 1 alone does not compile: merge the branch as a whole).

Behaviour notes for review: the ScoreTC reach check against max_blocks moves from launch time to argument-build time (same error value). OriginalQsaMappedSnapshot::logical_payload_eq no longer re-checks end against the serving cells (a diagnostic comparison; the owner validates snapshots on every use). The old process-wide guards only fired for a second load with different values in one process.
2026-11-23 21:16:57 +01:00
Pavlo Ratushnyi 1e5e5e14c6 cuda-driver: the resident KV window belongs to the Context its owners are made from, not to the process (STRA-338)
Context::configure_kv_resident fixes the window of one Context (Retained.kv_resident) and streamed QSA owners size their pool from c.kv_resident_pages(). The process cell KV_RESIDENT and configure_kv_resident / kv_resident_cells / kv_resident_pages leave cuda-model and the driver exports; the serve stack open phase configures the window on its Context (that call site already changed in the previous commit). Behaviour note: the old process-wide guard "resident KV window already configured differently" fired only for a second load with another window in the same process; a fresh Context after Unload now accepts another window.
2026-11-23 21:12:58 +01:00
Pavlo Ratushnyi 5ce8b3dd98 architecture.json: say why the two QSA geometry readers of the engine remain (STRA-338) 2026-11-23 17:10:32 +01:00
Pavlo Ratushnyi 38fc49e0dc engine: the speculative controller, its draft preparation and the prefill records take the serving cells from the binding
SpecContext (request ceiling and serving cells) replaces the bare max_context of SpecConfig and OriginalServeSettings; DraftPreparation and PrefillRecords keep the serving cells they were made for. The stack open passes the bound of its model binding. Three more process-global exceptions are deleted. STRA-338
2026-11-23 17:09:38 +01:00
Pavlo Ratushnyi c9f152992c engine: the model binding carries the serving context in cells; the validators take the bound from it
InputConstants and BindingIdentity capture the serving cells when the model is bound (the one read of the driver's context, contract::serving_cells). Seventeen validators (MTP frame, dense KV, snapshots, chunk charges, window limits, stack config, prompt plan) now receive the bound from the binding they already hold instead of reading the process-wide context; two redundant checks next to a context_length comparison are dropped. The laptop and prefix smokes fix their geometry before they bind the model. Seventeen process-global exceptions are deleted. STRA-338
2026-11-23 17:01:27 +01:00
Pavlo Ratushnyi 5fe30673c6 native-cpu-expert: the kernel A/B switches, the CPU probes and the dispatch are a Setting catalogue in settings.rs
Eight files kept their own OnceLock next to a settings::var parse (or a CPUID probe); they now ask settings.rs for a named Setting (same variables, same defaults, same parse, computed on first use). Eight process-global exceptions are deleted, one for the Setting cell is added. STRA-338
2026-11-23 16:46:06 +01:00
Pavlo Ratushnyi 44c65e3ce0 cuda-driver: operator settings and marker files live in the settings catalogue, not in ad-hoc OnceLock cells
Eleven call sites cached their own parse of an environment variable in a function-local OnceLock; they now ask settings.rs for a named cell (same variable, same default, same parse, read on first use). The three copies of the 250 ms marker-file poll become one MarkerFiles type. Eleven process-global exceptions are deleted; STRA-338
2026-11-23 16:43:07 +01:00
Pavlo Ratushnyi 82c306b49e engine: one MemoryServices and one VerifyPolicy per engine, injected from the composition root; no process-global governor, inventory or stamp registry
spawn_backend_configured creates the MemoryServices (the first Load installs the governor into it, at the same moment
as before) and hands it to the owner thread (LoadEnv), the Original runner (Run, ReopenEnv, GenerateEnv), the stack
(StackConfig.memory) and the status proxy. The prefix cache, the conversation device, the expert tier, the inventory
classes and the page-cache release ask it instead of Governor::global. NativeBackendConfig.verification carries the
stamp policy of leleka-inference (--verify-stamps, --verify-rehash, --kar-attested-by-stamp) to the shard and archive
verification. The nine Governor::global exceptions of architecture.json and the three singleton exceptions of
leleka-memory and leleka-model-format are deleted; the smokes and probes make their own services.
2026-11-23 12:16:30 +01:00
Pavlo Ratushnyi decc5ffd18 Merge branch 'claude/debt-hot-low' into HEAD
# Conflicts:
#	architecture-baseline.json
#	architecture.json
#	docs/architecture/tech-debt.md
2026-11-23 01:27:17 +01:00
Pavlo Ratushnyi 7df1a4b473 Merge main (engine stage 10) into claude/debt-rename; rename script rerun, old-names marker for the rename table, baseline regenerated 2026-11-14 22:17:24 +01:00
Pavlo Ratushnyi 8eca35e64e Merge branch 'main' into claude/debt-engine 2026-11-14 22:10:10 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 4e0bb1dd98 engine crates: 50 modules renamed for what they hold (the *_methods, *_and_*, *_sdet, *_types and qwen4exp_* names), exceptions and script paths follow
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 21:59:19 +01:00
Pavlo Ratushnyi ed781797ed Merge main into claude/debt-rename; rename script rerun over what the engine and low-level branches added; baseline regenerated 2026-11-14 21:47:45 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 5b84cd2cf8 engine crates: dyn closures and sinks become generics (engine-core 18 -> 2, engine 53 -> 9 outside the Box<dyn Backend> process boundary), load laps on the Clock port, named exceptions for what must stay, real headers for the last generated ones
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 21:44:58 +01:00
Pavlo Ratushnyi d19ef823d6 architecture.json: exception paths follow the renamed hot-path modules 2026-11-14 21:40:19 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 1207415a19 Low-level crates: 52 modules named after two things (*_and_*) are named after their responsibility; exception paths, include paths and docs updated
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 21:33:08 +01:00
Pavlo Ratushnyi 891736f061 Merge branch 'claude/debt-low-docs' into claude/debt-hot-low 2026-11-14 21:33:08 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 d027790278 cuda-driver and CPU expert pool (hot path, awaiting the identity gate): head_dispatch compiled once (shared module, no glob, no #[path]), copy_ring_layer split in two with explicit imports, measurement-timer comments, exceptions for the dyn, Instant::now and process-global sites that stay
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 21:20:07 +01:00
Pavlo Ratushnyi da9e4367ae Merge main into claude/debt-rename 2026-11-14 20:36:02 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 1cc29ea9db gateway-text: the env switch reader is a child of prompt, so the gpu_proofs of the engine crate that include prompt.rs by path still compile
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 20:34:45 +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 Ratushnyi 03ea6b1f16 Merge main into claude/debt-low (npu-service: keeps the other agent's env_settings.rs; exceptions and baseline merged) 2026-11-14 20:21:02 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 96b947248c Low-level crates: dyn and Instant::now reduced to named exceptions (port boundaries, measurement timers with a comment), generics for the callbacks, memory settings reader; baseline lowered
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 20:10:43 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 a354533a85 Low-level crates: the process environment is read in one settings module per crate (typed values for cpu-worker, tokenizer, gptoss-npu, gpu-npu-worker, igpu, npu-service, memory, gptoss, model-format), named exceptions for readers that must stay; baseline lowered
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 19:59:23 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 5bda5596a2 Architecture gate: exceptions for the readers, ports, adapters and singletons of the control side, baseline lowered; explicit_imports.py FORCE_FILES, wsl-cargo.sh debug=0
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 19:40:21 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 599f45a885 Low-level crates: allow(unused_imports) removed from cuda-driver, native-cpu-expert, cpu-sys, model-format, tokenizer and the small crates (unused imports deleted, test-only ones under cfg(test)); root_exports glob replaced by crate paths; EnvSwitch in cuda-model; scripts: prune_unused_imports.py, path_to_layout.py
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 19:09:13 +01:00
Pavlo Ratushnyi 92b03fca4e Architecture gate: named exceptions list (crate, file, ratchet, reason) so a ratchet can be zero outside documented sites; unused or reasonless entries are errors 2026-11-14 18:16:56 +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 15faea9d46 Explicit-imports tool, libc-shim trace modules named for what they hold, two import ratchets, docs of the debt rework
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-13 19:27:50 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 51b45b82d8 leleka-memory loses libc and windows-sys: PageLocking and ProcSource ports, OS adapters in the new L3 crate leleka-memory-os
The two baselined forbidden-dep violations are gone. FdMapping keeps the bounds checks and lock bookkeeping as safe Rust over plain addresses;
mmap/mlock/mincore/madvise/munmap/setrlimit are LinuxPageLocking, the Win32 host facts are WindowsProc, the glibc heap trim moved verbatim.
Governor::real is replaced by leleka_memory_os::real_governor (the page-locking adapter is part of it). No behaviour change.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-13 17:46:38 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 ac60df040f STRA-338: architecture gate forbids new mechanical file names (impl_*, *_fn, numbered), baseline lists the 964 existing; rustsplit names modules after what they hold
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 00:50:17 +01:00
Pavlo Ratushnyi 40896ba217 STRA-338 S24: peel the pure host-side models out of cuda-driver into leleka-cuda-model
New L1 crate crates/cuda-model (leleka-cuda-model, forbid(unsafe_code), depends on leleka-context only) holds:
Error/Result with Display, DenseFormat, RoutedFormat, ProjectionKind (+ layout/alignment/required_modes), ProjectionSpec,
the Bf16/Q5K/Q6K projection shapes, bringup_trace_enabled, and the modules serving_context, host_profile, command_profile,
original_mtp_loader, original_prefill_schedule, qsa_prompt_attention_select, original_expert_slots, native_flash_attn,
s_gemv_legacy, device_arena, mmq_original_prefill_misc (moved with git mv; code unchanged apart from pub visibility and
#[inline] on the tiny cached-switch readers, host_profile::add split into an inlined gate and a cold body).

leleka-cuda-driver re-exports every item at its old path, so no use path in the driver, engine-qwen35-cuda or
native-parity-bench changes. Tests moved with their modules; they read the .cu sources and oracle fixtures of the driver
through driver_source!; the one loader test that needs the driver's session geometry stays in the driver.

Housekeeping: workspace members/default-members, Cargo.lock, architecture.json (L1), hexagonal.md, ci-coverage.json,
check-local.sh, port.yml, linux-tests/run.sh, AGENTS.md. architecture-baseline.json: the source ratchets of the moved code
change crate key (dyn-trait driver 56 to 49 + model 3, env-read 72 to 67 + 5, process-global 110 to 99 + 11), regenerated
with --allow-increase for the new keys only; per-pattern totals do not rise. limits-baseline.json is unchanged: no moved
function is over a limit.
2026-11-07 17:40:24 +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 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 ff6cb3dcbf STRA-338 S21: leleka-gateway-domain (layer L2): the pure gateway domain leaves strata-control
New crate crates/gateway-domain, the first member of layer L2 in architecture.json (L2 is now a pure layer: tokio, axum,
reqwest, libc and the other adapter crates are forbidden dependencies there). It depends on serde, serde_json,
leleka-sampler-ref and leleka-tokenizer only. Moved out of control-plane/src with git mv, content unchanged apart from
paths: sampling (request sampling extensions, validation) and EngineTune (was in wire.rs), reasoning_budget (the budget
driver and its tests), codec (Family, TextCodec, TokenDecoder, QwenCodec), json_order, and the Chat Completions
translation (chat_completions: Request -> Responses request, reply fields; the axum handlers stay in chat.rs).
strata-control re-exports codec, json_order, reasoning_budget and sampling under their old paths, and wire.rs re-exports
EngineTune, so no caller and no test outside the moved modules changed. 4 new tests cover the chat translation.

Architecture gate: layer entry added; dyn-trait:leleka-gateway-domain = 5 appears because the five dyn in the moved
code (Box<dyn TokenDecoder>, Box<dyn Iterator> in the budget driver, &dyn Fn, ...) change crate; dyn-trait:strata-control
fell 21 -> 16 in the same step, so the total is unchanged (--allow-increase was needed for the new per-crate key only).
Test outcomes: 597 ok / 2 ignored before, 615 ok / 2 ignored after (18 new tests); the 13 moved tests keep their ids in the
new crate and their outcome.
2026-11-05 20:42:48 +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 Ratushnyi 6155c871b0 worker-protocol: one crate for both ends of the gateway/worker line protocol (STRA-338 S9)
New dependency-free crate crates/worker-protocol (L0): events (Event, Done, Finish, parse_line, moved from control-plane/src/wire.rs),
command (GEN/STOP/QUIT parser, moved from cpu-worker/src/protocol.rs) and lines (READY/T/PP/REUSED/ERR/DONE writers, moved from
cpu-worker). Finish was defined twice (gateway and worker) and is now one enum with a word(). wire.rs re-exports the event types and
cpu-worker/protocol.rs re-exports the old paths, so no caller changes. The gateway's rich GEN writer (golden-tested against the Python
server) stays in wire.rs. New golden: every line the worker writes round-trips through the gateway parser.

Verified (host): cargo test leleka-worker-protocol 8/8, cpu-worker, strata-control all green (0 failed); the 6 moved tests keep their
bodies; clippy -D warnings clean on the new crate; fmt clean.
2026-11-05 13:37:05 +01:00
Pavlo Ratushnyi 7b1922d116 gateway-text: prompt, response_tools and tool_output become one crate; desktop-core no longer compiles them twice (STRA-338 S8)
control-plane/src/{prompt,response_tools,tool_output}.rs (pure text logic: pinned chat template renderer, tool catalog, tool-call
parser) move by git mv to the new leaf crate crates/gateway-text. strata-control re-exports them under the same module paths
(crate::prompt, crate::tool_output keep working for tests and callers); strata-desktop-core replaces its three #[path] includes with
imports. The leleka-runtime GPU proof modules that hash prompt.rs follow the new location. The only text change in the moved files is
the relative include_str path to engine/strata. serde_json features (preserve_order + float_roundtrip) equal what both hosts already
got through unification.

Verified: cargo test strata-control + strata-desktop-core + gateway-text on the host: 504 tests, 0 failed; the 30 tests that vanish
are exactly the duplicate runtime_prompt/runtime_tool_catalog/runtime_tool_parser copies of the same 30 tests (11+2+17), which now run
once. WSL x86_64-linux cargo check --tests leleka-runtime: 62 warnings, unchanged. fmt clean on the new crate.
2026-11-05 13:32:35 +01:00