Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
b1fb774
feat(selfhost): one-box compose stack, Caddy, frps and object store (…
raphaeltm Nov 19, 2026
ed1c92c
fix(selfhost): check box ports as docker compose runs them (F21 L5)
raphaeltm Nov 19, 2026
57e400a
fix(selfhost): upgrade rebuilds an image only when its build inputs c…
raphaeltm Nov 19, 2026
ba0403f
feat(selfhost): GCP node trust bootstrap (pnpm selfhost:gcp-bootstrap)
raphaeltm Nov 19, 2026
a20f593
docs(selfhost): short operator README for the experimental box
raphaeltm Nov 19, 2026
6c92cff
test(selfhost): Docker live suite for the box runtime, CI job on self…
raphaeltm Nov 19, 2026
2ef8050
docs(selfhost): README describes upgrade retry and box-scoped compose…
raphaeltm Nov 19, 2026
8549ccb
style(quality): drop useless quote escapes in dependency-governance test
raphaeltm Nov 19, 2026
943d36a
ci(selfhost): run box static tests on deploy/selfhost changes; route …
raphaeltm Nov 19, 2026
509a63f
ci(selfhost): drop the workspace build from Validate Deploy Scripts
raphaeltm Nov 19, 2026
9f58d14
fix(selfhost): gcp-bootstrap refuses a shared pool, pins its APIs and…
raphaeltm Nov 19, 2026
28749ee
fix(selfhost): celld and frps run with no capabilities and a read-onl…
raphaeltm Nov 19, 2026
6ffc0c8
fix(selfhost): the bundled object store refuses a root secret under 2…
raphaeltm Nov 19, 2026
4f83ce8
fix(selfhost): reserve sam-mx's port and check box ports before anyth…
raphaeltm Nov 19, 2026
73a3bf2
fix(selfhost): strip client X-SAM-* headers on every route, not only …
raphaeltm Nov 19, 2026
f422403
test(selfhost): one Caddy runner, HTTPS client and Docker skip rule f…
raphaeltm Nov 19, 2026
096c6a7
test(selfhost): type the malformed-range cases for the selfhost type …
raphaeltm Nov 19, 2026
c4fac57
docs(tasks): L22 task file records PR 2 shipped and PR 3 progress
raphaeltm Nov 19, 2026
14bf564
chore(quality): reviewed baseline entry for the deploy harness fleet …
raphaeltm Nov 19, 2026
adaf1c0
fix(selfhost): resolve every compose-interpolated variable from the s…
raphaeltm Nov 19, 2026
17e44da
fix(selfhost): refuse a bare port for SAM_MX_LISTEN
raphaeltm Nov 19, 2026
a06613f
test(selfhost): verify Caddy's certificate in the live suite (Sonar S…
raphaeltm Nov 19, 2026
0a16c1e
ci(selfhost-live): install dependencies without lifecycle scripts (So…
raphaeltm Nov 19, 2026
23db935
fix(selfhost): run the Caddy image as a non-root user (Sonar S6471)
raphaeltm Nov 19, 2026
2661e08
chore(selfhost): clear Sonar code smells in the box scripts
raphaeltm Nov 19, 2026
795bf67
test(selfhost): read the non-root Caddy's environment as a privileged…
raphaeltm Nov 19, 2026
754d86c
docs(selfhost): README and gcp-bootstrap messages from the fresh BOX …
raphaeltm Nov 19, 2026
ba95e29
docs(selfhost): build steps share the box's egress; task file records…
raphaeltm Nov 19, 2026
7ae5db3
docs(tasks): format L22 task file
raphaeltm Nov 19, 2026
5bf419d
Merge remote-tracking branch 'origin/main' into sam/l22c-box-runtime-v3
raphaeltm Nov 19, 2026
cd175f7
fix(selfhost): GCP bootstrap trusts platform tokens only; refuse disa…
raphaeltm Nov 19, 2026
eba7151
fix(selfhost): Codex review round on L22c (overlays, state dir, profi…
raphaeltm Nov 19, 2026
662a092
fix(selfhost): refuse SAM_MX_LISTEN with an unbracketed IPv6 host
raphaeltm Nov 19, 2026
3e3ef8d
fix(selfhost): COMPOSE_PROFILES=* enables the mail profiles
raphaeltm Nov 19, 2026
5396252
fix(selfhost): refuse stale pool bindings; list-form build args; READ…
raphaeltm Nov 19, 2026
0991b27
fix(selfhost): port bounds in Caddy's start guard; repo-root build co…
raphaeltm Nov 19, 2026
08e2f60
Merge remote-tracking branch 'origin/main' into sam/l22c-box-runtime-v3
raphaeltm Nov 19, 2026
2cd4ba0
docs(tasks): L22c gates done; agent session proven on #2906 + #2907
raphaeltm Nov 19, 2026
a42fdbb
Merge remote-tracking branch 'origin/main' into sam/l22c-box-runtime-v3
raphaeltm Nov 19, 2026
e140443
fix(selfhost): refuse stray impersonators before granting node roles
raphaeltm Nov 19, 2026
7c00e5b
fix(selfhost): fail-closed service-account policy check in gcp-bootstrap
raphaeltm Nov 19, 2026
3f3c953
Merge remote-tracking branch 'origin/main' into sam/l22c-box-runtime-v3
raphaeltm Nov 19, 2026
4cefefc
fix(selfhost): refuse a reused node account with user-managed keys
raphaeltm Nov 19, 2026
34ffe66
docs(tasks): L22c merges now on Raphaël's decision; agent-session pro…
raphaeltm Nov 19, 2026
9d44181
Merge remote-tracking branch 'origin/main' into sam/l22c-box-runtime-v3
raphaeltm Nov 19, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,8 @@ updates:
directory: '/deploy/selfhost/sam-mx'
schedule:
interval: weekly
# Self-hosted Caddy build (caddy builder + runtime, both pinned by digest).
- package-ecosystem: 'docker'
directory: '/deploy/selfhost/caddy'
schedule:
interval: weekly
62 changes: 62 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ jobs:
browser-install: ${{ steps.filter.outputs.browser-install }}
go-modules: ${{ steps.filter.outputs.go-modules }}
selfhost-email: ${{ github.event_name == 'push' && 'true' || steps.filter.outputs.selfhost-email }}
# Path-filtered on main pushes too: the live suite runs only for self-host changes (D9).
selfhost-live: ${{ steps.filter.outputs.selfhost-live }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
Expand Down Expand Up @@ -150,6 +152,12 @@ jobs:
- 'scripts/selfhost/selfhost-migrations.ts'
# selfhost-inbound-email.test.ts builds this receiver (Self-host Email job only).
- 'deploy/selfhost/sam-mx/**'
# The self-host access-log redaction guard scans the API routes against this filter.
- 'deploy/selfhost/caddy/log-redaction.caddy'
# gcp-bootstrap-credential.test.ts runs the bootstrap against the fake gcloud and parses
# its output with the app's credential parser.
- 'deploy/selfhost/gcp-bootstrap.sh'
- 'scripts/selfhost/testdata/fake-gcloud-iam.mjs'
- 'scripts/quality/node-pool-boundary.ts'
- 'scripts/quality/node-pool-boundary/**'
- 'tests/fixtures/acp-activity-report-v1.json'
Expand All @@ -164,6 +172,8 @@ jobs:
- 'packages/terminal/**'
- 'packages/ui/**'
- 'tests/fixtures/diagnostic-secret-canaries.json'
# The self-host access-log redaction guard scans App.tsx against this filter.
- 'deploy/selfhost/caddy/log-redaction.caddy'
# Storybook (packages/ui) and the public site (apps/www, which depends on ui).
public-site:
- *workspace-root
Expand Down Expand Up @@ -251,6 +261,12 @@ jobs:
- 'scripts/deploy/**'
# Self-hosted (celld) packaging: config generator, deploy, upgrade, create-account.
- 'scripts/selfhost/**'
# The box files its static tests read: compose, Caddy fragments and start.sh, frps.toml,
# gcp-bootstrap.sh, .env.example.
- 'deploy/selfhost/**'
# gcp-bootstrap.test.ts pins the script's APIs and roles to the guided setup's.
- 'packages/shared/src/constants/gcp-required-apis.ts'
- 'apps/api/src/services/gcp-setup.ts'
# ...and what its tests read outside it: the self-host migration projection and the
# SMTP settings parser.
- 'apps/api/src/selfhost/**'
Expand Down Expand Up @@ -337,6 +353,12 @@ jobs:
- 'apps/api/tests/workers/smtp-client-workerd.test.ts'
- 'apps/api/tests/workers/support/smtp-native-entry.ts'
- '.github/workflows/selfhost-email-tests.yml'
# Self-host box runtime: the Docker live suite (landing plan D9). Self-host paths
# only: not packages/cloud-init (whose frpc.toml one live test renders) and not nightly.
selfhost-live:
- 'deploy/selfhost/**'
- 'scripts/selfhost/**'
- 'apps/api/src/selfhost/**'

# One job for the PR-body and PR-content checks. They used to be three jobs that each
# spent a runner slot on checkout and install for a few seconds of work. Each check
Expand Down Expand Up @@ -872,6 +894,8 @@ jobs:
- name: Enforce source file size limits
run: pnpm quality:file-sizes

# No workspace build here: neither these scripts nor their tests import a workspace package
# (the self-host tests that do live in the API unit suite and the Self-host Live job).
- name: Type check deployment scripts
run: |
pnpm exec tsc --project scripts/deploy/tsconfig.json --noEmit
Expand Down Expand Up @@ -1128,6 +1152,7 @@ jobs:
- pulumi-infra
- vm-agent-test
- selfhost-email
- selfhost-live
- cli-test
- vm-agent-integration
- devcontainer
Expand Down Expand Up @@ -1222,6 +1247,43 @@ jobs:
if: needs.changes.outputs.selfhost-email == 'true' && !github.event.pull_request.draft
uses: ./.github/workflows/selfhost-email-tests.yml

# The box runtime on real software (scripts/selfhost/live): Caddy built from
# deploy/selfhost/caddy/Dockerfile running the box's Caddyfile and start.sh (gateway 404s and
# path tricks, frp rate limit, X-SAM-* stripping, access log, keep-warm, mail collector), the
# pinned frpc/frps with the frpc.toml cloud-init renders, and the pinned celld (guarded fetch,
# shared in-flight reads). Needs Docker with host networking; no sudo or nftables.
selfhost-live:
name: Self-host Live (Docker)
needs: [changes]
if: (github.event_name == 'pull_request' || github.repository == 'raphaeltm/simple-agent-manager') && !github.event.pull_request.draft && needs.changes.outputs.selfhost-live == 'true'
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1

- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: '22'
cache: 'pnpm'

# No lifecycle scripts: nothing in this job needs one. celld runs esbuild's own bin entry
# (celld-binary.ts resolveEsbuild), which finds the platform binary without a postinstall.
- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts

# celld bundles API modules (worker-core's shared-flight) through their built dist/, and the
# live tests type-check against them.
- name: Build the API Worker's workspace dependencies
run: pnpm exec turbo run build --filter=@simple-agent-manager/api^...

- name: Type check the live tests
run: pnpm exec tsc --project scripts/selfhost/live/tsconfig.json --noEmit

- name: Run self-host live tests
run: pnpm selfhost:live-test

cli-test:
name: CLI Test
needs: [changes]
Expand Down
76 changes: 76 additions & 0 deletions apps/api/tests/unit/selfhost/caddy-log-redaction-routes.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/**
* The self-host box's Caddy access log (deploy/selfhost/caddy/log-redaction.caddy) replaces a
* credential that a route carries in its path. This scans the API routes for path parameters named
* like a credential, so a new one fails here until the redaction filter and this list cover it.
*
* It lives with the API unit tests, not with the self-host packaging tests, so that it runs when a
* route changes. The web app's routes have the same guard in
* apps/web/tests/unit/selfhost-log-redaction-routes.test.ts (the web suite runs on App.tsx
* changes). The redaction itself is proven against the real Caddy image in
* scripts/selfhost/live/access-log-keep-warm.live.test.ts.
*/
import { readdirSync, readFileSync, statSync } from 'node:fs';
import { join, relative, resolve } from 'node:path';

import { describe, expect, it } from 'vitest';

const REPO = resolve(import.meta.dirname, '../../../../..');
const ROUTES_DIR = resolve(import.meta.dirname, '../../../src/routes');
const REDACTION = resolve(
import.meta.dirname,
'../../../../../deploy/selfhost/caddy/log-redaction.caddy'
);

/** Route-definition strings with a path parameter named like a credential. */
const CREDENTIAL_ROUTE =
/(?:\.(?:get|post|put|patch|delete|all|on)\(|path=)\s*['"`]([^'"`]*\/:(?:[a-z]*token|sig|signature|secret|key|code|jwt|nonce)\b[^'"`]*)['"`]/gi;

/** Each known credential route and the logged path prefix the redaction filter rewrites. */
const KNOWN_CREDENTIAL_ROUTES: Record<string, string> = {
'apps/api/src/routes/ai-proxy-passthrough.ts /:wstoken/anthropic/v1/messages': '/ai/proxy/',
'apps/api/src/routes/ai-proxy-passthrough.ts /:wstoken/anthropic/v1/messages/count_tokens':
'/ai/proxy/',
'apps/api/src/routes/ai-proxy-passthrough.ts /:wstoken/openai/v1/chat/completions': '/ai/proxy/',
'apps/api/src/routes/bootstrap.ts /:token': '/api/bootstrap/',
'apps/api/src/routes/projects/members.ts /invite-links/:token': '/api/projects/invite-links/',
'apps/api/src/routes/projects/members.ts /invite-links/:token/request':
'/api/projects/invite-links/',
};

function routeFiles(dir: string): string[] {
return readdirSync(dir).flatMap((name) => {
const path = join(dir, name);
if (statSync(path).isDirectory()) return routeFiles(path);
return path.endsWith('.ts') && !path.endsWith('.test.ts') ? [path] : [];
});
}

/** The path prefixes the filter's `regexp "^(<a>|<b>|...)[^/?]*"` rule rewrites. */
function redactedPrefixes(): string[] {
const rule = /regexp "\^\(([^)"]+)\)\[\^\/\?\]\*" "\$\{1\}<redacted>"/.exec(
readFileSync(REDACTION, 'utf8')
);
return rule?.[1]?.split('|') ?? [];
}

describe('self-host access log: path credentials', () => {
it('every route with a credential in its path is on the redaction list', () => {
const found = routeFiles(ROUTES_DIR)
.flatMap((file) =>
[...readFileSync(file, 'utf8').matchAll(CREDENTIAL_ROUTE)].map(
(m) => `${relative(REPO, file)} ${m[1]}`
)
)
.sort();
expect(found.length).toBeGreaterThanOrEqual(6); // the scan itself works
expect(found).toEqual(Object.keys(KNOWN_CREDENTIAL_ROUTES).sort());
});

it('log-redaction.caddy rewrites the prefix each of those routes is served under', () => {
const prefixes = redactedPrefixes();
expect(prefixes.length).toBeGreaterThan(0); // the rule was found
for (const prefix of Object.values(KNOWN_CREDENTIAL_ROUTES)) {
expect(prefixes).toContain(prefix);
}
});
});
67 changes: 67 additions & 0 deletions apps/api/tests/unit/selfhost/gcp-bootstrap-credential.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* `pnpm selfhost:gcp-bootstrap` (deploy/selfhost/gcp-bootstrap.sh) prints the platform cloud
* credential an operator pastes into Admin -> Credentials. This runs the script against the fake
* `gcloud` its own tests use (scripts/selfhost/gcp-bootstrap.test.ts) and parses the printed JSON
* with the parser the app uses for every node (parseGcpCredential), so a change on either side
* fails here. It lives with the API unit tests because the parser imports workspace packages
* through their built dist/, which the API unit suite builds and the self-host packaging tests do
* not need.
*/
import { spawnSync } from 'node:child_process';
import { chmodSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join, resolve } from 'node:path';

import { afterEach, beforeEach, describe, expect, it } from 'vitest';

import { parseGcpCredential } from '../../../src/services/provider-credential-codecs';

const SCRIPT = resolve(import.meta.dirname, '../../../../../deploy/selfhost/gcp-bootstrap.sh');
const FAKE_GCLOUD_IAM = resolve(
import.meta.dirname,
'../../../../../scripts/selfhost/testdata/fake-gcloud-iam.mjs'
);
const ISSUER = 'https://api.vmtest.example.org';

let dir: string;

beforeEach(() => {
dir = mkdtempSync(join(tmpdir(), 'gcp-bootstrap-credential-'));
writeFileSync(
join(dir, 'gcloud'),
`#!/usr/bin/env bash\nexec node ${JSON.stringify(FAKE_GCLOUD_IAM)} "$@"\n`
);
writeFileSync(
join(dir, 'curl'),
`#!/usr/bin/env bash\nprintf '{"issuer":"%s"}' ${JSON.stringify(ISSUER)}\n`
);
chmodSync(join(dir, 'gcloud'), 0o755);
chmodSync(join(dir, 'curl'), 0o755);
});
afterEach(() => rmSync(dir, { recursive: true, force: true }));

describe('gcp-bootstrap.sh output', () => {
it('prints JSON the credential parser accepts once ZONE is filled in (box round R12)', () => {
const result = spawnSync('bash', [SCRIPT, '--project', 'sam-vm-test', '--api-url', ISSUER], {
encoding: 'utf8',
env: { PATH: `${dir}:${process.env.PATH ?? ''}`, STATE: dir, HOME: dir },
timeout: 60_000,
});
expect(result.status, result.stderr).toBe(0);
const json = /^\{"version":1,"provider":"gcp".*\}$/m.exec(result.stdout)?.[0];
expect(json).toBeDefined();
// The operator replaces ZONE; the result is what the app stores and parses for every node.
const parsed = parseGcpCredential(json!.replace('"ZONE"', '"europe-west1-b"'));
expect(parsed).toMatchObject({
authType: 'workload-identity',
gcpProjectId: 'sam-vm-test',
gcpProjectNumber: '123456789012',
serviceAccountEmail: 'sam-nodes@sam-vm-test.iam.gserviceaccount.com',
wifProviderId: 'sam-api',
defaultZone: 'europe-west1-b',
});
expect(parsed.authType === 'workload-identity' && parsed.wifPoolId).toMatch(
/^sam-[0-9a-f]{8}$/
);
});
});
42 changes: 42 additions & 0 deletions apps/web/tests/unit/selfhost-log-redaction-routes.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* The self-host box's Caddy access log (deploy/selfhost/caddy/log-redaction.caddy) replaces a
* credential that a route carries in its path. This scans the app's client routes (App.tsx: the
* box serves the app's HTML document for them, so they reach the access log) for path parameters
* named like a credential, so a new one fails here until the redaction filter and this list cover
* it. The API routes have the same guard in
* apps/api/tests/unit/selfhost/caddy-log-redaction-routes.test.ts.
*/
import { readFileSync } from 'node:fs';
import { resolve } from 'node:path';

import { describe, expect, it } from 'vitest';

const APP = resolve(__dirname, '../../src/App.tsx');
const REDACTION = resolve(__dirname, '../../../../deploy/selfhost/caddy/log-redaction.caddy');

/** `<Route path="...">` values with a path parameter named like a credential. */
const CREDENTIAL_ROUTE =
/path=\s*['"`]([^'"`]*\/:(?:[a-z]*token|sig|signature|secret|key|code|jwt|nonce)\b[^'"`]*)['"`]/gi;

/** Each known credential route and the logged path prefix the redaction filter rewrites. */
const KNOWN_CREDENTIAL_ROUTES: Record<string, string> = {
'/projects/invite/:token': '/projects/invite/',
};

describe('self-host access log: path credentials in app routes', () => {
it('every app route with a credential in its path is on the redaction list', () => {
const found = [...readFileSync(APP, 'utf8').matchAll(CREDENTIAL_ROUTE)].map((m) => m[1]);
expect(found.sort()).toEqual(Object.keys(KNOWN_CREDENTIAL_ROUTES).sort());
});

it('log-redaction.caddy rewrites the prefix each of those routes is served under', () => {
const rule = /regexp "\^\(([^)"]+)\)\[\^\/\?\]\*" "\$\{1\}<redacted>"/.exec(
readFileSync(REDACTION, 'utf8')
);
const prefixes = rule?.[1]?.split('|') ?? [];
expect(prefixes.length).toBeGreaterThan(0); // the rule was found
for (const prefix of Object.values(KNOWN_CREDENTIAL_ROUTES)) {
expect(prefixes).toContain(prefix);
}
});
});
Loading
Loading