Add clear script environment cache command (PEP 723 PR 13/16) - #1724
Open
Stella Huang (StellaHuang95) wants to merge 5 commits into
Open
Add clear script environment cache command (PEP 723 PR 13/16)#1724Stella Huang (StellaHuang95) wants to merge 5 commits into
Stella Huang (StellaHuang95) wants to merge 5 commits into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3cb82ae9-7424-40a4-9156-8c54ac6e0895
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3cb82ae9-7424-40a4-9156-8c54ac6e0895
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3cb82ae9-7424-40a4-9156-8c54ac6e0895
Coordinate per-entry deletion locks, keep partial failures consistent, and clean inline project settings safely. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6b12d843-8011-4bfc-9ba9-f75761eadee2
Claim exact stale or retained lock markers before inline cache cleanup. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6b12d843-8011-4bfc-9ba9-f75761eadee2
Stella Huang (StellaHuang95)
requested review from
Eduardo Villalpando Mello (edvilme),
Eleanor Boyd (eleanorjboyd) and
Rich Chiodo (rchiodo)
and removed request for
Eduardo Villalpando Mello (edvilme)
August 18, 2026 21:52
Contributor
|
🔒 Automated review in progress — Rich Chiodo (@rchiodo) is auto-reviewing this PR. |
Rich Chiodo (rchiodo)
approved these changes
Aug 18, 2026
Rich Chiodo (rchiodo)
left a comment
Contributor
There was a problem hiding this comment.
Approved via Review Center.
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 13 of 16 in the PEP 723 inline-script roadmap. It adds the explicit, user-confirmed cache lifecycle operation that the later TTL work will reuse.
get/set+ Memento)Why this PR
The extension can create extension-owned inline-script environments and persist script associations, but it has no complete way to remove that state. Clearing only the files would leave Memento associations and
pythonProjectsentries pointing at deleted interpreters; clearing only settings would leave disk usage behind.This PR adds one coordinated lifecycle operation covering:
Because this is destructive and the cache is shared by extension-host processes, the implementation is intentionally fail-closed around path ownership and locks.
What this PR does
Adds an internal, confirmation-gated clear command
python-envs.clearScriptEnvCacheonly while the hidden inline-script feature flag is enabled.package.jsonor the Command Palette before rollout.Keeps generic cache clearing behavior safe
python-envs.clearCachecommand continues to clear existing non-inline managers.Serializes in-process maintenance
create(),get(), andset()cannot observe or mutate half-cleared state.Coordinates deletion across extension hosts
retainedmarkers remain recognizable but are conservatively not reclaimed.Validates every destructive path
Before deleting an entry, cleanup verifies that:
script-envs-v1are normal directories rather than symlinks/junctions;realpathcontainment matches the expected ownership boundary;The entry lock is acquired first, then root and entry ownership are revalidated immediately before removal.
Keeps state consistent through partial failures
onDidChangeEnvironmentonly for selections actually invalidated.Removes generated inline project settings safely
pythonProjectsentries independently from global, workspace, and workspace-folder sources.Cleanup semantics
Example
Tests
Coverage includes:
Validation on the rebased branch:
npm run compile-testsnpm run compilenpm run lintThe full Windows unit run reaches 1638 passing and 5 pending; the existing concurrent
writeMetaJsonrename test can still intermittently fail withEPERMon Windows. That writer is unchanged by this PR and the same failure is reproducible onmain.Performance
User impact
No default-path user impact. The manager and command remain behind the undeclared, default-off
python-envs.inlineScripts.enabledflag, and the command is not publicly contributed.When the internal flag is manually enabled, the existing generic cache command still behaves as before for non-inline managers. Inline cleanup is available only through the dedicated confirmed lifecycle.
Scope and follow-up
This PR intentionally does not implement:
PR 14 will reuse this safety and state-cleanup foundation to remove entries whose
lastUsedAtexceeds the planned 14-day TTL.