From 736a5aa1045041c2324b68fbde12cba68c32c0b4 Mon Sep 17 00:00:00 2001 From: Teakowa <27560638+Teakowa@users.noreply.github.com> Date: Sat, 22 Aug 2026 22:39:52 +0800 Subject: [PATCH] chore(lpp): remove unconsumed provider-registry surface Entropy-audit cut (Risk A): four wright-lpp registry APIs had no production or external consumers. - ProviderRegistry::from_env and the LPP_MOCK_PROVIDER_ENV const: zero callers anywhere. The doc comment called it 'the integration-test/CI hook', but tests and CI read the LPP_MOCK_PROVIDER variable directly and register the mock provider explicitly, so the env-populated registry was dead code advertising a configuration path that nothing uses. - ProviderRegistry::get: zero external callers; spawn resolves configs through the internal map directly. - ProviderRegistry::languages: only wright-lpp's own test asserted it; the registry-lifecycle protections (duplicate refusal, spawn, not-configured refusal) are unchanged. - ProviderConfig::with_request_timeout: the only caller set the same 30s value ProviderConfig::new already defaults to. The pub request_timeout field remains settable for embedders that need a non-default timeout. The registry's remaining surface (new/register/spawn) is exactly what the driver session, ToolService flow, and integration tests consume. SessionConfig's doc comment now describes the env hook accurately as a test/CI mechanism rather than pointing at the removed API. --- crates/wright-driver/src/config.rs | 7 +++-- crates/wright-lpp/src/registry.rs | 38 ------------------------ crates/wright-lpp/tests/mock_provider.rs | 17 ++++------- 3 files changed, 9 insertions(+), 53 deletions(-) diff --git a/crates/wright-driver/src/config.rs b/crates/wright-driver/src/config.rs index 33d6554..f620666 100644 --- a/crates/wright-driver/src/config.rs +++ b/crates/wright-driver/src/config.rs @@ -125,9 +125,10 @@ pub struct SessionConfig { /// [`CompilerSession::language_provider`] spawns a provider client for a /// language id from this registry; when no provider is configured the /// refusal is explicit and there is no fallback to in-process frontends. - /// The registry is empty by default; `wright_lpp::ProviderRegistry` - /// documents the configuration (and the `LPP_MOCK_PROVIDER` env hook - /// used by tests and CI). + /// The registry is empty by default; providers are registered explicitly + /// through `wright_lpp::ProviderRegistry` (integration tests and CI + /// locate the mock provider through the `LPP_MOCK_PROVIDER` + /// environment variable). pub providers: wright_lpp::ProviderRegistry, } diff --git a/crates/wright-lpp/src/registry.rs b/crates/wright-lpp/src/registry.rs index be8b22c..ad6d06d 100644 --- a/crates/wright-lpp/src/registry.rs +++ b/crates/wright-lpp/src/registry.rs @@ -15,10 +15,6 @@ use std::time::Duration; use crate::error::ProviderError; use crate::provider::StdioLanguageProvider; -/// The environment variable naming the LPP mock/conformance provider binary -/// used by integration tests and CI. -pub const LPP_MOCK_PROVIDER_ENV: &str = "LPP_MOCK_PROVIDER"; - /// One configured provider, keyed by its opaque language id. #[derive(Debug, Clone)] pub struct ProviderConfig { @@ -47,12 +43,6 @@ impl ProviderConfig { request_timeout: Duration::from_secs(30), } } - - /// Set an explicit per-request timeout. - pub fn with_request_timeout(mut self, request_timeout: Duration) -> ProviderConfig { - self.request_timeout = request_timeout; - self - } } /// A registry error. @@ -99,16 +89,6 @@ impl ProviderRegistry { Ok(()) } - /// The configuration registered for a language id, if any. - pub fn get(&self, language_id: &str) -> Option<&ProviderConfig> { - self.providers.get(language_id) - } - - /// Every registered language id, in deterministic order. - pub fn languages(&self) -> impl Iterator { - self.providers.keys().map(String::as_str) - } - /// Spawn a fresh provider session for `language_id`. /// /// Refuses explicitly when no provider is configured for the id @@ -123,22 +103,4 @@ impl ProviderRegistry { })?; StdioLanguageProvider::spawn(&config.command, &config.args, config.request_timeout) } - - /// A registry populated from the environment: `LPP_MOCK_PROVIDER` names - /// a mock/conformance provider binary serving the reference language - /// `x-demo-lang`. This is the integration-test/CI hook; production - /// configuration registers providers explicitly. - pub fn from_env() -> ProviderRegistry { - let mut registry = ProviderRegistry::new(); - if let Ok(command) = std::env::var(LPP_MOCK_PROVIDER_ENV) { - if !command.is_empty() { - let _ = registry.register(ProviderConfig::new( - "x-demo-lang", - PathBuf::from(command), - Vec::new(), - )); - } - } - registry - } } diff --git a/crates/wright-lpp/tests/mock_provider.rs b/crates/wright-lpp/tests/mock_provider.rs index ee30ae9..a271c94 100644 --- a/crates/wright-lpp/tests/mock_provider.rs +++ b/crates/wright-lpp/tests/mock_provider.rs @@ -170,10 +170,6 @@ fn registry_lookup_is_by_opaque_language_id() { language_id: "x-other-lang".to_string(), } ); - assert_eq!( - registry.languages().collect::>(), - vec![DEMO_LANGUAGE_ID] - ); } // --------------------------------------------------------------------------- @@ -506,14 +502,11 @@ fn missing_capability_is_an_explicit_refusal_not_a_fallback() { }; let mut registry = ProviderRegistry::new(); registry - .register( - ProviderConfig::new( - DEMO_LANGUAGE_ID, - path, - vec!["--without".to_string(), "compile".to_string()], - ) - .with_request_timeout(std::time::Duration::from_secs(30)), - ) + .register(ProviderConfig::new( + DEMO_LANGUAGE_ID, + path, + vec!["--without".to_string(), "compile".to_string()], + )) .expect("registered"); let mut provider = registry.spawn(DEMO_LANGUAGE_ID).expect("spawns"); let result = provider