From 651ed44e907366aecfcb6a1c716a89aa526c0d4c Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Tue, 24 Nov 2026 08:19:15 +0100 Subject: [PATCH 1/6] Drop 49 allow(unused_imports) that no compiler warning needs (STRA-338) The re-exports left by the mechanical module splits carried a blanket allow(unused_imports). 49 of them cover nothing: cargo check --all-targets on backend-api, control-plane, gateway-domain, gateway-text and libc-shim gives no new unused-import or glob-import warning without them. 39 others in those crates still silence a real warning and stay; the 8 in desktop-core (engine-host) could not be checked because that crate needs the engine, which does not build on Windows (STRA-390), and stay too. --- control-plane/src/app.rs | 2 -- control-plane/src/kar_quality.rs | 2 -- control-plane/src/kar_writer.rs | 2 -- control-plane/src/mcp.rs | 2 -- control-plane/src/messages.rs | 2 -- control-plane/src/model.rs | 1 - control-plane/src/native_pack.rs | 2 -- control-plane/src/prepare_preview.rs | 3 --- control-plane/src/prometheus.rs | 1 - control-plane/src/request_log.rs | 2 -- control-plane/src/request_monitor.rs | 1 - control-plane/src/service_install.rs | 1 - control-plane/src/service_switch.rs | 1 - crates/backend-api/src/lib.rs | 22 ------------------- crates/gateway-domain/src/reasoning_budget.rs | 2 -- crates/gateway-text/src/tool_output.rs | 2 -- crates/libc-shim/src/cuda_trace.rs | 1 - 17 files changed, 49 deletions(-) diff --git a/control-plane/src/app.rs b/control-plane/src/app.rs index 6368149b..54da7daa 100644 --- a/control-plane/src/app.rs +++ b/control-plane/src/app.rs @@ -38,7 +38,6 @@ mod tests; mod state; pub use state::{AppState, EngineLink, HttpPolicy, ModelView, Services}; mod routes; -#[allow(unused_imports)] pub use routes::*; mod admin_routes; #[allow(unused_imports)] @@ -47,5 +46,4 @@ mod readiness; #[allow(unused_imports)] pub use readiness::*; mod metrics_document; -#[allow(unused_imports)] pub use metrics_document::*; diff --git a/control-plane/src/kar_quality.rs b/control-plane/src/kar_quality.rs index b70effd0..f4e0e2bc 100644 --- a/control-plane/src/kar_quality.rs +++ b/control-plane/src/kar_quality.rs @@ -98,8 +98,6 @@ mod tests; mod analyze; mod previous; mod sample; -#[allow(unused_imports)] pub use analyze::*; mod sample_records; -#[allow(unused_imports)] pub use sample_records::*; diff --git a/control-plane/src/kar_writer.rs b/control-plane/src/kar_writer.rs index bf27259d..fa74ce7d 100644 --- a/control-plane/src/kar_writer.rs +++ b/control-plane/src/kar_writer.rs @@ -103,13 +103,11 @@ mod tests; mod archive_entry_points; mod archive_file; mod archive_plan; -#[allow(unused_imports)] pub use archive_entry_points::*; mod archive_write_steps; #[allow(unused_imports)] pub use archive_write_steps::*; mod nested_layout; -#[allow(unused_imports)] pub use nested_layout::*; mod section_payload; #[allow(unused_imports)] diff --git a/control-plane/src/mcp.rs b/control-plane/src/mcp.rs index aded0adc..be75c7ca 100644 --- a/control-plane/src/mcp.rs +++ b/control-plane/src/mcp.rs @@ -164,11 +164,9 @@ mod server; #[allow(unused_imports)] pub use server::*; mod tool_result_text; -#[allow(unused_imports)] pub use tool_result_text::*; mod hub; #[allow(unused_imports)] pub use hub::*; mod parse_config; -#[allow(unused_imports)] pub use parse_config::*; diff --git a/control-plane/src/messages.rs b/control-plane/src/messages.rs index 87892f40..2476fa20 100644 --- a/control-plane/src/messages.rs +++ b/control-plane/src/messages.rs @@ -30,10 +30,8 @@ struct Events(mpsc::Receiver); mod tests; mod count_tokens; -#[allow(unused_imports)] pub use count_tokens::*; mod error_type; -#[allow(unused_imports)] pub use error_type::*; mod messages_stream; #[allow(unused_imports)] diff --git a/control-plane/src/model.rs b/control-plane/src/model.rs index 99cfc86c..9ebf0679 100644 --- a/control-plane/src/model.rs +++ b/control-plane/src/model.rs @@ -44,7 +44,6 @@ pub struct ModelFile { mod tests; mod manifest_fetch; -#[allow(unused_imports)] pub use manifest_fetch::*; mod file_download; #[allow(unused_imports)] diff --git a/control-plane/src/native_pack.rs b/control-plane/src/native_pack.rs index 67f673e0..c2d8c3b3 100644 --- a/control-plane/src/native_pack.rs +++ b/control-plane/src/native_pack.rs @@ -82,10 +82,8 @@ mod dense_files; #[allow(unused_imports)] pub use dense_files::*; mod pack_publication; -#[allow(unused_imports)] pub use pack_publication::*; mod pack_outputs; -#[allow(unused_imports)] pub use pack_outputs::*; mod same_bytes; #[allow(unused_imports)] diff --git a/control-plane/src/prepare_preview.rs b/control-plane/src/prepare_preview.rs index a14805ef..3fe21363 100644 --- a/control-plane/src/prepare_preview.rs +++ b/control-plane/src/prepare_preview.rs @@ -79,10 +79,8 @@ struct StagingDir(PathBuf); mod tests; mod preview_entry_points; -#[allow(unused_imports)] pub use preview_entry_points::*; mod prepare_sharded; -#[allow(unused_imports)] pub use prepare_sharded::*; mod streamed_sharded_prepare; #[allow(unused_imports)] @@ -94,7 +92,6 @@ mod prepare_single_file; #[allow(unused_imports)] pub use prepare_single_file::*; mod tensor_encoding; -#[allow(unused_imports)] pub use tensor_encoding::*; mod derived_verification; #[allow(unused_imports)] diff --git a/control-plane/src/prometheus.rs b/control-plane/src/prometheus.rs index 35199065..20e03c95 100644 --- a/control-plane/src/prometheus.rs +++ b/control-plane/src/prometheus.rs @@ -41,5 +41,4 @@ mod tests; mod series; use series::SERIES; mod render; -#[allow(unused_imports)] pub use render::*; diff --git a/control-plane/src/request_log.rs b/control-plane/src/request_log.rs index bcdb016e..795f53cc 100644 --- a/control-plane/src/request_log.rs +++ b/control-plane/src/request_log.rs @@ -168,10 +168,8 @@ impl Default for RequestMetrics { mod tests; mod request_context; -#[allow(unused_imports)] pub use request_context::*; mod observation; -#[allow(unused_imports)] pub use observation::*; mod metrics_text; #[allow(unused_imports)] diff --git a/control-plane/src/request_monitor.rs b/control-plane/src/request_monitor.rs index 5fd68621..4948ce6c 100644 --- a/control-plane/src/request_monitor.rs +++ b/control-plane/src/request_monitor.rs @@ -99,5 +99,4 @@ mod record; #[allow(unused_imports)] pub use record::*; mod capture; -#[allow(unused_imports)] pub use capture::*; diff --git a/control-plane/src/service_install.rs b/control-plane/src/service_install.rs index 0edfd0ad..fed7f11d 100644 --- a/control-plane/src/service_install.rs +++ b/control-plane/src/service_install.rs @@ -31,5 +31,4 @@ mod command_line; #[allow(unused_imports)] pub use command_line::*; mod control; -#[allow(unused_imports)] pub use control::*; diff --git a/control-plane/src/service_switch.rs b/control-plane/src/service_switch.rs index fa3dfa00..29ebaa55 100644 --- a/control-plane/src/service_switch.rs +++ b/control-plane/src/service_switch.rs @@ -191,7 +191,6 @@ mod switch_profiles; #[allow(unused_imports)] pub use switch_profiles::*; mod run; -#[allow(unused_imports)] pub use run::*; mod reconcile; #[cfg(unix)] diff --git a/crates/backend-api/src/lib.rs b/crates/backend-api/src/lib.rs index 6b50faea..8f8dfe1a 100644 --- a/crates/backend-api/src/lib.rs +++ b/crates/backend-api/src/lib.rs @@ -21,50 +21,28 @@ pub use recent_ids::{DEFAULT_RECENT_IDS, RecentIds}; mod tests; mod backend_contract; -#[allow(unused_imports)] pub use backend_contract::BACKEND_API_VERSION; -#[allow(unused_imports)] pub use backend_contract::Backend; -#[allow(unused_imports)] pub use backend_contract::BackendCapabilities; -#[allow(unused_imports)] pub use backend_contract::BackendError; -#[allow(unused_imports)] pub use backend_contract::BackendIdentity; -#[allow(unused_imports)] pub use backend_contract::ContractError; -#[allow(unused_imports)] pub use backend_contract::ErrorCode; -#[allow(unused_imports)] pub use backend_contract::FinishReason; -#[allow(unused_imports)] pub use backend_contract::GenerationEvent; -#[allow(unused_imports)] pub use backend_contract::GenerationRequest; -#[allow(unused_imports)] pub use backend_contract::GenerationSink; -#[allow(unused_imports)] pub use backend_contract::GenerationTerminal; -#[allow(unused_imports)] pub use backend_contract::LoadedModel; -#[allow(unused_imports)] pub use backend_contract::MAX_OUTPUT_TOKENS; -#[allow(unused_imports)] pub use backend_contract::ModelDescriptor; -#[allow(unused_imports)] pub use backend_contract::RuntimeConfig; -#[allow(unused_imports)] pub use backend_contract::SamplingOptions; -#[allow(unused_imports)] pub use backend_contract::SupportedModelTuple; -#[allow(unused_imports)] pub use backend_contract::Usage; mod generation_stream; -#[allow(unused_imports)] use generation_stream::EventSender; -#[allow(unused_imports)] pub use generation_stream::GenerationStream; -#[allow(unused_imports)] pub use generation_stream::StreamError; mod contract_rules; diff --git a/crates/gateway-domain/src/reasoning_budget.rs b/crates/gateway-domain/src/reasoning_budget.rs index 742ceca9..8f4b7c2b 100644 --- a/crates/gateway-domain/src/reasoning_budget.rs +++ b/crates/gateway-domain/src/reasoning_budget.rs @@ -79,8 +79,6 @@ pub struct Run { mod tests; mod budget; -#[allow(unused_imports)] pub use budget::*; mod generation_loop; -#[allow(unused_imports)] pub use generation_loop::*; diff --git a/crates/gateway-text/src/tool_output.rs b/crates/gateway-text/src/tool_output.rs index 97ae6de5..cc54d3c0 100644 --- a/crates/gateway-text/src/tool_output.rs +++ b/crates/gateway-text/src/tool_output.rs @@ -126,10 +126,8 @@ mod notes; #[allow(unused_imports)] pub use notes::*; mod incremental; -#[allow(unused_imports)] pub use incremental::*; mod parse_text; -#[allow(unused_imports)] pub use parse_text::*; mod parse_call; #[allow(unused_imports)] diff --git a/crates/libc-shim/src/cuda_trace.rs b/crates/libc-shim/src/cuda_trace.rs index bc1e3802..dbf92f9d 100644 --- a/crates/libc-shim/src/cuda_trace.rs +++ b/crates/libc-shim/src/cuda_trace.rs @@ -280,7 +280,6 @@ copy!( mod tests; mod trace_state; -#[allow(unused_imports)] pub use trace_state::*; mod launch_interposers; #[allow(unused_imports)] From c1734bc7c4a757ad8f46f9295969b011a7e05a7a Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Tue, 24 Nov 2026 08:23:00 +0100 Subject: [PATCH 2/6] cuda-driver: the expert tier probe names what it takes from its parent instead of use super::* (STRA-338) The probe module is compiled under cfg(any(test, feature = "expert-tier-probe")), so it is production code of that feature and the glob import counts for the gate. The 16 names it uses are listed; cargo check --all-targets with features cuda-driver,expert-tier-probe and with cuda-driver alone gives no new warning. --- .../src/original_verify/expert_probe.rs | 34 ++++--------------- .../expert_probe/probe_geometry.rs | 28 +++++++++++++++ 2 files changed, 35 insertions(+), 27 deletions(-) create mode 100644 crates/cuda-driver/src/original_verify/expert_probe/probe_geometry.rs diff --git a/crates/cuda-driver/src/original_verify/expert_probe.rs b/crates/cuda-driver/src/original_verify/expert_probe.rs index 948d4cef..33b76636 100644 --- a/crates/cuda-driver/src/original_verify/expert_probe.rs +++ b/crates/cuda-driver/src/original_verify/expert_probe.rs @@ -16,9 +16,15 @@ use super::kernels::ArenaMap; use super::moe::{self, MoeKnobs, OriginalVerifyExpertFormats}; use super::window_plan::PlanLayout; use super::window_record::{ExpertTier, Rows}; -use super::*; +use super::{ + Arg, Command, Context, Error, MappedAllocation, MappedRouteOperands, OriginalVerifyBank, OriginalVerifyCpuRows, + OriginalVerifyCpuSink, OriginalVerifyGeometry, Physical, Result, RouteRowSpan, combine, command, handle, kernels, +}; use crate::{OriginalGpuStream, OriginalStreamKind}; +mod probe_geometry; +pub use probe_geometry::expert_probe_geometry; + struct ProbeArena<'p, 'ctx>(&'p Physical<'ctx>); impl ArenaMap for ProbeArena<'_, '_> { fn span(&self, name: &str, offset: usize, bytes: usize) -> Result { @@ -34,32 +40,6 @@ pub struct OriginalExpertTierProbe<'ctx> { formats: OriginalVerifyExpertFormats, } -/// The probe geometry: the model's MoE shape with a small context and vocabulary (no head runs here). -pub fn expert_probe_geometry(max_t: usize, max_expert_blob: usize) -> OriginalVerifyGeometry { - OriginalVerifyGeometry { - max_t, - n: 2560, - hc: 4, - lr: 320, - ff: 640, - experts: 512, - k: 10, - channels: 10240, - value_heads: 48, - key_heads: 16, - heads: 24, - kv_heads: 2, - head_dim: 256, - index_heads: 4, - index_dim: 128, - index_block: 4, - selection: 2051, - max_cells: 256, - vocabulary: 1024, - max_expert_blob, - } -} - impl<'ctx> Context<'ctx> { pub fn original_expert_tier_probe( &'ctx self, diff --git a/crates/cuda-driver/src/original_verify/expert_probe/probe_geometry.rs b/crates/cuda-driver/src/original_verify/expert_probe/probe_geometry.rs new file mode 100644 index 00000000..15ef87d4 --- /dev/null +++ b/crates/cuda-driver/src/original_verify/expert_probe/probe_geometry.rs @@ -0,0 +1,28 @@ +//! The geometry of the expert tier probe: the shape the probe's verifier bank is sized for. +use crate::original_verify::OriginalVerifyGeometry; + +/// The probe geometry: the model's MoE shape with a small context and vocabulary (no head runs here). +pub fn expert_probe_geometry(max_t: usize, max_expert_blob: usize) -> OriginalVerifyGeometry { + OriginalVerifyGeometry { + max_t, + n: 2560, + hc: 4, + lr: 320, + ff: 640, + experts: 512, + k: 10, + channels: 10240, + value_heads: 48, + key_heads: 16, + heads: 24, + kv_heads: 2, + head_dim: 256, + index_heads: 4, + index_dim: 128, + index_block: 4, + selection: 2051, + max_cells: 256, + vocabulary: 1024, + max_expert_blob, + } +} From e79179a255857eaf49df9073456a0dc65ecd371e Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Tue, 24 Nov 2026 08:23:00 +0100 Subject: [PATCH 3/6] cuda-driver: the copy ring asks its arena for the stage slot count by static dispatch, not through a dyn view (STRA-338) admitted_slots coerced the read lease to &dyn RingArena only to call stage_slots on it. RingArena::stage_slots(read) is the same method of the same impl without the vtable; the Ring keeps its own dyn field, which has its exception entry. --- .../original_group/copy_ring/ring/ring_construction.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/cuda-driver/src/mmq/resident/original_group/copy_ring/ring/ring_construction.rs b/crates/cuda-driver/src/mmq/resident/original_group/copy_ring/ring/ring_construction.rs index 45e4ce8a..24006409 100644 --- a/crates/cuda-driver/src/mmq/resident/original_group/copy_ring/ring/ring_construction.rs +++ b/crates/cuda-driver/src/mmq/resident/original_group/copy_ring/ring/ring_construction.rs @@ -59,8 +59,7 @@ impl<'read, 'ctx> Ring<'read, 'ctx> { schedule: &OriginalMmqCopySchedule<'ctx>, layer: usize, ) -> Result { - let admitted: &dyn RingArena = read; - let count = admitted.stage_slots()?; + let count = RingArena::stage_slots(read)?; schedule.validate_context(context)?; if !schedule_serves_ring(schedule.ring_slots(), count) { let e = Error::InvalidProjectionShape; From d9c0c87dcfab72805d0ecc35c95cd182964ff83e Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Tue, 24 Nov 2026 08:32:41 +0100 Subject: [PATCH 4/6] Narrow the dead glob re-exports of the module splits: pub use x::* becomes use x::* or pub(crate) use x::* (STRA-338) Where the split left pub use x::* over items that no outside module can name, the compiler said the glob re-exports nothing pub. The glob now has the visibility its items really have: plain use where they are pub(self), pub(crate) where siblings reach them (model.rs file_download, libc-shim launch_interposers). One glob of backend-api scripted.rs was dead and is deleted. 7 globs of control-plane stay with their allow: the compiler calls them unused in the lib build and the lib test build of control-plane cannot be built on Windows, so a test use cannot be ruled out. cargo check --all-targets on backend-api, control-plane, gateway-domain, gateway-text and libc-shim: no new warning, no new error (the one control-plane lib test error is the pre-existing std::os::unix use). --- control-plane/src/app.rs | 6 ++---- control-plane/src/kar_writer.rs | 9 +++------ control-plane/src/mcp.rs | 12 ++++-------- control-plane/src/messages.rs | 3 +-- control-plane/src/model.rs | 3 +-- control-plane/src/native_pack.rs | 15 +++++---------- control-plane/src/prepare_preview.rs | 12 ++++-------- control-plane/src/request_monitor.rs | 3 +-- control-plane/src/service_install.rs | 3 +-- control-plane/src/service_switch.rs | 6 ++---- crates/backend-api/src/scripted.rs | 8 ++------ crates/gateway-text/src/tool_output.rs | 12 ++++-------- crates/libc-shim/src/cuda_trace.rs | 3 +-- 13 files changed, 31 insertions(+), 64 deletions(-) diff --git a/control-plane/src/app.rs b/control-plane/src/app.rs index 54da7daa..5f7bacc5 100644 --- a/control-plane/src/app.rs +++ b/control-plane/src/app.rs @@ -40,10 +40,8 @@ pub use state::{AppState, EngineLink, HttpPolicy, ModelView, Services}; mod routes; pub use routes::*; mod admin_routes; -#[allow(unused_imports)] -pub use admin_routes::*; +use admin_routes::*; mod readiness; -#[allow(unused_imports)] -pub use readiness::*; +use readiness::*; mod metrics_document; pub use metrics_document::*; diff --git a/control-plane/src/kar_writer.rs b/control-plane/src/kar_writer.rs index fa74ce7d..de089c5b 100644 --- a/control-plane/src/kar_writer.rs +++ b/control-plane/src/kar_writer.rs @@ -105,13 +105,10 @@ mod archive_file; mod archive_plan; pub use archive_entry_points::*; mod archive_write_steps; -#[allow(unused_imports)] -pub use archive_write_steps::*; +use archive_write_steps::*; mod nested_layout; pub use nested_layout::*; mod section_payload; -#[allow(unused_imports)] -pub use section_payload::*; +use section_payload::*; mod directory_record; -#[allow(unused_imports)] -pub use directory_record::*; +use directory_record::*; diff --git a/control-plane/src/mcp.rs b/control-plane/src/mcp.rs index be75c7ca..b7cd412b 100644 --- a/control-plane/src/mcp.rs +++ b/control-plane/src/mcp.rs @@ -146,17 +146,14 @@ pub struct Hub { mod tests; mod mcp_settings_errors; -#[allow(unused_imports)] -pub use mcp_settings_errors::*; +use mcp_settings_errors::*; mod stdio_transport; #[allow(unused_imports)] pub use stdio_transport::*; mod stdio_message_routing; -#[allow(unused_imports)] -pub use stdio_message_routing::*; +use stdio_message_routing::*; mod http_transport; -#[allow(unused_imports)] -pub use http_transport::*; +use http_transport::*; mod transport; #[allow(unused_imports)] pub use transport::*; @@ -166,7 +163,6 @@ pub use server::*; mod tool_result_text; pub use tool_result_text::*; mod hub; -#[allow(unused_imports)] -pub use hub::*; +use hub::*; mod parse_config; pub use parse_config::*; diff --git a/control-plane/src/messages.rs b/control-plane/src/messages.rs index 2476fa20..83dd75c8 100644 --- a/control-plane/src/messages.rs +++ b/control-plane/src/messages.rs @@ -34,5 +34,4 @@ pub use count_tokens::*; mod error_type; pub use error_type::*; mod messages_stream; -#[allow(unused_imports)] -pub use messages_stream::*; +use messages_stream::*; diff --git a/control-plane/src/model.rs b/control-plane/src/model.rs index 9ebf0679..31f90c1e 100644 --- a/control-plane/src/model.rs +++ b/control-plane/src/model.rs @@ -46,5 +46,4 @@ mod tests; mod manifest_fetch; pub use manifest_fetch::*; mod file_download; -#[allow(unused_imports)] -pub use file_download::*; +pub(crate) use file_download::*; diff --git a/control-plane/src/native_pack.rs b/control-plane/src/native_pack.rs index c2d8c3b3..0dea9a64 100644 --- a/control-plane/src/native_pack.rs +++ b/control-plane/src/native_pack.rs @@ -70,21 +70,16 @@ pub struct Options { mod tests; mod pack_rules; -#[allow(unused_imports)] -pub use pack_rules::*; +use pack_rules::*; mod expert_layout; -#[allow(unused_imports)] -pub use expert_layout::*; +use expert_layout::*; mod convert_tensor; -#[allow(unused_imports)] -pub use convert_tensor::*; +use convert_tensor::*; mod dense_files; -#[allow(unused_imports)] -pub use dense_files::*; +use dense_files::*; mod pack_publication; pub use pack_publication::*; mod pack_outputs; pub use pack_outputs::*; mod same_bytes; -#[allow(unused_imports)] -pub use same_bytes::*; +use same_bytes::*; diff --git a/control-plane/src/prepare_preview.rs b/control-plane/src/prepare_preview.rs index 3fe21363..40bee1fd 100644 --- a/control-plane/src/prepare_preview.rs +++ b/control-plane/src/prepare_preview.rs @@ -83,19 +83,15 @@ pub use preview_entry_points::*; mod prepare_sharded; pub use prepare_sharded::*; mod streamed_sharded_prepare; -#[allow(unused_imports)] -pub use streamed_sharded_prepare::*; +use streamed_sharded_prepare::*; mod spool_raw_f32; -#[allow(unused_imports)] -pub use spool_raw_f32::*; +use spool_raw_f32::*; mod prepare_single_file; -#[allow(unused_imports)] -pub use prepare_single_file::*; +use prepare_single_file::*; mod tensor_encoding; pub use tensor_encoding::*; mod derived_verification; -#[allow(unused_imports)] -pub use derived_verification::*; +use derived_verification::*; mod preview_tensor_io; use preview_tensor_io::*; mod sharded_encode; diff --git a/control-plane/src/request_monitor.rs b/control-plane/src/request_monitor.rs index 4948ce6c..61b23955 100644 --- a/control-plane/src/request_monitor.rs +++ b/control-plane/src/request_monitor.rs @@ -93,8 +93,7 @@ struct Tap { mod tests; mod captured_text; -#[allow(unused_imports)] -pub use captured_text::*; +use captured_text::*; mod record; #[allow(unused_imports)] pub use record::*; diff --git a/control-plane/src/service_install.rs b/control-plane/src/service_install.rs index fed7f11d..eaad8bff 100644 --- a/control-plane/src/service_install.rs +++ b/control-plane/src/service_install.rs @@ -28,7 +28,6 @@ mod unix; mod tests; mod command_line; -#[allow(unused_imports)] -pub use command_line::*; +use command_line::*; mod control; pub use control::*; diff --git a/control-plane/src/service_switch.rs b/control-plane/src/service_switch.rs index 29ebaa55..11c1b869 100644 --- a/control-plane/src/service_switch.rs +++ b/control-plane/src/service_switch.rs @@ -188,12 +188,10 @@ mod storage { mod tests; mod switch_profiles; -#[allow(unused_imports)] -pub use switch_profiles::*; +use switch_profiles::*; mod run; pub use run::*; mod reconcile; #[cfg(unix)] mod transaction; -#[allow(unused_imports)] -pub use reconcile::*; +use reconcile::*; diff --git a/crates/backend-api/src/scripted.rs b/crates/backend-api/src/scripted.rs index 09545971..f962acdb 100644 --- a/crates/backend-api/src/scripted.rs +++ b/crates/backend-api/src/scripted.rs @@ -103,12 +103,8 @@ pub struct ScriptedEngine { mod tests; mod scripted_handle; -#[allow(unused_imports)] -pub use scripted_handle::*; +use scripted_handle::*; mod backend_port; -#[allow(unused_imports)] -pub use backend_port::*; mod play; -#[allow(unused_imports)] -pub use play::*; +use play::*; mod shared_ops; diff --git a/crates/gateway-text/src/tool_output.rs b/crates/gateway-text/src/tool_output.rs index cc54d3c0..86e5b743 100644 --- a/crates/gateway-text/src/tool_output.rs +++ b/crates/gateway-text/src/tool_output.rs @@ -123,18 +123,14 @@ struct QuoteBalance<'a> { mod tests; mod notes; -#[allow(unused_imports)] -pub use notes::*; +use notes::*; mod incremental; pub use incremental::*; mod parse_text; pub use parse_text::*; mod parse_call; -#[allow(unused_imports)] -pub use parse_call::*; +use parse_call::*; mod parameter_value; -#[allow(unused_imports)] -pub use parameter_value::*; +use parameter_value::*; mod find_parameter_end; -#[allow(unused_imports)] -pub use find_parameter_end::*; +use find_parameter_end::*; diff --git a/crates/libc-shim/src/cuda_trace.rs b/crates/libc-shim/src/cuda_trace.rs index dbf92f9d..e814990d 100644 --- a/crates/libc-shim/src/cuda_trace.rs +++ b/crates/libc-shim/src/cuda_trace.rs @@ -282,5 +282,4 @@ mod tests; mod trace_state; pub use trace_state::*; mod launch_interposers; -#[allow(unused_imports)] -pub use launch_interposers::*; +pub(crate) use launch_interposers::*; From 219238cd08347065d63bc93cc45c455377a1f1ca Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Tue, 24 Nov 2026 08:44:55 +0100 Subject: [PATCH 5/6] 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). --- architecture.json | 84 +++- scripts/archcheck/measure.py | 114 +++--- scripts/archcheck/rustsource.py | 143 +++++++ scripts/check_architecture_test.py | 606 +++++++++++++++++------------ 4 files changed, 629 insertions(+), 318 deletions(-) create mode 100644 scripts/archcheck/rustsource.py diff --git a/architecture.json b/architecture.json index d73a679f..7719d63a 100644 --- a/architecture.json +++ b/architecture.json @@ -49,10 +49,9 @@ "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": "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 reason starts with `kept:` (the site must stay, and the boundary that forces it) or `debt:` (a real remaining owner problem, and what removes it). 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": "kept: operator environment switch. The OnceLock is the cell of each `static EnvSwitch` that is declared where the switch is read; the variable cannot change after process start, so the first-read value equals a fresh read, and the crate sits below the engine Settings owner, so a settings value cannot be handed down to it (dependency direction)"}, {"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"}, @@ -123,10 +122,9 @@ {"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"}, {"crate": "leleka-model-format", "file": "src/ple_reader/row_reading.rs", "ratchet": "dyn-trait", "reason": "port boundary: PleReader::open takes the PageSource as Arc"}, - {"crate": "leleka-model-format", "file": "src/huge_pages.rs", "ratchet": "process-global", "reason": "kept: ambient environment. The huge-page mode (LELEKA_HUGEPAGES) is immutable after start so the cache equals a fresh read; model-format is below the engine Settings owner (dependency direction), so no settings value reaches the mapping helpers"}, + {"crate": "leleka-model-format", "file": "src/huge_pages.rs", "ratchet": "process-global", "reason": "kept: ambient environment and the mapping registry. The huge-page mode (LELEKA_HUGEPAGES, MODE) is immutable after start so the cache equals a fresh read, and model-format is below the engine Settings owner (dependency direction); LIVE is the registry of the live huge-page mappings that the release path needs, a process-wide fact of the allocator"}, {"crate": "leleka-model-format", "file": "src/kar/independent_handles.rs", "ratchet": "process-global", "reason": "kept: ambient environment. The identity-recheck switch is immutable after start so the cache equals a fresh read; model-format is below the engine Settings owner (dependency direction)"}, - {"crate": "leleka-model-format", "file": "src/kar.rs", "ratchet": "process-global", "reason": "not a process global: a per-instance lazily opened set of file handles (a OnceLock field of the archive); the gate pattern matches the type name"}, - {"crate": "leleka-model-format", "file": "src/kar/verified_kar_ple_artifact.rs", "ratchet": "process-global", "reason": "not a process global: constructs the per-instance lazy handle cell of kar.rs; the gate pattern matches the type name"}, + {"crate": "leleka-model-format", "file": "src/kar.rs", "ratchet": "process-global", "reason": "kept: COLD_SKIP, the number of upcoming calls that read in parallel without probing after a cold verdict (a cold file would pay the probe's latency each time); a read-path heuristic of the process's one archive reader, output-neutral. The OnceLock field of the archive is an instance field and no longer counted"}, {"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"}, @@ -171,11 +169,7 @@ {"crate": "leleka-engine-qwen35-cuda", "file": "src/backend/spawn_preview.rs", "ratchet": "dyn-trait", "reason": "Box is the process boundary: the factory hands the composed engine to the host, which holds one Backend per process (startup composition only, never per round)"}, {"crate": "leleka-engine-qwen35-cuda", "file": "src/backend/measurement.rs", "ratchet": "dyn-trait", "reason": "the evaluation measurement sink is a stored callback handed in by the host (observer port, called once per request)"}, {"crate": "leleka-engine-qwen35-cuda", "file": "src/backend/original_serve/runner.rs", "ratchet": "dyn-trait", "reason": "the GPU telemetry probe is a stored callback handed in by the host at load (port, sampled by the telemetry tick, not per token)"}, - {"crate": "leleka-engine-qwen35-cuda", "file": "src/model_binding/weight_binding.rs", "ratchet": "process-global", "reason": "not a process global: `std::cell::OnceCell` is an instance field of the binding (lazy PLE reader); the gate pattern matches the type name"}, - {"crate": "leleka-engine-qwen35-cuda", "file": "src/model_binding/weight_binding/model_binding.rs", "ratchet": "process-global", "reason": "not a process global: `std::cell::OnceCell::new()` initialises the instance field `ple_reader` of one ModelBinding; the gate pattern matches the type name"}, {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/original_serve_stack.rs", "ratchet": "process-global", "reason": "kept: DBG_T0, the epoch of the bring-up trace timestamps (dbg_el()); diagnostics only, called from trace macros in many files that hold no common owner, never read by serving logic"}, - {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/session.rs", "ratchet": "process-global", "reason": "not a process global: `std::cell::OnceCell` is an instance field of the session; the gate pattern matches the type name"}, - {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/session/qwen_session.rs", "ratchet": "process-global", "reason": "not a process global: `std::cell::OnceCell::new()` initialises an instance field of one session; the gate pattern matches the type name"}, {"crate": "leleka-cuda-driver", "file": "src/compute_drain.rs", "ratchet": "instant-now", "reason": "measurement timer, not decision logic: stall span of one timed drain, reported by the prefill stall trace"}, {"crate": "leleka-cuda-driver", "file": "src/mmq/resident/original_group/copy_ring/chunk_stream/chunk_issuing.rs", "ratchet": "instant-now", "reason": "measurement timer, not decision logic: span of one chunk issue, summed into the copy-ring profile"}, {"crate": "leleka-cuda-driver", "file": "src/mmq/resident/original_group/copy_ring/original_mmq_copy_schedule/stream_start.rs", "ratchet": "instant-now", "reason": "measurement timer, not decision logic: start of the copy-ring stream, read once per stream for the profile"}, @@ -216,20 +210,82 @@ {"crate": "leleka-cuda-driver", "file": "src/qwen_dispatch/moe_prefill_batch.rs", "ratchet": "dyn-trait", "reason": "the batch owner holds its GEMM provider (cuBLAS-backed in production, a host stand-in in the tests) as a trait object for the life of one batch; it is a port, chosen when the owner is opened"}, {"crate": "leleka-cuda-driver", "file": "src/qwen_dispatch/moe_prefill_batch/moe_prefill_batch_lifecycle.rs", "ratchet": "dyn-trait", "reason": "the batch owner holds its GEMM provider (cuBLAS-backed in production, a host stand-in in the tests) as a trait object for the life of one batch; it is a port, chosen when the owner is opened"}, {"crate": "leleka-cuda-driver", "file": "src/mmq/asset.rs", "ratchet": "process-global", "reason": "kept: pure memo of the verdict of the immutable embedded MMQ artifact check (a function of the embedded bytes alone), so no caller can observe the cache; a Context-owned copy would re-prove the same bytes per Context"}, - {"crate": "leleka-cuda-driver", "file": "src/prefill_stage.rs", "ratchet": "process-global", "reason": "kept: pure memo of a proof about an embedded sealed image (usability of the kh recurrence), a result per device that no caller can observe as state"}, + {"crate": "leleka-cuda-driver", "file": "src/prefill_stage.rs", "ratchet": "process-global", "reason": "kept: pure memo of a proof about an embedded sealed image (usability of the kh recurrence), a result per device that no caller can observe as state; and two per-arm A/B overrides (GDN_OVERRIDE, NOSTORE_OVERRIDE) of the prefill GDN switches, written by the test harness for paired passes in one process"}, {"crate": "leleka-cuda-driver", "file": "src/qsa_index_ffi.rs", "ratchet": "process-global", "reason": "kept: pure memo of the RoPE ABI proof of the embedded index module, a function of the embedded bytes alone"}, {"crate": "leleka-cuda-driver", "file": "src/qsa_prompt_resolver.rs", "ratchet": "process-global", "reason": "kept: pure memo of the resolver ABI proof of the embedded module, a function of the embedded bytes alone"}, - {"crate": "leleka-cuda-driver", "file": "src/qwen_ffi/asset_admission.rs", "ratchet": "process-global", "reason": "kept: per-operation pure memo of the PTX proof of an embedded sealed image, a function of the embedded bytes alone"}, {"crate": "leleka-cuda-driver", "file": "src/qwen_ffi/n_types.rs", "ratchet": "process-global", "reason": "kept: the table of the PTX proof memos of asset_admission.rs, one cell per operation; pure functions of embedded bytes"}, - {"crate": "leleka-cuda-driver", "file": "src/marker_files.rs", "ratchet": "process-global", "reason": "kept: the marker files of the A/B controls are operator-named paths read once with the time of the first look, so a hot path stats the disk at most every 250 ms; one type serves three controls"}, {"crate": "leleka-native-cpu-expert", "file": "src/rust_bench_frontend.rs", "ratchet": "process-global", "reason": "kept: FFI. `static mut stdout` is libc's C stream, declared in an extern block; it is the C library's own global, not ours"}, - {"crate": "leleka-native-cpu-expert", "file": "src/settings.rs", "ratchet": "process-global", "reason": "kept: the cell of each `static Setting` (operator switches and the CPU probes the kernels dispatch on), computed on first read from the immutable environment and the CPU; the kernels are free functions called from pool worker threads that carry no context to pass a value through, and a hot path pays one atomic load"} + {"crate": "leleka-native-cpu-expert", "file": "src/settings.rs", "ratchet": "process-global", "reason": "kept: the cell of each `static Setting` (operator switches and the CPU probes the kernels dispatch on), computed on first read from the immutable environment and the CPU; the kernels are free functions called from pool worker threads that carry no context to pass a value through, and a hot path pays one atomic load"}, + {"crate": "leleka-control-plane", "file": "src/request_log.rs", "ratchet": "process-global", "reason": "kept: `tokio::task_local! CURRENT`, the request context (ReqCtx) of the running request, read without a request argument by code that holds no handle; it is scoped to one task, not to the process"}, + {"crate": "leleka-control-plane", "file": "src/responses.rs", "ratchet": "process-global", "reason": "kept: NEXT_RESPONSE_ID, the counter in the `resp_