Skip to content

Commit 22e37af

Browse files
refactor: reuse library discovery modules (Fixes #545) (#546)
Fixes #545. Isolates the mechanical module-reuse portion of #538. - Use the public library discovery/locator modules from JSONRPC instead of compiling duplicate binary module instances. - Keep locator ordering, public APIs, state lifetimes, and orchestration unchanged. - Document that discovery/locator tests belong to the library target and JSONRPC tests to the binary target. Independent main-based branch; does not update #524 or #526 or modify their changed files. No runtime speedup is claimed. Validation: all 59 library/binary/JSONRPC integration tests pass on Windows; Rust 1.98 formatting, mandatory Clippy, and all-targets/all-features Clippy pass. Independent Reviewer returned no findings. Platform CI and quality snapshots will validate the resulting binary. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 07abe3d commit 22e37af

3 files changed

Lines changed: 9 additions & 7 deletions

File tree

‎crates/pet/src/jsonrpc.rs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
use crate::find::find_and_report_envs;
5-
use crate::find::find_python_environments_in_workspace_folder_recursive;
6-
use crate::find::identify_python_executables_using_locators;
7-
use crate::find::SearchScope;
8-
use crate::locators::create_locators;
94
use log::{error, info, trace, warn};
5+
use pet::find::find_and_report_envs;
6+
use pet::find::find_python_environments_in_workspace_folder_recursive;
7+
use pet::find::identify_python_executables_using_locators;
8+
use pet::find::SearchScope;
109
use pet::initialize_tracing;
10+
use pet::locators::create_locators;
1111
use pet::resolve::resolve_environment;
1212
use pet_conda::Conda;
1313
use pet_conda::CondaLocator;

‎crates/pet/src/main.rs‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ use jsonrpc::start_jsonrpc_server;
88
use pet::{find_and_report_envs_stdio, resolve_report_stdio, FindOptions};
99
use pet_core::python_environment::PythonEnvironmentKind;
1010

11-
mod find;
1211
mod jsonrpc;
13-
mod locators;
1412

1513
#[derive(Parser, Debug)]
1614
#[command(version, about, long_about = None)]

‎docs/LOCATOR_STATE.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,7 @@ When adding mutable state to a locator, classify it before relying on it across
5050
3. If later requests need refresh-discovered state, use `SyncedDiscoveryState`, implement `sync_refresh_state_from()`, and cover full, workspace, and kind-filtered scopes with tests.
5151

5252
The locator graph has a regression test in `crates/pet/src/jsonrpc.rs` that pins the current classification of each locator created by `create_locators()`.
53+
54+
## Module Ownership
55+
56+
The CLI and JSONRPC server both use the `pet` library's public `find` and `locators` modules. The binary owns CLI dispatch and its `jsonrpc` adapter, rather than compiling separate copies of discovery and locator code. Discovery/locator unit tests run under the library target; JSONRPC orchestration tests remain under the binary target. This module boundary does not change the transient and shared locator lifetimes described above.

0 commit comments

Comments
 (0)