Files
leleka/architecture.json
T

173 lines
27 KiB
JSON

{
"_comment": "Policy read by scripts/check-architecture.py (STRA-338 ADR). Layers are ordered low to high; a normal dependency must point to the same or a lower layer. L2 (core) holds the extracted domain crates: leleka-gateway-domain (S21); the engine domain crates follow (S19). Every workspace package appears in exactly one layer.",
"max_lines": 400,
"adapter_layer": "L3",
"pure_layers": ["L0", "L1", "L2"],
"forbidden_in_pure": ["tokio", "axum", "tonic", "tonic-prost", "reqwest", "hyper", "libc", "rustix", "windows-sys", "sysinfo", "wgpu"],
"layers": {
"L0": ["leleka-backend-api", "leleka-worker-protocol"],
"L1": [
"leleka-obs", "leleka-context", "leleka-sampler-ref", "leleka-quant-core", "leleka-serving-policy", "leleka-harmony",
"leleka-tokenizer", "leleka-gguf", "leleka-kar-codec", "leleka-experimental-ref", "leleka-cpu-sys", "leleka-cpu-kernels",
"leleka-shm", "leleka-openvino", "leleka-memory", "leleka-gateway-text", "leleka-cuda-model"
],
"L2": ["leleka-gateway-domain", "leleka-engine-core"],
"L3": [
"leleka-libc-shim", "leleka-memory-os", "leleka-model-format", "leleka-cuda-driver", "leleka-native-cpu-expert", "leleka-gptoss", "leleka-igpu",
"leleka-gptoss-igpu", "leleka-gptoss-npu", "leleka-npu-service", "leleka-cpu-worker", "leleka-igpu-worker", "leleka-npu-worker",
"leleka-gpu-npu-worker", "leleka-offline-tools", "leleka-runtime-client",
"leleka-engine-fake",
"leleka-engine-qwen35-cuda"
],
"L4": ["leleka-runtime", "leleka-engine-host", "leleka-control-plane", "leleka-deploy", "leleka-native-parity-bench"]
},
"adapter_edges": [
["leleka-cuda-driver", "leleka-libc-shim"],
["leleka-cuda-driver", "leleka-model-format"],
["leleka-model-format", "leleka-libc-shim"],
["leleka-native-cpu-expert", "leleka-libc-shim"],
["leleka-cpu-worker", "leleka-gptoss"],
["leleka-gptoss-igpu", "leleka-gptoss"],
["leleka-gptoss-igpu", "leleka-igpu"],
["leleka-gptoss-npu", "leleka-gptoss"],
["leleka-igpu-worker", "leleka-cpu-worker"],
["leleka-igpu-worker", "leleka-gptoss-igpu"],
["leleka-npu-worker", "leleka-cpu-worker"],
["leleka-npu-worker", "leleka-gptoss-npu"],
["leleka-gpu-npu-worker", "leleka-cpu-worker"],
["leleka-gpu-npu-worker", "leleka-gptoss"],
["leleka-gpu-npu-worker", "leleka-gptoss-igpu"],
["leleka-gpu-npu-worker", "leleka-gptoss-npu"],
["leleka-offline-tools", "leleka-model-format"],
["leleka-engine-qwen35-cuda", "leleka-cuda-driver"],
["leleka-engine-qwen35-cuda", "leleka-model-format"],
["leleka-engine-qwen35-cuda", "leleka-native-cpu-expert"],
["leleka-engine-qwen35-cuda", "leleka-memory-os"]
],
"mechanical_names": {
"why": "a module name must say what it is and what it is for; names left by mechanical splits (impl_*, *_fn, numbered) make the source hard to read",
"patterns": ["^impl_.*\\.rs$", "_fn\\.rs$", "_[0-9]+(_[0-9]+)*\\.rs$"],
"allow": ["^(quantize_)?q[0-9]_[0-9k]\\.rs$"]
},
"_exceptions": "Sites that must stay, so the ratchet is zero outside this list (STRA-338 stage 10). Each entry: crate, file (relative to the crate directory), ratchet (a source_patterns id), reason. The file's hits of that ratchet are not counted; an entry that excuses nothing is an error.",
"exceptions": [
{"crate": "leleka-cuda-model", "file": "src/env_switch.rs", "ratchet": "env-read", "reason": "EnvSwitch is the one reader of the operator environment in this crate: it reads one named variable on the first get() and applies a typed rule"},
{"crate": "leleka-cuda-model", "file": "src/env_switch.rs", "ratchet": "process-global", "reason": "the OnceLock inside EnvSwitch caches the switch position for the process life (an immutable operator setting; a hot path pays one atomic load)"},
{"crate": "leleka-cuda-model", "file": "src/serving_context.rs", "ratchet": "process-global", "reason": "the serving context and the resident KV window are fixed once at engine start (configure_*) and read by every kernel geometry; injecting them through every owner is the settings follow-up of S13"},
{"crate": "leleka-cpu-worker", "file": "src/settings.rs", "ratchet": "env-read", "reason": "the one reader of the process environment in this crate: it returns the operator's switches as typed values"},
{"crate": "leleka-tokenizer", "file": "src/settings.rs", "ratchet": "env-read", "reason": "the one reader of the process environment in this crate: it returns the operator's switches as typed values"},
{"crate": "leleka-gptoss-npu", "file": "src/settings.rs", "ratchet": "env-read", "reason": "the one reader of the process environment in this crate: it returns the operator's switches as typed values"},
{"crate": "leleka-gpu-npu-worker", "file": "src/settings.rs", "ratchet": "env-read", "reason": "the one reader of the process environment in this crate: it returns the operator's switches as typed values"},
{"crate": "leleka-igpu", "file": "src/settings.rs", "ratchet": "env-read", "reason": "the one reader of the process environment in this crate: it returns the operator's switches as typed values"},
{"crate": "leleka-memory", "file": "src/settings.rs", "ratchet": "env-read", "reason": "the one reader of the process environment in this crate: it returns the operator's switches as typed values"},
{"crate": "leleka-gptoss", "file": "src/settings.rs", "ratchet": "env-read", "reason": "the one reader of the process environment in this crate: it returns the operator's switches as typed values"},
{"crate": "leleka-model-format", "file": "src/settings.rs", "ratchet": "env-read", "reason": "the one reader of the process environment in this crate: it returns the operator's switches as typed values"},
{"crate": "leleka-obs", "file": "src/level.rs", "ratchet": "env-read", "reason": "the one reader of the process environment in this crate: LELEKA_LOG* parsed once into Settings, and the request-log path"},
{"crate": "leleka-cuda-driver", "file": "src/settings.rs", "ratchet": "env-read", "reason": "the one reader of the process environment in this crate; call sites still parse the text they ask for (typed switches: EnvSwitch in leleka-cuda-model, in progress on claude/debt-hot-low)"},
{"crate": "leleka-native-cpu-expert", "file": "src/settings.rs", "ratchet": "env-read", "reason": "the one reader of the process environment in this crate; call sites still parse the text they ask for (CPU expert pool: hot path, in progress on claude/debt-hot-low)"},
{"crate": "leleka-cpu-kernels", "file": "src/dispatch.rs", "ratchet": "env-read", "reason": "the one reader of the process environment in this crate: ISA_ENV is parsed by Isa::from_request into the selected instruction set"},
{"crate": "leleka-libc-shim", "file": "src/cuda_trace/trace_state.rs", "ratchet": "env-read", "reason": "Windows interposer (FFI): the CUDA call tracer reads its own LELEKA_BRINGUP_TRACE switches and must not depend on other crates"},
{"crate": "leleka-libc-shim", "file": "src/lib.rs", "ratchet": "env-read", "reason": "Windows interposer (FFI): the DLL search directories come from the process environment before any other crate can load"},
{"crate": "leleka-memory-os", "file": "src/heap.rs", "ratchet": "env-read", "reason": "platform adapter (glibc heap): reads its own LELEKA_MEMORY_NO_TRIM switch once"},
{"crate": "leleka-native-parity-bench", "file": "src/lib.rs", "ratchet": "env-read", "reason": "benchmark host (L4): reads the operator's STRATA_IQ_MT_MIN override to report which value it measured"},
{"crate": "leleka-npu-worker", "file": "src/main.rs", "ratchet": "env-read", "reason": "worker binary (composition root): reads LELEKA_OPENVINO_ROOT into its configuration"},
{"crate": "leleka-memory", "file": "src/settings.rs", "ratchet": "process-global", "reason": "the cached LELEKA_NO_TRIM_FILE path: an immutable operator setting read once by the crate's one environment reader"},
{"crate": "leleka-memory", "file": "src/governor.rs", "ratchet": "process-global", "reason": "Governor::global(): the process-wide memory governor installed once at engine start; its injection through the engine stack (S13/S14) belongs to the engine crate"},
{"crate": "leleka-memory", "file": "src/inventory.rs", "ratchet": "process-global", "reason": "Inventory::global(): the process-wide census of live mappings and pinned regions, filled by the loaders; injected with the governor (S13/S14)"},
{"crate": "leleka-memory", "file": "src/governor.rs", "ratchet": "dyn-trait", "reason": "port boundary: the Governor holds its MemoryPressure adapter as Arc<dyn MemoryPressure>, chosen at start-up (hexagonal.md, ports table)"},
{"crate": "leleka-memory", "file": "src/governor/operations/setup.rs", "ratchet": "dyn-trait", "reason": "port boundary: Governor::new takes the host as Arc<dyn ProcSource + Send + Sync> (the adapter is chosen by the composition root) and source() hands it back"},
{"crate": "leleka-memory", "file": "src/lock/page_locking.rs", "ratchet": "dyn-trait", "reason": "port boundary: SharedPageLocking = Arc<dyn PageLocking>, the OS adapter of mmap/mlock chosen by the composition root"},
{"crate": "leleka-memory", "file": "src/telemetry.rs", "ratchet": "dyn-trait", "reason": "port boundary: the GPU probe is a closure chosen at start-up (nvidia-smi or NVML) and owned by the sampler thread"},
{"crate": "leleka-memory", "file": "src/smi.rs", "ratchet": "dyn-trait", "reason": "port boundary: the nvidia-smi probe closure handed to the telemetry sampler (see telemetry.rs)"},
{"crate": "leleka-cpu-worker", "file": "src/engine.rs", "ratchet": "instant-now", "reason": "measurement timer, not decision logic: load and prefill wall-time measurement, reported in the worker's timing line"},
{"crate": "leleka-cpu-worker", "file": "src/serve.rs", "ratchet": "instant-now", "reason": "measurement timer, not decision logic: per-request wall-time measurement (prefill and decode), reported in the worker's timing line"},
{"crate": "leleka-cpu-worker", "file": "src/serve/decode_loop.rs", "ratchet": "instant-now", "reason": "measurement timer, not decision logic: per-token lap timers of the decode loop; one reading per lap, summed into the timing line"},
{"crate": "leleka-gptoss", "file": "src/forward_pass.rs", "ratchet": "instant-now", "reason": "measurement timer, not decision logic: per-pass lap timer inside the forward pass; one reading per lap, summed into the timing report"},
{"crate": "leleka-gptoss", "file": "src/generation.rs", "ratchet": "instant-now", "reason": "measurement timer, not decision logic: generation wall-time measurement for the timing report"},
{"crate": "leleka-gptoss-igpu", "file": "src/prefill_pass.rs", "ratchet": "instant-now", "reason": "measurement timer, not decision logic: wall-time measurement of one prefill pass, reported with the pass"},
{"crate": "leleka-gptoss-igpu", "file": "src/prefill_run.rs", "ratchet": "instant-now", "reason": "measurement timer, not decision logic: stage lap timers of the iGPU prefill, reported in the timing line"},
{"crate": "leleka-gptoss-npu", "file": "src/expert_pass.rs", "ratchet": "instant-now", "reason": "measurement timer, not decision logic: stage lap timers of the NPU expert pass, reported in the timing line"},
{"crate": "leleka-gptoss-npu", "file": "src/prefill_batch.rs", "ratchet": "instant-now", "reason": "measurement timer, not decision logic: stage lap timers of the NPU prefill batch, reported in the timing line"},
{"crate": "leleka-gptoss-npu", "file": "src/prefill_part_pass.rs", "ratchet": "instant-now", "reason": "measurement timer, not decision logic: wall-time measurement of one NPU prefill part, reported with the pass"},
{"crate": "leleka-gptoss-npu", "file": "src/service_transfers.rs", "ratchet": "instant-now", "reason": "measurement timer, not decision logic: transfer wall-time measurement toward the NPU service"},
{"crate": "leleka-gpu-npu-worker", "file": "src/lib.rs", "ratchet": "instant-now", "reason": "measurement timer, not decision logic: wall-time measurement of the split prefill passes, reported in the timing line"},
{"crate": "leleka-gpu-npu-worker", "file": "src/split_run.rs", "ratchet": "instant-now", "reason": "measurement timer, not decision logic: lap timers of the GPU and NPU legs of the split prefill"},
{"crate": "leleka-igpu", "file": "src/matrix_uploads.rs", "ratchet": "instant-now", "reason": "measurement timer, not decision logic: wall-time measurement of the weight upload, reported at load"},
{"crate": "leleka-npu-service", "file": "src/engine/execution.rs", "ratchet": "instant-now", "reason": "measurement timer, not decision logic: lap timers of one NPU execution, summed into the profile report"},
{"crate": "leleka-model-format", "file": "src/bulk_read/for_each_chunk.rs", "ratchet": "instant-now", "reason": "measurement timer, not decision logic: wall-time measurement of the bulk read, reported in the load report"},
{"crate": "leleka-model-format", "file": "src/huge_pages.rs", "ratchet": "instant-now", "reason": "measurement timer, not decision logic: wall-time measurement of the huge-page allocation probe, reported in the load report"},
{"crate": "leleka-model-format", "file": "src/kar/independent_handles.rs", "ratchet": "instant-now", "reason": "measurement timer, not decision logic: wall-time measurement of opening the independent file handles"},
{"crate": "leleka-model-format", "file": "src/pinned_arena_plan/expert_parallel_load.rs", "ratchet": "instant-now", "reason": "measurement timer, not decision logic: read and copy lap timers of the expert load, reported in the load report"},
{"crate": "leleka-model-format", "file": "src/ple_reader/read_queue.rs", "ratchet": "instant-now", "reason": "measurement timer, not decision logic: readings of the per-row read queue's latency window, inside the reader loop"},
{"crate": "leleka-model-format", "file": "src/ple_reader/row_reading.rs", "ratchet": "instant-now", "reason": "measurement timer, not decision logic: latency measurement of one PLE row read, inside the reader loop"},
{"crate": "leleka-obs", "file": "src/time/clock.rs", "ratchet": "instant-now", "reason": "the clock adapter itself: SystemClock, AnyClock and ManualClock are the one place that reads the monotonic clock"},
{"crate": "leleka-memory-os", "file": "src/heap.rs", "ratchet": "process-global", "reason": "platform adapter (glibc heap): the LELEKA_MEMORY_NO_TRIM switch is read once and cached"},
{"crate": "leleka-libc-shim", "file": "src/cuda_trace/trace_state.rs", "ratchet": "process-global", "reason": "Windows interposer (FFI): the CUDA call tracer is process-wide state behind C-ABI hooks that carry no context pointer"},
{"crate": "leleka-obs", "file": "src/lib.rs", "ratchet": "process-global", "reason": "the logger is process-wide: its Settings, rate limiter and request sink are built once from the environment"},
{"crate": "leleka-obs", "file": "src/write_stderr.rs", "ratchet": "process-global", "reason": "the request-log sink of the process-wide logger (see lib.rs)"},
{"crate": "leleka-tokenizer", "file": "src/lib.rs", "ratchet": "process-global", "reason": "immutable constant tables built once: the pre-tokenizer regex and the character classes"},
{"crate": "leleka-gptoss-npu", "file": "src/half.rs", "ratchet": "process-global", "reason": "immutable constant table: the half-to-float conversion table, built once"},
{"crate": "leleka-cuda-model", "file": "src/original_prefill_schedule.rs", "ratchet": "dyn-trait", "reason": "parameter struct SourceView borrows three residency queries (resident, pinned, transient) from the caller's tables; a generic parameter per closure would make the type unnameable in the callers' signatures"},
{"crate": "leleka-experimental-ref", "file": "src/remote_experts.rs", "ratchet": "dyn-trait", "reason": "parameter struct Candidates borrows the primary's residency test from the caller's table; generic parameters would leak into every caller's signature"},
{"crate": "leleka-cpu-worker", "file": "src/engine.rs", "ratchet": "dyn-trait", "reason": "port boundary: the engine holds the prefill accelerator (iGPU, NPU or split) as Box<dyn PrefillAccelerator + Send>, chosen by the worker binary"},
{"crate": "leleka-cpu-worker", "file": "src/serve.rs", "ratchet": "dyn-trait", "reason": "dyn-compatible worker trait: the progress callback of a trait method must be a trait object"},
{"crate": "leleka-gptoss", "file": "src/decode_state.rs", "ratchet": "dyn-trait", "reason": "port boundary: PrefillAccelerator and LayerCache are the accelerator seams, chosen by the worker binary; their methods take the progress callback as a trait object"},
{"crate": "leleka-gptoss", "file": "src/model.rs", "ratchet": "dyn-trait", "reason": "port boundary: the model's weights read through Arc<dyn ModelBytes> (file, memory map or test bytes), chosen when the model is loaded"},
{"crate": "leleka-gptoss", "file": "src/tensor_loading.rs", "ratchet": "dyn-trait", "reason": "port boundary: the model's weights read through Arc<dyn ModelBytes> (file, memory map or test bytes), chosen when the model is loaded"},
{"crate": "leleka-gptoss", "file": "src/weights.rs", "ratchet": "dyn-trait", "reason": "port boundary: the model's weights read through Arc<dyn ModelBytes> (file, memory map or test bytes), chosen when the model is loaded"},
{"crate": "leleka-gptoss", "file": "src/pool.rs", "ratchet": "dyn-trait", "reason": "the worker pool runs heterogeneous closures: Box<dyn FnOnce + Send> is the type-erased job of its queue"},
{"crate": "leleka-gptoss-igpu", "file": "src/lib.rs", "ratchet": "dyn-trait", "reason": "port boundary: the memory probe closure and the PrefillAccelerator impl (trait objects by the trait's own signature)"},
{"crate": "leleka-gptoss-npu", "file": "src/lib.rs", "ratchet": "dyn-trait", "reason": "port boundary: the memory probe closure chosen by the worker binary"},
{"crate": "leleka-gptoss-npu", "file": "src/accelerator.rs", "ratchet": "dyn-trait", "reason": "PrefillAccelerator impl: the progress callback is a trait object by the trait's own signature"},
{"crate": "leleka-gpu-npu-worker", "file": "src/lib.rs", "ratchet": "dyn-trait", "reason": "port boundary: the memory probe closure, the LayerCache seam and the PrefillAccelerator impl (trait objects by the traits' own signatures)"},
{"crate": "leleka-tokenizer", "file": "src/lib.rs", "ratchet": "dyn-trait", "reason": "Result<T, Box<dyn Error>> of the public tokenizer API: the error is the std error object at the library boundary"},
{"crate": "leleka-model-format", "file": "src/gguf.rs", "ratchet": "dyn-trait", "reason": "Result<T, Box<dyn Error>> of the GGUF reader's public API: the std error object at the library boundary"},
{"crate": "leleka-model-format", "file": "src/qwen4exp.rs", "ratchet": "dyn-trait", "reason": "the artifact error wraps any std error (Box<dyn Error>) from the byte sources it reads through"},
{"crate": "leleka-model-format", "file": "src/qwen4exp/binding_topology.rs", "ratchet": "dyn-trait", "reason": "std::error::Error::source() returns &(dyn Error + 'static) by the trait's own signature"},
{"crate": "leleka-model-format", "file": "src/ple_reader.rs", "ratchet": "dyn-trait", "reason": "port boundary: the PLE reader holds its PageSource (file, direct-IO file or test double) as Arc<dyn PageSource>"},
{"crate": "leleka-model-format", "file": "src/ple_reader/row_reading.rs", "ratchet": "dyn-trait", "reason": "port boundary: PleReader::open takes the PageSource as Arc<dyn PageSource>"},
{"crate": "leleka-model-format", "file": "src/huge_pages.rs", "ratchet": "process-global", "reason": "the huge-page mode is an operator setting parsed once from LELEKA_HUGEPAGES and cached for the process"},
{"crate": "leleka-model-format", "file": "src/kar/independent_handles.rs", "ratchet": "process-global", "reason": "the identity-recheck switch is an operator setting parsed once and cached for the process"},
{"crate": "leleka-model-format", "file": "src/kar.rs", "ratchet": "process-global", "reason": "a per-instance lazily opened set of file handles (a OnceLock field of the archive), not a process global"},
{"crate": "leleka-model-format", "file": "src/kar/verified_kar_ple_artifact.rs", "ratchet": "process-global", "reason": "constructs the per-instance lazy handle cell of kar.rs, not a process global"},
{"crate": "leleka-model-format", "file": "src/verify_stamp.rs", "ratchet": "process-global", "reason": "the process-wide registry of verified-file stamps, written by the loaders and read by the identity re-checks; its injection belongs to the loader stack (S13)"},
{"crate": "leleka-control-plane", "file": "src/env_settings.rs", "ratchet": "env-read", "reason": "the one reader of the process environment of the crate: every variable is parsed here into a typed value (number, path, flag, mode)"},
{"crate": "leleka-deploy", "file": "src/env_settings.rs", "ratchet": "env-read", "reason": "the one reader of the process environment of the crate: every variable is parsed here into a typed value (path, flag, text)"},
{"crate": "leleka-engine-host", "file": "src/env_settings.rs", "ratchet": "env-read", "reason": "the one reader of the process environment of the crate and its binaries: credentials by name, the evaluation switches, the inherited child variables"},
{"crate": "leleka-gateway-text", "file": "src/prompt/env_settings.rs", "ratchet": "env-read", "reason": "the one reader of the process environment of the crate: the two prompt rendering switches"},
{"crate": "leleka-npu-service", "file": "src/env_settings.rs", "ratchet": "env-read", "reason": "the one reader of the process environment of the crate: the profile report switch"},
{"crate": "leleka-control-plane", "file": "src/adapters/system_clock.rs", "ratchet": "instant-now", "reason": "the production Clock adapter: the one place that reads the runtime clock for the injected Clock port"},
{"crate": "leleka-control-plane", "file": "src/ports/fakes/clock.rs", "ratchet": "instant-now", "reason": "test fixture: the manual clock needs one base instant to count from and never moves by itself"},
{"crate": "leleka-engine-host", "file": "src/clock.rs", "ratchet": "instant-now", "reason": "the runtime-clock adapter of the Clock port of the crate"},
{"crate": "leleka-engine-host", "file": "src/node_connection.rs", "ratchet": "instant-now", "reason": "freshness stamp and retry back-off of the node subscription: the monotonic time of network events, compared with elapsed(); the tests use real short timings"},
{"crate": "leleka-npu-service", "file": "src/engine/execution.rs", "ratchet": "instant-now", "reason": "profile laps around each product on the NPU execution loop (LELEKA_NPU_PROFILE report); a clock call per lap would be the only change on that path"},
{"crate": "leleka-backend-api", "file": "src/scripted/play.rs", "ratchet": "instant-now", "reason": "the scripted test engine paces a fake generation in real time; the L0 contract crate has no dependency to take a clock from"},
{"crate": "leleka-control-plane", "file": "src/ports/clock.rs", "ratchet": "dyn-trait", "reason": "port boundary: SharedClock is the Arc<dyn Clock> the composition root hands to AppState"},
{"crate": "leleka-control-plane", "file": "src/ports/engine.rs", "ratchet": "dyn-trait", "reason": "port boundary: SharedEngine is the Arc<dyn EngineClient> the composition root hands to AppState"},
{"crate": "leleka-control-plane", "file": "src/ports/response_store.rs", "ratchet": "dyn-trait", "reason": "port boundary: SharedResponseStore is the Arc<dyn ResponseStore> the composition root hands to AppState"},
{"crate": "leleka-control-plane", "file": "src/ports/tool_hub.rs", "ratchet": "dyn-trait", "reason": "port boundary: SharedToolHub is the Arc<dyn ToolHub> the composition root hands to AppState"},
{"crate": "leleka-control-plane", "file": "src/ports/vision.rs", "ratchet": "dyn-trait", "reason": "port boundary: SharedVisionEncoder is the Arc<dyn VisionEncoder> the composition root hands to AppState"},
{"crate": "leleka-control-plane", "file": "src/app/state.rs", "ratchet": "dyn-trait", "reason": "the tokenizer family (Qwen or gpt-oss) is chosen at start-up and held as Arc<dyn TextCodec>, once per request"},
{"crate": "leleka-control-plane", "file": "src/responses.rs", "ratchet": "dyn-trait", "reason": "SharedCodec, the alias of Arc<dyn TextCodec> that the response stages share"},
{"crate": "leleka-control-plane", "file": "src/model/manifest_fetch.rs", "ratchet": "dyn-trait", "reason": "walks an error's source() chain, whose items are dyn Error"},
{"crate": "leleka-control-plane", "file": "src/wire.rs", "ratchet": "dyn-trait", "reason": "the per-request token-bytes closure of a reasoning plan, built once per request from the tokenizer"},
{"crate": "leleka-engine-host", "file": "src/node.rs", "ratchet": "dyn-trait", "reason": "tonic server-streaming response type: the generated trait wants a boxed stream"},
{"crate": "leleka-engine-host", "file": "src/runtime_rpc.rs", "ratchet": "dyn-trait", "reason": "tonic server-streaming response type: the generated trait wants a boxed stream"},
{"crate": "leleka-backend-api", "file": "src/scripted.rs", "ratchet": "dyn-trait", "reason": "the scripted test engine stores the test's responder closure"},
{"crate": "leleka-gateway-domain", "file": "src/responses/schema.rs", "ratchet": "process-global", "reason": "pure cache: the validity of a tool schema by its compact text, so the dozen schemas of a coding agent are compiled once, not three times per request"},
{"crate": "leleka-gateway-text", "file": "src/prompt/renderer.rs", "ratchet": "process-global", "reason": "the compiled pinned chat template: immutable, built on first use, read by every request"},
{"crate": "leleka-control-plane", "file": "src/request_log.rs", "ratchet": "process-global", "reason": "the process-wide request counters and histograms that /metrics renders; written by every request"},
{"crate": "leleka-control-plane", "file": "src/responses/harmony_prompt.rs", "ratchet": "process-global", "reason": "the gpt-oss prompt date: configuration set once by serve before the first request"},
{"crate": "leleka-control-plane", "file": "src/stage_trace.rs", "ratchet": "process-global", "reason": "diagnostic stage table of the replay harness and STRATA_STAGE_TRACE: one table per process by design"}
],
"source_patterns": [
{"id": "env-read", "regex": "\\benv::var(_os)?\\(", "why": "configuration must be parsed once into a Settings struct (S13), not read all over the code"},
{"id": "instant-now", "regex": "\\bInstant::now\\(\\)", "why": "time must come from an injected Clock in core logic (S14)"},
{"id": "path-include", "regex": "#\\[path\\s*=\\s*\"(?![^\"]*tests\\.rs\")(?![A-Za-z0-9_]+/[A-Za-z0-9_]+\\.rs\")", "why": "a file compiled into two crates must be one crate (S8); a tests.rs or a child module file of the form dir/name.rs is not an include"},
{"id": "process-global", "ignore_imports": true, "regex": "\\b(OnceLock|LazyLock|OnceCell)\\b|\\bstatic\\s+mut\\b|Governor::global\\(|serving_cells\\(\\)", "why": "process globals make core logic untestable without a GPU (S14)"},
{"id": "dyn-trait", "regex": "\\bdyn\\s+[A-Z]", "why": "no dynamic dispatch per round or token; dyn is for startup composition only"},
{"id": "glob-super-import", "regex": "^use super::\\*;", "why": "a glob import of the parent hides what a module needs; name the items (use super::{A, B}); scripts/dev/explicit_imports.py does it for the files rustsplit leaves"},
{"id": "allow-unused-imports", "regex": "#\\[allow\\(unused_imports\\)\\]", "why": "a blanket allow hides imports that are really unused; it belongs on re-exports and on names that only some cargo features use"}
]
}