diff --git a/docs/architecture/tech-debt.md b/docs/architecture/tech-debt.md index 82d6dc3f..fc8aad06 100644 --- a/docs/architecture/tech-debt.md +++ b/docs/architecture/tech-debt.md @@ -205,6 +205,36 @@ their doc comment now says by which phase), `ConversationManager` (a domain type | `path-include` (engine 100, `desktop-core` 2) | not in the owner's list for this pass | `mod x;` through the directory layout with `git mv`, one directory at a time | | generated doc headers (`Methods of ...`, `Functions: ...`) in about 430 files of these crates | the sentence on why the file is separate needs the author's knowledge | by directory, together with the next feature that touches it | +### (e) Stage 10 pass: control-plane, desktop-core, deploy and the small crates (owner order 2026-11-14, branch `claude/debt-control`) + +Crates: `strata-control`, `strata-desktop-core`, `leleka-deploy`, `leleka-gateway-domain`, `leleka-gateway-text`, `leleka-backend-api`, `leleka-runtime-client`, `leleka-npu-service`. Numbers are from `scripts/check-architecture.py`; a site that must stay is a named entry of `exceptions` in `architecture.json` (crate, file, ratchet, reason), not a baseline number. + +| Ratchet | before | after (outside the exceptions) | +|---|---|---| +| `glob-super-import` | `deploy` 15, `control` 9 | 0 | +| `allow-unused-imports` | `control` 48, `desktop-core` 9, 4 small crates 9 | 0 | +| `env-read` | `deploy` 41, `control` 14, `desktop-core` 13, `gateway-text` 2, `npu-service` 1 | 3 (`control`, hot files, see below); each crate has one reader module | +| `dyn-trait` | `deploy` 17, `control` 11, `gateway-domain` 2, `desktop-core` 2, `backend-api` 1 | 0 | +| `path-include` | `desktop-core` 2 | 0 (`evaluation_measurement` is a module of the library; both binaries use it) | +| `instant-now` | `deploy` 28, `control` 22, `desktop-core` 14, `npu-service` 5, `backend-api` 2 | `control` 15 and `desktop-core` 4 in hot files, see below; the rest 0 | +| `process-global` | `control` 8, `gateway-text` 4, `gateway-domain` 2 | 2 (`control`, hot files) | + +**One reader per crate.** `env_settings.rs` in `strata-control`, `strata-desktop-core`, `leleka-deploy`, `leleka-gateway-text` and `leleka-npu-service` is the only file that calls `std::env::var`; the other modules ask for a typed value (`env_settings::number::("STRATA_QUEUE_TIMEOUT_S")`, `supervisor_status_file()`, `hub_token()`, `stage_trace()`, `home_dir()`, `hf_token_set()`). The reads stay live, so the order of the checks and the messages of the run configuration are as before. `leleka-deploy` passes its `LELEKA_*` lookup around as `EnvLookup = fn(&str) -> Option` (a function pointer, no `dyn`), the tests pass `env_settings::nothing` or a non-capturing closure. + +**Clock.** `leleka-deploy`: the supervisor owns an `AnyClock` (a manual one in tests) and the command flows read `SystemClock` of `leleka-obs`. `strata-control`: the MCP hub and servers and the hardware series hold an `AnyClock`; `model/file_download.rs` uses the gateway `SystemClock`. `strata-desktop-core`: the node's inventory cache holds an `AnyClock`, the asynchronous deadlines read `clock::RuntimeClock` (tokio's clock, which `tokio::time::pause` controls). Exceptions: the two adapters and the manual clock fixture, the node subscription's freshness stamps, the NPU profile laps and the scripted engine's pacing. + +**Exceptions (reasons in `architecture.json`).** `dyn-trait`: the five `Shared*` ports of `strata-control` and `AppState`'s codec (composition), `SharedCodec`, the error source chain, the per-request token-bytes closure, the two tonic streaming types of `desktop-core`, the scripted engine's responder. `process-global`: the compiled pinned chat template, the schema validity cache, the request metrics registry, the gpt-oss prompt date set at start-up, the stage-trace table. + +**Names and docs.** About 150 generated doc headers (`Methods of ...`, `Functions: ...`, `Unit tests of this module (split out ...)`) are real sentences that say what the file holds and why it is separate. 60 modules were renamed by what they hold with `scripts/dev/rename_module.py` (`worker/generation_result.rs` -> `worker_entry.rs`, `model/fetch_one.rs` -> `file_download.rs`, `mtp_fetch/mtime_ns.rs` -> `command_line.rs`, `server_api/slots.rs` -> `status_routes.rs`, `desktop-core` `gateway/secret.rs` -> `pool_gateway.rs`, ...). `*_methods` group modules and `ConversationManager` are in `engine-core`/the engine, not in these crates. + +**Left, with the next step.** + +| What | Why | Next step | +|---|---|---| +| hot-path sites (`env-read` 3, `instant-now` 15 + 4, `process-global` 2 in `control`/`desktop-core`) | admission, streaming and the gRPC client are held back until the two-binary identity run | branch `claude/debt-hot-control` | +| Windows-only files (`key_init/windows.rs`, `facts/windows.rs`, `winfront/*`, `winservice/*`) | edited by hand (names read from the code); no Windows `cargo check` could run because `leleka-memory` and `leleka-model-format` do not compile for Windows at this commit (`governor/operations.rs`, `qwen4exp_*`: unresolved imports under `cfg(windows)`) | a Windows `cargo check -p leleka-deploy -p strata-control` once those two crates compile there | +| deploy end-to-end tests `dry_run_*` and `reconfigure_flow::*` | need free VRAM and a quiet GPU (host checks read `nvidia-smi`); they fail on the busy laptop with "GPU memory: ... free but the engine needs ..." | run on the 5090 | + ### (d) Other open items of this file (unchanged by the pass; the owner's order for them) 1. S13/S14 injection: `settings::process()`, `Governor::global()`, `INSTANCE`/`RECONFIGURING` and the clock into the engine stack (sections S13, S14, S19 below). Blocks most of the `process-global` and `instant-now` numbers of (b).