ADR 0010doc/{zh,en}/adr/0010-tenant-and-user-data.md

ADR 0010: Tenant and User Data Directories

Status: accepted, 2026-11-20 (S5 of the release and runtime layout, section 8; the owner chose multi-tenancy for this round on 2026-11-19).

Status: accepted, 2026-11-20 (S5 of the release and runtime layout, section 8; the owner chose multi-tenancy for this round on 2026-11-19).

Context

Every plugin instance has one private DataDir. Plugins that keep data per person or per conversation (Memory's user-<id>.json, the skill workshop's drafts) put it all in that one directory, keyed by ids they read from the call context. The Host therefore cannot find a person's files: deleting a user (sessions forget), merging two users (identity link) and exporting a tenant miss them, and artifacts live in one flat directory for every tenant.

Decision

  1. Layout. Under state_dir: host/<instance>/ is the instance's own data (Env.DataDir, meaning unchanged); an instance that already has plugins/<instance>/ keeps using it, because plugins store absolute paths into their directory (git worktrees record theirs in the repository) and a move would break them; tenants/<t>/shared/instances/<instance>/ is data an instance keeps for a tenant (a group conversation's memory); tenants/<t>/users/<u>/instances/<instance>/ is data it keeps for one person; tenants/<t>/users/<u>/artifacts/ holds the person's artifacts. Tenants and users appear only as Host ids.
  2. Contract. plugin.Env gains TenantDirs and UserDirs, path patterns with {tenant} and {user}, and the methods Env.TenantDir(tenant) and Env.UserDir(principal) that fill them in (the user's tenant comes with the principal). Process plugins receive the patterns in initialize. A plugin fills them only with ids the Host gave it: CallContext.Principal and ObservedEvent.Principal. The directories are created on first use.
  3. Ownership. The Host owns the user and tenant directories as wholes: when two users merge it moves the merged user's directory into the kept one (keeping both files on a name clash); when a user is forgotten it deletes the directory; a tenant export packs tenants/<t>/. What is inside an instance's directory stays the plugin's format.
  4. Trust. This places data; it is not a sandbox. A builtin plugin runs inside the Host and a process plugin as its OS user, and either could read any path. Isolation between tenants stays logical, as section 8 of the design says; what the layout guarantees is that the Host knows whose data is where.
  5. Migration. Plugins move their old per-user files on first access (Memory: user-<id>.json and conversation-*.json into the new directories), so no step needs the Host to know a plugin's format.

Consequences

  • ◆Plugins that keep per-person data use UserDir; others are unchanged.
  • ◆Env gains two fields and initialize two parameters: JSON-compatible; a process plugin that ignores them keeps its data in DataDir, which the Host does not move with users.
  • ◆Deleting and merging users now cover their files, and artifact files follow their user.

Addendum: plugins below the system level (S6b, 2026-11-20)

Install levels section 5 puts its implicit instances here. The registry takes them from the caller (registry.Options.Implicit), not from the configuration file. Each has an owner (registry.Owner: tenant, user or workspace), and Applies refuses its calls for anyone else; every consumer of a runtime's uses already checks Applies. The registry adds each to every runtime's uses unless the runtime's levels.plugins leaves its level out. Only manifest plugins are taken: they carry skills, MCP servers and prompts rather than code of their own. Approval stays with the Host: the instance is listed with its reason (unapproved, untrusted, changed) and not started.