Route PEP 723 scripts to inline environments (PEP 723 PR 9/16) - #1729
Open
Stella Huang (StellaHuang95) wants to merge 2 commits into
Open
Route PEP 723 scripts to inline environments (PEP 723 PR 9/16)#1729Stella Huang (StellaHuang95) wants to merge 2 commits into
Stella Huang (StellaHuang95) wants to merge 2 commits into
Conversation
Add saved-metadata routing, durable association provenance, explicit override precedence, and race-safe active-environment transitions behind the internal feature gate. 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),
Heejae Chang (heejaechang) and
Rich Chiodo (rchiodo)
and removed request for
Eduardo Villalpando Mello (edvilme)
August 19, 2026 23:31
|
🔒 Automated review in progress — Heejae Chang (@heejaechang) is auto-reviewing this PR. |
|
Verification: The relevant tests could not be fully run in the isolated environment; this review is not fully verified. |
Cancel stale reads after edits, preserve monotonic metadata revisions, and align BOM source offsets. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6b12d843-8011-4bfc-9ba9-f75761eadee2
|
Verification: The relevant tests could not be fully run in the isolated environment; this review is not fully verified. |
Heejae Chang (heejaechang)
approved these changes
Aug 20, 2026
Heejae Chang (heejaechang)
left a comment
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 9 of 16 in the PEP 723 inline-script roadmap and the repository's intentional routing cutover. Earlier manager PRs create, discover, validate, and persist environments; this PR makes normal per-file environment lookup use them when a saved script association is proven current.
Why this PR
The inline manager can already create/reuse environments, persist a script association, rediscover cache entries after restart, clear state safely, and report lifecycle telemetry. Nothing automatically selects that manager for a Python file, however. A script continues to use its normal project/default environment unless another component directly asks the inline manager.
Automatic routing must be stricter than checking whether a file contains PEP 723 metadata or whether Memento contains an executable path. It must prove both:
If either proof is absent, dirty, stale, transiently unavailable, or superseded by an explicit choice, routing falls through to the existing project/default manager.
What this PR does
Adds an activation-scoped routing registry
shouldRoute(uri)becomes true.Turns the existing lazy detector into a routing input only when enabled
.pyfiles for routing while retaining the existing workspace-only telemetry population.When no routing registry exists, the detector retains its existing telemetry-only listeners, coalescing, workspace filter, and event behavior.
Defines a stable metadata identity
requires-python.[tool]table.Adds durable cache provenance
Makes sidecar replacement recoverable
Upgrades persisted associations from path-only values
Each current record contains:
legacy: old string association; remains retrievable but is not automatically routeable.pending: the environment is proven, but saved metadata has not yet been durably matched (for example, selection while the document is dirty).matched: saved metadata identity and cache provenance agree.Validates associations before routing
Validation requires:
Definitively stale associations are conditionally removed. Locked, transient, uncertain, or future-schema states are preserved but remain non-routeable.
Protects asynchronous validation from stale results
Adds central manager routing with explicit precedence
User flows
Previously configured script after restart
Metadata edit
New unassociated script
Opening a new PEP 723 script does not silently select a matching cache entry. It remains on normal routing until the future explicit setup action (PR 11/12) creates or reuses an environment and persists the association. After that, this PR provides automatic routing.
Routing and failure semantics
Review guide
The production changes are easiest to review in this order:
routingRegistry.tsactivation.tsmetadata.tslazyDetector.tscacheLayout.tsinlineScript/envManager.tsinlineScript/envManager.tsenvManagers.tsextension.tsinlineScript/main.tsMore than half of the diff is deterministic unit coverage for dirty/save/restart and async race behavior.
Tests
Coverage includes:
Validation on the final rebased tree:
npm run compile-testsnpm run compilenpm run lintnpm run unittest: 1,797 passing, 6 pendingPerformance
Privacy and safety
User impact
No default-path user impact.
python-envs.inlineScripts.enabledremains undeclared and defaults to false:For developers manually enabling the hidden flag, existing proven script associations route automatically and fall back conservatively when proof is absent. New scripts still require the future explicit setup UX.
Scope and follow-up
This PR intentionally does not implement:
Those later PRs can build on this guarded routing layer without changing its validation contract.