@rizom/ops 0.2.0-alpha.351 → 0.2.0-alpha.353

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.
@@ -1,87 +1,97 @@
1
1
  import type { FetchLike } from "@brains/deploy-support/origin-ca";
2
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>;
3
+ export declare const directorySyncStressProfileSchema: z.ZodEnum<{
4
+ regression: "regression";
5
+ load: "load";
6
+ stress: "stress";
7
+ }>;
8
+ export type DirectorySyncStressProfile = z.output<typeof directorySyncStressProfileSchema>;
9
+ export declare const directorySyncStressOperationSchema: z.ZodEnum<{
10
+ add: "add";
11
+ update: "update";
12
+ rename: "rename";
13
+ delete: "delete";
14
+ }>;
15
+ export type DirectorySyncStressOperation = z.output<typeof directorySyncStressOperationSchema>;
16
+ export declare const directorySyncStressPhaseSchema: z.ZodObject<{
17
+ id: z.ZodString;
18
+ operation: typeof directorySyncStressOperationSchema;
19
+ count: z.ZodNumber;
20
+ targetProbeCount: z.ZodNumber;
21
+ settleMs: z.ZodNumber;
22
+ }>;
23
+ export type DirectorySyncStressPhase = z.output<typeof directorySyncStressPhaseSchema>;
24
+ export declare const directorySyncStressPlanSchema: z.ZodObject<{
25
+ profile: typeof directorySyncStressProfileSchema;
26
+ maximumProbeCount: z.ZodNumber;
27
+ maximumExternalAiCalls: z.ZodOptional<z.ZodNumber>;
28
+ phases: z.ZodArray<typeof directorySyncStressPhaseSchema>;
29
+ }>;
30
+ export type DirectorySyncStressPlan = z.output<typeof directorySyncStressPlanSchema>;
31
+ export declare const stressBaselineSchema: z.ZodObject<{
32
+ entities: z.ZodNumber;
33
+ notes: z.ZodNumber;
34
+ version: z.ZodString;
35
+ }>;
36
+ export type StressBaseline = z.output<typeof stressBaselineSchema>;
37
+ export declare const stressHealthSampleSchema: z.ZodObject<{
38
+ timestamp: z.ZodISODateTime;
39
+ endpoint: z.ZodString;
40
+ status: z.ZodNumber;
41
+ durationMs: z.ZodNumber;
42
+ ok: z.ZodBoolean;
43
+ error: z.ZodOptional<z.ZodString>;
44
+ }>;
45
+ export type StressHealthSample = z.output<typeof stressHealthSampleSchema>;
46
+ export declare const stressRuntimeSampleSchema: z.ZodObject<{
47
+ timestamp: z.ZodISODateTime;
48
+ cpuPercent: z.ZodNumber;
49
+ memoryPercent: z.ZodNumber;
50
+ pids: z.ZodNumber;
51
+ }>;
52
+ export type StressRuntimeSample = z.output<typeof stressRuntimeSampleSchema>;
53
+ export declare const stressPhaseResultSchema: z.ZodObject<{
54
+ id: z.ZodString;
55
+ operation: typeof directorySyncStressOperationSchema;
56
+ count: z.ZodNumber;
57
+ success: z.ZodBoolean;
58
+ commitLatencyMs: z.ZodOptional<z.ZodNumber>;
59
+ persistenceLatencyMs: z.ZodOptional<z.ZodNumber>;
60
+ error: z.ZodOptional<z.ZodString>;
61
+ }>;
62
+ export type StressPhaseResult = z.output<typeof stressPhaseResultSchema>;
63
+ export declare const stressCleanupResultSchema: z.ZodObject<{
64
+ success: z.ZodBoolean;
65
+ probesRemaining: z.ZodNumber;
66
+ finalEntities: z.ZodOptional<z.ZodNumber>;
67
+ finalNotes: z.ZodOptional<z.ZodNumber>;
68
+ contentTreeRestored: z.ZodOptional<z.ZodBoolean>;
69
+ error: z.ZodOptional<z.ZodString>;
70
+ }>;
71
+ export type StressCleanupResult = z.output<typeof stressCleanupResultSchema>;
72
+ export declare const stressContainerStateSchema: z.ZodObject<{
73
+ status: z.ZodString;
74
+ restartCount: z.ZodNumber;
75
+ oomKilled: z.ZodBoolean;
76
+ }>;
77
+ export type StressContainerState = z.output<typeof stressContainerStateSchema>;
78
+ export declare const stressMetricsSchema: z.ZodObject<{
79
+ health: z.ZodArray<typeof stressHealthSampleSchema>;
80
+ runtime: z.ZodArray<typeof stressRuntimeSampleSchema>;
81
+ externalAiCalls: z.ZodOptional<z.ZodNumber>;
82
+ container: z.ZodOptional<typeof stressContainerStateSchema>;
83
+ }>;
84
+ export type StressMetrics = z.output<typeof stressMetricsSchema>;
85
+ export declare const directorySyncStressReportSchema: z.ZodObject<{
86
+ profile: typeof directorySyncStressProfileSchema;
87
+ success: z.ZodBoolean;
88
+ baseline: typeof stressBaselineSchema;
89
+ phases: z.ZodArray<typeof stressPhaseResultSchema>;
90
+ cleanup: typeof stressCleanupResultSchema;
91
+ metrics: typeof stressMetricsSchema;
92
+ failure: z.ZodOptional<z.ZodString>;
93
+ }>;
94
+ export type DirectorySyncStressReport = z.output<typeof directorySyncStressReportSchema>;
85
95
  export interface DirectorySyncStressTarget {
86
96
  handle: string;
87
97
  domain: string;
@@ -1,4 +1,3 @@
1
1
  export { readJsonResponse, parseEnvFile, parseEnvSchema, parseEnvSchemaFile, requireEnv, writeGitHubOutput, writeGitHubEnv, } from "@brains/deploy-support";
2
2
  export type { EnvSchemaEntry } from "@brains/deploy-support";
3
- export { siteImageTag, runtimeImageTag, sitePackagesFor, requiredImages, resolveImageBuilds, runResolveMissingImages, type ImageRequirementSource, type RequiredImage, type ResolveImageBuildsOptions, type RunResolveMissingImagesOptions, } from "../images";
4
- export { SHARED_FLEET_IMAGE_CONTRACT, ISOLATED_SITE_IMAGE_CONTRACT, imageContractSchema, type ImageContract, } from "../schema";
3
+ export { runtimeImageTag, sitePackagesFor, requiredImages, resolveImageBuilds, runResolveMissingImages, type ImageRequirementSource, type RequiredImage, type ResolveImageBuildsOptions, type RunResolveMissingImagesOptions, } from "../images";
package/dist/images.d.ts CHANGED
@@ -1,23 +1,13 @@
1
1
  import { type ResolvedSiteOverride } from "./load-registry";
2
2
  import { type RunCommand } from "./run-subprocess";
3
- import { type ImageContract } from "./schema";
4
3
  /**
5
- * Resolve a fleet image tag as a pure function of a single instance's own
6
- * config. This is the shared contract between the build (which tags the image
7
- * it pushes) and the deploy (which waits for and runs that tag), so both must
8
- * import this — never recompute it independently.
9
- *
10
- * The default path is deliberately untouched: an instance with no site packages
11
- * resolves to the plain `brain-{version}` tag every other fleet instance uses.
12
- * A site override is a per-instance opt-in that hashes only *that instance's*
13
- * package set into a distinct `brain-{version}-sites-{hash}` image, so it can
14
- * never collide with — or leak into — the shared default image.
4
+ * Resolve the immutable runtime image shared by every fleet instance on one
5
+ * Brain version. Build and Deploy both import this function so their tags can
6
+ * never disagree.
15
7
  */
16
- export declare function siteImageTag(brainVersion: string, sitePackages: string[]): string;
17
- /** Resolve the runtime tag selected by the pilot's explicit image contract. */
18
- export declare function runtimeImageTag(imageContract: ImageContract, brainVersion: string, sitePackages: string[]): string;
8
+ export declare function runtimeImageTag(brainVersion: string): string;
19
9
  /**
20
- * The npm packages a site override installs into its per-instance image.
10
+ * The npm packages a site override contributes to its version's shared image.
21
11
  * A @rizom-scoped theme is independently published and installs at its own
22
12
  * explicit version; @brains/* themes are bundled inside @rizom/brain and must
23
13
  * not be npm-installed.
@@ -35,15 +25,13 @@ export interface RequiredImage {
35
25
  sitePackages: string[];
36
26
  }
37
27
  /**
38
- * Derive the immutable images required by the declared fleet. Shared fleets
39
- * get one image per Brain version containing the union of packages required by
40
- * every instance on that version. Fleets that explicitly retain isolated site
41
- * images get one tag per distinct version/package set.
28
+ * Derive one immutable image per effective Brain version. Each image contains
29
+ * the union of exact site/theme package pins required by every instance on
30
+ * that version.
42
31
  */
43
- export declare function requiredImages(users: ImageRequirementSource[], imageContract?: ImageContract): RequiredImage[];
32
+ export declare function requiredImages(users: ImageRequirementSource[]): RequiredImage[];
44
33
  export interface ResolveImageBuildsOptions {
45
34
  users: ImageRequirementSource[];
46
- imageContract?: ImageContract | undefined;
47
35
  /**
48
36
  * Explicit dispatch override — the manual/backfill path. When set, exactly
49
37
  * this one image is built, skipping the registry-derived resolve. Published
@@ -70,13 +58,27 @@ export interface RunResolveMissingImagesOptions {
70
58
  writeOutput: (key: string, value: string) => void;
71
59
  log?: (line: string) => void;
72
60
  }
61
+ /**
62
+ * Whether the registry already holds this tag.
63
+ *
64
+ * `docker manifest inspect` exits non-zero when the manifest is unknown, so a
65
+ * command failure is the "absent" answer. A failure to run docker at all is
66
+ * not: answering false there would let resolveImageBuilds past its
67
+ * tag-immutability guard and overwrite a published tag, which is exactly what
68
+ * that guard exists to prevent. Those propagate.
69
+ *
70
+ * A non-zero exit caused by an auth or network problem is still read as
71
+ * absent — docker reports it the same way it reports an unknown manifest, and
72
+ * telling them apart means matching stderr text that shifts between versions.
73
+ */
74
+ export declare function imageTagExists(run: RunCommand, imageRepository: string, tag: string): Promise<boolean>;
73
75
  /**
74
76
  * The Build workflow's resolve step: derive the image set the declared fleet
75
77
  * state (pilot.yaml + cohorts + users) requires, probe the container registry
76
78
  * for each tag, and emit the missing ones as a GitHub Actions build matrix
77
79
  * (`images_json`, entries `{tag, brain_version, site_packages}`). Dispatch
78
- * inputs `BRAIN_VERSION_INPUT`/`SITE_PACKAGES_INPUT`/`IMAGE_CONTRACT_INPUT`
79
- * force a single explicit build instead. Deriving and probing here means a config push builds exactly
80
+ * inputs `BRAIN_VERSION_INPUT`/`SITE_PACKAGES_INPUT` force a single explicit
81
+ * build instead. Deriving and probing here means a config push builds exactly
80
82
  * what it declares — nothing reactive, nothing manual.
81
83
  */
82
84
  export declare function runResolveMissingImages(options: RunResolveMissingImagesOptions): Promise<RequiredImage[]>;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { initPilotRepo } from "./init";
2
2
  export { loadPilotRegistry, type LoadPilotRegistryOptions, } from "./load-registry";
3
- export { siteImageTag, runtimeImageTag, sitePackagesFor, requiredImages, resolveImageBuilds, runResolveMissingImages, type ImageRequirementSource, type RequiredImage, type ResolveImageBuildsOptions, type RunResolveMissingImagesOptions, } from "./images";
3
+ export { runtimeImageTag, sitePackagesFor, requiredImages, resolveImageBuilds, runResolveMissingImages, type ImageRequirementSource, type RequiredImage, type ResolveImageBuildsOptions, type RunResolveMissingImagesOptions, } from "./images";
4
4
  export { derivePreviewDomain, type PreviewDomainOptions, } from "./preview-domain";
5
5
  export { writeUsersTable } from "./render-users-table";
6
6
  export { onboardUser } from "./onboard-user";
@@ -18,4 +18,4 @@ export { assertDirectorySyncStressTarget, directorySyncStressPlanSchema, directo
18
18
  export { cleanupDirectorySyncStress, runDeployedDirectorySyncStress, verifyDirectorySyncStressAccess, type CleanupDirectorySyncStressOptions, type CleanupDirectorySyncStressResult, type DeployedDirectorySyncStressOptions, type DeployedDirectorySyncStressResult, type VerifyDirectorySyncStressAccessOptions, type VerifyDirectorySyncStressAccessResult, } from "./directory-sync-stress-system";
19
19
  export { assertHealthWatchdogSmokeTarget, cleanupHealthWatchdogSmoke, renderHealthWatchdogSmokeRemoteScript, runHealthWatchdogSmoke, type CleanupHealthWatchdogSmokeOptions, type CleanupHealthWatchdogSmokeResult, type HealthWatchdogSmokeOptions, type HealthWatchdogSmokeResult, type HealthWatchdogSmokeTarget, } from "./health-watchdog-smoke";
20
20
  export { runCommand, type CommandResult } from "./run-command";
21
- export { pilotSchema, cohortSchema, canonicalBundleIdSchema, CAPABILITY_BUNDLE_CONTRACT, SHARED_FLEET_IMAGE_CONTRACT, ISOLATED_SITE_IMAGE_CONTRACT, imageContractSchema, type ImageContract, type PilotConfig, type CohortConfig, } from "./schema";
21
+ export { pilotSchema, cohortSchema, canonicalBundleIdSchema, CAPABILITY_BUNDLE_CONTRACT, type PilotConfig, type CohortConfig, } from "./schema";