@jam-overture/loom 0.1.0 → 0.3.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 (414) 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/audience/compose.d.ts +112 -0
  11. package/dist/audience/compose.js +134 -0
  12. package/dist/audience/memory.d.ts +14 -0
  13. package/dist/audience/memory.js +71 -0
  14. package/dist/audience/overlay-store.d.ts +343 -0
  15. package/dist/audience/overlay-store.js +217 -0
  16. package/dist/audience/rule.d.ts +121 -0
  17. package/dist/audience/rule.js +78 -0
  18. package/dist/cli/index.d.ts +3 -4
  19. package/dist/cli/index.js +3 -4
  20. package/dist/cli/templates.js +19 -0
  21. package/dist/data/adapter.d.ts +9 -1
  22. package/dist/data/adapter.js +2 -0
  23. package/dist/data/plan.js +0 -0
  24. package/dist/data/resolution.d.ts +23 -1
  25. package/dist/data/resolve.d.ts +31 -4
  26. package/dist/data/resolve.js +11 -3
  27. package/dist/ids.d.ts +10 -0
  28. package/dist/ids.js +11 -1
  29. package/dist/index.d.ts +1 -0
  30. package/dist/index.js +1 -0
  31. package/dist/interpretation/anthropic.d.ts +1 -1
  32. package/dist/interpretation/anthropic.js +2 -22
  33. package/dist/interpretation/client.d.ts +1 -1
  34. package/dist/interpretation/materialize.js +67 -22
  35. package/dist/interpretation/openai-compatible.d.ts +36 -0
  36. package/dist/interpretation/openai-compatible.js +79 -0
  37. package/dist/interpretation/status.d.ts +19 -0
  38. package/dist/interpretation/status.js +26 -0
  39. package/dist/live/index.d.ts +73 -0
  40. package/dist/live/index.js +73 -0
  41. package/dist/live/pages.d.ts +187 -0
  42. package/dist/live/pages.js +161 -0
  43. package/dist/live/pull.d.ts +147 -0
  44. package/dist/live/pull.js +398 -0
  45. package/dist/live/pulling.d.ts +79 -0
  46. package/dist/live/pulling.js +117 -0
  47. package/dist/live/window.d.ts +129 -0
  48. package/dist/live/window.js +132 -0
  49. package/dist/patch.d.ts +54 -0
  50. package/dist/patch.js +44 -0
  51. package/dist/project/closing.d.ts +51 -0
  52. package/dist/project/closing.js +53 -0
  53. package/dist/project/memory.d.ts +20 -0
  54. package/dist/project/memory.js +97 -0
  55. package/dist/project/project.d.ts +90 -0
  56. package/dist/project/project.js +91 -0
  57. package/dist/project/store.d.ts +135 -0
  58. package/dist/project/store.js +41 -0
  59. package/dist/registered.d.ts +64 -0
  60. package/dist/registered.js +118 -0
  61. package/dist/render/addressed.d.ts +35 -0
  62. package/dist/render/addressed.js +79 -0
  63. package/dist/render/behaviour-adjust.d.ts +11 -19
  64. package/dist/render/behaviour-adjust.js +75 -21
  65. package/dist/render/behaviour-present.d.ts +8 -0
  66. package/dist/render/behaviour-present.js +57 -6
  67. package/dist/render/behaviour.d.ts +98 -17
  68. package/dist/render/behaviour.js +91 -26
  69. package/dist/render/control-name.d.ts +68 -0
  70. package/dist/render/control-name.js +37 -0
  71. package/dist/render/diagnostics.d.ts +72 -0
  72. package/dist/render/diagnostics.js +7 -0
  73. package/dist/render/document-theme.d.ts +70 -0
  74. package/dist/render/document-theme.js +139 -0
  75. package/dist/render/editable.d.ts +15 -1
  76. package/dist/render/editable.js +13 -1
  77. package/dist/render/expected.d.ts +98 -0
  78. package/dist/render/expected.js +88 -0
  79. package/dist/render/index.d.ts +4 -0
  80. package/dist/render/index.js +4 -0
  81. package/dist/render/reads.d.ts +11 -0
  82. package/dist/render/reads.js +12 -1
  83. package/dist/render/render.d.ts +11 -0
  84. package/dist/render/render.js +294 -53
  85. package/dist/render/request.d.ts +8 -1
  86. package/dist/render/request.js +1 -0
  87. package/dist/render/slots.d.ts +52 -0
  88. package/dist/render/slots.js +24 -0
  89. package/dist/render/theme.d.ts +54 -1
  90. package/dist/render/theme.js +23 -1
  91. package/dist/render/unshown.d.ts +152 -0
  92. package/dist/render/unshown.js +80 -0
  93. package/dist/runtime/analysis.d.ts +94 -9
  94. package/dist/runtime/analysis.js +54 -9
  95. package/dist/runtime/assessment.d.ts +36 -2
  96. package/dist/runtime/assessment.js +27 -2
  97. package/dist/runtime/auto-apply-ceiling.d.ts +54 -0
  98. package/dist/runtime/auto-apply-ceiling.js +66 -0
  99. package/dist/runtime/checks.d.ts +148 -0
  100. package/dist/runtime/checks.js +112 -0
  101. package/dist/runtime/disposition.d.ts +96 -0
  102. package/dist/runtime/disposition.js +46 -0
  103. package/dist/runtime/gate.js +91 -10
  104. package/dist/runtime/index.d.ts +4 -0
  105. package/dist/runtime/index.js +4 -0
  106. package/dist/runtime/irreversibility.d.ts +64 -0
  107. package/dist/runtime/irreversibility.js +45 -0
  108. package/dist/runtime/nesting.d.ts +13 -1
  109. package/dist/runtime/nesting.js +41 -24
  110. package/dist/runtime/pipeline.d.ts +43 -0
  111. package/dist/runtime/pipeline.js +10 -2
  112. package/dist/runtime/policy-change.d.ts +93 -0
  113. package/dist/runtime/policy-change.js +305 -0
  114. package/dist/runtime/policy-log.d.ts +406 -0
  115. package/dist/runtime/policy-log.js +285 -0
  116. package/dist/runtime/policy.d.ts +8 -6
  117. package/dist/runtime/policy.js +5 -2
  118. package/dist/runtime/repointing.js +0 -0
  119. package/dist/runtime/reversibility.d.ts +11 -9
  120. package/dist/runtime/stakes.d.ts +129 -1
  121. package/dist/runtime/stakes.js +240 -26
  122. package/dist/runtime/vocabulary.d.ts +164 -7
  123. package/dist/runtime/vocabulary.js +181 -8
  124. package/dist/sdk/audit.d.ts +174 -3
  125. package/dist/sdk/audit.js +176 -17
  126. package/dist/sdk/catalogue.d.ts +9 -1
  127. package/dist/sdk/conformance.d.ts +37 -3
  128. package/dist/sdk/conformance.js +25 -4
  129. package/dist/sdk/definition.d.ts +129 -5
  130. package/dist/sdk/definition.js +66 -0
  131. package/dist/sdk/registry.d.ts +45 -2
  132. package/dist/sdk/registry.js +102 -1
  133. package/dist/signals/acted.contract.d.ts +21 -0
  134. package/dist/signals/acted.contract.js +236 -0
  135. package/dist/signals/acted.d.ts +359 -0
  136. package/dist/signals/acted.js +135 -0
  137. package/dist/signals/action-change.d.ts +507 -0
  138. package/dist/signals/action-change.js +265 -0
  139. package/dist/signals/action.d.ts +331 -0
  140. package/dist/signals/action.js +182 -0
  141. package/dist/signals/agenda.d.ts +585 -0
  142. package/dist/signals/agenda.js +295 -0
  143. package/dist/signals/applied-window.contract.d.ts +23 -0
  144. package/dist/signals/applied-window.contract.js +160 -0
  145. package/dist/signals/arrivals.contract.d.ts +21 -0
  146. package/dist/signals/arrivals.contract.js +180 -0
  147. package/dist/signals/arrivals.d.ts +375 -0
  148. package/dist/signals/arrivals.js +254 -0
  149. package/dist/signals/arriving.d.ts +210 -0
  150. package/dist/signals/arriving.js +133 -0
  151. package/dist/signals/audiences.d.ts +528 -0
  152. package/dist/signals/audiences.js +255 -0
  153. package/dist/signals/broadcast.d.ts +33 -17
  154. package/dist/signals/broadcast.js +255 -32
  155. package/dist/signals/change.d.ts +378 -0
  156. package/dist/signals/change.js +327 -0
  157. package/dist/signals/collect.d.ts +169 -34
  158. package/dist/signals/collect.js +186 -38
  159. package/dist/signals/conversion.d.ts +348 -0
  160. package/dist/signals/conversion.js +235 -0
  161. package/dist/signals/copy-change.d.ts +553 -0
  162. package/dist/signals/copy-change.js +377 -0
  163. package/dist/signals/copy.d.ts +337 -0
  164. package/dist/signals/copy.js +211 -0
  165. package/dist/signals/correlated.contract.d.ts +24 -0
  166. package/dist/signals/correlated.contract.js +94 -0
  167. package/dist/signals/counters.d.ts +97 -0
  168. package/dist/signals/counters.js +160 -0
  169. package/dist/signals/deliver.d.ts +23 -4
  170. package/dist/signals/deliver.js +34 -6
  171. package/dist/signals/deployment-change.d.ts +395 -0
  172. package/dist/signals/deployment-change.js +309 -0
  173. package/dist/signals/deployment.d.ts +278 -0
  174. package/dist/signals/deployment.js +178 -0
  175. package/dist/signals/door.d.ts +114 -0
  176. package/dist/signals/door.js +77 -0
  177. package/dist/signals/expire.d.ts +192 -0
  178. package/dist/signals/expire.js +213 -0
  179. package/dist/signals/fold.d.ts +10 -0
  180. package/dist/signals/fold.js +5 -1
  181. package/dist/signals/form-action.d.ts +302 -0
  182. package/dist/signals/form-action.js +169 -0
  183. package/dist/signals/form-copy.d.ts +523 -0
  184. package/dist/signals/form-copy.js +346 -0
  185. package/dist/signals/forms.d.ts +247 -0
  186. package/dist/signals/forms.js +147 -0
  187. package/dist/signals/frontier.d.ts +268 -0
  188. package/dist/signals/frontier.js +145 -0
  189. package/dist/signals/funnel-change.d.ts +548 -0
  190. package/dist/signals/funnel-change.js +361 -0
  191. package/dist/signals/funnel-hours.contract.d.ts +21 -0
  192. package/dist/signals/funnel-hours.contract.js +221 -0
  193. package/dist/signals/funnel-hours.d.ts +293 -0
  194. package/dist/signals/funnel-hours.js +99 -0
  195. package/dist/signals/funnel.d.ts +592 -0
  196. package/dist/signals/funnel.js +231 -0
  197. package/dist/signals/health.d.ts +694 -0
  198. package/dist/signals/health.js +573 -0
  199. package/dist/signals/index.d.ts +60 -0
  200. package/dist/signals/index.js +60 -0
  201. package/dist/signals/ingest.d.ts +56 -1
  202. package/dist/signals/ingest.js +91 -1
  203. package/dist/signals/inside.d.ts +190 -0
  204. package/dist/signals/inside.js +263 -0
  205. package/dist/signals/join.d.ts +56 -0
  206. package/dist/signals/join.js +60 -0
  207. package/dist/signals/journal.d.ts +123 -9
  208. package/dist/signals/kept.contract.d.ts +22 -0
  209. package/dist/signals/kept.contract.js +111 -0
  210. package/dist/signals/kinds.d.ts +8 -6
  211. package/dist/signals/kinds.js +14 -6
  212. package/dist/signals/library-action.d.ts +430 -0
  213. package/dist/signals/library-action.js +336 -0
  214. package/dist/signals/library-agenda-change.d.ts +324 -0
  215. package/dist/signals/library-agenda-change.js +199 -0
  216. package/dist/signals/library-agenda.d.ts +258 -0
  217. package/dist/signals/library-agenda.js +167 -0
  218. package/dist/signals/library-change.d.ts +477 -0
  219. package/dist/signals/library-change.js +335 -0
  220. package/dist/signals/library-copy-change.d.ts +498 -0
  221. package/dist/signals/library-copy-change.js +476 -0
  222. package/dist/signals/library-pace.d.ts +319 -0
  223. package/dist/signals/library-pace.js +305 -0
  224. package/dist/signals/library-reach-change.d.ts +646 -0
  225. package/dist/signals/library-reach-change.js +542 -0
  226. package/dist/signals/library-reach.d.ts +377 -0
  227. package/dist/signals/library-reach.js +227 -0
  228. package/dist/signals/library-senders-change.d.ts +457 -0
  229. package/dist/signals/library-senders-change.js +367 -0
  230. package/dist/signals/library-senders-reach-change.d.ts +486 -0
  231. package/dist/signals/library-senders-reach-change.js +538 -0
  232. package/dist/signals/library-senders-reach.d.ts +340 -0
  233. package/dist/signals/library-senders-reach.js +252 -0
  234. package/dist/signals/library-senders.d.ts +271 -0
  235. package/dist/signals/library-senders.js +180 -0
  236. package/dist/signals/library-word-reach-change.d.ts +567 -0
  237. package/dist/signals/library-word-reach-change.js +564 -0
  238. package/dist/signals/library.d.ts +306 -0
  239. package/dist/signals/library.js +178 -0
  240. package/dist/signals/memory.d.ts +9 -0
  241. package/dist/signals/memory.js +246 -14
  242. package/dist/signals/migrate.d.ts +20 -4
  243. package/dist/signals/migrate.js +269 -8
  244. package/dist/signals/notice.d.ts +389 -0
  245. package/dist/signals/notice.js +250 -0
  246. package/dist/signals/pace-change.d.ts +501 -0
  247. package/dist/signals/pace-change.js +310 -0
  248. package/dist/signals/pace.d.ts +296 -0
  249. package/dist/signals/pace.js +291 -0
  250. package/dist/signals/page-views.d.ts +365 -0
  251. package/dist/signals/page-views.js +218 -0
  252. package/dist/signals/part-pace.d.ts +378 -0
  253. package/dist/signals/part-pace.js +333 -0
  254. package/dist/signals/parts.d.ts +354 -0
  255. package/dist/signals/parts.js +232 -0
  256. package/dist/signals/postgres.d.ts +16 -2
  257. package/dist/signals/postgres.js +753 -76
  258. package/dist/signals/progress.d.ts +212 -0
  259. package/dist/signals/progress.js +150 -0
  260. package/dist/signals/ratios.d.ts +108 -0
  261. package/dist/signals/ratios.js +40 -0
  262. package/dist/signals/reach.d.ts +309 -0
  263. package/dist/signals/reach.js +93 -0
  264. package/dist/signals/readable.d.ts +34 -0
  265. package/dist/signals/readable.js +34 -0
  266. package/dist/signals/readership.d.ts +381 -0
  267. package/dist/signals/readership.js +308 -0
  268. package/dist/signals/region-pages.d.ts +173 -0
  269. package/dist/signals/region-pages.js +62 -0
  270. package/dist/signals/region.d.ts +287 -0
  271. package/dist/signals/region.js +198 -0
  272. package/dist/signals/retention.d.ts +163 -0
  273. package/dist/signals/retention.js +75 -0
  274. package/dist/signals/rhythm.d.ts +302 -0
  275. package/dist/signals/rhythm.js +262 -0
  276. package/dist/signals/rollup.d.ts +194 -4
  277. package/dist/signals/rollup.js +0 -0
  278. package/dist/signals/schema.d.ts +1069 -1
  279. package/dist/signals/schema.js +393 -3
  280. package/dist/signals/signal.d.ts +237 -11
  281. package/dist/signals/signal.js +70 -10
  282. package/dist/signals/silence-census.d.ts +205 -0
  283. package/dist/signals/silence-census.js +87 -0
  284. package/dist/signals/silences.d.ts +1147 -0
  285. package/dist/signals/silences.js +996 -0
  286. package/dist/signals/subtrees.d.ts +123 -0
  287. package/dist/signals/subtrees.js +102 -0
  288. package/dist/signals/tally.d.ts +262 -12
  289. package/dist/signals/unread.d.ts +292 -0
  290. package/dist/signals/unread.js +137 -0
  291. package/dist/signals/window-agenda.d.ts +276 -0
  292. package/dist/signals/window-agenda.js +83 -0
  293. package/dist/signals/window-figures.d.ts +148 -0
  294. package/dist/signals/window-figures.js +42 -0
  295. package/dist/signals/window-funnels.d.ts +88 -0
  296. package/dist/signals/window-funnels.js +47 -0
  297. package/dist/signals/window.d.ts +866 -0
  298. package/dist/signals/window.js +693 -0
  299. package/dist/signals/words.d.ts +24 -0
  300. package/dist/signals/words.js +24 -0
  301. package/dist/store/cache.d.ts +101 -0
  302. package/dist/store/cache.js +149 -0
  303. package/dist/store/history.d.ts +82 -0
  304. package/dist/store/history.js +36 -0
  305. package/dist/store/index.d.ts +30 -0
  306. package/dist/store/index.js +30 -0
  307. package/dist/store/memory.d.ts +2 -1
  308. package/dist/store/memory.js +48 -12
  309. package/dist/store/migrate.d.ts +106 -0
  310. package/dist/store/migrate.js +323 -7
  311. package/dist/store/postgres-applications.d.ts +4 -0
  312. package/dist/store/postgres-applications.js +197 -0
  313. package/dist/store/postgres-audience.d.ts +14 -0
  314. package/dist/store/postgres-audience.js +272 -0
  315. package/dist/store/postgres-holds.d.ts +10 -1
  316. package/dist/store/postgres-holds.js +116 -101
  317. package/dist/store/postgres-policy-log.d.ts +14 -0
  318. package/dist/store/postgres-policy-log.js +240 -0
  319. package/dist/store/postgres-projects.d.ts +4 -0
  320. package/dist/store/postgres-projects.js +217 -0
  321. package/dist/store/postgres.d.ts +17 -1
  322. package/dist/store/postgres.js +60 -9
  323. package/dist/store/replay.d.ts +102 -1
  324. package/dist/store/replay.js +190 -19
  325. package/dist/store/reseed.d.ts +238 -0
  326. package/dist/store/reseed.js +308 -0
  327. package/dist/store/schema.d.ts +762 -2
  328. package/dist/store/schema.js +218 -5
  329. package/dist/store/source.d.ts +57 -1
  330. package/dist/store/source.js +65 -1
  331. package/dist/store/store.d.ts +29 -6
  332. package/dist/submit/resolve.d.ts +1 -1
  333. package/dist/submit/resolve.js +2 -1
  334. package/dist/telemetry/calibration.d.ts +25 -0
  335. package/dist/telemetry/calibration.js +27 -1
  336. package/dist/telemetry/event.d.ts +391 -33
  337. package/dist/telemetry/event.js +84 -20
  338. package/dist/telemetry/index.d.ts +2 -0
  339. package/dist/telemetry/index.js +2 -0
  340. package/dist/telemetry/journal.d.ts +104 -3
  341. package/dist/telemetry/journal.js +9 -0
  342. package/dist/telemetry/lookup.d.ts +27 -0
  343. package/dist/telemetry/lookup.js +18 -0
  344. package/dist/telemetry/memory.js +33 -1
  345. package/dist/telemetry/migrate.js +22 -1
  346. package/dist/telemetry/postgres.d.ts +10 -1
  347. package/dist/telemetry/postgres.js +188 -90
  348. package/dist/telemetry/remeasure.d.ts +78 -0
  349. package/dist/telemetry/remeasure.js +83 -0
  350. package/dist/telemetry/retention.d.ts +2 -2
  351. package/dist/telemetry/schema.d.ts +17 -0
  352. package/dist/telemetry/schema.js +27 -1
  353. package/dist/telemetry/sink.d.ts +2 -2
  354. package/dist/telemetry/window.d.ts +135 -0
  355. package/dist/telemetry/window.js +101 -0
  356. package/dist/testing/application-contract.d.ts +14 -0
  357. package/dist/testing/application-contract.js +270 -0
  358. package/dist/testing/audience-overlay-contract.d.ts +31 -0
  359. package/dist/testing/audience-overlay-contract.js +354 -0
  360. package/dist/testing/contracts.d.ts +13 -7
  361. package/dist/testing/contracts.js +13 -7
  362. package/dist/testing/definitions.d.ts +78 -0
  363. package/dist/testing/definitions.js +134 -9
  364. package/dist/testing/doubles.d.ts +103 -0
  365. package/dist/testing/doubles.js +143 -0
  366. package/dist/testing/index.d.ts +2 -2
  367. package/dist/testing/index.js +2 -2
  368. package/dist/testing/journal-contract.js +297 -6
  369. package/dist/testing/model-contract.d.ts +110 -0
  370. package/dist/testing/model-contract.js +150 -0
  371. package/dist/testing/policy-log-contract.d.ts +26 -0
  372. package/dist/testing/policy-log-contract.js +344 -0
  373. package/dist/testing/project-contract.d.ts +14 -0
  374. package/dist/testing/project-contract.js +266 -0
  375. package/dist/testing/reader-signal-contract.d.ts +27 -2
  376. package/dist/testing/reader-signal-contract.js +475 -5
  377. package/dist/testing/store-contract.d.ts +7 -1
  378. package/dist/testing/store-contract.js +84 -3
  379. package/dist/theme/apply.d.ts +20 -1
  380. package/dist/theme/apply.js +5 -3
  381. package/dist/theme/contrast.d.ts +19 -14
  382. package/dist/theme/contrast.js +181 -17
  383. package/dist/theme/derive.d.ts +22 -0
  384. package/dist/theme/derive.js +54 -1
  385. package/dist/theme/library.js +1 -1
  386. package/dist/theme/measure.d.ts +34 -0
  387. package/dist/theme/measure.js +30 -1
  388. package/dist/theme/palettes.js +7 -7
  389. package/dist/theme/ramp.d.ts +64 -0
  390. package/dist/theme/ramp.js +114 -0
  391. package/dist/theme/registry.d.ts +9 -0
  392. package/dist/theme/registry.js +11 -1
  393. package/dist/theme/separation.d.ts +97 -3
  394. package/dist/theme/separation.js +75 -0
  395. package/dist/tree/apply.js +13 -0
  396. package/dist/tree/compare.d.ts +9 -0
  397. package/dist/tree/compare.js +18 -0
  398. package/dist/tree/mutation.d.ts +18 -0
  399. package/dist/tree/mutation.js +24 -12
  400. package/dist/tree/navigation.d.ts +5 -0
  401. package/dist/tree/navigation.js +32 -10
  402. package/dist/tree/outline.d.ts +7 -0
  403. package/dist/tree/outline.js +9 -5
  404. package/dist/write/computed.d.ts +60 -0
  405. package/dist/write/computed.js +61 -0
  406. package/dist/write/held.d.ts +59 -0
  407. package/dist/write/index.d.ts +5 -2
  408. package/dist/write/index.js +5 -2
  409. package/dist/write/reseed.d.ts +151 -0
  410. package/dist/write/reseed.js +184 -0
  411. package/dist/write/revert.js +2 -16
  412. package/package.json +25 -3
  413. package/dist/runtime/inverse-interpreter.d.ts +0 -90
  414. package/dist/runtime/inverse-interpreter.js +0 -56
@@ -1,10 +1,13 @@
1
- import { and, asc, desc, eq, gt, lt } from "drizzle-orm";
1
+ import { and, asc, desc, eq, gt, gte, inArray, lt, sql } from "drizzle-orm";
2
2
  import { z } from "zod";
3
3
  import { treeIdSchema } from "../ids.js";
4
+ import { DEFAULT_APPLICATION_ID } from "../application/application.js";
4
5
  import { cursorPosition, pageEnds } from "../paging.js";
5
6
  import { err, ok } from "../result.js";
6
- import { telemetryEventSchema } from "./event.js";
7
+ import { assessmentSummarySchema, telemetryEventSchema } from "./event.js";
7
8
  import { clampTelemetryLimit, } from "./journal.js";
9
+ import { telemetrySpanOf } from "./window.js";
10
+ import { splitLookup } from "./lookup.js";
8
11
  import { loomTelemetry } from "./schema.js";
9
12
  export * from "./migrate.js";
10
13
  export * from "./schema.js";
@@ -42,98 +45,193 @@ const recordedSchema = z.object({
42
45
  .transform((value) => value.toISOString()),
43
46
  event: telemetryEventSchema,
44
47
  });
48
+ /**
49
+ * The three JSON paths the assessment lookup reads, named once.
50
+ *
51
+ * `event` is one document and its type is not also a column, which 0022's table
52
+ * comment argued for and this is the first query to pay for: the discriminant
53
+ * has to be read out of the JSON rather than compared against a column. That is
54
+ * the trade the comment described — an index on a path, available the day a
55
+ * query needs one — and not a duplicated column that can disagree.
56
+ */
57
+ const ASSESSED_TYPE = sql `${loomTelemetry.event} ->> 'type'`;
58
+ const ASSESSED_PROPOSAL_ID = sql `${loomTelemetry.event} -> 'assessment' ->> 'proposalId'`;
59
+ const ASSESSMENT = sql `${loomTelemetry.event} -> 'assessment'`;
45
60
  const failure = (cause, detail) => ({
46
61
  code: "unavailable",
47
62
  detail: `${detail}: ${cause instanceof Error ? cause.message : String(cause)}`,
48
63
  });
49
- export const postgresTelemetryJournal = (db) => ({
50
- record: async (batch) => {
51
- if (batch.length === 0)
52
- return ok(undefined);
53
- try {
54
- await db.insert(loomTelemetry).values(batch.map((entry) => ({
55
- treeId: entry.treeId,
56
- occurredAt: entry.occurredAt,
57
- event: entry.event,
58
- })));
59
- return ok(undefined);
60
- }
61
- catch (cause) {
62
- return err(failure(cause, `could not record ${batch.length} telemetry events`));
63
- }
64
- },
65
- read: async (request) => {
66
- const limit = clampTelemetryLimit(request?.limit);
67
- const from = cursorPosition(request?.cursor);
68
- const direction = request?.direction ?? "newer";
69
- try {
70
- /**
71
- * `older` scans descending so the newest page costs one index seek rather
72
- * than a walk from the start of the journal, then the rows are put back in
73
- * arrival order — the contract's promise that a page's order never depends
74
- * on which end it came from.
75
- */
76
- const rows = await db
77
- .select({
78
- seq: loomTelemetry.seq,
79
- treeId: loomTelemetry.treeId,
80
- occurredAt: loomTelemetry.occurredAt,
81
- recordedAt: loomTelemetry.recordedAt,
82
- event: loomTelemetry.event,
83
- })
84
- .from(loomTelemetry)
85
- .where(and(request?.treeId === undefined ? undefined : eq(loomTelemetry.treeId, request.treeId), from === undefined
86
- ? undefined
87
- : direction === "older"
88
- ? lt(loomTelemetry.seq, from)
89
- : gt(loomTelemetry.seq, from)))
90
- .orderBy(direction === "older" ? desc(loomTelemetry.seq) : asc(loomTelemetry.seq))
91
- /** One extra row answers "is there another page" without a count. */
92
- .limit(limit + 1);
93
- const taken = rows.slice(0, limit);
94
- const parsed = z
95
- .array(recordedSchema)
96
- .safeParse(direction === "older" ? taken.slice().reverse() : taken);
97
- if (!parsed.success) {
98
- return err({
99
- code: "unavailable",
100
- detail: `a stored telemetry record did not parse: ${parsed.error.issues[0]?.path.join(".") ?? "unknown"}`,
64
+ /**
65
+ * Every query is filtered by the project this handle speaks for (0260), and
66
+ * every write sets it.
67
+ *
68
+ * `seq` is not scoped and does not need to be — see `schema.ts`. What is scoped
69
+ * is every row this handle will ever see, so one project's gate decisions
70
+ * cannot appear on another's screen.
71
+ */
72
+ export const postgresTelemetryJournal = (db, scope = {}) => {
73
+ const project = scope.application ?? DEFAULT_APPLICATION_ID;
74
+ const mine = (...rest) => and(eq(loomTelemetry.applicationId, project), ...rest);
75
+ return {
76
+ record: async (batch) => {
77
+ if (batch.length === 0)
78
+ return ok(undefined);
79
+ try {
80
+ await db.insert(loomTelemetry).values(batch.map((entry) => ({
81
+ applicationId: project,
82
+ treeId: entry.treeId,
83
+ occurredAt: entry.occurredAt,
84
+ event: entry.event,
85
+ })));
86
+ return ok(undefined);
87
+ }
88
+ catch (cause) {
89
+ return err(failure(cause, `could not record ${batch.length} telemetry events`));
90
+ }
91
+ },
92
+ read: async (request) => {
93
+ const limit = clampTelemetryLimit(request?.limit);
94
+ const from = cursorPosition(request?.cursor);
95
+ const direction = request?.direction ?? "newer";
96
+ const window = request?.window;
97
+ try {
98
+ /**
99
+ * `older` scans descending so the newest page costs one index seek rather
100
+ * than a walk from the start of the journal, then the rows are put back in
101
+ * arrival order — the contract's promise that a page's order never depends
102
+ * on which end it came from.
103
+ */
104
+ const rows = await db
105
+ .select({
106
+ seq: loomTelemetry.seq,
107
+ treeId: loomTelemetry.treeId,
108
+ occurredAt: loomTelemetry.occurredAt,
109
+ recordedAt: loomTelemetry.recordedAt,
110
+ event: loomTelemetry.event,
111
+ })
112
+ .from(loomTelemetry)
113
+ .where(mine(request?.treeId === undefined ? undefined : eq(loomTelemetry.treeId, request.treeId), from === undefined
114
+ ? undefined
115
+ : direction === "older"
116
+ ? lt(loomTelemetry.seq, from)
117
+ : gt(loomTelemetry.seq, from),
118
+ /**
119
+ * The window, as the two comparisons it is: `gte` on the inclusive
120
+ * end and `lt` on the exclusive one, so two consecutive windows
121
+ * tile. Both are on `recorded_at`, which the column index already
122
+ * orders, and both sit in the same `where` as the cursor — which is
123
+ * what keeps the `limit + 1` probe below a question about the window
124
+ * rather than about the journal.
125
+ */
126
+ window?.since === undefined
127
+ ? undefined
128
+ : gte(loomTelemetry.recordedAt, new Date(window.since)), window?.until === undefined
129
+ ? undefined
130
+ : lt(loomTelemetry.recordedAt, new Date(window.until))))
131
+ .orderBy(direction === "older" ? desc(loomTelemetry.seq) : asc(loomTelemetry.seq))
132
+ /** One extra row answers "is there another page" without a count. */
133
+ .limit(limit + 1);
134
+ const taken = rows.slice(0, limit);
135
+ const parsed = z
136
+ .array(recordedSchema)
137
+ .safeParse(direction === "older" ? taken.slice().reverse() : taken);
138
+ if (!parsed.success) {
139
+ return err({
140
+ code: "unavailable",
141
+ detail: `a stored telemetry record did not parse: ${parsed.error.issues[0]?.path.join(".") ?? "unknown"}`,
142
+ });
143
+ }
144
+ const page = parsed.data;
145
+ return ok({
146
+ records: page,
147
+ span: telemetrySpanOf(page),
148
+ ...pageEnds(page.map((record) => record.seq), direction, {
149
+ beyond: rows.length > limit,
150
+ resumed: from !== undefined,
151
+ }),
101
152
  });
102
153
  }
103
- const page = parsed.data;
104
- return ok({
105
- records: page,
106
- ...pageEnds(page.map((record) => record.seq), direction, {
107
- beyond: rows.length > limit,
108
- resumed: from !== undefined,
109
- }),
110
- });
111
- }
112
- catch (cause) {
113
- return err(failure(cause, "could not read telemetry"));
114
- }
115
- },
116
- /**
117
- * One statement, and the count comes from the rows it returns rather than
118
- * from a driver-specific `rowCount` field — the two drivers this runs on
119
- * report that differently, and a number that means something else under
120
- * PGlite than under postgres.js is worse than no number.
121
- *
122
- * Returning only `seq` keeps the payload to one integer per row, and the
123
- * caller has already bounded how many rows there can be: `applyRetention`
124
- * derives `before` from a scan it capped itself.
125
- */
126
- forget: async ({ before }) => {
127
- try {
128
- const removed = await db
129
- .delete(loomTelemetry)
130
- .where(lt(loomTelemetry.seq, before))
131
- .returning({ seq: loomTelemetry.seq });
132
- return ok({ removed: removed.length });
133
- }
134
- catch (cause) {
135
- return err(failure(cause, `could not forget telemetry below ${before}`));
136
- }
137
- },
138
- });
154
+ catch (cause) {
155
+ return err(failure(cause, "could not read telemetry"));
156
+ }
157
+ },
158
+ /**
159
+ * One statement, one row per proposal, and the index the table's own comment
160
+ * said would arrive the day a query needed it.
161
+ *
162
+ * `DISTINCT ON` is what makes this bounded by construction rather than by a
163
+ * limit: the row count *is* the number of ids asked about, whatever the
164
+ * journal holds, so a proposal narrated twice cannot widen the read. Ordering
165
+ * by `seq DESC` within each id picks the latest assessment, which is the same
166
+ * answer the in-memory journal folds its way to.
167
+ *
168
+ * The two JSON paths are the shape of a `change-assessed` record and nothing
169
+ * else, which is why the index below them is partial: the predicate is the
170
+ * discriminant, so the index holds one entry per assessed proposal rather than
171
+ * one per row of a journal that is mostly other event types.
172
+ */
173
+ assessments: async ({ proposalIds, treeId }) => {
174
+ const { asked, unasked } = splitLookup(proposalIds);
175
+ if (asked.length === 0) {
176
+ return ok({ assessments: new Map(), unasked });
177
+ }
178
+ try {
179
+ const rows = await db
180
+ .selectDistinctOn([ASSESSED_PROPOSAL_ID], { assessment: ASSESSMENT })
181
+ .from(loomTelemetry)
182
+ .where(mine(eq(ASSESSED_TYPE, "change-assessed"), inArray(ASSESSED_PROPOSAL_ID, asked), treeId === undefined ? undefined : eq(loomTelemetry.treeId, treeId)))
183
+ .orderBy(ASSESSED_PROPOSAL_ID, desc(loomTelemetry.seq));
184
+ const parsed = z.array(assessmentSummarySchema).safeParse(rows.map((row) => row.assessment));
185
+ if (!parsed.success) {
186
+ return err({
187
+ code: "unavailable",
188
+ detail: `a stored assessment did not parse: ${parsed.error.issues[0]?.path.join(".") ?? "unknown"}`,
189
+ });
190
+ }
191
+ const assessments = parsed.data;
192
+ return ok({
193
+ assessments: new Map(assessments.map((assessment) => [assessment.proposalId, assessment])),
194
+ unasked,
195
+ });
196
+ }
197
+ catch (cause) {
198
+ return err(failure(cause, `could not look up ${asked.length} assessments`));
199
+ }
200
+ },
201
+ /**
202
+ * One statement, and the count comes from the rows it returns rather than
203
+ * from a driver-specific `rowCount` field — the two drivers this runs on
204
+ * report that differently, and a number that means something else under
205
+ * PGlite than under postgres.js is worse than no number.
206
+ *
207
+ * Returning only `seq` keeps the payload to one integer per row, and the
208
+ * caller has already bounded how many rows there can be: `applyRetention`
209
+ * derives `before` from a scan it capped itself.
210
+ */
211
+ forget: async ({ before }) => {
212
+ try {
213
+ const removed = await db
214
+ .delete(loomTelemetry)
215
+ /**
216
+ * Scoped like every read on this handle, which it was not when the
217
+ * application dimension landed (0269) — `forget` was the one statement
218
+ * in this file that did not go through `mine`.
219
+ *
220
+ * It matters more here than anywhere else in the file. `seq` is a
221
+ * `bigserial`, so it counts across every application the database
222
+ * holds: retention run for one application was deleting every other
223
+ * application's records below the same sequence number, and a deleted
224
+ * telemetry row is not recoverable from anything. Nothing had reached
225
+ * it, because nothing constructs a second handle yet.
226
+ */
227
+ .where(mine(lt(loomTelemetry.seq, before)))
228
+ .returning({ seq: loomTelemetry.seq });
229
+ return ok({ removed: removed.length });
230
+ }
231
+ catch (cause) {
232
+ return err(failure(cause, `could not forget telemetry below ${before}`));
233
+ }
234
+ },
235
+ };
236
+ };
139
237
  //# sourceMappingURL=postgres.js.map
@@ -0,0 +1,78 @@
1
+ import { type GatePolicy, type StakeFactorCode, type StakeLevel } from "../runtime/index.js";
2
+ import type { AssessmentSummary } from "./event.js";
3
+ /**
4
+ * What these stakes would have been, under a policy that was not in force.
5
+ *
6
+ * ## The question, and why only a record can answer it
7
+ *
8
+ * A host that wants to change its Gate policy has one thing worth consulting:
9
+ * the changes it really judged. `/portal/rules/what-if` replays the eight rungs
10
+ * of the escalation ladder against an edited policy and reproduces every recorded
11
+ * verdict before it is believed — but only seven of a policy's seventeen fields
12
+ * could be moved, because the other ten move the **measurement** and the
13
+ * measurement was a function of a page as it stood that day. The level was
14
+ * recorded; how it was arrived at was not.
15
+ *
16
+ * `remeasureStakes` is the missing half. It takes a journalled
17
+ * `AssessmentSummary` and a policy, re-runs the Gate's own measuring rules
18
+ * against it, and says what the stakes would have been.
19
+ *
20
+ * ## It is the Gate's rules, not a copy of them
21
+ *
22
+ * The seven policy-dependent rules are `measureStakes`, exactly as
23
+ * `assessStakes` runs them, against a `StakeMeasurement` this module assembles
24
+ * from the record instead of from a delta. Nothing here knows what a large
25
+ * removal is. A simulation that reimplemented the thresholds would be confidently
26
+ * wrong about the one subject a person came to it to be sure of, and it would go
27
+ * wrong silently, months after the copy was made.
28
+ *
29
+ * The other seven rules — an unreachable target, an unregistered type, props a
30
+ * primitive refuses, a question nothing reads, a redirected form, a repointed
31
+ * region, discarded work — cannot be re-run at all, because each reads a list of
32
+ * specifics that names parts of a particular page and does not cross the
33
+ * telemetry boundary (0023). They do not need to be: no field of a policy moves
34
+ * them, so the recorded code is the whole of the answer and `fixedStakeLevel`
35
+ * turns it back into a level. Those come back `source: "recorded"`.
36
+ *
37
+ * ## What it refuses to guess
38
+ *
39
+ * Four of the fields this needs are optional on the record, because 0045 says a
40
+ * telemetry field added after records exist is optional and never defaulted. So
41
+ * an older record may genuinely not say whether a protected prop was configured.
42
+ * **Defaulting that to "no" would silently lower the stakes of exactly the
43
+ * changes an operator is asking about**, and the answer would look like a result.
44
+ *
45
+ * Instead the rule is named in `unreadable` and left out of the level, which
46
+ * makes `level` a floor rather than an answer — the true stakes are that level or
47
+ * higher. A caller showing a figure to a person must say so, or set the row
48
+ * aside; `/portal/rules/what-if` already sets aside every change it cannot
49
+ * reproduce, and this is the same discipline one step earlier.
50
+ *
51
+ * A rule is only unreadable when the policy would actually have consulted the
52
+ * missing field. A host with nothing protected is not asking about protected
53
+ * types, and a record whose change removed nothing cannot have removed a
54
+ * protected type whatever it failed to write down — so the common case, an
55
+ * ordinary record under an ordinary policy, is readable in full.
56
+ */
57
+ /** One rule's contribution, and whether it was run again or taken as it stood. */
58
+ export type RemeasuredFactor = {
59
+ readonly code: StakeFactorCode;
60
+ readonly level: StakeLevel;
61
+ /**
62
+ * `remeasured` — this rule was run against the policy given here.
63
+ * `recorded` — no field of a policy can move it, so its code is its level.
64
+ */
65
+ readonly source: "remeasured" | "recorded";
66
+ };
67
+ export type RemeasuredStakes = {
68
+ /** A floor, not an answer, whenever `unreadable` is not empty. */
69
+ readonly level: StakeLevel;
70
+ readonly factors: readonly RemeasuredFactor[];
71
+ /**
72
+ * Rules this record cannot answer under this policy, because a field they read
73
+ * was not written down. Empty is the claim that `level` is exact.
74
+ */
75
+ readonly unreadable: readonly StakeFactorCode[];
76
+ };
77
+ export declare const remeasureStakes: (summary: AssessmentSummary, policy: GatePolicy) => RemeasuredStakes;
78
+ //# sourceMappingURL=remeasure.d.ts.map
@@ -0,0 +1,83 @@
1
+ import { FIXED_STAKE_FACTOR_CODES, fixedStakeLevel, highestStake, isFixedStakeFactor, measureStakes, } from "../runtime/index.js";
2
+ /**
3
+ * The largest `affectedNodeIds` could have been, from counts every record
4
+ * carries.
5
+ *
6
+ * Breadth is the one measuring rule whose input is a length, and a record
7
+ * written before `affectedNodeCount` existed does not carry it. It is still
8
+ * bounded: an insert or a remove contributes its whole subtree to both the
9
+ * affected set and its own node count, a move and a configure contribute one
10
+ * node to both, and the affected set is a set — so it can never be larger than
11
+ * the four counts added up. When even that ceiling is under the threshold the
12
+ * rule provably cannot fire, and the missing field does not matter.
13
+ *
14
+ * This is what makes the lever answerable over a journal written before today
15
+ * rather than only over records written after it.
16
+ */
17
+ const affectedNodeCeiling = (summary) => summary.insertedNodeCount +
18
+ summary.removedNodeCount +
19
+ summary.movedNodeCount +
20
+ summary.configuredNodeCount;
21
+ /**
22
+ * Whether a rule's missing input can change its answer.
23
+ *
24
+ * Absent is not empty (0045), so the question is never "what shall we assume" —
25
+ * it is whether this policy, on this record, could have reached the field at
26
+ * all. Each entry is a fact about the record and not a default: a change that
27
+ * removed no nodes removed no types, a change that configured no nodes set no
28
+ * prop keys, and a policy protecting nothing never looks at either list.
29
+ */
30
+ const unreadableUnder = (summary, policy) => {
31
+ const protects = policy.protectedPrimitiveTypes.length > 0;
32
+ return [
33
+ ...(protects && summary.removedPrimitiveTypes === undefined && summary.removedNodeCount > 0
34
+ ? ["protected-type-removed"]
35
+ : []),
36
+ ...(protects && summary.relocatedPrimitiveTypes === undefined && summary.movedNodeCount > 0
37
+ ? ["protected-type-relocated"]
38
+ : []),
39
+ ...(policy.protectedPropKeys.length > 0 &&
40
+ summary.configuredPropKeys === undefined &&
41
+ summary.configuredNodeCount > 0
42
+ ? ["protected-prop-configured"]
43
+ : []),
44
+ ...(summary.affectedNodeCount === undefined &&
45
+ affectedNodeCeiling(summary) >= policy.breadthThreshold
46
+ ? ["broad-change"]
47
+ : []),
48
+ ...(summary.stakeFactorCodes === undefined ? FIXED_STAKE_FACTOR_CODES : []),
49
+ ];
50
+ };
51
+ /**
52
+ * The record as a measurement, with every absent list read as absent.
53
+ *
54
+ * `[]` here is not a claim that nothing happened — it is what the rule has to be
55
+ * handed to produce no factor, and `unreadableUnder` is what says the resulting
56
+ * silence may be ignorance rather than a measurement. The two halves are
57
+ * separate on purpose: a measurement cannot hold "unknown", and a level cannot
58
+ * carry a caveat.
59
+ */
60
+ const measurementFrom = (summary) => ({
61
+ insertedNodeCount: summary.insertedNodeCount,
62
+ removedNodeCount: summary.removedNodeCount,
63
+ movedNodeCount: summary.movedNodeCount,
64
+ affectedNodeCount: summary.affectedNodeCount ?? 0,
65
+ shallowestAffectedDepth: summary.shallowestAffectedDepth,
66
+ touchedPrimitiveTypes: summary.touchedPrimitiveTypes,
67
+ removedPrimitiveTypes: summary.removedPrimitiveTypes ?? [],
68
+ relocatedPrimitiveTypes: summary.relocatedPrimitiveTypes ?? [],
69
+ configuredPropKeys: summary.configuredPropKeys ?? [],
70
+ });
71
+ export const remeasureStakes = (summary, policy) => {
72
+ const remeasured = measureStakes(measurementFrom(summary), policy).map((factor) => ({ code: factor.code, level: factor.level, source: "remeasured" }));
73
+ const carried = (summary.stakeFactorCodes ?? [])
74
+ .filter(isFixedStakeFactor)
75
+ .map((code) => ({ code, level: fixedStakeLevel(code), source: "recorded" }));
76
+ const factors = [...remeasured, ...carried];
77
+ return {
78
+ level: highestStake(factors.map((factor) => factor.level)),
79
+ factors,
80
+ unreadable: unreadableUnder(summary, policy),
81
+ };
82
+ };
83
+ //# sourceMappingURL=remeasure.js.map
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { type Clock } from "../runtime/events.js";
3
- import type { RecordedTelemetry, TelemetryError, TelemetryJournal } from "./journal.js";
3
+ import type { RecordedTelemetry, TelemetryError, TelemetryPruner } from "./journal.js";
4
4
  /**
5
5
  * How a journal is allowed to forget.
6
6
  *
@@ -125,7 +125,7 @@ export type RetentionOutcome = {
125
125
  * forget is an operational choice, and a framework that quietly deleted a
126
126
  * host's history on a timer it chose would be making it.
127
127
  */
128
- export declare const applyRetention: (journal: TelemetryJournal, request: RetentionRequest) => Promise<RetentionOutcome>;
128
+ export declare const applyRetention: (journal: TelemetryPruner, request: RetentionRequest) => Promise<RetentionOutcome>;
129
129
  /** One line for an operator, because an outcome nobody can read is an outcome nobody acts on. */
130
130
  export declare const describeRetention: (outcome: RetentionOutcome) => string;
131
131
  //# sourceMappingURL=retention.d.ts.map
@@ -22,6 +22,23 @@ export declare const loomTelemetry: import("drizzle-orm/pg-core").PgTableWithCol
22
22
  name: "loom_telemetry";
23
23
  schema: undefined;
24
24
  columns: {
25
+ applicationId: import("drizzle-orm/pg-core").PgColumn<{
26
+ name: "application_id";
27
+ tableName: "loom_telemetry";
28
+ dataType: "string";
29
+ columnType: "PgText";
30
+ data: string;
31
+ driverParam: string;
32
+ notNull: true;
33
+ hasDefault: true;
34
+ isPrimaryKey: false;
35
+ isAutoincrement: false;
36
+ hasRuntimeDefault: false;
37
+ enumValues: [string, ...string[]];
38
+ baseColumn: never;
39
+ identity: undefined;
40
+ generated: undefined;
41
+ }, {}, {}>;
25
42
  seq: import("drizzle-orm/pg-core").PgColumn<{
26
43
  name: "seq";
27
44
  tableName: "loom_telemetry";
@@ -21,6 +21,17 @@ import { bigserial, index, jsonb, pgTable, text, timestamp } from "drizzle-orm/p
21
21
  * duplicated column is a migration away from being wrong.
22
22
  */
23
23
  export const loomTelemetry = pgTable("loom_telemetry", {
24
+ /**
25
+ * The project the record belongs to (0260).
26
+ *
27
+ * **The key does not widen here, and that is the difference from the other
28
+ * tables.** `seq` is a surrogate from a sequence rather than anything a
29
+ * caller names: it is the journal's order and its cursor, and a cursor that
30
+ * only orders within a project would stop being a single thread of what
31
+ * happened. So the column is added, the indexes lead with it, and every
32
+ * read filters on it — while `seq` stays unique across the deployment.
33
+ */
34
+ applicationId: text("application_id").notNull().default("app_default"),
24
35
  seq: bigserial("seq", { mode: "number" }).primaryKey(),
25
36
  treeId: text("tree_id").notNull(),
26
37
  /** When the runtime said it happened, which is not when the row was written. */
@@ -29,5 +40,20 @@ export const loomTelemetry = pgTable("loom_telemetry", {
29
40
  recordedAt: timestamp("recorded_at", { withTimezone: true })
30
41
  .notNull()
31
42
  .default(sql `now()`),
32
- }, (table) => [index("loom_telemetry_tree_seq_idx").on(table.treeId, table.seq)]);
43
+ }, (table) => [
44
+ index("loom_telemetry_tree_seq_idx").on(table.applicationId, table.treeId, table.seq),
45
+ /**
46
+ * The JSON-path index the comment above promised, partial on the one event
47
+ * type that carries an assessment. `assessments` on the journal looks a set
48
+ * of proposals up by this path; without it that is a sequential scan of
49
+ * every record the deployment has ever narrated.
50
+ *
51
+ * Partial rather than whole because the predicate is the discriminant: only
52
+ * `change-assessed` records have the path at all, and an index over the rest
53
+ * would be an entry per row holding nothing.
54
+ */
55
+ index("loom_telemetry_assessed_proposal_idx")
56
+ .on(table.applicationId, sql `(${table.event} -> 'assessment' ->> 'proposalId')`)
57
+ .where(sql `${table.event} ->> 'type' = 'change-assessed'`),
58
+ ]);
33
59
  //# sourceMappingURL=schema.js.map
@@ -1,7 +1,7 @@
1
1
  import { type Result } from "../result.js";
2
2
  import type { EventSink } from "../runtime/events.js";
3
3
  import { type TelemetryRecord } from "./event.js";
4
- import type { TelemetryError, TelemetryJournal } from "./journal.js";
4
+ import type { TelemetryError, TelemetryWriter } from "./journal.js";
5
5
  /**
6
6
  * The seam between a runtime narrating itself and a journal that outlives the
7
7
  * request (0024).
@@ -38,5 +38,5 @@ export type TelemetryCollector = {
38
38
  */
39
39
  readonly flush: () => Promise<Result<void, TelemetryError>>;
40
40
  };
41
- export declare const collectTelemetry: (journal: TelemetryJournal) => TelemetryCollector;
41
+ export declare const collectTelemetry: (journal: TelemetryWriter) => TelemetryCollector;
42
42
  //# sourceMappingURL=sink.d.ts.map