Add opportunistic inline-script TTL eviction (PEP 723 PR 14/16) - #1745
Open
Stella Huang (StellaHuang95) wants to merge 2 commits into
Open
Add opportunistic inline-script TTL eviction (PEP 723 PR 14/16)#1745Stella Huang (StellaHuang95) wants to merge 2 commits into
Stella Huang (StellaHuang95) wants to merge 2 commits into
Conversation
Run a best-effort 14-day cache sweep once per manager session before the first inline-script environment creation. Reuse the existing safe deletion and association cleanup paths while preserving uncertain or active entries. Part of microsoft#1602. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
🔒 Automated review in progress — Rich Chiodo (@rchiodo) is auto-reviewing this PR. |
Contributor
|
Verification: The relevant tests could not be fully run in the isolated environment; this review is not fully verified. Result: Summary: Verification could not start because no trusted sandbox image is configured for this repository, and local execution was not authorized. No compile, lint, or targeted unit test command ran. The PR adds 10 focused TTL-eviction unit tests, but their results could not be confirmed. Confidence is therefore limited. Test runs: 1 not run
|
Rich Chiodo (rchiodo)
previously approved these changes
Aug 28, 2026
Rich Chiodo (rchiodo)
left a comment
Contributor
There was a problem hiding this comment.
Approved via Review Center.
TTL eviction ranked entries only by the sidecar lastUsedAt, which is refreshed on create/reuse but never when an environment is resolved for run, debug, or Pylance. A stable script's environment could therefore look stale and be evicted (clearing its association) while still in active use. Skip eviction of any cache entry a script association still references, so the sweep reclaims only orphaned entries (superseded by a dependency change, or left by a deleted/deselected script). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Stella Huang (StellaHuang95)
added a commit
to StellaHuang95/vscode-python-environments
that referenced
this pull request
Aug 29, 2026
Update sections 6, 7, 9, and 10 to reflect what was actually built and the in-flight PRs (vscode-python-environments microsoft#1744/microsoft#1745, pyrx #9265, vscode-python #26129): - Q6: dedicated InlineScriptAssociationStore + metadata-identity binding (pending/matched) instead of reusing VenvManager persistence; clarify pythonProjects[] is user-visible registration, not routing. - Q7: TTL runs once per session (runTtlEvictionOnce) and protects entries referenced by a live association (PR microsoft#1745). - Q9: Pylance re-routes via the existing didChangeConfiguration signal (_revalidateOpenRegularFiles / revalidateWorkspaceForFile), so PR 18's dedicated notification is optional; fix persistence/event-source bullets. - Q10: correct the '~10 LOC' estimate to the real exactResource + __pythonIsProgramInterpreter + middleware change; add useEnvExtension gating caveat for Run and Debug. Add a status banner noting the doc was revised post-implementation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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 14 of 16 in the PEP 723 inline-script roadmap. PR 13 added explicit, user-confirmed cache cleanup; this PR adds the separate best-effort TTL path.
get/set+ Memento)Why this PR
Inline-script environments are dependency/interpreter-keyed and intentionally rebuilt instead of synchronized in place. Without lifecycle cleanup, old cache keys accumulate whenever dependencies or the selected Python change.
The design calls for a pipx-style 14-day TTL in addition to the explicit clear command. Because TTL cleanup is silent, it must be more conservative than user-confirmed cleanup and must never prevent the requested environment from being created.
What this PR does
InlineScriptEnvManagersession..meta.jsonsidecars and selects entries whoselastUsedAtis strictly older than 14 days.lastUsedAtunder the entry lock before deletion.Eviction semantics
lastUsedAtolder than 14 dayslstat, then invalidate local associationsConcurrency and safety
ENOENTcounts as confirmed cross-host deletion; permission and transient access errors preserve associations.Performance
User impact
The feature remains behind
python-envs.inlineScripts.enabled. Users without inline-script environments see no behavior change. Existing environments are retained unless a valid sidecar proves they have not been successfully reused for more than 14 days.Tests
npm run compile-testsnpm run compilenpm run lintFocused coverage includes:
Scope and follow-up
This PR does not add telemetry, activation-time cleanup, a cache-root lock, project-setting cleanup, UX, or retry loops. Explicit clear-cache behavior remains unchanged.