@cedarjs/pg 0.2.0-alpha.0 → 0.2.0-beta.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 (92) hide show
  1. package/README.md +250 -229
  2. package/dist/cli.cjs +89 -39
  3. package/dist/cli.cjs.map +1 -1
  4. package/dist/cli.mjs +73 -23
  5. package/dist/cli.mjs.map +1 -1
  6. package/dist/dev-env.cjs +1 -1
  7. package/dist/dev-env.mjs +1 -1
  8. package/dist/index.cjs +9 -8
  9. package/dist/index.d.cts +31 -3
  10. package/dist/index.d.mts +31 -3
  11. package/dist/index.mjs +7 -7
  12. package/dist/jest-teardown.cjs +1 -1
  13. package/dist/jest-teardown.mjs +1 -1
  14. package/dist/jest-template.cjs +4 -1
  15. package/dist/jest-template.cjs.map +1 -1
  16. package/dist/jest-template.d.cts +4 -1
  17. package/dist/jest-template.d.mts +4 -1
  18. package/dist/jest-template.mjs +4 -1
  19. package/dist/jest-template.mjs.map +1 -1
  20. package/dist/jest.cjs +1 -1
  21. package/dist/jest.mjs +1 -1
  22. package/dist/{lease-BSBBpaR4.mjs → lease-DS1SX8U_.mjs} +23 -3
  23. package/dist/lease-DS1SX8U_.mjs.map +1 -0
  24. package/dist/{lease-Bq9wKwQa.cjs → lease-WlmOnNDi.cjs} +41 -3
  25. package/dist/lease-WlmOnNDi.cjs.map +1 -0
  26. package/dist/{lifecycle-DEJ4GgWV.cjs → lifecycle-BbrvFQvg.cjs} +175 -78
  27. package/dist/lifecycle-BbrvFQvg.cjs.map +1 -0
  28. package/dist/{lifecycle-BOo6xBjD.mjs → lifecycle-BvIx0xqq.mjs} +175 -78
  29. package/dist/lifecycle-BvIx0xqq.mjs.map +1 -0
  30. package/dist/{load-dev-env-7UjMHhw7.mjs → load-dev-env-BULkXyen.mjs} +2 -2
  31. package/dist/{load-dev-env-7UjMHhw7.mjs.map → load-dev-env-BULkXyen.mjs.map} +1 -1
  32. package/dist/{load-dev-env-cII6N4ZP.cjs → load-dev-env-Bl6Ddv1U.cjs} +2 -2
  33. package/dist/{load-dev-env-cII6N4ZP.cjs.map → load-dev-env-Bl6Ddv1U.cjs.map} +1 -1
  34. package/dist/{load-mode-env-B0qO9DZx.cjs → load-mode-env-CX9vd56X.cjs} +2 -2
  35. package/dist/{load-mode-env-B0qO9DZx.cjs.map → load-mode-env-CX9vd56X.cjs.map} +1 -1
  36. package/dist/{load-mode-env-C8gy4v9V.mjs → load-mode-env-Ce9ujisN.mjs} +2 -2
  37. package/dist/{load-mode-env-C8gy4v9V.mjs.map → load-mode-env-Ce9ujisN.mjs.map} +1 -1
  38. package/dist/{load-test-env-C34wpkIX.mjs → load-test-env-BqtA6V-d.mjs} +2 -2
  39. package/dist/{load-test-env-C34wpkIX.mjs.map → load-test-env-BqtA6V-d.mjs.map} +1 -1
  40. package/dist/{load-test-env-CkdUjTpV.cjs → load-test-env-Dcgh6YHV.cjs} +2 -2
  41. package/dist/{load-test-env-CkdUjTpV.cjs.map → load-test-env-Dcgh6YHV.cjs.map} +1 -1
  42. package/dist/nx.cjs +12 -14
  43. package/dist/nx.cjs.map +1 -1
  44. package/dist/nx.mjs +10 -12
  45. package/dist/nx.mjs.map +1 -1
  46. package/dist/status-4Uz6A3LB.cjs +31 -0
  47. package/dist/status-4Uz6A3LB.cjs.map +1 -0
  48. package/dist/status-Dcnpgnlz.mjs +26 -0
  49. package/dist/status-Dcnpgnlz.mjs.map +1 -0
  50. package/dist/studio-DIFw1qWC.mjs +173 -0
  51. package/dist/studio-DIFw1qWC.mjs.map +1 -0
  52. package/dist/studio-oJE30_PO.cjs +208 -0
  53. package/dist/studio-oJE30_PO.cjs.map +1 -0
  54. package/dist/{tasks-Caud9yHr.cjs → tasks-CNHvvlsN.cjs} +4 -4
  55. package/dist/{tasks-Caud9yHr.cjs.map → tasks-CNHvvlsN.cjs.map} +1 -1
  56. package/dist/{tasks-KherHLac.mjs → tasks-D5iWIdlo.mjs} +2 -2
  57. package/dist/{tasks-KherHLac.mjs.map → tasks-D5iWIdlo.mjs.map} +1 -1
  58. package/dist/{template-CGw3C1Ob.mjs → template-BiJ-0TIF.mjs} +3 -3
  59. package/dist/{template-CGw3C1Ob.mjs.map → template-BiJ-0TIF.mjs.map} +1 -1
  60. package/dist/{template-D0gJ_MS2.cjs → template-CXMpODzK.cjs} +3 -3
  61. package/dist/{template-D0gJ_MS2.cjs.map → template-CXMpODzK.cjs.map} +1 -1
  62. package/dist/{template-mode-IjlFOG4O.mjs → template-mode-BTUsdBtA.mjs} +27 -13
  63. package/dist/template-mode-BTUsdBtA.mjs.map +1 -0
  64. package/dist/{template-mode-CcxV_Iju.d.cts → template-mode-CzyVwHsi.d.cts} +4 -1
  65. package/dist/{template-mode-CcxV_Iju.d.mts → template-mode-CzyVwHsi.d.mts} +4 -1
  66. package/dist/{template-mode-BkEs9LnY.cjs → template-mode-JTOxrEgE.cjs} +27 -13
  67. package/dist/template-mode-JTOxrEgE.cjs.map +1 -0
  68. package/dist/test-env.cjs +1 -1
  69. package/dist/test-env.mjs +1 -1
  70. package/dist/vite-plus.cjs +107 -4
  71. package/dist/vite-plus.cjs.map +1 -1
  72. package/dist/vite-plus.d.cts +25 -1
  73. package/dist/vite-plus.d.mts +25 -1
  74. package/dist/vite-plus.mjs +108 -5
  75. package/dist/vite-plus.mjs.map +1 -1
  76. package/dist/vitest-template.cjs +1 -1
  77. package/dist/vitest-template.d.cts +1 -1
  78. package/dist/vitest-template.d.mts +1 -1
  79. package/dist/vitest-template.mjs +1 -1
  80. package/dist/vitest.cjs +1 -1
  81. package/dist/vitest.mjs +1 -1
  82. package/package.json +11 -2
  83. package/dist/constants-Ct8myrEn.cjs +0 -41
  84. package/dist/constants-Ct8myrEn.cjs.map +0 -1
  85. package/dist/constants-NLR0U4NR.mjs +0 -24
  86. package/dist/constants-NLR0U4NR.mjs.map +0 -1
  87. package/dist/lease-BSBBpaR4.mjs.map +0 -1
  88. package/dist/lease-Bq9wKwQa.cjs.map +0 -1
  89. package/dist/lifecycle-BOo6xBjD.mjs.map +0 -1
  90. package/dist/lifecycle-DEJ4GgWV.cjs.map +0 -1
  91. package/dist/template-mode-BkEs9LnY.cjs.map +0 -1
  92. package/dist/template-mode-IjlFOG4O.mjs.map +0 -1
@@ -1,6 +1,5 @@
1
- import { n as PASSWORD_SALT_PREFIX } from "./constants-NLR0U4NR.mjs";
2
- import { a as leaseDir, f as resolveWorktreeIdentity, i as isOrphanLease, l as readLease, n as envPath, r as forgetLease, s as listRegistryLeases, u as writeLease } from "./lease-BSBBpaR4.mjs";
3
- import { existsSync, mkdirSync, writeFileSync } from "node:fs";
1
+ import { a as leaseDir, f as resolveWorktreeIdentity, i as isOrphanLease, l as readLease, m as PASSWORD_SALT_PREFIX, n as envPath, r as forgetLease, s as listRegistryLeases, u as writeLease } from "./lease-DS1SX8U_.mjs";
2
+ import { existsSync, mkdirSync, readdirSync, rmSync, statfsSync, writeFileSync } from "node:fs";
4
3
  import { homedir, tmpdir } from "node:os";
5
4
  import { join } from "node:path";
6
5
  import { createHash } from "node:crypto";
@@ -172,7 +171,13 @@ function requireAutopgBin() {
172
171
  return bin;
173
172
  }
174
173
  /**
175
- * Parse `autopg status --json` output. Requires a numeric port and running !== false.
174
+ * Parse `autopg status --json` → the **registered** port. Throws only when the
175
+ * output is not autopg status JSON.
176
+ *
177
+ * Registration is not liveness: autopg reports a port for a stopped host too,
178
+ * and its `status` string is supervisor-specific (pm2 `online`, systemd-user /
179
+ * launchd differ). Liveness is a TCP accept on the port, proven by the caller —
180
+ * `acquire` does that before it connects.
176
181
  */
177
182
  function parseHostStatus(json) {
178
183
  let parsed;
@@ -182,7 +187,6 @@ function parseHostStatus(json) {
182
187
  throw new Error(`autopg status --json returned invalid JSON.\n${INSTALL_HINT}`);
183
188
  }
184
189
  if (typeof parsed.port !== "number") throw new Error(`autopg status --json missing numeric port.\n${INSTALL_HINT}`);
185
- if (parsed.running === false) throw new Error(`autopg host is not running.\n${INSTALL_HINT}`);
186
190
  return { port: parsed.port };
187
191
  }
188
192
  /**
@@ -199,7 +203,9 @@ function adminUrlFor(port, env = process.env) {
199
203
  return `postgresql://${encodeURIComponent(env.AUTOPG_PG_USER || env.PGSERVE_PG_USER || "postgres")}:${encodeURIComponent(env.AUTOPG_PG_PASSWORD || env.PGSERVE_PG_PASSWORD || "postgres")}@127.0.0.1:${port}/postgres`;
200
204
  }
201
205
  /**
202
- * Discover a live autopg host via `autopg status --json`. Throws if the host is not proven live.
206
+ * Discover the registered autopg host (port + admin URL) via `autopg status --json`.
207
+ * Throws when autopg cannot be queried; does **not** prove a listener — probe TCP
208
+ * (or use `acquire`, which does) before connecting.
203
209
  */
204
210
  function discoverHost(bin = requireAutopgBin()) {
205
211
  let status;
@@ -335,29 +341,50 @@ function buildDatabaseUrl(opts) {
335
341
  }
336
342
  //#endregion
337
343
  //#region src/providers/host.ts
338
- /** Fixed CI TCP port so install registration and postmaster listen on the same port. */
339
344
  const EPHEMERAL_PORT = 55432;
340
- const OWNED_POSTMASTER_READY_MS = 3e4;
341
- const OWNED_POSTMASTER_POLL_MS = 200;
345
+ const HOST_READY_MS = 3e4;
346
+ const HOST_POLL_MS = 200;
347
+ /**
348
+ * autopg verbs that can bring the *registered* local host up, cheapest fix first.
349
+ *
350
+ * `restart` exit 0 is not evidence of a listener: when pm2 is missing or does not
351
+ * list `autopg-server`, autopg still prints "respawned daemon" and returns 0.
352
+ * That is why every verb is followed by a TCP wait, not trusted on exit status.
353
+ *
354
+ * `install` covers a never-registered machine (postinstall ships the binary only)
355
+ * and a reboot whose pm2 list is empty (`pm2 start`). On an already-registered
356
+ * host it is a no-op for the server process but may `pm2 start` the autopg UI —
357
+ * so it runs only after `restart` failed to produce a listener.
358
+ */
359
+ const LOCAL_START = [{
360
+ argv: ["restart"],
361
+ readyMs: 1e4
362
+ }, {
363
+ argv: ["install"],
364
+ readyMs: HOST_READY_MS
365
+ }];
366
+ /** Soft minimum free bytes on /dev/shm before RAM-backed ephemeral start (warns only). */
367
+ const EPHEMERAL_SHM_MIN_FREE_BYTES = 512 * 1024 * 1024;
368
+ /**
369
+ * Hint when ephemeral `--ram` initdb fails for space / leftover dirs under `/dev/shm`.
370
+ * Cloud VMs often ship with a tiny default tmpfs (e.g. 64MB).
371
+ */
372
+ const EPHEMERAL_SHM_HINT = "Ephemeral autopg uses /dev/shm with --ram. If initdb fails with Disk quota / No space (Postgres 53100):\n 1. Enlarge tmpfs (cloud VMs often default to ~64MB): sudo mount -o remount,size=6G /dev/shm\n 2. Clear leftovers from OOM-killed runs (your test data only):\n rm -rf /dev/shm/cedar-pg-* /dev/shm/pgserve-* /dev/shm/PostgreSQL.*";
342
373
  /**
343
- * Resolve whether to start an owned ephemeral postmaster or use local pm2 install.
374
+ * Resolve how to start a host when none is listening.
344
375
  *
345
- * - `CEDAR_PG_EPHEMERAL_HOST=1` → ephemeral
346
- * - `CEDAR_PG_EPHEMERAL_HOST=0` → local (even when `CI=true`)
376
+ * - `CEDAR_PG_EPHEMERAL_HOST=1` → ephemeral owned postmaster
377
+ * - `CEDAR_PG_EPHEMERAL_HOST=0` → never own a postmaster, local autopg only (even in CI)
347
378
  * - unset + `CI=true` → ephemeral
348
379
  * - otherwise → local
349
380
  */
350
- function resolveEphemeralHostPolicy(env = process.env) {
381
+ function resolveHostStartPolicy(env = process.env) {
351
382
  const force = env.CEDAR_PG_EPHEMERAL_HOST;
352
383
  if (force === "1") return "ephemeral";
353
384
  if (force === "0") return "local";
354
385
  if (env.CI === "true") return "ephemeral";
355
386
  return "local";
356
387
  }
357
- /**
358
- * Fixed CI recipe: shared `--port` on install + postmaster, `--no-pm2 --no-ui`,
359
- * and `--ram` + `/dev/shm/cedar-pg-<uid>` on Linux when shm exists.
360
- */
361
388
  function ephemeralHostRecipe(ctx = {}) {
362
389
  const platform = ctx.platform ?? process.platform;
363
390
  const shmAvailable = ctx.shmAvailable ?? (platform === "linux" && existsSync("/dev/shm"));
@@ -368,15 +395,6 @@ function ephemeralHostRecipe(ctx = {}) {
368
395
  return {
369
396
  dataDir,
370
397
  port,
371
- installArgs: [
372
- "install",
373
- "--no-pm2",
374
- "--no-ui",
375
- "--port",
376
- String(port),
377
- "--data",
378
- dataDir
379
- ],
380
398
  postmasterArgs: [
381
399
  "postmaster",
382
400
  ...useRam ? ["--ram"] : [],
@@ -389,7 +407,6 @@ function ephemeralHostRecipe(ctx = {}) {
389
407
  ]
390
408
  };
391
409
  }
392
- /** Discovery from the recipe port — TCP readiness is the authority, not `autopg status`. */
393
410
  function discoveryFromRecipe(bin, recipe) {
394
411
  return {
395
412
  port: recipe.port,
@@ -400,8 +417,57 @@ function discoveryFromRecipe(bin, recipe) {
400
417
  function sleep(ms) {
401
418
  return new Promise((resolve) => setTimeout(resolve, ms));
402
419
  }
403
- function runInstall(bin, args) {
404
- const install = spawnSync(bin, args, {
420
+ /** True when stderr/stdout looks like a /dev/shm quota or ENOSPC failure. */
421
+ function looksLikeShmSpaceError(text) {
422
+ return /Disk quota exceeded|No space left on device|ENOSPC|\b53100\b/i.test(text);
423
+ }
424
+ function formatHostStartError(detail, useRamShm = false) {
425
+ return `Failed to start autopg host.\n${detail}\n${INSTALL_HINT}${useRamShm && looksLikeShmSpaceError(detail) ? `\n${EPHEMERAL_SHM_HINT}` : ""}`;
426
+ }
427
+ /**
428
+ * Remove leftover ephemeral data dirs under `/dev/shm` (and the recipe dataDir).
429
+ * Safe for OOM-killed CI/cloud runs that leave `cedar-pg-*` / `pgserve-*` /
430
+ * `PostgreSQL.*` filling tmpfs.
431
+ *
432
+ * Only called on ephemeral cold start, i.e. when the recipe port has no listener —
433
+ * never while a host owns those dirs.
434
+ */
435
+ function pruneStaleEphemeralDataDirs(opts) {
436
+ const removed = [];
437
+ const tryRm = (path) => {
438
+ if (!existsSync(path)) return;
439
+ try {
440
+ rmSync(path, {
441
+ recursive: true,
442
+ force: true
443
+ });
444
+ removed.push(path);
445
+ } catch {}
446
+ };
447
+ tryRm(opts.dataDir);
448
+ const shmRoot = opts.shmRoot ?? (existsSync("/dev/shm") ? "/dev/shm" : void 0);
449
+ if (!shmRoot) return removed;
450
+ let entries = [];
451
+ try {
452
+ entries = readdirSync(shmRoot);
453
+ } catch {
454
+ return removed;
455
+ }
456
+ for (const name of entries) if (name.startsWith("cedar-pg-") || name.startsWith("pgserve-") || name.startsWith("PostgreSQL.")) tryRm(join(shmRoot, name));
457
+ return removed;
458
+ }
459
+ /** Free bytes on `path`, or `null` if unavailable. */
460
+ function freeBytesOn(path) {
461
+ try {
462
+ const s = statfsSync(path);
463
+ return Number(s.bavail) * Number(s.bsize);
464
+ } catch {
465
+ return null;
466
+ }
467
+ }
468
+ /** Run a one-shot autopg verb. Returns failure detail, or `null` on exit 0. */
469
+ function runAutopg(bin, argv) {
470
+ const result = spawnSync(bin, argv, {
405
471
  encoding: "utf8",
406
472
  stdio: [
407
473
  "ignore",
@@ -409,7 +475,9 @@ function runInstall(bin, args) {
409
475
  "pipe"
410
476
  ]
411
477
  });
412
- if (install.status !== 0) throw new Error(`Failed to start autopg host (exit ${install.status}).\n${install.stderr || install.stdout || ""}\n${INSTALL_HINT}`);
478
+ if (result.error) return result.error.message;
479
+ if (result.status === 0) return null;
480
+ return `exit ${result.status}\n${(result.stderr || result.stdout || "").trim()}`.trim();
413
481
  }
414
482
  /** True when something accepts TCP on 127.0.0.1:port (postmaster live, not just admin.json). */
415
483
  function canConnect(port) {
@@ -426,7 +494,6 @@ function canConnect(port) {
426
494
  });
427
495
  });
428
496
  }
429
- /** Kill a detached owned postmaster (process group when possible) and drop our handle. */
430
497
  function killOwnedChild(child) {
431
498
  const pid = child.pid;
432
499
  if (pid != null) try {
@@ -439,66 +506,101 @@ function killOwnedChild(child) {
439
506
  child.unref();
440
507
  }
441
508
  /**
442
- * Poll until TCP accepts on port, or throw on timeout / {@link WaitForOwnedPostmasterOptions.failure}.
443
- * Exported for tests — the readiness seam for owned ephemeral start.
509
+ * The single liveness primitive: TCP accept on 127.0.0.1:port.
510
+ *
511
+ * Resolves `true` as soon as something is listening, `false` when the grace
512
+ * period expires, and throws only what {@link WaitForListenerOptions.failure}
513
+ * returns. Used for attach (one probe), local restart, and ephemeral start.
444
514
  */
445
- async function waitForOwnedPostmaster(opts) {
515
+ async function waitForListener(opts) {
446
516
  const probe = opts.canConnect ?? canConnect;
447
517
  const now = opts.now ?? Date.now;
448
518
  const pause = opts.sleep ?? sleep;
449
- const readyMs = opts.readyMs ?? OWNED_POSTMASTER_READY_MS;
450
- const pollMs = opts.pollMs ?? OWNED_POSTMASTER_POLL_MS;
451
- const deadline = now() + readyMs;
452
- let lastDetail = "TCP not accepting";
453
- while (now() < deadline) {
519
+ const pollMs = opts.pollMs ?? HOST_POLL_MS;
520
+ const deadline = now() + (opts.readyMs ?? 0);
521
+ for (;;) {
454
522
  const fail = opts.failure?.();
455
523
  if (fail) throw fail;
456
- if (await probe(opts.port)) return;
457
- lastDetail = `127.0.0.1:${opts.port} not accepting connections`;
524
+ if (await probe(opts.port)) return true;
525
+ if (now() >= deadline) return false;
458
526
  await pause(pollMs);
459
527
  }
460
- throw new Error(`Timed out waiting for autopg host after ${readyMs}ms.\n${lastDetail}\n${INSTALL_HINT}`);
461
528
  }
462
529
  /**
463
- * Install + detached postmaster with fully ignored stdio so the CI job owns lifetime
464
- * (caller exit must not close pipes under the daemon).
530
+ * Attach to the registered autopg host once TCP accepts on its port.
531
+ *
532
+ * Registration is not liveness: a stopped pm2 host still reports a port, and
533
+ * attaching to it is the `ECONNREFUSED 127.0.0.1:25432` bug. `readyMs` > 0 is
534
+ * the grace period after asking autopg to start.
535
+ */
536
+ async function attachLiveHost(bin, readyMs = 0) {
537
+ let discovered;
538
+ try {
539
+ discovered = discoverHost(bin);
540
+ } catch {
541
+ return null;
542
+ }
543
+ return await waitForListener({
544
+ port: discovered.port,
545
+ readyMs
546
+ }) ? discovered : null;
547
+ }
548
+ /**
549
+ * Bring the user's registered autopg host up and attach to it — same port, same
550
+ * `~/.autopg/data`, still there after this process exits. cedar-pg never runs a
551
+ * second local Postgres.
552
+ */
553
+ async function startLocalHost(bin, registeredPort) {
554
+ const failures = [];
555
+ for (const { argv, readyMs } of LOCAL_START) {
556
+ const label = `autopg ${argv.join(" ")}`;
557
+ const failure = runAutopg(bin, [...argv]);
558
+ if (failure) {
559
+ failures.push(`${label}: ${failure}`);
560
+ continue;
561
+ }
562
+ const attached = await attachLiveHost(bin, readyMs);
563
+ if (attached) return attached;
564
+ failures.push(`${label}: no listener within ${readyMs}ms`);
565
+ }
566
+ const where = registeredPort != null ? `autopg host is registered on 127.0.0.1:${registeredPort} but nothing is listening.\n` : "";
567
+ throw new Error(formatHostStartError(`${where}${failures.join("\n")}`));
568
+ }
569
+ /**
570
+ * Ephemeral host owned by this process/job: detached `autopg postmaster` with
571
+ * fully ignored stdio (caller exit must not close pipes under the daemon).
465
572
  *
466
- * Readiness is TCP accept on the recipe port — not `autopg status`, which succeeds
467
- * after `install --no-pm2` before postmaster is listening. On success, discovery is
468
- * recipe-derived (same port). On failure, the spawned child is killed.
573
+ * Never runs `autopg install` — that rewrites `~/.autopg/admin.json` and fails
574
+ * with `supervisor mismatch` next to a local pm2 install. Reuses a listener
575
+ * already on the recipe port, and prunes stale RAM dirs before a cold start.
469
576
  */
470
577
  async function startEphemeralHost(bin) {
471
578
  const recipe = ephemeralHostRecipe();
579
+ if (await canConnect(recipe.port)) return discoveryFromRecipe(bin, recipe);
580
+ const useRamShm = recipe.postmasterArgs.includes("--ram");
581
+ pruneStaleEphemeralDataDirs({ dataDir: recipe.dataDir });
582
+ if (useRamShm) {
583
+ const free = freeBytesOn("/dev/shm");
584
+ if (free != null && free < 536870912) process.stderr.write(`[cedar-pg] warning: /dev/shm has ~${Math.round(free / (1024 * 1024))}MB free (recommend ≥${Math.round(EPHEMERAL_SHM_MIN_FREE_BYTES / (1024 * 1024))}MB for --ram).\n${EPHEMERAL_SHM_HINT}\n`);
585
+ }
472
586
  mkdirSync(recipe.dataDir, { recursive: true });
473
- runInstall(bin, recipe.installArgs);
474
- const state = {
475
- exit: null,
476
- spawnError: null
477
- };
478
587
  const child = spawn(bin, recipe.postmasterArgs, {
479
588
  detached: true,
480
589
  stdio: "ignore"
481
590
  });
591
+ let died = null;
482
592
  child.on("error", (err) => {
483
- state.spawnError = err;
593
+ died = new Error(formatHostStartError(`Failed to spawn autopg postmaster.\n${err.message}`, useRamShm));
484
594
  });
485
595
  child.on("exit", (code, signal) => {
486
- state.exit = {
487
- code,
488
- signal
489
- };
596
+ died ??= new Error(formatHostStartError(`autopg postmaster exited before ready (code=${code}, signal=${signal}).`, useRamShm));
490
597
  });
491
598
  try {
492
- await waitForOwnedPostmaster({
599
+ if (!await waitForListener({
493
600
  port: recipe.port,
494
- failure: () => {
495
- if (state.spawnError) return /* @__PURE__ */ new Error(`Failed to spawn autopg postmaster.\n${state.spawnError.message}\n${INSTALL_HINT}`);
496
- if (state.exit) return /* @__PURE__ */ new Error(`autopg postmaster exited before ready (code=${state.exit.code}, signal=${state.exit.signal}).\nautopg is required. Install with:
497
- curl -fsSL https://raw.githubusercontent.com/automagik-dev/autopg/main/install.sh | bash
498
- Then ensure ~/.local/bin is on PATH, or set AUTOPG_BIN.`);
499
- return null;
500
- }
501
- });
601
+ readyMs: HOST_READY_MS,
602
+ failure: () => died
603
+ })) throw new Error(formatHostStartError(`autopg postmaster did not accept 127.0.0.1:${recipe.port} within ${HOST_READY_MS}ms.`, useRamShm));
502
604
  } catch (err) {
503
605
  killOwnedChild(child);
504
606
  throw err;
@@ -507,21 +609,16 @@ Then ensure ~/.local/bin is on PATH, or set AUTOPG_BIN.`);
507
609
  return discoveryFromRecipe(bin, recipe);
508
610
  }
509
611
  /**
510
- * Ensure the host postmaster is up.
511
- *
512
- * - Attaches when `autopg status --json` shows a live host.
513
- * - Otherwise starts from {@link resolveEphemeralHostPolicy}: local pm2 `install`,
514
- * or opinionated ephemeral (`--no-pm2 --no-ui` + detached postmaster).
515
- * - CI job owns ephemeral postmaster lifetime on success (no cedar-pg host dispose).
516
- * - Failed ephemeral start kills the spawned child so ensure is atomic for the caller.
612
+ * Attach to a listening autopg host, else start one per
613
+ * {@link resolveHostStartPolicy}. Internal: callers use `acquire` / `adminUrl`.
517
614
  */
518
615
  async function ensureHostRunning(bin = requireAutopgBin()) {
616
+ let registered = null;
519
617
  try {
520
- return discoverHost(bin);
618
+ registered = discoverHost(bin);
521
619
  } catch {}
522
- if (resolveEphemeralHostPolicy() === "ephemeral") return startEphemeralHost(bin);
523
- runInstall(bin, ["install"]);
524
- return discoverHost(bin);
620
+ if (registered && await waitForListener({ port: registered.port })) return registered;
621
+ return resolveHostStartPolicy() === "ephemeral" ? startEphemeralHost(bin) : startLocalHost(bin, registered?.port);
525
622
  }
526
623
  //#endregion
527
624
  //#region src/core/lifecycle.ts
@@ -681,4 +778,4 @@ async function gc() {
681
778
  //#endregion
682
779
  export { buildCloneDatabaseName as C, runIfNeeded as S, buildRoleName as T, setDatabaseIsTemplate as _, urlFromLease as a, isExternalDatabaseEscapeHatch as b, ROLE_PASSWORD_SCHEME as c, discoverHost as d, dropDatabase as f, rolePasswordFor as g, resolveAutopgBin as h, gc as i, buildDatabaseUrl as l, requireAutopgBin as m, acquireIfNeeded as n, ensureHostRunning as o, parseHostStatus as p, dispose as r, INSTALL_HINT as s, acquire as t, cloneDatabaseFromTemplate as u, applyDatabaseUrlEnv as v, buildDatabaseName as w, resolveAcquireSkip as x, isCedarPgManagedUrl as y };
683
780
 
684
- //# sourceMappingURL=lifecycle-BOo6xBjD.mjs.map
781
+ //# sourceMappingURL=lifecycle-BvIx0xqq.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lifecycle-BvIx0xqq.mjs","names":[],"sources":["../src/core/naming.ts","../src/core/policy.ts","../src/providers/autopg.ts","../src/providers/host.ts","../src/core/lifecycle.ts"],"sourcesContent":["import type { WorktreeIdentity } from \"./worktree.ts\";\n\nexport type DbMode = \"dev\" | \"test\";\n\nconst PG_MAX = 63;\nconst PREFIX = \"cpg_\";\n\n/**\n * Build an observable Postgres database name:\n * cpg_<repoSlug>_<worktreeSlug>_<mode>_<pathHash8>\n *\n * Never drops `mode` or `pathHash`. Truncates slugs to fit ≤63 chars.\n */\nexport function buildDatabaseName(identity: WorktreeIdentity, mode: DbMode): string {\n const modePart = mode;\n const hashPart = identity.pathHash;\n // PREFIX + slug + '_' + slug + '_' + mode + '_' + hash\n // fixed: PREFIX(4) + 2 underscores around mode/hash segments + mode + hash\n // layout: cpg_<repo>_<wt>_<mode>_<hash>\n const fixed =\n PREFIX.length +\n 1 + // after repo\n 1 + // after worktree\n modePart.length +\n 1 +\n hashPart.length;\n\n let budget = PG_MAX - fixed;\n if (budget < 2) {\n // Extreme truncation: keep mode+hash, minimal slugs\n return `${PREFIX}${modePart}_${hashPart}`.slice(0, PG_MAX);\n }\n\n let repo = identity.repoSlug;\n let wt = identity.worktreeSlug;\n // Split budget roughly evenly, preferring to keep both readable\n while (repo.length + wt.length > budget) {\n if (repo.length >= wt.length && repo.length > 1) {\n repo = repo.slice(0, -1);\n } else if (wt.length > 1) {\n wt = wt.slice(0, -1);\n } else {\n break;\n }\n }\n\n const name = `${PREFIX}${repo}_${wt}_${modePart}_${hashPart}`;\n if (name.length > PG_MAX) {\n return name.slice(0, PG_MAX);\n }\n return name;\n}\n\nexport function buildRoleName(databaseName: string): string {\n const suffix = \"_role\";\n const maxBase = PG_MAX - suffix.length;\n const base = databaseName.slice(0, maxBase);\n return `${base}${suffix}`;\n}\n\n/**\n * Build a worker clone datname from a TEMPLATE database name.\n * Layout: `<template>_c_<suffix>` truncated to ≤63 chars (keeps suffix).\n */\nexport function buildCloneDatabaseName(templateName: string, suffix: string): string {\n const safe = suffix\n .toLowerCase()\n .replace(/[^a-z0-9_]+/g, \"_\")\n .replace(/^_+|_+$/g, \"\")\n .slice(0, 24);\n const tag = safe.length > 0 ? safe : \"w\";\n const sep = \"_c_\";\n const maxTemplate = PG_MAX - sep.length - tag.length;\n const base = templateName.slice(0, Math.max(1, maxTemplate));\n return `${base}${sep}${tag}`.slice(0, PG_MAX);\n}\n","/**\n * Shared acquire skip policy for test-runner adapters and Cedar CLI bridges.\n */\n\nexport type AcquireSkip =\n | { skip: false }\n | { skip: true; reason: \"disabled\" }\n | { skip: true; reason: \"external-url\"; databaseUrl: string };\n\nexport type ResolveAcquireSkipInput = {\n /** Candidate URL (TEST_DATABASE_URL for tests, DATABASE_URL for dev). */\n url?: string;\n /** When true, never skip (CEDAR_PG_FORCE=1). */\n force?: boolean;\n /**\n * When true, skip acquire entirely.\n * Defaults from CEDAR_PG=0|false (opt-out adapters). Pass `false` for Cedar opt-in flows.\n */\n disabled?: boolean;\n};\n\n/**\n * Inject DATABASE_URL (and TEST_DATABASE_URL for test mode) from a resolved URL.\n * Single env path for acquire, clone, and external-url skip.\n */\nexport function applyDatabaseUrlEnv(\n databaseUrl: string,\n options: { mode?: \"dev\" | \"test\" } = {},\n): void {\n process.env.DATABASE_URL = databaseUrl;\n if ((options.mode ?? \"test\") === \"test\") {\n process.env.TEST_DATABASE_URL = databaseUrl;\n }\n}\n\nexport type RunIfNeededOptions = ResolveAcquireSkipInput & {\n mode: \"dev\" | \"test\";\n /** Default true (same as acquire / clone host wrappers). */\n setEnv?: boolean;\n};\n\nexport type RunIfNeededSkipped =\n | { status: \"skipped\"; reason: \"disabled\" }\n | { status: \"skipped\"; reason: \"external-url\"; databaseUrl: string };\n\nexport type RunIfNeededResult<T> = RunIfNeededSkipped | { status: \"ran\"; value: T };\n\n/**\n * Shared host skip+env gate for `acquireIfNeeded` / `cloneFromTemplateIfNeeded`.\n * On external-url skip, applies env when `setEnv` is not false.\n */\nexport async function runIfNeeded<T>(\n options: RunIfNeededOptions,\n run: () => Promise<T>,\n): Promise<RunIfNeededResult<T>> {\n const skip = resolveAcquireSkip({\n url: options.url,\n force: options.force,\n disabled: options.disabled,\n });\n if (skip.skip) {\n if (skip.reason === \"external-url\") {\n if (options.setEnv !== false) {\n applyDatabaseUrlEnv(skip.databaseUrl, { mode: options.mode });\n }\n return { status: \"skipped\", reason: \"external-url\", databaseUrl: skip.databaseUrl };\n }\n return { status: \"skipped\", reason: \"disabled\" };\n }\n return { status: \"ran\", value: await run() };\n}\n\n/**\n * True when the URL looks like a cedarpg provisioned database (`cpg_*` name/role).\n * These must never be treated as an external escape hatch; always re-acquire so\n * disposed/stale shell env cannot skip provisioning.\n */\nexport function isCedarPgManagedUrl(url: string | undefined): boolean {\n if (!url || url.startsWith(\"file:\")) return false;\n try {\n const parsed = new URL(url);\n const databaseName = decodeURIComponent(\n (parsed.pathname.replace(/^\\//, \"\").split(\"?\")[0] ?? \"\").trim(),\n );\n const user = decodeURIComponent(parsed.username);\n return databaseName.startsWith(\"cpg_\") || user.startsWith(\"cpg_\");\n } catch {\n return false;\n }\n}\n\n/**\n * True when `url` still looks like an unset dotenv/template value\n * (e.g. `postgresql://{yourMachine}@localhost:5432/app_test` or\n * `postgresql://<user>@localhost/db`), not a real external database.\n */\nfunction isUnsetTemplateUrl(url: string): boolean {\n // `{yourMachine}`, `{user}`, etc.\n if (/\\{[^}]+\\}/.test(url)) return true;\n // `<user>`, `<password>` style templates\n if (/<[^>]+>/.test(url)) return true;\n return false;\n}\n\n/**\n * True when `url` is a real external database and acquire should be skipped.\n * Sqlite `file:` URLs, cedarpg `cpg_*` URLs, and unset template placeholders\n * are not external.\n */\nexport function isExternalDatabaseEscapeHatch(url: string | undefined): boolean {\n if (!url) return false;\n if (url.startsWith(\"file:\")) return false;\n if (isCedarPgManagedUrl(url)) return false;\n if (isUnsetTemplateUrl(url)) return false;\n return true;\n}\n\n/**\n * Decide whether acquire should run.\n * Adapters may call with no args (env defaults). Cedar opt-in should pass `disabled: false`\n * and the relevant `url` (`DATABASE_URL` or `TEST_DATABASE_URL`).\n */\nexport function resolveAcquireSkip(input: ResolveAcquireSkipInput = {}): AcquireSkip {\n const disabled =\n input.disabled ?? (process.env.CEDAR_PG === \"0\" || process.env.CEDAR_PG === \"false\");\n if (disabled) {\n return { skip: true, reason: \"disabled\" };\n }\n\n const force = input.force ?? process.env.CEDAR_PG_FORCE === \"1\";\n if (force) {\n return { skip: false };\n }\n\n const url = input.url !== undefined ? input.url : process.env.TEST_DATABASE_URL;\n if (url && isExternalDatabaseEscapeHatch(url)) {\n return { skip: true, reason: \"external-url\", databaseUrl: url };\n }\n return { skip: false };\n}\n","import { createHash } from \"node:crypto\";\nimport { execFileSync, spawnSync } from \"node:child_process\";\nimport { existsSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport pg from \"pg\";\nimport { PASSWORD_SALT_PREFIX } from \"../core/constants.ts\";\n\nexport type AutopgDiscovery = {\n port: number;\n adminUrl: string;\n bin: string;\n};\n\nexport const INSTALL_HINT =\n \"autopg is required. Install with:\\n\" +\n \" curl -fsSL https://raw.githubusercontent.com/automagik-dev/autopg/main/install.sh | bash\\n\" +\n \"Then ensure ~/.local/bin is on PATH, or set AUTOPG_BIN.\";\n\n/** Password scheme v2: sha256(PASSWORD_SALT_PREFIX + \"\\\\0\" + roleName) hex[:32]. Frozen for URL rebuild. */\nexport const ROLE_PASSWORD_SCHEME = \"v2\" as const;\n\nfunction candidateBins(): string[] {\n const out: string[] = [];\n if (process.env.AUTOPG_BIN) out.push(process.env.AUTOPG_BIN);\n out.push(\"autopg\");\n out.push(join(homedir(), \".local\", \"bin\", \"autopg\"));\n return out;\n}\n\nexport function resolveAutopgBin(): string | null {\n for (const bin of candidateBins()) {\n if (bin === \"autopg\") {\n const which = spawnSync(\"which\", [\"autopg\"], { encoding: \"utf8\" });\n if (which.status === 0 && which.stdout.trim()) return which.stdout.trim();\n continue;\n }\n if (existsSync(bin)) return bin;\n }\n return null;\n}\n\nexport function requireAutopgBin(): string {\n const bin = resolveAutopgBin();\n if (!bin) {\n throw new Error(INSTALL_HINT);\n }\n return bin;\n}\n\n/**\n * Parse `autopg status --json` → the **registered** port. Throws only when the\n * output is not autopg status JSON.\n *\n * Registration is not liveness: autopg reports a port for a stopped host too,\n * and its `status` string is supervisor-specific (pm2 `online`, systemd-user /\n * launchd differ). Liveness is a TCP accept on the port, proven by the caller —\n * `acquire` does that before it connects.\n */\nexport function parseHostStatus(json: string): { port: number } {\n let parsed: { port?: unknown };\n try {\n parsed = JSON.parse(json) as typeof parsed;\n } catch {\n throw new Error(`autopg status --json returned invalid JSON.\\n${INSTALL_HINT}`);\n }\n if (typeof parsed.port !== \"number\") {\n throw new Error(`autopg status --json missing numeric port.\\n${INSTALL_HINT}`);\n }\n return { port: parsed.port };\n}\n\n/**\n * Admin URL for an autopg host on `port`.\n *\n * Credentials follow autopg's own defaults / env chain (not \"any local Postgres\"):\n * - user: `AUTOPG_PG_USER` / `PGSERVE_PG_USER` / `postgres`\n * - password: `AUTOPG_PG_PASSWORD` / `PGSERVE_PG_PASSWORD` / `postgres`\n *\n * Port is never scanned: callers pass the port from `autopg status` (attach) or the\n * ephemeral recipe (`55432`). That keeps us off unrelated local servers (e.g. brew on 5432).\n */\nexport function adminUrlFor(port: number, env: NodeJS.ProcessEnv = process.env): string {\n const user = encodeURIComponent(env.AUTOPG_PG_USER || env.PGSERVE_PG_USER || \"postgres\");\n const password = encodeURIComponent(\n env.AUTOPG_PG_PASSWORD || env.PGSERVE_PG_PASSWORD || \"postgres\",\n );\n return `postgresql://${user}:${password}@127.0.0.1:${port}/postgres`;\n}\n\n/**\n * Discover the registered autopg host (port + admin URL) via `autopg status --json`.\n * Throws when autopg cannot be queried; does **not** prove a listener — probe TCP\n * (or use `acquire`, which does) before connecting.\n */\nexport function discoverHost(bin = requireAutopgBin()): AutopgDiscovery {\n let status: string;\n try {\n status = execFileSync(bin, [\"status\", \"--json\"], {\n encoding: \"utf8\",\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n });\n } catch (err) {\n const detail = err instanceof Error ? err.message : String(err);\n throw new Error(`Failed to query autopg status.\\n${detail}\\n${INSTALL_HINT}`);\n }\n const { port } = parseHostStatus(status);\n return { port, adminUrl: adminUrlFor(port), bin };\n}\n\nfunction quoteIdent(name: string): string {\n return `\"${name.replace(/\"/g, '\"\"')}\"`;\n}\n\nfunction quoteLiteral(value: string): string {\n return `'${value.replace(/'/g, \"''\")}'`;\n}\n\nasync function withAdminClient<T>(\n adminUrl: string,\n fn: (client: pg.Client) => Promise<T>,\n): Promise<T> {\n const client = new pg.Client({ connectionString: adminUrl });\n await client.connect();\n try {\n return await fn(client);\n } finally {\n await client.end();\n }\n}\n\n/**\n * Deterministic local-only password for an app role (Prisma/TCP need it;\n * autopg hba uses `password` for 127.0.0.1).\n *\n * Keyed by `roleName` (not databaseName) so TEMPLATE clones that reuse the\n * same role keep working when `buildDatabaseUrl` is called with a new database.\n */\nexport function rolePasswordFor(roleName: string): string {\n return createHash(\"sha256\")\n .update(`${PASSWORD_SALT_PREFIX}\\0${roleName}`)\n .digest(\"hex\")\n .slice(0, 32);\n}\n\n/**\n * Idempotently CREATE ROLE + CREATE DATABASE with cedar-pg owned names.\n */\nexport async function ensureDatabase(opts: {\n adminUrl: string;\n databaseName: string;\n roleName: string;\n password?: string;\n}): Promise<void> {\n const password = opts.password ?? rolePasswordFor(opts.roleName);\n await withAdminClient(opts.adminUrl, async (client) => {\n const roleExists = await client.query(\"SELECT 1 FROM pg_roles WHERE rolname = $1\", [\n opts.roleName,\n ]);\n if (roleExists.rowCount === 0) {\n await client.query(\n `CREATE ROLE ${quoteIdent(opts.roleName)} WITH LOGIN PASSWORD ${quoteLiteral(password)}`,\n );\n } else {\n await client.query(\n `ALTER ROLE ${quoteIdent(opts.roleName)} WITH LOGIN PASSWORD ${quoteLiteral(password)}`,\n );\n }\n\n const dbExists = await client.query(\"SELECT 1 FROM pg_database WHERE datname = $1\", [\n opts.databaseName,\n ]);\n if (dbExists.rowCount === 0) {\n await client.query(\n `CREATE DATABASE ${quoteIdent(opts.databaseName)} OWNER ${quoteIdent(opts.roleName)}`,\n );\n } else {\n await client.query(\n `ALTER DATABASE ${quoteIdent(opts.databaseName)} OWNER TO ${quoteIdent(opts.roleName)}`,\n );\n }\n });\n}\n\n/**\n * Mark (or unmark) a database as a PostgreSQL template (`IS_TEMPLATE`).\n * Template DBs cannot be dropped until unset.\n */\nexport async function setDatabaseIsTemplate(opts: {\n adminUrl: string;\n databaseName: string;\n isTemplate: boolean;\n}): Promise<void> {\n const flag = opts.isTemplate ? \"true\" : \"false\";\n await withAdminClient(opts.adminUrl, async (client) => {\n await client.query(`ALTER DATABASE ${quoteIdent(opts.databaseName)} WITH IS_TEMPLATE ${flag}`);\n });\n}\n\n/**\n * CREATE DATABASE … TEMPLATE … OWNER via admin connection.\n * Test roles are LOGIN-only; workers cannot CREATE DATABASE themselves.\n */\nexport async function cloneDatabaseFromTemplate(opts: {\n adminUrl: string;\n templateName: string;\n databaseName: string;\n roleName: string;\n}): Promise<void> {\n await withAdminClient(opts.adminUrl, async (client) => {\n const tmpl = await client.query<{ datistemplate: boolean }>(\n `SELECT datistemplate FROM pg_database WHERE datname = $1`,\n [opts.templateName],\n );\n if (!tmpl.rowCount) {\n throw new Error(`template database not found: ${opts.templateName}`);\n }\n if (!tmpl.rows[0]?.datistemplate) {\n throw new Error(`database is not a TEMPLATE; run markTemplate first: ${opts.templateName}`);\n }\n\n const exists = await client.query(\"SELECT 1 FROM pg_database WHERE datname = $1\", [\n opts.databaseName,\n ]);\n if (exists.rowCount && exists.rowCount > 0) {\n throw new Error(`database already exists: ${opts.databaseName}`);\n }\n await client.query(\n `CREATE DATABASE ${quoteIdent(opts.databaseName)} WITH TEMPLATE ${quoteIdent(opts.templateName)} OWNER ${quoteIdent(opts.roleName)}`,\n );\n });\n}\n\nasync function listOwnedDatnames(client: pg.Client, roleName: string): Promise<string[]> {\n const result = await client.query<{ datname: string }>(\n `SELECT datname FROM pg_database\n WHERE datdba = (SELECT oid FROM pg_roles WHERE rolname = $1)\n ORDER BY datname`,\n [roleName],\n );\n return result.rows.map((r) => r.datname);\n}\n\n/** Unset IS_TEMPLATE if needed, terminate backends, DROP DATABASE (no-op if missing). */\nasync function dropOneDatabase(client: pg.Client, databaseName: string): Promise<void> {\n const db = await client.query<{ datistemplate: boolean }>(\n `SELECT datistemplate FROM pg_database WHERE datname = $1`,\n [databaseName],\n );\n if (!db.rowCount || db.rowCount === 0) return;\n if (db.rows[0]?.datistemplate) {\n await client.query(`ALTER DATABASE ${quoteIdent(databaseName)} WITH IS_TEMPLATE false`);\n }\n await client.query(\n `\n SELECT pg_terminate_backend(pid)\n FROM pg_stat_activity\n WHERE datname = $1 AND pid <> pg_backend_pid()\n `,\n [databaseName],\n );\n await client.query(`DROP DATABASE IF EXISTS ${quoteIdent(databaseName)}`);\n}\n\n/**\n * DROP every database owned by `roleName` on one admin connection, then DROP ROLE.\n * When `preferLast` is owned, it is dropped after the other owned datnames (TEMPLATE after clones).\n * Never invents a DROP target beyond role ownership.\n */\nexport async function dropDatabasesOwnedByRole(opts: {\n adminUrl: string;\n roleName: string;\n preferLast?: string;\n}): Promise<string[]> {\n return withAdminClient(opts.adminUrl, async (client) => {\n const owned = await listOwnedDatnames(client, opts.roleName);\n const ordered = [\n ...owned.filter((name) => name !== opts.preferLast),\n ...owned.filter((name) => name === opts.preferLast),\n ];\n const dropped: string[] = [];\n for (const databaseName of ordered) {\n await dropOneDatabase(client, databaseName);\n dropped.push(databaseName);\n }\n await client.query(`DROP ROLE IF EXISTS ${quoteIdent(opts.roleName)}`);\n return dropped;\n });\n}\n\n/**\n * DROP DATABASE (unset IS_TEMPLATE, force terminate backends) + DROP ROLE\n * when the role owns no remaining databases.\n */\nexport async function dropDatabase(opts: {\n adminUrl: string;\n databaseName: string;\n roleName: string;\n}): Promise<void> {\n await withAdminClient(opts.adminUrl, async (client) => {\n await dropOneDatabase(client, opts.databaseName);\n const owns = await client.query(\n `SELECT 1 FROM pg_database WHERE datdba = (SELECT oid FROM pg_roles WHERE rolname = $1) LIMIT 1`,\n [opts.roleName],\n );\n if (owns.rowCount === 0) {\n await client.query(`DROP ROLE IF EXISTS ${quoteIdent(opts.roleName)}`);\n }\n });\n}\n\nexport function buildDatabaseUrl(opts: {\n port: number;\n databaseName: string;\n roleName: string;\n password?: string;\n}): string {\n const password = opts.password ?? rolePasswordFor(opts.roleName);\n const user = encodeURIComponent(opts.roleName);\n const pass = encodeURIComponent(password);\n return `postgresql://${user}:${pass}@127.0.0.1:${opts.port}/${opts.databaseName}`;\n}\n","import { spawn, spawnSync, type ChildProcess } from \"node:child_process\";\nimport { existsSync, mkdirSync, readdirSync, rmSync, statfsSync } from \"node:fs\";\nimport { createConnection } from \"node:net\";\nimport { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\nimport {\n adminUrlFor,\n discoverHost,\n INSTALL_HINT,\n requireAutopgBin,\n type AutopgDiscovery,\n} from \"./autopg.ts\";\n\n/** How cedar-pg brings up an autopg host when nothing is listening. */\nexport type HostStartPolicy = \"local\" | \"ephemeral\";\n\nexport type EphemeralHostRecipe = {\n dataDir: string;\n port: number;\n postmasterArgs: string[];\n};\n\n/** Inputs for {@link ephemeralHostRecipe} (production uses process defaults). */\nexport type EphemeralRecipeContext = {\n platform?: NodeJS.Platform;\n shmAvailable?: boolean;\n tmpDir?: string;\n uid?: number;\n port?: number;\n};\n\nconst EPHEMERAL_PORT = 55432;\n\nconst HOST_READY_MS = 30_000;\nconst HOST_POLL_MS = 200;\n/** `pm2 restart` of an existing process is quick; 30s is only for first `install` / initdb. */\nconst LOCAL_RESTART_READY_MS = 10_000;\n\n/**\n * autopg verbs that can bring the *registered* local host up, cheapest fix first.\n *\n * `restart` exit 0 is not evidence of a listener: when pm2 is missing or does not\n * list `autopg-server`, autopg still prints \"respawned daemon\" and returns 0.\n * That is why every verb is followed by a TCP wait, not trusted on exit status.\n *\n * `install` covers a never-registered machine (postinstall ships the binary only)\n * and a reboot whose pm2 list is empty (`pm2 start`). On an already-registered\n * host it is a no-op for the server process but may `pm2 start` the autopg UI —\n * so it runs only after `restart` failed to produce a listener.\n */\nconst LOCAL_START = [\n { argv: [\"restart\"], readyMs: LOCAL_RESTART_READY_MS },\n { argv: [\"install\"], readyMs: HOST_READY_MS },\n] as const;\n\n/** Soft minimum free bytes on /dev/shm before RAM-backed ephemeral start (warns only). */\nexport const EPHEMERAL_SHM_MIN_FREE_BYTES = 512 * 1024 * 1024;\n\n/**\n * Hint when ephemeral `--ram` initdb fails for space / leftover dirs under `/dev/shm`.\n * Cloud VMs often ship with a tiny default tmpfs (e.g. 64MB).\n */\nexport const EPHEMERAL_SHM_HINT =\n \"Ephemeral autopg uses /dev/shm with --ram. If initdb fails with Disk quota / No space (Postgres 53100):\\n\" +\n \" 1. Enlarge tmpfs (cloud VMs often default to ~64MB): sudo mount -o remount,size=6G /dev/shm\\n\" +\n \" 2. Clear leftovers from OOM-killed runs (your test data only):\\n\" +\n \" rm -rf /dev/shm/cedar-pg-* /dev/shm/pgserve-* /dev/shm/PostgreSQL.*\";\n\n/**\n * Resolve how to start a host when none is listening.\n *\n * - `CEDAR_PG_EPHEMERAL_HOST=1` → ephemeral owned postmaster\n * - `CEDAR_PG_EPHEMERAL_HOST=0` → never own a postmaster, local autopg only (even in CI)\n * - unset + `CI=true` → ephemeral\n * - otherwise → local\n */\nexport function resolveHostStartPolicy(env: NodeJS.ProcessEnv = process.env): HostStartPolicy {\n const force = env.CEDAR_PG_EPHEMERAL_HOST;\n if (force === \"1\") return \"ephemeral\";\n if (force === \"0\") return \"local\";\n if (env.CI === \"true\") return \"ephemeral\";\n return \"local\";\n}\n\nexport function ephemeralHostRecipe(ctx: EphemeralRecipeContext = {}): EphemeralHostRecipe {\n const platform = ctx.platform ?? process.platform;\n const shmAvailable = ctx.shmAvailable ?? (platform === \"linux\" && existsSync(\"/dev/shm\"));\n const uid = ctx.uid ?? process.getuid?.() ?? 0;\n const port = ctx.port ?? EPHEMERAL_PORT;\n const useRam = platform === \"linux\" && shmAvailable;\n const dataDir = useRam\n ? `/dev/shm/cedar-pg-${uid}`\n : join(ctx.tmpDir ?? tmpdir(), \"cedar-pg-host\");\n\n const postmasterArgs = [\n \"postmaster\",\n ...(useRam ? [\"--ram\"] : []),\n \"--port\",\n String(port),\n \"--socket-dir\",\n dataDir,\n \"--data\",\n dataDir,\n ];\n\n return { dataDir, port, postmasterArgs };\n}\n\nexport function discoveryFromRecipe(bin: string, recipe: EphemeralHostRecipe): AutopgDiscovery {\n return { port: recipe.port, adminUrl: adminUrlFor(recipe.port), bin };\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/** True when stderr/stdout looks like a /dev/shm quota or ENOSPC failure. */\nexport function looksLikeShmSpaceError(text: string): boolean {\n return /Disk quota exceeded|No space left on device|ENOSPC|\\b53100\\b/i.test(text);\n}\n\nexport function formatHostStartError(detail: string, useRamShm = false): string {\n const hint = useRamShm && looksLikeShmSpaceError(detail) ? `\\n${EPHEMERAL_SHM_HINT}` : \"\";\n return `Failed to start autopg host.\\n${detail}\\n${INSTALL_HINT}${hint}`;\n}\n\n/**\n * Remove leftover ephemeral data dirs under `/dev/shm` (and the recipe dataDir).\n * Safe for OOM-killed CI/cloud runs that leave `cedar-pg-*` / `pgserve-*` /\n * `PostgreSQL.*` filling tmpfs.\n *\n * Only called on ephemeral cold start, i.e. when the recipe port has no listener —\n * never while a host owns those dirs.\n */\nexport function pruneStaleEphemeralDataDirs(opts: {\n dataDir: string;\n /** Parent of RAM dirs; default `/dev/shm` when it exists. */\n shmRoot?: string;\n}): string[] {\n const removed: string[] = [];\n const tryRm = (path: string) => {\n if (!existsSync(path)) return;\n try {\n rmSync(path, { recursive: true, force: true });\n removed.push(path);\n } catch {\n // best-effort: next initdb will surface a clearer error\n }\n };\n\n tryRm(opts.dataDir);\n\n const shmRoot = opts.shmRoot ?? (existsSync(\"/dev/shm\") ? \"/dev/shm\" : undefined);\n if (!shmRoot) return removed;\n\n let entries: string[] = [];\n try {\n entries = readdirSync(shmRoot);\n } catch {\n return removed;\n }\n\n for (const name of entries) {\n if (\n name.startsWith(\"cedar-pg-\") ||\n name.startsWith(\"pgserve-\") ||\n name.startsWith(\"PostgreSQL.\")\n ) {\n tryRm(join(shmRoot, name));\n }\n }\n return removed;\n}\n\n/** Free bytes on `path`, or `null` if unavailable. */\nfunction freeBytesOn(path: string): number | null {\n try {\n const s = statfsSync(path);\n return Number(s.bavail) * Number(s.bsize);\n } catch {\n return null;\n }\n}\n\n/** Run a one-shot autopg verb. Returns failure detail, or `null` on exit 0. */\nfunction runAutopg(bin: string, argv: string[]): string | null {\n const result = spawnSync(bin, argv, {\n encoding: \"utf8\",\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n });\n if (result.error) return result.error.message;\n if (result.status === 0) return null;\n return `exit ${result.status}\\n${(result.stderr || result.stdout || \"\").trim()}`.trim();\n}\n\n/** True when something accepts TCP on 127.0.0.1:port (postmaster live, not just admin.json). */\nfunction canConnect(port: number): Promise<boolean> {\n return new Promise((resolve) => {\n const socket = createConnection({ host: \"127.0.0.1\", port }, () => {\n socket.end();\n resolve(true);\n });\n socket.on(\"error\", () => {\n resolve(false);\n });\n });\n}\n\nfunction killOwnedChild(child: ChildProcess): void {\n const pid = child.pid;\n if (pid != null) {\n try {\n process.kill(-pid, \"SIGTERM\");\n } catch {\n try {\n child.kill(\"SIGTERM\");\n } catch {\n // already exited\n }\n }\n }\n child.unref();\n}\n\nexport type WaitForListenerOptions = {\n port: number;\n /** Total grace period; `0` (default) probes exactly once. */\n readyMs?: number;\n pollMs?: number;\n canConnect?: (port: number) => Promise<boolean>;\n now?: () => number;\n sleep?: (ms: number) => Promise<void>;\n /** Return an Error to abort early (spawn error / child exit). */\n failure?: () => Error | null;\n};\n\n/**\n * The single liveness primitive: TCP accept on 127.0.0.1:port.\n *\n * Resolves `true` as soon as something is listening, `false` when the grace\n * period expires, and throws only what {@link WaitForListenerOptions.failure}\n * returns. Used for attach (one probe), local restart, and ephemeral start.\n */\nexport async function waitForListener(opts: WaitForListenerOptions): Promise<boolean> {\n const probe = opts.canConnect ?? canConnect;\n const now = opts.now ?? Date.now;\n const pause = opts.sleep ?? sleep;\n const pollMs = opts.pollMs ?? HOST_POLL_MS;\n const deadline = now() + (opts.readyMs ?? 0);\n\n for (;;) {\n const fail = opts.failure?.();\n if (fail) throw fail;\n if (await probe(opts.port)) return true;\n if (now() >= deadline) return false;\n await pause(pollMs);\n }\n}\n\n/**\n * Attach to the registered autopg host once TCP accepts on its port.\n *\n * Registration is not liveness: a stopped pm2 host still reports a port, and\n * attaching to it is the `ECONNREFUSED 127.0.0.1:25432` bug. `readyMs` > 0 is\n * the grace period after asking autopg to start.\n */\nasync function attachLiveHost(bin: string, readyMs = 0): Promise<AutopgDiscovery | null> {\n let discovered: AutopgDiscovery;\n try {\n discovered = discoverHost(bin);\n } catch {\n return null;\n }\n return (await waitForListener({ port: discovered.port, readyMs })) ? discovered : null;\n}\n\n/**\n * Bring the user's registered autopg host up and attach to it — same port, same\n * `~/.autopg/data`, still there after this process exits. cedar-pg never runs a\n * second local Postgres.\n */\nasync function startLocalHost(bin: string, registeredPort?: number): Promise<AutopgDiscovery> {\n const failures: string[] = [];\n\n for (const { argv, readyMs } of LOCAL_START) {\n const label = `autopg ${argv.join(\" \")}`;\n const failure = runAutopg(bin, [...argv]);\n if (failure) {\n failures.push(`${label}: ${failure}`);\n continue;\n }\n const attached = await attachLiveHost(bin, readyMs);\n if (attached) return attached;\n failures.push(`${label}: no listener within ${readyMs}ms`);\n }\n\n const where =\n registeredPort != null\n ? `autopg host is registered on 127.0.0.1:${registeredPort} but nothing is listening.\\n`\n : \"\";\n throw new Error(formatHostStartError(`${where}${failures.join(\"\\n\")}`));\n}\n\n/**\n * Ephemeral host owned by this process/job: detached `autopg postmaster` with\n * fully ignored stdio (caller exit must not close pipes under the daemon).\n *\n * Never runs `autopg install` — that rewrites `~/.autopg/admin.json` and fails\n * with `supervisor mismatch` next to a local pm2 install. Reuses a listener\n * already on the recipe port, and prunes stale RAM dirs before a cold start.\n */\nasync function startEphemeralHost(bin: string): Promise<AutopgDiscovery> {\n const recipe = ephemeralHostRecipe();\n if (await canConnect(recipe.port)) return discoveryFromRecipe(bin, recipe);\n\n const useRamShm = recipe.postmasterArgs.includes(\"--ram\");\n pruneStaleEphemeralDataDirs({ dataDir: recipe.dataDir });\n\n if (useRamShm) {\n const free = freeBytesOn(\"/dev/shm\");\n if (free != null && free < EPHEMERAL_SHM_MIN_FREE_BYTES) {\n process.stderr.write(\n `[cedar-pg] warning: /dev/shm has ~${Math.round(free / (1024 * 1024))}MB free ` +\n `(recommend ≥${Math.round(EPHEMERAL_SHM_MIN_FREE_BYTES / (1024 * 1024))}MB for --ram).\\n` +\n `${EPHEMERAL_SHM_HINT}\\n`,\n );\n }\n }\n\n mkdirSync(recipe.dataDir, { recursive: true });\n\n const child = spawn(bin, recipe.postmasterArgs, { detached: true, stdio: \"ignore\" });\n let died: Error | null = null;\n child.on(\"error\", (err) => {\n died = new Error(\n formatHostStartError(`Failed to spawn autopg postmaster.\\n${err.message}`, useRamShm),\n );\n });\n child.on(\"exit\", (code, signal) => {\n died ??= new Error(\n formatHostStartError(\n `autopg postmaster exited before ready (code=${code}, signal=${signal}).`,\n useRamShm,\n ),\n );\n });\n\n try {\n const listening = await waitForListener({\n port: recipe.port,\n readyMs: HOST_READY_MS,\n failure: () => died,\n });\n if (!listening) {\n throw new Error(\n formatHostStartError(\n `autopg postmaster did not accept 127.0.0.1:${recipe.port} within ${HOST_READY_MS}ms.`,\n useRamShm,\n ),\n );\n }\n } catch (err) {\n killOwnedChild(child);\n throw err;\n }\n\n // Success: the process/job owns lifetime — drop our handle without killing.\n child.unref();\n return discoveryFromRecipe(bin, recipe);\n}\n\n/**\n * Attach to a listening autopg host, else start one per\n * {@link resolveHostStartPolicy}. Internal: callers use `acquire` / `adminUrl`.\n */\nexport async function ensureHostRunning(bin = requireAutopgBin()): Promise<AutopgDiscovery> {\n let registered: AutopgDiscovery | null = null;\n try {\n registered = discoverHost(bin);\n } catch {\n // no registration — local recovery may `install`\n }\n if (registered && (await waitForListener({ port: registered.port }))) return registered;\n\n return resolveHostStartPolicy() === \"ephemeral\"\n ? startEphemeralHost(bin)\n : startLocalHost(bin, registered?.port);\n}\n","import { mkdirSync, writeFileSync } from \"node:fs\";\nimport { buildDatabaseName, buildRoleName, type DbMode } from \"./naming.ts\";\nimport {\n envPath,\n forgetLease,\n isOrphanLease,\n leaseDir,\n listRegistryLeases,\n readLease,\n writeLease,\n type Lease,\n} from \"./lease.ts\";\nimport { applyDatabaseUrlEnv, runIfNeeded, type ResolveAcquireSkipInput } from \"./policy.ts\";\nimport { resolveWorktreeIdentity } from \"./worktree.ts\";\nimport { buildDatabaseUrl, dropDatabasesOwnedByRole, ensureDatabase } from \"../providers/autopg.ts\";\nimport { ensureHostRunning } from \"../providers/host.ts\";\n\nfunction writeEnvFile(root: string, mode: DbMode, databaseUrl: string): void {\n mkdirSync(leaseDir(root), { recursive: true, mode: 0o700 });\n let body = `DATABASE_URL=${databaseUrl}\\n`;\n if (mode === \"test\") body += `TEST_DATABASE_URL=${databaseUrl}\\n`;\n writeFileSync(envPath(root, mode), body, { mode: 0o600 });\n}\n\nexport function urlFromLease(lease: Lease): string {\n return buildDatabaseUrl({\n port: lease.port,\n databaseName: lease.databaseName,\n roleName: lease.roleName,\n });\n}\n\n/**\n * DROP every DB owned by the lease role (TEMPLATE + clones), then forget lease.\n * Provider owns ordering (clones before leased datname) on one admin connection.\n */\nasync function dropThenForget(lease: Lease, adminUrl: string): Promise<string[]> {\n const dropped = await dropDatabasesOwnedByRole({\n adminUrl,\n roleName: lease.roleName,\n preferLast: lease.databaseName,\n });\n forgetLease(lease);\n return dropped;\n}\n\nexport type AcquireOptions = {\n root?: string;\n mode: DbMode;\n /** Inject DATABASE_URL / TEST_DATABASE_URL into process.env (default true). */\n setEnv?: boolean;\n};\n\nexport type AcquireResult = {\n databaseUrl: string;\n /** Superuser URL for privileged DDL (mark template, CREATE DATABASE … TEMPLATE). */\n adminUrl: string;\n databaseName: string;\n roleName: string;\n repoSlug: string;\n worktreeSlug: string;\n pathHash: string;\n root: string;\n mode: DbMode;\n port: number;\n dispose: () => Promise<void>;\n};\n\n/**\n * Acquire a worktree-scoped database and return connection info.\n *\n * - `dev`: keep DB across restarts.\n * - `test`: DROP when `dispose()` is awaited (callers / test runners own teardown).\n */\nexport async function acquire(options: AcquireOptions): Promise<AcquireResult> {\n const identity = resolveWorktreeIdentity(options.root);\n const mode = options.mode;\n const databaseName = buildDatabaseName(identity, mode);\n const roleName = buildRoleName(databaseName);\n\n const host = await ensureHostRunning();\n await ensureDatabase({\n adminUrl: host.adminUrl,\n databaseName,\n roleName,\n });\n\n const databaseUrl = buildDatabaseUrl({\n port: host.port,\n databaseName,\n roleName,\n });\n\n const lease: Lease = {\n schemaVersion: 1,\n mode,\n root: identity.root,\n repoSlug: identity.repoSlug,\n worktreeSlug: identity.worktreeSlug,\n pathHash: identity.pathHash,\n databaseName,\n roleName,\n port: host.port,\n pid: process.pid,\n createdAt: new Date().toISOString(),\n };\n writeLease(lease);\n writeEnvFile(identity.root, mode, databaseUrl);\n\n if (options.setEnv !== false) {\n applyDatabaseUrlEnv(databaseUrl, { mode });\n }\n\n const disposeFn = async () => {\n await dispose({ root: identity.root, mode });\n };\n\n return {\n databaseUrl,\n adminUrl: host.adminUrl,\n databaseName,\n roleName,\n repoSlug: identity.repoSlug,\n worktreeSlug: identity.worktreeSlug,\n pathHash: identity.pathHash,\n root: identity.root,\n mode,\n port: host.port,\n dispose: disposeFn,\n };\n}\n\nexport type AcquireIfNeededOptions = AcquireOptions & ResolveAcquireSkipInput;\n\nexport type AcquireIfNeededResult =\n | { status: \"skipped\"; reason: \"disabled\" }\n | { status: \"skipped\"; reason: \"external-url\"; databaseUrl: string }\n | ({ status: \"acquired\" } & AcquireResult);\n\n/**\n * Resolve skip policy then acquire. Single entry for hosts (Cedar CLI, Jest, Vitest).\n * On external-url skip, applies DATABASE_URL / TEST_DATABASE_URL when `setEnv` is not false.\n */\nexport async function acquireIfNeeded(\n options: AcquireIfNeededOptions,\n): Promise<AcquireIfNeededResult> {\n const outcome = await runIfNeeded(options, () =>\n acquire({\n root: options.root,\n mode: options.mode,\n setEnv: options.setEnv,\n }),\n );\n if (outcome.status === \"skipped\") return outcome;\n return { status: \"acquired\", ...outcome.value };\n}\n\nexport type DisposeOptions = {\n root?: string;\n mode?: DbMode;\n};\n\nexport type DisposeResult =\n | { dropped: true; databaseName: string; droppedDatabases: string[] }\n | { dropped: false; reason: \"no-lease\" | \"host-unavailable\" };\n\n/**\n * Role-scoped suite teardown: DROP every database owned by the lease role\n * (TEMPLATE + clones), then DROP ROLE and forget the lease. Unsets `IS_TEMPLATE`\n * as needed. This is not per-clone cleanup — use `CloneResult.dropClone` for that.\n * No-ops without a valid lease; never invents a DROP target beyond role ownership.\n * If the host is unavailable, leaves the lease so dispose/gc can retry.\n */\nexport async function dispose(options: DisposeOptions = {}): Promise<DisposeResult> {\n const identity = resolveWorktreeIdentity(options.root);\n const mode = options.mode ?? \"test\";\n const lease = readLease(identity.root, mode);\n if (!lease) return { dropped: false, reason: \"no-lease\" };\n\n let host;\n try {\n host = await ensureHostRunning();\n } catch {\n // Keep lease + registry so a later dispose/gc can still find the DB.\n return { dropped: false, reason: \"host-unavailable\" };\n }\n\n const droppedDatabases = await dropThenForget(lease, host.adminUrl);\n return {\n dropped: true,\n databaseName: lease.databaseName,\n droppedDatabases,\n };\n}\n\n/**\n * Drop databases whose registered worktree root no longer exists on disk.\n * Registry entries are removed only after a successful DROP (owned DBs + lease DB).\n */\nexport async function gc(): Promise<{\n dropped: string[];\n}> {\n const dropped: string[] = [];\n const orphans = listRegistryLeases().filter(isOrphanLease);\n if (orphans.length === 0) return { dropped };\n\n let host;\n try {\n host = await ensureHostRunning();\n } catch {\n return { dropped };\n }\n\n for (const lease of orphans) {\n try {\n const names = await dropThenForget(lease, host.adminUrl);\n dropped.push(...names);\n } catch {\n // Keep registry entry for retry\n }\n }\n return { dropped };\n}\n"],"mappings":";;;;;;;;;AAIA,MAAM,SAAS;AACf,MAAM,SAAS;;;;;;;AAQf,SAAgB,kB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sB,QAAQ,UAA0B,CAAC,GAA2B;CAClF,MAAM,WAAW,wBAAwB,QAAQ,IAAI;CACrD,MAAM,OAAO,QAAQ,QAAQ;CAC7B,MAAM,QAAQ,UAAU,SAAS,MAAM,IAAI;CAC3C,IAAI,CAAC,OAAO,OAAO;EAAE,SAAS;EAAO,QAAQ;CAAW;CAExD,IAAI;CACJ,IAAI;EACF,OAAO,MAAM,kBAAkB;CACjC,QAAQ;EAEN,OAAO;GAAE,SAAS;GAAO,QAAQ;EAAmB;CACtD;CAEA,MAAM,mBAAmB,MAAM,eAAe,OAAO,KAAK,QAAQ;CAClE,OAAO;EACL,SAAS;EACT,cAAc,MAAM;EACpB;CACF;AACF;;;;;AAMA,eAAsB,KAEnB;CACD,MAAM,UAAoB,CAAC;CAC3B,MAAM,UAAU,mBAAmB,CAAC,CAAC,OAAO,aAAa;CACzD,IAAI,QAAQ,WAAW,GAAG,OAAO,EAAE,QAAQ;CAE3C,IAAI;CACJ,IAAI;EACF,OAAO,MAAM,kBAAkB;CACjC,QAAQ;EACN,OAAO,EAAE,QAAQ;CACnB;CAEA,KAAK,MAAM,SAAS,SAClB,IAAI;EACF,MAAM,QAAQ,MAAM,eAAe,OAAO,KAAK,QAAQ;EACvD,QAAQ,KAAK,GAAG,KAAK;CACvB,QAAQ,CAER;CAEF,OAAO,EAAE,QAAQ;AACnB"}
@@ -1,4 +1,4 @@
1
- import { n as normalizeLoadOptions, t as loadModeEnv } from "./load-mode-env-C8gy4v9V.mjs";
1
+ import { n as normalizeLoadOptions, t as loadModeEnv } from "./load-mode-env-Ce9ujisN.mjs";
2
2
  //#region src/adapters/load-dev-env.ts
3
3
  /** Load `.cedarpg/dev.env` into `process.env`. Use `{ overwrite: true }` to beat `.env`. */
4
4
  function loadDevEnv(rootOrOptions) {
@@ -7,4 +7,4 @@ function loadDevEnv(rootOrOptions) {
7
7
  //#endregion
8
8
  export { loadDevEnv as t };
9
9
 
10
- //# sourceMappingURL=load-dev-env-7UjMHhw7.mjs.map
10
+ //# sourceMappingURL=load-dev-env-BULkXyen.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"load-dev-env-7UjMHhw7.mjs","names":[],"sources":["../src/adapters/load-dev-env.ts"],"sourcesContent":["import { loadModeEnv, normalizeLoadOptions, type LoadModeEnvOptions } from \"./load-mode-env.ts\";\n\nexport type LoadDevEnvOptions = LoadModeEnvOptions;\n\n/** Load `.cedarpg/dev.env` into `process.env`. Use `{ overwrite: true }` to beat `.env`. */\nexport function loadDevEnv(rootOrOptions?: string | LoadDevEnvOptions): void {\n loadModeEnv(\"dev\", normalizeLoadOptions(rootOrOptions));\n}\n"],"mappings":";;;AAKA,SAAgB,WAAW,eAAkD;CAC3E,YAAY,OAAO,qBAAqB,aAAa,CAAC;AACxD"}
1
+ {"version":3,"file":"load-dev-env-BULkXyen.mjs","names":[],"sources":["../src/adapters/load-dev-env.ts"],"sourcesContent":["import { loadModeEnv, normalizeLoadOptions, type LoadModeEnvOptions } from \"./load-mode-env.ts\";\n\nexport type LoadDevEnvOptions = LoadModeEnvOptions;\n\n/** Load `.cedarpg/dev.env` into `process.env`. Use `{ overwrite: true }` to beat `.env`. */\nexport function loadDevEnv(rootOrOptions?: string | LoadDevEnvOptions): void {\n loadModeEnv(\"dev\", normalizeLoadOptions(rootOrOptions));\n}\n"],"mappings":";;;AAKA,SAAgB,WAAW,eAAkD;CAC3E,YAAY,OAAO,qBAAqB,aAAa,CAAC;AACxD"}
@@ -1,4 +1,4 @@
1
- const require_load_mode_env = require("./load-mode-env-B0qO9DZx.cjs");
1
+ const require_load_mode_env = require("./load-mode-env-CX9vd56X.cjs");
2
2
  //#region src/adapters/load-dev-env.ts
3
3
  /** Load `.cedarpg/dev.env` into `process.env`. Use `{ overwrite: true }` to beat `.env`. */
4
4
  function loadDevEnv(rootOrOptions) {
@@ -12,4 +12,4 @@ Object.defineProperty(exports, "loadDevEnv", {
12
12
  }
13
13
  });
14
14
 
15
- //# sourceMappingURL=load-dev-env-cII6N4ZP.cjs.map
15
+ //# sourceMappingURL=load-dev-env-Bl6Ddv1U.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"load-dev-env-cII6N4ZP.cjs","names":["normalizeLoadOptions"],"sources":["../src/adapters/load-dev-env.ts"],"sourcesContent":["import { loadModeEnv, normalizeLoadOptions, type LoadModeEnvOptions } from \"./load-mode-env.ts\";\n\nexport type LoadDevEnvOptions = LoadModeEnvOptions;\n\n/** Load `.cedarpg/dev.env` into `process.env`. Use `{ overwrite: true }` to beat `.env`. */\nexport function loadDevEnv(rootOrOptions?: string | LoadDevEnvOptions): void {\n loadModeEnv(\"dev\", normalizeLoadOptions(rootOrOptions));\n}\n"],"mappings":";;;AAKA,SAAgB,WAAW,eAAkD;CAC3E,sBAAA,YAAY,OAAOA,sBAAAA,qBAAqB,aAAa,CAAC;AACxD"}
1
+ {"version":3,"file":"load-dev-env-Bl6Ddv1U.cjs","names":["normalizeLoadOptions"],"sources":["../src/adapters/load-dev-env.ts"],"sourcesContent":["import { loadModeEnv, normalizeLoadOptions, type LoadModeEnvOptions } from \"./load-mode-env.ts\";\n\nexport type LoadDevEnvOptions = LoadModeEnvOptions;\n\n/** Load `.cedarpg/dev.env` into `process.env`. Use `{ overwrite: true }` to beat `.env`. */\nexport function loadDevEnv(rootOrOptions?: string | LoadDevEnvOptions): void {\n loadModeEnv(\"dev\", normalizeLoadOptions(rootOrOptions));\n}\n"],"mappings":";;;AAKA,SAAgB,WAAW,eAAkD;CAC3E,sBAAA,YAAY,OAAOA,sBAAAA,qBAAqB,aAAa,CAAC;AACxD"}
@@ -1,4 +1,4 @@
1
- const require_lease = require("./lease-Bq9wKwQa.cjs");
1
+ const require_lease = require("./lease-WlmOnNDi.cjs");
2
2
  let node_fs = require("node:fs");
3
3
  //#region src/adapters/load-mode-env.ts
4
4
  function normalizeLoadOptions(rootOrOptions) {
@@ -36,4 +36,4 @@ Object.defineProperty(exports, "normalizeLoadOptions", {
36
36
  }
37
37
  });
38
38
 
39
- //# sourceMappingURL=load-mode-env-B0qO9DZx.cjs.map
39
+ //# sourceMappingURL=load-mode-env-CX9vd56X.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"load-mode-env-B0qO9DZx.cjs","names":["resolveRoot","leasePath","envPath"],"sources":["../src/adapters/load-mode-env.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport { envPath, leasePath } from \"../core/lease.ts\";\nimport type { DbMode } from \"../core/naming.ts\";\nimport { resolveRoot } from \"../core/worktree.ts\";\n\nexport type LoadModeEnvOptions = {\n root?: string;\n /** Overwrite existing `process.env` keys (default: only fill undefined). */\n overwrite?: boolean;\n};\n\nexport function normalizeLoadOptions(\n rootOrOptions?: string | LoadModeEnvOptions,\n): LoadModeEnvOptions {\n if (typeof rootOrOptions === \"string\" || rootOrOptions === undefined) {\n return { root: rootOrOptions };\n }\n return rootOrOptions;\n}\n\n/** Load `.cedarpg/<mode>.env` when a matching lease exists; no-op if stale/missing. */\nexport function loadModeEnv(mode: DbMode, options: LoadModeEnvOptions = {}): void {\n const resolved = resolveRoot(options.root);\n if (!existsSync(leasePath(resolved, mode))) return;\n\n const file = envPath(resolved, mode);\n if (!existsSync(file)) return;\n\n const overwrite = options.overwrite === true;\n for (const line of readFileSync(file, \"utf8\").split(\"\\n\")) {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith(\"#\")) continue;\n const eq = trimmed.indexOf(\"=\");\n if (eq <= 0) continue;\n const key = trimmed.slice(0, eq);\n const value = trimmed.slice(eq + 1);\n if (overwrite || process.env[key] === undefined) {\n process.env[key] = value;\n }\n }\n}\n"],"mappings":";;;AAWA,SAAgB,qBACd,eACoB;CACpB,IAAI,OAAO,kBAAkB,YAAY,kBAAkB,KAAA,GACzD,OAAO,EAAE,MAAM,cAAc;CAE/B,OAAO;AACT;;AAGA,SAAgB,YAAY,MAAc,UAA8B,CAAC,GAAS;CAChF,MAAM,WAAWA,cAAAA,YAAY,QAAQ,IAAI;CACzC,IAAI,EAAA,GAAA,QAAA,WAAA,CAAYC,cAAAA,UAAU,UAAU,IAAI,CAAC,GAAG;CAE5C,MAAM,OAAOC,cAAAA,QAAQ,UAAU,IAAI;CACnC,IAAI,EAAA,GAAA,QAAA,WAAA,CAAY,IAAI,GAAG;CAEvB,MAAM,YAAY,QAAQ,cAAc;CACxC,KAAK,MAAM,SAAA,GAAA,QAAA,aAAA,CAAqB,MAAM,MAAM,CAAC,CAAC,MAAM,IAAI,GAAG;EACzD,MAAM,UAAU,KAAK,KAAK;EAC1B,IAAI,CAAC,WAAW,QAAQ,WAAW,GAAG,GAAG;EACzC,MAAM,KAAK,QAAQ,QAAQ,GAAG;EAC9B,IAAI,MAAM,GAAG;EACb,MAAM,MAAM,QAAQ,MAAM,GAAG,EAAE;EAC/B,MAAM,QAAQ,QAAQ,MAAM,KAAK,CAAC;EAClC,IAAI,aAAa,QAAQ,IAAI,SAAS,KAAA,GACpC,QAAQ,IAAI,OAAO;CAEvB;AACF"}
1
+ {"version":3,"file":"load-mode-env-CX9vd56X.cjs","names":["resolveRoot","leasePath","envPath"],"sources":["../src/adapters/load-mode-env.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport { envPath, leasePath } from \"../core/lease.ts\";\nimport type { DbMode } from \"../core/naming.ts\";\nimport { resolveRoot } from \"../core/worktree.ts\";\n\nexport type LoadModeEnvOptions = {\n root?: string;\n /** Overwrite existing `process.env` keys (default: only fill undefined). */\n overwrite?: boolean;\n};\n\nexport function normalizeLoadOptions(\n rootOrOptions?: string | LoadModeEnvOptions,\n): LoadModeEnvOptions {\n if (typeof rootOrOptions === \"string\" || rootOrOptions === undefined) {\n return { root: rootOrOptions };\n }\n return rootOrOptions;\n}\n\n/** Load `.cedarpg/<mode>.env` when a matching lease exists; no-op if stale/missing. */\nexport function loadModeEnv(mode: DbMode, options: LoadModeEnvOptions = {}): void {\n const resolved = resolveRoot(options.root);\n if (!existsSync(leasePath(resolved, mode))) return;\n\n const file = envPath(resolved, mode);\n if (!existsSync(file)) return;\n\n const overwrite = options.overwrite === true;\n for (const line of readFileSync(file, \"utf8\").split(\"\\n\")) {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith(\"#\")) continue;\n const eq = trimmed.indexOf(\"=\");\n if (eq <= 0) continue;\n const key = trimmed.slice(0, eq);\n const value = trimmed.slice(eq + 1);\n if (overwrite || process.env[key] === undefined) {\n process.env[key] = value;\n }\n }\n}\n"],"mappings":";;;AAWA,SAAgB,qBACd,eACoB;CACpB,IAAI,OAAO,kBAAkB,YAAY,kBAAkB,KAAA,GACzD,OAAO,EAAE,MAAM,cAAc;CAE/B,OAAO;AACT;;AAGA,SAAgB,YAAY,MAAc,UAA8B,CAAC,GAAS;CAChF,MAAM,WAAWA,cAAAA,YAAY,QAAQ,IAAI;CACzC,IAAI,EAAA,GAAA,QAAA,WAAA,CAAYC,cAAAA,UAAU,UAAU,IAAI,CAAC,GAAG;CAE5C,MAAM,OAAOC,cAAAA,QAAQ,UAAU,IAAI;CACnC,IAAI,EAAA,GAAA,QAAA,WAAA,CAAY,IAAI,GAAG;CAEvB,MAAM,YAAY,QAAQ,cAAc;CACxC,KAAK,MAAM,SAAA,GAAA,QAAA,aAAA,CAAqB,MAAM,MAAM,CAAC,CAAC,MAAM,IAAI,GAAG;EACzD,MAAM,UAAU,KAAK,KAAK;EAC1B,IAAI,CAAC,WAAW,QAAQ,WAAW,GAAG,GAAG;EACzC,MAAM,KAAK,QAAQ,QAAQ,GAAG;EAC9B,IAAI,MAAM,GAAG;EACb,MAAM,MAAM,QAAQ,MAAM,GAAG,EAAE;EAC/B,MAAM,QAAQ,QAAQ,MAAM,KAAK,CAAC;EAClC,IAAI,aAAa,QAAQ,IAAI,SAAS,KAAA,GACpC,QAAQ,IAAI,OAAO;CAEvB;AACF"}
@@ -1,4 +1,4 @@
1
- import { d as resolveRoot, n as envPath, o as leasePath } from "./lease-BSBBpaR4.mjs";
1
+ import { d as resolveRoot, n as envPath, o as leasePath } from "./lease-DS1SX8U_.mjs";
2
2
  import { existsSync, readFileSync } from "node:fs";
3
3
  //#region src/adapters/load-mode-env.ts
4
4
  function normalizeLoadOptions(rootOrOptions) {
@@ -25,4 +25,4 @@ function loadModeEnv(mode, options = {}) {
25
25
  //#endregion
26
26
  export { normalizeLoadOptions as n, loadModeEnv as t };
27
27
 
28
- //# sourceMappingURL=load-mode-env-C8gy4v9V.mjs.map
28
+ //# sourceMappingURL=load-mode-env-Ce9ujisN.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"load-mode-env-C8gy4v9V.mjs","names":[],"sources":["../src/adapters/load-mode-env.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport { envPath, leasePath } from \"../core/lease.ts\";\nimport type { DbMode } from \"../core/naming.ts\";\nimport { resolveRoot } from \"../core/worktree.ts\";\n\nexport type LoadModeEnvOptions = {\n root?: string;\n /** Overwrite existing `process.env` keys (default: only fill undefined). */\n overwrite?: boolean;\n};\n\nexport function normalizeLoadOptions(\n rootOrOptions?: string | LoadModeEnvOptions,\n): LoadModeEnvOptions {\n if (typeof rootOrOptions === \"string\" || rootOrOptions === undefined) {\n return { root: rootOrOptions };\n }\n return rootOrOptions;\n}\n\n/** Load `.cedarpg/<mode>.env` when a matching lease exists; no-op if stale/missing. */\nexport function loadModeEnv(mode: DbMode, options: LoadModeEnvOptions = {}): void {\n const resolved = resolveRoot(options.root);\n if (!existsSync(leasePath(resolved, mode))) return;\n\n const file = envPath(resolved, mode);\n if (!existsSync(file)) return;\n\n const overwrite = options.overwrite === true;\n for (const line of readFileSync(file, \"utf8\").split(\"\\n\")) {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith(\"#\")) continue;\n const eq = trimmed.indexOf(\"=\");\n if (eq <= 0) continue;\n const key = trimmed.slice(0, eq);\n const value = trimmed.slice(eq + 1);\n if (overwrite || process.env[key] === undefined) {\n process.env[key] = value;\n }\n }\n}\n"],"mappings":";;;AAWA,SAAgB,qBACd,eACoB;CACpB,IAAI,OAAO,kBAAkB,YAAY,kBAAkB,KAAA,GACzD,OAAO,EAAE,MAAM,cAAc;CAE/B,OAAO;AACT;;AAGA,SAAgB,YAAY,MAAc,UAA8B,CAAC,GAAS;CAChF,MAAM,WAAW,YAAY,QAAQ,IAAI;CACzC,IAAI,CAAC,WAAW,UAAU,UAAU,IAAI,CAAC,GAAG;CAE5C,MAAM,OAAO,QAAQ,UAAU,IAAI;CACnC,IAAI,CAAC,WAAW,IAAI,GAAG;CAEvB,MAAM,YAAY,QAAQ,cAAc;CACxC,KAAK,MAAM,QAAQ,aAAa,MAAM,MAAM,CAAC,CAAC,MAAM,IAAI,GAAG;EACzD,MAAM,UAAU,KAAK,KAAK;EAC1B,IAAI,CAAC,WAAW,QAAQ,WAAW,GAAG,GAAG;EACzC,MAAM,KAAK,QAAQ,QAAQ,GAAG;EAC9B,IAAI,MAAM,GAAG;EACb,MAAM,MAAM,QAAQ,MAAM,GAAG,EAAE;EAC/B,MAAM,QAAQ,QAAQ,MAAM,KAAK,CAAC;EAClC,IAAI,aAAa,QAAQ,IAAI,SAAS,KAAA,GACpC,QAAQ,IAAI,OAAO;CAEvB;AACF"}
1
+ {"version":3,"file":"load-mode-env-Ce9ujisN.mjs","names":[],"sources":["../src/adapters/load-mode-env.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport { envPath, leasePath } from \"../core/lease.ts\";\nimport type { DbMode } from \"../core/naming.ts\";\nimport { resolveRoot } from \"../core/worktree.ts\";\n\nexport type LoadModeEnvOptions = {\n root?: string;\n /** Overwrite existing `process.env` keys (default: only fill undefined). */\n overwrite?: boolean;\n};\n\nexport function normalizeLoadOptions(\n rootOrOptions?: string | LoadModeEnvOptions,\n): LoadModeEnvOptions {\n if (typeof rootOrOptions === \"string\" || rootOrOptions === undefined) {\n return { root: rootOrOptions };\n }\n return rootOrOptions;\n}\n\n/** Load `.cedarpg/<mode>.env` when a matching lease exists; no-op if stale/missing. */\nexport function loadModeEnv(mode: DbMode, options: LoadModeEnvOptions = {}): void {\n const resolved = resolveRoot(options.root);\n if (!existsSync(leasePath(resolved, mode))) return;\n\n const file = envPath(resolved, mode);\n if (!existsSync(file)) return;\n\n const overwrite = options.overwrite === true;\n for (const line of readFileSync(file, \"utf8\").split(\"\\n\")) {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith(\"#\")) continue;\n const eq = trimmed.indexOf(\"=\");\n if (eq <= 0) continue;\n const key = trimmed.slice(0, eq);\n const value = trimmed.slice(eq + 1);\n if (overwrite || process.env[key] === undefined) {\n process.env[key] = value;\n }\n }\n}\n"],"mappings":";;;AAWA,SAAgB,qBACd,eACoB;CACpB,IAAI,OAAO,kBAAkB,YAAY,kBAAkB,KAAA,GACzD,OAAO,EAAE,MAAM,cAAc;CAE/B,OAAO;AACT;;AAGA,SAAgB,YAAY,MAAc,UAA8B,CAAC,GAAS;CAChF,MAAM,WAAW,YAAY,QAAQ,IAAI;CACzC,IAAI,CAAC,WAAW,UAAU,UAAU,IAAI,CAAC,GAAG;CAE5C,MAAM,OAAO,QAAQ,UAAU,IAAI;CACnC,IAAI,CAAC,WAAW,IAAI,GAAG;CAEvB,MAAM,YAAY,QAAQ,cAAc;CACxC,KAAK,MAAM,QAAQ,aAAa,MAAM,MAAM,CAAC,CAAC,MAAM,IAAI,GAAG;EACzD,MAAM,UAAU,KAAK,KAAK;EAC1B,IAAI,CAAC,WAAW,QAAQ,WAAW,GAAG,GAAG;EACzC,MAAM,KAAK,QAAQ,QAAQ,GAAG;EAC9B,IAAI,MAAM,GAAG;EACb,MAAM,MAAM,QAAQ,MAAM,GAAG,EAAE;EAC/B,MAAM,QAAQ,QAAQ,MAAM,KAAK,CAAC;EAClC,IAAI,aAAa,QAAQ,IAAI,SAAS,KAAA,GACpC,QAAQ,IAAI,OAAO;CAEvB;AACF"}
@@ -1,4 +1,4 @@
1
- import { n as normalizeLoadOptions, t as loadModeEnv } from "./load-mode-env-C8gy4v9V.mjs";
1
+ import { n as normalizeLoadOptions, t as loadModeEnv } from "./load-mode-env-Ce9ujisN.mjs";
2
2
  //#region src/adapters/load-test-env.ts
3
3
  /**
4
4
  * Load `.cedarpg/test.env` into `process.env` (worker-side).
@@ -15,4 +15,4 @@ function loadTestEnv(rootOrOptions) {
15
15
  //#endregion
16
16
  export { loadTestEnv as t };
17
17
 
18
- //# sourceMappingURL=load-test-env-C34wpkIX.mjs.map
18
+ //# sourceMappingURL=load-test-env-BqtA6V-d.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"load-test-env-C34wpkIX.mjs","names":[],"sources":["../src/adapters/load-test-env.ts"],"sourcesContent":["import { loadModeEnv, normalizeLoadOptions, type LoadModeEnvOptions } from \"./load-mode-env.ts\";\n\nexport type LoadTestEnvOptions = LoadModeEnvOptions;\n\n/**\n * Load `.cedarpg/test.env` into `process.env` (worker-side).\n *\n * Jest (and optional Vitest `setupFiles`) run tests in a different process than\n * `globalSetup`, so `setEnv` in acquire does not reach workers — the env file does.\n *\n * No-ops unless a matching `test.json` lease exists, so a leftover env after dispose\n * cannot inject a dropped DATABASE_URL.\n */\nexport function loadTestEnv(rootOrOptions?: string | LoadTestEnvOptions): void {\n loadModeEnv(\"test\", normalizeLoadOptions(rootOrOptions));\n}\n"],"mappings":";;;;;;;;;;;AAaA,SAAgB,YAAY,eAAmD;CAC7E,YAAY,QAAQ,qBAAqB,aAAa,CAAC;AACzD"}
1
+ {"version":3,"file":"load-test-env-BqtA6V-d.mjs","names":[],"sources":["../src/adapters/load-test-env.ts"],"sourcesContent":["import { loadModeEnv, normalizeLoadOptions, type LoadModeEnvOptions } from \"./load-mode-env.ts\";\n\nexport type LoadTestEnvOptions = LoadModeEnvOptions;\n\n/**\n * Load `.cedarpg/test.env` into `process.env` (worker-side).\n *\n * Jest (and optional Vitest `setupFiles`) run tests in a different process than\n * `globalSetup`, so `setEnv` in acquire does not reach workers — the env file does.\n *\n * No-ops unless a matching `test.json` lease exists, so a leftover env after dispose\n * cannot inject a dropped DATABASE_URL.\n */\nexport function loadTestEnv(rootOrOptions?: string | LoadTestEnvOptions): void {\n loadModeEnv(\"test\", normalizeLoadOptions(rootOrOptions));\n}\n"],"mappings":";;;;;;;;;;;AAaA,SAAgB,YAAY,eAAmD;CAC7E,YAAY,QAAQ,qBAAqB,aAAa,CAAC;AACzD"}
@@ -1,4 +1,4 @@
1
- const require_load_mode_env = require("./load-mode-env-B0qO9DZx.cjs");
1
+ const require_load_mode_env = require("./load-mode-env-CX9vd56X.cjs");
2
2
  //#region src/adapters/load-test-env.ts
3
3
  /**
4
4
  * Load `.cedarpg/test.env` into `process.env` (worker-side).
@@ -20,4 +20,4 @@ Object.defineProperty(exports, "loadTestEnv", {
20
20
  }
21
21
  });
22
22
 
23
- //# sourceMappingURL=load-test-env-CkdUjTpV.cjs.map
23
+ //# sourceMappingURL=load-test-env-Dcgh6YHV.cjs.map