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.
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.
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.
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).
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.
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).
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.
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).
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.
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.
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.
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.
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.
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.
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.
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.
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.
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).
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).