Repository navigation
L22c: self-host box runtime (compose, Caddy, frps, live suite) - #2906
Conversation
…L22c) Brings the box runtime from the integration branch in plaintext mode: celld, Caddy, frps, the bundled object store, the mail collector and sam-mx. Without the egress fence, key agent, docker proxy and metadata proxy (and the files only they read: celld.env, egress-fence.nft, key-agent/agent.env, celld/start.sh), and without the key-rotation Caddy fragment. F11: the two local images (caddy, sam-mx) are never pulled (pull_policy: never) and are built only by an explicit `docker compose build` or when missing. The Caddy Dockerfile pins both images by digest and both modules by version, fetches modules only from proxy.golang.org with sum.golang.org verification and GOTOOLCHAIN=local, and fails unless the binary carries exactly those versions. Its build context is empty (.dockerignore), so Caddyfile edits never touch the build. F21: the gateway-route variant matcher reads the raw request target and accepts any encoding depth of every character of "api" and "self-host", backslash separators and absolute-form targets (L1), matches only an "api" segment followed by a "self-host" segment instead of any path containing "self-host" (L6), refuses dot-segment targets naming self-host in any encoding, and caddy-ratelimit limits frp connections per client address (L7, SAM_FRP_LOGIN_RATE_LIMIT_*). start.sh refuses any box port inside the lease range, as compose actually runs it (L5). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Compose takes a variable from the shell before the .env, so `CELLD_INTERNAL_PORT=20001 docker compose up` put celld's operator API inside the lease range the deploy had checked against the .env only. The deploy (and upgrade's box loader) now apply shell overrides of every BOX_RESERVED_PORTS name before the range check and report each one. The deploy harness strips those names from the test runner's environment so the suite stays hermetic. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hanged (F11) `selfhost:upgrade` ran `docker compose up -d --build` whenever any compose input changed, rebuilding (with network access) on every such upgrade. It now compares each locally built service's build section in docker-compose.yml at both refs and the files in its build context (a context whose .dockerignore is `*` counts only its Dockerfile), builds only the changed services the box runs with an explicit `docker compose build <service>`, and restarts with a plain `up -d`. The printed rollback rebuilds the same way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The integration branch's gcp-bootstrap.sh, trimmed to the node trust a plaintext box needs: the install-dedicated workload identity pool, the issuer-scoped OIDC provider, the node service account and its bindings, and the credential JSON to paste in Admin -> Credentials. Without the Cloud KMS key for sealed secrets (--kms, --kms-only, key versions) and without --teardown and its created-resources record, which only teardown read. Adds the selfhost:gcp-bootstrap and selfhost:live-test scripts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replaces the integration branch's ~1,400-line README with a short operator note, marked as an experimental test-box setup and not a supported deployment: prerequisites, the fresh-install sequence, upgrade (no automatic backup), image builds, R2_S3_REGION for s3:// stores, the lease port range and gateway secret, the frp rate limit, email, and what is not included yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-host paths (D9) Brings the live suite from the integration branch: caddy-fragments, access-log-keep-warm, mail-collector, frpc-tls, celld-redirect and shared-flight-cancel, with the harness and celld lab. Caddy runs from the image deploy/selfhost/caddy/Dockerfile builds, through start.sh, as compose runs it. New cases: encoded letters at any depth, backslash separators, dot segments and absolute-form targets never reach the gateway route (L1); public paths naming self-host still reach celld (L6); frp connections over the per-address limit get 429 (L7); start.sh refuses a box port inside the lease range and bad rate-limit values (L5). shared-flight-cancel loses its key agent case (sealed secrets are held) and talks to a plain slow upstream instead. CI: a Self-host Live (Docker) job runs `pnpm selfhost:live-test` only when deploy/selfhost, scripts/selfhost or apps/api/src/selfhost change, not for packages/cloud-init and not nightly. Validate Deploy Scripts builds the API's workspace dependencies first (the GCP bootstrap test parses with the real credential codec). Dependabot watches the Caddy Dockerfile's digests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… commands The upgrade from PR 2 records an unfinished upgrade in .state/upgrade-pending.json and retries from it, and runs and prints every compose command with the box's .env and selected compose files; the explicit image rebuild (F11) does the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ESLint no-useless-escape: \' inside a template literal is just '. No behaviour change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…redaction guards run with route changes deploy-scripts now selects deploy/selfhost/**, so compose, Caddy and gcp-bootstrap changes run the static tests that read them. The credential-route scan moves out of scripts/selfhost: the API half into an API unit test, the App.tsx half into a web unit test, so each runs with the suite CI already selects for those routes (App.tsx in the API unit filter would have started the API suite on every web routing change). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Only two things needed built packages: gcp-bootstrap.test.ts parsed the printed credential with parseGcpCredential (imports shared and worker-core dist), and the scripts/selfhost type check covered live/, whose shared-flight test imports worker-core. The parser contract test moves to the API unit suite, which builds and also runs when the parser changes; live/ gets its own tsconfig, type-checked in the Self-host Live job after its build. pnpm selfhost:test now passes with every @simple-agent-manager import aliased to a missing module. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… roles to the guided setup - An existing --pool-id is reused only when every provider in it (deleted ones too) is PROVIDER_ID trusting this install's issuer: the service account binding is pool-wide. - The binding comment no longer claims the pool is this install only: it admits any token the install signs for the provider's audience, and SAM does not yet stop a user credential from naming the pool (SAM task 01M7SB8FRZ08M5NEX9WGM74X61). README and the script say to use a project dedicated to SAM's nodes. - NODE_APIS / NODE_ROLES document why cloudresourcemanager, aiplatform and roles/aiplatform.user are left out; a test fails when the script drifts from GCP_REQUIRED_APIS or gcp-setup.ts SA_PROJECT_ROLES. - A trailing flag with no value is a clear error; --help prints the whole header. - README: the access log redacts path credentials on the listed routes only, and an .env build-arg change needs docker compose build caddy (upgrade never sees it). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…y root Both listen only on loopback ports above 1023. celld writes only CELLD_WATCH (its volume) and gets a tmpfs /tmp; checked on the pinned image with cap_drop ALL, no-new-privileges and a read-only root: a Worker and a SQLite Durable Object serve and keep their state across a restart, and /tmp stays empty. frps logs to the console and starts read-only. A static test pins the settings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…4 characters Its root credential reads every Worker secret in the fleet bucket. The entrypoint check moves from 8 to 24 characters (.env.example and README say so); a test runs the compose entrypoint under /bin/sh with the image entrypoint stubbed. The deploy test fixture's fleet secret is lengthened to match. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ing starts S4: - SAM_MX_LISTEN (sam-mx's public SMTP listener, default :25; the port after the last ':') joins the reserved box ports: the deploy, upgrade and Caddy's start.sh refuse it inside the lease range. compose passes it to Caddy. - loadBoxEnv (box-settings.ts) reads the .env, applies shell port overrides and checks the range, so selfhost:deploy refuses before writing platform keys and selfhost:upgrade before it fetches, checks out or runs docker compose. - start.sh checks each lease-range bound is a plain number: a malformed one such as 1:2 made the -ge test error, which if read as false, silently skipping the check. - celld, frps and the mail collector have no capabilities, so their ports must be 1024 or above. A6: deploy.ts and upgrade-lib.ts share loadBoxEnv instead of each parsing the .env and applying overrides; SELFHOST_DIR lives in deploy-steps.ts and COMPOSE_PATH derives from it. The live harness's caddyBoxEnv takes its names from BOX_RESERVED_PORTS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…node sockets A site-level request_header -X-SAM-* sorts before every handle, so the catch-all route to celld drops them too, and node-ws.caddy's forward_auth still copies the Worker's own X-SAM-* answer afterwards (the live forward_auth tests pass unchanged). A live test sends forged X-SAM-* headers to api, app and a preview host and checks celld sees none; it fails with the directive removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…or the live suite A3: caddy-fragments, access-log-keep-warm and mail-collector each built the same docker run (host network, cap-drop ALL + NET_BIND_SERVICE, the caddy dir, start.sh), logs reader, TLS wait, teardown and https client. harness.ts now has startCaddy, runCaddyToExit and httpsGet; DOCKER and hasDocker move there from celld-lab.ts and every docker call uses DOCKER; every Docker test uses skipWithoutDocker (skipped without Docker locally, never in CI). celld-lab.ts's header names its real consumers, and celld-redirect writes its project with writeProject. S6: start() and celld deploy pass children an allowlisted environment (PATH, HOME, TMPDIR, LANG, RUST_LOG, DOCKER_*) instead of the whole host environment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…check Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@coderabbitai review |
Action not completed
|
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c4fac57ca6
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…fixture The PR-range Gitleaks scan flags the deploy test harness's fixed objectstore secret, lengthened in 6ffc0c8 to meet the 24-character minimum. It is a synthetic fixture; the entry pins that exact finding and expires in 30 days. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hell, not only ports Docker Compose takes every variable its files interpolate from the invoking shell before --env-file, but the deploy and upgrade applied shell precedence only to BOX_RESERVED_PORTS. An exported CELLD_BUCKET or SAM_DOMAIN made selfhost:deploy publish with the .env value while docker compose ran celld and Caddy with the shell's. loadBoxEnv now collects the variables referenced in docker-compose.yml and every file the box's COMPOSE_FILE selects (composeFilesFor, moved to compose-env.ts so box-settings can reuse it without an import cycle), and applies a differing shell value for each, plus every box port. Each override is reported by name only. withComposePortOverrides is renamed withComposeShellOverrides; README and .env.example describe the general rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SAM_MX_LISTEN=2525 passed both the deploy's and Caddy start.sh's checks, but sam-mx hands it to
Go's net.Listen("tcp", "2525"), which fails with "missing port in address", so the inbound-mail
service restart-looped. Both validators now require a listen address with a host/port separator,
[host]:port (:2525, 0.0.0.0:2525, [::]:2525), and refuse a bare port with a clear message. The
live Caddy harness passes `:<port>` for listen addresses.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…4830, S5527) httpsGet turned TLS verification off (rejectUnauthorized: false). The live harness now reads the root of the Caddy container's internal CA (/data/caddy/pki/authorities/local/root.crt) once Caddy starts, and httpsGet trusts exactly that root with `ca` and checks the certificate against the request's host (servername, lowercased), so certificate and hostname checks stay on. Every request's Host is inside the *.SAM_DOMAIN wildcard Caddy serves, so no test needed a mismatch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nar S6505) Nothing in the job needs one: celld runs esbuild's own bin entry (resolveEsbuild), which finds the platform package without esbuild's postinstall, and the build and live tests pass after a fresh `pnpm install --frozen-lockfile --ignore-scripts`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Docker compose reads `*` as every profile, so the collector and sam-mx start; mailCollectorEnabled and inboundMailEnabled now agree, so the deploy configures the Worker for the services that actually run. Codex review. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Codex review 5974721639 ( |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3e3ef8d301
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…ME compose cwd Codex review on 3e3ef8d: - GCP bootstrap (P1): add-iam-policy-binding only adds a member, so a node account reused after a --pool-id change stayed impersonable through the old pool. Refuse while any other member holds workloadIdentityUser, with the remove-iam-policy-binding command. - imageRebuilds: normalise list-form build args to a mapping before the merge by name, so a base-only arg change still rebuilds. - README fresh install: run compose from deploy/selfhost so .env's COMPOSE_FILE overlays apply (a -f replaces them). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5396252025
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…ntext Codex review on 5396252: - caddy/start.sh: a compose run from another shell can override a port the deploy never saw; refuse values outside 1-65535 (1024 minimum for the services with no capability), as box-settings does. - imageRebuilds: an overlay build context at the repository root (`../..`) normalised to '.', so no changed path matched; count every non-README file there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0991b27ff4
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 08e2f605a8
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2cd4ba00dc
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a42fdbb162
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Codex P1 on a42fdbb: the workloadIdentityUser scan ran after the project role grants, so a reused service account with an unrelated impersonator gained Compute Instance Admin and Security Admin before the script refused. The scan now runs before any grant; the rotation test asserts that neither the impersonation binding nor a project role is granted before the refusal (red with the old order). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e140443386
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Security re-check (MEDIUM-1, LOW-1/2/3) and Codex P1 on e140443: - Read the node account's IAM policy as JSON and parse it strictly (node): refuse output that is not a policy, any conditional binding, and any member other than this pool's workloadIdentityUser on ANY role (serviceAccountTokenCreator, serviceAccountUser, ...). A filter that silently matched nothing could otherwise let the grants through. - Key the check on the first existence probe instead of a second one that a transient error could skip; a just-created account is skipped. - Drop bash-4-only ${x,,}; sanitise the member printed in the remedy. Each guard deleted once turns its test red. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3f3c953d71
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Codex P1 on 3f3c953: a user-managed key authenticates as the service account with no IAM binding, so the policy scan could not see who holds one, and the script then granted Compute Instance Admin and Security Admin. Before any grant, list the account's user-managed keys (--format=json, parsed strictly) and refuse any key or unparseable output; nodes use workload identity only. Each guard deleted once turns its test red. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4cefefcecf
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
Removing |
…of moves to H2 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 34ffe660a4
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|



Summary
L22c is the third and last slice of L22, self-host core packaging. It lands the one-box runtime on main: the compose stack, Caddy front door, frps, object store, Docker live tests and a self-host-only CI job, plus the operator README (marked experimental). Every file is self-host only. The only changes under
apps/are three new test files, so the Cloudflare Worker is unchanged. L22a (#2901) and L22b (#2902) are already shipped. Landing plan: idea01M72M9AEB933ZY8269D376DKC, row L22. Task:tasks/active/2026-11-19-l22-selfhost-core-packaging.md.What lands
deploy/selfhost/docker-compose.yml: celld, Caddy, frps, objectstore and objectstore-init, mail-collector, and sam-mx (profile). Every pulled image is pinned by digest. Caddy and sam-mx are built locally withpull_policy: never. celld and frps run withcap_drop: [ALL],no-new-privilegesand a read-only root; celld also gets a tmpfs at/tmp. Everything except Caddy (80/443) and sam-mx (25) binds loopback.deploy/selfhost/caddy/):start.shchecks the box ports exactly as compose resolves them.X-SAM-*headers are stripped at site level.frps/frps.toml: loopback bind;allowPortslimited to the lease range; one port per client. The Worker plugin gates every Login, NewProxy, Ping and NewWorkConn.gcp-bootstrap.sh(pnpm selfhost:gcp-bootstrap): creates the installation's node pool, provider and service account.GCP_REQUIRED_APISandSA_PROJECT_ROLESby a drift test.scripts/selfhost/image-rebuilds.ts,upgrade-lib.ts):docker compose build <svc>, and only if the box runs that service. It then runsup -dwithout--build, so an unchanged box never runs an image build./api/self-host/...only)./~!frp, beforereverse_proxy.s3://operator store needsR2_S3_REGION.scripts/selfhost/live/,pnpm selfhost:live-test):deploy/selfhost/**,scripts/selfhost/**andapps/api/src/selfhost/**. It does not use thepackages/cloud-initfilter and has no nightly schedule.Not in this PR
port_range_cooling_down→ retryable): this is Worker code (apps/api/src/selfhost/reverse-tunnel/leases.tsplus the shared node-failure path). The coordinator accepted it as tracked in idea01M7MK0PCF032CT45Z45HRSDEQ.Validation
pnpm selfhost:test: 19 files, 323 tests.pnpm selfhost:live-testwith real Docker: 6 files, 208 tests. No containers are left behind.apps/apitests/unit/selfhost: 14 files, 106 tests.ci-suite-selection: 70/70.pnpm quality:scripts:test: 1545/1549 under load. The 4 failures were 5 s timeouts in the untoucheddeployment-workflow-hardening.test.ts, which passes 71/71 when run alone.scripts/selfhost/tsconfig.jsonandscripts/selfhost/live/tsconfig.json.quality:file-sizesand actionlint are clean.scripts/quality/gitleaks-reviewed-baseline.json). Local PR-range and current-tree scans pass.selfhost:testpasses with every@simple-agent-manager/*import aliased to a missing module.Staging Verification (REQUIRED for all code changes — merge-blocking)
apps/are new tests. The import-graph test from L22b (apps/api/tests/unit/selfhost/selfhost-only-modules.test.ts) keepsapps/api/src/selfhost/andscripts/out of the Cloudflare entry graph.Staging Verification Evidence
BOX round R18, 2026-11-19, GCP project
sam-vm-control-plane-test.Teardown: the old box was fully removed. That covered the VM and disk, the fleet bucket contents, the DNS records, the node WIF pool, its providers and the
sam-nodesSA.Rebuild: done from
c4fac57caby followingdeploy/selfhost/README.mdonly, about 13 minutes from VM creation to a deployed install. The box was then upgraded to795bf674f.pnpm selfhost:deployexited 0./health200. Let's Encrypt wildcard certificate via Cloud DNS./api/auth/meshows superadmin.selfhost:create-accountmade a second account, which also signed in by email.01M7SFB13T…, transportreverse-tunnel. Its lease (port 20000) was created before the VM. frps logged plugin-allowed Login/NewProxy and listened on 127.0.0.1:20000. First heartbeat came 1 min 50 s after create.system-inforeturned 200 through the tunnel. On delete the lease went toreleased/runtime_terminatedand the VM was gone.node_reverse_tunnel_leasesis present with its schema and 4 indexes. Ledger row0255_node_reverse_tunnel_leases.sqlapplied 08:31:58.795bf674fcaddy: its build inputs changed, and sam-mx was not running. celld and frps were not restarted. Same certificate serial, with no ACME activity. Caddy runs as uid 7101.caddy-volumesexited 0. The admin signed in again, and the node's frpc reconnected within 2 s. A same-SHA upgrade is a no-op.platform_credentialsheld only GCP, and the AI proxy config showed no credentials), so it was not run. OWED.GITHUB_NOT_CONNECTED). The OpenCode key was stored but never used. The README says this under "Not included yet".The README findings from the round are fixed in
754d86cde. They covered the build toolchain prerequisite, creating.state/beforesecrets.env, the GCP propagation window and price backoff, the Hetzner default location for API-created nodes, the missing repository source, and gcp-bootstrap's retry notice and refusal message.Worker defects seen again from earlier rounds (Worker code, out of L22 scope, reported to the coordinator):
DEFAULT_VM_LOCATION = 'nbg1'breaks GCP-only installs.kidiskey-1970-01.Cleanup: the node VM, temporary SSH key and firewall rule, and local tokens were removed. The box was left running at
795bf674fwith no nodes, as in previous rounds. BOX FREE was posted on the channel.UI Compliance Checklist (Required for UI changes)
N/A: no UI changes.
End-to-End Verification (Required for multi-component changes)
Data Flow Trace
Browser to
api.<domain>: Caddy, withsam_client_ipoverwriting client-IP headers andX-SAM-*stripped, proxies to celld on loopback (docker-compose.yml,Caddyfile). celld runs the L22b-generated entry (renderCelldMain()importssrc/index.tsandsrc/selfhost/build.ts).Node to
/~!frp: Caddy applies the rate limit, then proxies to frps on 127.0.0.1. frps calls the plugin for each operation, celld's gateway authenticates it, and the reverse-tunnel lease check runs.Upgrade:
selfhost:upgradecallsloadBoxEnv, which validates the ports. It writes the pending record, checks out the target, appliesimageRebuilds()(build changed services only), runsdeploy, thenup -d.Untested Gaps
The live suite covers every container except a GCP-provisioned node and real ACME DNS, and the BOX fresh install covers both. Not covered anywhere yet: an agent session on a box (no repository source until hosted git lands), L19 and L13. All three are owed, as above.
Post-Mortem (Required for bug fix PRs)
N/A: feature slice. F11 and F21 are review findings from the integration branch.
Specialist Review Evidence (Required for agent-authored PRs)
needs-human-reviewlabel added and merge deferred to human: N/A, all completed.5bf419de4(main7de72d642+ this PR): PASS, 0 CRITICAL / 0 HIGH. The earlier HIGH (gcp-bootstrap.shpool/*with an issuer-only condition) is closed by #2905: one owner per pool, enforced at save and before signing. MEDIUM fixed incd175f708: the pool was claimable by a user before the operator saved the platform credential. The provider condition now also requiresassertion.user_id.startsWith('platform:'), and re-running narrows an older provider. LOWs left: the claim-release doc gives only thewrangler d1path, with no celld equivalent; a 409 does not name the conflicting owner; celld D1batchsemantics were not verified for the claim race. Earlier MEDIUMs did not regress (cap_drop/no-new-privileges/read_only; site-levelX-SAM-*strip; frp Login rate limit). First-pass findings, kept from before: MEDIUMs fixed (shared-pool refusal; celld/frps hardening; 24-character objectstore secret; sam-mx port reserved and checked; malformed range refused); LOWs fixed (site-levelX-SAM-*strip, live-harness env allowlist, README build-arg note, flag-without-value error); LOWs left (literal-path redaction; per-address frp Login limit). Delta re-check of gcp-bootstrap.sh changes5bf419de4..e14044338: PASS (0 CRITICAL/HIGH). Fixed in7c00e5b0f: MEDIUM-1, where theget-iam-policyfilter could fail open; LOW-1, where a second existence probe could skip the check; LOW-2,${x,,}; LOW-3 and Codex P1, where only workloadIdentityUser was checked. The policy is now read as JSON and parsed strictly; any non-pool member on any role, any conditional binding and any unparseable output are refused before every grant. Confirmation review of7c00e5b0f: PASS (0 CRITICAL/HIGH/MEDIUM). It ran the parser underset -euo pipefail; all malformed inputs and a missing node fail closed. LOWs deferred to idea01M7SXD931W6SR8S8PT0EXPNT2(items 6 and 7): gcloud's policy version for conditional bindings is unverified against real gcloud (bounded by the dedicated-project requirement), and node is not preflighted (fails closed). Codex P1 on3f3c953d7: a reused account with user-managed keys was not refused. Fixed in4cefefcec(the user-managed key list is parsed strictly and any key refused before the grants). Adversarial review at4cefefcecof every remaining way to act as a reused account: PASS (0 CRITICAL/HIGH); the key check has no fail-open path. MEDIUMs deferred with fix plans to idea01M7SXD931W6SR8S8PT0EXPNT2item 8: project, folder or organisation grants (M1), workloads already running as the account (M2), extra roles on a reused account (M3). All are outside the account's own policy, bounded by the README's dedicated-project requirement, and apply equally to a newly created account.deploy/selfhost/**was missing from the deploy-scripts filter, and the route redaction guard ran with no route filter. Fixed: the filter is added, and the guard moved to API and web tests that their suites select. Pinned inci-suite-selection. MEDIUMs: workspace build removed from Validate Deploy Scripts; live harness deduplicated (startCaddy,httpsGet,skipWithoutDocker); gcp-bootstrap pinned toGCP_REQUIRED_APIS/SA_PROJECT_ROLESwith documented omissions. LOWs: README logging claim narrowed;loadBoxEnvhelper;COMPOSE_PATHderived fromSELFHOST_DIR; celld-lab header.ask:01M7SVG6J5MJT8Q7T4EE5ERH2N, 2026-11-19: "Merge L22c now; the agent-session proof moves to H2". The proof is owned by hosted git #2907 (task01M7SR1B79DTRBBW2J2H226MGB), which already passed it on combined heade7ac643bcontaining this PR's code: agent task01M7T0VJHK2381FBXA2VG6PM8Qreplied "pong", push164c22e3dwas verified by a separate clone. The validator's re-run with H2's evidence found no other CRITICAL or HIGH. Earlier run on754d86cde: the live suite passed (6 files, 208 tests); MEDIUM and LOW findings were addressed or tracked (F21 L4 → idea01M7MK0PCF032CT45Z45HRSDEQ). L13 and L19 are still owed and are not acceptance criteria.CodeRabbit Review Evidence (Required for agent-authored PRs)
CodeRabbit Notes
coderabbit-reviewlabel applied when the PR opened (ready). The "Request CodeRabbit review" workflow succeeded.c4fac57ca:pool/*) is the security HIGH above. It is blocked on fix(security): one owner per GCP workload identity pool #2905.SAM_MX_LISTENport. A bare port is accepted, but Go'snet.Listenneedshost:port. Being fixed.pool/*: closed by fix(security): one owner per GCP workload identity pool #2905, plus the platform-only provider condition (cd175f708).cd175f708), and disabled service account plus reused provider audience (eba71510c).--state-dirpassed to compose, and shellCOMPOSE_PROFILES/COMPOSE_FILE(eba71510c).SAM_MX_LISTENwith an unbracketed IPv6 host (662a092f9).COMPOSE_PROFILES=*now enables the mail profiles, as it does in compose (3e3ef8d30).3e3ef8d30: a service account reused after a--pool-idchange kept the old pool's binding. The script now refuses while another member holds workloadIdentityUser. P2: list-form build args are merged by name. P2: the README fresh install runs compose fromdeploy/selfhost, soCOMPOSE_FILEoverlays apply (539625202).539625202: Caddy's start guard now refuses ports outside 1-65535, with a 1024 minimum for services with no capability. P2: a build context at the repository root now counts every changed file (0991b27ff).a42fdbb16: gcp-bootstrap granted the node's project roles before refusing a stray workloadIdentityUser member. The refusal now runs before any grant (e14044338). The box proof did not run gcp-bootstrap, so it still holds.0991b27ff, 1 on08e2f605a, 2 on2cd4ba00d: malformed bracketedSAM_MX_LISTENin start.sh; Markdown as a build input; 2 on4cefefcec:up -dwithout--remove-orphans; build labels and extra_hosts not merged by key): duplicate box listener ports are not rejected (box-settings / start.sh). an overlay'sbuild.additional_contextsis not watched by the upgrade's rebuild check, and retrying a failed upgrade with a different--tocan skip a rebuild. I did not push again because H2's box proof was running on this exact head. Tracked with a fix and test plan in SAM idea01M7SXD931W6SR8S8PT0EXPNT2.Exceptions (If any)
apps/webchange is a new unit test,apps/web/tests/unit/selfhost-log-redaction-routes.test.ts, which guards that path-credential routes inApp.tsxare on Caddy's redaction list. No UI code changed.Agent Preflight (Required)
Classification
External References
Caddy 2 (route ordering,
request_header,forward_auth, caddy-ratelimit), frp 0.6x server plugin protocol, Docker Compose (pull_policy,read_only,cap_drop), and the GCP IAM workload identity pool and provider CLI. All are as used and recorded onsam/selfhost-pass-2. The live suite runs the real pinned images.Codebase Impact Analysis
deploy/selfhost/**andscripts/selfhost/**(self-host only), three new tests underapps/api/tests/unit/selfhostandapps/web/tests/unit,.github/workflows/ci.yml(filters plus the selfhost-live job),.github/dependabot.yml,package.jsonscripts,scripts/quality/ci-suite-selection.test.ts, and an escape fix inscripts/quality/dependency-governance.test.ts. Cloudflare Worker graph: unchanged.Documentation & Specs
deploy/selfhost/README.mdis the operator guide, marked experimental. It coversR2_S3_REGION, upgrade retry, rebuilds, the dedicated GCP project and logging limits. Public docs are not updated, because self-hosting is deliberately not publicised yet. The task file is updated.Constitution & Risk Check
Principle XI: ports, ranges, rate limits and timeouts are
.env-configurable with defaults. Main risks:🤖 Generated with Claude Code