Skip to content

Add a setting to disable user-managed Posit Assistant installs - #18691

Merged
gtritchie merged 19 commits into
mainfrom
feature/18443-disable-user-pa-installs
Aug 30, 2026
Merged

gtritchie merged 19 commits into
mainfrom
feature/18443-disable-user-pa-installs

Conversation

@gtritchie

@gtritchie gtritchie commented Aug 30, 2026 •

Copy link
Copy Markdown
Member

Adds an administrator setting that turns off user-managed installation of Posit Assistant. Default is today's behavior. When disabled, the session uses only an administrator-managed or bundled installation, ignores any user-level copy, makes no manifest requests, refuses the install/update/uninstall RPCs, and hides the corresponding UI.

Two surfaces:

  • posit-assistant-installation-enabled in rsession.conf (default 1), in the pai group beside posit-assistant-enabled. Honored everywhere rsession.conf is read, including open-source RStudio Server.
  • RSTUDIO_DISABLE_POSIT_ASSISTANT_INSTALLATION (non-empty = disabled), mirroring RSTUDIO_DISABLE_POSIT_ASSISTANT. Desktop only, since rserver builds each session's environment from scratch rather than passing its own down.

Both are read by one helper, module_context::isPositAssistantInstallationEnabledByAdmin(), so no gate hand-syncs the logic.

Not an allow-* option

The issue specified allow-posit-assistant-installation in the allow group. That turned out to be wrong: generate-options.R emits value || allowOverlay() for every bool in that group, and open-source builds define allowOverlay() as unconditionally true, so the option would have been force-allowed everywhere except Posit Workbench. It has to work in open-source Server, so it is a regular option in the pai group instead — the same reason posit-assistant-enabled lives there rather than beside allow-posit-assistant.

RSTUDIO_POSIT_AI_PATH is the other half of that story: as a plain environment variable any user could set in .Renviron, it would have made the setting decorative.

Session side

  • Resolution skips the user data tier when installs are managed, inside locatePositAssistantInstallation() — the single point both the chat backend and the NES agent go through. A leftover user copy is ignored, never removed, and logged once per session because it silently changes which version runs.
  • chat_install_update and chat_uninstall_posit_assistant refuse, with the reason in client_info. The uninstall gate sits ahead of the on-disk checks, since a leftover copy may exist.
  • shouldFetchManifest() returns false in managed mode, ahead of the throttle and ahead of force. That covers all three callers of startUpdateCheck() and routes them through resolveWithoutManifestFetch(), so the client still learns installed/not-installed. fetchManifestAsync() has exactly one call site, behind that gate, and the cdn.posit.co URLs appear only inside it.
  • resolveWithoutManifestFetch() previously assumed its throttled-skip caller's precondition (a compatible version is installed). Managed mode reaches it with whatever the administrator provides, so it now recomputes the protocol mismatch and normalizes a missing install to 0.0.0. An administrator copy with a missing or mismatched protocol.json reports as unsupported — correct, since no update can be offered that would fix it.
  • ui/checkForUpdates fetches nothing itself, so it is suppressed separately: the capability is withheld from the handshake (so Posit Assistant hides its own update entry through the negotiation that already exists) and the request is refused as method-not-found if sent anyway.
  • chat_check_for_updates keeps succeeding and reports installationManaged. sessionInfo carries posit_assistant_installation_enabled.
  • The "installation not found" error no longer names the user data directory in managed mode — that is the one location the session ignores and refuses to install into.

RSTUDIO_POSIT_AI_PATH is removed

It was a development-only override: undocumented, unused by the e2e suite, and the bypass described above. It was also the resolver's only injection seam, so it is replaced by an InstallSearchPaths struct passed to an overload of locatePositAssistantInstallation(), following the bundledPositAssistantInstallPath(resourcePath) precedent. The search-order tests now assert the tiers directly instead of hedging on whatever is installed on the machine running them. Developers testing a local build install it into the XDG user data directory or point posit-assistant-path at it.

The unreleased 2026.09 entry for #18597 advertised the variable; it is reworded to keep only the system-wide-installation half. The rstudio-pro NEWS entry still advertises it and needs the same edit.

Client side

  • PositAiInstallManager.dispatchUpdateCheck() gains an onInstallationManaged(boolean installed) outcome, ranked below the blocking outcomes (an administrator copy with a mismatched protocol has a more specific message) and above the install and update ones. The flag is read with the file's optional-field convention, so an older rsession that omits it degrades rather than reporting a malformed response.
  • The chat pane starts the backend normally when the administrator's copy resolves, and otherwise says Posit Assistant is managed and not installed, with no install button. New automation state installation-managed.
  • "Check for Posit Assistant Updates" and "Uninstall Posit Assistant" are hidden. Uninstall is otherwise always available so a leftover copy can be removed; in managed mode that copy is inert anyway.
  • AssistantPreferencesPane replaces the update-check interval with an administrator notice, stops offering the Install button, and reports the mode rather than prompting for an install the backend would refuse.

Decisions on the issue's open questions

  • RSTUDIO_CONFIG_DIR / XDG_CONFIG_DIRS bypass: out of scope. Policy comes from rsession.conf, which users cannot edit; a user who can redefine the system config dir can already redefine much more.
  • Managed-but-nothing-installed copy: one message. The session cannot reliably tell "not installed yet" from "posit-assistant-path is set but invalid".
  • Refusal wording: matches the existing uninstall-refusal strings — "Posit Assistant installation is managed by your administrator and cannot be changed from RStudio."

Verification

Exercised end to end against a dev server, with pai/manifest-check.json removed before each run so the throttle could not skip the check:

posit-assistant-installation-enabled user install at ~/.local/share/rstudio/pai/bin manifest fetch
1 used manifest-check.json rewritten
0 ignored, warned once: "Ignoring user-level AI installation at …: Posit Assistant installation is managed by the administrator" none — record untouched, zero cdn.posit.co references in the session log

That A/B fails if the option ever regains an allowOverlay() term, which no unit test can catch: session::options() is a process-global populated by program-options parsing, and with the overlay restored a pure composition(option, env) helper would still be handed true.

Automated: full backend build clean; rstudio-tests --scope rsession 538 passed; ant javac, ant unittest 581 passed; npm run typecheck in e2e/rstudio clean. New tests cover the search-order tiers with and without the gate (ChatInstallationTests), the environment-variable half of the gate (SessionModuleContextTests), capability negotiation (ChatConstantsTests), and the managed dispatcher outcome with both precedence directions and the absent-flag default (PositAiInstallManagerTests).

ProcessTest.MultipleAsyncProcessesResults fails in the core scope, on this machine, before and after: it spawns 1000 concurrent processes and no file under src/cpp/core is touched here.

Notes

  • Rscript scripts/generate-options.R regenerates SessionOptions.gen.hpp; the rsession_conf.qmd half is a no-op in this repo (outputDocFile is /dev/null — the qmd lives in the docs repo).
  • Adjacent, not fixed: since rserver does not pass its environment to sessions, the existing RSTUDIO_DISABLE_POSIT_ASSISTANT row in environment-variables.qmd claiming "Desktop, Server" looks wrong for open-source Server too. The new row is scoped to Desktop.
  • Follow-ups, both already tracked: the Workbench profiles key assistant-installation-enabled translating to --posit-assistant-installation-enabled 0|1 (rstudio-pro#12483), and the versioned side-by-side install store (Install Posit Assistant side-by-side in versioned directories #18658), whose resolution carries this rule over unchanged.

Addresses #18443.

…installs

Adds allow-posit-assistant-installation (rsession.conf, default 1) and the
RSTUDIO_DISABLE_POSIT_ASSISTANT_INSTALLATION environment variable, read
together by module_context::isPositAssistantInstallationEnabledByAdmin().
The allow-* family generates "|| allowOverlay()", so Desktop force-allows
the option; the environment variable is the Desktop surface.

This commit adds the setting and reports it to the client as
sessionInfo["posit_assistant_installation_enabled"]. The gates that act on
it follow.

Addresses #18443
The variable was a development-only override: undocumented, unused by the
e2e suite, and a plain environment variable any user can set in .Renviron.
That last property would make an administrator setting that disables
user-managed installation decorative, so it goes rather than gaining a
gate of its own. Developers testing a local build install it into the XDG
user data directory or point posit-assistant-path at it.

It was also the only injection seam locatePositAssistantInstallation() had:
the tests used it both to neutralize ambient state and to point the search
at temp directories. Replace it with an InstallSearchPaths struct resolved
by positAssistantSearchPaths() and passed to an overload of the locate
function, following the bundledPositAssistantInstallPath(resourcePath)
precedent. getInstalledVersion() and getInstalledProtocolVersion() gain
path-taking overloads for the same reason.

The search-order tests now assert the tiers directly rather than hedging on
whatever happens to be installed on the machine running them.

Addresses #18443
locatePositAssistantInstallation() is the one resolution point both the chat
backend and the NES agent go through, so gating it there makes both honor
the setting. An installation already in the user data directory -- left from
before the setting changed, or copied there to get around it -- is ignored
rather than removed, and logged once per session because it silently changes
which version runs and can be a downgrade.

Addresses #18443
chat_install_update and chat_uninstall_posit_assistant now refuse when the
administrator has disabled user-managed installation, delivering the reason
via client_info so the frontend can show it verbatim. The uninstall gate sits
ahead of the on-disk checks: a leftover user-level installation may exist in
managed mode, and it is ignored rather than removed.

Addresses #18443
shouldFetchManifest() now returns false in managed mode, ahead of the
throttle and ahead of `force`. That covers all three callers of
startUpdateCheck() -- the startup kickoff, chat_check_for_updates, and
chat_install_update -- and routes them through resolveWithoutManifestFetch()
so the client still learns installed/not-installed without touching
cdn.posit.co.

resolveWithoutManifestFetch() previously assumed its throttled-skip caller's
precondition (a compatible version is installed). Managed mode reaches it
with whatever the administrator provides, so it now recomputes the protocol
mismatch and normalizes a missing install to "0.0.0". An administrator copy
with a missing or mismatched protocol.json reports as unsupported, which is
the correct outcome: no update can be offered that would fix it.

chat_check_for_updates keeps succeeding in managed mode and reports the mode
as installationManaged, so the pane and the preferences dialog get a
resolvable answer. The test-manifest banner no longer fires, since managed
mode reads no manifest.

Addresses #18443
ui/checkForUpdates fetches nothing itself -- it is a thin trigger for the
frontend command flow -- so the manifest gate does not cover it. Drop the
capability from the handshake response so Posit Assistant hides its own
update entry through the negotiation that already exists, and refuse the
request as "method not found" if a peer sends it anyway.

The capability list is filtered where the handshake response is built:
rstudioCapabilities() returns a reference to a function-local static and so
cannot vary by mode.

Addresses #18443
chat_install_update delivers its refusal wording via client_info, but
PositAiInstallManager.installUpdate() reported error.getMessage(), so the
user saw a generic execution error instead. Extract the client_info string
first, as the uninstall path already did, and share that extraction between
the two.

Addresses #18443
The client learns the mode two ways: sessionInfo tells it up front, for the
commands and the preferences layout, and chat_check_for_updates reports it
per check, for the pane.

- PositAiInstallManager.dispatchUpdateCheck() gains an onInstallationManaged
  outcome. It ranks below the blocking outcomes -- an administrator copy with
  a mismatched protocol has a more specific message -- and above the install
  and update ones, which managed mode can never act on. The flag is read with
  the file's optional-field convention, so an older rsession that omits it
  degrades rather than reporting a malformed response.
- The chat pane starts the backend normally when the administrator's copy
  resolves, and otherwise says Posit Assistant is managed and not installed,
  with no install button.
- Check for Posit Assistant Updates and Uninstall Posit Assistant are hidden.
  Uninstall is otherwise always available so a leftover copy can be removed;
  in managed mode that copy is ignored anyway.
- The preferences pane replaces the update-check interval with an
  administrator notice, stops offering the Install button, and reports the
  mode rather than prompting for an install the backend would refuse.

Addresses #18443
The handshake filter was an inline loop in handleGetProtocolVersion, which
needs the process plumbing to reach. Move it to
chat::constants::negotiatedCapabilities(bool), so the rule -- withhold
ui/checkForUpdates in managed mode, advertise everything else unchanged --
is covered directly.

Addresses #18443
The pane's new "installation-managed" state is exposed through
window.rstudio.chat like every other one, so list it in the ChatPresenter
doc comment and in the ChatBridge union the Playwright helpers type against.

Addresses #18443
A session that predates posit_assistant_installation_enabled sends no such
field, and the JSNI accessor read that as false -- reporting installation as
administrator-managed, hiding the install and uninstall commands, and
refusing installs the session would in fact have permitted. Read an absent
field as allowed instead, matching the option's default and the way
PositAiInstallManager already treats fields an older rsession may omit.

Addresses #18443
rserver builds each session's environment from scratch rather than passing
its own down: an rserver started with RSTUDIO_DISABLE_POSIT_ASSISTANT_-
INSTALLATION set launches an rsession without it. Server administrators use
the allow-posit-assistant-installation option in rsession.conf, so say that
rather than claiming a Server surface the variable does not have.

Addresses #18443
isPositAssistantInstallationEnabledByAdmin() is the entry point for every
gate in this change and the only surface a Desktop administrator has, but
nothing exercised it: the resolution tests take the flag as an argument by
design. A misspelled variable name would have gone unnoticed.

Addresses #18443
Timestamped scratch output from a browser session used while verifying this
change; it was swept in by a wildcard add and does not belong in the tree.
The guard inferred "was unset" from an empty value, so a variable that was
set to the empty string would have been unset on scope exit. Track presence
with the two-argument core::system::getenv() instead.

Addresses #18443
Open-source builds define allowOverlay() as unconditionally true, and every
allow-* accessor is "value || allowOverlay()", so
allow-posit-assistant-installation is force-allowed there. The option takes
effect in Posit Workbench, which is also where the profiles key that drives
it lands.

Addresses #18443
@gtritchie gtritchie added this to the 2026.09 (Autumn Hawkbit) milestone Aug 30, 2026
The allow-* family generates "value || allowOverlay()", and open-source
builds define allowOverlay() as unconditionally true, so
allow-posit-assistant-installation was force-allowed everywhere except Posit
Workbench. This setting has to work in open-source RStudio Server.

Rename it to posit-assistant-installation-enabled and move it to the pai
group, beside posit-assistant-enabled -- which is the option in that pair
that is honored everywhere, for the same reason. The accessor loses the
allowOverlay() term and the option now takes effect wherever rsession.conf
is read.

The environment variable is unchanged and remains the Desktop surface:
rserver builds each session's environment from scratch, so it does not reach
a server session.

Addresses #18443
The "installation not found" error named the XDG user data directory as a
place to install to. In managed mode that is the one location the session
ignores and refuses to install into, so name only the administrator's
location there.

Addresses #18443
The managed-mode guard in showInstallUpdatePrompt() reused the "Not
Installed" wording, but it is reachable only from onCheckFailed -- the
dispatcher routes managed sessions to onInstallationManaged before any
prompting outcome, and the unsupported-version prompt needs an update to
offer, which managed mode never has. On that path the RPC failed, so whether
the administrator's copy resolves is unknown: a managed session with a
working install would have been told it was not installed.

Use wording that states the mode without asserting install state. The
original pair stays in use in onInstallationManaged(false), where the
installation is known to be absent.

Addresses #18443
@gtritchie
gtritchie merged commit 5eb05aa into main Aug 30, 2026
6 checks passed
@gtritchie
gtritchie deleted the feature/18443-disable-user-pa-installs branch August 30, 2026 19:23
@github-actions

Copy link
Copy Markdown

RStudio E2E - all platforms

1 test(s) failed

###################- 99% pass rate

Passed Failed Skipped Flaky
2522 1 193 3
Platform ✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
✅ auth-teardown 2 0 10 0
❌ desktop-linux 625 1 47 0
✅ desktop-macos 640 0 33 1
✅ desktop-windows 638 0 39 2
✅ server-linux 589 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 13cd4b99670df2e838bbc9cff38d40c01cd958a2 - Run #763

This branch was previously deployed

1 inactive deployment
e2e-playwright — 13cd4b99 Deployed Aug 30, 2026 by gtritchie via windows / e2e-desktop-windows (4) #763
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