@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
@@ -41,26 +41,18 @@
41
41
  * `skipped` is therefore complete once every case has run; a consumer
42
42
  * pins it after the cases, which is the order a test file declares them.
43
43
  *
44
- * Context. A check's `context.allow` is the `allow_public` parameter
45
- * (tuples.ts). A check without a context runs with `allow: false`, the
46
- * listing posture: OpenFGA itself would fault on a conditional tuple it
47
- * reached with the parameter missing, so the cloud's documents never do
48
- * that — their CI would already fail — and the choice cannot change an
49
- * answer the oracle gives. The parser is strict on purpose: an unknown
50
- * key anywhere is a thrown fault, so a change to the format upstream is
51
- * loud here rather than half-run.
44
+ * The parser is strict on purpose: an unknown key anywhere is a thrown
45
+ * fault, so a change to the format upstream is loud here rather than
46
+ * half-run. The model declares no condition, so the format's `condition`
47
+ * on a tuple and `context` on a check are among the keys refused: a
48
+ * document that still carries them is written against a model this
49
+ * evaluator does not answer, and saying so beats running it half-blind.
52
50
  */
53
51
  import assert from "node:assert/strict";
54
52
 
55
53
  import { checkRelation } from "./evaluator.js";
56
54
  import type { Model } from "./model/index.js";
57
- import type {
58
- CheckContext,
59
- Person,
60
- Subject,
61
- Tuple,
62
- TupleSource,
63
- } from "./tuples.js";
55
+ import type { Person, Subject, Tuple, TupleSource } from "./tuples.js";
64
56
  import {
65
57
  ACCOUNT_TYPE,
66
58
  newInMemoryTupleSource,
@@ -76,20 +68,17 @@ export interface StoreTestTuple {
76
68
  readonly user: string;
77
69
  readonly relation: string;
78
70
  readonly object: string;
79
- readonly condition?: { readonly name: string };
80
71
  }
81
72
 
82
73
  export interface StoreTestCheck {
83
74
  readonly user: string;
84
75
  readonly object: string;
85
- readonly context?: CheckContext;
86
76
  readonly assertions: Readonly<Record<string, boolean>>;
87
77
  }
88
78
 
89
79
  export interface StoreTestListObjects {
90
80
  readonly user: string;
91
81
  readonly type: string;
92
- readonly context?: CheckContext;
93
82
  readonly assertions: Readonly<Record<string, ReadonlyArray<string>>>;
94
83
  }
95
84
 
@@ -132,28 +121,12 @@ export function parseStoreTestDocument(
132
121
  }
133
122
 
134
123
  function parseTuple(value: unknown, where: string): StoreTestTuple {
135
- const entry = record(value, where, [
136
- "user",
137
- "relation",
138
- "object",
139
- "condition",
140
- ]);
141
- const tuple: StoreTestTuple = {
124
+ const entry = record(value, where, ["user", "relation", "object"]);
125
+ return {
142
126
  user: text(entry["user"], `${where}.user`),
143
127
  relation: text(entry["relation"], `${where}.relation`),
144
128
  object: text(entry["object"], `${where}.object`),
145
129
  };
146
- if (entry["condition"] === undefined) {
147
- return tuple;
148
- }
149
- const condition = record(entry["condition"], `${where}.condition`, [
150
- "name",
151
- "context",
152
- ]);
153
- return {
154
- ...tuple,
155
- condition: { name: text(condition["name"], `${where}.condition.name`) },
156
- };
157
130
  }
158
131
 
159
132
  function parseTest(value: unknown, where: string): StoreTest {
@@ -173,12 +146,7 @@ function parseTest(value: unknown, where: string): StoreTest {
173
146
  }
174
147
 
175
148
  function parseCheck(value: unknown, where: string): StoreTestCheck {
176
- const entry = record(value, where, [
177
- "user",
178
- "object",
179
- "context",
180
- "assertions",
181
- ]);
149
+ const entry = record(value, where, ["user", "object", "assertions"]);
182
150
  const assertions = record(entry["assertions"], `${where}.assertions`);
183
151
  const parsed: Record<string, boolean> = {};
184
152
  for (const [relation, expected] of Object.entries(assertions)) {
@@ -187,17 +155,15 @@ function parseCheck(value: unknown, where: string): StoreTestCheck {
187
155
  }
188
156
  parsed[relation] = expected;
189
157
  }
190
- const context = parseContext(entry["context"], `${where}.context`);
191
158
  return {
192
159
  user: text(entry["user"], `${where}.user`),
193
160
  object: text(entry["object"], `${where}.object`),
194
- ...(context === undefined ? {} : { context }),
195
161
  assertions: parsed,
196
162
  };
197
163
  }
198
164
 
199
165
  function parseListObjects(value: unknown, where: string): StoreTestListObjects {
200
- const entry = record(value, where, ["user", "type", "context", "assertions"]);
166
+ const entry = record(value, where, ["user", "type", "assertions"]);
201
167
  const assertions = record(entry["assertions"], `${where}.assertions`);
202
168
  const parsed: Record<string, ReadonlyArray<string>> = {};
203
169
  for (const [relation, expected] of Object.entries(assertions)) {
@@ -205,26 +171,13 @@ function parseListObjects(value: unknown, where: string): StoreTestListObjects {
205
171
  (item, index) => text(item, `${where}.assertions.${relation}[${index}]`),
206
172
  );
207
173
  }
208
- const context = parseContext(entry["context"], `${where}.context`);
209
174
  return {
210
175
  user: text(entry["user"], `${where}.user`),
211
176
  type: text(entry["type"], `${where}.type`),
212
- ...(context === undefined ? {} : { context }),
213
177
  assertions: parsed,
214
178
  };
215
179
  }
216
180
 
217
- function parseContext(value: unknown, where: string): CheckContext | undefined {
218
- if (value === undefined) {
219
- return undefined;
220
- }
221
- const entry = record(value, where, ["allow"]);
222
- if (typeof entry["allow"] !== "boolean") {
223
- throw new Error(`${where}.allow: expected a boolean`);
224
- }
225
- return { allow: entry["allow"] };
226
- }
227
-
228
181
  function record(
229
182
  value: unknown,
230
183
  where: string,
@@ -297,9 +250,6 @@ export interface StoreTestKit {
297
250
  readonly skipped: ReadonlyArray<StoreTestSkip>;
298
251
  }
299
252
 
300
- /** The listing posture, for a check the document leaves without a context (the module header). */
301
- const CONTEXT_WHEN_ABSENT: CheckContext = { allow: false };
302
-
303
253
  /**
304
254
  * The document's tests as runnable cases over `model`, plus every
305
255
  * assertion group the kit does not run.
@@ -346,7 +296,6 @@ export function storeTestCases(
346
296
  for (const item of runnable) {
347
297
  const object = parseObjectRef(item.object);
348
298
  const person = personOf(item.user);
349
- const context = item.context ?? CONTEXT_WHEN_ABSENT;
350
299
  for (const [relation, expected] of Object.entries(item.assertions)) {
351
300
  const recording = recordUndeclaredTypes(source, model);
352
301
  const actual = await checkRelation(
@@ -354,7 +303,6 @@ export function storeTestCases(
354
303
  object,
355
304
  relation,
356
305
  person,
357
- context,
358
306
  );
359
307
  if (recording.reached.size > 0) {
360
308
  skipped.push({
@@ -371,7 +319,7 @@ export function storeTestCases(
371
319
  assert.equal(
372
320
  actual,
373
321
  expected,
374
- `${document.name} :: ${test.name}: ${item.user} ${relation} ${item.object} (allow: ${String(context.allow)}) expected ${String(expected)}, got ${String(actual)}`,
322
+ `${document.name} :: ${test.name}: ${item.user} ${relation} ${item.object} expected ${String(expected)}, got ${String(actual)}`,
375
323
  );
376
324
  }
377
325
  }
@@ -389,10 +337,9 @@ interface RecordingTupleSource extends TupleSource {
389
337
  /**
390
338
  * A view of `inner` that records, for one walk, every subject type the
391
339
  * evaluator read that `model` does not declare. A person
392
- * (`identity_account:<id>`, the wildcard) is a subject the evaluator
393
- * compares, never a type it resolves, so it is not a "reach" whatever
394
- * the model declares; a userset or a parent object of an undeclared
395
- * type is.
340
+ * (`identity_account:<id>`) is a subject the evaluator compares, never a
341
+ * type it resolves, so it is not a "reach" whatever the model declares; a
342
+ * userset or a parent object of an undeclared type is.
396
343
  */
397
344
  function recordUndeclaredTypes(
398
345
  inner: TupleSource,
@@ -423,8 +370,6 @@ function resolvedTypeOf(subject: Subject): string | undefined {
423
370
  : subject.object.type;
424
371
  case "userset":
425
372
  return subject.object.type;
426
- case "wildcard":
427
- return undefined;
428
373
  default: {
429
374
  const exhaustive: never = subject;
430
375
  throw new Error(`unknown subject form: ${JSON.stringify(exhaustive)}`);
@@ -433,14 +378,10 @@ function resolvedTypeOf(subject: Subject): string | undefined {
433
378
  }
434
379
 
435
380
  function tupleOf(entry: StoreTestTuple): Tuple {
436
- const subject = parseSubject(entry.user);
437
381
  return {
438
382
  object: parseObjectRef(entry.object),
439
383
  relation: entry.relation,
440
- subject:
441
- subject.form === "wildcard" && entry.condition !== undefined
442
- ? { ...subject, condition: entry.condition.name }
443
- : subject,
384
+ subject: parseSubject(entry.user),
444
385
  };
445
386
  }
446
387
 
@@ -1,9 +1,11 @@
1
1
  /**
2
2
  * The tuple vocabulary of the built-in authorizer — the OpenFGA notions
3
3
  * the cloud's model is written in (object, relation, subject; a subject
4
- * being an object, a userset `type:id#relation`, or the public wildcard
5
- * `type:*` under a condition), typed once so the evaluator, the
6
- * derivation and the store-test kit speak one language. Nothing here is
4
+ * being an object or a userset `type:id#relation`), typed once so the
5
+ * evaluator, the derivation and the store-test kit speak one language. The
6
+ * model declares no wildcard subject and no condition: every reader of a
7
+ * row is an account or the holder of a relation on an object, which is
8
+ * why a check needs no context parameter. Nothing here is
7
9
  * stored: open source derives every tuple from a row (derived-tuples.ts)
8
10
  * or reads it from an IamPolicy row, and this module only names what a
9
11
  * tuple IS.
@@ -18,28 +20,18 @@
18
20
  * The type is named here; the construction (`personFor`, `resolvePerson`)
19
21
  * is person.ts's, so this module stays vocabulary with no I/O.
20
22
  *
21
- * `CheckContext` is the FGA condition context. The one condition the
22
- * model declares is `allow_public(allow: bool)` on the public wildcard,
23
- * and the cloud's own posture (stigmer-cloud authorizer/fga-authorizer.ts,
24
- * the Java BuildCheckRequest) is `allow: true` on a point check — a public
25
- * resource reads for any authenticated caller — and `allow: false` in a
26
- * listing, which keeps a public wildcard from flooding an organization's
27
- * catalog. The parameter is required so a caller states which posture it
28
- * is in; there is no default because either one is wrong for the other.
29
- *
30
- * The string forms (`agent:x`, `organization:acme#viewer`,
31
- * `identity_account:*`) are the notation the cloud's store tests and the
32
- * IamPolicy proto both use; parse and format are here so the kit and the
33
- * tests never spell them a second way.
23
+ * The string forms (`agent:x`, `organization:acme#viewer`) are the
24
+ * notation the cloud's store tests and the IamPolicy proto both use; parse
25
+ * and format are here so the kit and the tests never spell them a second
26
+ * way. The wildcard notation `type:*` is refused by the parser: the model
27
+ * has no line that admits one, so a fixture or a policy that spells it is
28
+ * a mistake to surface, never a subject to carry.
34
29
  */
35
30
  import type { Message } from "@bufbuild/protobuf";
36
31
 
37
32
  /** The FGA type name of the kind every person is: `identity_account:<id>`. */
38
33
  export const ACCOUNT_TYPE = "identity_account";
39
34
 
40
- /** The one condition the model declares; it guards the public wildcard. */
41
- export const ALLOW_PUBLIC_CONDITION = "allow_public";
42
-
43
35
  /** `type:id` — an object of the model. */
44
36
  export interface ObjectRef {
45
37
  readonly type: string;
@@ -55,12 +47,6 @@ export type Subject =
55
47
  readonly form: "userset";
56
48
  readonly object: ObjectRef;
57
49
  readonly relation: string;
58
- }
59
- /** `type:*` — every object of the type, honoured only when its condition holds. */
60
- | {
61
- readonly form: "wildcard";
62
- readonly type: string;
63
- readonly condition: string | undefined;
64
50
  };
65
51
 
66
52
  export interface Tuple {
@@ -97,11 +83,6 @@ export interface Person {
97
83
  readonly aliases: ReadonlySet<string>;
98
84
  }
99
85
 
100
- /** The condition parameters of a check (the module header). */
101
- export interface CheckContext {
102
- readonly allow: boolean;
103
- }
104
-
105
86
  // ---------------------------------------------------------------------------
106
87
  // The string notation.
107
88
  // ---------------------------------------------------------------------------
@@ -120,10 +101,8 @@ export function formatObjectRef(object: ObjectRef): string {
120
101
  }
121
102
 
122
103
  /**
123
- * `type:id`, `type:id#relation` or `type:*` → Subject. A wildcard parsed
124
- * from text carries no condition; the caller attaches one when its source
125
- * says so (the store tests carry it on the tuple, the derivation attaches
126
- * the model's).
104
+ * `type:id` or `type:id#relation` → Subject. `type:*` is refused (the
105
+ * module header): no line of the model admits a wildcard subject.
127
106
  */
128
107
  export function parseSubject(text: string): Subject {
129
108
  const hash = text.indexOf("#");
@@ -136,7 +115,9 @@ export function parseSubject(text: string): Subject {
136
115
  }
137
116
  const object = parseObjectRef(text);
138
117
  if (object.id === "*") {
139
- return { form: "wildcard", type: object.type, condition: undefined };
118
+ throw new Error(
119
+ `wildcard subject '${text}' is not admitted: the model declares no wildcard line`,
120
+ );
140
121
  }
141
122
  return { form: "object", object };
142
123
  }
@@ -147,10 +128,6 @@ export function formatSubject(subject: Subject): string {
147
128
  return formatObjectRef(subject.object);
148
129
  case "userset":
149
130
  return `${formatObjectRef(subject.object)}#${subject.relation}`;
150
- case "wildcard":
151
- return subject.condition === undefined
152
- ? `${subject.type}:*`
153
- : `${subject.type}:* with ${subject.condition}`;
154
131
  default: {
155
132
  const exhaustive: never = subject;
156
133
  throw new Error(`unknown subject form: ${JSON.stringify(exhaustive)}`);
@@ -131,8 +131,10 @@ function agentInput(overrides?: {
131
131
  }
132
132
 
133
133
  /**
134
- * Seeds an MCP server straight into the store — the mcpserver controller
135
- * arrives with sub-project #9, and the agent pipelines only need the row.
134
+ * Seeds an MCP server straight into the store — the agent pipelines only
135
+ * need the row. Org-visible, the level the mcpserver create chain would
136
+ * have stamped: an org-visible agent may reference it under the reference
137
+ * floor, as it would a server created through the API.
136
138
  */
137
139
  async function seedMcpServer(opts: {
138
140
  id: string;
@@ -155,6 +157,7 @@ async function seedMcpServer(opts: {
155
157
  name: opts.slug,
156
158
  slug: opts.slug,
157
159
  org: opts.org ?? ORG,
160
+ visibility: ApiResourceVisibility.visibility_org,
158
161
  },
159
162
  spec: { env: opts.env ?? {} },
160
163
  status: connected
@@ -309,11 +312,11 @@ describe("agent enabled-tools validation (#402)", () => {
309
312
  });
310
313
 
311
314
  describe("agent cascade delete (oss#611)", () => {
312
- it("sweeps ALL instances by spec.agent_id (cross-org included), deletes same-org shares, keeps cross-org shares", async () => {
315
+ it("sweeps ALL instances by spec.agent_id (cross-org included), deletes same-org shares, keeps a stored cross-org share", async () => {
313
316
  const agent = await command.create(
314
317
  agentInput({
315
318
  name: "Cascade Target",
316
- visibility: ApiResourceVisibility.visibility_public,
319
+ visibility: ApiResourceVisibility.visibility_org,
317
320
  }),
318
321
  );
319
322
  const agentId = agent.metadata!.id;
@@ -355,6 +358,10 @@ describe("agent cascade delete (oss#611)", () => {
355
358
  AgentShareSchema,
356
359
  sameOrgShare,
357
360
  );
361
+ // A share in another organization is a row no create admits any more
362
+ // (a share's agent lives in the share's organization); one written
363
+ // before that rule is still another organization's row, and the
364
+ // cascade leaves it as it always did.
358
365
  const crossOrgShare = create(AgentShareSchema, {
359
366
  metadata: { id: "ash_cross_org", name: "cross-org-share", org: "globex" },
360
367
  spec: {
@@ -37,11 +37,11 @@ import type { PipelineStep } from "../../pipeline/pipeline.js";
37
37
  import { callerIdentityOf } from "../../pipeline/interceptors/auth.js";
38
38
  import { RequestContext } from "../../pipeline/request-context.js";
39
39
  import { newAuthorizeStep } from "../../pipeline/steps/authorize.js";
40
- import { newGuardReservedLabelsStep } from "../../pipeline/steps/guard-reserved-labels.js";
41
40
  import {
42
- newAuthorizeVisibilityTransitionStep,
43
- newGuardPublicVisibilityStep,
44
- } from "../../pipeline/steps/visibility-gates.js";
41
+ loadedTargetAsMethod,
42
+ newAuthorizeResolvedTargetStep,
43
+ } from "../../pipeline/steps/authorize-resolved-target.js";
44
+ import { newGuardReservedLabelsStep } from "../../pipeline/steps/guard-reserved-labels.js";
45
45
  import {
46
46
  newBuildNewStateStep,
47
47
  setAuditFieldsForUpdate,
@@ -73,6 +73,8 @@ import {
73
73
  newLoadTargetStep,
74
74
  } from "../../pipeline/steps/load-target.js";
75
75
  import {
76
+ collectSpecReferences,
77
+ newGuardReferenceFloorOnEscalationStep,
76
78
  newNormalizeReferencesStep,
77
79
  newValidateReferencesStep,
78
80
  } from "../../pipeline/steps/references.js";
@@ -164,7 +166,6 @@ async function createAgent(
164
166
  .addStep(newResolveSlugStep())
165
167
  .addStep(newCheckDuplicateStep(deps.store))
166
168
  .addStep(newBuildNewStateStep())
167
- .addStep(newGuardPublicVisibilityStep(deps.authorizer))
168
169
  .addStep(newGuardReservedLabelsStep(deps.authorizer))
169
170
  .addStep(newNormalizeReferencesStep())
170
171
  .addStep(newValidateReferencesStep(deps.store))
@@ -357,10 +358,13 @@ async function updateVisibility(
357
358
  )
358
359
  .addStep(newRecordVisibilityBeforeUpdateStep(UPDATE_VISIBILITY_AGENT_KEY))
359
360
  .addStep(newValidateVisibilityUpdateStep())
361
+ // The reference floor's second door: an agent may not be raised above
362
+ // the skills and MCP servers it runs with.
360
363
  .addStep(
361
- newAuthorizeVisibilityTransitionStep(
364
+ newGuardReferenceFloorOnEscalationStep(
365
+ deps.store,
362
366
  UPDATE_VISIBILITY_AGENT_KEY,
363
- deps.authorizer,
367
+ [(row) => collectSpecReferences(AgentSchema, row)],
364
368
  ),
365
369
  )
366
370
  .addStep(newSetAgentVisibilityStep())
@@ -527,6 +531,12 @@ async function getByReference(
527
531
  )
528
532
  .addStep(newValidateProtoStep())
529
533
  .addStep(newLoadByReferenceStep(deps.store, AgentSchema))
534
+ .addStep(
535
+ newAuthorizeResolvedTargetStep(
536
+ deps.authorizer,
537
+ loadedTargetAsMethod(AgentQueryController.method.get),
538
+ ),
539
+ )
530
540
  .build()
531
541
  .execute(reqCtx);
532
542
  return reqCtx.get(TARGET_RESOURCE_KEY) as Agent;