@rizom/ops 0.2.0-alpha.6 → 0.2.0-alpha.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +6 -3
  2. package/dist/age-key-bootstrap.d.ts +17 -0
  3. package/dist/brains-ops.js +305 -149
  4. package/dist/cert-bootstrap.d.ts +2 -2
  5. package/dist/content-repo.d.ts +13 -0
  6. package/dist/default-user-runner.d.ts +1 -1
  7. package/dist/deploy.js +24 -24
  8. package/dist/index.d.ts +3 -0
  9. package/dist/index.js +305 -149
  10. package/dist/load-registry.d.ts +19 -3
  11. package/dist/onboard-user.d.ts +2 -2
  12. package/dist/parse-args.d.ts +2 -0
  13. package/dist/push-secrets.d.ts +1 -1
  14. package/dist/reconcile-all.d.ts +2 -2
  15. package/dist/reconcile-cohort.d.ts +2 -2
  16. package/dist/reconcile-lib.d.ts +4 -2
  17. package/dist/run-command.d.ts +0 -1
  18. package/dist/run-subprocess.d.ts +1 -0
  19. package/dist/schema.d.ts +100 -0
  20. package/dist/secrets-encrypt.d.ts +32 -0
  21. package/dist/secrets-push.d.ts +1 -1
  22. package/dist/user-add.d.ts +15 -0
  23. package/dist/user-runner.d.ts +5 -0
  24. package/package.json +7 -3
  25. package/templates/rover-pilot/.env.schema +11 -0
  26. package/templates/rover-pilot/.github/workflows/build.yml +1 -0
  27. package/templates/rover-pilot/.github/workflows/deploy.yml +74 -19
  28. package/templates/rover-pilot/.github/workflows/reconcile.yml +16 -2
  29. package/templates/rover-pilot/README.md +6 -3
  30. package/templates/rover-pilot/deploy/scripts/decrypt-user-secrets.ts +83 -0
  31. package/templates/rover-pilot/deploy/scripts/provision-server.ts +1 -1
  32. package/templates/rover-pilot/deploy/scripts/resolve-deploy-handles.ts +15 -4
  33. package/templates/rover-pilot/deploy/scripts/resolve-user-config.ts +12 -12
  34. package/templates/rover-pilot/deploy/scripts/sync-content-repo.ts +179 -0
  35. package/templates/rover-pilot/deploy/scripts/update-dns.ts +14 -4
  36. package/templates/rover-pilot/docs/onboarding-checklist.md +28 -11
  37. package/templates/rover-pilot/docs/operator-playbook.md +43 -5
  38. package/templates/rover-pilot/docs/user-onboarding.md +505 -0
  39. package/templates/rover-pilot/package.json +3 -0
  40. package/templates/rover-pilot/pilot.yaml +4 -0
  41. package/templates/rover-pilot/users/alice.yaml +5 -1
  42. package/dist/user-secret-names.d.ts +0 -6
  43. package/templates/rover-pilot/.kamal/hooks/pre-deploy +0 -9
  44. package/templates/rover-pilot/deploy/Dockerfile +0 -15
  45. package/templates/rover-pilot/deploy/kamal/deploy.yml +0 -39
@@ -29,6 +29,7 @@ The repo also checks in its deploy contract:
29
29
  - `.github/workflows/*`
30
30
 
31
31
  `.env.schema` is the single source of truth for required and sensitive deploy vars.
32
+ Use separate GitHub tokens: `CONTENT_REPO_ADMIN_TOKEN` for operator-side content repo creation/checks, and `GIT_SYNC_TOKEN` for runtime directory-sync git access.
32
33
  The shared pilot image tag is `brain-${brainVersion}` end to end.
33
34
  When `pilot.yaml.brainVersion` changes and you push, CI rebuilds the shared tag, refreshes generated user env files, and redeploys affected users.
34
35
  When a push changes only deploy contract files, CI prints `No affected user configs; skipping deploy.` and stops before Kamal.
@@ -37,9 +38,11 @@ When a push changes only deploy contract files, CI prints `No affected user conf
37
38
 
38
39
  - `brains-ops init <repo>`
39
40
  - `brains-ops render <repo>` — regenerates `views/users.md` with live DNS, `/health`, and unauthenticated `/mcp` status checks
40
- - `brains-ops onboard <repo> <handle>`
41
+ - `brains-ops user:add <repo> <handle> --cohort <cohort>` — scaffolds a user file, per-user secrets template, and cohort membership
42
+ - `brains-ops onboard <repo> <handle>` — creates/seeds the user's content repo with separate admin and sync tokens
43
+ - `brains-ops age-key:bootstrap <repo>`
41
44
  - `brains-ops ssh-key:bootstrap <repo>`
42
- - `brains-ops cert:bootstrap <repo> <handle>`
43
- - `brains-ops secrets:push <repo> <handle>`
45
+ - `brains-ops cert:bootstrap <repo>`
46
+ - `brains-ops secrets:encrypt <repo> <handle>`
44
47
  - `brains-ops reconcile-cohort <repo> <cohort>`
45
48
  - `brains-ops reconcile-all <repo>`
@@ -0,0 +1,83 @@
1
+ import { readFileSync } from "node:fs";
2
+
3
+ import { Decrypter, armor } from "age-encryption";
4
+
5
+ import { requireEnv, writeGitHubEnv, writeGitHubOutput } from "./helpers";
6
+
7
+ const handle = process.argv[2] ?? requireEnv("HANDLE");
8
+ const ageSecretKey = extractAgeIdentity(requireEnv("AGE_SECRET_KEY"));
9
+ const encryptedPath = `users/${handle}.secrets.yaml.age`;
10
+
11
+ const armored = readFileSync(encryptedPath, "utf8");
12
+ const decoded = armor.decode(armored);
13
+
14
+ const decrypter = new Decrypter();
15
+ decrypter.addIdentity(ageSecretKey);
16
+
17
+ const plaintext = await decrypter.decrypt(decoded, "text");
18
+ const secrets = parseFlatYaml(plaintext);
19
+ const pilot = parseFlatYaml(readFileSync("pilot.yaml", "utf8"));
20
+
21
+ writeGitHubEnv("AI_API_KEY", secrets["aiApiKey"] ?? "");
22
+ writeGitHubEnv("GIT_SYNC_TOKEN", secrets["gitSyncToken"] ?? "");
23
+ writeGitHubEnv("MCP_AUTH_TOKEN", secrets["mcpAuthToken"] ?? "");
24
+ writeGitHubEnv("DISCORD_BOT_TOKEN", secrets["discordBotToken"] ?? "");
25
+
26
+ writeGitHubOutput(
27
+ "shared_ai_api_key_secret_name",
28
+ requireFlatValue(pilot, "aiApiKey", "pilot.yaml"),
29
+ );
30
+ writeGitHubOutput(
31
+ "shared_git_sync_token_secret_name",
32
+ requireFlatValue(pilot, "gitSyncToken", "pilot.yaml"),
33
+ );
34
+ writeGitHubOutput(
35
+ "shared_mcp_auth_token_secret_name",
36
+ requireFlatValue(pilot, "mcpAuthToken", "pilot.yaml"),
37
+ );
38
+
39
+ function extractAgeIdentity(contents: string): string {
40
+ const line = contents
41
+ .split(/\r?\n/)
42
+ .map((entry) => entry.trim())
43
+ .find((entry) => entry.startsWith("AGE-SECRET-KEY-"));
44
+
45
+ if (!line) {
46
+ throw new Error("Missing AGE-SECRET-KEY in AGE_SECRET_KEY");
47
+ }
48
+
49
+ return line;
50
+ }
51
+
52
+ function parseFlatYaml(contents: string): Record<string, string> {
53
+ const result: Record<string, string> = {};
54
+
55
+ for (const rawLine of contents.split(/\r?\n/)) {
56
+ const line = rawLine.trim();
57
+ if (!line || line.startsWith("#")) {
58
+ continue;
59
+ }
60
+
61
+ const match = line.match(/^([A-Za-z0-9_]+):\s*(.*)$/);
62
+ if (!match) {
63
+ continue;
64
+ }
65
+
66
+ const [, key, rawValue] = match;
67
+ result[key] = rawValue.replace(/^['"]|['"]$/g, "");
68
+ }
69
+
70
+ return result;
71
+ }
72
+
73
+ function requireFlatValue(
74
+ values: Record<string, string>,
75
+ key: string,
76
+ label: string,
77
+ ): string {
78
+ const value = values[key];
79
+ if (!value) {
80
+ throw new Error(`Missing ${key} in ${label}`);
81
+ }
82
+ return value;
83
+ }
@@ -101,7 +101,7 @@ while (server.status !== "running" || !server.public_net?.ipv4?.ip) {
101
101
  server = await getServer(server.id);
102
102
  }
103
103
 
104
- const serverIp = server.public_net?.ipv4?.ip;
104
+ const serverIp = server.public_net.ipv4.ip;
105
105
  if (!serverIp) {
106
106
  throw new Error(`Server ${server.id} running but has no IPv4 address`);
107
107
  }
@@ -9,14 +9,23 @@ if (eventName === "workflow_dispatch") {
9
9
  process.exit(0);
10
10
  }
11
11
 
12
- if (eventName !== "push") {
12
+ if (eventName !== "push" && eventName !== "workflow_run") {
13
13
  throw new Error(`Unsupported GITHUB_EVENT_NAME: ${eventName}`);
14
14
  }
15
15
 
16
16
  const beforeSha = requireEnv("BEFORE_SHA");
17
- const currentSha = requireEnv("GITHUB_SHA");
17
+ const currentSha =
18
+ eventName === "workflow_run"
19
+ ? execFileSync("git", ["rev-parse", "HEAD"], {
20
+ encoding: "utf8",
21
+ }).trim()
22
+ : requireEnv("GITHUB_SHA");
18
23
 
19
- if (!isUsableGitRevision(beforeSha) || !isUsableGitRevision(currentSha)) {
24
+ if (
25
+ !isUsableGitRevision(beforeSha) ||
26
+ !isUsableGitRevision(currentSha) ||
27
+ beforeSha === currentSha
28
+ ) {
20
29
  writeGitHubOutput("handles_json", JSON.stringify([]));
21
30
  process.exit(0);
22
31
  }
@@ -32,7 +41,9 @@ const handles = [
32
41
  diffOutput
33
42
  .split(/\r?\n/)
34
43
  .map((path) => {
35
- const match = path.match(/^users\/([^/]+)\/(?:\.env|brain\.yaml)$/);
44
+ const match =
45
+ path.match(/^users\/([^/]+)\/(?:\.env|brain\.yaml|content\/.*)$/) ??
46
+ path.match(/^users\/([^/]+)\.secrets\.yaml\.age$/);
36
47
  return match?.[1] ?? null;
37
48
  })
38
49
  .filter((handle): handle is string => handle !== null)
@@ -1,4 +1,5 @@
1
1
  import { readFileSync } from "node:fs";
2
+
2
3
  import { parseEnvFile, requireEnv, writeGitHubOutput } from "./helpers";
3
4
 
4
5
  const handle = requireEnv("HANDLE");
@@ -12,32 +13,31 @@ const repositoryOwner = repository.split("/")[0] ?? "";
12
13
  const brainYaml = readFileSync(brainYamlPath, "utf8");
13
14
  const domainMatch = brainYaml.match(/^domain:\s*(.+)$/m);
14
15
  const brainDomain = domainMatch?.[1]?.trim().replace(/^['"]|['"]$/g, "") ?? "";
15
-
16
16
  if (!brainDomain) {
17
17
  throw new Error(`Missing domain in ${brainYamlPath}`);
18
18
  }
19
19
 
20
+ const zone =
21
+ brainDomain.startsWith(`${handle}.`) && brainDomain.length > handle.length + 1
22
+ ? brainDomain.slice(handle.length + 1)
23
+ : "";
24
+ if (!zone) {
25
+ throw new Error(`Could not derive preview domain from ${brainDomain}`);
26
+ }
27
+ const previewDomain = `${handle}-preview.${zone}`;
28
+
20
29
  const outputs: Record<string, string> = {
21
30
  brain_version: envEntries["BRAIN_VERSION"] ?? "",
22
- ai_api_key_secret_name: envEntries["AI_API_KEY_SECRET"] ?? "",
23
- git_sync_token_secret_name: envEntries["GIT_SYNC_TOKEN_SECRET"] ?? "",
24
- mcp_auth_token_secret_name: envEntries["MCP_AUTH_TOKEN_SECRET"] ?? "",
25
- discord_bot_token_secret_name: envEntries["DISCORD_BOT_TOKEN_SECRET"] ?? "",
26
31
  content_repo: envEntries["CONTENT_REPO"] ?? "",
27
32
  brain_domain: brainDomain,
33
+ preview_domain: previewDomain,
28
34
  brain_yaml_path: brainYamlPath,
29
35
  instance_name: `rover-${handle}`,
30
36
  image_repository: `ghcr.io/${repository}`,
31
37
  registry_username: repositoryOwner,
32
38
  };
33
39
 
34
- const required = [
35
- "brain_version",
36
- "ai_api_key_secret_name",
37
- "git_sync_token_secret_name",
38
- "mcp_auth_token_secret_name",
39
- "registry_username",
40
- ];
40
+ const required = ["brain_version", "registry_username"];
41
41
  for (const key of required) {
42
42
  if (!outputs[key]) {
43
43
  throw new Error(`Missing ${key} (derived from ${envPath})`);
@@ -0,0 +1,179 @@
1
+ import { cp, mkdtemp, mkdir, readFile, readdir } from "node:fs/promises";
2
+ import { existsSync } from "node:fs";
3
+ import { tmpdir } from "node:os";
4
+ import { dirname, join } from "node:path";
5
+ import { execFileSync } from "node:child_process";
6
+ import { readJsonResponse, requireEnv } from "./helpers";
7
+
8
+ const handle = requireEnv("HANDLE");
9
+ const contentRepo = requireEnv("CONTENT_REPO");
10
+ const token = requireEnv("GIT_SYNC_TOKEN");
11
+ const sourceDir = join("users", handle, "content");
12
+
13
+ if (!existsSync(sourceDir)) {
14
+ process.exit(0);
15
+ }
16
+
17
+ const { owner, repo } = parseRepoSlug(contentRepo);
18
+ await ensureGitHubRepo({ owner, repo, token });
19
+
20
+ const tempRoot = await mkdtemp(join(tmpdir(), "brains-ops-content-"));
21
+ const checkoutDir = join(tempRoot, "repo");
22
+ const remoteUrl = buildAuthenticatedRemoteUrl(owner, repo, token);
23
+
24
+ runGit(["clone", remoteUrl, checkoutDir]);
25
+ runGit(["-C", checkoutDir, "checkout", "-B", "main"]);
26
+
27
+ const copiedFiles = await copyMissingFiles(sourceDir, checkoutDir);
28
+ if (copiedFiles === 0) {
29
+ process.exit(0);
30
+ }
31
+
32
+ runGit(["-C", checkoutDir, "config", "user.name", "brains-ops[bot]"]);
33
+ runGit([
34
+ "-C",
35
+ checkoutDir,
36
+ "config",
37
+ "user.email",
38
+ "41898282+github-actions[bot]@users.noreply.github.com",
39
+ ]);
40
+ runGit(["-C", checkoutDir, "add", "."]);
41
+
42
+ if (hasNoStagedChanges(checkoutDir)) {
43
+ process.exit(0);
44
+ }
45
+
46
+ runGit([
47
+ "-C",
48
+ checkoutDir,
49
+ "commit",
50
+ "-m",
51
+ `chore(content): seed ${handle} anchor profile`,
52
+ ]);
53
+ runGit(["-C", checkoutDir, "push", "origin", "HEAD:main"]);
54
+
55
+ const STALE_ANCHOR_PROFILE_MARKERS = [
56
+ "name: Your Name Here",
57
+ "Delete this and write your own",
58
+ ];
59
+
60
+ interface EnsureGitHubRepoOptions {
61
+ owner: string;
62
+ repo: string;
63
+ token: string;
64
+ }
65
+
66
+ interface GitHubRepoResponse {
67
+ clone_url?: string;
68
+ private?: boolean;
69
+ }
70
+
71
+ async function ensureGitHubRepo(
72
+ options: EnsureGitHubRepoOptions,
73
+ ): Promise<void> {
74
+ const headers = {
75
+ Authorization: `Bearer ${options.token}`,
76
+ Accept: "application/vnd.github+json",
77
+ "Content-Type": "application/json",
78
+ };
79
+ const repoUrl = `https://api.github.com/repos/${options.owner}/${options.repo}`;
80
+ const repoResponse = await fetch(repoUrl, { headers });
81
+
82
+ if (repoResponse.ok) {
83
+ await readJsonResponse(repoResponse, "GitHub repo lookup");
84
+ return;
85
+ }
86
+
87
+ if (repoResponse.status !== 404) {
88
+ const payload = await readJsonResponse(repoResponse, "GitHub repo lookup");
89
+ throw new Error(`GitHub repo lookup failed: ${JSON.stringify(payload)}`);
90
+ }
91
+
92
+ const createResponse = await fetch(
93
+ `https://api.github.com/orgs/${options.owner}/repos`,
94
+ {
95
+ method: "POST",
96
+ headers,
97
+ body: JSON.stringify({
98
+ name: options.repo,
99
+ private: true,
100
+ auto_init: false,
101
+ }),
102
+ },
103
+ );
104
+ const payload = (await readJsonResponse(
105
+ createResponse,
106
+ "GitHub repo create",
107
+ )) as GitHubRepoResponse;
108
+
109
+ if (!createResponse.ok) {
110
+ throw new Error(`GitHub repo create failed: ${JSON.stringify(payload)}`);
111
+ }
112
+ }
113
+
114
+ function parseRepoSlug(contentRepo: string): { owner: string; repo: string } {
115
+ const [owner, repo] = contentRepo.split("/");
116
+ if (!owner || !repo) {
117
+ throw new Error(`Invalid CONTENT_REPO: ${contentRepo}`);
118
+ }
119
+ return { owner, repo };
120
+ }
121
+
122
+ function buildAuthenticatedRemoteUrl(
123
+ owner: string,
124
+ repo: string,
125
+ token: string,
126
+ ): string {
127
+ return `https://x-access-token:${encodeURIComponent(token)}@github.com/${owner}/${repo}.git`;
128
+ }
129
+
130
+ function runGit(args: string[]): void {
131
+ execFileSync("git", args, { stdio: "inherit" });
132
+ }
133
+
134
+ function hasNoStagedChanges(checkoutDir: string): boolean {
135
+ try {
136
+ execFileSync("git", ["-C", checkoutDir, "diff", "--cached", "--quiet"], {
137
+ stdio: "ignore",
138
+ });
139
+ return true;
140
+ } catch {
141
+ return false;
142
+ }
143
+ }
144
+
145
+ async function copyMissingFiles(
146
+ sourceDir: string,
147
+ targetDir: string,
148
+ ): Promise<number> {
149
+ const entries = await readdir(sourceDir, { withFileTypes: true });
150
+ let copiedFiles = 0;
151
+
152
+ for (const entry of entries) {
153
+ const sourcePath = join(sourceDir, entry.name);
154
+ const targetPath = join(targetDir, entry.name);
155
+
156
+ if (entry.isDirectory()) {
157
+ await mkdir(targetPath, { recursive: true });
158
+ copiedFiles += await copyMissingFiles(sourcePath, targetPath);
159
+ continue;
160
+ }
161
+
162
+ const existing = await readFile(targetPath, "utf8").catch(() => undefined);
163
+ if (existing !== undefined && !isStaleAnchorProfile(existing)) {
164
+ continue;
165
+ }
166
+
167
+ await mkdir(dirname(targetPath), { recursive: true });
168
+ await cp(sourcePath, targetPath, { force: true });
169
+ copiedFiles += existing === (await readFile(sourcePath, "utf8")) ? 0 : 1;
170
+ }
171
+
172
+ return copiedFiles;
173
+ }
174
+
175
+ function isStaleAnchorProfile(content: string): boolean {
176
+ return STALE_ANCHOR_PROFILE_MARKERS.some((marker) =>
177
+ content.includes(marker),
178
+ );
179
+ }
@@ -16,8 +16,11 @@ interface CloudflareResult {
16
16
  result?: Array<{ id: string }>;
17
17
  }
18
18
 
19
- async function upsertRecord(name: string): Promise<void> {
20
- const lookupUrl = `${baseUrl}/zones/${zoneId}/dns_records?type=A&name=${encodeURIComponent(name)}`;
19
+ async function findRecordId(
20
+ name: string,
21
+ type: "A" | "CNAME",
22
+ ): Promise<string | undefined> {
23
+ const lookupUrl = `${baseUrl}/zones/${zoneId}/dns_records?type=${type}&name=${encodeURIComponent(name)}`;
21
24
  const lookup = await fetch(lookupUrl, { headers });
22
25
  const payload = (await readJsonResponse(
23
26
  lookup,
@@ -27,9 +30,16 @@ async function upsertRecord(name: string): Promise<void> {
27
30
  throw new Error(`Cloudflare DNS lookup failed: ${JSON.stringify(payload)}`);
28
31
  }
29
32
 
30
- const existing = payload.result?.[0];
33
+ return payload.result?.[0]?.id;
34
+ }
35
+
36
+ async function upsertRecord(name: string): Promise<void> {
37
+ // Prefer an existing A record. If the hostname currently has a CNAME,
38
+ // replace that CNAME in-place so deploys can claim legacy www aliases.
39
+ const existing =
40
+ (await findRecordId(name, "A")) ?? (await findRecordId(name, "CNAME"));
31
41
  const url = existing
32
- ? `${baseUrl}/zones/${zoneId}/dns_records/${existing.id}`
42
+ ? `${baseUrl}/zones/${zoneId}/dns_records/${existing}`
33
43
  : `${baseUrl}/zones/${zoneId}/dns_records`;
34
44
 
35
45
  const response = await fetch(url, {
@@ -1,16 +1,33 @@
1
1
  # Onboarding Checklist
2
2
 
3
3
  1. Run `bun install` so the repo uses its pinned `@rizom/ops` version.
4
- 2. Fill in `pilot.yaml`.
5
- 3. Add or edit `users/<handle>.yaml`.
6
- 4. Add the user to a cohort in `cohorts/*.yaml`.
7
- 5. Run `bunx brains-ops render <repo>`.
8
- 6. Run `bunx brains-ops ssh-key:bootstrap <repo> --push-to gh`.
9
- 7. Run `bunx brains-ops cert:bootstrap <repo> <handle> --push-to gh`.
10
- 8. Run `bunx brains-ops secrets:push <repo> <handle>`.
11
- 9. Run `bunx brains-ops onboard <repo> <handle>`.
12
- 10. Verify the deployed rover core contract:
4
+ 2. Run `bunx brains-ops age-key:bootstrap <repo> --push-to gh`.
5
+ 3. Fill in `pilot.yaml`.
6
+ - keep your pinned `brainVersion`
7
+ - confirm shared selectors for `aiApiKey`, `gitSyncToken`, `contentRepoAdminToken`, and `mcpAuthToken`
8
+ - use different tokens for `contentRepoAdminToken` and `gitSyncToken`: admin creates/checks content repos; sync is used by runtime directory-sync
9
+ - confirm `agePublicKey`
10
+ 4. Run `bunx brains-ops user:add <repo> <handle> --cohort <cohort>`.
11
+ - Discord is enabled by default for pilot users.
12
+ - if the user should be an anchor there, add `--anchor-id <discord-user-id>`.
13
+ - the command creates `users/<handle>.yaml`, `users/<handle>.secrets.yaml`, and the cohort membership without duplicating existing entries.
14
+ 5. Edit the generated user file if the anchor profile needs richer metadata.
15
+ 6. Run `bunx brains-ops render <repo>`.
16
+ 7. Run `bunx brains-ops ssh-key:bootstrap <repo> --push-to gh`.
17
+ 8. Run `bunx brains-ops cert:bootstrap <repo> --push-to gh`.
18
+ 9. Keep raw user secret material locally for now (`.env.local`, file-backed env vars, or equivalent local inputs), including `CONTENT_REPO_ADMIN_TOKEN` for operator onboarding.
19
+ 10. Run `bunx brains-ops secrets:encrypt <repo> <handle>`.
20
+ 11. Commit and push `users/<handle>.secrets.yaml.age`.
21
+ 12. Run `bunx brains-ops onboard <repo> <handle>`.
22
+ 13. Verify the deployed rover core contract:
13
23
  - `https://<handle>.rizom.ai/health` returns `200`
14
24
  - unauthenticated `POST https://<handle>.rizom.ai/mcp` returns `401`
15
- 11. For fleet upgrades, edit `pilot.yaml.brainVersion` and push once; CI rebuilds the shared image tag, refreshes generated user env files, and redeploys affected users.
16
- 12. Hand the MCP connection details to the user.
25
+ 14. For fleet upgrades, edit `pilot.yaml.brainVersion` and push once; CI rebuilds the shared image tag, refreshes generated user env files, and redeploys affected users.
26
+ 15. Hand the Discord setup details to the user.
27
+ 16. Hand over the browser defaults:
28
+ - Dashboard: `https://<handle>.rizom.ai/`
29
+ - CMS: `https://<handle>.rizom.ai/cms`
30
+ - GitHub token guidance for CMS access to the user's private content repo
31
+ 17. If they need direct client access, also hand over the MCP connection details.
32
+ 18. If you are also giving them a content repo workflow, describe it as optional and frame git/Obsidian as an advanced file-based path, not the default.
33
+ 19. Send `docs/user-onboarding.md` to the user as the pilot handoff guide.
@@ -35,14 +35,21 @@ They are scaffolded from `@rizom/ops`, then versioned in this repo like any othe
35
35
 
36
36
  ## Bootstrap flow
37
37
 
38
+ For this fleet, operator-local secret material remains the source of truth during onboarding and rotation. The repo stores encrypted per-user secrets, not raw values.
39
+
38
40
  For a new pilot user, the operator bootstrap order is:
39
41
 
40
- 1. `bunx brains-ops ssh-key:bootstrap <repo> --push-to gh`
41
- 2. `bunx brains-ops cert:bootstrap <repo> <handle> --push-to gh`
42
- 3. `bunx brains-ops secrets:push <repo> <handle>`
43
- 4. `bunx brains-ops onboard <repo> <handle>`
42
+ 1. `bunx brains-ops age-key:bootstrap <repo> --push-to gh`
43
+ 2. `bunx brains-ops ssh-key:bootstrap <repo> --push-to gh`
44
+ 3. `bunx brains-ops cert:bootstrap <repo> --push-to gh`
45
+ 4. `bunx brains-ops secrets:encrypt <repo> <handle>`
46
+ 5. `bunx brains-ops onboard <repo> <handle>`
47
+
48
+ `age-key:bootstrap` keeps a repo-local canonical age identity under `.brains-ops/age/identity.txt`, writes the matching public recipient to `pilot.yaml.agePublicKey`, and can push the private key to GitHub as `AGE_SECRET_KEY`.
49
+
50
+ The shared cert bootstrap writes local cert artifacts under `.brains-ops/certs/shared/`, which stays repo-local and ignored by git.
44
51
 
45
- `brains-ops cert:bootstrap` writes local cert artifacts under `.brains-ops/`, which stays repo-local and ignored by git.
52
+ Preview hosts use the shape `<handle>-preview.rizom.ai`, so one wildcard origin cert for `*.rizom.ai` covers both the primary and preview hosts for every pilot user.
46
53
 
47
54
  ## Upgrading operator behavior
48
55
 
@@ -63,6 +70,37 @@ Use these checks after deploy:
63
70
  - unauthenticated `POST https://<handle>.rizom.ai/mcp` should return `401 Unauthorized: Bearer token required`
64
71
  - a bare `GET /` may also return `401`; that is expected for rover core and does not indicate a bad deploy
65
72
 
73
+ ## Discord bot token checklist
74
+
75
+ Use this when enabling Discord for a pilot user.
76
+
77
+ 1. Pick the user handle (for example `smoke`).
78
+ 2. Open the Discord Developer Portal.
79
+ 3. Create a **new application** for that user's rover.
80
+ 4. Add a **Bot** to the application.
81
+ 5. Copy the bot token.
82
+ 6. Put that value in `.env` or `.env.local` in this repo as `DISCORD_BOT_TOKEN=...` while onboarding that user.
83
+ 7. Keep `discord.enabled: true` in `users/<handle>.yaml` unless you explicitly want to disable the primary pilot interface.
84
+ 8. Encrypt the current per-user secret payload:
85
+ - `bunx brains-ops secrets:encrypt . <handle>`
86
+ 9. Reconcile/deploy the user or cohort:
87
+
88
+ - `bunx brains-ops onboard . <handle>`
89
+ - or `bunx brains-ops reconcile-cohort . <cohort>`
90
+
91
+ 11. In the Discord Developer Portal, generate an install URL and invite the bot to the right server.
92
+ 12. Send a test message in Discord and confirm the rover responds.
93
+
94
+ Notes:
95
+
96
+ - Use **one bot token per user/rover**.
97
+ - Do not reuse the same Discord bot token across multiple pilot users.
98
+ - Discord is the default pilot interface moving forward.
99
+ - The encrypted `users/<handle>.secrets.yaml.age` file is the durable checked-in deploy input; your local env is only the operator staging source.
100
+ - MCP is optional and mainly for direct client access or specific testing workflows.
101
+ - When explaining the content workflow, describe it first as a normal **git repo** of **markdown/text files**.
102
+ - Position **Obsidian** as optional: it is just one possible editor for those same files, not the default requirement.
103
+
66
104
  ## Recovery notes
67
105
 
68
106
  Document known failure modes, recovery steps, and operator notes here.