93 lines
10 KiB
JSON
93 lines
10 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-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/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"}
|
|
]
|
|
}
|