@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
@@ -38,6 +38,26 @@ export interface AuthorizeTargetOverride {
38
38
  readonly resourceKind?: ApiResourceKind;
39
39
  readonly resourceId: string;
40
40
  }
41
+ /**
42
+ * One question for the Authorizer together with the lane's deny copy: the
43
+ * unit `authorizeResolvedResource` consumes, whether the annotation named
44
+ * it (`resolveAnnotatedCheck`) or a chain's own resolver did (the run gate,
45
+ * the resolved-target step).
46
+ */
47
+ export interface AuthorizationTarget extends AuthzCheck {
48
+ readonly deniedMessage: string;
49
+ }
50
+ /**
51
+ * The annotation's answer for one method: the target it names for this
52
+ * request, or `undefined` when it names none — `is_public`,
53
+ * `is_skip_authorization`, or no config at all. Pure over the descriptor
54
+ * and the request; the `internal` exemption is the evaluation's, not the
55
+ * annotation's, so it is not applied here. Exported so a chain step can
56
+ * authorize a loaded row exactly as a SIBLING method's annotation would
57
+ * (a read by reference asks what its `get` asks) without a second copy of
58
+ * the skip arms or the field-path resolution.
59
+ */
60
+ export declare function resolveAnnotatedCheck(method: DescMethod, input: Message, override?: AuthorizeTargetOverride): AuthorizationTarget | undefined;
41
61
  /**
42
62
  * The Authorize evaluation for direct handlers: identical skip arms,
43
63
  * target resolution, and decision-to-wire mapping as the pipeline step
@@ -45,6 +65,13 @@ export interface AuthorizeTargetOverride {
45
65
  * non-allow arm; resolves on allow and on every skip arm.
46
66
  */
47
67
  export declare function authorizeDirect(method: DescMethod, authorizer: Authorizer, identity: CallerIdentity, input: Message, override?: AuthorizeTargetOverride): Promise<void>;
68
+ /**
69
+ * `authorizeResolvedResource` over an AuthorizationTarget: the check the
70
+ * Authorizer sees carries exactly the three fields of an AuthzCheck, never
71
+ * the copy, so a recording Authorizer (a test's, a driver's audit line)
72
+ * observes the question and nothing else.
73
+ */
74
+ export declare function authorizeTarget(authorizer: Authorizer, identity: CallerIdentity, target: AuthorizationTarget): Promise<void>;
48
75
  /**
49
76
  * The SAME evaluation for a check whose target the HANDLER resolved —
50
77
  * the mid-chain resolved-id pattern DD-007 names ("the pattern the two
@@ -1 +1 @@
1
- {"version":3,"file":"authorize.d.ts","sourceRoot":"","sources":["../../../src/pipeline/steps/authorize.ts"],"names":[],"mappings":"AA4DA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,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ClB,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,cAAc,EACxB,KAAK,EAAE,OAAO,EACd,QAAQ,CAAC,EAAE,uBAAuB,GACjC,OAAO,CAAC,IAAI,CAAC,CASf;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,IAAI,CAAC,CAWf;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,yBAAyB,CAC7C,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,cAAc,EACxB,KAAK,EAAE,UAAU,EACjB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CA4Cf;AAED;;;;;;;;GAQG;AACH,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,cAAc,EACxB,KAAK,EAAE,UAAU,GAChB,OAAO,CAAC,aAAa,CAAC,CASxB"}
@@ -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 { getOption, hasOption } from "@bufbuild/protobuf";
@@ -98,6 +106,32 @@ export function newAuthorizeStep(method, authorizer) {
98
106
  },
99
107
  };
100
108
  }
109
+ /**
110
+ * The annotation's answer for one method: the target it names for this
111
+ * request, or `undefined` when it names none — `is_public`,
112
+ * `is_skip_authorization`, or no config at all. Pure over the descriptor
113
+ * and the request; the `internal` exemption is the evaluation's, not the
114
+ * annotation's, so it is not applied here. Exported so a chain step can
115
+ * authorize a loaded row exactly as a SIBLING method's annotation would
116
+ * (a read by reference asks what its `get` asks) without a second copy of
117
+ * the skip arms or the field-path resolution.
118
+ */
119
+ export function resolveAnnotatedCheck(method, input, override) {
120
+ if (getOption(method, is_public) ||
121
+ getOption(method, is_skip_authorization)) {
122
+ return undefined;
123
+ }
124
+ if (!hasOption(method, rpcAuthorizationConfig)) {
125
+ return undefined;
126
+ }
127
+ const config = getOption(method, rpcAuthorizationConfig);
128
+ return {
129
+ permission: config.permission,
130
+ resourceKind: override?.resourceKind ?? resolveResourceKind(input, config),
131
+ resourceId: override?.resourceId ?? resolveResourceId(input, config),
132
+ deniedMessage: config.errorMsg,
133
+ };
134
+ }
101
135
  /**
102
136
  * The Authorize evaluation for direct handlers: identical skip arms,
103
137
  * target resolution, and decision-to-wire mapping as the pipeline step
@@ -108,19 +142,24 @@ export async function authorizeDirect(method, authorizer, identity, input, overr
108
142
  if (identity.callerClass === "internal") {
109
143
  return;
110
144
  }
111
- if (getOption(method, is_public) ||
112
- getOption(method, is_skip_authorization)) {
145
+ const target = resolveAnnotatedCheck(method, input, override);
146
+ if (target === undefined) {
113
147
  return;
114
148
  }
115
- if (!hasOption(method, rpcAuthorizationConfig)) {
116
- return;
117
- }
118
- const config = getOption(method, rpcAuthorizationConfig);
149
+ return authorizeTarget(authorizer, identity, target);
150
+ }
151
+ /**
152
+ * `authorizeResolvedResource` over an AuthorizationTarget: the check the
153
+ * Authorizer sees carries exactly the three fields of an AuthzCheck, never
154
+ * the copy, so a recording Authorizer (a test's, a driver's audit line)
155
+ * observes the question and nothing else.
156
+ */
157
+ export function authorizeTarget(authorizer, identity, target) {
119
158
  return authorizeResolvedResource(authorizer, identity, {
120
- permission: config.permission,
121
- resourceKind: override?.resourceKind ?? resolveResourceKind(input, config),
122
- resourceId: override?.resourceId ?? resolveResourceId(input, config),
123
- }, config.errorMsg);
159
+ permission: target.permission,
160
+ resourceKind: target.resourceKind,
161
+ resourceId: target.resourceId,
162
+ }, target.deniedMessage);
124
163
  }
125
164
  /**
126
165
  * The SAME evaluation for a check whose target the HANDLER resolved —
@@ -1 +1 @@
1
- {"version":3,"file":"authorize.js","sourceRoot":"","sources":["../../../src/pipeline/steps/authorize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,EAAE,eAAe,EAAE,MAAM,qFAAqF,CAAC;AAEtH,OAAO,EACL,MAAM,IAAI,sBAAsB,EAChC,SAAS,EACT,qBAAqB,GACtB,MAAM,0DAA0D,CAAC;AAQlE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAI5D;;;;GAIG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAC5C,4CAA4C,CAAC;AAE/C,uEAAuE;AACvE,MAAM,CAAC,MAAM,qCAAqC,GAAG,mBAAmB,CAAC;AAEzE;;;;;;GAMG;AACH,MAAM,UAAU,iCAAiC;IAC/C,OAAO;QACL,SAAS;YACP,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;QAC5C,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAC9B,MAAkB,EAClB,UAAsB;IAEtB,OAAO;QACL,IAAI,EAAE,WAAW;QACjB,OAAO,CAAC,GAAyB;YAC/B,OAAO,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,CAAC,cAAc,EAAE,GAAG,CAAC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"version":3,"file":"guard-memory-capture.d.ts","sourceRoot":"","sources":["../../../src/pipeline/steps/guard-memory-capture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,gDAAgD,CAAC;AAG/F,wEAAwE;AACxE,eAAO,MAAM,6BAA6B,iEACsB,CAAC;AAEjE;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,4BAA4B,CAAC;AAEvE,wBAAgB,yBAAyB,CAAC,IAAI,SAAS,WAAW,EAChE,QAAQ,CAAC,EAAE,wBAAwB,GAClC,YAAY,CAAC,IAAI,CAAC,CAsDpB;AAED,4EAA4E;AAC5E,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,wBAAwB,EAAE,MAAM,CAAC;IAC1C,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;CAClC;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,SAAS,WAAW,EAChE,GAAG,EAAE,cAAc,CAAC,IAAI,CAAC,GACxB,uBAAuB,GAAG,SAAS,CAWrC"}
1
+ {"version":3,"file":"guard-memory-capture.d.ts","sourceRoot":"","sources":["../../../src/pipeline/steps/guard-memory-capture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAItD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,gDAAgD,CAAC;AAG/F,wEAAwE;AACxE,eAAO,MAAM,6BAA6B,iEACsB,CAAC;AAEjE;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,4BAA4B,CAAC;AAEvE,wBAAgB,yBAAyB,CAAC,IAAI,SAAS,WAAW,EAChE,QAAQ,CAAC,EAAE,wBAAwB,GAClC,YAAY,CAAC,IAAI,CAAC,CAsDpB;AAED,4EAA4E;AAC5E,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,wBAAwB,EAAE,MAAM,CAAC;IAC1C,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;CAClC;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,SAAS,WAAW,EAChE,GAAG,EAAE,cAAc,CAAC,IAAI,CAAC,GACxB,uBAAuB,GAAG,SAAS,CAWrC"}
@@ -1,4 +1,5 @@
1
1
  import { Code, ConnectError } from "@connectrpc/connect";
2
+ import { isServerComposedRequest } from "../../extensions/identity.js";
2
3
  import { metadataOf } from "./shapes.js";
3
4
  /** The Java MemoryPolicy.MEMORY_CAPTURE_CALLER_MESSAGE, byte-pinned. */
4
5
  export const MEMORY_CAPTURE_CALLER_MESSAGE = "memory can only be captured for a first-party human operator";
@@ -14,7 +15,7 @@ export function newGuardMemoryCaptureStep(provider) {
14
15
  name: "GuardMemoryCapture",
15
16
  async execute(ctx) {
16
17
  const caller = ctx.callerIdentity;
17
- if (caller.callerClass === "internal" || caller.origin === "in-process") {
18
+ if (isServerComposedRequest(caller)) {
18
19
  // Server-composed traversals are not capture requests from a
19
20
  // credential; the entry-point request already passed the gate.
20
21
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"guard-memory-capture.js","sourceRoot":"","sources":["../../../src/pipeline/steps/guard-memory-capture.ts"],"names":[],"mappings":"AAqCA,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAKzD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;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AA0B,CAAC,IAAI,SAAS,WAAW,EACjE,UAAU,EAAE,UAAU,EACtB,SAAS,GAAE,4BAA4B,CAAC,IAAI,CAAM,GACjD,YAAY,CAAC,IAAI,CAAC,CAwEpB"}
1
+ {"version":3,"file":"guard-reserved-labels.d.ts","sourceRoot":"","sources":["../../../src/pipeline/steps/guard-reserved-labels.ts"],"names":[],"mappings":"AAmDA,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAK/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAGjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAK5D,uEAAuE;AACvE,eAAO,MAAM,qBAAqB,gBAAgB,CAAC;AAYnD;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EACxC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAC1C,aAAa,CAAC,MAAM,CAAC,CAQvB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,4BAA4B,CAAC,IAAI,SAAS,WAAW;IACpE,uEAAuE;IACvE,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,cAAc,CAAC,IAAI,CAAC,KAAK,OAAO,GAAG,SAAS,CAAC;IACtE,oFAAoF;IACpF,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,wBAAgB,0BAA0B,CAAC,IAAI,SAAS,WAAW,EACjE,UAAU,EAAE,UAAU,EACtB,SAAS,GAAE,4BAA4B,CAAC,IAAI,CAAM,GACjD,YAAY,CAAC,IAAI,CAAC,CAoEpB"}
@@ -51,6 +51,7 @@
51
51
  import { Code, ConnectError } from "@connectrpc/connect";
52
52
  import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
53
53
  import { IamPermission } from "@stigmer/protos/ai/stigmer/iam/v1/enum_pb";
54
+ import { isServerComposedRequest } from "../../extensions/identity.js";
54
55
  import { internalError } from "../errors.js";
55
56
  import { EXISTING_RESOURCE_KEY } from "./load-existing.js";
56
57
  import { serverStampedReservedLabels } from "./server-stamped-reserved-labels.js";
@@ -83,13 +84,11 @@ export function newGuardReservedLabelsStep(authorizer, positions = {}) {
83
84
  return {
84
85
  name: "GuardReservedLabels",
85
86
  async execute(ctx) {
86
- if (ctx.callerIdentity.callerClass === "internal" ||
87
- ctx.callerIdentity.origin === "in-process") {
88
- // Server-composed request (the Java isInProcessCall arm,
89
- // cloud#386): the trust decision was made by the service code
90
- // that built it — default-instance factories stamp reserved
91
- // labels by design, even when the call propagates the user's
92
- // identity for attribution (ruling R5).
87
+ if (isServerComposedRequest(ctx.callerIdentity)) {
88
+ // The Java isInProcessCall arm (cloud#386): the trust decision was
89
+ // made by the service code that built the request — default-instance
90
+ // factories stamp reserved labels by design, even when the call
91
+ // propagates the user's identity for attribution (ruling R5).
93
92
  return;
94
93
  }
95
94
  const state = stateOf(ctx);
@@ -1 +1 @@
1
- {"version":3,"file":"guard-reserved-labels.js","sourceRoot":"","sources":["../../../src/pipeline/steps/guard-reserved-labels.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGzD,OAAO,EAAE,eAAe,EAAE,MAAM,qFAAqF,CAAC;AACtH,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAG1E,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,2BAA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ACnD,YAAY,EAAE,eAAe,CAAC,QAAQ;oBACtC,UAAU,EAAE,SAAS;iBACtB,CAAC,CAAC;YACL,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,yBAAyB,CAAC,KAAK,CAAC,CAAC;YACzC,CAAC;YACD,QAAQ,QAAQ,CAAC,IAAI,EAAE,CAAC;gBACtB,KAAK,OAAO;oBACV,OAAO;gBACT,KAAK,MAAM,CAAC;gBACZ,KAAK,WAAW;oBACd,MAAM,IAAI,YAAY,CACpB,2BAA2B,qBAAqB,cAAc;wBAC5D,4DAA4D;wBAC5D,YAAY,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,2BAA2B;wBAC3D,0CAA0C,EAC5C,IAAI,CAAC,eAAe,CACrB,CAAC;gBACJ,KAAK,aAAa;oBAChB,MAAM,yBAAyB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;gBAClD,OAAO,CAAC,CAAC,CAAC;oBACR,MAAM,UAAU,GAAU,QAAQ,CAAC;oBACnC,MAAM,yBAAyB,CAC7B,IAAI,KAAK,CAAC,oBAAoB,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,CAAC,CAC5D,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAED,2EAA2E;AAC3E,SAAS,yBAAyB,CAAC,KAAc;IAC/C,OAAO,aAAa,CAClB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EACzD,kDAAkD,CACnD,CAAC;AACJ,CAAC"}
@@ -20,11 +20,15 @@ export declare function findResourceBySlug<Desc extends DescMessage>(store: Stor
20
20
  */
21
21
  export declare function findResourceByLabelAndOrg<Desc extends DescMessage>(store: Store, kind: ApiResourceKind, schema: Desc, labelKey: string, labelValue: string, org: string): Promise<MessageShape<Desc> | undefined>;
22
22
  /**
23
- * Rejects a getByReference lookup that omits org for an org-scoped kind —
24
- * Go RequireOrgForReference. For AUTHORIZATION_SCOPE_TYPE_ORGANIZATION
25
- * kinds a slug is unique only WITHIN an org; resolving an org-less
26
- * reference globally would cross tenant boundaries. The message matches
27
- * the cloud edition verbatim (cross-edition error contract).
23
+ * Rejects a getByReference lookup that omits org — Go RequireOrgForReference,
24
+ * widened to every kind that has a reference lane. A slug is unique only
25
+ * WITHIN an org, so an org-less reference resolves globally and the first
26
+ * match wins: for an org-scoped kind that crosses tenant boundaries, and
27
+ * for an owner-only kind (the execution context) it let a caller name a
28
+ * slug and receive whichever organization's row matched first. Every kind
29
+ * with a reference lane is served per organization, so the rule is the
30
+ * same for all of them. The message matches the cloud edition verbatim
31
+ * (cross-edition error contract); the kind name comes from kind_meta.
28
32
  *
29
33
  * Belongs at the getByReference boundary only — the low-level slug finders
30
34
  * are legitimately called with a relative (possibly empty) org by internal
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/pipeline/steps/helpers.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,eAAe,EAAE,MAAM,qFAAqF,CAAC;AAGtH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAKtD;;;;;GAKG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,SAAS,WAAW,EAC/D,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,eAAe,EACrB,MAAM,EAAE,IAAI,EACZ,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,CAmBzC;AAED;;;;;;;;GAQG;AACH,wBAAsB,yBAAyB,CAAC,IAAI,SAAS,WAAW,EACtE,KAAK,EAAE,KAAK,EACZ,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EAAE,KAAK,EACZ,IAAI,EAAE,eAAe,EACrB,MAAM,EAAE,IAAI,EACZ,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,CAkBzC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,eAAe,EACrB,GAAG,EAAE,MAAM,GACV,IAAI,CAcN;AAOD,qEAAqE;AACrE,wBAAgB,oBAAoB,CAClC,CAAC,EAAE,SAAS,GAAG,SAAS,EACxB,CAAC,EAAE,SAAS,GAAG,SAAS,GACvB,MAAM,CAcR;AAED,0EAA0E;AAC1E,wBAAgB,gBAAgB,CAC9B,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACtC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACnC,OAAO,CAIT"}
@@ -4,7 +4,6 @@
4
4
  * interface, not here — D2 §3).
5
5
  */
6
6
  import { fromBinary } from "@bufbuild/protobuf";
7
- import { AuthorizationScopeType } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/authorization_config_pb";
8
7
  import { getKindMeta } from "../apiresource-meta.js";
9
8
  import { internalError, invalidArgumentError } from "../errors.js";
10
9
  import { metadataOf } from "./shapes.js";
@@ -65,11 +64,15 @@ export async function findResourceByLabelAndOrg(store, kind, schema, labelKey, l
65
64
  return undefined;
66
65
  }
67
66
  /**
68
- * Rejects a getByReference lookup that omits org for an org-scoped kind —
69
- * Go RequireOrgForReference. For AUTHORIZATION_SCOPE_TYPE_ORGANIZATION
70
- * kinds a slug is unique only WITHIN an org; resolving an org-less
71
- * reference globally would cross tenant boundaries. The message matches
72
- * the cloud edition verbatim (cross-edition error contract).
67
+ * Rejects a getByReference lookup that omits org — Go RequireOrgForReference,
68
+ * widened to every kind that has a reference lane. A slug is unique only
69
+ * WITHIN an org, so an org-less reference resolves globally and the first
70
+ * match wins: for an org-scoped kind that crosses tenant boundaries, and
71
+ * for an owner-only kind (the execution context) it let a caller name a
72
+ * slug and receive whichever organization's row matched first. Every kind
73
+ * with a reference lane is served per organization, so the rule is the
74
+ * same for all of them. The message matches the cloud edition verbatim
75
+ * (cross-edition error contract); the kind name comes from kind_meta.
73
76
  *
74
77
  * Belongs at the getByReference boundary only — the low-level slug finders
75
78
  * are legitimately called with a relative (possibly empty) org by internal
@@ -79,21 +82,14 @@ export function requireOrgForReference(kind, org) {
79
82
  if (org !== "") {
80
83
  return;
81
84
  }
82
- let scopeType;
83
85
  let kindName;
84
86
  try {
85
- const meta = getKindMeta(kind);
86
- scopeType = meta.authorization?.scopeType;
87
- kindName = meta.name;
87
+ kindName = getKindMeta(kind).name;
88
88
  }
89
89
  catch (error) {
90
90
  throw internalError(error, "failed to resolve kind metadata for reference org check");
91
91
  }
92
- // protobuf-es strips the shared enum prefix: proto
93
- // AUTHORIZATION_SCOPE_TYPE_ORGANIZATION generates as ORGANIZATION.
94
- if (scopeType === AuthorizationScopeType.ORGANIZATION) {
95
- throw invalidArgumentError(`org is required for ${kindName} lookup`);
96
- }
92
+ throw invalidArgumentError(`org is required for ${kindName} lookup`);
97
93
  }
98
94
  // The two list-step helpers below are duplicated per package in Go (each
99
95
  // controller carries its own copy); the TS tree consolidates them here
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/pipeline/steps/helpers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAKhD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wFAAwF,CAAC;AAGhI,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;;;GAKG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0E;AAC1E,MAAM,UAAU,gBAAgB,CAC9B,cAAsC,EACtC,YAAoC;IAEpC,OAAO,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,KAAK,CACvC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,KAAK,CAChD,CAAC;AACJ,CAAC"}
@@ -1,38 +1,196 @@
1
1
  /**
2
- * NormalizeReferences + ValidateReferences — port
3
- * steps/normalize_references.go and steps/validate_references.go, sharing
4
- * one spec walker (as the Go files share theirs).
2
+ * References — the two shared steps every chain that stores a spec with
3
+ * `ApiResourceReference` fields runs, and the ONE rule that decides whether
4
+ * a reference may be written.
5
5
  *
6
6
  * NormalizeReferences fills EMPTY org fields in ApiResourceReference
7
7
  * messages inside the spec from the resource's own metadata.org, so stored
8
- * references are absolute; explicit orgs (cross-org refs) are preserved.
9
- * Only the spec is walked — status is system-generated and already
10
- * absolute. Runs after BuildNewState/BuildUpdateState, before Persist.
11
- *
12
- * ValidateReferences verifies spec references point at existing resources
13
- * — strict FAILED_PRECONDITION for missing MCP servers (an agent whose MCP
14
- * server is missing cannot execute its declared tools). Runs AFTER
15
- * NormalizeReferences so orgs are resolved.
8
+ * references are absolute; an explicit org is preserved. Only the spec is
9
+ * walked — status is system-generated and already absolute. Runs after
10
+ * BuildNewState/BuildUpdateState, before Persist.
11
+ *
12
+ * ValidateReferences runs directly after it and asks `checkReference` for
13
+ * every reference the walk finds. The rule has three clauses, in the
14
+ * order they are asked:
15
+ *
16
+ * (i) A reference with no organization is refused. After the normalize
17
+ * step the only way an org is still empty is a resource that has
18
+ * none itself; a slug looked up with no org matches any
19
+ * organization's row (helpers.ts), which is the cross-tenant read
20
+ * the reference lane's `requireOrgForReference` exists to forbid.
21
+ * (ii) Same organization as the resource: the target must exist, and,
22
+ * when the target's kind is one the RUN reads as the person
23
+ * (`readByRun` in the table below), its visibility must be at least
24
+ * the resource's on the order private < org < platform — the FLOOR.
25
+ * What a person can run they must also be able to read: an
26
+ * org-visible agent over a private MCP server would run for every
27
+ * member and be readable by one. Environments, OAuth apps and
28
+ * channel apps are resolved by the server on the run's behalf and
29
+ * never read by the person, so their level is not a leak the floor
30
+ * closes, and an org-visible instance may hold a private personal
31
+ * environment as it always has.
32
+ * (iii) Another organization: the target must exist AND be
33
+ * platform-visible, answered with ONE sentence that does not say
34
+ * which failed. The caller has no standing to learn what another
35
+ * organization holds (the anti-probe posture the AgentShare lane set
36
+ * first). The rule reads the target's LEVEL, not tenancy: whether
37
+ * the writer's organization is one the target's identity provider
38
+ * links is the run-time authorizer's question, asked when the run
39
+ * reads the target, and the copy here claims no more than the rule
40
+ * checks. No Environment, OAuth app or channel app is ever
41
+ * platform-visible, so every cross-organization reference to one is
42
+ * refused here.
43
+ *
44
+ * The kind a reference names is the kind its FIELD declares
45
+ * (`reference_kind`, the contract's word for what the field points to),
46
+ * never the `kind` value a client happened to put on the message: the
47
+ * runtime resolves `skill_refs` as skills whatever the message says, and
48
+ * the rule must agree with the runtime. A reference with an empty slug is
49
+ * unset and skipped (the field-level CEL rules own "required").
50
+ *
51
+ * The floor has a second door. Raising a resource's level through
52
+ * updateVisibility could open the same gap a create cannot, so
53
+ * GuardReferenceFloorOnEscalation runs on the two chains whose rows carry
54
+ * run-read references (agent, workflow) after ValidateVisibilityUpdate:
55
+ * when the requested level is above the stored one, every run-read
56
+ * reference the STORED row carries must be at least the requested level,
57
+ * judged by the same function over the same collectors, else the
58
+ * escalation is refused naming the dependencies. Only the floor is asked at
59
+ * that door — a dependency that has since left or stopped being shared was
60
+ * judged when the row was written and is the run's to refuse.
61
+ *
62
+ * REFERENCE_TARGET_KINDS is the one explicit table of kinds a spec may
63
+ * reference, with each kind's schema and its `readByRun` flag: the
64
+ * composition-root idiom (query/search/registry.ts) — an explicit list a
65
+ * test pins against the protos, so a new `reference_kind` in the contract
66
+ * fails the pin until this table says how it is read.
67
+ *
68
+ * Cost: one `listResources` scan per referenced KIND per write (not per
69
+ * reference), decoded once into a (org, slug) index; the same scan every
70
+ * runtime path already pays per reference when it resolves the target at
71
+ * run start. A store read by (kind, org, slug) is the follow-on that
72
+ * removes the scan everywhere, and is not this module's.
73
+ *
74
+ * The refusal copy is exported below. The MCP-server sentence predates the
75
+ * rule and is wire contract (byte-pinned by pipeline/__tests__/steps.test.ts
76
+ * and the agent conformance suite); its siblings for the other kinds take
77
+ * the same shape. `collectSpecReferences` is the walk exported for the
78
+ * readers that ask the reverse question ("who references this?").
16
79
  */
17
- import type { DescMessage } from "@bufbuild/protobuf";
80
+ import type { DescMessage, Message } from "@bufbuild/protobuf";
18
81
  import { reflect } from "@bufbuild/protobuf/reflect";
19
82
  import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
83
+ import { ApiResourceVisibility } from "@stigmer/protos/ai/stigmer/commons/apiresource/enum_pb";
84
+ import type { UpdateVisibilityInputSchema } from "@stigmer/protos/ai/stigmer/commons/apiresource/io_pb";
20
85
  import type { Store } from "../../store/interface.js";
86
+ import { failedPreconditionError } from "../errors.js";
21
87
  import type { PipelineStep } from "../pipeline.js";
22
- export declare function newNormalizeReferencesStep<Desc extends DescMessage>(): PipelineStep<Desc>;
23
- export declare function newValidateReferencesStep<Desc extends DescMessage>(store: Store): PipelineStep<Desc>;
24
- /** One reference a spec carries, as the walker reads it. */
88
+ /** One kind a spec may reference, and how the rule reads it (the module header). */
89
+ export interface ReferenceTargetKind {
90
+ readonly kind: ApiResourceKind;
91
+ readonly schema: DescMessage;
92
+ /** Whether the run reads the target AS THE PERSON — the kinds the floor applies to. */
93
+ readonly readByRun: boolean;
94
+ /** The kind in the refusal copy's words, singular with the plural marker: "MCP server(s)". */
95
+ readonly label: string;
96
+ /** The CLI command a refusal points at, or undefined where the CLI has no verb for the kind. */
97
+ readonly listHint: string | undefined;
98
+ }
99
+ export declare const REFERENCE_TARGET_KINDS: ReadonlyArray<ReferenceTargetKind>;
100
+ export declare function referenceTargetKind(kind: ApiResourceKind): ReferenceTargetKind | undefined;
101
+ /** One reference a spec carries, as the walker reads it; `kind` is the field's declared kind. */
25
102
  export interface SpecReference {
26
103
  readonly kind: ApiResourceKind;
27
104
  readonly slug: string;
28
105
  readonly org: string;
29
106
  }
107
+ /** The resource the references belong to, as the rule needs it. */
108
+ export interface ReferenceParent {
109
+ readonly org: string;
110
+ readonly visibility: ApiResourceVisibility;
111
+ }
112
+ /** What the rule found for one reference; the collectors turn it into copy. */
113
+ export type ReferenceVerdict = {
114
+ readonly kind: "ok";
115
+ }
116
+ /** Clause (i): the reference names no organization. */
117
+ | {
118
+ readonly kind: "no-org";
119
+ }
120
+ /** Clause (ii): the same-organization target does not exist. */
121
+ | {
122
+ readonly kind: "missing";
123
+ }
124
+ /** Clause (ii): the target exists and is less visible than the resource. */
125
+ | {
126
+ readonly kind: "below-floor";
127
+ readonly targetVisibility: ApiResourceVisibility;
128
+ }
129
+ /** Clause (iii): the other-organization target is missing or not platform-visible — one answer. */
130
+ | {
131
+ readonly kind: "not-available";
132
+ };
133
+ /** The visibility of every referenced row the rule may need, one scan per kind (the module header). */
134
+ export interface ReferenceTargets {
135
+ visibilityOf(ref: SpecReference): ApiResourceVisibility | undefined;
136
+ }
137
+ /**
138
+ * Loads the rows the given references could name: one `listResources` per
139
+ * distinct kind, decoded once, indexed by (org, slug). A row that does not
140
+ * decode is skipped as the slug helpers skip it — it is not a row a
141
+ * reference can reach. A reference whose kind is not in the table is a
142
+ * contract the pin test has not admitted yet and is an internal fault.
143
+ */
144
+ export declare function loadReferenceTargets(store: Store, refs: ReadonlyArray<SpecReference>): Promise<ReferenceTargets>;
145
+ /** The three clauses of the module header, for one reference. */
146
+ export declare function checkReference(targets: ReferenceTargets, parent: ReferenceParent, ref: SpecReference): ReferenceVerdict;
147
+ /** Clause (i)'s sentence. */
148
+ export declare function noOrgReferenceMessage(entry: ReferenceTargetKind, slug: string): string;
149
+ /**
150
+ * Clause (ii)'s sentence for the targets not found, one per kind. The MCP
151
+ * server form is the wire contract that predates the rule; the others are
152
+ * its siblings.
153
+ */
154
+ export declare function missingReferencesMessage(entry: ReferenceTargetKind, handles: ReadonlyArray<{
155
+ readonly slug: string;
156
+ readonly org: string;
157
+ }>): string;
158
+ /** Clause (ii)'s floor sentence: the dependency and its level, against the resource's. */
159
+ export declare function belowFloorMessage(entry: ReferenceTargetKind, ref: SpecReference, targetVisibility: ApiResourceVisibility, parentVisibility: ApiResourceVisibility): string;
160
+ /** Clause (iii)'s one sentence — the same whether the target is missing or not platform-visible. */
161
+ export declare function notAvailableReferenceMessage(entry: ReferenceTargetKind, ref: SpecReference): string;
162
+ /**
163
+ * The refusal for a set of verdicts, or undefined when every one is ok.
164
+ * Missing same-organization targets are grouped per kind into one sentence
165
+ * (the contract's shape); every other refusal is its own sentence; the
166
+ * sentences are joined in the order the references were read. A no-org
167
+ * reference is malformed input (INVALID_ARGUMENT); everything else is a
168
+ * precondition the store does not meet (FAILED_PRECONDITION), the code the
169
+ * MCP-server contract already answers.
170
+ */
171
+ export declare function referenceRefusal(parent: ReferenceParent, verdicts: ReadonlyArray<{
172
+ readonly ref: SpecReference;
173
+ readonly verdict: ReferenceVerdict;
174
+ }>): ReturnType<typeof failedPreconditionError> | undefined;
175
+ export declare function newNormalizeReferencesStep<Desc extends DescMessage>(): PipelineStep<Desc>;
176
+ export declare function newValidateReferencesStep<Desc extends DescMessage>(store: Store): PipelineStep<Desc>;
177
+ /** The rule over a collected list: load once, check each, render the refusal. */
178
+ export declare function checkReferences(store: Store, parent: ReferenceParent, refs: ReadonlyArray<SpecReference>): Promise<ReturnType<typeof referenceRefusal>>;
179
+ /** The references a stored row carries, for the escalation door; a chain passes one collector per place its row keeps them. */
180
+ export type ReferenceCollector = (row: Message) => ReadonlyArray<SpecReference>;
181
+ /**
182
+ * The floor's second door (the module header): on an updateVisibility chain,
183
+ * after the loaded row is on the context under `targetKey` and after
184
+ * ValidateVisibilityUpdate, refuses raising the level while a run-read
185
+ * reference the row carries would end below it.
186
+ */
187
+ export declare function newGuardReferenceFloorOnEscalationStep(store: Store, targetKey: string, collectors: ReadonlyArray<ReferenceCollector>): PipelineStep<typeof UpdateVisibilityInputSchema>;
30
188
  /**
31
- * Every ApiResourceReference in a resource's spec — the same walk
32
- * ValidateReferences runs, exported for the readers that ask the reverse
33
- * question ("who references this?"): the plugin delete guard scans an
34
- * organization's agents and workflows for references to a member it is
35
- * about to remove.
189
+ * Every ApiResourceReference in a resource's spec, each with the kind its
190
+ * field declares — the walk both steps run, exported for the readers that
191
+ * ask the reverse question ("who references this?"): the plugin delete
192
+ * guard scans an organization's agents and workflows for references to a
193
+ * member it is about to remove.
36
194
  */
37
195
  export declare function collectSpecReferences(schema: DescMessage, msg: Parameters<typeof reflect>[1]): SpecReference[];
38
196
  //# sourceMappingURL=references.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"references.d.ts","sourceRoot":"","sources":["../../../src/pipeline/steps/references.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAIrD,OAAO,EAAE,eAAe,EAAE,MAAM,qFAAqF,CAAC;AAEtH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAQnD,wBAAgB,0BAA0B,CACxC,IAAI,SAAS,WAAW,KACrB,YAAY,CAAC,IAAI,CAAC,CAwBtB;AAED,wBAAgB,yBAAyB,CAAC,IAAI,SAAS,WAAW,EAChE,KAAK,EAAE,KAAK,GACX,YAAY,CAAC,IAAI,CAAC,CA0CpB;AAED,4DAA4D;AAC5D,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAA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