@rizom/ops 0.2.0-alpha.35 → 0.2.0-alpha.350

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 (63) hide show
  1. package/README.md +62 -2
  2. package/dist/brains-ops.js +785 -304
  3. package/dist/capability-bundle-migration.d.ts +22 -0
  4. package/dist/cert-bootstrap.d.ts +3 -1
  5. package/dist/content-repo-ref.d.ts +10 -0
  6. package/dist/content-repo.d.ts +1 -0
  7. package/dist/deploy.js +99 -166
  8. package/dist/directory-sync-stress-system.d.ts +75 -0
  9. package/dist/directory-sync-stress.d.ts +107 -0
  10. package/dist/entries/deploy.d.ts +3 -2
  11. package/dist/health-watchdog-smoke.d.ts +54 -0
  12. package/dist/images.d.ts +79 -0
  13. package/dist/index.d.ts +8 -0
  14. package/dist/index.js +784 -302
  15. package/dist/legacy-pilot-migration.d.ts +11 -0
  16. package/dist/legacy-projection-job-recovery.d.ts +29 -0
  17. package/dist/load-registry.d.ts +60 -6
  18. package/dist/observed-status.d.ts +1 -1
  19. package/dist/origin-ca.d.ts +1 -1
  20. package/dist/parse-args.d.ts +2 -10
  21. package/dist/preview-domain.d.ts +9 -0
  22. package/dist/push-secrets.d.ts +2 -9
  23. package/dist/push-target.d.ts +1 -2
  24. package/dist/reconcile-dry-run.d.ts +9 -0
  25. package/dist/run-command.d.ts +17 -3
  26. package/dist/run-subprocess.d.ts +1 -6
  27. package/dist/schema.d.ts +123 -162
  28. package/dist/secrets-encrypt.d.ts +7 -13
  29. package/dist/ssh-key-bootstrap.d.ts +1 -26
  30. package/dist/stage-legacy-crossover.d.ts +23 -0
  31. package/dist/stress-command.d.ts +14 -0
  32. package/dist/stress-git-checkout.d.ts +21 -0
  33. package/dist/stress-health-monitor.d.ts +46 -0
  34. package/dist/upgrade.d.ts +10 -0
  35. package/dist/user-add.d.ts +15 -0
  36. package/dist/verify-user.d.ts +22 -0
  37. package/package.json +50 -42
  38. package/templates/rover-pilot/.env.schema +24 -3
  39. package/templates/rover-pilot/.github/actions/varlock-env/action.yml +47 -0
  40. package/templates/rover-pilot/.github/workflows/build.yml +70 -17
  41. package/templates/rover-pilot/.github/workflows/deploy.yml +71 -57
  42. package/templates/rover-pilot/.github/workflows/directory-sync-stress.yml +119 -0
  43. package/templates/rover-pilot/.github/workflows/health-watchdog-smoke.yml +95 -0
  44. package/templates/rover-pilot/.github/workflows/reconcile.yml +10 -4
  45. package/templates/rover-pilot/.github/workflows/upgrade.yml +104 -0
  46. package/templates/rover-pilot/README.md +16 -6
  47. package/templates/rover-pilot/deploy/scripts/create-predeploy-backup.ts +873 -0
  48. package/templates/rover-pilot/deploy/scripts/decrypt-user-secrets.ts +80 -24
  49. package/templates/rover-pilot/deploy/scripts/helpers.ts +3 -0
  50. package/templates/rover-pilot/deploy/scripts/install-health-watchdog.ts +144 -0
  51. package/templates/rover-pilot/deploy/scripts/resolve-missing-images.ts +13 -0
  52. package/templates/rover-pilot/deploy/scripts/resolve-user-config.ts +44 -9
  53. package/templates/rover-pilot/deploy/scripts/sync-content-repo.ts +51 -47
  54. package/templates/rover-pilot/deploy/scripts/update-dns.ts +14 -4
  55. package/templates/rover-pilot/deploy/scripts/validate-secrets.ts +12 -1
  56. package/templates/rover-pilot/docs/canonical-crossover-record.md +107 -0
  57. package/templates/rover-pilot/docs/onboarding-checklist.md +28 -17
  58. package/templates/rover-pilot/docs/operator-playbook.md +307 -29
  59. package/templates/rover-pilot/docs/user-onboarding.md +48 -463
  60. package/templates/rover-pilot/pilot.yaml +7 -4
  61. package/templates/rover-pilot/.kamal/hooks/pre-deploy +0 -9
  62. package/templates/rover-pilot/deploy/Dockerfile +0 -30
  63. package/templates/rover-pilot/deploy/kamal/deploy.yml +0 -40
@@ -0,0 +1,75 @@
1
+ import type { FetchLike } from "@brains/deploy-support/origin-ca";
2
+ import { type DirectorySyncStressPhase, type DirectorySyncStressPlan, type DirectorySyncStressProfile, type DirectorySyncStressReport, type StressRuntimeSample } from "./directory-sync-stress";
3
+ import { type StressCommandRunner } from "./stress-command";
4
+ export { runStressCommand, type StressCommandOptions, type StressCommandResult, type StressCommandRunner, } from "./stress-command";
5
+ export interface DeployedDirectorySyncStressOptions {
6
+ rootDir: string;
7
+ handle: string;
8
+ profile: DirectorySyncStressProfile;
9
+ plan?: DirectorySyncStressPlan;
10
+ confirmation: string;
11
+ artifactsDir?: string;
12
+ env?: NodeJS.ProcessEnv;
13
+ fetchImpl?: FetchLike;
14
+ commandRunner?: StressCommandRunner;
15
+ logger?: (message: string) => void;
16
+ now?: () => Date;
17
+ sleep?: (milliseconds: number) => Promise<void>;
18
+ }
19
+ export interface VerifyDirectorySyncStressAccessOptions {
20
+ rootDir: string;
21
+ handle: string;
22
+ confirmation: string;
23
+ artifactsDir?: string;
24
+ env?: NodeJS.ProcessEnv;
25
+ commandRunner?: StressCommandRunner;
26
+ now?: () => Date;
27
+ }
28
+ export interface CleanupDirectorySyncStressOptions {
29
+ rootDir: string;
30
+ handle: string;
31
+ confirmation: string;
32
+ artifactsDir?: string;
33
+ env?: NodeJS.ProcessEnv;
34
+ commandRunner?: StressCommandRunner;
35
+ logger?: (message: string) => void;
36
+ now?: () => Date;
37
+ }
38
+ export interface DeployedDirectorySyncStressResult {
39
+ runId: string;
40
+ artifactsDir: string;
41
+ target: {
42
+ handle: string;
43
+ domain: string;
44
+ contentRepo: string;
45
+ };
46
+ startedAt: string;
47
+ completedAt: string;
48
+ report: DirectorySyncStressReport;
49
+ }
50
+ export interface VerifyDirectorySyncStressAccessResult {
51
+ success: true;
52
+ artifactsDir: string;
53
+ checkedAt: string;
54
+ remoteHead: string;
55
+ target: {
56
+ handle: string;
57
+ domain: string;
58
+ contentRepo: string;
59
+ };
60
+ }
61
+ export interface CleanupDirectorySyncStressResult {
62
+ success: boolean;
63
+ artifactsDir: string;
64
+ probesRemoved: number;
65
+ probesRemaining: number;
66
+ backupBranchesDeleted: string[];
67
+ cleanupCommit?: string;
68
+ }
69
+ export declare function runDeployedDirectorySyncStress(options: DeployedDirectorySyncStressOptions): Promise<DeployedDirectorySyncStressResult>;
70
+ export declare function verifyDirectorySyncStressAccess(options: VerifyDirectorySyncStressAccessOptions): Promise<VerifyDirectorySyncStressAccessResult>;
71
+ export declare function cleanupDirectorySyncStress(options: CleanupDirectorySyncStressOptions): Promise<CleanupDirectorySyncStressResult>;
72
+ export declare function applyDirectorySyncStressPhase(checkoutDir: string, phase: DirectorySyncStressPhase): Promise<void>;
73
+ export declare function listProbeFiles(checkoutDir: string): Promise<string[]>;
74
+ export declare function removeProbeFiles(checkoutDir: string): Promise<number>;
75
+ export declare function parseStressRuntimeSample(output: string, timestamp: string): StressRuntimeSample | undefined;
@@ -0,0 +1,107 @@
1
+ import type { FetchLike } from "@brains/deploy-support/origin-ca";
2
+ import { z } from "@brains/utils/zod";
3
+ export type DirectorySyncStressProfile = "regression" | "load" | "stress";
4
+ export type DirectorySyncStressOperation = "add" | "update" | "rename" | "delete";
5
+ export interface DirectorySyncStressPhase {
6
+ id: string;
7
+ operation: DirectorySyncStressOperation;
8
+ count: number;
9
+ targetProbeCount: number;
10
+ settleMs: number;
11
+ }
12
+ export interface DirectorySyncStressPlan {
13
+ profile: DirectorySyncStressProfile;
14
+ maximumProbeCount: number;
15
+ maximumExternalAiCalls?: number | undefined;
16
+ phases: DirectorySyncStressPhase[];
17
+ }
18
+ export interface StressBaseline {
19
+ entities: number;
20
+ notes: number;
21
+ version: string;
22
+ }
23
+ export interface StressHealthSample {
24
+ timestamp: string;
25
+ endpoint: string;
26
+ status: number;
27
+ durationMs: number;
28
+ ok: boolean;
29
+ error?: string | undefined;
30
+ }
31
+ export interface StressRuntimeSample {
32
+ timestamp: string;
33
+ cpuPercent: number;
34
+ memoryPercent: number;
35
+ pids: number;
36
+ }
37
+ export interface StressPhaseResult {
38
+ id: string;
39
+ operation: DirectorySyncStressOperation;
40
+ count: number;
41
+ success: boolean;
42
+ commitLatencyMs?: number | undefined;
43
+ persistenceLatencyMs?: number | undefined;
44
+ error?: string | undefined;
45
+ }
46
+ export interface StressCleanupResult {
47
+ success: boolean;
48
+ probesRemaining: number;
49
+ finalEntities?: number | undefined;
50
+ finalNotes?: number | undefined;
51
+ contentTreeRestored?: boolean | undefined;
52
+ error?: string | undefined;
53
+ }
54
+ export interface StressContainerState {
55
+ status: string;
56
+ restartCount: number;
57
+ oomKilled: boolean;
58
+ }
59
+ export interface StressMetrics {
60
+ health: StressHealthSample[];
61
+ runtime: StressRuntimeSample[];
62
+ externalAiCalls?: number | undefined;
63
+ container?: StressContainerState | undefined;
64
+ }
65
+ export interface DirectorySyncStressReport {
66
+ profile: DirectorySyncStressProfile;
67
+ success: boolean;
68
+ baseline: StressBaseline;
69
+ phases: StressPhaseResult[];
70
+ cleanup: StressCleanupResult;
71
+ metrics: StressMetrics;
72
+ failure?: string | undefined;
73
+ }
74
+ export declare const directorySyncStressProfileSchema: z.ZodType<DirectorySyncStressProfile>;
75
+ export declare const directorySyncStressOperationSchema: z.ZodType<DirectorySyncStressOperation>;
76
+ export declare const directorySyncStressPhaseSchema: z.ZodType<DirectorySyncStressPhase>;
77
+ export declare const directorySyncStressPlanSchema: z.ZodType<DirectorySyncStressPlan>;
78
+ export declare const stressBaselineSchema: z.ZodType<StressBaseline>;
79
+ export declare const stressHealthSampleSchema: z.ZodType<StressHealthSample>;
80
+ export declare const stressRuntimeSampleSchema: z.ZodType<StressRuntimeSample>;
81
+ export declare const stressPhaseResultSchema: z.ZodType<StressPhaseResult>;
82
+ export declare const stressCleanupResultSchema: z.ZodType<StressCleanupResult>;
83
+ export declare const stressMetricsSchema: z.ZodType<StressMetrics>;
84
+ export declare const directorySyncStressReportSchema: z.ZodType<DirectorySyncStressReport>;
85
+ export interface DirectorySyncStressTarget {
86
+ handle: string;
87
+ domain: string;
88
+ contentRepo: string;
89
+ confirmation: string;
90
+ }
91
+ export interface DirectorySyncStressDriver {
92
+ prepare(plan: DirectorySyncStressPlan): Promise<StressBaseline>;
93
+ startMonitoring(): Promise<void>;
94
+ executePhase(phase: DirectorySyncStressPhase, baseline: StressBaseline): Promise<StressPhaseResult>;
95
+ cleanup(baseline: StressBaseline): Promise<StressCleanupResult>;
96
+ stopMonitoring(): Promise<StressMetrics>;
97
+ }
98
+ export declare function resolveDirectorySyncStressPlan(profile: DirectorySyncStressProfile): DirectorySyncStressPlan;
99
+ export declare function assertDirectorySyncStressTarget(target: DirectorySyncStressTarget): void;
100
+ export interface SampleStressHealthOptions {
101
+ fetchImpl?: FetchLike;
102
+ now?: () => Date;
103
+ timeoutMs?: number;
104
+ }
105
+ export declare function sampleStressHealth(url: string, options?: SampleStressHealthOptions): Promise<StressHealthSample>;
106
+ export declare function runDirectorySyncStressPlan(plan: DirectorySyncStressPlan, driver: DirectorySyncStressDriver): Promise<DirectorySyncStressReport>;
107
+ export declare function stressMetricsFailure(metrics: StressMetrics, maximumExternalAiCalls?: number): string | undefined;
@@ -1,2 +1,3 @@
1
- export { readJsonResponse, parseEnvFile, parseEnvSchema, parseEnvSchemaFile, requireEnv, writeGitHubOutput, writeGitHubEnv, } from "@brains/utils";
2
- export type { EnvSchemaEntry } from "@brains/utils";
1
+ export { readJsonResponse, parseEnvFile, parseEnvSchema, parseEnvSchemaFile, requireEnv, writeGitHubOutput, writeGitHubEnv, } from "@brains/deploy-support";
2
+ export type { EnvSchemaEntry } from "@brains/deploy-support";
3
+ export { siteImageTag, sitePackagesFor, requiredImages, resolveImageBuilds, runResolveMissingImages, type ImageRequirementSource, type RequiredImage, type ResolveImageBuildsOptions, type RunResolveMissingImagesOptions, } from "../images";
@@ -0,0 +1,54 @@
1
+ import type { FetchLike } from "@brains/deploy-support/origin-ca";
2
+ import { type StressCommandRunner } from "./stress-command";
3
+ export interface HealthWatchdogSmokeTarget {
4
+ handle: string;
5
+ domain: string;
6
+ confirmation: string;
7
+ runId: string;
8
+ }
9
+ export interface HealthWatchdogSmokeOptions {
10
+ rootDir: string;
11
+ handle: string;
12
+ confirmation: string;
13
+ runId: string;
14
+ artifactsDir?: string | undefined;
15
+ env?: NodeJS.ProcessEnv | undefined;
16
+ fetchImpl?: FetchLike | undefined;
17
+ commandRunner?: StressCommandRunner | undefined;
18
+ logger?: ((message: string) => void) | undefined;
19
+ }
20
+ export interface HealthWatchdogSmokeResult {
21
+ success: true;
22
+ runId: string;
23
+ artifactsDir: string;
24
+ target: {
25
+ handle: string;
26
+ domain: string;
27
+ serverIp: string;
28
+ };
29
+ }
30
+ export interface CleanupHealthWatchdogSmokeOptions {
31
+ rootDir: string;
32
+ handle: string;
33
+ confirmation: string;
34
+ runId: string;
35
+ artifactsDir?: string | undefined;
36
+ env?: NodeJS.ProcessEnv | undefined;
37
+ fetchImpl?: FetchLike | undefined;
38
+ commandRunner?: StressCommandRunner | undefined;
39
+ logger?: ((message: string) => void) | undefined;
40
+ }
41
+ export interface CleanupHealthWatchdogSmokeResult {
42
+ success: true;
43
+ runId: string;
44
+ artifactsDir: string;
45
+ target: {
46
+ handle: string;
47
+ domain: string;
48
+ serverIp: string;
49
+ };
50
+ }
51
+ export declare function assertHealthWatchdogSmokeTarget(target: HealthWatchdogSmokeTarget): void;
52
+ export declare function renderHealthWatchdogSmokeRemoteScript(): string;
53
+ export declare function runHealthWatchdogSmoke(options: HealthWatchdogSmokeOptions): Promise<HealthWatchdogSmokeResult>;
54
+ export declare function cleanupHealthWatchdogSmoke(options: CleanupHealthWatchdogSmokeOptions): Promise<CleanupHealthWatchdogSmokeResult>;
@@ -0,0 +1,79 @@
1
+ import { type ResolvedSiteOverride } from "./load-registry";
2
+ import { type RunCommand } from "./run-subprocess";
3
+ /**
4
+ * Resolve a fleet image tag as a pure function of a single instance's own
5
+ * config. This is the shared contract between the build (which tags the image
6
+ * it pushes) and the deploy (which waits for and runs that tag), so both must
7
+ * import this — never recompute it independently.
8
+ *
9
+ * The default path is deliberately untouched: an instance with no site packages
10
+ * resolves to the plain `brain-{version}` tag every other fleet instance uses.
11
+ * A site override is a per-instance opt-in that hashes only *that instance's*
12
+ * package set into a distinct `brain-{version}-sites-{hash}` image, so it can
13
+ * never collide with — or leak into — the shared default image.
14
+ */
15
+ export declare function siteImageTag(brainVersion: string, sitePackages: string[]): string;
16
+ /**
17
+ * The npm packages a site override installs into its per-instance image.
18
+ * A @rizom-scoped theme is independently published and installs at its own
19
+ * explicit version; @brains/* themes are bundled inside @rizom/brain and must
20
+ * not be npm-installed.
21
+ */
22
+ export declare function sitePackagesFor(siteOverride: ResolvedSiteOverride | undefined): string[];
23
+ /** The per-user slice of the registry that determines which image it runs. */
24
+ export interface ImageRequirementSource {
25
+ brainVersion: string;
26
+ siteOverride?: ResolvedSiteOverride | undefined;
27
+ }
28
+ export interface RequiredImage {
29
+ tag: string;
30
+ brainVersion: string;
31
+ /** Sorted, deduped — build args for the image, empty for the default. */
32
+ sitePackages: string[];
33
+ }
34
+ /**
35
+ * The image set the declared fleet state requires: one default
36
+ * `brain-{version}` per distinct brain version in use, plus one
37
+ * `brain-{version}-sites-{hash}` per distinct site-override package set.
38
+ * Derived purely from resolved users (pass `registry.users`), so CI can build
39
+ * exactly what a config push declares — nothing reactive, nothing manual.
40
+ */
41
+ export declare function requiredImages(users: ImageRequirementSource[]): RequiredImage[];
42
+ export interface ResolveImageBuildsOptions {
43
+ users: ImageRequirementSource[];
44
+ /**
45
+ * Explicit dispatch override — the manual/backfill path. When set, exactly
46
+ * this one image is built, skipping the registry-derived resolve. Published
47
+ * tags stay immutable: a same-tag rebuild from a newer Dockerfile can
48
+ * strand the tag boot-broken, so rebuilding needs allowTagOverwrite.
49
+ */
50
+ brainVersionInput?: string | undefined;
51
+ sitePackagesInput?: string | undefined;
52
+ allowTagOverwrite?: boolean | undefined;
53
+ imageExists: (tag: string) => Promise<boolean>;
54
+ }
55
+ /**
56
+ * Decide which images a Build run must produce: the declared required set
57
+ * filtered to tags the registry does not already hold, or the single image an
58
+ * explicit dispatch input forces.
59
+ */
60
+ export declare function resolveImageBuilds(options: ResolveImageBuildsOptions): Promise<RequiredImage[]>;
61
+ export interface RunResolveMissingImagesOptions {
62
+ rootDir: string;
63
+ /** e.g. `ghcr.io/rizom-ai/rover-pilot` */
64
+ imageRepository: string;
65
+ env?: NodeJS.ProcessEnv;
66
+ runCommand?: RunCommand;
67
+ writeOutput: (key: string, value: string) => void;
68
+ log?: (line: string) => void;
69
+ }
70
+ /**
71
+ * The Build workflow's resolve step: derive the image set the declared fleet
72
+ * state (pilot.yaml + cohorts + users) requires, probe the container registry
73
+ * for each tag, and emit the missing ones as a GitHub Actions build matrix
74
+ * (`images_json`, entries `{tag, brain_version, site_packages}`). Dispatch
75
+ * inputs `BRAIN_VERSION_INPUT`/`SITE_PACKAGES_INPUT` force a single explicit
76
+ * build instead. Deriving and probing here means a config push builds exactly
77
+ * what it declares — nothing reactive, nothing manual.
78
+ */
79
+ export declare function runResolveMissingImages(options: RunResolveMissingImagesOptions): Promise<RequiredImage[]>;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,10 @@
1
1
  export { initPilotRepo } from "./init";
2
2
  export { loadPilotRegistry, type LoadPilotRegistryOptions, } from "./load-registry";
3
+ export { siteImageTag, sitePackagesFor, requiredImages, resolveImageBuilds, runResolveMissingImages, type ImageRequirementSource, type RequiredImage, type ResolveImageBuildsOptions, type RunResolveMissingImagesOptions, } from "./images";
4
+ export { derivePreviewDomain, type PreviewDomainOptions, } from "./preview-domain";
3
5
  export { writeUsersTable } from "./render-users-table";
4
6
  export { onboardUser } from "./onboard-user";
7
+ export { addPilotUser } from "./user-add";
5
8
  export { reconcileCohort } from "./reconcile-cohort";
6
9
  export { reconcileAll } from "./reconcile-all";
7
10
  export { parseArgs, type ParsedArgs } from "./parse-args";
@@ -10,4 +13,9 @@ export { bootstrapPilotSshKey, runPilotSshKeyBootstrap, } from "./ssh-key-bootst
10
13
  export { bootstrapPilotOriginCertificate, runPilotCertBootstrap, } from "./cert-bootstrap";
11
14
  export { encryptPilotSecrets } from "./secrets-encrypt";
12
15
  export { pushPilotSecrets } from "./secrets-push";
16
+ export { verifyPilotUser } from "./verify-user";
17
+ export { assertDirectorySyncStressTarget, directorySyncStressPlanSchema, directorySyncStressProfileSchema, directorySyncStressReportSchema, resolveDirectorySyncStressPlan, runDirectorySyncStressPlan, sampleStressHealth, stressMetricsFailure, type DirectorySyncStressDriver, type DirectorySyncStressPhase, type DirectorySyncStressPlan, type DirectorySyncStressProfile, type DirectorySyncStressReport, } from "./directory-sync-stress";
18
+ export { cleanupDirectorySyncStress, runDeployedDirectorySyncStress, verifyDirectorySyncStressAccess, type CleanupDirectorySyncStressOptions, type CleanupDirectorySyncStressResult, type DeployedDirectorySyncStressOptions, type DeployedDirectorySyncStressResult, type VerifyDirectorySyncStressAccessOptions, type VerifyDirectorySyncStressAccessResult, } from "./directory-sync-stress-system";
19
+ export { assertHealthWatchdogSmokeTarget, cleanupHealthWatchdogSmoke, renderHealthWatchdogSmokeRemoteScript, runHealthWatchdogSmoke, type CleanupHealthWatchdogSmokeOptions, type CleanupHealthWatchdogSmokeResult, type HealthWatchdogSmokeOptions, type HealthWatchdogSmokeResult, type HealthWatchdogSmokeTarget, } from "./health-watchdog-smoke";
13
20
  export { runCommand, type CommandResult } from "./run-command";
21
+ export { pilotSchema, cohortSchema, canonicalBundleIdSchema, CAPABILITY_BUNDLE_CONTRACT, type PilotConfig, type CohortConfig, } from "./schema";