@sixb/core 0.1.13 → 0.1.15

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 (236) hide show
  1. package/dist/actions/index.js +22 -22
  2. package/dist/agents/index.js +34 -34
  3. package/dist/agents/index.js.map +1 -1
  4. package/dist/agents/streams/index.js +2 -2
  5. package/dist/agents/streams/internal.js +2 -2
  6. package/dist/auth/errors.d.ts +12 -0
  7. package/dist/auth/errors.d.ts.map +1 -1
  8. package/dist/auth/index.d.ts +1 -1
  9. package/dist/auth/index.d.ts.map +1 -1
  10. package/dist/auth/index.js +7 -5
  11. package/dist/auth/index.js.map +1 -1
  12. package/dist/auth/runtime.d.ts.map +1 -1
  13. package/dist/auth/strategy.d.ts +2 -0
  14. package/dist/auth/strategy.d.ts.map +1 -1
  15. package/dist/auth/strategy.js +4 -2
  16. package/dist/auth/strategy.js.map +1 -1
  17. package/dist/auth/types.d.ts +8 -0
  18. package/dist/auth/types.d.ts.map +1 -1
  19. package/dist/authorization/index.js +2 -2
  20. package/dist/bootstrap/index.js +37 -37
  21. package/dist/{chunk-693f3zn8.js → chunk-1jvq82rp.js} +3 -3
  22. package/dist/{chunk-0321g649.js → chunk-2jntasmh.js} +13 -2
  23. package/dist/{chunk-0321g649.js.map → chunk-2jntasmh.js.map} +3 -3
  24. package/dist/{chunk-cvrbhvtr.js → chunk-2tz5vnvz.js} +28 -28
  25. package/dist/{chunk-cvrbhvtr.js.map → chunk-2tz5vnvz.js.map} +1 -1
  26. package/dist/{chunk-898y24dd.js → chunk-3c90jvfj.js} +2 -2
  27. package/dist/{chunk-vn3yh259.js → chunk-4gmng3vf.js} +1 -1
  28. package/dist/{chunk-91wthfwe.js → chunk-4jph1t3v.js} +7 -7
  29. package/dist/{chunk-znw0zvy4.js → chunk-4wn7bxxa.js} +25 -7
  30. package/dist/chunk-4wn7bxxa.js.map +12 -0
  31. package/dist/{chunk-3qpcrcj8.js → chunk-6aawea28.js} +2 -4
  32. package/dist/chunk-6aawea28.js.map +10 -0
  33. package/dist/{chunk-rzkr70gr.js → chunk-6fsr7y93.js} +5 -1
  34. package/dist/{chunk-rzkr70gr.js.map → chunk-6fsr7y93.js.map} +3 -3
  35. package/dist/{chunk-y487ywrv.js → chunk-6q7c68yx.js} +4 -4
  36. package/dist/{chunk-ypj2wqtj.js → chunk-70jmg2zx.js} +2 -2
  37. package/dist/{chunk-s24qbp32.js → chunk-7jc21943.js} +3 -3
  38. package/dist/{chunk-rzcjp5m2.js → chunk-8fjmqjyx.js} +1 -1
  39. package/dist/{chunk-m8zkvep1.js → chunk-8w27xf9e.js} +1 -1
  40. package/dist/{chunk-z9h698s8.js → chunk-a4g5yjm0.js} +1 -1
  41. package/dist/{chunk-gmt22nxx.js → chunk-adbve9zt.js} +1 -1
  42. package/dist/{chunk-mf6hwpzh.js → chunk-dqkd3kdj.js} +41 -23
  43. package/dist/{chunk-mf6hwpzh.js.map → chunk-dqkd3kdj.js.map} +3 -3
  44. package/dist/{chunk-gbcrz0gr.js → chunk-ex8s8wsk.js} +6 -6
  45. package/dist/{chunk-4tnrzqqh.js → chunk-fj1dvp37.js} +1 -1
  46. package/dist/{chunk-gc226ten.js → chunk-fjw417jf.js} +127 -69
  47. package/dist/{chunk-gc226ten.js.map → chunk-fjw417jf.js.map} +4 -4
  48. package/dist/{chunk-ht4a7mjg.js → chunk-g4rbm4a6.js} +42 -8
  49. package/dist/{chunk-ht4a7mjg.js.map → chunk-g4rbm4a6.js.map} +3 -3
  50. package/dist/{chunk-qma80ych.js → chunk-hn2r7z41.js} +3 -2
  51. package/dist/chunk-hn2r7z41.js.map +11 -0
  52. package/dist/{chunk-bdhfn0ww.js → chunk-kkqwzy6h.js} +1 -1
  53. package/dist/{chunk-bep5rrdq.js → chunk-mmac1mp6.js} +2 -2
  54. package/dist/{chunk-w9bp61e7.js → chunk-n5t4mq6z.js} +5 -5
  55. package/dist/{chunk-n33e8dz8.js → chunk-p0nbkys4.js} +1 -1
  56. package/dist/{chunk-04h4t2b5.js → chunk-py2dw8cw.js} +3 -3
  57. package/dist/{chunk-jhyc777j.js → chunk-q3grgzp1.js} +2 -2
  58. package/dist/{chunk-9pfw47qx.js → chunk-qne45xqq.js} +53 -48
  59. package/dist/{chunk-9pfw47qx.js.map → chunk-qne45xqq.js.map} +7 -7
  60. package/dist/{chunk-cbn96bve.js → chunk-r5sc1d2b.js} +2 -2
  61. package/dist/{chunk-y6vnvayj.js → chunk-vjcd8d27.js} +1 -1
  62. package/dist/{chunk-jmwy25mf.js → chunk-wd34wnsy.js} +6 -6
  63. package/dist/{chunk-63fp9x3q.js → chunk-wem5vqjw.js} +7 -7
  64. package/dist/{chunk-darm7eeg.js → chunk-xr7y35yj.js} +3 -3
  65. package/dist/{chunk-a69fkrtr.js → chunk-y0zmae99.js} +5 -5
  66. package/dist/{chunk-xgptywp0.js → chunk-y2aq6ag9.js} +1 -1
  67. package/dist/{chunk-2hbhn1ff.js → chunk-yfppyaty.js} +1 -1
  68. package/dist/{chunk-rqtdtm43.js → chunk-z708gemf.js} +129 -70
  69. package/dist/{chunk-rqtdtm43.js.map → chunk-z708gemf.js.map} +5 -5
  70. package/dist/deploy/define.d.ts +4 -0
  71. package/dist/deploy/define.d.ts.map +1 -0
  72. package/dist/deploy/index.d.ts +3 -0
  73. package/dist/deploy/index.d.ts.map +1 -0
  74. package/dist/deploy/index.js +10 -0
  75. package/dist/deploy/index.js.map +10 -0
  76. package/dist/deploy/internal.d.ts +3 -0
  77. package/dist/deploy/internal.d.ts.map +1 -0
  78. package/dist/deploy/internal.js +244 -0
  79. package/dist/deploy/internal.js.map +11 -0
  80. package/dist/deploy/services.d.ts +8 -0
  81. package/dist/deploy/services.d.ts.map +1 -0
  82. package/dist/deploy/types.d.ts +309 -0
  83. package/dist/deploy/types.d.ts.map +1 -0
  84. package/dist/deploy/validation.d.ts +7 -0
  85. package/dist/deploy/validation.d.ts.map +1 -0
  86. package/dist/error-reporting/internal.js +3 -3
  87. package/dist/errors/catalog.d.ts +4 -0
  88. package/dist/errors/catalog.d.ts.map +1 -1
  89. package/dist/errors/internal.js +1 -1
  90. package/dist/events/index.js +3 -3
  91. package/dist/execution/agent.js +33 -33
  92. package/dist/execution/primitive.js +29 -29
  93. package/dist/execution/request.js +31 -31
  94. package/dist/execution/request.js.map +1 -1
  95. package/dist/index.js +49 -49
  96. package/dist/index.js.map +1 -1
  97. package/dist/maintenance/ontology-maintenance.d.ts +2 -0
  98. package/dist/maintenance/ontology-maintenance.d.ts.map +1 -1
  99. package/dist/maintenance/types.d.ts +8 -2
  100. package/dist/maintenance/types.d.ts.map +1 -1
  101. package/dist/materialization/dataset-watermark.d.ts +6 -1
  102. package/dist/materialization/dataset-watermark.d.ts.map +1 -1
  103. package/dist/materialization/index.js +1 -1
  104. package/dist/materialization/model.d.ts +6 -0
  105. package/dist/materialization/model.d.ts.map +1 -1
  106. package/dist/materializer/index.js +18 -18
  107. package/dist/materializer/index.js.map +1 -1
  108. package/dist/materializer/projections/finish-run.d.ts.map +1 -1
  109. package/dist/materializer/projections/replace.d.ts.map +1 -1
  110. package/dist/materializer/projections/source-materialization.d.ts +6 -2
  111. package/dist/materializer/projections/source-materialization.d.ts.map +1 -1
  112. package/dist/models/execution/index.js +14 -14
  113. package/dist/objects/index.js +21 -21
  114. package/dist/objects/query/index.js +15 -15
  115. package/dist/pipelines/index.js +19 -19
  116. package/dist/projections/internal.js +16 -16
  117. package/dist/projections/types.d.ts +1 -1
  118. package/dist/projections/types.d.ts.map +1 -1
  119. package/dist/queues/in-memory.d.ts +1 -1
  120. package/dist/queues/in-memory.d.ts.map +1 -1
  121. package/dist/runtime/internal.js +19 -19
  122. package/dist/shares/internal.js +14 -14
  123. package/dist/shares/internal.js.map +1 -1
  124. package/dist/storage/action-runs/failure.js +2 -2
  125. package/dist/storage/ai-limits/enforcement.js +2 -2
  126. package/dist/storage/auth/errors.d.ts +1 -1
  127. package/dist/storage/auth/errors.d.ts.map +1 -1
  128. package/dist/storage/auth/in-memory/auth-storage.d.ts +2 -1
  129. package/dist/storage/auth/in-memory/auth-storage.d.ts.map +1 -1
  130. package/dist/storage/auth/types.d.ts +15 -7
  131. package/dist/storage/auth/types.d.ts.map +1 -1
  132. package/dist/storage/connector-connections/provider.js +1 -1
  133. package/dist/storage/file-upload-sessions/provider.js +5 -5
  134. package/dist/storage/index.d.ts +2 -2
  135. package/dist/storage/index.d.ts.map +1 -1
  136. package/dist/storage/index.js +29 -29
  137. package/dist/storage/index.js.map +1 -1
  138. package/dist/storage/internal.js +1 -1
  139. package/dist/storage/ontology/in-memory/sources.d.ts +6 -3
  140. package/dist/storage/ontology/in-memory/sources.d.ts.map +1 -1
  141. package/dist/storage/ontology/index.d.ts +1 -1
  142. package/dist/storage/ontology/index.d.ts.map +1 -1
  143. package/dist/storage/ontology/provider.d.ts +16 -3
  144. package/dist/storage/ontology/provider.d.ts.map +1 -1
  145. package/dist/storage/ontology/provider.js +8 -4
  146. package/dist/storage/ontology/provider.js.map +1 -1
  147. package/dist/storage/ontology/sources.d.ts +36 -8
  148. package/dist/storage/ontology/sources.d.ts.map +1 -1
  149. package/dist/storage/projection-runs/in-memory.d.ts +3 -1
  150. package/dist/storage/projection-runs/in-memory.d.ts.map +1 -1
  151. package/dist/storage/projection-runs/index.d.ts +1 -1
  152. package/dist/storage/projection-runs/index.d.ts.map +1 -1
  153. package/dist/storage/projection-runs/lifecycle.d.ts +12 -0
  154. package/dist/storage/projection-runs/lifecycle.d.ts.map +1 -1
  155. package/dist/storage/projection-runs/provider.js +10 -4
  156. package/dist/storage/projection-runs/provider.js.map +1 -1
  157. package/dist/storage/projection-runs/types.d.ts +32 -1
  158. package/dist/storage/projection-runs/types.d.ts.map +1 -1
  159. package/dist/storage/workflow-runs/provider.js +5 -5
  160. package/dist/syncs/index.js +20 -20
  161. package/dist/testing/auth-storage-contract.d.ts.map +1 -1
  162. package/dist/testing/index.js +381 -171
  163. package/dist/testing/index.js.map +5 -5
  164. package/dist/testing/ontology-storage-contract.d.ts.map +1 -1
  165. package/dist/testing/projection-run-storage-contract.d.ts.map +1 -1
  166. package/dist/webhooks/internal.js +15 -15
  167. package/dist/webhooks/internal.js.map +1 -1
  168. package/dist/workers/index.js +1 -1
  169. package/dist/workflows/index.js +34 -34
  170. package/package.json +13 -1
  171. package/src/auth/errors.ts +23 -0
  172. package/src/auth/index.ts +1 -1
  173. package/src/auth/runtime.ts +56 -22
  174. package/src/auth/strategy.ts +2 -0
  175. package/src/auth/types.ts +8 -0
  176. package/src/deploy/define.ts +6 -0
  177. package/src/deploy/index.ts +41 -0
  178. package/src/deploy/internal.ts +7 -0
  179. package/src/deploy/services.ts +51 -0
  180. package/src/deploy/types.ts +338 -0
  181. package/src/deploy/validation.ts +261 -0
  182. package/src/errors/catalog.ts +4 -0
  183. package/src/maintenance/ontology-maintenance.ts +32 -2
  184. package/src/maintenance/types.ts +8 -2
  185. package/src/materialization/dataset-watermark.ts +6 -4
  186. package/src/materialization/model.ts +7 -0
  187. package/src/materializer/README.md +26 -6
  188. package/src/materializer/projections/finish-run.ts +129 -26
  189. package/src/materializer/projections/replace.ts +67 -49
  190. package/src/materializer/projections/source-materialization.ts +11 -6
  191. package/src/projections/types.ts +1 -0
  192. package/src/storage/auth/errors.ts +0 -1
  193. package/src/storage/auth/in-memory/auth-storage.ts +44 -65
  194. package/src/storage/auth/types.ts +15 -7
  195. package/src/storage/index.ts +6 -1
  196. package/src/storage/ontology/in-memory/sources.ts +119 -55
  197. package/src/storage/ontology/index.ts +4 -1
  198. package/src/storage/ontology/provider.ts +64 -7
  199. package/src/storage/ontology/sources.ts +42 -8
  200. package/src/storage/projection-runs/in-memory.ts +41 -2
  201. package/src/storage/projection-runs/index.ts +2 -0
  202. package/src/storage/projection-runs/lifecycle.ts +61 -4
  203. package/src/storage/projection-runs/types.ts +41 -1
  204. package/src/testing/auth-storage-contract.ts +104 -130
  205. package/src/testing/ontology-storage-contract.ts +141 -15
  206. package/src/testing/projection-run-storage-contract.ts +174 -1
  207. package/dist/chunk-3qpcrcj8.js.map +0 -10
  208. package/dist/chunk-qma80ych.js.map +0 -11
  209. package/dist/chunk-znw0zvy4.js.map +0 -12
  210. /package/dist/{chunk-693f3zn8.js.map → chunk-1jvq82rp.js.map} +0 -0
  211. /package/dist/{chunk-898y24dd.js.map → chunk-3c90jvfj.js.map} +0 -0
  212. /package/dist/{chunk-vn3yh259.js.map → chunk-4gmng3vf.js.map} +0 -0
  213. /package/dist/{chunk-91wthfwe.js.map → chunk-4jph1t3v.js.map} +0 -0
  214. /package/dist/{chunk-y487ywrv.js.map → chunk-6q7c68yx.js.map} +0 -0
  215. /package/dist/{chunk-ypj2wqtj.js.map → chunk-70jmg2zx.js.map} +0 -0
  216. /package/dist/{chunk-s24qbp32.js.map → chunk-7jc21943.js.map} +0 -0
  217. /package/dist/{chunk-rzcjp5m2.js.map → chunk-8fjmqjyx.js.map} +0 -0
  218. /package/dist/{chunk-m8zkvep1.js.map → chunk-8w27xf9e.js.map} +0 -0
  219. /package/dist/{chunk-z9h698s8.js.map → chunk-a4g5yjm0.js.map} +0 -0
  220. /package/dist/{chunk-gmt22nxx.js.map → chunk-adbve9zt.js.map} +0 -0
  221. /package/dist/{chunk-gbcrz0gr.js.map → chunk-ex8s8wsk.js.map} +0 -0
  222. /package/dist/{chunk-4tnrzqqh.js.map → chunk-fj1dvp37.js.map} +0 -0
  223. /package/dist/{chunk-bdhfn0ww.js.map → chunk-kkqwzy6h.js.map} +0 -0
  224. /package/dist/{chunk-bep5rrdq.js.map → chunk-mmac1mp6.js.map} +0 -0
  225. /package/dist/{chunk-w9bp61e7.js.map → chunk-n5t4mq6z.js.map} +0 -0
  226. /package/dist/{chunk-n33e8dz8.js.map → chunk-p0nbkys4.js.map} +0 -0
  227. /package/dist/{chunk-04h4t2b5.js.map → chunk-py2dw8cw.js.map} +0 -0
  228. /package/dist/{chunk-jhyc777j.js.map → chunk-q3grgzp1.js.map} +0 -0
  229. /package/dist/{chunk-cbn96bve.js.map → chunk-r5sc1d2b.js.map} +0 -0
  230. /package/dist/{chunk-y6vnvayj.js.map → chunk-vjcd8d27.js.map} +0 -0
  231. /package/dist/{chunk-jmwy25mf.js.map → chunk-wd34wnsy.js.map} +0 -0
  232. /package/dist/{chunk-63fp9x3q.js.map → chunk-wem5vqjw.js.map} +0 -0
  233. /package/dist/{chunk-darm7eeg.js.map → chunk-xr7y35yj.js.map} +0 -0
  234. /package/dist/{chunk-a69fkrtr.js.map → chunk-y0zmae99.js.map} +0 -0
  235. /package/dist/{chunk-xgptywp0.js.map → chunk-y2aq6ag9.js.map} +0 -0
  236. /package/dist/{chunk-2hbhn1ff.js.map → chunk-yfppyaty.js.map} +0 -0
@@ -2,13 +2,13 @@
2
2
  import {
3
3
  AuthStorageError2,
4
4
  SYSTEM_PRINCIPAL2
5
- } from "../chunk-9pfw47qx.js";
5
+ } from "../chunk-qne45xqq.js";
6
6
  import {
7
7
  defineProjection2,
8
8
  agentServiceAccountId2,
9
9
  MAX_OBJECT_READ_FACETS2
10
- } from "../chunk-rzcjp5m2.js";
11
- import"../chunk-rzkr70gr.js";
10
+ } from "../chunk-8fjmqjyx.js";
11
+ import"../chunk-6fsr7y93.js";
12
12
  import"../chunk-z3y5kg1x.js";
13
13
  import {
14
14
  compileSelectedObjectReadScope2
@@ -17,7 +17,7 @@ import"../chunk-d8yes9yx.js";
17
17
  import {
18
18
  ref2
19
19
  } from "../chunk-drz59ve0.js";
20
- import"../chunk-0321g649.js";
20
+ import"../chunk-2jntasmh.js";
21
21
  import"../chunk-pqajwytd.js";
22
22
  import"../chunk-ky7zpbtt.js";
23
23
  import"../chunk-gfdh9kqa.js";
@@ -31,7 +31,7 @@ import {
31
31
  import {
32
32
  AiUsageStorageError2
33
33
  } from "../chunk-xnx96gfy.js";
34
- import"../chunk-xgptywp0.js";
34
+ import"../chunk-y2aq6ag9.js";
35
35
  import"../chunk-fc5zfxy1.js";
36
36
  import {
37
37
  aiLimitCalendarMonth2
@@ -39,7 +39,7 @@ import {
39
39
  import {
40
40
  DEFAULT_FILE_UPLOAD_TERMINAL_SESSION_TTL_MS2
41
41
  } from "../chunk-h89wz928.js";
42
- import"../chunk-n33e8dz8.js";
42
+ import"../chunk-p0nbkys4.js";
43
43
  import"../chunk-tw03bsmb.js";
44
44
  import {
45
45
  OntologyRegistry2,
@@ -50,7 +50,7 @@ import {
50
50
  } from "../chunk-3nx8vj5a.js";
51
51
  import {
52
52
  createEventId2
53
- } from "../chunk-ht4a7mjg.js";
53
+ } from "../chunk-g4rbm4a6.js";
54
54
  import {
55
55
  AGENT_MESSAGE_CONTENT_VERSION2,
56
56
  AiCostStorageError2,
@@ -59,30 +59,30 @@ import {
59
59
  objectLinkCursor2,
60
60
  WorkflowInterventionError2,
61
61
  InMemoryStorage2
62
- } from "../chunk-gc226ten.js";
62
+ } from "../chunk-fjw417jf.js";
63
63
  import"../chunk-7ytf06d3.js";
64
64
  import"../chunk-mr60an99.js";
65
65
  import"../chunk-mmagke4x.js";
66
- import"../chunk-qma80ych.js";
67
- import"../chunk-znw0zvy4.js";
66
+ import"../chunk-hn2r7z41.js";
67
+ import"../chunk-4wn7bxxa.js";
68
68
  import"../chunk-jmfet9r4.js";
69
69
  import"../chunk-qf954wje.js";
70
- import"../chunk-darm7eeg.js";
70
+ import"../chunk-xr7y35yj.js";
71
71
  import {
72
72
  ProjectionRegistry2,
73
73
  createLinkScopeFingerprint2,
74
74
  createOntologyMaterializer2
75
- } from "../chunk-rqtdtm43.js";
75
+ } from "../chunk-z708gemf.js";
76
76
  import {
77
77
  bindModelExecutionAttempt,
78
78
  isBoundSixb
79
- } from "../chunk-cvrbhvtr.js";
79
+ } from "../chunk-2tz5vnvz.js";
80
80
  import"../chunk-5a4a52tq.js";
81
81
  import {
82
82
  SixbHost2
83
- } from "../chunk-mf6hwpzh.js";
84
- import"../chunk-y6vnvayj.js";
85
- import"../chunk-ypj2wqtj.js";
83
+ } from "../chunk-dqkd3kdj.js";
84
+ import"../chunk-vjcd8d27.js";
85
+ import"../chunk-70jmg2zx.js";
86
86
  import"../chunk-r2y23egw.js";
87
87
  import"../chunk-dfm066qg.js";
88
88
  import {
@@ -94,18 +94,18 @@ import {
94
94
  existsObjects2,
95
95
  facetObjects2,
96
96
  executeObjectQueryLinks2
97
- } from "../chunk-898y24dd.js";
98
- import"../chunk-63fp9x3q.js";
97
+ } from "../chunk-3c90jvfj.js";
98
+ import"../chunk-wem5vqjw.js";
99
99
  import"../chunk-3qms4nax.js";
100
100
  import"../chunk-f85hpqnm.js";
101
- import"../chunk-4tnrzqqh.js";
102
- import"../chunk-gbcrz0gr.js";
103
- import"../chunk-y487ywrv.js";
101
+ import"../chunk-fj1dvp37.js";
102
+ import"../chunk-ex8s8wsk.js";
103
+ import"../chunk-6q7c68yx.js";
104
104
  import"../chunk-fb3feg1e.js";
105
105
  import"../chunk-z5rnrmz1.js";
106
106
  import"../chunk-85cd7e8c.js";
107
107
  import"../chunk-wr8qp979.js";
108
- import"../chunk-693f3zn8.js";
108
+ import"../chunk-1jvq82rp.js";
109
109
  import"../chunk-dsfw1bdr.js";
110
110
  import {
111
111
  col2,
@@ -115,14 +115,14 @@ import {
115
115
  import"../chunk-e1c18xjx.js";
116
116
  import"../chunk-9vx5e9g1.js";
117
117
  import"../chunk-dmn70ztd.js";
118
- import"../chunk-cbn96bve.js";
118
+ import"../chunk-r5sc1d2b.js";
119
119
  import {
120
120
  writeDataset2
121
121
  } from "../chunk-91kcnbf0.js";
122
- import"../chunk-vn3yh259.js";
122
+ import"../chunk-4gmng3vf.js";
123
123
  import {
124
124
  workflowAgentStepActorId2
125
- } from "../chunk-s24qbp32.js";
125
+ } from "../chunk-7jc21943.js";
126
126
  import {
127
127
  BrokerError2,
128
128
  InMemoryBroker2
@@ -135,22 +135,22 @@ import"../chunk-mdnw7nj8.js";
135
135
  import {
136
136
  SandboxNotRunningError2
137
137
  } from "../chunk-vef6qa14.js";
138
- import"../chunk-jhyc777j.js";
139
- import"../chunk-2hbhn1ff.js";
138
+ import"../chunk-q3grgzp1.js";
139
+ import"../chunk-yfppyaty.js";
140
140
  import"../chunk-7n30ybym.js";
141
- import"../chunk-jmwy25mf.js";
141
+ import"../chunk-wd34wnsy.js";
142
142
  import {
143
143
  createTestingScope
144
- } from "../chunk-z9h698s8.js";
144
+ } from "../chunk-a4g5yjm0.js";
145
145
  import"../chunk-x9v4cx1d.js";
146
146
  import"../chunk-ffwvdgk1.js";
147
- import"../chunk-a69fkrtr.js";
148
- import"../chunk-bep5rrdq.js";
149
- import"../chunk-gmt22nxx.js";
150
- import"../chunk-91wthfwe.js";
151
- import"../chunk-w9bp61e7.js";
147
+ import"../chunk-y0zmae99.js";
148
+ import"../chunk-adbve9zt.js";
149
+ import"../chunk-mmac1mp6.js";
152
150
  import"../chunk-bxx3ms5t.js";
153
- import"../chunk-04h4t2b5.js";
151
+ import"../chunk-py2dw8cw.js";
152
+ import"../chunk-4jph1t3v.js";
153
+ import"../chunk-n5t4mq6z.js";
154
154
  import {
155
155
  LakeStorageError2
156
156
  } from "../chunk-rb143ggb.js";
@@ -160,11 +160,11 @@ import {
160
160
  } from "../chunk-a0073121.js";
161
161
  import {
162
162
  restoreTrustedPrimitiveExecutionScope
163
- } from "../chunk-m8zkvep1.js";
164
- import"../chunk-zdkcdshk.js";
163
+ } from "../chunk-8w27xf9e.js";
165
164
  import"../chunk-br3k6qbf.js";
165
+ import"../chunk-zdkcdshk.js";
166
166
  import"../chunk-s3csryxe.js";
167
- import"../chunk-bdhfn0ww.js";
167
+ import"../chunk-kkqwzy6h.js";
168
168
  import"../chunk-2fv8sajb.js";
169
169
  import {
170
170
  blobIdFromDigest2
@@ -3931,6 +3931,30 @@ async function createUser(storage, input = {}) {
3931
3931
  createdAt: at4("2026-05-14T10:00:00.000Z")
3932
3932
  });
3933
3933
  }
3934
+ async function completeOidcSignInForAva(storage, directoryGroupIds) {
3935
+ await storage.oidcAuthorizationAttempts.create({
3936
+ id: "oidc_directory",
3937
+ projectId: projectId6,
3938
+ strategyId: "entra",
3939
+ audience: "atlas",
3940
+ stateHash: "directory-state",
3941
+ nonceHash: "nonce-hash",
3942
+ codeVerifier: "verifier",
3943
+ createdAt: at4("2026-05-14T10:00:00.000Z"),
3944
+ expiresAt: at4("2026-05-14T10:10:00.000Z")
3945
+ });
3946
+ await storage.completeOidcSignIn({
3947
+ projectId: projectId6,
3948
+ oidcAuthorizationAttemptId: "oidc_directory",
3949
+ stateHash: "directory-state",
3950
+ completedAt: at4("2026-05-14T10:01:00.000Z"),
3951
+ subject: "entra-ava",
3952
+ email: "ava@acme.com",
3953
+ directoryGroupIds,
3954
+ newUserId: "usr_unused",
3955
+ session: sessionInput("ses_directory")
3956
+ });
3957
+ }
3934
3958
  function runAuthStorageContractSuite(label, options) {
3935
3959
  const withStorage = async (body) => {
3936
3960
  const storage = await options.createStorage();
@@ -5299,81 +5323,6 @@ function runAuthStorageContractSuite(label, options) {
5299
5323
  await expect6(storage.groupMemberships.listForUser({ projectId: projectId6, userId: "usr_founder" })).resolves.toMatchObject([{ groupId: "security-admins", source: "manual" }]);
5300
5324
  });
5301
5325
  });
5302
- test6("closes bootstrap user creation when an active user already exists", async () => {
5303
- await withStorage(async (storage) => {
5304
- await createUser(storage, {
5305
- id: "usr_existing",
5306
- email: "existing@acme.com"
5307
- });
5308
- await storage.magicLinks.create({
5309
- id: "ml_1",
5310
- projectId: projectId6,
5311
- strategyId: "magic-link",
5312
- audience: "atlas",
5313
- email: "founder@acme.com",
5314
- tokenHash: "link-hash",
5315
- createdAt: at4("2026-05-14T10:01:00.000Z"),
5316
- expiresAt: at4("2026-05-14T10:16:00.000Z")
5317
- });
5318
- await expectAuthError(storage.completeMagicLinkSignIn({
5319
- projectId: projectId6,
5320
- magicLinkId: "ml_1",
5321
- tokenHash: "link-hash",
5322
- completedAt: at4("2026-05-14T10:03:00.000Z"),
5323
- newUserId: "usr_founder",
5324
- allowUserCreationWithoutInvitation: true,
5325
- requireNoActiveUsersForUserCreation: true,
5326
- session: sessionInput("ses_founder")
5327
- }), "user_creation_not_allowed");
5328
- await expect6(storage.users.getByEmail({ projectId: projectId6, email: "founder@acme.com" })).resolves.toBeNull();
5329
- await expect6(storage.magicLinks.getById({ projectId: projectId6, id: "ml_1" })).resolves.toMatchObject({
5330
- consumedAt: at4("2026-05-14T10:03:00.000Z")
5331
- });
5332
- });
5333
- });
5334
- test6("does not apply the bootstrap closure guard to invited user creation", async () => {
5335
- await withStorage(async (storage) => {
5336
- await createUser(storage, {
5337
- id: "usr_existing",
5338
- email: "existing@acme.com"
5339
- });
5340
- await storage.invitations.createOrUpdateActive({
5341
- id: "inv_1",
5342
- projectId: projectId6,
5343
- email: "invited@acme.com",
5344
- groupIds: ["commercial"],
5345
- createdAt: at4("2026-05-14T10:00:00.000Z"),
5346
- expiresAt: at4("2026-05-21T10:00:00.000Z")
5347
- });
5348
- await storage.magicLinks.create({
5349
- id: "ml_1",
5350
- projectId: projectId6,
5351
- strategyId: "magic-link",
5352
- audience: "atlas",
5353
- email: "invited@acme.com",
5354
- tokenHash: "link-hash",
5355
- createdAt: at4("2026-05-14T10:01:00.000Z"),
5356
- expiresAt: at4("2026-05-14T10:16:00.000Z")
5357
- });
5358
- const result = await storage.completeMagicLinkSignIn({
5359
- projectId: projectId6,
5360
- magicLinkId: "ml_1",
5361
- tokenHash: "link-hash",
5362
- completedAt: at4("2026-05-14T10:03:00.000Z"),
5363
- newUserId: "usr_invited",
5364
- requireNoActiveUsersForUserCreation: true,
5365
- session: sessionInput("ses_invited")
5366
- });
5367
- expect6(result.user).toMatchObject({
5368
- id: "usr_invited",
5369
- email: "invited@acme.com"
5370
- });
5371
- expect6(result.invitation).toMatchObject({
5372
- id: "inv_1",
5373
- status: "accepted"
5374
- });
5375
- });
5376
- });
5377
5326
  test6("consumes valid magic links when an existing user is suspended", async () => {
5378
5327
  await withStorage(async (storage) => {
5379
5328
  await createUser(storage, { status: "suspended" });
@@ -5429,7 +5378,6 @@ function runAuthStorageContractSuite(label, options) {
5429
5378
  completedAt: at4("2026-05-14T10:02:00.000Z"),
5430
5379
  subject: "00u1",
5431
5380
  email: "renamed@acme.com",
5432
- emailVerified: true,
5433
5381
  claims: { email: "renamed@acme.com" },
5434
5382
  newUserId: "usr_unused",
5435
5383
  session: sessionInput("ses_oidc")
@@ -5445,59 +5393,33 @@ function runAuthStorageContractSuite(label, options) {
5445
5393
  });
5446
5394
  });
5447
5395
  });
5448
- test6("auto-links OIDC by verified email only when explicitly allowed", async () => {
5396
+ test6("links a new OIDC identity to the existing user with its email", async () => {
5449
5397
  await withStorage(async (storage) => {
5450
5398
  await createUser(storage, { id: "usr_existing", email: "ava@acme.com" });
5451
5399
  await storage.oidcAuthorizationAttempts.create({
5452
- id: "oidc_blocked",
5400
+ id: "oidc_1",
5453
5401
  projectId: projectId6,
5454
5402
  strategyId: "okta",
5455
5403
  audience: "atlas",
5456
- stateHash: "blocked-state",
5404
+ stateHash: "state-hash",
5457
5405
  nonceHash: "nonce-hash",
5458
5406
  codeVerifier: "verifier",
5459
5407
  createdAt: at4("2026-05-14T10:00:00.000Z"),
5460
5408
  expiresAt: at4("2026-05-14T10:10:00.000Z")
5461
5409
  });
5462
- await expectAuthError(storage.completeOidcSignIn({
5463
- projectId: projectId6,
5464
- oidcAuthorizationAttemptId: "oidc_blocked",
5465
- stateHash: "blocked-state",
5466
- completedAt: at4("2026-05-14T10:01:00.000Z"),
5467
- subject: "00u1",
5468
- email: "ava@acme.com",
5469
- emailVerified: false,
5470
- autoLinkByVerifiedEmail: true,
5471
- newUserId: "usr_unused",
5472
- session: sessionInput("ses_blocked")
5473
- }), "email_link_not_allowed");
5474
- await storage.oidcAuthorizationAttempts.create({
5475
- id: "oidc_allowed",
5476
- projectId: projectId6,
5477
- strategyId: "okta",
5478
- audience: "atlas",
5479
- stateHash: "allowed-state",
5480
- nonceHash: "nonce-hash",
5481
- codeVerifier: "verifier",
5482
- createdAt: at4("2026-05-14T10:02:00.000Z"),
5483
- expiresAt: at4("2026-05-14T10:12:00.000Z")
5484
- });
5485
5410
  const result = await storage.completeOidcSignIn({
5486
5411
  projectId: projectId6,
5487
- oidcAuthorizationAttemptId: "oidc_allowed",
5488
- stateHash: "allowed-state",
5489
- completedAt: at4("2026-05-14T10:03:00.000Z"),
5412
+ oidcAuthorizationAttemptId: "oidc_1",
5413
+ stateHash: "state-hash",
5414
+ completedAt: at4("2026-05-14T10:01:00.000Z"),
5490
5415
  subject: "00u1",
5491
5416
  email: "ava@acme.com",
5492
- emailVerified: true,
5493
- autoLinkByVerifiedEmail: true,
5494
5417
  newUserId: "usr_unused",
5495
- session: sessionInput("ses_allowed")
5418
+ session: sessionInput("ses_oidc")
5496
5419
  });
5497
5420
  expect6(result.user.id).toBe("usr_existing");
5498
- expect6(result.identity).toMatchObject({
5499
- userId: "usr_existing"
5500
- });
5421
+ expect6(result.identity).toMatchObject({ subject: "00u1", userId: "usr_existing" });
5422
+ await expect6(storage.users.getById({ projectId: projectId6, id: "usr_unused" })).resolves.toBeNull();
5501
5423
  });
5502
5424
  });
5503
5425
  test6("creates new OIDC users through active invitations and applies groups", async () => {
@@ -5529,7 +5451,6 @@ function runAuthStorageContractSuite(label, options) {
5529
5451
  subject: "00u1",
5530
5452
  email: "ava@acme.com",
5531
5453
  displayName: "Ava Chen",
5532
- emailVerified: true,
5533
5454
  newUserId: "usr_oidc",
5534
5455
  session: sessionInput("ses_oidc")
5535
5456
  });
@@ -5570,14 +5491,13 @@ function runAuthStorageContractSuite(label, options) {
5570
5491
  completedAt: at4("2026-05-14T10:01:00.000Z"),
5571
5492
  subject: "00u1",
5572
5493
  email: "ava@acme.com",
5573
- emailVerified: true,
5574
5494
  newUserId: "usr_oidc",
5575
5495
  session: sessionInput("ses_oidc")
5576
5496
  }), "user_creation_not_allowed");
5577
5497
  await expect6(storage.users.getByEmail({ projectId: projectId6, email: "ava@acme.com" })).resolves.toBeNull();
5578
5498
  });
5579
5499
  });
5580
- test6("allows first OIDC bootstrap user creation with manual groups", async () => {
5500
+ test6("allows OIDC bootstrap user creation with manual groups", async () => {
5581
5501
  await withStorage(async (storage) => {
5582
5502
  await storage.oidcAuthorizationAttempts.create({
5583
5503
  id: "oidc_bootstrap",
@@ -5597,9 +5517,7 @@ function runAuthStorageContractSuite(label, options) {
5597
5517
  completedAt: at4("2026-05-14T10:01:00.000Z"),
5598
5518
  subject: "00u1",
5599
5519
  email: "founder@acme.com",
5600
- emailVerified: true,
5601
5520
  allowUserCreationWithoutInvitation: true,
5602
- requireNoActiveUsersForUserCreation: true,
5603
5521
  manualGroupIds: ["security-admins"],
5604
5522
  newUserId: "usr_founder",
5605
5523
  session: sessionInput("ses_oidc_bootstrap")
@@ -5611,6 +5529,56 @@ function runAuthStorageContractSuite(label, options) {
5611
5529
  await expect6(storage.groupMemberships.listForUser({ projectId: projectId6, userId: "usr_founder" })).resolves.toMatchObject([{ groupId: "security-admins", source: "manual" }]);
5612
5530
  });
5613
5531
  });
5532
+ test6("syncs directory memberships to exactly the groups the provider grants", async () => {
5533
+ await withStorage(async (storage) => {
5534
+ await createUser(storage);
5535
+ for (const [groupId, source] of [
5536
+ ["security-admins", "manual"],
5537
+ ["commercial", "invitation"],
5538
+ ["legacy-team", "directory"]
5539
+ ]) {
5540
+ await storage.groupMemberships.upsert({ projectId: projectId6, userId: "usr_1", groupId, source });
5541
+ }
5542
+ await completeOidcSignInForAva(storage, ["security-admins", "field-ops"]);
5543
+ await expect6(storage.groupMemberships.listForUser({ projectId: projectId6, userId: "usr_1" })).resolves.toMatchObject([
5544
+ { groupId: "commercial", source: "invitation" },
5545
+ { groupId: "field-ops", source: "directory" },
5546
+ { groupId: "security-admins", source: "manual" }
5547
+ ]);
5548
+ });
5549
+ });
5550
+ test6("removes every directory membership when the provider grants no groups", async () => {
5551
+ await withStorage(async (storage) => {
5552
+ await createUser(storage);
5553
+ await storage.groupMemberships.upsert({
5554
+ projectId: projectId6,
5555
+ userId: "usr_1",
5556
+ groupId: "security-admins",
5557
+ source: "manual"
5558
+ });
5559
+ await storage.groupMemberships.upsert({
5560
+ projectId: projectId6,
5561
+ userId: "usr_1",
5562
+ groupId: "field-ops",
5563
+ source: "directory"
5564
+ });
5565
+ await completeOidcSignInForAva(storage, []);
5566
+ await expect6(storage.groupMemberships.listForUser({ projectId: projectId6, userId: "usr_1" })).resolves.toMatchObject([{ groupId: "security-admins", source: "manual" }]);
5567
+ });
5568
+ });
5569
+ test6("leaves directory memberships alone when sign-in syncs no groups", async () => {
5570
+ await withStorage(async (storage) => {
5571
+ await createUser(storage);
5572
+ await storage.groupMemberships.upsert({
5573
+ projectId: projectId6,
5574
+ userId: "usr_1",
5575
+ groupId: "field-ops",
5576
+ source: "directory"
5577
+ });
5578
+ await completeOidcSignInForAva(storage, undefined);
5579
+ await expect6(storage.groupMemberships.listForUser({ projectId: projectId6, userId: "usr_1" })).resolves.toMatchObject([{ groupId: "field-ops", source: "directory" }]);
5580
+ });
5581
+ });
5614
5582
  test6("suspends users and revokes active sessions immediately", async () => {
5615
5583
  await withStorage(async (storage) => {
5616
5584
  await createUser(storage);
@@ -13192,33 +13160,140 @@ function runOntologyStorageContractSuite(label, options) {
13192
13160
  execution,
13193
13161
  abandonedAt: "2026-01-01T00:03:00.000Z"
13194
13162
  })).rejects.toMatchObject({ kind: "execution-lost" });
13163
+ const adopted = await storage.ontology.sources.adopt({
13164
+ projectId: "contract-project",
13165
+ source,
13166
+ execution: reclaimed.execution,
13167
+ adoptedAt: "2026-01-01T00:01:30.000Z"
13168
+ });
13169
+ expect21(adopted).toMatchObject({
13170
+ record: {
13171
+ materializationId: "staging-candidate",
13172
+ status: "ready",
13173
+ executionToken: reclaimed.execution.executionToken,
13174
+ updatedAt: "2026-01-01T00:01:30.000Z"
13175
+ },
13176
+ resumeStagingOrdinal: 1
13177
+ });
13178
+ expect21(await storage.ontology.sources.adopt({
13179
+ projectId: "contract-project",
13180
+ source,
13181
+ execution: reclaimed.execution,
13182
+ adoptedAt: "2026-01-01T00:01:40.000Z"
13183
+ })).toMatchObject({ record: { executionToken: reclaimed.execution.executionToken } });
13195
13184
  const abandoned = await storage.ontology.sources.abandon({
13196
- kind: "reclaim",
13185
+ kind: "run",
13197
13186
  projectId: "contract-project",
13198
13187
  source,
13199
13188
  execution: reclaimed.execution,
13200
13189
  abandonedAt: "2026-01-01T00:02:00.000Z"
13201
13190
  });
13202
13191
  expect21(abandoned).toMatchObject({ status: "abandoned", executionToken: null });
13203
- expect21(await storage.ontology.sources.summarizeTerminal({ projectId: "contract-project" })).toEqual({ count: 1, oldestTerminalAt: "2026-01-01T00:02:00.000Z" });
13204
- expect21(await storage.ontology.sources.cleanupTerminal({
13192
+ expect21(await storage.ontology.sources.abandon({
13193
+ kind: "run",
13205
13194
  projectId: "contract-project",
13206
- terminalBefore: "2026-02-01T00:00:00.000Z",
13207
- limit: 1
13208
- })).toEqual({ rowsDeleted: 1, materializationsDeleted: 0 });
13209
- expect21(await storage.ontology.sources.cleanupTerminal({
13195
+ source,
13196
+ execution: reclaimed.execution,
13197
+ abandonedAt: "2026-01-01T00:02:00.000Z"
13198
+ })).toBeNull();
13199
+ expect21(await storage.ontology.sources.adopt({
13210
13200
  projectId: "contract-project",
13211
- terminalBefore: "2026-02-01T00:00:00.000Z",
13212
- limit: 1
13213
- })).toEqual({ rowsDeleted: 1, materializationsDeleted: 0 });
13201
+ source,
13202
+ execution: reclaimed.execution,
13203
+ adoptedAt: "2026-01-01T00:02:10.000Z"
13204
+ })).toBeNull();
13205
+ expect21(await storage.ontology.sources.summarizeTerminal({ projectId: "contract-project" })).toEqual({ count: 1, oldestTerminalAt: "2026-01-01T00:02:00.000Z" });
13214
13206
  expect21(await storage.ontology.sources.cleanupTerminal({
13215
13207
  projectId: "contract-project",
13216
13208
  terminalBefore: "2026-02-01T00:00:00.000Z",
13217
- limit: 1
13218
- })).toEqual({ rowsDeleted: 0, materializationsDeleted: 1 });
13209
+ limit: 10
13210
+ })).toEqual({ rowsDeleted: 0, materializationsDeleted: 0 });
13211
+ expect21(await storage.ontology.sources.purgeAbandoned({ projectId: "contract-project", limit: 1 })).toEqual({ rowsDeleted: 1, materializationsDeleted: 0 });
13212
+ expect21(await storage.ontology.sources.purgeAbandoned({ projectId: "contract-project", limit: 1 })).toEqual({ rowsDeleted: 1, materializationsDeleted: 0 });
13213
+ expect21(await storage.ontology.sources.purgeAbandoned({ projectId: "contract-project", limit: 1 })).toEqual({ rowsDeleted: 0, materializationsDeleted: 1 });
13219
13214
  expect21(await storage.ontology.sources.summarizeTerminal({ projectId: "contract-project" })).toEqual({ count: 0, oldestTerminalAt: null });
13220
13215
  });
13221
13216
  });
13217
+ test21("adopts a staging candidate at its last staged root", async () => {
13218
+ await withStorage(async (storage) => {
13219
+ const identity = replacementIdentity("01");
13220
+ const claimed = await startTestProjectionRun(storage, {
13221
+ id: "resumed-run",
13222
+ projectId: "contract-project",
13223
+ identity,
13224
+ target: { objectTypeId: "ContractDevice" }
13225
+ });
13226
+ const source = { projectionId: identity.projectionId };
13227
+ await storage.ontology.sources.beginMaterialization({
13228
+ projectId: "contract-project",
13229
+ source,
13230
+ materializationId: "resumed-candidate",
13231
+ execution: claimed.execution,
13232
+ projectionKind: "object",
13233
+ protocol: "replacement",
13234
+ datasetVersion: identity.datasetVersion,
13235
+ projectionRevision: identity.projectionRevision,
13236
+ ownershipHash: identity.ownershipHash,
13237
+ ontologyRevision: identity.ontologyRevision,
13238
+ createdAt: "2026-01-01T00:00:00.000Z"
13239
+ });
13240
+ const row = (primaryId, stagingOrdinal) => ({
13241
+ root: { kind: "object", ref: { objectTypeId: "ContractDevice", primaryId } },
13242
+ assertion: {
13243
+ kind: "object",
13244
+ ref: { objectTypeId: "ContractDevice", primaryId },
13245
+ properties: { name: primaryId }
13246
+ },
13247
+ stagingOrdinal
13248
+ });
13249
+ await storage.ontology.sources.stageRows({
13250
+ projectId: "contract-project",
13251
+ source,
13252
+ materializationId: "resumed-candidate",
13253
+ execution: claimed.execution,
13254
+ rows: [row("zero", 0), row("one", 1)]
13255
+ });
13256
+ const reclaimed = await storage.projectionRuns.startOrReclaim({
13257
+ id: claimed.run.id,
13258
+ projectId: claimed.run.projectId,
13259
+ identity,
13260
+ target: { objectTypeId: "ContractDevice" }
13261
+ });
13262
+ const adopted = await storage.ontology.sources.adopt({
13263
+ projectId: "contract-project",
13264
+ source,
13265
+ execution: reclaimed.execution,
13266
+ adoptedAt: "2026-01-01T00:01:00.000Z"
13267
+ });
13268
+ expect21(adopted).toMatchObject({
13269
+ record: { status: "staging", executionToken: reclaimed.execution.executionToken },
13270
+ resumeStagingOrdinal: 1
13271
+ });
13272
+ await expect21(storage.ontology.sources.stageRows({
13273
+ projectId: "contract-project",
13274
+ source,
13275
+ materializationId: "resumed-candidate",
13276
+ execution: claimed.execution,
13277
+ rows: [row("two", 2)]
13278
+ })).rejects.toMatchObject({ kind: "execution-lost" });
13279
+ expect21(await storage.ontology.sources.stageRows({
13280
+ projectId: "contract-project",
13281
+ source,
13282
+ materializationId: "resumed-candidate",
13283
+ execution: reclaimed.execution,
13284
+ rows: [row("one", 1), row("two", 2)]
13285
+ })).toEqual({ inserted: 1, unchanged: 1 });
13286
+ expect21(await storage.ontology.sources.markReady({
13287
+ projectId: "contract-project",
13288
+ source,
13289
+ materializationId: "resumed-candidate",
13290
+ execution: reclaimed.execution,
13291
+ rootCount: 3,
13292
+ assertionCount: 3,
13293
+ readyAt: "2026-01-01T00:02:00.000Z"
13294
+ })).toMatchObject({ status: "ready", rootCount: 3 });
13295
+ });
13296
+ });
13222
13297
  test21("atomically activates explicit empty candidates and rejects competing stale heads", async () => {
13223
13298
  await withStorage(async (storage) => {
13224
13299
  const first = await createReadyEmptyCandidate(storage, "run-one", "candidate-one", "01");
@@ -13257,15 +13332,14 @@ function runOntologyStorageContractSuite(label, options) {
13257
13332
  });
13258
13333
  await expect21(activateEmptyCandidate(storage, stale, currentActive, "commit-stale-activation", "2026-01-06T00:00:00.000Z")).rejects.toThrow("execution token is stale");
13259
13334
  await storage.ontology.sources.abandon({
13260
- kind: "reclaim",
13335
+ kind: "run",
13261
13336
  projectId: "contract-project",
13262
13337
  source: stale.source,
13263
13338
  execution: reclaimed.execution,
13264
13339
  abandonedAt: "2026-01-06T00:01:00.000Z"
13265
13340
  });
13266
- const cleanup = await storage.ontology.sources.cleanupTerminal({
13341
+ const cleanup = await storage.ontology.sources.purgeAbandoned({
13267
13342
  projectId: "contract-project",
13268
- terminalBefore: "2026-02-01T00:00:00.000Z",
13269
13343
  limit: 10
13270
13344
  });
13271
13345
  expect21(cleanup.materializationsDeleted).toBeGreaterThanOrEqual(1);
@@ -13763,6 +13837,12 @@ var failure2 = {
13763
13837
  at: "2026-06-01T12:00:00.000Z",
13764
13838
  details: { projectionId: "contract.devices", runId: "failed-run" }
13765
13839
  };
13840
+ var attemptFailure = {
13841
+ code: "storage.unavailable",
13842
+ message: "Storage is temporarily unavailable.",
13843
+ retryable: true,
13844
+ at: "2026-06-01T11:00:00.000Z"
13845
+ };
13766
13846
  var replacementIdentity2 = {
13767
13847
  projectionId: "contract.devices",
13768
13848
  projectionKind: "object",
@@ -13850,11 +13930,120 @@ function runProjectionRunStorageContractSuite(label, options) {
13850
13930
  status: "failed",
13851
13931
  error: { code: "queue.enqueue_failed", message: "queue unavailable" }
13852
13932
  });
13853
- await expect22(context.projectionRuns.queue(admission)).resolves.toMatchObject({
13933
+ const requeued = await context.projectionRuns.queue(admission);
13934
+ expect22(requeued).toMatchObject({
13854
13935
  executionId: admission.executionId,
13855
13936
  status: "queued",
13856
13937
  attempt: 0
13857
13938
  });
13939
+ expect22(requeued.error).toBeUndefined();
13940
+ });
13941
+ });
13942
+ test22("keeps the failure of a retried attempt until the run ends", async () => {
13943
+ await withStorage(async (context) => {
13944
+ const storage = context.projectionRuns;
13945
+ const input = replacementInput("retried-run");
13946
+ await admitProjectionRun(context, input);
13947
+ const first = await storage.startOrReclaim(input);
13948
+ const failed = await storage.recordAttemptFailure({
13949
+ ...executionInput(first),
13950
+ error: attemptFailure
13951
+ });
13952
+ expect22(failed).toMatchObject({ status: "running", error: attemptFailure });
13953
+ const second = await storage.startOrReclaim(input);
13954
+ expect22(second.run).toMatchObject({ attempt: 2, error: attemptFailure });
13955
+ await expect22(storage.recordAttemptFailure({ ...executionInput(first), error: failure2 })).rejects.toThrow("execution token is stale");
13956
+ await expect22(storage.recordAttemptFailure({
13957
+ ...executionInput(second),
13958
+ error: { ...failure2, code: "dataset.not_found" }
13959
+ })).rejects.toThrow("code is not allowed by this failure contract");
13960
+ const succeeded = await storage.finish({
13961
+ ...executionInput(second),
13962
+ protocol: "replacement",
13963
+ status: "succeeded"
13964
+ });
13965
+ expect22(succeeded).toMatchObject({ status: "succeeded" });
13966
+ expect22(succeeded.error).toBeUndefined();
13967
+ await expect22(storage.recordAttemptFailure({ ...executionInput(second), error: failure2 })).rejects.toThrow("already terminal");
13968
+ });
13969
+ });
13970
+ test22("finds the newest later run that still stands to replace a source", async () => {
13971
+ await withStorage(async (context) => {
13972
+ const storage = context.projectionRuns;
13973
+ const current = replacementInput("current-run");
13974
+ const earlier = versionedReplacementInput("earlier-run", "version-0", "2025-12-31");
13975
+ const later = versionedReplacementInput("later-run", "version-2", "2026-01-02");
13976
+ const latest = versionedReplacementInput("latest-run", "version-3", "2026-01-03");
13977
+ const otherProjection = {
13978
+ ...versionedReplacementInput("other-projection-run", "version-4", "2026-01-04"),
13979
+ identity: {
13980
+ ...versionedReplacementInput("other", "version-4", "2026-01-04").identity,
13981
+ projectionId: "contract.rooms"
13982
+ }
13983
+ };
13984
+ for (const input of [current, earlier, later, latest, otherProjection]) {
13985
+ await admitProjectionRun(context, input);
13986
+ }
13987
+ const superseding = () => storage.findSupersedingRun({ projectId: projectId13, id: current.id });
13988
+ await expect22(superseding()).resolves.toMatchObject({ id: latest.id, status: "queued" });
13989
+ await expect22(storage.findSupersedingRun({ projectId: projectId13, id: latest.id })).resolves.toBeNull();
13990
+ await finishClaimed(context, latest, "failed");
13991
+ await expect22(superseding()).resolves.toMatchObject({ id: later.id });
13992
+ await finishClaimed(context, later, "cancelled");
13993
+ await expect22(superseding()).resolves.toBeNull();
13994
+ const telemetry = {
13995
+ id: "telemetry-run",
13996
+ projectId: projectId13,
13997
+ identity: telemetryIdentity,
13998
+ target: objectTarget,
13999
+ fixedBatchSize: 2
14000
+ };
14001
+ await admitProjectionRun(context, telemetry);
14002
+ await expect22(storage.findSupersedingRun({ projectId: projectId13, id: telemetry.id })).resolves.toBeNull();
14003
+ await expect22(storage.findSupersedingRun({ projectId: projectId13, id: "missing-run" })).rejects.toThrow("not found");
14004
+ });
14005
+ });
14006
+ test22("ends a superseded run without a failure and never reports it as the latest", async () => {
14007
+ await withStorage(async (context) => {
14008
+ const storage = context.projectionRuns;
14009
+ const stale = replacementInput("stale-run");
14010
+ const newer = versionedReplacementInput("newer-run", "version-2", "2026-01-02");
14011
+ await admitProjectionRun(context, stale);
14012
+ await admitProjectionRun(context, newer);
14013
+ const claim = await storage.startOrReclaim({
14014
+ ...stale,
14015
+ startedAt: new Date("2026-01-01T00:00:05.000Z")
14016
+ });
14017
+ const superseded = await storage.finish({
14018
+ ...executionInput(claim),
14019
+ protocol: "replacement",
14020
+ status: "superseded"
14021
+ });
14022
+ expect22(superseded).toMatchObject({ status: "superseded", attempt: 1 });
14023
+ expect22(superseded.error).toBeUndefined();
14024
+ expect22(superseded.finishedAt).toBeInstanceOf(Date);
14025
+ await expect22(storage.listLatestByProjectionIds({
14026
+ projectId: projectId13,
14027
+ projectionIds: [replacementIdentity2.projectionId]
14028
+ })).resolves.toMatchObject({ runs: [{ id: newer.id, status: "queued" }] });
14029
+ await expect22(storage.list({ projectId: projectId13, statuses: ["superseded"] })).resolves.toMatchObject({
14030
+ runs: [{ id: stale.id }],
14031
+ total: 1
14032
+ });
14033
+ const telemetry = {
14034
+ id: "telemetry-run",
14035
+ projectId: projectId13,
14036
+ identity: telemetryIdentity,
14037
+ target: objectTarget,
14038
+ fixedBatchSize: 2
14039
+ };
14040
+ await admitProjectionRun(context, telemetry);
14041
+ const telemetryClaim = await storage.startOrReclaim(telemetry);
14042
+ await expect22(storage.finish({
14043
+ ...executionInput(telemetryClaim),
14044
+ protocol: "telemetry",
14045
+ status: "superseded"
14046
+ })).rejects.toThrow("cannot be superseded");
13858
14047
  });
13859
14048
  });
13860
14049
  test22("keeps one run while reclaim rotates its execution", async () => {
@@ -14196,6 +14385,27 @@ async function admitProjectionRun(context, input) {
14196
14385
  function replacementInput(id) {
14197
14386
  return { id, projectId: projectId13, identity: replacementIdentity2, target: objectTarget };
14198
14387
  }
14388
+ function versionedReplacementInput(id, versionId, day) {
14389
+ return {
14390
+ ...replacementInput(id),
14391
+ identity: {
14392
+ ...replacementIdentity2,
14393
+ datasetVersion: {
14394
+ ...replacementIdentity2.datasetVersion,
14395
+ versionId,
14396
+ createdAt: `${day}T00:00:00.000Z`
14397
+ }
14398
+ }
14399
+ };
14400
+ }
14401
+ async function finishClaimed(context, input, status) {
14402
+ const claim = await context.projectionRuns.startOrReclaim(input);
14403
+ await context.projectionRuns.finish({
14404
+ ...executionInput(claim),
14405
+ protocol: "replacement",
14406
+ status
14407
+ });
14408
+ }
14199
14409
  function executionInput(claim) {
14200
14410
  return {
14201
14411
  id: claim.run.id,
@@ -16024,4 +16234,4 @@ export {
16024
16234
  startTestWebhookRun
16025
16235
  };
16026
16236
 
16027
- //# debugId=02F2DAA06B348FD164756E2164756E21
16237
+ //# debugId=9B51DDEB1A1D8F0764756E2164756E21