@stigmer/server 3.27.1 → 3.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. package/README.md +2 -0
  2. package/dist/authorization/authorizer.d.ts +7 -5
  3. package/dist/authorization/authorizer.d.ts.map +1 -1
  4. package/dist/authorization/authorizer.js +7 -5
  5. package/dist/authorization/authorizer.js.map +1 -1
  6. package/dist/authorization/derived-tuples.d.ts +3 -1
  7. package/dist/authorization/derived-tuples.d.ts.map +1 -1
  8. package/dist/authorization/derived-tuples.js +52 -2
  9. package/dist/authorization/derived-tuples.js.map +1 -1
  10. package/dist/authorization/evaluator.d.ts +9 -10
  11. package/dist/authorization/evaluator.d.ts.map +1 -1
  12. package/dist/authorization/evaluator.js.map +1 -1
  13. package/dist/authorization/list-read-scope.d.ts.map +1 -1
  14. package/dist/authorization/list-read-scope.js +29 -18
  15. package/dist/authorization/list-read-scope.js.map +1 -1
  16. package/dist/authorization/model/bindings.d.ts +41 -0
  17. package/dist/authorization/model/bindings.d.ts.map +1 -0
  18. package/dist/authorization/model/bindings.js +89 -0
  19. package/dist/authorization/model/bindings.js.map +1 -0
  20. package/dist/authorization/model/data/authorization-model.json +3114 -0
  21. package/dist/authorization/model/default-of.d.ts +2 -2
  22. package/dist/authorization/model/execution-viewer.d.ts +3 -0
  23. package/dist/authorization/model/execution-viewer.d.ts.map +1 -0
  24. package/dist/authorization/model/execution-viewer.js +50 -0
  25. package/dist/authorization/model/execution-viewer.js.map +1 -0
  26. package/dist/authorization/model/index.d.ts +33 -21
  27. package/dist/authorization/model/index.d.ts.map +1 -1
  28. package/dist/authorization/model/index.js +74 -52
  29. package/dist/authorization/model/index.js.map +1 -1
  30. package/dist/authorization/model/openfga-json.d.ts +18 -0
  31. package/dist/authorization/model/openfga-json.d.ts.map +1 -0
  32. package/dist/authorization/model/openfga-json.js +266 -0
  33. package/dist/authorization/model/openfga-json.js.map +1 -0
  34. package/dist/authorization/model/rewrite.d.ts +39 -67
  35. package/dist/authorization/model/rewrite.d.ts.map +1 -1
  36. package/dist/authorization/model/rewrite.js +1 -117
  37. package/dist/authorization/model/rewrite.js.map +1 -1
  38. package/dist/authorization/strict-json.d.ts +20 -0
  39. package/dist/authorization/strict-json.d.ts.map +1 -0
  40. package/dist/authorization/strict-json.js +45 -0
  41. package/dist/authorization/strict-json.js.map +1 -0
  42. package/dist/boot/compose.d.ts.map +1 -1
  43. package/dist/boot/compose.js +9 -7
  44. package/dist/boot/compose.js.map +1 -1
  45. package/dist/boot/list-indexes.d.ts.map +1 -1
  46. package/dist/boot/list-indexes.js +6 -0
  47. package/dist/boot/list-indexes.js.map +1 -1
  48. package/dist/domain/iampolicy/list-index.d.ts +2 -0
  49. package/dist/domain/iampolicy/list-index.d.ts.map +1 -0
  50. package/dist/domain/iampolicy/list-index.js +32 -0
  51. package/dist/domain/iampolicy/list-index.js.map +1 -0
  52. package/dist/domain/iampolicy/resource-store.d.ts.map +1 -1
  53. package/dist/domain/iampolicy/resource-store.js +24 -11
  54. package/dist/domain/iampolicy/resource-store.js.map +1 -1
  55. package/dist/domain/workflowexecution/list-index.d.ts +1 -1
  56. package/dist/extensions/list-read-scope.d.ts +20 -3
  57. package/dist/extensions/list-read-scope.d.ts.map +1 -1
  58. package/dist/extensions/list-read-scope.js +22 -2
  59. package/dist/extensions/list-read-scope.js.map +1 -1
  60. package/dist/index.d.ts +8 -8
  61. package/dist/index.d.ts.map +1 -1
  62. package/dist/index.js +20 -5
  63. package/dist/index.js.map +1 -1
  64. package/package.json +7 -6
  65. package/src/authorization/README.md +48 -39
  66. package/src/authorization/__tests__/authorizer.test.ts +5 -14
  67. package/src/authorization/__tests__/derived-tuples.test.ts +192 -17
  68. package/src/authorization/__tests__/evaluator.test.ts +53 -160
  69. package/src/authorization/__tests__/facts.test.ts +5 -11
  70. package/src/authorization/__tests__/list-read-scope.measure.test.ts +424 -62
  71. package/src/authorization/__tests__/list-read-scope.test.ts +15 -14
  72. package/src/authorization/__tests__/organization-directory.test.ts +2 -2
  73. package/src/authorization/__tests__/store-test-kit.ts +246 -0
  74. package/src/authorization/__tests__/store-tests.test.ts +91 -223
  75. package/src/authorization/__tests__/support.ts +30 -2
  76. package/src/authorization/__tests__/throwaway-model.ts +75 -0
  77. package/src/authorization/__tests__/wire-permissions.test.ts +141 -107
  78. package/src/authorization/authorizer.ts +7 -5
  79. package/src/authorization/derived-tuples.ts +105 -16
  80. package/src/authorization/evaluator.ts +8 -10
  81. package/src/authorization/list-read-scope.ts +37 -22
  82. package/src/authorization/model/__tests__/openfga-json.test.ts +353 -0
  83. package/src/authorization/model/__tests__/registry.test.ts +102 -276
  84. package/src/authorization/model/bindings.ts +131 -0
  85. package/src/authorization/model/data/authorization-model.json +3114 -0
  86. package/src/authorization/model/default-of.ts +2 -2
  87. package/src/authorization/model/execution-viewer.ts +56 -0
  88. package/src/authorization/model/index.ts +81 -72
  89. package/src/authorization/model/openfga-json.ts +310 -0
  90. package/src/authorization/model/rewrite.ts +39 -188
  91. package/src/authorization/strict-json.ts +52 -0
  92. package/src/boot/__tests__/list-indexes.test.ts +4 -0
  93. package/src/boot/compose.ts +9 -7
  94. package/src/boot/list-indexes.ts +6 -0
  95. package/src/domain/iampolicy/__tests__/resource-store.test.ts +65 -5
  96. package/src/domain/iampolicy/list-index.ts +33 -0
  97. package/src/domain/iampolicy/resource-store.ts +24 -11
  98. package/src/extensions/__tests__/built-in-authorization-composed.test.ts +3 -6
  99. package/src/extensions/list-read-scope.ts +32 -4
  100. package/src/index.ts +20 -44
  101. package/dist/authorization/model/agent.d.ts +0 -2
  102. package/dist/authorization/model/agent.d.ts.map +0 -1
  103. package/dist/authorization/model/agent.js +0 -43
  104. package/dist/authorization/model/agent.js.map +0 -1
  105. package/dist/authorization/model/agent_channel.d.ts +0 -2
  106. package/dist/authorization/model/agent_channel.d.ts.map +0 -1
  107. package/dist/authorization/model/agent_channel.js +0 -39
  108. package/dist/authorization/model/agent_channel.js.map +0 -1
  109. package/dist/authorization/model/agent_execution.d.ts +0 -2
  110. package/dist/authorization/model/agent_execution.d.ts.map +0 -1
  111. package/dist/authorization/model/agent_execution.js +0 -25
  112. package/dist/authorization/model/agent_execution.js.map +0 -1
  113. package/dist/authorization/model/agent_instance.d.ts +0 -2
  114. package/dist/authorization/model/agent_instance.d.ts.map +0 -1
  115. package/dist/authorization/model/agent_instance.js +0 -48
  116. package/dist/authorization/model/agent_instance.js.map +0 -1
  117. package/dist/authorization/model/agent_share.d.ts +0 -2
  118. package/dist/authorization/model/agent_share.d.ts.map +0 -1
  119. package/dist/authorization/model/agent_share.js +0 -29
  120. package/dist/authorization/model/agent_share.js.map +0 -1
  121. package/dist/authorization/model/api_key.d.ts +0 -2
  122. package/dist/authorization/model/api_key.d.ts.map +0 -1
  123. package/dist/authorization/model/api_key.js +0 -27
  124. package/dist/authorization/model/api_key.js.map +0 -1
  125. package/dist/authorization/model/artifact.d.ts +0 -2
  126. package/dist/authorization/model/artifact.d.ts.map +0 -1
  127. package/dist/authorization/model/artifact.js +0 -27
  128. package/dist/authorization/model/artifact.js.map +0 -1
  129. package/dist/authorization/model/channel_app.d.ts +0 -2
  130. package/dist/authorization/model/channel_app.d.ts.map +0 -1
  131. package/dist/authorization/model/channel_app.js +0 -28
  132. package/dist/authorization/model/channel_app.js.map +0 -1
  133. package/dist/authorization/model/environment.d.ts +0 -2
  134. package/dist/authorization/model/environment.d.ts.map +0 -1
  135. package/dist/authorization/model/environment.js +0 -33
  136. package/dist/authorization/model/environment.js.map +0 -1
  137. package/dist/authorization/model/execution_context.d.ts +0 -2
  138. package/dist/authorization/model/execution_context.d.ts.map +0 -1
  139. package/dist/authorization/model/execution_context.js +0 -19
  140. package/dist/authorization/model/execution_context.js.map +0 -1
  141. package/dist/authorization/model/iam_policy.d.ts +0 -2
  142. package/dist/authorization/model/iam_policy.d.ts.map +0 -1
  143. package/dist/authorization/model/iam_policy.js +0 -31
  144. package/dist/authorization/model/iam_policy.js.map +0 -1
  145. package/dist/authorization/model/identity_account.d.ts +0 -2
  146. package/dist/authorization/model/identity_account.d.ts.map +0 -1
  147. package/dist/authorization/model/identity_account.js +0 -25
  148. package/dist/authorization/model/identity_account.js.map +0 -1
  149. package/dist/authorization/model/mcp_server.d.ts +0 -2
  150. package/dist/authorization/model/mcp_server.d.ts.map +0 -1
  151. package/dist/authorization/model/mcp_server.js +0 -38
  152. package/dist/authorization/model/mcp_server.js.map +0 -1
  153. package/dist/authorization/model/memory.d.ts +0 -2
  154. package/dist/authorization/model/memory.d.ts.map +0 -1
  155. package/dist/authorization/model/memory.js +0 -26
  156. package/dist/authorization/model/memory.js.map +0 -1
  157. package/dist/authorization/model/oauth_app.d.ts +0 -2
  158. package/dist/authorization/model/oauth_app.d.ts.map +0 -1
  159. package/dist/authorization/model/oauth_app.js +0 -31
  160. package/dist/authorization/model/oauth_app.js.map +0 -1
  161. package/dist/authorization/model/organization.d.ts +0 -2
  162. package/dist/authorization/model/organization.d.ts.map +0 -1
  163. package/dist/authorization/model/organization.js +0 -58
  164. package/dist/authorization/model/organization.js.map +0 -1
  165. package/dist/authorization/model/platform_client.d.ts +0 -2
  166. package/dist/authorization/model/platform_client.d.ts.map +0 -1
  167. package/dist/authorization/model/platform_client.js +0 -31
  168. package/dist/authorization/model/platform_client.js.map +0 -1
  169. package/dist/authorization/model/plugin.d.ts +0 -2
  170. package/dist/authorization/model/plugin.d.ts.map +0 -1
  171. package/dist/authorization/model/plugin.js +0 -45
  172. package/dist/authorization/model/plugin.js.map +0 -1
  173. package/dist/authorization/model/schedule.d.ts +0 -2
  174. package/dist/authorization/model/schedule.d.ts.map +0 -1
  175. package/dist/authorization/model/schedule.js +0 -34
  176. package/dist/authorization/model/schedule.js.map +0 -1
  177. package/dist/authorization/model/session.d.ts +0 -2
  178. package/dist/authorization/model/session.d.ts.map +0 -1
  179. package/dist/authorization/model/session.js +0 -38
  180. package/dist/authorization/model/session.js.map +0 -1
  181. package/dist/authorization/model/skill.d.ts +0 -2
  182. package/dist/authorization/model/skill.d.ts.map +0 -1
  183. package/dist/authorization/model/skill.js +0 -39
  184. package/dist/authorization/model/skill.js.map +0 -1
  185. package/dist/authorization/model/workflow.d.ts +0 -2
  186. package/dist/authorization/model/workflow.d.ts.map +0 -1
  187. package/dist/authorization/model/workflow.js +0 -39
  188. package/dist/authorization/model/workflow.js.map +0 -1
  189. package/dist/authorization/model/workflow_execution.d.ts +0 -2
  190. package/dist/authorization/model/workflow_execution.d.ts.map +0 -1
  191. package/dist/authorization/model/workflow_execution.js +0 -33
  192. package/dist/authorization/model/workflow_execution.js.map +0 -1
  193. package/dist/authorization/model/workflow_instance.d.ts +0 -2
  194. package/dist/authorization/model/workflow_instance.d.ts.map +0 -1
  195. package/dist/authorization/model/workflow_instance.js +0 -96
  196. package/dist/authorization/model/workflow_instance.js.map +0 -1
  197. package/dist/authorization/store-test-kit.d.ts +0 -62
  198. package/dist/authorization/store-test-kit.d.ts.map +0 -1
  199. package/dist/authorization/store-test-kit.js +0 -265
  200. package/dist/authorization/store-test-kit.js.map +0 -1
  201. package/src/authorization/__tests__/fixtures/fga/agent-channel-owner.fga.yaml +0 -112
  202. package/src/authorization/__tests__/fixtures/fga/agent-instance-creation.fga.yaml +0 -177
  203. package/src/authorization/__tests__/fixtures/fga/agent-share-owner.fga.yaml +0 -109
  204. package/src/authorization/__tests__/fixtures/fga/artifact-org-and-owner.fga.yaml +0 -128
  205. package/src/authorization/__tests__/fixtures/fga/blueprint-private-visibility.fga.yaml +0 -318
  206. package/src/authorization/__tests__/fixtures/fga/channel-app-owner.fga.yaml +0 -125
  207. package/src/authorization/__tests__/fixtures/fga/channel-participation.fga.yaml +0 -201
  208. package/src/authorization/__tests__/fixtures/fga/channel-session-visibility.fga.yaml +0 -187
  209. package/src/authorization/__tests__/fixtures/fga/default-instance-inheritance.fga.yaml +0 -214
  210. package/src/authorization/__tests__/fixtures/fga/mcp-server-authoring.fga.yaml +0 -129
  211. package/src/authorization/__tests__/fixtures/fga/memory-subject-only.fga.yaml +0 -72
  212. package/src/authorization/__tests__/fixtures/fga/org-admin-owner-inheritance.fga.yaml +0 -308
  213. package/src/authorization/__tests__/fixtures/fga/org-shared-environment.fga.yaml +0 -144
  214. package/src/authorization/__tests__/fixtures/fga/platform-visibility.fga.yaml +0 -199
  215. package/src/authorization/__tests__/fixtures/fga/provider-standing-viewer.fga.yaml +0 -40
  216. package/src/authorization/__tests__/fixtures/fga/reserved-label-writer.fga.yaml +0 -41
  217. package/src/authorization/__tests__/fixtures/fga/schedule-owner.fga.yaml +0 -113
  218. package/src/authorization/__tests__/fixtures/fga/schedule-session-visibility.fga.yaml +0 -214
  219. package/src/authorization/__tests__/fixtures/fga/session-personal-resource.fga.yaml +0 -117
  220. package/src/authorization/__tests__/fixtures/fga/workflow-execution-sharing.fga.yaml +0 -190
  221. package/src/authorization/model/agent.ts +0 -64
  222. package/src/authorization/model/agent_channel.ts +0 -57
  223. package/src/authorization/model/agent_execution.ts +0 -33
  224. package/src/authorization/model/agent_instance.ts +0 -66
  225. package/src/authorization/model/agent_share.ts +0 -40
  226. package/src/authorization/model/api_key.ts +0 -28
  227. package/src/authorization/model/artifact.ts +0 -38
  228. package/src/authorization/model/channel_app.ts +0 -39
  229. package/src/authorization/model/environment.ts +0 -48
  230. package/src/authorization/model/execution_context.ts +0 -20
  231. package/src/authorization/model/iam_policy.ts +0 -42
  232. package/src/authorization/model/identity_account.ts +0 -26
  233. package/src/authorization/model/mcp_server.ts +0 -59
  234. package/src/authorization/model/memory.ts +0 -27
  235. package/src/authorization/model/oauth_app.ts +0 -43
  236. package/src/authorization/model/organization.ts +0 -59
  237. package/src/authorization/model/platform_client.ts +0 -43
  238. package/src/authorization/model/plugin.ts +0 -66
  239. package/src/authorization/model/schedule.ts +0 -49
  240. package/src/authorization/model/session.ts +0 -50
  241. package/src/authorization/model/skill.ts +0 -60
  242. package/src/authorization/model/workflow.ts +0 -60
  243. package/src/authorization/model/workflow_execution.ts +0 -46
  244. package/src/authorization/model/workflow_instance.ts +0 -125
  245. package/src/authorization/store-test-kit.ts +0 -395
@@ -1,59 +0,0 @@
1
- /**
2
- * Transcript of fga/model/tenancy/organization.fga — the root of the
3
- * model: no parent, the four roles as a ladder (`owner ⊂ admin ⊂ member
4
- * ⊂ viewer`, each `[identity_account] or <the rung above>`), and every
5
- * `can_create_*` an organization gates.
6
- *
7
- * In open source the `[identity_account]` tuples of this type ARE the
8
- * IamPolicy rows: 2b's role lifecycle writes the creator's `owner` row and
9
- * the grant path writes every other role, so the tuple source reads them
10
- * from the IamPolicyStore and the derivation writes no owner tuple for
11
- * this kind (derived-tuples.ts). `guest` is the cloud's anonymous
12
- * share-link visitor; no open-source lane mints one (claim check C5), so
13
- * the relation resolves to nothing and `can_create_session: member or
14
- * guest` is `member` here — the transcript still carries the line.
15
- * `can_create_team` is carried the same way: open source serves no Team
16
- * kind, so nothing here asks it.
17
- */
18
- import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
19
- import { OrganizationSchema } from "@stigmer/protos/ai/stigmer/tenancy/organization/v1/api_pb";
20
-
21
- import { computed, declareKind, direct, objectOf, union } from "./rewrite.js";
22
-
23
- export const organizationDeclaration = declareKind({
24
- kind: ApiResourceKind.organization,
25
- schema: OrganizationSchema,
26
- source: "fga/model/tenancy/organization.fga",
27
- relations: [
28
- ["owner", direct(objectOf("identity_account"))],
29
- ["admin", union(direct(objectOf("identity_account")), computed("owner"))],
30
- ["member", union(direct(objectOf("identity_account")), computed("admin"))],
31
- ["viewer", union(direct(objectOf("identity_account")), computed("member"))],
32
- ["guest", direct(objectOf("identity_account"))],
33
- ["can_view", computed("viewer")],
34
- ["can_edit", computed("admin")],
35
- ["can_delete", computed("owner")],
36
- ["can_manage_members", computed("admin")],
37
- ["can_assign_roles", computed("owner")],
38
- ["can_create_agent", computed("admin")],
39
- ["can_create_workflow", computed("admin")],
40
- ["can_create_session", union(computed("member"), computed("guest"))],
41
- ["can_create_environment", computed("member")],
42
- ["can_create_skill", computed("admin")],
43
- ["can_create_plugin", computed("admin")],
44
- ["can_create_mcp_server", computed("admin")],
45
- ["can_create_idp", computed("admin")],
46
- ["can_create_identity_account", computed("admin")],
47
- ["can_create_oauth_app", computed("admin")],
48
- ["can_create_platform_client", computed("admin")],
49
- ["can_create_channel_app", computed("admin")],
50
- ["can_create_execution_in", union(computed("member"), computed("guest"))],
51
- ["can_create_agent_share", computed("admin")],
52
- ["can_create_agent_instance", computed("member")],
53
- ["can_create_team", computed("admin")],
54
- ["can_grant_access", computed("admin")],
55
- ["can_view_access", computed("viewer")],
56
- ["can_view_billing", computed("viewer")],
57
- ["can_manage_billing", computed("admin")],
58
- ],
59
- });
@@ -1,43 +0,0 @@
1
- /**
2
- * Transcript of fga/model/iam/platform_client.fga — relation for relation
3
- * the oauth_app shape: organization-scoped, an `owner` with no admin arm
4
- * and a `viewer` that has one. A platform client holds credential material,
5
- * so the model is restricted: its creator (the owner) edits, deletes,
6
- * rotates and grants; the organization's admins may view it; ordinary
7
- * members have no access at all, which is why listByOrg narrows through
8
- * the list read scope. There is no public level.
9
- */
10
- import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
11
- import { PlatformClientSchema } from "@stigmer/protos/ai/stigmer/iam/platformclient/v1/api_pb";
12
-
13
- import {
14
- computed,
15
- declareKind,
16
- direct,
17
- from,
18
- objectOf,
19
- union,
20
- } from "./rewrite.js";
21
-
22
- export const platformClientDeclaration = declareKind({
23
- kind: ApiResourceKind.platform_client,
24
- schema: PlatformClientSchema,
25
- source: "fga/model/iam/platform_client.fga",
26
- relations: [
27
- ["organization", direct(objectOf("organization"))],
28
- ["owner", direct(objectOf("identity_account"))],
29
- [
30
- "viewer",
31
- union(
32
- direct(objectOf("identity_account")),
33
- computed("owner"),
34
- from("admin", "organization"),
35
- ),
36
- ],
37
- ["can_view", computed("viewer")],
38
- ["can_edit", computed("owner")],
39
- ["can_delete", computed("owner")],
40
- ["can_grant_access", computed("owner")],
41
- ["can_view_access", computed("viewer")],
42
- ],
43
- });
@@ -1,66 +0,0 @@
1
- /**
2
- * Transcript of fga/model/agentic/plugin.fga — the unit of install, shaped
3
- * exactly like a skill: an organization-owned blueprint whose owner is the
4
- * installer (and, through the organization, its admins), whose viewers are
5
- * the org's members and viewers and the platform viewer. Its verbs are the blueprint set: `can_view`, `can_edit`
6
- * (visibility), `can_delete` (uninstall), `can_grant_access`,
7
- * `can_view_access`; `can_use` is carried as the model's word for
8
- * "install from" though no wire permission names it yet. `team#member` on
9
- * `viewer` is the Enterprise team grant, which no open-source tuple ever
10
- * names.
11
- *
12
- * The members a plugin materialises are NOT reached through this type:
13
- * each is an ordinary skill, MCP server, agent or workflow with its own
14
- * tuples, written by its own chain as the installing caller.
15
- */
16
- import { PluginSchema } from "@stigmer/protos/ai/stigmer/agentic/plugin/v1/api_pb";
17
- import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
18
-
19
- import {
20
- computed,
21
- declareKind,
22
- direct,
23
- from,
24
- objectOf,
25
- union,
26
- usersetOf,
27
- } from "./rewrite.js";
28
-
29
- export const pluginDeclaration = declareKind({
30
- kind: ApiResourceKind.plugin,
31
- schema: PluginSchema,
32
- source: "fga/model/agentic/plugin.fga",
33
- relations: [
34
- ["organization", direct(objectOf("organization"))],
35
- [
36
- "owner",
37
- union(
38
- direct(objectOf("identity_account")),
39
- from("admin", "organization"),
40
- ),
41
- ],
42
- [
43
- "platform_viewer",
44
- direct(usersetOf("identity_provider", "platform_user")),
45
- ],
46
- [
47
- "viewer",
48
- union(
49
- direct(
50
- objectOf("identity_account"),
51
- usersetOf("organization", "member"),
52
- usersetOf("organization", "viewer"),
53
- usersetOf("team", "member"),
54
- ),
55
- computed("owner"),
56
- computed("platform_viewer"),
57
- ),
58
- ],
59
- ["can_view", computed("viewer")],
60
- ["can_edit", computed("owner")],
61
- ["can_delete", computed("owner")],
62
- ["can_use", computed("viewer")],
63
- ["can_grant_access", computed("owner")],
64
- ["can_view_access", computed("viewer")],
65
- ],
66
- });
@@ -1,49 +0,0 @@
1
- /**
2
- * Transcript of fga/model/agentic/schedule.fga — a scheduled run's
3
- * definition, admin-owned like a blueprint and viewable by its owners and
4
- * explicit grantees. The sessions its fires create name it back through
5
- * `session#schedule`, a link the cloud writes and this edition does not
6
- * (session.ts); the schedule's own relations are unaffected. An explicit
7
- * grant may name an Enterprise team (`team#member`), which no open-source
8
- * tuple ever does.
9
- */
10
- import { ScheduleSchema } from "@stigmer/protos/ai/stigmer/agentic/schedule/v1/api_pb";
11
- import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
12
-
13
- import {
14
- computed,
15
- declareKind,
16
- direct,
17
- from,
18
- objectOf,
19
- union,
20
- usersetOf,
21
- } from "./rewrite.js";
22
-
23
- export const scheduleDeclaration = declareKind({
24
- kind: ApiResourceKind.schedule,
25
- schema: ScheduleSchema,
26
- source: "fga/model/agentic/schedule.fga",
27
- relations: [
28
- ["organization", direct(objectOf("organization"))],
29
- [
30
- "owner",
31
- union(
32
- direct(objectOf("identity_account")),
33
- from("admin", "organization"),
34
- ),
35
- ],
36
- [
37
- "viewer",
38
- union(
39
- direct(objectOf("identity_account"), usersetOf("team", "member")),
40
- computed("owner"),
41
- ),
42
- ],
43
- ["can_view", computed("viewer")],
44
- ["can_edit", computed("owner")],
45
- ["can_delete", computed("owner")],
46
- ["can_grant_access", computed("owner")],
47
- ["can_view_access", computed("viewer")],
48
- ],
49
- });
@@ -1,50 +0,0 @@
1
- /**
2
- * Transcript of fga/model/agentic/session.fga — a personal resource: the
3
- * owner and explicit grantees, and NO admin arm anywhere ("private
4
- * conversations that admins have no business accessing", the file's own
5
- * words). Three parent links beside the organization: `agent_instance`,
6
- * `channel` and `schedule`. None is a `kind_meta` fact — the cloud's
7
- * channel and schedule lanes write them — so on this edition the
8
- * derivation produces no such tuple and `viewer from channel` / `viewer
9
- * from schedule` resolve to nobody; the lines stand in the transcript
10
- * because they are the model's, and a scheduled run reaches its creator
11
- * through the fire caller's stamp on the session instead.
12
- */
13
- import { SessionSchema } from "@stigmer/protos/ai/stigmer/agentic/session/v1/api_pb";
14
- import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
15
-
16
- import {
17
- computed,
18
- declareKind,
19
- direct,
20
- from,
21
- objectOf,
22
- union,
23
- } from "./rewrite.js";
24
-
25
- export const sessionDeclaration = declareKind({
26
- kind: ApiResourceKind.session,
27
- schema: SessionSchema,
28
- source: "fga/model/agentic/session.fga",
29
- relations: [
30
- ["organization", direct(objectOf("organization"))],
31
- ["agent_instance", direct(objectOf("agent_instance"))],
32
- ["channel", direct(objectOf("agent_channel"))],
33
- ["schedule", direct(objectOf("schedule"))],
34
- ["owner", direct(objectOf("identity_account"))],
35
- ["viewer", union(direct(objectOf("identity_account")), computed("owner"))],
36
- [
37
- "can_view",
38
- union(
39
- computed("viewer"),
40
- from("viewer", "channel"),
41
- from("viewer", "schedule"),
42
- ),
43
- ],
44
- ["can_edit", computed("owner")],
45
- ["can_delete", computed("owner")],
46
- ["can_create_execution_in", computed("viewer")],
47
- ["can_grant_access", computed("owner")],
48
- ["can_view_access", computed("viewer")],
49
- ],
50
- });
@@ -1,60 +0,0 @@
1
- /**
2
- * Transcript of fga/model/agentic/skill.fga — a blueprint whose verbs are
3
- * `can_use` and `can_clone` rather than `can_execute`. Only `can_view`,
4
- * `can_edit`, `can_delete`, `can_grant_access` and `can_view_access` are
5
- * in the wire's IamPermission vocabulary; the others are the model's and
6
- * are carried so the transcript is the file. `team#member` on `viewer` is
7
- * the Enterprise team grant, which no open-source tuple ever names.
8
- */
9
- import { SkillSchema } from "@stigmer/protos/ai/stigmer/agentic/skill/v1/api_pb";
10
- import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
11
-
12
- import {
13
- computed,
14
- declareKind,
15
- direct,
16
- from,
17
- objectOf,
18
- union,
19
- usersetOf,
20
- } from "./rewrite.js";
21
-
22
- export const skillDeclaration = declareKind({
23
- kind: ApiResourceKind.skill,
24
- schema: SkillSchema,
25
- source: "fga/model/agentic/skill.fga",
26
- relations: [
27
- ["organization", direct(objectOf("organization"))],
28
- [
29
- "owner",
30
- union(
31
- direct(objectOf("identity_account")),
32
- from("admin", "organization"),
33
- ),
34
- ],
35
- [
36
- "platform_viewer",
37
- direct(usersetOf("identity_provider", "platform_user")),
38
- ],
39
- [
40
- "viewer",
41
- union(
42
- direct(
43
- objectOf("identity_account"),
44
- usersetOf("organization", "member"),
45
- usersetOf("organization", "viewer"),
46
- usersetOf("team", "member"),
47
- ),
48
- computed("owner"),
49
- computed("platform_viewer"),
50
- ),
51
- ],
52
- ["can_view", computed("viewer")],
53
- ["can_edit", computed("owner")],
54
- ["can_delete", computed("owner")],
55
- ["can_use", computed("viewer")],
56
- ["can_clone", computed("viewer")],
57
- ["can_grant_access", computed("owner")],
58
- ["can_view_access", computed("viewer")],
59
- ],
60
- });
@@ -1,60 +0,0 @@
1
- /**
2
- * Transcript of fga/model/agentic/workflow.fga — the agent's shape
3
- * without `can_create_instance` (a workflow instance is created through
4
- * the workflow-instance lane, gated by the organization). Kept as its own
5
- * transcript, not a shared "blueprint" helper, so the file-by-file drift
6
- * compare sees exactly this file's lines. `team#member` on `viewer` is the
7
- * Enterprise team grant, which no open-source tuple ever names.
8
- */
9
- import { WorkflowSchema } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/api_pb";
10
- import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
11
-
12
- import {
13
- computed,
14
- declareKind,
15
- direct,
16
- from,
17
- objectOf,
18
- union,
19
- usersetOf,
20
- } from "./rewrite.js";
21
-
22
- export const workflowDeclaration = declareKind({
23
- kind: ApiResourceKind.workflow,
24
- schema: WorkflowSchema,
25
- source: "fga/model/agentic/workflow.fga",
26
- relations: [
27
- ["organization", direct(objectOf("organization"))],
28
- [
29
- "owner",
30
- union(
31
- direct(objectOf("identity_account")),
32
- from("admin", "organization"),
33
- ),
34
- ],
35
- [
36
- "platform_viewer",
37
- direct(usersetOf("identity_provider", "platform_user")),
38
- ],
39
- [
40
- "viewer",
41
- union(
42
- direct(
43
- objectOf("identity_account"),
44
- usersetOf("organization", "member"),
45
- usersetOf("organization", "viewer"),
46
- usersetOf("team", "member"),
47
- ),
48
- computed("owner"),
49
- computed("platform_viewer"),
50
- ),
51
- ],
52
- ["can_view", computed("viewer")],
53
- ["can_edit", computed("owner")],
54
- ["can_delete", computed("owner")],
55
- ["can_execute", computed("viewer")],
56
- ["can_clone", computed("viewer")],
57
- ["can_grant_access", computed("owner")],
58
- ["can_view_access", computed("viewer")],
59
- ],
60
- });
@@ -1,46 +0,0 @@
1
- /**
2
- * Transcript of fga/model/agentic/workflow_execution.fga — a run with an
3
- * owner of its own (the person who triggered it; `kind_meta` attribution
4
- * DIRECT, unlike agent_execution's inherited owner) and two ways in for
5
- * others: an explicit per-run grant, or the instance's opt-in run
6
- * audience through `execution_viewer from workflow_instance`, standing on
7
- * the `workflow_instance` link the derivation writes from
8
- * `spec.workflow_instance_id`. No `can_delete`: run history outlives its
9
- * instance by design. The per-run grant may name an Enterprise team
10
- * (`team#member`), which no open-source tuple ever does.
11
- */
12
- import { WorkflowExecutionSchema } from "@stigmer/protos/ai/stigmer/agentic/workflowexecution/v1/api_pb";
13
- import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
14
-
15
- import {
16
- computed,
17
- declareKind,
18
- direct,
19
- from,
20
- objectOf,
21
- union,
22
- usersetOf,
23
- } from "./rewrite.js";
24
-
25
- export const workflowExecutionDeclaration = declareKind({
26
- kind: ApiResourceKind.workflow_execution,
27
- schema: WorkflowExecutionSchema,
28
- source: "fga/model/agentic/workflow_execution.fga",
29
- relations: [
30
- ["organization", direct(objectOf("organization"))],
31
- ["workflow_instance", direct(objectOf("workflow_instance"))],
32
- ["owner", direct(objectOf("identity_account"))],
33
- [
34
- "viewer",
35
- union(
36
- direct(objectOf("identity_account"), usersetOf("team", "member")),
37
- computed("owner"),
38
- from("execution_viewer", "workflow_instance"),
39
- ),
40
- ],
41
- ["can_view", computed("viewer")],
42
- ["can_edit", computed("owner")],
43
- ["can_grant_access", computed("owner")],
44
- ["can_view_access", computed("viewer")],
45
- ],
46
- });
@@ -1,125 +0,0 @@
1
- /**
2
- * Transcript of fga/model/agentic/workflow_instance.fga — the agent
3
- * instance's shape plus one relation of its own: `execution_viewer`, the
4
- * opt-in audience for the instance's RUN history, kept apart from
5
- * `viewer` so making an instance org-runnable never exposes other
6
- * people's run inputs and outputs. Consumed by workflow_execution through
7
- * `execution_viewer from workflow_instance`.
8
- *
9
- * `execution_viewer` is derived here from `spec.execution_visibility`
10
- * (the second rule `kind_meta` cannot express): `organization` derives
11
- * `#execution_viewer@organization:<org>#viewer` — the organization's full
12
- * read audience, the shape the file's comment names and the cloud's own
13
- * store test writes, with `#member` the legacy shape the line still
14
- * admits — and `private` or unset derives nothing, so each run stays its
15
- * triggerer's. The cloud has no writer for this tuple today; this
16
- * edition enforces the field as the contract states it.
17
- *
18
- * `team#member` on `viewer` is the Enterprise team grant, which no
19
- * open-source tuple ever names; `execution_viewer` is not a grantable role
20
- * and admits no team.
21
- */
22
- import { isMessage } from "@bufbuild/protobuf";
23
-
24
- import { WorkflowSchema } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/api_pb";
25
- import { WorkflowInstanceSchema } from "@stigmer/protos/ai/stigmer/agentic/workflowinstance/v1/api_pb";
26
- import { WorkflowExecutionVisibility } from "@stigmer/protos/ai/stigmer/agentic/workflowinstance/v1/spec_pb";
27
- import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
28
-
29
- import { defaultOfBlueprint } from "./default-of.js";
30
- import type { DerivedRelation } from "./rewrite.js";
31
- import {
32
- computed,
33
- declareKind,
34
- direct,
35
- from,
36
- objectOf,
37
- union,
38
- usersetOf,
39
- } from "./rewrite.js";
40
-
41
- const executionViewer: DerivedRelation = (object, row) => {
42
- if (!isMessage(row, WorkflowInstanceSchema)) {
43
- return Promise.resolve([]);
44
- }
45
- const level =
46
- row.spec?.executionVisibility ?? WorkflowExecutionVisibility.unspecified;
47
- switch (level) {
48
- case WorkflowExecutionVisibility.organization: {
49
- const org = row.metadata?.org ?? "";
50
- return Promise.resolve(
51
- org === ""
52
- ? []
53
- : [
54
- {
55
- object,
56
- relation: "execution_viewer",
57
- subject: {
58
- form: "userset",
59
- object: { type: "organization", id: org },
60
- relation: "viewer",
61
- },
62
- },
63
- ],
64
- );
65
- }
66
- case WorkflowExecutionVisibility.private:
67
- case WorkflowExecutionVisibility.unspecified:
68
- return Promise.resolve([]);
69
- default: {
70
- const exhaustive: never = level;
71
- throw new Error(`unknown execution visibility: ${String(exhaustive)}`);
72
- }
73
- }
74
- };
75
-
76
- export const workflowInstanceDeclaration = declareKind({
77
- kind: ApiResourceKind.workflow_instance,
78
- schema: WorkflowInstanceSchema,
79
- source: "fga/model/agentic/workflow_instance.fga",
80
- relations: [
81
- ["organization", direct(objectOf("organization"))],
82
- ["workflow", direct(objectOf("workflow"))],
83
- ["default_of", direct(objectOf("workflow"))],
84
- ["owner", direct(objectOf("identity_account"))],
85
- [
86
- "viewer",
87
- union(
88
- direct(
89
- objectOf("identity_account"),
90
- usersetOf("organization", "member"),
91
- usersetOf("organization", "viewer"),
92
- usersetOf("team", "member"),
93
- ),
94
- computed("owner"),
95
- from("viewer", "default_of"),
96
- ),
97
- ],
98
- [
99
- "execution_viewer",
100
- direct(
101
- objectOf("identity_account"),
102
- usersetOf("organization", "member"),
103
- usersetOf("organization", "viewer"),
104
- ),
105
- ],
106
- ["can_view", computed("viewer")],
107
- ["can_execute", computed("can_view")],
108
- ["can_edit", computed("owner")],
109
- ["can_delete", computed("owner")],
110
- ["can_grant_access", computed("owner")],
111
- ["can_view_access", computed("viewer")],
112
- ],
113
- derived: [
114
- [
115
- "default_of",
116
- defaultOfBlueprint({
117
- kind: ApiResourceKind.workflow,
118
- schema: WorkflowSchema,
119
- defaultInstanceIdOf: (workflow) =>
120
- workflow.status?.defaultInstanceId ?? "",
121
- }),
122
- ],
123
- ["execution_viewer", executionViewer],
124
- ],
125
- });