@dads-framework/postgres 0.0.0-stage → 0.2.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 (160) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +97 -2
  3. package/dist/drizzle.d.ts +9 -0
  4. package/dist/drizzle.d.ts.map +1 -0
  5. package/dist/drizzle.js +2 -0
  6. package/dist/drizzle.js.map +1 -0
  7. package/dist/index.d.ts +13 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +12 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/lib/attributed-pool.d.ts +95 -0
  12. package/dist/lib/attributed-pool.d.ts.map +1 -0
  13. package/dist/lib/attributed-pool.js +128 -0
  14. package/dist/lib/attributed-pool.js.map +1 -0
  15. package/dist/lib/bytea-column.d.ts +37 -0
  16. package/dist/lib/bytea-column.d.ts.map +1 -0
  17. package/dist/lib/bytea-column.js +20 -0
  18. package/dist/lib/bytea-column.js.map +1 -0
  19. package/dist/lib/checked-out-client-errors.d.ts +22 -0
  20. package/dist/lib/checked-out-client-errors.d.ts.map +1 -0
  21. package/dist/lib/checked-out-client-errors.js +28 -0
  22. package/dist/lib/checked-out-client-errors.js.map +1 -0
  23. package/dist/lib/connect-postgres-client.d.ts +16 -0
  24. package/dist/lib/connect-postgres-client.d.ts.map +1 -0
  25. package/dist/lib/connect-postgres-client.js +14 -0
  26. package/dist/lib/connect-postgres-client.js.map +1 -0
  27. package/dist/lib/counting-client.d.ts +39 -0
  28. package/dist/lib/counting-client.d.ts.map +1 -0
  29. package/dist/lib/counting-client.js +102 -0
  30. package/dist/lib/counting-client.js.map +1 -0
  31. package/dist/lib/create-postgres-connection.d.ts +65 -0
  32. package/dist/lib/create-postgres-connection.d.ts.map +1 -0
  33. package/dist/lib/create-postgres-connection.js +68 -0
  34. package/dist/lib/create-postgres-connection.js.map +1 -0
  35. package/dist/lib/event-actor-columns.d.ts +49 -0
  36. package/dist/lib/event-actor-columns.d.ts.map +1 -0
  37. package/dist/lib/event-actor-columns.js +37 -0
  38. package/dist/lib/event-actor-columns.js.map +1 -0
  39. package/dist/lib/inet-column.d.ts +37 -0
  40. package/dist/lib/inet-column.d.ts.map +1 -0
  41. package/dist/lib/inet-column.js +17 -0
  42. package/dist/lib/inet-column.js.map +1 -0
  43. package/dist/lib/load-page-and-total.d.ts +16 -0
  44. package/dist/lib/load-page-and-total.d.ts.map +1 -0
  45. package/dist/lib/load-page-and-total.js +16 -0
  46. package/dist/lib/load-page-and-total.js.map +1 -0
  47. package/dist/lib/postgres-pool-laws.d.ts +6 -0
  48. package/dist/lib/postgres-pool-laws.d.ts.map +1 -0
  49. package/dist/lib/postgres-pool-laws.js +58 -0
  50. package/dist/lib/postgres-pool-laws.js.map +1 -0
  51. package/dist/lib/synced-rows.d.ts +97 -0
  52. package/dist/lib/synced-rows.d.ts.map +1 -0
  53. package/dist/lib/synced-rows.js +158 -0
  54. package/dist/lib/synced-rows.js.map +1 -0
  55. package/dist/lib/unique-violation.d.ts +10 -0
  56. package/dist/lib/unique-violation.d.ts.map +1 -0
  57. package/dist/lib/unique-violation.js +24 -0
  58. package/dist/lib/unique-violation.js.map +1 -0
  59. package/dist/lib/update-at-row-version.d.ts +31 -0
  60. package/dist/lib/update-at-row-version.d.ts.map +1 -0
  61. package/dist/lib/update-at-row-version.js +14 -0
  62. package/dist/lib/update-at-row-version.js.map +1 -0
  63. package/dist/lib/xid8-column.d.ts +38 -0
  64. package/dist/lib/xid8-column.d.ts.map +1 -0
  65. package/dist/lib/xid8-column.js +18 -0
  66. package/dist/lib/xid8-column.js.map +1 -0
  67. package/dist/postgres.tsbuildinfo +1 -0
  68. package/dist/testing/create-test-pool.d.ts +35 -0
  69. package/dist/testing/create-test-pool.d.ts.map +1 -0
  70. package/dist/testing/create-test-pool.js +47 -0
  71. package/dist/testing/create-test-pool.js.map +1 -0
  72. package/dist/testing/deterministic-uuid.d.ts +2 -0
  73. package/dist/testing/deterministic-uuid.d.ts.map +1 -0
  74. package/dist/testing/deterministic-uuid.js +20 -0
  75. package/dist/testing/deterministic-uuid.js.map +1 -0
  76. package/dist/testing/global-setup/container-tier-semaphore.d.ts +51 -0
  77. package/dist/testing/global-setup/container-tier-semaphore.d.ts.map +1 -0
  78. package/dist/testing/global-setup/container-tier-semaphore.js +129 -0
  79. package/dist/testing/global-setup/container-tier-semaphore.js.map +1 -0
  80. package/dist/testing/global-setup/decide-shared-test-postgres.d.ts +51 -0
  81. package/dist/testing/global-setup/decide-shared-test-postgres.d.ts.map +1 -0
  82. package/dist/testing/global-setup/decide-shared-test-postgres.js +109 -0
  83. package/dist/testing/global-setup/decide-shared-test-postgres.js.map +1 -0
  84. package/dist/testing/global-setup/index.d.ts +16 -0
  85. package/dist/testing/global-setup/index.d.ts.map +1 -0
  86. package/dist/testing/global-setup/index.js +151 -0
  87. package/dist/testing/global-setup/index.js.map +1 -0
  88. package/dist/testing/global-setup/refuse-disabled-container-cleanup.d.ts +34 -0
  89. package/dist/testing/global-setup/refuse-disabled-container-cleanup.d.ts.map +1 -0
  90. package/dist/testing/global-setup/refuse-disabled-container-cleanup.js +45 -0
  91. package/dist/testing/global-setup/refuse-disabled-container-cleanup.js.map +1 -0
  92. package/dist/testing/global-setup/refuse-low-memory-runs.d.ts +176 -0
  93. package/dist/testing/global-setup/refuse-low-memory-runs.d.ts.map +1 -0
  94. package/dist/testing/global-setup/refuse-low-memory-runs.js +388 -0
  95. package/dist/testing/global-setup/refuse-low-memory-runs.js.map +1 -0
  96. package/dist/testing/global-setup/refuse-slow-local-test-mode.d.ts +5 -0
  97. package/dist/testing/global-setup/refuse-slow-local-test-mode.d.ts.map +1 -0
  98. package/dist/testing/global-setup/refuse-slow-local-test-mode.js +18 -0
  99. package/dist/testing/global-setup/refuse-slow-local-test-mode.js.map +1 -0
  100. package/dist/testing/global-setup/refuse-stacked-container-runs.d.ts +106 -0
  101. package/dist/testing/global-setup/refuse-stacked-container-runs.d.ts.map +1 -0
  102. package/dist/testing/global-setup/refuse-stacked-container-runs.js +284 -0
  103. package/dist/testing/global-setup/refuse-stacked-container-runs.js.map +1 -0
  104. package/dist/testing/global-setup/remove-stale-testcontainers.d.ts +33 -0
  105. package/dist/testing/global-setup/remove-stale-testcontainers.d.ts.map +1 -0
  106. package/dist/testing/global-setup/remove-stale-testcontainers.js +165 -0
  107. package/dist/testing/global-setup/remove-stale-testcontainers.js.map +1 -0
  108. package/dist/testing/global-setup/retired-database-touches.d.ts +16 -0
  109. package/dist/testing/global-setup/retired-database-touches.d.ts.map +1 -0
  110. package/dist/testing/global-setup/retired-database-touches.js +73 -0
  111. package/dist/testing/global-setup/retired-database-touches.js.map +1 -0
  112. package/dist/testing/global-setup/schema-keyed-coverage.d.ts +56 -0
  113. package/dist/testing/global-setup/schema-keyed-coverage.d.ts.map +1 -0
  114. package/dist/testing/global-setup/schema-keyed-coverage.js +84 -0
  115. package/dist/testing/global-setup/schema-keyed-coverage.js.map +1 -0
  116. package/dist/testing/global-setup/skip-unless-container-tests.d.ts +31 -0
  117. package/dist/testing/global-setup/skip-unless-container-tests.d.ts.map +1 -0
  118. package/dist/testing/global-setup/skip-unless-container-tests.js +33 -0
  119. package/dist/testing/global-setup/skip-unless-container-tests.js.map +1 -0
  120. package/dist/testing/global-setup/start-migrated-template-postgres.d.ts +20 -0
  121. package/dist/testing/global-setup/start-migrated-template-postgres.d.ts.map +1 -0
  122. package/dist/testing/global-setup/start-migrated-template-postgres.js +53 -0
  123. package/dist/testing/global-setup/start-migrated-template-postgres.js.map +1 -0
  124. package/dist/testing/global-setup/verify-schema-keyed-suite.d.ts +43 -0
  125. package/dist/testing/global-setup/verify-schema-keyed-suite.d.ts.map +1 -0
  126. package/dist/testing/global-setup/verify-schema-keyed-suite.js +201 -0
  127. package/dist/testing/global-setup/verify-schema-keyed-suite.js.map +1 -0
  128. package/dist/testing/global-setup/worktree-identity.d.ts +21 -0
  129. package/dist/testing/global-setup/worktree-identity.d.ts.map +1 -0
  130. package/dist/testing/global-setup/worktree-identity.js +30 -0
  131. package/dist/testing/global-setup/worktree-identity.js.map +1 -0
  132. package/dist/testing/index.d.ts +11 -0
  133. package/dist/testing/index.d.ts.map +1 -0
  134. package/dist/testing/index.js +11 -0
  135. package/dist/testing/index.js.map +1 -0
  136. package/dist/testing/rehearsal-postgres.d.ts +20 -0
  137. package/dist/testing/rehearsal-postgres.d.ts.map +1 -0
  138. package/dist/testing/rehearsal-postgres.js +61 -0
  139. package/dist/testing/rehearsal-postgres.js.map +1 -0
  140. package/dist/testing/start-test-postgres.d.ts +59 -0
  141. package/dist/testing/start-test-postgres.d.ts.map +1 -0
  142. package/dist/testing/start-test-postgres.js +241 -0
  143. package/dist/testing/start-test-postgres.js.map +1 -0
  144. package/dist/testing/test-postgres-storage.d.ts +44 -0
  145. package/dist/testing/test-postgres-storage.d.ts.map +1 -0
  146. package/dist/testing/test-postgres-storage.js +88 -0
  147. package/dist/testing/test-postgres-storage.js.map +1 -0
  148. package/dist/testing/truncate-tables.d.ts +31 -0
  149. package/dist/testing/truncate-tables.d.ts.map +1 -0
  150. package/dist/testing/truncate-tables.js +39 -0
  151. package/dist/testing/truncate-tables.js.map +1 -0
  152. package/dist/testing/violated-foreign-key.d.ts +14 -0
  153. package/dist/testing/violated-foreign-key.d.ts.map +1 -0
  154. package/dist/testing/violated-foreign-key.js +78 -0
  155. package/dist/testing/violated-foreign-key.js.map +1 -0
  156. package/dist/testing/with-database.d.ts +2 -0
  157. package/dist/testing/with-database.d.ts.map +1 -0
  158. package/dist/testing/with-database.js +6 -0
  159. package/dist/testing/with-database.js.map +1 -0
  160. package/package.json +88 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refuse-low-memory-runs.js","sourceRoot":"","sources":["../../../src/testing/global-setup/refuse-low-memory-runs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CA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AAc;YACzF,IAAI,UAAU,CAAC,+BAA+B,CAAC,gDAAgD;KAClG,CAAC;AACJ,CAAC;AAOD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAChD,OAA6B,EAC7B,KAAa,EACb,GAAG,GAA2B,QAAQ,CAAC,GAAG;IAE1C,MAAM,IAAI,GAAG,MAAM,uBAAuB,EAAE,CAAC;IAC7C,MAAM,GAAG,GAAG,qBAAqB,CAAC;QAChC,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,iBAAiB,EAAE,OAAO,CAAC,MAAM,CAAC,UAAU;QAC5C,KAAK;QACL,cAAc,EAAE,IAAI,CAAC,kBAAkB;QACvC,YAAY,EAAE,gBAAgB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,gBAAgB;KAC7D,CAAC,CAAC;IACH,IAAI,GAAG,CAAC,OAAO,KAAK,IAAI;QAAE,OAAO;IACjC,OAAO,CAAC,MAAM,CAAC,UAAU,GAAG,GAAG,CAAC,OAAO,CAAC;IACxC,IAAI,GAAG,CAAC,OAAO,KAAK,IAAI;QAAE,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare const ALLOW_SLOW_TEST_MODE = "ALLOW_SLOW_TEST_MODE";
2
+ export declare const VITEST_ISOLATE = "VITEST_ISOLATE";
3
+ export declare const SLOW_LOCAL_TEST_MODE_MESSAGE: string;
4
+ export declare function refuseSlowLocalTestMode(env: Readonly<Record<string, string | undefined>>): void;
5
+ //# sourceMappingURL=refuse-slow-local-test-mode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refuse-slow-local-test-mode.d.ts","sourceRoot":"","sources":["../../../src/testing/global-setup/refuse-slow-local-test-mode.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,oBAAoB,yBAAyB,CAAC;AAC3D,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAE/C,eAAO,MAAM,4BAA4B,QAIkB,CAAC;AAE5D,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GAChD,IAAI,CAON"}
@@ -0,0 +1,18 @@
1
+ import { CONTAINER_PER_FILE } from "../start-test-postgres.js";
2
+ export const ALLOW_SLOW_TEST_MODE = "ALLOW_SLOW_TEST_MODE";
3
+ export const VITEST_ISOLATE = "VITEST_ISOLATE";
4
+ export const SLOW_LOCAL_TEST_MODE_MESSAGE = "This is the hour-long honesty job, not the local suite.\n" +
5
+ " npm run verify # lint, typecheck, unit, integration, prettier, detect\n" +
6
+ " npm run test:integration # container tier only, shared Postgres\n" +
7
+ "To run the slow path on purpose: ALLOW_SLOW_TEST_MODE=1";
8
+ export function refuseSlowLocalTestMode(env) {
9
+ if (env["CI"] !== undefined)
10
+ return;
11
+ if (env[ALLOW_SLOW_TEST_MODE] === "1")
12
+ return;
13
+ if (env[CONTAINER_PER_FILE] !== "1" && env[VITEST_ISOLATE] !== "1") {
14
+ return;
15
+ }
16
+ throw new Error(SLOW_LOCAL_TEST_MODE_MESSAGE);
17
+ }
18
+ //# sourceMappingURL=refuse-slow-local-test-mode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refuse-slow-local-test-mode.js","sourceRoot":"","sources":["../../../src/testing/global-setup/refuse-slow-local-test-mode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,MAAM,CAAC,MAAM,oBAAoB,GAAG,sBAAsB,CAAC;AAC3D,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAE/C,MAAM,CAAC,MAAM,4BAA4B,GACvC,2DAA2D;IAC3D,wFAAwF;IACxF,wEAAwE;IACxE,yDAAyD,CAAC;AAE5D,MAAM,UAAU,uBAAuB,CACrC,GAAiD;IAEjD,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO;IACpC,IAAI,GAAG,CAAC,oBAAoB,CAAC,KAAK,GAAG;QAAE,OAAO;IAC9C,IAAI,GAAG,CAAC,kBAAkB,CAAC,KAAK,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,KAAK,GAAG,EAAE,CAAC;QACnE,OAAO;IACT,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;AAChD,CAAC"}
@@ -0,0 +1,106 @@
1
+ export { decideContainerTierSemaphore, parseContainerTestRunLock, type ContainerTierSemaphoreDecision, type ContainerTestRunLock, } from "./container-tier-semaphore.js";
2
+ /**
3
+ * A counting semaphore over container-tier runs. The wall against pileups.
4
+ *
5
+ * WHY THIS EXISTS. On 2026-08-02 a root npm script became an inferred Nx target
6
+ * and re-invoked itself, and separately a foreground run that hit its timeout
7
+ * orphaned its process tree so every retry added another full sweep. The box
8
+ * reached ~200 concurrent runs and 74 containers; nothing could finish, so
9
+ * every run looked "slow" rather than "duplicated", which invited more retries.
10
+ * The failure mode is not any one of those bugs — it is that stacking is
11
+ * SILENT. Nothing anywhere said "one of these is already running."
12
+ *
13
+ * WHY IT COUNTS INSTEAD OF REFUSING. The first version allowed exactly one run
14
+ * per machine, which was right when one checkout was the only checkout. With a
15
+ * worktree per initiative, a single writer means an agent's integration run
16
+ * refuses because an unrelated checkout is busy. So the tier now owns N slots
17
+ * (`DADS_TEST_TIER_SLOTS`, default 2): a run takes a free one, and when all
18
+ * are busy it QUEUES rather than dying, printing who it is waiting for and
19
+ * where. The refusal is still there — it is what happens when the wait budget
20
+ * (`DADS_TEST_TIER_WAIT_MS`, default ten minutes) runs out.
21
+ *
22
+ * ONE RUN PER WORKTREE, THOUGH. Two runs in one checkout would share that
23
+ * checkout's migrated template Postgres, so a live slot held by this worktree
24
+ * makes a second run wait however many slots are free.
25
+ *
26
+ * ADVISORY, NOT MANDATORY, AND DELIBERATELY SO. A slot is a pidfile, not an
27
+ * OS lock: a crashed run leaves the file behind, and the next run STEALS it
28
+ * once it sees the holder's pid is gone. A lock that can wedge a repo after a
29
+ * crash would be worse than the pileup it prevents.
30
+ */
31
+ /** The number of container-tier runs this machine allows at once. */
32
+ export declare const CONTAINER_TIER_SLOTS = "DADS_TEST_TIER_SLOTS";
33
+ /** How long a run queues for a slot before refusing. `0` refuses at once. */
34
+ export declare const CONTAINER_TIER_WAIT_MS = "DADS_TEST_TIER_WAIT_MS";
35
+ /**
36
+ * The pid of the `nx` invocation this process belongs to, so the 12 projects
37
+ * of ONE `nx run-many -t test:integration` share a slot instead of fighting
38
+ * over it. Each project gets its own vitest process and its own `globalSetup`,
39
+ * and without this the second project to start would abort the run it is part
40
+ * of — which is exactly what happened the first time this shipped.
41
+ *
42
+ * A direct `vitest run` with no `nx` ancestor gets its own pid, so two of those
43
+ * still see each other as separate runs and the second queues. That is the
44
+ * behaviour we want in both directions.
45
+ */
46
+ export declare function findNxRunProcessId(pid: number, table: ReadonlyMap<number, {
47
+ readonly ppid: number;
48
+ readonly command: string;
49
+ }>): number;
50
+ /** Thrown instead of booting, so the abort is loud and immediate. */
51
+ export declare class ContainerTestRunAlreadyActiveError extends Error {
52
+ constructor(message: string);
53
+ }
54
+ /** The tier's slot directory: `command-test-tier-integration/1.lock …`. */
55
+ export declare function containerTestRunLockDir(tier: string, dir?: string): string;
56
+ /** One slot file. `slot` is 1-based, so the names read as a count. */
57
+ export declare function containerTierSlotPath(tier: string, slot: number, dir?: string): string;
58
+ export declare function containerTierSlotCount(env: Readonly<Record<string, string | undefined>>): number;
59
+ export declare function containerTierWaitBudgetMs(env: Readonly<Record<string, string | undefined>>): number;
60
+ /**
61
+ * Set by a wrapper that already holds this run's slot (`run-integration-gate.ts`)
62
+ * on the projects it starts after its shared vendors have stopped. Those
63
+ * children inherit no shared Postgres URL, and without this they would queue
64
+ * behind their own parent's slot until the wait budget ran out.
65
+ */
66
+ export declare const CONTAINER_TIER_SLOT_HELD = "DADS_TEST_TIER_SLOT_HELD";
67
+ /**
68
+ * The wrapper that starts shared Postgres holds the slot; children inherit
69
+ * the URL (or the held-slot marker) and must not take a second slot with a
70
+ * different nx runId.
71
+ */
72
+ export declare function shouldHoldContainerTestRunLock(env: Readonly<Record<string, string | undefined>>): boolean;
73
+ /** `process.kill(pid, 0)` throws only when the process is gone (or not ours). */
74
+ export declare function processIsAlive(pid: number): boolean;
75
+ export type ContainerTierSlotDeps = {
76
+ readonly readLock: (path: string) => string | null;
77
+ readonly writeLock: (path: string, text: string) => void;
78
+ readonly removeLock: (path: string) => void;
79
+ readonly isAlive: (pid: number) => boolean;
80
+ readonly now: () => Date;
81
+ readonly sleep: (ms: number) => Promise<void>;
82
+ readonly pid: number;
83
+ readonly runId: () => number;
84
+ readonly worktree: () => string;
85
+ readonly log: (line: string) => void;
86
+ };
87
+ export declare function currentNxRunId(): number;
88
+ /**
89
+ * Takes a slot for `tier`, queueing until one frees up, and throws
90
+ * `ContainerTestRunAlreadyActiveError` once the wait budget is spent. Returns
91
+ * the release function, which only removes the file if this process still owns
92
+ * it — a run that had its slot stolen must not delete its successor's.
93
+ */
94
+ export declare function acquireContainerTierSlot(tier: string, options?: {
95
+ readonly dir?: string;
96
+ readonly slots?: number;
97
+ readonly waitBudgetMs?: number;
98
+ readonly deps?: Partial<ContainerTierSlotDeps>;
99
+ /**
100
+ * Runs once, the first time this run is about to take or steal a slot —
101
+ * never for a sibling project that re-enters its run's slot. The memory
102
+ * preflight goes here, so it measures before this run uses anything.
103
+ */
104
+ readonly beforeTake?: () => Promise<void>;
105
+ }): Promise<() => void>;
106
+ //# sourceMappingURL=refuse-stacked-container-runs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refuse-stacked-container-runs.d.ts","sourceRoot":"","sources":["../../../src/testing/global-setup/refuse-stacked-container-runs.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,4BAA4B,EAC5B,yBAAyB,EACzB,KAAK,8BAA8B,EACnC,KAAK,oBAAoB,GAC1B,MAAM,+BAA+B,CAAC;AAevC;;;;;;;;;;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ContainerTierSemaphore, parseContainerTestRunLock, } from "./container-tier-semaphore.js";
2
+ export { decideContainerTierSemaphore, parseContainerTestRunLock, } from "./container-tier-semaphore.js";
3
+ import { execFileSync } from "node:child_process";
4
+ import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync, } from "node:fs";
5
+ import { tmpdir } from "node:os";
6
+ import { join } from "node:path";
7
+ import { SHARED_TEST_POSTGRES_URL } from "../start-test-postgres.js";
8
+ import { currentWorktreePath } from "./worktree-identity.js";
9
+ /**
10
+ * A counting semaphore over container-tier runs. The wall against pileups.
11
+ *
12
+ * WHY THIS EXISTS. On 2026-08-02 a root npm script became an inferred Nx target
13
+ * and re-invoked itself, and separately a foreground run that hit its timeout
14
+ * orphaned its process tree so every retry added another full sweep. The box
15
+ * reached ~200 concurrent runs and 74 containers; nothing could finish, so
16
+ * every run looked "slow" rather than "duplicated", which invited more retries.
17
+ * The failure mode is not any one of those bugs — it is that stacking is
18
+ * SILENT. Nothing anywhere said "one of these is already running."
19
+ *
20
+ * WHY IT COUNTS INSTEAD OF REFUSING. The first version allowed exactly one run
21
+ * per machine, which was right when one checkout was the only checkout. With a
22
+ * worktree per initiative, a single writer means an agent's integration run
23
+ * refuses because an unrelated checkout is busy. So the tier now owns N slots
24
+ * (`DADS_TEST_TIER_SLOTS`, default 2): a run takes a free one, and when all
25
+ * are busy it QUEUES rather than dying, printing who it is waiting for and
26
+ * where. The refusal is still there — it is what happens when the wait budget
27
+ * (`DADS_TEST_TIER_WAIT_MS`, default ten minutes) runs out.
28
+ *
29
+ * ONE RUN PER WORKTREE, THOUGH. Two runs in one checkout would share that
30
+ * checkout's migrated template Postgres, so a live slot held by this worktree
31
+ * makes a second run wait however many slots are free.
32
+ *
33
+ * ADVISORY, NOT MANDATORY, AND DELIBERATELY SO. A slot is a pidfile, not an
34
+ * OS lock: a crashed run leaves the file behind, and the next run STEALS it
35
+ * once it sees the holder's pid is gone. A lock that can wedge a repo after a
36
+ * crash would be worse than the pileup it prevents.
37
+ */
38
+ /** The number of container-tier runs this machine allows at once. */
39
+ export const CONTAINER_TIER_SLOTS = "DADS_TEST_TIER_SLOTS";
40
+ /** How long a run queues for a slot before refusing. `0` refuses at once. */
41
+ export const CONTAINER_TIER_WAIT_MS = "DADS_TEST_TIER_WAIT_MS";
42
+ const DEFAULT_SLOTS = 2;
43
+ const DEFAULT_WAIT_BUDGET_MS = 600_000;
44
+ const POLL_INTERVAL_MS = 2_000;
45
+ const ANNOUNCE_INTERVAL_MS = 15_000;
46
+ /**
47
+ * The pid of the `nx` invocation this process belongs to, so the 12 projects
48
+ * of ONE `nx run-many -t test:integration` share a slot instead of fighting
49
+ * over it. Each project gets its own vitest process and its own `globalSetup`,
50
+ * and without this the second project to start would abort the run it is part
51
+ * of — which is exactly what happened the first time this shipped.
52
+ *
53
+ * A direct `vitest run` with no `nx` ancestor gets its own pid, so two of those
54
+ * still see each other as separate runs and the second queues. That is the
55
+ * behaviour we want in both directions.
56
+ */
57
+ export function findNxRunProcessId(pid, table) {
58
+ let current = pid;
59
+ let root = pid;
60
+ const seen = new Set();
61
+ while (!seen.has(current)) {
62
+ seen.add(current);
63
+ const entry = table.get(current);
64
+ if (entry === undefined)
65
+ break;
66
+ if (/\bnx\b/.test(entry.command))
67
+ root = current;
68
+ if (entry.ppid <= 1)
69
+ break;
70
+ current = entry.ppid;
71
+ }
72
+ return root;
73
+ }
74
+ /** A release that owns nothing. Named so it is not an empty arrow literal. */
75
+ const noRelease = () => undefined;
76
+ /** Thrown instead of booting, so the abort is loud and immediate. */
77
+ export class ContainerTestRunAlreadyActiveError extends Error {
78
+ constructor(message) {
79
+ super(message);
80
+ this.name = "ContainerTestRunAlreadyActiveError";
81
+ }
82
+ }
83
+ /** The tier's slot directory: `command-test-tier-integration/1.lock …`. */
84
+ export function containerTestRunLockDir(tier, dir = tmpdir()) {
85
+ return join(dir, `command-test-tier-${tier}`);
86
+ }
87
+ /** One slot file. `slot` is 1-based, so the names read as a count. */
88
+ export function containerTierSlotPath(tier, slot, dir = tmpdir()) {
89
+ return join(containerTestRunLockDir(tier, dir), `${String(slot)}.lock`);
90
+ }
91
+ /** A knob that is set to nonsense is a mistake worth saying out loud. */
92
+ function readNumericSetting(env, name, fallback, minimum) {
93
+ const raw = env[name];
94
+ if (raw === undefined || raw.trim().length === 0)
95
+ return fallback;
96
+ const value = Number(raw);
97
+ if (!Number.isInteger(value) || value < minimum) {
98
+ throw new Error(`${name} must be an integer of at least ${String(minimum)} — got "${raw}"`);
99
+ }
100
+ return value;
101
+ }
102
+ export function containerTierSlotCount(env) {
103
+ return readNumericSetting(env, CONTAINER_TIER_SLOTS, DEFAULT_SLOTS, 1);
104
+ }
105
+ export function containerTierWaitBudgetMs(env) {
106
+ return readNumericSetting(env, CONTAINER_TIER_WAIT_MS, DEFAULT_WAIT_BUDGET_MS, 0);
107
+ }
108
+ /**
109
+ * Set by a wrapper that already holds this run's slot (`run-integration-gate.ts`)
110
+ * on the projects it starts after its shared vendors have stopped. Those
111
+ * children inherit no shared Postgres URL, and without this they would queue
112
+ * behind their own parent's slot until the wait budget ran out.
113
+ */
114
+ export const CONTAINER_TIER_SLOT_HELD = "DADS_TEST_TIER_SLOT_HELD";
115
+ /**
116
+ * The wrapper that starts shared Postgres holds the slot; children inherit
117
+ * the URL (or the held-slot marker) and must not take a second slot with a
118
+ * different nx runId.
119
+ */
120
+ export function shouldHoldContainerTestRunLock(env) {
121
+ if (env["CI"] !== undefined)
122
+ return false;
123
+ if (env[CONTAINER_TIER_SLOT_HELD] === "1")
124
+ return false;
125
+ const inherited = env[SHARED_TEST_POSTGRES_URL];
126
+ return inherited === undefined || inherited.length === 0;
127
+ }
128
+ /** `process.kill(pid, 0)` throws only when the process is gone (or not ours). */
129
+ export function processIsAlive(pid) {
130
+ try {
131
+ process.kill(pid, 0);
132
+ return true;
133
+ }
134
+ catch (error) {
135
+ // EPERM means it exists but belongs to another user — still alive.
136
+ return (typeof error === "object" &&
137
+ error !== null &&
138
+ "code" in error &&
139
+ error.code === "EPERM");
140
+ }
141
+ }
142
+ /** Reads the process table once, so `findNxRunProcessId` has something to walk. */
143
+ function processTable() {
144
+ const table = new Map();
145
+ try {
146
+ const text = execFileSync("ps", ["-eo", "pid=,ppid=,command="], {
147
+ encoding: "utf8",
148
+ timeout: 4000,
149
+ });
150
+ for (const line of text.split("\n")) {
151
+ const match = /^\s*(\d+)\s+(\d+)\s+(.*)$/.exec(line);
152
+ if (match === null)
153
+ continue;
154
+ table.set(Number(match[1]), {
155
+ ppid: Number(match[2]),
156
+ command: match[3] ?? "",
157
+ });
158
+ }
159
+ }
160
+ catch {
161
+ // No `ps` (or it timed out): fall back to a per-process run id, which is
162
+ // stricter rather than looser — worst case a sibling waits its turn.
163
+ }
164
+ return table;
165
+ }
166
+ const realDeps = {
167
+ readLock: (path) => (existsSync(path) ? readFileSync(path, "utf8") : null),
168
+ writeLock: (path, text) => {
169
+ mkdirSync(join(path, ".."), { recursive: true });
170
+ writeFileSync(path, text);
171
+ },
172
+ removeLock: (path) => {
173
+ rmSync(path, { force: true });
174
+ },
175
+ isAlive: processIsAlive,
176
+ now: () => new Date(),
177
+ sleep: (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
178
+ pid: process.pid,
179
+ runId: () => findNxRunProcessId(process.pid, processTable()),
180
+ worktree: currentWorktreePath,
181
+ log: (line) => process.stdout.write(`${line}\n`),
182
+ };
183
+ export function currentNxRunId() {
184
+ return findNxRunProcessId(process.pid, processTable());
185
+ }
186
+ function readSlot(deps, path) {
187
+ const text = deps.readLock(path);
188
+ return text === null ? null : parseContainerTestRunLock(text);
189
+ }
190
+ /**
191
+ * Takes a slot for `tier`, queueing until one frees up, and throws
192
+ * `ContainerTestRunAlreadyActiveError` once the wait budget is spent. Returns
193
+ * the release function, which only removes the file if this process still owns
194
+ * it — a run that had its slot stolen must not delete its successor's.
195
+ */
196
+ export async function acquireContainerTierSlot(tier, options = {}) {
197
+ const deps = { ...realDeps, ...options.deps };
198
+ const slotCount = options.slots ?? containerTierSlotCount(process.env);
199
+ return waitForSlot({
200
+ tier,
201
+ deps,
202
+ dir: options.dir,
203
+ paths: Array.from({ length: slotCount }, (_unused, index) => containerTierSlotPath(tier, index + 1, options.dir)),
204
+ runId: deps.runId(),
205
+ worktree: deps.worktree(),
206
+ waitBudgetMs: options.waitBudgetMs ?? containerTierWaitBudgetMs(process.env),
207
+ beforeTake: options.beforeTake,
208
+ });
209
+ }
210
+ async function waitForSlot(search) {
211
+ const { deps, paths, tier, runId, worktree, waitBudgetMs } = search;
212
+ const logWait = createWaitLogger(deps.log);
213
+ let waitedMs = 0;
214
+ let beforeTake = search.beforeTake;
215
+ for (;;) {
216
+ const decision = decideContainerTierSemaphore({
217
+ slots: paths.map((path) => readSlot(deps, path)),
218
+ isAlive: deps.isAlive,
219
+ now: deps.now(),
220
+ tier,
221
+ runId,
222
+ worktree,
223
+ waitedMs,
224
+ waitBudgetMs,
225
+ });
226
+ // A sibling project of the same run already holds a slot: nothing to
227
+ // write, and nothing to release — the project that took it owns teardown.
228
+ if (decision.action === "reenter")
229
+ return noRelease;
230
+ if (decision.action === "abort") {
231
+ throw new ContainerTestRunAlreadyActiveError(decision.message);
232
+ }
233
+ if (decision.action === "wait") {
234
+ logWait(decision.message, waitedMs);
235
+ }
236
+ else if (beforeTake !== undefined) {
237
+ // The hook may wait; the slots can change meanwhile, so decide again.
238
+ await beforeTake();
239
+ beforeTake = undefined;
240
+ continue;
241
+ }
242
+ else {
243
+ const release = tryTakeSlot(tier, decision, search);
244
+ if (release !== null)
245
+ return release;
246
+ }
247
+ await deps.sleep(POLL_INTERVAL_MS);
248
+ waitedMs += POLL_INTERVAL_MS;
249
+ }
250
+ }
251
+ function createWaitLogger(log) {
252
+ let announcedAtMs = null;
253
+ return (message, waitedMs) => {
254
+ if (announcedAtMs !== null &&
255
+ waitedMs - announcedAtMs < ANNOUNCE_INTERVAL_MS)
256
+ return;
257
+ log(message);
258
+ announcedAtMs = waitedMs;
259
+ };
260
+ }
261
+ function tryTakeSlot(tier, decision, context) {
262
+ const { runId, worktree, dir, deps } = context;
263
+ if (decision.action === "steal")
264
+ deps.log(decision.message);
265
+ const path = containerTierSlotPath(tier, decision.slot, dir);
266
+ const mine = {
267
+ pid: deps.pid,
268
+ runId,
269
+ tier,
270
+ worktree,
271
+ startedAt: deps.now().toISOString(),
272
+ };
273
+ deps.writeLock(path, JSON.stringify(mine));
274
+ // Two runs can pick the same slot in the same instant; the file says which
275
+ // one ended up with it. The loser waits a tick and picks again.
276
+ if (readSlot(deps, path)?.pid === deps.pid) {
277
+ return () => {
278
+ if (readSlot(deps, path)?.pid === deps.pid)
279
+ deps.removeLock(path);
280
+ };
281
+ }
282
+ return null;
283
+ }
284
+ //# sourceMappingURL=refuse-stacked-container-runs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refuse-stacked-container-runs.js","sourceRoot":"","sources":["../../../src/testing/global-setup/refuse-stacked-container-runs.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,yBAAyB,GAG1B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,4BAA4B,EAC5B,yBAAyB,GAG1B,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACL,UAAU,EACV,SAAS,EACT,YAAY,EACZ,MAAM,EACN,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,qEAAqE;AACrE,MAAM,CAAC,MAAM,oBAAoB,GAAG,sBAAsB,CAAC;AAC3D,6EAA6E;AAC7E,MAAM,CAAC,MAAM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}
@@ -0,0 +1,33 @@
1
+ /** How old a container must be before the sweep will treat it as a corpse. */
2
+ export declare const STALE_AFTER_MS: number;
3
+ /** A harness-started container, as the sweep needs to see it. */
4
+ export type TestcontainersContainer = {
5
+ readonly id: string;
6
+ readonly image: string;
7
+ readonly sessionId: string;
8
+ readonly isReaper: boolean;
9
+ /** Stopped containers are corpses too, and `docker ps` cannot see them. */
10
+ readonly running: boolean;
11
+ /** Creation, not start: a container that never started still has an age. */
12
+ readonly createdAt: Date;
13
+ };
14
+ /** The Docker calls the sweep makes — a port, so the logic tests against a fake. */
15
+ export type DockerContainerClient = {
16
+ listTestcontainersContainers: () => Promise<readonly TestcontainersContainer[]>;
17
+ remove: (id: string) => Promise<void>;
18
+ };
19
+ export type RemovedTestcontainersReport = {
20
+ readonly removed: number;
21
+ readonly failed: number;
22
+ readonly sessions: readonly string[];
23
+ readonly unavailable: boolean;
24
+ };
25
+ /** Pure: which of these containers are corpses? */
26
+ export declare function selectStaleTestcontainers(containers: readonly TestcontainersContainer[], now: Date): readonly TestcontainersContainer[];
27
+ /** Remove the corpses. Never throws: housekeeping does not fail a test run. */
28
+ export declare function removeStaleTestcontainers(client: DockerContainerClient, now: Date): Promise<RemovedTestcontainersReport>;
29
+ /** The one line a sweep is worth, or nothing at all when it found nothing. */
30
+ export declare function describeRemovedTestcontainers(report: RemovedTestcontainersReport): string | null;
31
+ /** The real Docker, driven through its CLI so the harness gains no dependency. */
32
+ export declare function dockerCli(): DockerContainerClient;
33
+ //# sourceMappingURL=remove-stale-testcontainers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove-stale-testcontainers.d.ts","sourceRoot":"","sources":["../../../src/testing/global-setup/remove-stale-testcontainers.ts"],"names":[],"mappings":"AA4CA,8EAA8E;AAC9E,eAAO,MAAM,cAAc,QAAc,CAAC;AAE1C,iEAAiE;AACjE,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,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