Add inline script environment persistence (PEP 723 PR 7/16) - #1697
Open
Stella Huang (StellaHuang95) wants to merge 1 commit into
Open
Add inline script environment persistence (PEP 723 PR 7/16)#1697Stella Huang (StellaHuang95) wants to merge 1 commit into
Stella Huang (StellaHuang95) wants to merge 1 commit into
Conversation
Stella Huang (StellaHuang95)
requested review from
Eduardo Villalpando Mello (edvilme) and
Eleanor Boyd (eleanorjboyd)
August 6, 2026 22:06
Contributor
Author
|
🔒 Automated review in progress — Stella Huang (@StellaHuang95) is auto-reviewing this PR. |
Persist and safely rehydrate per-script environment associations. Harden selection races, cache-lock handling, corrupt-state repair, scope validation, and central batch selection consistency without globally serializing environment operations. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1a9f6ba1-9bd3-4664-bc25-a0d34d7a2e91
Stella Huang (StellaHuang95)
force-pushed
the
pep723-pr7-persistence
branch
from
August 7, 2026 17:14
81c9e6a to
2719448
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Roadmap context
This is PR 7 of 16 in the PEP 723 inline-script roadmap. It adds durable per-script environment associations to the internal manager.
InlineScriptEnvManagerskeletoncreate()happy pathcreate()uv-install fallbackget/set+ Memento)Why this PR
PR 5 can build or reuse an inline-script environment, but the manager does not remember that the resulting environment belongs to a particular script. After an extension-host restart, the in-memory association is gone.
This PR implements the persistence portion of Q4 in the design:
requires-pythonmetadata before returning an environment;What this PR does
Implements per-script
set()file:URIs and rejects invalid or mixed scopes atomically.onDidChangeEnvironmentonly for effective changes.create()behavior separate: creation alone does not implicitly establish a persisted association.Implements per-script
get()requires-pythonagainst the reconstructed Python version before returning it.Safely rehydrates persisted associations
PythonEnvironmentand confirms that it belongs to the expected extension-owned cache entry.Validates warm in-memory associations
Protects persistence and selection from races
Updates central active-environment tracking
Example
Given two scripts in the same workspace:
PR 7 stores and retrieves those associations independently. Selecting the environment for
import.pydoes not overwrite the last-known environment forreport.py.After restart:
If
report.pylater changes fromrequires-python = ">=3.11"to">=3.13", its persisted Python 3.12 environment is no longer returned as compatible.Persistence and failure semantics
Tests
Coverage includes:
npm run compile-tests,npm run lint, the full unit suite, and the focused persistence/central-manager suites are clean.Performance
User impact
No default-path user impact yet. This completes an internal Phase 2 manager capability. Automatic routing and user-facing entry points arrive in later roadmap PRs.
Once routing is wired, script-specific selections will survive extension-host restarts and remain independent even for multiple scripts in the same workspace.
Merge order
The core persistence behavior depends on the merged manager skeleton (#1610). This branch is rebased on current
main; PR 8 and PR 9 build on this capability.