@sixb/core 0.1.14 → 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 (206) hide show
  1. package/dist/actions/index.js +21 -21
  2. package/dist/agents/index.js +33 -33
  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/index.js +3 -3
  7. package/dist/authorization/index.js +2 -2
  8. package/dist/bootstrap/index.js +36 -36
  9. package/dist/{chunk-dv4ct8mp.js → chunk-1jvq82rp.js} +3 -3
  10. package/dist/{chunk-16jenmzw.js → chunk-2tz5vnvz.js} +28 -28
  11. package/dist/{chunk-16jenmzw.js.map → chunk-2tz5vnvz.js.map} +1 -1
  12. package/dist/{chunk-728fp090.js → chunk-3c90jvfj.js} +2 -2
  13. package/dist/{chunk-vn3yh259.js → chunk-4gmng3vf.js} +1 -1
  14. package/dist/{chunk-hxgj4kzd.js → chunk-4jph1t3v.js} +7 -7
  15. package/dist/{chunk-znw0zvy4.js → chunk-4wn7bxxa.js} +25 -7
  16. package/dist/chunk-4wn7bxxa.js.map +12 -0
  17. package/dist/{chunk-3qpcrcj8.js → chunk-6aawea28.js} +2 -4
  18. package/dist/chunk-6aawea28.js.map +10 -0
  19. package/dist/{chunk-rzkr70gr.js → chunk-6fsr7y93.js} +5 -1
  20. package/dist/{chunk-rzkr70gr.js.map → chunk-6fsr7y93.js.map} +3 -3
  21. package/dist/{chunk-y487ywrv.js → chunk-6q7c68yx.js} +4 -4
  22. package/dist/{chunk-ypj2wqtj.js → chunk-70jmg2zx.js} +2 -2
  23. package/dist/{chunk-wn7mznxc.js → chunk-7jc21943.js} +3 -3
  24. package/dist/{chunk-rzcjp5m2.js → chunk-8fjmqjyx.js} +1 -1
  25. package/dist/{chunk-m8zkvep1.js → chunk-8w27xf9e.js} +1 -1
  26. package/dist/{chunk-z9h698s8.js → chunk-a4g5yjm0.js} +1 -1
  27. package/dist/{chunk-4ypbe95r.js → chunk-adbve9zt.js} +1 -1
  28. package/dist/{chunk-hj0n3c2p.js → chunk-dqkd3kdj.js} +40 -22
  29. package/dist/{chunk-hj0n3c2p.js.map → chunk-dqkd3kdj.js.map} +3 -3
  30. package/dist/{chunk-wnxabtn4.js → chunk-ex8s8wsk.js} +6 -6
  31. package/dist/{chunk-4tnrzqqh.js → chunk-fj1dvp37.js} +1 -1
  32. package/dist/{chunk-3fpgxpsq.js → chunk-fjw417jf.js} +127 -69
  33. package/dist/{chunk-3fpgxpsq.js.map → chunk-fjw417jf.js.map} +4 -4
  34. package/dist/{chunk-ht4a7mjg.js → chunk-g4rbm4a6.js} +42 -8
  35. package/dist/{chunk-ht4a7mjg.js.map → chunk-g4rbm4a6.js.map} +3 -3
  36. package/dist/{chunk-qma80ych.js → chunk-hn2r7z41.js} +3 -2
  37. package/dist/chunk-hn2r7z41.js.map +11 -0
  38. package/dist/{chunk-bdhfn0ww.js → chunk-kkqwzy6h.js} +1 -1
  39. package/dist/{chunk-ww185kt6.js → chunk-mmac1mp6.js} +2 -2
  40. package/dist/{chunk-jfdggg1p.js → chunk-n5t4mq6z.js} +5 -5
  41. package/dist/{chunk-3a338wrp.js → chunk-p0nbkys4.js} +1 -1
  42. package/dist/{chunk-kxea54yg.js → chunk-py2dw8cw.js} +3 -3
  43. package/dist/{chunk-e2c5yxfe.js → chunk-q3grgzp1.js} +2 -2
  44. package/dist/{chunk-6rzb1g6h.js → chunk-qne45xqq.js} +1 -1
  45. package/dist/{chunk-cbn96bve.js → chunk-r5sc1d2b.js} +2 -2
  46. package/dist/{chunk-y6vnvayj.js → chunk-vjcd8d27.js} +1 -1
  47. package/dist/{chunk-ma1mhh7w.js → chunk-wd34wnsy.js} +6 -6
  48. package/dist/{chunk-pvgpckm1.js → chunk-wem5vqjw.js} +7 -7
  49. package/dist/{chunk-gct3m1da.js → chunk-xr7y35yj.js} +3 -3
  50. package/dist/{chunk-q2xghyft.js → chunk-y0zmae99.js} +5 -5
  51. package/dist/{chunk-xgptywp0.js → chunk-y2aq6ag9.js} +1 -1
  52. package/dist/{chunk-yvf2jqj8.js → chunk-yfppyaty.js} +1 -1
  53. package/dist/{chunk-00pfcqh4.js → chunk-z708gemf.js} +129 -70
  54. package/dist/{chunk-00pfcqh4.js.map → chunk-z708gemf.js.map} +5 -5
  55. package/dist/deploy/define.d.ts +4 -0
  56. package/dist/deploy/define.d.ts.map +1 -0
  57. package/dist/deploy/index.d.ts +3 -0
  58. package/dist/deploy/index.d.ts.map +1 -0
  59. package/dist/deploy/index.js +10 -0
  60. package/dist/deploy/index.js.map +10 -0
  61. package/dist/deploy/internal.d.ts +3 -0
  62. package/dist/deploy/internal.d.ts.map +1 -0
  63. package/dist/deploy/internal.js +244 -0
  64. package/dist/deploy/internal.js.map +11 -0
  65. package/dist/deploy/services.d.ts +8 -0
  66. package/dist/deploy/services.d.ts.map +1 -0
  67. package/dist/deploy/types.d.ts +309 -0
  68. package/dist/deploy/types.d.ts.map +1 -0
  69. package/dist/deploy/validation.d.ts +7 -0
  70. package/dist/deploy/validation.d.ts.map +1 -0
  71. package/dist/error-reporting/internal.js +3 -3
  72. package/dist/errors/catalog.d.ts +4 -0
  73. package/dist/errors/catalog.d.ts.map +1 -1
  74. package/dist/errors/internal.js +1 -1
  75. package/dist/events/index.js +3 -3
  76. package/dist/execution/agent.js +32 -32
  77. package/dist/execution/primitive.js +28 -28
  78. package/dist/execution/request.js +30 -30
  79. package/dist/execution/request.js.map +1 -1
  80. package/dist/index.js +48 -48
  81. package/dist/index.js.map +1 -1
  82. package/dist/maintenance/ontology-maintenance.d.ts +2 -0
  83. package/dist/maintenance/ontology-maintenance.d.ts.map +1 -1
  84. package/dist/maintenance/types.d.ts +8 -2
  85. package/dist/maintenance/types.d.ts.map +1 -1
  86. package/dist/materialization/dataset-watermark.d.ts +6 -1
  87. package/dist/materialization/dataset-watermark.d.ts.map +1 -1
  88. package/dist/materialization/index.js +1 -1
  89. package/dist/materialization/model.d.ts +6 -0
  90. package/dist/materialization/model.d.ts.map +1 -1
  91. package/dist/materializer/index.js +17 -17
  92. package/dist/materializer/index.js.map +1 -1
  93. package/dist/materializer/projections/finish-run.d.ts.map +1 -1
  94. package/dist/materializer/projections/replace.d.ts.map +1 -1
  95. package/dist/materializer/projections/source-materialization.d.ts +6 -2
  96. package/dist/materializer/projections/source-materialization.d.ts.map +1 -1
  97. package/dist/models/execution/index.js +13 -13
  98. package/dist/objects/index.js +20 -20
  99. package/dist/objects/query/index.js +14 -14
  100. package/dist/pipelines/index.js +18 -18
  101. package/dist/projections/internal.js +15 -15
  102. package/dist/projections/types.d.ts +1 -1
  103. package/dist/projections/types.d.ts.map +1 -1
  104. package/dist/queues/in-memory.d.ts +1 -1
  105. package/dist/queues/in-memory.d.ts.map +1 -1
  106. package/dist/runtime/internal.js +18 -18
  107. package/dist/shares/internal.js +13 -13
  108. package/dist/shares/internal.js.map +1 -1
  109. package/dist/storage/action-runs/failure.js +2 -2
  110. package/dist/storage/ai-limits/enforcement.js +2 -2
  111. package/dist/storage/connector-connections/provider.js +1 -1
  112. package/dist/storage/file-upload-sessions/provider.js +4 -4
  113. package/dist/storage/index.d.ts +2 -2
  114. package/dist/storage/index.d.ts.map +1 -1
  115. package/dist/storage/index.js +28 -28
  116. package/dist/storage/index.js.map +1 -1
  117. package/dist/storage/internal.js +1 -1
  118. package/dist/storage/ontology/in-memory/sources.d.ts +6 -3
  119. package/dist/storage/ontology/in-memory/sources.d.ts.map +1 -1
  120. package/dist/storage/ontology/index.d.ts +1 -1
  121. package/dist/storage/ontology/index.d.ts.map +1 -1
  122. package/dist/storage/ontology/provider.d.ts +16 -3
  123. package/dist/storage/ontology/provider.d.ts.map +1 -1
  124. package/dist/storage/ontology/provider.js +8 -4
  125. package/dist/storage/ontology/provider.js.map +1 -1
  126. package/dist/storage/ontology/sources.d.ts +36 -8
  127. package/dist/storage/ontology/sources.d.ts.map +1 -1
  128. package/dist/storage/projection-runs/in-memory.d.ts +3 -1
  129. package/dist/storage/projection-runs/in-memory.d.ts.map +1 -1
  130. package/dist/storage/projection-runs/index.d.ts +1 -1
  131. package/dist/storage/projection-runs/index.d.ts.map +1 -1
  132. package/dist/storage/projection-runs/lifecycle.d.ts +12 -0
  133. package/dist/storage/projection-runs/lifecycle.d.ts.map +1 -1
  134. package/dist/storage/projection-runs/provider.js +10 -4
  135. package/dist/storage/projection-runs/provider.js.map +1 -1
  136. package/dist/storage/projection-runs/types.d.ts +32 -1
  137. package/dist/storage/projection-runs/types.d.ts.map +1 -1
  138. package/dist/storage/workflow-runs/provider.js +4 -4
  139. package/dist/syncs/index.js +19 -19
  140. package/dist/testing/index.js +296 -54
  141. package/dist/testing/index.js.map +4 -4
  142. package/dist/testing/ontology-storage-contract.d.ts.map +1 -1
  143. package/dist/testing/projection-run-storage-contract.d.ts.map +1 -1
  144. package/dist/webhooks/internal.js +14 -14
  145. package/dist/webhooks/internal.js.map +1 -1
  146. package/dist/workers/index.js +1 -1
  147. package/dist/workflows/index.js +33 -33
  148. package/package.json +13 -1
  149. package/src/deploy/define.ts +6 -0
  150. package/src/deploy/index.ts +41 -0
  151. package/src/deploy/internal.ts +7 -0
  152. package/src/deploy/services.ts +51 -0
  153. package/src/deploy/types.ts +338 -0
  154. package/src/deploy/validation.ts +261 -0
  155. package/src/errors/catalog.ts +4 -0
  156. package/src/maintenance/ontology-maintenance.ts +32 -2
  157. package/src/maintenance/types.ts +8 -2
  158. package/src/materialization/dataset-watermark.ts +6 -4
  159. package/src/materialization/model.ts +7 -0
  160. package/src/materializer/README.md +26 -6
  161. package/src/materializer/projections/finish-run.ts +129 -26
  162. package/src/materializer/projections/replace.ts +67 -49
  163. package/src/materializer/projections/source-materialization.ts +11 -6
  164. package/src/projections/types.ts +1 -0
  165. package/src/storage/index.ts +6 -1
  166. package/src/storage/ontology/in-memory/sources.ts +119 -55
  167. package/src/storage/ontology/index.ts +4 -1
  168. package/src/storage/ontology/provider.ts +64 -7
  169. package/src/storage/ontology/sources.ts +42 -8
  170. package/src/storage/projection-runs/in-memory.ts +41 -2
  171. package/src/storage/projection-runs/index.ts +2 -0
  172. package/src/storage/projection-runs/lifecycle.ts +61 -4
  173. package/src/storage/projection-runs/types.ts +41 -1
  174. package/src/testing/ontology-storage-contract.ts +141 -15
  175. package/src/testing/projection-run-storage-contract.ts +174 -1
  176. package/dist/chunk-3qpcrcj8.js.map +0 -10
  177. package/dist/chunk-qma80ych.js.map +0 -11
  178. package/dist/chunk-znw0zvy4.js.map +0 -12
  179. /package/dist/{chunk-dv4ct8mp.js.map → chunk-1jvq82rp.js.map} +0 -0
  180. /package/dist/{chunk-728fp090.js.map → chunk-3c90jvfj.js.map} +0 -0
  181. /package/dist/{chunk-vn3yh259.js.map → chunk-4gmng3vf.js.map} +0 -0
  182. /package/dist/{chunk-hxgj4kzd.js.map → chunk-4jph1t3v.js.map} +0 -0
  183. /package/dist/{chunk-y487ywrv.js.map → chunk-6q7c68yx.js.map} +0 -0
  184. /package/dist/{chunk-ypj2wqtj.js.map → chunk-70jmg2zx.js.map} +0 -0
  185. /package/dist/{chunk-wn7mznxc.js.map → chunk-7jc21943.js.map} +0 -0
  186. /package/dist/{chunk-rzcjp5m2.js.map → chunk-8fjmqjyx.js.map} +0 -0
  187. /package/dist/{chunk-m8zkvep1.js.map → chunk-8w27xf9e.js.map} +0 -0
  188. /package/dist/{chunk-z9h698s8.js.map → chunk-a4g5yjm0.js.map} +0 -0
  189. /package/dist/{chunk-4ypbe95r.js.map → chunk-adbve9zt.js.map} +0 -0
  190. /package/dist/{chunk-wnxabtn4.js.map → chunk-ex8s8wsk.js.map} +0 -0
  191. /package/dist/{chunk-4tnrzqqh.js.map → chunk-fj1dvp37.js.map} +0 -0
  192. /package/dist/{chunk-bdhfn0ww.js.map → chunk-kkqwzy6h.js.map} +0 -0
  193. /package/dist/{chunk-ww185kt6.js.map → chunk-mmac1mp6.js.map} +0 -0
  194. /package/dist/{chunk-jfdggg1p.js.map → chunk-n5t4mq6z.js.map} +0 -0
  195. /package/dist/{chunk-3a338wrp.js.map → chunk-p0nbkys4.js.map} +0 -0
  196. /package/dist/{chunk-kxea54yg.js.map → chunk-py2dw8cw.js.map} +0 -0
  197. /package/dist/{chunk-e2c5yxfe.js.map → chunk-q3grgzp1.js.map} +0 -0
  198. /package/dist/{chunk-6rzb1g6h.js.map → chunk-qne45xqq.js.map} +0 -0
  199. /package/dist/{chunk-cbn96bve.js.map → chunk-r5sc1d2b.js.map} +0 -0
  200. /package/dist/{chunk-y6vnvayj.js.map → chunk-vjcd8d27.js.map} +0 -0
  201. /package/dist/{chunk-ma1mhh7w.js.map → chunk-wd34wnsy.js.map} +0 -0
  202. /package/dist/{chunk-pvgpckm1.js.map → chunk-wem5vqjw.js.map} +0 -0
  203. /package/dist/{chunk-gct3m1da.js.map → chunk-xr7y35yj.js.map} +0 -0
  204. /package/dist/{chunk-q2xghyft.js.map → chunk-y0zmae99.js.map} +0 -0
  205. /package/dist/{chunk-xgptywp0.js.map → chunk-y2aq6ag9.js.map} +0 -0
  206. /package/dist/{chunk-yvf2jqj8.js.map → chunk-yfppyaty.js.map} +0 -0
@@ -3,13 +3,13 @@ import {
3
3
  createSixbError2,
4
4
  captureSixbFailure2,
5
5
  isSixbError2
6
- } from "./chunk-rzkr70gr.js";
6
+ } from "./chunk-6fsr7y93.js";
7
7
  import {
8
8
  reportVectorIndexingFailure
9
- } from "./chunk-y6vnvayj.js";
9
+ } from "./chunk-vjcd8d27.js";
10
10
  import {
11
11
  createKernelRuntimeAuthorization
12
- } from "./chunk-rzcjp5m2.js";
12
+ } from "./chunk-8fjmqjyx.js";
13
13
  import {
14
14
  estimateModelCall
15
15
  } from "./chunk-ky7zpbtt.js";
@@ -18,14 +18,14 @@ import {
18
18
  vectorSources,
19
19
  normalizeVector2,
20
20
  VECTOR_INDEXING_FAILURE_CODES2
21
- } from "./chunk-3fpgxpsq.js";
21
+ } from "./chunk-fjw417jf.js";
22
22
  import {
23
23
  ModelExecutionSession
24
- } from "./chunk-ww185kt6.js";
24
+ } from "./chunk-mmac1mp6.js";
25
25
  import {
26
26
  executionRecordInputFromRuntime,
27
27
  ensureExecutionRecord2
28
- } from "./chunk-m8zkvep1.js";
28
+ } from "./chunk-8w27xf9e.js";
29
29
  import {
30
30
  MaterializationConflictError2
31
31
  } from "./chunk-96yw3pwd.js";
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  createSixbError2
4
- } from "./chunk-rzkr70gr.js";
4
+ } from "./chunk-6fsr7y93.js";
5
5
  import {
6
6
  aiLimitSubjectKey2
7
7
  } from "./chunk-jgwb25gc.js";
@@ -3,10 +3,10 @@ import {
3
3
  createSixbError2,
4
4
  toSixbFailure2,
5
5
  parseSixbFailure2
6
- } from "./chunk-rzkr70gr.js";
6
+ } from "./chunk-6fsr7y93.js";
7
7
  import {
8
8
  parseActionRunFailure2
9
- } from "./chunk-xgptywp0.js";
9
+ } from "./chunk-y2aq6ag9.js";
10
10
  import {
11
11
  ActionRunError2,
12
12
  assertActionRunExecution2
@@ -15,13 +15,13 @@ import {
15
15
  paginate,
16
16
  InMemoryAuthStorage2,
17
17
  principalsEqual2
18
- } from "./chunk-6rzb1g6h.js";
18
+ } from "./chunk-qne45xqq.js";
19
19
  import {
20
20
  ObjectReadLimitExceededError2,
21
21
  snapshotObjectReadExecutionLimits2,
22
22
  assertObjectReadFacetCount2,
23
23
  assertObjectReadOutputWithinLimit2
24
- } from "./chunk-rzcjp5m2.js";
24
+ } from "./chunk-8fjmqjyx.js";
25
25
  import {
26
26
  assertObjectReaderProject2
27
27
  } from "./chunk-v4jbb3rs.js";
@@ -80,7 +80,7 @@ import {
80
80
  } from "./chunk-h89wz928.js";
81
81
  import {
82
82
  DurableFileUploadSessions2
83
- } from "./chunk-3a338wrp.js";
83
+ } from "./chunk-p0nbkys4.js";
84
84
  import {
85
85
  ExecutionStorageError2,
86
86
  prepareExecutionRecord2,
@@ -119,7 +119,7 @@ import {
119
119
  assertSourceStagedRow2,
120
120
  isExactStagingManifest2,
121
121
  sourceConflict2
122
- } from "./chunk-ht4a7mjg.js";
122
+ } from "./chunk-g4rbm4a6.js";
123
123
  import {
124
124
  objectRefKey2,
125
125
  linkRefKey2,
@@ -146,7 +146,7 @@ import {
146
146
  } from "./chunk-mmagke4x.js";
147
147
  import {
148
148
  projectionRunObjectTypesVisible2
149
- } from "./chunk-qma80ych.js";
149
+ } from "./chunk-hn2r7z41.js";
150
150
  import {
151
151
  ProjectionRunError2,
152
152
  assertProjectionRunNonEmpty2,
@@ -163,7 +163,9 @@ import {
163
163
  advanceProjectionTelemetry2,
164
164
  finishProjectionRunRecord2,
165
165
  failProjectionRunEnqueue2,
166
+ parseProjectionAttemptFailure2,
166
167
  canRequeueProjectionRunAfterEnqueueFailure2,
168
+ projectionRunSupersedes2,
167
169
  publicProjectionRunRecord2,
168
170
  createProjectionRunClaim2,
169
171
  staleProjectionRunExecution2,
@@ -172,7 +174,7 @@ import {
172
174
  assertProjectionMissingTarget2,
173
175
  requireTelemetryProjectionRun2,
174
176
  assertProjectionRunDurableExecution2
175
- } from "./chunk-znw0zvy4.js";
177
+ } from "./chunk-4wn7bxxa.js";
176
178
  import {
177
179
  SyncRunError2,
178
180
  assertSyncRunExecution2
@@ -185,18 +187,7 @@ import {
185
187
  WorkflowRunError2,
186
188
  assertWorkflowRunExecution2,
187
189
  assertWorkflowAgentNodeRunExecution2
188
- } from "./chunk-gct3m1da.js";
189
- import {
190
- actionSubjectsEqual2,
191
- actionRunPhaseRecordsEqual2,
192
- canRequeueActionRunAfterEnqueueFailure2,
193
- isTerminalActionRun2,
194
- StorageTransactionError2,
195
- canRequeuePipelineRunAfterEnqueueFailure2,
196
- canRequeueSyncRunAfterEnqueueFailure2,
197
- createTransactionStorageProxy2,
198
- throwNestedStorageTransaction2
199
- } from "./chunk-zdkcdshk.js";
190
+ } from "./chunk-xr7y35yj.js";
200
191
  import {
201
192
  ShareGrantStorageError2,
202
193
  normalizeShareGrantCreate2,
@@ -215,13 +206,24 @@ import {
215
206
  normalizeRevokeShareSessionInput2,
216
207
  cloneShareSessionRecord2
217
208
  } from "./chunk-z8fx5cgb.js";
209
+ import {
210
+ actionSubjectsEqual2,
211
+ actionRunPhaseRecordsEqual2,
212
+ canRequeueActionRunAfterEnqueueFailure2,
213
+ isTerminalActionRun2,
214
+ StorageTransactionError2,
215
+ canRequeuePipelineRunAfterEnqueueFailure2,
216
+ canRequeueSyncRunAfterEnqueueFailure2,
217
+ createTransactionStorageProxy2,
218
+ throwNestedStorageTransaction2
219
+ } from "./chunk-zdkcdshk.js";
218
220
  import {
219
221
  ConnectorConnectionStorageError2,
220
222
  CONNECTOR_CONNECTION_RUN_FAILURE_CODES2
221
223
  } from "./chunk-2c4j899j.js";
222
224
  import {
223
225
  assertPinnedDatasetWatermark2
224
- } from "./chunk-3qpcrcj8.js";
226
+ } from "./chunk-6aawea28.js";
225
227
  import {
226
228
  MaterializationValidationError2,
227
229
  MaterializationConflictError2
@@ -5701,7 +5703,7 @@ class InMemoryOntologySourceStorage {
5701
5703
  }
5702
5704
  const nonterminal = this.findRunCandidates(input.projectId, input.source.projectionId, input.execution.projectionRunId);
5703
5705
  if (nonterminal.length > 0) {
5704
- throw sourceConflict2(`Projection run '${input.execution.projectionRunId}' already has a nonterminal source materialization; reclaim it before beginning another.`);
5706
+ throw sourceConflict2(`Projection run '${input.execution.projectionRunId}' already has a nonterminal source materialization; adopt it before beginning another.`);
5705
5707
  }
5706
5708
  const materialization = {
5707
5709
  projectId: input.projectId,
@@ -5785,72 +5787,105 @@ class InMemoryOntologySourceStorage {
5785
5787
  return active ? sourceMaterializationRecord(active) : null;
5786
5788
  });
5787
5789
  }
5790
+ async adopt(input) {
5791
+ return this.runRootOperation(async () => {
5792
+ assertSourceProject2(input);
5793
+ assertSourceExecutionIdentity2(input.execution.projectionRunId, input.execution.executionToken);
5794
+ assertTimestamp2(input.adoptedAt, "Source adoptedAt");
5795
+ await this.assertCurrentExecution(input);
5796
+ const [candidate, ...others] = this.findRunCandidates(input.projectId, input.source.projectionId, input.execution.projectionRunId);
5797
+ if (!candidate)
5798
+ return null;
5799
+ if (others.length > 0)
5800
+ throw multipleRunCandidates(input.execution.projectionRunId);
5801
+ const [key, materialization] = candidate;
5802
+ const adopted = {
5803
+ ...materialization,
5804
+ executionToken: input.execution.executionToken,
5805
+ updatedAt: input.adoptedAt > materialization.updatedAt ? input.adoptedAt : materialization.updatedAt
5806
+ };
5807
+ this.state.sourceMaterializations.set(key, adopted);
5808
+ return {
5809
+ record: sourceMaterializationRecord(adopted),
5810
+ resumeStagingOrdinal: adopted.status === "ready" ? adopted.rootCount ?? 0 : Math.max(0, ...adopted.ordinalRoots.keys())
5811
+ };
5812
+ });
5813
+ }
5788
5814
  async abandon(input) {
5789
5815
  return this.runRootOperation(async () => {
5790
5816
  assertSourceProject2(input);
5791
5817
  assertSourceExecutionIdentity2(input.execution.projectionRunId, input.execution.executionToken);
5792
5818
  assertTimestamp2(input.abandonedAt, "Source abandonedAt");
5793
5819
  await this.assertCurrentExecution(input);
5794
- return input.kind === "candidate" ? this.abandonCandidate(input) : this.abandonForReclaim(input);
5820
+ return input.kind === "candidate" ? this.abandonCandidate(input) : this.abandonRunCandidate(input);
5795
5821
  });
5796
5822
  }
5797
5823
  async cleanupTerminal(input) {
5798
5824
  return this.runRootOperation(() => {
5799
5825
  assertNonblank(input.projectId, "Terminal source cleanup project id");
5800
5826
  assertTimestamp2(input.terminalBefore, "Terminal source cleanup cutoff");
5801
- if (!Number.isSafeInteger(input.limit) || input.limit <= 0) {
5802
- throw new MaterializationValidationError2("Terminal source cleanup limit must be a positive safe integer.");
5803
- }
5827
+ assertCleanupLimit(input.limit);
5804
5828
  const candidates = [];
5805
5829
  for (const entry of this.state.sourceMaterializations.entries()) {
5806
5830
  const materialization = entry[1];
5807
- if (materialization.projectId !== input.projectId || materialization.status !== "superseded" && materialization.status !== "abandoned" || materialization.terminalAt === null || materialization.terminalAt >= input.terminalBefore) {
5831
+ if (materialization.projectId !== input.projectId || materialization.status !== "superseded" || materialization.terminalAt === null || materialization.terminalAt >= input.terminalBefore) {
5808
5832
  continue;
5809
5833
  }
5810
5834
  if (materialization.roots.size > 0 && ![...materialization.roots.values()].some((root) => !root.active && root.retiredAt !== null && root.retiredAt < input.terminalBefore))
5811
5835
  continue;
5812
5836
  insertBounded(candidates, entry, input.limit, compareTerminalMaterializations);
5813
5837
  }
5814
- let remaining = input.limit;
5815
- let rowsDeleted = 0;
5816
- let materializationsDeleted = 0;
5817
- for (const [key, candidate] of candidates) {
5838
+ return this.deleteRetiredRoots(candidates, input.limit, (root) => !root.active && root.retiredAt !== null && root.retiredAt < input.terminalBefore);
5839
+ });
5840
+ }
5841
+ async purgeAbandoned(input) {
5842
+ return this.runRootOperation(() => {
5843
+ assertNonblank(input.projectId, "Abandoned source purge project id");
5844
+ assertCleanupLimit(input.limit);
5845
+ const abandoned = [...this.state.sourceMaterializations.entries()].filter(([, materialization]) => materialization.projectId === input.projectId && materialization.status === "abandoned").sort(compareTerminalMaterializations);
5846
+ return this.deleteRetiredRoots(abandoned, input.limit, () => true);
5847
+ });
5848
+ }
5849
+ deleteRetiredRoots(candidates, limit, retired) {
5850
+ let remaining = limit;
5851
+ let rowsDeleted = 0;
5852
+ let materializationsDeleted = 0;
5853
+ for (const [key, candidate] of candidates) {
5854
+ if (remaining === 0)
5855
+ break;
5856
+ const current = this.state.sourceMaterializations.get(key);
5857
+ if (current !== candidate)
5858
+ continue;
5859
+ current.rootOrdinals.clear();
5860
+ current.ordinalRoots.clear();
5861
+ for (const [rootKey, root] of current.roots) {
5818
5862
  if (remaining === 0)
5819
5863
  break;
5820
- const current = this.state.sourceMaterializations.get(key);
5821
- if (current !== candidate)
5864
+ if (!retired(root))
5822
5865
  continue;
5823
- current.rootOrdinals.clear();
5824
- current.ordinalRoots.clear();
5825
- for (const [rootKey, root] of current.roots) {
5866
+ for (const entityKey of root.entityKeys) {
5826
5867
  if (remaining === 0)
5827
5868
  break;
5828
- if (root.active || root.retiredAt === null || root.retiredAt >= input.terminalBefore)
5829
- continue;
5830
- for (const entityKey of root.entityKeys) {
5831
- if (remaining === 0)
5832
- break;
5833
- current.rowsByEntity.delete(entityKey);
5834
- root.entityKeys.delete(entityKey);
5835
- rowsDeleted += 1;
5836
- remaining -= 1;
5837
- }
5838
- if (root.entityKeys.size === 0 && remaining > 0) {
5839
- current.roots.delete(rootKey);
5840
- current.rootOrdinals.delete(rootKey);
5841
- current.ordinalRoots.delete(root.stagingOrdinal);
5842
- rowsDeleted += 1;
5843
- remaining -= 1;
5844
- }
5869
+ current.rowsByEntity.delete(entityKey);
5870
+ root.entityKeys.delete(entityKey);
5871
+ rowsDeleted += 1;
5872
+ remaining -= 1;
5845
5873
  }
5846
- if (current.roots.size === 0 && current.rowsByEntity.size === 0 && remaining > 0) {
5847
- this.state.sourceMaterializations.delete(key);
5848
- materializationsDeleted += 1;
5874
+ if (root.entityKeys.size === 0 && remaining > 0) {
5875
+ current.roots.delete(rootKey);
5876
+ current.rootOrdinals.delete(rootKey);
5877
+ current.ordinalRoots.delete(root.stagingOrdinal);
5878
+ rowsDeleted += 1;
5849
5879
  remaining -= 1;
5850
5880
  }
5851
5881
  }
5852
- return { rowsDeleted, materializationsDeleted };
5853
- });
5882
+ if (current.roots.size === 0 && current.rowsByEntity.size === 0 && remaining > 0) {
5883
+ this.state.sourceMaterializations.delete(key);
5884
+ materializationsDeleted += 1;
5885
+ remaining -= 1;
5886
+ }
5887
+ }
5888
+ return { rowsDeleted, materializationsDeleted };
5854
5889
  }
5855
5890
  async summarizeTerminal(input) {
5856
5891
  return this.runRootOperation(() => {
@@ -5898,14 +5933,10 @@ class InMemoryOntologySourceStorage {
5898
5933
  }
5899
5934
  return this.transitionToAbandoned(materialization, input.abandonedAt);
5900
5935
  }
5901
- abandonForReclaim(input) {
5936
+ abandonRunCandidate(input) {
5902
5937
  const candidates = this.findRunCandidates(input.projectId, input.source.projectionId, input.execution.projectionRunId);
5903
- if (candidates.some(([, materialization]) => materialization.executionToken === input.execution.executionToken)) {
5904
- throw sourceConflict2(`Projection run '${input.execution.projectionRunId}' already has a source materialization owned by the current execution.`);
5905
- }
5906
- if (candidates.length > 1) {
5907
- throw sourceConflict2(`Projection run '${input.execution.projectionRunId}' has multiple nonterminal source materializations.`);
5908
- }
5938
+ if (candidates.length > 1)
5939
+ throw multipleRunCandidates(input.execution.projectionRunId);
5909
5940
  const candidate = candidates[0]?.[1];
5910
5941
  return candidate ? this.transitionToAbandoned(candidate, input.abandonedAt) : null;
5911
5942
  }
@@ -6058,6 +6089,14 @@ function assertNotBefore(value, minimum, label, minimumLabel) {
6058
6089
  throw new MaterializationValidationError2(`${label} cannot precede source ${minimumLabel}.`);
6059
6090
  }
6060
6091
  }
6092
+ function assertCleanupLimit(limit) {
6093
+ if (!Number.isSafeInteger(limit) || limit <= 0) {
6094
+ throw new MaterializationValidationError2("Terminal source cleanup limit must be a positive safe integer.");
6095
+ }
6096
+ }
6097
+ function multipleRunCandidates(projectionRunId) {
6098
+ return sourceConflict2(`Projection run '${projectionRunId}' has multiple nonterminal source materializations.`);
6099
+ }
6061
6100
  function compareTerminalMaterializations([, left], [, right]) {
6062
6101
  return (left.terminalAt ?? "").localeCompare(right.terminalAt ?? "") || left.source.projectionId.localeCompare(right.source.projectionId) || left.materializationId.localeCompare(right.materializationId);
6063
6102
  }
@@ -6613,6 +6652,9 @@ var runDirectly3 = async (run) => run();
6613
6652
  function projectionRunKey(projectId, id) {
6614
6653
  return JSON.stringify([projectId, id]);
6615
6654
  }
6655
+ function compareText(left, right) {
6656
+ return left < right ? -1 : left > right ? 1 : 0;
6657
+ }
6616
6658
  function compareRuns2(a, b, order) {
6617
6659
  return compareStartedAt(a, b, order);
6618
6660
  }
@@ -6684,8 +6726,7 @@ class InMemoryProjectionRunStorage2 {
6684
6726
  attempt,
6685
6727
  executionToken,
6686
6728
  startedAt: existing.startedAt ?? new Date(input.startedAt ?? new Date),
6687
- finishedAt: undefined,
6688
- error: undefined
6729
+ finishedAt: undefined
6689
6730
  };
6690
6731
  this.rows.set(key, structuredClone(record));
6691
6732
  return createProjectionRunClaim2(record);
@@ -6759,6 +6800,14 @@ class InMemoryProjectionRunStorage2 {
6759
6800
  return publicProjectionRunRecord2(next);
6760
6801
  });
6761
6802
  }
6803
+ async recordAttemptFailure(input) {
6804
+ return this.runRootOperation(() => {
6805
+ const existing = this.requireExecution(input);
6806
+ const next = { ...existing, error: parseProjectionAttemptFailure2(existing, input.error) };
6807
+ this.rows.set(projectionRunKey(input.projectId, input.id), structuredClone(next));
6808
+ return publicProjectionRunRecord2(next);
6809
+ });
6810
+ }
6762
6811
  async finish(input) {
6763
6812
  return this.runRootOperation(() => {
6764
6813
  const existing = this.requireExecution(input);
@@ -6795,9 +6844,18 @@ class InMemoryProjectionRunStorage2 {
6795
6844
  return { runs, hasMore: offset + runs.length < total, total };
6796
6845
  });
6797
6846
  }
6847
+ async findSupersedingRun(input) {
6848
+ return this.runRootOperation(() => {
6849
+ const run = this.rows.get(projectionRunKey(input.projectId, input.id));
6850
+ if (!run)
6851
+ throw projectionRunNotFound2(input.projectId, input.id);
6852
+ const newest = [...this.rows.values()].filter((candidate) => projectionRunSupersedes2(candidate, run)).sort((left, right) => compareText(right.identity.datasetVersion.createdAt, left.identity.datasetVersion.createdAt) || compareText(right.id, left.id))[0];
6853
+ return newest ? publicProjectionRunRecord2(newest) : null;
6854
+ });
6855
+ }
6798
6856
  async listLatestByProjectionIds(input) {
6799
6857
  return this.runRootOperation(() => {
6800
- const runs = latestStartedAtByOwnerId([...this.rows.values()].filter((record) => record.projectId === input.projectId), input.projectionIds, (record) => record.identity.projectionId);
6858
+ const runs = latestStartedAtByOwnerId([...this.rows.values()].filter((record) => record.projectId === input.projectId && record.status !== "superseded"), input.projectionIds, (record) => record.identity.projectionId);
6801
6859
  return { runs: runs.map(publicProjectionRunRecord2) };
6802
6860
  });
6803
6861
  }
@@ -8579,4 +8637,4 @@ var VECTOR_INDEXING_FAILURE_CODES2 = [
8579
8637
  ];
8580
8638
  export { InMemoryActionRunStorage2, AGENT_MESSAGE_CONTENT_VERSION2, InMemoryAgentStorage2, AiCostStorageError2, InMemoryAiCostStorage2, InMemoryAiLimitStorage2, InMemoryConnectorConnectionStorage2, InMemoryFileUploadSessions2, hasVectorProfile2, isVectorProfileQuery2, objectBatchKey2, linkBatchKey2, objectLinkCursor2, compareQueryScalarValues, queryScalarValuesEqual, MAX_VECTOR_K, vectorConfiguration, vectorSources, normalizeVector2, vectorSearchCandidateLimit2, PIPELINE_RUN_FAILURE_CODES2, InMemoryPipelineRunStorage2, InMemoryProjectionRunStorage2, InMemoryRulesStorage2, InMemoryShareGrantStorage2, InMemoryShareSessionStorage2, SYNC_RUN_FAILURE_CODES2, InMemorySyncRunStorage2, WEBHOOK_RUN_FAILURE_CODES2, canRetryWebhookRun2, InMemoryWebhookRunStorage2, WorkflowInterventionError2, InMemoryWorkflowInterventionStorage2, WORKFLOW_RUN_FAILURE_CODES2, InMemoryWorkflowRunStorage2, InMemoryWorkflowNodeRunStorage2, InMemoryWorkflowAgentNodeRunStorage2, InMemoryStorage2, isMigrationCapableStorage2, migrateStorage2, checkStorageSchema2, step2, defineMigrations2, runMigrationSet2, describeMigrationHistory2, VECTOR_INDEXING_FAILURE_CODES2 };
8581
8639
 
8582
- //# debugId=1A5AE33B23C6729064756E2164756E21
8640
+ //# debugId=C915DC2D44D0A8AD64756E2164756E21