Skip to content

Bug: formalize locator state that must survive refresh boundaries #387

@karthiknadig

Description

@karthiknadig

Summary

Issue #383 changed refresh to run against a transient locator graph and then copy back the shared state that later JSONRPC requests still depend on. We currently do that explicitly for Conda and Poetry, but there is no general contract for which locator state is allowed to matter after a refresh completes.

That is fragile: future locator changes can silently regress resolve, find, or telemetry behavior if a locator starts depending on refresh-populated state and nobody also adds a handoff step.

Current examples

  • Conda keeps discovered environments/managers that are later used by condaInfo and missing-env telemetry.
  • Poetry keeps a cached search_result that improves later resolve fidelity.
  • Other locators also keep mutable state, but under different assumptions:
    • PipEnv stores the configured executable.
    • Uv stores configured workspace directories.
    • WindowsRegistry caches search_result, but can self-hydrate on demand.
    • LinuxGlobalPython caches discovered executables for reuse/perf.

The current code has no explicit distinction between:

  • config-only state
  • refresh-discovered state that must survive for correctness
  • performance caches that may be recomputed

Problem

Right now the server logic effectively knows about stateful locators by name. That makes the refresh pipeline harder to reason about and increases the chance that a future locator will accidentally depend on stale or missing state after a transient refresh.

Proposed direction

Audit all locators and define an explicit contract for post-refresh state, for example by doing one of the following:

  • Make locators fully stateless apart from configured inputs.
  • Make stateful locators self-hydrating on try_from() / later requests.
  • Introduce an explicit interface for state that must be synchronized from transient refresh locators back into the long-lived shared locators.

Acceptance criteria

  • Inventory locator state across the current locator set.
  • Classify each piece of state as config-only, correctness-critical post-refresh state, or perf-only cache.
  • Pick and document the intended contract.
  • Add tests covering at least one non-Conda/Poetry stateful locator path so regressions are easier to catch.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue identified by VS Code Team member as probable bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions