Add inline script activation-time discovery (PEP 723 PR 8/16) - #1722
Open
Stella Huang (StellaHuang95) wants to merge 4 commits into
Open
Add inline script activation-time discovery (PEP 723 PR 8/16)#1722Stella Huang (StellaHuang95) wants to merge 4 commits into
Stella Huang (StellaHuang95) wants to merge 4 commits into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3cb82ae9-7424-40a4-9156-8c54ac6e0895
Use stable cache identities, fail closed on lock probes, and retry snapshot changes safely. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6b12d843-8011-4bfc-9ba9-f75761eadee2
Contributor
|
🔒 Automated review in progress — Rich Chiodo (@rchiodo) is auto-reviewing this PR. |
Rich Chiodo (rchiodo)
previously approved these changes
Aug 18, 2026
Rich Chiodo (rchiodo)
left a comment
Contributor
There was a problem hiding this comment.
Approved via Review Center.
Use async and await without changing refresh behavior. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6b12d843-8011-4bfc-9ba9-f75761eadee2
Avoid bounded retries when the cache remains definitively empty. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6b12d843-8011-4bfc-9ba9-f75761eadee2
Rich Chiodo (rchiodo)
approved these changes
Aug 18, 2026
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 8 of 16 in the PEP 723 inline-script roadmap. It makes extension-owned cached environments discoverable after activation; automatic script routing remains a separate follow-up.
InlineScriptEnvManagerskeletoncreate()happy pathcreate()uv-install fallbackget/set+ Memento)Why this PR
PR 7 persists and lazily rehydrates a specific script's selected inline environment when the manager is asked for that script. The manager still has no global inventory, however:
getEnvironments()returns[], and cached environments are not published after an extension-host restart unless a script-specific lookup happens to reconstruct one.This PR implements the activation-discovery portion of Q4 in the design:
PythonEnvironment;What this PR does
Defers discovery until after manager registration
setImmediate()after the manager is registered.Publishes a global discovered collection
getEnvironments('all')returns a copy of the validated cache collection.EnvironmentChangeKind.addandremoveevents only when manager identity, executable path, or Python version materially changes.Validates every cache entry before publication
A candidate must:
.meta.jsonsidecar;PythonEnvironment;sysPrefix; andDiscovery is read-only. It does not delete, rebuild, or rewrite invalid entries.
Distinguishes definitive invalidity from uncertainty
Handles concurrent cache changes
sysPrefixpaths, avoiding false removal through symlink/junction path differences.lstat; onlyENOENTmeans unlocked.EIO, access failures, and other uncertain states fail closed.Coalesces refresh work without weakening activation discovery
refresh()cancels activation retries, performs one settled pass, and schedules no delayed work afterward.Retries activation discovery only while useful
Strengthens the Windows usability guard
pyvenv.cfg.Scripts\python.exeappear usable.Discovery semantics
Example
This inventory does not associate an environment with a script. PR 7 owns persisted script associations, and PR 9 will use those associations for automatic per-file routing.
Tests
Coverage includes:
all-scope publication;EIO) lock probes;sysPrefixversus lexical cache-root identities;Validation on the rebased branch:
npm run compile-testsnpm run compilenpm run lintThe full Windows unit run reaches 1613 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 discovery remain behind the undeclared, default-off
python-envs.inlineScripts.enabledflag.With the internal flag manually enabled, valid cached inline environments become available through the manager after restart. This PR does not automatically select one for a script and introduces no public command, setting, picker item, project registration, cache deletion, TTL cleanup, or telemetry.
Scope and follow-up
This PR intentionally does not implement:
PR 7 (#1697) is merged, and this branch is rebased on current
main. Automatic routing can follow independently after this manager-discovery layer lands.