Skip to content

Multi-tenant Phase D — per-user plugin installs (system tier + per-user overlay) #284

Closed

Description

@thomas-stegemann

Extracted from #28 — Phase D of the multi-tenant rollout. Tracked separately so it can be sized + scheduled.

Why

IBowireUserStore (Phase B) gives each authenticated identity its own disk slot for recordings / environments / collections / flows. Plugins are the one piece of state still shared globally: ~/.bowire/plugins/ is a single flat directory every user sees. In a multi-tenant install that means a user can't add a workflow-specific protocol plugin without an admin shelling into the host, and one user's plugin set leaks into everyone's workbench.

Scope

  • Split ~/.bowire/plugins/ into two tiers:
    • System tier (admin-managed) — plugins available to every user, installed once on the host.
    • Per-user overlay — routed through BowireUserContext.GetUserPath(...), so each identity installs workflow-specific plugins without admin help.
  • Resolution order: the per-user overlay shadows / extends the system tier.
  • PluginManager + PluginUpdateCheckService already route through the IBowireUserStore seam (Phase B) — extend them to honour the two-tier layout.
  • Standalone single-user mode keeps the flat layout by binding to the synthetic default user (consistent with Phases B / E).

Tracked in ROADMAP.md.

Activity

  1. thomas-stegemann commented on Aug 28, 2026

    @thomas-stegemann
    MemberAuthor

    What shipped, and what this issue still covers

    Two tiers landed in f721266 and d0e6e18 — but they are OS tiers, not identity tiers, and the difference is the whole remaining scope of this issue. Recording it here so nobody closes this as done on the strength of those commits.

    Shipped

    BowirePluginRoot resolves two directories and expresses the precedence rule in one place (EnumeratePackages, user first, one row per package id):

    Tier Where Who writes it
    Machine %ProgramData%\Bowire\plugins / /var/lib/bowire/plugins (via BowireStorageScope.Machine, #616) an administrator
    User ~/.bowire/plugins, a project's .bowire/plugins, or --plugin-dir the account running the process

    The loader, the workbench listing, the update check and the sidecar discovery all walk them through that one rule. Uninstall refuses what belongs to the machine tier and names the elevated command that would work, instead of the old "not installed" about a plugin the workbench is visibly listing. An explicitly configured --plugin-dir yields only that directory — an override that half-applied was the bug in #549.

    For the desktop and single-host cases, that is the feature, and it is complete.

    Not shipped — and worth deciding rather than just building

    The user tier resolves through BowirePaths (BowireStorageScope.Data), not through BowireUserContext.GetUserPath(...) as this issue's scope asked. So the tier is per OS account. In a multi-tenant server — OIDC on, several authenticated identities, one process under one service account — every identity shares one user tier.

    Before that gets routed through the user store, the design question needs an answer, because a directory overlay is the wrong shape for it:

    1. Plugins are assemblies loaded into the host process. A per-identity overlay in a shared server means any authenticated user can place code that the server process loads. That is a privilege-escalation surface, not a path lookup. The per-user tier is safe on the desktop precisely because the account that writes it is the account that runs the process — that equivalence is what disappears server-side.
    2. Loading is process-wide. A plugin set that differs per identity needs its own AssemblyLoadContext per identity, plus a story for unloading when a session ends. That is a different mechanism from "look in a second directory", and it has a cost per identity.
    3. There may be no per-identity install at all. The alternative is that a server-mode install is machine-tier only, an administrator provisions plugins, and per-identity control is enable/disable over that provisioned set — which BowireDisabledPluginsStore already routes through BowireUserContext and which carries none of the code-loading risk.

    Option 3 is the one to beat: it gives users the control they actually asked for (not seeing plugin sets that are not theirs, choosing what is active for them) without letting an authenticated user load code into a shared process.

    Remaining scope of this issue

    • Decide between a per-identity install overlay and enable/disable over a machine-provisioned set, with the loading and privilege consequences written down.
    • If the overlay wins: route the user tier through BowireUserContext, and answer the AssemblyLoadContext question.
    • Either way: state in the docs what "per-user plugins" means in server mode, since it is not what it means on the desktop.

    Related: #28 (Phase D row), #616 (the machine scope this rides on).

  2. thomas-stegemann commented on Aug 31, 2026

    @thomas-stegemann
    MemberAuthor

    Decision: per-identity visibility, not per-identity loading

    The scope above says the per-user overlay should be "routed through BowireUserContext.GetUserPath(...)", as if the remaining work were a change of resolver. It is not, and the reason is worth writing down so this is not re-opened as an oversight.

    Three facts from the code:

    1. plugins.Load() runs once, before builder.Build() (BrowserUiHost.cs) — before there is a request, and therefore before there is an identity.
    2. Plugins contribute to the process-wide container (IBowireServiceContribution.ConfigureServices(IServiceCollection)) and map endpoints (IBowireProtocolServices → MapDiscoveryEndpoints). Both are frozen once the host is built.
    3. BowirePluginLoadContext is isCollectible: true, so re-loading is technically possible — which does not help with 1 or 2.

    So loading per identity means rewriting the plugin SPI: contributions could no longer reach IServiceCollection, and routes would have to appear at runtime. That is a change to the contract every existing plugin is written against, not a change to path resolution.

    And it would buy the opposite of what it promises. BowirePluginLoadContext deliberately shares the host's Kuestenlogik.Bowire* and System.* assemblies with each plugin, so a plugin one identity installed would run in the shared server process, with the server's rights, alongside every other identity's slot under <root>/users/<slug>/. "Your own plugins" would arrive together with "everyone else's plugins run next to your data".

    What ships instead

    The process keeps loading exactly one set — the machine tier plus whatever the operator provisioned. Per identity, Bowire decides what is active, not what is loaded.

    Half of that already exists and is inconsistent today: disabled-plugins.json is written under <user-store>/, so it is per-identity on disk — but BowireDisabledPluginsStore is static with a static cache, so in memory it is process-wide. The first identity to disable a protocol disables it for everyone until restart. That is a bug on its own terms, and fixing it is most of this phase:

    • BowireDisabledPluginsStore becomes an injected, identity-scoped service instead of static state.
    • Protocol resolution and the Plugins rail read it per request.
    • The machine/user tier split stays exactly as it is — it is the right answer to "who provisioned this", which is a different question from "who wants it on".

    Honest cost: "a user installs a plugin for their own workflow without admin help" does not survive this. That is the capability named in the Why above, and it is being traded for not putting one identity's code in another identity's process. Installing becomes explicitly an administrator's action — see #636, which found that it is currently not gated at all.

    For installs that genuinely need per-identity plugins

    The answer is a process per identity: one Bowire per person, each with its own slot and its own overlay, behind a router. That is the only shape that delivers "my own plugins" and "no foreign code in my process" at the same time, and it is a deployment question rather than a code one — the sidecar shape already exists. It will be documented as the answer rather than approximated in-process.

    Phase D scope, restated

    • BowireDisabledPluginsStore from static state to an identity-scoped service
    • Protocol resolution + Plugins rail honour it per request
    • A second identity disabling a plugin does not disable it for the first — the test that would have failed before
    • Single-user mode unchanged
    • Per-identity plugin installs documented as a deployment shape (process per identity), not built in-process
    • Installing gated to administrators — split out as Any authenticated user can install a plugin into the shared server process #636
  3. thomas-stegemann commented on Aug 31, 2026

    @thomas-stegemann
    MemberAuthor

    Shipped: the list now lives where its effect does

    disabled-plugins.json resolves against BowireStorageScope.Data — the process's own storage root — instead of <user-store>/. Verified in CI on c5c5e5d.

    Four tests state the behaviour, and one of them is the point of the whole change: what one identity disables reads back the same for another, because the process only has one registry and now only one file to explain it.

    No migration ships with it, deliberately. In the flat single-user layout a person's state sits directly in the storage root, so the user store and the Data scope were already naming one file — a test pins that equality, and a laptop notices nothing. A multi-tenant install with old per-identity copies stops reading them rather than merging them: a union of several people's lists is not any one person's intent, and a protocol disabled by surprise is harder to notice than one that is simply on. The old files are inert and can be deleted.

    Two things fell out on the way, both worth more than the lines they cost:

    • A #pragma warning disable CA1508 is gone. It existed to keep a double-checked lock the analyzer could not reason about. This is a dozen strings read on endpoint paths, so the fast-path went instead of the suppression.
    • A test was writing to the developer's real home. ResetStorage_deletes_state_directory_when_present seeded %UserProfile%/.bowire/plugins/fake-state-test/state and asserted the endpoint deleted it. It passed only because nothing had redirected BowirePaths yet; once the fixture did, the endpoint cleared the scratch root while the assertion still watched the home directory. It had been deleting a directory in whoever ran the suite. Fixed by seeding where the resolver actually points.

    What is left in Phase D

    • disabled-plugins.json filed at the process scope its effect already had
    • A second identity reads back what the first disabled — the test that would have failed before
    • Single-user mode unchanged, and pinned by a test rather than by assertion
    • Installing / updating / uninstalling gated to administrators — Any authenticated user can install a plugin into the shared server process #636
    • Per-identity plugin installs documented as a deployment shape rather than built in-process — docs/setup/multi-user.md
    • Per-identity "hidden in my workbench" — the other half of the visibility split, not yet built

    The last box is the one this issue's Why actually asked for, in the form that survives review: a per-identity preference file, filtered where the workbench reads the registry (13 call sites across 6 files), and deliberately not applied to invoke — hiding a protocol is tidying, not a permission, and someone who hides MQTT and then calls an MQTT method should not get an error.

    It is worth its own issue rather than being carried here: this one has answered the question it was opened for, which was whether per-identity plugins meant loading or visibility.

  4. thomas-stegemann commented on Sep 1, 2026

    @thomas-stegemann
    MemberAuthor

    Verified against the code, not against memory

    Every item in the Scope above, checked in the tree rather than recalled:

    Scope item State
    Split ~/.bowire/plugins/ into a system tier and an overlay Done — BowirePluginTier + BowirePluginRoot.MachineRoot, %ProgramData%\Bowire\plugins / /var/lib/bowire/plugins
    Resolution order: the overlay shadows and extends the system tier Done — EnumeratePackages(), the single place that ordering is expressed
    PluginManager + update check honour the two-tier layout Done — and so do the loader, the workbench listing and sidecar discovery: five call sites, one rule
    Standalone single-user keeps the flat layout Done, and pinned by a test that asserts the user store and the Data scope resolve to one path
    Per-user overlay routed through BowireUserContext so each identity installs without admin help Deliberately not done — see below

    The one item that changed rather than shipped

    The scope asked for per-identity installs. That turned out not to be a path question, and the decision is recorded above: plugins.Load() runs before builder.Build(), plugins contribute to the process-wide container and map endpoints at build time, and BowirePluginLoadContext shares the host's own assemblies with them by design. Per-identity loading would mean one person's code running in the shared server process beside another person's slot — the opposite of what "your own plugins" is asking for.

    What shipped instead is the same intent split into the two questions it actually contains:

    And the defect underneath both: disabled-plugins.json was written per identity while its effect was process-wide, so the last person to touch it decided for everybody. It now resolves against BowireStorageScope.Data — identical to its old path in single-user mode, so nothing moved on a laptop.

    One correction to my own earlier comment here. It said the store would become "an injected, identity-scoped service". That was written before the process-wide effect was understood; the later decision — which you took — was that the list belongs at the process scope its effect already had, and that the per-identity thing is a separate file. The table above is what shipped; that sentence is not.

    For installs that genuinely need per-identity plugins, the answer is a process per identity, documented in docs/setup/multi-user.md rather than approximated in-process.

    Closing: everything here is either delivered or superseded by a decision recorded in this thread.

  5. moved this from Backlog to Done in Bowireon Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    • Status
      Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions