Files
loki/docs/architecture/multitenancy-execution-plan.md
CatoandClaude Fable 5.1 95c40a9cd8 refactor: rename the product from FleetCrown to Loki (#695)
The product, its assistant, the repo, the host and every unit on the box now
share one name. 638 files, ~3,000 mentions: UI copy, config, env keys
(FLEETCROWN_* -> LOKI_*), systemd units (fleetcrown-* -> loki-*), docs,
articles, the deploy workflow other repos reuse, and nine file names.

- Three article slugs carried the old name and had been shared; permanent
  redirects keep those links alive (next.config.ts).
- test-no-retired-name.sh now also forbids the old product name across the
  whole repo, so the rename cannot creep back through templates and examples.
- ASSISTANT_STACK collapses the product and the assistant into one entry,
  because they are now the same name.

Infra was cut over ahead of this merge: /opt/loki, loki-* units, the `loki`
database and role, loki.orangecat.ch (old host 308s to it; /api, /widget,
/embed keep proxying), GitHub repos bitbaum/loki and bitbaum/loki-releases.
The Resend sending domain stays fleetcrown.orangecat.ch until the new domain
is verified in DNS.


Claude-Session: https://claude.ai/code/session_016YJVAanfj8keVSXyZnTemh

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-13 16:13:10 -07:00

3.6 KiB


created_date: 2026-06-30 last_modified_date: 2026-09-11 last_modified_summary: Routing is stored, not presence-based; previous: Shared cloud builder remains private; Docker-backed SandboxExecutor substrate exists behind an explicit env flag, but public hosted execution still waits for credentials, metering, and entitlement gates.

Multitenancy Execution Plan

Loki is already mostly tenant-shaped at the control-plane layer: users own projects, agent tokens are per-user, pending commands carry user_id, and runners claim commands with their own ck_ token. The scaling risk is execution, not CRUD.

Tenant Boundary

The current always-on box-runner is a founder cloud builder. It owns real PTYs, filesystem state, CLI auth, project checkouts, and agent credentials. That is not a safe tenant boundary for arbitrary users.

Therefore:

  • Founder / allowlisted accounts may use the shared cloud builder channel.
  • Other accounts must use their own Fleet Runner (local builder channel).
  • If no builder is connected for a non-cloud-enabled account, dispatch fails clearly with builder-required instead of queueing forever.
  • Explicit Cloud terminal/input requests for non-cloud-enabled accounts return cloud-builder-private.

The SSOT is src/lib/execution-access.ts.

Why This Comes First

Without this boundary, a new public user can experience one of two failures:

  • Work queues into infrastructure they do not own and may never be able to observe.
  • A shared runner becomes a cross-tenant filesystem / credential / terminal risk.

The current slice chooses product honesty over fake availability.

Path To Scalable Hosted Execution

  1. Keep control-plane data user/org scoped.
  2. External beta users are not on the cloud allowlist, so their projects run through Fleet Runner desktop until hosted execution is sandboxed. Routing is still the stored rule (locus lock → builder_pref → cloud floor); for a non-allowlisted account decideQueuedExecution resolves the cloud floor to their connected runner or a clear builder-required.
  3. Build and harden hosted sandbox execution before enabling Cloud broadly:
    • one workspace per sandbox (SandboxExecutor substrate exists behind LOKI_EXECUTOR=sandbox)
    • fresh clone from git_url under LOKI_SANDBOX_WORKSPACE_ROOT
    • no shared home directory (HOME=/tmp in the container)
    • per-tenant secret vault, explicitly injected per run
    • CPU/memory/PID/time quotas
    • durable run logs and artifacts
    • explicit egress policy (none by default, bridge only when needed)
  4. Add an entitlement flag for hosted execution when billing/quotas exist.
  5. Enable Cloud per tenant only after sandbox executor passes registration → onboarding → dispatch → terminal smoke.

Product Contract

Projects remains the strategic registry. Loki and Control compile intent into the same queue. Terminal verifies and lets the user type into the actual PTY. Multitenancy requires those surfaces to agree on executor availability:

  • If Cloud is unavailable, say so.
  • Route by the project's stored builder (builder_pref, cloud floor); connection state only decides whether the work runs now or waits, visibly.
  • If no builder is connected, do not claim work has started.

Current Implementation Boundary

SandboxExecutor is now a real Executor implementation, but it is a substrate, not a launch policy. It gives the control plane an isolated place to run a PTY when an operator deliberately enables LOKI_EXECUTOR=sandbox. The existing product gate remains: non-founder users do not get shared hosted cloud execution until credentials, billing/metering, and registration→onboarding→dispatch→terminal smoke tests exist.