Skip to content

feat(fleet): multi-tenant hosting via openclaw fleet cell supervisor - #104527

Merged
steipete merged 8 commits into
mainfrom
claude/openclaw-multi-tenancy-ed3dc8
Jul 11, 2026
Merged

steipete merged 8 commits into
mainfrom
claude/openclaw-multi-tenancy-ed3dc8

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

OpenClaw's trust model is one trusted operator domain per gateway: all agents, plugins, and Codex app-servers share one Node process, one OS user, and one shared-secret gateway credential. Operators who want to host agents for multiple users have no supported deployment shape, and in-process separation cannot become one — tenant plugins and Codex installs are arbitrary code running with the whole gateway's authority. Closes #104436.

Why This Change Was Made

Treat the container boundary as the tenant boundary and keep every tenant a normal single-operator OpenClaw. This PR adds the v1 supervisor:

  • openclaw fleet create|list|status|start|stop|restart|upgrade|rm — provisions one cell (a complete OpenClaw instance from the official ghcr.io/openclaw/openclaw image) per tenant, on Docker or Podman.
  • Hardened container profile, asserted by tests both positively and negatively: --cap-drop=ALL, no-new-privileges, --init, PID/memory/CPU limits, --restart unless-stopped, per-cell bridge network, gateway port published on 127.0.0.1 only; never docker.sock, --privileged, host networking, or added capabilities.
  • Cell state and auth-profile secrets mount at the paths the Docker install docs pin (/home/node/.openclaw, /home/node/.config/openclaw); user mapping handles rootful/rootless Docker and Podman keep-id, with SELinux :Z relabeling when active.
  • The gateway token travels via a mode-0600 env-file (never argv), is redacted from error output, lives only in container env (not SQLite), and is carried over on upgrade from container inspection.
  • Registry is a fleet_cells table in the shared state DB (Kysely; same zero-config-key pattern as managed worktrees). Per-tenant operation leases reuse the existing state_leases table so concurrent CLI mutations of one cell fail fast instead of corrupting container state; failed create rolls back only its own attempt-labeled artifacts, and failed upgrade restores the previous container.
  • rm --purge-data requires --force and performs realpath containment checks (symlink-swap and sibling-cell escapes refused) before deleting anything.
  • Docs: a new multi-tenant hosting concept page with an explicit trust statement (tenancy protects tenants from each other; the operator/host is trusted; host-compromise resistance is a non-goal), an isolation ladder (hardened container → gVisor/Kata/microVM → separate machines), and a fleet CLI reference. Shared channel ingress, slim per-tenant hosts, remote cells, and a tenant portal are explicitly deferred.

No gateway/runtime behavior changes, no new openclaw.json keys, no new dependencies; personal-mode deployments are untouched.

User Impact

Operators get a supported, documented way to host multiple users on one Linux host with a real isolation story and lifecycle UX (create prints the cell URL and one-time gateway token). Existing single-operator deployments see no behavior change.

Evidence

  • Focused tests: 120 passed (7 files) on Blacksmith Testbox at the final head, Actions run https://github.com/openclaw/openclaw/actions/runs/29157009109 (earlier heads: 115/118 passed, runs 29156227026 and 29156762499)
  • Changed-lanes gate (pnpm check:changed) on Blacksmith Testbox: all lanes green except "test temp creation report", which crashes on the delegated sync checkout with fatal: origin/main...HEAD: no merge base — an infrastructure issue unrelated to this diff (the same report over this diff locally returns zero findings in both branch and staged mode); harness fix tracked separately.
  • Full pnpm build clean, no [INEFFECTIVE_DYNAMIC_IMPORT] findings.
  • Docs checks: docs:map regenerated; docs link check passed (5,849 links, 0 broken) in the Codex build pass.
  • Structured autoreview (Codex gpt-5.6-sol, xhigh) per commit: the test and docs commits reviewed clean apart from accepted findings that are fixed in the follow-up commit; the feat commit surfaced two real P2s — upgrades could commit an immediately-crashing replacement without triggering restore, and a name collision with an unlabeled foreign container/network stranded the tenant reservation unrecoverably. Both fixed (replacement now verified by attempt-label + running-state inspection before the registry update; unlabeled resources treated as provably foreign: left untouched, reservation released) plus five new regression tests; the docs finding (unknown state also signals ownership mismatch) is documented. A second review round hardened the upgrade gate further: commit now waits for the replacement to answer /healthz (the compose health contract) with fast-fail on exit/restart-loop and a bounded ~60s deadline before restore, so a start-then-crash image cannot displace a healthy cell. Final fix commit reviewed clean ("no accepted/actionable findings", confidence 0.94).
  • Design provenance: adversarially reviewed architecture discussion (cells over in-process RBAC), see Multi-tenant hosting: openclaw fleet cell supervisor MVP (per-tenant isolated instances) #104436 for the threat-model rationale.

@steipete
steipete requested a review from a team as a code owner July 11, 2026 14:57
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime cli CLI command changes security Security documentation docker Docker and sandbox tooling size: XL maintainer Maintainer-authored PR labels Jul 11, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c8112156ec

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/fleet/cell-profile.ts
Comment on lines +277 to +280
"--network",
profile.networkName,
"-p",
`127.0.0.1:${profile.hostPort}:${FLEET_GATEWAY_PORT}`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Add host gateway mapping for Docker cells

For Linux Docker Engine cells, the official Docker setup documents host.docker.internal as the URL tenants should use for host-side LM Studio/Ollama and says custom docker run users must add --add-host=host.docker.internal:host-gateway (docs/install/docker.md:305-319). The fleet profile only joins the per-cell bridge and publishes the gateway port here, so a tenant configuring those documented Docker provider URLs inside a fleet-created Docker cell cannot reach the host provider. Add the Docker-only host-gateway mapping when building the cell args; Podman can keep its own host-alias behavior.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Jul 11, 2026
@clawsweeper

clawsweeper Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: stale review; fresh review needed.

Summary
The latest durable ClawSweeper review was for head 2bcbad7714f74702d06740a434678345e763cd63, but the PR head is now 35e1d5727dd9377383f75f64032779c7b9c8f490. Its old verdict and PR readiness labels are no longer current.

Next step
Run or wait for a fresh ClawSweeper review on the current PR head.

Review history (4 earlier review cycles)
  • reviewed 2026-07-11T15:13:44.815Z sha c811215 :: needs real behavior proof before merge. :: [P1] Persist user-scoped Codex state across replacements | [P2] Skip host ports already in use
  • reviewed 2026-07-11T17:32:38.217Z sha 6468ee1 :: needs real behavior proof before merge. :: [P1] Persist the user-scoped Codex home across replacements | [P2] Skip host ports already occupied outside the registry | [P2] Add the documented Docker host-gateway alias
  • reviewed 2026-07-11T17:58:03.826Z sha 22ba8c9 :: needs real behavior proof before merge. :: [P1] Persist the user-scoped Codex home across replacements | [P1] Preserve the inspected image user during upgrade | [P2] Skip host ports already occupied outside Fleet | [P2] Add the documented Docker host-gateway mapping
  • reviewed 2026-07-11T18:07:00.385Z sha 22ba8c9 :: needs real behavior proof before merge. :: [P1] Persist the complete cell-owned user home | [P1] Preserve named image users during replacement | [P2] Skip host ports already occupied outside Fleet | [P2] Add the documented Docker host-gateway alias

@steipete

Copy link
Copy Markdown
Contributor Author

Pre-merge verification

Automated validation

  • Focused tests: 120 passed (7 files) on Blacksmith Testbox at head c8112156ecd5 (Actions run https://github.com/openclaw/openclaw/actions/runs/29157009109); CLI wiring re-verified locally after the docs/experimental-label commit (12 passed).
  • Full pnpm build clean, no [INEFFECTIVE_DYNAMIC_IMPORT] findings.
  • Structured autoreview (Codex gpt-5.6-sol, xhigh) per commit; two review rounds produced the upgrade health gate and foreign-collision reservation release; final fix commit reviewed clean ("no accepted/actionable findings").
  • pnpm check:changed: all lanes green except "test temp creation report", which crashes on the delegated Testbox checkout with fatal: origin/main...HEAD: no merge base — pre-existing harness issue independent of this diff (the same report over this diff returns zero findings locally in branch and staged mode); fix tracked as a follow-up.

Live scenario proof (real user path; macOS host, OrbStack Docker 29.4.0, real ghcr.io/openclaw/openclaw:latest, isolated OPENCLAW_STATE_DIR)

  • openclaw fleet create smoke → container openclaw-cell-smoke on 127.0.0.1:19100, started; fleet status health ok on the first /healthz probe.
  • docker inspect of the created container confirms the documented profile verbatim: CapDrop=["ALL"], SecurityOpt=["no-new-privileges"], PidsLimit=512, Memory=2147483648, NanoCpus=2000000000, RestartPolicy=unless-stopped, dedicated network openclaw-cell-smoke-net, port bindings only 127.0.0.1:19100 -> 18789/tcp, and all four openclaw.fleet.* labels.
  • openclaw fleet upgrade smoke → completed in 7.3s wall; commit was health-gated (post-upgrade state running, health ok); the Gateway token env survived replacement (sha256 prefix of the token env identical before/after: 02e24ee4791a7cec).
  • openclaw fleet rm smoke --force --purge-data → 0 matching containers, 0 matching networks, tenant data dir removed.

Known gaps

  • Live pass ran on macOS/OrbStack; no Linux-host live pass (unit/integration coverage runs on Linux CI). Podman path is covered by tests only.
  • docs:map regenerated; docs link check passed in the build pass.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6468ee1fd2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

hostIdentity: HostIdentity | undefined;
user?: string;
}): Promise<CellContainerProfile["containerUser"]> {
const match = params.user?.match(/^(\d+):(\d+)$/u);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve inspected image users during upgrade

When a cell was created by root against rootful Docker, Fleet chowns the mounts to uid 1000 (src/fleet/service.runtime.ts:200-224) and the official image runs as USER node (Dockerfile:359-362). On a later fleet upgrade run by a non-root docker-group operator, Docker inspect reports Config.User as node, but this numeric-only match ignores that and falls through to the current host UID, so both the replacement and rollback containers are recreated with --user <operator uid>:<gid> and cannot read the 0700 mounts. Preserve a non-numeric inspected user, or map the official node user to 1000, instead of substituting the caller.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 11, 2026
@steipete
steipete force-pushed the claude/openclaw-multi-tenancy-ed3dc8 branch from 22ba8c9 to 2bcbad7 Compare July 11, 2026 18:15
@clawsweeper clawsweeper Bot removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 11, 2026
@steipete
steipete merged commit 5a54244 into main Jul 11, 2026
218 of 230 checks passed
@steipete
steipete deleted the claude/openclaw-multi-tenancy-ed3dc8 branch July 11, 2026 18:24
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@steipete

Copy link
Copy Markdown
Contributor Author

Follow-up live proof for the gap noted in the pre-merge verification (macOS-only live pass): the full fleet scenario now also passed on Linux against both supported runtimes, on a Blacksmith Testbox (Actions run https://github.com/openclaw/openclaw/actions/runs/29165538971, ALL_SCENARIOS_PASSED):

  • Docker (rootful) and Podman (rootless), real ghcr.io/openclaw/openclaw:latest, isolated OPENCLAW_STATE_DIR.
  • Hardening verified via inspect on both: all capabilities dropped (docker reports CapDrop=["ALL"]; podman equivalently enumerates the dropped default capability set), no-new-privileges, pids limit, unless-stopped restart policy, port bound to 127.0.0.1 only.
  • /healthz ok on the first probe for both cells; fleet logs --tail 5 (landed in feat(fleet): stream tenant cell logs through the supervisor #104669) streamed real gateway boot lines from inside both cells.
  • fleet upgrade: token env hash identical before/after on both runtimes.
  • fleet rm --force --purge-data: zero containers, zero networks, data dirs purged.

This closes the "no Linux-host live pass; Podman covered by tests only" gaps from the earlier verification comment.

steipete added a commit that referenced this pull request Jul 12, 2026
… cell diagnostics (#104828)

* feat(fleet): per-cell disk limits, egress policy, backup/restore, logs, and doctor

- fleet create --disk <size> caps the container writable layer via --storage-opt;
  unsupported storage backends fail create with an actionable support-matrix
  error, and the limit replays across upgrade/restore through a fleet-owned
  container label because Podman inspect has no HostConfig.StorageOpt.
- fleet create --network bridge|internal adds an opt-in no-egress mode on
  Podman (published loopback port keeps working, verified live); Docker
  internal cells are rejected fail-closed because Docker does not publish
  loopback ports on internal networks.
- fleet backup/restore: per-tenant 0600 tar archives with manifest tenant
  binding, symlink/hardlink rejection, byte and path-segment budgets,
  root-bounded extraction, atomic no-overwrite publish, lease fencing, and
  Gateway token rotation on restore; failures preserve displaced data and
  never leave a force-stopped or half-started cell serving silently.
- fleet logs: ownership-asserted, bounded, token-redacted on both streams,
  with a generation re-check so a concurrent restore cannot leak a rotated
  token.
- fleet doctor: read-only per-cell audit of ownership labels, health,
  hardening drift, loopback port binding, token presence, network egress
  mode, and 0700 state-dir permissions; any failed finding exits nonzero.
  Cross-runtime checks are grounded in live-verified Docker 28/Podman 4.9
  inspect shapes (CapDrop vs EffectiveCaps, missing StorageOpt, missing
  network containers map).

Related: #104436 (v1 shipped in #104527)

* fix(fleet): harden streamed log redaction and root restore ownership

- redacting stream writer honors target backpressure, retains secret-prefix
  overlap across forced long-line flushes, and never splits a token between
  emitted chunks
- root-invoked restores repair ownership for explicit non-root user mappings
  instead of leaving root-owned 0700 state trees
- fleet logs merges the shipped --follow streaming surface (#104669) with the
  v1.1 token-redaction contract

* fix(fleet): stream partial log lines live and report phase-accurate restore recovery paths

- the redacting log writer emits safe text on every chunk (retaining only a
  possible token prefix) so unterminated progress output streams immediately
- restore failure notes distinguish pre-swap, displaced, and swapped states so
  operators recover the correct tree, and an unavailable runtime inspection is
  reported as an unverified replacement instead of silence

* fix(fleet): reject backslash archive paths, guard stderr pipes, and validate disk-limit labels in doctor

- restore/backup path rules reject literal backslashes so a tampered entry
  cannot validate as one path and extract as another on POSIX
- fleet logs handles broken pipes on stderr as well as stdout
- fleet doctor fails malformed disk-limit labels that would break
  upgrade/restore replay instead of reporting them as passing
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 12, 2026
…penclaw#104527)

* feat(fleet): add openclaw fleet cell supervisor for multi-tenant hosting

* test(fleet): cover cell profile, registry, containers, and service flows

* docs(fleet): document multi-tenant hosting and the fleet CLI

* fix(fleet): verify upgrade replacements and release foreign-collision reservations

* fix(fleet): gate upgrade commit on replacement health

* docs(fleet): mark fleet experimental and pin its single-host scope

* test(fleet): make incomplete-profile casts explicit for test-type lane

* fix(state): regenerate kysely schema artifacts after rebase conflict
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 12, 2026
… cell diagnostics (openclaw#104828)

* feat(fleet): per-cell disk limits, egress policy, backup/restore, logs, and doctor

- fleet create --disk <size> caps the container writable layer via --storage-opt;
  unsupported storage backends fail create with an actionable support-matrix
  error, and the limit replays across upgrade/restore through a fleet-owned
  container label because Podman inspect has no HostConfig.StorageOpt.
- fleet create --network bridge|internal adds an opt-in no-egress mode on
  Podman (published loopback port keeps working, verified live); Docker
  internal cells are rejected fail-closed because Docker does not publish
  loopback ports on internal networks.
- fleet backup/restore: per-tenant 0600 tar archives with manifest tenant
  binding, symlink/hardlink rejection, byte and path-segment budgets,
  root-bounded extraction, atomic no-overwrite publish, lease fencing, and
  Gateway token rotation on restore; failures preserve displaced data and
  never leave a force-stopped or half-started cell serving silently.
- fleet logs: ownership-asserted, bounded, token-redacted on both streams,
  with a generation re-check so a concurrent restore cannot leak a rotated
  token.
- fleet doctor: read-only per-cell audit of ownership labels, health,
  hardening drift, loopback port binding, token presence, network egress
  mode, and 0700 state-dir permissions; any failed finding exits nonzero.
  Cross-runtime checks are grounded in live-verified Docker 28/Podman 4.9
  inspect shapes (CapDrop vs EffectiveCaps, missing StorageOpt, missing
  network containers map).

Related: openclaw#104436 (v1 shipped in openclaw#104527)

* fix(fleet): harden streamed log redaction and root restore ownership

- redacting stream writer honors target backpressure, retains secret-prefix
  overlap across forced long-line flushes, and never splits a token between
  emitted chunks
- root-invoked restores repair ownership for explicit non-root user mappings
  instead of leaving root-owned 0700 state trees
- fleet logs merges the shipped --follow streaming surface (openclaw#104669) with the
  v1.1 token-redaction contract

* fix(fleet): stream partial log lines live and report phase-accurate restore recovery paths

- the redacting log writer emits safe text on every chunk (retaining only a
  possible token prefix) so unterminated progress output streams immediately
- restore failure notes distinguish pre-swap, displaced, and swapped states so
  operators recover the correct tree, and an unavailable runtime inspection is
  reported as an unverified replacement instead of silence

* fix(fleet): reject backslash archive paths, guard stderr pipes, and validate disk-limit labels in doctor

- restore/backup path rules reject literal backslashes so a tampered entry
  cannot validate as one path and extract as another on POSIX
- fleet logs handles broken pipes on stderr as well as stdout
- fleet doctor fails malformed disk-limit labels that would break
  upgrade/restore replay instead of reporting them as passing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docker Docker and sandbox tooling docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. security Security documentation size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multi-tenant hosting: openclaw fleet cell supervisor MVP (per-tenant isolated instances)

1 participant