Add inline script environment persistence (PEP 723 PR 7/16) - #1697
Conversation
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 |
3072ce4 to
628c729
Compare
|
🔒 Automated review in progress — Rich Chiodo (@rchiodo) is auto-reviewing this PR. |
Rich Chiodo (rchiodo)
left a comment
There was a problem hiding this comment.
Approved via Review Center.
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
Prevent stale central selection publication, align inline environment identity with executable paths, normalize stale cleanup paths, and extract named association types. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1a9f6ba1-9bd3-4664-bc25-a0d34d7a2e91
Publish same-path version rebuilds, emit completed multi-manager unset groups consistently, and preserve cold associations across transient rehydration failures. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1a9f6ba1-9bd3-4664-bc25-a0d34d7a2e91
2e6ce79 to
1262b21
Compare
| } | ||
|
|
||
| const key = project ? project.uri.toString() : 'global'; | ||
| if (scope instanceof Uri) { |
There was a problem hiding this comment.
Issue · Please address or respond
Switching away from the inline manager only removes central in-memory routing; it does not unset the inline manager's persisted script association. A later restart or inline discovery can therefore resurrect the superseded selection. Clear the durable inline association after the replacement manager succeeds.
bde7cf8
into
microsoft:main
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.