Harden PEP 723 per-script routing against stale asynchronous selections - #1734
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
🔒 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. |
…kup classification Trim this PR to the minimal set of fixes for the default-off PEP 723 inline-script feature: - Batch settings persistence now obeys the selection revision-ordering guarantee. In the Uri[] branch of setEnvironments, the winning (non-superseded) selections are committed via the revision-commit guard BEFORE settings are persisted, and settings/routing/events are applied only for those winners. This fixes the settings/routing divergence where an out-of-order older batch could persist a stale manager to settings.json even though its routing override was rejected. - Future-schema backup sidecars are classified as `unsupported` (not `missing`) so a newer-schema cache is not rebuilt by an older client. Reverts the association-validation retry/generation subsystem in the inline-script env manager (AssociationValidationResult, retry generations, nested pending-op maps, conditional Memento commit guards, required routing-registry injection) — deferred to a follow-up. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f881304e-3c5f-4144-9f0d-d80c68768d18
|
Verification: The relevant tests could not be fully run in the isolated environment; this review is not fully verified. |
Heejae Chang (heejaechang)
left a comment
There was a problem hiding this comment.
Approved via Review Center.
Replace the generic cross-manager selection-finalization machinery with a narrow PEP 723-only routing-mutation guard. Only a current (non-superseded) inline-routing operation may mutate a script's per-script routing override; the ordinary project/global active-selection and settings lanes are committed independently and are no longer suppressed by a stale inline operation. - Restore the origin/main batch settings construction/write order (no committedSelections, no pre-settings revision filter, no post-settings recheck) and the one-key commitSelectionOperation. - Add commitInlineRoutingOperation, gated to inlineScriptRouting + file .py scopes via getInlineScriptRoutingKey; feature-off and non-script scopes return true immediately and preserve the old flow. - Guard only the single-URI and batch inline routing blocks. Each script commits on its own per-file inline key, so two scripts under the same containing project no longer contend on a shared project revision (the first script now installs its override instead of skipping it). - The generic cross-manager settings write race is explicitly deferred. Tests: adapt the stale-non-inline-vs-newer-inline regression to assert the script still routes to inline without asserting containing-project suppression; add a same-project batch non-inline regression and a feature-off distinct-projects batch regression; remove the batch settings-ordering test. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f881304e-3c5f-4144-9f0d-d80c68768d18
|
|
||
| if (validBackups.length === 0) { | ||
| return { kind: 'missing' }; | ||
| return { kind: hasUnsupportedBackup ? 'unsupported' : 'missing' }; |
There was a problem hiding this comment.
Warning · Non-blocking recommendation
When compatible and future-schema backups coexist, validBackups takes precedence over hasUnsupportedBackup, restoring older metadata despite the newer-schema sidecar. Make an unsupported backup dominate restoration and add coverage for the mixed-backup case.
|
Verification: The relevant tests could not be fully run in the isolated environment; this review is not fully verified. |
c6b1e27
into
microsoft:main
Summary
This PR narrows the earlier inline-script hardening to two focused, PEP 723-specific changes. Everything here is scoped to the manually enabled (default-off) inline-script routing feature.
1. Prevent stale asynchronous selections from mutating PEP 723 per-script routing overrides
When environment selections for a script resolve out of order, a superseded (older) operation could still install, clear, or overwrite that script's per-script inline routing override. The central manager now guards inline routing mutations with a per-script revision check (
commitInlineRoutingOperation), gated strictly to:inlineScriptRoutingbeing enabled, and.pyscope recognized bygetInlineScriptRoutingKey.Only a current (non-superseded) operation may change a script's routing override. Each script commits on its own per-file inline key, so two routeable scripts under the same containing project no longer contend on a shared project revision — batch-selecting one non-inline environment for both now correctly routes both scripts.
The ordinary project/global active-selection and settings lanes commit independently, so a stale inline operation can no longer suppress a legitimate containing-project selection.
2. Preserve future-schema inline cache backups
cacheLayoutnow classifies a backup sidecar written by a newer cache schema asunsupportedrather than rebuildable, so a newer-schema cache isn't rebuilt (and clobbered) by an older client.Explicitly deferred / out of scope
The generic cross-manager batch settings write race is not addressed here. A correct fix requires shared cross-manager settings serialization. This PR intentionally does not claim to make batch settings persistence revision-ordered, and it does not change ordinary (non-inline) project selection behavior. That work is deferred to a follow-up.
Tests
cacheLayoutfuture-schema backup tests.Unit suite: 1838 passing, 6 pending, 0 failing.