@sixb/core 0.1.5 → 0.1.7

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 (564) hide show
  1. package/dist/actions/index.js +37 -33
  2. package/dist/actions/index.js.map +1 -1
  3. package/dist/actions/types/definitions.d.ts +8 -2
  4. package/dist/actions/types/definitions.d.ts.map +1 -1
  5. package/dist/actions/worker.js +3 -3
  6. package/dist/agents/adapters.d.ts +33 -76
  7. package/dist/agents/adapters.d.ts.map +1 -1
  8. package/dist/agents/authority.d.ts +22 -6
  9. package/dist/agents/authority.d.ts.map +1 -1
  10. package/dist/agents/builders.d.ts +3 -11
  11. package/dist/agents/builders.d.ts.map +1 -1
  12. package/dist/agents/context.js +2 -2
  13. package/dist/agents/dispatch.d.ts +9 -1
  14. package/dist/agents/dispatch.d.ts.map +1 -1
  15. package/dist/agents/errors.d.ts +2 -2
  16. package/dist/agents/errors.d.ts.map +1 -1
  17. package/dist/agents/execution.d.ts +9 -10
  18. package/dist/agents/execution.d.ts.map +1 -1
  19. package/dist/agents/ids.d.ts +4 -0
  20. package/dist/agents/ids.d.ts.map +1 -1
  21. package/dist/agents/index.d.ts +13 -9
  22. package/dist/agents/index.d.ts.map +1 -1
  23. package/dist/agents/index.js +80 -68
  24. package/dist/agents/index.js.map +1 -1
  25. package/dist/agents/message.d.ts +17 -10
  26. package/dist/agents/message.d.ts.map +1 -1
  27. package/dist/agents/model-loop.d.ts +56 -0
  28. package/dist/agents/model-loop.d.ts.map +1 -0
  29. package/dist/agents/reference.d.ts +4 -0
  30. package/dist/agents/reference.d.ts.map +1 -0
  31. package/dist/agents/request.d.ts +10 -8
  32. package/dist/agents/request.d.ts.map +1 -1
  33. package/dist/agents/retired-config.d.ts +4 -0
  34. package/dist/agents/retired-config.d.ts.map +1 -0
  35. package/dist/agents/streams.d.ts +13 -8
  36. package/dist/agents/streams.d.ts.map +1 -1
  37. package/dist/agents/streams.js +7 -5
  38. package/dist/agents/streams.js.map +1 -1
  39. package/dist/agents/tool-catalog.d.ts +9 -0
  40. package/dist/agents/tool-catalog.d.ts.map +1 -0
  41. package/dist/agents/tool-definition.d.ts +1 -0
  42. package/dist/agents/tool-definition.d.ts.map +1 -1
  43. package/dist/agents/types.d.ts +31 -68
  44. package/dist/agents/types.d.ts.map +1 -1
  45. package/dist/agents/validation.d.ts +4 -10
  46. package/dist/agents/validation.d.ts.map +1 -1
  47. package/dist/ai-usage/execution.d.ts +53 -0
  48. package/dist/ai-usage/execution.d.ts.map +1 -0
  49. package/dist/ai-usage/index.d.ts +3 -0
  50. package/dist/ai-usage/index.d.ts.map +1 -0
  51. package/dist/auth/index.d.ts +1 -1
  52. package/dist/auth/index.d.ts.map +1 -1
  53. package/dist/auth/index.js +7 -7
  54. package/dist/auth/runtime.d.ts.map +1 -1
  55. package/dist/auth/strategy.d.ts +1 -1
  56. package/dist/auth/strategy.d.ts.map +1 -1
  57. package/dist/auth/types.d.ts +13 -0
  58. package/dist/auth/types.d.ts.map +1 -1
  59. package/dist/authorization/decision.d.ts +5 -2
  60. package/dist/authorization/decision.d.ts.map +1 -1
  61. package/dist/authorization/grant-kinds.d.ts +24 -8
  62. package/dist/authorization/grant-kinds.d.ts.map +1 -1
  63. package/dist/authorization/index.d.ts +1 -1
  64. package/dist/authorization/index.d.ts.map +1 -1
  65. package/dist/authorization/index.js +8 -6
  66. package/dist/authorization/index.js.map +1 -1
  67. package/dist/authorization/resolve.d.ts +3 -3
  68. package/dist/authorization/resolve.d.ts.map +1 -1
  69. package/dist/authorization/types.d.ts +7 -5
  70. package/dist/authorization/types.d.ts.map +1 -1
  71. package/dist/blob-storage/browser.js +2 -2
  72. package/dist/blob-storage/index.js +3 -3
  73. package/dist/bootstrap/discovery.d.ts +1 -7
  74. package/dist/bootstrap/discovery.d.ts.map +1 -1
  75. package/dist/bootstrap/index.js +52 -48
  76. package/dist/bootstrap/index.js.map +1 -1
  77. package/dist/broker/index.js +2 -2
  78. package/dist/{chunk-zqysyfjt.js → chunk-08m3b6w8.js} +1 -1
  79. package/dist/{chunk-xdf9yswn.js → chunk-08twe8m6.js} +93 -8
  80. package/dist/chunk-08twe8m6.js.map +12 -0
  81. package/dist/{chunk-xkthy56g.js → chunk-1kamz6j0.js} +1 -1
  82. package/dist/{chunk-h6h91mfy.js → chunk-2b5qtban.js} +12 -12
  83. package/dist/{chunk-h6h91mfy.js.map → chunk-2b5qtban.js.map} +3 -3
  84. package/dist/{chunk-0172wgm9.js → chunk-2xns679x.js} +10 -2
  85. package/dist/{chunk-0172wgm9.js.map → chunk-2xns679x.js.map} +3 -3
  86. package/dist/{chunk-f83ka50g.js → chunk-37wk412q.js} +86 -28
  87. package/dist/{chunk-f83ka50g.js.map → chunk-37wk412q.js.map} +8 -8
  88. package/dist/{chunk-6d5xdj1q.js → chunk-3fqt22c4.js} +4 -4
  89. package/dist/{chunk-t9xghkva.js → chunk-3kv70xwp.js} +3 -2
  90. package/dist/{chunk-t9xghkva.js.map → chunk-3kv70xwp.js.map} +3 -3
  91. package/dist/{chunk-z3zp0bj1.js → chunk-407j3msh.js} +1 -1
  92. package/dist/{chunk-rhrbz7d4.js → chunk-4a849fr1.js} +1 -1
  93. package/dist/{chunk-62c7t4jc.js → chunk-4nxeacx7.js} +1 -1
  94. package/dist/{chunk-cy0n5dms.js → chunk-5jcdmjam.js} +1 -1
  95. package/dist/{chunk-819wnjz8.js → chunk-64sr682n.js} +7 -7
  96. package/dist/{chunk-v0egge8b.js → chunk-6ed5bwnd.js} +666 -81
  97. package/dist/chunk-6ed5bwnd.js.map +57 -0
  98. package/dist/{chunk-x2yw73hy.js → chunk-7ds9620f.js} +1 -1
  99. package/dist/{chunk-dm72y8wt.js → chunk-7y0f6rf1.js} +29 -16
  100. package/dist/chunk-7y0f6rf1.js.map +10 -0
  101. package/dist/{chunk-72q2y8hn.js → chunk-8tsf6dmc.js} +2 -2
  102. package/dist/{chunk-72q2y8hn.js.map → chunk-8tsf6dmc.js.map} +3 -3
  103. package/dist/{chunk-tbv03sx2.js → chunk-9aehf39w.js} +7 -7
  104. package/dist/{chunk-ezake7g1.js → chunk-agsvg9ar.js} +1 -1
  105. package/dist/{chunk-rdeagz6b.js → chunk-atmkaf60.js} +1 -1
  106. package/dist/{chunk-rdeagz6b.js.map → chunk-atmkaf60.js.map} +2 -2
  107. package/dist/chunk-c15dr03f.js +43 -0
  108. package/dist/chunk-c15dr03f.js.map +10 -0
  109. package/dist/{chunk-78c6xvyr.js → chunk-d2ndstdf.js} +8 -6
  110. package/dist/{chunk-78c6xvyr.js.map → chunk-d2ndstdf.js.map} +2 -2
  111. package/dist/{chunk-rnshztfq.js → chunk-d63tybny.js} +2 -2
  112. package/dist/{chunk-t0jjkep3.js → chunk-d8qkxt2v.js} +4 -2
  113. package/dist/chunk-d8qkxt2v.js.map +10 -0
  114. package/dist/{chunk-vybf6pkp.js → chunk-dbc80ad7.js} +1 -1
  115. package/dist/{chunk-4gz41why.js → chunk-dqn23610.js} +1 -1
  116. package/dist/{chunk-z3ga9q5m.js → chunk-e4rvtvpw.js} +13 -11
  117. package/dist/{chunk-z3ga9q5m.js.map → chunk-e4rvtvpw.js.map} +2 -2
  118. package/dist/{chunk-h9kxd41f.js → chunk-gbrpsx4m.js} +19 -6
  119. package/dist/chunk-gbrpsx4m.js.map +11 -0
  120. package/dist/{chunk-84h6qhmp.js → chunk-h0knpbz5.js} +468 -1236
  121. package/dist/chunk-h0knpbz5.js.map +38 -0
  122. package/dist/{chunk-zp2v2rv6.js → chunk-ha58tjtt.js} +6 -6
  123. package/dist/{chunk-f6erf2vv.js → chunk-hdz94br2.js} +2 -2
  124. package/dist/chunk-jecn6t54.js +307 -0
  125. package/dist/chunk-jecn6t54.js.map +12 -0
  126. package/dist/{chunk-dsrkgtnh.js → chunk-jq43kdvk.js} +1 -1
  127. package/dist/{chunk-wtmzkcht.js → chunk-k34z5rvh.js} +1 -1
  128. package/dist/{chunk-htq0qh7z.js → chunk-ka3a2ft3.js} +2 -2
  129. package/dist/{chunk-4h947jd8.js → chunk-kt81c11h.js} +2 -2
  130. package/dist/chunk-n2arzn6e.js +1745 -0
  131. package/dist/chunk-n2arzn6e.js.map +20 -0
  132. package/dist/{chunk-f2rt4vkh.js → chunk-n2w475r0.js} +3 -3
  133. package/dist/{chunk-t8t39h7v.js → chunk-n6jxh8sw.js} +10 -2
  134. package/dist/chunk-n6jxh8sw.js.map +10 -0
  135. package/dist/{chunk-drjqm1aa.js → chunk-p03r0h5s.js} +310 -28
  136. package/dist/chunk-p03r0h5s.js.map +16 -0
  137. package/dist/chunk-p2vqaxkc.js +528 -0
  138. package/dist/chunk-p2vqaxkc.js.map +15 -0
  139. package/dist/{chunk-gadsm794.js → chunk-qjycjdj6.js} +84 -11
  140. package/dist/chunk-qjycjdj6.js.map +12 -0
  141. package/dist/chunk-qjzp9xyb.js +286 -0
  142. package/dist/chunk-qjzp9xyb.js.map +12 -0
  143. package/dist/{chunk-am6eczah.js → chunk-qv38twt8.js} +50 -69
  144. package/dist/{chunk-am6eczah.js.map → chunk-qv38twt8.js.map} +8 -8
  145. package/dist/{chunk-bhxaq2nn.js → chunk-qw9gvjv5.js} +1 -1
  146. package/dist/{chunk-r0rry8dn.js → chunk-rp1mvzb4.js} +6 -6
  147. package/dist/{chunk-tkdscva6.js → chunk-rre42skh.js} +187 -18
  148. package/dist/chunk-rre42skh.js.map +39 -0
  149. package/dist/{chunk-ghteq96b.js → chunk-s5y30bc9.js} +2 -2
  150. package/dist/{chunk-a31h57d5.js → chunk-tn7xcs2n.js} +2 -2
  151. package/dist/{chunk-6gjqgd3d.js → chunk-tpnd31c1.js} +2 -1
  152. package/dist/chunk-tpnd31c1.js.map +11 -0
  153. package/dist/chunk-trxxmgnf.js +68 -0
  154. package/dist/chunk-trxxmgnf.js.map +11 -0
  155. package/dist/{chunk-ea73pzk7.js → chunk-vjjv9mrb.js} +2 -2
  156. package/dist/{chunk-8b55ygje.js → chunk-w3e09qqk.js} +1 -1
  157. package/dist/{chunk-ckxfnx7f.js → chunk-wjgm6jjt.js} +2 -2
  158. package/dist/{chunk-3j7573mj.js → chunk-x0qhkqje.js} +2 -2
  159. package/dist/{chunk-dysw7nsm.js → chunk-xdpwpkha.js} +2 -2
  160. package/dist/{chunk-1q02e95s.js → chunk-y35ma3mj.js} +11 -16
  161. package/dist/{chunk-1q02e95s.js.map → chunk-y35ma3mj.js.map} +3 -4
  162. package/dist/{chunk-qewtks41.js → chunk-z2sery1b.js} +64 -1
  163. package/dist/{chunk-qewtks41.js.map → chunk-z2sery1b.js.map} +3 -3
  164. package/dist/error-reporting/internal.js +4 -4
  165. package/dist/error-reporting/types.d.ts +7 -2
  166. package/dist/error-reporting/types.d.ts.map +1 -1
  167. package/dist/errors/catalog.d.ts +8 -0
  168. package/dist/errors/catalog.d.ts.map +1 -1
  169. package/dist/errors/internal.js +2 -2
  170. package/dist/events/index.js +4 -4
  171. package/dist/execution/agent.d.ts +18 -9
  172. package/dist/execution/agent.d.ts.map +1 -1
  173. package/dist/execution/agent.js +52 -43
  174. package/dist/execution/agent.js.map +1 -1
  175. package/dist/execution/authorization.d.ts +14 -4
  176. package/dist/execution/authorization.d.ts.map +1 -1
  177. package/dist/execution/primitive.js +45 -43
  178. package/dist/execution/primitive.js.map +2 -2
  179. package/dist/execution/request.d.ts +3 -1
  180. package/dist/execution/request.d.ts.map +1 -1
  181. package/dist/execution/request.js +46 -44
  182. package/dist/execution/request.js.map +3 -3
  183. package/dist/execution/types.d.ts +1 -1
  184. package/dist/execution/types.d.ts.map +1 -1
  185. package/dist/http/api-routes.d.ts.map +1 -1
  186. package/dist/http/index.js +1 -1
  187. package/dist/index.d.ts +9 -6
  188. package/dist/index.d.ts.map +1 -1
  189. package/dist/index.js +82 -77
  190. package/dist/index.js.map +1 -1
  191. package/dist/json.d.ts +2 -0
  192. package/dist/json.d.ts.map +1 -1
  193. package/dist/lake-storage/index.js +5 -5
  194. package/dist/logging/index.js +3 -3
  195. package/dist/logging/types.js +2 -2
  196. package/dist/materialization/index.js +2 -2
  197. package/dist/materializer/index.js +33 -29
  198. package/dist/materializer/index.js.map +1 -1
  199. package/dist/models/catalog.d.ts +40 -0
  200. package/dist/models/catalog.d.ts.map +1 -0
  201. package/dist/models/definitions.d.ts +25 -0
  202. package/dist/models/definitions.d.ts.map +1 -0
  203. package/dist/models/errors.d.ts +52 -0
  204. package/dist/models/errors.d.ts.map +1 -0
  205. package/dist/models/events.d.ts +192 -0
  206. package/dist/models/events.d.ts.map +1 -0
  207. package/dist/models/index.d.ts +17 -39
  208. package/dist/models/index.d.ts.map +1 -1
  209. package/dist/models/index.js +50 -0
  210. package/dist/models/index.js.map +9 -0
  211. package/dist/models/language-model.d.ts +90 -0
  212. package/dist/models/language-model.d.ts.map +1 -0
  213. package/dist/models/messages.d.ts +74 -0
  214. package/dist/models/messages.d.ts.map +1 -0
  215. package/dist/models/pricing.d.ts +69 -0
  216. package/dist/models/pricing.d.ts.map +1 -0
  217. package/dist/models/rate-card.d.ts +24 -0
  218. package/dist/models/rate-card.d.ts.map +1 -0
  219. package/dist/models/tools.d.ts +24 -0
  220. package/dist/models/tools.d.ts.map +1 -0
  221. package/dist/objects/index.js +38 -34
  222. package/dist/objects/index.js.map +1 -1
  223. package/dist/objects/query/index.js +32 -28
  224. package/dist/objects/query/index.js.map +1 -1
  225. package/dist/ontology/index.js +5 -5
  226. package/dist/ontology/internal.js +4 -4
  227. package/dist/pipelines/index.js +37 -35
  228. package/dist/pipelines/index.js.map +1 -1
  229. package/dist/projections/internal.js +35 -31
  230. package/dist/projections/internal.js.map +1 -1
  231. package/dist/queues/in-memory.d.ts +3 -2
  232. package/dist/queues/in-memory.d.ts.map +1 -1
  233. package/dist/queues/index.d.ts +3 -1
  234. package/dist/queues/index.d.ts.map +1 -1
  235. package/dist/queues/index.js +1 -1
  236. package/dist/queues/types.d.ts +15 -3
  237. package/dist/queues/types.d.ts.map +1 -1
  238. package/dist/runtime/create.d.ts +4 -4
  239. package/dist/runtime/create.d.ts.map +1 -1
  240. package/dist/runtime/definitions.d.ts +2 -2
  241. package/dist/runtime/definitions.d.ts.map +1 -1
  242. package/dist/runtime/host.d.ts +3 -2
  243. package/dist/runtime/host.d.ts.map +1 -1
  244. package/dist/runtime/resolve-definitions.d.ts +2 -2
  245. package/dist/runtime/resolve-definitions.d.ts.map +1 -1
  246. package/dist/runtime/sixb.d.ts +4 -2
  247. package/dist/runtime/sixb.d.ts.map +1 -1
  248. package/dist/security/every.d.ts +1 -4
  249. package/dist/security/every.d.ts.map +1 -1
  250. package/dist/security/grants.d.ts +6 -5
  251. package/dist/security/grants.d.ts.map +1 -1
  252. package/dist/security/index.d.ts +1 -1
  253. package/dist/security/index.d.ts.map +1 -1
  254. package/dist/security/registry.d.ts +1 -1
  255. package/dist/security/registry.d.ts.map +1 -1
  256. package/dist/security/types.d.ts +13 -5
  257. package/dist/security/types.d.ts.map +1 -1
  258. package/dist/security/validation.d.ts +4 -2
  259. package/dist/security/validation.d.ts.map +1 -1
  260. package/dist/storage/action-runs/failure.js +3 -3
  261. package/dist/storage/action-runs/provider.js +2 -2
  262. package/dist/storage/agents/errors.d.ts +1 -1
  263. package/dist/storage/agents/errors.d.ts.map +1 -1
  264. package/dist/storage/agents/in-memory.d.ts +3 -2
  265. package/dist/storage/agents/in-memory.d.ts.map +1 -1
  266. package/dist/storage/agents/index.d.ts +1 -1
  267. package/dist/storage/agents/index.d.ts.map +1 -1
  268. package/dist/storage/agents/provider.d.ts +11 -4
  269. package/dist/storage/agents/provider.d.ts.map +1 -1
  270. package/dist/storage/agents/provider.js +18 -15
  271. package/dist/storage/agents/provider.js.map +1 -1
  272. package/dist/storage/agents/types.d.ts +65 -17
  273. package/dist/storage/agents/types.d.ts.map +1 -1
  274. package/dist/storage/ai-cost/analytics.d.ts +2 -1
  275. package/dist/storage/ai-cost/analytics.d.ts.map +1 -1
  276. package/dist/storage/ai-cost/codec.d.ts +3 -2
  277. package/dist/storage/ai-cost/codec.d.ts.map +1 -1
  278. package/dist/storage/ai-cost/groups.d.ts +51 -0
  279. package/dist/storage/ai-cost/groups.d.ts.map +1 -0
  280. package/dist/storage/ai-cost/in-memory.d.ts +11 -1
  281. package/dist/storage/ai-cost/in-memory.d.ts.map +1 -1
  282. package/dist/storage/ai-cost/index.d.ts +1 -1
  283. package/dist/storage/ai-cost/index.d.ts.map +1 -1
  284. package/dist/storage/ai-cost/provider.d.ts +2 -0
  285. package/dist/storage/ai-cost/provider.d.ts.map +1 -1
  286. package/dist/storage/ai-cost/provider.js +29 -13
  287. package/dist/storage/ai-cost/provider.js.map +3 -3
  288. package/dist/storage/ai-cost/types.d.ts +64 -15
  289. package/dist/storage/ai-cost/types.d.ts.map +1 -1
  290. package/dist/storage/ai-cost/validation.d.ts +2 -1
  291. package/dist/storage/ai-cost/validation.d.ts.map +1 -1
  292. package/dist/storage/ai-limits/enforcement.d.ts +14 -0
  293. package/dist/storage/ai-limits/enforcement.d.ts.map +1 -0
  294. package/dist/storage/ai-limits/enforcement.js +21 -0
  295. package/dist/storage/ai-limits/enforcement.js.map +9 -0
  296. package/dist/storage/ai-limits/errors.d.ts +8 -0
  297. package/dist/storage/ai-limits/errors.d.ts.map +1 -0
  298. package/dist/storage/ai-limits/in-memory.d.ts +78 -0
  299. package/dist/storage/ai-limits/in-memory.d.ts.map +1 -0
  300. package/dist/storage/ai-limits/index.d.ts +7 -0
  301. package/dist/storage/ai-limits/index.d.ts.map +1 -0
  302. package/dist/storage/ai-limits/period.d.ts +4 -0
  303. package/dist/storage/ai-limits/period.d.ts.map +1 -0
  304. package/dist/storage/ai-limits/provider.d.ts +85 -0
  305. package/dist/storage/ai-limits/provider.d.ts.map +1 -0
  306. package/dist/storage/ai-limits/provider.js +62 -0
  307. package/dist/storage/ai-limits/provider.js.map +9 -0
  308. package/dist/storage/ai-limits/types.d.ts +175 -0
  309. package/dist/storage/ai-limits/types.d.ts.map +1 -0
  310. package/dist/storage/ai-usage/in-memory.d.ts +4 -0
  311. package/dist/storage/ai-usage/in-memory.d.ts.map +1 -1
  312. package/dist/storage/ai-usage/record.d.ts.map +1 -1
  313. package/dist/storage/ai-usage/types.d.ts +6 -2
  314. package/dist/storage/ai-usage/types.d.ts.map +1 -1
  315. package/dist/storage/auth/errors.d.ts +1 -1
  316. package/dist/storage/auth/errors.d.ts.map +1 -1
  317. package/dist/storage/auth/in-memory/auth-storage.d.ts +4 -1
  318. package/dist/storage/auth/in-memory/auth-storage.d.ts.map +1 -1
  319. package/dist/storage/auth/in-memory/device-authorizations.d.ts +29 -0
  320. package/dist/storage/auth/in-memory/device-authorizations.d.ts.map +1 -0
  321. package/dist/storage/auth/in-memory/shared.d.ts +3 -1
  322. package/dist/storage/auth/in-memory/shared.d.ts.map +1 -1
  323. package/dist/storage/auth/index.d.ts +2 -1
  324. package/dist/storage/auth/index.d.ts.map +1 -1
  325. package/dist/storage/auth/types.d.ts +66 -0
  326. package/dist/storage/auth/types.d.ts.map +1 -1
  327. package/dist/storage/connector-connections/provider.js +2 -2
  328. package/dist/storage/executions/provider.js +1 -1
  329. package/dist/storage/executions/run-link.d.ts +7 -2
  330. package/dist/storage/executions/run-link.d.ts.map +1 -1
  331. package/dist/storage/executions/validation.d.ts.map +1 -1
  332. package/dist/storage/in-memory/index.d.ts +4 -0
  333. package/dist/storage/in-memory/index.d.ts.map +1 -1
  334. package/dist/storage/index.d.ts +8 -5
  335. package/dist/storage/index.d.ts.map +1 -1
  336. package/dist/storage/index.js +51 -38
  337. package/dist/storage/index.js.map +1 -1
  338. package/dist/storage/ontology/in-memory/materializations.d.ts +4 -3
  339. package/dist/storage/ontology/in-memory/materializations.d.ts.map +1 -1
  340. package/dist/storage/ontology/index.d.ts +1 -1
  341. package/dist/storage/ontology/index.d.ts.map +1 -1
  342. package/dist/storage/ontology/materializations.d.ts +7 -3
  343. package/dist/storage/ontology/materializations.d.ts.map +1 -1
  344. package/dist/storage/ontology/provider.d.ts +2 -2
  345. package/dist/storage/ontology/provider.d.ts.map +1 -1
  346. package/dist/storage/ontology/provider.js +3 -3
  347. package/dist/storage/pipeline-runs/provider.js +2 -2
  348. package/dist/storage/projection-runs/provider.js +4 -4
  349. package/dist/storage/sync-runs/provider.js +2 -2
  350. package/dist/storage/types.d.ts +5 -1
  351. package/dist/storage/types.d.ts.map +1 -1
  352. package/dist/storage/webhook-runs/provider.js +2 -2
  353. package/dist/storage/workflow-runs/provider.d.ts +1 -1
  354. package/dist/storage/workflow-runs/provider.js +10 -11
  355. package/dist/storage/workflow-runs/provider.js.map +1 -1
  356. package/dist/storage/workflow-runs/types.d.ts +5 -4
  357. package/dist/storage/workflow-runs/types.d.ts.map +1 -1
  358. package/dist/syncs/index.js +37 -35
  359. package/dist/syncs/index.js.map +1 -1
  360. package/dist/testing/agent-execution.d.ts +3 -1
  361. package/dist/testing/agent-execution.d.ts.map +1 -1
  362. package/dist/testing/agent-storage-contract.d.ts.map +1 -1
  363. package/dist/testing/ai-cost-storage-contract.d.ts.map +1 -1
  364. package/dist/testing/ai-limit-storage-contract.d.ts +18 -0
  365. package/dist/testing/ai-limit-storage-contract.d.ts.map +1 -0
  366. package/dist/testing/ai-model-call-groups-contract.d.ts +6 -0
  367. package/dist/testing/ai-model-call-groups-contract.d.ts.map +1 -0
  368. package/dist/testing/ai-usage-storage-contract.d.ts.map +1 -1
  369. package/dist/testing/auth-storage-contract.d.ts.map +1 -1
  370. package/dist/testing/index.d.ts +2 -0
  371. package/dist/testing/index.d.ts.map +1 -1
  372. package/dist/testing/index.js +3758 -1945
  373. package/dist/testing/index.js.map +15 -13
  374. package/dist/testing/materializer-storage-contract.d.ts.map +1 -1
  375. package/dist/testing/queues-contract.d.ts.map +1 -1
  376. package/dist/webhooks/internal.js +32 -28
  377. package/dist/webhooks/internal.js.map +2 -2
  378. package/dist/workers/index.js +2 -2
  379. package/dist/workflows/agent-step-identity.d.ts +3 -0
  380. package/dist/workflows/agent-step-identity.d.ts.map +1 -0
  381. package/dist/workflows/builders.d.ts +2 -3
  382. package/dist/workflows/builders.d.ts.map +1 -1
  383. package/dist/workflows/execution.d.ts +1 -1
  384. package/dist/workflows/execution.d.ts.map +1 -1
  385. package/dist/workflows/failure.d.ts +1 -1
  386. package/dist/workflows/failure.d.ts.map +1 -1
  387. package/dist/workflows/index.d.ts +3 -2
  388. package/dist/workflows/index.d.ts.map +1 -1
  389. package/dist/workflows/index.js +53 -45
  390. package/dist/workflows/index.js.map +1 -1
  391. package/dist/workflows/types.d.ts +26 -11
  392. package/dist/workflows/types.d.ts.map +1 -1
  393. package/dist/workflows/validation.d.ts +7 -1
  394. package/dist/workflows/validation.d.ts.map +1 -1
  395. package/package.json +19 -4
  396. package/src/actions/types/definitions.ts +24 -2
  397. package/src/agents/adapters.ts +109 -115
  398. package/src/agents/authority.ts +214 -32
  399. package/src/agents/builders.ts +3 -50
  400. package/src/agents/context-compaction.ts +4 -0
  401. package/src/agents/dispatch.ts +59 -2
  402. package/src/agents/errors.ts +5 -2
  403. package/src/agents/execution.ts +53 -52
  404. package/src/agents/ids.ts +16 -1
  405. package/src/agents/index.ts +23 -11
  406. package/src/agents/message.ts +18 -9
  407. package/src/agents/model-loop.ts +1023 -0
  408. package/src/agents/reference.ts +7 -0
  409. package/src/agents/request.ts +141 -74
  410. package/src/agents/retired-config.ts +20 -0
  411. package/src/agents/streams.ts +45 -19
  412. package/src/agents/tool-catalog.ts +21 -0
  413. package/src/agents/tool-definition.ts +23 -0
  414. package/src/agents/types.ts +39 -81
  415. package/src/agents/validation.ts +34 -180
  416. package/src/ai-usage/execution.ts +196 -0
  417. package/src/ai-usage/index.ts +15 -0
  418. package/src/auth/index.ts +1 -0
  419. package/src/auth/runtime.ts +8 -0
  420. package/src/auth/strategy.ts +1 -0
  421. package/src/auth/types.ts +14 -0
  422. package/src/authorization/decision.ts +27 -10
  423. package/src/authorization/grant-kinds.ts +62 -15
  424. package/src/authorization/index.ts +1 -0
  425. package/src/authorization/resolve.ts +12 -5
  426. package/src/authorization/types.ts +7 -5
  427. package/src/bootstrap/discovery.ts +0 -3
  428. package/src/error-reporting/types.ts +4 -2
  429. package/src/errors/catalog.ts +8 -0
  430. package/src/execution/agent.ts +129 -22
  431. package/src/execution/authorization.ts +48 -18
  432. package/src/execution/request.ts +4 -1
  433. package/src/execution/types.ts +1 -1
  434. package/src/http/api-routes.ts +63 -0
  435. package/src/index.ts +36 -7
  436. package/src/json.ts +9 -0
  437. package/src/models/catalog.ts +137 -0
  438. package/src/models/definitions.ts +202 -0
  439. package/src/models/errors.ts +83 -0
  440. package/src/models/events.ts +198 -0
  441. package/src/models/index.ts +89 -71
  442. package/src/models/language-model.ts +143 -0
  443. package/src/models/messages.ts +78 -0
  444. package/src/models/pricing.ts +390 -0
  445. package/src/models/rate-card.ts +101 -0
  446. package/src/models/tools.ts +29 -0
  447. package/src/queues/in-memory.ts +5 -0
  448. package/src/queues/index.ts +11 -0
  449. package/src/queues/types.ts +20 -3
  450. package/src/runtime/create.ts +7 -5
  451. package/src/runtime/definitions.ts +2 -2
  452. package/src/runtime/host.ts +3 -2
  453. package/src/runtime/resolve-definitions.ts +13 -36
  454. package/src/runtime/sixb.ts +6 -8
  455. package/src/security/every.ts +0 -4
  456. package/src/security/grants.ts +55 -11
  457. package/src/security/index.ts +2 -0
  458. package/src/security/registry.ts +6 -5
  459. package/src/security/types.ts +15 -4
  460. package/src/security/validation.ts +30 -9
  461. package/src/storage/agents/errors.ts +1 -0
  462. package/src/storage/agents/in-memory.ts +121 -11
  463. package/src/storage/agents/index.ts +7 -0
  464. package/src/storage/agents/provider.ts +150 -6
  465. package/src/storage/agents/types.ts +73 -16
  466. package/src/storage/ai-cost/analytics.ts +63 -6
  467. package/src/storage/ai-cost/codec.ts +37 -12
  468. package/src/storage/ai-cost/groups.ts +248 -0
  469. package/src/storage/ai-cost/in-memory.ts +42 -0
  470. package/src/storage/ai-cost/index.ts +6 -0
  471. package/src/storage/ai-cost/provider.ts +7 -0
  472. package/src/storage/ai-cost/types.ts +76 -14
  473. package/src/storage/ai-cost/validation.ts +147 -17
  474. package/src/storage/ai-limits/enforcement.ts +68 -0
  475. package/src/storage/ai-limits/errors.ts +23 -0
  476. package/src/storage/ai-limits/in-memory.ts +671 -0
  477. package/src/storage/ai-limits/index.ts +31 -0
  478. package/src/storage/ai-limits/period.ts +11 -0
  479. package/src/storage/ai-limits/provider.ts +430 -0
  480. package/src/storage/ai-limits/types.ts +195 -0
  481. package/src/storage/ai-usage/in-memory.ts +13 -0
  482. package/src/storage/ai-usage/record.ts +17 -0
  483. package/src/storage/ai-usage/types.ts +6 -2
  484. package/src/storage/auth/errors.ts +6 -0
  485. package/src/storage/auth/in-memory/auth-storage.ts +69 -0
  486. package/src/storage/auth/in-memory/device-authorizations.ts +145 -0
  487. package/src/storage/auth/in-memory/shared.ts +7 -0
  488. package/src/storage/auth/index.ts +7 -0
  489. package/src/storage/auth/types.ts +73 -0
  490. package/src/storage/executions/run-link.ts +16 -6
  491. package/src/storage/executions/validation.ts +36 -6
  492. package/src/storage/in-memory/index.ts +48 -4
  493. package/src/storage/index.ts +52 -1
  494. package/src/storage/ontology/in-memory/materializations.ts +34 -22
  495. package/src/storage/ontology/index.ts +1 -0
  496. package/src/storage/ontology/materializations.ts +8 -3
  497. package/src/storage/ontology/provider.ts +2 -2
  498. package/src/storage/types.ts +37 -0
  499. package/src/storage/workflow-runs/in-memory.ts +3 -3
  500. package/src/storage/workflow-runs/provider.ts +2 -2
  501. package/src/storage/workflow-runs/types.ts +6 -3
  502. package/src/testing/agent-execution.ts +40 -28
  503. package/src/testing/agent-storage-contract.ts +249 -28
  504. package/src/testing/ai-cost-storage-contract.ts +96 -8
  505. package/src/testing/ai-limit-storage-contract.ts +1134 -0
  506. package/src/testing/ai-model-call-groups-contract.ts +353 -0
  507. package/src/testing/ai-usage-storage-contract.ts +31 -0
  508. package/src/testing/auth-storage-contract.ts +85 -0
  509. package/src/testing/execution-storage-contract.ts +2 -2
  510. package/src/testing/index.ts +10 -0
  511. package/src/testing/materializer-storage-contract.ts +170 -2
  512. package/src/testing/queues-contract.ts +36 -1
  513. package/src/workflows/agent-step-identity.ts +4 -0
  514. package/src/workflows/builders.ts +95 -9
  515. package/src/workflows/execution.ts +2 -2
  516. package/src/workflows/failure.ts +2 -2
  517. package/src/workflows/index.ts +3 -0
  518. package/src/workflows/types.ts +23 -11
  519. package/src/workflows/validation.ts +100 -7
  520. package/dist/chunk-6gjqgd3d.js.map +0 -11
  521. package/dist/chunk-84h6qhmp.js.map +0 -46
  522. package/dist/chunk-a09jx26t.js +0 -55
  523. package/dist/chunk-a09jx26t.js.map +0 -11
  524. package/dist/chunk-dm72y8wt.js.map +0 -10
  525. package/dist/chunk-drjqm1aa.js.map +0 -15
  526. package/dist/chunk-gadsm794.js.map +0 -11
  527. package/dist/chunk-h9kxd41f.js.map +0 -11
  528. package/dist/chunk-nzw7sm3b.js +0 -137
  529. package/dist/chunk-nzw7sm3b.js.map +0 -10
  530. package/dist/chunk-t0jjkep3.js.map +0 -10
  531. package/dist/chunk-t8t39h7v.js.map +0 -10
  532. package/dist/chunk-tkdscva6.js.map +0 -37
  533. package/dist/chunk-v0egge8b.js.map +0 -56
  534. package/dist/chunk-xdf9yswn.js.map +0 -11
  535. /package/dist/{chunk-zqysyfjt.js.map → chunk-08m3b6w8.js.map} +0 -0
  536. /package/dist/{chunk-xkthy56g.js.map → chunk-1kamz6j0.js.map} +0 -0
  537. /package/dist/{chunk-6d5xdj1q.js.map → chunk-3fqt22c4.js.map} +0 -0
  538. /package/dist/{chunk-z3zp0bj1.js.map → chunk-407j3msh.js.map} +0 -0
  539. /package/dist/{chunk-rhrbz7d4.js.map → chunk-4a849fr1.js.map} +0 -0
  540. /package/dist/{chunk-62c7t4jc.js.map → chunk-4nxeacx7.js.map} +0 -0
  541. /package/dist/{chunk-cy0n5dms.js.map → chunk-5jcdmjam.js.map} +0 -0
  542. /package/dist/{chunk-819wnjz8.js.map → chunk-64sr682n.js.map} +0 -0
  543. /package/dist/{chunk-x2yw73hy.js.map → chunk-7ds9620f.js.map} +0 -0
  544. /package/dist/{chunk-tbv03sx2.js.map → chunk-9aehf39w.js.map} +0 -0
  545. /package/dist/{chunk-ezake7g1.js.map → chunk-agsvg9ar.js.map} +0 -0
  546. /package/dist/{chunk-rnshztfq.js.map → chunk-d63tybny.js.map} +0 -0
  547. /package/dist/{chunk-vybf6pkp.js.map → chunk-dbc80ad7.js.map} +0 -0
  548. /package/dist/{chunk-4gz41why.js.map → chunk-dqn23610.js.map} +0 -0
  549. /package/dist/{chunk-zp2v2rv6.js.map → chunk-ha58tjtt.js.map} +0 -0
  550. /package/dist/{chunk-f6erf2vv.js.map → chunk-hdz94br2.js.map} +0 -0
  551. /package/dist/{chunk-dsrkgtnh.js.map → chunk-jq43kdvk.js.map} +0 -0
  552. /package/dist/{chunk-wtmzkcht.js.map → chunk-k34z5rvh.js.map} +0 -0
  553. /package/dist/{chunk-htq0qh7z.js.map → chunk-ka3a2ft3.js.map} +0 -0
  554. /package/dist/{chunk-4h947jd8.js.map → chunk-kt81c11h.js.map} +0 -0
  555. /package/dist/{chunk-f2rt4vkh.js.map → chunk-n2w475r0.js.map} +0 -0
  556. /package/dist/{chunk-bhxaq2nn.js.map → chunk-qw9gvjv5.js.map} +0 -0
  557. /package/dist/{chunk-r0rry8dn.js.map → chunk-rp1mvzb4.js.map} +0 -0
  558. /package/dist/{chunk-ghteq96b.js.map → chunk-s5y30bc9.js.map} +0 -0
  559. /package/dist/{chunk-a31h57d5.js.map → chunk-tn7xcs2n.js.map} +0 -0
  560. /package/dist/{chunk-ea73pzk7.js.map → chunk-vjjv9mrb.js.map} +0 -0
  561. /package/dist/{chunk-8b55ygje.js.map → chunk-w3e09qqk.js.map} +0 -0
  562. /package/dist/{chunk-ckxfnx7f.js.map → chunk-wjgm6jjt.js.map} +0 -0
  563. /package/dist/{chunk-3j7573mj.js.map → chunk-x0qhkqje.js.map} +0 -0
  564. /package/dist/{chunk-dysw7nsm.js.map → chunk-xdpwpkha.js.map} +0 -0
@@ -2,22 +2,22 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/authorization/grant-kinds.ts", "../src/execution/types.ts", "../src/execution/authorization.ts", "../src/authorization/errors.ts", "../src/authorization/decision.ts", "../src/authorization/application-access.ts", "../src/authorization/event-visibility.ts", "../src/authorization/resolve.ts", "../src/projections/errors.ts", "../src/projections/ownership.ts", "../src/projections/validation.ts", "../src/projections/builders.ts", "../src/authorization/run-visibility.ts", "../src/authorization/types.ts"],
4
4
  "sourcesContent": [
5
- "/**\n * Grant kinds: the single source of truth for the (capability, target) space.\n *\n * Every grant collapses to one `GrantKind` discriminant — the same\n * `capability:target` string the decision engine uses as a grant key (e.g.\n * `view:object`, `run:sync`). Resolution, validation, enforcement, and the\n * resolved `GrantIndex` all key off it, so adding a grant family is a single\n * entry in `GRANT_KINDS` plus the compile errors that forces at every consumer.\n */\n\nimport type { GrantDefinition } from \"../security/types\"\n\nexport type GrantKind =\n | \"access:application\"\n | \"view:object\"\n | \"view:dataset\"\n | \"edit:object\"\n | \"append:telemetry\"\n | \"apply:action\"\n | \"run:workflow\"\n | \"run:sync\"\n | \"run:pipeline\"\n | \"run:agent\"\n | \"observe:logs\"\n | \"manage:connector\"\n\n/** Registered id universes a grant kind ranges over, plus subtype expansion. */\nexport interface GrantUniverse {\n readonly applicationIds: ReadonlySet<string>\n readonly objectTypeIds: ReadonlySet<string>\n readonly datasetIds: ReadonlySet<string>\n readonly actionIds: ReadonlySet<string>\n readonly workflowIds: ReadonlySet<string>\n readonly syncIds: ReadonlySet<string>\n readonly pipelineIds: ReadonlySet<string>\n readonly agentIds: ReadonlySet<string>\n readonly observableIds: ReadonlySet<string>\n readonly connectorIds: ReadonlySet<string>\n readonly getSubTypes: (objectTypeId: string) => readonly string[]\n}\n\n/** The registered-id sets a grant kind validates against (no subtype hook). */\nexport type GrantUniverseKey = Exclude<keyof GrantUniverse, \"getSubTypes\">\n\ninterface GrantKindSpec {\n /** Registered universe the grant's ids must belong to. */\n readonly universeKey: GrantUniverseKey\n /** Subject noun used in validation errors (\"unknown <subject> '<id>'\"). */\n readonly subject: string\n /** Actionable hint appended to the \"unknown <subject>\" error. */\n readonly fix: string\n /** Only object-type grants also expand to subtypes. */\n readonly expandsSubtypes?: true\n}\n\n/**\n * The exhaustive grant-kind table. A new grant family is one entry here; the\n * `Record<GrantKind, …>` makes every omission a compile error.\n */\nexport const GRANT_KINDS: Record<GrantKind, GrantKindSpec> = {\n \"access:application\": {\n universeKey: \"applicationIds\",\n subject: \"application\",\n fix: \"Use an application exported from '@sixb/core'.\",\n },\n \"view:object\": {\n universeKey: \"objectTypeIds\",\n subject: \"object type\",\n fix: \"Register it in 'ontology/' or pass it to createSixb({ ontologies }).\",\n expandsSubtypes: true,\n },\n \"view:dataset\": {\n universeKey: \"datasetIds\",\n subject: \"dataset\",\n fix: \"Add it to 'datasets/' or pass it to createSixb({ datasets }).\",\n },\n // Deliberately no `expandsSubtypes`: granting writes on a parent type must not\n // silently extend to types added under it later. `view:object` expands because\n // a read of a subtype reveals nothing the parent's grant did not already cover.\n \"edit:object\": {\n universeKey: \"objectTypeIds\",\n subject: \"object type\",\n fix: \"Register it in 'ontology/' or pass it to createSixb({ ontologies }).\",\n },\n \"append:telemetry\": {\n universeKey: \"objectTypeIds\",\n subject: \"object type\",\n fix: \"Register it in 'ontology/' or pass it to createSixb({ ontologies }).\",\n },\n \"apply:action\": {\n universeKey: \"actionIds\",\n subject: \"action\",\n fix: \"Add it to 'actions/' or pass it to createSixb({ actions }).\",\n },\n \"run:workflow\": {\n universeKey: \"workflowIds\",\n subject: \"workflow\",\n fix: \"Add it to 'workflows/' or pass it to createSixb({ workflows }).\",\n },\n \"run:sync\": {\n universeKey: \"syncIds\",\n subject: \"sync\",\n fix: \"Add it to 'syncs/' or pass it to createSixb({ syncs }).\",\n },\n \"run:pipeline\": {\n universeKey: \"pipelineIds\",\n subject: \"pipeline\",\n fix: \"Add it to 'pipelines/' or pass it to createSixb({ pipelines }).\",\n },\n \"run:agent\": {\n universeKey: \"agentIds\",\n subject: \"agent\",\n fix: \"Add it to 'agents/' or pass it to createSixb({ agents }).\",\n },\n \"observe:logs\": {\n universeKey: \"observableIds\",\n subject: \"observability surface\",\n fix: 'Use can.observe(\"logs\").',\n },\n \"manage:connector\": {\n universeKey: \"connectorIds\",\n subject: \"connector\",\n fix: \"Add it to 'connectors/' or pass it to createSixb({ connectors }).\",\n },\n}\n\nexport const GRANT_KIND_KEYS = Object.keys(GRANT_KINDS) as readonly GrantKind[]\n\n/** The grant kind a stored grant resolves to. */\nexport function grantKindOf(grant: GrantDefinition): GrantKind {\n switch (grant.capability) {\n case \"access\":\n return \"access:application\"\n case \"view\":\n return `view:${grant.target}`\n case \"edit\":\n return \"edit:object\"\n case \"append\":\n return \"append:telemetry\"\n case \"apply\":\n return \"apply:action\"\n case \"run\":\n return `run:${grant.target}`\n case \"observe\":\n return \"observe:logs\"\n case \"manage\":\n return \"manage:connector\"\n }\n}\n\n/** A fresh, mutable grant index with one empty id set per kind. */\nexport function emptyGrantSets(): Record<GrantKind, Set<string>> {\n const sets = {} as Record<GrantKind, Set<string>>\n for (const kind of GRANT_KIND_KEYS) {\n sets[kind] = new Set<string>()\n }\n return sets\n}\n",
6
- "import type { Principal } from \"../auth/types\"\n\n/** User or service account that may initiate or authorize an execution. */\nexport type AuthorizablePrincipal = Extract<Principal, { readonly type: \"user\" | \"serviceAccount\" }>\n\n/** Registered primitive kinds that may receive internal trusted authority. */\nexport type TrustedPrimitiveKind =\n | \"action\"\n | \"pipeline\"\n | \"projection\"\n | \"rule\"\n | \"sync\"\n | \"webhook\"\n | \"workflow\"\n\nexport interface TrustedPrimitiveRef {\n readonly kind: TrustedPrimitiveKind\n readonly id: string\n readonly runId: string\n}\n\nexport type KernelOperation = {\n readonly type: \"ontology.recover\"\n readonly recoveryId: string\n}\n\n/** Workload currently executing. This is provenance and never grants authority by itself. */\nexport type ExecutionExecutor =\n | { readonly type: \"request\"; readonly requestId: string }\n | {\n readonly type: \"primitive\"\n readonly kind: TrustedPrimitiveKind\n readonly id: string\n readonly runId: string\n }\n | { readonly type: \"agent\"; readonly agentId: string; readonly runId: string }\n | { readonly type: \"kernel\"; readonly operation: KernelOperation }\n\n/**\n * Occurrence that directly triggered an execution.\n *\n * An `execution` source is the single logical parent of a nested execution.\n */\nexport type ExecutionSource =\n | { readonly type: \"http\"; readonly requestId: string }\n | { readonly type: \"webhook\"; readonly deliveryId: string }\n | { readonly type: \"schedule\"; readonly eventId: string }\n | { readonly type: \"event\"; readonly eventId: string }\n | { readonly type: \"datasetVersion\"; readonly datasetId: string; readonly versionId: string }\n | { readonly type: \"execution\"; readonly executionId: string }\n\n/** Immutable provenance for one request, primitive run, agent run, or kernel operation. */\nexport interface ExecutionContext {\n readonly id: string\n readonly projectId: string\n readonly requestedBy?: AuthorizablePrincipal\n readonly executor: ExecutionExecutor\n readonly source: ExecutionSource\n readonly correlationId: string\n}\n\n/** Durable descriptor used to rebuild authority. A reference is never authoritative by itself. */\nexport type AuthorizationRef =\n | {\n readonly type: \"principal\"\n readonly principal: AuthorizablePrincipal\n readonly credential?:\n | { readonly type: \"session\"; readonly id: string }\n | { readonly type: \"accessToken\"; readonly id: string }\n }\n | { readonly type: \"trustedPrimitive\"; readonly primitive: TrustedPrimitiveRef }\n | { readonly type: \"kernel\"; readonly operation: KernelOperation }\n | { readonly type: \"disabled\" }\n\nclass RuntimeAuthorizationCapability {\n readonly #runtimeAuthorization = true\n\n private constructor() {}\n\n static create(): RuntimeAuthorizationCapability {\n const capability = new RuntimeAuthorizationCapability()\n Object.freeze(capability)\n return capability\n }\n\n static is(value: unknown): value is RuntimeAuthorizationCapability {\n return typeof value === \"object\" && value !== null && #runtimeAuthorization in value\n }\n}\n\n/**\n * Opaque, process-local authority.\n *\n * The private class makes it nominal in TypeScript; Core registry membership makes it authoritative\n * at runtime. The capability itself is never persisted.\n */\nexport type RuntimeAuthorization = RuntimeAuthorizationCapability\n\n/** Execution provenance paired with the process-local authority that permits its operations. */\nexport interface ExecutionScope {\n readonly execution: ExecutionContext\n readonly authorization: RuntimeAuthorization\n}\n\n/** Internal constructor; the package root exports only the opaque type. */\nexport function createRuntimeAuthorizationCapability(): RuntimeAuthorization {\n return RuntimeAuthorizationCapability.create()\n}\n\n/** Internal runtime guard; registry membership remains the source of authority. */\nexport function isRuntimeAuthorizationCapability(value: unknown): value is RuntimeAuthorization {\n return RuntimeAuthorizationCapability.is(value)\n}\n",
7
- "import type { Principal } from \"../auth\"\nimport { emptyGrantSets, GRANT_KIND_KEYS } from \"../authorization/grant-kinds\"\nimport type { AuthorizationContext, GrantIndex } from \"../authorization/types\"\nimport { createSixbError } from \"../errors/internal\"\nimport {\n type AuthorizablePrincipal,\n type AuthorizationRef,\n createRuntimeAuthorizationCapability,\n type ExecutionScope,\n isRuntimeAuthorizationCapability,\n type KernelOperation,\n type RuntimeAuthorization,\n type TrustedPrimitiveKind,\n type TrustedPrimitiveRef,\n} from \"./types\"\n\nexport type ResolvedRuntimeAuthorization =\n | {\n readonly type: \"principal\"\n readonly projectId: string\n readonly context: AuthorizationContext\n readonly ref: Extract<AuthorizationRef, { readonly type: \"principal\" }>\n /** Process-local binding used by provider façades that explicitly support agent runs. */\n readonly executionBinding?: AgentExecutionBinding\n }\n | {\n readonly type: \"unrestricted\"\n readonly projectId: string\n readonly ref: Exclude<AuthorizationRef, { readonly type: \"principal\" }>\n }\n | { readonly type: \"denied\" }\n\ntype RegisteredRuntimeAuthorization = Exclude<\n ResolvedRuntimeAuthorization,\n { readonly type: \"denied\" }\n>\n\ntype PrincipalAuthorizationContext = Omit<AuthorizationContext, \"principal\"> & {\n readonly principal: AuthorizablePrincipal\n}\n\ninterface AgentExecutionBinding {\n readonly type: \"agent\"\n readonly executionId: string\n readonly agentId: string\n readonly runId: string\n}\n\nconst registeredAuthorizations = new WeakMap<RuntimeAuthorization, RegisteredRuntimeAuthorization>()\n\nexport function createPrincipalRuntimeAuthorization(input: {\n readonly projectId: string\n readonly context: AuthorizationContext\n readonly credential?: Extract<AuthorizationRef, { readonly type: \"principal\" }>[\"credential\"]\n}): RuntimeAuthorization {\n return createRegisteredPrincipalAuthorization(input)\n}\n\n/** Register service-account authority bound to one exact agent run. */\nexport function createAgentRuntimeAuthorization(input: {\n readonly projectId: string\n readonly context: AuthorizationContext\n readonly executionId: string\n readonly agentId: string\n readonly runId: string\n}): RuntimeAuthorization {\n if (input.context.principal.type !== \"serviceAccount\") {\n throw new Error(\"[Sixb] Agent execution authority must belong to a service account.\")\n }\n assertNonEmpty(input.executionId, \"Execution id\")\n assertNonEmpty(input.agentId, \"Agent id\")\n assertNonEmpty(input.runId, \"Agent run id\")\n return createRegisteredPrincipalAuthorization(input, {\n type: \"agent\",\n executionId: input.executionId,\n agentId: input.agentId,\n runId: input.runId,\n })\n}\n\nfunction createRegisteredPrincipalAuthorization(\n input: {\n readonly projectId: string\n readonly context: AuthorizationContext\n readonly credential?: Extract<AuthorizationRef, { readonly type: \"principal\" }>[\"credential\"]\n },\n executionBinding?: AgentExecutionBinding\n): RuntimeAuthorization {\n const context = snapshotAuthorizationContext(input.context)\n const credential = input.credential ? snapshotCredential(input.credential) : undefined\n assertCredentialMatchesContext(context, credential)\n const ref: Extract<AuthorizationRef, { readonly type: \"principal\" }> = Object.freeze({\n type: \"principal\",\n principal: context.principal,\n ...(credential === undefined ? {} : { credential }),\n })\n return register({\n type: \"principal\",\n projectId: input.projectId,\n context,\n ref,\n ...(executionBinding === undefined\n ? {}\n : { executionBinding: Object.freeze({ ...executionBinding }) }),\n })\n}\n\nexport function createDisabledRuntimeAuthorization(projectId: string): RuntimeAuthorization {\n return register({ type: \"unrestricted\", projectId, ref: Object.freeze({ type: \"disabled\" }) })\n}\n\nexport function createTrustedPrimitiveRuntimeAuthorization(input: {\n readonly projectId: string\n readonly primitive: TrustedPrimitiveRef\n}): RuntimeAuthorization {\n const primitive = snapshotTrustedPrimitive(input.primitive)\n return register({\n type: \"unrestricted\",\n projectId: input.projectId,\n ref: Object.freeze({ type: \"trustedPrimitive\", primitive }),\n })\n}\n\nexport function createKernelRuntimeAuthorization(input: {\n readonly projectId: string\n readonly operation: KernelOperation\n}): RuntimeAuthorization {\n const operation = snapshotKernelOperation(input.operation)\n return register({\n type: \"unrestricted\",\n projectId: input.projectId,\n ref: Object.freeze({ type: \"kernel\", operation }),\n })\n}\n\nexport function resolveRuntimeAuthorization(authorization: unknown): ResolvedRuntimeAuthorization {\n if (!isRuntimeAuthorizationCapability(authorization)) {\n return { type: \"denied\" }\n }\n return registeredAuthorizations.get(authorization) ?? { type: \"denied\" }\n}\n\nexport function getAuthorizationRef(authorization: RuntimeAuthorization): AuthorizationRef {\n const resolved = resolveRuntimeAuthorization(authorization)\n if (resolved.type === \"denied\") {\n throw new Error(\"[Sixb] Runtime authorization is not a registered Core capability.\")\n }\n return cloneAuthorizationRef(resolved.ref)\n}\n\nexport function assertExecutionScopeProject(projectId: string, scope: ExecutionScope): void {\n assertNonEmpty(projectId, \"Project id\")\n if (scope.execution.projectId !== projectId) {\n throw createSixbError(\n \"internal.unexpected\",\n `[Sixb] Execution scope belongs to project '${scope.execution.projectId}', not '${projectId}'.`,\n {\n details: {\n executionId: scope.execution.id,\n expectedProjectId: projectId,\n scopeProjectId: scope.execution.projectId,\n },\n }\n )\n }\n\n const resolved = resolveRuntimeAuthorization(scope.authorization)\n if (resolved.type === \"denied\") {\n throw createSixbError(\n \"internal.unexpected\",\n \"[Sixb] Execution scope carries unregistered runtime authorization.\",\n { details: { executionId: scope.execution.id, projectId } }\n )\n }\n if (resolved.projectId !== projectId) {\n throw createSixbError(\n \"internal.unexpected\",\n `[Sixb] Execution authorization belongs to project '${resolved.projectId}', not '${projectId}'.`,\n {\n details: {\n authorizationProjectId: resolved.projectId,\n executionId: scope.execution.id,\n expectedProjectId: projectId,\n },\n }\n )\n }\n}\n\n/** Validate that one registered authority belongs to the exact execution it accompanies. */\nexport function resolveExecutionScopeAuthorization(\n projectId: string,\n scope: ExecutionScope\n): RegisteredRuntimeAuthorization {\n assertExecutionScopeProject(projectId, scope)\n const resolved = resolveRuntimeAuthorization(scope.authorization)\n if (resolved.type === \"denied\") {\n throw createSixbError(\n \"internal.unexpected\",\n \"[Sixb] Execution scope carries unregistered runtime authorization.\",\n { details: { executionId: scope.execution.id, projectId } }\n )\n }\n\n const { execution } = scope\n switch (execution.executor.type) {\n case \"request\":\n if (\n execution.source.type !== \"http\" ||\n execution.source.requestId !== execution.executor.requestId\n ) {\n throw invalidExecutionAuthority(execution.id, \"request source does not match its executor\")\n }\n if (resolved.ref.type === \"principal\") {\n if (\n resolved.type !== \"principal\" ||\n resolved.executionBinding !== undefined ||\n !principalsEqual(execution.requestedBy, resolved.ref.principal)\n ) {\n throw invalidExecutionAuthority(\n execution.id,\n \"request authority does not match its requested-by principal\"\n )\n }\n return resolved\n }\n if (resolved.ref.type === \"disabled\" && execution.requestedBy === undefined) return resolved\n throw invalidExecutionAuthority(\n execution.id,\n \"request execution requires principal or explicitly disabled authority\"\n )\n\n case \"primitive\":\n if (\n resolved.ref.type !== \"trustedPrimitive\" ||\n resolved.ref.primitive.kind !== execution.executor.kind ||\n resolved.ref.primitive.id !== execution.executor.id ||\n resolved.ref.primitive.runId !== execution.executor.runId\n ) {\n throw invalidExecutionAuthority(\n execution.id,\n \"trusted primitive authority does not match its executor\"\n )\n }\n return resolved\n\n case \"agent\":\n if (\n resolved.type !== \"principal\" ||\n resolved.ref.type !== \"principal\" ||\n resolved.ref.principal.type !== \"serviceAccount\" ||\n resolved.ref.credential !== undefined ||\n resolved.executionBinding?.type !== \"agent\" ||\n resolved.executionBinding.executionId !== execution.id ||\n resolved.executionBinding.agentId !== execution.executor.agentId ||\n resolved.executionBinding.runId !== execution.executor.runId\n ) {\n throw invalidExecutionAuthority(\n execution.id,\n \"agent authority does not match its execution binding\"\n )\n }\n return resolved\n\n case \"kernel\":\n if (\n resolved.ref.type !== \"kernel\" ||\n execution.requestedBy !== undefined ||\n resolved.ref.operation.type !== execution.executor.operation.type ||\n resolved.ref.operation.recoveryId !== execution.executor.operation.recoveryId\n ) {\n throw invalidExecutionAuthority(\n execution.id,\n \"kernel authority does not match its executor\"\n )\n }\n return resolved\n }\n}\n\nfunction principalsEqual(\n left: AuthorizablePrincipal | undefined,\n right: AuthorizablePrincipal | undefined\n): boolean {\n return left?.type === right?.type && left?.id === right?.id\n}\n\nfunction invalidExecutionAuthority(executionId: string, reason: string): Error {\n return createSixbError(\n \"internal.unexpected\",\n `[Sixb] Execution '${executionId}' is incompatible with its authority: ${reason}.`,\n { details: { executionId, reason } }\n )\n}\n\nfunction register(input: RegisteredRuntimeAuthorization): RuntimeAuthorization {\n assertNonEmpty(input.projectId, \"Authorization project id\")\n const authorization = createRuntimeAuthorizationCapability()\n registeredAuthorizations.set(authorization, Object.freeze(input))\n return authorization\n}\n\nfunction snapshotAuthorizationContext(\n context: AuthorizationContext\n): PrincipalAuthorizationContext {\n const principal = snapshotAuthorizablePrincipal(context.principal)\n const grants = emptyGrantSets()\n for (const kind of GRANT_KIND_KEYS) {\n grants[kind] = new Set(context.grants[kind])\n }\n const frozenGrants: GrantIndex = Object.freeze(grants)\n return Object.freeze({\n principal,\n ...(context.sessionId === undefined ? {} : { sessionId: context.sessionId }),\n groupIds: Object.freeze([...context.groupIds]),\n roleIds: Object.freeze([...context.roleIds]),\n grants: frozenGrants,\n })\n}\n\nfunction snapshotAuthorizablePrincipal(principal: Principal): 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, \"Authorization principal id\")\n return Object.freeze({ type: principal.type, id: principal.id })\n}\n\nfunction snapshotCredential(\n credential: NonNullable<Extract<AuthorizationRef, { readonly type: \"principal\" }>[\"credential\"]>\n): NonNullable<Extract<AuthorizationRef, { readonly type: \"principal\" }>[\"credential\"]> {\n assertNonEmpty(credential.id, \"Authorization credential id\")\n if (credential.type !== \"session\" && credential.type !== \"accessToken\") {\n const credentialType = (credential as { readonly type: string }).type\n throw new Error(`[Sixb] Unknown authorization credential type '${credentialType}'.`)\n }\n return Object.freeze({ type: credential.type, id: credential.id })\n}\n\nfunction assertCredentialMatchesContext(\n context: PrincipalAuthorizationContext,\n credential:\n | NonNullable<Extract<AuthorizationRef, { readonly type: \"principal\" }>[\"credential\"]>\n | undefined\n): void {\n if (credential?.type === \"session\") {\n if (context.sessionId !== credential.id) {\n throw new Error(\n \"[Sixb] Session credential id must match the authorization context session id.\"\n )\n }\n return\n }\n if (context.sessionId !== undefined) {\n throw new Error(\"[Sixb] Authorization context session requires a matching session credential.\")\n }\n}\n\nfunction snapshotTrustedPrimitive(primitive: TrustedPrimitiveRef): TrustedPrimitiveRef {\n if (!isTrustedPrimitiveKind(primitive.kind)) {\n throw new Error(`[Sixb] Unknown trusted primitive kind '${primitive.kind}'.`)\n }\n assertNonEmpty(primitive.id, \"Trusted primitive id\")\n assertNonEmpty(primitive.runId, \"Trusted primitive run id\")\n return Object.freeze({ kind: primitive.kind, id: primitive.id, runId: primitive.runId })\n}\n\nfunction snapshotKernelOperation(operation: KernelOperation): KernelOperation {\n if (operation.type !== \"ontology.recover\") {\n throw new Error(`[Sixb] Unknown kernel operation '${operation.type}'.`)\n }\n assertNonEmpty(operation.recoveryId, \"Kernel recovery id\")\n return Object.freeze({ type: operation.type, recoveryId: operation.recoveryId })\n}\n\nfunction cloneAuthorizationRef(ref: AuthorizationRef): AuthorizationRef {\n switch (ref.type) {\n case \"principal\":\n return {\n type: \"principal\",\n principal: { ...ref.principal },\n ...(ref.credential === undefined ? {} : { credential: { ...ref.credential } }),\n }\n case \"trustedPrimitive\":\n return { type: \"trustedPrimitive\", primitive: { ...ref.primitive } }\n case \"kernel\":\n return { type: \"kernel\", operation: { ...ref.operation } }\n case \"disabled\":\n return { type: \"disabled\" }\n }\n}\n\nfunction isTrustedPrimitiveKind(value: string): value is TrustedPrimitiveKind {\n return (\n value === \"action\" ||\n value === \"pipeline\" ||\n value === \"projection\" ||\n value === \"rule\" ||\n value === \"sync\" ||\n value === \"webhook\" ||\n value === \"workflow\"\n )\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",
5
+ "/**\n * Grant kinds: the single source of truth for the (capability, target) space.\n *\n * Every grant collapses to one `GrantKind` discriminant — the same\n * `capability:target` string the decision engine uses as a grant key (e.g.\n * `view:object`, `run:sync`). Resolution, validation, enforcement, and the\n * resolved `GrantIndex` all key off it, so adding a grant family is a single\n * entry in `GRANT_KINDS` plus the compile errors that forces at every consumer.\n */\n\nimport type { AgentRunGrant, GrantDefinition } from \"../security/types\"\n\nexport type GrantKind =\n | \"access:application\"\n | \"view:object\"\n | \"view:dataset\"\n | \"edit:object\"\n | \"append:telemetry\"\n | \"apply:action\"\n | \"run:workflow\"\n | \"run:sync\"\n | \"run:pipeline\"\n | \"run:agent\"\n | \"observe:logs\"\n | \"observe:aiUsage\"\n | \"manage:connector\"\n | \"manage:aiUsage\"\n\nexport type SingletonGrantKind = \"run:agent\"\nexport type TargetedGrantKind = Exclude<GrantKind, SingletonGrantKind>\n\n/** Registered id universes a grant kind ranges over, plus subtype expansion. */\nexport interface GrantUniverse {\n readonly applicationIds: ReadonlySet<string>\n readonly objectTypeIds: ReadonlySet<string>\n readonly datasetIds: ReadonlySet<string>\n readonly actionIds: ReadonlySet<string>\n readonly workflowIds: ReadonlySet<string>\n readonly syncIds: ReadonlySet<string>\n readonly pipelineIds: ReadonlySet<string>\n readonly observableIds: ReadonlySet<string>\n readonly connectorIds: ReadonlySet<string>\n readonly manageableIds: ReadonlySet<string>\n readonly getSubTypes: (objectTypeId: string) => readonly string[]\n}\n\n/** The registered-id sets a grant kind validates against (no subtype hook). */\nexport type GrantUniverseKey = Exclude<keyof GrantUniverse, \"getSubTypes\">\n\ninterface TargetedGrantKindSpec {\n /** Registered universe the grant's ids must belong to. */\n readonly universeKey: GrantUniverseKey\n /** Subject noun used in validation errors (\"unknown <subject> '<id>'\"). */\n readonly subject: string\n /** Actionable hint appended to the \"unknown <subject>\" error. */\n readonly fix: string\n /** Only object-type grants also expand to subtypes. */\n readonly expandsSubtypes?: true\n}\n\ninterface SingletonGrantKindSpec {\n /** Project-wide capability with no resource selection; resolves to a boolean. */\n readonly singleton: true\n readonly subject: string\n readonly fix: string\n}\n\n/**\n * The exhaustive grant-kind table. A new grant family is one entry here; the\n * mapped type makes every omission a compile error.\n */\nexport const GRANT_KINDS: {\n readonly [TKind in GrantKind]: TKind extends SingletonGrantKind\n ? SingletonGrantKindSpec\n : TargetedGrantKindSpec\n} = {\n \"access:application\": {\n universeKey: \"applicationIds\",\n subject: \"application\",\n fix: \"Use an application exported from '@sixb/core'.\",\n },\n \"view:object\": {\n universeKey: \"objectTypeIds\",\n subject: \"object type\",\n fix: \"Register it in 'ontology/' or pass it to createSixb({ ontologies }).\",\n expandsSubtypes: true,\n },\n \"view:dataset\": {\n universeKey: \"datasetIds\",\n subject: \"dataset\",\n fix: \"Add it to 'datasets/' or pass it to createSixb({ datasets }).\",\n },\n // Deliberately no `expandsSubtypes`: granting writes on a parent type must not\n // silently extend to types added under it later. `view:object` expands because\n // a read of a subtype reveals nothing the parent's grant did not already cover.\n \"edit:object\": {\n universeKey: \"objectTypeIds\",\n subject: \"object type\",\n fix: \"Register it in 'ontology/' or pass it to createSixb({ ontologies }).\",\n },\n \"append:telemetry\": {\n universeKey: \"objectTypeIds\",\n subject: \"object type\",\n fix: \"Register it in 'ontology/' or pass it to createSixb({ ontologies }).\",\n },\n \"apply:action\": {\n universeKey: \"actionIds\",\n subject: \"action\",\n fix: \"Add it to 'actions/' or pass it to createSixb({ actions }).\",\n },\n \"run:workflow\": {\n universeKey: \"workflowIds\",\n subject: \"workflow\",\n fix: \"Add it to 'workflows/' or pass it to createSixb({ workflows }).\",\n },\n \"run:sync\": {\n universeKey: \"syncIds\",\n subject: \"sync\",\n fix: \"Add it to 'syncs/' or pass it to createSixb({ syncs }).\",\n },\n \"run:pipeline\": {\n universeKey: \"pipelineIds\",\n subject: \"pipeline\",\n fix: \"Add it to 'pipelines/' or pass it to createSixb({ pipelines }).\",\n },\n \"run:agent\": {\n singleton: true,\n subject: \"agent\",\n fix: \"Configure models.language and use the exported agent reference in can.run(agent).\",\n },\n \"observe:logs\": {\n universeKey: \"observableIds\",\n subject: \"observability surface\",\n fix: 'Use can.observe(\"logs\").',\n },\n \"observe:aiUsage\": {\n universeKey: \"observableIds\",\n subject: \"observability surface\",\n fix: \"Use can.observe(agent.usage).\",\n },\n \"manage:connector\": {\n universeKey: \"connectorIds\",\n subject: \"connector\",\n fix: \"Add it to 'connectors/' or pass it to createSixb({ connectors }).\",\n },\n \"manage:aiUsage\": {\n universeKey: \"manageableIds\",\n subject: \"management surface\",\n fix: \"Use can.manage(agent.usage).\",\n },\n}\n\nexport const GRANT_KIND_KEYS = Object.keys(GRANT_KINDS) as readonly GrantKind[]\nexport const TARGETED_GRANT_KIND_KEYS = GRANT_KIND_KEYS.filter(\n (kind): kind is TargetedGrantKind => kind !== \"run:agent\"\n)\n\n/** The grant kind a stored grant resolves to. */\nexport function grantKindOf(grant: AgentRunGrant): SingletonGrantKind\nexport function grantKindOf(grant: Exclude<GrantDefinition, AgentRunGrant>): TargetedGrantKind\nexport function grantKindOf(grant: GrantDefinition): GrantKind\nexport function grantKindOf(grant: GrantDefinition): GrantKind {\n switch (grant.capability) {\n case \"access\":\n return \"access:application\"\n case \"view\":\n return `view:${grant.target}`\n case \"edit\":\n return \"edit:object\"\n case \"append\":\n return \"append:telemetry\"\n case \"apply\":\n return \"apply:action\"\n case \"run\":\n return `run:${grant.target}`\n case \"observe\":\n return `observe:${grant.target}`\n case \"manage\":\n return `manage:${grant.target}`\n }\n}\n\n/** Mutable grant index: booleans for singleton capabilities, id sets for selected resources. */\nexport type MutableGrantIndex = {\n [TKind in GrantKind]: TKind extends SingletonGrantKind ? boolean : Set<string>\n}\n\nexport function emptyGrantSets(): MutableGrantIndex {\n return {\n \"access:application\": new Set(),\n \"view:object\": new Set(),\n \"view:dataset\": new Set(),\n \"edit:object\": new Set(),\n \"append:telemetry\": new Set(),\n \"apply:action\": new Set(),\n \"run:workflow\": new Set(),\n \"run:sync\": new Set(),\n \"run:pipeline\": new Set(),\n \"run:agent\": false,\n \"observe:logs\": new Set(),\n \"observe:aiUsage\": new Set(),\n \"manage:connector\": new Set(),\n \"manage:aiUsage\": new Set(),\n }\n}\n",
6
+ "import type { Principal } from \"../auth/types\"\n\n/** User or service account that may initiate or authorize an execution. */\nexport type AuthorizablePrincipal = Extract<Principal, { readonly type: \"user\" | \"serviceAccount\" }>\n\n/** Registered primitive kinds that may receive internal trusted authority. */\nexport type TrustedPrimitiveKind =\n | \"action\"\n | \"pipeline\"\n | \"projection\"\n | \"rule\"\n | \"sync\"\n | \"webhook\"\n | \"workflow\"\n\nexport interface TrustedPrimitiveRef {\n readonly kind: TrustedPrimitiveKind\n readonly id: string\n readonly runId: string\n}\n\nexport type KernelOperation = {\n readonly type: \"ontology.recover\"\n readonly recoveryId: string\n}\n\n/** Workload currently executing. This is provenance and never grants authority by itself. */\nexport type ExecutionExecutor =\n | { readonly type: \"request\"; readonly requestId: string }\n | {\n readonly type: \"primitive\"\n readonly kind: TrustedPrimitiveKind\n readonly id: string\n readonly runId: string\n }\n | { readonly type: \"agent\"; readonly actorId?: string; readonly runId: string }\n | { readonly type: \"kernel\"; readonly operation: KernelOperation }\n\n/**\n * Occurrence that directly triggered an execution.\n *\n * An `execution` source is the single logical parent of a nested execution.\n */\nexport type ExecutionSource =\n | { readonly type: \"http\"; readonly requestId: string }\n | { readonly type: \"webhook\"; readonly deliveryId: string }\n | { readonly type: \"schedule\"; readonly eventId: string }\n | { readonly type: \"event\"; readonly eventId: string }\n | { readonly type: \"datasetVersion\"; readonly datasetId: string; readonly versionId: string }\n | { readonly type: \"execution\"; readonly executionId: string }\n\n/** Immutable provenance for one request, primitive run, agent run, or kernel operation. */\nexport interface ExecutionContext {\n readonly id: string\n readonly projectId: string\n readonly requestedBy?: AuthorizablePrincipal\n readonly executor: ExecutionExecutor\n readonly source: ExecutionSource\n readonly correlationId: string\n}\n\n/** Durable descriptor used to rebuild authority. A reference is never authoritative by itself. */\nexport type AuthorizationRef =\n | {\n readonly type: \"principal\"\n readonly principal: AuthorizablePrincipal\n readonly credential?:\n | { readonly type: \"session\"; readonly id: string }\n | { readonly type: \"accessToken\"; readonly id: string }\n }\n | { readonly type: \"trustedPrimitive\"; readonly primitive: TrustedPrimitiveRef }\n | { readonly type: \"kernel\"; readonly operation: KernelOperation }\n | { readonly type: \"disabled\" }\n\nclass RuntimeAuthorizationCapability {\n readonly #runtimeAuthorization = true\n\n private constructor() {}\n\n static create(): RuntimeAuthorizationCapability {\n const capability = new RuntimeAuthorizationCapability()\n Object.freeze(capability)\n return capability\n }\n\n static is(value: unknown): value is RuntimeAuthorizationCapability {\n return typeof value === \"object\" && value !== null && #runtimeAuthorization in value\n }\n}\n\n/**\n * Opaque, process-local authority.\n *\n * The private class makes it nominal in TypeScript; Core registry membership makes it authoritative\n * at runtime. The capability itself is never persisted.\n */\nexport type RuntimeAuthorization = RuntimeAuthorizationCapability\n\n/** Execution provenance paired with the process-local authority that permits its operations. */\nexport interface ExecutionScope {\n readonly execution: ExecutionContext\n readonly authorization: RuntimeAuthorization\n}\n\n/** Internal constructor; the package root exports only the opaque type. */\nexport function createRuntimeAuthorizationCapability(): RuntimeAuthorization {\n return RuntimeAuthorizationCapability.create()\n}\n\n/** Internal runtime guard; registry membership remains the source of authority. */\nexport function isRuntimeAuthorizationCapability(value: unknown): value is RuntimeAuthorization {\n return RuntimeAuthorizationCapability.is(value)\n}\n",
7
+ "import type { Principal } from \"../auth\"\nimport { emptyGrantSets, TARGETED_GRANT_KIND_KEYS } from \"../authorization/grant-kinds\"\nimport type { AuthorizationContext, GrantIndex } from \"../authorization/types\"\nimport { createSixbError } from \"../errors/internal\"\nimport {\n type AuthorizablePrincipal,\n type AuthorizationRef,\n createRuntimeAuthorizationCapability,\n type ExecutionScope,\n isRuntimeAuthorizationCapability,\n type KernelOperation,\n type RuntimeAuthorization,\n type TrustedPrimitiveKind,\n type TrustedPrimitiveRef,\n} from \"./types\"\n\nexport type ResolvedRuntimeAuthorization =\n | {\n readonly type: \"principal\"\n readonly projectId: string\n readonly context: AuthorizationContext\n readonly ref: Extract<AuthorizationRef, { readonly type: \"principal\" }>\n /** Process-local binding used by provider façades that explicitly support agent runs. */\n readonly executionBinding?: AgentExecutionBinding\n }\n | {\n readonly type: \"unrestricted\"\n readonly projectId: string\n readonly ref: Exclude<AuthorizationRef, { readonly type: \"principal\" }>\n /** Process-local binding used by provider façades that explicitly support agent runs. */\n readonly executionBinding?: AgentExecutionBinding\n }\n | { readonly type: \"denied\" }\n\ntype RegisteredRuntimeAuthorization = Exclude<\n ResolvedRuntimeAuthorization,\n { readonly type: \"denied\" }\n>\n\ntype PrincipalAuthorizationContext = Omit<AuthorizationContext, \"principal\"> & {\n readonly principal: AuthorizablePrincipal\n}\n\ninterface AgentExecutionBinding {\n readonly type: \"agent\"\n readonly executionId: string\n readonly actorId?: string\n readonly runId: string\n}\n\nconst registeredAuthorizations = new WeakMap<RuntimeAuthorization, RegisteredRuntimeAuthorization>()\n\nexport function createPrincipalRuntimeAuthorization(input: {\n readonly projectId: string\n readonly context: AuthorizationContext\n readonly credential?: Extract<AuthorizationRef, { readonly type: \"principal\" }>[\"credential\"]\n}): RuntimeAuthorization {\n return createRegisteredPrincipalAuthorization(input)\n}\n\n/** Register restored authority bound to one exact agent run. */\nexport function createAgentRuntimeAuthorization(input: {\n readonly projectId: string\n readonly executionId: string\n readonly actorId?: string\n readonly runId: string\n readonly authority:\n | {\n readonly type: \"principal\"\n readonly context: AuthorizationContext\n readonly credential?: Extract<\n AuthorizationRef,\n { readonly type: \"principal\" }\n >[\"credential\"]\n }\n | { readonly type: \"disabled\" }\n}): RuntimeAuthorization {\n assertNonEmpty(input.executionId, \"Execution id\")\n if (input.actorId !== undefined) assertNonEmpty(input.actorId, \"Agent actor id\")\n assertNonEmpty(input.runId, \"Agent run id\")\n const executionBinding: AgentExecutionBinding = {\n type: \"agent\",\n executionId: input.executionId,\n ...(input.actorId === undefined ? {} : { actorId: input.actorId }),\n runId: input.runId,\n }\n\n if (input.authority.type === \"principal\") {\n return createRegisteredPrincipalAuthorization(\n {\n projectId: input.projectId,\n context: input.authority.context,\n ...(input.authority.credential === undefined\n ? {}\n : { credential: input.authority.credential }),\n },\n executionBinding\n )\n }\n\n return register({\n type: \"unrestricted\",\n projectId: input.projectId,\n ref: Object.freeze({ type: \"disabled\" }),\n executionBinding: Object.freeze(executionBinding),\n })\n}\n\nfunction createRegisteredPrincipalAuthorization(\n input: {\n readonly projectId: string\n readonly context: AuthorizationContext\n readonly credential?: Extract<AuthorizationRef, { readonly type: \"principal\" }>[\"credential\"]\n },\n executionBinding?: AgentExecutionBinding\n): RuntimeAuthorization {\n const context = snapshotAuthorizationContext(input.context)\n const credential = input.credential ? snapshotCredential(input.credential) : undefined\n assertCredentialMatchesContext(context, credential)\n const ref: Extract<AuthorizationRef, { readonly type: \"principal\" }> = Object.freeze({\n type: \"principal\",\n principal: context.principal,\n ...(credential === undefined ? {} : { credential }),\n })\n return register({\n type: \"principal\",\n projectId: input.projectId,\n context,\n ref,\n ...(executionBinding === undefined\n ? {}\n : { executionBinding: Object.freeze({ ...executionBinding }) }),\n })\n}\n\nexport function createDisabledRuntimeAuthorization(projectId: string): RuntimeAuthorization {\n return register({ type: \"unrestricted\", projectId, ref: Object.freeze({ type: \"disabled\" }) })\n}\n\nexport function createTrustedPrimitiveRuntimeAuthorization(input: {\n readonly projectId: string\n readonly primitive: TrustedPrimitiveRef\n}): RuntimeAuthorization {\n const primitive = snapshotTrustedPrimitive(input.primitive)\n return register({\n type: \"unrestricted\",\n projectId: input.projectId,\n ref: Object.freeze({ type: \"trustedPrimitive\", primitive }),\n })\n}\n\nexport function createKernelRuntimeAuthorization(input: {\n readonly projectId: string\n readonly operation: KernelOperation\n}): RuntimeAuthorization {\n const operation = snapshotKernelOperation(input.operation)\n return register({\n type: \"unrestricted\",\n projectId: input.projectId,\n ref: Object.freeze({ type: \"kernel\", operation }),\n })\n}\n\nexport function resolveRuntimeAuthorization(authorization: unknown): ResolvedRuntimeAuthorization {\n if (!isRuntimeAuthorizationCapability(authorization)) {\n return { type: \"denied\" }\n }\n return registeredAuthorizations.get(authorization) ?? { type: \"denied\" }\n}\n\nexport function getAuthorizationRef(authorization: RuntimeAuthorization): AuthorizationRef {\n const resolved = resolveRuntimeAuthorization(authorization)\n if (resolved.type === \"denied\") {\n throw new Error(\"[Sixb] Runtime authorization is not a registered Core capability.\")\n }\n return cloneAuthorizationRef(resolved.ref)\n}\n\nexport function assertExecutionScopeProject(projectId: string, scope: ExecutionScope): void {\n assertNonEmpty(projectId, \"Project id\")\n if (scope.execution.projectId !== projectId) {\n throw createSixbError(\n \"internal.unexpected\",\n `[Sixb] Execution scope belongs to project '${scope.execution.projectId}', not '${projectId}'.`,\n {\n details: {\n executionId: scope.execution.id,\n expectedProjectId: projectId,\n scopeProjectId: scope.execution.projectId,\n },\n }\n )\n }\n\n const resolved = resolveRuntimeAuthorization(scope.authorization)\n if (resolved.type === \"denied\") {\n throw createSixbError(\n \"internal.unexpected\",\n \"[Sixb] Execution scope carries unregistered runtime authorization.\",\n { details: { executionId: scope.execution.id, projectId } }\n )\n }\n if (resolved.projectId !== projectId) {\n throw createSixbError(\n \"internal.unexpected\",\n `[Sixb] Execution authorization belongs to project '${resolved.projectId}', not '${projectId}'.`,\n {\n details: {\n authorizationProjectId: resolved.projectId,\n executionId: scope.execution.id,\n expectedProjectId: projectId,\n },\n }\n )\n }\n}\n\n/** Validate that one registered authority belongs to the exact execution it accompanies. */\nexport function resolveExecutionScopeAuthorization(\n projectId: string,\n scope: ExecutionScope\n): RegisteredRuntimeAuthorization {\n assertExecutionScopeProject(projectId, scope)\n const resolved = resolveRuntimeAuthorization(scope.authorization)\n if (resolved.type === \"denied\") {\n throw createSixbError(\n \"internal.unexpected\",\n \"[Sixb] Execution scope carries unregistered runtime authorization.\",\n { details: { executionId: scope.execution.id, projectId } }\n )\n }\n\n const { execution } = scope\n switch (execution.executor.type) {\n case \"request\":\n if (\n execution.source.type !== \"http\" ||\n execution.source.requestId !== execution.executor.requestId\n ) {\n throw invalidExecutionAuthority(execution.id, \"request source does not match its executor\")\n }\n if (resolved.ref.type === \"principal\") {\n if (\n resolved.type !== \"principal\" ||\n resolved.executionBinding !== undefined ||\n !principalsEqual(execution.requestedBy, resolved.ref.principal)\n ) {\n throw invalidExecutionAuthority(\n execution.id,\n \"request authority does not match its requested-by principal\"\n )\n }\n return resolved\n }\n if (resolved.ref.type === \"disabled\" && execution.requestedBy === undefined) return resolved\n throw invalidExecutionAuthority(\n execution.id,\n \"request execution requires principal or explicitly disabled authority\"\n )\n\n case \"primitive\":\n if (\n resolved.ref.type !== \"trustedPrimitive\" ||\n resolved.ref.primitive.kind !== execution.executor.kind ||\n resolved.ref.primitive.id !== execution.executor.id ||\n resolved.ref.primitive.runId !== execution.executor.runId\n ) {\n throw invalidExecutionAuthority(\n execution.id,\n \"trusted primitive authority does not match its executor\"\n )\n }\n return resolved\n\n case \"agent\":\n if (\n resolved.executionBinding?.type !== \"agent\" ||\n resolved.executionBinding.executionId !== execution.id ||\n resolved.executionBinding.actorId !== execution.executor.actorId ||\n resolved.executionBinding.runId !== execution.executor.runId\n ) {\n throw invalidExecutionAuthority(\n execution.id,\n \"agent authority does not match its execution binding\"\n )\n }\n if (resolved.type === \"principal\" && resolved.ref.type === \"principal\") return resolved\n if (resolved.type === \"unrestricted\" && resolved.ref.type === \"disabled\") return resolved\n throw invalidExecutionAuthority(\n execution.id,\n \"agent authority must be principal or explicitly disabled\"\n )\n\n case \"kernel\":\n if (\n resolved.ref.type !== \"kernel\" ||\n execution.requestedBy !== undefined ||\n resolved.ref.operation.type !== execution.executor.operation.type ||\n resolved.ref.operation.recoveryId !== execution.executor.operation.recoveryId\n ) {\n throw invalidExecutionAuthority(\n execution.id,\n \"kernel authority does not match its executor\"\n )\n }\n return resolved\n }\n}\n\nfunction principalsEqual(\n left: AuthorizablePrincipal | undefined,\n right: AuthorizablePrincipal | undefined\n): boolean {\n return left?.type === right?.type && left?.id === right?.id\n}\n\nfunction invalidExecutionAuthority(executionId: string, reason: string): Error {\n return createSixbError(\n \"internal.unexpected\",\n `[Sixb] Execution '${executionId}' is incompatible with its authority: ${reason}.`,\n { details: { executionId, reason } }\n )\n}\n\nfunction register(input: RegisteredRuntimeAuthorization): RuntimeAuthorization {\n assertNonEmpty(input.projectId, \"Authorization project id\")\n const authorization = createRuntimeAuthorizationCapability()\n registeredAuthorizations.set(authorization, Object.freeze(input))\n return authorization\n}\n\nfunction snapshotAuthorizationContext(\n context: AuthorizationContext\n): PrincipalAuthorizationContext {\n const principal = snapshotAuthorizablePrincipal(context.principal)\n const grants = emptyGrantSets()\n grants[\"run:agent\"] = context.grants[\"run:agent\"]\n for (const kind of TARGETED_GRANT_KIND_KEYS) {\n grants[kind] = new Set(context.grants[kind])\n }\n const frozenGrants: GrantIndex = Object.freeze(grants)\n return Object.freeze({\n principal,\n ...(context.sessionId === undefined ? {} : { sessionId: context.sessionId }),\n groupIds: Object.freeze([...context.groupIds]),\n roleIds: Object.freeze([...context.roleIds]),\n grants: frozenGrants,\n })\n}\n\nfunction snapshotAuthorizablePrincipal(principal: Principal): 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, \"Authorization principal id\")\n return Object.freeze({ type: principal.type, id: principal.id })\n}\n\nfunction snapshotCredential(\n credential: NonNullable<Extract<AuthorizationRef, { readonly type: \"principal\" }>[\"credential\"]>\n): NonNullable<Extract<AuthorizationRef, { readonly type: \"principal\" }>[\"credential\"]> {\n assertNonEmpty(credential.id, \"Authorization credential id\")\n if (credential.type !== \"session\" && credential.type !== \"accessToken\") {\n const credentialType = (credential as { readonly type: string }).type\n throw new Error(`[Sixb] Unknown authorization credential type '${credentialType}'.`)\n }\n return Object.freeze({ type: credential.type, id: credential.id })\n}\n\nfunction assertCredentialMatchesContext(\n context: PrincipalAuthorizationContext,\n credential:\n | NonNullable<Extract<AuthorizationRef, { readonly type: \"principal\" }>[\"credential\"]>\n | undefined\n): void {\n if (credential?.type === \"session\") {\n if (context.sessionId !== credential.id) {\n throw new Error(\n \"[Sixb] Session credential id must match the authorization context session id.\"\n )\n }\n return\n }\n if (context.sessionId !== undefined) {\n throw new Error(\"[Sixb] Authorization context session requires a matching session credential.\")\n }\n}\n\nfunction snapshotTrustedPrimitive(primitive: TrustedPrimitiveRef): TrustedPrimitiveRef {\n if (!isTrustedPrimitiveKind(primitive.kind)) {\n throw new Error(`[Sixb] Unknown trusted primitive kind '${primitive.kind}'.`)\n }\n assertNonEmpty(primitive.id, \"Trusted primitive id\")\n assertNonEmpty(primitive.runId, \"Trusted primitive run id\")\n return Object.freeze({ kind: primitive.kind, id: primitive.id, runId: primitive.runId })\n}\n\nfunction snapshotKernelOperation(operation: KernelOperation): KernelOperation {\n if (operation.type !== \"ontology.recover\") {\n throw new Error(`[Sixb] Unknown kernel operation '${operation.type}'.`)\n }\n assertNonEmpty(operation.recoveryId, \"Kernel recovery id\")\n return Object.freeze({ type: operation.type, recoveryId: operation.recoveryId })\n}\n\nfunction cloneAuthorizationRef(ref: AuthorizationRef): AuthorizationRef {\n switch (ref.type) {\n case \"principal\":\n return {\n type: \"principal\",\n principal: { ...ref.principal },\n ...(ref.credential === undefined ? {} : { credential: { ...ref.credential } }),\n }\n case \"trustedPrimitive\":\n return { type: \"trustedPrimitive\", primitive: { ...ref.primitive } }\n case \"kernel\":\n return { type: \"kernel\", operation: { ...ref.operation } }\n case \"disabled\":\n return { type: \"disabled\" }\n }\n}\n\nfunction isTrustedPrimitiveKind(value: string): value is TrustedPrimitiveKind {\n return (\n value === \"action\" ||\n value === \"pipeline\" ||\n value === \"projection\" ||\n value === \"rule\" ||\n value === \"sync\" ||\n value === \"webhook\" ||\n value === \"workflow\"\n )\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",
8
8
  "/** Thrown when a scoped operation is not covered by the principal's grants. Maps to HTTP 403. */\nexport class AuthorizationError extends Error {\n readonly name = \"AuthorizationError\"\n\n constructor(\n /** Stable key of the missing grant, e.g. `view:object:Contract`. */\n readonly grantKey: string,\n message: string\n ) {\n super(message)\n }\n}\n",
9
- "/**\n * Authorization decisions for the core data path.\n *\n * `evaluate` is the single place that maps a request to the resolved grant\n * index. `can` (boolean) and `assertAuthorized` (throw) are the two ways to\n * consume a decision; every enforcement site goes through one of them.\n *\n * Every protected leaf first resolves the opaque runtime capability. Missing, forged, or\n * unregistered authority is denied; only an explicitly registered trusted or disabled execution\n * is unrestricted.\n */\n\nimport type { AuthSessionAudience } from \"../auth/audience\"\nimport {\n type ResolvedRuntimeAuthorization,\n resolveRuntimeAuthorization,\n} from \"../execution/authorization\"\nimport type { ExecutionContext, RuntimeAuthorization } from \"../execution/types\"\nimport { AuthorizationError } from \"./errors\"\nimport type { GrantKind } from \"./grant-kinds\"\nimport type { AuthorizationContext, GrantIndex } from \"./types\"\n\n/** Something a principal may attempt, paired with the resource it targets. */\nexport type AuthzRequest =\n | { readonly kind: \"application.access\"; readonly audience: AuthSessionAudience }\n | { readonly kind: \"object.view\"; readonly objectTypeId: string }\n | { readonly kind: \"dataset.view\"; readonly datasetId: string }\n | { readonly kind: \"object.edit\"; readonly objectTypeId: string }\n | { readonly kind: \"telemetry.append\"; readonly objectTypeId: string }\n | { readonly kind: \"action.apply\"; readonly actionId: string }\n | { readonly kind: \"workflow.run\"; readonly workflowId: string }\n | { readonly kind: \"sync.run\"; readonly syncId: string }\n | { readonly kind: \"pipeline.run\"; readonly pipelineId: string }\n | { readonly kind: \"agent.run\"; readonly agentId: string }\n | { readonly kind: \"logs.observe\" }\n | { readonly kind: \"connector.manage\"; readonly connectorId: string }\n | { readonly kind: \"object.query\"; readonly touchedObjectTypeIds: readonly string[] }\n\nexport interface AuthzDecision {\n readonly allowed: boolean\n /** Grant keys the request needs, e.g. `view:object:quote`. */\n readonly requirements: readonly string[]\n /** Required keys the principal lacks; empty when allowed. */\n readonly missing: readonly string[]\n}\n\ninterface AuthorizedRuntime {\n readonly runtimeAuthorization?: RuntimeAuthorization\n readonly authorization?: AuthorizationContext\n}\n\n// A request expands to one or more atomic (grant kind, id) checks. The atom is\n// the single unit that both names a requirement and tests the grant index, so\n// the two can never drift. `kind` is the resolved-index key, so enforcement is\n// a direct lookup with no per-target dispatch.\ninterface Atom {\n readonly kind: GrantKind\n readonly id: string\n}\n\nfunction atomsFor(request: AuthzRequest): readonly Atom[] {\n switch (request.kind) {\n case \"application.access\":\n return [{ kind: \"access:application\", id: request.audience }]\n case \"object.view\":\n return [{ kind: \"view:object\", id: request.objectTypeId }]\n case \"dataset.view\":\n return [{ kind: \"view:dataset\", id: request.datasetId }]\n case \"object.edit\":\n return [{ kind: \"edit:object\", id: request.objectTypeId }]\n case \"telemetry.append\":\n return [{ kind: \"append:telemetry\", id: request.objectTypeId }]\n case \"action.apply\":\n return [{ kind: \"apply:action\", id: request.actionId }]\n case \"workflow.run\":\n return [{ kind: \"run:workflow\", id: request.workflowId }]\n case \"sync.run\":\n return [{ kind: \"run:sync\", id: request.syncId }]\n case \"pipeline.run\":\n return [{ kind: \"run:pipeline\", id: request.pipelineId }]\n case \"agent.run\":\n return [{ kind: \"run:agent\", id: request.agentId }]\n case \"logs.observe\":\n return [{ kind: \"observe:logs\", id: \"logs\" }]\n case \"connector.manage\":\n return [{ kind: \"manage:connector\", id: request.connectorId }]\n case \"object.query\":\n return request.touchedObjectTypeIds.map((id) => ({ kind: \"view:object\", id }))\n }\n}\n\nfunction atomKey(atom: Atom): string {\n if (atom.kind === \"observe:logs\") return atom.kind\n return `${atom.kind}:${atom.id}`\n}\n\nfunction holds(grants: GrantIndex, atom: Atom): boolean {\n return grants[atom.kind].has(atom.id)\n}\n\n/** Resolve a request against a principal's grants. Never throws. */\nexport function evaluate(\n authorization: AuthorizationContext | null | undefined,\n request: AuthzRequest\n): AuthzDecision {\n const atoms = atomsFor(request)\n const requirements = atoms.map(atomKey)\n const missing = authorization\n ? atoms.filter((atom) => !holds(authorization.grants, atom)).map(atomKey)\n : []\n return { allowed: missing.length === 0, requirements, missing }\n}\n\nexport function isAllowed(\n authorization: AuthorizationContext | null | undefined,\n request: AuthzRequest\n): boolean {\n return evaluate(authorization, request).allowed\n}\n\nexport function assertAuthorized(runtime: AuthorizedRuntime, request: AuthzRequest): void {\n const resolved = assertRuntimeAuthorizationBound(runtime)\n const authorization = resolved.type === \"principal\" ? resolved.context : undefined\n const decision = evaluate(authorization, request)\n if (decision.allowed) {\n return\n }\n\n throw new AuthorizationError(\n decision.missing[0] ?? request.kind,\n deniedMessage(authorization, request)\n )\n}\n\n/** Resolve registered process-local authority before a protected leaf makes a decision. */\nexport function assertRuntimeAuthorizationBound(\n runtime: AuthorizedRuntime\n): Exclude<ResolvedRuntimeAuthorization, { readonly type: \"denied\" }> {\n const resolved = resolveRuntimeAuthorization(runtime.runtimeAuthorization)\n if (resolved.type === \"denied\") {\n throw new AuthorizationError(\n \"runtime:unbound\",\n \"[Sixb] Protected operations require a registered execution scope.\"\n )\n }\n return resolved\n}\n\n/**\n * Assert a principal may write objects of this type.\n *\n * Requires `view:object` as well as `edit:object`, and that is not belt-and-braces: an upsert\n * returns the *merged* row, which the Materializer reconciles against source authority, so the\n * response can carry properties the caller never sent. Granting the write without the read would\n * leak them.\n *\n * The pairing is asserted here rather than implied during resolution: `resolveRoleGrants` has no\n * notion of one grant entailing another, and giving it one would put ids in the resolved index that\n * no role granted — an index that no longer answers \"what was actually granted\".\n *\n * Telemetry append is deliberately *not* paired this way; see {@link assertCanAppendTelemetry}.\n */\nexport function assertCanEdit(runtime: AuthorizedRuntime, objectTypeId: string): void {\n assertAuthorized(runtime, { kind: \"object.view\", objectTypeId })\n assertAuthorized(runtime, { kind: \"object.edit\", objectTypeId })\n}\n\n/**\n * Assert a principal may append telemetry points to objects of this type.\n *\n * No `view:object` requirement, unlike {@link assertCanEdit}: an append answers with no object\n * state, so there is nothing to leak. That is what makes a write-only principal — a device, an\n * ingestion service — expressible at all, and it is the reason telemetry has its own grant.\n */\nexport function assertCanAppendTelemetry(runtime: AuthorizedRuntime, objectTypeId: string): void {\n assertAuthorized(runtime, { kind: \"telemetry.append\", objectTypeId })\n}\n\n/** Assert a principal may manage lifecycle state for this connector definition. */\nexport function assertCanManageConnector(runtime: AuthorizedRuntime, connectorId: string): void {\n assertAuthorized(runtime, { kind: \"connector.manage\", connectorId })\n}\n\n/**\n * Fail closed for operations that have no grant semantics yet.\n *\n * One caller left — `listLinks`, whose rows reveal target types that no read grant covers. Object,\n * link, and telemetry writes moved to {@link assertCanEdit} / {@link assertCanAppendTelemetry}.\n * Keeps unsupported surfaces denied even if a principal-bound runtime context reaches a code path\n * the execution SDK does not expose.\n */\nexport function assertPrivileged(runtime: AuthorizedRuntime, operation: string): void {\n const resolved = assertRuntimeAuthorizationBound(runtime)\n if (resolved.type === \"unrestricted\") {\n return\n }\n\n throw new AuthorizationError(\n `privileged:${operation}`,\n `[Sixb] Operation '${operation}' is not covered by scoped authorization grants.`\n )\n}\n\n/**\n * Assert access to process providers that trusted executions and genuine agent runs may use.\n *\n * Agent provenance alone is not authority: the registered capability must be bound to the exact\n * same agent and run before this check succeeds.\n */\nexport function assertProviderAccess(\n runtime: AuthorizedRuntime,\n execution: ExecutionContext,\n operation: string\n): void {\n const resolved = assertRuntimeAuthorizationBound(runtime)\n if (resolved.type === \"unrestricted\") {\n return\n }\n\n const binding = resolved.executionBinding\n const executor = execution.executor\n if (\n binding?.type === \"agent\" &&\n executor.type === \"agent\" &&\n binding.executionId === execution.id &&\n binding.agentId === executor.agentId &&\n binding.runId === executor.runId\n ) {\n return\n }\n\n throw new AuthorizationError(\n `privileged:${operation}`,\n `[Sixb] Operation '${operation}' is not covered by scoped authorization grants.`\n )\n}\n\nfunction deniedMessage(\n authorization: AuthorizationContext | null | undefined,\n request: AuthzRequest\n): string {\n const principalId = authorization?.principal.id ?? \"unknown\"\n switch (request.kind) {\n case \"application.access\":\n return `[Sixb] Principal '${principalId}' is not allowed to access application '${request.audience}'.`\n case \"object.view\":\n return `[Sixb] Principal '${principalId}' is not allowed to view object type '${request.objectTypeId}'.`\n case \"dataset.view\":\n return `[Sixb] Principal '${principalId}' is not allowed to view dataset '${request.datasetId}'.`\n case \"object.edit\":\n return `[Sixb] Principal '${principalId}' is not allowed to write object type '${request.objectTypeId}'.`\n case \"telemetry.append\":\n return `[Sixb] Principal '${principalId}' is not allowed to append telemetry for object type '${request.objectTypeId}'.`\n case \"action.apply\":\n return `[Sixb] Principal '${principalId}' is not allowed to apply action '${request.actionId}'.`\n case \"workflow.run\":\n return `[Sixb] Principal '${principalId}' is not allowed to run workflow '${request.workflowId}'.`\n case \"sync.run\":\n return `[Sixb] Principal '${principalId}' is not allowed to run sync '${request.syncId}'.`\n case \"pipeline.run\":\n return `[Sixb] Principal '${principalId}' is not allowed to run pipeline '${request.pipelineId}'.`\n case \"agent.run\":\n return `[Sixb] Principal '${principalId}' is not allowed to run agent '${request.agentId}'.`\n case \"logs.observe\":\n return `[Sixb] Principal '${principalId}' is not allowed to observe project logs.`\n case \"connector.manage\":\n return `[Sixb] Principal '${principalId}' is not allowed to manage connector '${request.connectorId}'.`\n case \"object.query\": {\n // Name the first touched type the principal cannot view.\n const blocked = request.touchedObjectTypeIds.find(\n (objectTypeId) => !isAllowed(authorization, { kind: \"object.view\", objectTypeId })\n )\n return `[Sixb] Principal '${principalId}' is not allowed to view object type '${blocked}'.`\n }\n }\n}\n",
9
+ "/**\n * Authorization decisions for the core data path.\n *\n * `evaluate` is the single place that maps a request to the resolved grant\n * index. `can` (boolean) and `assertAuthorized` (throw) are the two ways to\n * consume a decision; every enforcement site goes through one of them.\n *\n * Every protected leaf first resolves the opaque runtime capability. Missing, forged, or\n * unregistered authority is denied; only an explicitly registered trusted or disabled execution\n * is unrestricted.\n */\n\nimport type { AuthSessionAudience } from \"../auth/audience\"\nimport {\n type ResolvedRuntimeAuthorization,\n resolveRuntimeAuthorization,\n} from \"../execution/authorization\"\nimport type { ExecutionContext, RuntimeAuthorization } from \"../execution/types\"\nimport { AuthorizationError } from \"./errors\"\nimport type { GrantKind } from \"./grant-kinds\"\nimport type { AuthorizationContext, GrantIndex } from \"./types\"\n\n/** Something a principal may attempt, paired with the resource it targets. */\nexport type AuthzRequest =\n | { readonly kind: \"application.access\"; readonly audience: AuthSessionAudience }\n | { readonly kind: \"object.view\"; readonly objectTypeId: string }\n | { readonly kind: \"dataset.view\"; readonly datasetId: string }\n | { readonly kind: \"object.edit\"; readonly objectTypeId: string }\n | { readonly kind: \"telemetry.append\"; readonly objectTypeId: string }\n | { readonly kind: \"action.apply\"; readonly actionId: string }\n | { readonly kind: \"workflow.run\"; readonly workflowId: string }\n | { readonly kind: \"sync.run\"; readonly syncId: string }\n | { readonly kind: \"pipeline.run\"; readonly pipelineId: string }\n | { readonly kind: \"agent.run\" }\n | { readonly kind: \"logs.observe\" }\n | { readonly kind: \"aiUsage.observe\" }\n | { readonly kind: \"aiUsage.manage\" }\n | { readonly kind: \"connector.manage\"; readonly connectorId: string }\n | { readonly kind: \"object.query\"; readonly touchedObjectTypeIds: readonly string[] }\n\nexport interface AuthzDecision {\n readonly allowed: boolean\n /** Grant keys the request needs, e.g. `view:object:quote`. */\n readonly requirements: readonly string[]\n /** Required keys the principal lacks; empty when allowed. */\n readonly missing: readonly string[]\n}\n\ninterface AuthorizedRuntime {\n readonly runtimeAuthorization?: RuntimeAuthorization\n readonly authorization?: AuthorizationContext\n}\n\n// A request expands to one or more atomic (grant kind, id) checks. The atom is\n// the single unit that both names a requirement and tests the grant index, so\n// the two can never drift. `kind` is the resolved-index key, so enforcement is\n// a direct lookup with no per-target dispatch.\ntype Atom =\n | { readonly kind: \"run:agent\" }\n | { readonly kind: Exclude<GrantKind, \"run:agent\">; readonly id: string }\n\nfunction atomsFor(request: AuthzRequest): readonly Atom[] {\n switch (request.kind) {\n case \"application.access\":\n return [{ kind: \"access:application\", id: request.audience }]\n case \"object.view\":\n return [{ kind: \"view:object\", id: request.objectTypeId }]\n case \"dataset.view\":\n return [{ kind: \"view:dataset\", id: request.datasetId }]\n case \"object.edit\":\n return [{ kind: \"edit:object\", id: request.objectTypeId }]\n case \"telemetry.append\":\n return [{ kind: \"append:telemetry\", id: request.objectTypeId }]\n case \"action.apply\":\n return [{ kind: \"apply:action\", id: request.actionId }]\n case \"workflow.run\":\n return [{ kind: \"run:workflow\", id: request.workflowId }]\n case \"sync.run\":\n return [{ kind: \"run:sync\", id: request.syncId }]\n case \"pipeline.run\":\n return [{ kind: \"run:pipeline\", id: request.pipelineId }]\n case \"agent.run\":\n return [{ kind: \"run:agent\" }]\n case \"logs.observe\":\n return [{ kind: \"observe:logs\", id: \"logs\" }]\n case \"aiUsage.observe\":\n return [{ kind: \"observe:aiUsage\", id: \"aiUsage\" }]\n case \"aiUsage.manage\":\n return [{ kind: \"manage:aiUsage\", id: \"aiUsage\" }]\n case \"connector.manage\":\n return [{ kind: \"manage:connector\", id: request.connectorId }]\n case \"object.query\":\n return request.touchedObjectTypeIds.map((id) => ({ kind: \"view:object\", id }))\n }\n}\n\nfunction atomKey(atom: Atom): string {\n if (atom.kind === \"run:agent\") return atom.kind\n if (\n atom.kind === \"observe:logs\" ||\n atom.kind === \"observe:aiUsage\" ||\n atom.kind === \"manage:aiUsage\"\n ) {\n return atom.kind\n }\n return `${atom.kind}:${atom.id}`\n}\n\nfunction holds(grants: GrantIndex, atom: Atom): boolean {\n if (atom.kind === \"run:agent\") return grants[atom.kind]\n return grants[atom.kind].has(atom.id)\n}\n\n/** Resolve a request against a principal's grants. Never throws. */\nexport function evaluate(\n authorization: AuthorizationContext | null | undefined,\n request: AuthzRequest\n): AuthzDecision {\n const atoms = atomsFor(request)\n const requirements = atoms.map(atomKey)\n const missing = authorization\n ? atoms.filter((atom) => !holds(authorization.grants, atom)).map(atomKey)\n : []\n return { allowed: missing.length === 0, requirements, missing }\n}\n\nexport function isAllowed(\n authorization: AuthorizationContext | null | undefined,\n request: AuthzRequest\n): boolean {\n return evaluate(authorization, request).allowed\n}\n\nexport function assertAuthorized(runtime: AuthorizedRuntime, request: AuthzRequest): void {\n const resolved = assertRuntimeAuthorizationBound(runtime)\n const authorization = resolved.type === \"principal\" ? resolved.context : undefined\n const decision = evaluate(authorization, request)\n if (decision.allowed) {\n return\n }\n\n throw new AuthorizationError(\n decision.missing[0] ?? request.kind,\n deniedMessage(authorization, request)\n )\n}\n\n/** Resolve registered process-local authority before a protected leaf makes a decision. */\nexport function assertRuntimeAuthorizationBound(\n runtime: AuthorizedRuntime\n): Exclude<ResolvedRuntimeAuthorization, { readonly type: \"denied\" }> {\n const resolved = resolveRuntimeAuthorization(runtime.runtimeAuthorization)\n if (resolved.type === \"denied\") {\n throw new AuthorizationError(\n \"runtime:unbound\",\n \"[Sixb] Protected operations require a registered execution scope.\"\n )\n }\n return resolved\n}\n\n/**\n * Assert a principal may write objects of this type.\n *\n * Requires `view:object` as well as `edit:object`, and that is not belt-and-braces: an upsert\n * returns the *merged* row, which the Materializer reconciles against source authority, so the\n * response can carry properties the caller never sent. Granting the write without the read would\n * leak them.\n *\n * The pairing is asserted here rather than implied during resolution: `resolveRoleGrants` has no\n * notion of one grant entailing another, and giving it one would put ids in the resolved index that\n * no role granted — an index that no longer answers \"what was actually granted\".\n *\n * Telemetry append is deliberately *not* paired this way; see {@link assertCanAppendTelemetry}.\n */\nexport function assertCanEdit(runtime: AuthorizedRuntime, objectTypeId: string): void {\n assertAuthorized(runtime, { kind: \"object.view\", objectTypeId })\n assertAuthorized(runtime, { kind: \"object.edit\", objectTypeId })\n}\n\n/**\n * Assert a principal may append telemetry points to objects of this type.\n *\n * No `view:object` requirement, unlike {@link assertCanEdit}: an append answers with no object\n * state, so there is nothing to leak. That is what makes a write-only principal — a device, an\n * ingestion service — expressible at all, and it is the reason telemetry has its own grant.\n */\nexport function assertCanAppendTelemetry(runtime: AuthorizedRuntime, objectTypeId: string): void {\n assertAuthorized(runtime, { kind: \"telemetry.append\", objectTypeId })\n}\n\n/** Assert a principal may manage lifecycle state for this connector definition. */\nexport function assertCanManageConnector(runtime: AuthorizedRuntime, connectorId: string): void {\n assertAuthorized(runtime, { kind: \"connector.manage\", connectorId })\n}\n\n/**\n * Fail closed for operations that have no grant semantics yet.\n *\n * One caller left — `listLinks`, whose rows reveal target types that no read grant covers. Object,\n * link, and telemetry writes moved to {@link assertCanEdit} / {@link assertCanAppendTelemetry}.\n * Keeps unsupported surfaces denied even if a principal-bound runtime context reaches a code path\n * the execution SDK does not expose.\n */\nexport function assertPrivileged(runtime: AuthorizedRuntime, operation: string): void {\n const resolved = assertRuntimeAuthorizationBound(runtime)\n if (resolved.type === \"unrestricted\") {\n return\n }\n\n throw new AuthorizationError(\n `privileged:${operation}`,\n `[Sixb] Operation '${operation}' is not covered by scoped authorization grants.`\n )\n}\n\n/**\n * Assert access to process providers that trusted executions and genuine agent runs may use.\n *\n * Agent provenance alone is not authority: the registered capability must be bound to the exact\n * same execution identity and run before this check succeeds.\n */\nexport function assertProviderAccess(\n runtime: AuthorizedRuntime,\n execution: ExecutionContext,\n operation: string\n): void {\n const resolved = assertRuntimeAuthorizationBound(runtime)\n if (resolved.type === \"unrestricted\") {\n return\n }\n\n const binding = resolved.executionBinding\n const executor = execution.executor\n if (\n binding?.type === \"agent\" &&\n executor.type === \"agent\" &&\n binding.executionId === execution.id &&\n binding.actorId === executor.actorId &&\n binding.runId === executor.runId\n ) {\n return\n }\n\n throw new AuthorizationError(\n `privileged:${operation}`,\n `[Sixb] Operation '${operation}' is not covered by scoped authorization grants.`\n )\n}\n\nfunction deniedMessage(\n authorization: AuthorizationContext | null | undefined,\n request: AuthzRequest\n): string {\n const principalId = authorization?.principal.id ?? \"unknown\"\n switch (request.kind) {\n case \"application.access\":\n return `[Sixb] Principal '${principalId}' is not allowed to access application '${request.audience}'.`\n case \"object.view\":\n return `[Sixb] Principal '${principalId}' is not allowed to view object type '${request.objectTypeId}'.`\n case \"dataset.view\":\n return `[Sixb] Principal '${principalId}' is not allowed to view dataset '${request.datasetId}'.`\n case \"object.edit\":\n return `[Sixb] Principal '${principalId}' is not allowed to write object type '${request.objectTypeId}'.`\n case \"telemetry.append\":\n return `[Sixb] Principal '${principalId}' is not allowed to append telemetry for object type '${request.objectTypeId}'.`\n case \"action.apply\":\n return `[Sixb] Principal '${principalId}' is not allowed to apply action '${request.actionId}'.`\n case \"workflow.run\":\n return `[Sixb] Principal '${principalId}' is not allowed to run workflow '${request.workflowId}'.`\n case \"sync.run\":\n return `[Sixb] Principal '${principalId}' is not allowed to run sync '${request.syncId}'.`\n case \"pipeline.run\":\n return `[Sixb] Principal '${principalId}' is not allowed to run pipeline '${request.pipelineId}'.`\n case \"agent.run\":\n return `[Sixb] Principal '${principalId}' is not allowed to run the project Agent.`\n case \"logs.observe\":\n return `[Sixb] Principal '${principalId}' is not allowed to observe project logs.`\n case \"aiUsage.observe\":\n return `[Sixb] Principal '${principalId}' is not allowed to observe project AI usage.`\n case \"aiUsage.manage\":\n return `[Sixb] Principal '${principalId}' is not allowed to manage project AI usage limits.`\n case \"connector.manage\":\n return `[Sixb] Principal '${principalId}' is not allowed to manage connector '${request.connectorId}'.`\n case \"object.query\": {\n // Name the first touched type the principal cannot view.\n const blocked = request.touchedObjectTypeIds.find(\n (objectTypeId) => !isAllowed(authorization, { kind: \"object.view\", objectTypeId })\n )\n return `[Sixb] Principal '${principalId}' is not allowed to view object type '${blocked}'.`\n }\n }\n}\n",
10
10
  "import type { AuthSessionAudience } from \"../auth/audience\"\nimport { isAllowed } from \"./decision\"\nimport type { AuthorizationContext, ResolvedRole } from \"./types\"\n\n/** Whether declaring roles has enabled an allowlist for an application. */\nexport function isApplicationAccessControlled(\n roles: readonly ResolvedRole[],\n audience: AuthSessionAudience\n): boolean {\n return roles.some((role) => role.grants[\"access:application\"].has(audience))\n}\n\n/**\n * Whether this principal may open this application.\n *\n * KNOWN LIMITATION (0.1.x): application access is the one capability that is **not** deny-by-default.\n * While no role mentions an application, every authenticated principal may open it; the allowlist only\n * switches on once some role grants it. Every other capability — `view`, `apply`, `run`, `observe` —\n * denies unless granted, so this is the single asymmetry in the model.\n *\n * It is deliberate for now: flipping it would lock every project out of Atlas until it declares a role,\n * including projects with no security definitions at all. Closing it means shipping a default grant with\n * the scaffold first, and it is a breaking change for any project relying on the open default.\n */\nexport function canAccessApplication(\n authorization: AuthorizationContext,\n roles: readonly ResolvedRole[],\n audience: AuthSessionAudience\n): boolean {\n return (\n !isApplicationAccessControlled(roles, audience) ||\n isAllowed(authorization, { kind: \"application.access\", audience })\n )\n}\n",
11
11
  "/**\n * Event visibility derived from grants.\n *\n * There is no standalone \"view events\" capability: a principal sees a domain\n * event only when it can view/apply/run the event's subject. A privileged\n * caller (no authorization context) sees everything.\n *\n * The topic switch is fail-closed: an unrecognized topic is hidden, because a\n * topic we don't yet model may carry a subject the principal is not allowed to\n * see. Adding an event topic therefore requires an explicit visibility decision\n * here, never a silent default.\n */\n\nimport type { StoredDomainEvent } from \"../events\"\nimport { isAllowed } from \"./decision\"\nimport type { AuthorizationContext } from \"./types\"\n\nexport function canViewEvent(\n authorization: AuthorizationContext | null | undefined,\n event: StoredDomainEvent\n): boolean {\n if (!authorization) {\n return true\n }\n\n switch (event.topic) {\n case \"objects\":\n case \"telemetry\":\n return isAllowed(authorization, {\n kind: \"object.view\",\n objectTypeId: event.payload.objectTypeId,\n })\n case \"links\":\n return (\n isAllowed(authorization, {\n kind: \"object.view\",\n objectTypeId: event.payload.sourceTypeId,\n }) &&\n isAllowed(authorization, { kind: \"object.view\", objectTypeId: event.payload.targetTypeId })\n )\n case \"actions\": {\n // Apply is necessary; for object-bound actions the principal must also be\n // able to view the subject type, or the event would leak a hidden\n // object's id/type — mirroring the rule in `canListAction`.\n if (!isAllowed(authorization, { kind: \"action.apply\", actionId: event.payload.actionId })) {\n return false\n }\n const subject = event.payload.subject\n return subject.kind === \"object\"\n ? isAllowed(authorization, { kind: \"object.view\", objectTypeId: subject.objectTypeId })\n : true\n }\n case \"workflows\":\n return isAllowed(authorization, {\n kind: \"workflow.run\",\n workflowId: event.payload.workflowId,\n })\n case \"rules\":\n // Rule events carry the object they fired on, so gate on viewing it —\n // otherwise they leak the existence and id of hidden-type objects.\n return isAllowed(authorization, {\n kind: \"object.view\",\n objectTypeId: event.payload.subject.objectTypeId,\n })\n // Run grant gates the operational stream. These payloads may also carry the\n // produced datasetId/versionId; that target is already visible to a runner\n // through the sync/pipeline catalog (`sync.target.dataset`), so surfacing it\n // here discloses nothing new.\n case \"syncs\":\n return isAllowed(authorization, {\n kind: \"sync.run\",\n syncId: event.payload.syncId,\n })\n case \"pipelines\":\n return isAllowed(authorization, {\n kind: \"pipeline.run\",\n pipelineId: event.payload.pipelineId,\n })\n case \"schedules\":\n // Infra topics with no object/action/workflow/dataset subject: no grant\n // governs them yet, so they stay visible to any authorized reader. When\n // they gain their own grants, add the checks here.\n return true\n case \"datasets\":\n // dataset.view alone. The payload's `producer` (the sync/pipeline that\n // produced the version, plus its runId) is intentionally visible to any\n // dataset viewer as provenance — the same identity the versions API\n // already serializes for that principal. This is distinct from the\n // operational `references` in the dataset catalog (which syncs/pipelines\n // are wired to a dataset), which stays gated on the run grants.\n return isAllowed(authorization, {\n kind: \"dataset.view\",\n datasetId: event.payload.datasetId,\n })\n default:\n // Fail closed: an unmodeled topic may carry a subject we don't yet gate.\n return false\n }\n}\n",
12
- "import type { Principal } from \"../auth/types\"\nimport type { RoleDefinition, Selection } from \"../security\"\nimport {\n emptyGrantSets,\n GRANT_KIND_KEYS,\n GRANT_KINDS,\n type GrantUniverse,\n grantKindOf,\n} from \"./grant-kinds\"\nimport type { AuthorizationContext, GrantIndex, ResolvedRole } from \"./types\"\n\n/**\n * Expand a role's grants into concrete id sets once at startup.\n *\n * Broad grants (`every.object().except([...])`) expand against the registered\n * universe; object-type grants also expand to subtypes. The result holds only\n * `Set`s, so per-request resolution and runtime checks stay simple `set.has`.\n * The per-kind universe and subtype rules come from the `GRANT_KINDS` table, so\n * this loop never enumerates targets by hand.\n */\nexport function resolveRoleGrants(role: RoleDefinition, universe: GrantUniverse): GrantIndex {\n const grants = emptyGrantSets()\n\n for (const grant of role.grants) {\n const kind = grantKindOf(grant)\n const spec = GRANT_KINDS[kind]\n expandSelection(\n grant.selection,\n universe[spec.universeKey],\n grants[kind],\n spec.expandsSubtypes ? universe.getSubTypes : undefined\n )\n }\n\n return grants\n}\n\nfunction expandSelection(\n selection: Selection,\n universe: ReadonlySet<string>,\n into: Set<string>,\n expand?: (id: string) => readonly string[]\n): void {\n if (selection.all) {\n const except = new Set(selection.except)\n for (const id of universe) {\n if (!except.has(id)) {\n into.add(id)\n }\n }\n return\n }\n\n for (const id of selection.ids) {\n into.add(id)\n if (expand) {\n for (const subTypeId of expand(id)) {\n into.add(subTypeId)\n }\n }\n }\n}\n\n/**\n * Resolve a principal's authorization context from its group memberships.\n *\n * Pure set-union over pre-resolved roles: roles match when their grantedTo\n * groups intersect the principal's memberships, and their concrete id sets\n * union into the principal's grant index.\n */\nexport function resolveAuthorizationContext(input: {\n readonly principal: Principal\n readonly sessionId?: string\n readonly groupIds: readonly string[]\n readonly roles: readonly ResolvedRole[]\n}): AuthorizationContext {\n const memberGroupIds = new Set(input.groupIds)\n const roleIds: string[] = []\n const grants = emptyGrantSets()\n\n for (const role of input.roles) {\n if (!role.grantedToGroupIds.some((groupId) => memberGroupIds.has(groupId))) {\n continue\n }\n\n roleIds.push(role.id)\n for (const kind of GRANT_KIND_KEYS) {\n for (const id of role.grants[kind]) {\n grants[kind].add(id)\n }\n }\n }\n\n return {\n principal: input.principal,\n ...(input.sessionId !== undefined ? { sessionId: input.sessionId } : {}),\n groupIds: input.groupIds,\n roleIds,\n grants,\n }\n}\n",
12
+ "import type { Principal } from \"../auth/types\"\nimport type { RoleDefinition, Selection } from \"../security\"\nimport {\n emptyGrantSets,\n GRANT_KINDS,\n type GrantUniverse,\n grantKindOf,\n TARGETED_GRANT_KIND_KEYS,\n} from \"./grant-kinds\"\nimport type { AuthorizationContext, GrantIndex, ResolvedRole } from \"./types\"\n\n/**\n * Resolve a role's grants once at startup.\n *\n * Broad grants (`every.object().except([...])`) expand against the registered\n * universe; object-type grants also expand to subtypes. Resource grants become\n * id sets; the project Agent grant becomes a boolean.\n * The per-kind universe and subtype rules come from the `GRANT_KINDS` table, so\n * this loop never enumerates targets by hand.\n */\nexport function resolveRoleGrants(role: RoleDefinition, universe: GrantUniverse): GrantIndex {\n const grants = emptyGrantSets()\n\n for (const grant of role.grants) {\n if (grant.capability === \"run\" && grant.target === \"agent\") {\n grants[\"run:agent\"] = true\n continue\n }\n const kind = grantKindOf(grant)\n const spec = GRANT_KINDS[kind]\n expandSelection(\n grant.selection,\n universe[spec.universeKey],\n grants[kind],\n spec.expandsSubtypes ? universe.getSubTypes : undefined\n )\n }\n\n return grants\n}\n\nfunction expandSelection(\n selection: Selection,\n universe: ReadonlySet<string>,\n into: Set<string>,\n expand?: (id: string) => readonly string[]\n): void {\n if (selection.all) {\n const except = new Set(selection.except)\n for (const id of universe) {\n if (!except.has(id)) {\n into.add(id)\n }\n }\n return\n }\n\n for (const id of selection.ids) {\n into.add(id)\n if (expand) {\n for (const subTypeId of expand(id)) {\n into.add(subTypeId)\n }\n }\n }\n}\n\n/**\n * Resolve a principal's authorization context from its group memberships.\n *\n * Pure set-union over pre-resolved roles: roles match when their grantedTo\n * groups intersect the principal's memberships, and their concrete id sets\n * union into the principal's grant index.\n */\nexport function resolveAuthorizationContext(input: {\n readonly principal: Principal\n readonly sessionId?: string\n readonly groupIds: readonly string[]\n readonly roles: readonly ResolvedRole[]\n}): AuthorizationContext {\n const memberGroupIds = new Set(input.groupIds)\n const roleIds: string[] = []\n const grants = emptyGrantSets()\n\n for (const role of input.roles) {\n if (!role.grantedToGroupIds.some((groupId) => memberGroupIds.has(groupId))) {\n continue\n }\n\n roleIds.push(role.id)\n if (role.grants[\"run:agent\"]) {\n grants[\"run:agent\"] = true\n }\n for (const kind of TARGETED_GRANT_KIND_KEYS) {\n for (const id of role.grants[kind]) {\n grants[kind].add(id)\n }\n }\n }\n\n return {\n principal: input.principal,\n ...(input.sessionId !== undefined ? { sessionId: input.sessionId } : {}),\n groupIds: input.groupIds,\n roleIds,\n grants,\n }\n}\n",
13
13
  "export class ProjectionValidationError extends Error {\n readonly name = \"ProjectionValidationError\"\n}\n",
14
14
  "import { compareStrings } from \"../json\"\nimport type { OntologyDefinitionCatalog } from \"../ontology\"\nimport { ProjectionValidationError } from \"./errors\"\nimport type { ProjectionDefinition, ProjectionOwnership } from \"./types\"\n\nexport function computeProjectionOwnership(\n projection: ProjectionDefinition,\n ontology: OntologyDefinitionCatalog\n): ProjectionOwnership {\n if (projection._tag === \"ObjectProjectionDefinition\") {\n const primaryId = ontology.getPrimaryPropertyId(projection.objectTypeId)\n return freezeOwnership({\n objects: [\n {\n objectTypeId: projection.objectTypeId,\n existence: true,\n propertyIds: Object.keys(projection.properties)\n .filter((propertyId) => propertyId !== primaryId)\n .sort(compareStrings),\n },\n ],\n links: Object.keys(projection.links)\n .sort(compareStrings)\n .map((linkId) => ({ sourceObjectTypeId: projection.objectTypeId, linkId })),\n telemetry: [],\n })\n }\n\n if (projection._tag === \"LinkProjectionDefinition\") {\n return freezeOwnership({\n objects: [],\n links: [\n {\n sourceObjectTypeId: projection.sourceObjectTypeId,\n linkId: projection.linkId,\n },\n ],\n telemetry: [],\n })\n }\n\n return freezeOwnership({\n objects: [],\n links: [],\n telemetry: Object.keys(projection.properties)\n .sort(compareStrings)\n .map((propertyId) => ({\n objectTypeId: projection.objectTypeId,\n propertyId,\n })),\n })\n}\n\nexport interface ProjectionOwnershipRecord<\n TDefinition extends ProjectionDefinition = ProjectionDefinition,\n> {\n readonly definition: TDefinition\n readonly ownership: ProjectionOwnership\n}\n\nexport function validateProjectionOwnership(\n projections: readonly ProjectionOwnershipRecord[]\n): void {\n const existenceOwners = new Map<string, string>()\n const propertyOwners = new Map<string, string>()\n const linkOwners = new Map<string, string>()\n const telemetryOwners = new Map<string, string>()\n\n for (const { definition, ownership } of projections) {\n for (const object of ownership.objects) {\n if (object.existence) {\n registerOwner(\n existenceOwners,\n object.objectTypeId,\n definition.id,\n `object type '${object.objectTypeId}' existence`\n )\n }\n for (const propertyId of object.propertyIds) {\n registerOwner(\n propertyOwners,\n JSON.stringify([object.objectTypeId, propertyId]),\n definition.id,\n `property '${object.objectTypeId}.${propertyId}'`\n )\n }\n }\n for (const link of ownership.links) {\n registerOwner(\n linkOwners,\n JSON.stringify([link.sourceObjectTypeId, link.linkId]),\n definition.id,\n `link scope '${link.sourceObjectTypeId}.${link.linkId}'`\n )\n }\n for (const telemetry of ownership.telemetry) {\n registerOwner(\n telemetryOwners,\n JSON.stringify([telemetry.objectTypeId, telemetry.propertyId]),\n definition.id,\n `telemetry source '${telemetry.objectTypeId}.${telemetry.propertyId}'`\n )\n }\n }\n}\n\nfunction registerOwner(\n owners: Map<string, string>,\n key: string,\n projectionId: string,\n description: string\n): void {\n const existing = owners.get(key)\n if (existing !== undefined) {\n throw new ProjectionValidationError(\n `[Sixb] Projection '${projectionId}' overlaps ${description} owned by projection '${existing}'.`\n )\n }\n owners.set(key, projectionId)\n}\n\nfunction freezeOwnership(ownership: ProjectionOwnership): ProjectionOwnership {\n return Object.freeze({\n objects: Object.freeze(\n ownership.objects.map((object) =>\n Object.freeze({ ...object, propertyIds: Object.freeze([...object.propertyIds]) })\n )\n ),\n links: Object.freeze(ownership.links.map((link) => Object.freeze({ ...link }))),\n telemetry: Object.freeze(\n ownership.telemetry.map((telemetry) => Object.freeze({ ...telemetry }))\n ),\n })\n}\n",
15
15
  "/**\n * Build-time validation helpers for projection definitions.\n *\n * These run eagerly inside builder calls (not deferred to `.build()`).\n * They are also reusable by Increment 7 for startup validation.\n */\n\nimport type { DatasetDefinition } from \"../datasets\"\nimport type { OntologyDefinitionCatalog } from \"../ontology\"\nimport type { ObjectType, Property, ValueType } from \"../ontology/types\"\nimport { resolveSemanticType } from \"../ontology/validation\"\nimport { ProjectionValidationError } from \"./errors\"\nimport {\n computeProjectionOwnership,\n type ProjectionOwnershipRecord,\n validateProjectionOwnership,\n} from \"./ownership\"\nimport type {\n ForeignKeyDescriptor,\n LinkProjectionDefinition,\n ObjectProjectionDefinition,\n ProjectionDefinition,\n TelemetryProjectionDefinition,\n} from \"./types\"\n\n/**\n * Validates the property mapping for an object projection.\n *\n * Rules:\n * 1. All keys must be valid property ids on the object type.\n * 2. The object type must have exactly one primary property.\n * 3. The primary property must be included in the mapping.\n */\nexport function validatePropertyMapping(\n objectType: ObjectType,\n mapping: Record<string, string>\n): void {\n const propertyIds = new Set(objectType.properties.map((p) => p.id))\n const mappingKeys = Object.keys(mapping)\n\n // Rule 1: all keys are valid property ids\n for (const key of mappingKeys) {\n if (!propertyIds.has(key)) {\n const available = [...propertyIds].sort().join(\", \")\n throw new ProjectionValidationError(\n `Property '${key}' does not exist on object type '${objectType.id}'. ` +\n `Available properties: ${available}`\n )\n }\n }\n\n // Rule 2: exactly one primary property\n const primaryProperties = objectType.properties.filter((p) => p.primary === true)\n if (primaryProperties.length !== 1) {\n throw new ProjectionValidationError(\n `Object type '${objectType.id}' must have exactly one primary property, ` +\n `found ${primaryProperties.length}.`\n )\n }\n\n // Rule 3: primary property is in the mapping\n const primaryId = primaryProperties[0].id\n if (!(primaryId in mapping)) {\n throw new ProjectionValidationError(\n `Primary property '${primaryId}' of object type '${objectType.id}' ` +\n `must be included in the property mapping.`\n )\n }\n}\n\n/**\n * Validates the link mapping for an object projection and returns a validated copy.\n *\n * Rules:\n * 1. All keys must be valid link ids on the object type.\n * 2. Record key must match descriptor.linkId.\n * 3. Link target must be a single concrete type (not polymorphic or wildcard).\n * 4. The descriptor must use exactly one source: sourcePropertyId or sourceField.\n * 5. Source properties must exist and be present in the property mapping.\n * Source fields are validated later against the projection dataset.\n */\nexport function validateAndLowerLinkMapping(\n objectType: ObjectType,\n linkMapping: Record<string, ForeignKeyDescriptor>,\n propertyMapping: Record<string, string>\n): Record<string, ForeignKeyDescriptor> {\n const linkIds = new Set(objectType.links.map((l) => l.id))\n const linksById = new Map(objectType.links.map((l) => [l.id, l]))\n const propertyIds = new Set(objectType.properties.map((p) => p.id))\n\n for (const [key, descriptor] of Object.entries(linkMapping)) {\n // Rule 1: valid link id\n if (!linkIds.has(key)) {\n const available = [...linkIds].sort().join(\", \")\n throw new ProjectionValidationError(\n `Link '${key}' does not exist on object type '${objectType.id}'. ` +\n `Available links: ${available}`\n )\n }\n\n // Rule 2: key matches descriptor.linkId\n if (key !== descriptor.linkId) {\n throw new ProjectionValidationError(\n `Link mapping key '${key}' does not match descriptor linkId '${descriptor.linkId}'.`\n )\n }\n\n // Rule 3: single concrete target\n const link = linksById.get(key)!\n if (Array.isArray(link.targetObjectTypeId)) {\n throw new ProjectionValidationError(\n `Link '${key}' on object type '${objectType.id}' has a polymorphic target. ` +\n `FK projection of polymorphic links is not yet supported.`\n )\n }\n if (link.targetObjectTypeId === \"*\") {\n throw new ProjectionValidationError(\n `Link '${key}' on object type '${objectType.id}' has a wildcard target. ` +\n `FK projection of wildcard links is not supported.`\n )\n }\n\n const sourcePropertyId = descriptor.sourcePropertyId\n const sourceField = descriptor.sourceField\n if (sourcePropertyId && sourceField) {\n throw new ProjectionValidationError(\n `FK link '${key}' must use either sourceProperty or sourceField, not both.`\n )\n }\n if (!sourcePropertyId && !sourceField) {\n throw new ProjectionValidationError(\n `FK link '${key}' must declare sourceProperty or sourceField.`\n )\n }\n\n if (!sourcePropertyId) {\n continue\n }\n\n // Rule 4: source property exists on the type\n if (!propertyIds.has(sourcePropertyId)) {\n const available = [...propertyIds].sort().join(\", \")\n throw new ProjectionValidationError(\n `Source property '${sourcePropertyId}' does not exist on ` +\n `object type '${objectType.id}'. Available properties: ${available}`\n )\n }\n\n // Rule 5: source property is in the property mapping\n if (!(sourcePropertyId in propertyMapping)) {\n throw new ProjectionValidationError(\n `Source property '${sourcePropertyId}' for link '${key}' ` +\n `must be included in the property mapping.`\n )\n }\n }\n\n return Object.fromEntries(\n Object.entries(linkMapping).map(([linkId, descriptor]) => [\n linkId,\n {\n linkId: descriptor.linkId,\n ...(descriptor.sourcePropertyId !== undefined\n ? { sourcePropertyId: descriptor.sourcePropertyId }\n : {}),\n ...(descriptor.sourceField !== undefined ? { sourceField: descriptor.sourceField } : {}),\n targetObjectTypeId: descriptor.targetObjectTypeId,\n },\n ])\n )\n}\n\n/**\n * Validates that a link token points to a single concrete target type.\n *\n * Rules:\n * 1. Not an array (polymorphic).\n * 2. Not wildcard (\"*\").\n */\nexport function validateLinkProjectionTarget(linkToken: {\n readonly id: string\n readonly targetObjectTypeId: string | readonly string[]\n}): void {\n if (Array.isArray(linkToken.targetObjectTypeId)) {\n throw new ProjectionValidationError(\n `Link '${linkToken.id}' has a polymorphic target. ` +\n `Link projection of polymorphic links is not yet supported.`\n )\n }\n if (linkToken.targetObjectTypeId === \"*\") {\n throw new ProjectionValidationError(\n `Link '${linkToken.id}' has a wildcard target. ` +\n `Link projection of wildcard links is not supported.`\n )\n }\n}\n\n/**\n * Validates a telemetry projection's field mapping against its dataset columns\n * and object type: every mapped property exists and is telemetry-enabled, and\n * every mapped field (objectId/at/value/unit) resolves to a real dataset column.\n *\n * Owned here so startup validation and the projection worker's pre-execution\n * check share one implementation and cannot drift; the worker layers\n * dataset-version column type compatibility on top of these rules. Returns the\n * resolved telemetry properties for callers that need their schemas.\n */\nexport function validateTelemetryProjectionFieldMapping(\n projection: TelemetryProjectionDefinition,\n objectType: { readonly id: string; readonly properties: readonly Property[] },\n datasetColumnNames: ReadonlySet<string>,\n valueTypesById: ReadonlyMap<string, ValueType>,\n prefix: string\n): ReadonlyMap<string, Property> {\n const mappedProperties = Object.entries(projection.properties)\n if (mappedProperties.length === 0) {\n throw new ProjectionValidationError(`${prefix}: must map at least one telemetry property`)\n }\n\n const mappedFields = [\n [\"objectId\", projection.objectIdField],\n [\"at\", projection.atField],\n ] as const\n for (const [fieldRole, columnName] of mappedFields) {\n if (!datasetColumnNames.has(columnName)) {\n throw new ProjectionValidationError(\n `${prefix}: ${fieldRole} field \"${columnName}\" references unknown dataset column ` +\n `on dataset \"${projection.datasetId}\"`\n )\n }\n }\n\n const propertiesById = new Map(objectType.properties.map((property) => [property.id, property]))\n const resolvedProperties = new Map<string, Property>()\n for (const [propertyId, mapping] of mappedProperties) {\n const property = propertiesById.get(propertyId)\n if (!property) {\n throw new ProjectionValidationError(\n `${prefix}: unknown property \"${propertyId}\" on type \"${projection.objectTypeId}\"`\n )\n }\n if (property.mode !== \"telemetry\") {\n throw new ProjectionValidationError(\n `${prefix}: property \"${propertyId}\" on type \"${projection.objectTypeId}\" must be telemetry-enabled`\n )\n }\n\n for (const [fieldRole, columnName] of [\n [\"value\", mapping.valueField],\n ...(mapping.unitField !== undefined ? ([[\"unit\", mapping.unitField]] as const) : []),\n ] as const) {\n if (!datasetColumnNames.has(columnName)) {\n throw new ProjectionValidationError(\n `${prefix}: property \"${propertyId}\" ${fieldRole} field \"${columnName}\" references ` +\n `unknown dataset column on dataset \"${projection.datasetId}\"`\n )\n }\n }\n\n const semanticType = resolveSemanticType(property, valueTypesById)\n if (semanticType !== undefined && mapping.unitField === undefined) {\n throw new ProjectionValidationError(\n `${prefix}: property \"${propertyId}\" requires a unit field because it uses semantic type \"${semanticType}\"`\n )\n }\n if (semanticType === undefined && mapping.unitField !== undefined) {\n throw new ProjectionValidationError(\n `${prefix}: property \"${propertyId}\" cannot map a unit field because it has no semantic type`\n )\n }\n\n resolvedProperties.set(propertyId, property)\n }\n\n return resolvedProperties\n}\n\n/**\n * Validates all registered projections against the ontology at startup.\n *\n * For object projections:\n * 1. `datasetId` exists in the dataset registry.\n * 2. `objectTypeId` exists in the type registry.\n * 3. All property mapping keys are valid property ids on the type.\n * 4. All mapped dataset columns exist in the referenced dataset.\n * 5. The primary property is included in the property mapping.\n * 6. FK link descriptors reference valid links, valid source properties (present in mapping),\n * and valid target types with primaries.\n *\n * For link projections:\n * 1. `datasetId` exists in the dataset registry.\n * 2. Source and target types exist.\n * 3. The link exists on the source type.\n * 4. Source and target fields exist in the referenced dataset.\n * 5. Both source and target types have primary properties.\n *\n * For telemetry projections:\n * 1. `datasetId` exists in the dataset registry.\n * 2. `objectTypeId` exists in the type registry.\n * 3. Every mapped property exists on the object type and is telemetry-enabled.\n * 4. Point mapping fields exist in the referenced dataset.\n * 5. Unit mappings match each property's semantic type requirements.\n */\nexport interface ValidatedProjectionRecord<TDefinition extends ProjectionDefinition>\n extends ProjectionOwnershipRecord<TDefinition> {\n readonly dataset: DatasetDefinition\n}\n\nexport interface ProjectionValidationInput {\n readonly objectProjections: readonly ObjectProjectionDefinition[]\n readonly linkProjections: readonly LinkProjectionDefinition[]\n readonly telemetryProjections: readonly TelemetryProjectionDefinition[]\n}\n\nexport interface ValidatedProjectionCatalog {\n readonly objectProjections: readonly ValidatedProjectionRecord<ObjectProjectionDefinition>[]\n readonly linkProjections: readonly ValidatedProjectionRecord<LinkProjectionDefinition>[]\n readonly telemetryProjections: readonly ValidatedProjectionRecord<TelemetryProjectionDefinition>[]\n}\n\nexport function validateProjectionsAtStartup(\n projections: ProjectionValidationInput,\n ontology: OntologyDefinitionCatalog,\n datasetsById: ReadonlyMap<string, DatasetDefinition>\n): ValidatedProjectionCatalog {\n const { objectProjections, linkProjections, telemetryProjections } = projections\n const objectTypesById = ontology.getObjectTypesById()\n const primaryByTypeId = ontology.getPrimaryByTypeId()\n const validatedObjectProjections: ValidatedProjectionRecord<ObjectProjectionDefinition>[] = []\n const validatedLinkProjections: ValidatedProjectionRecord<LinkProjectionDefinition>[] = []\n const validatedTelemetryProjections: ValidatedProjectionRecord<TelemetryProjectionDefinition>[] =\n []\n\n validateMaterializationOntologyConstraints(ontology)\n\n for (const projection of objectProjections) {\n const prefix = `Projection \"${projection.id}\"`\n const dataset = datasetsById.get(projection.datasetId)\n if (!dataset) {\n throw new ProjectionValidationError(\n `${prefix}: unknown dataset \"${projection.datasetId}\". ` +\n `Add it to 'datasets' in createSixb() or export it from 'datasets/'.`\n )\n }\n\n const objectType = objectTypesById.get(projection.objectTypeId)\n if (!objectType) {\n throw new ProjectionValidationError(\n `${prefix}: unknown object type \"${projection.objectTypeId}\"`\n )\n }\n\n const datasetColumnNames = new Set(dataset.schema.columns.map((column) => column.name))\n const conflictResolution = projection.conflictResolution ?? { strategy: \"editsWin\" }\n if (conflictResolution.strategy === \"mostRecent\") {\n const sourceTimestamp = dataset.schema.columns.find(\n (column) => column.name === conflictResolution.sourceTimestamp\n )\n if (!sourceTimestamp) {\n throw new ProjectionValidationError(\n `${prefix}: source timestamp \"${conflictResolution.sourceTimestamp}\" references unknown ` +\n `dataset column on dataset \"${projection.datasetId}\"`\n )\n }\n if (sourceTimestamp.type !== \"timestamp\") {\n throw new ProjectionValidationError(\n `${prefix}: source timestamp \"${conflictResolution.sourceTimestamp}\" must reference a ` +\n `timestamp dataset column`\n )\n }\n if (sourceTimestamp.nullable === true) {\n throw new ProjectionValidationError(\n `${prefix}: source timestamp \"${conflictResolution.sourceTimestamp}\" must reference a ` +\n `non-null timestamp dataset column`\n )\n }\n }\n const propertyIds = new Set(objectType.properties.map((p) => p.id))\n for (const [propId, columnName] of Object.entries(projection.properties)) {\n if (!propertyIds.has(propId)) {\n throw new ProjectionValidationError(\n `${prefix}: unknown property \"${propId}\" on type \"${projection.objectTypeId}\"`\n )\n }\n if (!datasetColumnNames.has(columnName)) {\n throw new ProjectionValidationError(\n `${prefix}: property \"${propId}\" references unknown dataset column \"${columnName}\" ` +\n `on dataset \"${projection.datasetId}\"`\n )\n }\n const property = objectType.properties.find((candidate) => candidate.id === propId)\n if (property?.mode === \"telemetry\") {\n throw new ProjectionValidationError(\n `[Sixb] ${prefix}: source mappings cannot own telemetry property \"${projection.objectTypeId}.${propId}\"`\n )\n }\n }\n\n const primaryId = primaryByTypeId.get(projection.objectTypeId)!\n if (!(primaryId in projection.properties)) {\n throw new ProjectionValidationError(\n `${prefix}: primary property \"${primaryId}\" must be in property mapping`\n )\n }\n\n const linkIds = new Set(objectType.links.map((l) => l.id))\n for (const [linkId, fk] of Object.entries(projection.links)) {\n if (!linkIds.has(linkId)) {\n throw new ProjectionValidationError(\n `${prefix}: FK link \"${linkId}\" references unknown link on type \"${projection.objectTypeId}\"`\n )\n }\n if (fk.linkId !== linkId) {\n throw new ProjectionValidationError(\n `${prefix}: FK link mapping key \"${linkId}\" does not match descriptor linkId \"${fk.linkId}\"`\n )\n }\n const sourcePropertyId = fk.sourcePropertyId\n const sourceField = fk.sourceField\n if (sourcePropertyId && sourceField) {\n throw new ProjectionValidationError(\n `${prefix}: FK link \"${linkId}\" must use either sourcePropertyId or sourceField, not both`\n )\n }\n if (!sourcePropertyId && !sourceField) {\n throw new ProjectionValidationError(\n `${prefix}: FK link \"${linkId}\" must declare sourcePropertyId or sourceField`\n )\n }\n if (sourcePropertyId && !propertyIds.has(sourcePropertyId)) {\n throw new ProjectionValidationError(\n `${prefix}: FK link \"${linkId}\" source property \"${sourcePropertyId}\" does not exist on type \"${projection.objectTypeId}\"`\n )\n }\n if (sourcePropertyId && !(sourcePropertyId in projection.properties)) {\n throw new ProjectionValidationError(\n `${prefix}: FK link \"${linkId}\" source property \"${sourcePropertyId}\" must be in property mapping`\n )\n }\n if (sourceField && !datasetColumnNames.has(sourceField)) {\n throw new ProjectionValidationError(\n `${prefix}: FK link \"${linkId}\" source field \"${sourceField}\" references unknown dataset column on dataset \"${projection.datasetId}\"`\n )\n }\n if (!objectTypesById.has(fk.targetObjectTypeId)) {\n throw new ProjectionValidationError(\n `${prefix}: FK link \"${linkId}\" target type \"${fk.targetObjectTypeId}\" is unknown`\n )\n }\n if (!primaryByTypeId.has(fk.targetObjectTypeId)) {\n throw new ProjectionValidationError(\n `${prefix}: FK link \"${linkId}\" target type \"${fk.targetObjectTypeId}\" has no primary property`\n )\n }\n const link = objectType.links.find((candidate) => candidate.id === linkId)!\n if (!ontology.isValidLinkTarget(link.targetObjectTypeId, fk.targetObjectTypeId)) {\n throw new ProjectionValidationError(\n `${prefix}: FK link \"${linkId}\" target type \"${fk.targetObjectTypeId}\" is not compatible with its declared target`\n )\n }\n }\n\n validatedObjectProjections.push({\n definition: projection,\n dataset,\n ownership: computeProjectionOwnership(projection, ontology),\n })\n }\n\n for (const projection of linkProjections) {\n const prefix = `Projection \"${projection.id}\"`\n const dataset = datasetsById.get(projection.datasetId)\n if (!dataset) {\n throw new ProjectionValidationError(\n `${prefix}: unknown dataset \"${projection.datasetId}\". ` +\n `Add it to 'datasets' in createSixb() or export it from 'datasets/'.`\n )\n }\n\n if (!objectTypesById.has(projection.sourceObjectTypeId)) {\n throw new ProjectionValidationError(\n `${prefix}: unknown source type \"${projection.sourceObjectTypeId}\"`\n )\n }\n if (!objectTypesById.has(projection.targetObjectTypeId)) {\n throw new ProjectionValidationError(\n `${prefix}: unknown target type \"${projection.targetObjectTypeId}\"`\n )\n }\n const sourceType = objectTypesById.get(projection.sourceObjectTypeId)!\n const link = sourceType.links.find((candidate) => candidate.id === projection.linkId)\n if (!link) {\n throw new ProjectionValidationError(\n `${prefix}: link \"${projection.linkId}\" does not exist on source type \"${projection.sourceObjectTypeId}\"`\n )\n }\n if (!ontology.isValidLinkTarget(link.targetObjectTypeId, projection.targetObjectTypeId)) {\n throw new ProjectionValidationError(\n `${prefix}: target type \"${projection.targetObjectTypeId}\" is not compatible with link \"${projection.linkId}\"`\n )\n }\n const datasetColumnNames = new Set(dataset.schema.columns.map((column) => column.name))\n if (!datasetColumnNames.has(projection.sourceField)) {\n throw new ProjectionValidationError(\n `${prefix}: source field \"${projection.sourceField}\" references unknown dataset column ` +\n `on dataset \"${projection.datasetId}\"`\n )\n }\n if (!datasetColumnNames.has(projection.targetField)) {\n throw new ProjectionValidationError(\n `${prefix}: target field \"${projection.targetField}\" references unknown dataset column ` +\n `on dataset \"${projection.datasetId}\"`\n )\n }\n if (!primaryByTypeId.has(projection.sourceObjectTypeId)) {\n throw new ProjectionValidationError(\n `${prefix}: source type \"${projection.sourceObjectTypeId}\" has no primary property`\n )\n }\n if (!primaryByTypeId.has(projection.targetObjectTypeId)) {\n throw new ProjectionValidationError(\n `${prefix}: target type \"${projection.targetObjectTypeId}\" has no primary property`\n )\n }\n\n validatedLinkProjections.push({\n definition: projection,\n dataset,\n ownership: computeProjectionOwnership(projection, ontology),\n })\n }\n\n for (const projection of telemetryProjections) {\n const prefix = `Projection \"${projection.id}\"`\n const dataset = datasetsById.get(projection.datasetId)\n if (!dataset) {\n throw new ProjectionValidationError(\n `${prefix}: unknown dataset \"${projection.datasetId}\". ` +\n `Add it to 'datasets' in createSixb() or export it from 'datasets/'.`\n )\n }\n\n const objectType = objectTypesById.get(projection.objectTypeId)\n if (!objectType) {\n throw new ProjectionValidationError(\n `${prefix}: unknown object type \"${projection.objectTypeId}\"`\n )\n }\n\n const datasetColumnNames = new Set(dataset.schema.columns.map((column) => column.name))\n validateTelemetryProjectionFieldMapping(\n projection,\n objectType,\n datasetColumnNames,\n ontology.getValueTypesById(),\n prefix\n )\n validatedTelemetryProjections.push({\n definition: projection,\n dataset,\n ownership: computeProjectionOwnership(projection, ontology),\n })\n }\n\n const validatedProjections = [\n ...validatedObjectProjections,\n ...validatedLinkProjections,\n ...validatedTelemetryProjections,\n ]\n validateProjectionOwnership(validatedProjections)\n return {\n objectProjections: validatedObjectProjections,\n linkProjections: validatedLinkProjections,\n telemetryProjections: validatedTelemetryProjections,\n }\n}\n\nfunction validateMaterializationOntologyConstraints(ontology: OntologyDefinitionCatalog): void {\n for (const objectType of ontology.getObjectTypesById().values()) {\n for (const property of objectType.properties) {\n if (property.mode === \"telemetry\" && property.required === true) {\n throw new ProjectionValidationError(\n `[Sixb] Telemetry property '${objectType.id}.${property.id}' cannot be required.`\n )\n }\n }\n for (const link of objectType.links) {\n for (const property of link.properties ?? []) {\n if (property.mode === \"telemetry\") {\n throw new ProjectionValidationError(\n `[Sixb] Link property '${objectType.id}.${link.id}.${property.id}' cannot use telemetry mode.`\n )\n }\n }\n }\n }\n}\n",
16
16
  "/**\n * Projection DSL builders, helpers, and type guards.\n *\n * Uses the same fluent builder style as the other definition APIs.\n */\n\nimport type {\n DatasetColumnDefinitionOf,\n DatasetColumnNameOf,\n DatasetColumnType,\n DatasetColumnTypeOf,\n DatasetDefinition,\n} from \"../datasets\"\nimport type { LinkToken, PropertyToken } from \"../ontology/tokens\"\nimport type { ObjectLink, ObjectType, Property, Schema } from \"../ontology/types\"\nimport { ProjectionValidationError } from \"./errors\"\nimport type {\n ForeignKeyDescriptor,\n LinkProjectionDefinition,\n LinkProjectionTarget,\n ObjectProjectionDefinition,\n ObjectProjectionTarget,\n ProjectionDefinition,\n ProjectionTarget,\n SourceEditConflictResolution,\n TelemetryProjectionDefinition,\n TelemetryProjectionPropertyMapping,\n} from \"./types\"\nimport {\n validateAndLowerLinkMapping,\n validateLinkProjectionTarget,\n validatePropertyMapping,\n} from \"./validation\"\n\n// ── Internal helpers ─────────────────────────────────────────\n\nfunction assertNonEmpty(value: string, field: string): void {\n if (!value.trim()) {\n throw new ProjectionValidationError(`Projection ${field} must not be empty.`)\n }\n}\n\nfunction assertProjectionDataset(dataset: DatasetDefinition): void {\n if (!dataset || dataset.kind !== \"dataset\" || typeof dataset.id !== \"string\") {\n throw new ProjectionValidationError(\"Projection dataset must be a dataset definition.\")\n }\n assertNonEmpty(dataset.id, \"dataset id\")\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value)\n}\n\n// ── Type utilities ───────────────────────────────────────────\n\n/** Union of property ids from an ObjectType. */\ntype PropertyIdOf<T extends ObjectType> = T[\"properties\"][number][\"id\"]\n\n/** Property definition by id from an ObjectType. */\ntype PropertyById<T extends ObjectType, TPropertyId extends PropertyIdOf<T>> = Extract<\n T[\"properties\"][number],\n { id: TPropertyId }\n>\n\n/** Union of link ids from an ObjectType. */\ntype LinkIdOf<T extends ObjectType> = T[\"links\"][number][\"id\"]\n\ntype LinkById<T extends ObjectType, TLinkId extends LinkIdOf<T>> = Extract<\n T[\"links\"][number],\n { id: TLinkId }\n>\n\ntype SingleTargetIdOf<TLink extends ObjectLink> = TLink[\"targetObjectTypeId\"] extends string\n ? TLink[\"targetObjectTypeId\"]\n : never\n\ntype ResolvedProjectionSchema<TSchema extends Schema> = TSchema extends {\n type: \"valueTypeRef\"\n _resolved: infer TResolved extends Schema\n}\n ? ResolvedProjectionSchema<TResolved>\n : TSchema extends { type: \"valueTypeRef\" }\n ? never\n : TSchema\n\ntype StringCompatibleProjectionSchema =\n | \"string\"\n | \"uuid\"\n | { type: \"enum\"; values: readonly string[] }\n\ntype IntegerCompatibleProjectionSchema =\n | \"integer\"\n | \"double\"\n | \"decimal\"\n | { type: \"enum\"; values: readonly number[] }\n\ntype JsonCompatibleProjectionSchema = { type: \"object\" | \"array\" | \"map\" | \"enum\" }\n\ntype ProjectionSchemaByDatasetColumnType = {\n readonly string: StringCompatibleProjectionSchema\n readonly boolean: \"boolean\"\n readonly int64: IntegerCompatibleProjectionSchema\n readonly float64: \"double\"\n readonly decimal: \"decimal\" | \"double\"\n readonly date: \"date\"\n readonly timestamp: \"timestamp\"\n readonly json: JsonCompatibleProjectionSchema\n readonly fileRef: \"fileRef\"\n}\n\ntype DatasetColumnCompatibleWithSchema<\n TColumnType extends DatasetColumnType,\n TSchema extends Schema,\n> = [ResolvedProjectionSchema<TSchema>] extends [never]\n ? false\n : ResolvedProjectionSchema<TSchema> extends ProjectionSchemaByDatasetColumnType[TColumnType]\n ? true\n : false\n\ntype DatasetColumnNameCompatibleWithSchema<\n TDataset extends DatasetDefinition,\n TSchema extends Schema,\n> =\n string extends DatasetColumnNameOf<TDataset>\n ? string\n : {\n [TColumnName in DatasetColumnNameOf<TDataset>]: DatasetColumnCompatibleWithSchema<\n DatasetColumnTypeOf<TDataset, TColumnName>,\n TSchema\n > extends true\n ? TColumnName\n : never\n }[DatasetColumnNameOf<TDataset>]\n\ntype StringDatasetColumnNameOf<TDataset extends DatasetDefinition> =\n string extends DatasetColumnNameOf<TDataset>\n ? string\n : {\n [TColumnName in DatasetColumnNameOf<TDataset>]: DatasetColumnTypeOf<\n TDataset,\n TColumnName\n > extends \"string\"\n ? TColumnName\n : never\n }[DatasetColumnNameOf<TDataset>]\n\ntype DateLikeDatasetColumnNameOf<TDataset extends DatasetDefinition> =\n string extends DatasetColumnNameOf<TDataset>\n ? string\n : {\n [TColumnName in DatasetColumnNameOf<TDataset>]: DatasetColumnTypeOf<\n TDataset,\n TColumnName\n > extends \"string\" | \"date\" | \"timestamp\"\n ? TColumnName\n : never\n }[DatasetColumnNameOf<TDataset>]\n\ntype TimestampDatasetColumnNameOf<TDataset extends DatasetDefinition> =\n string extends DatasetColumnNameOf<TDataset>\n ? string\n : {\n [TColumnName in DatasetColumnNameOf<TDataset>]: DatasetColumnTypeOf<\n TDataset,\n TColumnName\n > extends \"timestamp\"\n ? DatasetColumnDefinitionOf<TDataset, TColumnName> extends { readonly nullable: true }\n ? never\n : TColumnName\n : never\n }[DatasetColumnNameOf<TDataset>]\n\ntype ProjectionMappingFor<TObjectType extends ObjectType, TDataset extends DatasetDefinition> = {\n readonly [TPropertyId in PropertyIdOf<TObjectType>]?: DatasetColumnNameCompatibleWithSchema<\n TDataset,\n PropertyById<TObjectType, TPropertyId>[\"schema\"]\n >\n}\n\ntype ExactProjectionMapping<TObjectType extends ObjectType, TMapping> = TMapping & {\n readonly [TKey in Exclude<keyof TMapping, PropertyIdOf<TObjectType>>]: never\n}\n\ntype TelemetryPropertyToken<TObjectTypeId extends string = string> = PropertyToken<\n TObjectTypeId,\n string,\n Property & { readonly mode: \"telemetry\" }\n>\n\ntype TelemetryPropertyOf<TObjectType extends ObjectType> = Extract<\n TObjectType[\"properties\"][number],\n { readonly mode: \"telemetry\" }\n>\n\ntype TelemetryPropertyIdOf<TObjectType extends ObjectType> = TelemetryPropertyOf<TObjectType>[\"id\"]\n\ntype TelemetryPropertyById<\n TObjectType extends ObjectType,\n TPropertyId extends TelemetryPropertyIdOf<TObjectType>,\n> = Extract<TelemetryPropertyOf<TObjectType>, { readonly id: TPropertyId }>\n\ntype TelemetryProjectionPointMapping<\n TPropertyToken extends TelemetryPropertyToken,\n TDataset extends DatasetDefinition,\n> = {\n readonly objectId: StringDatasetColumnNameOf<TDataset>\n readonly at: DateLikeDatasetColumnNameOf<TDataset>\n readonly value: DatasetColumnNameCompatibleWithSchema<\n TDataset,\n TPropertyToken[\"property\"][\"schema\"]\n >\n readonly unit?: StringDatasetColumnNameOf<TDataset>\n}\n\ntype ExactTelemetryProjectionPointMapping<TMapping> = TMapping & {\n readonly [TKey in Exclude<keyof TMapping, \"objectId\" | \"at\" | \"value\" | \"unit\">]: never\n}\n\ntype TelemetryProjectionPropertyInput<\n TProperty extends Property,\n TDataset extends DatasetDefinition,\n> =\n | DatasetColumnNameCompatibleWithSchema<TDataset, TProperty[\"schema\"]>\n | {\n readonly value: DatasetColumnNameCompatibleWithSchema<TDataset, TProperty[\"schema\"]>\n readonly unit: StringDatasetColumnNameOf<TDataset>\n }\n\ntype TelemetryProjectionPropertiesMapping<\n TObjectType extends ObjectType,\n TDataset extends DatasetDefinition,\n> = {\n readonly [TPropertyId in TelemetryPropertyIdOf<TObjectType>]?: TelemetryProjectionPropertyInput<\n TelemetryPropertyById<TObjectType, TPropertyId>,\n TDataset\n >\n}\n\ntype ExactTelemetryProjectionPropertiesMapping<\n TObjectType extends ObjectType,\n TMapping,\n> = TMapping & {\n readonly [TKey in Exclude<keyof TMapping, TelemetryPropertyIdOf<TObjectType>>]: never\n}\n\ntype ExactTelemetryProjectionPropertyInputs<TMapping> = {\n readonly [TPropertyId in keyof TMapping]: TMapping[TPropertyId] extends object\n ? TMapping[TPropertyId] & {\n readonly [TKey in Exclude<keyof TMapping[TPropertyId], \"value\" | \"unit\">]: never\n }\n : TMapping[TPropertyId]\n}\n\ntype NonEmptyTelemetryProjectionProperties<TMapping> = keyof TMapping extends never\n ? never\n : TMapping\n\ntype TelemetryProjectionPropertiesPointMapping<\n TObjectType extends ObjectType,\n TDataset extends DatasetDefinition,\n TProperties,\n> = {\n readonly objectId: StringDatasetColumnNameOf<TDataset>\n readonly at: DateLikeDatasetColumnNameOf<TDataset>\n readonly properties: NonEmptyTelemetryProjectionProperties<\n ExactTelemetryProjectionPropertiesMapping<TObjectType, TProperties> &\n ExactTelemetryProjectionPropertyInputs<TProperties>\n >\n}\n\ntype ForeignKeyFromSourceProperty = Omit<\n ForeignKeyDescriptor,\n \"sourcePropertyId\" | \"sourceField\"\n> & {\n readonly sourcePropertyId: string\n readonly sourceField?: never\n}\n\ntype ForeignKeyFromSourceField<TSourceField extends string = string> = Omit<\n ForeignKeyDescriptor,\n \"sourcePropertyId\" | \"sourceField\"\n> & {\n readonly sourcePropertyId?: never\n readonly sourceField: TSourceField\n}\n\ntype ProjectionForeignKeyDescriptor<TDataset extends DatasetDefinition> =\n | ForeignKeyFromSourceProperty\n | ForeignKeyFromSourceField<StringDatasetColumnNameOf<TDataset>>\n\ntype ProjectionForeignKeyTokenInput<\n TObjectType extends ObjectType,\n TDataset extends DatasetDefinition,\n TLinkId extends LinkIdOf<TObjectType>,\n> =\n | {\n readonly link: LinkToken<\n TObjectType[\"id\"],\n TLinkId,\n SingleTargetIdOf<LinkById<TObjectType, TLinkId>>\n >\n readonly sourceProperty: PropertyToken<TObjectType[\"id\"]>\n readonly target: ObjectType &\n (\n | { id: NoInfer<SingleTargetIdOf<LinkById<TObjectType, TLinkId>>> }\n | { extends: NoInfer<SingleTargetIdOf<LinkById<TObjectType, TLinkId>>> }\n )\n }\n | {\n readonly link: LinkToken<\n TObjectType[\"id\"],\n TLinkId,\n SingleTargetIdOf<LinkById<TObjectType, TLinkId>>\n >\n readonly sourceField: StringDatasetColumnNameOf<TDataset>\n readonly target: ObjectType &\n (\n | { id: NoInfer<SingleTargetIdOf<LinkById<TObjectType, TLinkId>>> }\n | { extends: NoInfer<SingleTargetIdOf<LinkById<TObjectType, TLinkId>>> }\n )\n }\n\nexport type ProjectionForeignKeyInput<\n TObjectType extends ObjectType,\n TDataset extends DatasetDefinition,\n TLinkId extends LinkIdOf<TObjectType>,\n> =\n | ProjectionForeignKeyDescriptor<TDataset>\n | ProjectionForeignKeyTokenInput<TObjectType, TDataset, TLinkId>\n\nfunction lowerForeignKeyMapping<TObjectType extends ObjectType, TDataset extends DatasetDefinition>(\n mapping: {\n [K in LinkIdOf<TObjectType>]?: ProjectionForeignKeyInput<TObjectType, TDataset, K>\n }\n): Record<string, ForeignKeyDescriptor> {\n const lowered: Record<string, ForeignKeyDescriptor> = {}\n for (const [linkId, descriptor] of Object.entries(mapping)) {\n if (!descriptor) continue\n lowered[linkId] = isForeignKeyDescriptor(descriptor)\n ? descriptor\n : fromForeignKey(descriptor as Parameters<typeof fromForeignKey>[0])\n }\n return lowered\n}\n\nfunction isForeignKeyDescriptor(value: unknown): value is ForeignKeyDescriptor {\n return isRecord(value) && typeof value.linkId === \"string\"\n}\n\n// ── defineProjection ─────────────────────────────────────────\n\ninterface ObjectTypeProjectionSourceBuilder<TObjectType extends ObjectType> {\n fromDataset<const TDataset extends DatasetDefinition>(\n dataset: TDataset\n ): ObjectTypeProjectionDatasetBuilder<TObjectType, TDataset>\n}\n\ninterface ObjectTypeProjectionDatasetBuilder<\n TObjectType extends ObjectType,\n TDataset extends DatasetDefinition,\n> {\n properties<const TMapping extends ProjectionMappingFor<TObjectType, TDataset>>(\n mapping: ExactProjectionMapping<TObjectType, TMapping>\n ): ObjectProjectionBuilder<TObjectType, TDataset>\n points<const TProperties extends TelemetryProjectionPropertiesMapping<TObjectType, TDataset>>(\n mapping: TelemetryProjectionPropertiesPointMapping<TObjectType, TDataset, TProperties>\n ): TelemetryProjectionDefinition\n}\n\nexport type ObjectProjectionConflictResolution<TDataset extends DatasetDefinition> =\n | { readonly strategy: \"editsWin\" }\n | {\n readonly strategy: \"mostRecent\"\n readonly sourceTimestamp: TimestampDatasetColumnNameOf<TDataset>\n }\n\nexport interface ObjectProjectionBuilder<\n TObjectType extends ObjectType,\n TDataset extends DatasetDefinition,\n> extends ObjectProjectionDefinition {\n readonly conflictResolution: SourceEditConflictResolution\n withLinks(\n mapping: { [K in LinkIdOf<TObjectType>]?: ProjectionForeignKeyInput<TObjectType, TDataset, K> }\n ): ObjectProjectionBuilder<TObjectType, TDataset>\n resolveConflicts(\n resolution: ObjectProjectionConflictResolution<TDataset>\n ): ObjectProjectionBuilder<TObjectType, TDataset>\n}\n\n/**\n * Defines an object, link, or telemetry projection from its ontology target.\n *\n * ```ts\n * defineProjection(\"room-projection\", Room)\n * .fromDataset(canonicalRoomsDataset)\n * .properties({ id: \"room_id\", name: \"room_name\" })\n * .withLinks({\n * inBuilding: {\n * link: Room.l.inBuilding,\n * sourceField: \"building_id\",\n * target: Building,\n * },\n * })\n * ```\n */\nexport function defineProjection<const TObjectType extends ObjectType>(\n id: string,\n objectType: TObjectType\n): ObjectTypeProjectionSourceBuilder<TObjectType>\nexport function defineProjection<\n TObjectTypeId extends string,\n TLinkId extends string,\n TTargetObjectTypeId extends string,\n>(\n id: string,\n linkToken: LinkToken<TObjectTypeId, TLinkId, TTargetObjectTypeId>\n): LinkProjectionSourceBuilder\nexport function defineProjection<const TPropertyToken extends TelemetryPropertyToken>(\n id: string,\n propertyToken: TPropertyToken\n): TelemetryProjectionSourceBuilder<TPropertyToken>\nexport function defineProjection(\n id: string,\n target: ObjectType | LinkToken<string, string, string> | TelemetryPropertyToken\n):\n | ObjectTypeProjectionSourceBuilder<ObjectType>\n | LinkProjectionSourceBuilder\n | TelemetryProjectionSourceBuilder<TelemetryPropertyToken> {\n if (\"link\" in target) return buildLinkProjection(id, target)\n if (\"property\" in target) return buildTelemetryProjection(id, target)\n return buildObjectTypeProjection(id, target)\n}\n\nfunction buildObjectTypeProjection<const TObjectType extends ObjectType>(\n id: string,\n objectType: TObjectType\n): ObjectTypeProjectionSourceBuilder<TObjectType> {\n assertNonEmpty(id, \"id\")\n\n return {\n fromDataset<const TDataset extends DatasetDefinition>(\n dataset: TDataset\n ): ObjectTypeProjectionDatasetBuilder<TObjectType, TDataset> {\n assertProjectionDataset(dataset)\n const datasetId = dataset.id\n\n return {\n properties<const TMapping extends ProjectionMappingFor<TObjectType, TDataset>>(\n mapping: ExactProjectionMapping<TObjectType, TMapping>\n ): ObjectProjectionBuilder<TObjectType, TDataset> {\n const propertyMapping = mapping as Record<string, string>\n validatePropertyMapping(objectType, propertyMapping)\n\n return objectProjectionBuilder({\n id,\n objectType,\n datasetId,\n propertyMapping,\n links: {},\n conflictResolution: { strategy: \"editsWin\" },\n })\n },\n points<\n const TProperties extends TelemetryProjectionPropertiesMapping<TObjectType, TDataset>,\n >(\n mapping: TelemetryProjectionPropertiesPointMapping<TObjectType, TDataset, TProperties>\n ): TelemetryProjectionDefinition {\n const pointMapping = lowerTelemetryPropertiesPointMapping(\n objectType,\n mapping as {\n readonly objectId?: string\n readonly at?: string\n readonly properties?: Readonly<Record<string, unknown>>\n }\n )\n return {\n _tag: \"TelemetryProjectionDefinition\",\n id,\n objectTypeId: objectType.id,\n datasetId,\n objectIdField: pointMapping.objectId,\n atField: pointMapping.at,\n properties: pointMapping.properties,\n }\n },\n }\n },\n }\n}\n\nfunction objectProjectionBuilder<\n TObjectType extends ObjectType,\n TDataset extends DatasetDefinition,\n>(input: {\n readonly id: string\n readonly objectType: TObjectType\n readonly datasetId: string\n readonly propertyMapping: Readonly<Record<string, string>>\n readonly links: Readonly<Record<string, ForeignKeyDescriptor>>\n readonly conflictResolution: SourceEditConflictResolution\n}): ObjectProjectionBuilder<TObjectType, TDataset> {\n const definition: ObjectProjectionDefinition & {\n readonly conflictResolution: SourceEditConflictResolution\n } = {\n _tag: \"ObjectProjectionDefinition\",\n id: input.id,\n objectTypeId: input.objectType.id,\n datasetId: input.datasetId,\n properties: { ...input.propertyMapping },\n links: { ...input.links },\n conflictResolution: { ...input.conflictResolution },\n }\n\n return Object.assign(definition, {\n withLinks(\n linkMapping: {\n [K in LinkIdOf<TObjectType>]?: ProjectionForeignKeyInput<TObjectType, TDataset, K>\n }\n ): ObjectProjectionBuilder<TObjectType, TDataset> {\n const loweredLinkMapping = lowerForeignKeyMapping(linkMapping)\n const validatedLinks = validateAndLowerLinkMapping(\n input.objectType,\n loweredLinkMapping,\n input.propertyMapping as Record<string, string>\n )\n return objectProjectionBuilder({ ...input, links: validatedLinks })\n },\n resolveConflicts(\n resolution: ObjectProjectionConflictResolution<TDataset>\n ): ObjectProjectionBuilder<TObjectType, TDataset> {\n validateConflictResolution(resolution)\n return objectProjectionBuilder({\n ...input,\n conflictResolution: resolution as SourceEditConflictResolution,\n })\n },\n })\n}\n\nfunction validateConflictResolution(resolution: SourceEditConflictResolution): void {\n if (resolution.strategy === \"editsWin\") return\n assertNonEmpty(resolution.sourceTimestamp, \"source timestamp field\")\n}\n\n// ── Telemetry projection ────────────────────────────────────\n\ninterface TelemetryProjectionSourceBuilder<TPropertyToken extends TelemetryPropertyToken> {\n fromDataset<const TDataset extends DatasetDefinition>(\n dataset: TDataset\n ): TelemetryProjectionMappingBuilder<TPropertyToken, TDataset>\n}\n\ninterface TelemetryProjectionMappingBuilder<\n TPropertyToken extends TelemetryPropertyToken,\n TDataset extends DatasetDefinition,\n> {\n points<const TMapping extends TelemetryProjectionPointMapping<TPropertyToken, TDataset>>(\n mapping: ExactTelemetryProjectionPointMapping<TMapping>\n ): TelemetryProjectionDefinition\n}\n\n/**\n * Fluent builder for {@link TelemetryProjectionDefinition}.\n *\n * ```ts\n * defineProjection(\"room-temperatures\", Room.p.temperature)\n * .fromDataset(roomReadingsDataset)\n * .points({\n * objectId: \"room_id\",\n * at: \"observed_at\",\n * value: \"temperature\",\n * unit: \"unit\",\n * })\n * ```\n */\nfunction buildTelemetryProjection<const TPropertyToken extends TelemetryPropertyToken>(\n id: string,\n propertyToken: TPropertyToken\n): TelemetryProjectionSourceBuilder<TPropertyToken> {\n assertNonEmpty(id, \"id\")\n validateTelemetryProjectionProperty(propertyToken)\n\n return {\n fromDataset<const TDataset extends DatasetDefinition>(\n dataset: TDataset\n ): TelemetryProjectionMappingBuilder<TPropertyToken, TDataset> {\n assertProjectionDataset(dataset)\n const datasetId = dataset.id\n\n return {\n points<const TMapping extends TelemetryProjectionPointMapping<TPropertyToken, TDataset>>(\n mapping: ExactTelemetryProjectionPointMapping<TMapping>\n ): TelemetryProjectionDefinition {\n const pointMapping = lowerTelemetryPointMapping(mapping)\n return {\n _tag: \"TelemetryProjectionDefinition\",\n id,\n objectTypeId: propertyToken.objectTypeId,\n datasetId,\n objectIdField: pointMapping.objectId,\n atField: pointMapping.at,\n properties: {\n [propertyToken.id]: {\n valueField: pointMapping.value,\n ...(pointMapping.unit !== undefined ? { unitField: pointMapping.unit } : {}),\n },\n },\n }\n },\n }\n },\n }\n}\n\nfunction validateTelemetryProjectionProperty(propertyToken: PropertyToken): void {\n if (propertyToken.property.mode !== \"telemetry\") {\n throw new ProjectionValidationError(\n `Projection property '${propertyToken.objectTypeId}.${propertyToken.id}' must be telemetry-enabled.`\n )\n }\n}\n\nfunction lowerTelemetryPointMapping(mapping: {\n readonly objectId?: string\n readonly at?: string\n readonly value?: string\n readonly unit?: string\n}): {\n readonly objectId: string\n readonly at: string\n readonly value: string\n readonly unit?: string\n} {\n const allowedKeys = new Set([\"objectId\", \"at\", \"value\", \"unit\"])\n for (const key of Object.keys(mapping)) {\n if (!allowedKeys.has(key)) {\n throw new ProjectionValidationError(\n `Telemetry projection point mapping contains unknown key '${key}'.`\n )\n }\n }\n\n if (mapping.objectId === undefined) {\n throw new ProjectionValidationError(\"Telemetry projection point mapping requires objectId.\")\n }\n if (mapping.at === undefined) {\n throw new ProjectionValidationError(\"Telemetry projection point mapping requires at.\")\n }\n if (mapping.value === undefined) {\n throw new ProjectionValidationError(\"Telemetry projection point mapping requires value.\")\n }\n\n assertNonEmpty(mapping.objectId, \"objectId field\")\n assertNonEmpty(mapping.at, \"at field\")\n assertNonEmpty(mapping.value, \"value field\")\n if (mapping.unit !== undefined) {\n assertNonEmpty(mapping.unit, \"unit field\")\n }\n\n return {\n objectId: mapping.objectId,\n at: mapping.at,\n value: mapping.value,\n ...(mapping.unit !== undefined ? { unit: mapping.unit } : {}),\n }\n}\n\nfunction lowerTelemetryPropertiesPointMapping(\n objectType: ObjectType,\n mapping: {\n readonly objectId?: string\n readonly at?: string\n readonly properties?: Readonly<Record<string, unknown>>\n }\n): {\n readonly objectId: string\n readonly at: string\n readonly properties: Readonly<Record<string, TelemetryProjectionPropertyMapping>>\n} {\n const allowedKeys = new Set([\"objectId\", \"at\", \"properties\"])\n for (const key of Object.keys(mapping)) {\n if (!allowedKeys.has(key)) {\n throw new ProjectionValidationError(\n `Telemetry projection point mapping contains unknown key '${key}'.`\n )\n }\n }\n\n if (mapping.objectId === undefined) {\n throw new ProjectionValidationError(\"Telemetry projection point mapping requires objectId.\")\n }\n if (mapping.at === undefined) {\n throw new ProjectionValidationError(\"Telemetry projection point mapping requires at.\")\n }\n if (mapping.properties === undefined) {\n throw new ProjectionValidationError(\"Telemetry projection point mapping requires properties.\")\n }\n if (!isRecord(mapping.properties)) {\n throw new ProjectionValidationError(\n \"Telemetry projection point mapping properties must be an object.\"\n )\n }\n\n assertNonEmpty(mapping.objectId, \"objectId field\")\n assertNonEmpty(mapping.at, \"at field\")\n\n const propertyEntries = Object.entries(mapping.properties)\n if (propertyEntries.length === 0) {\n throw new ProjectionValidationError(\n \"Telemetry projection point mapping requires at least one property.\"\n )\n }\n\n const propertiesById = new Map(objectType.properties.map((property) => [property.id, property]))\n const properties: Record<string, TelemetryProjectionPropertyMapping> = {}\n for (const [propertyId, input] of propertyEntries) {\n const property = propertiesById.get(propertyId)\n if (!property) {\n throw new ProjectionValidationError(\n `Property '${propertyId}' does not exist on object type '${objectType.id}'.`\n )\n }\n if (property.mode !== \"telemetry\") {\n throw new ProjectionValidationError(\n `Projection property '${objectType.id}.${propertyId}' must be telemetry-enabled.`\n )\n }\n properties[propertyId] = lowerTelemetryPropertyMapping(propertyId, input)\n }\n\n return { objectId: mapping.objectId, at: mapping.at, properties }\n}\n\nfunction lowerTelemetryPropertyMapping(\n propertyId: string,\n input: unknown\n): TelemetryProjectionPropertyMapping {\n if (typeof input === \"string\") {\n assertNonEmpty(input, `property '${propertyId}' value field`)\n return { valueField: input }\n }\n if (!isRecord(input)) {\n throw new ProjectionValidationError(\n `Telemetry projection property '${propertyId}' must map a value column or value/unit columns.`\n )\n }\n\n const allowedKeys = new Set([\"value\", \"unit\"])\n for (const key of Object.keys(input)) {\n if (!allowedKeys.has(key)) {\n throw new ProjectionValidationError(\n `Telemetry projection property '${propertyId}' contains unknown key '${key}'.`\n )\n }\n }\n if (typeof input.value !== \"string\") {\n throw new ProjectionValidationError(\n `Telemetry projection property '${propertyId}' requires a value field.`\n )\n }\n if (typeof input.unit !== \"string\") {\n throw new ProjectionValidationError(\n `Telemetry projection property '${propertyId}' requires a unit field.`\n )\n }\n assertNonEmpty(input.value, `property '${propertyId}' value field`)\n assertNonEmpty(input.unit, `property '${propertyId}' unit field`)\n return { valueField: input.value, unitField: input.unit }\n}\n\n// ── fromForeignKey ───────────────────────────────────────────\n\n/**\n * Creates a {@link ForeignKeyDescriptor} from typed tokens.\n *\n * Compile-time constraints:\n * - `TObjectTypeId` ties `link` and `sourceProperty` to the same object type\n * when a projected source property is used.\n * - `TTargetObjectTypeId` (inferred from the link token) constrains `target`\n * to an ObjectType whose `id` or `extends` matches the link's declared target.\n * This covers exact type match and direct subtypes. Multi-level inheritance\n * is validated at Sixb startup when the full type graph is available.\n *\n * ```ts\n * fromForeignKey({\n * link: Room.l.inBuilding,\n * sourceProperty: Room.p.buildingRef,\n * target: Building,\n * })\n * ```\n */\nexport function fromForeignKey<\n TObjectTypeId extends string,\n TTargetObjectTypeId extends string,\n>(input: {\n link: LinkToken<TObjectTypeId, string, TTargetObjectTypeId>\n sourceProperty: PropertyToken<TObjectTypeId>\n target: ObjectType &\n ({ id: NoInfer<TTargetObjectTypeId> } | { extends: NoInfer<TTargetObjectTypeId> })\n}): ForeignKeyFromSourceProperty\nexport function fromForeignKey<\n TObjectTypeId extends string,\n TTargetObjectTypeId extends string,\n const TSourceField extends string,\n>(input: {\n link: LinkToken<TObjectTypeId, string, TTargetObjectTypeId>\n sourceField: TSourceField\n target: ObjectType &\n ({ id: NoInfer<TTargetObjectTypeId> } | { extends: NoInfer<TTargetObjectTypeId> })\n}): ForeignKeyFromSourceField<TSourceField>\nexport function fromForeignKey<\n TObjectTypeId extends string,\n TTargetObjectTypeId extends string,\n>(input: {\n link: LinkToken<TObjectTypeId, string, TTargetObjectTypeId>\n sourceProperty?: PropertyToken<TObjectTypeId>\n sourceField?: string\n target: ObjectType &\n ({ id: NoInfer<TTargetObjectTypeId> } | { extends: NoInfer<TTargetObjectTypeId> })\n}): ForeignKeyDescriptor {\n validateLinkProjectionTarget(input.link)\n\n if (input.sourceProperty) {\n return {\n linkId: input.link.id,\n sourcePropertyId: input.sourceProperty.id,\n targetObjectTypeId: input.target.id,\n }\n }\n\n if (input.sourceField === undefined) {\n throw new ProjectionValidationError(\"Foreign key sourceField is required.\")\n }\n assertNonEmpty(input.sourceField, \"source field\")\n return {\n linkId: input.link.id,\n sourceField: input.sourceField,\n targetObjectTypeId: input.target.id,\n }\n}\n\n// ── Link projection ─────────────────────────────────────────\n\ninterface LinkProjectionSourceBuilder {\n fromDataset<const TDataset extends DatasetDefinition>(\n dataset: TDataset\n ): LinkProjectionFieldBuilder<TDataset>\n}\n\ninterface LinkProjectionFieldBuilder<TDataset extends DatasetDefinition> {\n sourceField(\n columnName: StringDatasetColumnNameOf<TDataset>\n ): LinkProjectionTargetBuilder<TDataset>\n}\n\ninterface LinkProjectionTargetBuilder<TDataset extends DatasetDefinition> {\n targetField(columnName: StringDatasetColumnNameOf<TDataset>): LinkProjectionDefinition\n}\n\n/**\n * Fluent builder for {@link LinkProjectionDefinition} (many-to-many join datasets).\n *\n * ```ts\n * defineProjection(\"room-sensor-links\", Room.l.hasSensors)\n * .fromDataset(roomSensorsDataset)\n * .sourceField(\"room_id\")\n * .targetField(\"sensor_id\")\n * ```\n */\nfunction buildLinkProjection<\n TObjectTypeId extends string,\n TLinkId extends string,\n TTargetObjectTypeId extends string,\n>(\n id: string,\n linkToken: LinkToken<TObjectTypeId, TLinkId, TTargetObjectTypeId>\n): LinkProjectionSourceBuilder {\n assertNonEmpty(id, \"id\")\n validateLinkProjectionTarget(linkToken)\n\n return {\n fromDataset<const TDataset extends DatasetDefinition>(\n dataset: TDataset\n ): LinkProjectionFieldBuilder<TDataset> {\n assertProjectionDataset(dataset)\n const datasetId = dataset.id\n\n return {\n sourceField(\n columnName: StringDatasetColumnNameOf<TDataset>\n ): LinkProjectionTargetBuilder<TDataset> {\n assertNonEmpty(columnName, \"source field\")\n\n return {\n targetField(\n targetColumnName: StringDatasetColumnNameOf<TDataset>\n ): LinkProjectionDefinition {\n assertNonEmpty(targetColumnName, \"target field\")\n\n return {\n _tag: \"LinkProjectionDefinition\",\n id,\n linkId: linkToken.id,\n sourceObjectTypeId: linkToken.objectTypeId,\n targetObjectTypeId: linkToken.targetObjectTypeId as string,\n datasetId,\n sourceField: columnName,\n targetField: targetColumnName,\n }\n },\n }\n },\n }\n },\n }\n}\n\n// ── Type guards ──────────────────────────────────────────────\n\n/** Runtime type guard for {@link ObjectProjectionDefinition}. */\nexport function isObjectProjectionDefinition(value: unknown): value is ObjectProjectionDefinition {\n if (!isRecord(value)) return false\n return (\n value._tag === \"ObjectProjectionDefinition\" &&\n typeof value.id === \"string\" &&\n typeof value.objectTypeId === \"string\" &&\n typeof value.datasetId === \"string\" &&\n isRecord(value.properties) &&\n isRecord(value.links) &&\n isSourceEditConflictResolution(value.conflictResolution)\n )\n}\n\nfunction isSourceEditConflictResolution(value: unknown): boolean {\n if (value === undefined) return true\n if (!isRecord(value) || typeof value.strategy !== \"string\") return false\n if (value.strategy === \"editsWin\") return value.sourceTimestamp === undefined\n return value.strategy === \"mostRecent\" && typeof value.sourceTimestamp === \"string\"\n}\n\n/** Runtime type guard for {@link LinkProjectionDefinition}. */\nexport function isLinkProjectionDefinition(value: unknown): value is LinkProjectionDefinition {\n if (!isRecord(value)) return false\n return (\n value._tag === \"LinkProjectionDefinition\" &&\n typeof value.id === \"string\" &&\n typeof value.linkId === \"string\" &&\n typeof value.sourceObjectTypeId === \"string\" &&\n typeof value.targetObjectTypeId === \"string\" &&\n typeof value.datasetId === \"string\" &&\n typeof value.sourceField === \"string\" &&\n typeof value.targetField === \"string\"\n )\n}\n\n/** Runtime type guard for {@link TelemetryProjectionDefinition}. */\nexport function isTelemetryProjectionDefinition(\n value: unknown\n): value is TelemetryProjectionDefinition {\n if (!isRecord(value)) return false\n return (\n value._tag === \"TelemetryProjectionDefinition\" &&\n typeof value.id === \"string\" &&\n typeof value.objectTypeId === \"string\" &&\n typeof value.datasetId === \"string\" &&\n typeof value.objectIdField === \"string\" &&\n typeof value.atField === \"string\" &&\n isTelemetryProjectionProperties(value.properties)\n )\n}\n\nfunction isTelemetryProjectionProperties(value: unknown): boolean {\n if (!isRecord(value) || Object.keys(value).length === 0) return false\n return Object.values(value).every(\n (mapping) =>\n isRecord(mapping) &&\n typeof mapping.valueField === \"string\" &&\n (mapping.unitField === undefined || typeof mapping.unitField === \"string\")\n )\n}\n\n/** Runtime type guard for any {@link ProjectionDefinition}. */\nexport function isProjectionDefinition(value: unknown): value is ProjectionDefinition {\n return (\n isObjectProjectionDefinition(value) ||\n isLinkProjectionDefinition(value) ||\n isTelemetryProjectionDefinition(value)\n )\n}\n\n/**\n * Extracts the object type id(s) a projection targets, used to authorize run\n * visibility (`object.view`). Link projections require both ends; object and\n * telemetry projections target a single type.\n */\nexport function projectionTargetOf(projection: LinkProjectionDefinition): LinkProjectionTarget\nexport function projectionTargetOf(\n projection: ObjectProjectionDefinition | TelemetryProjectionDefinition\n): ObjectProjectionTarget\nexport function projectionTargetOf(projection: ProjectionDefinition): ProjectionTarget\nexport function projectionTargetOf(projection: ProjectionDefinition): ProjectionTarget {\n return projection._tag === \"LinkProjectionDefinition\"\n ? {\n sourceObjectTypeId: projection.sourceObjectTypeId,\n targetObjectTypeId: projection.targetObjectTypeId,\n }\n : { objectTypeId: projection.objectTypeId }\n}\n\n// ── Categorization ──────────────────────────────────────────\n\n/** Splits a mixed list of projection definitions into typed arrays by tag. */\nexport function categorizeProjections(projections: readonly ProjectionDefinition[]): {\n objectProjections: ObjectProjectionDefinition[]\n linkProjections: LinkProjectionDefinition[]\n telemetryProjections: TelemetryProjectionDefinition[]\n} {\n const objectProjections: ObjectProjectionDefinition[] = []\n const linkProjections: LinkProjectionDefinition[] = []\n const telemetryProjections: TelemetryProjectionDefinition[] = []\n for (const projection of projections) {\n if (isObjectProjectionDefinition(projection)) {\n objectProjections.push(projection)\n } else if (isLinkProjectionDefinition(projection)) {\n linkProjections.push(projection)\n } else if (isTelemetryProjectionDefinition(projection)) {\n telemetryProjections.push(projection)\n }\n }\n return { objectProjections, linkProjections, telemetryProjections }\n}\n",
17
17
  "import type { ProjectionDefinition, ProjectionTarget } from \"../projections\"\nimport { projectionTargetOf } from \"../projections/builders\"\nimport type { ActionRunRecord } from \"../storage/action-runs\"\nimport type { PipelineRunRecord } from \"../storage/pipeline-runs\"\nimport type { WorkflowInterventionRecord } from \"../storage/workflow-interventions\"\nimport type { WorkflowRunRecord } from \"../storage/workflow-runs\"\nimport { isAllowed } from \"./decision\"\nimport type { AuthorizationContext } from \"./types\"\n\nexport function canViewActionRun(\n authorization: AuthorizationContext | null | undefined,\n run: Pick<ActionRunRecord, \"actionId\" | \"subject\">\n): boolean {\n if (!authorization) {\n return true\n }\n\n if (!isAllowed(authorization, { kind: \"action.apply\", actionId: run.actionId })) {\n return false\n }\n\n return run.subject.kind !== \"object\"\n ? true\n : isAllowed(authorization, {\n kind: \"object.view\",\n objectTypeId: run.subject.objectTypeId,\n })\n}\n\nexport function canViewWorkflowRun(\n authorization: AuthorizationContext | null | undefined,\n run: Pick<WorkflowRunRecord, \"workflowId\">\n): boolean {\n return (\n !authorization || isAllowed(authorization, { kind: \"workflow.run\", workflowId: run.workflowId })\n )\n}\n\nexport function canViewWorkflowIntervention(\n authorization: AuthorizationContext | null | undefined,\n intervention: Pick<WorkflowInterventionRecord, \"workflowId\">\n): boolean {\n return (\n !authorization ||\n isAllowed(authorization, { kind: \"workflow.run\", workflowId: intervention.workflowId })\n )\n}\n\nexport function canViewPipelineRun(\n authorization: AuthorizationContext | null | undefined,\n run: Pick<PipelineRunRecord, \"pipelineId\">\n): boolean {\n return (\n !authorization || isAllowed(authorization, { kind: \"pipeline.run\", pipelineId: run.pipelineId })\n )\n}\n\n/** A projection run is viewable when its target object type(s) are viewable. */\nexport function canViewProjectionRun(\n authorization: AuthorizationContext | null | undefined,\n target: ProjectionTarget\n): boolean {\n if (!authorization) return true\n const canView = (objectTypeId: string) =>\n isAllowed(authorization, { kind: \"object.view\", objectTypeId })\n if (\"sourceObjectTypeId\" in target) {\n return canView(target.sourceObjectTypeId) && canView(target.targetObjectTypeId)\n }\n return canView(target.objectTypeId)\n}\n\n/** Whether a principal may see a projection definition (and its run history). */\nexport function canViewProjection(\n authorization: AuthorizationContext | null | undefined,\n projection: ProjectionDefinition\n): boolean {\n return canViewProjectionRun(authorization, projectionTargetOf(projection))\n}\n",
18
- "/**\n * Authorization context types.\n *\n * The context is plain, immutable data resolved once per request\n * (`principal -> groups -> roles -> grants`). Grants resolve eagerly into set\n * lookups so enforcement on the hot path is synchronous and allocation-free.\n * Group and role ids are retained so decisions stay explainable.\n */\n\nimport type { Principal } from \"../auth/types\"\nimport { emptyGrantSets, type GrantKind } from \"./grant-kinds\"\n\n/**\n * Grants resolved to concrete id sets, keyed by grant kind (`view:object`,\n * `run:sync`, …). Broad grants and object subtypes are already expanded, so\n * enforcement is a single `grants[kind].has(id)` lookup. Keyed by `GrantKind`\n * so a new grant family adds one key, not a new bucket every consumer must\n * learn.\n */\nexport type GrantIndex = Readonly<Record<GrantKind, ReadonlySet<string>>>\n\n/**\n * A grant index that grants nothing, as the base for a hand-built context — typically in tests.\n *\n * This is the read-only face of `emptyGrantSets()`, the mutable builder resolution fills in and which\n * stays internal. A factory rather than a shared constant, because the sets are only `ReadonlySet` to\n * the type system: one frozen instance would be aliased into every context that spreads it.\n *\n * Writing the literal by hand is what this avoids. `GrantIndex` is deliberately a total `Record` so\n * that `grants[kind].has(id)` cannot be misspelled into a silent `undefined` — with an optional index\n * every enforcement site would read `?.has(id) ?? false`, where a typo denies instead of failing to\n * compile. The cost of totality is that a literal breaks whenever a grant family is added.\n */\nexport function emptyGrantIndex(): GrantIndex {\n return emptyGrantSets()\n}\n\n/** A role with its grants pre-expanded to concrete id sets at startup. */\nexport interface ResolvedRole {\n readonly id: string\n readonly grantedToGroupIds: readonly string[]\n readonly grants: GrantIndex\n}\n\nexport interface AuthorizationContext {\n readonly principal: Principal\n readonly sessionId?: string\n readonly groupIds: readonly string[]\n /** Roles whose grantedTo groups intersect the principal's memberships. */\n readonly roleIds: readonly string[]\n readonly grants: GrantIndex\n}\n"
18
+ "/**\n * Authorization context types.\n *\n * The context is plain, immutable data resolved once per request\n * (`principal -> groups -> roles -> grants`). Grants resolve eagerly into set\n * lookups so enforcement on the hot path is synchronous and allocation-free.\n * Group and role ids are retained so decisions stay explainable.\n */\n\nimport type { Principal } from \"../auth/types\"\nimport { emptyGrantSets, type GrantKind, type SingletonGrantKind } from \"./grant-kinds\"\n\n/**\n * Grants keyed by kind (`view:object`, `run:sync`, …). Resource selections resolve\n * to id sets; project-wide singleton capabilities resolve to booleans.\n * Broad grants and object subtypes are already expanded. Keyed by `GrantKind`\n * so a new grant family adds one key, not a new bucket every consumer must\n * learn.\n */\nexport type GrantIndex = Readonly<{\n [TKind in GrantKind]: TKind extends SingletonGrantKind ? boolean : ReadonlySet<string>\n}>\n\n/**\n * A grant index that grants nothing, as the base for a hand-built context — typically in tests.\n *\n * This is the read-only face of `emptyGrantSets()`, the mutable builder resolution fills in and which\n * stays internal. A factory rather than a shared constant, because the sets are only `ReadonlySet` to\n * the type system: one frozen instance would be aliased into every context that spreads it.\n *\n * Writing the literal by hand is what this avoids. `GrantIndex` is deliberately a total `Record` so\n * that `grants[kind].has(id)` cannot be misspelled into a silent `undefined` — with an optional index\n * every enforcement site would read `?.has(id) ?? false`, where a typo denies instead of failing to\n * compile. The cost of totality is that a literal breaks whenever a grant family is added.\n */\nexport function emptyGrantIndex(): GrantIndex {\n return emptyGrantSets()\n}\n\n/** A role with its grants pre-expanded to concrete id sets at startup. */\nexport interface ResolvedRole {\n readonly id: string\n readonly grantedToGroupIds: readonly string[]\n readonly grants: GrantIndex\n}\n\nexport interface AuthorizationContext {\n readonly principal: Principal\n readonly sessionId?: string\n readonly groupIds: readonly string[]\n /** Roles whose grantedTo groups intersect the principal's memberships. */\n readonly roleIds: readonly string[]\n readonly grants: GrantIndex\n}\n"
19
19
  ],
20
- "mappings": ";;;;;;;;;;;;AA2DO,IAAM,cAAgD;AAAA,EAC3D,sBAAsB;AAAA,IACpB,aAAa;AAAA,IACb,SAAS;AAAA,IACT,KAAK;AAAA,EACP;AAAA,EACA,eAAe;AAAA,IACb,aAAa;AAAA,IACb,SAAS;AAAA,IACT,KAAK;AAAA,IACL,iBAAiB;AAAA,EACnB;AAAA,EACA,gBAAgB;AAAA,IACd,aAAa;AAAA,IACb,SAAS;AAAA,IACT,KAAK;AAAA,EACP;AAAA,EAIA,eAAe;AAAA,IACb,aAAa;AAAA,IACb,SAAS;AAAA,IACT,KAAK;AAAA,EACP;AAAA,EACA,oBAAoB;AAAA,IAClB,aAAa;AAAA,IACb,SAAS;AAAA,IACT,KAAK;AAAA,EACP;AAAA,EACA,gBAAgB;AAAA,IACd,aAAa;AAAA,IACb,SAAS;AAAA,IACT,KAAK;AAAA,EACP;AAAA,EACA,gBAAgB;AAAA,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