@osva-ai/cli 1.1.0 → 1.1.2

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 (183) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +36 -0
  3. package/dist/bin/osva.js +26 -0
  4. package/dist/bin/osva.js.map +1 -1
  5. package/dist/commands/index.js +6 -0
  6. package/dist/commands/index.js.map +1 -1
  7. package/dist/doctor/redact.d.ts.map +1 -1
  8. package/dist/doctor/redact.js +3 -1
  9. package/dist/doctor/redact.js.map +1 -1
  10. package/dist/doctor/run-doctor.d.ts +2 -1
  11. package/dist/doctor/run-doctor.d.ts.map +1 -1
  12. package/dist/doctor/run-doctor.js +1 -1
  13. package/dist/doctor/run-doctor.js.map +1 -1
  14. package/dist/doctor/streaming-redact.d.ts +11 -0
  15. package/dist/doctor/streaming-redact.d.ts.map +1 -0
  16. package/dist/doctor/streaming-redact.js +29 -0
  17. package/dist/doctor/streaming-redact.js.map +1 -0
  18. package/dist/platform/compose-inspect.d.ts +9 -0
  19. package/dist/platform/compose-inspect.d.ts.map +1 -0
  20. package/dist/platform/compose-inspect.js +114 -0
  21. package/dist/platform/compose-inspect.js.map +1 -0
  22. package/dist/platform/doctor.d.ts +10 -0
  23. package/dist/platform/doctor.d.ts.map +1 -0
  24. package/dist/platform/doctor.js +154 -0
  25. package/dist/platform/doctor.js.map +1 -0
  26. package/dist/platform/format.d.ts +10 -0
  27. package/dist/platform/format.d.ts.map +1 -0
  28. package/dist/platform/format.js +73 -0
  29. package/dist/platform/format.js.map +1 -0
  30. package/dist/platform/index.d.ts +9 -0
  31. package/dist/platform/index.d.ts.map +1 -0
  32. package/dist/platform/index.js +143 -0
  33. package/dist/platform/index.js.map +1 -0
  34. package/dist/platform/lifecycle.d.ts +20 -0
  35. package/dist/platform/lifecycle.d.ts.map +1 -0
  36. package/dist/platform/lifecycle.js +136 -0
  37. package/dist/platform/lifecycle.js.map +1 -0
  38. package/dist/platform/logs.d.ts +12 -0
  39. package/dist/platform/logs.d.ts.map +1 -0
  40. package/dist/platform/logs.js +81 -0
  41. package/dist/platform/logs.js.map +1 -0
  42. package/dist/platform/readiness.d.ts +9 -0
  43. package/dist/platform/readiness.d.ts.map +1 -0
  44. package/dist/platform/readiness.js +58 -0
  45. package/dist/platform/readiness.js.map +1 -0
  46. package/dist/platform/resolve-installation.d.ts +5 -0
  47. package/dist/platform/resolve-installation.d.ts.map +1 -0
  48. package/dist/platform/resolve-installation.js +115 -0
  49. package/dist/platform/resolve-installation.js.map +1 -0
  50. package/dist/platform/services.d.ts +7 -0
  51. package/dist/platform/services.d.ts.map +1 -0
  52. package/dist/platform/services.js +21 -0
  53. package/dist/platform/services.js.map +1 -0
  54. package/dist/platform/status.d.ts +7 -0
  55. package/dist/platform/status.d.ts.map +1 -0
  56. package/dist/platform/status.js +60 -0
  57. package/dist/platform/status.js.map +1 -0
  58. package/dist/platform/types.d.ts +37 -0
  59. package/dist/platform/types.d.ts.map +1 -0
  60. package/dist/platform/types.js +8 -0
  61. package/dist/platform/types.js.map +1 -0
  62. package/dist/platform/upgrade/backup-policy.d.ts +4 -0
  63. package/dist/platform/upgrade/backup-policy.d.ts.map +1 -0
  64. package/dist/platform/upgrade/backup-policy.js +20 -0
  65. package/dist/platform/upgrade/backup-policy.js.map +1 -0
  66. package/dist/platform/upgrade/catalog.d.ts +26 -0
  67. package/dist/platform/upgrade/catalog.d.ts.map +1 -0
  68. package/dist/platform/upgrade/catalog.js +56 -0
  69. package/dist/platform/upgrade/catalog.js.map +1 -0
  70. package/dist/platform/upgrade/options.d.ts +8 -0
  71. package/dist/platform/upgrade/options.d.ts.map +1 -0
  72. package/dist/platform/upgrade/options.js +17 -0
  73. package/dist/platform/upgrade/options.js.map +1 -0
  74. package/dist/platform/upgrade/preflight.d.ts +25 -0
  75. package/dist/platform/upgrade/preflight.d.ts.map +1 -0
  76. package/dist/platform/upgrade/preflight.js +91 -0
  77. package/dist/platform/upgrade/preflight.js.map +1 -0
  78. package/dist/platform/upgrade/run-upgrade.d.ts +22 -0
  79. package/dist/platform/upgrade/run-upgrade.d.ts.map +1 -0
  80. package/dist/platform/upgrade/run-upgrade.js +253 -0
  81. package/dist/platform/upgrade/run-upgrade.js.map +1 -0
  82. package/dist/platform/upgrade/state.d.ts +31 -0
  83. package/dist/platform/upgrade/state.d.ts.map +1 -0
  84. package/dist/platform/upgrade/state.js +129 -0
  85. package/dist/platform/upgrade/state.js.map +1 -0
  86. package/dist/platform/upgrade/version.d.ts +11 -0
  87. package/dist/platform/upgrade/version.d.ts.map +1 -0
  88. package/dist/platform/upgrade/version.js +70 -0
  89. package/dist/platform/upgrade/version.js.map +1 -0
  90. package/dist/platform/upgrade-guard.d.ts +2 -0
  91. package/dist/platform/upgrade-guard.d.ts.map +1 -0
  92. package/dist/platform/upgrade-guard.js +12 -0
  93. package/dist/platform/upgrade-guard.js.map +1 -0
  94. package/dist/setup/acceptance-install.d.ts +15 -0
  95. package/dist/setup/acceptance-install.d.ts.map +1 -0
  96. package/dist/setup/acceptance-install.js +44 -0
  97. package/dist/setup/acceptance-install.js.map +1 -0
  98. package/dist/setup/atomic-write.d.ts +4 -0
  99. package/dist/setup/atomic-write.d.ts.map +1 -0
  100. package/dist/setup/atomic-write.js +19 -0
  101. package/dist/setup/atomic-write.js.map +1 -0
  102. package/dist/setup/bootstrap-capture.d.ts +9 -0
  103. package/dist/setup/bootstrap-capture.d.ts.map +1 -0
  104. package/dist/setup/bootstrap-capture.js +64 -0
  105. package/dist/setup/bootstrap-capture.js.map +1 -0
  106. package/dist/setup/compose-exec.d.ts +21 -0
  107. package/dist/setup/compose-exec.d.ts.map +1 -0
  108. package/dist/setup/compose-exec.js +55 -0
  109. package/dist/setup/compose-exec.js.map +1 -0
  110. package/dist/setup/compose-project.d.ts +3 -0
  111. package/dist/setup/compose-project.d.ts.map +1 -0
  112. package/dist/setup/compose-project.js +12 -0
  113. package/dist/setup/compose-project.js.map +1 -0
  114. package/dist/setup/compose-template-root.d.ts +3 -0
  115. package/dist/setup/compose-template-root.d.ts.map +1 -0
  116. package/dist/setup/compose-template-root.js +8 -0
  117. package/dist/setup/compose-template-root.js.map +1 -0
  118. package/dist/setup/distribution.d.ts +13 -0
  119. package/dist/setup/distribution.d.ts.map +1 -0
  120. package/dist/setup/distribution.js +55 -0
  121. package/dist/setup/distribution.js.map +1 -0
  122. package/dist/setup/env-file.d.ts +23 -0
  123. package/dist/setup/env-file.d.ts.map +1 -0
  124. package/dist/setup/env-file.js +141 -0
  125. package/dist/setup/env-file.js.map +1 -0
  126. package/dist/setup/format.d.ts +4 -0
  127. package/dist/setup/format.d.ts.map +1 -0
  128. package/dist/setup/format.js +58 -0
  129. package/dist/setup/format.js.map +1 -0
  130. package/dist/setup/index.d.ts +17 -0
  131. package/dist/setup/index.d.ts.map +1 -0
  132. package/dist/setup/index.js +45 -0
  133. package/dist/setup/index.js.map +1 -0
  134. package/dist/setup/install-path.d.ts +3 -0
  135. package/dist/setup/install-path.d.ts.map +1 -0
  136. package/dist/setup/install-path.js +26 -0
  137. package/dist/setup/install-path.js.map +1 -0
  138. package/dist/setup/installation-state.d.ts +29 -0
  139. package/dist/setup/installation-state.d.ts.map +1 -0
  140. package/dist/setup/installation-state.js +83 -0
  141. package/dist/setup/installation-state.js.map +1 -0
  142. package/dist/setup/installation-status.d.ts +14 -0
  143. package/dist/setup/installation-status.d.ts.map +1 -0
  144. package/dist/setup/installation-status.js +36 -0
  145. package/dist/setup/installation-status.js.map +1 -0
  146. package/dist/setup/materialize-install.d.ts +24 -0
  147. package/dist/setup/materialize-install.d.ts.map +1 -0
  148. package/dist/setup/materialize-install.js +108 -0
  149. package/dist/setup/materialize-install.js.map +1 -0
  150. package/dist/setup/probe-spawn.d.ts +16 -0
  151. package/dist/setup/probe-spawn.d.ts.map +1 -0
  152. package/dist/setup/probe-spawn.js +87 -0
  153. package/dist/setup/probe-spawn.js.map +1 -0
  154. package/dist/setup/read-options.d.ts +15 -0
  155. package/dist/setup/read-options.d.ts.map +1 -0
  156. package/dist/setup/read-options.js +69 -0
  157. package/dist/setup/read-options.js.map +1 -0
  158. package/dist/setup/run-onboarding.d.ts +22 -0
  159. package/dist/setup/run-onboarding.d.ts.map +1 -0
  160. package/dist/setup/run-onboarding.js +273 -0
  161. package/dist/setup/run-onboarding.js.map +1 -0
  162. package/dist/setup/run-provision.d.ts +17 -0
  163. package/dist/setup/run-provision.d.ts.map +1 -0
  164. package/dist/setup/run-provision.js +224 -0
  165. package/dist/setup/run-provision.js.map +1 -0
  166. package/dist/setup/run-setup.d.ts +26 -0
  167. package/dist/setup/run-setup.d.ts.map +1 -0
  168. package/dist/setup/run-setup.js +227 -0
  169. package/dist/setup/run-setup.js.map +1 -0
  170. package/dist/setup/secrets.d.ts +2 -0
  171. package/dist/setup/secrets.d.ts.map +1 -0
  172. package/dist/setup/secrets.js +8 -0
  173. package/dist/setup/secrets.js.map +1 -0
  174. package/dist/setup/setup-report.d.ts +19 -0
  175. package/dist/setup/setup-report.d.ts.map +1 -0
  176. package/dist/setup/setup-report.js +35 -0
  177. package/dist/setup/setup-report.js.map +1 -0
  178. package/dist/tsconfig.tsbuildinfo +1 -1
  179. package/package.json +15 -15
  180. package/templates/agent-typescript/.gitignore +4 -0
  181. package/templates/compose-install/compose.yml +307 -0
  182. package/templates/compose-install/distribution.json +5 -0
  183. package/templates/compose-install/upgrade-catalog.json +39 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/platform/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,MAAM,MAAM,mBAAmB,GAC7B,SA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B,GACtB,sBAAsB,GACtB,cAAc,GACd,oBAAoB,GACpB,gBAAgB,GAChB,oBAAoB,CAAC;gBAEb,IAAI,EAAE,oBAAoB,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM;CAIhE"}
@@ -0,0 +1,8 @@
1
+ export class PlatformCommandError extends Error {
2
+ code;
3
+ constructor(code, message) {
4
+ super(message);
5
+ this.code = code;
6
+ }
7
+ }
8
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/platform/types.ts"],"names":[],"mappings":"AAsCA,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IACpC,IAAI,CAOY;IAEzB,YAAY,IAAkC,EAAE,OAAe;QAC7D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF"}
@@ -0,0 +1,4 @@
1
+ export declare const BACKUP_ATTESTATION_FLAG = "backup-confirmed";
2
+ export declare function backupRequirementsText(): string;
3
+ export declare function requiresBackupAttestation(migrationRequired: boolean): boolean;
4
+ //# sourceMappingURL=backup-policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backup-policy.d.ts","sourceRoot":"","sources":["../../../src/platform/upgrade/backup-policy.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,qBAAqB,CAAC;AAE1D,wBAAgB,sBAAsB,IAAI,MAAM,CAc/C;AAED,wBAAgB,yBAAyB,CAAC,iBAAiB,EAAE,OAAO,GAAG,OAAO,CAE7E"}
@@ -0,0 +1,20 @@
1
+ export const BACKUP_ATTESTATION_FLAG = "backup-confirmed";
2
+ export function backupRequirementsText() {
3
+ return [
4
+ "Before upgrading OSVA you must back up durable state manually:",
5
+ "",
6
+ "1. PostgreSQL — logical dump (pg_dump) or your managed snapshot process.",
7
+ " OSVA stores Runs, workflows, agents, API keys, and migration history in PostgreSQL.",
8
+ "2. Artifact storage — back up the Compose artifact volume (filesystem mode) or your S3 bucket.",
9
+ "3. Document secrets separately — OSVA does not back up OSVA_AUTH_SECRET or provider keys.",
10
+ "",
11
+ "OSVA migrations are forward-only. A backup confirmation flag is operator attestation only;",
12
+ "it does not prove a backup exists or that restore was tested.",
13
+ "",
14
+ "See docs/operations/BACKUP_AND_RECOVERY.md and docs/operations/UPGRADE.md.",
15
+ ].join("\n");
16
+ }
17
+ export function requiresBackupAttestation(migrationRequired) {
18
+ return migrationRequired;
19
+ }
20
+ //# sourceMappingURL=backup-policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backup-policy.js","sourceRoot":"","sources":["../../../src/platform/upgrade/backup-policy.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,uBAAuB,GAAG,kBAAkB,CAAC;AAE1D,MAAM,UAAU,sBAAsB;IACpC,OAAO;QACL,gEAAgE;QAChE,EAAE;QACF,0EAA0E;QAC1E,wFAAwF;QACxF,gGAAgG;QAChG,2FAA2F;QAC3F,EAAE;QACF,4FAA4F;QAC5F,+DAA+D;QAC/D,EAAE;QACF,4EAA4E;KAC7E,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,iBAA0B;IAClE,OAAO,iBAAiB,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,26 @@
1
+ export interface UpgradeTarget {
2
+ readonly platformVersion: string;
3
+ readonly imageRef: string;
4
+ }
5
+ export interface UpgradePath {
6
+ readonly fromPlatformVersion: string;
7
+ readonly toPlatformVersion: string;
8
+ readonly migrationRequired: boolean;
9
+ readonly composeTemplateUpdate: boolean;
10
+ }
11
+ export interface ResolvedUpgradeTarget {
12
+ readonly platformVersion: string;
13
+ readonly imageRef: string;
14
+ readonly composeYaml: string;
15
+ readonly path: UpgradePath;
16
+ }
17
+ export declare function loadUpgradeCatalog(): Promise<{
18
+ readonly targets: readonly UpgradeTarget[];
19
+ readonly paths: readonly UpgradePath[];
20
+ }>;
21
+ export declare function resolveUpgradeTarget(input: {
22
+ readonly toPlatformVersion: string;
23
+ readonly fromPlatformVersion: string;
24
+ readonly processEnv: NodeJS.ProcessEnv;
25
+ }): Promise<ResolvedUpgradeTarget>;
26
+ //# sourceMappingURL=catalog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../../src/platform/upgrade/catalog.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,qBAAqB,EAAE,OAAO,CAAC;CACzC;AAQD,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;CAC5B;AAED,wBAAsB,kBAAkB,IAAI,OAAO,CAAC;IAClD,QAAQ,CAAC,OAAO,EAAE,SAAS,aAAa,EAAE,CAAC;IAC3C,QAAQ,CAAC,KAAK,EAAE,SAAS,WAAW,EAAE,CAAC;CACxC,CAAC,CAWD;AAED,wBAAsB,oBAAoB,CAAC,KAAK,EAAE;IAChD,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC;CACxC,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAqDjC"}
@@ -0,0 +1,56 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { assertPinnedImageRef, loadComposeDistribution, } from "../../setup/distribution.js";
4
+ import { resolveComposeInstallTemplateRoot } from "../../setup/compose-template-root.js";
5
+ import { comparePlatformVersions } from "./version.js";
6
+ export async function loadUpgradeCatalog() {
7
+ const templateRoot = resolveComposeInstallTemplateRoot();
8
+ const catalogPath = path.join(templateRoot, "upgrade-catalog.json");
9
+ const raw = await readFile(catalogPath, "utf8");
10
+ const parsed = JSON.parse(raw);
11
+ if (parsed.schemaVersion !== 1) {
12
+ throw new Error(`Unsupported upgrade catalog schema version ${String(parsed.schemaVersion)}.`);
13
+ }
14
+ return { targets: parsed.targets, paths: parsed.paths };
15
+ }
16
+ export async function resolveUpgradeTarget(input) {
17
+ const catalog = await loadUpgradeCatalog();
18
+ const distribution = await loadComposeDistribution();
19
+ const targetEntry = catalog.targets.find((target) => target.platformVersion === input.toPlatformVersion) ??
20
+ (distribution.manifest.platformVersion === input.toPlatformVersion
21
+ ? {
22
+ platformVersion: distribution.manifest.platformVersion,
23
+ imageRef: distribution.manifest.imageRef,
24
+ }
25
+ : undefined);
26
+ if (targetEntry === undefined) {
27
+ throw new Error(`Unsupported upgrade target '${input.toPlatformVersion}'. This CLI supports explicit upgrades to: ${catalog.targets.map((target) => target.platformVersion).join(", ")}.`);
28
+ }
29
+ const pathRule = catalog.paths.find((candidate) => candidate.fromPlatformVersion === input.fromPlatformVersion &&
30
+ candidate.toPlatformVersion === input.toPlatformVersion);
31
+ if (pathRule === undefined) {
32
+ throw new Error(`No supported upgrade path from ${input.fromPlatformVersion} to ${input.toPlatformVersion}. See docs/operations/UPGRADE.md and docs/release/COMPATIBILITY.md.`);
33
+ }
34
+ if (comparePlatformVersions(input.fromPlatformVersion, input.toPlatformVersion) >= 0) {
35
+ throw new Error(`Refusing downgrade or no-op upgrade (${input.fromPlatformVersion} → ${input.toPlatformVersion}).`);
36
+ }
37
+ const imageRef = resolveUpgradeImageRef({
38
+ target: targetEntry,
39
+ processEnv: input.processEnv,
40
+ });
41
+ assertPinnedImageRef(imageRef);
42
+ return {
43
+ platformVersion: targetEntry.platformVersion,
44
+ imageRef,
45
+ composeYaml: distribution.composeYaml,
46
+ path: pathRule,
47
+ };
48
+ }
49
+ function resolveUpgradeImageRef(input) {
50
+ const override = input.processEnv.OSVA_UPGRADE_LOCAL_IMAGE?.trim();
51
+ if (override !== undefined && override.length > 0) {
52
+ return override;
53
+ }
54
+ return input.target.imageRef;
55
+ }
56
+ //# sourceMappingURL=catalog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../../src/platform/upgrade/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EACL,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,iCAAiC,EAAE,MAAM,sCAAsC,CAAC;AACzF,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AA2BvD,MAAM,CAAC,KAAK,UAAU,kBAAkB;IAItC,MAAM,YAAY,GAAG,iCAAiC,EAAE,CAAC;IACzD,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,sBAAsB,CAAC,CAAC;IACpE,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAChD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAuB,CAAC;IACrD,IAAI,MAAM,CAAC,aAAa,KAAK,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CACb,8CAA8C,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,CAC9E,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,KAAK,E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,mBAAmB,EACzB,KAAK,CAAC,iBAAiB,CACxB,IAAI,CAAC,EACN,CAAC;QACD,MAAM,IAAI,KAAK,CACb,wCAAwC,KAAK,CAAC,mBAAmB,MAAM,KAAK,CAAC,iBAAiB,IAAI,CACnG,CAAC;IACJ,CAAC;IAED,MAAM,QAAQ,GAAG,sBAAsB,CAAC;QACtC,MAAM,EAAE,WAAW;QACnB,UAAU,EAAE,KAAK,CAAC,UAAU;KAC7B,CAAC,CAAC;IACH,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IAE/B,OAAO;QACL,eAAe,EAAE,WAAW,CAAC,eAAe;QAC5C,QAAQ;QACR,WAAW,EAAE,YAAY,CAAC,WAAW;QACrC,IAAI,EAAE,QAAQ;KACf,CAAC;AACJ,CAAC;AAED,SAAS,sBAAsB,CAAC,KAG/B;IACC,MAAM,QAAQ,GAAG,KAAK,CAAC,UAAU,CAAC,wBAAwB,EAAE,IAAI,EAAE,CAAC;IACnE,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClD,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,OAAO,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,8 @@
1
+ export interface PlatformUpgradeOptions {
2
+ readonly toPlatformVersion: string;
3
+ readonly dryRun: boolean;
4
+ readonly backupConfirmed: boolean;
5
+ readonly authorizeExecute: boolean;
6
+ }
7
+ export declare function parsePlatformUpgradeOptions(flags: Readonly<Record<string, string | boolean>>): PlatformUpgradeOptions;
8
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../src/platform/upgrade/options.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;CACpC;AAED,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAChD,sBAAsB,CAoBxB"}
@@ -0,0 +1,17 @@
1
+ import { PlatformCommandError } from "../types.js";
2
+ export function parsePlatformUpgradeOptions(flags) {
3
+ const toFlag = flags.to;
4
+ if (toFlag === true || toFlag === undefined) {
5
+ throw new PlatformCommandError("usage", "Usage: osva platform upgrade --to VERSION [--dry-run] [--backup-confirmed] [--yes]");
6
+ }
7
+ if (typeof toFlag !== "string" || toFlag.trim().length === 0) {
8
+ throw new PlatformCommandError("usage", "--to requires an explicit platform version (for example 1.1.0).");
9
+ }
10
+ return {
11
+ toPlatformVersion: toFlag.trim(),
12
+ dryRun: flags["dry-run"] === true,
13
+ backupConfirmed: flags["backup-confirmed"] === true,
14
+ authorizeExecute: flags.yes === true,
15
+ };
16
+ }
17
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/platform/upgrade/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AASnD,MAAM,UAAU,2BAA2B,CACzC,KAAiD;IAEjD,MAAM,MAAM,GAAG,KAAK,CAAC,EAAE,CAAC;IACxB,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QAC5C,MAAM,IAAI,oBAAoB,CAC5B,OAAO,EACP,oFAAoF,CACrF,CAAC;IACJ,CAAC;IACD,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7D,MAAM,IAAI,oBAAoB,CAC5B,OAAO,EACP,iEAAiE,CAClE,CAAC;IACJ,CAAC;IACD,OAAO;QACL,iBAAiB,EAAE,MAAM,CAAC,IAAI,EAAE;QAChC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,KAAK,IAAI;QACjC,eAAe,EAAE,KAAK,CAAC,kBAAkB,CAAC,KAAK,IAAI;QACnD,gBAAgB,EAAE,KAAK,CAAC,GAAG,KAAK,IAAI;KACrC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,25 @@
1
+ import type { ResolvedInstallation } from "../types.js";
2
+ import type { ProbeSpawnFn } from "../../setup/probe-spawn.js";
3
+ import { type ResolvedUpgradeTarget } from "./catalog.js";
4
+ export interface UpgradePreflightReport {
5
+ readonly currentPlatformVersion: string;
6
+ readonly currentImageRef: string;
7
+ readonly targetPlatformVersion: string;
8
+ readonly targetImageRef: string;
9
+ readonly migrationRequired: boolean;
10
+ readonly composeTemplateUpdate: boolean;
11
+ readonly backupRequired: boolean;
12
+ readonly serviceInterruption: string;
13
+ readonly blockingIssues: readonly string[];
14
+ readonly warnings: readonly string[];
15
+ readonly target: ResolvedUpgradeTarget | undefined;
16
+ }
17
+ export declare function runUpgradePreflight(input: {
18
+ readonly installation: ResolvedInstallation;
19
+ readonly toPlatformVersion: string;
20
+ readonly processEnv: NodeJS.ProcessEnv;
21
+ readonly spawn?: ProbeSpawnFn;
22
+ readonly fetch?: typeof fetch;
23
+ }): Promise<UpgradePreflightReport>;
24
+ export declare function formatUpgradeDryRunHuman(report: UpgradePreflightReport): string;
25
+ //# sourceMappingURL=preflight.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preflight.d.ts","sourceRoot":"","sources":["../../../src/platform/upgrade/preflight.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,OAAO,EAAwB,KAAK,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAQhF,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,sBAAsB,EAAE,MAAM,CAAC;IACxC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC;IACvC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,qBAAqB,EAAE,OAAO,CAAC;IACxC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3C,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,QAAQ,CAAC,MAAM,EAAE,qBAAqB,GAAG,SAAS,CAAC;CACpD;AAED,wBAAsB,mBAAmB,CAAC,KAAK,EAAE;IAC/C,QAAQ,CAAC,YAAY,EAAE,oBAAoB,CAAC;IAC5C,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC;IACvC,QAAQ,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CAC/B,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAoElC;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,sBAAsB,GAC7B,MAAM,CAiCR"}
@@ -0,0 +1,91 @@
1
+ import { loadComposeDistribution } from "../../setup/distribution.js";
2
+ import { collectPlatformStatus } from "../status.js";
3
+ import { backupRequirementsText } from "./backup-policy.js";
4
+ import { resolveUpgradeTarget } from "./catalog.js";
5
+ import { isIncompleteUpgrade, isUpgradeInProgress, readUpgradeState, recoveryGuidance, } from "./state.js";
6
+ export async function runUpgradePreflight(input) {
7
+ const blockingIssues = [];
8
+ const warnings = [];
9
+ const existingState = await readUpgradeState(input.installation.installDir);
10
+ if (isUpgradeInProgress(existingState)) {
11
+ blockingIssues.push(`Upgrade already in progress (phase ${existingState.phase}).`);
12
+ }
13
+ else if (isIncompleteUpgrade(existingState)) {
14
+ warnings.push(recoveryGuidance(existingState));
15
+ }
16
+ const currentPlatformVersion = input.installation.marker.platformVersion;
17
+ const currentImageRef = input.installation.marker.imageRef;
18
+ let target;
19
+ try {
20
+ target = await resolveUpgradeTarget({
21
+ toPlatformVersion: input.toPlatformVersion,
22
+ fromPlatformVersion: currentPlatformVersion,
23
+ processEnv: input.processEnv,
24
+ });
25
+ }
26
+ catch (error) {
27
+ blockingIssues.push(error instanceof Error ? error.message : "Unsupported upgrade target.");
28
+ }
29
+ if (target !== undefined) {
30
+ const distribution = await loadComposeDistribution();
31
+ if (distribution.manifest.platformVersion !== target.platformVersion) {
32
+ warnings.push("Target version differs from the bundled CLI distribution metadata; verify image compatibility before proceeding.");
33
+ }
34
+ }
35
+ const status = await collectPlatformStatus(input.installation, {
36
+ spawn: input.spawn,
37
+ fetch: input.fetch,
38
+ });
39
+ if (!status.apiReadyOk) {
40
+ warnings.push("Control plane is not fully ready before upgrade; expect additional startup time after migration.");
41
+ }
42
+ if (currentImageRef !== input.installation.envValues.OSVA_IMAGE) {
43
+ blockingIssues.push("Installation marker and .env image references disagree; repair metadata before upgrading.");
44
+ }
45
+ return {
46
+ currentPlatformVersion,
47
+ currentImageRef,
48
+ targetPlatformVersion: target?.platformVersion ?? input.toPlatformVersion,
49
+ targetImageRef: target?.imageRef ?? "unknown",
50
+ migrationRequired: target?.path.migrationRequired ?? true,
51
+ composeTemplateUpdate: target?.path.composeTemplateUpdate ?? false,
52
+ backupRequired: target?.path.migrationRequired ?? true,
53
+ serviceInterruption: "Expect control plane and Console downtime while application services stop, migrations run, and services restart. PostgreSQL and Valkey remain running.",
54
+ blockingIssues,
55
+ warnings,
56
+ target,
57
+ };
58
+ }
59
+ export function formatUpgradeDryRunHuman(report) {
60
+ const lines = [
61
+ "OSVA platform upgrade dry-run",
62
+ "",
63
+ `Current: ${report.currentPlatformVersion} (${report.currentImageRef})`,
64
+ `Target: ${report.target?.platformVersion ?? report.targetPlatformVersion} (${report.target?.imageRef ?? report.targetImageRef})`,
65
+ "",
66
+ `Migration required: ${report.migrationRequired ? "yes" : "no"}`,
67
+ `Compose template update: ${report.composeTemplateUpdate ? "yes" : "no"}`,
68
+ `Service interruption: ${report.serviceInterruption}`,
69
+ "",
70
+ "Backup requirements:",
71
+ backupRequirementsText(),
72
+ "",
73
+ ];
74
+ if (report.blockingIssues.length > 0) {
75
+ lines.push("Blocking issues:");
76
+ for (const issue of report.blockingIssues) {
77
+ lines.push(` - ${issue}`);
78
+ }
79
+ lines.push("");
80
+ }
81
+ if (report.warnings.length > 0) {
82
+ lines.push("Warnings:");
83
+ for (const warning of report.warnings) {
84
+ lines.push(` - ${warning}`);
85
+ }
86
+ lines.push("");
87
+ }
88
+ lines.push("Dry-run is read-only and cannot predict all migration failures. Run with --backup-confirmed and --yes to execute.");
89
+ return `${lines.join("\n")}\n`;
90
+ }
91
+ //# sourceMappingURL=preflight.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preflight.js","sourceRoot":"","sources":["../../../src/platform/upgrade/preflight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAEtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAA8B,MAAM,cAAc,CAAC;AAChF,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,YAAY,CAAC;AAgBpB,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,KAMzC;IACC,MAAM,cAAc,GAAa,EAAE,CAAC;IACpC,MAAM,QAAQ,GAAa,EAAE,CAAC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BAAyB,MAAM,CAAC,mBAAmB,EAAE;QACrD,EAAE;QACF,sBAAsB;QACtB,sBAAsB,EAAE;QACxB,EAAE;KACH,CAAC;IACF,IAAI,MAAM,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrC,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAC/B,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,cAAc,EAAE,CAAC;YAC1C,KAAK,CAAC,IAAI,CAAC,OAAO,KAAK,EAAE,CAAC,CAAC;QAC7B,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IACD,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/B,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACxB,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;YACtC,KAAK,CAAC,IAAI,CAAC,OAAO,OAAO,EAAE,CAAC,CAAC;QAC/B,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IACD,KAAK,CAAC,IAAI,CACR,mHAAmH,CACpH,CAAC;IACF,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AACjC,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { type ProbeSpawnFn } from "../../setup/probe-spawn.js";
2
+ import { type ResolvedInstallation } from "../types.js";
3
+ import { type UpgradePreflightReport } from "./preflight.js";
4
+ import type { PlatformUpgradeOptions } from "./options.js";
5
+ export declare const COMPOSE_UPGRADE_PULL_TIMEOUT_MS = 900000;
6
+ export interface UpgradeResult {
7
+ readonly fromPlatformVersion: string;
8
+ readonly toPlatformVersion: string;
9
+ readonly imageRef: string;
10
+ readonly message: string;
11
+ }
12
+ export declare function runPlatformUpgrade(installation: ResolvedInstallation, options: PlatformUpgradeOptions, deps?: {
13
+ readonly spawn?: ProbeSpawnFn;
14
+ readonly fetch?: typeof fetch;
15
+ readonly processEnv?: NodeJS.ProcessEnv;
16
+ }): Promise<UpgradeResult>;
17
+ export declare class PlatformUpgradeDryRunReport extends Error {
18
+ readonly formatted: string;
19
+ readonly report: UpgradePreflightReport;
20
+ constructor(formatted: string, report: UpgradePreflightReport);
21
+ }
22
+ //# sourceMappingURL=run-upgrade.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-upgrade.d.ts","sourceRoot":"","sources":["../../../src/platform/upgrade/run-upgrade.ts"],"names":[],"mappings":"AAgBA,OAAO,EAEL,KAAK,YAAY,EAClB,MAAM,4BAA4B,CAAC;AAKpC,OAAO,EAAwB,KAAK,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAM9E,OAAO,EAGL,KAAK,sBAAsB,EAC5B,MAAM,gBAAgB,CAAC;AAUxB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAE3D,eAAO,MAAM,+BAA+B,SAAU,CAAC;AAIvD,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAsB,kBAAkB,CACtC,YAAY,EAAE,oBAAoB,EAClC,OAAO,EAAE,sBAAsB,EAC/B,IAAI,GAAE;IACJ,QAAQ,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IAC9B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CACpC,GACL,OAAO,CAAC,aAAa,CAAC,CAoJxB;AAED,qBAAa,2BAA4B,SAAQ,KAAK;IACpD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,sBAAsB,CAAC;gBAE5B,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,sBAAsB;CAK9D"}
@@ -0,0 +1,253 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { redactSecrets } from "../../doctor/redact.js";
4
+ import { assertComposeSuccess, buildComposeSpawnEnv, composeCommandIncludesDestructiveVolumeRemoval, runComposeCommand, } from "../../setup/compose-exec.js";
5
+ import { writeFileAtomic } from "../../setup/atomic-write.js";
6
+ import { renderInstallEnvFile } from "../../setup/env-file.js";
7
+ import { INSTALLATION_MARKER_RELATIVE, renderInstallationMarker, } from "../../setup/installation-state.js";
8
+ import { defaultProbeSpawn, } from "../../setup/probe-spawn.js";
9
+ import { CLI_VERSION } from "../../version.js";
10
+ import { installEnvValuesFromMap } from "../resolve-installation.js";
11
+ import { probeInstallationReadiness } from "../readiness.js";
12
+ import { PLATFORM_APPLICATION_SERVICES } from "../services.js";
13
+ import { PlatformCommandError } from "../types.js";
14
+ import { COMPOSE_LIFECYCLE_TIMEOUT_MS } from "../lifecycle.js";
15
+ import { backupRequirementsText, requiresBackupAttestation, } from "./backup-policy.js";
16
+ import { formatUpgradeDryRunHuman, runUpgradePreflight, } from "./preflight.js";
17
+ import { acquireUpgradeLock, clearUpgradeState, releaseUpgradeLock, writeUpgradeState, } from "./state.js";
18
+ export const COMPOSE_UPGRADE_PULL_TIMEOUT_MS = 900_000;
19
+ const INTEGRITY_CLI_IMAGE_PATH = "/app/packages/db/dist/migrations-integrity-cli.js";
20
+ export async function runPlatformUpgrade(installation, options, deps = {}) {
21
+ const processEnv = deps.processEnv ?? process.env;
22
+ const report = await runUpgradePreflight({
23
+ installation,
24
+ toPlatformVersion: options.toPlatformVersion,
25
+ processEnv,
26
+ spawn: deps.spawn,
27
+ fetch: deps.fetch,
28
+ });
29
+ if (report.blockingIssues.length > 0) {
30
+ throw new PlatformCommandError("installation_invalid", report.blockingIssues.join(" "));
31
+ }
32
+ if (options.dryRun) {
33
+ throw new PlatformUpgradeDryRunReport(formatUpgradeDryRunHuman(report), report);
34
+ }
35
+ if (report.target === undefined) {
36
+ throw new PlatformCommandError("installation_invalid", report.blockingIssues.join(" "));
37
+ }
38
+ const target = report.target;
39
+ if (!options.authorizeExecute) {
40
+ throw new PlatformCommandError("usage", "Refusing to upgrade without --yes. Run with --dry-run first to review the plan.");
41
+ }
42
+ if (requiresBackupAttestation(report.migrationRequired) &&
43
+ !options.backupConfirmed) {
44
+ throw new PlatformCommandError("usage", `Refusing upgrade without --backup-confirmed.\n\n${backupRequirementsText()}`);
45
+ }
46
+ await acquireUpgradeLock(installation.installDir);
47
+ const startedAt = new Date().toISOString();
48
+ let state = {
49
+ schemaVersion: 1,
50
+ phase: "locked",
51
+ fromPlatformVersion: report.currentPlatformVersion,
52
+ toPlatformVersion: report.targetPlatformVersion,
53
+ fromImageRef: report.currentImageRef,
54
+ targetImageRef: report.targetImageRef,
55
+ startedAt,
56
+ updatedAt: startedAt,
57
+ migrationRequired: report.migrationRequired,
58
+ };
59
+ try {
60
+ await persistState(installation.installDir, state);
61
+ state = await advance(state, "pulling_image", installation.installDir);
62
+ pullTargetImage(target.imageRef, deps.spawn);
63
+ state = await advance(state, "prepared_configuration", installation.installDir);
64
+ await prepareInstallationConfiguration(installation, target);
65
+ state = await advance(state, "stopped_applications", installation.installDir);
66
+ stopApplicationServices(installation, deps.spawn);
67
+ if (report.migrationRequired) {
68
+ state = await advance(state, "migrating", installation.installDir);
69
+ try {
70
+ runMigrationJob(installation, deps.spawn);
71
+ verifyMigrationIntegrity(installation, deps.spawn);
72
+ }
73
+ catch (error) {
74
+ state = await advance(state, "migration_failed", installation.installDir, error);
75
+ throw migrationFailure(error);
76
+ }
77
+ }
78
+ state = await advance(state, "starting_applications", installation.installDir);
79
+ startApplicationServices(installation, deps.spawn);
80
+ state = await advance(state, "validating_readiness", installation.installDir);
81
+ const readiness = await probeInstallationReadiness({
82
+ ...installation,
83
+ envValues: {
84
+ ...installation.envValues,
85
+ OSVA_IMAGE: target.imageRef,
86
+ },
87
+ }, deps.fetch ?? fetch);
88
+ if (!readiness.apiReadyOk || !readiness.consoleReady) {
89
+ throw new PlatformCommandError("platform_not_ready", "Upgrade rolled out the target image but readiness checks failed. The database schema may have migrated; do not downgrade the application without operator review. Inspect logs and docs/operations/UPGRADE.md.");
90
+ }
91
+ await updateInstallationMarker(installation, target);
92
+ state = await advance(state, "completed", installation.installDir);
93
+ await clearUpgradeState(installation.installDir);
94
+ return {
95
+ fromPlatformVersion: report.currentPlatformVersion,
96
+ toPlatformVersion: report.targetPlatformVersion,
97
+ imageRef: target.imageRef,
98
+ message: `Upgraded OSVA platform from ${report.currentPlatformVersion} to ${report.targetPlatformVersion}.`,
99
+ };
100
+ }
101
+ catch (error) {
102
+ if (state.phase !== "completed" &&
103
+ state.phase !== "migration_failed" &&
104
+ state.phase !== "failed") {
105
+ state = await advance(state, "failed", installation.installDir, error);
106
+ }
107
+ throw error;
108
+ }
109
+ finally {
110
+ await releaseUpgradeLock(installation.installDir);
111
+ }
112
+ }
113
+ export class PlatformUpgradeDryRunReport extends Error {
114
+ formatted;
115
+ report;
116
+ constructor(formatted, report) {
117
+ super("dry-run");
118
+ this.formatted = formatted;
119
+ this.report = report;
120
+ }
121
+ }
122
+ async function persistState(installDir, state) {
123
+ await writeUpgradeState(installDir, state);
124
+ }
125
+ async function advance(state, phase, installDir, error) {
126
+ const next = {
127
+ ...state,
128
+ phase,
129
+ updatedAt: new Date().toISOString(),
130
+ ...(error === undefined
131
+ ? {}
132
+ : {
133
+ lastError: redactSecrets(error instanceof Error ? error.message : String(error)),
134
+ }),
135
+ };
136
+ await writeUpgradeState(installDir, next);
137
+ return next;
138
+ }
139
+ function pullTargetImage(imageRef, spawn) {
140
+ const run = spawn ?? defaultProbeSpawn;
141
+ const pull = run("docker", ["pull", imageRef], COMPOSE_UPGRADE_PULL_TIMEOUT_MS);
142
+ if (pull.status !== 0) {
143
+ throw new PlatformCommandError("compose_failed", redactSecrets(pull.stderr.trim() ||
144
+ pull.stdout.trim() ||
145
+ `Failed to pull ${imageRef}.`));
146
+ }
147
+ }
148
+ async function prepareInstallationConfiguration(installation, target) {
149
+ const envMap = new Map(Object.entries(installation.envValues));
150
+ envMap.set("OSVA_IMAGE", target.imageRef);
151
+ const values = installEnvValuesFromMap(envMap);
152
+ await writeFileAtomic(installation.envPath, renderInstallEnvFile(values), {
153
+ restrictPermissions: true,
154
+ });
155
+ if (target.path.composeTemplateUpdate) {
156
+ await writeFileAtomic(installation.composePath, target.composeYaml);
157
+ }
158
+ }
159
+ function stopApplicationServices(installation, spawn) {
160
+ const services = [...PLATFORM_APPLICATION_SERVICES].reverse();
161
+ const args = ["stop", ...services];
162
+ assertSafeArgs(args);
163
+ const result = runComposeCommand(installation.execCtx, args, {
164
+ spawn,
165
+ timeoutMs: COMPOSE_LIFECYCLE_TIMEOUT_MS,
166
+ processEnv: buildComposeSpawnEnv(installation.execCtx),
167
+ });
168
+ assertComposeSuccess(result, "Stopping application services for upgrade");
169
+ }
170
+ function runMigrationJob(installation, spawn) {
171
+ const args = ["up", "--no-build", "--wait", "migrate"];
172
+ assertSafeArgs(args);
173
+ const result = runComposeCommand(installation.execCtx, args, {
174
+ spawn,
175
+ timeoutMs: COMPOSE_LIFECYCLE_TIMEOUT_MS,
176
+ processEnv: buildComposeSpawnEnv(installation.execCtx),
177
+ });
178
+ assertComposeSuccess(result, "Database migration job");
179
+ }
180
+ function verifyMigrationIntegrity(installation, spawn) {
181
+ const args = [
182
+ "run",
183
+ "--rm",
184
+ "-T",
185
+ "--no-deps",
186
+ "--entrypoint",
187
+ "node",
188
+ "web",
189
+ INTEGRITY_CLI_IMAGE_PATH,
190
+ ];
191
+ assertSafeArgs(args);
192
+ const result = runComposeCommand(installation.execCtx, args, {
193
+ spawn,
194
+ timeoutMs: COMPOSE_LIFECYCLE_TIMEOUT_MS,
195
+ processEnv: buildComposeSpawnEnv(installation.execCtx),
196
+ });
197
+ if (result.status !== 0) {
198
+ throw new PlatformCommandError("platform_not_ready", redactSecrets(result.stderr.trim() ||
199
+ result.stdout.trim() ||
200
+ "Migration integrity probe failed."));
201
+ }
202
+ const output = result.stdout.trim();
203
+ if (output.includes("schema_mismatch") ||
204
+ output.includes("schema_ahead") ||
205
+ output.includes("database_inaccessible")) {
206
+ throw new PlatformCommandError("platform_not_ready", "Migration integrity probe reported schema mismatch. Follow docs/operations/UPGRADE.md before restarting applications.");
207
+ }
208
+ }
209
+ function startApplicationServices(installation, spawn) {
210
+ const args = [
211
+ "up",
212
+ "-d",
213
+ "--no-build",
214
+ "--pull",
215
+ "never",
216
+ "--wait",
217
+ ...PLATFORM_APPLICATION_SERVICES,
218
+ ];
219
+ assertSafeArgs(args);
220
+ const result = runComposeCommand(installation.execCtx, args, {
221
+ spawn,
222
+ timeoutMs: COMPOSE_LIFECYCLE_TIMEOUT_MS,
223
+ processEnv: buildComposeSpawnEnv(installation.execCtx),
224
+ });
225
+ assertComposeSuccess(result, "Starting upgraded application services");
226
+ }
227
+ async function updateInstallationMarker(installation, target) {
228
+ const markerPath = path.join(installation.installDir, INSTALLATION_MARKER_RELATIVE);
229
+ const raw = await readFile(markerPath, "utf8");
230
+ const existing = JSON.parse(raw);
231
+ const marker = renderInstallationMarker({
232
+ platformVersion: target.platformVersion,
233
+ imageRef: target.imageRef,
234
+ cliVersion: CLI_VERSION,
235
+ installDir: installation.installDir,
236
+ composeProjectName: installation.envValues.COMPOSE_PROJECT_NAME,
237
+ existing,
238
+ });
239
+ await writeFileAtomic(markerPath, `${JSON.stringify(marker, null, 2)}\n`, {
240
+ restrictPermissions: true,
241
+ });
242
+ }
243
+ function assertSafeArgs(args) {
244
+ if (composeCommandIncludesDestructiveVolumeRemoval(args)) {
245
+ throw new Error("Refusing destructive compose operation during upgrade.");
246
+ }
247
+ }
248
+ function migrationFailure(error) {
249
+ return new PlatformCommandError("platform_not_ready", error instanceof PlatformCommandError
250
+ ? error.message
251
+ : "Database migration failed during upgrade. Application services remain stopped. Schema may be partially migrated — see docs/operations/UPGRADE.md.");
252
+ }
253
+ //# sourceMappingURL=run-upgrade.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-upgrade.js","sourceRoot":"","sources":["../../../src/platform/upgrade/run-upgrade.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,8CAA8C,EAC9C,iBAAiB,GAClB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EACL,4BAA4B,EAC5B,wBAAwB,GACzB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,iBAAiB,GAElB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAA6B,MAAM,aAAa,CAAC;AAC9E,OAAO,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EACL,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,wBAAwB,EACxB,mBAAmB,GAEpB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,GAGlB,MAAM,YAAY,CAAC;AAGpB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