BrowserOS icon indicating copy to clipboard operation
BrowserOS copied to clipboard

Question: managed server durable state is OS-user scoped while its execution dir and lock are profile scoped

Open WindriseAI opened this issue 3 weeks ago • 1 comments

Question

Should the managed server's durable state (SQLite database, installation identity, sessions) be scoped to the BrowserOS profile that launched it, or is it intentional that all BrowserOS processes under the same OS user share it?

Static reading of main (79e615832) shows the two kinds of state resolve to different roots, and only one of them is profile-scoped.

Profile-scoped (browser side)

  • browseros_server_manager.cc → GetBrowserOSExecutionDir() returns <chrome::DIR_USER_DATA>/.browseros (created on demand), writes it to directories.execution, and puts server.lock there. AcquireLock() takes an exclusive lock on that file, so the "already running in another Chrome process" guard is per user-data-dir.
  • process_controller_impl.cc writes config.json into directories.execution and launches the child with --config <path> and nothing else.

OS-user-scoped (server side)

  • apps/server/src/lib/browseros-dir.ts → getBrowserosDir() returns BROWSEROS_DIR when set, otherwise <homedir>/.browseros (.browseros-dev when NODE_ENV=development). getDbPath() resolves the DB to <root>/db/browseros.sqlite, and main.ts also loads/creates installation.json, sessions, cache and tool outputs under the same root.
  • server_process_launcher.h exposes only LaunchServerProcess(const base::CommandLine&); nothing in the launch path computes or forwards BROWSEROS_DIR per profile. The only code that sets it is the server test helpers.
  • Chromium also reads the same variable in browseros_product_state.cc::GetProductStateDirectory() for its own product-state root, with the same fallback to <homedir>/.browseros.

So two instances started with different --user-data-dir values (a supported scenario, and also what happens when a system-wide install coexists with a dev build) each get their own execution directory and their own server.lock, while their server processes would target the same database, the same installation ID and the same sessions directory.

Why this looks worth confirming

  • Nothing on the browser side can tell that another managed server already owns the shared durable root, because the only mutex is scoped to the per-profile execution directory.
  • openBrowserOsDatabase() opens the file with PRAGMA journal_mode = WAL and runs drizzle migrations at startup (runMigrations defaults to true). Two processes migrating the same file is the window that would concern us most. Port defaults come from local_state (9200/9000/9100 for the BrowserOS build, 9210/9010/9110 for BrowserClaw) with command-line overrides, so a second instance started with overridden ports can run while the first one is running.
  • Even without concurrency, shared durable state means profile B's server sees profile A's conversations, provider/OAuth rows and installation ID.

Questions

  1. Is the managed server meant to be one instance per OS user with intentionally shared durable state?
  2. If shared state is intended, is there a supported lifecycle guarantee that keeps two managed servers from opening the same database at the same time?
  3. If profile-local state is intended instead, would you accept threading a per-launch state root through the launcher (an environment argument on LaunchServerProcess, or a field in the sidecar config) so the database, installation ID and sessions follow directories.execution?

Scope and evidence limits

This is a source-reading question against public main at 79e615832. No browser was started, no profile or database was read or modified, no multi-instance or concurrency test was run. I am not reporting a corruption or data-loss symptom; the point is the mismatch between the profile-scoped lock and the user-scoped durable root, which the maintainers can confirm or rule out in one line.

Related history: #923 moved the server DB from the execution directory to the BrowserOS state directory, and #836 introduced the explicit BROWSEROS_DIR override for dogfood, so the split looks deliberate on the browser side. Happy to send a patch for the third question if the direction is useful.

WindriseAI avatar Nov 10 '26 01:11 WindriseAI

Nudging this once, with a re-check instead of a plain ping.

Against main at a7e536e1 (2026-11-15) the split is unchanged. server_process_launcher.cc still calls base::LaunchProcess(command_line, {}), so LaunchServerProcess(const base::CommandLine&) forwards no environment, and getBrowserosDir() still falls back to <homedir>/.browseros. The execution directory and server.lock stay under DIR_USER_DATA; the database, installation.json and the sessions directory stay OS-user scoped. Only the file layout moved (apps/server -> packages/browseros-agent/apps/server), so the paths in the original report are now one level deeper.

#2530 reads like the answer to Q1: one installation ID per product at ~/.browseros/installation.json, shared across Chromium and both sidecars instead of profile-scoped prefs. If that intent extends to the database and sessions, I will treat shared durable state as intended and drop Q1 and Q3.

That leaves Q2. Two managed servers can still open the same browseros.sqlite: openBrowserOsDatabase() uses WAL and runs migrations at startup, and #2530's atomic publish covers first-run creation of installation.json, not the database. If that overlap is meant to be impossible, which side should hold the guard: a lock next to the database, or the existing server.lock moved to the shared root so the already-running check spans profiles? Happy to send a patch for either; I would rather not pick the side for you.

WindriseAI avatar Nov 16 '26 01:11 WindriseAI