@stigmer/server 3.40.1 → 3.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (527) hide show
  1. package/dist/authorization/authorizer.d.ts +16 -10
  2. package/dist/authorization/authorizer.d.ts.map +1 -1
  3. package/dist/authorization/authorizer.js +17 -9
  4. package/dist/authorization/authorizer.js.map +1 -1
  5. package/dist/authorization/derived-tuples.d.ts +7 -3
  6. package/dist/authorization/derived-tuples.d.ts.map +1 -1
  7. package/dist/authorization/derived-tuples.js +62 -6
  8. package/dist/authorization/derived-tuples.js.map +1 -1
  9. package/dist/authorization/evaluator.d.ts +11 -7
  10. package/dist/authorization/evaluator.d.ts.map +1 -1
  11. package/dist/authorization/evaluator.js +16 -10
  12. package/dist/authorization/evaluator.js.map +1 -1
  13. package/dist/authorization/list-read-scope.d.ts +4 -0
  14. package/dist/authorization/list-read-scope.d.ts.map +1 -1
  15. package/dist/authorization/list-read-scope.js +1 -0
  16. package/dist/authorization/list-read-scope.js.map +1 -1
  17. package/dist/authorization/model/data/authorization-model.json +830 -67
  18. package/dist/authorization/model/execution-viewer.d.ts.map +1 -1
  19. package/dist/authorization/model/execution-viewer.js +26 -24
  20. package/dist/authorization/model/execution-viewer.js.map +1 -1
  21. package/dist/authorization/model/index.d.ts +4 -1
  22. package/dist/authorization/model/index.d.ts.map +1 -1
  23. package/dist/authorization/model/index.js +4 -1
  24. package/dist/authorization/model/index.js.map +1 -1
  25. package/dist/authorization/model/rewrite.d.ts +5 -3
  26. package/dist/authorization/model/rewrite.d.ts.map +1 -1
  27. package/dist/authorization/organization-directory.d.ts +44 -0
  28. package/dist/authorization/organization-directory.d.ts.map +1 -1
  29. package/dist/authorization/organization-directory.js +1 -0
  30. package/dist/authorization/organization-directory.js.map +1 -1
  31. package/dist/authorization/person.d.ts +14 -1
  32. package/dist/authorization/person.d.ts.map +1 -1
  33. package/dist/authorization/person.js +16 -0
  34. package/dist/authorization/person.js.map +1 -1
  35. package/dist/authorization/policy-check.d.ts +52 -0
  36. package/dist/authorization/policy-check.d.ts.map +1 -0
  37. package/dist/authorization/policy-check.js +35 -0
  38. package/dist/authorization/policy-check.js.map +1 -0
  39. package/dist/authorization/posture.d.ts +30 -4
  40. package/dist/authorization/posture.d.ts.map +1 -1
  41. package/dist/authorization/posture.js +58 -0
  42. package/dist/authorization/posture.js.map +1 -1
  43. package/dist/authorization/resource-creators.d.ts +4 -0
  44. package/dist/authorization/resource-creators.d.ts.map +1 -0
  45. package/dist/authorization/resource-creators.js +44 -0
  46. package/dist/authorization/resource-creators.js.map +1 -0
  47. package/dist/authorization/trusted-local-authorizer.d.ts +9 -0
  48. package/dist/authorization/trusted-local-authorizer.d.ts.map +1 -0
  49. package/dist/authorization/trusted-local-authorizer.js +70 -0
  50. package/dist/authorization/trusted-local-authorizer.js.map +1 -0
  51. package/dist/authorization/tuples.d.ts +12 -0
  52. package/dist/authorization/tuples.d.ts.map +1 -1
  53. package/dist/authorization/tuples.js +3 -0
  54. package/dist/authorization/tuples.js.map +1 -1
  55. package/dist/boot/compose.d.ts.map +1 -1
  56. package/dist/boot/compose.js +132 -43
  57. package/dist/boot/compose.js.map +1 -1
  58. package/dist/boot/config.d.ts +22 -7
  59. package/dist/boot/config.d.ts.map +1 -1
  60. package/dist/boot/config.js +2 -1
  61. package/dist/boot/config.js.map +1 -1
  62. package/dist/boot/inprocess.d.ts.map +1 -1
  63. package/dist/boot/inprocess.js +10 -4
  64. package/dist/boot/inprocess.js.map +1 -1
  65. package/dist/boot/list-indexes.d.ts.map +1 -1
  66. package/dist/boot/list-indexes.js +6 -1
  67. package/dist/boot/list-indexes.js.map +1 -1
  68. package/dist/boot/logger.d.ts +3 -1
  69. package/dist/boot/logger.d.ts.map +1 -1
  70. package/dist/boot/logger.js +3 -1
  71. package/dist/boot/logger.js.map +1 -1
  72. package/dist/boot/oauth-redirect-uri.d.ts +33 -12
  73. package/dist/boot/oauth-redirect-uri.d.ts.map +1 -1
  74. package/dist/boot/oauth-redirect-uri.js +43 -14
  75. package/dist/boot/oauth-redirect-uri.js.map +1 -1
  76. package/dist/boot/skill-transfer-origin.d.ts +46 -14
  77. package/dist/boot/skill-transfer-origin.d.ts.map +1 -1
  78. package/dist/boot/skill-transfer-origin.js +53 -13
  79. package/dist/boot/skill-transfer-origin.js.map +1 -1
  80. package/dist/domain/agentchannel/steps.d.ts +8 -6
  81. package/dist/domain/agentchannel/steps.d.ts.map +1 -1
  82. package/dist/domain/agentchannel/steps.js +9 -7
  83. package/dist/domain/agentchannel/steps.js.map +1 -1
  84. package/dist/domain/agentexecution/controller.d.ts +7 -0
  85. package/dist/domain/agentexecution/controller.d.ts.map +1 -1
  86. package/dist/domain/agentexecution/controller.js +1 -1
  87. package/dist/domain/agentexecution/controller.js.map +1 -1
  88. package/dist/domain/agentexecution/create-steps.d.ts +26 -12
  89. package/dist/domain/agentexecution/create-steps.d.ts.map +1 -1
  90. package/dist/domain/agentexecution/create-steps.js +61 -43
  91. package/dist/domain/agentexecution/create-steps.js.map +1 -1
  92. package/dist/domain/agentexecution/submit-approval.d.ts.map +1 -1
  93. package/dist/domain/agentexecution/submit-approval.js +9 -6
  94. package/dist/domain/agentexecution/submit-approval.js.map +1 -1
  95. package/dist/domain/agentexecution/submit-file-decision.d.ts.map +1 -1
  96. package/dist/domain/agentexecution/submit-file-decision.js +5 -4
  97. package/dist/domain/agentexecution/submit-file-decision.js.map +1 -1
  98. package/dist/domain/agentshare/steps.d.ts +5 -3
  99. package/dist/domain/agentshare/steps.d.ts.map +1 -1
  100. package/dist/domain/agentshare/steps.js +6 -4
  101. package/dist/domain/agentshare/steps.js.map +1 -1
  102. package/dist/domain/apikey/verifier.d.ts +7 -0
  103. package/dist/domain/apikey/verifier.d.ts.map +1 -1
  104. package/dist/domain/apikey/verifier.js +34 -1
  105. package/dist/domain/apikey/verifier.js.map +1 -1
  106. package/dist/domain/channelapp/controller.d.ts +4 -3
  107. package/dist/domain/channelapp/controller.d.ts.map +1 -1
  108. package/dist/domain/channelapp/controller.js.map +1 -1
  109. package/dist/domain/executioncontext/steps.d.ts +2 -1
  110. package/dist/domain/executioncontext/steps.d.ts.map +1 -1
  111. package/dist/domain/executioncontext/steps.js +2 -1
  112. package/dist/domain/executioncontext/steps.js.map +1 -1
  113. package/dist/domain/iampolicy/access-lists.d.ts.map +1 -1
  114. package/dist/domain/iampolicy/access-lists.js +57 -2
  115. package/dist/domain/iampolicy/access-lists.js.map +1 -1
  116. package/dist/domain/iampolicy/change.d.ts +53 -0
  117. package/dist/domain/iampolicy/change.d.ts.map +1 -0
  118. package/dist/domain/iampolicy/change.js +44 -0
  119. package/dist/domain/iampolicy/change.js.map +1 -0
  120. package/dist/domain/iampolicy/constants.d.ts +6 -0
  121. package/dist/domain/iampolicy/constants.d.ts.map +1 -1
  122. package/dist/domain/iampolicy/constants.js +6 -0
  123. package/dist/domain/iampolicy/constants.js.map +1 -1
  124. package/dist/domain/iampolicy/controller.d.ts.map +1 -1
  125. package/dist/domain/iampolicy/controller.js +9 -5
  126. package/dist/domain/iampolicy/controller.js.map +1 -1
  127. package/dist/domain/iampolicy/grant-path.d.ts +31 -13
  128. package/dist/domain/iampolicy/grant-path.d.ts.map +1 -1
  129. package/dist/domain/iampolicy/grant-path.js +216 -19
  130. package/dist/domain/iampolicy/grant-path.js.map +1 -1
  131. package/dist/domain/iampolicy/membership.d.ts +11 -3
  132. package/dist/domain/iampolicy/membership.d.ts.map +1 -1
  133. package/dist/domain/iampolicy/membership.js +18 -13
  134. package/dist/domain/iampolicy/membership.js.map +1 -1
  135. package/dist/domain/iampolicy/resource-store.d.ts.map +1 -1
  136. package/dist/domain/iampolicy/resource-store.js +4 -0
  137. package/dist/domain/iampolicy/resource-store.js.map +1 -1
  138. package/dist/domain/iampolicy/role-lifecycle.d.ts.map +1 -1
  139. package/dist/domain/iampolicy/role-lifecycle.js +2 -2
  140. package/dist/domain/iampolicy/role-lifecycle.js.map +1 -1
  141. package/dist/domain/iampolicy/roles.d.ts.map +1 -1
  142. package/dist/domain/iampolicy/roles.js +7 -0
  143. package/dist/domain/iampolicy/roles.js.map +1 -1
  144. package/dist/domain/iampolicy/steps.d.ts +4 -3
  145. package/dist/domain/iampolicy/steps.d.ts.map +1 -1
  146. package/dist/domain/iampolicy/steps.js +7 -7
  147. package/dist/domain/iampolicy/steps.js.map +1 -1
  148. package/dist/domain/iampolicy/store-contract.d.ts.map +1 -1
  149. package/dist/domain/iampolicy/store-contract.js +22 -1
  150. package/dist/domain/iampolicy/store-contract.js.map +1 -1
  151. package/dist/domain/iampolicy/store.d.ts +18 -5
  152. package/dist/domain/iampolicy/store.d.ts.map +1 -1
  153. package/dist/domain/iampolicy/store.js.map +1 -1
  154. package/dist/domain/identityaccount/constants.d.ts +15 -0
  155. package/dist/domain/identityaccount/constants.d.ts.map +1 -1
  156. package/dist/domain/identityaccount/constants.js +17 -0
  157. package/dist/domain/identityaccount/constants.js.map +1 -1
  158. package/dist/domain/identityaccount/controller.d.ts.map +1 -1
  159. package/dist/domain/identityaccount/controller.js +17 -6
  160. package/dist/domain/identityaccount/controller.js.map +1 -1
  161. package/dist/domain/identityaccount/resolve.d.ts +47 -0
  162. package/dist/domain/identityaccount/resolve.d.ts.map +1 -1
  163. package/dist/domain/identityaccount/resolve.js +38 -1
  164. package/dist/domain/identityaccount/resolve.js.map +1 -1
  165. package/dist/domain/identityaccount/resource-store.d.ts.map +1 -1
  166. package/dist/domain/identityaccount/resource-store.js +11 -1
  167. package/dist/domain/identityaccount/resource-store.js.map +1 -1
  168. package/dist/domain/identityaccount/steps.d.ts +2 -1
  169. package/dist/domain/identityaccount/steps.d.ts.map +1 -1
  170. package/dist/domain/identityaccount/steps.js +4 -3
  171. package/dist/domain/identityaccount/steps.js.map +1 -1
  172. package/dist/domain/identityaccount/store-contract.js +2 -2
  173. package/dist/domain/identityaccount/store-contract.js.map +1 -1
  174. package/dist/domain/identityaccount/store.d.ts +6 -1
  175. package/dist/domain/identityaccount/store.d.ts.map +1 -1
  176. package/dist/domain/mcpserver/connect-sandbox.d.ts +67 -0
  177. package/dist/domain/mcpserver/connect-sandbox.d.ts.map +1 -0
  178. package/dist/domain/mcpserver/connect-sandbox.js +64 -0
  179. package/dist/domain/mcpserver/connect-sandbox.js.map +1 -0
  180. package/dist/domain/mcpserver/connect.d.ts +42 -10
  181. package/dist/domain/mcpserver/connect.d.ts.map +1 -1
  182. package/dist/domain/mcpserver/connect.js +147 -40
  183. package/dist/domain/mcpserver/connect.js.map +1 -1
  184. package/dist/domain/mcpserver/controller.js +4 -2
  185. package/dist/domain/mcpserver/controller.js.map +1 -1
  186. package/dist/domain/mcpserver/engine.d.ts +26 -7
  187. package/dist/domain/mcpserver/engine.d.ts.map +1 -1
  188. package/dist/domain/mcpserver/engine.js.map +1 -1
  189. package/dist/domain/mcpserver/start-connect.d.ts +5 -0
  190. package/dist/domain/mcpserver/start-connect.d.ts.map +1 -1
  191. package/dist/domain/mcpserver/start-connect.js +38 -15
  192. package/dist/domain/mcpserver/start-connect.js.map +1 -1
  193. package/dist/domain/memory/controller.js +2 -1
  194. package/dist/domain/memory/controller.js.map +1 -1
  195. package/dist/domain/memory/list-index.d.ts +2 -0
  196. package/dist/domain/memory/list-index.d.ts.map +1 -0
  197. package/dist/domain/memory/list-index.js +31 -0
  198. package/dist/domain/memory/list-index.js.map +1 -0
  199. package/dist/domain/memory/queries.d.ts +10 -0
  200. package/dist/domain/memory/queries.d.ts.map +1 -0
  201. package/dist/domain/memory/queries.js +54 -0
  202. package/dist/domain/memory/queries.js.map +1 -0
  203. package/dist/domain/memory/steps.d.ts +13 -11
  204. package/dist/domain/memory/steps.d.ts.map +1 -1
  205. package/dist/domain/memory/steps.js +26 -57
  206. package/dist/domain/memory/steps.js.map +1 -1
  207. package/dist/domain/organization/steps.d.ts.map +1 -1
  208. package/dist/domain/organization/steps.js +1 -1
  209. package/dist/domain/organization/steps.js.map +1 -1
  210. package/dist/domain/platformclient/mint.d.ts.map +1 -1
  211. package/dist/domain/platformclient/mint.js +2 -2
  212. package/dist/domain/platformclient/mint.js.map +1 -1
  213. package/dist/domain/platformclient/verifier.d.ts.map +1 -1
  214. package/dist/domain/platformclient/verifier.js +6 -3
  215. package/dist/domain/platformclient/verifier.js.map +1 -1
  216. package/dist/domain/plugin/push.d.ts.map +1 -1
  217. package/dist/domain/plugin/push.js +1 -0
  218. package/dist/domain/plugin/push.js.map +1 -1
  219. package/dist/domain/schedule/steps.d.ts +3 -1
  220. package/dist/domain/schedule/steps.d.ts.map +1 -1
  221. package/dist/domain/schedule/steps.js +3 -1
  222. package/dist/domain/schedule/steps.js.map +1 -1
  223. package/dist/domain/skill/push.d.ts.map +1 -1
  224. package/dist/domain/skill/push.js +1 -0
  225. package/dist/domain/skill/push.js.map +1 -1
  226. package/dist/domain/workflow/registry/data/task-kind-registry.json +27 -1
  227. package/dist/domain/workflowexecution/submit-approval.d.ts +5 -2
  228. package/dist/domain/workflowexecution/submit-approval.d.ts.map +1 -1
  229. package/dist/domain/workflowexecution/submit-approval.js +1 -1
  230. package/dist/domain/workflowexecution/submit-approval.js.map +1 -1
  231. package/dist/domain/workflowexecution/submit-file-decision.d.ts +5 -2
  232. package/dist/domain/workflowexecution/submit-file-decision.d.ts.map +1 -1
  233. package/dist/domain/workflowexecution/submit-file-decision.js +1 -1
  234. package/dist/domain/workflowexecution/submit-file-decision.js.map +1 -1
  235. package/dist/domain/workflowexecution/submit-workflow-task-approval.d.ts.map +1 -1
  236. package/dist/domain/workflowexecution/submit-workflow-task-approval.js +12 -1
  237. package/dist/domain/workflowexecution/submit-workflow-task-approval.js.map +1 -1
  238. package/dist/domain/workflowinstance/controller.d.ts +6 -3
  239. package/dist/domain/workflowinstance/controller.d.ts.map +1 -1
  240. package/dist/domain/workflowinstance/controller.js +12 -7
  241. package/dist/domain/workflowinstance/controller.js.map +1 -1
  242. package/dist/domain/workflowinstance/steps.d.ts +31 -0
  243. package/dist/domain/workflowinstance/steps.d.ts.map +1 -1
  244. package/dist/domain/workflowinstance/steps.js +88 -1
  245. package/dist/domain/workflowinstance/steps.js.map +1 -1
  246. package/dist/extensions/composed-services.d.ts +56 -0
  247. package/dist/extensions/composed-services.d.ts.map +1 -0
  248. package/dist/extensions/composed-services.js +2 -0
  249. package/dist/extensions/composed-services.js.map +1 -0
  250. package/dist/extensions/drivers.d.ts +32 -1
  251. package/dist/extensions/drivers.d.ts.map +1 -1
  252. package/dist/extensions/identity.d.ts +4 -1
  253. package/dist/extensions/identity.d.ts.map +1 -1
  254. package/dist/extensions/identity.js +4 -1
  255. package/dist/extensions/identity.js.map +1 -1
  256. package/dist/extensions/registry.d.ts +37 -0
  257. package/dist/extensions/registry.d.ts.map +1 -1
  258. package/dist/extensions/registry.js +50 -0
  259. package/dist/extensions/registry.js.map +1 -1
  260. package/dist/extensions/resource-authorization.d.ts +78 -0
  261. package/dist/extensions/resource-authorization.d.ts.map +1 -1
  262. package/dist/extensions/resource-row-reader.d.ts +43 -0
  263. package/dist/extensions/resource-row-reader.d.ts.map +1 -0
  264. package/dist/extensions/resource-row-reader.js +2 -0
  265. package/dist/extensions/resource-row-reader.js.map +1 -0
  266. package/dist/extensions/visitor-classifier.d.ts +41 -0
  267. package/dist/extensions/visitor-classifier.d.ts.map +1 -0
  268. package/dist/extensions/visitor-classifier.js +2 -0
  269. package/dist/extensions/visitor-classifier.js.map +1 -0
  270. package/dist/identity/oidc-userinfo.d.ts +6 -1
  271. package/dist/identity/oidc-userinfo.d.ts.map +1 -1
  272. package/dist/identity/oidc-userinfo.js.map +1 -1
  273. package/dist/identity/oidc-verifier.d.ts.map +1 -1
  274. package/dist/identity/oidc-verifier.js +37 -8
  275. package/dist/identity/oidc-verifier.js.map +1 -1
  276. package/dist/index.d.ts +14 -6
  277. package/dist/index.d.ts.map +1 -1
  278. package/dist/index.js +25 -9
  279. package/dist/index.js.map +1 -1
  280. package/dist/pipeline/errors.d.ts +8 -0
  281. package/dist/pipeline/errors.d.ts.map +1 -1
  282. package/dist/pipeline/errors.js +25 -16
  283. package/dist/pipeline/errors.js.map +1 -1
  284. package/dist/pipeline/interceptors/auth.d.ts +17 -9
  285. package/dist/pipeline/interceptors/auth.d.ts.map +1 -1
  286. package/dist/pipeline/interceptors/auth.js +17 -9
  287. package/dist/pipeline/interceptors/auth.js.map +1 -1
  288. package/dist/pipeline/steps/authorization-tuples.d.ts +23 -1
  289. package/dist/pipeline/steps/authorization-tuples.d.ts.map +1 -1
  290. package/dist/pipeline/steps/authorization-tuples.js +42 -0
  291. package/dist/pipeline/steps/authorization-tuples.js.map +1 -1
  292. package/dist/pipeline/steps/authorize.d.ts +6 -5
  293. package/dist/pipeline/steps/authorize.d.ts.map +1 -1
  294. package/dist/pipeline/steps/authorize.js +6 -5
  295. package/dist/pipeline/steps/authorize.js.map +1 -1
  296. package/dist/pipeline/steps/defaults.d.ts +12 -0
  297. package/dist/pipeline/steps/defaults.d.ts.map +1 -1
  298. package/dist/pipeline/steps/defaults.js +42 -7
  299. package/dist/pipeline/steps/defaults.js.map +1 -1
  300. package/dist/pipeline/steps/guard-memory-capture.d.ts +13 -15
  301. package/dist/pipeline/steps/guard-memory-capture.d.ts.map +1 -1
  302. package/dist/pipeline/steps/guard-memory-capture.js +2 -3
  303. package/dist/pipeline/steps/guard-memory-capture.js.map +1 -1
  304. package/dist/runnerauth/built-in-runner-credential-provider.d.ts +0 -2
  305. package/dist/runnerauth/built-in-runner-credential-provider.d.ts.map +1 -1
  306. package/dist/runnerauth/built-in-runner-credential-provider.js +8 -17
  307. package/dist/runnerauth/built-in-runner-credential-provider.js.map +1 -1
  308. package/dist/runnerauth/runner-credential-provider.d.ts +17 -7
  309. package/dist/runnerauth/runner-credential-provider.d.ts.map +1 -1
  310. package/dist/runnerauth/runner-credential-provider.js.map +1 -1
  311. package/dist/sandbox/docker.d.ts.map +1 -1
  312. package/dist/sandbox/docker.js +3 -0
  313. package/dist/sandbox/docker.js.map +1 -1
  314. package/dist/sandbox/kubernetes.d.ts.map +1 -1
  315. package/dist/sandbox/kubernetes.js +3 -0
  316. package/dist/sandbox/kubernetes.js.map +1 -1
  317. package/dist/sandbox/local-process.d.ts.map +1 -1
  318. package/dist/sandbox/local-process.js +4 -0
  319. package/dist/sandbox/local-process.js.map +1 -1
  320. package/dist/sandbox/provisioner.d.ts +18 -6
  321. package/dist/sandbox/provisioner.d.ts.map +1 -1
  322. package/dist/sandbox/provisioner.js.map +1 -1
  323. package/dist/temporal/manager.d.ts +5 -0
  324. package/dist/temporal/manager.d.ts.map +1 -1
  325. package/dist/temporal/manager.js +9 -0
  326. package/dist/temporal/manager.js.map +1 -1
  327. package/dist/temporal/mcpserver/engine-client.d.ts +2 -2
  328. package/dist/temporal/mcpserver/engine-client.d.ts.map +1 -1
  329. package/dist/temporal/mcpserver/engine-client.js +6 -4
  330. package/dist/temporal/mcpserver/engine-client.js.map +1 -1
  331. package/dist/temporal/mcpserver/names.d.ts +13 -2
  332. package/dist/temporal/mcpserver/names.d.ts.map +1 -1
  333. package/dist/temporal/mcpserver/names.js +15 -2
  334. package/dist/temporal/mcpserver/names.js.map +1 -1
  335. package/dist/temporal/sdk-logger.d.ts +74 -0
  336. package/dist/temporal/sdk-logger.d.ts.map +1 -0
  337. package/dist/temporal/sdk-logger.js +143 -0
  338. package/dist/temporal/sdk-logger.js.map +1 -0
  339. package/package.json +6 -6
  340. package/src/authorization/README.md +18 -6
  341. package/src/authorization/__tests__/authorizer.test.ts +5 -1
  342. package/src/authorization/__tests__/derived-tuples.test.ts +26 -0
  343. package/src/authorization/__tests__/evaluator.test.ts +4 -0
  344. package/src/authorization/__tests__/list-read-scope.test.ts +11 -5
  345. package/src/authorization/__tests__/store-tests.test.ts +3 -1
  346. package/src/authorization/__tests__/trusted-local-authorizer.test.ts +155 -0
  347. package/src/authorization/__tests__/unit-owned-kinds.test.ts +420 -0
  348. package/src/authorization/__tests__/wire-permissions.test.ts +31 -2
  349. package/src/authorization/authorizer.ts +21 -10
  350. package/src/authorization/derived-tuples.ts +92 -18
  351. package/src/authorization/evaluator.ts +30 -15
  352. package/src/authorization/list-read-scope.ts +4 -0
  353. package/src/authorization/model/__tests__/registry.test.ts +23 -0
  354. package/src/authorization/model/data/authorization-model.json +830 -67
  355. package/src/authorization/model/execution-viewer.ts +32 -27
  356. package/src/authorization/model/index.ts +4 -1
  357. package/src/authorization/model/rewrite.ts +5 -3
  358. package/src/authorization/organization-directory.ts +4 -0
  359. package/src/authorization/person.ts +32 -1
  360. package/src/authorization/policy-check.ts +105 -0
  361. package/src/authorization/posture.ts +45 -4
  362. package/src/authorization/resource-creators.ts +48 -0
  363. package/src/authorization/trusted-local-authorizer.ts +91 -0
  364. package/src/authorization/tuples.ts +17 -0
  365. package/src/boot/__tests__/compose.test.ts +120 -4
  366. package/src/boot/__tests__/list-indexes.test.ts +4 -0
  367. package/src/boot/__tests__/oauth-redirect-uri.test.ts +121 -10
  368. package/src/boot/__tests__/skill-transfer-origin.test.ts +96 -25
  369. package/src/boot/compose.ts +153 -61
  370. package/src/boot/config.ts +28 -12
  371. package/src/boot/inprocess.ts +18 -4
  372. package/src/boot/list-indexes.ts +6 -1
  373. package/src/boot/logger.ts +3 -1
  374. package/src/boot/oauth-redirect-uri.ts +62 -17
  375. package/src/boot/skill-transfer-origin.ts +71 -16
  376. package/src/domain/agent/__tests__/agent.test.ts +42 -1
  377. package/src/domain/agentchannel/__tests__/agentchannel.test.ts +9 -0
  378. package/src/domain/agentchannel/__tests__/channel-runtime.test.ts +2 -0
  379. package/src/domain/agentchannel/__tests__/create-authorization.test.ts +7 -6
  380. package/src/domain/agentchannel/steps.ts +9 -7
  381. package/src/domain/agentexecution/__tests__/agentexecution.test.ts +148 -56
  382. package/src/domain/agentexecution/__tests__/create-steps.test.ts +175 -12
  383. package/src/domain/agentexecution/__tests__/file-review-seed.ts +91 -0
  384. package/src/domain/agentexecution/controller.ts +8 -0
  385. package/src/domain/agentexecution/create-steps.ts +74 -44
  386. package/src/domain/agentexecution/submit-approval.ts +9 -6
  387. package/src/domain/agentexecution/submit-file-decision.ts +5 -4
  388. package/src/domain/agentinstance/__tests__/agentinstance.test.ts +2 -0
  389. package/src/domain/agentshare/__tests__/agentshare.test.ts +17 -0
  390. package/src/domain/agentshare/__tests__/create-authorization.test.ts +5 -4
  391. package/src/domain/agentshare/steps.ts +6 -4
  392. package/src/domain/apikey/__tests__/verifier.test.ts +73 -1
  393. package/src/domain/apikey/verifier.ts +45 -1
  394. package/src/domain/artifact/__tests__/artifact.test.ts +13 -24
  395. package/src/domain/channelapp/__tests__/channelapp.test.ts +7 -0
  396. package/src/domain/channelapp/controller.ts +4 -3
  397. package/src/domain/environment/__tests__/environment.test.ts +13 -0
  398. package/src/domain/executioncontext/__tests__/executioncontext.test.ts +2 -0
  399. package/src/domain/executioncontext/steps.ts +2 -1
  400. package/src/domain/iampolicy/__tests__/access-lists.test.ts +79 -0
  401. package/src/domain/iampolicy/__tests__/change.test.ts +63 -0
  402. package/src/domain/iampolicy/__tests__/controller.test.ts +39 -3
  403. package/src/domain/iampolicy/__tests__/grant-path.test.ts +595 -27
  404. package/src/domain/iampolicy/__tests__/iampolicy.test.ts +33 -2
  405. package/src/domain/iampolicy/__tests__/membership.test.ts +47 -5
  406. package/src/domain/iampolicy/__tests__/resource-store.test.ts +1 -0
  407. package/src/domain/iampolicy/__tests__/role-lifecycle.test.ts +41 -8
  408. package/src/domain/iampolicy/__tests__/roles.test.ts +3 -2
  409. package/src/domain/iampolicy/__tests__/steps.test.ts +75 -6
  410. package/src/domain/iampolicy/__tests__/support.ts +68 -4
  411. package/src/domain/iampolicy/access-lists.ts +70 -2
  412. package/src/domain/iampolicy/change.ts +109 -0
  413. package/src/domain/iampolicy/constants.ts +8 -0
  414. package/src/domain/iampolicy/controller.ts +17 -3
  415. package/src/domain/iampolicy/grant-path.ts +349 -31
  416. package/src/domain/iampolicy/membership.ts +32 -12
  417. package/src/domain/iampolicy/resource-store.ts +4 -0
  418. package/src/domain/iampolicy/role-lifecycle.ts +2 -0
  419. package/src/domain/iampolicy/roles.ts +8 -0
  420. package/src/domain/iampolicy/steps.ts +15 -5
  421. package/src/domain/iampolicy/store-contract.ts +37 -1
  422. package/src/domain/iampolicy/store.ts +19 -5
  423. package/src/domain/identityaccount/__tests__/resolve.test.ts +246 -2
  424. package/src/domain/identityaccount/__tests__/resource-store.test.ts +1 -1
  425. package/src/domain/identityaccount/constants.ts +20 -0
  426. package/src/domain/identityaccount/controller.ts +20 -5
  427. package/src/domain/identityaccount/resolve.ts +80 -1
  428. package/src/domain/identityaccount/resource-store.ts +14 -1
  429. package/src/domain/identityaccount/steps.ts +4 -3
  430. package/src/domain/identityaccount/store-contract.ts +4 -4
  431. package/src/domain/identityaccount/store.ts +6 -1
  432. package/src/domain/mcpserver/__tests__/connect-authorization.test.ts +1 -0
  433. package/src/domain/mcpserver/__tests__/connect.test.ts +358 -15
  434. package/src/domain/mcpserver/__tests__/mcpserver.test.ts +2 -0
  435. package/src/domain/mcpserver/__tests__/oauth-handshake.test.ts +2 -0
  436. package/src/domain/mcpserver/__tests__/store-faults.test.ts +2 -0
  437. package/src/domain/mcpserver/connect-sandbox.ts +135 -0
  438. package/src/domain/mcpserver/connect.ts +226 -56
  439. package/src/domain/mcpserver/controller.ts +8 -2
  440. package/src/domain/mcpserver/engine.ts +24 -6
  441. package/src/domain/mcpserver/start-connect.ts +49 -10
  442. package/src/domain/memory/__tests__/memory.test.ts +92 -22
  443. package/src/domain/memory/__tests__/queries.test.ts +173 -0
  444. package/src/domain/memory/controller.ts +2 -1
  445. package/src/domain/memory/list-index.ts +32 -0
  446. package/src/domain/memory/queries.ts +72 -0
  447. package/src/domain/memory/steps.ts +26 -63
  448. package/src/domain/oauthapp/__tests__/oauthapp.test.ts +14 -0
  449. package/src/domain/organization/__tests__/support.ts +41 -0
  450. package/src/domain/organization/steps.ts +1 -0
  451. package/src/domain/platformclient/mint.ts +6 -2
  452. package/src/domain/platformclient/verifier.ts +6 -3
  453. package/src/domain/plugin/__tests__/plugin.test.ts +11 -24
  454. package/src/domain/plugin/push.ts +1 -0
  455. package/src/domain/schedule/__tests__/schedule.composed.test.ts +2 -0
  456. package/src/domain/schedule/steps.ts +3 -1
  457. package/src/domain/session/__tests__/session.test.ts +2 -0
  458. package/src/domain/skill/__tests__/skill.test.ts +7 -25
  459. package/src/domain/skill/push.ts +1 -0
  460. package/src/domain/workflow/__tests__/workflow.test.ts +2 -0
  461. package/src/domain/workflow/registry/data/task-kind-registry.json +27 -1
  462. package/src/domain/workflowexecution/__tests__/forward-attribution-composed.test.ts +270 -0
  463. package/src/domain/workflowexecution/__tests__/submit-workflow-task-approval.test.ts +196 -0
  464. package/src/domain/workflowexecution/__tests__/workflowexecution.test.ts +3 -57
  465. package/src/domain/workflowexecution/submit-approval.ts +9 -2
  466. package/src/domain/workflowexecution/submit-file-decision.ts +6 -1
  467. package/src/domain/workflowexecution/submit-workflow-task-approval.ts +23 -5
  468. package/src/domain/workflowinstance/controller.ts +27 -9
  469. package/src/domain/workflowinstance/steps.ts +123 -1
  470. package/src/extensions/__tests__/apikey-before-sign-in-composed.test.ts +172 -0
  471. package/src/extensions/__tests__/built-in-authorization-composed.test.ts +80 -1
  472. package/src/extensions/__tests__/composed-services-composed.test.ts +236 -0
  473. package/src/extensions/__tests__/extension-composition.test.ts +229 -16
  474. package/src/extensions/__tests__/identity-account-composed.test.ts +84 -4
  475. package/src/extensions/__tests__/list-read-scope-composed.test.ts +2 -0
  476. package/src/extensions/__tests__/registry.test.ts +147 -1
  477. package/src/extensions/__tests__/secret-cleanup-composed.test.ts +2 -0
  478. package/src/extensions/__tests__/visitor-classifier-points.test.ts +42 -0
  479. package/src/extensions/composed-services.ts +61 -0
  480. package/src/extensions/drivers.ts +33 -1
  481. package/src/extensions/identity.ts +4 -1
  482. package/src/extensions/registry.ts +105 -0
  483. package/src/extensions/resource-authorization.ts +87 -0
  484. package/src/extensions/resource-row-reader.ts +43 -0
  485. package/src/extensions/visitor-classifier.ts +41 -0
  486. package/src/identity/__tests__/oidc-verifier.test.ts +38 -12
  487. package/src/identity/oidc-userinfo.ts +6 -1
  488. package/src/identity/oidc-verifier.ts +42 -8
  489. package/src/index.ts +61 -6
  490. package/src/pipeline/__tests__/steps.test.ts +31 -4
  491. package/src/pipeline/errors.ts +30 -16
  492. package/src/pipeline/interceptors/auth.ts +17 -9
  493. package/src/pipeline/steps/__tests__/authorization-tuples.test.ts +20 -0
  494. package/src/pipeline/steps/__tests__/guard-memory-capture.test.ts +72 -15
  495. package/src/pipeline/steps/authorization-tuples.ts +54 -0
  496. package/src/pipeline/steps/authorize.ts +6 -5
  497. package/src/pipeline/steps/defaults.ts +52 -7
  498. package/src/pipeline/steps/guard-memory-capture.ts +15 -20
  499. package/src/runnerauth/__tests__/built-in-runner-credential-provider.test.ts +1 -1
  500. package/src/runnerauth/__tests__/runner-subject-composed.test.ts +13 -0
  501. package/src/runnerauth/bound-execution.ts +2 -2
  502. package/src/runnerauth/built-in-runner-credential-provider.ts +8 -21
  503. package/src/runnerauth/runner-credential-provider.ts +17 -7
  504. package/src/sandbox/__tests__/docker.integration.test.ts +4 -0
  505. package/src/sandbox/__tests__/kubernetes.test.ts +18 -1
  506. package/src/sandbox/__tests__/local-process.integration.test.ts +4 -0
  507. package/src/sandbox/__tests__/provisioner.test.ts +1 -0
  508. package/src/sandbox/docker.ts +3 -0
  509. package/src/sandbox/kubernetes.ts +3 -0
  510. package/src/sandbox/local-process.ts +4 -0
  511. package/src/sandbox/provisioner.ts +18 -6
  512. package/src/store/postgres/__tests__/support.ts +11 -2
  513. package/src/temporal/README.md +1 -0
  514. package/src/temporal/__tests__/manager.test.ts +56 -4
  515. package/src/temporal/__tests__/sdk-log-workflows.ts +26 -0
  516. package/src/temporal/__tests__/sdk-logger.e2e.test.ts +150 -0
  517. package/src/temporal/__tests__/sdk-logger.test.ts +238 -0
  518. package/src/temporal/manager.ts +9 -0
  519. package/src/temporal/mcpserver/engine-client.ts +8 -3
  520. package/src/temporal/mcpserver/names.ts +16 -2
  521. package/src/temporal/sdk-logger.ts +173 -0
  522. package/dist/authorization/lane-admission.d.ts +0 -50
  523. package/dist/authorization/lane-admission.d.ts.map +0 -1
  524. package/dist/authorization/lane-admission.js +0 -13
  525. package/dist/authorization/lane-admission.js.map +0 -1
  526. package/src/authorization/__tests__/lane-admission.test.ts +0 -115
  527. package/src/authorization/lane-admission.ts +0 -73
@@ -11,13 +11,21 @@
11
11
  * `#execution_viewer@organization:<org>#viewer`, the organization's full
12
12
  * read audience (the relation also admits `#member`, the legacy shape),
13
13
  * and `private` or unset derives nothing, so each run stays its
14
- * triggerer's. Pure over the row; no related row is read.
14
+ * triggerer's. Pure over the row; no related row is read. Which level
15
+ * names which audience is `executionAudienceShapes`
16
+ * (pipeline/steps/authorization-tuples.ts), the one mapping this
17
+ * derivation and the lifecycle event a tuple-storing edition hears both
18
+ * read, so the two editions cannot disagree about who sees the runs.
15
19
  */
16
20
  import { isMessage } from "@bufbuild/protobuf";
17
21
 
18
22
  import { WorkflowInstanceSchema } from "@stigmer/protos/ai/stigmer/agentic/workflowinstance/v1/api_pb";
19
23
  import { WorkflowExecutionVisibility } from "@stigmer/protos/ai/stigmer/agentic/workflowinstance/v1/spec_pb";
20
24
 
25
+ import { executionAudienceShapes } from "../../pipeline/steps/authorization-tuples.js";
26
+
27
+ import type { Tuple } from "../tuples.js";
28
+
21
29
  import type { DerivedRelation } from "./rewrite.js";
22
30
 
23
31
  export const executionViewer: DerivedRelation = (object, row) => {
@@ -26,31 +34,28 @@ export const executionViewer: DerivedRelation = (object, row) => {
26
34
  }
27
35
  const level =
28
36
  row.spec?.executionVisibility ?? WorkflowExecutionVisibility.unspecified;
29
- switch (level) {
30
- case WorkflowExecutionVisibility.organization: {
31
- const org = row.metadata?.org ?? "";
32
- return Promise.resolve(
33
- org === ""
34
- ? []
35
- : [
36
- {
37
- object,
38
- relation: "execution_viewer",
39
- subject: {
40
- form: "userset",
41
- object: { type: "organization", id: org },
42
- relation: "viewer",
43
- },
44
- },
45
- ],
46
- );
47
- }
48
- case WorkflowExecutionVisibility.private:
49
- case WorkflowExecutionVisibility.unspecified:
50
- return Promise.resolve([]);
51
- default: {
52
- const exhaustive: never = level;
53
- throw new Error(`unknown execution visibility: ${String(exhaustive)}`);
54
- }
37
+ const org = row.metadata?.org ?? "";
38
+ if (org === "") {
39
+ return Promise.resolve([]);
55
40
  }
41
+ return Promise.resolve(
42
+ [...executionAudienceShapes(level)].map((shape): Tuple => {
43
+ switch (shape) {
44
+ case "org-viewer":
45
+ return {
46
+ object,
47
+ relation: "execution_viewer",
48
+ subject: {
49
+ form: "userset",
50
+ object: { type: "organization", id: org },
51
+ relation: "viewer",
52
+ },
53
+ };
54
+ default: {
55
+ const exhaustive: never = shape;
56
+ throw new Error(`unknown execution audience: ${String(exhaustive)}`);
57
+ }
58
+ }
59
+ }),
60
+ );
56
61
  };
@@ -18,7 +18,10 @@
18
18
  * evaluation (authorizer.ts, `kindServedByEdition`): open source refuses a
19
19
  * check that targets `team`, `identity_provider`, `invitation` or
20
20
  * `platform`, and a tuple that names one resolves over tuples alone, since
21
- * this edition stores no row of those kinds.
21
+ * open source stores no row of those kinds. An edition that serves them
22
+ * keeps their rows in its units' own stores and registers a reader for
23
+ * each (extensions/resource-row-reader.ts), which the derivation reads them
24
+ * through.
22
25
  *
23
26
  * `newModel` exists for tests that need a throwaway model (a cycle, a
24
27
  * chain past the depth bound).
@@ -15,10 +15,12 @@
15
15
  * define can_view: viewer → computed("viewer")
16
16
  *
17
17
  * `and` exists for one shape: a relation that is true only while another
18
- * holds too (a team's member is a person granted the role AND still one
18
+ * holds too. Every direct grant on an organization-scoped type is bounded
19
+ * that way (`([identity_account] and affiliated from organization) or
20
+ * ...`), and a team's member is a person granted the role AND still one
19
21
  * of the organization's viewers, so leaving the organization ends every
20
- * team-derived grant with no cleanup). Operators nest to any depth, as
21
- * the DSL's parentheses allow; the evaluator recurses through them.
22
+ * grant with no cleanup. Operators nest to any depth, as the DSL's
23
+ * parentheses allow; the evaluator recurses through them.
22
24
  * `but not`, wildcards (`type:*`) and conditions have no form here: the
23
25
  * reader refuses them by name, and the day the model needs one is a
24
26
  * design act.
@@ -42,6 +42,7 @@ import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/
42
42
 
43
43
  import type { IamPolicyStore } from "../domain/iampolicy/store.js";
44
44
  import type { CallerIdentity } from "../extensions/identity.js";
45
+ import type { ResourceRowReader } from "../extensions/resource-row-reader.js";
45
46
  import type { OrganizationDirectory } from "../extensions/organization-directory.js";
46
47
  import { ALL_ORGANIZATIONS } from "../extensions/organization-directory.js";
47
48
  import { kindEnumName } from "../pipeline/apiresource-meta.js";
@@ -57,6 +58,8 @@ export interface BuiltInOrganizationDirectoryDeps {
57
58
  readonly store: Store;
58
59
  readonly policies: IamPolicyStore;
59
60
  readonly accounts: AccountsByCaller;
61
+ /** The readers of the kinds units keep themselves (`drivers.resourceRowReaders`), handed to every tuple source. */
62
+ readonly rowReaders?: ReadonlyMap<ApiResourceKind, ResourceRowReader>;
60
63
  readonly model?: Model;
61
64
  }
62
65
 
@@ -81,6 +84,7 @@ export function newBuiltInOrganizationDirectory(
81
84
  store: deps.store,
82
85
  policies: deps.policies,
83
86
  accounts: deps.accounts,
87
+ rowReaders: deps.rowReaders,
84
88
  model,
85
89
  },
86
90
  person,
@@ -4,13 +4,17 @@
4
4
  * list scope when it lands), so "who is asking" cannot be answered two
5
5
  * ways.
6
6
  *
7
- * Two steps, split so the pure half is testable without a store:
7
+ * The steps, split so the pure half is testable without a store:
8
8
  *
9
9
  * `resolvePerson(accounts, caller)` — the I/O: the account the caller
10
10
  * stands for through `accountForCaller` (domain/identityaccount/
11
11
  * resolve.ts, the domain's one statement of that question — the two
12
12
  * reads whoAmI makes), then `personFor`.
13
13
  *
14
+ * `personOfAccount(accounts, id)` — the person an account id names
15
+ * when no caller stands for them (an invitation's creator), with the
16
+ * same alias rule.
17
+ *
14
18
  * `personFor(caller, account)` — the pure half: the account id the
15
19
  * IamPolicy rows name, and every string a creator stamp may carry for
16
20
  * the same human. A provisioned caller carries the account id and the
@@ -35,6 +39,7 @@ import type { IdentityAccount } from "@stigmer/protos/ai/stigmer/iam/identityacc
35
39
 
36
40
  import { isPersonStamp } from "../domain/iampolicy/membership.js";
37
41
  import type { AccountsByCaller } from "../domain/identityaccount/resolve.js";
42
+ import type { IdentityAccountStore } from "../domain/identityaccount/store.js";
38
43
  import { accountForCaller } from "../domain/identityaccount/resolve.js";
39
44
  import type { CallerIdentity } from "../extensions/identity.js";
40
45
  import type { Person } from "./tuples.js";
@@ -51,6 +56,32 @@ export function personFor(
51
56
  `caller '${accountId}' names no person — the built-in authorizer evaluates people only`,
52
57
  );
53
58
  }
59
+ return withAliases(accountId, account);
60
+ }
61
+
62
+ /**
63
+ * The person an account id names when no caller stands for them: the
64
+ * creator of an invitation, asked whether they could still grant what it
65
+ * grants. The alias rule is `personFor`'s: the id itself, and the issuer
66
+ * subject when the account is found. An account that is gone is its id
67
+ * alone, and the rows that still name it are what the check reads.
68
+ */
69
+ export async function personOfAccount(
70
+ accounts: Pick<IdentityAccountStore, "findById">,
71
+ accountId: string,
72
+ ): Promise<Person> {
73
+ if (!isPersonStamp(accountId)) {
74
+ throw new Error(
75
+ `account '${accountId}' names no person — the built-in authorizer evaluates people only`,
76
+ );
77
+ }
78
+ return withAliases(accountId, await accounts.findById(accountId));
79
+ }
80
+
81
+ function withAliases(
82
+ accountId: string,
83
+ account: IdentityAccount | undefined,
84
+ ): Person {
54
85
  const aliases = new Set<string>([accountId]);
55
86
  const subject = account?.spec?.idpId ?? "";
56
87
  if (subject !== "") {
@@ -0,0 +1,105 @@
1
+ /**
2
+ * The built-in policy check — the one question of the authorization-query
3
+ * engine (extensions/authorization-queries.ts, `check`) that the built-in
4
+ * posture can answer from its own evaluator: "is this policy effectively
5
+ * held". A unit composed on the built-in posture asks it through the
6
+ * services the composition hands it (extensions/registry.ts,
7
+ * `ComposedServices`), exactly where a composition with its own engine
8
+ * hands that engine's `check`, so the unit asks one question in every
9
+ * edition and the model answers it one way.
10
+ *
11
+ * What it answers, and why no more:
12
+ * - A policy whose principal is a person (`identity_account:<id>`): the
13
+ * person the id names, with `personFor`'s alias rule (person.ts), and
14
+ * the rows they and their teams hold — the same walk a point check
15
+ * makes for a caller.
16
+ * - A policy whose principal is any other object (`organization:<o>`):
17
+ * the structural question a grant to a team asks — does this resource
18
+ * belong to the team's organization — answered by the resource's own
19
+ * derived links (derived-tuples.ts).
20
+ * - Contextual policies are refused as a programming error. No caller
21
+ * asks with them, and the derived source has no notion of a tuple held
22
+ * only for the length of one check; answering without them would be a
23
+ * silent wrong answer, the failure a throw prevents.
24
+ * - A userset principal (`organization:<o>#member`) is refused the same
25
+ * way: the engine contract checks direct principals.
26
+ *
27
+ * The engine's list verbs are not answered here: they enumerate, which the
28
+ * built-in posture does not do, and the tuple-half RPCs that expose them
29
+ * keep refusing in open source without an engine. One source per check,
30
+ * like the Authorizer: its memo is the check's. Faults propagate; the
31
+ * caller's own error mapping decides the wire.
32
+ */
33
+ import type { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
34
+
35
+ import type { IamPolicyStore } from "../domain/iampolicy/store.js";
36
+ import type { IdentityAccountStore } from "../domain/identityaccount/store.js";
37
+ import type { AuthorizationQueryEngine } from "../extensions/authorization-queries.js";
38
+ import type { ResourceRowReader } from "../extensions/resource-row-reader.js";
39
+ import type { Store } from "../store/interface.js";
40
+ import { newDerivedTupleSource } from "./derived-tuples.js";
41
+ import { checkRelation } from "./evaluator.js";
42
+ import type { Model } from "./model/index.js";
43
+ import { builtInModel } from "./model/index.js";
44
+ import { personOfAccount } from "./person.js";
45
+ import type { Principal } from "./tuples.js";
46
+ import { ACCOUNT_TYPE } from "./tuples.js";
47
+
48
+ export interface BuiltInPolicyCheckDeps {
49
+ readonly store: Store;
50
+ /** The port the grant path writes through — the principal's rows are read from the same instance. */
51
+ readonly policies: IamPolicyStore;
52
+ /** The account port: a person principal's aliases, and identity_account objects. */
53
+ readonly accounts: Pick<IdentityAccountStore, "findById">;
54
+ /** The readers of the kinds units keep themselves (`drivers.resourceRowReaders`). */
55
+ readonly rowReaders?: ReadonlyMap<ApiResourceKind, ResourceRowReader>;
56
+ /** The declarations to evaluate; the built-in model unless a test says otherwise. */
57
+ readonly model?: Model;
58
+ }
59
+
60
+ export function newBuiltInPolicyCheck(
61
+ deps: BuiltInPolicyCheckDeps,
62
+ ): Pick<AuthorizationQueryEngine, "check"> {
63
+ const model = deps.model ?? builtInModel;
64
+ return {
65
+ async check(policy, contextualPolicies) {
66
+ if (contextualPolicies.length > 0) {
67
+ throw new Error(
68
+ "the built-in policy check evaluates held policies only — contextual policies are not supported",
69
+ );
70
+ }
71
+ const principalRef = policy.principal;
72
+ const resource = policy.resource;
73
+ if (principalRef === undefined || resource === undefined) {
74
+ throw new Error(
75
+ "the built-in policy check needs a principal and a resource",
76
+ );
77
+ }
78
+ if (principalRef.relation !== "") {
79
+ throw new Error(
80
+ `the built-in policy check takes a direct principal — '${principalRef.kind}:${principalRef.id}#${principalRef.relation}' is a userset`,
81
+ );
82
+ }
83
+ const principal: Principal =
84
+ principalRef.kind === ACCOUNT_TYPE
85
+ ? await personOfAccount(deps.accounts, principalRef.id)
86
+ : { object: { type: principalRef.kind, id: principalRef.id } };
87
+ const source = newDerivedTupleSource(
88
+ {
89
+ store: deps.store,
90
+ policies: deps.policies,
91
+ accounts: deps.accounts,
92
+ rowReaders: deps.rowReaders,
93
+ model,
94
+ },
95
+ principal,
96
+ );
97
+ return checkRelation(
98
+ { model, source },
99
+ { type: resource.kind, id: resource.id },
100
+ policy.relation,
101
+ principal,
102
+ );
103
+ },
104
+ };
105
+ }
@@ -14,19 +14,34 @@
14
14
  * posture (the OSS OIDC issuer, or a unit's declaration). Open source
15
15
  * composes the built-in Authorizer, the organization directory and
16
16
  * the schedule fire caller — the cloud's model evaluated over derived
17
- * tuples — so the roles 2b records are enforced.
17
+ * tuples — so the roles 2b records are enforced. An edition above
18
+ * open source may run it too, once every kind it serves has rows the
19
+ * derivation can read (`kindsWithoutRows` below).
18
20
  * - `trusted-local`: no unit Authorizer and no authentication posture —
19
- * the laptop. The permissive default stays: one caller, nothing to
20
- * separate; the trusted-local identity carries the operator's EMAIL,
21
+ * the laptop. The permissive driver (trusted-local-authorizer.ts): one
22
+ * caller, nothing to separate, so every check is allowed except one
23
+ * that names an Organization the server does not hold, which is
24
+ * not-found as under the other two postures (stigmer#1163). The
25
+ * trusted-local identity carries the operator's EMAIL,
21
26
  * never an account id, and pre-2a rows are stamped `"system"`, so an
22
27
  * enforcing evaluator would refuse the laptop's own history. The roles
23
28
  * still exist (the lifecycle and the membership rules run) to feed the
24
- * Members page truthfully.
29
+ * Members page truthfully. Open source's edition only: a composition
30
+ * serving an edition above it refuses to boot here, since an edition
31
+ * of many organizations with no sign-in would act as the operator for
32
+ * every request that carries no credential.
25
33
  *
26
34
  * The type lives with the module that gives it meaning (the precedent:
27
35
  * `ConsoleSignInPosture` in transport/console/handler.ts); the
28
36
  * composition root computes the value once and hands it down.
29
37
  */
38
+ import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
39
+ import { ServerEdition } from "@stigmer/protos/ai/stigmer/platform/v1/server_info_pb";
40
+
41
+ import type { ResourceRowReader } from "../extensions/resource-row-reader.js";
42
+ import { kindServedByEdition } from "../pipeline/apiresource-meta.js";
43
+ import type { Model } from "./model/index.js";
44
+
30
45
  export type AuthorizationPosture =
31
46
  | "trusted-local"
32
47
  | "built-in"
@@ -47,3 +62,29 @@ export function authorizationPostureOf(
47
62
  }
48
63
  return inputs.requireAuthentication ? "built-in" : "trusted-local";
49
64
  }
65
+
66
+ /**
67
+ * The kinds an edition serves whose rows the built-in authorizer could not
68
+ * read: declared by the model with a row schema, served by the edition,
69
+ * not served by open source (whose kinds are its own store's), and not
70
+ * `identity_account` (read through the account port), with no reader
71
+ * registered for them. Empty means the built-in posture can answer every
72
+ * check the edition's lanes make. The composition root refuses a built-in
73
+ * posture that leaves any, rather than answer from rows that are not there.
74
+ */
75
+ export function kindsWithoutRows(inputs: {
76
+ readonly edition: ServerEdition;
77
+ readonly model: Model;
78
+ readonly readers: ReadonlyMap<ApiResourceKind, ResourceRowReader>;
79
+ }): ReadonlyArray<ApiResourceKind> {
80
+ return inputs.model.declarations
81
+ .filter(
82
+ (declaration) =>
83
+ declaration.schema !== undefined &&
84
+ declaration.kind !== ApiResourceKind.identity_account &&
85
+ kindServedByEdition(declaration.kind, inputs.edition) &&
86
+ !kindServedByEdition(declaration.kind, ServerEdition.oss) &&
87
+ !inputs.readers.has(declaration.kind),
88
+ )
89
+ .map((declaration) => declaration.kind);
90
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * The removal sweep's one read outside the policy rows: a stored
3
+ * resource's recorded creator (`ResourceCreators`,
4
+ * domain/iampolicy/grant-path.ts). When an account leaves an
5
+ * organization, the grant path keeps the rows that record the account as
6
+ * a resource's author, and only the resource's own row says who that is.
7
+ *
8
+ * The row is read through the generic store with the schema the built-in
9
+ * model binds to its kind, the same read the derived tuple source makes
10
+ * for a check (derived-tuples.ts `loadRow`), and the creator is the stamp
11
+ * that source derives an author's `owner` tuple from (`createdByOf`). A
12
+ * kind the model binds no schema to, or a row the store does not hold (a
13
+ * kind a composition keeps in its own table), has no recorded creator
14
+ * here, so no row of it is kept as authorship.
15
+ */
16
+ import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
17
+
18
+ import type { ResourceCreators } from "../domain/iampolicy/grant-path.js";
19
+ import { kindByEnumName } from "../pipeline/apiresource-meta.js";
20
+ import { createdByOf } from "../pipeline/steps/authorization-facts.js";
21
+ import type { Store } from "../store/interface.js";
22
+ import { ResourceNotFoundError } from "../store/interface.js";
23
+ import { builtInModel } from "./model/index.js";
24
+
25
+ export function newStoreResourceCreators(store: Store): ResourceCreators {
26
+ return {
27
+ async creatorOf(kindName, id): Promise<string | undefined> {
28
+ const kind = kindByEnumName(kindName);
29
+ const schema = builtInModel.byKind(kind)?.schema;
30
+ if (
31
+ kind === ApiResourceKind.api_resource_kind_unknown ||
32
+ kind === ApiResourceKind.identity_account ||
33
+ schema === undefined ||
34
+ id === ""
35
+ ) {
36
+ return undefined;
37
+ }
38
+ try {
39
+ return createdByOf(await store.getResource(kind, id, schema));
40
+ } catch (error) {
41
+ if (error instanceof ResourceNotFoundError) {
42
+ return undefined;
43
+ }
44
+ throw error;
45
+ }
46
+ },
47
+ };
48
+ }
@@ -0,0 +1,91 @@
1
+ /**
2
+ * The trusted-local Authorizer — open source's driver for the one
3
+ * authorization decision seam (extensions/authorizer.ts) under the
4
+ * trusted-local posture (posture.ts): the laptop, a server with no sign-in.
5
+ * It separates no callers (there is one, the operator), so every check is
6
+ * `allow`, with one exception that is not a permission question at all.
7
+ *
8
+ * A check whose target is an Organization the store does not hold is
9
+ * `not-found`. "Does this Organization exist" is a load question, and
10
+ * every posture's Authorizer answers it the same way: the built-in
11
+ * driver's arm 4 (authorizer.ts) before any permission is evaluated, and
12
+ * the cloud's on its deny path (stigmer-cloud
13
+ * src/authorizer/fga-authorizer.ts, the existence probe). The Authorize
14
+ * step turns the arm into the load-first chain's NOT_FOUND,
15
+ * `Organization not found: <slug>`, so a server without sign-in refuses a
16
+ * write into a phantom Organization with the sentence a server with
17
+ * sign-in answers, instead of storing it under a slug nothing lists
18
+ * (stigmer#1163). Reads that name the Organization (a list by org, a
19
+ * usage report) are answered the same way, as they are under sign-in.
20
+ *
21
+ * Why the Organization alone. Every org-scoped lane authorizes on it (a
22
+ * create by `metadata.org`, a list or report by `org`/`org_id`), and its
23
+ * absence is the one no later step catches. The other kinds' update, get
24
+ * and delete chains load their target first and answer NOT_FOUND
25
+ * themselves, and a general existence read would refuse the rowless
26
+ * `platform` (model/bindings.ts), whose checks the laptop must keep
27
+ * allowing. An Organization's id is its slug (domain/organization/
28
+ * steps.ts), so the read is one primary key; the posture is open source's
29
+ * edition only (compose.ts refuses a wider edition without sign-in), so
30
+ * every Organization is a row in this store.
31
+ *
32
+ * Arms, in order: an empty target id is `allow` (a platform-scoped write
33
+ * names no Organization, and the Authorize step maps a not-found on an
34
+ * empty id to INTERNAL); a kind other than the Organization is `allow`
35
+ * with no read; a missing Organization is `not-found`; a present one is
36
+ * `allow`. A store fault is `unavailable` with its cause, the built-in
37
+ * driver's guard: an outage is never softened into a refusal of a
38
+ * different kind, and the driver never throws.
39
+ *
40
+ * Proven by __tests__/trusted-local-authorizer.test.ts (the arms, on both
41
+ * store drivers) and extensions/__tests__/built-in-authorization-
42
+ * composed.test.ts (the wire, beside the same sentence under sign-in).
43
+ */
44
+ import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
45
+ import { OrganizationSchema } from "@stigmer/protos/ai/stigmer/tenancy/organization/v1/api_pb";
46
+
47
+ import type {
48
+ Authorizer,
49
+ AuthzCheck,
50
+ AuthzDecision,
51
+ } from "../extensions/authorizer.js";
52
+ import { ResourceNotFoundError } from "../store/interface.js";
53
+ import type { Store } from "../store/interface.js";
54
+
55
+ /** The one read the driver makes: the Organization's row by id. */
56
+ export type TrustedLocalAuthorizerStore = Pick<Store, "getResource">;
57
+
58
+ export interface TrustedLocalAuthorizerDeps {
59
+ readonly store: TrustedLocalAuthorizerStore;
60
+ }
61
+
62
+ export function newTrustedLocalAuthorizer(
63
+ deps: TrustedLocalAuthorizerDeps,
64
+ ): Authorizer {
65
+ return {
66
+ async authorize(_caller, check: AuthzCheck): Promise<AuthzDecision> {
67
+ if (
68
+ check.resourceKind !== ApiResourceKind.organization ||
69
+ check.resourceId === ""
70
+ ) {
71
+ return { kind: "allow" };
72
+ }
73
+ try {
74
+ await deps.store.getResource(
75
+ ApiResourceKind.organization,
76
+ check.resourceId,
77
+ OrganizationSchema,
78
+ );
79
+ return { kind: "allow" };
80
+ } catch (error) {
81
+ if (error instanceof ResourceNotFoundError) {
82
+ return { kind: "not-found" };
83
+ }
84
+ return {
85
+ kind: "unavailable",
86
+ cause: error instanceof Error ? error : new Error(String(error)),
87
+ };
88
+ }
89
+ },
90
+ };
91
+ }
@@ -83,6 +83,23 @@ export interface Person {
83
83
  readonly aliases: ReadonlySet<string>;
84
84
  }
85
85
 
86
+ /**
87
+ * An object other than a person that a check asks about: "does
88
+ * `organization:o` hold `organization` on this agent", the question a
89
+ * grant to a team asks before it names the team on a resource. It matches
90
+ * a tuple's subject by its own reference, with no aliases.
91
+ */
92
+ export interface ObjectPrincipal {
93
+ readonly object: ObjectRef;
94
+ }
95
+
96
+ /** Whom a check asks about: a person through their aliases, or any other object by its reference. */
97
+ export type Principal = Person | ObjectPrincipal;
98
+
99
+ export function isPerson(principal: Principal): principal is Person {
100
+ return "accountId" in principal;
101
+ }
102
+
86
103
  // ---------------------------------------------------------------------------
87
104
  // The string notation.
88
105
  // ---------------------------------------------------------------------------