@stigmer/server 3.21.0 → 3.22.1-dev.20260922095755

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 (383) hide show
  1. package/dist/authorization/authorizer.d.ts +4 -8
  2. package/dist/authorization/authorizer.d.ts.map +1 -1
  3. package/dist/authorization/authorizer.js +5 -9
  4. package/dist/authorization/authorizer.js.map +1 -1
  5. package/dist/authorization/derived-tuples.d.ts.map +1 -1
  6. package/dist/authorization/derived-tuples.js +10 -25
  7. package/dist/authorization/derived-tuples.js.map +1 -1
  8. package/dist/authorization/evaluator.d.ts +13 -8
  9. package/dist/authorization/evaluator.d.ts.map +1 -1
  10. package/dist/authorization/evaluator.js +4 -20
  11. package/dist/authorization/evaluator.js.map +1 -1
  12. package/dist/authorization/list-read-scope.d.ts.map +1 -1
  13. package/dist/authorization/list-read-scope.js +24 -20
  14. package/dist/authorization/list-read-scope.js.map +1 -1
  15. package/dist/authorization/model/agent.d.ts.map +1 -1
  16. package/dist/authorization/model/agent.js +4 -5
  17. package/dist/authorization/model/agent.js.map +1 -1
  18. package/dist/authorization/model/agent_instance.d.ts.map +1 -1
  19. package/dist/authorization/model/agent_instance.js +2 -2
  20. package/dist/authorization/model/agent_instance.js.map +1 -1
  21. package/dist/authorization/model/mcp_server.d.ts.map +1 -1
  22. package/dist/authorization/model/mcp_server.js +2 -2
  23. package/dist/authorization/model/mcp_server.js.map +1 -1
  24. package/dist/authorization/model/organization.d.ts.map +1 -1
  25. package/dist/authorization/model/organization.js +2 -0
  26. package/dist/authorization/model/organization.js.map +1 -1
  27. package/dist/authorization/model/plugin.d.ts.map +1 -1
  28. package/dist/authorization/model/plugin.js +3 -4
  29. package/dist/authorization/model/plugin.js.map +1 -1
  30. package/dist/authorization/model/rewrite.d.ts +8 -10
  31. package/dist/authorization/model/rewrite.d.ts.map +1 -1
  32. package/dist/authorization/model/rewrite.js +0 -3
  33. package/dist/authorization/model/rewrite.js.map +1 -1
  34. package/dist/authorization/model/skill.d.ts.map +1 -1
  35. package/dist/authorization/model/skill.js +2 -2
  36. package/dist/authorization/model/skill.js.map +1 -1
  37. package/dist/authorization/model/workflow.d.ts.map +1 -1
  38. package/dist/authorization/model/workflow.js +2 -2
  39. package/dist/authorization/model/workflow.js.map +1 -1
  40. package/dist/authorization/model/workflow_instance.d.ts.map +1 -1
  41. package/dist/authorization/model/workflow_instance.js +2 -2
  42. package/dist/authorization/model/workflow_instance.js.map +1 -1
  43. package/dist/authorization/organization-directory.d.ts.map +1 -1
  44. package/dist/authorization/organization-directory.js +2 -3
  45. package/dist/authorization/organization-directory.js.map +1 -1
  46. package/dist/authorization/store-test-kit.d.ts +0 -6
  47. package/dist/authorization/store-test-kit.d.ts.map +1 -1
  48. package/dist/authorization/store-test-kit.js +16 -62
  49. package/dist/authorization/store-test-kit.js.map +1 -1
  50. package/dist/authorization/tuples.d.ts +13 -32
  51. package/dist/authorization/tuples.d.ts.map +1 -1
  52. package/dist/authorization/tuples.js +3 -11
  53. package/dist/authorization/tuples.js.map +1 -1
  54. package/dist/domain/agent/controller.d.ts.map +1 -1
  55. package/dist/domain/agent/controller.js +6 -4
  56. package/dist/domain/agent/controller.js.map +1 -1
  57. package/dist/domain/agentchannel/controller.d.ts.map +1 -1
  58. package/dist/domain/agentchannel/controller.js +9 -2
  59. package/dist/domain/agentchannel/controller.js.map +1 -1
  60. package/dist/domain/agentchannel/steps.d.ts +19 -0
  61. package/dist/domain/agentchannel/steps.d.ts.map +1 -1
  62. package/dist/domain/agentchannel/steps.js +32 -0
  63. package/dist/domain/agentchannel/steps.js.map +1 -1
  64. package/dist/domain/agentexecution/controller.d.ts.map +1 -1
  65. package/dist/domain/agentexecution/controller.js +3 -1
  66. package/dist/domain/agentexecution/controller.js.map +1 -1
  67. package/dist/domain/agentinstance/controller.d.ts +5 -5
  68. package/dist/domain/agentinstance/controller.d.ts.map +1 -1
  69. package/dist/domain/agentinstance/controller.js +9 -5
  70. package/dist/domain/agentinstance/controller.js.map +1 -1
  71. package/dist/domain/agentinstance/steps.d.ts +43 -8
  72. package/dist/domain/agentinstance/steps.d.ts.map +1 -1
  73. package/dist/domain/agentinstance/steps.js +71 -8
  74. package/dist/domain/agentinstance/steps.js.map +1 -1
  75. package/dist/domain/agentshare/constants.d.ts +6 -11
  76. package/dist/domain/agentshare/constants.d.ts.map +1 -1
  77. package/dist/domain/agentshare/constants.js +8 -16
  78. package/dist/domain/agentshare/constants.js.map +1 -1
  79. package/dist/domain/agentshare/controller.d.ts.map +1 -1
  80. package/dist/domain/agentshare/controller.js +10 -2
  81. package/dist/domain/agentshare/controller.js.map +1 -1
  82. package/dist/domain/agentshare/steps.d.ts +61 -10
  83. package/dist/domain/agentshare/steps.d.ts.map +1 -1
  84. package/dist/domain/agentshare/steps.js +121 -117
  85. package/dist/domain/agentshare/steps.js.map +1 -1
  86. package/dist/domain/artifact/controller.js +21 -25
  87. package/dist/domain/artifact/controller.js.map +1 -1
  88. package/dist/domain/channelapp/controller.d.ts.map +1 -1
  89. package/dist/domain/channelapp/controller.js +2 -0
  90. package/dist/domain/channelapp/controller.js.map +1 -1
  91. package/dist/domain/environment/controller.d.ts.map +1 -1
  92. package/dist/domain/environment/controller.js +4 -3
  93. package/dist/domain/environment/controller.js.map +1 -1
  94. package/dist/domain/executioncontext/controller.d.ts.map +1 -1
  95. package/dist/domain/executioncontext/controller.js +4 -1
  96. package/dist/domain/executioncontext/controller.js.map +1 -1
  97. package/dist/domain/executioncontext/steps.d.ts.map +1 -1
  98. package/dist/domain/executioncontext/steps.js +2 -1
  99. package/dist/domain/executioncontext/steps.js.map +1 -1
  100. package/dist/domain/mcpserver/connect.d.ts.map +1 -1
  101. package/dist/domain/mcpserver/connect.js +8 -7
  102. package/dist/domain/mcpserver/connect.js.map +1 -1
  103. package/dist/domain/mcpserver/controller.d.ts.map +1 -1
  104. package/dist/domain/mcpserver/controller.js +5 -4
  105. package/dist/domain/mcpserver/controller.js.map +1 -1
  106. package/dist/domain/mcpserver/start-connect.d.ts.map +1 -1
  107. package/dist/domain/mcpserver/start-connect.js +8 -7
  108. package/dist/domain/mcpserver/start-connect.js.map +1 -1
  109. package/dist/domain/memory/controller.d.ts.map +1 -1
  110. package/dist/domain/memory/controller.js +6 -1
  111. package/dist/domain/memory/controller.js.map +1 -1
  112. package/dist/domain/memory/steps.d.ts +23 -0
  113. package/dist/domain/memory/steps.d.ts.map +1 -1
  114. package/dist/domain/memory/steps.js +35 -0
  115. package/dist/domain/memory/steps.js.map +1 -1
  116. package/dist/domain/oauthapp/controller.d.ts.map +1 -1
  117. package/dist/domain/oauthapp/controller.js +2 -0
  118. package/dist/domain/oauthapp/controller.js.map +1 -1
  119. package/dist/domain/plugin/controller.d.ts.map +1 -1
  120. package/dist/domain/plugin/controller.js +6 -27
  121. package/dist/domain/plugin/controller.js.map +1 -1
  122. package/dist/domain/plugin/push.d.ts +7 -5
  123. package/dist/domain/plugin/push.d.ts.map +1 -1
  124. package/dist/domain/plugin/push.js +8 -14
  125. package/dist/domain/plugin/push.js.map +1 -1
  126. package/dist/domain/schedule/controller.d.ts.map +1 -1
  127. package/dist/domain/schedule/controller.js +10 -2
  128. package/dist/domain/schedule/controller.js.map +1 -1
  129. package/dist/domain/schedule/steps.d.ts +19 -0
  130. package/dist/domain/schedule/steps.d.ts.map +1 -1
  131. package/dist/domain/schedule/steps.js +32 -0
  132. package/dist/domain/schedule/steps.js.map +1 -1
  133. package/dist/domain/session/controller.d.ts.map +1 -1
  134. package/dist/domain/session/controller.js +3 -2
  135. package/dist/domain/session/controller.js.map +1 -1
  136. package/dist/domain/session/steps.d.ts +8 -9
  137. package/dist/domain/session/steps.d.ts.map +1 -1
  138. package/dist/domain/session/steps.js +17 -21
  139. package/dist/domain/session/steps.js.map +1 -1
  140. package/dist/domain/skill/controller.d.ts.map +1 -1
  141. package/dist/domain/skill/controller.js +8 -19
  142. package/dist/domain/skill/controller.js.map +1 -1
  143. package/dist/domain/workflow/agent-call-references.d.ts +54 -0
  144. package/dist/domain/workflow/agent-call-references.d.ts.map +1 -0
  145. package/dist/domain/workflow/agent-call-references.js +97 -0
  146. package/dist/domain/workflow/agent-call-references.js.map +1 -0
  147. package/dist/domain/workflow/controller.d.ts.map +1 -1
  148. package/dist/domain/workflow/controller.js +44 -113
  149. package/dist/domain/workflow/controller.js.map +1 -1
  150. package/dist/domain/workflow/registry/data/task-kind-registry.json +1 -1
  151. package/dist/domain/workflow/validation/task-config-constraints.d.ts +10 -1
  152. package/dist/domain/workflow/validation/task-config-constraints.d.ts.map +1 -1
  153. package/dist/domain/workflow/validation/task-config-constraints.js +3 -2
  154. package/dist/domain/workflow/validation/task-config-constraints.js.map +1 -1
  155. package/dist/domain/workflow/version-resolution.d.ts +5 -0
  156. package/dist/domain/workflow/version-resolution.d.ts.map +1 -0
  157. package/dist/domain/workflow/version-resolution.js +113 -0
  158. package/dist/domain/workflow/version-resolution.js.map +1 -0
  159. package/dist/domain/workflowexecution/controller.d.ts.map +1 -1
  160. package/dist/domain/workflowexecution/controller.js +4 -2
  161. package/dist/domain/workflowexecution/controller.js.map +1 -1
  162. package/dist/domain/workflowinstance/controller.d.ts.map +1 -1
  163. package/dist/domain/workflowinstance/controller.js +9 -5
  164. package/dist/domain/workflowinstance/controller.js.map +1 -1
  165. package/dist/domain/workflowinstance/steps.d.ts +20 -0
  166. package/dist/domain/workflowinstance/steps.d.ts.map +1 -1
  167. package/dist/domain/workflowinstance/steps.js +39 -0
  168. package/dist/domain/workflowinstance/steps.js.map +1 -1
  169. package/dist/extensions/authorization-queries.d.ts +6 -5
  170. package/dist/extensions/authorization-queries.d.ts.map +1 -1
  171. package/dist/extensions/identity.d.ts +19 -0
  172. package/dist/extensions/identity.d.ts.map +1 -1
  173. package/dist/extensions/identity.js +22 -3
  174. package/dist/extensions/identity.js.map +1 -1
  175. package/dist/extensions/list-read-scope.d.ts +42 -8
  176. package/dist/extensions/list-read-scope.d.ts.map +1 -1
  177. package/dist/extensions/list-read-scope.js +13 -2
  178. package/dist/extensions/list-read-scope.js.map +1 -1
  179. package/dist/extensions/resource-authorization.d.ts +3 -2
  180. package/dist/extensions/resource-authorization.d.ts.map +1 -1
  181. package/dist/index.d.ts +1 -1
  182. package/dist/index.d.ts.map +1 -1
  183. package/dist/index.js.map +1 -1
  184. package/dist/pipeline/apiresource-meta.d.ts +12 -3
  185. package/dist/pipeline/apiresource-meta.d.ts.map +1 -1
  186. package/dist/pipeline/apiresource-meta.js +21 -10
  187. package/dist/pipeline/apiresource-meta.js.map +1 -1
  188. package/dist/pipeline/steps/authorization-tuples.d.ts +9 -3
  189. package/dist/pipeline/steps/authorization-tuples.d.ts.map +1 -1
  190. package/dist/pipeline/steps/authorization-tuples.js +9 -11
  191. package/dist/pipeline/steps/authorization-tuples.js.map +1 -1
  192. package/dist/pipeline/steps/authorize-resolved-target.d.ts +88 -0
  193. package/dist/pipeline/steps/authorize-resolved-target.d.ts.map +1 -0
  194. package/dist/pipeline/steps/authorize-resolved-target.js +36 -0
  195. package/dist/pipeline/steps/authorize-resolved-target.js.map +1 -0
  196. package/dist/pipeline/steps/authorize.d.ts +27 -0
  197. package/dist/pipeline/steps/authorize.d.ts.map +1 -1
  198. package/dist/pipeline/steps/authorize.js +49 -10
  199. package/dist/pipeline/steps/authorize.js.map +1 -1
  200. package/dist/pipeline/steps/guard-memory-capture.d.ts.map +1 -1
  201. package/dist/pipeline/steps/guard-memory-capture.js +2 -1
  202. package/dist/pipeline/steps/guard-memory-capture.js.map +1 -1
  203. package/dist/pipeline/steps/guard-reserved-labels.d.ts.map +1 -1
  204. package/dist/pipeline/steps/guard-reserved-labels.js +6 -7
  205. package/dist/pipeline/steps/guard-reserved-labels.js.map +1 -1
  206. package/dist/pipeline/steps/helpers.d.ts +9 -5
  207. package/dist/pipeline/steps/helpers.d.ts.map +1 -1
  208. package/dist/pipeline/steps/helpers.js +11 -15
  209. package/dist/pipeline/steps/helpers.js.map +1 -1
  210. package/dist/pipeline/steps/references.d.ts +178 -20
  211. package/dist/pipeline/steps/references.d.ts.map +1 -1
  212. package/dist/pipeline/steps/references.js +344 -43
  213. package/dist/pipeline/steps/references.js.map +1 -1
  214. package/dist/pipeline/steps/version-history.d.ts +11 -0
  215. package/dist/pipeline/steps/version-history.d.ts.map +1 -1
  216. package/dist/pipeline/steps/version-history.js +26 -0
  217. package/dist/pipeline/steps/version-history.js.map +1 -1
  218. package/dist/query/search/controller.js +0 -1
  219. package/dist/query/search/controller.js.map +1 -1
  220. package/dist/query/search/criteria.d.ts +1 -5
  221. package/dist/query/search/criteria.d.ts.map +1 -1
  222. package/dist/query/search/criteria.js +3 -13
  223. package/dist/query/search/criteria.js.map +1 -1
  224. package/dist/query/search/handler.d.ts +5 -4
  225. package/dist/query/search/handler.d.ts.map +1 -1
  226. package/dist/query/search/handler.js +7 -6
  227. package/dist/query/search/handler.js.map +1 -1
  228. package/dist/query/search/query-store.d.ts.map +1 -1
  229. package/dist/query/search/query-store.js +0 -2
  230. package/dist/query/search/query-store.js.map +1 -1
  231. package/dist/store/interface.d.ts +3 -6
  232. package/dist/store/interface.d.ts.map +1 -1
  233. package/dist/store/interface.js.map +1 -1
  234. package/dist/store/postgres/migrations.d.ts +3 -1
  235. package/dist/store/postgres/migrations.d.ts.map +1 -1
  236. package/dist/store/postgres/migrations.js +35 -1
  237. package/dist/store/postgres/migrations.js.map +1 -1
  238. package/dist/store/postgres/store.d.ts.map +1 -1
  239. package/dist/store/postgres/store.js +4 -9
  240. package/dist/store/postgres/store.js.map +1 -1
  241. package/dist/store/public-visibility-retired.d.ts +67 -0
  242. package/dist/store/public-visibility-retired.d.ts.map +1 -0
  243. package/dist/store/public-visibility-retired.js +55 -0
  244. package/dist/store/public-visibility-retired.js.map +1 -0
  245. package/dist/store/sqlite/migrations.d.ts +3 -1
  246. package/dist/store/sqlite/migrations.d.ts.map +1 -1
  247. package/dist/store/sqlite/migrations.js +36 -1
  248. package/dist/store/sqlite/migrations.js.map +1 -1
  249. package/dist/store/sqlite/store.d.ts.map +1 -1
  250. package/dist/store/sqlite/store.js +4 -8
  251. package/dist/store/sqlite/store.js.map +1 -1
  252. package/package.json +6 -6
  253. package/src/authorization/README.md +24 -26
  254. package/src/authorization/__tests__/authorizer.test.ts +10 -9
  255. package/src/authorization/__tests__/derived-tuples.test.ts +4 -11
  256. package/src/authorization/__tests__/evaluator.test.ts +14 -73
  257. package/src/authorization/__tests__/facts.test.ts +2 -2
  258. package/src/authorization/__tests__/fixtures/fga/blueprint-private-visibility.fga.yaml +6 -98
  259. package/src/authorization/__tests__/fixtures/fga/default-instance-inheritance.fga.yaml +4 -61
  260. package/src/authorization/__tests__/fixtures/fga/org-admin-owner-inheritance.fga.yaml +1 -21
  261. package/src/authorization/__tests__/fixtures/fga/platform-visibility.fga.yaml +1 -25
  262. package/src/authorization/__tests__/fixtures/fga/workflow-execution-sharing.fga.yaml +1 -3
  263. package/src/authorization/__tests__/list-read-scope.test.ts +41 -29
  264. package/src/authorization/__tests__/skip-lane-inventory.test.ts +160 -0
  265. package/src/authorization/__tests__/store-tests.test.ts +1 -6
  266. package/src/authorization/__tests__/tuples.test.ts +12 -11
  267. package/src/authorization/__tests__/wire-permissions.test.ts +5 -5
  268. package/src/authorization/authorizer.ts +4 -9
  269. package/src/authorization/derived-tuples.ts +14 -31
  270. package/src/authorization/evaluator.ts +15 -44
  271. package/src/authorization/list-read-scope.ts +27 -22
  272. package/src/authorization/model/__tests__/registry.test.ts +2 -0
  273. package/src/authorization/model/agent.ts +2 -5
  274. package/src/authorization/model/agent_instance.ts +0 -2
  275. package/src/authorization/model/mcp_server.ts +0 -2
  276. package/src/authorization/model/organization.ts +2 -0
  277. package/src/authorization/model/plugin.ts +1 -4
  278. package/src/authorization/model/rewrite.ts +8 -13
  279. package/src/authorization/model/skill.ts +0 -2
  280. package/src/authorization/model/workflow.ts +0 -2
  281. package/src/authorization/model/workflow_instance.ts +0 -2
  282. package/src/authorization/organization-directory.ts +1 -3
  283. package/src/authorization/store-test-kit.ts +16 -75
  284. package/src/authorization/tuples.ts +16 -39
  285. package/src/domain/agent/__tests__/agent.test.ts +11 -4
  286. package/src/domain/agent/controller.ts +17 -7
  287. package/src/domain/agentchannel/__tests__/agentchannel.test.ts +223 -48
  288. package/src/domain/agentchannel/__tests__/create-authorization.test.ts +58 -0
  289. package/src/domain/agentchannel/controller.ts +25 -1
  290. package/src/domain/agentchannel/steps.ts +40 -0
  291. package/src/domain/agentexecution/controller.ts +6 -1
  292. package/src/domain/agentinstance/__tests__/create-authorization.composed.test.ts +243 -0
  293. package/src/domain/agentinstance/__tests__/create-authorization.test.ts +144 -0
  294. package/src/domain/agentinstance/controller.ts +30 -17
  295. package/src/domain/agentinstance/steps.ts +82 -8
  296. package/src/domain/agentshare/__tests__/agentshare.test.ts +196 -172
  297. package/src/domain/agentshare/__tests__/create-authorization.test.ts +71 -0
  298. package/src/domain/agentshare/__tests__/member-audience.test.ts +113 -0
  299. package/src/domain/agentshare/constants.ts +14 -26
  300. package/src/domain/agentshare/controller.ts +27 -1
  301. package/src/domain/agentshare/steps.ts +168 -155
  302. package/src/domain/artifact/controller.ts +18 -22
  303. package/src/domain/channelapp/controller.ts +10 -0
  304. package/src/domain/environment/controller.ts +15 -8
  305. package/src/domain/executioncontext/__tests__/executioncontext.test.ts +1 -0
  306. package/src/domain/executioncontext/controller.ts +15 -1
  307. package/src/domain/executioncontext/steps.ts +2 -1
  308. package/src/domain/mcpserver/__tests__/mcpserver.test.ts +115 -28
  309. package/src/domain/mcpserver/__tests__/oauth-handshake.test.ts +53 -18
  310. package/src/domain/mcpserver/connect.ts +11 -10
  311. package/src/domain/mcpserver/controller.ts +19 -13
  312. package/src/domain/mcpserver/start-connect.ts +17 -11
  313. package/src/domain/memory/__tests__/create-authorization.test.ts +59 -0
  314. package/src/domain/memory/controller.ts +11 -0
  315. package/src/domain/memory/steps.ts +41 -0
  316. package/src/domain/oauthapp/controller.ts +10 -0
  317. package/src/domain/plugin/controller.ts +23 -44
  318. package/src/domain/plugin/push.ts +8 -16
  319. package/src/domain/schedule/__tests__/create-authorization.test.ts +58 -0
  320. package/src/domain/schedule/controller.ts +26 -1
  321. package/src/domain/schedule/steps.ts +45 -2
  322. package/src/domain/session/controller.ts +12 -4
  323. package/src/domain/session/steps.ts +24 -32
  324. package/src/domain/skill/controller.ts +24 -30
  325. package/src/domain/workflow/__tests__/agent-call-references.test.ts +222 -0
  326. package/src/domain/workflow/agent-call-references.ts +157 -0
  327. package/src/domain/workflow/controller.ts +86 -155
  328. package/src/domain/workflow/registry/data/task-kind-registry.json +1 -1
  329. package/src/domain/workflow/validation/task-config-constraints.ts +7 -3
  330. package/src/domain/workflow/version-resolution.ts +166 -0
  331. package/src/domain/workflowexecution/controller.ts +7 -2
  332. package/src/domain/workflowinstance/__tests__/create-authorization.test.ts +109 -0
  333. package/src/domain/workflowinstance/controller.ts +25 -12
  334. package/src/domain/workflowinstance/steps.ts +49 -1
  335. package/src/extensions/__tests__/built-in-authorization-composed.test.ts +32 -19
  336. package/src/extensions/__tests__/composed-support.ts +38 -4
  337. package/src/extensions/__tests__/extension-composition.test.ts +4 -4
  338. package/src/extensions/__tests__/identity.test.ts +44 -1
  339. package/src/extensions/__tests__/list-read-scope-composed.test.ts +96 -7
  340. package/src/extensions/__tests__/list-read-scope.test.ts +63 -0
  341. package/src/extensions/authorization-queries.ts +6 -5
  342. package/src/extensions/identity.ts +23 -5
  343. package/src/extensions/list-read-scope.ts +48 -8
  344. package/src/extensions/resource-authorization.ts +3 -5
  345. package/src/index.ts +0 -1
  346. package/src/pipeline/__tests__/supports-visibility.test.ts +112 -0
  347. package/src/pipeline/apiresource-meta.ts +21 -10
  348. package/src/pipeline/steps/__tests__/authorization-tuples.test.ts +18 -31
  349. package/src/pipeline/steps/__tests__/authorize-resolved-target.test.ts +285 -0
  350. package/src/pipeline/steps/__tests__/references.test.ts +703 -0
  351. package/src/pipeline/steps/authorization-tuples.ts +9 -11
  352. package/src/pipeline/steps/authorize-resolved-target.ts +129 -0
  353. package/src/pipeline/steps/authorize.ts +70 -13
  354. package/src/pipeline/steps/guard-memory-capture.ts +2 -1
  355. package/src/pipeline/steps/guard-reserved-labels.ts +6 -9
  356. package/src/pipeline/steps/helpers.ts +11 -15
  357. package/src/pipeline/steps/references.ts +578 -70
  358. package/src/pipeline/steps/version-history.ts +34 -0
  359. package/src/query/search/__tests__/criteria.test.ts +0 -4
  360. package/src/query/search/__tests__/query-store.test.ts +11 -40
  361. package/src/query/search/controller.ts +0 -1
  362. package/src/query/search/criteria.ts +0 -14
  363. package/src/query/search/handler.ts +6 -7
  364. package/src/query/search/query-store.ts +0 -2
  365. package/src/store/__tests__/public-visibility-retired.test.ts +127 -0
  366. package/src/store/__tests__/store-contract.ts +6 -51
  367. package/src/store/interface.ts +3 -6
  368. package/src/store/postgres/__tests__/migrations.test.ts +187 -6
  369. package/src/store/postgres/__tests__/store-contract.test.ts +0 -2
  370. package/src/store/postgres/migrations.ts +48 -1
  371. package/src/store/postgres/store.ts +4 -11
  372. package/src/store/public-visibility-retired.ts +119 -0
  373. package/src/store/sqlite/__tests__/migrations.test.ts +191 -5
  374. package/src/store/sqlite/migrations.ts +45 -1
  375. package/src/store/sqlite/store.ts +4 -10
  376. package/dist/pipeline/steps/visibility-gates.d.ts +0 -27
  377. package/dist/pipeline/steps/visibility-gates.d.ts.map +0 -1
  378. package/dist/pipeline/steps/visibility-gates.js +0 -139
  379. package/dist/pipeline/steps/visibility-gates.js.map +0 -1
  380. package/src/authorization/__tests__/fixtures/fga/cross-org-share-creation.fga.yaml +0 -98
  381. package/src/authorization/__tests__/fixtures/fga/public-visibility-setter.fga.yaml +0 -52
  382. package/src/pipeline/steps/__tests__/visibility-gates.test.ts +0 -187
  383. package/src/pipeline/steps/visibility-gates.ts +0 -174
@@ -94,9 +94,15 @@ import { metadataOf, parentIdOf } from "./shapes.js";
94
94
  * validation).
95
95
  *
96
96
  * The org floor: kinds flagged defaults_to_org_visibility (blueprints —
97
- * shared org assets) keep the org-viewer shape at public and platform
98
- * levels, so sharing a blueprint beyond the org never hides it from its
99
- * own org's catalog (ListObjects suppresses the public wildcard).
97
+ * shared org assets) keep the org-viewer shape at the platform level, so
98
+ * sharing a blueprint beyond the org never hides it from its own org's
99
+ * catalog.
100
+ *
101
+ * The retired public level has no shape here. No stored row holds it once
102
+ * the store migration has run, so no transition FROM it reaches this
103
+ * policy; a deployment that still holds public rows must move them through
104
+ * updateVisibility on the release that knew the level, whose reconciler
105
+ * deletes the wildcard grant, before it runs this one.
100
106
  */
101
107
  export function visibilityShapesFor(
102
108
  kind: ApiResourceKind,
@@ -112,14 +118,6 @@ export function visibilityShapesFor(
112
118
  shapes.add("org-viewer");
113
119
  }
114
120
  break;
115
- case ApiResourceVisibility.visibility_public:
116
- if (config?.supportsPublic === true) {
117
- shapes.add("public-viewer");
118
- if (orgFloor) {
119
- shapes.add("org-viewer");
120
- }
121
- }
122
- break;
123
121
  case ApiResourceVisibility.visibility_platform:
124
122
  if (config?.supportsPlatform === true) {
125
123
  shapes.add("platform-viewer");
@@ -0,0 +1,129 @@
1
+ /**
2
+ * AuthorizeResolvedTarget — the ONE mid-chain authorization step: the
3
+ * question a lane can only ask once its chain has loaded something the
4
+ * position-1 annotation could not key on.
5
+ *
6
+ * The `Authorize` step resolves its target from the REQUEST (a field path
7
+ * over the input), so it cannot serve two shapes of lane, and both are
8
+ * `is_skip_authorization` on the wire for that reason alone:
9
+ *
10
+ * - a read by reference: the request carries an org and a slug, the
11
+ * target is the row the loader finds, and the question is exactly the
12
+ * one the kind's `get` asks by id — `can_view` on that row, with the
13
+ * `get` annotation's byte-pinned copy. `loadedTargetAsMethod(get)` is
14
+ * that resolver: it reads the row under TARGET_RESOURCE_KEY and asks the
15
+ * sibling `get` descriptor's annotation about its id, so the two lanes
16
+ * cannot drift (one annotation owns the permission and the copy; a
17
+ * `get` that is itself a skip makes the reference read a skip too).
18
+ * - a parent-gated create: the request names a parent (an agent to
19
+ * schedule, share, channel-bind or instantiate; a workflow to
20
+ * instantiate), the domain's resolve step loads and stashes it, and the
21
+ * question is the caller's standing on that parent (or on the row's
22
+ * organization), with the copy the lane has always answered.
23
+ *
24
+ * The step owns nothing but the position and the evaluation: a PURE
25
+ * resolver over the request context names the questions (kind, id,
26
+ * permission, copy), in the order the lane asks them; the first refusal
27
+ * answers. The evaluation is `authorizeTarget` (authorize.ts): allow
28
+ * proceeds, deny is PERMISSION_DENIED with the copy, not-found is NOT_FOUND
29
+ * as the load-first chain would answer, unavailable is INTERNAL, and the
30
+ * `internal` class alone is exempt — the annotation's skip arms do not
31
+ * apply, because the caller IS the enforcement the annotation opted out of.
32
+ *
33
+ * Two contracts a resolver keeps. It returns an EMPTY list only for an arm
34
+ * the lane has modelled as "nothing to ask" (a default instance the server
35
+ * composed for the run's human, whose access already follows the parent);
36
+ * an absent stash, a parent the chain guaranteed and did not deliver, is a
37
+ * chain invariant broken and the resolver THROWS, so a mis-ordered chain
38
+ * fails loudly instead of silently reopening the lane. And it names the
39
+ * questions in the anti-probing order: the organization's bar before the
40
+ * parent's where both are asked, so an outsider learns nothing about the
41
+ * parent's grants from which copy came back.
42
+ *
43
+ * Position: immediately after the step that loads what the resolver reads,
44
+ * before the duplicate check, before any engine or store side effect, and
45
+ * before any step whose refusal would reveal the loaded row (a same-org
46
+ * rule that names the parent's organization, an enrichment that reads the
47
+ * row's connections).
48
+ *
49
+ * The step's name is the shared vocabulary for every NEW lane. The lanes
50
+ * that carried a hand-written copy of this body before it existed keep
51
+ * their frozen names through `stepName` — the version ladder's own
52
+ * precedent (LoadSkillByReference and LoadPluginByReference are one
53
+ * factory) — because a step name is never renamed.
54
+ *
55
+ * Sibling: `AuthorizeRunTarget` runs the same evaluation over the record
56
+ * being built (`ctx.newState`) and carries the run-gate doctrine an
57
+ * edition's lane admission keys on; this step reads what the chain LOADED
58
+ * and carries no doctrine of its own.
59
+ */
60
+ import type { DescMessage, DescMethod, Message } from "@bufbuild/protobuf";
61
+
62
+ import type { ApiResourceReferenceSchema } from "@stigmer/protos/ai/stigmer/commons/apiresource/io_pb";
63
+
64
+ import type { Authorizer } from "../../extensions/authorizer.js";
65
+ import type { PipelineStep } from "../pipeline.js";
66
+ import type { RequestContext } from "../request-context.js";
67
+ import { metadataOf } from "./shapes.js";
68
+ import { TARGET_RESOURCE_KEY } from "./load-target.js";
69
+ import {
70
+ authorizeTarget,
71
+ resolveAnnotatedCheck,
72
+ type AuthorizationTarget,
73
+ } from "./authorize.js";
74
+
75
+ /** The step's shared name; a folded lane passes its own frozen name instead. */
76
+ export const AUTHORIZE_RESOLVED_TARGET_STEP = "AuthorizeResolvedTarget";
77
+
78
+ /**
79
+ * Names the questions a lane asks, in order, over the request context after
80
+ * its chain has loaded the target. Pure: no store, no clock, no side effect.
81
+ * Empty means the lane has nothing to ask on this request; an invariant the
82
+ * chain broke (an absent stash) is a throw, never an empty list.
83
+ */
84
+ export type ResolvedTargetResolver<Desc extends DescMessage> = (
85
+ ctx: RequestContext<Desc>,
86
+ ) => ReadonlyArray<AuthorizationTarget>;
87
+
88
+ export function newAuthorizeResolvedTargetStep<Desc extends DescMessage>(
89
+ authorizer: Authorizer,
90
+ resolve: ResolvedTargetResolver<Desc>,
91
+ stepName: string = AUTHORIZE_RESOLVED_TARGET_STEP,
92
+ ): PipelineStep<Desc> {
93
+ return {
94
+ name: stepName,
95
+ async execute(ctx: RequestContext<Desc>): Promise<void> {
96
+ for (const target of resolve(ctx)) {
97
+ await authorizeTarget(authorizer, ctx.callerIdentity, target);
98
+ }
99
+ },
100
+ };
101
+ }
102
+
103
+ /** The request shape every `getByReference` lane runs on. */
104
+ export type GetByReferenceDesc = typeof ApiResourceReferenceSchema;
105
+
106
+ /**
107
+ * The reads' resolver: the row the loader stashed under TARGET_RESOURCE_KEY,
108
+ * authorized exactly as `get` would authorize it by id. The `get`
109
+ * descriptor's annotation supplies the kind, the permission and the copy;
110
+ * the loaded row's id is the target override (a reference has no `value`
111
+ * field for the annotation's path to read). A `get` that is public, skip
112
+ * or unannotated makes this a no-op — the reference read is never stricter
113
+ * than the read by id, and never laxer.
114
+ */
115
+ export function loadedTargetAsMethod(
116
+ get: DescMethod,
117
+ ): ResolvedTargetResolver<GetByReferenceDesc> {
118
+ return (ctx) => {
119
+ const loaded = ctx.get(TARGET_RESOURCE_KEY) as Message | undefined;
120
+ const id = loaded === undefined ? undefined : metadataOf(loaded)?.id;
121
+ if (id === undefined) {
122
+ throw new Error(
123
+ `${AUTHORIZE_RESOLVED_TARGET_STEP}: no loaded target with metadata under ${TARGET_RESOURCE_KEY}; the loader must run first`,
124
+ );
125
+ }
126
+ const target = resolveAnnotatedCheck(get, ctx.input, { resourceId: id });
127
+ return target === undefined ? [] : [target];
128
+ };
129
+ }
@@ -56,6 +56,14 @@
56
56
  * names no kind because the target is the loaded row's resource). The
57
57
  * annotation keeps owning the permission, the copy and the skip arms in
58
58
  * both shapes; only the target is the handler's.
59
+ *
60
+ * The annotation read itself is one pure function, `resolveAnnotatedCheck`,
61
+ * so a third entry shape needs no third copy of it: the resolved-target
62
+ * step (authorize-resolved-target.ts) authorizes a row a chain LOADED as
63
+ * a sibling method's annotation would — a read by reference asks exactly
64
+ * what its `get` asks, target override and all — and every lane whose
65
+ * position-1 annotation is a skip because the target is not in the request
66
+ * answers its question there, with the same four arms.
59
67
  */
60
68
  import { Code, ConnectError } from "@connectrpc/connect";
61
69
  import type { DescMethod, DescMessage, Message } from "@bufbuild/protobuf";
@@ -137,6 +145,49 @@ export interface AuthorizeTargetOverride {
137
145
  readonly resourceId: string;
138
146
  }
139
147
 
148
+ /**
149
+ * One question for the Authorizer together with the lane's deny copy: the
150
+ * unit `authorizeResolvedResource` consumes, whether the annotation named
151
+ * it (`resolveAnnotatedCheck`) or a chain's own resolver did (the run gate,
152
+ * the resolved-target step).
153
+ */
154
+ export interface AuthorizationTarget extends AuthzCheck {
155
+ readonly deniedMessage: string;
156
+ }
157
+
158
+ /**
159
+ * The annotation's answer for one method: the target it names for this
160
+ * request, or `undefined` when it names none — `is_public`,
161
+ * `is_skip_authorization`, or no config at all. Pure over the descriptor
162
+ * and the request; the `internal` exemption is the evaluation's, not the
163
+ * annotation's, so it is not applied here. Exported so a chain step can
164
+ * authorize a loaded row exactly as a SIBLING method's annotation would
165
+ * (a read by reference asks what its `get` asks) without a second copy of
166
+ * the skip arms or the field-path resolution.
167
+ */
168
+ export function resolveAnnotatedCheck(
169
+ method: DescMethod,
170
+ input: Message,
171
+ override?: AuthorizeTargetOverride,
172
+ ): AuthorizationTarget | undefined {
173
+ if (
174
+ getOption(method, is_public) ||
175
+ getOption(method, is_skip_authorization)
176
+ ) {
177
+ return undefined;
178
+ }
179
+ if (!hasOption(method, rpcAuthorizationConfig)) {
180
+ return undefined;
181
+ }
182
+ const config = getOption(method, rpcAuthorizationConfig);
183
+ return {
184
+ permission: config.permission,
185
+ resourceKind: override?.resourceKind ?? resolveResourceKind(input, config),
186
+ resourceId: override?.resourceId ?? resolveResourceId(input, config),
187
+ deniedMessage: config.errorMsg,
188
+ };
189
+ }
190
+
140
191
  /**
141
192
  * The Authorize evaluation for direct handlers: identical skip arms,
142
193
  * target resolution, and decision-to-wire mapping as the pipeline step
@@ -153,27 +204,33 @@ export async function authorizeDirect(
153
204
  if (identity.callerClass === "internal") {
154
205
  return;
155
206
  }
156
- if (
157
- getOption(method, is_public) ||
158
- getOption(method, is_skip_authorization)
159
- ) {
160
- return;
161
- }
162
- if (!hasOption(method, rpcAuthorizationConfig)) {
207
+ const target = resolveAnnotatedCheck(method, input, override);
208
+ if (target === undefined) {
163
209
  return;
164
210
  }
165
- const config = getOption(method, rpcAuthorizationConfig);
211
+ return authorizeTarget(authorizer, identity, target);
212
+ }
166
213
 
214
+ /**
215
+ * `authorizeResolvedResource` over an AuthorizationTarget: the check the
216
+ * Authorizer sees carries exactly the three fields of an AuthzCheck, never
217
+ * the copy, so a recording Authorizer (a test's, a driver's audit line)
218
+ * observes the question and nothing else.
219
+ */
220
+ export function authorizeTarget(
221
+ authorizer: Authorizer,
222
+ identity: CallerIdentity,
223
+ target: AuthorizationTarget,
224
+ ): Promise<void> {
167
225
  return authorizeResolvedResource(
168
226
  authorizer,
169
227
  identity,
170
228
  {
171
- permission: config.permission,
172
- resourceKind:
173
- override?.resourceKind ?? resolveResourceKind(input, config),
174
- resourceId: override?.resourceId ?? resolveResourceId(input, config),
229
+ permission: target.permission,
230
+ resourceKind: target.resourceKind,
231
+ resourceId: target.resourceId,
175
232
  },
176
- config.errorMsg,
233
+ target.deniedMessage,
177
234
  );
178
235
  }
179
236
 
@@ -37,6 +37,7 @@
37
37
  import type { DescMessage } from "@bufbuild/protobuf";
38
38
  import { Code, ConnectError } from "@connectrpc/connect";
39
39
 
40
+ import { isServerComposedRequest } from "../../extensions/identity.js";
40
41
  import type { PipelineStep } from "../pipeline.js";
41
42
  import type { RequestContext } from "../request-context.js";
42
43
  import type { RunnerCredentialProvider } from "../../runnerauth/runner-credential-provider.js";
@@ -61,7 +62,7 @@ export function newGuardMemoryCaptureStep<Desc extends DescMessage>(
61
62
  name: "GuardMemoryCapture",
62
63
  async execute(ctx: RequestContext<Desc>): Promise<void> {
63
64
  const caller = ctx.callerIdentity;
64
- if (caller.callerClass === "internal" || caller.origin === "in-process") {
65
+ if (isServerComposedRequest(caller)) {
65
66
  // Server-composed traversals are not capture requests from a
66
67
  // credential; the entry-point request already passed the gate.
67
68
  return;
@@ -55,6 +55,7 @@ import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/
55
55
  import { IamPermission } from "@stigmer/protos/ai/stigmer/iam/v1/enum_pb";
56
56
 
57
57
  import type { Authorizer } from "../../extensions/authorizer.js";
58
+ import { isServerComposedRequest } from "../../extensions/identity.js";
58
59
  import { internalError } from "../errors.js";
59
60
  import type { PipelineStep } from "../pipeline.js";
60
61
  import type { RequestContext } from "../request-context.js";
@@ -117,15 +118,11 @@ export function newGuardReservedLabelsStep<Desc extends DescMessage>(
117
118
  return {
118
119
  name: "GuardReservedLabels",
119
120
  async execute(ctx: RequestContext<Desc>): Promise<void> {
120
- if (
121
- ctx.callerIdentity.callerClass === "internal" ||
122
- ctx.callerIdentity.origin === "in-process"
123
- ) {
124
- // Server-composed request (the Java isInProcessCall arm,
125
- // cloud#386): the trust decision was made by the service code
126
- // that built it — default-instance factories stamp reserved
127
- // labels by design, even when the call propagates the user's
128
- // identity for attribution (ruling R5).
121
+ if (isServerComposedRequest(ctx.callerIdentity)) {
122
+ // The Java isInProcessCall arm (cloud#386): the trust decision was
123
+ // made by the service code that built the request — default-instance
124
+ // factories stamp reserved labels by design, even when the call
125
+ // propagates the user's identity for attribution (ruling R5).
129
126
  return;
130
127
  }
131
128
  const state = stateOf(ctx);
@@ -8,7 +8,6 @@ import type { DescMessage, MessageShape } from "@bufbuild/protobuf";
8
8
  import type { Timestamp } from "@bufbuild/protobuf/wkt";
9
9
 
10
10
  import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
11
- import { AuthorizationScopeType } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/authorization_config_pb";
12
11
 
13
12
  import type { Store } from "../../store/interface.js";
14
13
  import { getKindMeta } from "../apiresource-meta.js";
@@ -85,11 +84,15 @@ export async function findResourceByLabelAndOrg<Desc extends DescMessage>(
85
84
  }
86
85
 
87
86
  /**
88
- * Rejects a getByReference lookup that omits org for an org-scoped kind —
89
- * Go RequireOrgForReference. For AUTHORIZATION_SCOPE_TYPE_ORGANIZATION
90
- * kinds a slug is unique only WITHIN an org; resolving an org-less
91
- * reference globally would cross tenant boundaries. The message matches
92
- * the cloud edition verbatim (cross-edition error contract).
87
+ * Rejects a getByReference lookup that omits org — Go RequireOrgForReference,
88
+ * widened to every kind that has a reference lane. A slug is unique only
89
+ * WITHIN an org, so an org-less reference resolves globally and the first
90
+ * match wins: for an org-scoped kind that crosses tenant boundaries, and
91
+ * for an owner-only kind (the execution context) it let a caller name a
92
+ * slug and receive whichever organization's row matched first. Every kind
93
+ * with a reference lane is served per organization, so the rule is the
94
+ * same for all of them. The message matches the cloud edition verbatim
95
+ * (cross-edition error contract); the kind name comes from kind_meta.
93
96
  *
94
97
  * Belongs at the getByReference boundary only — the low-level slug finders
95
98
  * are legitimately called with a relative (possibly empty) org by internal
@@ -102,23 +105,16 @@ export function requireOrgForReference(
102
105
  if (org !== "") {
103
106
  return;
104
107
  }
105
- let scopeType: AuthorizationScopeType | undefined;
106
108
  let kindName: string;
107
109
  try {
108
- const meta = getKindMeta(kind);
109
- scopeType = meta.authorization?.scopeType;
110
- kindName = meta.name;
110
+ kindName = getKindMeta(kind).name;
111
111
  } catch (error) {
112
112
  throw internalError(
113
113
  error,
114
114
  "failed to resolve kind metadata for reference org check",
115
115
  );
116
116
  }
117
- // protobuf-es strips the shared enum prefix: proto
118
- // AUTHORIZATION_SCOPE_TYPE_ORGANIZATION generates as ORGANIZATION.
119
- if (scopeType === AuthorizationScopeType.ORGANIZATION) {
120
- throw invalidArgumentError(`org is required for ${kindName} lookup`);
121
- }
117
+ throw invalidArgumentError(`org is required for ${kindName} lookup`);
122
118
  }
123
119
 
124
120
  // The two list-step helpers below are duplicated per package in Go (each