Phase 13, part 9: running at scale, and the proof

The multi-tenant edition starts. compose.multi.yaml runs several copies
behind Caddy, with the managed Postgres and Garage outside. A test walks
every page and fragment, with ids filled in, and every MCP tool, as one
team, and none shows another team's data or changes it; another has three
copies share six teams' work, each team's turn once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 12:46:01 -07:00
co-authored by Claude Opus 5.5
parent b8a64e258a
commit f4c31c9fa3
13 changed files with 453 additions and 14 deletions
+31 -1
View File
@@ -55,7 +55,7 @@ tools over MCP, approvals, limits and visibility, and the JSON API. Schema
39.
**Phase 13 (multi-tenant) is under way** on branch `phase13`, with a
Postgres schema per team (decided 2026-11-26); parts 1–8 are built.
Postgres schema per team (decided 2026-11-26); parts 1–9 are built.
**Phase 12 (signing in with the Core, OIDC) is set aside for now**
(2026-11-26): before it starts, the user will share the Federated Core's
@@ -2930,6 +2930,36 @@ stand.
schema and role, its agents and their keys, memberships, sessions and
row. People keep their accounts.
**Part 9 built 2026-11-26** on `phase13`. **The multi-tenant edition
starts.**
- `supermarket` with `SUPERMARKET_MODE=multi` opens the teams' schemas,
skips what's only the local edition's (the old app's import, the setup
link, Hermes' socket), and recovers each team's interrupted drafts at
start.
- `compose.multi.yaml`: several copies of the app (`SUPERMARKET_COPIES`,
3 by default) with only scratch space of their own, behind Caddy
(`server/Caddyfile.multi`: every copy found by name, round robin, health
checked); the managed Postgres and Garage outside, in `multi.env`.
Everything a request needs is in Postgres (sessions, OAuth sign-ins under
way, locks), the files in the object storage. Each team's pool is small;
a PgBouncer in front must pool by session (each connection carries its
team's role and search path). The platform page (part 7) shows each
team's size and failures.
- **Done when, checked** (on Postgres, `TestTeamsIsolatedEverywhere`): two
teams, each filled with data marked as its own (profile, Market,
signals, prospects, drafts, suppression, settings, keys). As team A's
owner, every GET route there is, with its ids filled in (1, 2, 3) and
with and without a site and a search (over 300 requests), and as A's
agent with every scope, every MCP tool (over 30, three sets of
arguments): none shows B's data, and A's deletions aimed at B's ids
change nothing of B's. A control checks that B sees its own marker on
the same pages, so the check can tell. `TestThreeCopiesShareTheWork`:
three copies on one database run a round of a job for six teams at once;
each team's turn runs exactly once, the copies share them, and any copy
answers a team's requests.
- Not run yet: the whole multi-tenant edition in Docker with Garage (the
server edition's was, in Phase 10).
1. **Teams everywhere.**
- Every table that holds a company's data gets `team_id`, and its
unique keys include it. The settings table's key becomes