@adaptic/backend 0.0.1054 → 0.0.1056

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 (364) hide show
  1. package/Account.cjs +26 -0
  2. package/AccountLinkingRequest.cjs +26 -0
  3. package/AccountRiskMetrics.cjs +58 -0
  4. package/Action.cjs +26 -0
  5. package/AdaConversation.cjs +84 -0
  6. package/AdaMessage.cjs +29 -0
  7. package/Alert.cjs +58 -0
  8. package/Allocation.cjs +58 -0
  9. package/AlpacaAccount.cjs +52 -0
  10. package/Authenticator.cjs +26 -0
  11. package/AutoFollowRule.cjs +84 -0
  12. package/BrokerageAccount.cjs +116 -0
  13. package/Customer.cjs +55 -0
  14. package/DeskDecision.cjs +116 -0
  15. package/FeatureFlagOverride.cjs +26 -0
  16. package/Follow.cjs +84 -0
  17. package/Fund.cjs +197 -0
  18. package/FundAssignment.cjs +84 -0
  19. package/Holding.cjs +87 -0
  20. package/Investor.cjs +55 -0
  21. package/InvestorDocument.cjs +87 -0
  22. package/InvestorTransaction.cjs +87 -0
  23. package/InviteToken.cjs +29 -0
  24. package/LinkedProvider.cjs +26 -0
  25. package/LlmConfiguration.cjs +26 -0
  26. package/Mandate.cjs +142 -0
  27. package/MandateApproval.cjs +55 -0
  28. package/MandateRule.cjs +29 -0
  29. package/MandateVersion.cjs +113 -0
  30. package/NotificationDelivery.cjs +26 -0
  31. package/NotificationEvent.cjs +87 -0
  32. package/NotificationPreference.cjs +26 -0
  33. package/OrgMembership.cjs +26 -0
  34. package/Organization.cjs +174 -0
  35. package/PushSubscription.cjs +26 -0
  36. package/RiskEscalationEvent.cjs +58 -0
  37. package/Session.cjs +26 -0
  38. package/Strategy.cjs +15 -0
  39. package/StrategyHealthSnapshot.cjs +58 -0
  40. package/StrategySubscription.cjs +54 -0
  41. package/TaxDocument.cjs +87 -0
  42. package/Trade.cjs +23 -0
  43. package/TradingPolicy.cjs +58 -0
  44. package/User.cjs +110 -0
  45. package/UserTotp.cjs +26 -0
  46. package/WaitlistEntry.cjs +26 -0
  47. package/esm/Account.mjs +26 -0
  48. package/esm/AccountLinkingRequest.mjs +26 -0
  49. package/esm/AccountRiskMetrics.mjs +58 -0
  50. package/esm/Action.mjs +26 -0
  51. package/esm/AdaConversation.mjs +84 -0
  52. package/esm/AdaMessage.mjs +29 -0
  53. package/esm/Alert.mjs +58 -0
  54. package/esm/Allocation.mjs +58 -0
  55. package/esm/AlpacaAccount.mjs +52 -0
  56. package/esm/Authenticator.mjs +26 -0
  57. package/esm/AutoFollowRule.mjs +84 -0
  58. package/esm/BrokerageAccount.mjs +116 -0
  59. package/esm/Customer.mjs +55 -0
  60. package/esm/DeskDecision.mjs +116 -0
  61. package/esm/FeatureFlagOverride.mjs +26 -0
  62. package/esm/Follow.mjs +84 -0
  63. package/esm/Fund.mjs +197 -0
  64. package/esm/FundAssignment.mjs +84 -0
  65. package/esm/Holding.mjs +87 -0
  66. package/esm/Investor.mjs +55 -0
  67. package/esm/InvestorDocument.mjs +87 -0
  68. package/esm/InvestorTransaction.mjs +87 -0
  69. package/esm/InviteToken.mjs +29 -0
  70. package/esm/LinkedProvider.mjs +26 -0
  71. package/esm/LlmConfiguration.mjs +26 -0
  72. package/esm/Mandate.mjs +142 -0
  73. package/esm/MandateApproval.mjs +55 -0
  74. package/esm/MandateRule.mjs +29 -0
  75. package/esm/MandateVersion.mjs +113 -0
  76. package/esm/NotificationDelivery.mjs +26 -0
  77. package/esm/NotificationEvent.mjs +87 -0
  78. package/esm/NotificationPreference.mjs +26 -0
  79. package/esm/OrgMembership.mjs +26 -0
  80. package/esm/Organization.mjs +174 -0
  81. package/esm/PushSubscription.mjs +26 -0
  82. package/esm/RiskEscalationEvent.mjs +58 -0
  83. package/esm/Session.mjs +26 -0
  84. package/esm/Strategy.mjs +15 -0
  85. package/esm/StrategyHealthSnapshot.mjs +58 -0
  86. package/esm/StrategySubscription.mjs +54 -0
  87. package/esm/TaxDocument.mjs +87 -0
  88. package/esm/Trade.mjs +23 -0
  89. package/esm/TradingPolicy.mjs +58 -0
  90. package/esm/User.mjs +110 -0
  91. package/esm/UserTotp.mjs +26 -0
  92. package/esm/WaitlistEntry.mjs +26 -0
  93. package/esm/auth/membership-write-authority.d.ts +110 -0
  94. package/esm/auth/membership-write-authority.mjs +125 -0
  95. package/esm/auth/mutation-authorization.d.ts +23 -4
  96. package/esm/auth/mutation-authorization.mjs +36 -3
  97. package/esm/auth/nested-write-policy.d.ts +4 -0
  98. package/esm/auth/nested-write-policy.mjs +19 -0
  99. package/esm/auth/tenancy-scope.d.ts +50 -8
  100. package/esm/auth/tenancy-scope.mjs +87 -10
  101. package/esm/generated/selectionSets/Strategy.d.ts +1 -1
  102. package/esm/generated/selectionSets/Strategy.mjs +2 -0
  103. package/esm/generated/selectionSets/StrategySubscription.d.ts +1 -1
  104. package/esm/generated/selectionSets/StrategySubscription.mjs +2 -0
  105. package/esm/generated/typeStrings/Strategy.d.ts +1 -1
  106. package/esm/generated/typeStrings/Strategy.mjs +7 -0
  107. package/esm/generated/typeStrings/index.d.ts +1 -1
  108. package/esm/generated/typegraphql-prisma/enhance.mjs +79 -62
  109. package/esm/generated/typegraphql-prisma/enums/StrategyLifecycleState.d.ts +1 -0
  110. package/esm/generated/typegraphql-prisma/enums/StrategyLifecycleState.mjs +1 -0
  111. package/esm/generated/typegraphql-prisma/enums/StrategyScalarFieldEnum.d.ts +2 -0
  112. package/esm/generated/typegraphql-prisma/enums/StrategyScalarFieldEnum.mjs +2 -0
  113. package/esm/generated/typegraphql-prisma/models/Fund.d.ts +5 -0
  114. package/esm/generated/typegraphql-prisma/models/Fund.mjs +4 -0
  115. package/esm/generated/typegraphql-prisma/models/Strategy.d.ts +30 -1
  116. package/esm/generated/typegraphql-prisma/models/Strategy.mjs +43 -1
  117. package/esm/generated/typegraphql-prisma/resolvers/crud/Strategy/args/FindFirstStrategyArgs.d.ts +1 -1
  118. package/esm/generated/typegraphql-prisma/resolvers/crud/Strategy/args/FindFirstStrategyOrThrowArgs.d.ts +1 -1
  119. package/esm/generated/typegraphql-prisma/resolvers/crud/Strategy/args/FindManyStrategyArgs.d.ts +1 -1
  120. package/esm/generated/typegraphql-prisma/resolvers/crud/Strategy/args/GroupByStrategyArgs.d.ts +1 -1
  121. package/esm/generated/typegraphql-prisma/resolvers/inputs/EnumStrategyLifecycleStateFieldUpdateOperationsInput.d.ts +1 -1
  122. package/esm/generated/typegraphql-prisma/resolvers/inputs/EnumStrategyLifecycleStateFilter.d.ts +3 -3
  123. package/esm/generated/typegraphql-prisma/resolvers/inputs/EnumStrategyLifecycleStateWithAggregatesFilter.d.ts +3 -3
  124. package/esm/generated/typegraphql-prisma/resolvers/inputs/FundCreateNestedOneWithoutStrategiesInput.d.ts +9 -0
  125. package/esm/generated/typegraphql-prisma/resolvers/inputs/FundCreateNestedOneWithoutStrategiesInput.mjs +41 -0
  126. package/esm/generated/typegraphql-prisma/resolvers/inputs/FundCreateOrConnectWithoutStrategiesInput.d.ts +7 -0
  127. package/esm/generated/typegraphql-prisma/resolvers/inputs/FundCreateOrConnectWithoutStrategiesInput.mjs +33 -0
  128. package/esm/generated/typegraphql-prisma/resolvers/inputs/FundCreateWithoutStrategiesInput.d.ts +53 -0
  129. package/esm/generated/typegraphql-prisma/resolvers/inputs/FundCreateWithoutStrategiesInput.mjs +272 -0
  130. package/esm/generated/typegraphql-prisma/resolvers/inputs/FundUpdateOneWithoutStrategiesNestedInput.d.ts +16 -0
  131. package/esm/generated/typegraphql-prisma/resolvers/inputs/FundUpdateOneWithoutStrategiesNestedInput.mjs +72 -0
  132. package/esm/generated/typegraphql-prisma/resolvers/inputs/FundUpdateToOneWithWhereWithoutStrategiesInput.d.ts +7 -0
  133. package/esm/generated/typegraphql-prisma/resolvers/inputs/FundUpdateToOneWithWhereWithoutStrategiesInput.mjs +33 -0
  134. package/esm/generated/typegraphql-prisma/resolvers/inputs/FundUpdateWithoutStrategiesInput.d.ts +60 -0
  135. package/esm/generated/typegraphql-prisma/resolvers/inputs/FundUpdateWithoutStrategiesInput.mjs +278 -0
  136. package/esm/generated/typegraphql-prisma/resolvers/inputs/FundUpsertWithoutStrategiesInput.d.ts +9 -0
  137. package/esm/generated/typegraphql-prisma/resolvers/inputs/FundUpsertWithoutStrategiesInput.mjs +41 -0
  138. package/esm/generated/typegraphql-prisma/resolvers/inputs/NestedEnumStrategyLifecycleStateFilter.d.ts +3 -3
  139. package/esm/generated/typegraphql-prisma/resolvers/inputs/NestedEnumStrategyLifecycleStateWithAggregatesFilter.d.ts +3 -3
  140. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyCountOrderByAggregateInput.d.ts +2 -0
  141. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyCountOrderByAggregateInput.mjs +14 -0
  142. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateInput.d.ts +2 -1
  143. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateInput.mjs +7 -0
  144. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateManyFundInput.d.ts +20 -0
  145. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateManyFundInput.mjs +134 -0
  146. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateManyFundInputEnvelope.d.ts +6 -0
  147. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateManyFundInputEnvelope.mjs +32 -0
  148. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateManyInput.d.ts +3 -1
  149. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateManyInput.mjs +14 -0
  150. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateManyOwnerInput.d.ts +3 -1
  151. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateManyOwnerInput.mjs +14 -0
  152. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateNestedManyWithoutFundInput.d.ts +11 -0
  153. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateNestedManyWithoutFundInput.mjs +49 -0
  154. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateOrConnectWithoutFundInput.d.ts +7 -0
  155. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateOrConnectWithoutFundInput.mjs +33 -0
  156. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateWithoutFundInput.d.ts +25 -0
  157. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateWithoutFundInput.mjs +151 -0
  158. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateWithoutOwnerInput.d.ts +2 -1
  159. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateWithoutOwnerInput.mjs +7 -0
  160. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateWithoutSubscriptionsInput.d.ts +2 -1
  161. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateWithoutSubscriptionsInput.mjs +7 -0
  162. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateWithoutTradesInput.d.ts +2 -1
  163. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateWithoutTradesInput.mjs +7 -0
  164. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyMaxOrderByAggregateInput.d.ts +2 -0
  165. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyMaxOrderByAggregateInput.mjs +14 -0
  166. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyMinOrderByAggregateInput.d.ts +2 -0
  167. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyMinOrderByAggregateInput.mjs +14 -0
  168. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyOrderByWithAggregationInput.d.ts +2 -0
  169. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyOrderByWithAggregationInput.mjs +14 -0
  170. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyOrderByWithRelationInput.d.ts +2 -0
  171. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyOrderByWithRelationInput.mjs +14 -0
  172. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyScalarWhereInput.d.ts +2 -0
  173. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyScalarWhereInput.mjs +14 -0
  174. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyScalarWhereWithAggregatesInput.d.ts +2 -0
  175. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyScalarWhereWithAggregatesInput.mjs +14 -0
  176. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyUpdateInput.d.ts +1 -0
  177. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyUpdateInput.mjs +7 -0
  178. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyUpdateManyMutationInput.d.ts +1 -0
  179. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyUpdateManyMutationInput.mjs +7 -0
  180. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyUpdateManyWithWhereWithoutFundInput.d.ts +7 -0
  181. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyUpdateManyWithWhereWithoutFundInput.mjs +33 -0
  182. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyUpdateManyWithoutFundNestedInput.d.ts +22 -0
  183. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyUpdateManyWithoutFundNestedInput.mjs +102 -0
  184. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyUpdateWithWhereUniqueWithoutFundInput.d.ts +7 -0
  185. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyUpdateWithWhereUniqueWithoutFundInput.mjs +33 -0
  186. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyUpdateWithoutFundInput.d.ts +33 -0
  187. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyUpdateWithoutFundInput.mjs +155 -0
  188. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyUpdateWithoutOwnerInput.d.ts +1 -0
  189. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyUpdateWithoutOwnerInput.mjs +7 -0
  190. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyUpdateWithoutSubscriptionsInput.d.ts +1 -0
  191. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyUpdateWithoutSubscriptionsInput.mjs +7 -0
  192. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyUpdateWithoutTradesInput.d.ts +1 -0
  193. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyUpdateWithoutTradesInput.mjs +7 -0
  194. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyUpsertWithWhereUniqueWithoutFundInput.d.ts +9 -0
  195. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyUpsertWithWhereUniqueWithoutFundInput.mjs +41 -0
  196. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyWhereInput.d.ts +2 -0
  197. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyWhereInput.mjs +14 -0
  198. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyWhereUniqueInput.d.ts +2 -0
  199. package/esm/generated/typegraphql-prisma/resolvers/inputs/StrategyWhereUniqueInput.mjs +14 -0
  200. package/esm/generated/typegraphql-prisma/resolvers/inputs/index.d.ts +17 -0
  201. package/esm/generated/typegraphql-prisma/resolvers/inputs/index.mjs +17 -0
  202. package/esm/generated/typegraphql-prisma/resolvers/outputs/CreateManyAndReturnStrategy.d.ts +7 -1
  203. package/esm/generated/typegraphql-prisma/resolvers/outputs/CreateManyAndReturnStrategy.mjs +31 -0
  204. package/esm/generated/typegraphql-prisma/resolvers/outputs/FundCount.d.ts +3 -0
  205. package/esm/generated/typegraphql-prisma/resolvers/outputs/FundCount.mjs +16 -0
  206. package/esm/generated/typegraphql-prisma/resolvers/outputs/StrategyCountAggregate.d.ts +2 -0
  207. package/esm/generated/typegraphql-prisma/resolvers/outputs/StrategyCountAggregate.mjs +14 -0
  208. package/esm/generated/typegraphql-prisma/resolvers/outputs/StrategyGroupBy.d.ts +3 -1
  209. package/esm/generated/typegraphql-prisma/resolvers/outputs/StrategyGroupBy.mjs +14 -0
  210. package/esm/generated/typegraphql-prisma/resolvers/outputs/StrategyMaxAggregate.d.ts +3 -1
  211. package/esm/generated/typegraphql-prisma/resolvers/outputs/StrategyMaxAggregate.mjs +14 -0
  212. package/esm/generated/typegraphql-prisma/resolvers/outputs/StrategyMinAggregate.d.ts +3 -1
  213. package/esm/generated/typegraphql-prisma/resolvers/outputs/StrategyMinAggregate.mjs +14 -0
  214. package/esm/generated/typegraphql-prisma/resolvers/outputs/args/CreateManyAndReturnStrategyFundArgs.d.ts +5 -0
  215. package/esm/generated/typegraphql-prisma/resolvers/outputs/args/CreateManyAndReturnStrategyFundArgs.mjs +25 -0
  216. package/esm/generated/typegraphql-prisma/resolvers/outputs/args/FundCountStrategiesArgs.d.ts +5 -0
  217. package/esm/generated/typegraphql-prisma/resolvers/outputs/args/FundCountStrategiesArgs.mjs +25 -0
  218. package/esm/generated/typegraphql-prisma/resolvers/outputs/args/index.d.ts +2 -0
  219. package/esm/generated/typegraphql-prisma/resolvers/outputs/args/index.mjs +2 -0
  220. package/esm/generated/typegraphql-prisma/resolvers/relations/User/args/UserOwnedStrategiesArgs.d.ts +1 -1
  221. package/esm/middleware/__tests__/mutation-auth-guard.harness.d.ts +2 -0
  222. package/esm/middleware/__tests__/mutation-auth-guard.harness.mjs +136 -10
  223. package/esm/middleware/mutation-auth-guard.d.ts +4 -2
  224. package/esm/middleware/mutation-auth-guard.mjs +20 -2
  225. package/esm/middleware/mutation-membership-facts.d.ts +133 -0
  226. package/esm/middleware/mutation-membership-facts.mjs +271 -0
  227. package/esm/middleware/mutation-tenant-facts.d.ts +4 -2
  228. package/esm/middleware/mutation-tenant-facts.mjs +4 -2
  229. package/esm/middleware/tenancy-scoping.mjs +15 -3
  230. package/esm/resolvers/custom/StrategyDraftResolver.d.ts +44 -0
  231. package/esm/resolvers/custom/StrategyDraftResolver.mjs +188 -0
  232. package/esm/resolvers/custom/index.d.ts +1 -0
  233. package/esm/resolvers/custom/index.mjs +1 -0
  234. package/esm/resolvers/custom/strategy-draft-service.d.ts +180 -0
  235. package/esm/resolvers/custom/strategy-draft-service.mjs +254 -0
  236. package/esm/resolvers/custom/strategy-spec-hash.d.ts +32 -0
  237. package/esm/resolvers/custom/strategy-spec-hash.mjs +54 -0
  238. package/esm/tests/strategy-fund-tenancy.harness.d.ts +20 -0
  239. package/esm/tests/strategy-fund-tenancy.harness.mjs +212 -0
  240. package/generated/typeStrings/Strategy.cjs +7 -0
  241. package/generated/typeStrings/Strategy.d.ts +1 -1
  242. package/generated/typeStrings/index.d.ts +1 -1
  243. package/generated/typegraphql-prisma/enhance.cjs +79 -62
  244. package/generated/typegraphql-prisma/enums/StrategyLifecycleState.cjs +1 -0
  245. package/generated/typegraphql-prisma/enums/StrategyLifecycleState.d.ts +1 -0
  246. package/generated/typegraphql-prisma/enums/StrategyScalarFieldEnum.cjs +2 -0
  247. package/generated/typegraphql-prisma/enums/StrategyScalarFieldEnum.d.ts +2 -0
  248. package/generated/typegraphql-prisma/models/Fund.d.ts +5 -0
  249. package/generated/typegraphql-prisma/models/Strategy.cjs +15 -1
  250. package/generated/typegraphql-prisma/models/Strategy.d.ts +30 -1
  251. package/generated/typegraphql-prisma/resolvers/crud/Strategy/args/FindFirstStrategyArgs.d.ts +1 -1
  252. package/generated/typegraphql-prisma/resolvers/crud/Strategy/args/FindFirstStrategyOrThrowArgs.d.ts +1 -1
  253. package/generated/typegraphql-prisma/resolvers/crud/Strategy/args/FindManyStrategyArgs.d.ts +1 -1
  254. package/generated/typegraphql-prisma/resolvers/crud/Strategy/args/GroupByStrategyArgs.d.ts +1 -1
  255. package/generated/typegraphql-prisma/resolvers/inputs/EnumStrategyLifecycleStateFieldUpdateOperationsInput.d.ts +1 -1
  256. package/generated/typegraphql-prisma/resolvers/inputs/EnumStrategyLifecycleStateFilter.d.ts +3 -3
  257. package/generated/typegraphql-prisma/resolvers/inputs/EnumStrategyLifecycleStateWithAggregatesFilter.d.ts +3 -3
  258. package/generated/typegraphql-prisma/resolvers/inputs/FundCreateNestedOneWithoutStrategiesInput.cjs +74 -0
  259. package/generated/typegraphql-prisma/resolvers/inputs/FundCreateNestedOneWithoutStrategiesInput.d.ts +9 -0
  260. package/generated/typegraphql-prisma/resolvers/inputs/FundCreateOrConnectWithoutStrategiesInput.cjs +67 -0
  261. package/generated/typegraphql-prisma/resolvers/inputs/FundCreateOrConnectWithoutStrategiesInput.d.ts +7 -0
  262. package/generated/typegraphql-prisma/resolvers/inputs/FundCreateWithoutStrategiesInput.cjs +274 -0
  263. package/generated/typegraphql-prisma/resolvers/inputs/FundCreateWithoutStrategiesInput.d.ts +53 -0
  264. package/generated/typegraphql-prisma/resolvers/inputs/FundUpdateOneWithoutStrategiesNestedInput.cjs +101 -0
  265. package/generated/typegraphql-prisma/resolvers/inputs/FundUpdateOneWithoutStrategiesNestedInput.d.ts +16 -0
  266. package/generated/typegraphql-prisma/resolvers/inputs/FundUpdateToOneWithWhereWithoutStrategiesInput.cjs +67 -0
  267. package/generated/typegraphql-prisma/resolvers/inputs/FundUpdateToOneWithWhereWithoutStrategiesInput.d.ts +7 -0
  268. package/generated/typegraphql-prisma/resolvers/inputs/FundUpdateWithoutStrategiesInput.cjs +280 -0
  269. package/generated/typegraphql-prisma/resolvers/inputs/FundUpdateWithoutStrategiesInput.d.ts +60 -0
  270. package/generated/typegraphql-prisma/resolvers/inputs/FundUpsertWithoutStrategiesInput.cjs +74 -0
  271. package/generated/typegraphql-prisma/resolvers/inputs/FundUpsertWithoutStrategiesInput.d.ts +9 -0
  272. package/generated/typegraphql-prisma/resolvers/inputs/NestedEnumStrategyLifecycleStateFilter.d.ts +3 -3
  273. package/generated/typegraphql-prisma/resolvers/inputs/NestedEnumStrategyLifecycleStateWithAggregatesFilter.d.ts +3 -3
  274. package/generated/typegraphql-prisma/resolvers/inputs/StrategyCountOrderByAggregateInput.cjs +12 -0
  275. package/generated/typegraphql-prisma/resolvers/inputs/StrategyCountOrderByAggregateInput.d.ts +2 -0
  276. package/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateInput.cjs +6 -0
  277. package/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateInput.d.ts +2 -1
  278. package/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateManyFundInput.cjs +154 -0
  279. package/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateManyFundInput.d.ts +20 -0
  280. package/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateManyFundInputEnvelope.cjs +66 -0
  281. package/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateManyFundInputEnvelope.d.ts +6 -0
  282. package/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateManyInput.cjs +12 -0
  283. package/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateManyInput.d.ts +3 -1
  284. package/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateManyOwnerInput.cjs +12 -0
  285. package/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateManyOwnerInput.d.ts +3 -1
  286. package/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateNestedManyWithoutFundInput.cjs +81 -0
  287. package/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateNestedManyWithoutFundInput.d.ts +11 -0
  288. package/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateOrConnectWithoutFundInput.cjs +67 -0
  289. package/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateOrConnectWithoutFundInput.d.ts +7 -0
  290. package/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateWithoutFundInput.cjs +169 -0
  291. package/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateWithoutFundInput.d.ts +25 -0
  292. package/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateWithoutOwnerInput.cjs +6 -0
  293. package/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateWithoutOwnerInput.d.ts +2 -1
  294. package/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateWithoutSubscriptionsInput.cjs +6 -0
  295. package/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateWithoutSubscriptionsInput.d.ts +2 -1
  296. package/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateWithoutTradesInput.cjs +6 -0
  297. package/generated/typegraphql-prisma/resolvers/inputs/StrategyCreateWithoutTradesInput.d.ts +2 -1
  298. package/generated/typegraphql-prisma/resolvers/inputs/StrategyMaxOrderByAggregateInput.cjs +12 -0
  299. package/generated/typegraphql-prisma/resolvers/inputs/StrategyMaxOrderByAggregateInput.d.ts +2 -0
  300. package/generated/typegraphql-prisma/resolvers/inputs/StrategyMinOrderByAggregateInput.cjs +12 -0
  301. package/generated/typegraphql-prisma/resolvers/inputs/StrategyMinOrderByAggregateInput.d.ts +2 -0
  302. package/generated/typegraphql-prisma/resolvers/inputs/StrategyOrderByWithAggregationInput.cjs +12 -0
  303. package/generated/typegraphql-prisma/resolvers/inputs/StrategyOrderByWithAggregationInput.d.ts +2 -0
  304. package/generated/typegraphql-prisma/resolvers/inputs/StrategyOrderByWithRelationInput.cjs +12 -0
  305. package/generated/typegraphql-prisma/resolvers/inputs/StrategyOrderByWithRelationInput.d.ts +2 -0
  306. package/generated/typegraphql-prisma/resolvers/inputs/StrategyScalarWhereInput.cjs +12 -0
  307. package/generated/typegraphql-prisma/resolvers/inputs/StrategyScalarWhereInput.d.ts +2 -0
  308. package/generated/typegraphql-prisma/resolvers/inputs/StrategyScalarWhereWithAggregatesInput.cjs +12 -0
  309. package/generated/typegraphql-prisma/resolvers/inputs/StrategyScalarWhereWithAggregatesInput.d.ts +2 -0
  310. package/generated/typegraphql-prisma/resolvers/inputs/StrategyUpdateInput.cjs +6 -0
  311. package/generated/typegraphql-prisma/resolvers/inputs/StrategyUpdateInput.d.ts +1 -0
  312. package/generated/typegraphql-prisma/resolvers/inputs/StrategyUpdateManyMutationInput.cjs +6 -0
  313. package/generated/typegraphql-prisma/resolvers/inputs/StrategyUpdateManyMutationInput.d.ts +1 -0
  314. package/generated/typegraphql-prisma/resolvers/inputs/StrategyUpdateManyWithWhereWithoutFundInput.cjs +67 -0
  315. package/generated/typegraphql-prisma/resolvers/inputs/StrategyUpdateManyWithWhereWithoutFundInput.d.ts +7 -0
  316. package/generated/typegraphql-prisma/resolvers/inputs/StrategyUpdateManyWithoutFundNestedInput.cjs +127 -0
  317. package/generated/typegraphql-prisma/resolvers/inputs/StrategyUpdateManyWithoutFundNestedInput.d.ts +22 -0
  318. package/generated/typegraphql-prisma/resolvers/inputs/StrategyUpdateWithWhereUniqueWithoutFundInput.cjs +67 -0
  319. package/generated/typegraphql-prisma/resolvers/inputs/StrategyUpdateWithWhereUniqueWithoutFundInput.d.ts +7 -0
  320. package/generated/typegraphql-prisma/resolvers/inputs/StrategyUpdateWithoutFundInput.cjs +173 -0
  321. package/generated/typegraphql-prisma/resolvers/inputs/StrategyUpdateWithoutFundInput.d.ts +33 -0
  322. package/generated/typegraphql-prisma/resolvers/inputs/StrategyUpdateWithoutOwnerInput.cjs +6 -0
  323. package/generated/typegraphql-prisma/resolvers/inputs/StrategyUpdateWithoutOwnerInput.d.ts +1 -0
  324. package/generated/typegraphql-prisma/resolvers/inputs/StrategyUpdateWithoutSubscriptionsInput.cjs +6 -0
  325. package/generated/typegraphql-prisma/resolvers/inputs/StrategyUpdateWithoutSubscriptionsInput.d.ts +1 -0
  326. package/generated/typegraphql-prisma/resolvers/inputs/StrategyUpdateWithoutTradesInput.cjs +6 -0
  327. package/generated/typegraphql-prisma/resolvers/inputs/StrategyUpdateWithoutTradesInput.d.ts +1 -0
  328. package/generated/typegraphql-prisma/resolvers/inputs/StrategyUpsertWithWhereUniqueWithoutFundInput.cjs +74 -0
  329. package/generated/typegraphql-prisma/resolvers/inputs/StrategyUpsertWithWhereUniqueWithoutFundInput.d.ts +9 -0
  330. package/generated/typegraphql-prisma/resolvers/inputs/StrategyWhereInput.cjs +12 -0
  331. package/generated/typegraphql-prisma/resolvers/inputs/StrategyWhereInput.d.ts +2 -0
  332. package/generated/typegraphql-prisma/resolvers/inputs/StrategyWhereUniqueInput.cjs +12 -0
  333. package/generated/typegraphql-prisma/resolvers/inputs/StrategyWhereUniqueInput.d.ts +2 -0
  334. package/generated/typegraphql-prisma/resolvers/inputs/index.cjs +84 -50
  335. package/generated/typegraphql-prisma/resolvers/inputs/index.d.ts +17 -0
  336. package/generated/typegraphql-prisma/resolvers/outputs/CreateManyAndReturnStrategy.cjs +28 -0
  337. package/generated/typegraphql-prisma/resolvers/outputs/CreateManyAndReturnStrategy.d.ts +7 -1
  338. package/generated/typegraphql-prisma/resolvers/outputs/FundCount.cjs +15 -0
  339. package/generated/typegraphql-prisma/resolvers/outputs/FundCount.d.ts +3 -0
  340. package/generated/typegraphql-prisma/resolvers/outputs/StrategyCountAggregate.cjs +12 -0
  341. package/generated/typegraphql-prisma/resolvers/outputs/StrategyCountAggregate.d.ts +2 -0
  342. package/generated/typegraphql-prisma/resolvers/outputs/StrategyGroupBy.cjs +12 -0
  343. package/generated/typegraphql-prisma/resolvers/outputs/StrategyGroupBy.d.ts +3 -1
  344. package/generated/typegraphql-prisma/resolvers/outputs/StrategyMaxAggregate.cjs +12 -0
  345. package/generated/typegraphql-prisma/resolvers/outputs/StrategyMaxAggregate.d.ts +3 -1
  346. package/generated/typegraphql-prisma/resolvers/outputs/StrategyMinAggregate.cjs +12 -0
  347. package/generated/typegraphql-prisma/resolvers/outputs/StrategyMinAggregate.d.ts +3 -1
  348. package/generated/typegraphql-prisma/resolvers/outputs/args/CreateManyAndReturnStrategyFundArgs.cjs +60 -0
  349. package/generated/typegraphql-prisma/resolvers/outputs/args/CreateManyAndReturnStrategyFundArgs.d.ts +5 -0
  350. package/generated/typegraphql-prisma/resolvers/outputs/args/FundCountStrategiesArgs.cjs +60 -0
  351. package/generated/typegraphql-prisma/resolvers/outputs/args/FundCountStrategiesArgs.d.ts +5 -0
  352. package/generated/typegraphql-prisma/resolvers/outputs/args/index.cjs +7 -3
  353. package/generated/typegraphql-prisma/resolvers/outputs/args/index.d.ts +2 -0
  354. package/generated/typegraphql-prisma/resolvers/relations/User/args/UserOwnedStrategiesArgs.d.ts +1 -1
  355. package/package.json +1 -1
  356. package/resolvers/custom/StrategyDraftResolver.cjs +221 -0
  357. package/resolvers/custom/StrategyDraftResolver.d.ts +44 -0
  358. package/resolvers/custom/index.cjs +5 -1
  359. package/resolvers/custom/index.d.ts +1 -0
  360. package/resolvers/custom/strategy-draft-service.cjs +262 -0
  361. package/resolvers/custom/strategy-draft-service.d.ts +180 -0
  362. package/resolvers/custom/strategy-spec-hash.cjs +58 -0
  363. package/resolvers/custom/strategy-spec-hash.d.ts +32 -0
  364. package/server.cjs +1 -0
@@ -30,7 +30,15 @@
30
30
  * accounts has no single owner to check.
31
31
  * - `self` — `User`: only the caller's own row, and only its profile and
32
32
  * onboarding fields (`./user-write-content.ts`).
33
- * - `tenant_scoped` — the tenancy-governed models: the row (for an update,
33
+ * - `membership_authority` — `OrgMembership` and `FundAssignment`, the rows
34
+ * every other entitlement is read from: the caller must hold OWNER or
35
+ * ADMIN in the row's organization (OWNER for a row whose role is OWNER),
36
+ * or MANAGER on the assignment's own fund; or the write makes the caller
37
+ * the first owner of an empty organization, the one self-service create
38
+ * the backend can verify from rows the caller cannot write
39
+ * (`./membership-write-authority.ts`). Roles are read from the database
40
+ * for the mutation, never from the token.
41
+ * - `tenant_scoped` — the other tenancy-governed models: the row (for an update,
34
42
  * upsert or delete) or the payload's tenant (for a create) must lie in the
35
43
  * caller's OrgMembership / FundAssignment entitlement. The guard checks
36
44
  * this itself, whatever `TENANCY_SCOPING_MODE` says, because fund
@@ -45,7 +53,8 @@
45
53
  * must belong to an organization the caller is a member of or a fund they
46
54
  * are entitled to. Nested writes treat it as `authenticated`, as before.
47
55
  * - `resolver_authorized` — custom mutations whose resolver performs its own
48
- * authorization.
56
+ * authorization, among them the strategy-draft mutations: the only user
57
+ * writes to `Strategy`, which is otherwise `service_only`.
49
58
  * - everything else is `service_only`.
50
59
  * - `UserTotp` and the TOTP custom mutations are service-principal only:
51
60
  * not even an admin may write a user's second factor through GraphQL
@@ -80,6 +89,7 @@
80
89
  *
81
90
  * @module auth/mutation-authorization
82
91
  */
92
+ import { ADMITTING_MEMBERSHIP_VERDICTS, isMembershipModel, } from './membership-write-authority.mjs';
83
93
  import { DESK_MODELS, GOVERNED_MODELS } from './tenancy-scope.mjs';
84
94
  /** Environment variable selecting the global mode. */
85
95
  export const MUTATION_AUTH_MODE_ENV = 'MUTATION_AUTH_MODE';
@@ -223,6 +233,13 @@ export function classifyMutationField(fieldName, models) {
223
233
  }
224
234
  return { model: `custom:${fieldName}`, action: 'custom', cardinality: 'one', fieldName };
225
235
  }
236
+ /** The strategy-draft custom mutations (`src/resolvers/custom/StrategyDraftResolver.ts`), as classified targets. */
237
+ export const STRATEGY_DRAFT_MUTATIONS = [
238
+ 'custom:createStrategyDraft',
239
+ 'custom:saveStrategyDraft',
240
+ 'custom:deleteStrategyDraft',
241
+ 'custom:recordStrategyDraftBacktest',
242
+ ];
226
243
  const ONLY = (...actions) => new Set(actions);
227
244
  /**
228
245
  * Explicit user-write rules. Every model absent here is `service_only`.
@@ -238,7 +255,11 @@ export const MODEL_WRITE_RULES = new Map([
238
255
  ['TradingPolicy', { policy: 'account_owned', userActions: ONLY('create', 'update', 'upsert') }],
239
256
  ['AlpacaAccount', { policy: 'account_owned', userActions: ONLY('create', 'update') }],
240
257
  ['User', { policy: 'self', userActions: ONLY('update') }],
241
- ...GOVERNED_MODELS.map((model) => [model, { policy: 'tenant_scoped' }]),
258
+ ...GOVERNED_MODELS.filter((model) => !isMembershipModel(model)).map((model) => [model, { policy: 'tenant_scoped' }]),
259
+ // The entitlement rows: being inside the tenant is not enough to write the
260
+ // role that decides what everyone in it may do.
261
+ ['OrgMembership', { policy: 'membership_authority' }],
262
+ ['FundAssignment', { policy: 'membership_authority' }],
242
263
  ['Configuration', { policy: 'authenticated', userActions: ONLY('upsert') }],
243
264
  ['DashboardLayout', { policy: 'authenticated', userActions: ONLY('upsert') }],
244
265
  ['Mandate', { policy: 'authenticated', userActions: ONLY('create', 'update') }],
@@ -256,6 +277,12 @@ export const MODEL_WRITE_RULES = new Map([
256
277
  ['InvestorTransaction', { policy: 'authenticated', userActions: ONLY('update') }],
257
278
  ['custom:updateOrgTradingDefaults', { policy: 'resolver_authorized' }],
258
279
  ['custom:updateFundTradingOverrides', { policy: 'resolver_authorized' }],
280
+ // Strategy itself stays service_only: its generated inputs carry the
281
+ // operator-governed columns (desk, lifecycleState, origin). A user writes
282
+ // only their own DRAFT through these, which take no such column and
283
+ // enforce author + state + revision in one statement
284
+ // (`src/resolvers/custom/strategy-draft-service.ts`).
285
+ ...STRATEGY_DRAFT_MUTATIONS.map((field) => [field, { policy: 'resolver_authorized' }]),
259
286
  ]);
260
287
  const SERVICE_ONLY = { policy: 'service_only' };
261
288
  /** The write rule for a model. */
@@ -312,6 +339,12 @@ export function evaluateMutationAccess(principal, target, facts = {}) {
312
339
  }
313
340
  case 'self':
314
341
  return facts.targetsSelf === true ? allow('self') : forbid('not_self');
342
+ case 'membership_authority': {
343
+ const authority = facts.membershipAuthority;
344
+ if (authority === undefined || authority === 'unresolved')
345
+ return forbid('membership_authority_unresolved');
346
+ return ADMITTING_MEMBERSHIP_VERDICTS.has(authority) ? allow(authority) : forbid(authority);
347
+ }
315
348
  case 'tenant_scoped':
316
349
  case 'mandate_tenant':
317
350
  if (facts.tenantScope === 'in_scope')
@@ -33,6 +33,10 @@
33
33
  * root's tenant check reads exactly that connect); re-tenanting an
34
34
  * existing row is refused;
35
35
  * - into the caller's own `User` row while the parent is being created;
36
+ * - into any `User` row as the member of a root `OrgMembership` or
37
+ * `FundAssignment` create: adding a person to a team is what those
38
+ * creates are for, and the root decision reads that connect and requires
39
+ * authority over the tenant (`./membership-write-authority.ts`);
36
40
  * - into `AlpacaAccount` only as the policy's own account on a root
37
41
  * TradingPolicy create, whose ownership check reads that connect.
38
42
  * - **Content writes into an owned model** (account, policy, user row) are
@@ -33,6 +33,10 @@
33
33
  * root's tenant check reads exactly that connect); re-tenanting an
34
34
  * existing row is refused;
35
35
  * - into the caller's own `User` row while the parent is being created;
36
+ * - into any `User` row as the member of a root `OrgMembership` or
37
+ * `FundAssignment` create: adding a person to a team is what those
38
+ * creates are for, and the root decision reads that connect and requires
39
+ * authority over the tenant (`./membership-write-authority.ts`);
36
40
  * - into `AlpacaAccount` only as the policy's own account on a root
37
41
  * TradingPolicy create, whose ownership check reads that connect.
38
42
  * - **Content writes into an owned model** (account, policy, user row) are
@@ -76,12 +80,27 @@ function nestedPolicyOf(model) {
76
80
  const policy = ruleFor(model).policy;
77
81
  return policy === 'mandate_tenant' ? 'authenticated' : policy;
78
82
  }
83
+ /**
84
+ * Whether a connect names the member of a root entitlement-row create. The
85
+ * root's own decision reads the member from this connect and holds the
86
+ * caller to authority over the tenant, so the hop needs no check of its own.
87
+ */
88
+ function isRootMemberConnect(write) {
89
+ return (write.depth === 1 &&
90
+ write.parentMode === 'create' &&
91
+ write.relation === 'user' &&
92
+ ENTITLEMENT_MODELS.has(write.parentModel) &&
93
+ write.connectIds !== null &&
94
+ write.connectIds.length === 1);
95
+ }
79
96
  function connectAllowed(write, callerId, relations) {
80
97
  if (relations.fkOnParent(write.parentModel, write.relation) !== true)
81
98
  return false;
82
99
  const policy = nestedPolicyOf(write.model);
83
100
  switch (policy) {
84
101
  case 'self':
102
+ if (isRootMemberConnect(write))
103
+ return true;
85
104
  return (write.parentMode === 'create' &&
86
105
  write.connectIds !== null &&
87
106
  write.connectIds.length > 0 &&
@@ -68,6 +68,34 @@ export declare function getTenancyScopingMode(env?: Record<string, string | unde
68
68
  * FeatureFlagOverride belongs to a user or an organization.
69
69
  */
70
70
  export declare const DESK_MODELS: readonly ["Follow", "AutoFollowRule", "PushSubscription", "AdaConversation", "AdaMessage", "UserTotp", "DeskDecision", "FeatureFlagOverride"];
71
+ /**
72
+ * Models scoped on READ only: the middleware classifies their read fields and
73
+ * none of their writes.
74
+ *
75
+ * `Strategy` holds two kinds of row. A SYSTEM strategy (`kind` NULL) is the
76
+ * platform's catalog and stays readable as it always was. An authored
77
+ * strategy (`kind` set, written by the strategy builder) belongs to one fund
78
+ * (`fundId`) and is readable only by that fund's members, so a draft never
79
+ * reaches a person outside the fund it was written in.
80
+ *
81
+ * Writes are decided elsewhere, and more narrowly: every generated `Strategy`
82
+ * mutation is `service_only` for a user in the mutation guard, and the draft
83
+ * mutations hold the author and the fund themselves
84
+ * (`src/resolvers/custom/strategy-draft-service.ts`, through
85
+ * {@link buildWriteScopeWhere}). The model is kept out of
86
+ * {@link GOVERNED_MODELS} on purpose: that list also gives each model a
87
+ * user-write rule (`tenant_scoped`, or `membership_authority` for the
88
+ * entitlement rows; `src/auth/mutation-authorization.ts`),
89
+ * which would make the generated `Strategy` writes user-writable.
90
+ *
91
+ * Scoped in every mode ({@link ALWAYS_ENFORCED_MODELS}): the predicate leaves
92
+ * every SYSTEM row exactly as readable as before, so a staged rollout has no
93
+ * existing reader to protect, and holding it in shadow would serve every
94
+ * fund's drafts to any signed-in user.
95
+ */
96
+ export declare const READ_SCOPED_MODELS: readonly ["Strategy"];
97
+ /** A model scoped on read only (see {@link READ_SCOPED_MODELS}). */
98
+ export type ReadScopedModel = (typeof READ_SCOPED_MODELS)[number];
71
99
  /**
72
100
  * The tenancy, notification and desk models subject to row-level scoping.
73
101
  * Everything else (AlpacaAccount, Trade, User, …) is intentionally out of
@@ -91,8 +119,10 @@ export declare const GOVERNED_MODELS: readonly ["Organization", "OrgMembership",
91
119
  export declare const ALWAYS_ENFORCED_MODELS: ReadonlySet<string>;
92
120
  /** Whether a governed model is scoped in every mode (see {@link ALWAYS_ENFORCED_MODELS}). */
93
121
  export declare function isAlwaysEnforced(model: string): boolean;
94
- /** A model name subject to row-level tenancy scoping. */
122
+ /** A model name subject to row-level tenancy scoping on reads and writes. */
95
123
  export type GovernedModel = (typeof GOVERNED_MODELS)[number];
124
+ /** Any model the tenancy middleware scopes: governed, or read-scoped only. */
125
+ export type ScopedModel = GovernedModel | ReadScopedModel;
96
126
  /**
97
127
  * Operation family for a governed resolver field:
98
128
  *
@@ -108,7 +138,7 @@ export type GovernedModel = (typeof GOVERNED_MODELS)[number];
108
138
  export type GovernedOpKind = 'whereScope' | 'createScope' | 'upsertScope';
109
139
  /** Resolution of a resolver field name onto its governed model + op kind. */
110
140
  export interface GovernedField {
111
- readonly model: GovernedModel;
141
+ readonly model: ScopedModel;
112
142
  readonly opKind: GovernedOpKind;
113
143
  }
114
144
  /**
@@ -206,18 +236,30 @@ export type WhereFragment = Record<string, unknown>;
206
236
  * @param ent - The caller's entitlement.
207
237
  * @returns A Prisma `where` fragment.
208
238
  */
209
- export declare function buildScopeWhere(model: GovernedModel, ent: Entitlement): WhereFragment;
239
+ export declare function buildScopeWhere(model: ScopedModel, ent: Entitlement): WhereFragment;
210
240
  /**
211
241
  * The scope a WRITE (update, upsert, delete) must stay inside. Identical to
212
242
  * {@link buildScopeWhere} except for Ada conversations: a conversation shared
213
243
  * with the organization is readable by its members but writable only by its
214
- * author, and the same holds for its messages.
244
+ * author, and the same holds for its messages. A Strategy is written by a
245
+ * user only as their own authored draft, in a fund they belong to; a SYSTEM
246
+ * strategy is never in a user's write scope.
215
247
  *
216
248
  * @param model - The governed model.
217
249
  * @param ent - The caller's entitlement.
218
250
  * @returns A Prisma `where` fragment.
219
251
  */
220
- export declare function buildWriteScopeWhere(model: GovernedModel, ent: Entitlement): WhereFragment;
252
+ export declare function buildWriteScopeWhere(model: ScopedModel, ent: Entitlement): WhereFragment;
253
+ /**
254
+ * The scope an UNAUTHENTICATED read of a model is held to, or `null` when the
255
+ * model has none (it is then passed or refused by the middleware's mode
256
+ * rules). A caller with no identity belongs to no fund, so it reads only the
257
+ * SYSTEM strategies and never an authored one.
258
+ *
259
+ * @param model - The scoped model.
260
+ * @returns A Prisma `where` fragment, or `null`.
261
+ */
262
+ export declare function anonymousScopeWhere(model: ScopedModel): WhereFragment | null;
221
263
  /**
222
264
  * AND-compose a scope fragment onto a caller-supplied `where`, preserving any
223
265
  * top-level fields (including a unique selector such as `id`/`slug`) so
@@ -245,7 +287,7 @@ export interface ParentScopePrismaClient {
245
287
  adaConversation: ParentScopeReader;
246
288
  }
247
289
  /** Whether a model's create is scoped by a parent row (see {@link parentScopedCreateInScope}). */
248
- export declare function hasCreateParent(model: GovernedModel): boolean;
290
+ export declare function hasCreateParent(model: ScopedModel): boolean;
249
291
  /**
250
292
  * Whether a create payload (or every element of a createMany payload) names a
251
293
  * parent row the caller may WRITE. Used for models whose tenant is their
@@ -258,7 +300,7 @@ export declare function hasCreateParent(model: GovernedModel): boolean;
258
300
  * @returns `false` for a model with no parent rule, a payload naming no
259
301
  * parent, or a parent outside the caller's write scope.
260
302
  */
261
- export declare function parentScopedCreateInScope(prisma: ParentScopePrismaClient, model: GovernedModel, data: unknown, ent: Entitlement): Promise<boolean>;
303
+ export declare function parentScopedCreateInScope(prisma: ParentScopePrismaClient, model: ScopedModel, data: unknown, ent: Entitlement): Promise<boolean>;
262
304
  /**
263
305
  * Whether a create/createMany/upsert payload is entirely within the caller's
264
306
  * entitlement. Accepts a single object or an array (createMany), requiring
@@ -269,7 +311,7 @@ export declare function parentScopedCreateInScope(prisma: ParentScopePrismaClien
269
311
  * @param ent - The caller's entitlement.
270
312
  * @returns `true` when every element lands in an entitled tenant.
271
313
  */
272
- export declare function dataInScope(model: GovernedModel, data: unknown, ent: Entitlement): boolean;
314
+ export declare function dataInScope(model: ScopedModel, data: unknown, ent: Entitlement): boolean;
273
315
  /**
274
316
  * The scoping decision for one governed operation:
275
317
  *
@@ -73,6 +73,32 @@ export const DESK_MODELS = [
73
73
  'DeskDecision',
74
74
  'FeatureFlagOverride',
75
75
  ];
76
+ /**
77
+ * Models scoped on READ only: the middleware classifies their read fields and
78
+ * none of their writes.
79
+ *
80
+ * `Strategy` holds two kinds of row. A SYSTEM strategy (`kind` NULL) is the
81
+ * platform's catalog and stays readable as it always was. An authored
82
+ * strategy (`kind` set, written by the strategy builder) belongs to one fund
83
+ * (`fundId`) and is readable only by that fund's members, so a draft never
84
+ * reaches a person outside the fund it was written in.
85
+ *
86
+ * Writes are decided elsewhere, and more narrowly: every generated `Strategy`
87
+ * mutation is `service_only` for a user in the mutation guard, and the draft
88
+ * mutations hold the author and the fund themselves
89
+ * (`src/resolvers/custom/strategy-draft-service.ts`, through
90
+ * {@link buildWriteScopeWhere}). The model is kept out of
91
+ * {@link GOVERNED_MODELS} on purpose: that list also gives each model a
92
+ * user-write rule (`tenant_scoped`, or `membership_authority` for the
93
+ * entitlement rows; `src/auth/mutation-authorization.ts`),
94
+ * which would make the generated `Strategy` writes user-writable.
95
+ *
96
+ * Scoped in every mode ({@link ALWAYS_ENFORCED_MODELS}): the predicate leaves
97
+ * every SYSTEM row exactly as readable as before, so a staged rollout has no
98
+ * existing reader to protect, and holding it in shadow would serve every
99
+ * fund's drafts to any signed-in user.
100
+ */
101
+ export const READ_SCOPED_MODELS = ['Strategy'];
76
102
  /**
77
103
  * The tenancy, notification and desk models subject to row-level scoping.
78
104
  * Everything else (AlpacaAccount, Trade, User, …) is intentionally out of
@@ -103,7 +129,10 @@ export const GOVERNED_MODELS = [
103
129
  * user's conversations, push endpoints and second-factor state to whoever
104
130
  * asks while the shadow series accumulated.
105
131
  */
106
- export const ALWAYS_ENFORCED_MODELS = new Set(DESK_MODELS);
132
+ export const ALWAYS_ENFORCED_MODELS = new Set([
133
+ ...DESK_MODELS,
134
+ ...READ_SCOPED_MODELS,
135
+ ]);
107
136
  /** Whether a governed model is scoped in every mode (see {@link ALWAYS_ENFORCED_MODELS}). */
108
137
  export function isAlwaysEnforced(model) {
109
138
  return ALWAYS_ENFORCED_MODELS.has(model);
@@ -131,7 +160,20 @@ const PLURAL_FIELD = {
131
160
  UserTotp: 'userTotps',
132
161
  DeskDecision: 'deskDecisions',
133
162
  FeatureFlagOverride: 'featureFlagOverrides',
163
+ Strategy: 'strategies',
134
164
  };
165
+ /** The read fields typegraphql-prisma generates for a model. */
166
+ function readFieldsOf(model) {
167
+ return [
168
+ PLURAL_FIELD[model], // findMany
169
+ lowerFirst(model), // findUnique
170
+ `get${model}`, // findUniqueOrThrow
171
+ `findFirst${model}`,
172
+ `findFirst${model}OrThrow`,
173
+ `aggregate${model}`,
174
+ `groupBy${model}`,
175
+ ];
176
+ }
135
177
  /** Lower-camel the first character of a model name (e.g. `Fund` → `fund`). */
136
178
  function lowerFirst(value) {
137
179
  return value.length === 0 ? value : value[0].toLowerCase() + value.slice(1);
@@ -143,16 +185,14 @@ function lowerFirst(value) {
143
185
  */
144
186
  const GOVERNED_FIELD_MAP = (() => {
145
187
  const map = new Map();
188
+ for (const model of READ_SCOPED_MODELS) {
189
+ for (const field of readFieldsOf(model)) {
190
+ map.set(field, { model, opKind: 'whereScope' });
191
+ }
192
+ }
146
193
  for (const model of GOVERNED_MODELS) {
147
- const singular = lowerFirst(model);
148
194
  const whereScopeFields = [
149
- PLURAL_FIELD[model], // findMany
150
- singular, // findUnique
151
- `get${model}`, // findUniqueOrThrow
152
- `findFirst${model}`,
153
- `findFirst${model}OrThrow`,
154
- `aggregate${model}`,
155
- `groupBy${model}`,
195
+ ...readFieldsOf(model),
156
196
  `updateOne${model}`,
157
197
  `updateMany${model}`,
158
198
  `deleteOne${model}`,
@@ -221,6 +261,14 @@ export async function resolveEntitlement(prisma, userId) {
221
261
  ]);
222
262
  return { userId, orgIds, fundIds };
223
263
  }
264
+ /**
265
+ * The Strategy rows a user may READ: every SYSTEM strategy (no authoring
266
+ * kind), and an authored strategy only in a fund they belong to. An authored
267
+ * row with no fund belongs to no fund, so no user reads it.
268
+ */
269
+ function strategyReadScope(fundIds) {
270
+ return { OR: [{ kind: { equals: null } }, { fundId: { in: fundIds } }] };
271
+ }
224
272
  /** The AdaConversation rows a user may READ: their own, and shared ones in an entitled fund. */
225
273
  function adaConversationReadScope(ent, fundIds) {
226
274
  return {
@@ -299,25 +347,48 @@ export function buildScopeWhere(model, ent) {
299
347
  return { conversation: { is: adaConversationReadScope(ent, fundIds) } };
300
348
  case 'FeatureFlagOverride':
301
349
  return { OR: [{ userId: eq(ent.userId) }, { organizationId: { in: orgIds } }] };
350
+ case 'Strategy':
351
+ return strategyReadScope(fundIds);
302
352
  }
303
353
  }
304
354
  /**
305
355
  * The scope a WRITE (update, upsert, delete) must stay inside. Identical to
306
356
  * {@link buildScopeWhere} except for Ada conversations: a conversation shared
307
357
  * with the organization is readable by its members but writable only by its
308
- * author, and the same holds for its messages.
358
+ * author, and the same holds for its messages. A Strategy is written by a
359
+ * user only as their own authored draft, in a fund they belong to; a SYSTEM
360
+ * strategy is never in a user's write scope.
309
361
  *
310
362
  * @param model - The governed model.
311
363
  * @param ent - The caller's entitlement.
312
364
  * @returns A Prisma `where` fragment.
313
365
  */
314
366
  export function buildWriteScopeWhere(model, ent) {
367
+ if (model === 'Strategy') {
368
+ return {
369
+ kind: { not: null },
370
+ ownerUserId: eq(ent.userId),
371
+ fundId: { in: [...ent.fundIds] },
372
+ };
373
+ }
315
374
  if (model === 'AdaConversation')
316
375
  return { userId: eq(ent.userId) };
317
376
  if (model === 'AdaMessage')
318
377
  return { conversation: { is: { userId: eq(ent.userId) } } };
319
378
  return buildScopeWhere(model, ent);
320
379
  }
380
+ /**
381
+ * The scope an UNAUTHENTICATED read of a model is held to, or `null` when the
382
+ * model has none (it is then passed or refused by the middleware's mode
383
+ * rules). A caller with no identity belongs to no fund, so it reads only the
384
+ * SYSTEM strategies and never an authored one.
385
+ *
386
+ * @param model - The scoped model.
387
+ * @returns A Prisma `where` fragment, or `null`.
388
+ */
389
+ export function anonymousScopeWhere(model) {
390
+ return model === 'Strategy' ? { kind: { equals: null } } : null;
391
+ }
321
392
  /**
322
393
  * AND-compose a scope fragment onto a caller-supplied `where`, preserving any
323
394
  * top-level fields (including a unique selector such as `id`/`slug`) so
@@ -432,6 +503,10 @@ function singleDataInScope(model, data, ent) {
432
503
  // by id: it cannot be proven from the payload alone. The callers that can
433
504
  // read the database resolve it with {@link parentScopedCreateInScope}.
434
505
  return false;
506
+ case 'Strategy':
507
+ // No create is classified for Strategy: a user creates one only through
508
+ // createStrategyDraft, which checks the fund itself.
509
+ return false;
435
510
  }
436
511
  }
437
512
  const CREATE_PARENTS = {
@@ -585,6 +660,8 @@ function readAlreadyScoped(model, where, ent) {
585
660
  return isSelf('userId') || inOrg('organizationId');
586
661
  case 'AdaMessage':
587
662
  return false;
663
+ case 'Strategy':
664
+ return inFund('fundId');
588
665
  }
589
666
  }
590
667
  /** Whether a compound unique selector in `where` names the caller as its `userId`. */
@@ -1,2 +1,2 @@
1
- export declare const Strategy = "\n id\n key\n displayName\n description\n origin\n lifecycleState\n manifestHash\n kind\n spec\n backtestJobId\n desk\n ownerUserId\n createdAt\n updatedAt\n deletedAt\n";
1
+ export declare const Strategy = "\n id\n key\n displayName\n description\n origin\n lifecycleState\n manifestHash\n kind\n spec\n backtestJobId\n backtestSpecHash\n desk\n ownerUserId\n fundId\n createdAt\n updatedAt\n deletedAt\n";
2
2
  //# sourceMappingURL=Strategy.d.ts.map
@@ -9,8 +9,10 @@ export const Strategy = `
9
9
  kind
10
10
  spec
11
11
  backtestJobId
12
+ backtestSpecHash
12
13
  desk
13
14
  ownerUserId
15
+ fundId
14
16
  createdAt
15
17
  updatedAt
16
18
  deletedAt
@@ -1,2 +1,2 @@
1
- export declare const StrategySubscription = "\n id\n accountId\n strategyId\n strategy {\n id\n key\n displayName\n description\n origin\n lifecycleState\n manifestHash\n kind\n spec\n backtestJobId\n desk\n ownerUserId\n createdAt\n updatedAt\n deletedAt\n }\n status\n units\n costBasis\n realizedPL\n targetAllocationPct\n currency\n subscribedAt\n lastRebalancedAt\n createdAt\n updatedAt\n deletedAt\n";
1
+ export declare const StrategySubscription = "\n id\n accountId\n strategyId\n strategy {\n id\n key\n displayName\n description\n origin\n lifecycleState\n manifestHash\n kind\n spec\n backtestJobId\n backtestSpecHash\n desk\n ownerUserId\n fundId\n createdAt\n updatedAt\n deletedAt\n }\n status\n units\n costBasis\n realizedPL\n targetAllocationPct\n currency\n subscribedAt\n lastRebalancedAt\n createdAt\n updatedAt\n deletedAt\n";
2
2
  //# sourceMappingURL=StrategySubscription.d.ts.map
@@ -13,8 +13,10 @@ export const StrategySubscription = `
13
13
  kind
14
14
  spec
15
15
  backtestJobId
16
+ backtestSpecHash
16
17
  desk
17
18
  ownerUserId
19
+ fundId
18
20
  createdAt
19
21
  updatedAt
20
22
  deletedAt
@@ -1,2 +1,2 @@
1
- export declare const StrategyTypeString = "\n// Your response should adhere to the following type definition for the \"Strategy\" type.\n// Importantly, DO NOT include any annotations in your response (i.e., remove the ones we have provided for your reference below).\n\nexport type Strategy = {\n // Stable machine key, e.g. \"core-equity-llm-v1\". Matches the engine Tier A\n`StrategyRegistryEntry.key` column type exactly.\n key: string;\n // Operator/user-facing name.\n displayName: string;\n // Human-readable description of what the strategy does.\n description?: string;\n // Where the definition came from.\n origin: StrategyOrigin;\n // Lifecycle stage. New rows default to DRAFT so a strategy is never\nrecorded as live merely by virtue of existing.\n lifecycleState: StrategyLifecycleState;\n // SHA-256 (hex) of the canonical JSON manifest describing what this\nstrategy runs (prompt id, feature view, exit tiers). NULL means no\nmanifest is bound yet \u2014 it is genuinely unknown, never a placeholder.\n manifestHash?: string;\n // Authoring kind: a thematic basket or a signal strategy. NULL for strategies\nthat predate desk authoring.\n kind?: StrategyKind;\n // Authored specification (JSON). Thematic: `{ thesis, horizon, constituents[],\nweighting, allocationPct, maxNamePct, rebalance, exitRule, benchmark }`;\nsignal: `{ hypothesis, inputs[], formula, universe, neutralise { sector, beta,\nsize }, allocationPct, paperSessions, promotionGate }`. NULL means no draft\nhas been authored.\n spec?: any;\n // The agent desk this strategy trades under. NULL means no operator has\nassigned it yet: a strategy is never placed on a desk by default, because\nthe desk decides which autonomy matrix governs its orders and which desk's\nmetrics its fills count toward.\n desk?: DeskType;\n};\n\nenum StrategyOrigin {\n SYSTEM\n\n USER\n\n AI_GENERATED\n}\n\nenum StrategyLifecycleState {\n DRAFT\n\n SHADOW\n\n ACTIVE\n\n PAUSED\n\n RETIRED\n}\n\nenum StrategyKind {\n thematic\n\n signal\n}\n\nenum DeskType {\n EVENT\n\n THEMATIC\n\n SYSTEMATIC\n}\n\n";
1
+ export declare const StrategyTypeString = "\n// Your response should adhere to the following type definition for the \"Strategy\" type.\n// Importantly, DO NOT include any annotations in your response (i.e., remove the ones we have provided for your reference below).\n\nexport type Strategy = {\n // Stable machine key, e.g. \"core-equity-llm-v1\". Matches the engine Tier A\n`StrategyRegistryEntry.key` column type exactly.\n key: string;\n // Operator/user-facing name.\n displayName: string;\n // Human-readable description of what the strategy does.\n description?: string;\n // Where the definition came from.\n origin: StrategyOrigin;\n // Lifecycle stage. New rows default to DRAFT so a strategy is never\nrecorded as live merely by virtue of existing.\n lifecycleState: StrategyLifecycleState;\n // SHA-256 (hex) of the canonical JSON manifest describing what this\nstrategy runs (prompt id, feature view, exit tiers). NULL means no\nmanifest is bound yet \u2014 it is genuinely unknown, never a placeholder.\n manifestHash?: string;\n // Authoring kind: a thematic basket or a signal strategy. NULL for strategies\nthat predate desk authoring.\n kind?: StrategyKind;\n // Authored specification (JSON). Thematic: `{ thesis, horizon, constituents[],\nweighting, allocationPct, maxNamePct, rebalance, exitRule, benchmark }`;\nsignal: `{ hypothesis, inputs[], formula, universe, neutralise { sector, beta,\nsize }, allocationPct, paperSessions, promotionGate }`. NULL means no draft\nhas been authored.\n spec?: any;\n // SHA-256 (hex) of the canonical JSON of the `spec` the backtest in\n`backtestJobId` was run against (`src/resolvers/custom/strategy-spec-hash.ts`).\nA backtest attests a spec only while this equals the hash of the stored\nspec. NULL means no backtest is recorded against any spec.\n backtestSpecHash?: string;\n // The agent desk this strategy trades under. NULL means no operator has\nassigned it yet: a strategy is never placed on a desk by default, because\nthe desk decides which autonomy matrix governs its orders and which desk's\nmetrics its fills count toward.\n desk?: DeskType;\n};\n\nenum StrategyOrigin {\n SYSTEM\n\n USER\n\n AI_GENERATED\n}\n\nenum StrategyLifecycleState {\n DRAFT\n\n PENDING_APPROVAL\n\n SHADOW\n\n ACTIVE\n\n PAUSED\n\n RETIRED\n}\n\nenum StrategyKind {\n thematic\n\n signal\n}\n\nenum DeskType {\n EVENT\n\n THEMATIC\n\n SYSTEMATIC\n}\n\n";
2
2
  //# sourceMappingURL=Strategy.d.ts.map
@@ -28,6 +28,11 @@ signal: \`{ hypothesis, inputs[], formula, universe, neutralise { sector, beta,
28
28
  size }, allocationPct, paperSessions, promotionGate }\`. NULL means no draft
29
29
  has been authored.
30
30
  spec?: any;
31
+ // SHA-256 (hex) of the canonical JSON of the \`spec\` the backtest in
32
+ \`backtestJobId\` was run against (\`src/resolvers/custom/strategy-spec-hash.ts\`).
33
+ A backtest attests a spec only while this equals the hash of the stored
34
+ spec. NULL means no backtest is recorded against any spec.
35
+ backtestSpecHash?: string;
31
36
  // The agent desk this strategy trades under. NULL means no operator has
32
37
  assigned it yet: a strategy is never placed on a desk by default, because
33
38
  the desk decides which autonomy matrix governs its orders and which desk's
@@ -46,6 +51,8 @@ enum StrategyOrigin {
46
51
  enum StrategyLifecycleState {
47
52
  DRAFT
48
53
 
54
+ PENDING_APPROVAL
55
+
49
56
  SHADOW
50
57
 
51
58
  ACTIVE
@@ -83,7 +83,7 @@ export declare const typeStrings: {
83
83
  readonly mandateVersion: "\n// Your response should adhere to the following type definition for the \"MandateVersion\" type.\n// Importantly, DO NOT include any annotations in your response (i.e., remove the ones we have provided for your reference below).\n\nexport type MandateVersion = {\n // Relation to the parent Mandate.\n mandate: {\n // Human-readable mandate name.\n name: string;\n // Category of the mandate (strategy charter, firm ethos, approval matrix, risk policy, SOP).\n klass: MandateClass;\n };\n // Human-readable version label (e.g. 'v1', 'v2.1', '2026-Q3').\n versionLabel: string;\n // Monotonic version sequence within the mandate (1, 2, 3, …); orders the version history.\n versionSeq: number;\n // Lifecycle state of this version.\n status: MandateStatus;\n // Short human summary of what this version establishes or changes.\n summary?: string;\n // Autonomy matrix: desk → action → size bucket (four buckets) → 'auto' | 'notify' | 'approve' | 'forbidden' (JSON). Null means the version sets none.\n autonomy?: any;\n // Escalation triggers: `{ id, label, condition, route, deadlineMinutes | null, defaultAction, enabled }[]` (JSON). Null means none are set.\n triggers?: any;\n // Instrument permissions: `{ id, label, enabled }[]` (JSON). Null means none are set.\n instruments?: any;\n // Excluded symbols, sectors or issuers named by this version. Empty means no exclusions.\n exclusions: string[];\n // Relation to the authoring User.\n authoredBy?: {\n // The user's full name.\n name?: string;\n // The user's email address, must be unique.\n email?: string;\n };\n};\n\nenum MandateClass {\n STRATEGY_CHARTER\n\n FIRM_ETHOS\n\n APPROVAL_MATRIX\n\n RISK_POLICY\n\n SOP\n}\n\nenum MandateStatus {\n DRAFTED\n\n PROPOSED\n\n APPROVED\n\n SUPERSEDED\n\n ARCHIVED\n}\n\n";
84
84
  readonly mandateRule: "\n// Your response should adhere to the following type definition for the \"MandateRule\" type.\n// Importantly, DO NOT include any annotations in your response (i.e., remove the ones we have provided for your reference below).\n\nexport type MandateRule = {\n // Relation to the parent MandateVersion.\n mandateVersion: {\n // Human-readable version label (e.g. 'v1', 'v2.1', '2026-Q3').\n versionLabel: string;\n };\n // Short label identifying the clause (platform MandateRule.label).\n label: string;\n // Human-readable clause text (platform MandateRule.detail).\n detail: string;\n // Control gate this clause imposes (platform MandateRule.control / GovActType).\n control: MandateControlGate;\n // Numeric threshold for the clause, if quantitative (platform MandateRule.threshold). Null for qualitative clauses.\n threshold?: number;\n // Unit of the threshold (e.g. '%', 'bps', 'USD', 'positions'); platform MandateRule.unit.\n unit?: string;\n // Direction/nature of the threshold (MAX/MIN/TARGET/TRIGGER); platform MandateRule.limitKind. Null for qualitative clauses.\n limitKind?: MandateLimitKind;\n // Stable code naming this rule within its version (e.g. `R-01`, `R-01b`); the\ndesk's limit gauges and the ledger cite it. Unique per mandate version.\nNull for a clause no gauge or ledger entry cites.\n ruleCode?: string;\n // The quantity the engine measures against `threshold`. Null for a\nqualitative clause, which no gauge can show. A rule naming a metric must\nalso carry `threshold`, `action`, `group` and `ruleCode` (database CHECK\n`mandate_rules_metric_complete_check`), because a limit gauge needs every\none of them.\n metricKey?: MandateMetric;\n // What the engine does when the measured quantity crosses `threshold`. Null\nfor a qualitative clause.\n action?: MandateAction;\n // The gauge group this rule is shown under on the desk. Null for a\nqualitative clause.\n group?: MandateRuleGroup;\n};\n\nenum MandateControlGate {\n AUTO\n\n NOTIFY\n\n APPROVAL\n\n PROPOSE\n\n HUMAN\n}\n\nenum MandateLimitKind {\n MAX\n\n MIN\n\n TARGET\n\n TRIGGER\n}\n\nenum MandateMetric {\n GROSS_LEVERAGE\n\n NET_EXPOSURE_RATIO\n\n SINGLE_NAME_CONCENTRATION\n\n MAX_SECTOR_CONCENTRATION\n\n DAILY_LOSS\n\n DRAWDOWN\n\n VAR_95\n\n VAR_99\n\n EXPECTED_SHORTFALL_95\n\n MARGIN_UTILIZATION\n\n OPEN_POSITIONS\n}\n\nenum MandateAction {\n BLOCK\n\n ESCALATE\n\n HALT\n\n DERISK\n}\n\nenum MandateRuleGroup {\n EXPOSURE\n\n LOSS\n\n LIQUIDITY\n}\n\n";
85
85
  readonly mandateApproval: "\n// Your response should adhere to the following type definition for the \"MandateApproval\" type.\n// Importantly, DO NOT include any annotations in your response (i.e., remove the ones we have provided for your reference below).\n\nexport type MandateApproval = {\n // Relation to the MandateVersion.\n mandateVersion: {\n // Human-readable version label (e.g. 'v1', 'v2.1', '2026-Q3').\n versionLabel: string;\n // Lifecycle state of this version.\n status: MandateStatus;\n };\n // Governance action taken ('propose' | 'approve' | 'reject' | 'escalate' | 'supersede' | 'archive'); lowercase String matching the platform/engine decision contract. Kept as String, not an enum, per the five-enum mandate-store spec.\n action: string;\n // Relation to the deciding User.\n decidedBy?: {\n // The user's full name.\n name?: string;\n // The user's email address, must be unique.\n email?: string;\n };\n // Role under which the decision was made ('compliance_officer' | 'fund_operator' | …); lowercase String to match the platform contract.\n decidedByRole?: string;\n // Free-text rationale for the decision.\n rationale?: string;\n};\n\nenum MandateStatus {\n DRAFTED\n\n PROPOSED\n\n APPROVED\n\n SUPERSEDED\n\n ARCHIVED\n}\n\n";
86
- readonly strategy: "\n// Your response should adhere to the following type definition for the \"Strategy\" type.\n// Importantly, DO NOT include any annotations in your response (i.e., remove the ones we have provided for your reference below).\n\nexport type Strategy = {\n // Stable machine key, e.g. \"core-equity-llm-v1\". Matches the engine Tier A\n`StrategyRegistryEntry.key` column type exactly.\n key: string;\n // Operator/user-facing name.\n displayName: string;\n // Human-readable description of what the strategy does.\n description?: string;\n // Where the definition came from.\n origin: StrategyOrigin;\n // Lifecycle stage. New rows default to DRAFT so a strategy is never\nrecorded as live merely by virtue of existing.\n lifecycleState: StrategyLifecycleState;\n // SHA-256 (hex) of the canonical JSON manifest describing what this\nstrategy runs (prompt id, feature view, exit tiers). NULL means no\nmanifest is bound yet — it is genuinely unknown, never a placeholder.\n manifestHash?: string;\n // Authoring kind: a thematic basket or a signal strategy. NULL for strategies\nthat predate desk authoring.\n kind?: StrategyKind;\n // Authored specification (JSON). Thematic: `{ thesis, horizon, constituents[],\nweighting, allocationPct, maxNamePct, rebalance, exitRule, benchmark }`;\nsignal: `{ hypothesis, inputs[], formula, universe, neutralise { sector, beta,\nsize }, allocationPct, paperSessions, promotionGate }`. NULL means no draft\nhas been authored.\n spec?: any;\n // The agent desk this strategy trades under. NULL means no operator has\nassigned it yet: a strategy is never placed on a desk by default, because\nthe desk decides which autonomy matrix governs its orders and which desk's\nmetrics its fills count toward.\n desk?: DeskType;\n};\n\nenum StrategyOrigin {\n SYSTEM\n\n USER\n\n AI_GENERATED\n}\n\nenum StrategyLifecycleState {\n DRAFT\n\n SHADOW\n\n ACTIVE\n\n PAUSED\n\n RETIRED\n}\n\nenum StrategyKind {\n thematic\n\n signal\n}\n\nenum DeskType {\n EVENT\n\n THEMATIC\n\n SYSTEMATIC\n}\n\n";
86
+ readonly strategy: "\n// Your response should adhere to the following type definition for the \"Strategy\" type.\n// Importantly, DO NOT include any annotations in your response (i.e., remove the ones we have provided for your reference below).\n\nexport type Strategy = {\n // Stable machine key, e.g. \"core-equity-llm-v1\". Matches the engine Tier A\n`StrategyRegistryEntry.key` column type exactly.\n key: string;\n // Operator/user-facing name.\n displayName: string;\n // Human-readable description of what the strategy does.\n description?: string;\n // Where the definition came from.\n origin: StrategyOrigin;\n // Lifecycle stage. New rows default to DRAFT so a strategy is never\nrecorded as live merely by virtue of existing.\n lifecycleState: StrategyLifecycleState;\n // SHA-256 (hex) of the canonical JSON manifest describing what this\nstrategy runs (prompt id, feature view, exit tiers). NULL means no\nmanifest is bound yet — it is genuinely unknown, never a placeholder.\n manifestHash?: string;\n // Authoring kind: a thematic basket or a signal strategy. NULL for strategies\nthat predate desk authoring.\n kind?: StrategyKind;\n // Authored specification (JSON). Thematic: `{ thesis, horizon, constituents[],\nweighting, allocationPct, maxNamePct, rebalance, exitRule, benchmark }`;\nsignal: `{ hypothesis, inputs[], formula, universe, neutralise { sector, beta,\nsize }, allocationPct, paperSessions, promotionGate }`. NULL means no draft\nhas been authored.\n spec?: any;\n // SHA-256 (hex) of the canonical JSON of the `spec` the backtest in\n`backtestJobId` was run against (`src/resolvers/custom/strategy-spec-hash.ts`).\nA backtest attests a spec only while this equals the hash of the stored\nspec. NULL means no backtest is recorded against any spec.\n backtestSpecHash?: string;\n // The agent desk this strategy trades under. NULL means no operator has\nassigned it yet: a strategy is never placed on a desk by default, because\nthe desk decides which autonomy matrix governs its orders and which desk's\nmetrics its fills count toward.\n desk?: DeskType;\n};\n\nenum StrategyOrigin {\n SYSTEM\n\n USER\n\n AI_GENERATED\n}\n\nenum StrategyLifecycleState {\n DRAFT\n\n PENDING_APPROVAL\n\n SHADOW\n\n ACTIVE\n\n PAUSED\n\n RETIRED\n}\n\nenum StrategyKind {\n thematic\n\n signal\n}\n\nenum DeskType {\n EVENT\n\n THEMATIC\n\n SYSTEMATIC\n}\n\n";
87
87
  readonly strategySubscription: "\n// Your response should adhere to the following type definition for the \"StrategySubscription\" type.\n// Importantly, DO NOT include any annotations in your response (i.e., remove the ones we have provided for your reference below).\n\nexport type StrategySubscription = {\n // Lifecycle status of the opt-in.\n status: StrategySubscriptionStatus;\n // Units (sleeve shares) currently held under this subscription. A fresh\nsubscription genuinely holds zero, so `0` here is a true measurement and\nnot a stand-in for \"unknown\".\n units: number;\n // Cumulative net capital contributed to this sleeve, net of withdrawals.\n costBasis: number;\n // Cumulative realized P/L booked out of this sleeve.\n realizedPL: number;\n // Target share of account equity allocated to this strategy, as a 0..1\nfraction. NULL means NO ALLOCATION HAS BEEN DECIDED — deliberately\nnullable with NO default so that \"unallocated\" can never be read as a\n0% target. Consumers must render absence as absence; the platform\nStrategies grid renders it as an em-dash.\n targetAllocationPct?: number;\n // Base currency of the capital columns (ISO 4217).\n currency: string;\n // When the account first opted in.\n subscribedAt?: Date;\n // When a rebalance toward `targetAllocationPct` was last recorded against\nthis sleeve. NULL means none has been.\n lastRebalancedAt?: Date;\n};\n\nenum StrategySubscriptionStatus {\n ACTIVE\n\n PAUSED\n\n CLOSED\n}\n\n";
88
88
  readonly featureFlagOverride: "\n// Your response should adhere to the following type definition for the \"FeatureFlagOverride\" type.\n// Importantly, DO NOT include any annotations in your response (i.e., remove the ones we have provided for your reference below).\n\nexport type FeatureFlagOverride = {\n // Flag key, e.g. 'desk_ia'.\n flag: string;\n // Whether the flag is on for this user or organization.\n enabled: boolean;\n // Principal that last set the override (user id or service name).\n updatedBy: string;\n};\n\n";
89
89
  readonly follow: "\n// Your response should adhere to the following type definition for the \"Follow\" type.\n// Importantly, DO NOT include any annotations in your response (i.e., remove the ones we have provided for your reference below).\n\nexport type Follow = {\n // Relation to the Fund.\n fund: {\n // Fund display name.\n name: string;\n // URL-safe slug, unique within the owning organization.\n slug: string;\n };\n // What the follow points at.\n targetKind: FollowTargetKind;\n // Follow level 0..2 (0 watch, 1 propose, 2 act within the risk budget). Enforced by a CHECK constraint.\n level: number;\n // Risk budget as a percentage of fund NAV. Null means no budget is set, never zero.\n riskBudgetPctNav?: number;\n};\n\nenum FollowTargetKind {\n asset\n\n event\n}\n\n";