@plexus-ms/lib 0.122.0 → 0.123.0

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 (87) hide show
  1. package/dist/bookkeeping.d.ts +0 -8
  2. package/dist/bookkeeping.d.ts.map +1 -1
  3. package/dist/bookkeeping.js +2 -15
  4. package/dist/bookkeeping.js.map +1 -1
  5. package/dist/compose.d.ts +41 -0
  6. package/dist/compose.d.ts.map +1 -0
  7. package/dist/compose.js +169 -0
  8. package/dist/compose.js.map +1 -0
  9. package/dist/consumers.d.ts +3 -18
  10. package/dist/consumers.d.ts.map +1 -1
  11. package/dist/consumers.js +13 -42
  12. package/dist/consumers.js.map +1 -1
  13. package/dist/context.d.ts +6 -0
  14. package/dist/context.d.ts.map +1 -1
  15. package/dist/context.js +14 -5
  16. package/dist/context.js.map +1 -1
  17. package/dist/deploy.d.ts +11 -3
  18. package/dist/deploy.d.ts.map +1 -1
  19. package/dist/deploy.js +181 -117
  20. package/dist/deploy.js.map +1 -1
  21. package/dist/doctor.d.ts +121 -15
  22. package/dist/doctor.d.ts.map +1 -1
  23. package/dist/doctor.js +512 -71
  24. package/dist/doctor.js.map +1 -1
  25. package/dist/effects.d.ts +3 -0
  26. package/dist/effects.d.ts.map +1 -1
  27. package/dist/effects.js.map +1 -1
  28. package/dist/frontmatter.js +1 -1
  29. package/dist/frontmatter.js.map +1 -1
  30. package/dist/index.d.ts +10 -10
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +10 -10
  33. package/dist/index.js.map +1 -1
  34. package/dist/io.d.ts +28 -0
  35. package/dist/io.d.ts.map +1 -1
  36. package/dist/io.js +86 -4
  37. package/dist/io.js.map +1 -1
  38. package/dist/marker.d.ts +22 -5
  39. package/dist/marker.d.ts.map +1 -1
  40. package/dist/marker.js +100 -13
  41. package/dist/marker.js.map +1 -1
  42. package/dist/model.d.ts +48 -4
  43. package/dist/model.d.ts.map +1 -1
  44. package/dist/model.js +59 -11
  45. package/dist/model.js.map +1 -1
  46. package/dist/need.d.ts +11 -34
  47. package/dist/need.d.ts.map +1 -1
  48. package/dist/need.js +92 -54
  49. package/dist/need.js.map +1 -1
  50. package/dist/overview.d.ts +25 -0
  51. package/dist/overview.d.ts.map +1 -1
  52. package/dist/overview.js +106 -14
  53. package/dist/overview.js.map +1 -1
  54. package/dist/propagate.d.ts +3 -3
  55. package/dist/propagate.d.ts.map +1 -1
  56. package/dist/propagate.js +8 -6
  57. package/dist/propagate.js.map +1 -1
  58. package/dist/requirements.d.ts +1 -1
  59. package/dist/requirements.d.ts.map +1 -1
  60. package/dist/requirements.js +6 -5
  61. package/dist/requirements.js.map +1 -1
  62. package/dist/standard-index.json +90 -6
  63. package/dist/take.d.ts +1 -1
  64. package/dist/take.d.ts.map +1 -1
  65. package/dist/take.js +6 -25
  66. package/dist/take.js.map +1 -1
  67. package/dist/templates.d.ts +21 -0
  68. package/dist/templates.d.ts.map +1 -0
  69. package/dist/templates.js +55 -0
  70. package/dist/templates.js.map +1 -0
  71. package/dist/update.d.ts +3 -3
  72. package/dist/update.d.ts.map +1 -1
  73. package/dist/update.js +58 -71
  74. package/dist/update.js.map +1 -1
  75. package/dist/version.d.ts +7 -2
  76. package/dist/version.d.ts.map +1 -1
  77. package/dist/version.js +17 -2
  78. package/dist/version.js.map +1 -1
  79. package/package.json +1 -1
  80. package/dist/catalog.d.ts +0 -23
  81. package/dist/catalog.d.ts.map +0 -1
  82. package/dist/catalog.js +0 -38
  83. package/dist/catalog.js.map +0 -1
  84. package/dist/manifest.d.ts +0 -20
  85. package/dist/manifest.d.ts.map +0 -1
  86. package/dist/manifest.js +0 -59
  87. package/dist/manifest.js.map +0 -1
package/dist/deploy.js CHANGED
@@ -4,7 +4,7 @@
4
4
  // render compose.yaml from the invoking checkout, pinning the image ref (§§ 2 and 3 PLX-App)
5
5
  // → stage it on the host → docker compose pull → compose run --rm migrate (if declared),
6
6
  // both against the staged file → swap the file into place → docker compose up -d --remove-orphans
7
- // → poll the readiness path → on failure: restore the previous file, up -d --remove-orphans (no pull), fail
7
+ // → wait for web's healthcheck → on failure: restore the previous file, up -d --remove-orphans (no pull), fail
8
8
  //
9
9
  // Run from a checkout of the app's SOURCE repo (§ 2 PLX-App): an app repo's
10
10
  // CI, or the operations repo for third-party software the tenant merely
@@ -20,7 +20,7 @@
20
20
  //
21
21
  // Every command sent to the host is one line of shell over ssh, carried in
22
22
  // the plan and printed verbatim by the dry run, so a stranded operator copies
23
- // the lines; the host needs bash, docker and curl and nothing else. The ssh
23
+ // the lines; the host needs bash and docker and nothing else. The ssh
24
24
  // calls share one connection (ControlMaster), opened by the first and closed
25
25
  // at the end. Reality is the source of truth: the previous image is read from
26
26
  // the running container, never from a file this verb owns.
@@ -29,11 +29,12 @@
29
29
  // has them declares a one-shot `migrate` service (same image, migrate command,
30
30
  // `profiles: ["migrate"]` so plain `up` never starts it). The `web` service is
31
31
  // the app service by convention; it is the one the live image and the
32
- // readiness path are read from, every other service rides along with pull
33
- // and up. A third-party app pins its image inside compose.yaml and passes no
34
- // image ref; the file is then placed as is. Where the host already serves
35
- // the same file with `web` running and healthy, with or without a ref, the
36
- // verb ends there: nothing is pulled, migrated or restarted.
32
+ // health status are read from, and the one that must declare a healthcheck
33
+ // (PLX-App/Healthcheck); every other service rides along with pull and up.
34
+ // A third-party app pins its image inside compose.yaml and passes no image
35
+ // ref; the file is then placed as is. Where the host already serves the same
36
+ // file with `web` running and healthy, with or without a ref, the verb ends
37
+ // there: nothing is pulled, migrated or restarted.
37
38
  //
38
39
  // plx deploy deploy@1.2.3.4 website --image ghcr.io/org/website:<sha>
39
40
  // plx deploy deploy@1.2.3.4 website --environment staging --image … # into /opt/stacks/website-staging
@@ -41,11 +42,11 @@
41
42
  import { randomBytes } from 'node:crypto';
42
43
  import { tmpdir } from 'node:os';
43
44
  import { join } from 'node:path';
45
+ import { declaresHealthcheck, healthcheckOf, IMAGE_PLACEHOLDER, parseCompose } from "./compose.js";
44
46
  import { DEFAULT_ENVIRONMENT, deploymentSlug } from "./deployTargets.js";
45
47
  import { run } from "./effects.js";
46
48
  import { orAbsent } from "./io.js";
47
49
  import { UsageError } from "./version.js";
48
- const PLACEHOLDER = /\$\{PLEXUS_DEPLOYMENT_IMAGE(:[^}]*)?\}/g;
49
50
  const INCOMING = '.incoming';
50
51
  /**
51
52
  * Pin the image ref in place of the ${PLEXUS_DEPLOYMENT_IMAGE} placeholder
@@ -55,12 +56,12 @@ const INCOMING = '.incoming';
55
56
  * would ship an empty image; both are errors here, never on the host.
56
57
  */
57
58
  export function renderCompose(text, image, path) {
58
- const has = PLACEHOLDER.test(text);
59
- PLACEHOLDER.lastIndex = 0;
59
+ const has = IMAGE_PLACEHOLDER.test(text);
60
+ IMAGE_PLACEHOLDER.lastIndex = 0;
60
61
  if (image) {
61
62
  if (!has)
62
63
  throw new UsageError(`${path} does not reference \${PLEXUS_DEPLOYMENT_IMAGE}; an image ref was given but nothing would use it (§ 3 PLX-App)`);
63
- return text.replace(PLACEHOLDER, image);
64
+ return text.replace(IMAGE_PLACEHOLDER, image);
64
65
  }
65
66
  if (has)
66
67
  throw new UsageError(`${path} references \${PLEXUS_DEPLOYMENT_IMAGE} but no image ref was given`);
@@ -123,6 +124,30 @@ class Remote {
123
124
  return this.ctx.apply([run('ssh', ['-o', `ControlPath=${this.socket}`, '-O', 'exit', this.host])]);
124
125
  }
125
126
  }
127
+ /** A compose duration (Go's syntax: `1m30s`, `500ms`) in seconds, or undefined when it is not one. */
128
+ export function seconds(duration) {
129
+ if (typeof duration !== 'string' || !/^((\d+\.?\d*|\.\d+)(ns|us|µs|ms|s|m|h))+$/.test(duration))
130
+ return undefined;
131
+ const unit = { ns: 1e-9, us: 1e-6, µs: 1e-6, ms: 1e-3, s: 1, m: 60, h: 3600 };
132
+ let total = 0;
133
+ for (const [, n, u] of duration.matchAll(/(\d+\.?\d*|\.\d+)(ns|us|µs|ms|s|m|h)/g))
134
+ total += Number(n) * (unit[u] ?? 0);
135
+ return total;
136
+ }
137
+ /**
138
+ * Why the healthcheck would be seen healthy late, or not at all within a
139
+ * wait of `budget` seconds: without `start_interval`, or once a short
140
+ * `start_period` is over, Docker probes only every `interval`. Undefined when
141
+ * the timing keys cover the wait; a value the verb cannot read is left to compose.
142
+ */
143
+ export function slowStart(check, budget) {
144
+ if (check.start_interval == null)
145
+ return 'sets no start_interval';
146
+ const period = check.start_period == null ? 0 : seconds(check.start_period);
147
+ if (period !== undefined && period < budget)
148
+ return `has a start_period of ${period}s, under the deploy's ${budget}s wait`;
149
+ return undefined;
150
+ }
126
151
  /** Deploy from the checkout at `dir`: read, render, then the host-side steps in order. */
127
152
  export async function deploy(ctx, options) {
128
153
  const { host, app } = options;
@@ -146,142 +171,181 @@ export async function deploy(ctx, options) {
146
171
  if (compose === undefined)
147
172
  throw new UsageError(`no compose.yaml under ${source}; run from the app's source repo (§ 2 PLX-App)`);
148
173
  const rendered = renderCompose(text, image, compose);
174
+ // The wait's budget: `retries` looks, two seconds apart.
175
+ const budget = retries * 2;
176
+ const check = healthcheckOf(parseCompose(rendered, compose));
177
+ if (!declaresHealthcheck(check))
178
+ throw new UsageError(`${compose}: the web service declares no healthcheck with a test of its own, and the deploy waits for it to turn healthy (PLX-App/Healthcheck); ` +
179
+ `the files an \`include\` names are not read, nor a service an \`extends\` takes from another file (\`file:\`), and an image's own HEALTHCHECK does not count; to use it, declare it here:\n` +
180
+ ` healthcheck: { test: [CMD, <the image's check command>], start_period: ${budget}s, start_interval: 1s }`);
181
+ const slow = slowStart(check, budget);
149
182
  ctx.say(`→ deploying ${image ?? '<image pinned in compose.yaml>'}`);
150
183
  ctx.say(` host: ${host}`);
151
184
  ctx.say(` dir: ${appDir}`);
152
185
  ctx.say(` compose: ${compose}`);
153
- ctx.say(` health: ${options.healthUrl || '<resolved on host>'}`);
154
- const remote = new Remote(ctx, host);
186
+ ctx.say(' health: the healthcheck of service web, as Docker reports it');
187
+ if (slow)
188
+ ctx.say(`⚠ ${compose}: the web healthcheck ${slow}, so Docker may probe it only every interval while the deploy waits, which then sees it healthy late or rolls it back; set start_interval: 1s and start_period: ${budget}s`);
155
189
  const D = q(appDir);
156
190
  // The staged compose file, read in place: --project-directory keeps .env and
157
191
  // relative paths resolving against the app dir, so pull and migrate run
158
192
  // against the new run shape while the host keeps serving from the old one.
159
193
  const dc = `cd ${D} && docker compose`;
160
- const dci = `${dc} --project-directory . -f ${INCOMING}/compose.yaml`;
161
- const liveImage = `${dc} ps -q web 2>/dev/null | head -1 | xargs -r docker inspect --format '{{.Config.Image}}' 2>/dev/null || true`;
162
- const result = { host, appDir, compose, image, healthy: false, rolledBack: false };
194
+ const s = {
195
+ ctx,
196
+ remote: new Remote(ctx, host),
197
+ D,
198
+ dc,
199
+ dci: `${dc} --project-directory . -f ${INCOMING}/compose.yaml`,
200
+ // One `web` container is assumed, hence `head -1`: the app contract binds
201
+ // one fixed loopback port (§ 4 PLX-App), which a second replica could not.
202
+ liveImage: `${dc} ps -q web 2>/dev/null | head -1 | xargs -r docker inspect --format '{{.Config.Image}}' 2>/dev/null || true`,
203
+ image,
204
+ result: { host, appDir, compose, image, healthy: false, rolledBack: false },
205
+ };
206
+ const { result } = s;
163
207
  let staged = false;
164
208
  try {
165
- // Stage into a verb-owned dir inside the app dir; only the file is written,
166
- // never the dir's own mode, which the playbook set. Nothing the host runs
167
- // from is touched until the checks below have passed.
168
- await remote.exec(`rm -rf ${D}/${INCOMING} && mkdir -p ${D}/${INCOMING} && cat > ${D}/${INCOMING}/compose.yaml`, rendered);
209
+ await stage(s, rendered);
169
210
  staged = true;
170
- result.previous = (await remote.read(liveImage)) || undefined;
211
+ result.previous = (await s.remote.read(s.liveImage)) || undefined;
171
212
  ctx.say(` previous: ${result.previous ?? (ctx.dryRun ? '<read on host>' : '<none>')}`);
172
- // The same image from the same run shape, healthy: nothing to do, and a
173
- // promotion that changed another app leaves this one running. Decided from
174
- // the host (the live container, the file it serves), never from a record.
175
- const poll = (attempts) => `cd ${D} && for _ in $(seq 1 ${attempts}); do curl -fsS --max-time 5 -o /dev/null ${q(url())} && exit 0; sleep 2; done; exit 1`;
176
- let resolvedUrl;
177
- const url = () => {
178
- if (resolvedUrl === undefined)
179
- throw new Error('health URL read before it was resolved');
180
- return resolvedUrl;
181
- };
182
- if (ctx.dryRun)
183
- ctx.say(' (nothing more runs when the host already serves this image from this file, healthy)');
184
- else if (image ? result.previous === image : result.previous !== undefined) {
185
- // A third-party app passes no ref: its file pins the image, so the same
186
- // file with `web` running is the same deployment, and a platform repo
187
- // can deploy every app on every push without restarting any.
188
- const sameFile = await remote.test(`cd ${D} && cmp -s compose.yaml ${INCOMING}/compose.yaml`);
189
- if (sameFile) {
190
- resolvedUrl = options.healthUrl || (await resolveHealthUrl(remote, D, dc, ctx));
191
- if (await remote.test(poll(1))) {
192
- result.live = result.previous;
193
- result.healthy = true;
194
- result.unchanged = true;
195
- ctx.done(`${result.previous} is already live and healthy; nothing to do`);
196
- return result;
197
- }
198
- }
199
- }
200
- // Pull → migrate (idempotent; runs only if compose.yaml declares it), both
201
- // against the STAGED run shape: a failure here leaves the host exactly as
202
- // it was. Every non-profiled service is pulled, not just `web`.
203
- await remote.exec(`${dci} pull`);
204
- // `compose run` targets the service regardless of its profile; the --profile
205
- // flag is only needed for the existence check, since `config --services`
206
- // hides profiled services by default. stdin from /dev/null: `compose run`
207
- // is interactive by default and would wait on a terminal that is not there.
208
- const migrate = await remote.test(`${dci} --profile migrate config --services 2>/dev/null | grep -qx migrate`);
209
- if (migrate === undefined)
210
- ctx.say(' (if compose.yaml declares a migrate service:)');
211
- if (migrate !== false)
212
- await remote.exec(`${dci} run --rm migrate </dev/null`);
213
- // Swap the run shape into place; the previous one is kept for rollback
214
- // until this run ends.
215
- const hadPrev = await remote.test(`test -f ${D}/compose.yaml`);
216
- if (hadPrev !== false)
217
- await remote.exec(`cd ${D} && cp -p compose.yaml ${INCOMING}/compose.yaml.prev`);
218
- await remote.exec(`cd ${D} && mv ${INCOMING}/compose.yaml compose.yaml`);
219
- // No pull here: the new image was pulled above, the previous one is in the
220
- // host's cache; a rollback must never depend on the registry answering.
221
- // --remove-orphans: a service the new shape dropped goes with it, and a
222
- // rollback drops the containers a failed shape started (a dependency the
223
- // migrate step brought up), which would otherwise keep a stale network
224
- // and break the next attempt.
225
- await remote.exec(`${dc} up -d --remove-orphans`);
226
- // Readiness path: /healthz by contract (§ 5 PLX-App); a third-party image
227
- // that cannot serve it declares its own via the `plexus.healthz` label,
228
- // read from the running container, reality, not a parse of the compose
229
- // file. Each attempt is bounded, so a container that accepts connections
230
- // but never answers cannot hang the deploy.
231
- resolvedUrl ??= options.healthUrl || (await resolveHealthUrl(remote, D, dc, ctx));
213
+ if (await alreadyServing(s))
214
+ return result;
215
+ await pullAndMigrate(s);
216
+ const hadPrev = await swapAndUp(s);
232
217
  const started = Date.now();
233
- const healthy = await remote.test(poll(retries), true);
234
- if (healthy !== false) {
235
- result.live = (await remote.read(liveImage)) || image;
218
+ if ((await awaitHealthy(s, retries, true)) !== false) {
219
+ result.live = (await s.remote.read(s.liveImage)) || image;
236
220
  result.healthy = true;
237
221
  if (ctx.dryRun)
238
- ctx.say(' (on failure: restore the previous compose.yaml, up -d --remove-orphans, poll again)');
222
+ ctx.say(' (on failure: restore the previous compose.yaml, up -d --remove-orphans, wait again)');
239
223
  else
240
224
  ctx.done(`${result.live ?? 'the app'} is live and healthy`);
241
225
  return result;
242
226
  }
243
227
  ctx.say(`✗ healthcheck failed after ${Math.round((Date.now() - started) / 1000)}s; last lines from the app:`);
244
- const logs = await remote.read(`${dc} logs --no-color --tail 50 web 2>&1 || true`);
228
+ const logs = await s.remote.read(`${dc} logs --no-color --tail 50 web 2>&1 || true`);
245
229
  if (logs)
246
230
  ctx.say(logs.replace(/^/gm, ' '));
247
- // Rollback: the previous compose file, image pinned, so it is the
248
- // combination that was actually serving. There is something to go back to
249
- // when the file changed with a container running; a first deploy, or a
250
- // re-deploy of the very same run shape, has no previous state and fails
251
- // loudly instead.
252
- const differs = hadPrev && (await remote.test(`cd ${D} && ! cmp -s compose.yaml ${INCOMING}/compose.yaml.prev`));
253
- if (!differs) {
254
- ctx.done('nothing to roll back to (first deploy, or the same run shape re-deployed); manual intervention needed', false);
255
- return result;
256
- }
257
- await remote.exec(`cd ${D} && cp -p ${INCOMING}/compose.yaml.prev compose.yaml`);
258
- ctx.say(`↩ rolling back to ${result.previous ?? 'the previous compose.yaml'}`);
259
- await remote.exec(`${dc} up -d --remove-orphans`);
260
- result.rolledBack = true;
261
- if (await remote.test(poll(retries))) {
262
- result.live = result.previous;
263
- ctx.done(`rolled back to ${result.previous ?? 'the previous compose.yaml'}`);
264
- }
265
- else {
266
- ctx.done('rollback also unhealthy; manual intervention needed', false);
267
- }
231
+ await rollback(s, hadPrev, retries);
268
232
  return result;
269
233
  }
270
234
  finally {
271
235
  // The staged run shape and the rollback copy are gone on exit, whatever
272
236
  // happened; the shared connection with them.
273
237
  if (staged)
274
- await remote.exec(`rm -rf ${D}/${INCOMING}`).catch(() => undefined);
275
- await remote.close().catch(() => undefined);
238
+ await s.remote.exec(`rm -rf ${D}/${INCOMING}`).catch(() => undefined);
239
+ await s.remote.close().catch(() => undefined);
276
240
  }
277
241
  }
278
- async function resolveHealthUrl(remote, D, dc, ctx) {
279
- const port = await remote.read(`sed -n 's/^PLEXUS_LOOPBACK_PORT=//p' ${D}/.env 2>/dev/null | tail -1`);
280
- const path = await remote.read(`${dc} ps -q web 2>/dev/null | head -1 | xargs -r docker inspect --format '{{ index .Config.Labels "plexus.healthz" }}' 2>/dev/null || true`);
281
- const url = ctx.dryRun
282
- ? 'http://127.0.0.1:${PLEXUS_LOOPBACK_PORT:-3000}${plexus.healthz:-/healthz}'
283
- : `http://127.0.0.1:${port || '3000'}${path || '/healthz'}`;
284
- ctx.say(` health: ${url}`);
285
- return url;
242
+ /**
243
+ * Stage the rendered file into a verb-owned dir inside the app dir; only the
244
+ * file is written, never the dir's own mode, which the playbook set. Nothing
245
+ * the host runs from is touched until pull and migrate have passed.
246
+ */
247
+ async function stage(s, rendered) {
248
+ const { D } = s;
249
+ await s.remote.exec(`rm -rf ${D}/${INCOMING} && mkdir -p ${D}/${INCOMING} && cat > ${D}/${INCOMING}/compose.yaml`, rendered);
250
+ }
251
+ /**
252
+ * The same image from the same run shape, healthy: nothing to do, and a
253
+ * promotion that changed another app leaves this one running. Decided from
254
+ * the host (the live container, the file it serves), never from a record.
255
+ */
256
+ async function alreadyServing(s) {
257
+ const { ctx, result } = s;
258
+ if (ctx.dryRun) {
259
+ ctx.say(' (nothing more runs when the host already serves this image from this file, healthy)');
260
+ return false;
261
+ }
262
+ // A third-party app passes no ref: its file pins the image, so the same
263
+ // file with `web` running is the same deployment, and a platform repo can
264
+ // deploy every app on every push without restarting any.
265
+ if (!(s.image ? result.previous === s.image : result.previous !== undefined))
266
+ return false;
267
+ if (!(await s.remote.test(`cd ${s.D} && cmp -s compose.yaml ${INCOMING}/compose.yaml`)))
268
+ return false;
269
+ if (!(await awaitHealthy(s, 1)))
270
+ return false;
271
+ result.live = result.previous;
272
+ result.healthy = true;
273
+ result.unchanged = true;
274
+ ctx.done(`${result.previous} is already live and healthy; nothing to do`);
275
+ return true;
276
+ }
277
+ /**
278
+ * Pull → migrate (idempotent; runs only if compose.yaml declares it), both
279
+ * against the STAGED run shape: a failure here leaves the host exactly as it
280
+ * was. Every non-profiled service is pulled, not just `web`.
281
+ */
282
+ async function pullAndMigrate(s) {
283
+ await s.remote.exec(`${s.dci} pull`);
284
+ // `compose run` targets the service regardless of its profile; the --profile
285
+ // flag is only needed for the existence check, since `config --services`
286
+ // hides profiled services by default. stdin from /dev/null: `compose run`
287
+ // is interactive by default and would wait on a terminal that is not there.
288
+ const migrate = await s.remote.test(`${s.dci} --profile migrate config --services 2>/dev/null | grep -qx migrate`);
289
+ if (migrate === undefined)
290
+ s.ctx.say(' (if compose.yaml declares a migrate service:)');
291
+ if (migrate !== false)
292
+ await s.remote.exec(`${s.dci} run --rm migrate </dev/null`);
293
+ }
294
+ /**
295
+ * Swap the run shape into place, keeping the previous one for rollback until
296
+ * this run ends, and bring it up. Whether there was a previous file (undefined
297
+ * under --dry-run).
298
+ */
299
+ async function swapAndUp(s) {
300
+ const { D } = s;
301
+ const hadPrev = await s.remote.test(`test -f ${D}/compose.yaml`);
302
+ if (hadPrev !== false)
303
+ await s.remote.exec(`cd ${D} && cp -p compose.yaml ${INCOMING}/compose.yaml.prev`);
304
+ await s.remote.exec(`cd ${D} && mv ${INCOMING}/compose.yaml compose.yaml`);
305
+ // No pull here: the new image was pulled above, the previous one is in the
306
+ // host's cache; a rollback must never depend on the registry answering.
307
+ // --remove-orphans: a service the new shape dropped goes with it, and a
308
+ // rollback drops the containers a failed shape started (a dependency the
309
+ // migrate step brought up), which would otherwise keep a stale network
310
+ // and break the next attempt.
311
+ await s.remote.exec(`${s.dc} up -d --remove-orphans`);
312
+ return hadPrev;
313
+ }
314
+ /**
315
+ * Wait for the `web` container to turn healthy, as Docker reports it from the
316
+ * healthcheck the compose file declares (PLX-App/Healthcheck): reality, read
317
+ * from the running container, two seconds between looks. Whether it did
318
+ * (undefined under --dry-run, where `show` prints the line).
319
+ */
320
+ function awaitHealthy(s, attempts, show = false) {
321
+ // One `web` container is assumed, hence `head -1`: the app contract binds
322
+ // one fixed loopback port (§ 4 PLX-App), which a second replica could not.
323
+ const status = `docker compose ps -q web 2>/dev/null | head -1 | xargs -r docker inspect --format '{{if .State.Health}}{{.State.Health.Status}}{{end}}' 2>/dev/null`;
324
+ return s.remote.test(`cd ${s.D} && for _ in $(seq 1 ${attempts}); do [ "$(${status})" = healthy ] && exit 0; sleep 2; done; exit 1`, show);
325
+ }
326
+ /**
327
+ * Rollback: the previous compose file, image pinned, so it is the combination
328
+ * that was actually serving. There is something to go back to when the file
329
+ * changed with a container running; a first deploy, or a re-deploy of the
330
+ * very same run shape, has no previous state and fails loudly instead.
331
+ */
332
+ async function rollback(s, hadPrev, retries) {
333
+ const { ctx, D, result } = s;
334
+ const differs = hadPrev && (await s.remote.test(`cd ${D} && ! cmp -s compose.yaml ${INCOMING}/compose.yaml.prev`));
335
+ if (!differs) {
336
+ ctx.done('nothing to roll back to (first deploy, or the same run shape re-deployed); manual intervention needed', false);
337
+ return;
338
+ }
339
+ await s.remote.exec(`cd ${D} && cp -p ${INCOMING}/compose.yaml.prev compose.yaml`);
340
+ ctx.say(`↩ rolling back to ${result.previous ?? 'the previous compose.yaml'}`);
341
+ await s.remote.exec(`${s.dc} up -d --remove-orphans`);
342
+ result.rolledBack = true;
343
+ if (await awaitHealthy(s, retries)) {
344
+ result.live = result.previous;
345
+ ctx.done(`rolled back to ${result.previous ?? 'the previous compose.yaml'}`);
346
+ }
347
+ else {
348
+ ctx.done('rollback also unhealthy; manual intervention needed', false);
349
+ }
286
350
  }
287
351
  //# sourceMappingURL=deploy.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"deploy.js","sourceRoot":"","sources":["../src/deploy.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,sDAAsD;AACtD,EAAE;AACF,+FAA+F;AAC/F,2FAA2F;AAC3F,sGAAsG;AACtG,gHAAgH;AAChH,EAAE;AACF,4EAA4E;AAC5E,wEAAwE;AACxE,8DAA8D;AAC9D,2EAA2E;AAC3E,4EAA4E;AAC5E,+EAA+E;AAC/E,yEAAyE;AACzE,4EAA4E;AAC5E,6EAA6E;AAC7E,+EAA+E;AAC/E,8DAA8D;AAC9D,EAAE;AACF,2EAA2E;AAC3E,8EAA8E;AAC9E,4EAA4E;AAC5E,6EAA6E;AAC7E,8EAA8E;AAC9E,2DAA2D;AAC3D,EAAE;AACF,2EAA2E;AAC3E,+EAA+E;AAC/E,+EAA+E;AAC/E,sEAAsE;AACtE,0EAA0E;AAC1E,6EAA6E;AAC7E,0EAA0E;AAC1E,2EAA2E;AAC3E,6DAA6D;AAC7D,EAAE;AACF,wEAAwE;AACxE,2GAA2G;AAC3G,2EAA2E;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa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AC,CAAC;IAC/E,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,yBAAyB,CAAC,CAAC;IACtD,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC;IACzB,IAAI,MAAM,YAAY,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC;QACnC,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC;QAC9B,GAAG,CAAC,IAAI,CAAC,kBAAkB,MAAM,CAAC,QAAQ,IAAI,2BAA2B,EAAE,CAAC,CAAC;IAC/E,CAAC;SAAM,CAAC;QACN,GAAG,CAAC,IAAI,CAAC,qDAAqD,EAAE,KAAK,CAAC,CAAC;IACzE,CAAC;AACH,CAAC"}
package/dist/doctor.d.ts CHANGED
@@ -1,19 +1,125 @@
1
- import type { Catalog } from './catalog.ts';
2
- import type { Directory } from './model.ts';
3
- export interface Diagnosis {
4
- /** The marker's directory, relative to the scanned root. */
1
+ import { type Compose, type Mapping } from './compose.ts';
2
+ import type { Context } from './context.ts';
3
+ import { type Declaration } from './marker.ts';
4
+ import { type Kind } from './model.ts';
5
+ export type Profile = 'stateless' | 'stateful';
6
+ /** The marker as read: its declaration, or why it cannot be read. */
7
+ export interface MarkerRead {
8
+ declaration?: Declaration;
9
+ problem?: string;
10
+ }
11
+ /** What doctor read of a repo. */
12
+ export interface RepoFacts {
13
+ kind: 'repo' | 'operations';
14
+ /** Relative to the directory doctor was run on. */
15
+ path: string;
16
+ /** Undefined when the repo carries no marker. */
17
+ marker?: MarkerRead;
18
+ /** The root mise tasks, or why mise could not list them. */
19
+ tasks: {
20
+ names: string[];
21
+ } | {
22
+ problem: string;
23
+ };
24
+ /** The files git tracks, relative to the repo; undefined outside a git checkout. */
25
+ tracked?: string[];
26
+ /** Its apps' directories, relative to the repo (`apps/<name>`). */
27
+ apps: string[];
28
+ }
29
+ /** What doctor read of an app. */
30
+ export interface AppFacts {
31
+ kind: 'app';
5
32
  path: string;
6
- plexus?: string;
7
- modules: string[];
8
- findings: string[];
33
+ /** The app's source repo. */
34
+ repo: RepoFacts;
35
+ /** The app's directory, relative to the repo (`apps/<name>`). */
36
+ dir: string;
37
+ thirdParty: boolean;
38
+ marker: MarkerRead;
39
+ /** `docker/compose.yaml`; neither field set when there is none. */
40
+ compose?: Compose;
41
+ composeProblem?: string;
42
+ /** Whether `docker/Dockerfile` exists. */
43
+ dockerfile: boolean;
44
+ /** `package.json`; neither field set when there is none. */
45
+ packageJson?: Mapping;
46
+ packageJsonProblem?: string;
47
+ }
48
+ export type Facts = RepoFacts | AppFacts;
49
+ interface RepoCheck {
50
+ binds: 'repo';
51
+ check: (repo: RepoFacts) => string[];
52
+ }
53
+ /** A check of whichever unit holds what it finds, a repo or an app. */
54
+ interface UnitCheck {
55
+ binds: 'unit';
56
+ check: (unit: Facts) => string[];
57
+ }
58
+ interface AppCheck {
59
+ binds: 'app';
60
+ /** Only an app of this profile. */
61
+ profile?: Profile;
62
+ /** Only a built app, never a third-party one. */
63
+ built?: true;
64
+ check: (app: AppFacts) => string[];
65
+ }
66
+ /** Every requirement doctor checks, by name: what the contract pages list, in their order. */
67
+ export declare const CHECKS: Readonly<Record<string, RepoCheck | AppCheck | UnitCheck>>;
68
+ export interface Finding {
69
+ /** The requirement's name, e.g. `PLX-App/LoopbackPort`. */
70
+ requirement: string;
71
+ problem: string;
72
+ }
73
+ export interface UnitReport {
74
+ path: string;
75
+ kind: Kind;
76
+ /** An app's profile, when its marker states a valid one. */
77
+ profile?: Profile;
78
+ /** The deviations its marker lists, whose checks were not run. */
79
+ deviations: string[];
80
+ findings: Finding[];
81
+ /** What is worth doing and fails no check, such as deleting keys nothing reads any more. */
82
+ hints?: string[];
9
83
  }
10
84
  export interface Report {
11
- declarations: Diagnosis[];
12
- /** Declarations with at least one finding. */
13
- stale: number;
14
- }
15
- /** A scanned tree against a catalogue: pure, so a test compares reports. */
16
- export declare function diagnose(root: Directory, catalog: Catalog): Report;
17
- /** Numeric comparison of two Plexus versions; suffixes ignored. */
18
- export declare function compareVersions(a: string, b: string): number;
85
+ units: UnitReport[];
86
+ /** Units with at least one finding. */
87
+ failed: number;
88
+ }
89
+ /** The requirement names the index this plx carries knows: what a deviation may name. */
90
+ export declare const knownRequirements: () => Set<string>;
91
+ /** What was read, against the checks: pure, so a test compares reports. */
92
+ export declare function diagnose(facts: Facts[], known?: Set<string>): Report;
93
+ /** What doctor read under the directory it was given. */
94
+ export interface Examination {
95
+ /** What the unit paths are relative to: the repo's root when the directory is in a repo, else the directory. */
96
+ root: string;
97
+ /** Whether the directory is in a repo; then `root` is that repo's root, and only that repo is read. */
98
+ inRepo: boolean;
99
+ /** Each repo, then its apps. */
100
+ facts: Facts[];
101
+ /** In a workspace, the git roots that are not Plexus repos and were not checked, relative to `root`. */
102
+ skipped: string[];
103
+ /** Symbolic links not followed, so not checked: a directory in a repo's `apps/`, or a repo in a workspace; relative to `root`. */
104
+ links: string[];
105
+ /** Directories that could not be read, so nothing beneath them was checked, with why; relative to `root`. */
106
+ unreadable: {
107
+ path: string;
108
+ why: string;
109
+ }[];
110
+ }
111
+ /**
112
+ * Read the units (§ 1.2 PLX) under `dir`. A repo is a git root; its apps are
113
+ * what `appsOf` finds in its `apps/` (overview.ts; overview reads them by it
114
+ * too), with a marker or without. `dir` is a workspace when git roots lie
115
+ * beneath it, whatever lies above: every git root beneath it is read that is
116
+ * a Plexus repo, which carries a marker or has an app, and the others are
117
+ * named. Otherwise `dir` is in a repo, the nearest git root at or above it,
118
+ * and that repo is read from its root, with no git root nested in it: that
119
+ * is another repo, and none of its files are this repo's. A directory that
120
+ * cannot be read, and a symbolic link to an app or a repo, are named, never
121
+ * fatal.
122
+ */
123
+ export declare function examine(ctx: Context, dir: string): Promise<Examination>;
124
+ export {};
19
125
  //# sourceMappingURL=doctor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../src/doctor.ts"],"names":[],"mappings":"AAeA,OAAO,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