@jam-overture/loom 0.1.0 → 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 (290) hide show
  1. package/README.md +3 -1
  2. package/dist/application/application.d.ts +109 -0
  3. package/dist/application/application.js +97 -0
  4. package/dist/application/memory.d.ts +20 -0
  5. package/dist/application/memory.js +79 -0
  6. package/dist/application/store.d.ts +101 -0
  7. package/dist/application/store.js +25 -0
  8. package/dist/audience/audience.d.ts +36 -0
  9. package/dist/audience/audience.js +41 -0
  10. package/dist/cli/templates.js +19 -0
  11. package/dist/data/plan.js +0 -0
  12. package/dist/data/resolution.d.ts +23 -1
  13. package/dist/data/resolve.d.ts +30 -3
  14. package/dist/data/resolve.js +11 -3
  15. package/dist/ids.d.ts +10 -0
  16. package/dist/ids.js +11 -1
  17. package/dist/index.d.ts +1 -0
  18. package/dist/index.js +1 -0
  19. package/dist/patch.d.ts +54 -0
  20. package/dist/patch.js +44 -0
  21. package/dist/project/closing.d.ts +51 -0
  22. package/dist/project/closing.js +53 -0
  23. package/dist/project/memory.d.ts +20 -0
  24. package/dist/project/memory.js +97 -0
  25. package/dist/project/project.d.ts +90 -0
  26. package/dist/project/project.js +91 -0
  27. package/dist/project/store.d.ts +135 -0
  28. package/dist/project/store.js +41 -0
  29. package/dist/registered.d.ts +64 -0
  30. package/dist/registered.js +118 -0
  31. package/dist/render/behaviour-adjust.d.ts +11 -19
  32. package/dist/render/behaviour-adjust.js +75 -21
  33. package/dist/render/behaviour-present.d.ts +8 -0
  34. package/dist/render/behaviour-present.js +57 -6
  35. package/dist/render/behaviour.d.ts +98 -17
  36. package/dist/render/behaviour.js +91 -26
  37. package/dist/render/control-name.d.ts +68 -0
  38. package/dist/render/control-name.js +37 -0
  39. package/dist/render/diagnostics.d.ts +72 -0
  40. package/dist/render/diagnostics.js +7 -0
  41. package/dist/render/index.d.ts +2 -0
  42. package/dist/render/index.js +2 -0
  43. package/dist/render/reads.d.ts +11 -0
  44. package/dist/render/reads.js +12 -1
  45. package/dist/render/render.js +102 -7
  46. package/dist/render/slots.d.ts +52 -0
  47. package/dist/render/slots.js +24 -0
  48. package/dist/render/theme.d.ts +54 -1
  49. package/dist/render/theme.js +23 -1
  50. package/dist/render/unshown.d.ts +152 -0
  51. package/dist/render/unshown.js +80 -0
  52. package/dist/runtime/analysis.d.ts +94 -9
  53. package/dist/runtime/analysis.js +54 -9
  54. package/dist/runtime/assessment.d.ts +36 -2
  55. package/dist/runtime/assessment.js +27 -2
  56. package/dist/runtime/checks.d.ts +148 -0
  57. package/dist/runtime/checks.js +112 -0
  58. package/dist/runtime/disposition.d.ts +96 -0
  59. package/dist/runtime/disposition.js +46 -0
  60. package/dist/runtime/gate.js +22 -0
  61. package/dist/runtime/index.d.ts +3 -0
  62. package/dist/runtime/index.js +3 -0
  63. package/dist/runtime/irreversibility.d.ts +64 -0
  64. package/dist/runtime/irreversibility.js +45 -0
  65. package/dist/runtime/pipeline.d.ts +43 -0
  66. package/dist/runtime/pipeline.js +10 -2
  67. package/dist/runtime/policy-change.d.ts +93 -0
  68. package/dist/runtime/policy-change.js +299 -0
  69. package/dist/runtime/policy-log.d.ts +406 -0
  70. package/dist/runtime/policy-log.js +285 -0
  71. package/dist/runtime/reversibility.d.ts +11 -9
  72. package/dist/runtime/stakes.d.ts +129 -1
  73. package/dist/runtime/stakes.js +240 -26
  74. package/dist/runtime/vocabulary.d.ts +164 -7
  75. package/dist/runtime/vocabulary.js +181 -8
  76. package/dist/sdk/audit.d.ts +174 -3
  77. package/dist/sdk/audit.js +176 -17
  78. package/dist/sdk/catalogue.d.ts +9 -1
  79. package/dist/sdk/conformance.d.ts +37 -3
  80. package/dist/sdk/conformance.js +25 -4
  81. package/dist/sdk/definition.d.ts +65 -0
  82. package/dist/sdk/definition.js +22 -0
  83. package/dist/sdk/registry.d.ts +29 -2
  84. package/dist/sdk/registry.js +63 -1
  85. package/dist/signals/action-change.d.ts +507 -0
  86. package/dist/signals/action-change.js +265 -0
  87. package/dist/signals/action.d.ts +331 -0
  88. package/dist/signals/action.js +182 -0
  89. package/dist/signals/applied-window.contract.d.ts +23 -0
  90. package/dist/signals/applied-window.contract.js +160 -0
  91. package/dist/signals/arriving.d.ts +210 -0
  92. package/dist/signals/arriving.js +133 -0
  93. package/dist/signals/audiences.d.ts +528 -0
  94. package/dist/signals/audiences.js +255 -0
  95. package/dist/signals/broadcast.d.ts +8 -2
  96. package/dist/signals/broadcast.js +58 -8
  97. package/dist/signals/change.d.ts +378 -0
  98. package/dist/signals/change.js +327 -0
  99. package/dist/signals/collect.d.ts +41 -0
  100. package/dist/signals/collect.js +88 -7
  101. package/dist/signals/copy-change.d.ts +553 -0
  102. package/dist/signals/copy-change.js +377 -0
  103. package/dist/signals/copy.d.ts +337 -0
  104. package/dist/signals/copy.js +211 -0
  105. package/dist/signals/counters.d.ts +46 -0
  106. package/dist/signals/counters.js +102 -0
  107. package/dist/signals/deliver.d.ts +23 -4
  108. package/dist/signals/deliver.js +34 -6
  109. package/dist/signals/deployment-change.d.ts +371 -0
  110. package/dist/signals/deployment-change.js +268 -0
  111. package/dist/signals/deployment.d.ts +265 -0
  112. package/dist/signals/deployment.js +152 -0
  113. package/dist/signals/door.d.ts +92 -0
  114. package/dist/signals/door.js +53 -0
  115. package/dist/signals/fold.d.ts +10 -0
  116. package/dist/signals/fold.js +5 -1
  117. package/dist/signals/form-action.d.ts +302 -0
  118. package/dist/signals/form-action.js +169 -0
  119. package/dist/signals/form-copy.d.ts +523 -0
  120. package/dist/signals/form-copy.js +346 -0
  121. package/dist/signals/forms.d.ts +247 -0
  122. package/dist/signals/forms.js +147 -0
  123. package/dist/signals/funnel-change.d.ts +548 -0
  124. package/dist/signals/funnel-change.js +361 -0
  125. package/dist/signals/funnel.d.ts +532 -0
  126. package/dist/signals/funnel.js +216 -0
  127. package/dist/signals/health.d.ts +497 -0
  128. package/dist/signals/health.js +361 -0
  129. package/dist/signals/index.d.ts +41 -0
  130. package/dist/signals/index.js +41 -0
  131. package/dist/signals/ingest.d.ts +56 -1
  132. package/dist/signals/ingest.js +91 -1
  133. package/dist/signals/journal.d.ts +11 -0
  134. package/dist/signals/kinds.d.ts +8 -6
  135. package/dist/signals/kinds.js +14 -6
  136. package/dist/signals/library-action.d.ts +430 -0
  137. package/dist/signals/library-action.js +336 -0
  138. package/dist/signals/library-change.d.ts +477 -0
  139. package/dist/signals/library-change.js +335 -0
  140. package/dist/signals/library-copy-change.d.ts +498 -0
  141. package/dist/signals/library-copy-change.js +476 -0
  142. package/dist/signals/library-pace.d.ts +319 -0
  143. package/dist/signals/library-pace.js +305 -0
  144. package/dist/signals/library-reach-change.d.ts +636 -0
  145. package/dist/signals/library-reach-change.js +534 -0
  146. package/dist/signals/library-reach.d.ts +377 -0
  147. package/dist/signals/library-reach.js +227 -0
  148. package/dist/signals/library-word-reach-change.d.ts +567 -0
  149. package/dist/signals/library-word-reach-change.js +568 -0
  150. package/dist/signals/library.d.ts +306 -0
  151. package/dist/signals/library.js +178 -0
  152. package/dist/signals/memory.d.ts +9 -0
  153. package/dist/signals/memory.js +105 -14
  154. package/dist/signals/migrate.d.ts +17 -2
  155. package/dist/signals/migrate.js +122 -5
  156. package/dist/signals/notice.d.ts +334 -0
  157. package/dist/signals/notice.js +228 -0
  158. package/dist/signals/pace-change.d.ts +501 -0
  159. package/dist/signals/pace-change.js +310 -0
  160. package/dist/signals/pace.d.ts +296 -0
  161. package/dist/signals/pace.js +291 -0
  162. package/dist/signals/page-views.d.ts +365 -0
  163. package/dist/signals/page-views.js +218 -0
  164. package/dist/signals/parts.d.ts +344 -0
  165. package/dist/signals/parts.js +273 -0
  166. package/dist/signals/postgres.d.ts +16 -2
  167. package/dist/signals/postgres.js +390 -87
  168. package/dist/signals/progress.d.ts +212 -0
  169. package/dist/signals/progress.js +150 -0
  170. package/dist/signals/ratios.d.ts +108 -0
  171. package/dist/signals/ratios.js +40 -0
  172. package/dist/signals/reach.d.ts +309 -0
  173. package/dist/signals/reach.js +93 -0
  174. package/dist/signals/readable.d.ts +34 -0
  175. package/dist/signals/readable.js +34 -0
  176. package/dist/signals/readership.d.ts +381 -0
  177. package/dist/signals/readership.js +308 -0
  178. package/dist/signals/region-pages.d.ts +173 -0
  179. package/dist/signals/region-pages.js +62 -0
  180. package/dist/signals/region.d.ts +287 -0
  181. package/dist/signals/region.js +198 -0
  182. package/dist/signals/retention.d.ts +141 -0
  183. package/dist/signals/retention.js +58 -0
  184. package/dist/signals/rollup.d.ts +67 -3
  185. package/dist/signals/rollup.js +0 -0
  186. package/dist/signals/schema.d.ts +432 -1
  187. package/dist/signals/schema.js +157 -3
  188. package/dist/signals/signal.d.ts +237 -11
  189. package/dist/signals/signal.js +70 -10
  190. package/dist/signals/silence-census.d.ts +205 -0
  191. package/dist/signals/silence-census.js +87 -0
  192. package/dist/signals/silences.d.ts +848 -0
  193. package/dist/signals/silences.js +753 -0
  194. package/dist/signals/tally.d.ts +140 -11
  195. package/dist/signals/window-figures.d.ts +148 -0
  196. package/dist/signals/window-figures.js +42 -0
  197. package/dist/signals/window.d.ts +866 -0
  198. package/dist/signals/window.js +693 -0
  199. package/dist/signals/words.d.ts +24 -0
  200. package/dist/signals/words.js +24 -0
  201. package/dist/store/index.d.ts +19 -0
  202. package/dist/store/index.js +19 -0
  203. package/dist/store/memory.d.ts +2 -1
  204. package/dist/store/memory.js +48 -12
  205. package/dist/store/migrate.d.ts +80 -0
  206. package/dist/store/migrate.js +259 -7
  207. package/dist/store/postgres-applications.d.ts +4 -0
  208. package/dist/store/postgres-applications.js +197 -0
  209. package/dist/store/postgres-holds.d.ts +10 -1
  210. package/dist/store/postgres-holds.js +116 -101
  211. package/dist/store/postgres-policy-log.d.ts +14 -0
  212. package/dist/store/postgres-policy-log.js +240 -0
  213. package/dist/store/postgres-projects.d.ts +4 -0
  214. package/dist/store/postgres-projects.js +217 -0
  215. package/dist/store/postgres.d.ts +16 -1
  216. package/dist/store/postgres.js +59 -9
  217. package/dist/store/replay.d.ts +102 -1
  218. package/dist/store/replay.js +190 -19
  219. package/dist/store/reseed.d.ts +238 -0
  220. package/dist/store/reseed.js +308 -0
  221. package/dist/store/schema.d.ts +450 -2
  222. package/dist/store/schema.js +141 -5
  223. package/dist/store/store.d.ts +29 -6
  224. package/dist/submit/resolve.js +2 -1
  225. package/dist/telemetry/calibration.d.ts +25 -0
  226. package/dist/telemetry/calibration.js +27 -1
  227. package/dist/telemetry/event.d.ts +391 -33
  228. package/dist/telemetry/event.js +84 -20
  229. package/dist/telemetry/index.d.ts +1 -0
  230. package/dist/telemetry/index.js +1 -0
  231. package/dist/telemetry/journal.d.ts +72 -3
  232. package/dist/telemetry/journal.js +9 -0
  233. package/dist/telemetry/lookup.d.ts +27 -0
  234. package/dist/telemetry/lookup.js +18 -0
  235. package/dist/telemetry/memory.js +23 -0
  236. package/dist/telemetry/migrate.js +22 -1
  237. package/dist/telemetry/postgres.d.ts +10 -1
  238. package/dist/telemetry/postgres.js +172 -90
  239. package/dist/telemetry/remeasure.d.ts +78 -0
  240. package/dist/telemetry/remeasure.js +83 -0
  241. package/dist/telemetry/retention.d.ts +2 -2
  242. package/dist/telemetry/schema.d.ts +17 -0
  243. package/dist/telemetry/schema.js +27 -1
  244. package/dist/telemetry/sink.d.ts +2 -2
  245. package/dist/testing/application-contract.d.ts +14 -0
  246. package/dist/testing/application-contract.js +270 -0
  247. package/dist/testing/contracts.d.ts +12 -7
  248. package/dist/testing/contracts.js +12 -7
  249. package/dist/testing/definitions.d.ts +78 -0
  250. package/dist/testing/definitions.js +134 -9
  251. package/dist/testing/doubles.d.ts +103 -0
  252. package/dist/testing/doubles.js +143 -0
  253. package/dist/testing/index.d.ts +2 -2
  254. package/dist/testing/index.js +2 -2
  255. package/dist/testing/journal-contract.js +140 -2
  256. package/dist/testing/model-contract.d.ts +110 -0
  257. package/dist/testing/model-contract.js +150 -0
  258. package/dist/testing/policy-log-contract.d.ts +26 -0
  259. package/dist/testing/policy-log-contract.js +344 -0
  260. package/dist/testing/project-contract.d.ts +14 -0
  261. package/dist/testing/project-contract.js +266 -0
  262. package/dist/testing/reader-signal-contract.d.ts +27 -2
  263. package/dist/testing/reader-signal-contract.js +475 -5
  264. package/dist/testing/store-contract.d.ts +7 -1
  265. package/dist/testing/store-contract.js +84 -3
  266. package/dist/theme/apply.d.ts +20 -1
  267. package/dist/theme/apply.js +5 -3
  268. package/dist/theme/derive.d.ts +22 -0
  269. package/dist/theme/derive.js +54 -1
  270. package/dist/theme/library.js +1 -1
  271. package/dist/theme/measure.d.ts +34 -0
  272. package/dist/theme/measure.js +30 -1
  273. package/dist/theme/palettes.js +7 -7
  274. package/dist/theme/ramp.d.ts +64 -0
  275. package/dist/theme/ramp.js +114 -0
  276. package/dist/theme/registry.d.ts +9 -0
  277. package/dist/theme/registry.js +11 -1
  278. package/dist/theme/separation.d.ts +97 -3
  279. package/dist/theme/separation.js +75 -0
  280. package/dist/tree/compare.d.ts +9 -0
  281. package/dist/tree/compare.js +18 -0
  282. package/dist/write/computed.d.ts +60 -0
  283. package/dist/write/computed.js +61 -0
  284. package/dist/write/held.d.ts +59 -0
  285. package/dist/write/index.d.ts +5 -2
  286. package/dist/write/index.js +5 -2
  287. package/dist/write/reseed.d.ts +151 -0
  288. package/dist/write/reseed.js +184 -0
  289. package/dist/write/revert.js +2 -16
  290. package/package.json +98 -19
@@ -15,6 +15,23 @@ export declare const loomTrees: import("drizzle-orm/pg-core").PgTableWithColumns
15
15
  name: "loom_trees";
16
16
  schema: undefined;
17
17
  columns: {
18
+ applicationId: import("drizzle-orm/pg-core").PgColumn<{
19
+ name: "application_id";
20
+ tableName: "loom_trees";
21
+ dataType: "string";
22
+ columnType: "PgText";
23
+ data: string;
24
+ driverParam: string;
25
+ notNull: true;
26
+ hasDefault: true;
27
+ isPrimaryKey: false;
28
+ isAutoincrement: false;
29
+ hasRuntimeDefault: false;
30
+ enumValues: [string, ...string[]];
31
+ baseColumn: never;
32
+ identity: undefined;
33
+ generated: undefined;
34
+ }, {}, {}>;
18
35
  treeId: import("drizzle-orm/pg-core").PgColumn<{
19
36
  name: "tree_id";
20
37
  tableName: "loom_trees";
@@ -24,7 +41,7 @@ export declare const loomTrees: import("drizzle-orm/pg-core").PgTableWithColumns
24
41
  driverParam: string;
25
42
  notNull: true;
26
43
  hasDefault: false;
27
- isPrimaryKey: true;
44
+ isPrimaryKey: false;
28
45
  isAutoincrement: false;
29
46
  hasRuntimeDefault: false;
30
47
  enumValues: [string, ...string[]];
@@ -100,6 +117,23 @@ export declare const loomRevisions: import("drizzle-orm/pg-core").PgTableWithCol
100
117
  name: "loom_revisions";
101
118
  schema: undefined;
102
119
  columns: {
120
+ applicationId: import("drizzle-orm/pg-core").PgColumn<{
121
+ name: "application_id";
122
+ tableName: "loom_revisions";
123
+ dataType: "string";
124
+ columnType: "PgText";
125
+ data: string;
126
+ driverParam: string;
127
+ notNull: true;
128
+ hasDefault: true;
129
+ isPrimaryKey: false;
130
+ isAutoincrement: false;
131
+ hasRuntimeDefault: false;
132
+ enumValues: [string, ...string[]];
133
+ baseColumn: never;
134
+ identity: undefined;
135
+ generated: undefined;
136
+ }, {}, {}>;
103
137
  treeId: import("drizzle-orm/pg-core").PgColumn<{
104
138
  name: "tree_id";
105
139
  tableName: "loom_revisions";
@@ -246,6 +280,23 @@ export declare const loomHolds: import("drizzle-orm/pg-core").PgTableWithColumns
246
280
  name: "loom_holds";
247
281
  schema: undefined;
248
282
  columns: {
283
+ applicationId: import("drizzle-orm/pg-core").PgColumn<{
284
+ name: "application_id";
285
+ tableName: "loom_holds";
286
+ dataType: "string";
287
+ columnType: "PgText";
288
+ data: string;
289
+ driverParam: string;
290
+ notNull: true;
291
+ hasDefault: true;
292
+ isPrimaryKey: false;
293
+ isAutoincrement: false;
294
+ hasRuntimeDefault: false;
295
+ enumValues: [string, ...string[]];
296
+ baseColumn: never;
297
+ identity: undefined;
298
+ generated: undefined;
299
+ }, {}, {}>;
249
300
  proposalId: import("drizzle-orm/pg-core").PgColumn<{
250
301
  name: "proposal_id";
251
302
  tableName: "loom_holds";
@@ -255,7 +306,7 @@ export declare const loomHolds: import("drizzle-orm/pg-core").PgTableWithColumns
255
306
  driverParam: string;
256
307
  notNull: true;
257
308
  hasDefault: false;
258
- isPrimaryKey: true;
309
+ isPrimaryKey: false;
259
310
  isAutoincrement: false;
260
311
  hasRuntimeDefault: false;
261
312
  enumValues: [string, ...string[]];
@@ -368,4 +419,401 @@ export declare const loomHolds: import("drizzle-orm/pg-core").PgTableWithColumns
368
419
  };
369
420
  dialect: "pg";
370
421
  }>;
422
+ /**
423
+ * The policy's own log.
424
+ *
425
+ * A fourth table rather than a column anywhere, because a policy revision is not
426
+ * a tree revision: it is not keyed by a tree, it does not advance one, and the
427
+ * same revision of one policy judges changes to every tree a deployment holds.
428
+ * `policy-log.ts` says the same thing from the other side.
429
+ *
430
+ * `policy` is the whole `GatePolicy` as JSON, for the reason
431
+ * `loom_revisions.delta` is: it is a Zod-validated shape owned by §2, and
432
+ * columns would duplicate that definition and drift from it. A knob added to the
433
+ * policy would otherwise be a migration away from a log that quietly stops
434
+ * recording it.
435
+ *
436
+ * `fingerprint` is the one denormalised value in this schema, and it is a column
437
+ * rather than a JSON path because of the query it exists for: a `Disposition`
438
+ * carries a fingerprint, and finding the revision it names has to be a seek. The
439
+ * runtime computes it from the policy beside it on the way in and never accepts
440
+ * one from a caller, so the two cannot disagree.
441
+ *
442
+ * The composite primary key is load-bearing exactly as `loom_revisions`' is: it
443
+ * makes the database enforce the revision sequence, so two writers racing at the
444
+ * same head cannot both commit even if both read the head before either wrote.
445
+ *
446
+ * `recorded_at` is text rather than a timestamp to match
447
+ * `loom_revisions.applied_at` and `loom_holds.held_at` — an ISO-8601 UTC instant
448
+ * orders lexicographically exactly as it orders in time, and what the runtime
449
+ * holds above this boundary is a string.
450
+ */
451
+ export declare const loomPolicyRevisions: import("drizzle-orm/pg-core").PgTableWithColumns<{
452
+ name: "loom_policy_revisions";
453
+ schema: undefined;
454
+ columns: {
455
+ applicationId: import("drizzle-orm/pg-core").PgColumn<{
456
+ name: "application_id";
457
+ tableName: "loom_policy_revisions";
458
+ dataType: "string";
459
+ columnType: "PgText";
460
+ data: string;
461
+ driverParam: string;
462
+ notNull: true;
463
+ hasDefault: true;
464
+ isPrimaryKey: false;
465
+ isAutoincrement: false;
466
+ hasRuntimeDefault: false;
467
+ enumValues: [string, ...string[]];
468
+ baseColumn: never;
469
+ identity: undefined;
470
+ generated: undefined;
471
+ }, {}, {}>;
472
+ policyId: import("drizzle-orm/pg-core").PgColumn<{
473
+ name: "policy_id";
474
+ tableName: "loom_policy_revisions";
475
+ dataType: "string";
476
+ columnType: "PgText";
477
+ data: string;
478
+ driverParam: string;
479
+ notNull: true;
480
+ hasDefault: false;
481
+ isPrimaryKey: false;
482
+ isAutoincrement: false;
483
+ hasRuntimeDefault: false;
484
+ enumValues: [string, ...string[]];
485
+ baseColumn: never;
486
+ identity: undefined;
487
+ generated: undefined;
488
+ }, {}, {}>;
489
+ revision: import("drizzle-orm/pg-core").PgColumn<{
490
+ name: "revision";
491
+ tableName: "loom_policy_revisions";
492
+ dataType: "number";
493
+ columnType: "PgInteger";
494
+ data: number;
495
+ driverParam: string | number;
496
+ notNull: true;
497
+ hasDefault: false;
498
+ isPrimaryKey: false;
499
+ isAutoincrement: false;
500
+ hasRuntimeDefault: false;
501
+ enumValues: undefined;
502
+ baseColumn: never;
503
+ identity: undefined;
504
+ generated: undefined;
505
+ }, {}, {}>;
506
+ fingerprint: import("drizzle-orm/pg-core").PgColumn<{
507
+ name: "fingerprint";
508
+ tableName: "loom_policy_revisions";
509
+ dataType: "string";
510
+ columnType: "PgText";
511
+ data: string;
512
+ driverParam: string;
513
+ notNull: true;
514
+ hasDefault: false;
515
+ isPrimaryKey: false;
516
+ isAutoincrement: false;
517
+ hasRuntimeDefault: false;
518
+ enumValues: [string, ...string[]];
519
+ baseColumn: never;
520
+ identity: undefined;
521
+ generated: undefined;
522
+ }, {}, {}>;
523
+ policy: import("drizzle-orm/pg-core").PgColumn<{
524
+ name: "policy";
525
+ tableName: "loom_policy_revisions";
526
+ dataType: "json";
527
+ columnType: "PgJsonb";
528
+ data: unknown;
529
+ driverParam: unknown;
530
+ notNull: true;
531
+ hasDefault: false;
532
+ isPrimaryKey: false;
533
+ isAutoincrement: false;
534
+ hasRuntimeDefault: false;
535
+ enumValues: undefined;
536
+ baseColumn: never;
537
+ identity: undefined;
538
+ generated: undefined;
539
+ }, {}, {}>;
540
+ actor: import("drizzle-orm/pg-core").PgColumn<{
541
+ name: "actor";
542
+ tableName: "loom_policy_revisions";
543
+ dataType: "string";
544
+ columnType: "PgText";
545
+ data: string;
546
+ driverParam: string;
547
+ notNull: true;
548
+ hasDefault: false;
549
+ isPrimaryKey: false;
550
+ isAutoincrement: false;
551
+ hasRuntimeDefault: false;
552
+ enumValues: [string, ...string[]];
553
+ baseColumn: never;
554
+ identity: undefined;
555
+ generated: undefined;
556
+ }, {}, {}>;
557
+ recordedAt: import("drizzle-orm/pg-core").PgColumn<{
558
+ name: "recorded_at";
559
+ tableName: "loom_policy_revisions";
560
+ dataType: "string";
561
+ columnType: "PgText";
562
+ data: string;
563
+ driverParam: string;
564
+ notNull: true;
565
+ hasDefault: false;
566
+ isPrimaryKey: false;
567
+ isAutoincrement: false;
568
+ hasRuntimeDefault: false;
569
+ enumValues: [string, ...string[]];
570
+ baseColumn: never;
571
+ identity: undefined;
572
+ generated: undefined;
573
+ }, {}, {}>;
574
+ note: import("drizzle-orm/pg-core").PgColumn<{
575
+ name: "note";
576
+ tableName: "loom_policy_revisions";
577
+ dataType: "string";
578
+ columnType: "PgText";
579
+ data: string;
580
+ driverParam: string;
581
+ notNull: false;
582
+ hasDefault: false;
583
+ isPrimaryKey: false;
584
+ isAutoincrement: false;
585
+ hasRuntimeDefault: false;
586
+ enumValues: [string, ...string[]];
587
+ baseColumn: never;
588
+ identity: undefined;
589
+ generated: undefined;
590
+ }, {}, {}>;
591
+ };
592
+ dialect: "pg";
593
+ }>;
594
+ /**
595
+ * The applications a deployment governs.
596
+ *
597
+ * The unit everything else is stored under: five tables carry `application_id`
598
+ * and none of them could say what that id named until this existed — the column
599
+ * was a foreign key to nothing.
600
+ *
601
+ * It carried the name *project* until 12 October, when the maintainer settled
602
+ * the hierarchy as **account > project > application** and the thing with the
603
+ * pages turned out to be the third of those rather than the second.
604
+ *
605
+ * `created_at` is text rather than `timestamptz` to match `applicationSchema`,
606
+ * which takes an ISO string — the same choice `loom_revisions.applied_at`
607
+ * makes, and for the same reason: what the row holds is what the type holds,
608
+ * so nothing has to agree about how a driver renders a timestamp.
609
+ */
610
+ export declare const loomApplications: import("drizzle-orm/pg-core").PgTableWithColumns<{
611
+ name: "loom_applications";
612
+ schema: undefined;
613
+ columns: {
614
+ applicationId: import("drizzle-orm/pg-core").PgColumn<{
615
+ name: "application_id";
616
+ tableName: "loom_applications";
617
+ dataType: "string";
618
+ columnType: "PgText";
619
+ data: string;
620
+ driverParam: string;
621
+ notNull: true;
622
+ hasDefault: false;
623
+ isPrimaryKey: true;
624
+ isAutoincrement: false;
625
+ hasRuntimeDefault: false;
626
+ enumValues: [string, ...string[]];
627
+ baseColumn: never;
628
+ identity: undefined;
629
+ generated: undefined;
630
+ }, {}, {}>;
631
+ projectId: import("drizzle-orm/pg-core").PgColumn<{
632
+ name: "project_id";
633
+ tableName: "loom_applications";
634
+ dataType: "string";
635
+ columnType: "PgText";
636
+ data: string;
637
+ driverParam: string;
638
+ notNull: true;
639
+ hasDefault: true;
640
+ isPrimaryKey: false;
641
+ isAutoincrement: false;
642
+ hasRuntimeDefault: false;
643
+ enumValues: [string, ...string[]];
644
+ baseColumn: never;
645
+ identity: undefined;
646
+ generated: undefined;
647
+ }, {}, {}>;
648
+ name: import("drizzle-orm/pg-core").PgColumn<{
649
+ name: "name";
650
+ tableName: "loom_applications";
651
+ dataType: "string";
652
+ columnType: "PgText";
653
+ data: string;
654
+ driverParam: string;
655
+ notNull: true;
656
+ hasDefault: false;
657
+ isPrimaryKey: false;
658
+ isAutoincrement: false;
659
+ hasRuntimeDefault: false;
660
+ enumValues: [string, ...string[]];
661
+ baseColumn: never;
662
+ identity: undefined;
663
+ generated: undefined;
664
+ }, {}, {}>;
665
+ createdAt: import("drizzle-orm/pg-core").PgColumn<{
666
+ name: "created_at";
667
+ tableName: "loom_applications";
668
+ dataType: "string";
669
+ columnType: "PgText";
670
+ data: string;
671
+ driverParam: string;
672
+ notNull: true;
673
+ hasDefault: false;
674
+ isPrimaryKey: false;
675
+ isAutoincrement: false;
676
+ hasRuntimeDefault: false;
677
+ enumValues: [string, ...string[]];
678
+ baseColumn: never;
679
+ identity: undefined;
680
+ generated: undefined;
681
+ }, {}, {}>;
682
+ host: import("drizzle-orm/pg-core").PgColumn<{
683
+ name: "host";
684
+ tableName: "loom_applications";
685
+ dataType: "string";
686
+ columnType: "PgText";
687
+ data: string;
688
+ driverParam: string;
689
+ notNull: false;
690
+ hasDefault: false;
691
+ isPrimaryKey: false;
692
+ isAutoincrement: false;
693
+ hasRuntimeDefault: false;
694
+ enumValues: [string, ...string[]];
695
+ baseColumn: never;
696
+ identity: undefined;
697
+ generated: undefined;
698
+ }, {}, {}>;
699
+ closedAt: import("drizzle-orm/pg-core").PgColumn<{
700
+ name: "closed_at";
701
+ tableName: "loom_applications";
702
+ dataType: "string";
703
+ columnType: "PgText";
704
+ data: string;
705
+ driverParam: string;
706
+ notNull: false;
707
+ hasDefault: false;
708
+ isPrimaryKey: false;
709
+ isAutoincrement: false;
710
+ hasRuntimeDefault: false;
711
+ enumValues: [string, ...string[]];
712
+ baseColumn: never;
713
+ identity: undefined;
714
+ generated: undefined;
715
+ }, {}, {}>;
716
+ };
717
+ dialect: "pg";
718
+ }>;
719
+ /**
720
+ * The projects a deployment has, which group the applications above.
721
+ *
722
+ * Three columns, because the grouping is organisational and owns nothing yet.
723
+ * No row anywhere is scoped by a project: the five scoped tables name their
724
+ * application and the application names its project, so there is one place a
725
+ * thing's project is recorded and nothing to disagree with.
726
+ */
727
+ export declare const loomProjects: import("drizzle-orm/pg-core").PgTableWithColumns<{
728
+ name: "loom_projects";
729
+ schema: undefined;
730
+ columns: {
731
+ projectId: import("drizzle-orm/pg-core").PgColumn<{
732
+ name: "project_id";
733
+ tableName: "loom_projects";
734
+ dataType: "string";
735
+ columnType: "PgText";
736
+ data: string;
737
+ driverParam: string;
738
+ notNull: true;
739
+ hasDefault: false;
740
+ isPrimaryKey: true;
741
+ isAutoincrement: false;
742
+ hasRuntimeDefault: false;
743
+ enumValues: [string, ...string[]];
744
+ baseColumn: never;
745
+ identity: undefined;
746
+ generated: undefined;
747
+ }, {}, {}>;
748
+ name: import("drizzle-orm/pg-core").PgColumn<{
749
+ name: "name";
750
+ tableName: "loom_projects";
751
+ dataType: "string";
752
+ columnType: "PgText";
753
+ data: string;
754
+ driverParam: string;
755
+ notNull: true;
756
+ hasDefault: false;
757
+ isPrimaryKey: false;
758
+ isAutoincrement: false;
759
+ hasRuntimeDefault: false;
760
+ enumValues: [string, ...string[]];
761
+ baseColumn: never;
762
+ identity: undefined;
763
+ generated: undefined;
764
+ }, {}, {}>;
765
+ createdAt: import("drizzle-orm/pg-core").PgColumn<{
766
+ name: "created_at";
767
+ tableName: "loom_projects";
768
+ dataType: "string";
769
+ columnType: "PgText";
770
+ data: string;
771
+ driverParam: string;
772
+ notNull: true;
773
+ hasDefault: false;
774
+ isPrimaryKey: false;
775
+ isAutoincrement: false;
776
+ hasRuntimeDefault: false;
777
+ enumValues: [string, ...string[]];
778
+ baseColumn: never;
779
+ identity: undefined;
780
+ generated: undefined;
781
+ }, {}, {}>;
782
+ repository: import("drizzle-orm/pg-core").PgColumn<{
783
+ name: "repository";
784
+ tableName: "loom_projects";
785
+ dataType: "string";
786
+ columnType: "PgText";
787
+ data: string;
788
+ driverParam: string;
789
+ notNull: false;
790
+ hasDefault: false;
791
+ isPrimaryKey: false;
792
+ isAutoincrement: false;
793
+ hasRuntimeDefault: false;
794
+ enumValues: [string, ...string[]];
795
+ baseColumn: never;
796
+ identity: undefined;
797
+ generated: undefined;
798
+ }, {}, {}>;
799
+ closedAt: import("drizzle-orm/pg-core").PgColumn<{
800
+ name: "closed_at";
801
+ tableName: "loom_projects";
802
+ dataType: "string";
803
+ columnType: "PgText";
804
+ data: string;
805
+ driverParam: string;
806
+ notNull: false;
807
+ hasDefault: false;
808
+ isPrimaryKey: false;
809
+ isAutoincrement: false;
810
+ hasRuntimeDefault: false;
811
+ enumValues: [string, ...string[]];
812
+ baseColumn: never;
813
+ identity: undefined;
814
+ generated: undefined;
815
+ }, {}, {}>;
816
+ };
817
+ dialect: "pg";
818
+ }>;
371
819
  //# sourceMappingURL=schema.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import { sql } from "drizzle-orm";
2
- import { integer, jsonb, pgTable, primaryKey, text, timestamp } from "drizzle-orm/pg-core";
2
+ import { index, integer, jsonb, pgTable, primaryKey, text, timestamp } from "drizzle-orm/pg-core";
3
3
  /**
4
4
  * Two tables: the log, and the snapshot it produces.
5
5
  *
@@ -14,13 +14,24 @@ import { integer, jsonb, pgTable, primaryKey, text, timestamp } from "drizzle-or
14
14
  * that shredded it would have to be migrated every time §1 changes the AST.
15
15
  */
16
16
  export const loomTrees = pgTable("loom_trees", {
17
- treeId: text("tree_id").primaryKey(),
17
+ /**
18
+ * The project the tree belongs to (0260). First in the key rather than
19
+ * beside it: every read this store performs is already inside one project,
20
+ * so a composite key led by the project is the index those reads want, and
21
+ * a tree id only has to be unique within its own project.
22
+ *
23
+ * Defaulted so a database written before projects existed keeps answering.
24
+ * `DEFAULT_APPLICATION_ID` is the value, spelled out here because DDL cannot
25
+ * import it — `project.test.ts` holds the two together.
26
+ */
27
+ applicationId: text("application_id").notNull().default("app_default"),
28
+ treeId: text("tree_id").notNull(),
18
29
  revision: integer("revision").notNull(),
19
30
  document: jsonb("document").notNull(),
20
31
  updatedAt: timestamp("updated_at", { withTimezone: true })
21
32
  .notNull()
22
33
  .default(sql `now()`),
23
- });
34
+ }, (table) => [primaryKey({ columns: [table.applicationId, table.treeId] })]);
24
35
  /**
25
36
  * The log. The composite primary key is load-bearing rather than incidental: it
26
37
  * makes the *database* enforce the revision sequence, so two writers racing at
@@ -32,6 +43,8 @@ export const loomTrees = pgTable("loom_trees", {
32
43
  * by §1 and §2. Columns would duplicate those definitions and drift from them.
33
44
  */
34
45
  export const loomRevisions = pgTable("loom_revisions", {
46
+ /** See `loomTrees.applicationId`. */
47
+ applicationId: text("application_id").notNull().default("app_default"),
35
48
  treeId: text("tree_id").notNull(),
36
49
  revision: integer("revision").notNull(),
37
50
  proposalId: text("proposal_id").notNull(),
@@ -45,7 +58,7 @@ export const loomRevisions = pgTable("loom_revisions", {
45
58
  * nobody observed stays unrecorded rather than being invented.
46
59
  */
47
60
  answeredBy: text("answered_by"),
48
- }, (table) => [primaryKey({ columns: [table.treeId, table.revision] })]);
61
+ }, (table) => [primaryKey({ columns: [table.applicationId, table.treeId, table.revision] })]);
49
62
  /**
50
63
  * The custody of what the Gate held back.
51
64
  *
@@ -67,12 +80,135 @@ export const loomRevisions = pgTable("loom_revisions", {
67
80
  * than by two that happen to agree.
68
81
  */
69
82
  export const loomHolds = pgTable("loom_holds", {
70
- proposalId: text("proposal_id").primaryKey(),
83
+ /**
84
+ * The project the hold belongs to (0260). First in the key, as it is on
85
+ * the two tables above, because every read of this table is already inside
86
+ * one project.
87
+ *
88
+ * Widening the key does not weaken what it was doing. The note on `hold`
89
+ * in `postgres-holds.ts` is that the key is what makes *already held* a
90
+ * fact the database establishes rather than a check the code races
91
+ * against; within a project that is unchanged, and across projects two
92
+ * proposals that happen to share an id were never the same proposal.
93
+ */
94
+ applicationId: text("application_id").notNull().default("app_default"),
95
+ proposalId: text("proposal_id").notNull(),
71
96
  treeId: text("tree_id").notNull(),
72
97
  baseRevision: integer("base_revision").notNull(),
73
98
  intent: jsonb("intent").notNull(),
74
99
  proposal: jsonb("proposal").notNull(),
75
100
  disposition: jsonb("disposition").notNull(),
76
101
  heldAt: text("held_at").notNull(),
102
+ }, (table) => [primaryKey({ columns: [table.applicationId, table.proposalId] })]);
103
+ /**
104
+ * The policy's own log.
105
+ *
106
+ * A fourth table rather than a column anywhere, because a policy revision is not
107
+ * a tree revision: it is not keyed by a tree, it does not advance one, and the
108
+ * same revision of one policy judges changes to every tree a deployment holds.
109
+ * `policy-log.ts` says the same thing from the other side.
110
+ *
111
+ * `policy` is the whole `GatePolicy` as JSON, for the reason
112
+ * `loom_revisions.delta` is: it is a Zod-validated shape owned by §2, and
113
+ * columns would duplicate that definition and drift from it. A knob added to the
114
+ * policy would otherwise be a migration away from a log that quietly stops
115
+ * recording it.
116
+ *
117
+ * `fingerprint` is the one denormalised value in this schema, and it is a column
118
+ * rather than a JSON path because of the query it exists for: a `Disposition`
119
+ * carries a fingerprint, and finding the revision it names has to be a seek. The
120
+ * runtime computes it from the policy beside it on the way in and never accepts
121
+ * one from a caller, so the two cannot disagree.
122
+ *
123
+ * The composite primary key is load-bearing exactly as `loom_revisions`' is: it
124
+ * makes the database enforce the revision sequence, so two writers racing at the
125
+ * same head cannot both commit even if both read the head before either wrote.
126
+ *
127
+ * `recorded_at` is text rather than a timestamp to match
128
+ * `loom_revisions.applied_at` and `loom_holds.held_at` — an ISO-8601 UTC instant
129
+ * orders lexicographically exactly as it orders in time, and what the runtime
130
+ * holds above this boundary is a string.
131
+ */
132
+ export const loomPolicyRevisions = pgTable("loom_policy_revisions", {
133
+ /** The project whose policy this is (0260). See `loomTrees.applicationId`. */
134
+ applicationId: text("application_id").notNull().default("app_default"),
135
+ policyId: text("policy_id").notNull(),
136
+ revision: integer("revision").notNull(),
137
+ fingerprint: text("fingerprint").notNull(),
138
+ policy: jsonb("policy").notNull(),
139
+ /**
140
+ * Who made this the policy (0200). Never null: a revision nobody can be named
141
+ * for is not a record of a decision.
142
+ */
143
+ actor: text("actor").notNull(),
144
+ recordedAt: text("recorded_at").notNull(),
145
+ note: text("note"),
146
+ }, (table) => [
147
+ primaryKey({ columns: [table.applicationId, table.policyId, table.revision] }),
148
+ /**
149
+ * The join `judgedUnder` is. Without it, resolving the fingerprint on a
150
+ * disposition is a scan of every policy revision the deployment has ever
151
+ * recorded — which is small today and is on the path of a screen that reads
152
+ * it once per record on the page.
153
+ */
154
+ index("loom_policy_revisions_fingerprint_idx").on(table.applicationId, table.policyId, table.fingerprint),
155
+ ]);
156
+ /**
157
+ * The applications a deployment governs.
158
+ *
159
+ * The unit everything else is stored under: five tables carry `application_id`
160
+ * and none of them could say what that id named until this existed — the column
161
+ * was a foreign key to nothing.
162
+ *
163
+ * It carried the name *project* until 12 October, when the maintainer settled
164
+ * the hierarchy as **account > project > application** and the thing with the
165
+ * pages turned out to be the third of those rather than the second.
166
+ *
167
+ * `created_at` is text rather than `timestamptz` to match `applicationSchema`,
168
+ * which takes an ISO string — the same choice `loom_revisions.applied_at`
169
+ * makes, and for the same reason: what the row holds is what the type holds,
170
+ * so nothing has to agree about how a driver renders a timestamp.
171
+ */
172
+ export const loomApplications = pgTable("loom_applications", {
173
+ applicationId: text("application_id").primaryKey(),
174
+ /**
175
+ * The project it is grouped under. Not null and not defaulted in the type,
176
+ * but defaulted in the DDL so a database written before projects existed
177
+ * keeps answering — the same device every scoped column here uses.
178
+ */
179
+ projectId: text("project_id").notNull().default("prj_default"),
180
+ name: text("name").notNull(),
181
+ createdAt: text("created_at").notNull(),
182
+ /** Absent until the application says where it lives. */
183
+ host: text("host"),
184
+ /** When it was closed, absent while it is open (0289). See `loomProjects.closedAt`. */
185
+ closedAt: text("closed_at"),
186
+ });
187
+ /**
188
+ * The projects a deployment has, which group the applications above.
189
+ *
190
+ * Three columns, because the grouping is organisational and owns nothing yet.
191
+ * No row anywhere is scoped by a project: the five scoped tables name their
192
+ * application and the application names its project, so there is one place a
193
+ * thing's project is recorded and nothing to disagree with.
194
+ */
195
+ export const loomProjects = pgTable("loom_projects", {
196
+ projectId: text("project_id").primaryKey(),
197
+ name: text("name").notNull(),
198
+ createdAt: text("created_at").notNull(),
199
+ /**
200
+ * The repository this project's pages live in, absent while it has none
201
+ * (0292). Unique where present, because a repository belongs to at most one
202
+ * project and two claiming it is a race rather than a typo.
203
+ */
204
+ repository: text("repository"),
205
+ /**
206
+ * When it was closed, absent while it is open (0289).
207
+ *
208
+ * This store has no delete and this is what it has instead. Nullable and
209
+ * undefaulted, which is the honest value for every row written before closing
210
+ * existed: they were open, and they still are.
211
+ */
212
+ closedAt: text("closed_at"),
77
213
  });
78
214
  //# sourceMappingURL=schema.js.map