Skip to content

Install Posit Assistant into versioned slots and resolve from them - #18673

Closed
gtritchie wants to merge 4 commits into
mainfrom
feature/pai-versioned-installs-wire
Closed

gtritchie wants to merge 4 commits into
mainfrom
feature/pai-versioned-installs-wire

Conversation

@gtritchie

Copy link
Copy Markdown
Member

PR 3 of the five-PR sequence in #18658: the resolver switch and the install path
rewrite. This is the behavior-changing one -- the layout PR 2 built is now what
RStudio installs into and runs from.

Addresses #18658.

Resolution

locatePositAssistantInstallation() becomes the ordered list of independent
sources from the issue, each its own function so the list can be gated and
extended without disturbing the others (#18443 disables the user-writable
sources; rstudio/rstudio-pro#12483 appends a fourth):

  1. RSTUDIO_POSIT_AI_PATH
  2. pai/versions via selected.json, chosen by protocol
  3. <systemConfigDir>/pai/bin

Sources 1 and 3 are unversioned directories, not slots. They carry no install
manifest and are not named for a version, so they get verifyInstallDir() --
the expected paths exist and are non-empty -- and nothing more. Neither is
chosen by protocol, and what they declare is reported downstream to the update
check rather than gating them here: an override or a system install is taken on
the authority of whoever put it there, and a system install predating
protocol.json still resolves and reports the legacy empty protocol the update
check already handles.

A session resolves once and holds the answer for the process lifetime, so an
install elsewhere never changes what it is executing. Its own install clears
the pin so the components it restarts come back on the new version.
getInstalledVersion() and getInstalledProtocolVersion() report from the
pinned install.

Install

installPackage() and performInstall() become download -> verify SHA-256 ->
stage -> publish a slot -> select it. A version already on disk in a verifying
slot skips the download and just updates the selector.

The ai.prev backup and every restore branch are gone: a slot only reaches a
final name after allocateSlot() has recorded its manifest and verified the
result, so there is no torn install for a backup to restore.

The backend and agent are stopped after the install rather than before it.
Nothing on disk is mutated, so stopping is only about picking up the new
version -- and a failed install now leaves a working assistant running. The
waitForOwnComponentsReaped() reap-wait and its "a process is still shutting
down" failure path go away with the reason they existed.

The download is SHA-256 checked against the manifest entry for this protocol,
but the extracted package's own declared version and protocol are still checked
before anything is published: a mis-published package would otherwise write
another protocol's selector entry, changing what a different RStudio release
resolves, and report an update this session cannot run.

Verification replaced, not duplicated

verifyPositAiInstallation() and the package.json / protocol.json readers
in ChatInstallation.cpp are deleted rather than left beside the slot
equivalents. The existence-only check they implemented accepted a zero-byte
main.js; verifyInstallDir() does not, and slots::verifySlot() builds the
manifest-backed check on top of it. ChatInstallationTests.cpp is reworked
around the new surface.

Playwright sandbox

PW_SEED_PAI trees are now laid out the way an install leaves them --
versions/<version> carrying its own slot manifest, named by selected.json
-- because a versioned-aware RStudio never reads the unversioned pai/bin. A
bare copy would resolve to nothing and the suite would silently download and
test the official package instead of the build that was asked for. The seed's
own bin/ is not copied for the same reason, and the version-under-test report
follows the selector rather than a fixed path.

check-for-updates-command.test.ts needs no change: it drives the update-check
dialogs and dismisses before any install.

Decision: the lost-selection downgrade case is accepted

The selector is advisory and selectSlot() is an unserialized
read-modify-write, so two sessions recording different protocols at once can
drop an entry. Resolution recovers by converging on the newest verifying slot
for the protocol, not on what the entry said. That is the same answer while a
selection only records the version just installed, but this PR wires up the
manifest-serves-a-lower-version case (isVersionDowngrade), where a lost entry
resolves up to a newer slot.

Accepted, not made durable. It needs two sessions on different protocols
installing in the same instant; the session then runs a newer package the same
protocol already accepted; and the next update check re-selects the manifest's
version with no download, since it is still on disk. Making it durable would
mean either serializing the selector write -- locking, which this effort exists
to remove -- or recording a "prefer the older one" intent inside the slot,
which is the retention policy #18658 defers to the manage-installs work.

Deviation from the task's recommended split

waitForOwnComponentsReaped() is deleted here rather than with the lock in
PR 4. It is a free function in an anonymous namespace, so leaving it unused
would emit -Wunused-function. ChatInstallLock and the MutationScope call
site stay for PR 4.

The Windows access-denied install message ("close all other instances of
RStudio and try again") is also gone: it described a directory swap losing to
another session's open handles, which no longer happens, so the advice would be
wrong.

Testing

  • rstudio-tests --scope rsession: 537 pass. New coverage for each resolver
    source in isolation, precedence between them, a present-but-unverifying
    source falling through, the pin being held and cleared, reporting from the
    resolved install, and the staged -> published -> selected sequence composing
    into something the resolver returns. selectInstalledVersion() covers
    skip-if-already-installed, including a reinstall slot matched by the version
    it holds rather than its name.
  • A ChatSlots test pins the manifest wire format the TypeScript seeder
    writes, so a change to the format fails a build rather than quietly making
    every seeded run download the official package.
  • Ran open-chat-pane.test.ts and check-for-updates-command.test.ts against
    a dev server with PW_SEED_PAI set: 11 passed. The preserved sandbox held
    pai/versions/1.2.2 and selected.json and no pai/bin, and the backend
    started from the slot.

Note for the assistant repo

npm run deploy:rstudio writes ~/.local/share/rstudio/pai/bin, which a
versioned-aware RStudio no longer reads. Developers can point
RSTUDIO_POSIT_AI_PATH at that directory (source 1), or the deploy script can
be taught to write a slot -- worth a follow-up there.

Replace the single pai/bin installation with the ordered source list from
the versioned-installs design: RSTUDIO_POSIT_AI_PATH, then the per-user
pai/versions slots chosen by protocol through selected.json, then the
admin-managed system install. Each source is a separate function so the
list can be gated and extended without disturbing the others.

An install now downloads, verifies, extracts into a private staging
directory and publishes a slot, then records it in the selector. Nothing
already on disk is modified, so the ai.prev backup and every restore
branch are gone, and the backend is stopped after the install rather than
before it -- a failed install leaves a working assistant running. A
version already on disk in a verifying slot skips the download and just
updates the selector.

Resolution happens once per session and is pinned for the process
lifetime, so an install in another session never changes what this one is
executing; the pin is cleared when this session's own install publishes a
slot. The existence-only verifyPositAiInstallation() is replaced by
verifyInstallDir(), which also rejects the zero-byte main.js a truncated
extraction leaves behind, and by the manifest-backed slot verification for
the versioned source.

Addresses #18658
PW_SEED_PAI trees are laid out the way an install leaves them --
versions/<version> carrying its own slot manifest, named by selected.json
-- because a versioned-aware RStudio never reads the unversioned pai/bin.
A bare copy would resolve to nothing and the suite would silently
download and test the official package instead of the build that was
asked for. The seed's bin/ is not copied for the same reason.

The version-under-test report follows the selector rather than a fixed
path, and a sandbox-layout test asserts the seeded shape. A C++ test
pins the manifest wire format the TypeScript seeder writes, so a change
to the format fails a build rather than quietly degrading seeded runs.

Addresses #18658
The archive is SHA-256 checked against the manifest entry chosen for
this protocol, so a package declaring another version or protocol is
mis-published rather than corrupt -- but installing it anyway recorded a
slot against a different protocol's selection, changing what another
RStudio release resolves, and reported an update this session could not
run and would be offered again on every check.

Report install failures through the error description rather than
getMessage(), which for these errors is only the bare errno string.
@gtritchie gtritchie added this to the 2026.09 (Autumn Hawkbit) milestone Aug 28, 2026
A package version is not a path. The seeder used it as one, so a
malformed or hostile version wrote the tree outside versions/ and
recorded a selector entry RStudio ignores -- which fails as a silent
download of the official package rather than as a broken seed. Reject a
version that cannot name a slot, using the same rules as
slots::isUsableSlotName().

Report all selected installs rather than the first. A seed the IDE finds
incompatible leaves two selector entries, and which one the session ran
depends on the protocol compiled into the IDE, which is not readable from
disk -- so naming a single build was liable to name the one that was not
under test.

Add a harness self-test for the seeder, so a drift in what it produces
fails there rather than degrading every seeded run.
@gtritchie

Copy link
Copy Markdown
Member Author

Closing: too risky to land against the current release timeline. The branch feature/pai-versioned-installs-wire is left in place, so this can be reopened or rebased when there is room for it.

State at close: three commits (resolver switch + install rewrite, Playwright slot seeding, two rounds of review fixes). 537 rsession tests pass, and the seeded layout was verified end to end against a dev server. One open question is recorded in the PR discussion -- getPackageInfoFromManifest() matches the highest minor within a major while every other protocol comparison matches exactly. That inconsistency predates this branch and is unreachable while only .0 minors are published.

@github-actions

Copy link
Copy Markdown

RStudio E2E - all platforms

All tests passed!

#################### 100% pass rate

Passed Failed Skipped Flaky
2540 0 187 4
Platform ✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
✅ auth-teardown 2 0 10 0
✅ desktop-linux 635 0 39 1
✅ desktop-macos 641 0 34 1
✅ desktop-windows 639 0 40 2
✅ server-linux 595 0 44 0
✅ setup 28 0 20 0
View / download the full report

View report online -- opens in the browser, no download needed. Available for 14 days.

Download playwright-report.zip -- extract and open index.html

Includes screenshots, traces, and step-by-step details for every test. Expires in 15 days.


All platforms - commit 5ef8784190b1106afd7686c25648af2275b660da - Run #740

This branch was previously deployed

1 inactive deployment
e2e-playwright — 5ef87841 Deployed Aug 28, 2026 by gtritchie via windows / e2e-desktop-windows (3) #740
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant