You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,6 +31,8 @@ This project will be consumed by the [Python extension](https://marketplace.visu
31
31
32
32
Our approach prioritizes performance and efficiency by leveraging Rust. We minimize I/O operations by collecting all necessary environment information at once, which reduces repeated I/O and the need to spawn additional processes, significantly enhancing overall performance.
33
33
34
+
Locator refresh-state contracts are documented in [docs/LOCATOR_STATE.md](docs/LOCATOR_STATE.md).
35
+
34
36
## Contributing
35
37
36
38
This project welcomes contributions and suggestions. Most contributions require you to agree to a
Refresh requests run on a transient locator graph. The server configures that graph from a single configuration snapshot, runs discovery, and then syncs selected refresh-discovered state back into the long-lived shared locator graph only if that configuration generation is still current.
4
+
5
+
The `Locator::refresh_state()` classification is the contract for that boundary. It keeps configured inputs, self-hydrating caches, and correctness-critical discovery state distinct.
6
+
7
+
## Classifications
8
+
9
+
| Classification | Meaning | Sync behavior |
10
+
| --- | --- | --- |
11
+
|`Stateless`| The locator keeps no mutable state that survives a request. | Nothing is copied back. |
12
+
|`ConfiguredOnly`| The locator stores configured inputs such as executable paths or workspace directories. | Refresh must use the transient locator's request snapshot and must not copy this state back. |
13
+
|`SelfHydratingCache`| The locator stores a cache that later requests can rebuild on demand. | Refresh may fill a transient cache, but correctness must not rely on syncing it. |
14
+
|`SyncedDiscoveryState`| The locator stores refresh-discovered state that later requests need for correctness or fidelity. | The locator must override `sync_refresh_state_from()` and copy only state appropriate for the `RefreshStateSyncScope`. |
15
+
16
+
## Current Locator Inventory
17
+
18
+
| Locator | Mutable state | Classification | Notes |
19
+
| --- | --- | --- | --- |
20
+
| WindowsStore | Discovered Store environments |`SyncedDiscoveryState`| Full and matching global-kind refreshes replace the cache; workspace refreshes leave it alone. |
21
+
| WindowsRegistry | Discovered registry managers and environments |`SyncedDiscoveryState`| Full and matching global-kind refreshes replace the cache; workspace refreshes leave it alone. |
| PyEnv | Manager and versions-directory cache |`SelfHydratingCache`|`find()` clears the cache, and `try_from()` can rebuild it from the environment. |
24
+
| Pixi | None |`Stateless`| Identification is derived from filesystem markers. |
25
+
| Conda | Environment, manager, and mamba-manager discovery caches; configured executable |`SyncedDiscoveryState`| Discovery caches are synced. The configured executable remains configuration state and is not copied from refresh locators. |
26
+
| Uv | Configured workspace directories; immutable uv install directory |`ConfiguredOnly`| Workspace directories come from the request configuration snapshot. |
27
+
| Poetry | Configured workspace directories and executable; discovered search result |`SyncedDiscoveryState`| Search results are synced or merged by scope. Configured inputs are not copied back. |
28
+
| PipEnv | Configured pipenv executable |`ConfiguredOnly`| The executable comes from the configuration snapshot. |
29
+
| VirtualEnvWrapper | Environment variables captured at construction |`Stateless`| No refresh-discovered mutable state. |
30
+
| Venv | None |`Stateless`| Identification is derived from `pyvenv.cfg` and filesystem layout. |
31
+
| VirtualEnv | None |`Stateless`| Identification is derived from virtualenv markers. |
32
+
| Homebrew | Environment variables captured at construction |`Stateless`| No refresh-discovered mutable state. |
| LinuxGlobalPython | Reported executable cache |`SelfHydratingCache`|`try_from()` can repopulate the cache by scanning known global bin directories. |
37
+
38
+
## Updating The Contract
39
+
40
+
When adding mutable state to a locator, classify it before relying on it across refreshes:
41
+
42
+
1. If it is configured input, keep it under `ConfiguredOnly` and source it from `Configuration`.
43
+
2. If it is only a performance cache, use `SelfHydratingCache` and make later requests able to rebuild it.
44
+
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.
45
+
46
+
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()`.
0 commit comments