Skip to content

Add slot, manifest and selector machinery for versioned Posit AI installs - #18666

Merged
gtritchie merged 14 commits into
mainfrom
feature/pai-versioned-slots
Aug 28, 2026
Merged

gtritchie merged 14 commits into
mainfrom
feature/pai-versioned-slots

Conversation

@gtritchie

@gtritchie gtritchie commented Aug 27, 2026 •

Copy link
Copy Markdown
Member

PR 2 of the five-PR sequence in #18658. Pure addition under src/cpp/session/modules/chat/ — no existing call site changes, and nothing is wired up. The resolver switch and install rewrite are PR 3, deleting ChatInstallLock is PR 4, the Reinstall button is PR 5.

What lands

ChatSlots — slot allocation and verification.

The install API is prepareStagingDir → extract → allocateSlot. allocateSlot() records the slot manifest, verifies the result, and only then renames the staged tree into pai/versions/<version>, or <version>-2, -3, ... when that name is taken. Recording and verifying inside the call rather than asking callers to do it first means "a slot only reaches a final name once it has been checked" holds by construction, not by an ordering each install path has to remember.

Slot names are never read for identity. The name comes from the staged package's own package.json, and a slot is adopted only when it verifies and declares the same version and protocol as what was staged — a directory named 1.1.0 is not evidence that it holds 1.1.0. SlotPolicy::AlwaysFresh never adopts, which is what PR 5 needs.

isUsableSlotName() gates both untrusted sources of a name (the archive's package.json and selected.json), rejecting anything that cannot round-trip as a directory name. The Windows rules are applied on every platform so a home reached from both Windows and Linux agrees on which names are slots.

prepareStagingDir() returns a directory no other session can name. See the deviation note.

verifySlot() requires the expected paths to exist and be non-empty, package.json to parse with a version, protocol.json to parse with a protocol, the slot not to be a link, and every manifest entry to be intact. The check it replaces in PR 3 tests only that three paths exist, so a zero-byte main.js passes it.

ChatSlotManifest — relative path to size and SHA-256 for every regular file in a slot, recorded after extraction while the tree is known to match the verified package. Verification compares sizes only, so it stays a stat walk cheap enough to run at every resolve; the hashes are recorded for a deeper check later, as the issue specifies. Symlinks are excluded and paths reached through a symlinked or junction-backed directory are rejected, so a slot cannot come to depend on a tree it does not contain.

ChatSelector — pai/selected.json, holding {"selected": {"11.0": "1.1.0-2", "10.0": "0.4.8"}}. Read, write (temp file then rename, last-writer-wins), and the fallback: when the named slot is missing, unusable, or serves another protocol, resolution picks the best verifying slot for the protocol and records it. Ordering is release version, then a release over a prerelease of it, then — only between slots holding the very same version — the later reinstall.

Legacy pai/bin is not read, written, or deleted. There is no garbage collection; slots accumulate, as the issue specifies.

One deviation from the issue text

The issue specified staging at pai/versions/.tmp-<pid>/, cleared first. This PR uses a unique name per install (.tmp-<host>-<pid>-<nonce>) and clears nothing. Two sessions sharing an NFS home can compute the same pid-based name — under container runtimes they routinely do, since each session pod has its own PID namespace and low pids repeat — and the second session's prepare would delete the first's half-extracted tree. Because the manifest is recorded from whatever is on disk when it runs, the victim would record a manifest describing the damage, verify it against itself, and publish a truncated slot that keeps verifying forever.

The issue body has been updated to match, with the reasoning in this comment.

Testing

91 new unit tests: rename arbitration and adoption (including refusing to adopt a different version or protocol), forced mode, ordinal allocation past -2 and past -9, staged installs being unresolvable and not disturbing each other, name validation from both sources, manifest round trip, symlink and junction hardening, every verification failure mode separately, selector round trip, and fallback and repair including absent or malformed selected.json.

cmake --build build --target rsession
./build/src/cpp/rstudio-tests --scope rsession    # 519 tests, all passing

No NEWS.md entry: nothing user-visible ships until PR 3, so the versioned-install entry lands there.

Addresses #18658.

…alls

Groundwork for installing Posit Assistant side by side under
pai/versions, as a pure addition: nothing calls into these modules yet.

ChatSlots allocates a directory per installed package version. A staged
install is renamed from a sibling .tmp-<pid> directory to <version>, or
to <version>-2, -3, ... when that name is taken; the rename is the only
arbiter, so concurrent installers cannot corrupt each other. The loser
of a race adopts an existing slot that verifies, or takes the next name.
A forced mode never adopts, which is what Reinstall will need.

ChatSlotManifest records relative path, size and SHA-256 for every file
in a slot after extraction, while the tree is known to match the
verified package. Verification compares sizes only, so it stays a stat
walk; the hashes are recorded for a deeper check later.

Slot verification requires the expected files to exist and be non-empty,
package.json to declare a version, protocol.json to declare a protocol,
and every manifest entry to be intact. The old check passed a zero-byte
main.js.

ChatSelector reads and writes selected.json, which names the active slot
per protocol. When the named slot is missing or fails verification,
resolution falls back to the newest-versioned verifying slot for the
protocol and repairs the entry, so a dropped or malformed selector heals
itself.

Addresses #18658.
@gtritchie gtritchie added this to the 2026.09 (Autumn Hawkbit) milestone Aug 27, 2026
Two fixes from review of the slot machinery.

allocateSlot() took the version as a parameter and adopted any existing
slot whose name matched, which reads a directory name as evidence of its
contents -- the one thing the versioned layout says never to do. A slot
named 1.1.0 holding 1.0.4 would be adopted and selected, leaving the
session on a version nobody asked for. It now derives the version from
the staged package's own package.json and adopts only a slot that
verifies and declares the same version and protocol.

allocateSlot() also verifies the staged tree before publishing it, so
"a slot only reaches a final name once it has been checked" holds by
construction rather than by every install path remembering to check.

Staging directories were named for the pid alone. Machines sharing an
NFS home hand out the same pids, so one session could delete another's
in-flight extraction. They are now named for host and pid, which is
unique among live sessions but still reclaimable once a session is gone.

Slot names must also be printable ASCII, since the version naming them
comes from a downloaded archive.

The test fixture pasted versions into JSON unescaped, so the case meant
to reject a backslash was really testing an unparseable package.json. It
now encodes backslashes and control characters.

Addresses #18658.
getHostname() returns an empty string when HOSTNAME is unset and
gethostname() fails, which named every such session ".tmp--<pid>" and
put them straight back into the pid-only collision the hostname was
added to avoid. It now falls back to a placeholder.

The hostname was also capped at 64 characters, short enough that two
long hostnames sharing a prefix would collapse onto one name. The cap is
now 200, which still leaves the ".tmp-" prefix and the pid inside the
255-byte limit on a path component but is longer than any real hostname.

Documents why the staging name is reusable rather than random: reuse is
what reclaims a crashed session's extraction and what leaves a later
cleanup pass a name it can test for liveness, and the residual case
costs a failed install rather than a damaged slot.

Adds a test that a staged install is invisible to verifiedSlots() when
the directory is named by prepareStagingDir() rather than by hand, so
the name and the rule that hides it cannot drift apart.

Addresses #18658.
Staging directories were named for host and pid, which two sessions
sharing an NFS home can compute identically -- and under container
runtimes routinely do, since each session gets its own PID namespace and
low pids repeat across pods. The second session's prepare then deleted
the first session's half-extracted tree.

That is worse than a failed install. The install-time manifest is
recorded from whatever is on disk when it runs, so a tree mutated before
that point is described by the manifest rather than caught by it. The
first session would record a manifest of the second's partial
extraction, verify it successfully against itself, and publish a
truncated slot that goes on verifying for the rest of its life.

The name now carries a random nonce, so no other session can compute it
and nothing can write into a tree between extraction and the manifest.
Host and pid stay in the name for a later cleanup pass to identify
abandoned extractions by; they no longer carry any correctness weight.

Nothing is reclaimed by name any more. An interrupted install leaves its
extraction behind, joining the orphans the issue already expects a
manage-installs effort to collect. Reclaiming by name cannot be made
safe: any directory a session deletes because it looks abandoned may
belong to a live peer, which puts the same corruption on the other side.

Addresses #18658.
The selector fallback broke ties between slots of one version with a
string compare on the slot name, which ranks "1.1.0-9" above "1.1.0-10".
A user who reinstalls to escape corruption verification cannot detect --
the case SlotPolicy::AlwaysFresh exists for -- gets 1.1.0-10; if the
selector is then lost, the fallback hands back 1.1.0-9, the corrupt slot
the reinstall was meant to abandon, and records it.

Ties now compare the ordinal numerically. This is the one place a slot
name is read, and only to order slots that are otherwise identical.

Ordering also compared versions through SemanticVersion::parse, which
converts each dot-separated component with boost::lexical_cast and so
rejects any version carrying a prerelease suffix. A slot declaring
"1.2.0-beta.1" therefore lost to a "0.0.1" slot unconditionally.
Comparison now uses the release portion of the version, and a release
outranks a prerelease of the same version as semantic versioning has it.

Addresses #18658.
Neither source of a slot name is trusted: one comes from the package.json
of a downloaded archive, the other from a file in the user's home.

resolveSlot() passed the recorded name straight to completeChildPath().
A dot-prefixed entry resolved a staging directory -- which verifies,
being a complete tree, right up until its owner renames it away
underneath the running backend -- and a traversal or empty entry handed
back the versions directory itself, because completeChildPath() assigns
the parent when it rejects an escape. Selections are now checked before
use, so rejection is by intent rather than by verifySlot happening to
fail on whatever came back.

isUsableSlotName also missed names Windows rejects or rewrites. A
trailing dot or space is dropped silently, so the directory on disk
would not be the name recorded in the selector, and on a home shared
with Linux sessions the two are separate directories; reserved device
names and *?"<>| failed only at rename time with an opaque OS error
after a full extraction. The Windows rules are checked on every platform
so a shared home agrees on which names are slots, which is also why this
does not use file_utils::isWindowsReservedName -- that is compiled only
on Windows.

Addresses #18658.
isRegularFile(), getSize() and readStringFromFile() all follow symlinks,
so a symlink inside a slot was recorded with its target's size and hash
and then verified against that target. A slot that is supposed to be
immutable and checked once would instead depend on a mutable file
outside the versions tree: swapping the target for a same-size file
passes verification, and a change in the target's size permanently fails
an otherwise intact slot.

collectEntries now skips symlinks, and matchesSlotManifest treats a
recorded path that has become one as missing. Skipping rather than
rejecting matches what a symlinked directory already gets, since the
recursive iterator does not descend into one.

Reachability is narrow -- R's internal unzip() materializes archive
symlink entries as regular files, so the package cannot plant one, and a
symlink only enters a slot if something writes it directly.

Addresses #18658.
allocateSlot verified the staged tree, but the manifest that verification
checks only existed if the caller had separately called
writeSlotManifest after extracting -- an ordering carried by comments and
test fixtures alone. Forgetting it fails every install with "not a
complete Posit Assistant installation" despite a perfect extraction,
which is precisely the "rule every install path has to remember" the
adjacent comment claimed the design had eliminated.

allocateSlot now records the manifest itself before verifying. The
staging directory is private to the call, so the tree being recorded is
the one just extracted, and the install API shrinks to prepare, extract,
allocate.

Addresses #18658.
prepareStagingDir's @return promised "an error if the directory could
not be cleared or created", but nothing is cleared any more -- the same
doc block says so two paragraphs up. A maintainer trusting the phantom
clearing could reuse a fixed staging name, sweeping stale files from an
aborted extraction into the manifest, which is the corruption the nonce
exists to prevent.

The comment above kMaxHostnameLength asserted getHostname() reads at
most 255 bytes. Only its gethostname() fallback is capped; the HOSTNAME
environment variable is returned verbatim. The truncation is what
actually bounds the name, so the comment now says that rather than
inviting someone to remove it.

ChatSelector's header said a selection lost to a concurrent writer "is
recovered by the next resolveSlot()". Resolution converges on the newest
verifying slot for the protocol, which is the same answer only while a
selection records the version just installed. Both places now state what
recovery actually does, so the difference is visible when a later change
gives a selection some other intent to carry.

Addresses #18658.
The ordinal counts reinstalls of one version, so comparing it between
slots holding different versions is meaningless: "1.2.0-beta.1-10", the
tenth reinstall of beta.1, outranked the newer "1.2.0-beta.2". Ordinals
are now compared only when the two version strings are identical.

Build metadata was also treated as a prerelease suffix, so
"1.2.0+build.1" lost its release precedence and could rank below
"1.2.0-beta.1". Only a '-' that precedes any '+' now marks a prerelease.

The remaining string comparisons are documented for what they are -- a
stable arbitrary order, not semantic-version precedence, which would
need identifier-by-identifier comparison to tell beta.9 from beta.10.
Nothing published for RStudio carries a prerelease suffix.

Addresses #18658.
Windows resolves CON, NUL, COM1 and friends whatever follows them, so
"nul.txt" and "com1.log" name the device just as "nul" does. The check
compared the whole name and let those through, to fail later at rename
time with an opaque OS error. It now compares the part before the first
dot. No real version can collide, since none of the reserved names
starts with a digit.

Addresses #18658.
Checking only the recorded file left the hole one level up: replacing an
ancestor directory with a symlink makes the recorded path resolve
outside the slot while the leaf is still an ordinary file of the
recorded size, so verification passed and the "immutable" slot went on
depending on a tree it does not contain.

Every directory between the slot and a recorded file is now checked.
Cleared directories are remembered, so a deep tree costs one check per
directory rather than one per file in it, keeping verification a stat
walk cheap enough to run at every resolve.

Addresses #18658.
The comment said 180 characters is longer than any real hostname and
then noted in the same breath that a hostname can reach 253. It now
describes the cap as the path-length budget it is, and says plainly that
two long hostnames can share a prefix -- harmless, because the nonce is
what keeps staging directories distinct.

Addresses #18658.
Two gaps left by the ancestor check. The slot directory itself was never
examined, so replacing pai/versions/1.1.0 with a link to an external
tree let everything in it, manifest included, be read from somewhere the
slot does not contain and cannot promise is immutable. verifySlot now
rejects that, which covers both resolution and the staged tree.

Ancestor directories were tested with isSymlink() alone. Windows
redirects a directory with a junction, which is_symlink() does not
report -- that is why FilePath carries isJunction() at all -- so both
are now checked.

The junction path has no test here: junctions exist only on Windows and
the symlink coverage is POSIX-only.

Addresses #18658.
@github-actions

Copy link
Copy Markdown

RStudio E2E - all platforms

All tests passed!

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

Passed Failed Skipped Flaky
2431 0 152 0
Platform ✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
✅ auth-teardown 2 0 10 0
✅ desktop-linux 603 0 31 0
✅ desktop-macos 609 0 26 0
✅ desktop-windows 609 0 31 0
✅ server-linux 582 0 44 0
✅ setup 26 0 10 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 bc35e91c158f1c49c203ae9b76401b307f17916e - Run #731

@gtritchie
gtritchie merged commit 98adde4 into main Aug 28, 2026
29 checks passed
@gtritchie
gtritchie deleted the feature/pai-versioned-slots branch August 28, 2026 01:18
gtritchie added a commit that referenced this pull request Sep 23, 2026
* Give the slot selector a read-only mode and drop prerelease ordering

The administrator's storage directory carries the same selected.json as
the user's, but RStudio never writes there, so resolveSlot() now takes a
SelectorRepair argument: Enabled records the fallback as before, Disabled
resolves through the same fallback without touching the file. Before this
every resolve against a read-only /etc/rstudio would have tried the
repair, failed, and warned.

preferredOver() no longer parses a release portion out of a version or
ranks releases above prereleases. Posit Assistant versions are plain
x.y.z and every other parser site rejects a suffixed one, so the selector
was the one place that accepted them. What remains is: parse, compare,
then reinstall ordinal, then name. The four tests that pinned the
prerelease handling go with it, replaced by one that pins an unparsable
version ranking below every parsed one.

selectInstalledVersion() records a slot that already holds the requested
version for a protocol, which the install path uses to skip the download
when the target version is already on disk.

Three small fixes to the slot machinery, found on re-review:

- allocateSlot() retries the publish rename briefly while the target
  name is still free. On Windows, antivirus or the indexer can hold a
  handle inside a freshly extracted tree and MoveFileEx fails with
  access denied for a moment; that used to orphan the staging directory.
- The hostname in a staging directory name is capped at 32 characters
  rather than 180. The nonce carries the uniqueness, and the long cap
  only pushed deep dist/client/assets/ paths towards MAX_PATH.
- verifiedSlots() skips any entry isUsableSlotName() rejects, not only
  dot-prefixed ones. A hand-made directory with a trailing space was
  otherwise recorded as the fallback, rejected on the next read, and
  recorded again on every resolve.

Also adds the test that resolveSlot() still returns the fallback when the
storage directory cannot be written, which the read-only system tier
depends on.

Addresses #18658.

* Prefer the latest reinstall when re-selecting an installed version

selectInstalledVersion() took the first slot the directory listing
yielded that held the requested version. After a reinstall two slots
hold one version, and the later one exists precisely because the earlier
one is suspect, so re-selecting the version could hand the older slot
back and undo the reinstall.

It now picks the preferred matching slot by the same order the fallback
uses (later reinstall ordinal first), and leaves a selection that already
names a slot holding the version as it is.

Addresses #18658.

* Resolve Posit Assistant from versioned install slots

The slot machinery merged inert in #18666 is now what the session runs
from. ChatInstallation resolves from four sources: the user's slots under
pai/versions (chosen by protocol through the user's selected.json, which
a stale entry repairs), the administrator's slots under the system
config directory's pai/versions (chosen through the administrator's
selected.json, which is never rewritten), the administrator's legacy
pai/bin, and the bundled copy. They race as #18774 established --
compatible protocol first, then highest version, ties in that order --
and posit-assistant-path stays outside the race. The user's legacy
pai/bin is never read: older releases still mutate it, and reading it
would re-import the corruption the layout removes.

The session resolves once, lazily on first need, and holds the answer.
The backend start, the agent start, the asset handler and its
Content-Security-Policy, and every report of the installed version and
protocol read that one resolution, so they cannot drift onto different
installations. It is re-checked structurally on each read, so an
installation removed out of band is resolved around, and it is cleared
by exactly one thing: this session's own successful install. An install
made elsewhere takes effect at the next session start. The separate
static-file pin from #18832 is gone; the CSP cache is keyed on the
installation being served, so it still follows a change of resolution
that no backend start accompanies.

The install path is now download, verify SHA-256, extract into a
private staging directory, check that the extracted package declares
the requested version and this build's protocol, publish it as a slot,
select it, and only then stop the backend and agent so they restart on
the new slot. A version already on disk in a verifying slot skips the
download and is just re-selected. Nothing already on disk is modified,
so the ai.prev backup and its restore branches, the stop-before-install
reap-wait with its "still shutting down" failure, and the Windows
"close all other instances" message are gone. A package without
protocol.json is refused rather than backfilled, so
writeProtocolVersionFileIfMissing() is deleted.

verifyPositAiInstallation() and the package.json/protocol.json readers
are replaced by verifyInstallDir(), declaredVersion() and
declaredProtocol(), which slots::verifySlot() now builds on, so there is
one definition of a runnable installation. The lock call sites stay for
the follow-up PR that removes the locking.

Addresses #18658.

* Seed the Playwright sandbox as a versioned Posit Assistant install

A versioned-aware RStudio never reads pai/bin, so a PW_SEED_PAI tree
copied as-is would resolve nothing and the @ai suite would download the
official package instead of the build that was asked for. globalSetup
now lays the seed's bin/ out as a version slot with its install
manifest, selected for the protocol it declares (fixtures/pai-seed.ts,
mirroring the C++ wire format). Any versions/ or selected.json beside
the seed's bin/ belong to the machine's own installs and are not
copied.

Each per-spec data home gets its own pai storage directory provisioned
from the seed -- selected.json and the shared state copied, the slots
hardlink-cloned -- instead of a symlink to it. An install run by the
session under test publishes a slot and rewrites selected.json where it
resolves, which through the link was the seed every other spec reads.

The version-under-test report follows the selector rather than reading
bin/package.json, and reports every selected install because which one
the session ran depends on the protocol compiled into the IDE.

Addresses #18658.

* Document the versioned Posit Assistant layout

The user guide's removal section now describes what pai holds after
this change -- one directory per installed version under versions/,
selected.json, and a bin/ only if an earlier release installed there --
and that installs add directories and remove nothing. The ai.prev note
is attributed to earlier releases, which are the only ones that create
it. NEWS entry for #18658.

Addresses #18658.

* Refuse a PW_SEED_PAI build RStudio could not run

inspectSeed() checked only the identity files, so a stale or partial
build -- a missing or zero-byte main.js or index.html -- was laid out
as a selected slot that RStudio then rejected, and the run downloaded
the official package without saying so. It now applies the same
structural check as installation::verifyInstallDir() before anything is
written, and the harness spec covers a missing and an empty required
file.

Addresses #18658.

* Describe selected.json as a selection, not the running version

The administrator's selected.json chooses which slot the system-wide
installation offers; the newest compatible copy among the user's, the
system-wide and the bundled one still wins, and posit-assistant-path is
what pins one outright. The NEWS entry now says so. The user guide's
description of pai now calls the version directories installs (a
reinstall adds a suffixed one) and selected.json a per-protocol record
of what was selected rather than the version in use.

Addresses #18658.

* Stop pointing manual installs at pai/versions

A directory under pai/versions is only used when it carries the slot
manifest an install writes, so a package extracted there by hand is
skipped. The NEWS entry said an administrator could provide versions
"the same way", and the not-found error told users to install into
their own pai/versions; both described something that does not work.
The release note now names the manifest requirement, and the error
points at the in-product install and the system-wide location.

Addresses #18658

* Name the legacy bin directory in the not-found message

Without a pinned path the message named the system pai directory
itself, which the resolver never reads directly: it reads versions/
slots, which need the manifest an install writes, and the legacy bin
child. Name pai/bin, the one system location an administrator can
populate by hand, as the message did before the versioned layout.

Addresses #18658

* Match the manifest protocol entry exactly

The manifest lookup matched on major version and took the highest
minor, while the mismatch check, the selector and the install identity
check all compare the protocol string exactly. A manifest entry for a
higher minor (11.1 on an 11.0 build) was therefore offered as an update
and then refused by the install, each attempt downloading the package
again and leaving an extracted copy in pai/versions.

Protocol versions are published as <major>.0 and nothing else, so the
lookup now reads the entry for the exact protocol string; an entry of
any other form is warned about, since it can never be selected. A test
pins kProtocolVersion to that form so a stray minor fails the build's
tests rather than surfacing as a failed install.

Addresses #18658

* Report an unusable manifest entry as protocol_not_supported

The exact-match lookup returned bad_message or a readObject error when
the entry for the protocol was not an object or lacked version or url.
The update check only treats protocol_not_supported as "nothing to
offer", so a fresh installation facing such an entry was reported as
current instead of as having no compatible version, as it was when the
old loop skipped the entry. Every unusable-entry path now returns
protocol_not_supported, and a test pins the code for each.

The <major>.0 warning used SemanticVersion::parse, which accepts "11",
"v11.0" and "11.0.0". isProtocolVersionForm() is a textual check shared
by the manifest warning and the kProtocolVersion test.

Addresses #18658

* Check package identity in the installation module and discard failed staging

installPackage() left its staging directory behind when extraction, the
version/protocol identity check or slot allocation failed. The directory is
this call's own (no other session can name it), and after an identity
mismatch the same update is offered again, so each retry added an orphaned
tree under pai/versions. The three error returns now remove it.

The identity check moves to chat_installation::verifyDeclaredIdentity() so
its error paths have unit tests: version mismatch, protocol mismatch, a
package without protocol.json, and one without package.json.

ChatIntegrity.GetPackageInfoErrorsOnInvalidProtocolVersion is deleted: since
the lookup became an exact match it only repeated the absent-key case that
GetPackageInfoUnusableEntryReportsProtocolNotSupported covers.

Addresses #18658

* Filter slots by protocol before walking their manifests

verifiedSlots() ran the full manifest check (one stat per recorded file) on
every slot and only then did its callers drop the ones for another protocol.
When no slot serves the current protocol nothing is selected, an empty
resolution is not held, and the walk repeated on every resolve, growing with
the slots left by earlier protocols. The protocol is now read first and
slots declaring another one are skipped for the cost of one small read.

Addresses #18658

* Use positAiStorageDir() for the manifest-check state path

manifestCheckStatePath() built userDataDir()/pai by hand; positAiStorageDir()
is the one definition of the storage root.

Addresses #18658

* Shorten the #18658 NEWS entry

The layout detail lives in the user guide; the entry keeps what a user
notices.

Addresses #18658

* Apply the protocol filter inside the slot verifier

verifiedSlots() read protocol.json before verifySlot() had rejected a
symlinked or junction slot, so the filter followed a link into a tree the
slot does not contain, and the protocol was read twice, once to filter and
once to fill the SlotInfo. The filter now runs inside the verifier after the
link and directory checks, and the protocol is read once, so the slot
returned is the one that was checked.

Addresses #18658

* Read the slot protocol before the other verification steps

verifySlotForProtocol() compared the protocol only after verifyInstallDir()
and the package.json read, so a slot for another protocol still cost four
stats and a parse, against the header's promise of one small read. The
protocol is now read and compared right after the directory and link checks.

Addresses #18658

* Say that the first install after upgrading re-downloads Posit Assistant

The versioned layout does not adopt an existing pai/bin, so the NEWS entry
states the one-time download.

Addresses #18658

* Say installPackage() leaves installations, not all files, untouched

selectSlot() rewrites selected.json, so "nothing already on disk is
modified" overstated it.

Addresses #18658

* Drop installPackage()'s version out-parameter

verifyDeclaredIdentity() guarantees the published slot declares the
requested version, so the parameter only echoed its input.

Addresses #18658

* Fail the install when the assistant agent does not stop

finishInstall() only warned when stopAgentForUpdate() timed out, then
cleared the held resolution and reported Complete, so the backend restarted
on the new slot while the agent could still be running from the old one. It
now reports the install as an error asking for a retry and leaves the
resolution alone; the retry finds the version installed and repeats only
the stop.

Addresses #18658

* Report the resolved version after an install, not the requested one

finishInstall() recorded the installed version as current, but a read-only
source can outrank the new user slot, and the throttled update check uses
that value as its baseline. It now reads the version the session resolves
after the held resolution is cleared.

Addresses #18658

* Clear the test backend port before restoring the real search paths

The fixture restored the session's search paths first, so clearing the port
rebuilt the CSP header by resolving against the real user storage with
selector repair enabled, and a test run could rewrite the selector of the
machine running it.

Addresses #18658

* Compare reinstall ordinals only within one version string

preferredOver() compared ordinals across two unparsed versions that differ,
so the tenth reinstall of one could outrank a later other. Differing
versions are ordered by string first, as they were before the prerelease
handling was removed, and the test returns.

Addresses #18658

* Build the CSP header from the installation the handler resolved

An HTML request resolved the installation three times: in the handler, in
buildCspHeader() and in rebuildCspHeaderCache(). An install landing between
them could serve one slot's page under another's policy. The handler's
resolution is now passed through both, which also drops the two extra
resolves.

Addresses #18658

* Retry the publish rename on Windows only

The retry exists for antivirus and indexer handles on Windows. On other
platforms a rename between siblings either works or fails for good, so ten
attempts a second apart only delayed the error on the main thread.

Addresses #18658

* Check the managed-mode warning flag before resolving the user slot

With user installs disabled and nothing installed anywhere, every locate
resolved the user's slots to decide whether to log a warning that had
already been logged, because RS_ONCE() was evaluated last.

Addresses #18658

* Leave the seed's locks directory out of the sandbox

A real pai used as PW_SEED_PAI carries the machine's live in-use lock
entries, which could make installs in every sandbox refuse.

Addresses #18658

* Run a post-check install from the scheduler, not inside the poll

When the main thread's own process-supervisor poll reaps the manifest
fetch, the check's completion runs inline inside that poll, so an install
queued behind it called finishInstall() there. Its agent stop waits on the
same poll, which is a no-op when re-entered, so the wait could never reap
the agent and, since the timeout now fails the install, would fail it for
nothing. The install is scheduled as delayed work instead, which runs after
the poll has returned.

Addresses #18658

* Return the rebuilt CSP header under the rebuild lock

buildCspHeader() released the lock after rebuilding and re-took it to copy
the cached header, so a rebuild for another installation in between would
have been returned for this request. rebuildCspHeaderCache() now returns
the header it built.

Addresses #18658

* Do not sleep after the final publish attempt

With a single attempt outside Windows, a failed rename still slept 100 ms
before returning its error.

Addresses #18658

This branch was previously deployed

1 inactive deployment
e2e-playwright — bc35e91c Deployed Aug 28, 2026 by gtritchie via windows / e2e-desktop-windows (6) #731
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