Add inline script environment persistence (PEP 723 PR 7/16) - #1697
Add inline script environment persistence (PEP 723 PR 7/16)#1697Stella Huang (StellaHuang95) wants to merge 3 commits into
Conversation
|
🔒 Automated review in progress — Stella Huang (@StellaHuang95) is auto-reviewing this PR. |
2719448 to
dbb5c72
Compare
|
AI agent review findings:
I validated the PR with Reviewed and posted by Eleanor's AI agent. |
dbb5c72 to
7c4f36e
Compare
Thanks Eleanor Boyd (@eleanorjboyd), both findings are valid.
|
105d9ca to
a39fd2e
Compare
|
will give a thumbs up to after the prior one merges as I assume that will create merge conflicts |
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
Keep inline-script manager settings scoped to exact script projects and prevent stale warm validation from superseding a newer selection. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1a9f6ba1-9bd3-4664-bc25-a0d34d7a2e91
Keep exact script-project settings authoritative while routing active inline selections ahead of containing-project defaults, and retain strict PEP 440 validation for persisted associations. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1a9f6ba1-9bd3-4664-bc25-a0d34d7a2e91
a39fd2e to
3072ce4
Compare
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.