Repository navigation
Description
Context
BowireStorageRoot already gets the hard part right: data lives under ~/.bowire/ rather than next to the executable, and a project can opt in to .bowire/ via its manifest — deliberately not via a CLI flag, so the answer does not depend on who launched the process. Surgewave has now adopted the same separation (Kuestenlogik/Surgewave#158) and hit two cases this does not cover.
What is missing
A machine scope. ~/.bowire/ is the user's home. A Bowire instance that runs as a service — a shared team instance rather than someone's desktop tool — resolves ~ to the service account's profile, not to the operator's. In Surgewave this produced a real defect: an admin installed a plugin, the tool confirmed it, and the broker never saw it, because they were looking at two different profiles with the same name (Kuestenlogik/Surgewave#157). Anything a service reads needs a scope that does not depend on the account:
| Windows | Linux | |
|---|---|---|
| Machine | %ProgramData%\Bowire |
/var/lib/bowire |
| User | ~/.bowire |
~/.bowire |
Note that SpecialFolder.CommonApplicationData maps to /usr/share on .NET for Unix, which is for static package data rather than for state a service writes — the platform branch has to be written by hand.
An instance segment. Several Bowire instances on one machine currently share ~/.bowire/. BOWIRE_INSTANCE adding a single path segment separates them, the way PGDATA and GEOSERVER_DATA_DIR do. Unset should mean the root itself, so nothing moves for the single-instance case. Reject a name that contains a path separator or that collides with a directory the root already owns — with no instance set the scope is the root, so an instance named after one of those would share state with an unnamed one.
One override for tests. BOWIRE_DATA_DIR pointing every scope at one directory is what makes a test fixture able to create one tree and delete one tree, instead of hunting for state next to whichever output directory the run happened to use.
The project opt-in stays exactly as it is — it answers a different question (which checkout owns this data) and it answers it well.
Reference
SurgewaveDataRoot and SurgewavePluginDirectories in Kuestenlogik/Surgewave (commit d9c92dc), with tests covering the platform branch, the instance rules and the de-duplication that a redirected root needs.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
thomas-stegemann commentedon Aug 25, 2026
Looked at this while working nearby, and there is a prerequisite worth pulling into the issue: a machine scope and an instance segment added to
BowireStorageRootwould not reach most of the code that stores things.What the audit found
BowireStorageRoot.Apply()setsBowireUserContext.Current, and everything that asksBowireUserContextfor a path follows it. But 14 files across 6 assemblies build the path themselves instead:Kuestenlogik.BowireAuth/IBowireUserStore.cs(UserProfileRoot),BowireServiceCollectionExtensions.cs(×2),Endpoints/BowirePluginEndpoints.cs,Plugins/PluginUpdateCheckService.cs,Plugins/Sidecar/SidecarPluginDiscovery.cs,Proxy/BowireProxyCertificateAuthority.cs,Sources/BowireCatalogueOverride.cs,Sources/LocalCatalogueProvider.csKuestenlogik.Bowire.McpBowireMcpResources.cs(×2),BowireMcpTools.cs,BowireMcpTypedUrlStore.csKuestenlogik.Bowire.ToolPlugins/BowirePluginOptions.csKuestenlogik.Bowire.Security.ScannerVulnDbCache.csKuestenlogik.Bowire.MonitoringMonitoringServiceCollectionExtensions.csEach one is
Path.Combine(Environment.GetFolderPath(SpecialFolder.UserProfile), ".bowire", …)— the string".bowire"written out sixteen times.Alongside them sit per-feature environment overrides that each resolve on their own terms:
BOWIRE_CATALOGUE_CONFIG_PATH,BOWIRE_CATALOGUE_PATH,BOWIRE_PLUGIN_DIR. And several carry their own fallback rules —VulnDbCachedrops to%TEMP%/bowire/vulndbwhen the profile is empty,BowireCatalogueOverride.ResolvePath()returns"", others would produce.bowirerelative to the working directory.So the defect this issue exists to fix reappears per feature. A service instance that resolves
~to its service account gets the right answer for anything routed throughBowireUserContextand the wrong one for the plugin directory, the proxy CA, the vuln-db cache, the catalogue config and the MCP stores. Which is exactly the Surgewave failure — an admin installs a plugin, the tool confirms it, the broker never sees it — andBOWIRE_INSTANCEwould separate instances everywhere except where they actually collide.Proposed shape
An injectable resolver rather than more static helpers, so that scope selection is a decision made once and passed down:
AddBowire(); every consumer above takes it as a constructor dependency.BOWIRE_DATA_DIRandBOWIRE_INSTANCEare read once, inside the resolver — which is what makes the test-fixture override from this issue's third bullet actually cover everything, rather than every store needing its own escape hatch.BowireUserContextpath stays for now as a thin forwarder, so this does not have to land as one commit.The two hard cases are worth naming up front:
DefaultBowireUserStore.UserProfileRootis a static property that half the codebase reads. It becomes the resolver's default rather than the thing everyone calls.BowirePluginOptions.DefaultDirectoryis a static in the Tool, read before any container exists. That one needs the resolver to be constructible without DI, which is fine — a parameterlessnewwith the same defaults, with DI supplying a configured one where a container exists.Happy to take this on; it is mostly mechanical once the resolver exists, and it makes the machine scope and instance segment land everywhere in one move rather than one store at a time.
(Unrelated but adjacent:
--port-filefrom #615 is not affected — the caller names an absolute path, so there is no resolution to route.)thomas-stegemann commentedon Aug 25, 2026
The consolidation from the comment above landed in
d6a2846d— the prerequisite, not the feature. Here is what is now true and what is left.Done
One resolver.
IBowirePathResolveranswers for two scopes:Data(whateverBowireStorageRootdecided — the project's.bowire/or the user root) andMachine(%ProgramData%\Bowire|/var/lib/bowire). Injected viaAddBowire(), reachable through aBowirePathsfacade for the call sites that resolve during type initialisation, before any container exists.BOWIRE_INSTANCEandBOWIRE_DATA_DIRare read in exactly one place. Instance names are validated rather than accepted quietly: anything that is not a single path segment, and anything colliding with a directory the root already owns (plugins,workspaces,recordings,flows,cache,certs,logs,presets,mocks) — because with no instance set the root is the scope, so such a name would silently share state with an unnamed instance.Fourteen files stopped building the path themselves — 16 hand-rolled resolutions down to 1, which is
DefaultBowireUserStore.UserProfileRoot, the value the resolver's own default reads.Three defects fell out of having one place instead of sixteen:
Apply()path.BowireStorageRoot.Apply()runs when the host is built, which can be after a type is first touched — soPluginUpdateCheckService.DefaultPluginDir,BowirePluginOptions.DefaultDirectoryandSidecarPluginDiscovery.DefaultPluginRootcaptured the user root and then ignored a project that had opted into.bowire/storage. They are properties now.%TEMP%, one returned""— which madeBowireCatalogueOverrideStoresilently never persist — and the rest would have produced a relative.bowirenext to the working directory. One guard now, in the resolver, returning a usable absolute root.HomeDirOverridewas three copies across three types, so "redirect everything MCP reads" was a promise each new call site had to remember. One property, inMcpPaths.A convention test scans
src/for either half of the old pattern and fails with the offending file list.Tests: 24 for the resolver, 2 for the convention. Core 2830/2831 (the one failure is a pre-existing cancellation-timing flake in
ProxyCommandTests, green in isolation), MCP 134/134, Benchmarking 95/95, Monitoring 118/118.Docs:
architecture/storage-locations.md.Still open — and one that needs your call
The scopes exist; nothing uses
Machineyet. That is the actual feature and it is deliberately a separate step: routing a store to the machine scope moves its data, so each one is a decision (the plugin directory is the obvious first candidate, since it is the one the Surgewave defect was about).Two files resolve against the working directory, not the user profile —
BowireBenchmarkScheduleStoreandContractResultStore, bothPath.Combine(Directory.GetCurrentDirectory(), ".bowire", …). The convention test found them; I exempted them rather than sweeping them in, because they answer a different question: a contract result and a benchmark schedule belong to the checkout being tested, and both already take an explicitrootPaththat CI passes. Routing them through theDatascope would move them out of the repo for anyone who does not pass one — a product decision, not a cleanup. Worth deciding here.feat(storage): one resolver decides where Bowire stores things (#616)
test(plugins): cover the listing the plugin browser renders
fix(plugins): one answer to where the plugins live
thomas-stegemann commentedon Aug 28, 2026
Shipped in 9e8718e (
feat(storage): one resolver decides where Bowire stores things).All three gaps this issue named are closed:
BowireStorageScope.Machineresolves to%ProgramData%\Bowireon Windows and/var/lib/bowireon Linux. The platform branch is written by hand, exactly as the issue warned:SpecialFolder.CommonApplicationDatamaps to/usr/shareon .NET for Unix, which is for static package data, not for state a service writes.BOWIRE_INSTANCEadds one segment under every root. Unset means the root itself, so nothing moves for the single-instance case. A name containing a path separator is refused, and so is one colliding with a directory the root already owns (plugins,workspaces,recordings, …) — with no instance set the scope is the root, so such a name would silently share state with an unnamed instance.BOWIRE_DATA_DIRredirects every scope at one directory, so a fixture creates one tree and deletes one tree.The project opt-in is untouched, as intended.
Covered by 19 tests in
BowirePathResolverTests, plusStoragePathConventionTestsguarding against new hand-rolledPath.Combine(home, ".bowire", …)call sites. Documented indocs/architecture/storage-locations.md.The machine scope is already carrying its first consumer: the machine-wide plugin tier from #28 Phase D resolves through it.