@sixb/core 0.1.7 → 0.1.8

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 (612) hide show
  1. package/dist/actions/delegated-admission.d.ts +24 -0
  2. package/dist/actions/delegated-admission.d.ts.map +1 -0
  3. package/dist/actions/descriptor.d.ts +29 -0
  4. package/dist/actions/descriptor.d.ts.map +1 -0
  5. package/dist/actions/execution.d.ts +5 -5
  6. package/dist/actions/execution.d.ts.map +1 -1
  7. package/dist/actions/index.js +36 -30
  8. package/dist/actions/index.js.map +1 -1
  9. package/dist/actions/request.d.ts.map +1 -1
  10. package/dist/actions/run-authorization.d.ts +20 -0
  11. package/dist/actions/run-authorization.d.ts.map +1 -0
  12. package/dist/actions/run-dispatch.d.ts +3 -1
  13. package/dist/actions/run-dispatch.d.ts.map +1 -1
  14. package/dist/actions/worker.js +3 -3
  15. package/dist/actions/worker.js.map +1 -1
  16. package/dist/agents/adapters.d.ts +5 -122
  17. package/dist/agents/adapters.d.ts.map +1 -1
  18. package/dist/agents/authority.d.ts +1 -1
  19. package/dist/agents/authority.d.ts.map +1 -1
  20. package/dist/agents/context-resolution.d.ts.map +1 -1
  21. package/dist/agents/context.js +1 -1
  22. package/dist/agents/errors.d.ts +0 -9
  23. package/dist/agents/errors.d.ts.map +1 -1
  24. package/dist/agents/execution.d.ts.map +1 -1
  25. package/dist/agents/identity.d.ts +3 -0
  26. package/dist/agents/identity.d.ts.map +1 -0
  27. package/dist/agents/index.d.ts +3 -3
  28. package/dist/agents/index.d.ts.map +1 -1
  29. package/dist/agents/index.js +43 -43
  30. package/dist/agents/index.js.map +1 -1
  31. package/dist/agents/message.d.ts +4 -5
  32. package/dist/agents/message.d.ts.map +1 -1
  33. package/dist/agents/model-loop.d.ts +2 -0
  34. package/dist/agents/model-loop.d.ts.map +1 -1
  35. package/dist/agents/request.d.ts.map +1 -1
  36. package/dist/agents/tool-definition.d.ts +0 -1
  37. package/dist/agents/tool-definition.d.ts.map +1 -1
  38. package/dist/agents/validation.d.ts +0 -4
  39. package/dist/agents/validation.d.ts.map +1 -1
  40. package/dist/ai-usage/execution.d.ts.map +1 -1
  41. package/dist/auth/index.js +8 -5
  42. package/dist/auth/index.js.map +1 -1
  43. package/dist/authorization/decision.d.ts +10 -2
  44. package/dist/authorization/decision.d.ts.map +1 -1
  45. package/dist/authorization/grant-kinds.d.ts +2 -1
  46. package/dist/authorization/grant-kinds.d.ts.map +1 -1
  47. package/dist/authorization/index.d.ts +1 -1
  48. package/dist/authorization/index.d.ts.map +1 -1
  49. package/dist/authorization/index.js +7 -4
  50. package/dist/authorization/index.js.map +1 -1
  51. package/dist/bootstrap/discovery.d.ts +7 -1
  52. package/dist/bootstrap/discovery.d.ts.map +1 -1
  53. package/dist/bootstrap/index.js +46 -39
  54. package/dist/bootstrap/index.js.map +1 -1
  55. package/dist/bootstrap/ontology-type-manifest.d.ts.map +1 -1
  56. package/dist/chunk-19jp6g9d.js +131 -0
  57. package/dist/chunk-19jp6g9d.js.map +11 -0
  58. package/dist/{chunk-x0qhkqje.js → chunk-2dw777qw.js} +50 -5
  59. package/dist/{chunk-x0qhkqje.js.map → chunk-2dw777qw.js.map} +4 -3
  60. package/dist/chunk-359jm1jw.js +147 -0
  61. package/dist/chunk-359jm1jw.js.map +10 -0
  62. package/dist/{chunk-2b5qtban.js → chunk-3xep5cjx.js} +56 -21
  63. package/dist/chunk-3xep5cjx.js.map +15 -0
  64. package/dist/{chunk-qjycjdj6.js → chunk-3z1qec12.js} +6 -8
  65. package/dist/{chunk-qjycjdj6.js.map → chunk-3z1qec12.js.map} +2 -2
  66. package/dist/{chunk-5jcdmjam.js → chunk-4jjp5k14.js} +1 -1
  67. package/dist/{chunk-n2arzn6e.js → chunk-4qfkag59.js} +44 -221
  68. package/dist/chunk-4qfkag59.js.map +20 -0
  69. package/dist/{chunk-rre42skh.js → chunk-4sm0aznx.js} +515 -80
  70. package/dist/{chunk-rre42skh.js.map → chunk-4sm0aznx.js.map} +11 -7
  71. package/dist/chunk-4yqmp43v.js +159 -0
  72. package/dist/chunk-4yqmp43v.js.map +11 -0
  73. package/dist/{chunk-atmkaf60.js → chunk-5e3pq99w.js} +2 -6
  74. package/dist/{chunk-atmkaf60.js.map → chunk-5e3pq99w.js.map} +3 -3
  75. package/dist/{chunk-agsvg9ar.js → chunk-5ntny1qx.js} +1 -1
  76. package/dist/{chunk-z2sery1b.js → chunk-9nbmsvn5.js} +60 -20
  77. package/dist/chunk-9nbmsvn5.js.map +11 -0
  78. package/dist/{chunk-e4rvtvpw.js → chunk-aa2pen2v.js} +250 -78
  79. package/dist/chunk-aa2pen2v.js.map +34 -0
  80. package/dist/{chunk-64sr682n.js → chunk-ajnan18g.js} +11 -8
  81. package/dist/chunk-ajnan18g.js.map +12 -0
  82. package/dist/{chunk-9aehf39w.js → chunk-f26bck4t.js} +4 -4
  83. package/dist/{chunk-7ds9620f.js → chunk-fvt9rjsa.js} +23 -7
  84. package/dist/chunk-fvt9rjsa.js.map +10 -0
  85. package/dist/{chunk-kt81c11h.js → chunk-gbejpkex.js} +5 -5
  86. package/dist/{chunk-kt81c11h.js.map → chunk-gbejpkex.js.map} +1 -1
  87. package/dist/{chunk-vjjv9mrb.js → chunk-gzasd5b6.js} +5 -5
  88. package/dist/{chunk-vjjv9mrb.js.map → chunk-gzasd5b6.js.map} +3 -3
  89. package/dist/{chunk-d63tybny.js → chunk-h0k55pc7.js} +4 -4
  90. package/dist/{chunk-d63tybny.js.map → chunk-h0k55pc7.js.map} +1 -1
  91. package/dist/chunk-h5vqbfmd.js +1537 -0
  92. package/dist/chunk-h5vqbfmd.js.map +19 -0
  93. package/dist/{chunk-3kv70xwp.js → chunk-j1sbhm7p.js} +18 -2
  94. package/dist/chunk-j1sbhm7p.js.map +10 -0
  95. package/dist/{chunk-hdz94br2.js → chunk-k522z7v6.js} +10 -5
  96. package/dist/chunk-k522z7v6.js.map +10 -0
  97. package/dist/{chunk-wjgm6jjt.js → chunk-mth82m8t.js} +128 -94
  98. package/dist/chunk-mth82m8t.js.map +14 -0
  99. package/dist/{chunk-qv38twt8.js → chunk-mwsxn98e.js} +46 -25
  100. package/dist/{chunk-qv38twt8.js.map → chunk-mwsxn98e.js.map} +6 -6
  101. package/dist/chunk-n4khvw9n.js +111 -0
  102. package/dist/chunk-n4khvw9n.js.map +11 -0
  103. package/dist/{chunk-qjzp9xyb.js → chunk-nn0tekr1.js} +6 -8
  104. package/dist/chunk-nn0tekr1.js.map +12 -0
  105. package/dist/chunk-nx7k8tpr.js +436 -0
  106. package/dist/chunk-nx7k8tpr.js.map +12 -0
  107. package/dist/{chunk-08twe8m6.js → chunk-p1rzczbt.js} +1 -1
  108. package/dist/{chunk-37wk412q.js → chunk-p1x242ad.js} +587 -70
  109. package/dist/chunk-p1x242ad.js.map +25 -0
  110. package/dist/{chunk-tn7xcs2n.js → chunk-pc7ys28c.js} +68 -5
  111. package/dist/chunk-pc7ys28c.js.map +14 -0
  112. package/dist/{chunk-3fqt22c4.js → chunk-q0k9nc5a.js} +280 -88
  113. package/dist/chunk-q0k9nc5a.js.map +14 -0
  114. package/dist/chunk-r8jrnexe.js +403 -0
  115. package/dist/chunk-r8jrnexe.js.map +10 -0
  116. package/dist/{chunk-gbrpsx4m.js → chunk-rafagrwr.js} +30 -2
  117. package/dist/chunk-rafagrwr.js.map +11 -0
  118. package/dist/{chunk-xdpwpkha.js → chunk-rv2hkwwa.js} +1 -1
  119. package/dist/{chunk-6ed5bwnd.js → chunk-sbzzr4kx.js} +1203 -691
  120. package/dist/{chunk-6ed5bwnd.js.map → chunk-sbzzr4kx.js.map} +15 -9
  121. package/dist/{chunk-d2ndstdf.js → chunk-v1xppd0y.js} +13 -11
  122. package/dist/{chunk-d2ndstdf.js.map → chunk-v1xppd0y.js.map} +2 -2
  123. package/dist/chunk-v4en4jc2.js +252 -0
  124. package/dist/chunk-v4en4jc2.js.map +10 -0
  125. package/dist/{chunk-1kamz6j0.js → chunk-w1tvjszy.js} +1 -1
  126. package/dist/{chunk-rp1mvzb4.js → chunk-w9tg6yyb.js} +11 -6
  127. package/dist/{chunk-rp1mvzb4.js.map → chunk-w9tg6yyb.js.map} +3 -3
  128. package/dist/{chunk-4nxeacx7.js → chunk-wdage1eb.js} +1 -1
  129. package/dist/{chunk-ha58tjtt.js → chunk-wtf06et8.js} +9 -5
  130. package/dist/{chunk-ha58tjtt.js.map → chunk-wtf06et8.js.map} +3 -3
  131. package/dist/{chunk-h0knpbz5.js → chunk-xajtptbw.js} +782 -211
  132. package/dist/chunk-xajtptbw.js.map +40 -0
  133. package/dist/{chunk-xc7hq65b.js → chunk-yp8ee62z.js} +49 -2
  134. package/dist/chunk-yp8ee62z.js.map +11 -0
  135. package/dist/chunk-z4ccwbkz.js +139 -0
  136. package/dist/chunk-z4ccwbkz.js.map +10 -0
  137. package/dist/datasets/builders.d.ts +11 -2
  138. package/dist/datasets/builders.d.ts.map +1 -1
  139. package/dist/datasets/changes.d.ts +14 -4
  140. package/dist/datasets/changes.d.ts.map +1 -1
  141. package/dist/datasets/execution.d.ts +15 -1
  142. package/dist/datasets/execution.d.ts.map +1 -1
  143. package/dist/datasets/index.d.ts +1 -0
  144. package/dist/datasets/index.d.ts.map +1 -1
  145. package/dist/datasets/sequence.d.ts +7 -0
  146. package/dist/datasets/sequence.d.ts.map +1 -0
  147. package/dist/datasets/types.d.ts +1 -0
  148. package/dist/datasets/types.d.ts.map +1 -1
  149. package/dist/datasets/validation.d.ts.map +1 -1
  150. package/dist/datasets/write.d.ts +37 -0
  151. package/dist/datasets/write.d.ts.map +1 -0
  152. package/dist/datasets/write.js +17 -0
  153. package/dist/datasets/write.js.map +9 -0
  154. package/dist/events/execution.d.ts.map +1 -1
  155. package/dist/events/types/datasets.d.ts +2 -6
  156. package/dist/events/types/datasets.d.ts.map +1 -1
  157. package/dist/execution/agent.d.ts.map +1 -1
  158. package/dist/execution/agent.js +39 -32
  159. package/dist/execution/agent.js.map +1 -1
  160. package/dist/execution/authorization.d.ts +58 -20
  161. package/dist/execution/authorization.d.ts.map +1 -1
  162. package/dist/execution/authorized-object-reader.d.ts +69 -0
  163. package/dist/execution/authorized-object-reader.d.ts.map +1 -0
  164. package/dist/execution/durable.d.ts.map +1 -1
  165. package/dist/execution/index.d.ts +1 -1
  166. package/dist/execution/index.d.ts.map +1 -1
  167. package/dist/execution/primitive.js +39 -32
  168. package/dist/execution/primitive.js.map +2 -2
  169. package/dist/execution/request.d.ts +11 -0
  170. package/dist/execution/request.d.ts.map +1 -1
  171. package/dist/execution/request.js +76 -40
  172. package/dist/execution/request.js.map +3 -3
  173. package/dist/execution/scopes.d.ts +16 -0
  174. package/dist/execution/scopes.d.ts.map +1 -1
  175. package/dist/execution/types.d.ts +9 -0
  176. package/dist/execution/types.d.ts.map +1 -1
  177. package/dist/http/api-routes.d.ts +2 -0
  178. package/dist/http/api-routes.d.ts.map +1 -1
  179. package/dist/http/index.js +1 -1
  180. package/dist/index.d.ts +8 -5
  181. package/dist/index.d.ts.map +1 -1
  182. package/dist/index.js +92 -78
  183. package/dist/index.js.map +1 -1
  184. package/dist/lake-storage/definition-updates.d.ts.map +1 -1
  185. package/dist/lake-storage/errors.d.ts +5 -1
  186. package/dist/lake-storage/errors.d.ts.map +1 -1
  187. package/dist/lake-storage/in-memory.d.ts +1 -0
  188. package/dist/lake-storage/in-memory.d.ts.map +1 -1
  189. package/dist/lake-storage/index.d.ts +6 -1
  190. package/dist/lake-storage/index.d.ts.map +1 -1
  191. package/dist/lake-storage/index.js +24 -7
  192. package/dist/lake-storage/index.js.map +1 -1
  193. package/dist/lake-storage/merge-validation.d.ts.map +1 -1
  194. package/dist/lake-storage/merge.d.ts +13 -2
  195. package/dist/lake-storage/merge.d.ts.map +1 -1
  196. package/dist/lake-storage/source-ordering.d.ts +19 -0
  197. package/dist/lake-storage/source-ordering.d.ts.map +1 -0
  198. package/dist/lake-storage/sql-transforms.d.ts +2 -1
  199. package/dist/lake-storage/sql-transforms.d.ts.map +1 -1
  200. package/dist/lake-storage/types.d.ts +10 -5
  201. package/dist/lake-storage/types.d.ts.map +1 -1
  202. package/dist/lake-storage/version-inputs.d.ts +4 -0
  203. package/dist/lake-storage/version-inputs.d.ts.map +1 -0
  204. package/dist/materializer/index.js +25 -22
  205. package/dist/materializer/index.js.map +1 -1
  206. package/dist/objects/authorized-ontology-view.d.ts +25 -0
  207. package/dist/objects/authorized-ontology-view.d.ts.map +1 -0
  208. package/dist/objects/execution.d.ts +1 -1
  209. package/dist/objects/execution.d.ts.map +1 -1
  210. package/dist/objects/index.js +29 -26
  211. package/dist/objects/index.js.map +1 -1
  212. package/dist/objects/link/authorization.d.ts +2 -7
  213. package/dist/objects/link/authorization.d.ts.map +1 -1
  214. package/dist/objects/query/executor.d.ts +4 -2
  215. package/dist/objects/query/executor.d.ts.map +1 -1
  216. package/dist/objects/query/index.js +24 -21
  217. package/dist/objects/query/index.js.map +1 -1
  218. package/dist/objects/query/links.d.ts +22 -1
  219. package/dist/objects/query/links.d.ts.map +1 -1
  220. package/dist/objects/query/selected-read-admission.d.ts +27 -0
  221. package/dist/objects/query/selected-read-admission.d.ts.map +1 -0
  222. package/dist/objects/query/validate.d.ts +60 -2
  223. package/dist/objects/query/validate.d.ts.map +1 -1
  224. package/dist/objects/sdk/object-handle.d.ts.map +1 -1
  225. package/dist/objects/sdk/object-set.d.ts.map +1 -1
  226. package/dist/objects/sdk/runtime-query-executor.d.ts +2 -7
  227. package/dist/objects/sdk/runtime-query-executor.d.ts.map +1 -1
  228. package/dist/objects/sdk/telemetry-channel.d.ts.map +1 -1
  229. package/dist/objects/service/list-service.d.ts +2 -3
  230. package/dist/objects/service/list-service.d.ts.map +1 -1
  231. package/dist/objects/telemetry/history.d.ts +8 -6
  232. package/dist/objects/telemetry/history.d.ts.map +1 -1
  233. package/dist/objects/telemetry/index.d.ts +2 -2
  234. package/dist/objects/telemetry/index.d.ts.map +1 -1
  235. package/dist/objects/telemetry/workload.d.ts +11 -0
  236. package/dist/objects/telemetry/workload.d.ts.map +1 -0
  237. package/dist/ontology/index.d.ts +2 -1
  238. package/dist/ontology/index.d.ts.map +1 -1
  239. package/dist/ontology/index.js +13 -12
  240. package/dist/ontology/index.js.map +1 -1
  241. package/dist/ontology/inference/index.d.ts +2 -1
  242. package/dist/ontology/inference/index.d.ts.map +1 -1
  243. package/dist/ontology/internal.d.ts +0 -1
  244. package/dist/ontology/internal.d.ts.map +1 -1
  245. package/dist/ontology/internal.js +5 -10
  246. package/dist/ontology/internal.js.map +3 -3
  247. package/dist/ontology/json-schema.d.ts +10 -6
  248. package/dist/ontology/json-schema.d.ts.map +1 -1
  249. package/dist/ontology/link-path-selection.d.ts +35 -0
  250. package/dist/ontology/link-path-selection.d.ts.map +1 -0
  251. package/dist/ontology/refs.d.ts +2 -0
  252. package/dist/ontology/refs.d.ts.map +1 -1
  253. package/dist/ontology/tokens.d.ts +2 -1
  254. package/dist/ontology/tokens.d.ts.map +1 -1
  255. package/dist/pipelines/execution.d.ts.map +1 -1
  256. package/dist/pipelines/index.js +27 -24
  257. package/dist/pipelines/index.js.map +1 -1
  258. package/dist/pipelines/request.d.ts.map +1 -1
  259. package/dist/projections/execution.d.ts.map +1 -1
  260. package/dist/projections/internal.js +25 -22
  261. package/dist/projections/internal.js.map +1 -1
  262. package/dist/projections/run-dispatch.d.ts.map +1 -1
  263. package/dist/rules/execution.d.ts.map +1 -1
  264. package/dist/runtime/create.d.ts +4 -1
  265. package/dist/runtime/create.d.ts.map +1 -1
  266. package/dist/runtime/definitions.d.ts +2 -0
  267. package/dist/runtime/definitions.d.ts.map +1 -1
  268. package/dist/runtime/host.d.ts +2 -0
  269. package/dist/runtime/host.d.ts.map +1 -1
  270. package/dist/runtime/internal.d.ts +1 -0
  271. package/dist/runtime/internal.d.ts.map +1 -1
  272. package/dist/runtime/resolve-definitions.d.ts +2 -0
  273. package/dist/runtime/resolve-definitions.d.ts.map +1 -1
  274. package/dist/runtime/sixb.d.ts +4 -0
  275. package/dist/runtime/sixb.d.ts.map +1 -1
  276. package/dist/runtime/types.d.ts +3 -0
  277. package/dist/runtime/types.d.ts.map +1 -1
  278. package/dist/schedules/execution.d.ts +2 -1
  279. package/dist/schedules/execution.d.ts.map +1 -1
  280. package/dist/security/every.d.ts +4 -1
  281. package/dist/security/every.d.ts.map +1 -1
  282. package/dist/security/grants.d.ts +7 -2
  283. package/dist/security/grants.d.ts.map +1 -1
  284. package/dist/security/index.d.ts +1 -1
  285. package/dist/security/index.d.ts.map +1 -1
  286. package/dist/security/registry.d.ts +1 -0
  287. package/dist/security/registry.d.ts.map +1 -1
  288. package/dist/security/types.d.ts +7 -1
  289. package/dist/security/types.d.ts.map +1 -1
  290. package/dist/security/validation.d.ts +2 -0
  291. package/dist/security/validation.d.ts.map +1 -1
  292. package/dist/shares/access-plan.d.ts +22 -0
  293. package/dist/shares/access-plan.d.ts.map +1 -0
  294. package/dist/shares/builders.d.ts +14 -0
  295. package/dist/shares/builders.d.ts.map +1 -0
  296. package/dist/shares/compiler.d.ts +14 -0
  297. package/dist/shares/compiler.d.ts.map +1 -0
  298. package/dist/shares/errors.d.ts +4 -0
  299. package/dist/shares/errors.d.ts.map +1 -0
  300. package/dist/shares/execution.d.ts +57 -0
  301. package/dist/shares/execution.d.ts.map +1 -0
  302. package/dist/shares/index.d.ts +10 -0
  303. package/dist/shares/index.d.ts.map +1 -0
  304. package/dist/shares/internal.d.ts +3 -0
  305. package/dist/shares/internal.d.ts.map +1 -0
  306. package/dist/shares/internal.js +239 -0
  307. package/dist/shares/internal.js.map +10 -0
  308. package/dist/shares/intersection.d.ts +9 -0
  309. package/dist/shares/intersection.d.ts.map +1 -0
  310. package/dist/shares/session-protocol.d.ts +41 -0
  311. package/dist/shares/session-protocol.d.ts.map +1 -0
  312. package/dist/shares/types.d.ts +51 -0
  313. package/dist/shares/types.d.ts.map +1 -0
  314. package/dist/shares/validation.d.ts +11 -0
  315. package/dist/shares/validation.d.ts.map +1 -0
  316. package/dist/storage/action-runs/provider.js +2 -2
  317. package/dist/storage/agents/provider.js +2 -2
  318. package/dist/storage/executions/in-memory.d.ts +3 -0
  319. package/dist/storage/executions/in-memory.d.ts.map +1 -1
  320. package/dist/storage/executions/provider.d.ts +4 -1
  321. package/dist/storage/executions/provider.d.ts.map +1 -1
  322. package/dist/storage/executions/provider.js +23 -3
  323. package/dist/storage/executions/provider.js.map +3 -3
  324. package/dist/storage/executions/run-link.d.ts +7 -0
  325. package/dist/storage/executions/run-link.d.ts.map +1 -1
  326. package/dist/storage/executions/validation.d.ts +6 -0
  327. package/dist/storage/executions/validation.d.ts.map +1 -1
  328. package/dist/storage/in-memory/index.d.ts +8 -0
  329. package/dist/storage/in-memory/index.d.ts.map +1 -1
  330. package/dist/storage/index.d.ts +8 -2
  331. package/dist/storage/index.d.ts.map +1 -1
  332. package/dist/storage/index.js +65 -36
  333. package/dist/storage/index.js.map +1 -1
  334. package/dist/storage/objects/execution-limits.d.ts +25 -0
  335. package/dist/storage/objects/execution-limits.d.ts.map +1 -0
  336. package/dist/storage/objects/guard.d.ts +16 -0
  337. package/dist/storage/objects/guard.d.ts.map +1 -0
  338. package/dist/storage/objects/in-memory/index.d.ts +3 -0
  339. package/dist/storage/objects/in-memory/index.d.ts.map +1 -0
  340. package/dist/storage/objects/in-memory/keys.d.ts +10 -0
  341. package/dist/storage/objects/in-memory/keys.d.ts.map +1 -0
  342. package/dist/storage/objects/in-memory/query.d.ts +31 -0
  343. package/dist/storage/objects/in-memory/query.d.ts.map +1 -0
  344. package/dist/storage/objects/in-memory/read-scope.d.ts +18 -0
  345. package/dist/storage/objects/in-memory/read-scope.d.ts.map +1 -0
  346. package/dist/storage/objects/in-memory/read-source.d.ts +10 -0
  347. package/dist/storage/objects/in-memory/read-source.d.ts.map +1 -0
  348. package/dist/storage/objects/in-memory/selected-reader.d.ts +9 -0
  349. package/dist/storage/objects/in-memory/selected-reader.d.ts.map +1 -0
  350. package/dist/storage/objects/{in-memory.d.ts → in-memory/storage.d.ts} +13 -10
  351. package/dist/storage/objects/in-memory/storage.d.ts.map +1 -0
  352. package/dist/storage/objects/index.d.ts +4 -1
  353. package/dist/storage/objects/index.d.ts.map +1 -1
  354. package/dist/storage/objects/keys.d.ts +1 -1
  355. package/dist/storage/objects/keys.d.ts.map +1 -1
  356. package/dist/storage/objects/read-scope.d.ts +25 -0
  357. package/dist/storage/objects/read-scope.d.ts.map +1 -0
  358. package/dist/storage/objects/types.d.ts +114 -22
  359. package/dist/storage/objects/types.d.ts.map +1 -1
  360. package/dist/storage/operation-scope.d.ts +3 -0
  361. package/dist/storage/operation-scope.d.ts.map +1 -1
  362. package/dist/storage/operation-scope.js +4 -2
  363. package/dist/storage/operation-scope.js.map +1 -1
  364. package/dist/storage/pipeline-runs/provider.js +2 -2
  365. package/dist/storage/projection-runs/provider.js +2 -2
  366. package/dist/storage/share-grants/errors.d.ts +8 -0
  367. package/dist/storage/share-grants/errors.d.ts.map +1 -0
  368. package/dist/storage/share-grants/in-memory.d.ts +11 -0
  369. package/dist/storage/share-grants/in-memory.d.ts.map +1 -0
  370. package/dist/storage/share-grants/index.d.ts +5 -0
  371. package/dist/storage/share-grants/index.d.ts.map +1 -0
  372. package/dist/storage/share-grants/provider.d.ts +4 -0
  373. package/dist/storage/share-grants/provider.d.ts.map +1 -0
  374. package/dist/storage/share-grants/provider.js +24 -0
  375. package/dist/storage/share-grants/provider.js.map +9 -0
  376. package/dist/storage/share-grants/record.d.ts +11 -0
  377. package/dist/storage/share-grants/record.d.ts.map +1 -0
  378. package/dist/storage/share-grants/types.d.ts +97 -0
  379. package/dist/storage/share-grants/types.d.ts.map +1 -0
  380. package/dist/storage/share-sessions/errors.d.ts +8 -0
  381. package/dist/storage/share-sessions/errors.d.ts.map +1 -0
  382. package/dist/storage/share-sessions/in-memory.d.ts +14 -0
  383. package/dist/storage/share-sessions/in-memory.d.ts.map +1 -0
  384. package/dist/storage/share-sessions/index.d.ts +5 -0
  385. package/dist/storage/share-sessions/index.d.ts.map +1 -0
  386. package/dist/storage/share-sessions/provider.d.ts +3 -0
  387. package/dist/storage/share-sessions/provider.d.ts.map +1 -0
  388. package/dist/storage/share-sessions/provider.js +20 -0
  389. package/dist/storage/share-sessions/provider.js.map +9 -0
  390. package/dist/storage/share-sessions/record.d.ts +8 -0
  391. package/dist/storage/share-sessions/record.d.ts.map +1 -0
  392. package/dist/storage/share-sessions/types.d.ts +50 -0
  393. package/dist/storage/share-sessions/types.d.ts.map +1 -0
  394. package/dist/storage/sync-runs/provider.js +2 -2
  395. package/dist/storage/transaction.d.ts +2 -1
  396. package/dist/storage/transaction.d.ts.map +1 -1
  397. package/dist/storage/types.d.ts +8 -0
  398. package/dist/storage/types.d.ts.map +1 -1
  399. package/dist/storage/webhook-runs/provider.js +2 -2
  400. package/dist/storage/workflow-runs/provider.js +10 -7
  401. package/dist/storage/workflow-runs/provider.js.map +1 -1
  402. package/dist/syncs/execution.d.ts.map +1 -1
  403. package/dist/syncs/index.js +27 -24
  404. package/dist/syncs/index.js.map +1 -1
  405. package/dist/syncs/request.d.ts.map +1 -1
  406. package/dist/testing/dataset-sequence-contract.d.ts +4 -0
  407. package/dist/testing/dataset-sequence-contract.d.ts.map +1 -0
  408. package/dist/testing/effective-storage-contract.d.ts.map +1 -1
  409. package/dist/testing/execution-storage-contract.d.ts +4 -0
  410. package/dist/testing/execution-storage-contract.d.ts.map +1 -1
  411. package/dist/testing/index.d.ts +3 -0
  412. package/dist/testing/index.d.ts.map +1 -1
  413. package/dist/testing/index.js +2555 -908
  414. package/dist/testing/index.js.map +11 -7
  415. package/dist/testing/lake-merge-storage-contract.d.ts +1 -0
  416. package/dist/testing/lake-merge-storage-contract.d.ts.map +1 -1
  417. package/dist/testing/lake-storage-contract.d.ts.map +1 -1
  418. package/dist/testing/object-read-scope-contract.d.ts +22 -0
  419. package/dist/testing/object-read-scope-contract.d.ts.map +1 -0
  420. package/dist/testing/share-grant-storage-contract.d.ts +10 -0
  421. package/dist/testing/share-grant-storage-contract.d.ts.map +1 -0
  422. package/dist/testing/share-session-storage-contract.d.ts +9 -0
  423. package/dist/testing/share-session-storage-contract.d.ts.map +1 -0
  424. package/dist/webhooks/internal.js +24 -21
  425. package/dist/webhooks/internal.js.map +2 -2
  426. package/dist/workflows/execution.d.ts.map +1 -1
  427. package/dist/workflows/index.js +42 -35
  428. package/dist/workflows/index.js.map +1 -1
  429. package/dist/workflows/request.d.ts.map +1 -1
  430. package/package.json +25 -1
  431. package/src/actions/delegated-admission.ts +72 -0
  432. package/src/actions/descriptor.ts +58 -0
  433. package/src/actions/execution.ts +99 -24
  434. package/src/actions/request.ts +136 -19
  435. package/src/actions/run-authorization.ts +53 -0
  436. package/src/actions/run-dispatch.ts +8 -1
  437. package/src/agents/adapters.ts +30 -420
  438. package/src/agents/authority.ts +3 -4
  439. package/src/agents/context-resolution.ts +1 -4
  440. package/src/agents/errors.ts +0 -10
  441. package/src/agents/execution.ts +13 -5
  442. package/src/agents/identity.ts +4 -0
  443. package/src/agents/index.ts +1 -20
  444. package/src/agents/message.ts +4 -5
  445. package/src/agents/model-loop.ts +54 -6
  446. package/src/agents/request.ts +16 -3
  447. package/src/agents/tool-definition.ts +0 -19
  448. package/src/agents/validation.ts +6 -65
  449. package/src/ai-usage/execution.ts +4 -11
  450. package/src/authorization/decision.ts +29 -14
  451. package/src/authorization/grant-kinds.ts +10 -0
  452. package/src/authorization/index.ts +1 -0
  453. package/src/bootstrap/discovery.ts +3 -0
  454. package/src/bootstrap/ontology-type-manifest.ts +12 -6
  455. package/src/datasets/builders.ts +23 -2
  456. package/src/datasets/changes.ts +16 -4
  457. package/src/datasets/execution.ts +76 -5
  458. package/src/datasets/index.ts +1 -0
  459. package/src/datasets/sequence.ts +77 -0
  460. package/src/datasets/types.ts +1 -0
  461. package/src/datasets/validation.ts +26 -0
  462. package/src/datasets/write.ts +240 -0
  463. package/src/events/execution.ts +57 -7
  464. package/src/events/types/datasets.ts +2 -6
  465. package/src/execution/agent.ts +1 -4
  466. package/src/execution/authorization.ts +470 -90
  467. package/src/execution/authorized-object-reader.ts +695 -0
  468. package/src/execution/durable.ts +10 -2
  469. package/src/execution/index.ts +1 -0
  470. package/src/execution/request.ts +63 -13
  471. package/src/execution/scopes.ts +36 -6
  472. package/src/execution/types.ts +8 -0
  473. package/src/http/api-routes.ts +45 -0
  474. package/src/index.ts +36 -15
  475. package/src/lake-storage/definition-updates.ts +9 -0
  476. package/src/lake-storage/errors.ts +6 -1
  477. package/src/lake-storage/in-memory.ts +53 -17
  478. package/src/lake-storage/index.ts +10 -1
  479. package/src/lake-storage/merge-validation.ts +12 -2
  480. package/src/lake-storage/merge.ts +40 -2
  481. package/src/lake-storage/source-ordering.ts +95 -0
  482. package/src/lake-storage/sql-transforms.ts +2 -1
  483. package/src/lake-storage/types.ts +10 -5
  484. package/src/lake-storage/version-inputs.ts +14 -0
  485. package/src/objects/authorized-ontology-view.ts +512 -0
  486. package/src/objects/execution.ts +98 -143
  487. package/src/objects/link/authorization.ts +3 -2
  488. package/src/objects/query/executor.ts +45 -34
  489. package/src/objects/query/links.ts +84 -25
  490. package/src/objects/query/selected-read-admission.ts +310 -0
  491. package/src/objects/query/validate.ts +353 -36
  492. package/src/objects/sdk/object-handle.ts +2 -8
  493. package/src/objects/sdk/object-set.ts +10 -11
  494. package/src/objects/sdk/runtime-query-executor.ts +8 -28
  495. package/src/objects/sdk/telemetry-channel.ts +11 -7
  496. package/src/objects/service/list-service.ts +15 -29
  497. package/src/objects/telemetry/history.ts +297 -17
  498. package/src/objects/telemetry/index.ts +2 -2
  499. package/src/objects/telemetry/workload.ts +79 -0
  500. package/src/ontology/index.ts +7 -1
  501. package/src/ontology/inference/index.ts +4 -1
  502. package/src/ontology/internal.ts +0 -1
  503. package/src/ontology/json-schema.ts +13 -12
  504. package/src/ontology/link-path-selection.ts +193 -0
  505. package/src/ontology/refs.ts +19 -0
  506. package/src/ontology/tokens.ts +15 -8
  507. package/src/pipelines/execution.ts +30 -7
  508. package/src/pipelines/request.ts +5 -0
  509. package/src/projections/execution.ts +72 -11
  510. package/src/projections/run-dispatch.ts +6 -12
  511. package/src/rules/execution.ts +20 -8
  512. package/src/runtime/create.ts +5 -1
  513. package/src/runtime/definitions.ts +2 -0
  514. package/src/runtime/host.ts +25 -6
  515. package/src/runtime/internal.ts +1 -0
  516. package/src/runtime/resolve-definitions.ts +9 -0
  517. package/src/runtime/sixb.ts +23 -2
  518. package/src/runtime/types.ts +3 -0
  519. package/src/schedules/execution.ts +24 -2
  520. package/src/security/every.ts +4 -0
  521. package/src/security/grants.ts +45 -3
  522. package/src/security/index.ts +1 -0
  523. package/src/security/registry.ts +3 -0
  524. package/src/security/types.ts +8 -0
  525. package/src/security/validation.ts +3 -0
  526. package/src/shares/access-plan.ts +225 -0
  527. package/src/shares/builders.ts +381 -0
  528. package/src/shares/compiler.ts +359 -0
  529. package/src/shares/errors.ts +3 -0
  530. package/src/shares/execution.ts +394 -0
  531. package/src/shares/index.ts +28 -0
  532. package/src/shares/internal.ts +9 -0
  533. package/src/shares/intersection.ts +178 -0
  534. package/src/shares/session-protocol.ts +258 -0
  535. package/src/shares/types.ts +76 -0
  536. package/src/shares/validation.ts +40 -0
  537. package/src/storage/executions/in-memory.ts +9 -1
  538. package/src/storage/executions/provider.ts +30 -1
  539. package/src/storage/executions/run-link.ts +29 -0
  540. package/src/storage/executions/validation.ts +46 -1
  541. package/src/storage/in-memory/index.ts +21 -2
  542. package/src/storage/index.ts +51 -0
  543. package/src/storage/objects/execution-limits.ts +283 -0
  544. package/src/storage/objects/guard.ts +55 -0
  545. package/src/storage/objects/in-memory/index.ts +2 -0
  546. package/src/storage/objects/in-memory/keys.ts +46 -0
  547. package/src/storage/objects/in-memory/query.ts +754 -0
  548. package/src/storage/objects/in-memory/read-scope.ts +211 -0
  549. package/src/storage/objects/in-memory/read-source.ts +10 -0
  550. package/src/storage/objects/in-memory/selected-reader.ts +252 -0
  551. package/src/storage/objects/in-memory/storage.ts +589 -0
  552. package/src/storage/objects/index.ts +21 -0
  553. package/src/storage/objects/keys.ts +1 -1
  554. package/src/storage/objects/read-scope.ts +672 -0
  555. package/src/storage/objects/types.ts +123 -19
  556. package/src/storage/operation-scope.ts +16 -0
  557. package/src/storage/share-grants/errors.ts +14 -0
  558. package/src/storage/share-grants/in-memory.ts +107 -0
  559. package/src/storage/share-grants/index.ts +14 -0
  560. package/src/storage/share-grants/provider.ts +11 -0
  561. package/src/storage/share-grants/record.ts +347 -0
  562. package/src/storage/share-grants/types.ts +112 -0
  563. package/src/storage/share-sessions/errors.ts +14 -0
  564. package/src/storage/share-sessions/in-memory.ts +105 -0
  565. package/src/storage/share-sessions/index.ts +11 -0
  566. package/src/storage/share-sessions/provider.ts +9 -0
  567. package/src/storage/share-sessions/record.ts +176 -0
  568. package/src/storage/share-sessions/types.ts +57 -0
  569. package/src/storage/transaction.ts +14 -2
  570. package/src/storage/types.ts +27 -0
  571. package/src/syncs/execution.ts +25 -5
  572. package/src/syncs/request.ts +5 -0
  573. package/src/testing/dataset-sequence-contract.ts +373 -0
  574. package/src/testing/effective-storage-contract.ts +34 -0
  575. package/src/testing/execution-storage-contract.ts +79 -0
  576. package/src/testing/index.ts +16 -0
  577. package/src/testing/lake-merge-storage-contract.ts +3 -0
  578. package/src/testing/lake-storage-contract.ts +58 -0
  579. package/src/testing/object-read-scope-contract.ts +939 -0
  580. package/src/testing/share-grant-storage-contract.ts +325 -0
  581. package/src/testing/share-session-storage-contract.ts +235 -0
  582. package/src/workflows/execution.ts +53 -14
  583. package/src/workflows/request.ts +5 -0
  584. package/dist/chunk-2b5qtban.js.map +0 -14
  585. package/dist/chunk-37wk412q.js.map +0 -23
  586. package/dist/chunk-3fqt22c4.js.map +0 -14
  587. package/dist/chunk-3kv70xwp.js.map +0 -10
  588. package/dist/chunk-64sr682n.js.map +0 -12
  589. package/dist/chunk-7ds9620f.js.map +0 -10
  590. package/dist/chunk-dqn23610.js +0 -72
  591. package/dist/chunk-dqn23610.js.map +0 -11
  592. package/dist/chunk-e4rvtvpw.js.map +0 -34
  593. package/dist/chunk-gbrpsx4m.js.map +0 -11
  594. package/dist/chunk-h0knpbz5.js.map +0 -38
  595. package/dist/chunk-hdz94br2.js.map +0 -10
  596. package/dist/chunk-n2arzn6e.js.map +0 -20
  597. package/dist/chunk-qjzp9xyb.js.map +0 -12
  598. package/dist/chunk-tn7xcs2n.js.map +0 -13
  599. package/dist/chunk-wjgm6jjt.js.map +0 -13
  600. package/dist/chunk-xc7hq65b.js.map +0 -10
  601. package/dist/chunk-y35ma3mj.js +0 -551
  602. package/dist/chunk-y35ma3mj.js.map +0 -15
  603. package/dist/chunk-z2sery1b.js.map +0 -11
  604. package/dist/storage/objects/in-memory.d.ts.map +0 -1
  605. package/src/storage/objects/in-memory.ts +0 -1241
  606. /package/dist/{chunk-5jcdmjam.js.map → chunk-4jjp5k14.js.map} +0 -0
  607. /package/dist/{chunk-agsvg9ar.js.map → chunk-5ntny1qx.js.map} +0 -0
  608. /package/dist/{chunk-9aehf39w.js.map → chunk-f26bck4t.js.map} +0 -0
  609. /package/dist/{chunk-08twe8m6.js.map → chunk-p1rzczbt.js.map} +0 -0
  610. /package/dist/{chunk-xdpwpkha.js.map → chunk-rv2hkwwa.js.map} +0 -0
  611. /package/dist/{chunk-1kamz6j0.js.map → chunk-w1tvjszy.js.map} +0 -0
  612. /package/dist/{chunk-4nxeacx7.js.map → chunk-wdage1eb.js.map} +0 -0
@@ -0,0 +1,34 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/objects/action/request.ts", "../src/objects/errors.ts", "../src/objects/materializer-adapter.ts", "../src/objects/link/authorization.ts", "../src/objects/link/remove.ts", "../src/objects/link/endpoints.ts", "../src/objects/link/upsert.ts", "../src/objects/runtime-batch.ts", "../src/objects/link/upsert-batch.ts", "../src/objects/object/delete.ts", "../src/objects/object/upsert.ts", "../src/objects/object/upsert-batch.ts", "../src/objects/telemetry/write-batch.ts", "../src/objects/telemetry/append-batch.ts", "../src/objects/telemetry/history.ts", "../src/objects/context/resolve.ts", "../src/objects/sdk/telemetry-channel.ts", "../src/objects/sdk/object-handle.ts", "../src/objects/sdk/runtime-query-executor.ts", "../src/objects/sdk/object-set.ts", "../src/objects/service/action-service.ts", "../src/objects/service/link-service.ts", "../src/objects/service/list-service.ts", "../src/objects/service/object-service.ts", "../src/objects/service/telemetry-service.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * Compatibility leaf operation: request an action on an object.\n *\n * The canonical action request path lives in `actions/request.ts`; object-bound\n * helpers delegate here by supplying an object subject.\n */\nimport {\n type RequestActionAndWaitOptions,\n type RequestActionOptions,\n type RequestActionResult,\n requestAction as requestRuntimeAction,\n requestActionAndWait as requestRuntimeActionAndWait,\n} from \"../../actions/request\"\nimport type { ActionRunRecord } from \"../../storage\"\nimport type { ExecutionObjectContext } from \"../context\"\n\nexport type { RequestActionAndWaitOptions, RequestActionOptions }\n\nexport async function requestAction(\n ctx: ExecutionObjectContext,\n params: {\n primaryId: string\n actionId: string\n params?: Record<string, unknown>\n options?: RequestActionOptions\n }\n): Promise<RequestActionResult> {\n return requestRuntimeAction(ctx, ctx.execution, {\n actionId: params.actionId,\n subject: {\n kind: \"object\",\n objectTypeId: ctx.objectType.id,\n primaryId: params.primaryId,\n },\n params: params.params,\n runId: params.options?.runId,\n signal: params.options?.signal,\n })\n}\n\nexport async function requestActionAndWait(\n ctx: ExecutionObjectContext,\n params: {\n primaryId: string\n actionId: string\n params?: Record<string, unknown>\n options?: RequestActionAndWaitOptions\n }\n): Promise<ActionRunRecord> {\n return requestRuntimeActionAndWait(ctx, ctx.execution, {\n actionId: params.actionId,\n subject: {\n kind: \"object\",\n objectTypeId: ctx.objectType.id,\n primaryId: params.primaryId,\n },\n params: params.params,\n runId: params.options?.runId,\n timeoutMs: params.options?.timeoutMs,\n signal: params.options?.signal,\n onRequested: params.options?.onRequested,\n })\n}\n",
6
+ "/**\n * Error for runtime invariants and failures specific to the objects module\n * (e.g., unexpected event results after appending an object/link event).\n */\nexport class ObjectError extends Error {\n readonly name = \"ObjectError\"\n}\n",
7
+ "/**\n * Runtime translation onto the ontology Materializer.\n *\n * Every typed and dynamic object/link mutation lowers to canonical Materializer operations here and\n * every Materializer result is mapped back to the public runtime shapes. The adapter owns no\n * ontology semantics: authority classification, effective resolution, validation, and event\n * construction all happen inside the Materializer's single commit.\n */\n\nimport { randomUUID } from \"node:crypto\"\nimport type { JsonValue } from \"../json\"\nimport type {\n EditCommitResult,\n EffectiveObjectSnapshot,\n MaterializationItemError,\n OntologyEditOperation,\n OntologyLinkRef,\n OntologyObjectRef,\n OntologyOperationOutcome,\n} from \"../materialization/model\"\nimport { normalizeJsonProperties } from \"../materializer\"\nimport type { ObjectLink, ValueType } from \"../ontology\"\nimport { OntologyValidationError } from \"../ontology/errors\"\nimport type { ObjectTypeWithPropertyTokens } from \"../ontology/tokens\"\nimport {\n assertKnownProperties,\n assertLinkTargetType,\n normalizeLinkProperties,\n normalizeObjectProperties,\n validateLinkProperties,\n validateObjectProperties,\n} from \"../ontology/validation\"\nimport { getOntologyMutationRuntime } from \"../runtime/ontology-mutations\"\nimport type { SixbRuntimeContext } from \"../runtime/types\"\nimport type { ObjectRow } from \"../storage\"\nimport { ObjectError } from \"./errors\"\n\n/** The runtime pieces one commit needs. */\nexport type RuntimeMaterializerContext = Pick<SixbRuntimeContext, \"projectId\" | \"storage\">\n\n/** One caller-supplied batch item, lowered to the operations it contributes. */\nexport interface RuntimeBatchGroup {\n /** Position in the caller's input array; item errors are reported against it. */\n readonly index: number\n readonly operations: readonly OntologyEditOperation[]\n}\n\nexport interface RuntimeBatchCommit {\n readonly commit: EditCommitResult | null\n /** Outcomes per input position, in the order the item's operations were submitted. */\n readonly outcomes: ReadonlyMap<number, readonly OntologyOperationOutcome[]>\n}\n\n/**\n * Commits ordered operations as one atomic runtime commit.\n *\n * A fresh request id per call keeps each runtime mutation its own commit; the Materializer's\n * idempotency replay then only collapses a retry of the very same request.\n */\nexport async function commitRuntimeOperations(\n ctx: RuntimeMaterializerContext,\n operations: readonly OntologyEditOperation[]\n): Promise<EditCommitResult> {\n const mutations = getOntologyMutationRuntime(ctx)\n const commit = await mutations.commitEdits({\n mode: \"atomic\",\n source: { kind: \"runtime\", requestId: randomUUID() },\n operations,\n expectedObjects: [],\n expectedLinks: [],\n expectedLinkScopes: [],\n })\n return commit\n}\n\n/**\n * Commits grouped batch operations as one ordered continue-mode transaction.\n *\n * Successful items apply against one evolving authority state while semantic failures are recorded\n * per item. Provider, serialization, and CAS failures still roll the whole transaction back.\n *\n * An item that lowers to several operations is declared as one operation group so the Materializer\n * rolls the whole item back rather than committing the operations that ran before the failure.\n */\nexport async function commitRuntimeBatch(\n ctx: RuntimeMaterializerContext,\n groups: readonly RuntimeBatchGroup[]\n): Promise<RuntimeBatchCommit> {\n const operations = groups.flatMap((group) => group.operations)\n if (operations.length === 0) {\n return { commit: null, outcomes: new Map() }\n }\n\n const operationGroups = groups\n .filter((group) => group.operations.length > 1)\n .map((group) => group.operations.map((operation) => operation.id))\n\n const mutations = getOntologyMutationRuntime(ctx)\n const commit = await mutations.commitEdits({\n mode: \"continue\",\n source: { kind: \"runtime\", requestId: randomUUID() },\n operations,\n ...(operationGroups.length > 0 ? { operationGroups } : {}),\n })\n\n const byId = new Map(commit.outcomes.map((outcome) => [outcome.id, outcome]))\n const outcomes = new Map<number, readonly OntologyOperationOutcome[]>()\n for (const group of groups) {\n outcomes.set(\n group.index,\n group.operations.map((operation) => requireOutcome(byId, operation.id))\n )\n }\n return { commit, outcomes }\n}\n\n/**\n * Assigns the canonical operation id for one batch item.\n *\n * Ids derive from the caller's original ordinal so outcomes map back to input positions even when\n * earlier items failed local validation and never reached the Materializer.\n */\nexport function runtimeOperationId(index: number, subOrdinal = 0): string {\n return subOrdinal === 0 ? `op:${index}` : `op:${index}.${subOrdinal}`\n}\n\nexport interface NormalizedRuntimeObject {\n readonly primaryId: string\n /** Managed authority values; identity lives in the object ref, never in the properties. */\n readonly properties: Readonly<Record<string, JsonValue>>\n}\n\n/**\n * Validates and normalizes one runtime object input at the SDK/service boundary.\n *\n * Shape and value-type errors surface here so a batch can report them against the caller's original\n * position. Authority classification, required-property enforcement, and cardinality stay in the\n * Materializer, which validates the resolved effective object instead of the request.\n */\nexport function normalizeRuntimeObject(input: {\n readonly objectType: ObjectTypeWithPropertyTokens\n readonly primaryPropertyId: string\n readonly properties: Record<string, unknown>\n readonly valueTypesById: ReadonlyMap<string, ValueType>\n}): NormalizedRuntimeObject {\n const { objectType, primaryPropertyId, properties, valueTypesById } = input\n assertKnownProperties(objectType, properties)\n validateObjectProperties(objectType, properties, valueTypesById)\n\n const primaryValue = properties[primaryPropertyId]\n if (primaryValue === undefined || primaryValue === null) {\n throw new OntologyValidationError(\n `[Sixb] Missing primary property '${primaryPropertyId}' in upsert for '${objectType.id}'`\n )\n }\n\n const normalized = normalizeObjectProperties(\n objectType.properties,\n properties,\n valueTypesById,\n objectType.id\n )\n const { [primaryPropertyId]: _identity, ...managed } = normalized\n return {\n primaryId: String(primaryValue),\n properties: normalizeJsonProperties(managed, `${objectType.id} properties`),\n }\n}\n\n/**\n * Validates and normalizes one runtime link input.\n *\n * Managed link authority carries the complete property set, so required link properties must be\n * present in the request rather than inherited from the stored edge.\n */\nexport function normalizeRuntimeLink(input: {\n readonly objectType: ObjectTypeWithPropertyTokens\n readonly linkDefinition: ObjectLink\n readonly linkId: string\n readonly targetTypeId: string\n readonly properties?: Record<string, unknown>\n readonly valueTypesById: ReadonlyMap<string, ValueType>\n readonly isValidLinkTarget: (expected: string | string[], actual: string) => boolean\n}): Readonly<Record<string, JsonValue>> | undefined {\n const { objectType, linkDefinition, linkId, targetTypeId, properties, valueTypesById } = input\n assertLinkTargetType(objectType.id, linkId, linkDefinition, targetTypeId, input.isValidLinkTarget)\n validateLinkProperties(objectType, linkDefinition, properties, undefined, valueTypesById)\n const normalized = normalizeLinkProperties(objectType, linkDefinition, properties, valueTypesById)\n if (normalized === undefined) return undefined\n return normalizeJsonProperties(normalized, `${objectType.id}.${linkId} properties`)\n}\n\nexport function objectUpsertOperation(input: {\n readonly id: string\n readonly ref: OntologyObjectRef\n readonly properties: Readonly<Record<string, JsonValue>>\n}): OntologyEditOperation {\n return { id: input.id, kind: \"object.upsert\", ref: input.ref, properties: input.properties }\n}\n\nexport function objectDeleteOperation(input: {\n readonly id: string\n readonly ref: OntologyObjectRef\n}): OntologyEditOperation {\n return { id: input.id, kind: \"object.delete\", ref: input.ref }\n}\n\nexport function objectRestoreOperation(input: {\n readonly id: string\n readonly ref: OntologyObjectRef\n}): OntologyEditOperation {\n return { id: input.id, kind: \"object.restore\", ref: input.ref }\n}\n\nexport function linkUpsertOperation(input: {\n readonly id: string\n readonly ref: OntologyLinkRef\n readonly properties?: Readonly<Record<string, JsonValue>>\n}): OntologyEditOperation {\n return {\n id: input.id,\n kind: \"link.upsert\",\n ref: input.ref,\n ...(input.properties !== undefined ? { properties: input.properties } : {}),\n }\n}\n\nexport function linkDeleteOperation(input: {\n readonly id: string\n readonly ref: OntologyLinkRef\n}): OntologyEditOperation {\n return { id: input.id, kind: \"link.delete\", ref: input.ref }\n}\n\n/** Reads the outcomes one batch item produced; the commit returns one per submitted operation. */\nexport function requireItemOutcomes(\n commit: RuntimeBatchCommit,\n index: number\n): readonly OntologyOperationOutcome[] {\n const outcomes = commit.outcomes.get(index)\n if (!outcomes || outcomes.length === 0) {\n throw new ObjectError(`[Sixb] Materializer returned no outcome for batch item ${index}.`)\n }\n return outcomes\n}\n\n/** Reads the effective object an ok outcome produced; runtime object writes always resolve one. */\nexport function requireEffectiveObject(outcome: OntologyOperationOutcome): EffectiveObjectSnapshot {\n if (!outcome.ok || !outcome.object) {\n throw new ObjectError(`[Sixb] Materializer returned no effective object for '${outcome.id}'.`)\n }\n return outcome.object\n}\n\nexport function toObjectRow(projectId: string, snapshot: EffectiveObjectSnapshot): ObjectRow {\n return {\n projectId,\n objectTypeId: snapshot.ref.objectTypeId,\n primaryId: snapshot.ref.primaryId,\n properties: structuredClone(snapshot.properties) as Record<string, unknown>,\n createdAt: new Date(snapshot.createdAt),\n updatedAt: new Date(snapshot.updatedAt),\n version: snapshot.version,\n lastCommitId: snapshot.lastCommitId,\n }\n}\n\n/** Rehydrates a persisted item error into the public runtime error type. */\nexport function toItemError(error: MaterializationItemError): Error {\n switch (error.code) {\n case \"validation\":\n return new OntologyValidationError(error.message)\n }\n}\n\nfunction requireOutcome(\n outcomes: ReadonlyMap<string, OntologyOperationOutcome>,\n id: string\n): OntologyOperationOutcome {\n const outcome = outcomes.get(id)\n if (!outcome) {\n throw new ObjectError(`[Sixb] Materializer returned no outcome for '${id}'.`)\n }\n return outcome\n}\n",
8
+ "/**\n * The authorization rule for writing a link, in one place because all three link leaves need it.\n */\nimport { assertAuthorized, assertCanEdit } from \"../../authorization\"\nimport type { SixbRuntimeContext } from \"../../runtime/types\"\n\n/**\n * Assert a principal may create or remove a link.\n *\n * `edit` on the **source** type, `view` on the **target**: a link is declared on the source type\n * (`objectType.links`), and writing one changes the source's edges, not the target's properties.\n * Requiring `edit` on the target too would mean a clerk needs write access to every customer before\n * attaching an invoice to one.\n *\n * `view` on the target is still required, and for two reasons: it matches how links are *read* —\n * `canViewLink` already demands `view` on both endpoints — and without it the endpoint-existence\n * check that follows would answer whether a target the principal cannot see exists.\n *\n * Call this *before* any endpoint lookup, for that second reason.\n */\nexport function assertCanWriteLink(\n ctx: Pick<SixbRuntimeContext, \"projectId\" | \"runtimeAuthorization\" | \"authorization\">,\n endpoints: { readonly sourceTypeId: string; readonly targetTypeId: string }\n): void {\n assertCanEdit(ctx, endpoints.sourceTypeId)\n assertAuthorized(ctx, { kind: \"object.view\", objectTypeId: endpoints.targetTypeId })\n}\n",
9
+ "/**\n * Leaf operation: remove a single link through the ontology Materializer.\n */\nimport { assertLinkTargetType } from \"../../ontology/validation\"\nimport type { ResolvedLinkContext } from \"../context\"\nimport {\n commitRuntimeOperations,\n linkDeleteOperation,\n runtimeOperationId,\n} from \"../materializer-adapter\"\nimport { assertCanWriteLink } from \"./authorization\"\n\nexport async function removeLink(\n ctx: ResolvedLinkContext,\n params: {\n sourceId: string\n linkId: string\n targetTypeId: string\n targetId: string\n }\n): Promise<void> {\n const { objectType, linkDefinition, ontology } = ctx\n const { sourceId, linkId, targetTypeId, targetId } = params\n assertCanWriteLink(ctx, { sourceTypeId: objectType.id, targetTypeId })\n\n assertLinkTargetType(objectType.id, linkId, linkDefinition, targetTypeId, (expected, actual) =>\n ontology.isValidLinkTarget(expected, actual)\n )\n\n // A missing link is a no-op: the delete records managed authority only when an effective edge\n // exists, so the commit reports `unchanged` instead of failing.\n await commitRuntimeOperations(ctx, [\n linkDeleteOperation({\n id: runtimeOperationId(0),\n ref: {\n source: { objectTypeId: objectType.id, primaryId: sourceId },\n linkId,\n target: { objectTypeId: targetTypeId, primaryId: targetId },\n },\n }),\n ])\n}\n",
10
+ "/**\n * Shared endpoint existence reads for runtime link batches.\n *\n * The Materializer independently refuses a link whose endpoints are not effective. These reads exist\n * only so batch callers keep receiving the public {@link ObjectNotFoundError} for a missing endpoint\n * instead of a generic per-item validation error.\n */\n\nimport type { SixbRuntimeContext } from \"../../runtime/types\"\nimport { objectBatchKey } from \"../../storage\"\nimport { ObjectNotFoundError } from \"../../storage/errors\"\n\nexport interface LinkEndpointItem {\n readonly objectType: { readonly id: string }\n readonly sourceId: string\n readonly targetTypeId: string\n readonly targetId: string\n}\n\nexport type EndpointExistence = ReadonlySet<string>\n\nexport function collectEndpointLookups(\n items: readonly LinkEndpointItem[]\n): { objectTypeId: string; primaryId: string }[] {\n const lookups: { objectTypeId: string; primaryId: string }[] = []\n const seen = new Set<string>()\n\n for (const item of items) {\n for (const endpoint of [\n { objectTypeId: item.objectType.id, primaryId: item.sourceId },\n { objectTypeId: item.targetTypeId, primaryId: item.targetId },\n ]) {\n const key = endpointKey(endpoint.objectTypeId, endpoint.primaryId)\n if (seen.has(key)) continue\n seen.add(key)\n lookups.push(endpoint)\n }\n }\n\n return lookups\n}\n\nexport async function loadEndpointExistence(\n ctx: Pick<SixbRuntimeContext, \"projectId\" | \"storage\">,\n lookups: readonly { objectTypeId: string; primaryId: string }[]\n): Promise<EndpointExistence> {\n if (lookups.length === 0) return new Set()\n const rows = await ctx.storage.objects.getByPrimaryIdBatch({\n projectId: ctx.projectId,\n items: lookups,\n })\n return new Set(rows.keys())\n}\n\n/** Throws {@link ObjectNotFoundError} for the first endpoint the read did not find. */\nexport function requireEndpoints(item: LinkEndpointItem, existing: EndpointExistence): void {\n if (!existing.has(endpointKey(item.objectType.id, item.sourceId))) {\n throw new ObjectNotFoundError(item.objectType.id, item.sourceId, \"Source object not found\")\n }\n if (!existing.has(endpointKey(item.targetTypeId, item.targetId))) {\n throw new ObjectNotFoundError(item.targetTypeId, item.targetId, \"Target object not found\")\n }\n}\n\nfunction endpointKey(objectTypeId: string, primaryId: string): string {\n return objectBatchKey(objectTypeId, primaryId)\n}\n",
11
+ "/**\n * Leaf operation: upsert a single link through the ontology Materializer.\n */\nimport type { ResolvedLinkContext } from \"../context\"\nimport {\n commitRuntimeOperations,\n linkUpsertOperation,\n normalizeRuntimeLink,\n runtimeOperationId,\n} from \"../materializer-adapter\"\nimport { assertCanWriteLink } from \"./authorization\"\nimport { collectEndpointLookups, loadEndpointExistence, requireEndpoints } from \"./endpoints\"\n\nexport async function upsertLink(\n ctx: ResolvedLinkContext,\n params: {\n sourceId: string\n linkId: string\n targetTypeId: string\n targetId: string\n properties?: Record<string, unknown>\n }\n): Promise<void> {\n const { objectType, linkDefinition, ontology } = ctx\n const { sourceId, linkId, targetTypeId, targetId, properties } = params\n assertCanWriteLink(ctx, { sourceTypeId: objectType.id, targetTypeId })\n const endpoints = { objectType, sourceId, targetTypeId, targetId }\n\n // Endpoint reads keep the public `ObjectNotFoundError` contract; the Materializer independently\n // refuses a link whose endpoints are not effective when it commits. This runs before property\n // normalization so the same input reports the same error class here and through the batch APIs,\n // which check endpoints first inside `plan`.\n requireEndpoints(endpoints, await loadEndpointExistence(ctx, collectEndpointLookups([endpoints])))\n\n const normalizedProperties = normalizeRuntimeLink({\n objectType,\n linkDefinition,\n linkId,\n targetTypeId,\n properties,\n valueTypesById: ontology.getValueTypesById(),\n isValidLinkTarget: (expected, actual) => ontology.isValidLinkTarget(expected, actual),\n })\n\n await commitRuntimeOperations(ctx, [\n linkUpsertOperation({\n id: runtimeOperationId(0),\n ref: {\n source: { objectTypeId: objectType.id, primaryId: sourceId },\n linkId,\n target: { objectTypeId: targetTypeId, primaryId: targetId },\n },\n ...(normalizedProperties !== undefined ? { properties: normalizedProperties } : {}),\n }),\n ])\n}\n",
12
+ "/**\n * Per-item mechanics shared by every runtime batch.\n *\n * One place owns the rules the public batch APIs promise: a local failure stays at its own input\n * position, an identical repeat collapses onto the first item and shares its result, a conflicting\n * repeat is rejected, and each item's Materializer outcomes map back to the position they came from.\n */\n\nimport type { OntologyEditOperation, OntologyOperationOutcome } from \"../materialization/model\"\nimport { OntologyValidationError } from \"../ontology/errors\"\nimport type { BatchItemResult } from \"../runtime/types\"\nimport {\n commitRuntimeBatch,\n type RuntimeMaterializerContext,\n requireItemOutcomes,\n toItemError,\n} from \"./materializer-adapter\"\n\nexport interface RuntimeBatchItemPlan {\n /** Identity this item claims. A later item claiming it must be identical. */\n readonly key: string\n /** How that identity reads in an error message, e.g. `object 'room:r1'`. */\n readonly label: string\n /** Canonical content, so an identical repeat is recognized as one. */\n readonly fingerprint: string\n readonly operations: readonly OntologyEditOperation[]\n}\n\nexport interface RuntimeItemBatch<TItem, TValue> {\n readonly ctx: RuntimeMaterializerContext\n readonly items: readonly TItem[]\n /** Lowers one item, throwing to record a local failure at that item's position. */\n plan(item: TItem, index: number): RuntimeBatchItemPlan\n /** Maps the outcomes of a fully successful item to its public value. */\n value(outcomes: readonly OntologyOperationOutcome[]): TValue\n}\n\ninterface PlannedItem {\n readonly index: number\n readonly operations: readonly OntologyEditOperation[]\n}\n\ninterface ClaimedIdentity {\n readonly index: number\n readonly fingerprint: string\n}\n\nexport async function runRuntimeItemBatch<TItem, TValue>(\n batch: RuntimeItemBatch<TItem, TValue>\n): Promise<readonly BatchItemResult<TValue>[]> {\n const { items } = batch\n if (items.length === 0) return []\n\n const results: BatchItemResult<TValue>[] = new Array(items.length)\n const planned: PlannedItem[] = []\n const claims = new Map<string, ClaimedIdentity>()\n /** Positions that repeat an earlier identical item and share its result. */\n const aliases = new Map<number, number>()\n\n for (const [index, item] of items.entries()) {\n let plan: RuntimeBatchItemPlan\n try {\n plan = batch.plan(item, index)\n } catch (error) {\n results[index] = {\n ok: false,\n error: error instanceof Error ? error : new Error(String(error)),\n }\n continue\n }\n\n const claimed = claims.get(plan.key)\n if (claimed) {\n if (claimed.fingerprint !== plan.fingerprint) {\n results[index] = {\n ok: false,\n error: new OntologyValidationError(\n `[Sixb] Conflicting duplicate ${plan.label} at batch positions ${claimed.index} and ${index}`\n ),\n }\n continue\n }\n aliases.set(index, claimed.index)\n continue\n }\n\n claims.set(plan.key, { index, fingerprint: plan.fingerprint })\n planned.push({ index, operations: plan.operations })\n }\n\n const commit = await commitRuntimeBatch(batch.ctx, planned)\n\n for (const { index } of planned) {\n const outcomes = requireItemOutcomes(commit, index)\n const failed = outcomes.find((outcome) => !outcome.ok)\n results[index] =\n failed?.ok === false\n ? { ok: false, error: toItemError(failed.error) }\n : { ok: true, value: batch.value(outcomes) }\n }\n for (const [index, source] of aliases) {\n results[index] = results[source]\n }\n return results\n}\n",
13
+ "/**\n * Leaf operation: batch upsert links through the ontology Materializer.\n *\n * Takes SixbRuntimeContext (shared infra) + per-item pre-resolved data, because each item can target\n * a different objectType + linkDefinition. Everything valid is submitted as one ordered\n * continue-mode commit.\n */\n\nimport { stableJsonStringify } from \"../../json\"\nimport { linkRefKey } from \"../../materialization/refs\"\nimport type { BatchItemResult, SixbRuntimeContext } from \"../../runtime/types\"\nimport type { ResolvedLinkBatchItem } from \"../context\"\nimport {\n linkUpsertOperation,\n normalizeRuntimeLink,\n runtimeOperationId,\n} from \"../materializer-adapter\"\nimport { runRuntimeItemBatch } from \"../runtime-batch\"\nimport { assertCanWriteLink } from \"./authorization\"\nimport { collectEndpointLookups, loadEndpointExistence, requireEndpoints } from \"./endpoints\"\n\nexport async function upsertLinkBatch(\n ctx: SixbRuntimeContext,\n items: readonly ResolvedLinkBatchItem[]\n): Promise<readonly BatchItemResult<void>[]> {\n const { ontology } = ctx\n if (items.length === 0) return []\n\n // Every item, up front, and before the endpoint lookup below. Authorization is a precondition, not\n // a per-item validation: a refused item must not become one failed `BatchItemResult` while the\n // rest of the batch commits. Asserting inside `plan` would do exactly that, and would also let the\n // existence lookup answer for targets the principal cannot see.\n for (const item of items) {\n assertCanWriteLink(ctx, {\n sourceTypeId: item.objectType.id,\n targetTypeId: item.targetTypeId,\n })\n }\n\n const existing = await loadEndpointExistence(ctx, collectEndpointLookups(items))\n const valueTypesById = ontology.getValueTypesById()\n\n return runRuntimeItemBatch({\n ctx,\n items,\n plan(item, index) {\n requireEndpoints(item, existing)\n const properties = normalizeRuntimeLink({\n objectType: item.objectType,\n linkDefinition: item.linkDefinition,\n linkId: item.linkId,\n targetTypeId: item.targetTypeId,\n properties: item.properties,\n valueTypesById,\n isValidLinkTarget: (expected, actual) => ontology.isValidLinkTarget(expected, actual),\n })\n const ref = {\n source: { objectTypeId: item.objectType.id, primaryId: item.sourceId },\n linkId: item.linkId,\n target: { objectTypeId: item.targetTypeId, primaryId: item.targetId },\n }\n const edge = linkRefKey(ref)\n return {\n key: edge,\n // The key is a JSON array, which is unreadable in the error an operator sees on a failed\n // link projection. Name the edge the way the object path names an object.\n label: `link '${item.objectType.id}:${item.sourceId}.${item.linkId} -> ${item.targetTypeId}:${item.targetId}'`,\n fingerprint: stableJsonStringify(properties ?? null),\n operations: [\n linkUpsertOperation({\n id: runtimeOperationId(index),\n ref,\n ...(properties !== undefined ? { properties } : {}),\n }),\n ],\n }\n },\n value: () => undefined,\n })\n}\n",
14
+ "/**\n * Leaf operations: delete and restore a single object through the ontology Materializer.\n *\n * Both are thin wrappers over one materializer operation, exactly like `removeLink` — the cascade\n * over links and the effective-state bookkeeping happen inside the commit.\n */\nimport { assertCanEdit } from \"../../authorization\"\nimport type { ResolvedObjectContext } from \"../context\"\nimport {\n commitRuntimeOperations,\n objectDeleteOperation,\n objectRestoreOperation,\n runtimeOperationId,\n} from \"../materializer-adapter\"\n\n/**\n * Delete the object with this primary id.\n *\n * A missing object is a no-op: the delete records managed authority only where effective state\n * exists, so the commit reports `unchanged` rather than failing. An object a projection also writes\n * stays hidden even while the projection keeps asserting it — `restore()` is what reveals it again.\n */\nexport async function deleteObject(ctx: ResolvedObjectContext, primaryId: string): Promise<void> {\n assertCanEdit(ctx, ctx.objectType.id)\n await commitRuntimeOperations(ctx, [\n objectDeleteOperation({\n id: runtimeOperationId(0),\n ref: { objectTypeId: ctx.objectType.id, primaryId },\n }),\n ])\n}\n\n/**\n * Withdraw a previous delete.\n *\n * For an object written only from code this is a no-op — there is nothing left to reveal, so write it\n * again instead. For an object a projection also writes, it makes the projected state visible again.\n */\nexport async function restoreObject(ctx: ResolvedObjectContext, primaryId: string): Promise<void> {\n assertCanEdit(ctx, ctx.objectType.id)\n await commitRuntimeOperations(ctx, [\n objectRestoreOperation({\n id: runtimeOperationId(0),\n ref: { objectTypeId: ctx.objectType.id, primaryId },\n }),\n ])\n}\n",
15
+ "/**\n * Leaf operation: upsert a single object through the ontology Materializer.\n */\n\nimport { assertCanEdit } from \"../../authorization\"\nimport type { ObjectRow } from \"../../storage\"\nimport type { ResolvedObjectContext } from \"../context\"\nimport {\n commitRuntimeOperations,\n normalizeRuntimeObject,\n objectUpsertOperation,\n requireEffectiveObject,\n runtimeOperationId,\n toObjectRow,\n} from \"../materializer-adapter\"\n\nexport async function upsertObject(\n ctx: ResolvedObjectContext,\n properties: Record<string, unknown>\n): Promise<ObjectRow> {\n assertCanEdit(ctx, ctx.objectType.id)\n const { objectType, primaryPropertyId, ontology } = ctx\n\n const normalized = normalizeRuntimeObject({\n objectType,\n primaryPropertyId,\n properties,\n valueTypesById: ontology.getValueTypesById(),\n })\n const ref = { objectTypeId: objectType.id, primaryId: normalized.primaryId }\n\n // The Materializer classifies this as an independent create, a patch over source authority, or a\n // restore plus patch inside its own transaction.\n const commit = await commitRuntimeOperations(ctx, [\n objectUpsertOperation({ id: runtimeOperationId(0), ref, properties: normalized.properties }),\n ])\n return toObjectRow(ctx.projectId, requireEffectiveObject(commit.outcomes[0]))\n}\n",
16
+ "/**\n * Leaf operation: batch upsert objects of a single type through the ontology Materializer.\n *\n * Everything that survives local normalization is submitted as one ordered continue-mode commit, so\n * later items observe earlier ones and a provider failure rolls the whole batch back.\n */\nimport { assertCanEdit } from \"../../authorization\"\nimport { stableJsonStringify } from \"../../json\"\nimport type { BatchItemResult } from \"../../runtime/types\"\nimport type { ObjectRow } from \"../../storage\"\nimport type { ResolvedObjectContext } from \"../context\"\nimport {\n normalizeRuntimeObject,\n objectUpsertOperation,\n requireEffectiveObject,\n runtimeOperationId,\n toObjectRow,\n} from \"../materializer-adapter\"\nimport { runRuntimeItemBatch } from \"../runtime-batch\"\n\nexport async function upsertObjectBatch(\n ctx: ResolvedObjectContext,\n items: readonly { properties: Record<string, unknown> }[]\n): Promise<readonly BatchItemResult<ObjectRow>[]> {\n assertCanEdit(ctx, ctx.objectType.id)\n const { objectType, primaryPropertyId, ontology } = ctx\n const valueTypesById = ontology.getValueTypesById()\n\n return runRuntimeItemBatch({\n ctx,\n items,\n plan(item, index) {\n const normalized = normalizeRuntimeObject({\n objectType,\n primaryPropertyId,\n properties: item.properties,\n valueTypesById,\n })\n const ref = { objectTypeId: objectType.id, primaryId: normalized.primaryId }\n return {\n // One commit resolves one authority state per object, so two items for the same identity are\n // unambiguous only when they ask for the same thing.\n key: `${ref.objectTypeId}:${ref.primaryId}`,\n label: `object '${ref.objectTypeId}:${ref.primaryId}'`,\n fingerprint: stableJsonStringify(normalized.properties),\n operations: [\n objectUpsertOperation({\n id: runtimeOperationId(index),\n ref,\n properties: normalized.properties,\n }),\n ],\n }\n },\n value: ([outcome]) => toObjectRow(ctx.projectId, requireEffectiveObject(outcome)),\n })\n}\n",
17
+ "/**\n * Low-level write: append normalized telemetry points through the ontology Materializer.\n *\n * Shared by the batch operation and the per-property appenders in ObjectByIdHandle. The Materializer\n * persists immutable point history, derives latest telemetry state, and writes the commit's outbox\n * facts in one transaction, so this leaf never appends events or writes providers itself.\n */\nimport { randomUUID } from \"node:crypto\"\nimport type { AuthorizationContext } from \"../../authorization\"\nimport { assertCanAppendTelemetry } from \"../../authorization\"\nimport { MaterializationObjectNotFoundError } from \"../../materialization/errors\"\nimport type { TelemetryCommitResult, TelemetryPointWrite } from \"../../materialization/model\"\nimport { getOntologyMutationRuntime } from \"../../runtime/ontology-mutations\"\nimport { ObjectNotFoundError } from \"../../storage/errors\"\nimport type { RuntimeMaterializerContext } from \"../materializer-adapter\"\n\nexport type TelemetryWriteContext = RuntimeMaterializerContext & {\n readonly authorization?: AuthorizationContext\n}\n\nexport async function writeTelemetryBatch(\n ctx: TelemetryWriteContext,\n points: readonly TelemetryPointWrite[]\n): Promise<TelemetryCommitResult | null> {\n // Asserted from the points rather than a resolved context: this leaf is the low-level choke point\n // for both `appendTelemetryBatch` and the per-property `TelemetryChannel`, and only the points know\n // which object types the call actually touches.\n for (const objectTypeId of new Set(points.map((point) => point.series.object.objectTypeId))) {\n assertCanAppendTelemetry(ctx, objectTypeId)\n }\n if (points.length === 0) return null\n\n let commit: TelemetryCommitResult\n try {\n commit = await getOntologyMutationRuntime(ctx).appendTelemetry({\n source: { kind: \"runtime\", requestId: randomUUID() },\n points,\n })\n } catch (error) {\n if (error instanceof MaterializationObjectNotFoundError) {\n throw new ObjectNotFoundError(\n error.objectTypeId,\n error.primaryId,\n \"Object not found for telemetry append\"\n )\n }\n throw error\n }\n return commit\n}\n",
18
+ "/**\n * Leaf operation: batch telemetry append for multiple objects of a single type.\n */\nimport { assertCanAppendTelemetry } from \"../../authorization\"\nimport type { TelemetryPointWrite } from \"../../materialization/model\"\nimport { telemetryPointKey } from \"../../materialization/refs\"\nimport { OntologyValidationError } from \"../../ontology/errors\"\nimport { assertTelemetryProperty } from \"../../ontology/validation\"\nimport type { ResolvedObjectContext } from \"../context\"\nimport { writeTelemetryBatch } from \"./write-batch\"\n\n/**\n * Type guard for telemetry values that carry an explicit unit.\n *\n * Matches only the exact `{ value, unit }` wrapper (a string `unit` and no other\n * keys) so a legitimate JSON/object telemetry value is not silently\n * reinterpreted as value+unit. A fully explicit batch contract (passing units\n * out-of-band like the single-property appender) is tracked as a follow-up;\n * this narrows the heuristic without changing the public batch API.\n */\nfunction isUnitBearingValue(raw: unknown): raw is { value: unknown; unit: string } {\n if (raw === null || typeof raw !== \"object\") {\n return false\n }\n const record = raw as Record<string, unknown>\n return \"value\" in record && typeof record.unit === \"string\" && Object.keys(record).length === 2\n}\n\nexport async function appendTelemetryBatch(\n ctx: ResolvedObjectContext,\n items: readonly {\n id: string\n properties: Record<string, unknown | { value: unknown; unit: string }>\n at?: Date\n }[]\n): Promise<void> {\n // `writeTelemetryBatch` asserts again from the points it receives. Asserting here as well is not\n // redundant: it reports the type by name before any property is resolved, and it still refuses an\n // empty batch, which produces no points to assert over.\n assertCanAppendTelemetry(ctx, ctx.objectType.id)\n const { objectType } = ctx\n // Telemetry identity is `(series, at)`, so a repeated instant inside one call is an upsert: the\n // last value wins rather than failing the whole batch.\n const points = new Map<string, TelemetryPointWrite>()\n\n for (const item of items) {\n const at = (item.at ?? new Date()).toISOString()\n\n for (const [propertyId, rawValue] of Object.entries(item.properties)) {\n const propertyToken = objectType.p[propertyId]\n if (!propertyToken) {\n throw new OntologyValidationError(`Unknown property '${objectType.id}.${propertyId}'`)\n }\n\n assertTelemetryProperty(propertyToken.property)\n\n // Value and unit validation, plus schema normalization, happen inside the Materializer.\n const series = {\n object: { objectTypeId: objectType.id, primaryId: item.id },\n propertyId: propertyToken.id,\n }\n points.set(telemetryPointKey(series, at), {\n series,\n value: isUnitBearingValue(rawValue)\n ? (rawValue.value as TelemetryPointWrite[\"value\"])\n : (rawValue as TelemetryPointWrite[\"value\"]),\n ...(isUnitBearingValue(rawValue) ? { unit: rawValue.unit } : {}),\n at,\n })\n }\n }\n\n await writeTelemetryBatch(ctx, [...points.values()])\n}\n",
19
+ "import { createSixbError } from \"../../errors/internal\"\nimport type { AuthorizedObjectReader } from \"../../execution/authorized-object-reader\"\nimport type {\n TimeseriesHistoryBatchInput,\n TimeseriesHistoryBatchResult,\n TimeseriesHistorySeriesInput,\n TimeseriesPoint,\n TimeseriesStorage,\n} from \"../../storage\"\n\nexport interface TelemetryHistoryOptions {\n readonly storage: TimeseriesStorage\n readonly objectReader: AuthorizedObjectReader\n}\n\nexport type TelemetryHistoryBatchInput = Omit<TimeseriesHistoryBatchInput, \"projectId\">\n\ninterface SnapshotTelemetryHistoryRequest extends TelemetryHistoryBatchInput {\n readonly maxPointOccurrences?: number\n}\n\n/** Read only series selected for the exact object occurrence carried by the nominal reader. */\nexport async function getTelemetryHistoryBatch(\n input: TelemetryHistoryBatchInput,\n options: TelemetryHistoryOptions\n): Promise<readonly TimeseriesHistoryBatchResult[]> {\n // Capture both provider capabilities before reading caller-owned request fields.\n const objectReader = options.objectReader\n const storage = options.storage\n const projectId = objectReader.projectId\n const request = snapshotTelemetryHistoryInput(input, objectReader)\n\n const uniqueSeries = deduplicateSeries(request.series)\n const readableSeries = await selectReadableSeries(uniqueSeries, objectReader)\n const resultsBySeries = await readAndValidateHistory({\n storage,\n projectId,\n request,\n series: readableSeries,\n })\n\n // Objects and telemetry do not share a portable read snapshot. Recheck live selection after\n // all provider-owned values have been detached, before deciding which points to return.\n const releasableSeries =\n readableSeries.length === 0 ? [] : await selectReadableSeries(readableSeries, objectReader)\n const result = assembleHistoryResults({ request, resultsBySeries, releasableSeries })\n objectReader.assertVisibleOutputWithinLimit(result)\n return result\n}\n\n/** Read the latest point only while its exact object property remains selected. */\nexport async function getLatestTelemetryPoint(\n input: TimeseriesHistorySeriesInput,\n options: TelemetryHistoryOptions\n): Promise<TimeseriesPoint | null> {\n const objectReader = options.objectReader\n const storage = options.storage\n const projectId = objectReader.projectId\n const series = snapshotTelemetrySeries(input)\n const readable = await objectReader.canReadObjectProperty(objectPropertySelection(series))\n if (!readable) return visibleLatestResult(null, objectReader)\n\n const rawResult = await storage.getLatest({ projectId, ...series })\n const result = rawResult === null ? null : snapshotProviderPoint(rawResult)\n if (result) assertTimeseriesPointMatchesSeries(projectId, series, result)\n\n // See the batch release check above. Revocation during the timeseries read hides the result.\n const releaseReadable = await objectReader.canReadObjectProperty(objectPropertySelection(series))\n if (!releaseReadable) return visibleLatestResult(null, objectReader)\n\n return visibleLatestResult(result, objectReader)\n}\n\nfunction deduplicateSeries(\n series: readonly TimeseriesHistorySeriesInput[]\n): TimeseriesHistorySeriesInput[] {\n const uniqueSeries = new Map<string, TimeseriesHistorySeriesInput>()\n for (const item of series) {\n const key = seriesKey(item)\n if (!uniqueSeries.has(key)) uniqueSeries.set(key, item)\n }\n return [...uniqueSeries.values()]\n}\n\nasync function selectReadableSeries(\n series: readonly TimeseriesHistorySeriesInput[],\n objectReader: AuthorizedObjectReader\n): Promise<readonly TimeseriesHistorySeriesInput[]> {\n const readable = await objectReader.canReadObjectPropertiesBatch({\n items: series.map(objectPropertySelection),\n })\n return series.filter((_, index) => readable[index] === true)\n}\n\nasync function readAndValidateHistory(input: {\n readonly storage: TimeseriesStorage\n readonly projectId: string\n readonly request: SnapshotTelemetryHistoryRequest\n readonly series: readonly TimeseriesHistorySeriesInput[]\n}): Promise<ReadonlyMap<string, TimeseriesHistoryBatchResult>> {\n const { storage, projectId, request, series } = input\n\n // The provider receives its own detached request. It must never retain or mutate the canonical\n // series snapshot that admission and the final release check rely on.\n const providerRequest = structuredClone({\n projectId,\n series,\n ...(request.from === undefined ? {} : { from: request.from }),\n ...(request.to === undefined ? {} : { to: request.to }),\n ...(request.limitPerSeries === undefined ? {} : { limitPerSeries: request.limitPerSeries }),\n ...(request.order === undefined ? {} : { order: request.order }),\n })\n const stored = series.length === 0 ? [] : await storage.getHistoryBatch(providerRequest)\n\n // Fully detach and validate provider-owned data before the final live check. A provider result\n // may contain accessors or a custom iterator; none of that code may run after release admission.\n if (!Array.isArray(stored)) throw invalidTimeseriesProviderResult()\n const storedCount = stored.length\n if (!Number.isSafeInteger(storedCount) || storedCount > series.length) {\n throw invalidTimeseriesProviderResult()\n }\n const seriesKeys = new Set(series.map(seriesKey))\n const providerResultBySeries = new Map<string, TimeseriesHistoryBatchResult>()\n for (let index = 0; index < storedCount; index += 1) {\n const providerResult = snapshotProviderResult(stored[index]!, request.limitPerSeries)\n const key = seriesKey(providerResult)\n if (providerResultBySeries.has(key) || !seriesKeys.has(key)) {\n throw invalidTimeseriesProviderResult()\n }\n for (const point of providerResult.points) {\n assertTimeseriesPointMatchesSeries(projectId, providerResult, point)\n }\n providerResultBySeries.set(key, providerResult)\n }\n\n return providerResultBySeries\n}\n\n/** Restore request order and duplicates, with independent point copies for every occurrence. */\nfunction assembleHistoryResults(input: {\n readonly request: SnapshotTelemetryHistoryRequest\n readonly resultsBySeries: ReadonlyMap<string, TimeseriesHistoryBatchResult>\n readonly releasableSeries: readonly TimeseriesHistorySeriesInput[]\n}): readonly TimeseriesHistoryBatchResult[] {\n const { request, resultsBySeries, releasableSeries } = input\n const releasableSeriesKeys = new Set(releasableSeries.map(seriesKey))\n const releasedPoints = request.series.map((series) =>\n releasableSeriesKeys.has(seriesKey(series))\n ? (resultsBySeries.get(seriesKey(series))?.points ?? [])\n : []\n )\n const pointOccurrences = releasedPoints.reduce((total, points) => total + points.length, 0)\n if (request.maxPointOccurrences !== undefined && pointOccurrences > request.maxPointOccurrences) {\n throw invalidTimeseriesProviderResult()\n }\n return request.series.map((series, index) => ({\n ...series,\n points: releasedPoints[index]!.map((point) => structuredClone(point)),\n }))\n}\n\nfunction snapshotTelemetrySeries(\n series: TimeseriesHistorySeriesInput\n): TimeseriesHistorySeriesInput {\n if (typeof series !== \"object\" || series === null || Array.isArray(series)) {\n throw new Error(\"[Sixb] Telemetry history series must be an object.\")\n }\n const objectTypeId = telemetryIdentifier(series.objectTypeId, \"objectTypeId\")\n const objectId = telemetryIdentifier(series.objectId, \"objectId\")\n const propertyId = telemetryIdentifier(series.propertyId, \"propertyId\")\n return structuredClone({ objectTypeId, objectId, propertyId })\n}\n\nfunction assertTimeseriesPointMatchesSeries(\n projectId: string,\n series: TimeseriesHistorySeriesInput,\n point: TimeseriesPoint\n): void {\n if (\n typeof point !== \"object\" ||\n point === null ||\n point.projectId !== projectId ||\n point.objectTypeId !== series.objectTypeId ||\n point.objectId !== series.objectId ||\n point.propertyId !== series.propertyId\n ) {\n throw invalidTimeseriesProviderResult()\n }\n}\n\nfunction snapshotTelemetryHistoryInput(\n input: TelemetryHistoryBatchInput,\n objectReader: AuthorizedObjectReader\n): SnapshotTelemetryHistoryRequest {\n const authoredSeries = input.series\n const from = input.from\n const to = input.to\n const limitPerSeries = input.limitPerSeries\n const order = input.order\n if (!Array.isArray(authoredSeries)) {\n throw new Error(\"[Sixb] Telemetry history series must be an array.\")\n }\n if (order !== undefined && order !== \"asc\" && order !== \"desc\") {\n throw new Error(\"[Sixb] Telemetry history order must be 'asc' or 'desc'.\")\n }\n\n // Capture length once and walk by index so proxies cannot change the iteration shape halfway.\n const seriesCount = authoredSeries.length\n const admission = objectReader.admitTelemetryHistoryRead({\n seriesCount,\n ...(limitPerSeries === undefined ? {} : { limitPerSeries }),\n })\n const series: TimeseriesHistorySeriesInput[] = []\n for (let index = 0; index < seriesCount; index += 1) {\n series.push(snapshotTelemetrySeries(authoredSeries[index]!))\n }\n return structuredClone({\n series,\n ...(from === undefined ? {} : { from }),\n ...(to === undefined ? {} : { to }),\n ...(admission.limitPerSeries === undefined ? {} : { limitPerSeries: admission.limitPerSeries }),\n ...(order === undefined ? {} : { order }),\n ...(admission.maxPointOccurrences === undefined\n ? {}\n : { maxPointOccurrences: admission.maxPointOccurrences }),\n })\n}\n\nfunction objectPropertySelection(series: TimeseriesHistorySeriesInput): {\n readonly objectTypeId: string\n readonly primaryId: string\n readonly propertyId: string\n} {\n return {\n objectTypeId: series.objectTypeId,\n primaryId: series.objectId,\n propertyId: series.propertyId,\n }\n}\n\nfunction visibleLatestResult<T extends TimeseriesPoint | null>(\n result: T,\n objectReader: AuthorizedObjectReader\n): T {\n objectReader.assertVisibleOutputWithinLimit(result)\n return result\n}\n\nfunction snapshotProviderResult(\n result: TimeseriesHistoryBatchResult,\n maxPointsPerSeries: number | undefined\n): TimeseriesHistoryBatchResult {\n try {\n if (typeof result !== \"object\" || result === null || Array.isArray(result)) {\n throw invalidTimeseriesProviderResult()\n }\n const series = snapshotTelemetrySeries(result)\n const authoredPoints = result.points\n if (!Array.isArray(authoredPoints)) throw invalidTimeseriesProviderResult()\n const pointCount = authoredPoints.length\n if (\n !Number.isSafeInteger(pointCount) ||\n (maxPointsPerSeries !== undefined && pointCount > maxPointsPerSeries)\n ) {\n throw invalidTimeseriesProviderResult()\n }\n const points: TimeseriesPoint[] = []\n for (let index = 0; index < pointCount; index += 1) {\n points.push(snapshotProviderPoint(authoredPoints[index]!))\n }\n return { ...series, points }\n } catch (error) {\n if (isInvalidTimeseriesProviderResult(error)) throw error\n throw invalidTimeseriesProviderResult(error)\n }\n}\n\nfunction snapshotProviderPoint(point: TimeseriesPoint): TimeseriesPoint {\n try {\n const snapshot = structuredClone(point)\n if (!snapshot || typeof snapshot !== \"object\") throw invalidTimeseriesProviderResult()\n return snapshot\n } catch (error) {\n if (isInvalidTimeseriesProviderResult(error)) throw error\n throw invalidTimeseriesProviderResult(error)\n }\n}\n\nfunction invalidTimeseriesProviderResult(cause?: unknown): Error {\n return createSixbError(\n \"internal.unexpected\",\n \"[Sixb] Timeseries storage returned data outside the requested series.\",\n cause === undefined ? {} : { cause }\n )\n}\n\nfunction isInvalidTimeseriesProviderResult(\n error: unknown\n): error is Error & { readonly code: \"internal.unexpected\" } {\n return (\n error instanceof Error &&\n \"code\" in error &&\n error.code === \"internal.unexpected\" &&\n error.message === \"[Sixb] Timeseries storage returned data outside the requested series.\"\n )\n}\n\nfunction telemetryIdentifier(value: unknown, field: string): string {\n if (typeof value !== \"string\" || !value.trim()) {\n throw new Error(`[Sixb] Telemetry history ${field} must be a non-empty string.`)\n }\n return value\n}\n\nfunction seriesKey(series: TimeseriesHistorySeriesInput): string {\n return JSON.stringify([series.objectTypeId, series.objectId, series.propertyId])\n}\n",
20
+ "/**\n * Context resolution factories.\n *\n * Resolve ontology identifiers into concrete type data so leaf functions\n * receive all structural information pre-resolved.\n */\n\nimport type { ObjectLink } from \"../../ontology\"\nimport { OntologyNotFoundError } from \"../../ontology/errors\"\nimport type { ObjectTypeWithPropertyTokens } from \"../../ontology/tokens\"\nimport type { SixbRuntimeContext } from \"../../runtime/types\"\nimport type { ResolvedLinkContext, ResolvedObjectContext } from \"./types\"\n\n/** Look up a link definition on an object type, throwing if not found. */\nexport function requireLinkDefinition(\n objectType: ObjectTypeWithPropertyTokens,\n linkId: string\n): ObjectLink {\n const def = objectType.links.find((l) => l.id === linkId)\n if (!def) throw new OntologyNotFoundError(`Unknown link '${objectType.id}.${linkId}'`)\n return def\n}\n\n/**\n * Resolve an object type id to a full ResolvedObjectContext.\n *\n * Uses ontology.resolveObjectType() and getPrimaryPropertyId() — these\n * are structural resolution calls that belong in factories, not leaf functions.\n */\nexport function resolveObjectContext(\n runtime: SixbRuntimeContext,\n objectTypeId: string\n): ResolvedObjectContext {\n const objectType = runtime.ontology.resolveObjectType(objectTypeId)\n const primaryPropertyId = runtime.ontology.getPrimaryPropertyId(objectTypeId)\n return { ...runtime, objectType, primaryPropertyId }\n}\n\n/**\n * Resolve a link id to a full ResolvedLinkContext.\n *\n * Uses requireLinkDefinition to look up the link definition on the\n * already-resolved object type.\n */\nexport function resolveLinkContext(\n objCtx: ResolvedObjectContext,\n linkId: string\n): ResolvedLinkContext {\n const linkDefinition = requireLinkDefinition(objCtx.objectType, linkId)\n return { ...objCtx, linkDefinition }\n}\n",
21
+ "/**\n * Telemetry channel factory for ObjectByIdHandle.\n *\n * Creates a per-property channel that writes through the low-level `writeTelemetryBatch` leaf and\n * reads the same series back through `getTelemetryHistoryBatch`, both keyed by the property token.\n */\nimport type { TelemetryPointWrite } from \"../../materialization/model\"\nimport type { ValueType } from \"../../ontology\"\nimport type { ObjectTypeWithPropertyTokens } from \"../../ontology/tokens\"\nimport {\n assertPropertyTokenBelongsToObjectType,\n assertTelemetryProperty,\n} from \"../../ontology/validation\"\nimport { RuntimeError } from \"../../runtime/errors\"\nimport type {\n TelemetryChannel,\n TelemetryHistoryInput,\n TelemetryPropertyToken,\n} from \"../../runtime/types\"\nimport type { ResolvedObjectContext } from \"../context\"\nimport { getTelemetryHistoryBatch, writeTelemetryBatch } from \"../telemetry\"\n\nexport function createTelemetryChannel<\n TObjectType extends ObjectTypeWithPropertyTokens,\n TValueTypes extends readonly ValueType[],\n>(ctx: ResolvedObjectContext, primaryId: string) {\n return <TToken extends TelemetryPropertyToken<TObjectType>>(\n property: TToken\n ): TelemetryChannel<TToken, TValueTypes> => {\n const { objectType } = ctx\n assertPropertyTokenBelongsToObjectType(objectType, property)\n assertTelemetryProperty(property.property)\n\n const series = { objectTypeId: objectType.id, objectId: primaryId, propertyId: property.id }\n\n const channel = {\n append: async (input: { value: unknown; unit?: string; at: Date }) => {\n // Value and unit validation, plus schema normalization, happen inside the Materializer.\n await writeTelemetryBatch(ctx, [\n {\n series: {\n object: { objectTypeId: objectType.id, primaryId },\n propertyId: property.id,\n },\n value: input.value as TelemetryPointWrite[\"value\"],\n ...(input.unit !== undefined ? { unit: input.unit } : {}),\n at: input.at.toISOString(),\n },\n ])\n },\n\n history: async (input: TelemetryHistoryInput = {}) => {\n const timeseries = ctx.storage.timeseries\n const objectReader = ctx.objectReader\n if (!timeseries) {\n throw new RuntimeError(\"[Sixb] Reading telemetry requires storage.timeseries support.\")\n }\n\n const from = input.from\n const to = input.to\n const limit = input.limit\n const order = input.order\n\n const [result] = await getTelemetryHistoryBatch(\n {\n series: [series],\n ...(from !== undefined ? { from } : {}),\n ...(to !== undefined ? { to } : {}),\n ...(limit !== undefined ? { limitPerSeries: limit } : {}),\n ...(order !== undefined ? { order } : {}),\n },\n {\n storage: timeseries,\n objectReader,\n }\n )\n\n return (result?.points ?? []).map((point) => ({\n value: point.value,\n at: point.at,\n ...(point.unit !== undefined ? { unit: point.unit } : {}),\n }))\n },\n }\n\n // Cast needed: generic token inference boundary — TToken is narrower than what `channel` sees\n return channel as unknown as TelemetryChannel<TToken, TValueTypes>\n }\n}\n",
22
+ "/**\n * ObjectByIdHandle binds operations to a specific object id within an ObjectSet.\n * Created via `sixb.objects(MyType).byId(\"id-1\")`, it provides link/unlink and\n * per-property telemetry appenders with compile-time unit and value type safety.\n */\nimport type { ActionDefinition } from \"../../actions\"\nimport type { ObjectLink, ObjectRef, ValueType } from \"../../ontology\"\nimport { OntologyValidationError } from \"../../ontology/errors\"\nimport type { LinkToken, ObjectTypeWithPropertyTokens } from \"../../ontology/tokens\"\nimport { assertLinkTokenBelongsToObjectType } from \"../../ontology/validation\"\nimport type { ObjectByIdHandle, TwinObject } from \"../../runtime/types\"\nimport {\n requestActionAndWait as requestActionAndWaitLeaf,\n requestAction as requestActionLeaf,\n} from \"../action\"\nimport type { ExecutionObjectContext, ResolvedLinkContext } from \"../context\"\nimport { removeLink as removeLinkLeaf, upsertLink as upsertLinkLeaf } from \"../link\"\nimport { deleteObject, restoreObject } from \"../object\"\nimport { createTelemetryChannel } from \"./telemetry-channel\"\n\ntype ObjectRefInput = ObjectRef\ntype AnyLinkToken = LinkToken<string, string, string | readonly string[], ObjectLink>\n\nexport function createObjectByIdHandle<\n TObjectType extends ObjectTypeWithPropertyTokens,\n TValueTypes extends readonly ValueType[],\n>(ctx: ExecutionObjectContext, primaryId: string): ObjectByIdHandle<TObjectType, TValueTypes> {\n const objectHandle = {\n get: async () => {\n const row = await ctx.objectReader.getByPrimaryId({\n objectTypeId: ctx.objectType.id,\n primaryId,\n })\n return row ? (row as unknown as TwinObject<TObjectType, TValueTypes>) : null\n },\n\n listLinks: async (linkToken?: AnyLinkToken) => {\n if (linkToken) {\n assertLinkTokenBelongsToObjectType(ctx.objectType, linkToken)\n }\n return ctx.objectReader.listLinks({\n objectTypeId: ctx.objectType.id,\n objectId: primaryId,\n linkId: linkToken?.id,\n })\n },\n\n link: async (\n linkToken: AnyLinkToken,\n target: ObjectRefInput,\n options?: { properties?: Record<string, unknown> }\n ) => {\n assertLinkTokenBelongsToObjectType(ctx.objectType, linkToken)\n\n const linkCtx: ResolvedLinkContext = { ...ctx, linkDefinition: linkToken.link }\n await upsertLinkLeaf(linkCtx, {\n sourceId: primaryId,\n linkId: linkToken.id,\n targetTypeId: target.objectTypeId,\n targetId: target.primaryId,\n properties: options?.properties,\n })\n },\n\n unlink: async (linkToken: AnyLinkToken, target: ObjectRefInput) => {\n assertLinkTokenBelongsToObjectType(ctx.objectType, linkToken)\n\n const linkCtx: ResolvedLinkContext = { ...ctx, linkDefinition: linkToken.link }\n await removeLinkLeaf(linkCtx, {\n sourceId: primaryId,\n linkId: linkToken.id,\n targetTypeId: target.objectTypeId,\n targetId: target.primaryId,\n })\n },\n\n delete: async () => {\n await deleteObject(ctx, primaryId)\n },\n\n restore: async () => {\n await restoreObject(ctx, primaryId)\n },\n\n requestAction: async (input: {\n action?: ActionDefinition\n actionId?: string\n params?: Record<string, unknown>\n runId?: string\n }) => {\n const actionId = input.action?.id ?? input.actionId\n if (!actionId) {\n throw new OntologyValidationError(\n \"[Sixb] requestAction requires either 'action' or 'actionId'\"\n )\n }\n return requestActionLeaf(ctx, {\n primaryId,\n actionId,\n params: input.params,\n options: { runId: input.runId },\n })\n },\n\n requestActionAndWait: async (input: {\n action?: ActionDefinition\n actionId?: string\n params?: Record<string, unknown>\n timeoutMs?: number\n signal?: AbortSignal\n }) => {\n const actionId = input.action?.id ?? input.actionId\n if (!actionId) {\n throw new OntologyValidationError(\n \"[Sixb] requestActionAndWait requires either 'action' or 'actionId'\"\n )\n }\n return requestActionAndWaitLeaf(ctx, {\n primaryId,\n actionId,\n params: input.params,\n options: {\n timeoutMs: input.timeoutMs,\n signal: input.signal,\n },\n })\n },\n\n telemetry: createTelemetryChannel<TObjectType, TValueTypes>(ctx, primaryId),\n }\n\n return objectHandle as unknown as ObjectByIdHandle<TObjectType, TValueTypes>\n}\n",
23
+ "/**\n * Server-side ObjectQueryExecutor backed by the shared query executor and storage.\n * Validation, planning, fallback, and execution all run in-process here; the\n * HTTP executor in `@sixb/client` is the remote counterpart.\n */\n\nimport type { AuthorizedObjectReader } from \"../../execution/authorized-object-reader\"\nimport type { OntologyRegistry } from \"../../ontology\"\nimport { ObjectQueryPlanningError } from \"../query\"\nimport { explainObjectQuery } from \"../query/explain\"\nimport type { ObjectQuery } from \"../query/ir\"\nimport { validateObjectQuery } from \"../query/validate\"\nimport type { ObjectQueryExecutor, ObjectQueryExecutorFacetRequest } from \"./query-executor\"\n\nexport function createRuntimeQueryExecutor(params: {\n ontology: OntologyRegistry\n objectReader: AuthorizedObjectReader\n}): ObjectQueryExecutor {\n const { ontology, objectReader } = params\n\n return {\n async list(query: ObjectQuery, options?: { includeTotal?: boolean }) {\n try {\n return await objectReader.executeQuery({ query, includeTotal: options?.includeTotal })\n } catch (error) {\n if (error instanceof ObjectQueryPlanningError) {\n throw addSdkPlanningHints(error)\n }\n throw error\n }\n },\n\n async count(query: ObjectQuery) {\n const result = await objectReader.count({ query })\n return result.count\n },\n\n async exists(query: ObjectQuery) {\n const result = await objectReader.exists({ query })\n return result.exists\n },\n\n async facets(query: ObjectQuery, facets: readonly ObjectQueryExecutorFacetRequest[]) {\n const result = await objectReader.facet({ query, facets })\n return result.facets.map((facet) => ({\n propertyId: facet.propertyId,\n buckets: [...facet.buckets],\n }))\n },\n\n validate(query: ObjectQuery) {\n return validateObjectQuery(query, { ontology, normalize: false })\n },\n\n explain(query: ObjectQuery) {\n return explainObjectQuery(query, { ontology, normalize: false })\n },\n }\n}\n\nfunction addSdkPlanningHints(error: ObjectQueryPlanningError): ObjectQueryPlanningError {\n if (!error.issues.some((issue) => issue.code === \"fallback_requires_bound\")) return error\n\n return new ObjectQueryPlanningError(\n error.issues.map((issue) =>\n issue.code === \"fallback_requires_bound\"\n ? {\n ...issue,\n message:\n \"Object query fallback requires an explicit result bound. Add .limit(n) or .page({ pageSize: n }) before .list().\",\n }\n : issue\n )\n )\n}\n",
24
+ "/**\n * ObjectSet provides a type-safe collection API for objects of a given type.\n * Created via `sixb.objects(MyType)`, it exposes upsert, query, and telemetry batch operations\n * while preserving compile-time property types inferred from the ontology definition.\n */\n\nimport type { ActionDefinition } from \"../../actions\"\nimport type { AuthorizationContext } from \"../../authorization\"\nimport { shareSixbErrorReporter } from \"../../error-reporting/capability\"\nimport type { ExecutionContext } from \"../../execution\"\nimport { assertAuthorizedObjectReaderBinding } from \"../../execution/authorized-object-reader\"\nimport type { ValueType } from \"../../ontology\"\nimport { OntologyValidationError } from \"../../ontology/errors\"\nimport type { ObjectTypeWithPropertyTokens } from \"../../ontology/tokens\"\nimport { shareOntologyMutationRuntime } from \"../../runtime/ontology-mutations\"\nimport type {\n ObjectSet,\n ObjectSetListInput,\n SixbRuntimeContext,\n TwinObject,\n} from \"../../runtime/types\"\nimport {\n requestActionAndWait as requestActionAndWaitLeaf,\n requestAction as requestActionLeaf,\n} from \"../action\"\nimport type { ExecutionObjectContext, ResolvedLinkContext } from \"../context\"\nimport { requireLinkDefinition } from \"../context\"\nimport { removeLink as removeLinkLeaf, upsertLink as upsertLinkLeaf } from \"../link\"\nimport { upsertObject as upsertObjectLeaf } from \"../object\"\nimport { appendTelemetryBatch as appendTelemetryBatchLeaf } from \"../telemetry\"\nimport { createObjectByIdHandle } from \"./object-handle\"\nimport { createObjectQueryBuilder } from \"./query-builder\"\nimport { createRuntimeQueryExecutor } from \"./runtime-query-executor\"\n\nexport function createObjectSet<\n TObjectType extends ObjectTypeWithPropertyTokens,\n TRegisteredObjectTypes extends ObjectTypeWithPropertyTokens,\n TValueTypes extends readonly ValueType[],\n>(\n params: SixbRuntimeContext & {\n readonly execution: ExecutionContext\n readonly objectType: TObjectType\n readonly authorization?: AuthorizationContext\n }\n): ObjectSet<TObjectType, TValueTypes, TRegisteredObjectTypes> {\n assertAuthorizedObjectReaderBinding({\n reader: params.objectReader,\n scope: { execution: params.execution, authorization: params.runtimeAuthorization },\n })\n const { objectType } = params\n const primaryProp = objectType.properties.find((p) => p.primary)\n if (!primaryProp) {\n throw new OntologyValidationError(`Object type '${objectType.id}' has no primary property`)\n }\n const primaryPropertyId = primaryProp.id\n\n const {\n projectId,\n broker,\n ontology,\n actionRegistry,\n events,\n storage,\n queues,\n objectReader,\n runtimeAuthorization,\n authorization,\n execution,\n } = params\n const queryExecutor = createRuntimeQueryExecutor({\n ontology,\n objectReader,\n })\n\n const resolvedCtx: ExecutionObjectContext = {\n projectId,\n broker,\n ontology,\n actionRegistry,\n events,\n storage,\n queues,\n objectReader,\n runtimeAuthorization,\n authorization,\n execution,\n objectType,\n primaryPropertyId,\n }\n shareOntologyMutationRuntime(params, resolvedCtx)\n shareSixbErrorReporter(params, resolvedCtx)\n\n const objectSet = {\n get: async (id: string) => {\n const row = await objectReader.getByPrimaryId({\n objectTypeId: objectType.id,\n primaryId: id,\n })\n return row ? (row as unknown as TwinObject<TObjectType, TValueTypes>) : null\n },\n\n upsert: async (input: { properties: Record<string, unknown> }) => {\n const row = await upsertObjectLeaf(resolvedCtx, input.properties)\n return row as unknown as TwinObject<TObjectType, TValueTypes>\n },\n\n query: () =>\n createObjectQueryBuilder<TObjectType, TRegisteredObjectTypes, TValueTypes>({\n query: { kind: \"start\", objectTypeId: objectType.id },\n executor: queryExecutor,\n }),\n\n byId: (id: string) => createObjectByIdHandle<TObjectType, TValueTypes>(resolvedCtx, id),\n\n list: async (input?: ObjectSetListInput) => {\n const result = await objectReader.list({\n objectTypeId: objectType.id,\n primaryIdPrefix: input?.idPrefix,\n primaryIdSuffix: input?.idSuffix,\n updatedAfter: input?.updatedAfter,\n updatedBefore: input?.updatedBefore,\n createdAfter: input?.createdAfter,\n createdBefore: input?.createdBefore,\n limit: input?.limit,\n offset: input?.offset,\n orderBy: input?.orderBy,\n order: input?.order,\n })\n\n return {\n objects: result.objects.map(\n (row) => row as unknown as TwinObject<TObjectType, TValueTypes>\n ),\n hasMore: result.hasMore,\n total: result.total ?? result.objects.length,\n }\n },\n\n appendTelemetryBatch: async (\n items: readonly {\n id: string\n properties: Record<string, unknown | { value: unknown; unit: string }>\n at?: Date\n }[]\n ) => {\n await appendTelemetryBatchLeaf(resolvedCtx, items)\n },\n\n requestAction: async (input: {\n id: string\n action?: ActionDefinition\n actionId?: string\n params?: Record<string, unknown>\n runId?: string\n }) => {\n const actionId = input.action?.id ?? input.actionId\n if (!actionId) {\n throw new OntologyValidationError(\n \"[Sixb] requestAction requires either 'action' or 'actionId'\"\n )\n }\n return requestActionLeaf(resolvedCtx, {\n primaryId: input.id,\n actionId,\n params: input.params,\n options: { runId: input.runId },\n })\n },\n\n requestActionAndWait: async (input: {\n id: string\n action?: ActionDefinition\n actionId?: string\n params?: Record<string, unknown>\n timeoutMs?: number\n signal?: AbortSignal\n }) => {\n const actionId = input.action?.id ?? input.actionId\n if (!actionId) {\n throw new OntologyValidationError(\n \"[Sixb] requestActionAndWait requires either 'action' or 'actionId'\"\n )\n }\n return requestActionAndWaitLeaf(resolvedCtx, {\n primaryId: input.id,\n actionId,\n params: input.params,\n options: {\n timeoutMs: input.timeoutMs,\n signal: input.signal,\n },\n })\n },\n\n upsertLink: async (input: {\n sourceId: string\n linkId: string\n targetTypeId: string\n targetId: string\n properties?: Record<string, unknown>\n }) => {\n const linkDefinition = requireLinkDefinition(objectType, input.linkId)\n const linkCtx: ResolvedLinkContext = { ...resolvedCtx, linkDefinition }\n\n await upsertLinkLeaf(linkCtx, {\n sourceId: input.sourceId,\n linkId: input.linkId,\n targetTypeId: input.targetTypeId,\n targetId: input.targetId,\n properties: input.properties,\n })\n },\n\n removeLink: async (input: {\n sourceId: string\n linkId: string\n targetTypeId: string\n targetId: string\n }) => {\n const linkDefinition = requireLinkDefinition(objectType, input.linkId)\n const linkCtx: ResolvedLinkContext = { ...resolvedCtx, linkDefinition }\n\n await removeLinkLeaf(linkCtx, {\n sourceId: input.sourceId,\n linkId: input.linkId,\n targetTypeId: input.targetTypeId,\n targetId: input.targetId,\n })\n },\n }\n\n return objectSet as unknown as ObjectSet<TObjectType, TValueTypes, TRegisteredObjectTypes>\n}\n",
25
+ "/**\n * Service layer for action operations.\n *\n * Resolves objectTypeId to a typed context and delegates to the leaf function.\n */\n\nimport type { RequestActionResult } from \"../../actions/request\"\nimport type { ExecutionContext } from \"../../execution\"\nimport type { SixbRuntimeContext } from \"../../runtime/types\"\nimport type { ActionRunRecord } from \"../../storage\"\nimport {\n type RequestActionAndWaitOptions,\n type RequestActionOptions,\n requestActionAndWait as requestActionAndWaitLeaf,\n requestAction as requestActionLeaf,\n} from \"../action\"\nimport { resolveObjectContext } from \"../context\"\n\nexport async function requestAction(\n runtime: SixbRuntimeContext,\n execution: ExecutionContext,\n objectTypeId: string,\n primaryId: string,\n actionId: string,\n params?: Record<string, unknown>,\n options?: RequestActionOptions\n): Promise<RequestActionResult> {\n const ctx = { ...resolveObjectContext(runtime, objectTypeId), execution }\n return requestActionLeaf(ctx, { primaryId, actionId, params, options })\n}\n\nexport async function requestActionAndWait(\n runtime: SixbRuntimeContext,\n execution: ExecutionContext,\n objectTypeId: string,\n primaryId: string,\n actionId: string,\n params?: Record<string, unknown>,\n options?: RequestActionAndWaitOptions\n): Promise<ActionRunRecord> {\n const ctx = { ...resolveObjectContext(runtime, objectTypeId), execution }\n return requestActionAndWaitLeaf(ctx, { primaryId, actionId, params, options })\n}\n",
26
+ "/**\n * Service layer for link operations.\n *\n * Resolves objectTypeId to a typed context and delegates to leaf functions.\n */\nimport type { BatchItemResult, SixbRuntimeContext } from \"../../runtime/types\"\nimport type { ResolvedLinkBatchItem } from \"../context\"\nimport { requireLinkDefinition, resolveLinkContext, resolveObjectContext } from \"../context\"\nimport {\n removeLink as removeLinkLeaf,\n upsertLinkBatch as upsertLinkBatchLeaf,\n upsertLink as upsertLinkLeaf,\n} from \"../link\"\n\nexport async function upsertLink(\n runtime: SixbRuntimeContext,\n objectTypeId: string,\n sourceId: string,\n linkId: string,\n target: { targetTypeId: string; targetId: string; properties?: Record<string, unknown> }\n): Promise<void> {\n const ctx = resolveObjectContext(runtime, objectTypeId)\n const linkCtx = resolveLinkContext(ctx, linkId)\n await upsertLinkLeaf(linkCtx, {\n sourceId,\n linkId,\n targetTypeId: target.targetTypeId,\n targetId: target.targetId,\n properties: target.properties,\n })\n}\n\nexport async function upsertLinkBatch(\n runtime: SixbRuntimeContext,\n items: readonly {\n objectTypeId: string\n sourceId: string\n linkId: string\n target: { targetTypeId: string; targetId: string; properties?: Record<string, unknown> }\n }[]\n): Promise<readonly BatchItemResult<void>[]> {\n const resolvedItems: ResolvedLinkBatchItem[] = items.map((item) => {\n const objectType = runtime.ontology.resolveObjectType(item.objectTypeId)\n const linkDefinition = requireLinkDefinition(objectType, item.linkId)\n return {\n objectType,\n linkDefinition,\n sourceId: item.sourceId,\n linkId: item.linkId,\n targetTypeId: item.target.targetTypeId,\n targetId: item.target.targetId,\n properties: item.target.properties,\n }\n })\n\n return upsertLinkBatchLeaf(runtime, resolvedItems)\n}\n\nexport async function removeLink(\n runtime: SixbRuntimeContext,\n objectTypeId: string,\n sourceId: string,\n linkId: string,\n target: { targetTypeId: string; targetId: string }\n): Promise<void> {\n const ctx = resolveObjectContext(runtime, objectTypeId)\n const linkCtx = resolveLinkContext(ctx, linkId)\n await removeLinkLeaf(linkCtx, {\n sourceId,\n linkId,\n targetTypeId: target.targetTypeId,\n targetId: target.targetId,\n })\n}\n",
27
+ "/**\n * Cross-type object listing for dashboards and search.\n *\n * Type hierarchies are expanded before the request reaches the canonical object\n * reader, which owns authorization and provider-scope enforcement.\n */\n\nimport { resolveRuntimeAuthorizationForProject } from \"../../execution/authorization\"\nimport { getAuthorizedOntologyView } from \"../../execution/authorized-object-reader\"\nimport type { ListResult, SixbRuntimeContext } from \"../../runtime/types\"\nimport type { ObjectRow } from \"../../storage\"\n\nexport interface ListObjectsParams {\n objectTypeIds?: readonly string[]\n idPrefix?: string\n idSuffix?: string\n updatedAfter?: Date\n updatedBefore?: Date\n createdAfter?: Date\n createdBefore?: Date\n limit?: number\n offset?: number\n orderBy?: \"createdAt\" | \"updatedAt\" | \"primaryId\"\n order?: \"asc\" | \"desc\"\n}\n\nexport async function listObjects(\n runtime: SixbRuntimeContext,\n params: ListObjectsParams\n): Promise<ListResult<ObjectRow>> {\n const objectTypeIds = resolveTypeFilter(runtime, params.objectTypeIds)\n\n if (objectTypeIds !== undefined && objectTypeIds.length === 0) {\n return { objects: [], hasMore: false, total: 0 }\n }\n\n const result = await runtime.objectReader.list({\n objectTypeId: objectTypeIds?.length === 1 ? objectTypeIds[0] : objectTypeIds,\n primaryIdPrefix: params.idPrefix,\n primaryIdSuffix: params.idSuffix,\n updatedAfter: params.updatedAfter,\n updatedBefore: params.updatedBefore,\n createdAfter: params.createdAfter,\n createdBefore: params.createdBefore,\n limit: params.limit,\n offset: params.offset,\n orderBy: params.orderBy,\n order: params.order,\n })\n\n return {\n objects: [...result.objects],\n hasMore: result.hasMore,\n total: result.total,\n }\n}\n\nfunction resolveTypeFilter(\n runtime: SixbRuntimeContext,\n requested: readonly string[] | undefined\n): readonly string[] | undefined {\n const ontology =\n resolveRuntimeAuthorizationForProject(runtime).type === \"delegated\"\n ? getAuthorizedOntologyView(runtime.objectReader)\n : runtime.ontology\n if (requested) {\n for (const objectTypeId of requested) {\n ontology.resolveObjectType(objectTypeId)\n }\n }\n\n return requested\n ? [...new Set(requested.flatMap((id) => [id, ...ontology.listSubTypes(id)]))]\n : undefined\n}\n",
28
+ "/**\n * Service layer for object upsert operations.\n *\n * Resolves objectTypeId to a typed context and delegates to leaf functions.\n */\nimport type { BatchItemResult, SixbRuntimeContext } from \"../../runtime/types\"\nimport type { ObjectRow } from \"../../storage\"\nimport { resolveObjectContext } from \"../context\"\nimport {\n upsertObjectBatch as upsertObjectBatchLeaf,\n upsertObject as upsertObjectLeaf,\n} from \"../object\"\n\nexport async function upsertObject(\n runtime: SixbRuntimeContext,\n objectTypeId: string,\n properties: Record<string, unknown>\n): Promise<ObjectRow> {\n return upsertObjectLeaf(resolveObjectContext(runtime, objectTypeId), properties)\n}\n\nexport async function upsertObjectBatch(\n runtime: SixbRuntimeContext,\n objectTypeId: string,\n items: readonly { properties: Record<string, unknown> }[]\n): Promise<readonly BatchItemResult<ObjectRow>[]> {\n return upsertObjectBatchLeaf(resolveObjectContext(runtime, objectTypeId), items)\n}\n",
29
+ "/**\n * Service layer for telemetry operations.\n *\n * Resolves objectTypeId to a typed context and delegates to the leaf function.\n */\nimport type { SixbRuntimeContext } from \"../../runtime/types\"\nimport { resolveObjectContext } from \"../context\"\nimport { appendTelemetryBatch as appendTelemetryBatchLeaf } from \"../telemetry\"\n\nexport async function appendTelemetry(\n runtime: SixbRuntimeContext,\n objectTypeId: string,\n items: readonly { id: string; properties: Record<string, unknown>; at?: Date }[]\n): Promise<void> {\n const ctx = resolveObjectContext(runtime, objectTypeId)\n await appendTelemetryBatchLeaf(ctx, items)\n}\n"
30
+ ],
31
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,eAAsB,cAAa,CACjC,KACA,QAM8B;AAAA,EAC9B,OAAO,cAAqB,KAAK,IAAI,WAAW;AAAA,IAC9C,UAAU,OAAO;AAAA,IACjB,SAAS;AAAA,MACP,MAAM;AAAA,MACN,cAAc,IAAI,WAAW;AAAA,MAC7B,WAAW,OAAO;AAAA,IACpB;AAAA,IACA,QAAQ,OAAO;AAAA,IACf,OAAO,OAAO,SAAS;AAAA,IACvB,QAAQ,OAAO,SAAS;AAAA,EAC1B,CAAC;AAAA;AAGH,eAAsB,qBAAoB,CACxC,K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nC,SACA,cACA,OACe;AAAA,EACf,MAAM,MAAM,qBAAqB,SAAS,YAAY;AAAA,EACtD,MAAM,qBAAyB,KAAK,KAAK;AAAA;",
32
+ "debugId": "33637F3A5FA7C13764756E2164756E21",
33
+ "names": []
34
+ }
@@ -1,25 +1,25 @@
1
1
  // @bun
2
2
  import {
3
3
  createPrimitiveExecutionRecord
4
- } from "./chunk-hdz94br2.js";
5
- import {
6
- sha256Canonical
7
- } from "./chunk-8tsf6dmc.js";
4
+ } from "./chunk-k522z7v6.js";
8
5
  import {
9
6
  PROJECTION_RUN_FAILURE_CODES,
10
7
  ProjectionRunError,
11
8
  assertProjectionRunDurableExecution,
12
9
  assertProjectionRunIdentityMatches
13
- } from "./chunk-xdpwpkha.js";
10
+ } from "./chunk-rv2hkwwa.js";
11
+ import {
12
+ sha256Canonical
13
+ } from "./chunk-8tsf6dmc.js";
14
14
  import {
15
15
  findPrimitiveRunExecution
16
- } from "./chunk-3kv70xwp.js";
16
+ } from "./chunk-j1sbhm7p.js";
17
17
  import {
18
18
  reportRunFailure
19
19
  } from "./chunk-jq43kdvk.js";
20
20
  import {
21
21
  ProjectionValidationError
22
- } from "./chunk-37wk412q.js";
22
+ } from "./chunk-p1x242ad.js";
23
23
  import {
24
24
  createSixbError,
25
25
  toSixbFailure
@@ -243,6 +243,9 @@ async function assertExistingRun(storage, run, identity) {
243
243
  });
244
244
  }
245
245
  async function resolveProducerExecution(storage, projectId, producer) {
246
+ if (producer?.kind === "ingest") {
247
+ return producer.id ? storage.executions.getById({ projectId, id: producer.id }) : null;
248
+ }
246
249
  if (!producer?.runId)
247
250
  return null;
248
251
  if (producer.kind === "sync") {
@@ -407,4 +410,4 @@ function toEnqueueFailure(error, run, at) {
407
410
  }
408
411
  export { registerProjectionRegistry, getProjectionRegistry, getProjectionDispatchDescriptors, shareProjectionRegistry, createProjectionRunId, PROJECTION_TELEMETRY_BATCH_SIZE, ProjectionRunDispatcher };
409
412
 
410
- //# debugId=B6A6488EDF798EDD64756E2164756E21
413
+ //# debugId=C0C0C7AA378374DA64756E2164756E21
@@ -0,0 +1,12 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/projections/capability.ts", "../src/projections/run-dispatch.ts", "../src/projections/run-id.ts"],
4
+ "sourcesContent": [
5
+ "import type { ProjectionRegistry } from \"./registry\"\nimport type { ProjectionDispatchDescriptor } from \"./types\"\n\nconst projectionRegistryKey: unique symbol = Symbol(\"sixb.projectionRegistry\")\n\ninterface ProjectionRegistryOwner {\n readonly [projectionRegistryKey]?: ProjectionRegistry\n}\n\nexport function registerProjectionRegistry(owner: object, registry: ProjectionRegistry): void {\n const registered = (owner as ProjectionRegistryOwner)[projectionRegistryKey]\n if (registered && registered !== registry) {\n throw new Error(\"[Sixb] Projection registry is already registered for this owner.\")\n }\n Object.defineProperty(owner, projectionRegistryKey, {\n configurable: false,\n enumerable: false,\n value: registry,\n writable: false,\n })\n}\n\nexport function getProjectionRegistry(owner: object): ProjectionRegistry {\n const registry = (owner as ProjectionRegistryOwner)[projectionRegistryKey]\n if (registry) return registry\n throw new Error(\"[Sixb] Projection registry is not registered for this runtime.\")\n}\n\nexport function getProjectionDispatchDescriptors(\n owner: object\n): readonly ProjectionDispatchDescriptor[] {\n return getProjectionRegistry(owner).getDispatchDescriptors()\n}\n\nexport function shareProjectionRegistry(source: object, target: object): void {\n registerProjectionRegistry(target, getProjectionRegistry(source))\n}\n",
6
+ "import { randomUUID } from \"node:crypto\"\nimport { reportRunFailure } from \"../error-reporting/capability\"\nimport { createSixbError, toSixbFailure } from \"../errors/internal\"\nimport type { SixbFailure } from \"../errors/types\"\nimport type { RunDispatcher } from \"../execution/dispatch\"\nimport { createPrimitiveExecutionRecord } from \"../execution/durable\"\nimport type { DatasetProducer, LakeStorage } from \"../lake-storage\"\nimport type { Queues } from \"../queues\"\nimport type { SixbDefinitions } from \"../runtime/definitions\"\nimport type { ExecutionRecord, ProjectionRunRecord, Storage } from \"../storage\"\nimport { ProjectionRunError } from \"../storage\"\nimport { findPrimitiveRunExecution } from \"../storage/executions/run-link\"\nimport {\n assertProjectionRunDurableExecution,\n assertProjectionRunIdentityMatches,\n} from \"../storage/projection-runs/provider\"\nimport { getProjectionRegistry } from \"./capability\"\nimport { ProjectionValidationError } from \"./errors\"\nimport { createProjectionRunId } from \"./run-id\"\nimport {\n PROJECTION_RUN_FAILURE_CODES,\n type ProjectionDefinition,\n type ProjectionRunFailureCode,\n} from \"./types\"\n\n/** Target maximum mapped points per telemetry commit; a single-property projection reads 500 rows. */\nexport const PROJECTION_TELEMETRY_BATCH_SIZE = 500\n\nexport interface ProjectionRunDispatchInput {\n readonly projectionId: string\n readonly datasetVersion: {\n readonly datasetId: string\n readonly versionId: string\n readonly createdAt: string\n }\n readonly metadata?: Readonly<Record<string, string>>\n}\n\nexport interface ProjectionRunDispatchResult {\n readonly projectionId: string\n readonly runId: string\n readonly queuedAt: string\n readonly jobId?: string\n readonly created: boolean\n}\n\nexport type ProjectionRunDispatchPort = RunDispatcher<\n ProjectionRunDispatchInput,\n ProjectionRunDispatchResult\n>\n\nexport interface ProjectionRunDispatcherDependencies {\n readonly id: string\n readonly definitions: Pick<SixbDefinitions, \"projections\">\n readonly lakeStorage: Pick<LakeStorage, \"getVersion\">\n readonly storage: Storage\n readonly queues: Pick<Queues, \"projections\">\n}\n\ntype PersistedProjectionRun =\n | { readonly publish: false; readonly run: ProjectionRunRecord }\n | {\n readonly publish: true\n readonly run: ProjectionRunRecord\n readonly queuedAt: Date\n readonly created: boolean\n }\n\n/** Core-owned durable dispatch boundary for immutable dataset-version materialization. */\nexport class ProjectionRunDispatcher implements ProjectionRunDispatchPort {\n constructor(private readonly dependencies: ProjectionRunDispatcherDependencies) {}\n\n async dispatch(input: ProjectionRunDispatchInput): Promise<ProjectionRunDispatchResult> {\n assertDispatchInput(input)\n const registry = getProjectionRegistry(this.dependencies)\n const descriptor = registry.resolveDispatch(input.projectionId)\n if (descriptor.datasetId !== input.datasetVersion.datasetId) {\n throw new ProjectionValidationError(\n `[Sixb] Projection '${input.projectionId}' consumes dataset '${descriptor.datasetId}', not '${input.datasetVersion.datasetId}'.`\n )\n }\n const projection = this.dependencies.definitions.projections.getById(input.projectionId)\n if (!projection) {\n throw new ProjectionValidationError(`[Sixb] Unknown projection '${input.projectionId}'.`)\n }\n const version = await this.dependencies.lakeStorage.getVersion(\n input.datasetVersion.datasetId,\n input.datasetVersion.versionId\n )\n if (!version || version.createdAt.toISOString() !== input.datasetVersion.createdAt) {\n throw new ProjectionValidationError(\n `[Sixb] Dataset '${input.datasetVersion.datasetId}' version '${input.datasetVersion.versionId}' does not match its immutable metadata.`\n )\n }\n if (version.mode === \"schema\") {\n throw new ProjectionValidationError(\n `[Sixb] Projection '${input.projectionId}' cannot materialize a schema-only dataset version.`\n )\n }\n\n const { datasetId: _datasetId, ...semanticIdentity } = descriptor\n const identity = {\n ...semanticIdentity,\n datasetVersion: structuredClone(input.datasetVersion),\n }\n const runId = createProjectionRunId(this.dependencies.id, identity)\n const projectionRuns = requireProjectionRunStorage(this.dependencies.storage)\n const existing = await projectionRuns.getById({ projectId: this.dependencies.id, id: runId })\n const persisted = existing\n ? await reuseProjectionRun(this.dependencies, existing, identity)\n : await persistProjectionRun({\n dependencies: this.dependencies,\n runId,\n identity,\n projection,\n producerExecution: await resolveProducerExecution(\n this.dependencies.storage,\n this.dependencies.id,\n version.producer\n ),\n })\n\n if (!persisted.publish) return existingResult(persisted.run)\n return publishProjectionRun(this.dependencies, input.metadata, persisted)\n }\n}\n\nasync function persistProjectionRun(input: {\n readonly dependencies: ProjectionRunDispatcherDependencies\n readonly runId: string\n readonly identity: ProjectionRunRecord[\"identity\"]\n readonly projection: ProjectionDefinition\n readonly producerExecution: ExecutionRecord | null\n}): Promise<PersistedProjectionRun> {\n const execution = createPrimitiveExecutionRecord({\n id: `exec_${randomUUID()}`,\n primitive: { kind: \"projection\", id: input.identity.projectionId, runId: input.runId },\n origin: {\n type: \"automatic\",\n projectId: input.dependencies.id,\n source: {\n type: \"datasetVersion\",\n datasetId: input.identity.datasetVersion.datasetId,\n versionId: input.identity.datasetVersion.versionId,\n },\n correlationId: input.producerExecution?.correlationId ?? input.runId,\n ...(input.producerExecution?.requestedBy === undefined\n ? {}\n : { requestedBy: input.producerExecution.requestedBy }),\n },\n })\n const queuedAt = new Date()\n\n try {\n return await input.dependencies.storage.transaction(\n async (tx): Promise<PersistedProjectionRun> => {\n const projectionRuns = requireProjectionRunStorage(tx)\n const raced = await projectionRuns.getById({\n projectId: input.dependencies.id,\n id: input.runId,\n })\n if (raced) {\n await assertExistingRun(tx, raced, input.identity)\n return { publish: false, run: raced }\n }\n await tx.executions.create(execution)\n const run = await queueProjectionRun(projectionRuns, {\n id: input.runId,\n projectId: input.dependencies.id,\n executionId: execution.id,\n identity: input.identity,\n projection: input.projection,\n queuedAt,\n })\n return { publish: true, run, queuedAt, created: true }\n },\n { isolation: \"serializable\" }\n )\n } catch (error) {\n if (!(error instanceof ProjectionRunError)) throw error\n const raced = await requireProjectionRunStorage(input.dependencies.storage).getById({\n projectId: input.dependencies.id,\n id: input.runId,\n })\n if (!raced) throw error\n await assertExistingRun(input.dependencies.storage, raced, input.identity)\n return { publish: false, run: raced }\n }\n}\n\nasync function reuseProjectionRun(\n dependencies: ProjectionRunDispatcherDependencies,\n existing: ProjectionRunRecord,\n identity: ProjectionRunRecord[\"identity\"]\n): Promise<PersistedProjectionRun> {\n await assertExistingRun(dependencies.storage, existing, identity)\n if (\n existing.status !== \"failed\" ||\n existing.error?.code !== \"queue.enqueue_failed\" ||\n !existing.error.retryable\n ) {\n return { publish: false, run: existing }\n }\n const queuedAt = new Date()\n const projectionRuns = requireProjectionRunStorage(dependencies.storage)\n try {\n const run = await requeueProjectionRun(projectionRuns, existing, queuedAt)\n return { publish: true, run, queuedAt, created: false }\n } catch (error) {\n if (!(error instanceof ProjectionRunError)) throw error\n const raced = await projectionRuns.getById({ projectId: existing.projectId, id: existing.id })\n if (\n !raced ||\n (raced.status === \"failed\" &&\n raced.error?.code === \"queue.enqueue_failed\" &&\n raced.error.retryable)\n ) {\n throw error\n }\n await assertExistingRun(dependencies.storage, raced, identity)\n return { publish: false, run: raced }\n }\n}\n\nasync function publishProjectionRun(\n dependencies: ProjectionRunDispatcherDependencies,\n metadata: Readonly<Record<string, string>> | undefined,\n persisted: Extract<PersistedProjectionRun, { readonly publish: true }>\n): Promise<ProjectionRunDispatchResult> {\n try {\n const [job] = await dependencies.queues.projections.enqueue({\n projectId: dependencies.id,\n jobs: [\n {\n id: persisted.run.id,\n type: \"projection.run.requested\",\n payload: { runId: persisted.run.id },\n ...(metadata === undefined ? {} : { metadata }),\n },\n ],\n })\n return {\n projectionId: persisted.run.identity.projectionId,\n runId: persisted.run.id,\n queuedAt: persisted.queuedAt.toISOString(),\n ...(job?.id ? { jobId: job.id } : {}),\n created: persisted.created,\n }\n } catch (error) {\n const failedAt = new Date()\n const failure = toEnqueueFailure(error, persisted.run, failedAt)\n const failed = await requireProjectionRunStorage(dependencies.storage).failEnqueue({\n projectId: dependencies.id,\n id: persisted.run.id,\n finishedAt: failedAt,\n error: failure,\n })\n reportRunFailure(dependencies, error, {\n projectId: dependencies.id,\n runKind: \"projection\",\n run: {\n runId: failed.id,\n projectionId: failed.identity.projectionId,\n projectionKind: failed.identity.projectionKind,\n },\n failure,\n })\n throw error\n }\n}\n\nasync function assertExistingRun(\n storage: Storage,\n run: ProjectionRunRecord,\n identity: ProjectionRunRecord[\"identity\"]\n): Promise<void> {\n assertProjectionRunIdentityMatches(run, identity)\n await assertProjectionRunDurableExecution({\n executions: storage.executions,\n projectId: run.projectId,\n executionId: run.executionId,\n runId: run.id,\n projectionId: run.identity.projectionId,\n datasetId: run.identity.datasetVersion.datasetId,\n datasetVersionId: run.identity.datasetVersion.versionId,\n })\n}\n\nasync function resolveProducerExecution(\n storage: Storage,\n projectId: string,\n producer: DatasetProducer | undefined\n): Promise<ExecutionRecord | null> {\n if (producer?.kind === \"ingest\") {\n return producer.id ? storage.executions.getById({ projectId, id: producer.id }) : null\n }\n if (!producer?.runId) return null\n if (producer.kind === \"sync\") {\n const run = await storage.syncRuns?.getById({ projectId, id: producer.runId })\n if (!run) return null\n assertProducerId(producer, run.syncId)\n return requireProducerExecution({\n executions: storage.executions,\n projectId,\n executionId: run.executionId,\n primitive: { kind: \"sync\", id: run.syncId, runId: run.id },\n })\n }\n\n const run = await storage.pipelineRuns?.getById({ projectId, id: producer.runId })\n if (!run) return null\n assertProducerId(producer, run.pipelineId)\n return requireProducerExecution({\n executions: storage.executions,\n projectId,\n executionId: run.executionId,\n primitive: { kind: \"pipeline\", id: run.pipelineId, runId: run.id },\n })\n}\n\nasync function requireProducerExecution(input: {\n readonly executions: Storage[\"executions\"]\n readonly projectId: string\n readonly executionId: string\n readonly primitive:\n | { readonly kind: \"sync\"; readonly id: string; readonly runId: string }\n | { readonly kind: \"pipeline\"; readonly id: string; readonly runId: string }\n}): Promise<ExecutionRecord> {\n const execution = await findPrimitiveRunExecution({\n executions: input.executions,\n projectId: input.projectId,\n executionId: input.executionId,\n primitive: input.primitive,\n sourceTypes: [\"execution\", \"schedule\", \"event\"],\n })\n if (execution) return execution\n throw new ProjectionValidationError(\n `[Sixb] Dataset producer run '${input.primitive.runId}' references an invalid execution.`\n )\n}\n\nfunction assertProducerId(producer: DatasetProducer, runOwnerId: string): void {\n if (producer.id === undefined || producer.id === runOwnerId) return\n throw new ProjectionValidationError(\n `[Sixb] Dataset producer '${producer.kind}:${producer.id}' does not match run '${producer.runId}'.`\n )\n}\n\nfunction requireProjectionRunStorage(storage: Storage): NonNullable<Storage[\"projectionRuns\"]> {\n if (storage.projectionRuns) return storage.projectionRuns\n throw new ProjectionValidationError(\"[Sixb] Projection run storage is not configured.\")\n}\n\nfunction queueProjectionRun(\n storage: NonNullable<Storage[\"projectionRuns\"]>,\n input: {\n readonly id: string\n readonly projectId: string\n readonly executionId: string\n readonly identity: ProjectionRunRecord[\"identity\"]\n readonly projection: ProjectionDefinition\n readonly queuedAt: Date\n }\n): Promise<ProjectionRunRecord> {\n const common = {\n id: input.id,\n projectId: input.projectId,\n executionId: input.executionId,\n queuedAt: input.queuedAt,\n }\n switch (input.projection._tag) {\n case \"ObjectProjectionDefinition\":\n if (input.identity.projectionKind !== \"object\") {\n throw invalidProjectionDefinition(input.id)\n }\n return storage.queue({\n ...common,\n identity: input.identity,\n target: { objectTypeId: input.projection.objectTypeId },\n })\n case \"LinkProjectionDefinition\":\n if (input.identity.projectionKind !== \"link\") {\n throw invalidProjectionDefinition(input.id)\n }\n return storage.queue({\n ...common,\n identity: input.identity,\n target: {\n sourceObjectTypeId: input.projection.sourceObjectTypeId,\n targetObjectTypeId: input.projection.targetObjectTypeId,\n },\n })\n case \"TelemetryProjectionDefinition\":\n if (input.identity.projectionKind !== \"telemetry\") {\n throw invalidProjectionDefinition(input.id)\n }\n return storage.queue({\n ...common,\n identity: input.identity,\n target: { objectTypeId: input.projection.objectTypeId },\n fixedBatchSize: telemetryProjectionBatchRowCount(input.projection),\n })\n }\n}\n\nfunction telemetryProjectionBatchRowCount(\n projection: Extract<ProjectionDefinition, { readonly _tag: \"TelemetryProjectionDefinition\" }>\n): number {\n const mappedPropertyCount = Object.keys(projection.properties).length\n if (mappedPropertyCount === 0) throw invalidProjectionDefinition(projection.id)\n return Math.max(1, Math.floor(PROJECTION_TELEMETRY_BATCH_SIZE / mappedPropertyCount))\n}\n\nfunction requeueProjectionRun(\n storage: NonNullable<Storage[\"projectionRuns\"]>,\n run: ProjectionRunRecord,\n queuedAt: Date\n): Promise<ProjectionRunRecord> {\n const common = {\n id: run.id,\n projectId: run.projectId,\n executionId: run.executionId,\n queuedAt,\n }\n switch (run.identity.projectionKind) {\n case \"object\": {\n if (!(\"objectTypeId\" in run.target)) throw invalidProjectionDefinition(run.id)\n return storage.queue({ ...common, identity: run.identity, target: run.target })\n }\n case \"link\": {\n if (!(\"sourceObjectTypeId\" in run.target)) throw invalidProjectionDefinition(run.id)\n return storage.queue({ ...common, identity: run.identity, target: run.target })\n }\n case \"telemetry\": {\n if (!(\"objectTypeId\" in run.target) || !run.telemetryCheckpoint) {\n throw invalidProjectionDefinition(run.id)\n }\n return storage.queue({\n ...common,\n identity: run.identity,\n target: run.target,\n fixedBatchSize: run.telemetryCheckpoint.fixedBatchSize,\n })\n }\n }\n}\n\nfunction invalidProjectionDefinition(runId: string): ProjectionValidationError {\n return new ProjectionValidationError(\n `[Sixb] Projection run '${runId}' has inconsistent definition metadata.`\n )\n}\n\nfunction existingResult(run: ProjectionRunRecord): ProjectionRunDispatchResult {\n return {\n projectionId: run.identity.projectionId,\n runId: run.id,\n queuedAt: run.queuedAt.toISOString(),\n created: false,\n }\n}\n\nfunction assertDispatchInput(input: ProjectionRunDispatchInput): void {\n for (const [field, value] of [\n [\"projectionId\", input.projectionId],\n [\"datasetId\", input.datasetVersion.datasetId],\n [\"versionId\", input.datasetVersion.versionId],\n ] as const) {\n if (!value.trim())\n throw new ProjectionValidationError(`[Sixb] Projection ${field} is required.`)\n }\n const timestamp = Date.parse(input.datasetVersion.createdAt)\n if (\n !Number.isFinite(timestamp) ||\n new Date(timestamp).toISOString() !== input.datasetVersion.createdAt\n ) {\n throw new ProjectionValidationError(\"[Sixb] Projection dataset version timestamp is invalid.\")\n }\n}\n\nfunction toEnqueueFailure(\n error: unknown,\n run: ProjectionRunRecord,\n at: Date\n): SixbFailure<ProjectionRunFailureCode> {\n const enqueueError = createSixbError(\n \"queue.enqueue_failed\",\n `[Sixb] Could not enqueue Projection run '${run.id}'.`,\n {\n cause: error,\n details: {\n projectionId: run.identity.projectionId,\n projectionKind: run.identity.projectionKind,\n runId: run.id,\n phase: \"enqueue\",\n },\n }\n )\n return toSixbFailure(enqueueError, { allowedCodes: PROJECTION_RUN_FAILURE_CODES, at })\n}\n",
7
+ "import { sha256Canonical } from \"../materialization/identity\"\nimport type { ProjectionMaterializationIdentity } from \"../materialization/model\"\n\nexport function createProjectionRunId(\n projectId: string,\n identity: ProjectionMaterializationIdentity\n): string {\n return sha256Canonical({\n projectId,\n projectionId: identity.projectionId,\n projectionKind: identity.projectionKind,\n protocol: identity.protocol,\n datasetId: identity.datasetVersion.datasetId,\n versionId: identity.datasetVersion.versionId,\n createdAt: identity.datasetVersion.createdAt,\n ontologyRevision: identity.ontologyRevision,\n projectionRevision: identity.projectionRevision,\n ownershipHash: identity.ownershipHash,\n })\n}\n"
8
+ ],
9
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAM,wBAAuC,OAAO,yBAAyB;AAMtE,SAAS,0BAA0B,CAAC,OAAe,UAAoC;AAAA,EAC5F,MAAM,aAAc,MAAkC;AAAA,EACtD,IAAI,cAAc,eAAe,UAAU;AAAA,IACzC,MAAM,IAAI,MAAM,kEAAkE;AAAA,EACpF;AAAA,EACA,OAAO,eAAe,OAAO,uBAAuB;AAAA,IAClD,cAAc;AAAA,IACd,YAAY;AAAA,IACZ,OAAO;AAAA,IACP,UAAU;AAAA,EACZ,CAAC;AAAA;AAGI,SAAS,qBAAqB,CAAC,OAAmC;AAAA,EACvE,MAAM,WAAY,MAAkC;AAAA,EACpD,IAAI;AAAA,IAAU,OAAO;AAAA,EACrB,MAAM,IAAI,MAAM,gEAAgE;AAAA;AAG3E,SAAS,gCAAgC,CAC9C,OACyC;AAAA,EACzC,OAAO,sBAAsB,KAAK,EAAE,uBAAuB;AAAA;AAGtD,SAAS,uBAAuB,CAAC,QAAgB,QAAsB;AAAA,EAC5E,2BAA2B,QAAQ,sBAAsB,MAAM,CAAC;AAAA;;ACnClE;;;ACGO,SAAS,qBAAqB,CACnC,WACA,UACQ;AAAA,EACR,OAAO,gBAAgB;AAAA,IACrB;AAAA,IACA,cAAc,SAAS;AAAA,IACvB,gBAAgB,SAAS;AAAA,IACzB,UAAU,SAAS;AAAA,IACnB,WAAW,SAAS,eAAe;AAAA,IACnC,WAAW,SAAS,eAAe;AAAA,IACnC,WAAW,SAAS,eAAe;AAAA,IACnC,kBAAkB,SAAS;AAAA,IAC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,EAC9C,GAAY;AAAA,IACV,IAAI,CAAC,MAAM,KAAK;AAAA,MACd,MAAM,IAAI,0BAA0B,qBAAqB,oBAAoB;AAAA,EACjF;AAAA,EACA,MAAM,YAAY,KAAK,MAAM,MAAM,eAAe,SAAS;AAAA,EAC3D,IACE,CAAC,OAAO,SAAS,SAAS,KAC1B,IAAI,KAAK,SAAS,EAAE,YAAY,MAAM,MAAM,eAAe,WAC3D;AAAA,IACA,MAAM,IAAI,0BAA0B,yDAAyD;AAAA,EAC/F;AAAA;AAGF,SAAS,gBAAgB,CACvB,OACA,KACA,IACuC;AAAA,EACvC,MAAM,eAAe,gBACnB,wBACA,4CAA4C,IAAI,QAChD;AAAA,IACE,OAAO;AAAA,IACP,SAAS;AAAA,MACP,cAAc,IAAI,SAAS;AAAA,MAC3B,gBAAgB,IAAI,SAAS;AAAA,MAC7B,OAAO,IAAI;AAAA,MACX,OAAO;AAAA,IACT;AAAA,EACF,CACF;AAAA,EACA,OAAO,cAAc,cAAc,EAAE,cAAc,8BAA8B,GAAG,CAAC;AAAA;",
10
+ "debugId": "C0C0C7AA378374DA64756E2164756E21",
11
+ "names": []
12
+ }
@@ -5,10 +5,10 @@ import {
5
5
  import {
6
6
  ensureExecutionRecord,
7
7
  executionRecordInputFromRuntime
8
- } from "./chunk-hdz94br2.js";
8
+ } from "./chunk-k522z7v6.js";
9
9
  import {
10
10
  isStorageSerializationFailure
11
- } from "./chunk-6ed5bwnd.js";
11
+ } from "./chunk-sbzzr4kx.js";
12
12
  import {
13
13
  createCommitId,
14
14
  createEventId,
@@ -49,7 +49,7 @@ import {
49
49
  isProjectionDefinition,
50
50
  resolveExecutionScopeAuthorization,
51
51
  validateProjectionsAtStartup
52
- } from "./chunk-37wk412q.js";
52
+ } from "./chunk-p1x242ad.js";
53
53
  import {
54
54
  assertKnownProperties,
55
55
  normalizeLinkProperties,
@@ -59,7 +59,7 @@ import {
59
59
  validateObjectProperties,
60
60
  validatePropertyValue,
61
61
  validateTelemetryUnit
62
- } from "./chunk-d63tybny.js";
62
+ } from "./chunk-h0k55pc7.js";
63
63
  import {
64
64
  assertJsonValue,
65
65
  cloneJsonValue,
@@ -1,8 +1,9 @@
1
1
  // @bun
2
2
  import {
3
+ createDelegatedRuntimeAuthorization,
3
4
  createDisabledRuntimeAuthorization,
4
5
  createPrincipalRuntimeAuthorization
5
- } from "./chunk-37wk412q.js";
6
+ } from "./chunk-p1x242ad.js";
6
7
 
7
8
  // src/execution/scopes.ts
8
9
  import { randomUUID } from "crypto";
@@ -16,16 +17,31 @@ function createPrincipalRequestScope(input) {
16
17
  return Object.freeze({
17
18
  execution,
18
19
  authorization: createPrincipalRuntimeAuthorization({
19
- projectId: input.projectId,
20
+ execution,
20
21
  context: input.context,
21
22
  ...input.credential === undefined ? {} : { credential: input.credential }
22
23
  })
23
24
  });
24
25
  }
25
26
  function createDisabledRequestScope(input) {
27
+ const execution = createRequestExecution(input);
26
28
  return Object.freeze({
27
- execution: createRequestExecution(input),
28
- authorization: createDisabledRuntimeAuthorization(input.projectId)
29
+ execution,
30
+ authorization: createDisabledRuntimeAuthorization(execution)
31
+ });
32
+ }
33
+ function createDelegatedRequestScope(input) {
34
+ const execution = createRequestExecution(input);
35
+ const actionApply = input.actionApply;
36
+ const delegation = input.delegation;
37
+ return Object.freeze({
38
+ execution,
39
+ authorization: createDelegatedRuntimeAuthorization({
40
+ execution,
41
+ objectRead: input.objectRead,
42
+ ...actionApply === undefined ? {} : { actionApply },
43
+ ...delegation === undefined ? {} : { delegation }
44
+ })
29
45
  });
30
46
  }
31
47
  function createTestingScope(input) {
@@ -40,7 +56,7 @@ function createTestingScope(input) {
40
56
  });
41
57
  return Object.freeze({
42
58
  execution,
43
- authorization: context ? createPrincipalRuntimeAuthorization({ projectId: input.projectId, context }) : createDisabledRuntimeAuthorization(input.projectId)
59
+ authorization: context ? createPrincipalRuntimeAuthorization({ execution, context }) : createDisabledRuntimeAuthorization(execution)
44
60
  });
45
61
  }
46
62
  function withoutSession(context) {
@@ -85,6 +101,6 @@ function assertNonEmpty(value, label) {
85
101
  }
86
102
  }
87
103
 
88
- export { createPrincipalRequestScope, createDisabledRequestScope, createTestingScope };
104
+ export { createPrincipalRequestScope, createDisabledRequestScope, createDelegatedRequestScope, createTestingScope };
89
105
 
90
- //# debugId=921D959D4D3E5CA264756E2164756E21
106
+ //# debugId=98B8C11FFD62175C64756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/execution/scopes.ts"],
4
+ "sourcesContent": [
5
+ "import { randomUUID } from \"node:crypto\"\nimport type { AuthorizationContext } from \"../authorization\"\nimport type { ObjectReadExecutionLimits, SelectedObjectReadScope } from \"../storage\"\nimport {\n createDelegatedRuntimeAuthorization,\n createDisabledRuntimeAuthorization,\n createKernelRuntimeAuthorization,\n createPrincipalRuntimeAuthorization,\n type DelegatedActionApplyTarget,\n} from \"./authorization\"\nimport type {\n AuthorizablePrincipal,\n AuthorizationRef,\n ExecutionContext,\n ExecutionScope,\n ExecutionSource,\n KernelOperation,\n} from \"./types\"\n\nexport function createPrincipalRequestScope(input: {\n readonly projectId: string\n readonly requestId: string\n readonly correlationId: string\n readonly context: AuthorizationContext\n readonly credential?: Extract<AuthorizationRef, { readonly type: \"principal\" }>[\"credential\"]\n}): ExecutionScope {\n const execution = createRequestExecution({\n projectId: input.projectId,\n requestId: input.requestId,\n correlationId: input.correlationId,\n requestedBy: asAuthorizablePrincipal(input.context.principal),\n })\n\n return Object.freeze({\n execution,\n authorization: createPrincipalRuntimeAuthorization({\n execution,\n context: input.context,\n ...(input.credential === undefined ? {} : { credential: input.credential }),\n }),\n })\n}\n\nexport function createDisabledRequestScope(input: {\n readonly projectId: string\n readonly requestId: string\n readonly correlationId: string\n}): ExecutionScope {\n const execution = createRequestExecution(input)\n return Object.freeze({\n execution,\n authorization: createDisabledRuntimeAuthorization(execution),\n })\n}\n\n/** Internal request scope carrying only a finite object-read selection. */\nexport function createDelegatedRequestScope(input: {\n readonly projectId: string\n readonly requestId: string\n readonly correlationId: string\n readonly objectRead: {\n readonly selection: SelectedObjectReadScope\n readonly limits: ObjectReadExecutionLimits\n }\n readonly actionApply?: readonly DelegatedActionApplyTarget[]\n readonly delegation?: Extract<AuthorizationRef, { readonly type: \"delegated\" }>[\"delegation\"]\n}): ExecutionScope {\n const execution = createRequestExecution(input)\n const actionApply = input.actionApply\n const delegation = input.delegation\n return Object.freeze({\n execution,\n authorization: createDelegatedRuntimeAuthorization({\n execution,\n objectRead: input.objectRead,\n ...(actionApply === undefined ? {} : { actionApply }),\n ...(delegation === undefined ? {} : { delegation }),\n }),\n })\n}\n\nexport function createKernelScope(input: {\n readonly projectId: string\n readonly operation: KernelOperation\n readonly source: ExecutionSource\n readonly correlationId?: string\n}): ExecutionScope {\n const operation = Object.freeze({ ...input.operation })\n const execution = createKernelExecution({\n projectId: input.projectId,\n operation,\n source: input.source,\n correlationId: input.correlationId,\n })\n return Object.freeze({\n execution,\n authorization: createKernelRuntimeAuthorization({ execution, operation }),\n })\n}\n\nfunction createKernelExecution(input: {\n readonly projectId: string\n readonly operation: KernelOperation\n readonly source: ExecutionSource\n readonly correlationId?: string\n}): ExecutionContext {\n const source = snapshotExecutionSource(input.source)\n assertNestedProvenance(source, input.correlationId)\n return freezeExecution({\n id: `exec_${randomUUID()}`,\n projectId: input.projectId,\n executor: Object.freeze({ type: \"kernel\", operation: input.operation }),\n source,\n correlationId: input.correlationId ?? `corr_${randomUUID()}`,\n })\n}\n\nfunction assertNestedProvenance(source: ExecutionSource, correlationId: string | undefined): void {\n if (source.type === \"execution\" && correlationId === undefined) {\n throw new Error(\"[Sixb] Nested execution must preserve its parent correlation id.\")\n }\n}\n\nexport function createTestingScope(input: {\n readonly projectId: string\n readonly context?: AuthorizationContext\n readonly executionId?: string\n readonly requestId?: string\n readonly correlationId?: string\n}): ExecutionScope {\n const context = input.context ? withoutSession(input.context) : undefined\n const requestId = input.requestId ?? `test_request_${randomUUID()}`\n const execution = createRequestExecution({\n projectId: input.projectId,\n requestId,\n correlationId: input.correlationId ?? `test_correlation_${randomUUID()}`,\n ...(context === undefined ? {} : { requestedBy: asAuthorizablePrincipal(context.principal) }),\n executionId: input.executionId,\n })\n return Object.freeze({\n execution,\n authorization: context\n ? createPrincipalRuntimeAuthorization({ execution, context })\n : createDisabledRuntimeAuthorization(execution),\n })\n}\n\nfunction withoutSession(context: AuthorizationContext): AuthorizationContext {\n return {\n principal: context.principal,\n groupIds: context.groupIds,\n roleIds: context.roleIds,\n grants: context.grants,\n }\n}\n\nfunction createRequestExecution(input: {\n readonly projectId: string\n readonly requestId: string\n readonly correlationId: string\n readonly requestedBy?: AuthorizablePrincipal\n readonly executionId?: string\n}): ExecutionContext {\n assertNonEmpty(input.projectId, \"Execution project id\")\n assertNonEmpty(input.requestId, \"Execution request id\")\n assertNonEmpty(input.correlationId, \"Execution correlation id\")\n const id = input.executionId ?? `exec_${randomUUID()}`\n assertNonEmpty(id, \"Execution id\")\n return freezeExecution({\n id,\n projectId: input.projectId,\n ...(input.requestedBy === undefined ? {} : { requestedBy: input.requestedBy }),\n executor: Object.freeze({ type: \"request\", requestId: input.requestId }),\n source: Object.freeze({ type: \"http\", requestId: input.requestId }),\n correlationId: input.correlationId,\n })\n}\n\nfunction freezeExecution(execution: ExecutionContext): ExecutionContext {\n assertNonEmpty(execution.id, \"Execution id\")\n assertNonEmpty(execution.projectId, \"Execution project id\")\n assertNonEmpty(execution.correlationId, \"Execution correlation id\")\n return Object.freeze(execution)\n}\n\nfunction snapshotExecutionSource(source: ExecutionSource): ExecutionSource {\n const field = sourceIdentifier(source)\n assertNonEmpty(field.value, field.label)\n if (source.type === \"datasetVersion\") {\n assertNonEmpty(source.datasetId, \"Execution source dataset id\")\n }\n return Object.freeze({ ...source })\n}\n\nfunction sourceIdentifier(source: ExecutionSource): {\n readonly label: string\n readonly value: string\n} {\n switch (source.type) {\n case \"http\":\n return { label: \"Execution source request id\", value: source.requestId }\n case \"webhook\":\n return { label: \"Execution source delivery id\", value: source.deliveryId }\n case \"schedule\":\n case \"event\":\n return { label: \"Execution source event id\", value: source.eventId }\n case \"datasetVersion\":\n return { label: \"Execution source dataset version id\", value: source.versionId }\n case \"execution\":\n return { label: \"Execution source execution id\", value: source.executionId }\n }\n}\n\nfunction asAuthorizablePrincipal(\n principal: AuthorizationContext[\"principal\"]\n): AuthorizablePrincipal {\n if (principal.type !== \"user\" && principal.type !== \"serviceAccount\") {\n throw new Error(`[Sixb] Principal type '${principal.type}' cannot hold runtime authorization.`)\n }\n assertNonEmpty(principal.id, \"Execution principal id\")\n return Object.freeze({ type: principal.type, id: principal.id })\n}\n\nfunction assertNonEmpty(value: string, label: string): void {\n if (!value.trim()) {\n throw new Error(`[Sixb] ${label} must not be empty.`)\n }\n}\n"
6
+ ],
7
+ "mappings": ";;;;;;;;AAAA;AAmBO,SAAS,2BAA2B,CAAC,OAMzB;AAAA,EACjB,MAAM,YAAY,uBAAuB;AAAA,IACvC,WAAW,MAAM;AAAA,IACjB,WAAW,MAAM;AAAA,IACjB,eAAe,MAAM;AAAA,IACrB,aAAa,wBAAwB,MAAM,QAAQ,SAAS;AAAA,EAC9D,CAAC;AAAA,EAED,OAAO,OAAO,OAAO;AAAA,IACnB;AAAA,IACA,eAAe,oCAAoC;AAAA,MACjD;AAAA,MACA,SAAS,MAAM;AAAA,SACX,MAAM,eAAe,YAAY,CAAC,IAAI,EAAE,YAAY,MAAM,WAAW;AAAA,IAC3E,CAAC;AAAA,EACH,CAAC;AAAA;AAGI,SAAS,0BAA0B,CAAC,OAIxB;AAAA,EACjB,MAAM,YAAY,uBAAuB,KAAK;AAAA,EAC9C,OAAO,OAAO,OAAO;AAAA,IACnB;AAAA,IACA,eAAe,mCAAmC,SAAS;AAAA,EAC7D,CAAC;AAAA;AAII,SAAS,2BAA2B,CAAC,OAUzB;AAAA,EACjB,MAAM,YAAY,uBAAuB,KAAK;AAAA,EAC9C,MAAM,cAAc,MAAM;AAAA,EAC1B,MAAM,aA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AAAA,OACb,MAAM,gBAAgB,YAAY,CAAC,IAAI,EAAE,aAAa,MAAM,YAAY;AAAA,IAC5E,UAAU,OAAO,OAAO,EAAE,MAAM,WAAW,WAAW,MAAM,UAAU,CAAC;AAAA,IACvE,QAAQ,OAAO,OAAO,EAAE,MAAM,QAAQ,WAAW,MAAM,UAAU,CAAC;AAAA,IAClE,eAAe,MAAM;AAAA,EACvB,CAAC;AAAA;AAGH,SAAS,eAAe,CAAC,WAA+C;AAAA,EACtE,eAAe,UAAU,IAAI,cAAc;AAAA,EAC3C,eAAe,UAAU,WAAW,sBAAsB;AAAA,EAC1D,eAAe,UAAU,eAAe,0BAA0B;AAAA,EAClE,OAAO,OAAO,OAAO,SAAS;AAAA;AA+BhC,SAAS,uBAAuB,CAC9B,WACuB;AAAA,EACvB,IAAI,UAAU,SAAS,UAAU,UAAU,SAAS,kBAAkB;AAAA,IACpE,MAAM,IAAI,MAAM,0BAA0B,UAAU,0CAA0C;AAAA,EAChG;AAAA,EACA,eAAe,UAAU,IAAI,wBAAwB;AAAA,EACrD,OAAO,OAAO,OAAO,EAAE,MAAM,UAAU,MAAM,IAAI,UAAU,GAAG,CAAC;AAAA;AAGjE,SAAS,cAAc,CAAC,OAAe,OAAqB;AAAA,EAC1D,IAAI,CAAC,MAAM,KAAK,GAAG;AAAA,IACjB,MAAM,IAAI,MAAM,UAAU,0BAA0B;AAAA,EACtD;AAAA;",
8
+ "debugId": "98B8C11FFD62175C64756E2164756E21",
9
+ "names": []
10
+ }
@@ -3,19 +3,19 @@ import {
3
3
  isScheduleDefinition,
4
4
  isScheduleReference
5
5
  } from "./chunk-5sz8ta9r.js";
6
- import {
7
- isDatasetDefinition
8
- } from "./chunk-tn7xcs2n.js";
9
6
  import {
10
7
  ConnectorError,
11
8
  SyncValidationError,
12
9
  createConnectorCodedError,
13
10
  getConnectorExecutionSourceResolver
14
- } from "./chunk-ha58tjtt.js";
11
+ } from "./chunk-wtf06et8.js";
15
12
  import {
16
13
  isConnectorDefinition,
17
14
  isOAuthConnectorAdapter
18
15
  } from "./chunk-8m5ejdpn.js";
16
+ import {
17
+ isDatasetDefinition
18
+ } from "./chunk-pc7ys28c.js";
19
19
 
20
20
  // src/syncs/builders.ts
21
21
  function assertNonEmpty(value, field) {
@@ -125,4 +125,4 @@ function isRecord(value) {
125
125
  }
126
126
  export { defineConnector, defineSync, resolveSyncConnectorSources, isSyncDefinition };
127
127
 
128
- //# debugId=027CA8B23EAA01DB64756E2164756E21
128
+ //# debugId=B72DF63B00EA257C64756E2164756E21
@@ -8,6 +8,6 @@
8
8
  "import type { BlobStorage } from \"../blob-storage\"\nimport {\n type AnyConnectorAdapter,\n type ConnectorAdapter,\n type ConnectorClient,\n type ConnectorConnectionMetadata,\n type ConnectorDefinition,\n isConnectorDefinition,\n type OAuthConnectorAdapter,\n} from \"../connectors\"\nimport type { DatasetDefinition, DatasetPrimaryKey, MergeChange } from \"../datasets\"\nimport { isDatasetDefinition } from \"../datasets\"\nimport type { Logger } from \"../logging\"\nimport type { ScheduleDefinition, ScheduleReference } from \"../schedules\"\nimport { isScheduleReference } from \"../schedules\"\n\n/** Blob operations available to sync read handlers. */\nexport type SyncBlobContext = Pick<BlobStorage, \"put\" | \"open\" | \"stat\">\n\n/** Non-secret connector connection metadata available to OAuth-backed Sync handlers. */\nexport type SyncConnectorConnection = ConnectorConnectionMetadata\n\ntype SyncConnectionContext<TAdapter extends AnyConnectorAdapter> =\n TAdapter extends OAuthConnectorAdapter\n ? { readonly connection: SyncConnectorConnection }\n : { readonly connection?: undefined }\n\n/** Context passed to a sync read handler. */\nexport type SyncReadContext<\n TCheckpoint = never,\n TAdapter extends AnyConnectorAdapter = ConnectorAdapter,\n> = {\n readonly projectId: string\n readonly syncId: string\n readonly signal: AbortSignal\n readonly blobs: SyncBlobContext\n readonly logger: Logger\n} & ([TCheckpoint] extends [never]\n ? { readonly checkpoint?: undefined }\n : {\n readonly checkpoint?: TCheckpoint\n setCheckpoint(next: TCheckpoint): void\n }) &\n SyncConnectionContext<TAdapter>\n\nexport type SyncMode = \"snapshot\" | \"append\" | \"merge\"\n\ntype MergeSyncChange = MergeChange<\n Readonly<Record<string, unknown>>,\n Readonly<Record<string, unknown>>\n>\n\n/** A sync read handler may return one item, a sync iterable, or an async iterable. */\nexport type SyncReadResult<TMode extends SyncMode = SyncMode> = TMode extends \"merge\"\n ? MergeSyncChange | Iterable<MergeSyncChange> | AsyncIterable<MergeSyncChange>\n : unknown | Iterable<unknown> | AsyncIterable<unknown>\n\n/** User-facing batch sync options accepted by `defineSync(...)`. */\nexport interface BatchSyncConfig<TMode extends SyncMode = SyncMode> {\n readonly mode?: TMode\n}\n\n/** Normalized batch sync config stored on the final sync definition. */\nexport interface BatchSyncDefinitionConfig<TMode extends SyncMode = SyncMode> {\n readonly kind: \"batch\"\n readonly mode: TMode\n}\n\n/** V1 syncs always target a named raw dataset. */\nexport interface DatasetSyncTarget {\n readonly kind: \"dataset\"\n readonly dataset: DatasetDefinition\n}\n\n/**\n * Connector-scoped read handler used by batch sync definitions.\n *\n * This intentionally uses TypeScript's method-parameter bivariance behavior so syncs with\n * different checkpoint types can still be stored as general `SyncDefinition[]` values. The\n * builder still gives users precise `context.checkpoint` and `setCheckpoint(...)` types when\n * they author a sync.\n */\nexport type SyncReadHandler<\n TAdapter extends AnyConnectorAdapter,\n TCheckpoint = never,\n TMode extends SyncMode = SyncMode,\n> = {\n bivarianceHack(\n client: ConnectorClient<TAdapter>,\n context: SyncReadContext<TCheckpoint, TAdapter>\n ): SyncReadResult<TMode> | Promise<SyncReadResult<TMode>>\n}[\"bivarianceHack\"]\n\n/**\n * Inert sync definition registered with Sixb.\n *\n * V1 supports batch syncs only. Definitions are declarative metadata and do not\n * start any background work on their own.\n */\nexport interface SyncDefinition<\n TId extends string = string,\n TConnector extends ConnectorDefinition<string, AnyConnectorAdapter> = ConnectorDefinition<\n string,\n AnyConnectorAdapter\n >,\n TCheckpoint = unknown,\n TMode extends SyncMode = SyncMode,\n> {\n readonly kind: \"sync\"\n readonly id: TId\n readonly config: BatchSyncDefinitionConfig<TMode>\n readonly triggers: readonly ScheduleReference[]\n readonly connector: TConnector\n readonly read: SyncReadHandler<TConnector[\"adapter\"], TCheckpoint, TMode>\n readonly target: DatasetSyncTarget\n}\n\nexport interface SyncTargetBuilder<\n TId extends string = string,\n TConnector extends ConnectorDefinition<string, AnyConnectorAdapter> = ConnectorDefinition<\n string,\n AnyConnectorAdapter\n >,\n TCheckpoint = never,\n TMode extends SyncMode = SyncMode,\n> {\n intoDataset<TDataset extends DatasetDefinition>(\n dataset: TMode extends \"merge\"\n ? TDataset & { readonly primaryKey: DatasetPrimaryKey }\n : TDataset\n ): SyncDefinition<TId, TConnector, TCheckpoint, TMode>\n}\n\nexport interface SyncReadBuilder<\n TId extends string = string,\n TConnector extends ConnectorDefinition<string, AnyConnectorAdapter> = ConnectorDefinition<\n string,\n AnyConnectorAdapter\n >,\n TCheckpoint = never,\n TMode extends SyncMode = SyncMode,\n> {\n read(\n handler: SyncReadHandler<TConnector[\"adapter\"], TCheckpoint, TMode>\n ): SyncTargetBuilder<TId, TConnector, TCheckpoint, TMode>\n}\n\nexport interface SyncBuilder<\n TId extends string = string,\n TCheckpoint = never,\n TMode extends SyncMode = SyncMode,\n> {\n when(schedule: ScheduleDefinition): SyncBuilder<TId, TCheckpoint, TMode>\n checkpoint<TNextCheckpoint>(): SyncBuilder<TId, TNextCheckpoint, TMode>\n from<TConnector extends ConnectorDefinition<string, AnyConnectorAdapter>>(\n connector: TConnector\n ): SyncReadBuilder<TId, TConnector, TCheckpoint, TMode>\n}\n\n/** Runtime type guard for values discovered from `syncs/` modules. */\nexport function isSyncDefinition(value: unknown): value is SyncDefinition {\n if (!isRecord(value)) {\n return false\n }\n\n return (\n value.kind === \"sync\" &&\n typeof value.id === \"string\" &&\n isRecord(value.config) &&\n value.config.kind === \"batch\" &&\n (value.config.mode === \"snapshot\" ||\n value.config.mode === \"append\" ||\n value.config.mode === \"merge\") &&\n Array.isArray(value.triggers) &&\n (value.triggers as unknown[]).every((reference) => isScheduleReference(reference)) &&\n isConnectorDefinition(value.connector) &&\n typeof value.read === \"function\" &&\n isRecord(value.target) &&\n value.target.kind === \"dataset\" &&\n isDatasetDefinition(value.target.dataset)\n )\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value)\n}\n"
9
9
  ],
10
10
  "mappings": ";;;;;;;;;;;;;;;;;;;;AAeA,SAAS,cAAc,CAAC,OAAe,OAAqB;AAAA,EAC1D,IAAI,CAAC,MAAM,KAAK,GAAG;AAAA,IACjB,MAAM,IAAI,oBAAoB,QAAQ,0BAA0B;AAAA,EAClE;AAAA;AAGF,SAAS,aAAa,CAAC,SAA4B,MAAsB;AAAA,EACvE,eAAe,QAAQ,IAAI,YAAY;AAAA,EACvC,IAAI,SAAS,WAAW,QAAQ,eAAe,WAAW;AAAA,IACxD,MAAM,IAAI,oBAAoB,uBAAuB,QAAQ,+BAA+B;AAAA,EAC9F;AAAA;AAGF,SAAS,wBAAwB,CAAC,SAAiE;AAAA,EACjG,MAAM,OAAO,SAAS,QAAQ;AAAA,EAE9B,IAAI,SAAS,cAAc,SAAS,YAAY,SAAS,SAAS;AAAA,IAChE,MAAM,IAAI,oBACR,sBAAsB,OAAO,IAAI,gDACnC;AAAA,EACF;AAAA,EAEA,OAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,EACF;AAAA;AAuBK,SAAS,UAA8B,CAC5C,IACA,SACmC;AAAA,EACnC,eAAe,IAAI,IAAI;AAAA,EAEvB,MAAM,SAAS,yBAAyB,OAAO;AAAA,EAC/C,MAAM,WAAgC,CAAC;AAAA,EAEvC,SAAS,aAA0B,GAA4C;AAAA,IAC7E,MAAM,UAAmD;AAAA,MACvD,IAAI,CAAC,UAAuE;AAAA,QAC1E,IAAI,CAAC,qBAAqB,QAAQ,GAAG;AAAA,UACnC,MAAM,IAAI,oBAAoB,yCAAyC;AAAA,QACzE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