@adaptic/backend 0.0.1055 → 0.0.1057

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 (199) hide show
  1. package/Account.cjs +14 -0
  2. package/AccountLinkingRequest.cjs +14 -0
  3. package/AccountRiskMetrics.cjs +11 -0
  4. package/AdaConversation.cjs +14 -0
  5. package/Alert.cjs +11 -0
  6. package/Allocation.cjs +11 -0
  7. package/AlpacaAccount.cjs +36 -0
  8. package/Authenticator.cjs +14 -0
  9. package/AutoFollowRule.cjs +14 -0
  10. package/BrokerageAccount.cjs +11 -0
  11. package/Customer.cjs +14 -0
  12. package/DeskDecision.cjs +11 -0
  13. package/FeatureFlagOverride.cjs +14 -0
  14. package/Follow.cjs +14 -0
  15. package/Fund.cjs +56 -0
  16. package/FundAssignment.cjs +14 -0
  17. package/Investor.cjs +14 -0
  18. package/LinkedProvider.cjs +14 -0
  19. package/LlmConfiguration.cjs +14 -0
  20. package/Mandate.cjs +14 -0
  21. package/MandateApproval.cjs +14 -0
  22. package/MandateVersion.cjs +14 -0
  23. package/NotificationDelivery.cjs +14 -0
  24. package/NotificationPreference.cjs +14 -0
  25. package/OrgMembership.cjs +14 -0
  26. package/PolicyOverlay.cjs +64 -0
  27. package/PushSubscription.cjs +14 -0
  28. package/RiskEscalationEvent.cjs +33 -0
  29. package/Session.cjs +14 -0
  30. package/Strategy.cjs +28 -0
  31. package/StrategyHealthSnapshot.cjs +11 -0
  32. package/StrategySubscription.cjs +11 -0
  33. package/TradingPolicy.cjs +6 -0
  34. package/User.cjs +11 -0
  35. package/UserTotp.cjs +14 -0
  36. package/WaitlistEntry.cjs +14 -0
  37. package/esm/Account.mjs +14 -0
  38. package/esm/AccountLinkingRequest.mjs +14 -0
  39. package/esm/AccountRiskMetrics.mjs +11 -0
  40. package/esm/AdaConversation.mjs +14 -0
  41. package/esm/Alert.mjs +11 -0
  42. package/esm/Allocation.mjs +11 -0
  43. package/esm/AlpacaAccount.mjs +36 -0
  44. package/esm/Authenticator.mjs +14 -0
  45. package/esm/AutoFollowRule.mjs +14 -0
  46. package/esm/BrokerageAccount.mjs +11 -0
  47. package/esm/Customer.mjs +14 -0
  48. package/esm/DeskDecision.mjs +11 -0
  49. package/esm/FeatureFlagOverride.mjs +14 -0
  50. package/esm/Follow.mjs +14 -0
  51. package/esm/Fund.mjs +56 -0
  52. package/esm/FundAssignment.mjs +14 -0
  53. package/esm/Investor.mjs +14 -0
  54. package/esm/LinkedProvider.mjs +14 -0
  55. package/esm/LlmConfiguration.mjs +14 -0
  56. package/esm/Mandate.mjs +14 -0
  57. package/esm/MandateApproval.mjs +14 -0
  58. package/esm/MandateVersion.mjs +14 -0
  59. package/esm/NotificationDelivery.mjs +14 -0
  60. package/esm/NotificationPreference.mjs +14 -0
  61. package/esm/OrgMembership.mjs +14 -0
  62. package/esm/PolicyOverlay.mjs +64 -0
  63. package/esm/PushSubscription.mjs +14 -0
  64. package/esm/RiskEscalationEvent.mjs +33 -0
  65. package/esm/Session.mjs +14 -0
  66. package/esm/Strategy.mjs +28 -0
  67. package/esm/StrategyHealthSnapshot.mjs +11 -0
  68. package/esm/StrategySubscription.mjs +11 -0
  69. package/esm/TradingPolicy.mjs +6 -0
  70. package/esm/User.mjs +11 -0
  71. package/esm/UserTotp.mjs +14 -0
  72. package/esm/WaitlistEntry.mjs +14 -0
  73. package/esm/auth/membership-write-authority.d.ts +110 -0
  74. package/esm/auth/membership-write-authority.mjs +125 -0
  75. package/esm/auth/mutation-authorization.d.ts +19 -3
  76. package/esm/auth/mutation-authorization.mjs +21 -2
  77. package/esm/auth/nested-write-policy.d.ts +4 -0
  78. package/esm/auth/nested-write-policy.mjs +19 -0
  79. package/esm/auth/tenancy-scope.d.ts +2 -1
  80. package/esm/auth/tenancy-scope.mjs +2 -1
  81. package/esm/generated/typeStrings/PolicyOverlay.d.ts +1 -1
  82. package/esm/generated/typeStrings/PolicyOverlay.mjs +18 -0
  83. package/esm/generated/typeStrings/TradingPolicy.d.ts +1 -1
  84. package/esm/generated/typeStrings/TradingPolicy.mjs +18 -0
  85. package/esm/generated/typeStrings/index.d.ts +2 -2
  86. package/esm/generated/typegraphql-prisma/enhance.mjs +18 -18
  87. package/esm/generated/typegraphql-prisma/enums/TradingPolicyScalarFieldEnum.d.ts +1 -0
  88. package/esm/generated/typegraphql-prisma/enums/TradingPolicyScalarFieldEnum.mjs +1 -0
  89. package/esm/generated/typegraphql-prisma/models/TradingPolicy.d.ts +20 -0
  90. package/esm/generated/typegraphql-prisma/models/TradingPolicy.mjs +27 -0
  91. package/esm/generated/typegraphql-prisma/resolvers/crud/TradingPolicy/args/FindFirstTradingPolicyArgs.d.ts +1 -1
  92. package/esm/generated/typegraphql-prisma/resolvers/crud/TradingPolicy/args/FindFirstTradingPolicyOrThrowArgs.d.ts +1 -1
  93. package/esm/generated/typegraphql-prisma/resolvers/crud/TradingPolicy/args/FindManyTradingPolicyArgs.d.ts +1 -1
  94. package/esm/generated/typegraphql-prisma/resolvers/crud/TradingPolicy/args/GroupByTradingPolicyArgs.d.ts +1 -1
  95. package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCountOrderByAggregateInput.d.ts +1 -0
  96. package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCountOrderByAggregateInput.mjs +7 -0
  97. package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCreateInput.d.ts +1 -0
  98. package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCreateInput.mjs +7 -0
  99. package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCreateManyInput.d.ts +1 -0
  100. package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCreateManyInput.mjs +7 -0
  101. package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCreateWithoutAlpacaAccountInput.d.ts +1 -0
  102. package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCreateWithoutAlpacaAccountInput.mjs +7 -0
  103. package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCreateWithoutOverlaysInput.d.ts +1 -0
  104. package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCreateWithoutOverlaysInput.mjs +7 -0
  105. package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyOrderByWithAggregationInput.d.ts +1 -0
  106. package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyOrderByWithAggregationInput.mjs +7 -0
  107. package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyOrderByWithRelationInput.d.ts +1 -0
  108. package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyOrderByWithRelationInput.mjs +7 -0
  109. package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyScalarWhereWithAggregatesInput.d.ts +1 -0
  110. package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyScalarWhereWithAggregatesInput.mjs +7 -0
  111. package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyUpdateInput.d.ts +1 -0
  112. package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyUpdateInput.mjs +7 -0
  113. package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyUpdateManyMutationInput.d.ts +1 -0
  114. package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyUpdateManyMutationInput.mjs +7 -0
  115. package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyUpdateWithoutAlpacaAccountInput.d.ts +1 -0
  116. package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyUpdateWithoutAlpacaAccountInput.mjs +7 -0
  117. package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyUpdateWithoutOverlaysInput.d.ts +1 -0
  118. package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyUpdateWithoutOverlaysInput.mjs +7 -0
  119. package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyWhereInput.d.ts +1 -0
  120. package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyWhereInput.mjs +7 -0
  121. package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyWhereUniqueInput.d.ts +1 -0
  122. package/esm/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyWhereUniqueInput.mjs +7 -0
  123. package/esm/generated/typegraphql-prisma/resolvers/outputs/CreateManyAndReturnTradingPolicy.d.ts +1 -0
  124. package/esm/generated/typegraphql-prisma/resolvers/outputs/CreateManyAndReturnTradingPolicy.mjs +7 -0
  125. package/esm/generated/typegraphql-prisma/resolvers/outputs/TradingPolicyCountAggregate.d.ts +1 -0
  126. package/esm/generated/typegraphql-prisma/resolvers/outputs/TradingPolicyCountAggregate.mjs +7 -0
  127. package/esm/generated/typegraphql-prisma/resolvers/outputs/TradingPolicyGroupBy.d.ts +1 -0
  128. package/esm/generated/typegraphql-prisma/resolvers/outputs/TradingPolicyGroupBy.mjs +7 -0
  129. package/esm/index.d.ts +1 -0
  130. package/esm/index.mjs +2 -0
  131. package/esm/middleware/__tests__/mutation-auth-guard.harness.d.ts +2 -0
  132. package/esm/middleware/__tests__/mutation-auth-guard.harness.mjs +141 -10
  133. package/esm/middleware/mutation-account-facts.d.ts +3 -0
  134. package/esm/middleware/mutation-account-facts.mjs +2 -0
  135. package/esm/middleware/mutation-auth-guard.d.ts +4 -2
  136. package/esm/middleware/mutation-auth-guard.mjs +20 -2
  137. package/esm/middleware/mutation-membership-facts.d.ts +133 -0
  138. package/esm/middleware/mutation-membership-facts.mjs +271 -0
  139. package/esm/middleware/mutation-tenant-facts.d.ts +4 -2
  140. package/esm/middleware/mutation-tenant-facts.mjs +4 -2
  141. package/esm/middleware/trading-policy-audit.d.ts +16 -4
  142. package/esm/middleware/trading-policy-audit.mjs +40 -11
  143. package/esm/readers/index.d.ts +10 -0
  144. package/esm/readers/index.mjs +10 -0
  145. package/esm/readers/intraday-lane-prefs.d.ts +45 -0
  146. package/esm/readers/intraday-lane-prefs.mjs +71 -0
  147. package/esm/tests/trading-policy-lane-fields-roundtrip.harness.d.ts +14 -0
  148. package/esm/tests/trading-policy-lane-fields-roundtrip.harness.mjs +107 -0
  149. package/generated/typeStrings/PolicyOverlay.cjs +18 -0
  150. package/generated/typeStrings/PolicyOverlay.d.ts +1 -1
  151. package/generated/typeStrings/TradingPolicy.cjs +18 -0
  152. package/generated/typeStrings/TradingPolicy.d.ts +1 -1
  153. package/generated/typeStrings/index.d.ts +2 -2
  154. package/generated/typegraphql-prisma/enhance.cjs +18 -18
  155. package/generated/typegraphql-prisma/enums/TradingPolicyScalarFieldEnum.cjs +1 -0
  156. package/generated/typegraphql-prisma/enums/TradingPolicyScalarFieldEnum.d.ts +1 -0
  157. package/generated/typegraphql-prisma/models/TradingPolicy.cjs +7 -0
  158. package/generated/typegraphql-prisma/models/TradingPolicy.d.ts +20 -0
  159. package/generated/typegraphql-prisma/resolvers/crud/TradingPolicy/args/FindFirstTradingPolicyArgs.d.ts +1 -1
  160. package/generated/typegraphql-prisma/resolvers/crud/TradingPolicy/args/FindFirstTradingPolicyOrThrowArgs.d.ts +1 -1
  161. package/generated/typegraphql-prisma/resolvers/crud/TradingPolicy/args/FindManyTradingPolicyArgs.d.ts +1 -1
  162. package/generated/typegraphql-prisma/resolvers/crud/TradingPolicy/args/GroupByTradingPolicyArgs.d.ts +1 -1
  163. package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCountOrderByAggregateInput.cjs +6 -0
  164. package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCountOrderByAggregateInput.d.ts +1 -0
  165. package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCreateInput.cjs +6 -0
  166. package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCreateInput.d.ts +1 -0
  167. package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCreateManyInput.cjs +6 -0
  168. package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCreateManyInput.d.ts +1 -0
  169. package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCreateWithoutAlpacaAccountInput.cjs +6 -0
  170. package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCreateWithoutAlpacaAccountInput.d.ts +1 -0
  171. package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCreateWithoutOverlaysInput.cjs +6 -0
  172. package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyCreateWithoutOverlaysInput.d.ts +1 -0
  173. package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyOrderByWithAggregationInput.cjs +6 -0
  174. package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyOrderByWithAggregationInput.d.ts +1 -0
  175. package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyOrderByWithRelationInput.cjs +6 -0
  176. package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyOrderByWithRelationInput.d.ts +1 -0
  177. package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyScalarWhereWithAggregatesInput.cjs +6 -0
  178. package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyScalarWhereWithAggregatesInput.d.ts +1 -0
  179. package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyUpdateInput.cjs +6 -0
  180. package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyUpdateInput.d.ts +1 -0
  181. package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyUpdateManyMutationInput.cjs +6 -0
  182. package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyUpdateManyMutationInput.d.ts +1 -0
  183. package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyUpdateWithoutAlpacaAccountInput.cjs +6 -0
  184. package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyUpdateWithoutAlpacaAccountInput.d.ts +1 -0
  185. package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyUpdateWithoutOverlaysInput.cjs +6 -0
  186. package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyUpdateWithoutOverlaysInput.d.ts +1 -0
  187. package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyWhereInput.cjs +6 -0
  188. package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyWhereInput.d.ts +1 -0
  189. package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyWhereUniqueInput.cjs +6 -0
  190. package/generated/typegraphql-prisma/resolvers/inputs/TradingPolicyWhereUniqueInput.d.ts +1 -0
  191. package/generated/typegraphql-prisma/resolvers/outputs/CreateManyAndReturnTradingPolicy.cjs +6 -0
  192. package/generated/typegraphql-prisma/resolvers/outputs/CreateManyAndReturnTradingPolicy.d.ts +1 -0
  193. package/generated/typegraphql-prisma/resolvers/outputs/TradingPolicyCountAggregate.cjs +6 -0
  194. package/generated/typegraphql-prisma/resolvers/outputs/TradingPolicyCountAggregate.d.ts +1 -0
  195. package/generated/typegraphql-prisma/resolvers/outputs/TradingPolicyGroupBy.cjs +6 -0
  196. package/generated/typegraphql-prisma/resolvers/outputs/TradingPolicyGroupBy.d.ts +1 -0
  197. package/index.cjs +2 -0
  198. package/index.d.ts +1 -0
  199. package/package.json +1 -1
@@ -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
@@ -81,6 +89,7 @@
81
89
  *
82
90
  * @module auth/mutation-authorization
83
91
  */
92
+ import { type MembershipVerdict } from './membership-write-authority';
84
93
  import type { BackendPrincipal } from './token-verifier';
85
94
  /** Operating mode of the mutation guard. See the module doc. */
86
95
  export type MutationAuthMode = 'off' | 'shadow' | 'enforce';
@@ -173,7 +182,7 @@ export interface MutationTarget {
173
182
  */
174
183
  export declare function classifyMutationField(fieldName: string, models: ReadonlySet<string>): MutationTarget;
175
184
  /** How a `user` principal may write a model. See the module doc. */
176
- export type UserWritePolicy = 'service_only' | 'account_owned' | 'self' | 'tenant_scoped' | 'mandate_tenant' | 'authenticated' | 'resolver_authorized';
185
+ export type UserWritePolicy = 'service_only' | 'account_owned' | 'self' | 'tenant_scoped' | 'membership_authority' | 'mandate_tenant' | 'authenticated' | 'resolver_authorized';
177
186
  /** A model's user policy plus the actions a user may perform under it. */
178
187
  export interface ModelWriteRule {
179
188
  readonly policy: UserWritePolicy;
@@ -196,7 +205,7 @@ export declare const MODEL_WRITE_RULES: ReadonlyMap<string, ModelWriteRule>;
196
205
  /** The write rule for a model. */
197
206
  export declare function ruleFor(model: string): ModelWriteRule;
198
207
  /** Why a mutation was admitted or refused. A bounded metric label. */
199
- export type MutationAuthReason = 'guard_off' | 'guard_error' | 'service_principal' | 'admin_principal' | 'account_owner' | 'account_fund_entitled' | 'self' | 'tenant_scoped' | 'authenticated_user_model' | 'resolver_authorized' | 'unauthenticated' | 'service_principal_only' | 'model_not_user_writable' | 'action_not_user_writable' | 'bulk_not_user_writable' | 'not_account_owner' | 'account_unresolved' | 'not_self' | 'tenant_out_of_scope' | 'tenant_unresolved' | 'field_not_user_writable' | 'reserved_audit_source' | 'audit_actor_mismatch' | 'ledger_fund_reserved' | 'config_key_not_user_scoped' | 'nested_write_not_user_writable' | 'nested_entitlement_write';
208
+ export type MutationAuthReason = 'guard_off' | 'guard_error' | 'service_principal' | 'admin_principal' | 'account_owner' | 'account_fund_entitled' | 'self' | 'tenant_scoped' | 'authenticated_user_model' | 'resolver_authorized' | 'unauthenticated' | 'service_principal_only' | 'model_not_user_writable' | 'action_not_user_writable' | 'bulk_not_user_writable' | 'not_account_owner' | 'account_unresolved' | 'not_self' | 'tenant_out_of_scope' | 'tenant_unresolved' | 'membership_org_admin' | 'membership_fund_manager' | 'membership_first_owner' | 'membership_role_insufficient' | 'membership_owner_requires_owner' | 'membership_authority_unresolved' | 'field_not_user_writable' | 'reserved_audit_source' | 'audit_actor_mismatch' | 'ledger_fund_reserved' | 'config_key_not_user_scoped' | 'nested_write_not_user_writable' | 'nested_entitlement_write';
200
209
  /** Ownership facts the middleware resolved for an `account_owned` write. */
201
210
  export type AccountOwnership = {
202
211
  readonly kind: 'owner';
@@ -209,6 +218,11 @@ export type AccountOwnership = {
209
218
  };
210
219
  /** For a `tenant_scoped` write: whether the row or payload lies in the caller's entitlement. */
211
220
  export type TenantScope = 'in_scope' | 'out_of_scope';
221
+ /**
222
+ * For a `membership_authority` write: the verdict read from the database, or
223
+ * `unresolved` when the rows it reaches could not be identified or read.
224
+ */
225
+ export type MembershipAuthority = MembershipVerdict | 'unresolved';
212
226
  /** Everything the decision needs beyond the principal and target. */
213
227
  export interface MutationFacts {
214
228
  /** For `account_owned`: whether the caller owns every account touched. */
@@ -217,6 +231,8 @@ export interface MutationFacts {
217
231
  readonly targetsSelf?: boolean;
218
232
  /** For `tenant_scoped`: the guard's own scope check; absent = not yet resolved. */
219
233
  readonly tenantScope?: TenantScope;
234
+ /** For `membership_authority`: the caller's authority over the row; absent = not yet resolved. */
235
+ readonly membershipAuthority?: MembershipAuthority;
220
236
  /**
221
237
  * Every model the mutation's nested writes reach. A non-service principal is
222
238
  * refused when one is service-principal only, whatever its root.
@@ -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
@@ -81,6 +89,7 @@
81
89
  *
82
90
  * @module auth/mutation-authorization
83
91
  */
92
+ import { ADMITTING_MEMBERSHIP_VERDICTS, isMembershipModel, } from './membership-write-authority.mjs';
84
93
  import { DESK_MODELS, GOVERNED_MODELS } from './tenancy-scope.mjs';
85
94
  /** Environment variable selecting the global mode. */
86
95
  export const MUTATION_AUTH_MODE_ENV = 'MUTATION_AUTH_MODE';
@@ -246,7 +255,11 @@ export const MODEL_WRITE_RULES = new Map([
246
255
  ['TradingPolicy', { policy: 'account_owned', userActions: ONLY('create', 'update', 'upsert') }],
247
256
  ['AlpacaAccount', { policy: 'account_owned', userActions: ONLY('create', 'update') }],
248
257
  ['User', { policy: 'self', userActions: ONLY('update') }],
249
- ...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' }],
250
263
  ['Configuration', { policy: 'authenticated', userActions: ONLY('upsert') }],
251
264
  ['DashboardLayout', { policy: 'authenticated', userActions: ONLY('upsert') }],
252
265
  ['Mandate', { policy: 'authenticated', userActions: ONLY('create', 'update') }],
@@ -326,6 +339,12 @@ export function evaluateMutationAccess(principal, target, facts = {}) {
326
339
  }
327
340
  case 'self':
328
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
+ }
329
348
  case 'tenant_scoped':
330
349
  case 'mandate_tenant':
331
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 &&
@@ -84,7 +84,8 @@ export declare const DESK_MODELS: readonly ["Follow", "AutoFollowRule", "PushSub
84
84
  * (`src/resolvers/custom/strategy-draft-service.ts`, through
85
85
  * {@link buildWriteScopeWhere}). The model is kept out of
86
86
  * {@link GOVERNED_MODELS} on purpose: that list also gives each model a
87
- * `tenant_scoped` user-write rule (`src/auth/mutation-authorization.ts`),
87
+ * user-write rule (`tenant_scoped`, or `membership_authority` for the
88
+ * entitlement rows; `src/auth/mutation-authorization.ts`),
88
89
  * which would make the generated `Strategy` writes user-writable.
89
90
  *
90
91
  * Scoped in every mode ({@link ALWAYS_ENFORCED_MODELS}): the predicate leaves
@@ -89,7 +89,8 @@ export const DESK_MODELS = [
89
89
  * (`src/resolvers/custom/strategy-draft-service.ts`, through
90
90
  * {@link buildWriteScopeWhere}). The model is kept out of
91
91
  * {@link GOVERNED_MODELS} on purpose: that list also gives each model a
92
- * `tenant_scoped` user-write rule (`src/auth/mutation-authorization.ts`),
92
+ * user-write rule (`tenant_scoped`, or `membership_authority` for the
93
+ * entitlement rows; `src/auth/mutation-authorization.ts`),
93
94
  * which would make the generated `Strategy` writes user-writable.
94
95
  *
95
96
  * Scoped in every mode ({@link ALWAYS_ENFORCED_MODELS}): the predicate leaves
@@ -1,2 +1,2 @@
1
- export declare const PolicyOverlayTypeString = "\n// Your response should adhere to the following type definition for the \"PolicyOverlay\" 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 PolicyOverlay = {\n // Relation to TradingPolicy.\n tradingPolicy: {\n // Relation to AlpacaAccount.\n alpacaAccount: {\n // The type of Alpaca account (PAPER or LIVE).\n type: AlpacaAccountType;\n // JSON configuration settings for the Alpaca account.\n configuration?: any;\n };\n version: number;\n lastModifiedBy?: string;\n lastModifiedAt: Date;\n autonomyMode: AutonomyMode;\n realtimeTradingEnabled: boolean;\n paperTradingOnly: boolean;\n killSwitchEnabled: boolean;\n autonomyPrefs?: any;\n equitiesEnabled: boolean;\n etfsEnabled: boolean;\n cryptoEnabled: boolean;\n optionsEnabled: boolean;\n futuresEnabled: boolean;\n forexEnabled: boolean;\n shortingEnabled: boolean;\n marginEnabled: boolean;\n fractionalSharesEnabled: boolean;\n assetUniversePrefs?: any;\n maxBuyingPowerUtilPct: number;\n cashFloorPct: number;\n maxGrossExposurePct: number;\n maxNetExposurePct: number;\n maxLeverage: number;\n maxSymbolConcentrationPct: number;\n maxSectorConcentrationPct: number;\n maxOpenPositions: number;\n maxOpenOrders: number;\n // Percentage of account equity (with leverage) allocated per equities trade. Canonical replacement for legacy AlpacaAccount.tradeAllocationPct.\n perTradeEquityAllocationPct: number;\n // Percentage of the crypto allocation slice of account equity allocated per crypto trade. Canonical replacement for legacy AlpacaAccount.cryptoTradeAllocationPct.\n perTradeCryptoAllocationPct: number;\n // Opt-in for enabling the portfolio-level trailing stop service within Adaptic's Realtime Trade Engine. Canonical replacement for legacy AlpacaAccount.enablePortfolioTrailingStop.\n enablePortfolioTrailingStop: boolean;\n // Portfolio-level trailing stop percentage used by the Realtime Trade Engine, if opted into the portfolio-level trailing stop service. Canonical replacement for legacy AlpacaAccount.portfolioTrailPercent.\n portfolioTrailPercent: number;\n // Portfolio-level profit threshold percentage used by the Realtime Trade Engine, if opted into the portfolio-level trailing stop service. Canonical replacement for legacy AlpacaAccount.portfolioProfitThresholdPercent.\n portfolioProfitThresholdPercent: number;\n // Portfolio-level trailing stop percentage used by the Realtime Trade Engine for reducing the trailing stop once the profit threshold is exceeded. Canonical replacement for legacy AlpacaAccount.reducedPortfolioTrailPercent.\n reducedPortfolioTrailPercent: number;\n // Ordered ladder of portfolio trailing-stop rungs, generalising the single\nportfolioProfitThresholdPercent/reducedPortfolioTrailPercent pair above.\nShape: [{ \"thresholdPercent\": 0.35, \"trailPercent\": 0.25 }, ...] in WHOLE\nPERCENT of the session's opening equity (0.35 = 35bp), ordered ascending by\nthreshold. The engine applies min() across every rung whose threshold the\nsession high-water mark has reached, so the trail tightens monotonically and\na mis-ordered or wider rung can never loosen a stop that has already\ntightened. NULL = use the single legacy rung, which reproduces today's\nbehaviour exactly.\n portfolioTrailRungs?: any;\n // Local ET time (\"HH:MM\", 24h) at which the portfolio trailing-stop state\nre-anchors for a SECOND intraday round: open equity re-seeds from that\ntick, the high-water mark resets to zero and the trail returns to base.\nIntended for an afternoon session traded with freshly entered positions.\nNULL = single round per day, which is today's behaviour.\n portfolioAfternoonResetEt?: string;\n // Rung ladder for the afternoon round, same shape as portfolioTrailRungs.\nThe afternoon window is materially shorter than the morning, so the\nthresholds that are reachable within it differ and must be set from the\nafternoon's own distribution rather than inherited. NULL = reuse\nportfolioTrailRungs for the second round.\n portfolioAfternoonTrailRungs?: any;\n // Whether the portfolio-level daily take-profit circuit breaker is enabled for this account.\n enablePortfolioTakeProfit?: boolean;\n // Daily gain target (whole percent, e.g. 1 = 1%) since the 09:30 open that trips the take-profit breaker.\n portfolioTakeProfitThresholdPercent?: number;\n // Initial trailing stop percentage used by the Position Trailing Stop Service. Canonical replacement for legacy AlpacaAccount.defaultTrailingStopPercentage100.\n defaultTrailingStopPercentage100: number;\n // First profit threshold at which the Position Trailing Stop Service reduces the trailing stop. Canonical replacement for legacy AlpacaAccount.firstTrailReductionThreshold100.\n firstTrailReductionThreshold100: number;\n // Second profit threshold at which the Position Trailing Stop Service further reduces the trailing stop. Canonical replacement for legacy AlpacaAccount.secondTrailReductionThreshold100.\n secondTrailReductionThreshold100: number;\n // Trailing stop percentage to use when profit exceeds the first threshold. Canonical replacement for legacy AlpacaAccount.firstReducedTrailPercentage100.\n firstReducedTrailPercentage100: number;\n // Trailing stop percentage to use when profit exceeds the second threshold. Canonical replacement for legacy AlpacaAccount.secondReducedTrailPercentage100.\n secondReducedTrailPercentage100: number;\n // Minimum change in trailing stop percent to warrant an adjustment. Canonical replacement for legacy AlpacaAccount.minimumPriceChangePercent100.\n minimumPriceChangePercent100: number;\n // Wash-trade cooldown period in milliseconds for equities \u2014 minimum elapsed time between opposing-side fills on the same symbol per FINRA Rule 5210. Mirrors the 30s default already enforced for crypto. Default: 30000 (30 seconds).\n equityWashTradeCooldownMs: number;\n // Minimum intraday liquidity threshold (shares traded in last 5 min). Required for scalping. Default: 10000 (10k shares in last 5 min).\n minIntradayLiquidityShares: number;\n // Maximum spread in basis points (1/100ths of 1%) to allow entry. Scalping requires tight spreads; use 1-3 bps. Default: 5 (0.05%).\n maxEntrySpreadBps: number;\n // Minimum time between same-symbol same-side entries (ms). FINRA Rule 5210 requires 30s for opposite-side trades; this controls same-side rapid re-entry. Default: 5000 (5 seconds) for scalping; 30000 for normal trading.\n sameSideReentryDelayMs: number;\n // Volatility filter: only trade if ATR(14) >= minAtrPercentage. Scalping needs moderate volatility; too low = no edge. Default: 0.3 (0.3%).\n minAtrPercentage: number;\n // Volatility filter: only trade if ATR(14) <= maxAtrPercentage. Scalping needs moderate volatility; too high = whipsaws. Default: 2.0 (2.0%).\n maxAtrPercentage: number;\n // Order book depth requirement: minimum shares at best bid/ask to qualify for entry. Scalping needs guaranteed liquidity. Default: 5000 shares.\n minBookDepthShares: number;\n // Maximum market order slippage in basis points before flagging as anomaly. Helps detect liquidity crunches. Default: 10 bps.\n maxAnomalousSlippageBps: number;\n // Intraday session windows allowed (JSON array). Format: [{ startMinutesFromOpen, endMinutesFromOpen, active }]. Example: skip first 5 min and last 10 min of RTH.\n intradayTradingWindows?: any;\n // Hard position exit clock (minutes from entry). 0 = disabled. Forces liquidation regardless of signal. Useful for strict day-trading discipline. Default: 0.\n hardPositionExitMinutes: number;\n // Rapid-fire order-rate limit: max orders within orderWindowSeconds. Default: 10 orders per 5 seconds.\n maxOrdersPerWindow: number;\n // Window size for maxOrdersPerWindow rate limit (seconds). Default: 5.\n orderWindowSeconds: number;\n // Enforce intraday-only trading (auto-close all positions before EOD). Default: false.\n dayTradeOnly: boolean;\n riskBudgetPrefs?: any;\n signalConsumptionPrefs?: any;\n executionPrefs?: any;\n positionManagementPrefs?: any;\n portfolioConstructionPrefs?: any;\n macroOverlayEnabled: boolean;\n sectorOverlayEnabled: boolean;\n volatilityOverlayEnabled: boolean;\n liquidityStressOverlayEnabled: boolean;\n blackSwanProtectionEnabled: boolean;\n drawdownGuardianEnabled: boolean;\n correlationSpikeProtectionEnabled: boolean;\n newsEventRiskOverlayEnabled: boolean;\n exchangeHealthOverlayEnabled: boolean;\n dataQualitySentinelEnabled: boolean;\n overlayResponsePrefs?: any;\n miniModelProvider?: LlmProvider;\n normalModelProvider?: LlmProvider;\n advancedModelProvider?: LlmProvider;\n modelPrefs?: any;\n auditNotificationPrefs?: any;\n // List of policy overlays.\n overlays: PolicyOverlay[];\n escalationPolicyOverrides?: any;\n currentRiskState: AccountRiskState;\n currentRiskStateAt?: Date;\n lastRiskStateChangedBy?: string;\n };\n overlayType: OverlayType;\n source: string;\n reason: string;\n severity: OverlaySeverity;\n version: number;\n mutations: any;\n status: OverlayStatus;\n activatedAt: Date;\n expiresAt?: Date;\n deactivatedAt?: Date;\n deactivatedBy?: string;\n};\n\nenum AlpacaAccountType {\n PAPER\n\n LIVE\n}\n\nenum AutonomyMode {\n ADVISORY_ONLY\n\n EXECUTION_ON_APPROVAL\n\n SEMI_AUTONOMOUS\n\n FULLY_AUTONOMOUS\n\n EMERGENCY_SAFE_MODE\n}\n\nenum LlmProvider {\n OPENAI\n\n ANTHROPIC\n\n DEEPSEEK\n\n KIMI\n\n QWEN\n\n XAI\n\n GEMINI\n\n DEEPINFRA\n}\n\nenum AccountRiskState {\n NORMAL\n\n WARN\n\n THROTTLE\n\n PAUSED\n\n FLATTEN\n\n HALT\n}\n\nenum OverlayType {\n BLACK_SWAN\n\n VOLATILITY_REGIME\n\n SECTOR_DETERIORATION\n\n DRAWDOWN_BREACH\n\n CORRELATION_SPIKE\n\n LIQUIDITY_STRESS\n\n EXCHANGE_DEGRADATION\n\n DATA_QUALITY\n\n NEWS_EVENT_RISK\n\n RATES_BONDS_STRESS\n\n MANUAL_OVERRIDE\n\n INCIDENT_RESPONSE\n}\n\nenum OverlaySeverity {\n LOW\n\n MEDIUM\n\n HIGH\n\n CRITICAL\n}\n\nenum OverlayStatus {\n ACTIVE\n\n EXPIRED\n\n DEACTIVATED\n\n SUPERSEDED\n}\n\n";
1
+ export declare const PolicyOverlayTypeString = "\n// Your response should adhere to the following type definition for the \"PolicyOverlay\" 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 PolicyOverlay = {\n // Relation to TradingPolicy.\n tradingPolicy: {\n // Relation to AlpacaAccount.\n alpacaAccount: {\n // The type of Alpaca account (PAPER or LIVE).\n type: AlpacaAccountType;\n // JSON configuration settings for the Alpaca account.\n configuration?: any;\n };\n version: number;\n lastModifiedBy?: string;\n lastModifiedAt: Date;\n autonomyMode: AutonomyMode;\n realtimeTradingEnabled: boolean;\n paperTradingOnly: boolean;\n killSwitchEnabled: boolean;\n autonomyPrefs?: any;\n equitiesEnabled: boolean;\n etfsEnabled: boolean;\n cryptoEnabled: boolean;\n optionsEnabled: boolean;\n futuresEnabled: boolean;\n forexEnabled: boolean;\n shortingEnabled: boolean;\n marginEnabled: boolean;\n fractionalSharesEnabled: boolean;\n assetUniversePrefs?: any;\n maxBuyingPowerUtilPct: number;\n cashFloorPct: number;\n maxGrossExposurePct: number;\n maxNetExposurePct: number;\n maxLeverage: number;\n maxSymbolConcentrationPct: number;\n maxSectorConcentrationPct: number;\n maxOpenPositions: number;\n maxOpenOrders: number;\n // Percentage of account equity (with leverage) allocated per equities trade. Canonical replacement for legacy AlpacaAccount.tradeAllocationPct.\n perTradeEquityAllocationPct: number;\n // Percentage of the crypto allocation slice of account equity allocated per crypto trade. Canonical replacement for legacy AlpacaAccount.cryptoTradeAllocationPct.\n perTradeCryptoAllocationPct: number;\n // Opt-in for enabling the portfolio-level trailing stop service within Adaptic's Realtime Trade Engine. Canonical replacement for legacy AlpacaAccount.enablePortfolioTrailingStop.\n enablePortfolioTrailingStop: boolean;\n // Portfolio-level trailing stop percentage used by the Realtime Trade Engine, if opted into the portfolio-level trailing stop service. Canonical replacement for legacy AlpacaAccount.portfolioTrailPercent.\n portfolioTrailPercent: number;\n // Portfolio-level profit threshold percentage used by the Realtime Trade Engine, if opted into the portfolio-level trailing stop service. Canonical replacement for legacy AlpacaAccount.portfolioProfitThresholdPercent.\n portfolioProfitThresholdPercent: number;\n // Portfolio-level trailing stop percentage used by the Realtime Trade Engine for reducing the trailing stop once the profit threshold is exceeded. Canonical replacement for legacy AlpacaAccount.reducedPortfolioTrailPercent.\n reducedPortfolioTrailPercent: number;\n // Ordered ladder of portfolio trailing-stop rungs, generalising the single\nportfolioProfitThresholdPercent/reducedPortfolioTrailPercent pair above.\nShape: [{ \"thresholdPercent\": 0.35, \"trailPercent\": 0.25 }, ...] in WHOLE\nPERCENT of the session's opening equity (0.35 = 35bp), ordered ascending by\nthreshold. The engine applies min() across every rung whose threshold the\nsession high-water mark has reached, so the trail tightens monotonically and\na mis-ordered or wider rung can never loosen a stop that has already\ntightened. NULL = use the single legacy rung, which reproduces today's\nbehaviour exactly.\n portfolioTrailRungs?: any;\n // Local ET time (\"HH:MM\", 24h) at which the portfolio trailing-stop state\nre-anchors for a SECOND intraday round: open equity re-seeds from that\ntick, the high-water mark resets to zero and the trail returns to base.\nIntended for an afternoon session traded with freshly entered positions.\nNULL = single round per day, which is today's behaviour.\n portfolioAfternoonResetEt?: string;\n // Rung ladder for the afternoon round, same shape as portfolioTrailRungs.\nThe afternoon window is materially shorter than the morning, so the\nthresholds that are reachable within it differ and must be set from the\nafternoon's own distribution rather than inherited. NULL = reuse\nportfolioTrailRungs for the second round.\n portfolioAfternoonTrailRungs?: any;\n // Whether the portfolio-level daily take-profit circuit breaker is enabled for this account.\n enablePortfolioTakeProfit?: boolean;\n // Daily gain target (whole percent, e.g. 1 = 1%) since the 09:30 open that trips the take-profit breaker.\n portfolioTakeProfitThresholdPercent?: number;\n // Initial trailing stop percentage used by the Position Trailing Stop Service. Canonical replacement for legacy AlpacaAccount.defaultTrailingStopPercentage100.\n defaultTrailingStopPercentage100: number;\n // First profit threshold at which the Position Trailing Stop Service reduces the trailing stop. Canonical replacement for legacy AlpacaAccount.firstTrailReductionThreshold100.\n firstTrailReductionThreshold100: number;\n // Second profit threshold at which the Position Trailing Stop Service further reduces the trailing stop. Canonical replacement for legacy AlpacaAccount.secondTrailReductionThreshold100.\n secondTrailReductionThreshold100: number;\n // Trailing stop percentage to use when profit exceeds the first threshold. Canonical replacement for legacy AlpacaAccount.firstReducedTrailPercentage100.\n firstReducedTrailPercentage100: number;\n // Trailing stop percentage to use when profit exceeds the second threshold. Canonical replacement for legacy AlpacaAccount.secondReducedTrailPercentage100.\n secondReducedTrailPercentage100: number;\n // Minimum change in trailing stop percent to warrant an adjustment. Canonical replacement for legacy AlpacaAccount.minimumPriceChangePercent100.\n minimumPriceChangePercent100: number;\n // Wash-trade cooldown period in milliseconds for equities \u2014 minimum elapsed time between opposing-side fills on the same symbol per FINRA Rule 5210. Mirrors the 30s default already enforced for crypto. Default: 30000 (30 seconds).\n equityWashTradeCooldownMs: number;\n // Minimum intraday liquidity threshold (shares traded in last 5 min). Required for scalping. Default: 10000 (10k shares in last 5 min).\n minIntradayLiquidityShares: number;\n // Maximum spread in basis points (1/100ths of 1%) to allow entry. Scalping requires tight spreads; use 1-3 bps. Default: 5 (0.05%).\n maxEntrySpreadBps: number;\n // Minimum time between same-symbol same-side entries (ms). FINRA Rule 5210 requires 30s for opposite-side trades; this controls same-side rapid re-entry. Default: 5000 (5 seconds) for scalping; 30000 for normal trading.\n sameSideReentryDelayMs: number;\n // Volatility filter: only trade if ATR(14) >= minAtrPercentage. Scalping needs moderate volatility; too low = no edge. Default: 0.3 (0.3%).\n minAtrPercentage: number;\n // Volatility filter: only trade if ATR(14) <= maxAtrPercentage. Scalping needs moderate volatility; too high = whipsaws. Default: 2.0 (2.0%).\n maxAtrPercentage: number;\n // Order book depth requirement: minimum shares at best bid/ask to qualify for entry. Scalping needs guaranteed liquidity. Default: 5000 shares.\n minBookDepthShares: number;\n // Maximum market order slippage in basis points before flagging as anomaly. Helps detect liquidity crunches. Default: 10 bps.\n maxAnomalousSlippageBps: number;\n // Intraday session windows allowed (JSON array). Format: [{ startMinutesFromOpen, endMinutesFromOpen, active }]. Example: skip first 5 min and last 10 min of RTH.\n intradayTradingWindows?: any;\n // Hard position exit clock (minutes from entry). 0 = disabled. Forces liquidation regardless of signal. Useful for strict day-trading discipline. Default: 0.\n hardPositionExitMinutes: number;\n // Rapid-fire order-rate limit: max orders within orderWindowSeconds. Default: 10 orders per 5 seconds.\n maxOrdersPerWindow: number;\n // Window size for maxOrdersPerWindow rate limit (seconds). Default: 5.\n orderWindowSeconds: number;\n // Enforce intraday-only trading (auto-close all positions before EOD). Default: false.\n dayTradeOnly: boolean;\n // Per-account multi-lane intraday preferences: the single carrier of the\naccount's lane opt-in (`armed`) and its per-lane caps, including the\ntrades-per-day cap (`perLaneTradesPerDay`). It is validated at the engine's\nread boundary by the strict IntradayLanePrefs schema in @adaptic/utils\n(trading-policy/schemas). NULL, a value that fails that schema, or an\nabsent cap means the lanes are disarmed for this account. One JSON carrier\ninstead of separate arming and cap columns keeps a single arming predicate,\nso there are no two homes for one setting that could disagree.\n\nIt is left out of every generated selection set (GQL.SKIP) on purpose. A\nGraphQL server that predates the column rejects any operation that\nselects it, and the TradingPolicy selection set feeds the engine's order\nchokepoint and broker-credential reads. Keeping the field out lets a\nconsumer of this package run against a server whether or not the\nmigration has been applied. It is read through `readIntradayLanePrefs`,\nwhose failure the lane path treats as disarmed, and written through the\ngenerated create and update inputs.\n intradayLanePrefs?: any;\n riskBudgetPrefs?: any;\n signalConsumptionPrefs?: any;\n executionPrefs?: any;\n positionManagementPrefs?: any;\n portfolioConstructionPrefs?: any;\n macroOverlayEnabled: boolean;\n sectorOverlayEnabled: boolean;\n volatilityOverlayEnabled: boolean;\n liquidityStressOverlayEnabled: boolean;\n blackSwanProtectionEnabled: boolean;\n drawdownGuardianEnabled: boolean;\n correlationSpikeProtectionEnabled: boolean;\n newsEventRiskOverlayEnabled: boolean;\n exchangeHealthOverlayEnabled: boolean;\n dataQualitySentinelEnabled: boolean;\n overlayResponsePrefs?: any;\n miniModelProvider?: LlmProvider;\n normalModelProvider?: LlmProvider;\n advancedModelProvider?: LlmProvider;\n modelPrefs?: any;\n auditNotificationPrefs?: any;\n // List of policy overlays.\n overlays: PolicyOverlay[];\n escalationPolicyOverrides?: any;\n currentRiskState: AccountRiskState;\n currentRiskStateAt?: Date;\n lastRiskStateChangedBy?: string;\n };\n overlayType: OverlayType;\n source: string;\n reason: string;\n severity: OverlaySeverity;\n version: number;\n mutations: any;\n status: OverlayStatus;\n activatedAt: Date;\n expiresAt?: Date;\n deactivatedAt?: Date;\n deactivatedBy?: string;\n};\n\nenum AlpacaAccountType {\n PAPER\n\n LIVE\n}\n\nenum AutonomyMode {\n ADVISORY_ONLY\n\n EXECUTION_ON_APPROVAL\n\n SEMI_AUTONOMOUS\n\n FULLY_AUTONOMOUS\n\n EMERGENCY_SAFE_MODE\n}\n\nenum LlmProvider {\n OPENAI\n\n ANTHROPIC\n\n DEEPSEEK\n\n KIMI\n\n QWEN\n\n XAI\n\n GEMINI\n\n DEEPINFRA\n}\n\nenum AccountRiskState {\n NORMAL\n\n WARN\n\n THROTTLE\n\n PAUSED\n\n FLATTEN\n\n HALT\n}\n\nenum OverlayType {\n BLACK_SWAN\n\n VOLATILITY_REGIME\n\n SECTOR_DETERIORATION\n\n DRAWDOWN_BREACH\n\n CORRELATION_SPIKE\n\n LIQUIDITY_STRESS\n\n EXCHANGE_DEGRADATION\n\n DATA_QUALITY\n\n NEWS_EVENT_RISK\n\n RATES_BONDS_STRESS\n\n MANUAL_OVERRIDE\n\n INCIDENT_RESPONSE\n}\n\nenum OverlaySeverity {\n LOW\n\n MEDIUM\n\n HIGH\n\n CRITICAL\n}\n\nenum OverlayStatus {\n ACTIVE\n\n EXPIRED\n\n DEACTIVATED\n\n SUPERSEDED\n}\n\n";
2
2
  //# sourceMappingURL=PolicyOverlay.d.ts.map
@@ -115,6 +115,24 @@ portfolioTrailRungs for the second round.
115
115
  orderWindowSeconds: number;
116
116
  // Enforce intraday-only trading (auto-close all positions before EOD). Default: false.
117
117
  dayTradeOnly: boolean;
118
+ // Per-account multi-lane intraday preferences: the single carrier of the
119
+ account's lane opt-in (\`armed\`) and its per-lane caps, including the
120
+ trades-per-day cap (\`perLaneTradesPerDay\`). It is validated at the engine's
121
+ read boundary by the strict IntradayLanePrefs schema in @adaptic/utils
122
+ (trading-policy/schemas). NULL, a value that fails that schema, or an
123
+ absent cap means the lanes are disarmed for this account. One JSON carrier
124
+ instead of separate arming and cap columns keeps a single arming predicate,
125
+ so there are no two homes for one setting that could disagree.
126
+
127
+ It is left out of every generated selection set (GQL.SKIP) on purpose. A
128
+ GraphQL server that predates the column rejects any operation that
129
+ selects it, and the TradingPolicy selection set feeds the engine's order
130
+ chokepoint and broker-credential reads. Keeping the field out lets a
131
+ consumer of this package run against a server whether or not the
132
+ migration has been applied. It is read through \`readIntradayLanePrefs\`,
133
+ whose failure the lane path treats as disarmed, and written through the
134
+ generated create and update inputs.
135
+ intradayLanePrefs?: any;
118
136
  riskBudgetPrefs?: any;
119
137
  signalConsumptionPrefs?: any;
120
138
  executionPrefs?: any;
@@ -1,2 +1,2 @@
1
- export declare const TradingPolicyTypeString = "\n// Your response should adhere to the following type definition for the \"TradingPolicy\" 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 TradingPolicy = {\n // Relation to AlpacaAccount.\n alpacaAccount: {\n // The type of Alpaca account (PAPER or LIVE).\n type: AlpacaAccountType;\n // JSON configuration settings for the Alpaca account.\n configuration?: any;\n };\n version: number;\n lastModifiedBy?: string;\n lastModifiedAt: Date;\n autonomyMode: AutonomyMode;\n realtimeTradingEnabled: boolean;\n paperTradingOnly: boolean;\n killSwitchEnabled: boolean;\n autonomyPrefs?: any;\n equitiesEnabled: boolean;\n etfsEnabled: boolean;\n cryptoEnabled: boolean;\n optionsEnabled: boolean;\n futuresEnabled: boolean;\n forexEnabled: boolean;\n shortingEnabled: boolean;\n marginEnabled: boolean;\n fractionalSharesEnabled: boolean;\n assetUniversePrefs?: any;\n maxBuyingPowerUtilPct: number;\n cashFloorPct: number;\n maxGrossExposurePct: number;\n maxNetExposurePct: number;\n maxLeverage: number;\n maxSymbolConcentrationPct: number;\n maxSectorConcentrationPct: number;\n maxOpenPositions: number;\n maxOpenOrders: number;\n // Percentage of account equity (with leverage) allocated per equities trade. Canonical replacement for legacy AlpacaAccount.tradeAllocationPct.\n perTradeEquityAllocationPct: number;\n // Percentage of the crypto allocation slice of account equity allocated per crypto trade. Canonical replacement for legacy AlpacaAccount.cryptoTradeAllocationPct.\n perTradeCryptoAllocationPct: number;\n // Opt-in for enabling the portfolio-level trailing stop service within Adaptic's Realtime Trade Engine. Canonical replacement for legacy AlpacaAccount.enablePortfolioTrailingStop.\n enablePortfolioTrailingStop: boolean;\n // Portfolio-level trailing stop percentage used by the Realtime Trade Engine, if opted into the portfolio-level trailing stop service. Canonical replacement for legacy AlpacaAccount.portfolioTrailPercent.\n portfolioTrailPercent: number;\n // Portfolio-level profit threshold percentage used by the Realtime Trade Engine, if opted into the portfolio-level trailing stop service. Canonical replacement for legacy AlpacaAccount.portfolioProfitThresholdPercent.\n portfolioProfitThresholdPercent: number;\n // Portfolio-level trailing stop percentage used by the Realtime Trade Engine for reducing the trailing stop once the profit threshold is exceeded. Canonical replacement for legacy AlpacaAccount.reducedPortfolioTrailPercent.\n reducedPortfolioTrailPercent: number;\n // Ordered ladder of portfolio trailing-stop rungs, generalising the single\nportfolioProfitThresholdPercent/reducedPortfolioTrailPercent pair above.\nShape: [{ \"thresholdPercent\": 0.35, \"trailPercent\": 0.25 }, ...] in WHOLE\nPERCENT of the session's opening equity (0.35 = 35bp), ordered ascending by\nthreshold. The engine applies min() across every rung whose threshold the\nsession high-water mark has reached, so the trail tightens monotonically and\na mis-ordered or wider rung can never loosen a stop that has already\ntightened. NULL = use the single legacy rung, which reproduces today's\nbehaviour exactly.\n portfolioTrailRungs?: any;\n // Local ET time (\"HH:MM\", 24h) at which the portfolio trailing-stop state\nre-anchors for a SECOND intraday round: open equity re-seeds from that\ntick, the high-water mark resets to zero and the trail returns to base.\nIntended for an afternoon session traded with freshly entered positions.\nNULL = single round per day, which is today's behaviour.\n portfolioAfternoonResetEt?: string;\n // Rung ladder for the afternoon round, same shape as portfolioTrailRungs.\nThe afternoon window is materially shorter than the morning, so the\nthresholds that are reachable within it differ and must be set from the\nafternoon's own distribution rather than inherited. NULL = reuse\nportfolioTrailRungs for the second round.\n portfolioAfternoonTrailRungs?: any;\n // Whether the portfolio-level daily take-profit circuit breaker is enabled for this account.\n enablePortfolioTakeProfit?: boolean;\n // Daily gain target (whole percent, e.g. 1 = 1%) since the 09:30 open that trips the take-profit breaker.\n portfolioTakeProfitThresholdPercent?: number;\n // Initial trailing stop percentage used by the Position Trailing Stop Service. Canonical replacement for legacy AlpacaAccount.defaultTrailingStopPercentage100.\n defaultTrailingStopPercentage100: number;\n // First profit threshold at which the Position Trailing Stop Service reduces the trailing stop. Canonical replacement for legacy AlpacaAccount.firstTrailReductionThreshold100.\n firstTrailReductionThreshold100: number;\n // Second profit threshold at which the Position Trailing Stop Service further reduces the trailing stop. Canonical replacement for legacy AlpacaAccount.secondTrailReductionThreshold100.\n secondTrailReductionThreshold100: number;\n // Trailing stop percentage to use when profit exceeds the first threshold. Canonical replacement for legacy AlpacaAccount.firstReducedTrailPercentage100.\n firstReducedTrailPercentage100: number;\n // Trailing stop percentage to use when profit exceeds the second threshold. Canonical replacement for legacy AlpacaAccount.secondReducedTrailPercentage100.\n secondReducedTrailPercentage100: number;\n // Minimum change in trailing stop percent to warrant an adjustment. Canonical replacement for legacy AlpacaAccount.minimumPriceChangePercent100.\n minimumPriceChangePercent100: number;\n // Wash-trade cooldown period in milliseconds for equities \u2014 minimum elapsed time between opposing-side fills on the same symbol per FINRA Rule 5210. Mirrors the 30s default already enforced for crypto. Default: 30000 (30 seconds).\n equityWashTradeCooldownMs: number;\n // Minimum intraday liquidity threshold (shares traded in last 5 min). Required for scalping. Default: 10000 (10k shares in last 5 min).\n minIntradayLiquidityShares: number;\n // Maximum spread in basis points (1/100ths of 1%) to allow entry. Scalping requires tight spreads; use 1-3 bps. Default: 5 (0.05%).\n maxEntrySpreadBps: number;\n // Minimum time between same-symbol same-side entries (ms). FINRA Rule 5210 requires 30s for opposite-side trades; this controls same-side rapid re-entry. Default: 5000 (5 seconds) for scalping; 30000 for normal trading.\n sameSideReentryDelayMs: number;\n // Volatility filter: only trade if ATR(14) >= minAtrPercentage. Scalping needs moderate volatility; too low = no edge. Default: 0.3 (0.3%).\n minAtrPercentage: number;\n // Volatility filter: only trade if ATR(14) <= maxAtrPercentage. Scalping needs moderate volatility; too high = whipsaws. Default: 2.0 (2.0%).\n maxAtrPercentage: number;\n // Order book depth requirement: minimum shares at best bid/ask to qualify for entry. Scalping needs guaranteed liquidity. Default: 5000 shares.\n minBookDepthShares: number;\n // Maximum market order slippage in basis points before flagging as anomaly. Helps detect liquidity crunches. Default: 10 bps.\n maxAnomalousSlippageBps: number;\n // Intraday session windows allowed (JSON array). Format: [{ startMinutesFromOpen, endMinutesFromOpen, active }]. Example: skip first 5 min and last 10 min of RTH.\n intradayTradingWindows?: any;\n // Hard position exit clock (minutes from entry). 0 = disabled. Forces liquidation regardless of signal. Useful for strict day-trading discipline. Default: 0.\n hardPositionExitMinutes: number;\n // Rapid-fire order-rate limit: max orders within orderWindowSeconds. Default: 10 orders per 5 seconds.\n maxOrdersPerWindow: number;\n // Window size for maxOrdersPerWindow rate limit (seconds). Default: 5.\n orderWindowSeconds: number;\n // Enforce intraday-only trading (auto-close all positions before EOD). Default: false.\n dayTradeOnly: boolean;\n riskBudgetPrefs?: any;\n signalConsumptionPrefs?: any;\n executionPrefs?: any;\n positionManagementPrefs?: any;\n portfolioConstructionPrefs?: any;\n macroOverlayEnabled: boolean;\n sectorOverlayEnabled: boolean;\n volatilityOverlayEnabled: boolean;\n liquidityStressOverlayEnabled: boolean;\n blackSwanProtectionEnabled: boolean;\n drawdownGuardianEnabled: boolean;\n correlationSpikeProtectionEnabled: boolean;\n newsEventRiskOverlayEnabled: boolean;\n exchangeHealthOverlayEnabled: boolean;\n dataQualitySentinelEnabled: boolean;\n overlayResponsePrefs?: any;\n miniModelProvider?: LlmProvider;\n normalModelProvider?: LlmProvider;\n advancedModelProvider?: LlmProvider;\n modelPrefs?: any;\n auditNotificationPrefs?: any;\n // List of policy overlays.\n overlays: {\n overlayType: OverlayType;\n source: string;\n reason: string;\n severity: OverlaySeverity;\n version: number;\n mutations: any;\n status: OverlayStatus;\n activatedAt: Date;\n expiresAt?: Date;\n deactivatedAt?: Date;\n deactivatedBy?: string;\n }[];\n escalationPolicyOverrides?: any;\n currentRiskState: AccountRiskState;\n currentRiskStateAt?: Date;\n lastRiskStateChangedBy?: string;\n};\n\nenum AlpacaAccountType {\n PAPER\n\n LIVE\n}\n\nenum AutonomyMode {\n ADVISORY_ONLY\n\n EXECUTION_ON_APPROVAL\n\n SEMI_AUTONOMOUS\n\n FULLY_AUTONOMOUS\n\n EMERGENCY_SAFE_MODE\n}\n\nenum LlmProvider {\n OPENAI\n\n ANTHROPIC\n\n DEEPSEEK\n\n KIMI\n\n QWEN\n\n XAI\n\n GEMINI\n\n DEEPINFRA\n}\n\nenum OverlayType {\n BLACK_SWAN\n\n VOLATILITY_REGIME\n\n SECTOR_DETERIORATION\n\n DRAWDOWN_BREACH\n\n CORRELATION_SPIKE\n\n LIQUIDITY_STRESS\n\n EXCHANGE_DEGRADATION\n\n DATA_QUALITY\n\n NEWS_EVENT_RISK\n\n RATES_BONDS_STRESS\n\n MANUAL_OVERRIDE\n\n INCIDENT_RESPONSE\n}\n\nenum OverlaySeverity {\n LOW\n\n MEDIUM\n\n HIGH\n\n CRITICAL\n}\n\nenum OverlayStatus {\n ACTIVE\n\n EXPIRED\n\n DEACTIVATED\n\n SUPERSEDED\n}\n\nenum AccountRiskState {\n NORMAL\n\n WARN\n\n THROTTLE\n\n PAUSED\n\n FLATTEN\n\n HALT\n}\n\n";
1
+ export declare const TradingPolicyTypeString = "\n// Your response should adhere to the following type definition for the \"TradingPolicy\" 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 TradingPolicy = {\n // Relation to AlpacaAccount.\n alpacaAccount: {\n // The type of Alpaca account (PAPER or LIVE).\n type: AlpacaAccountType;\n // JSON configuration settings for the Alpaca account.\n configuration?: any;\n };\n version: number;\n lastModifiedBy?: string;\n lastModifiedAt: Date;\n autonomyMode: AutonomyMode;\n realtimeTradingEnabled: boolean;\n paperTradingOnly: boolean;\n killSwitchEnabled: boolean;\n autonomyPrefs?: any;\n equitiesEnabled: boolean;\n etfsEnabled: boolean;\n cryptoEnabled: boolean;\n optionsEnabled: boolean;\n futuresEnabled: boolean;\n forexEnabled: boolean;\n shortingEnabled: boolean;\n marginEnabled: boolean;\n fractionalSharesEnabled: boolean;\n assetUniversePrefs?: any;\n maxBuyingPowerUtilPct: number;\n cashFloorPct: number;\n maxGrossExposurePct: number;\n maxNetExposurePct: number;\n maxLeverage: number;\n maxSymbolConcentrationPct: number;\n maxSectorConcentrationPct: number;\n maxOpenPositions: number;\n maxOpenOrders: number;\n // Percentage of account equity (with leverage) allocated per equities trade. Canonical replacement for legacy AlpacaAccount.tradeAllocationPct.\n perTradeEquityAllocationPct: number;\n // Percentage of the crypto allocation slice of account equity allocated per crypto trade. Canonical replacement for legacy AlpacaAccount.cryptoTradeAllocationPct.\n perTradeCryptoAllocationPct: number;\n // Opt-in for enabling the portfolio-level trailing stop service within Adaptic's Realtime Trade Engine. Canonical replacement for legacy AlpacaAccount.enablePortfolioTrailingStop.\n enablePortfolioTrailingStop: boolean;\n // Portfolio-level trailing stop percentage used by the Realtime Trade Engine, if opted into the portfolio-level trailing stop service. Canonical replacement for legacy AlpacaAccount.portfolioTrailPercent.\n portfolioTrailPercent: number;\n // Portfolio-level profit threshold percentage used by the Realtime Trade Engine, if opted into the portfolio-level trailing stop service. Canonical replacement for legacy AlpacaAccount.portfolioProfitThresholdPercent.\n portfolioProfitThresholdPercent: number;\n // Portfolio-level trailing stop percentage used by the Realtime Trade Engine for reducing the trailing stop once the profit threshold is exceeded. Canonical replacement for legacy AlpacaAccount.reducedPortfolioTrailPercent.\n reducedPortfolioTrailPercent: number;\n // Ordered ladder of portfolio trailing-stop rungs, generalising the single\nportfolioProfitThresholdPercent/reducedPortfolioTrailPercent pair above.\nShape: [{ \"thresholdPercent\": 0.35, \"trailPercent\": 0.25 }, ...] in WHOLE\nPERCENT of the session's opening equity (0.35 = 35bp), ordered ascending by\nthreshold. The engine applies min() across every rung whose threshold the\nsession high-water mark has reached, so the trail tightens monotonically and\na mis-ordered or wider rung can never loosen a stop that has already\ntightened. NULL = use the single legacy rung, which reproduces today's\nbehaviour exactly.\n portfolioTrailRungs?: any;\n // Local ET time (\"HH:MM\", 24h) at which the portfolio trailing-stop state\nre-anchors for a SECOND intraday round: open equity re-seeds from that\ntick, the high-water mark resets to zero and the trail returns to base.\nIntended for an afternoon session traded with freshly entered positions.\nNULL = single round per day, which is today's behaviour.\n portfolioAfternoonResetEt?: string;\n // Rung ladder for the afternoon round, same shape as portfolioTrailRungs.\nThe afternoon window is materially shorter than the morning, so the\nthresholds that are reachable within it differ and must be set from the\nafternoon's own distribution rather than inherited. NULL = reuse\nportfolioTrailRungs for the second round.\n portfolioAfternoonTrailRungs?: any;\n // Whether the portfolio-level daily take-profit circuit breaker is enabled for this account.\n enablePortfolioTakeProfit?: boolean;\n // Daily gain target (whole percent, e.g. 1 = 1%) since the 09:30 open that trips the take-profit breaker.\n portfolioTakeProfitThresholdPercent?: number;\n // Initial trailing stop percentage used by the Position Trailing Stop Service. Canonical replacement for legacy AlpacaAccount.defaultTrailingStopPercentage100.\n defaultTrailingStopPercentage100: number;\n // First profit threshold at which the Position Trailing Stop Service reduces the trailing stop. Canonical replacement for legacy AlpacaAccount.firstTrailReductionThreshold100.\n firstTrailReductionThreshold100: number;\n // Second profit threshold at which the Position Trailing Stop Service further reduces the trailing stop. Canonical replacement for legacy AlpacaAccount.secondTrailReductionThreshold100.\n secondTrailReductionThreshold100: number;\n // Trailing stop percentage to use when profit exceeds the first threshold. Canonical replacement for legacy AlpacaAccount.firstReducedTrailPercentage100.\n firstReducedTrailPercentage100: number;\n // Trailing stop percentage to use when profit exceeds the second threshold. Canonical replacement for legacy AlpacaAccount.secondReducedTrailPercentage100.\n secondReducedTrailPercentage100: number;\n // Minimum change in trailing stop percent to warrant an adjustment. Canonical replacement for legacy AlpacaAccount.minimumPriceChangePercent100.\n minimumPriceChangePercent100: number;\n // Wash-trade cooldown period in milliseconds for equities \u2014 minimum elapsed time between opposing-side fills on the same symbol per FINRA Rule 5210. Mirrors the 30s default already enforced for crypto. Default: 30000 (30 seconds).\n equityWashTradeCooldownMs: number;\n // Minimum intraday liquidity threshold (shares traded in last 5 min). Required for scalping. Default: 10000 (10k shares in last 5 min).\n minIntradayLiquidityShares: number;\n // Maximum spread in basis points (1/100ths of 1%) to allow entry. Scalping requires tight spreads; use 1-3 bps. Default: 5 (0.05%).\n maxEntrySpreadBps: number;\n // Minimum time between same-symbol same-side entries (ms). FINRA Rule 5210 requires 30s for opposite-side trades; this controls same-side rapid re-entry. Default: 5000 (5 seconds) for scalping; 30000 for normal trading.\n sameSideReentryDelayMs: number;\n // Volatility filter: only trade if ATR(14) >= minAtrPercentage. Scalping needs moderate volatility; too low = no edge. Default: 0.3 (0.3%).\n minAtrPercentage: number;\n // Volatility filter: only trade if ATR(14) <= maxAtrPercentage. Scalping needs moderate volatility; too high = whipsaws. Default: 2.0 (2.0%).\n maxAtrPercentage: number;\n // Order book depth requirement: minimum shares at best bid/ask to qualify for entry. Scalping needs guaranteed liquidity. Default: 5000 shares.\n minBookDepthShares: number;\n // Maximum market order slippage in basis points before flagging as anomaly. Helps detect liquidity crunches. Default: 10 bps.\n maxAnomalousSlippageBps: number;\n // Intraday session windows allowed (JSON array). Format: [{ startMinutesFromOpen, endMinutesFromOpen, active }]. Example: skip first 5 min and last 10 min of RTH.\n intradayTradingWindows?: any;\n // Hard position exit clock (minutes from entry). 0 = disabled. Forces liquidation regardless of signal. Useful for strict day-trading discipline. Default: 0.\n hardPositionExitMinutes: number;\n // Rapid-fire order-rate limit: max orders within orderWindowSeconds. Default: 10 orders per 5 seconds.\n maxOrdersPerWindow: number;\n // Window size for maxOrdersPerWindow rate limit (seconds). Default: 5.\n orderWindowSeconds: number;\n // Enforce intraday-only trading (auto-close all positions before EOD). Default: false.\n dayTradeOnly: boolean;\n // Per-account multi-lane intraday preferences: the single carrier of the\naccount's lane opt-in (`armed`) and its per-lane caps, including the\ntrades-per-day cap (`perLaneTradesPerDay`). It is validated at the engine's\nread boundary by the strict IntradayLanePrefs schema in @adaptic/utils\n(trading-policy/schemas). NULL, a value that fails that schema, or an\nabsent cap means the lanes are disarmed for this account. One JSON carrier\ninstead of separate arming and cap columns keeps a single arming predicate,\nso there are no two homes for one setting that could disagree.\n\nIt is left out of every generated selection set (GQL.SKIP) on purpose. A\nGraphQL server that predates the column rejects any operation that\nselects it, and the TradingPolicy selection set feeds the engine's order\nchokepoint and broker-credential reads. Keeping the field out lets a\nconsumer of this package run against a server whether or not the\nmigration has been applied. It is read through `readIntradayLanePrefs`,\nwhose failure the lane path treats as disarmed, and written through the\ngenerated create and update inputs.\n intradayLanePrefs?: any;\n riskBudgetPrefs?: any;\n signalConsumptionPrefs?: any;\n executionPrefs?: any;\n positionManagementPrefs?: any;\n portfolioConstructionPrefs?: any;\n macroOverlayEnabled: boolean;\n sectorOverlayEnabled: boolean;\n volatilityOverlayEnabled: boolean;\n liquidityStressOverlayEnabled: boolean;\n blackSwanProtectionEnabled: boolean;\n drawdownGuardianEnabled: boolean;\n correlationSpikeProtectionEnabled: boolean;\n newsEventRiskOverlayEnabled: boolean;\n exchangeHealthOverlayEnabled: boolean;\n dataQualitySentinelEnabled: boolean;\n overlayResponsePrefs?: any;\n miniModelProvider?: LlmProvider;\n normalModelProvider?: LlmProvider;\n advancedModelProvider?: LlmProvider;\n modelPrefs?: any;\n auditNotificationPrefs?: any;\n // List of policy overlays.\n overlays: {\n overlayType: OverlayType;\n source: string;\n reason: string;\n severity: OverlaySeverity;\n version: number;\n mutations: any;\n status: OverlayStatus;\n activatedAt: Date;\n expiresAt?: Date;\n deactivatedAt?: Date;\n deactivatedBy?: string;\n }[];\n escalationPolicyOverrides?: any;\n currentRiskState: AccountRiskState;\n currentRiskStateAt?: Date;\n lastRiskStateChangedBy?: string;\n};\n\nenum AlpacaAccountType {\n PAPER\n\n LIVE\n}\n\nenum AutonomyMode {\n ADVISORY_ONLY\n\n EXECUTION_ON_APPROVAL\n\n SEMI_AUTONOMOUS\n\n FULLY_AUTONOMOUS\n\n EMERGENCY_SAFE_MODE\n}\n\nenum LlmProvider {\n OPENAI\n\n ANTHROPIC\n\n DEEPSEEK\n\n KIMI\n\n QWEN\n\n XAI\n\n GEMINI\n\n DEEPINFRA\n}\n\nenum OverlayType {\n BLACK_SWAN\n\n VOLATILITY_REGIME\n\n SECTOR_DETERIORATION\n\n DRAWDOWN_BREACH\n\n CORRELATION_SPIKE\n\n LIQUIDITY_STRESS\n\n EXCHANGE_DEGRADATION\n\n DATA_QUALITY\n\n NEWS_EVENT_RISK\n\n RATES_BONDS_STRESS\n\n MANUAL_OVERRIDE\n\n INCIDENT_RESPONSE\n}\n\nenum OverlaySeverity {\n LOW\n\n MEDIUM\n\n HIGH\n\n CRITICAL\n}\n\nenum OverlayStatus {\n ACTIVE\n\n EXPIRED\n\n DEACTIVATED\n\n SUPERSEDED\n}\n\nenum AccountRiskState {\n NORMAL\n\n WARN\n\n THROTTLE\n\n PAUSED\n\n FLATTEN\n\n HALT\n}\n\n";
2
2
  //# sourceMappingURL=TradingPolicy.d.ts.map
@@ -113,6 +113,24 @@ portfolioTrailRungs for the second round.
113
113
  orderWindowSeconds: number;
114
114
  // Enforce intraday-only trading (auto-close all positions before EOD). Default: false.
115
115
  dayTradeOnly: boolean;
116
+ // Per-account multi-lane intraday preferences: the single carrier of the
117
+ account's lane opt-in (\`armed\`) and its per-lane caps, including the
118
+ trades-per-day cap (\`perLaneTradesPerDay\`). It is validated at the engine's
119
+ read boundary by the strict IntradayLanePrefs schema in @adaptic/utils
120
+ (trading-policy/schemas). NULL, a value that fails that schema, or an
121
+ absent cap means the lanes are disarmed for this account. One JSON carrier
122
+ instead of separate arming and cap columns keeps a single arming predicate,
123
+ so there are no two homes for one setting that could disagree.
124
+
125
+ It is left out of every generated selection set (GQL.SKIP) on purpose. A
126
+ GraphQL server that predates the column rejects any operation that
127
+ selects it, and the TradingPolicy selection set feeds the engine's order
128
+ chokepoint and broker-credential reads. Keeping the field out lets a
129
+ consumer of this package run against a server whether or not the
130
+ migration has been applied. It is read through \`readIntradayLanePrefs\`,
131
+ whose failure the lane path treats as disarmed, and written through the
132
+ generated create and update inputs.
133
+ intradayLanePrefs?: any;
116
134
  riskBudgetPrefs?: any;
117
135
  signalConsumptionPrefs?: any;
118
136
  executionPrefs?: any;
@@ -56,8 +56,8 @@ export declare const typeStrings: {
56
56
  readonly waitlistEntry: "\n// Your response should adhere to the following type definition for the \"WaitlistEntry\" 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 WaitlistEntry = {\n // The email address of the person on the waitlist.\n email: string;\n // The full name of the person on the waitlist.\n fullName: string;\n // The company name of the person on the waitlist.\n companyName: string;\n // The company website URL (optional).\n companyWebsite?: string;\n // The job role/title of the person on the waitlist.\n jobRole: string;\n // Whether the person has confirmed they are a professional investor.\n professionalInvestorConfirmed: boolean;\n // The current status of the waitlist entry.\n status: WaitlistStatus;\n // The position in the waitlist queue.\n queuePosition: number;\n};\n\nenum WaitlistStatus {\n PENDING\n\n APPROVED\n\n REJECTED\n}\n\n";
57
57
  readonly inviteToken: "\n// Your response should adhere to the following type definition for the \"InviteToken\" 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 InviteToken = {\n // The unique token string used for invitation.\n token: string;\n // The email address the token was generated for.\n email: string;\n // Whether the token has been used.\n used: boolean;\n};\n\n";
58
58
  readonly auditLog: "\n// Your response should adhere to the following type definition for the \"AuditLog\" 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 AuditLog = {\n // The type of mutation operation performed.\n operationType: AuditOperationType;\n // The name of the Prisma model that was mutated.\n modelName: string;\n // JSON snapshot of the fields that were changed. For creates: all fields. For updates: changed fields with before/after values. For deletes: all fields at time of deletion.\n changedFields: any;\n // The GraphQL operation name that triggered the mutation, if available.\n operationName?: string;\n // Ledger position, assigned by the database from the `audit_logs_ledger_seq`\nsequence on insert and never by a caller (omitted from the create and\nupdate inputs). Strictly increasing across all rows, so increasing within\nevery fund, with gaps. Rows written before the ledger existed hold null:\nnumbering them would invent an order their timestamps do not establish.\nThe desk ledger id is `L-<ledgerSeq>`; a page before a cursor is\n`where: { fundId: { equals }, ledgerSeq: { lt } }`, `orderBy: [{ ledgerSeq: { sort: desc } }]`.\n@TypeGraphQL.omit(input: [\"create\", \"update\"])\n ledgerSeq?: any;\n};\n\nenum AuditOperationType {\n CREATE\n\n UPDATE\n\n DELETE\n}\n\n";
59
- readonly tradingPolicy: "\n// Your response should adhere to the following type definition for the \"TradingPolicy\" 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 TradingPolicy = {\n // Relation to AlpacaAccount.\n alpacaAccount: {\n // The type of Alpaca account (PAPER or LIVE).\n type: AlpacaAccountType;\n // JSON configuration settings for the Alpaca account.\n configuration?: any;\n };\n version: number;\n lastModifiedBy?: string;\n lastModifiedAt: Date;\n autonomyMode: AutonomyMode;\n realtimeTradingEnabled: boolean;\n paperTradingOnly: boolean;\n killSwitchEnabled: boolean;\n autonomyPrefs?: any;\n equitiesEnabled: boolean;\n etfsEnabled: boolean;\n cryptoEnabled: boolean;\n optionsEnabled: boolean;\n futuresEnabled: boolean;\n forexEnabled: boolean;\n shortingEnabled: boolean;\n marginEnabled: boolean;\n fractionalSharesEnabled: boolean;\n assetUniversePrefs?: any;\n maxBuyingPowerUtilPct: number;\n cashFloorPct: number;\n maxGrossExposurePct: number;\n maxNetExposurePct: number;\n maxLeverage: number;\n maxSymbolConcentrationPct: number;\n maxSectorConcentrationPct: number;\n maxOpenPositions: number;\n maxOpenOrders: number;\n // Percentage of account equity (with leverage) allocated per equities trade. Canonical replacement for legacy AlpacaAccount.tradeAllocationPct.\n perTradeEquityAllocationPct: number;\n // Percentage of the crypto allocation slice of account equity allocated per crypto trade. Canonical replacement for legacy AlpacaAccount.cryptoTradeAllocationPct.\n perTradeCryptoAllocationPct: number;\n // Opt-in for enabling the portfolio-level trailing stop service within Adaptic's Realtime Trade Engine. Canonical replacement for legacy AlpacaAccount.enablePortfolioTrailingStop.\n enablePortfolioTrailingStop: boolean;\n // Portfolio-level trailing stop percentage used by the Realtime Trade Engine, if opted into the portfolio-level trailing stop service. Canonical replacement for legacy AlpacaAccount.portfolioTrailPercent.\n portfolioTrailPercent: number;\n // Portfolio-level profit threshold percentage used by the Realtime Trade Engine, if opted into the portfolio-level trailing stop service. Canonical replacement for legacy AlpacaAccount.portfolioProfitThresholdPercent.\n portfolioProfitThresholdPercent: number;\n // Portfolio-level trailing stop percentage used by the Realtime Trade Engine for reducing the trailing stop once the profit threshold is exceeded. Canonical replacement for legacy AlpacaAccount.reducedPortfolioTrailPercent.\n reducedPortfolioTrailPercent: number;\n // Ordered ladder of portfolio trailing-stop rungs, generalising the single\nportfolioProfitThresholdPercent/reducedPortfolioTrailPercent pair above.\nShape: [{ \"thresholdPercent\": 0.35, \"trailPercent\": 0.25 }, ...] in WHOLE\nPERCENT of the session's opening equity (0.35 = 35bp), ordered ascending by\nthreshold. The engine applies min() across every rung whose threshold the\nsession high-water mark has reached, so the trail tightens monotonically and\na mis-ordered or wider rung can never loosen a stop that has already\ntightened. NULL = use the single legacy rung, which reproduces today's\nbehaviour exactly.\n portfolioTrailRungs?: any;\n // Local ET time (\"HH:MM\", 24h) at which the portfolio trailing-stop state\nre-anchors for a SECOND intraday round: open equity re-seeds from that\ntick, the high-water mark resets to zero and the trail returns to base.\nIntended for an afternoon session traded with freshly entered positions.\nNULL = single round per day, which is today's behaviour.\n portfolioAfternoonResetEt?: string;\n // Rung ladder for the afternoon round, same shape as portfolioTrailRungs.\nThe afternoon window is materially shorter than the morning, so the\nthresholds that are reachable within it differ and must be set from the\nafternoon's own distribution rather than inherited. NULL = reuse\nportfolioTrailRungs for the second round.\n portfolioAfternoonTrailRungs?: any;\n // Whether the portfolio-level daily take-profit circuit breaker is enabled for this account.\n enablePortfolioTakeProfit?: boolean;\n // Daily gain target (whole percent, e.g. 1 = 1%) since the 09:30 open that trips the take-profit breaker.\n portfolioTakeProfitThresholdPercent?: number;\n // Initial trailing stop percentage used by the Position Trailing Stop Service. Canonical replacement for legacy AlpacaAccount.defaultTrailingStopPercentage100.\n defaultTrailingStopPercentage100: number;\n // First profit threshold at which the Position Trailing Stop Service reduces the trailing stop. Canonical replacement for legacy AlpacaAccount.firstTrailReductionThreshold100.\n firstTrailReductionThreshold100: number;\n // Second profit threshold at which the Position Trailing Stop Service further reduces the trailing stop. Canonical replacement for legacy AlpacaAccount.secondTrailReductionThreshold100.\n secondTrailReductionThreshold100: number;\n // Trailing stop percentage to use when profit exceeds the first threshold. Canonical replacement for legacy AlpacaAccount.firstReducedTrailPercentage100.\n firstReducedTrailPercentage100: number;\n // Trailing stop percentage to use when profit exceeds the second threshold. Canonical replacement for legacy AlpacaAccount.secondReducedTrailPercentage100.\n secondReducedTrailPercentage100: number;\n // Minimum change in trailing stop percent to warrant an adjustment. Canonical replacement for legacy AlpacaAccount.minimumPriceChangePercent100.\n minimumPriceChangePercent100: number;\n // Wash-trade cooldown period in milliseconds for equities — minimum elapsed time between opposing-side fills on the same symbol per FINRA Rule 5210. Mirrors the 30s default already enforced for crypto. Default: 30000 (30 seconds).\n equityWashTradeCooldownMs: number;\n // Minimum intraday liquidity threshold (shares traded in last 5 min). Required for scalping. Default: 10000 (10k shares in last 5 min).\n minIntradayLiquidityShares: number;\n // Maximum spread in basis points (1/100ths of 1%) to allow entry. Scalping requires tight spreads; use 1-3 bps. Default: 5 (0.05%).\n maxEntrySpreadBps: number;\n // Minimum time between same-symbol same-side entries (ms). FINRA Rule 5210 requires 30s for opposite-side trades; this controls same-side rapid re-entry. Default: 5000 (5 seconds) for scalping; 30000 for normal trading.\n sameSideReentryDelayMs: number;\n // Volatility filter: only trade if ATR(14) >= minAtrPercentage. Scalping needs moderate volatility; too low = no edge. Default: 0.3 (0.3%).\n minAtrPercentage: number;\n // Volatility filter: only trade if ATR(14) <= maxAtrPercentage. Scalping needs moderate volatility; too high = whipsaws. Default: 2.0 (2.0%).\n maxAtrPercentage: number;\n // Order book depth requirement: minimum shares at best bid/ask to qualify for entry. Scalping needs guaranteed liquidity. Default: 5000 shares.\n minBookDepthShares: number;\n // Maximum market order slippage in basis points before flagging as anomaly. Helps detect liquidity crunches. Default: 10 bps.\n maxAnomalousSlippageBps: number;\n // Intraday session windows allowed (JSON array). Format: [{ startMinutesFromOpen, endMinutesFromOpen, active }]. Example: skip first 5 min and last 10 min of RTH.\n intradayTradingWindows?: any;\n // Hard position exit clock (minutes from entry). 0 = disabled. Forces liquidation regardless of signal. Useful for strict day-trading discipline. Default: 0.\n hardPositionExitMinutes: number;\n // Rapid-fire order-rate limit: max orders within orderWindowSeconds. Default: 10 orders per 5 seconds.\n maxOrdersPerWindow: number;\n // Window size for maxOrdersPerWindow rate limit (seconds). Default: 5.\n orderWindowSeconds: number;\n // Enforce intraday-only trading (auto-close all positions before EOD). Default: false.\n dayTradeOnly: boolean;\n riskBudgetPrefs?: any;\n signalConsumptionPrefs?: any;\n executionPrefs?: any;\n positionManagementPrefs?: any;\n portfolioConstructionPrefs?: any;\n macroOverlayEnabled: boolean;\n sectorOverlayEnabled: boolean;\n volatilityOverlayEnabled: boolean;\n liquidityStressOverlayEnabled: boolean;\n blackSwanProtectionEnabled: boolean;\n drawdownGuardianEnabled: boolean;\n correlationSpikeProtectionEnabled: boolean;\n newsEventRiskOverlayEnabled: boolean;\n exchangeHealthOverlayEnabled: boolean;\n dataQualitySentinelEnabled: boolean;\n overlayResponsePrefs?: any;\n miniModelProvider?: LlmProvider;\n normalModelProvider?: LlmProvider;\n advancedModelProvider?: LlmProvider;\n modelPrefs?: any;\n auditNotificationPrefs?: any;\n // List of policy overlays.\n overlays: {\n overlayType: OverlayType;\n source: string;\n reason: string;\n severity: OverlaySeverity;\n version: number;\n mutations: any;\n status: OverlayStatus;\n activatedAt: Date;\n expiresAt?: Date;\n deactivatedAt?: Date;\n deactivatedBy?: string;\n }[];\n escalationPolicyOverrides?: any;\n currentRiskState: AccountRiskState;\n currentRiskStateAt?: Date;\n lastRiskStateChangedBy?: string;\n};\n\nenum AlpacaAccountType {\n PAPER\n\n LIVE\n}\n\nenum AutonomyMode {\n ADVISORY_ONLY\n\n EXECUTION_ON_APPROVAL\n\n SEMI_AUTONOMOUS\n\n FULLY_AUTONOMOUS\n\n EMERGENCY_SAFE_MODE\n}\n\nenum LlmProvider {\n OPENAI\n\n ANTHROPIC\n\n DEEPSEEK\n\n KIMI\n\n QWEN\n\n XAI\n\n GEMINI\n\n DEEPINFRA\n}\n\nenum OverlayType {\n BLACK_SWAN\n\n VOLATILITY_REGIME\n\n SECTOR_DETERIORATION\n\n DRAWDOWN_BREACH\n\n CORRELATION_SPIKE\n\n LIQUIDITY_STRESS\n\n EXCHANGE_DEGRADATION\n\n DATA_QUALITY\n\n NEWS_EVENT_RISK\n\n RATES_BONDS_STRESS\n\n MANUAL_OVERRIDE\n\n INCIDENT_RESPONSE\n}\n\nenum OverlaySeverity {\n LOW\n\n MEDIUM\n\n HIGH\n\n CRITICAL\n}\n\nenum OverlayStatus {\n ACTIVE\n\n EXPIRED\n\n DEACTIVATED\n\n SUPERSEDED\n}\n\nenum AccountRiskState {\n NORMAL\n\n WARN\n\n THROTTLE\n\n PAUSED\n\n FLATTEN\n\n HALT\n}\n\n";
60
- readonly policyOverlay: "\n// Your response should adhere to the following type definition for the \"PolicyOverlay\" 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 PolicyOverlay = {\n // Relation to TradingPolicy.\n tradingPolicy: {\n // Relation to AlpacaAccount.\n alpacaAccount: {\n // The type of Alpaca account (PAPER or LIVE).\n type: AlpacaAccountType;\n // JSON configuration settings for the Alpaca account.\n configuration?: any;\n };\n version: number;\n lastModifiedBy?: string;\n lastModifiedAt: Date;\n autonomyMode: AutonomyMode;\n realtimeTradingEnabled: boolean;\n paperTradingOnly: boolean;\n killSwitchEnabled: boolean;\n autonomyPrefs?: any;\n equitiesEnabled: boolean;\n etfsEnabled: boolean;\n cryptoEnabled: boolean;\n optionsEnabled: boolean;\n futuresEnabled: boolean;\n forexEnabled: boolean;\n shortingEnabled: boolean;\n marginEnabled: boolean;\n fractionalSharesEnabled: boolean;\n assetUniversePrefs?: any;\n maxBuyingPowerUtilPct: number;\n cashFloorPct: number;\n maxGrossExposurePct: number;\n maxNetExposurePct: number;\n maxLeverage: number;\n maxSymbolConcentrationPct: number;\n maxSectorConcentrationPct: number;\n maxOpenPositions: number;\n maxOpenOrders: number;\n // Percentage of account equity (with leverage) allocated per equities trade. Canonical replacement for legacy AlpacaAccount.tradeAllocationPct.\n perTradeEquityAllocationPct: number;\n // Percentage of the crypto allocation slice of account equity allocated per crypto trade. Canonical replacement for legacy AlpacaAccount.cryptoTradeAllocationPct.\n perTradeCryptoAllocationPct: number;\n // Opt-in for enabling the portfolio-level trailing stop service within Adaptic's Realtime Trade Engine. Canonical replacement for legacy AlpacaAccount.enablePortfolioTrailingStop.\n enablePortfolioTrailingStop: boolean;\n // Portfolio-level trailing stop percentage used by the Realtime Trade Engine, if opted into the portfolio-level trailing stop service. Canonical replacement for legacy AlpacaAccount.portfolioTrailPercent.\n portfolioTrailPercent: number;\n // Portfolio-level profit threshold percentage used by the Realtime Trade Engine, if opted into the portfolio-level trailing stop service. Canonical replacement for legacy AlpacaAccount.portfolioProfitThresholdPercent.\n portfolioProfitThresholdPercent: number;\n // Portfolio-level trailing stop percentage used by the Realtime Trade Engine for reducing the trailing stop once the profit threshold is exceeded. Canonical replacement for legacy AlpacaAccount.reducedPortfolioTrailPercent.\n reducedPortfolioTrailPercent: number;\n // Ordered ladder of portfolio trailing-stop rungs, generalising the single\nportfolioProfitThresholdPercent/reducedPortfolioTrailPercent pair above.\nShape: [{ \"thresholdPercent\": 0.35, \"trailPercent\": 0.25 }, ...] in WHOLE\nPERCENT of the session's opening equity (0.35 = 35bp), ordered ascending by\nthreshold. The engine applies min() across every rung whose threshold the\nsession high-water mark has reached, so the trail tightens monotonically and\na mis-ordered or wider rung can never loosen a stop that has already\ntightened. NULL = use the single legacy rung, which reproduces today's\nbehaviour exactly.\n portfolioTrailRungs?: any;\n // Local ET time (\"HH:MM\", 24h) at which the portfolio trailing-stop state\nre-anchors for a SECOND intraday round: open equity re-seeds from that\ntick, the high-water mark resets to zero and the trail returns to base.\nIntended for an afternoon session traded with freshly entered positions.\nNULL = single round per day, which is today's behaviour.\n portfolioAfternoonResetEt?: string;\n // Rung ladder for the afternoon round, same shape as portfolioTrailRungs.\nThe afternoon window is materially shorter than the morning, so the\nthresholds that are reachable within it differ and must be set from the\nafternoon's own distribution rather than inherited. NULL = reuse\nportfolioTrailRungs for the second round.\n portfolioAfternoonTrailRungs?: any;\n // Whether the portfolio-level daily take-profit circuit breaker is enabled for this account.\n enablePortfolioTakeProfit?: boolean;\n // Daily gain target (whole percent, e.g. 1 = 1%) since the 09:30 open that trips the take-profit breaker.\n portfolioTakeProfitThresholdPercent?: number;\n // Initial trailing stop percentage used by the Position Trailing Stop Service. Canonical replacement for legacy AlpacaAccount.defaultTrailingStopPercentage100.\n defaultTrailingStopPercentage100: number;\n // First profit threshold at which the Position Trailing Stop Service reduces the trailing stop. Canonical replacement for legacy AlpacaAccount.firstTrailReductionThreshold100.\n firstTrailReductionThreshold100: number;\n // Second profit threshold at which the Position Trailing Stop Service further reduces the trailing stop. Canonical replacement for legacy AlpacaAccount.secondTrailReductionThreshold100.\n secondTrailReductionThreshold100: number;\n // Trailing stop percentage to use when profit exceeds the first threshold. Canonical replacement for legacy AlpacaAccount.firstReducedTrailPercentage100.\n firstReducedTrailPercentage100: number;\n // Trailing stop percentage to use when profit exceeds the second threshold. Canonical replacement for legacy AlpacaAccount.secondReducedTrailPercentage100.\n secondReducedTrailPercentage100: number;\n // Minimum change in trailing stop percent to warrant an adjustment. Canonical replacement for legacy AlpacaAccount.minimumPriceChangePercent100.\n minimumPriceChangePercent100: number;\n // Wash-trade cooldown period in milliseconds for equities — minimum elapsed time between opposing-side fills on the same symbol per FINRA Rule 5210. Mirrors the 30s default already enforced for crypto. Default: 30000 (30 seconds).\n equityWashTradeCooldownMs: number;\n // Minimum intraday liquidity threshold (shares traded in last 5 min). Required for scalping. Default: 10000 (10k shares in last 5 min).\n minIntradayLiquidityShares: number;\n // Maximum spread in basis points (1/100ths of 1%) to allow entry. Scalping requires tight spreads; use 1-3 bps. Default: 5 (0.05%).\n maxEntrySpreadBps: number;\n // Minimum time between same-symbol same-side entries (ms). FINRA Rule 5210 requires 30s for opposite-side trades; this controls same-side rapid re-entry. Default: 5000 (5 seconds) for scalping; 30000 for normal trading.\n sameSideReentryDelayMs: number;\n // Volatility filter: only trade if ATR(14) >= minAtrPercentage. Scalping needs moderate volatility; too low = no edge. Default: 0.3 (0.3%).\n minAtrPercentage: number;\n // Volatility filter: only trade if ATR(14) <= maxAtrPercentage. Scalping needs moderate volatility; too high = whipsaws. Default: 2.0 (2.0%).\n maxAtrPercentage: number;\n // Order book depth requirement: minimum shares at best bid/ask to qualify for entry. Scalping needs guaranteed liquidity. Default: 5000 shares.\n minBookDepthShares: number;\n // Maximum market order slippage in basis points before flagging as anomaly. Helps detect liquidity crunches. Default: 10 bps.\n maxAnomalousSlippageBps: number;\n // Intraday session windows allowed (JSON array). Format: [{ startMinutesFromOpen, endMinutesFromOpen, active }]. Example: skip first 5 min and last 10 min of RTH.\n intradayTradingWindows?: any;\n // Hard position exit clock (minutes from entry). 0 = disabled. Forces liquidation regardless of signal. Useful for strict day-trading discipline. Default: 0.\n hardPositionExitMinutes: number;\n // Rapid-fire order-rate limit: max orders within orderWindowSeconds. Default: 10 orders per 5 seconds.\n maxOrdersPerWindow: number;\n // Window size for maxOrdersPerWindow rate limit (seconds). Default: 5.\n orderWindowSeconds: number;\n // Enforce intraday-only trading (auto-close all positions before EOD). Default: false.\n dayTradeOnly: boolean;\n riskBudgetPrefs?: any;\n signalConsumptionPrefs?: any;\n executionPrefs?: any;\n positionManagementPrefs?: any;\n portfolioConstructionPrefs?: any;\n macroOverlayEnabled: boolean;\n sectorOverlayEnabled: boolean;\n volatilityOverlayEnabled: boolean;\n liquidityStressOverlayEnabled: boolean;\n blackSwanProtectionEnabled: boolean;\n drawdownGuardianEnabled: boolean;\n correlationSpikeProtectionEnabled: boolean;\n newsEventRiskOverlayEnabled: boolean;\n exchangeHealthOverlayEnabled: boolean;\n dataQualitySentinelEnabled: boolean;\n overlayResponsePrefs?: any;\n miniModelProvider?: LlmProvider;\n normalModelProvider?: LlmProvider;\n advancedModelProvider?: LlmProvider;\n modelPrefs?: any;\n auditNotificationPrefs?: any;\n // List of policy overlays.\n overlays: PolicyOverlay[];\n escalationPolicyOverrides?: any;\n currentRiskState: AccountRiskState;\n currentRiskStateAt?: Date;\n lastRiskStateChangedBy?: string;\n };\n overlayType: OverlayType;\n source: string;\n reason: string;\n severity: OverlaySeverity;\n version: number;\n mutations: any;\n status: OverlayStatus;\n activatedAt: Date;\n expiresAt?: Date;\n deactivatedAt?: Date;\n deactivatedBy?: string;\n};\n\nenum AlpacaAccountType {\n PAPER\n\n LIVE\n}\n\nenum AutonomyMode {\n ADVISORY_ONLY\n\n EXECUTION_ON_APPROVAL\n\n SEMI_AUTONOMOUS\n\n FULLY_AUTONOMOUS\n\n EMERGENCY_SAFE_MODE\n}\n\nenum LlmProvider {\n OPENAI\n\n ANTHROPIC\n\n DEEPSEEK\n\n KIMI\n\n QWEN\n\n XAI\n\n GEMINI\n\n DEEPINFRA\n}\n\nenum AccountRiskState {\n NORMAL\n\n WARN\n\n THROTTLE\n\n PAUSED\n\n FLATTEN\n\n HALT\n}\n\nenum OverlayType {\n BLACK_SWAN\n\n VOLATILITY_REGIME\n\n SECTOR_DETERIORATION\n\n DRAWDOWN_BREACH\n\n CORRELATION_SPIKE\n\n LIQUIDITY_STRESS\n\n EXCHANGE_DEGRADATION\n\n DATA_QUALITY\n\n NEWS_EVENT_RISK\n\n RATES_BONDS_STRESS\n\n MANUAL_OVERRIDE\n\n INCIDENT_RESPONSE\n}\n\nenum OverlaySeverity {\n LOW\n\n MEDIUM\n\n HIGH\n\n CRITICAL\n}\n\nenum OverlayStatus {\n ACTIVE\n\n EXPIRED\n\n DEACTIVATED\n\n SUPERSEDED\n}\n\n";
59
+ readonly tradingPolicy: "\n// Your response should adhere to the following type definition for the \"TradingPolicy\" 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 TradingPolicy = {\n // Relation to AlpacaAccount.\n alpacaAccount: {\n // The type of Alpaca account (PAPER or LIVE).\n type: AlpacaAccountType;\n // JSON configuration settings for the Alpaca account.\n configuration?: any;\n };\n version: number;\n lastModifiedBy?: string;\n lastModifiedAt: Date;\n autonomyMode: AutonomyMode;\n realtimeTradingEnabled: boolean;\n paperTradingOnly: boolean;\n killSwitchEnabled: boolean;\n autonomyPrefs?: any;\n equitiesEnabled: boolean;\n etfsEnabled: boolean;\n cryptoEnabled: boolean;\n optionsEnabled: boolean;\n futuresEnabled: boolean;\n forexEnabled: boolean;\n shortingEnabled: boolean;\n marginEnabled: boolean;\n fractionalSharesEnabled: boolean;\n assetUniversePrefs?: any;\n maxBuyingPowerUtilPct: number;\n cashFloorPct: number;\n maxGrossExposurePct: number;\n maxNetExposurePct: number;\n maxLeverage: number;\n maxSymbolConcentrationPct: number;\n maxSectorConcentrationPct: number;\n maxOpenPositions: number;\n maxOpenOrders: number;\n // Percentage of account equity (with leverage) allocated per equities trade. Canonical replacement for legacy AlpacaAccount.tradeAllocationPct.\n perTradeEquityAllocationPct: number;\n // Percentage of the crypto allocation slice of account equity allocated per crypto trade. Canonical replacement for legacy AlpacaAccount.cryptoTradeAllocationPct.\n perTradeCryptoAllocationPct: number;\n // Opt-in for enabling the portfolio-level trailing stop service within Adaptic's Realtime Trade Engine. Canonical replacement for legacy AlpacaAccount.enablePortfolioTrailingStop.\n enablePortfolioTrailingStop: boolean;\n // Portfolio-level trailing stop percentage used by the Realtime Trade Engine, if opted into the portfolio-level trailing stop service. Canonical replacement for legacy AlpacaAccount.portfolioTrailPercent.\n portfolioTrailPercent: number;\n // Portfolio-level profit threshold percentage used by the Realtime Trade Engine, if opted into the portfolio-level trailing stop service. Canonical replacement for legacy AlpacaAccount.portfolioProfitThresholdPercent.\n portfolioProfitThresholdPercent: number;\n // Portfolio-level trailing stop percentage used by the Realtime Trade Engine for reducing the trailing stop once the profit threshold is exceeded. Canonical replacement for legacy AlpacaAccount.reducedPortfolioTrailPercent.\n reducedPortfolioTrailPercent: number;\n // Ordered ladder of portfolio trailing-stop rungs, generalising the single\nportfolioProfitThresholdPercent/reducedPortfolioTrailPercent pair above.\nShape: [{ \"thresholdPercent\": 0.35, \"trailPercent\": 0.25 }, ...] in WHOLE\nPERCENT of the session's opening equity (0.35 = 35bp), ordered ascending by\nthreshold. The engine applies min() across every rung whose threshold the\nsession high-water mark has reached, so the trail tightens monotonically and\na mis-ordered or wider rung can never loosen a stop that has already\ntightened. NULL = use the single legacy rung, which reproduces today's\nbehaviour exactly.\n portfolioTrailRungs?: any;\n // Local ET time (\"HH:MM\", 24h) at which the portfolio trailing-stop state\nre-anchors for a SECOND intraday round: open equity re-seeds from that\ntick, the high-water mark resets to zero and the trail returns to base.\nIntended for an afternoon session traded with freshly entered positions.\nNULL = single round per day, which is today's behaviour.\n portfolioAfternoonResetEt?: string;\n // Rung ladder for the afternoon round, same shape as portfolioTrailRungs.\nThe afternoon window is materially shorter than the morning, so the\nthresholds that are reachable within it differ and must be set from the\nafternoon's own distribution rather than inherited. NULL = reuse\nportfolioTrailRungs for the second round.\n portfolioAfternoonTrailRungs?: any;\n // Whether the portfolio-level daily take-profit circuit breaker is enabled for this account.\n enablePortfolioTakeProfit?: boolean;\n // Daily gain target (whole percent, e.g. 1 = 1%) since the 09:30 open that trips the take-profit breaker.\n portfolioTakeProfitThresholdPercent?: number;\n // Initial trailing stop percentage used by the Position Trailing Stop Service. Canonical replacement for legacy AlpacaAccount.defaultTrailingStopPercentage100.\n defaultTrailingStopPercentage100: number;\n // First profit threshold at which the Position Trailing Stop Service reduces the trailing stop. Canonical replacement for legacy AlpacaAccount.firstTrailReductionThreshold100.\n firstTrailReductionThreshold100: number;\n // Second profit threshold at which the Position Trailing Stop Service further reduces the trailing stop. Canonical replacement for legacy AlpacaAccount.secondTrailReductionThreshold100.\n secondTrailReductionThreshold100: number;\n // Trailing stop percentage to use when profit exceeds the first threshold. Canonical replacement for legacy AlpacaAccount.firstReducedTrailPercentage100.\n firstReducedTrailPercentage100: number;\n // Trailing stop percentage to use when profit exceeds the second threshold. Canonical replacement for legacy AlpacaAccount.secondReducedTrailPercentage100.\n secondReducedTrailPercentage100: number;\n // Minimum change in trailing stop percent to warrant an adjustment. Canonical replacement for legacy AlpacaAccount.minimumPriceChangePercent100.\n minimumPriceChangePercent100: number;\n // Wash-trade cooldown period in milliseconds for equities — minimum elapsed time between opposing-side fills on the same symbol per FINRA Rule 5210. Mirrors the 30s default already enforced for crypto. Default: 30000 (30 seconds).\n equityWashTradeCooldownMs: number;\n // Minimum intraday liquidity threshold (shares traded in last 5 min). Required for scalping. Default: 10000 (10k shares in last 5 min).\n minIntradayLiquidityShares: number;\n // Maximum spread in basis points (1/100ths of 1%) to allow entry. Scalping requires tight spreads; use 1-3 bps. Default: 5 (0.05%).\n maxEntrySpreadBps: number;\n // Minimum time between same-symbol same-side entries (ms). FINRA Rule 5210 requires 30s for opposite-side trades; this controls same-side rapid re-entry. Default: 5000 (5 seconds) for scalping; 30000 for normal trading.\n sameSideReentryDelayMs: number;\n // Volatility filter: only trade if ATR(14) >= minAtrPercentage. Scalping needs moderate volatility; too low = no edge. Default: 0.3 (0.3%).\n minAtrPercentage: number;\n // Volatility filter: only trade if ATR(14) <= maxAtrPercentage. Scalping needs moderate volatility; too high = whipsaws. Default: 2.0 (2.0%).\n maxAtrPercentage: number;\n // Order book depth requirement: minimum shares at best bid/ask to qualify for entry. Scalping needs guaranteed liquidity. Default: 5000 shares.\n minBookDepthShares: number;\n // Maximum market order slippage in basis points before flagging as anomaly. Helps detect liquidity crunches. Default: 10 bps.\n maxAnomalousSlippageBps: number;\n // Intraday session windows allowed (JSON array). Format: [{ startMinutesFromOpen, endMinutesFromOpen, active }]. Example: skip first 5 min and last 10 min of RTH.\n intradayTradingWindows?: any;\n // Hard position exit clock (minutes from entry). 0 = disabled. Forces liquidation regardless of signal. Useful for strict day-trading discipline. Default: 0.\n hardPositionExitMinutes: number;\n // Rapid-fire order-rate limit: max orders within orderWindowSeconds. Default: 10 orders per 5 seconds.\n maxOrdersPerWindow: number;\n // Window size for maxOrdersPerWindow rate limit (seconds). Default: 5.\n orderWindowSeconds: number;\n // Enforce intraday-only trading (auto-close all positions before EOD). Default: false.\n dayTradeOnly: boolean;\n // Per-account multi-lane intraday preferences: the single carrier of the\naccount's lane opt-in (`armed`) and its per-lane caps, including the\ntrades-per-day cap (`perLaneTradesPerDay`). It is validated at the engine's\nread boundary by the strict IntradayLanePrefs schema in @adaptic/utils\n(trading-policy/schemas). NULL, a value that fails that schema, or an\nabsent cap means the lanes are disarmed for this account. One JSON carrier\ninstead of separate arming and cap columns keeps a single arming predicate,\nso there are no two homes for one setting that could disagree.\n\nIt is left out of every generated selection set (GQL.SKIP) on purpose. A\nGraphQL server that predates the column rejects any operation that\nselects it, and the TradingPolicy selection set feeds the engine's order\nchokepoint and broker-credential reads. Keeping the field out lets a\nconsumer of this package run against a server whether or not the\nmigration has been applied. It is read through `readIntradayLanePrefs`,\nwhose failure the lane path treats as disarmed, and written through the\ngenerated create and update inputs.\n intradayLanePrefs?: any;\n riskBudgetPrefs?: any;\n signalConsumptionPrefs?: any;\n executionPrefs?: any;\n positionManagementPrefs?: any;\n portfolioConstructionPrefs?: any;\n macroOverlayEnabled: boolean;\n sectorOverlayEnabled: boolean;\n volatilityOverlayEnabled: boolean;\n liquidityStressOverlayEnabled: boolean;\n blackSwanProtectionEnabled: boolean;\n drawdownGuardianEnabled: boolean;\n correlationSpikeProtectionEnabled: boolean;\n newsEventRiskOverlayEnabled: boolean;\n exchangeHealthOverlayEnabled: boolean;\n dataQualitySentinelEnabled: boolean;\n overlayResponsePrefs?: any;\n miniModelProvider?: LlmProvider;\n normalModelProvider?: LlmProvider;\n advancedModelProvider?: LlmProvider;\n modelPrefs?: any;\n auditNotificationPrefs?: any;\n // List of policy overlays.\n overlays: {\n overlayType: OverlayType;\n source: string;\n reason: string;\n severity: OverlaySeverity;\n version: number;\n mutations: any;\n status: OverlayStatus;\n activatedAt: Date;\n expiresAt?: Date;\n deactivatedAt?: Date;\n deactivatedBy?: string;\n }[];\n escalationPolicyOverrides?: any;\n currentRiskState: AccountRiskState;\n currentRiskStateAt?: Date;\n lastRiskStateChangedBy?: string;\n};\n\nenum AlpacaAccountType {\n PAPER\n\n LIVE\n}\n\nenum AutonomyMode {\n ADVISORY_ONLY\n\n EXECUTION_ON_APPROVAL\n\n SEMI_AUTONOMOUS\n\n FULLY_AUTONOMOUS\n\n EMERGENCY_SAFE_MODE\n}\n\nenum LlmProvider {\n OPENAI\n\n ANTHROPIC\n\n DEEPSEEK\n\n KIMI\n\n QWEN\n\n XAI\n\n GEMINI\n\n DEEPINFRA\n}\n\nenum OverlayType {\n BLACK_SWAN\n\n VOLATILITY_REGIME\n\n SECTOR_DETERIORATION\n\n DRAWDOWN_BREACH\n\n CORRELATION_SPIKE\n\n LIQUIDITY_STRESS\n\n EXCHANGE_DEGRADATION\n\n DATA_QUALITY\n\n NEWS_EVENT_RISK\n\n RATES_BONDS_STRESS\n\n MANUAL_OVERRIDE\n\n INCIDENT_RESPONSE\n}\n\nenum OverlaySeverity {\n LOW\n\n MEDIUM\n\n HIGH\n\n CRITICAL\n}\n\nenum OverlayStatus {\n ACTIVE\n\n EXPIRED\n\n DEACTIVATED\n\n SUPERSEDED\n}\n\nenum AccountRiskState {\n NORMAL\n\n WARN\n\n THROTTLE\n\n PAUSED\n\n FLATTEN\n\n HALT\n}\n\n";
60
+ readonly policyOverlay: "\n// Your response should adhere to the following type definition for the \"PolicyOverlay\" 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 PolicyOverlay = {\n // Relation to TradingPolicy.\n tradingPolicy: {\n // Relation to AlpacaAccount.\n alpacaAccount: {\n // The type of Alpaca account (PAPER or LIVE).\n type: AlpacaAccountType;\n // JSON configuration settings for the Alpaca account.\n configuration?: any;\n };\n version: number;\n lastModifiedBy?: string;\n lastModifiedAt: Date;\n autonomyMode: AutonomyMode;\n realtimeTradingEnabled: boolean;\n paperTradingOnly: boolean;\n killSwitchEnabled: boolean;\n autonomyPrefs?: any;\n equitiesEnabled: boolean;\n etfsEnabled: boolean;\n cryptoEnabled: boolean;\n optionsEnabled: boolean;\n futuresEnabled: boolean;\n forexEnabled: boolean;\n shortingEnabled: boolean;\n marginEnabled: boolean;\n fractionalSharesEnabled: boolean;\n assetUniversePrefs?: any;\n maxBuyingPowerUtilPct: number;\n cashFloorPct: number;\n maxGrossExposurePct: number;\n maxNetExposurePct: number;\n maxLeverage: number;\n maxSymbolConcentrationPct: number;\n maxSectorConcentrationPct: number;\n maxOpenPositions: number;\n maxOpenOrders: number;\n // Percentage of account equity (with leverage) allocated per equities trade. Canonical replacement for legacy AlpacaAccount.tradeAllocationPct.\n perTradeEquityAllocationPct: number;\n // Percentage of the crypto allocation slice of account equity allocated per crypto trade. Canonical replacement for legacy AlpacaAccount.cryptoTradeAllocationPct.\n perTradeCryptoAllocationPct: number;\n // Opt-in for enabling the portfolio-level trailing stop service within Adaptic's Realtime Trade Engine. Canonical replacement for legacy AlpacaAccount.enablePortfolioTrailingStop.\n enablePortfolioTrailingStop: boolean;\n // Portfolio-level trailing stop percentage used by the Realtime Trade Engine, if opted into the portfolio-level trailing stop service. Canonical replacement for legacy AlpacaAccount.portfolioTrailPercent.\n portfolioTrailPercent: number;\n // Portfolio-level profit threshold percentage used by the Realtime Trade Engine, if opted into the portfolio-level trailing stop service. Canonical replacement for legacy AlpacaAccount.portfolioProfitThresholdPercent.\n portfolioProfitThresholdPercent: number;\n // Portfolio-level trailing stop percentage used by the Realtime Trade Engine for reducing the trailing stop once the profit threshold is exceeded. Canonical replacement for legacy AlpacaAccount.reducedPortfolioTrailPercent.\n reducedPortfolioTrailPercent: number;\n // Ordered ladder of portfolio trailing-stop rungs, generalising the single\nportfolioProfitThresholdPercent/reducedPortfolioTrailPercent pair above.\nShape: [{ \"thresholdPercent\": 0.35, \"trailPercent\": 0.25 }, ...] in WHOLE\nPERCENT of the session's opening equity (0.35 = 35bp), ordered ascending by\nthreshold. The engine applies min() across every rung whose threshold the\nsession high-water mark has reached, so the trail tightens monotonically and\na mis-ordered or wider rung can never loosen a stop that has already\ntightened. NULL = use the single legacy rung, which reproduces today's\nbehaviour exactly.\n portfolioTrailRungs?: any;\n // Local ET time (\"HH:MM\", 24h) at which the portfolio trailing-stop state\nre-anchors for a SECOND intraday round: open equity re-seeds from that\ntick, the high-water mark resets to zero and the trail returns to base.\nIntended for an afternoon session traded with freshly entered positions.\nNULL = single round per day, which is today's behaviour.\n portfolioAfternoonResetEt?: string;\n // Rung ladder for the afternoon round, same shape as portfolioTrailRungs.\nThe afternoon window is materially shorter than the morning, so the\nthresholds that are reachable within it differ and must be set from the\nafternoon's own distribution rather than inherited. NULL = reuse\nportfolioTrailRungs for the second round.\n portfolioAfternoonTrailRungs?: any;\n // Whether the portfolio-level daily take-profit circuit breaker is enabled for this account.\n enablePortfolioTakeProfit?: boolean;\n // Daily gain target (whole percent, e.g. 1 = 1%) since the 09:30 open that trips the take-profit breaker.\n portfolioTakeProfitThresholdPercent?: number;\n // Initial trailing stop percentage used by the Position Trailing Stop Service. Canonical replacement for legacy AlpacaAccount.defaultTrailingStopPercentage100.\n defaultTrailingStopPercentage100: number;\n // First profit threshold at which the Position Trailing Stop Service reduces the trailing stop. Canonical replacement for legacy AlpacaAccount.firstTrailReductionThreshold100.\n firstTrailReductionThreshold100: number;\n // Second profit threshold at which the Position Trailing Stop Service further reduces the trailing stop. Canonical replacement for legacy AlpacaAccount.secondTrailReductionThreshold100.\n secondTrailReductionThreshold100: number;\n // Trailing stop percentage to use when profit exceeds the first threshold. Canonical replacement for legacy AlpacaAccount.firstReducedTrailPercentage100.\n firstReducedTrailPercentage100: number;\n // Trailing stop percentage to use when profit exceeds the second threshold. Canonical replacement for legacy AlpacaAccount.secondReducedTrailPercentage100.\n secondReducedTrailPercentage100: number;\n // Minimum change in trailing stop percent to warrant an adjustment. Canonical replacement for legacy AlpacaAccount.minimumPriceChangePercent100.\n minimumPriceChangePercent100: number;\n // Wash-trade cooldown period in milliseconds for equities — minimum elapsed time between opposing-side fills on the same symbol per FINRA Rule 5210. Mirrors the 30s default already enforced for crypto. Default: 30000 (30 seconds).\n equityWashTradeCooldownMs: number;\n // Minimum intraday liquidity threshold (shares traded in last 5 min). Required for scalping. Default: 10000 (10k shares in last 5 min).\n minIntradayLiquidityShares: number;\n // Maximum spread in basis points (1/100ths of 1%) to allow entry. Scalping requires tight spreads; use 1-3 bps. Default: 5 (0.05%).\n maxEntrySpreadBps: number;\n // Minimum time between same-symbol same-side entries (ms). FINRA Rule 5210 requires 30s for opposite-side trades; this controls same-side rapid re-entry. Default: 5000 (5 seconds) for scalping; 30000 for normal trading.\n sameSideReentryDelayMs: number;\n // Volatility filter: only trade if ATR(14) >= minAtrPercentage. Scalping needs moderate volatility; too low = no edge. Default: 0.3 (0.3%).\n minAtrPercentage: number;\n // Volatility filter: only trade if ATR(14) <= maxAtrPercentage. Scalping needs moderate volatility; too high = whipsaws. Default: 2.0 (2.0%).\n maxAtrPercentage: number;\n // Order book depth requirement: minimum shares at best bid/ask to qualify for entry. Scalping needs guaranteed liquidity. Default: 5000 shares.\n minBookDepthShares: number;\n // Maximum market order slippage in basis points before flagging as anomaly. Helps detect liquidity crunches. Default: 10 bps.\n maxAnomalousSlippageBps: number;\n // Intraday session windows allowed (JSON array). Format: [{ startMinutesFromOpen, endMinutesFromOpen, active }]. Example: skip first 5 min and last 10 min of RTH.\n intradayTradingWindows?: any;\n // Hard position exit clock (minutes from entry). 0 = disabled. Forces liquidation regardless of signal. Useful for strict day-trading discipline. Default: 0.\n hardPositionExitMinutes: number;\n // Rapid-fire order-rate limit: max orders within orderWindowSeconds. Default: 10 orders per 5 seconds.\n maxOrdersPerWindow: number;\n // Window size for maxOrdersPerWindow rate limit (seconds). Default: 5.\n orderWindowSeconds: number;\n // Enforce intraday-only trading (auto-close all positions before EOD). Default: false.\n dayTradeOnly: boolean;\n // Per-account multi-lane intraday preferences: the single carrier of the\naccount's lane opt-in (`armed`) and its per-lane caps, including the\ntrades-per-day cap (`perLaneTradesPerDay`). It is validated at the engine's\nread boundary by the strict IntradayLanePrefs schema in @adaptic/utils\n(trading-policy/schemas). NULL, a value that fails that schema, or an\nabsent cap means the lanes are disarmed for this account. One JSON carrier\ninstead of separate arming and cap columns keeps a single arming predicate,\nso there are no two homes for one setting that could disagree.\n\nIt is left out of every generated selection set (GQL.SKIP) on purpose. A\nGraphQL server that predates the column rejects any operation that\nselects it, and the TradingPolicy selection set feeds the engine's order\nchokepoint and broker-credential reads. Keeping the field out lets a\nconsumer of this package run against a server whether or not the\nmigration has been applied. It is read through `readIntradayLanePrefs`,\nwhose failure the lane path treats as disarmed, and written through the\ngenerated create and update inputs.\n intradayLanePrefs?: any;\n riskBudgetPrefs?: any;\n signalConsumptionPrefs?: any;\n executionPrefs?: any;\n positionManagementPrefs?: any;\n portfolioConstructionPrefs?: any;\n macroOverlayEnabled: boolean;\n sectorOverlayEnabled: boolean;\n volatilityOverlayEnabled: boolean;\n liquidityStressOverlayEnabled: boolean;\n blackSwanProtectionEnabled: boolean;\n drawdownGuardianEnabled: boolean;\n correlationSpikeProtectionEnabled: boolean;\n newsEventRiskOverlayEnabled: boolean;\n exchangeHealthOverlayEnabled: boolean;\n dataQualitySentinelEnabled: boolean;\n overlayResponsePrefs?: any;\n miniModelProvider?: LlmProvider;\n normalModelProvider?: LlmProvider;\n advancedModelProvider?: LlmProvider;\n modelPrefs?: any;\n auditNotificationPrefs?: any;\n // List of policy overlays.\n overlays: PolicyOverlay[];\n escalationPolicyOverrides?: any;\n currentRiskState: AccountRiskState;\n currentRiskStateAt?: Date;\n lastRiskStateChangedBy?: string;\n };\n overlayType: OverlayType;\n source: string;\n reason: string;\n severity: OverlaySeverity;\n version: number;\n mutations: any;\n status: OverlayStatus;\n activatedAt: Date;\n expiresAt?: Date;\n deactivatedAt?: Date;\n deactivatedBy?: string;\n};\n\nenum AlpacaAccountType {\n PAPER\n\n LIVE\n}\n\nenum AutonomyMode {\n ADVISORY_ONLY\n\n EXECUTION_ON_APPROVAL\n\n SEMI_AUTONOMOUS\n\n FULLY_AUTONOMOUS\n\n EMERGENCY_SAFE_MODE\n}\n\nenum LlmProvider {\n OPENAI\n\n ANTHROPIC\n\n DEEPSEEK\n\n KIMI\n\n QWEN\n\n XAI\n\n GEMINI\n\n DEEPINFRA\n}\n\nenum AccountRiskState {\n NORMAL\n\n WARN\n\n THROTTLE\n\n PAUSED\n\n FLATTEN\n\n HALT\n}\n\nenum OverlayType {\n BLACK_SWAN\n\n VOLATILITY_REGIME\n\n SECTOR_DETERIORATION\n\n DRAWDOWN_BREACH\n\n CORRELATION_SPIKE\n\n LIQUIDITY_STRESS\n\n EXCHANGE_DEGRADATION\n\n DATA_QUALITY\n\n NEWS_EVENT_RISK\n\n RATES_BONDS_STRESS\n\n MANUAL_OVERRIDE\n\n INCIDENT_RESPONSE\n}\n\nenum OverlaySeverity {\n LOW\n\n MEDIUM\n\n HIGH\n\n CRITICAL\n}\n\nenum OverlayStatus {\n ACTIVE\n\n EXPIRED\n\n DEACTIVATED\n\n SUPERSEDED\n}\n\n";
61
61
  readonly accountDecisionRecord: "\n// Your response should adhere to the following type definition for the \"AccountDecisionRecord\" 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 AccountDecisionRecord = {\n symbol: string;\n assetClass: string;\n signalAction: string;\n signalConfidence: number;\n decision: DecisionOutcome;\n decisionRationale?: string;\n decisionConfidence?: number;\n actionIntents?: any;\n validationResults?: any;\n executionResults?: any;\n effectivePolicySnapshot: any;\n positionsSnapshot?: any;\n openOrdersSnapshot?: any;\n exposureSnapshot?: any;\n overlaysSnapshot?: any;\n modelProvider: string;\n modelTier: string;\n routingReason?: string;\n tokenUsage?: any;\n sessionDurationMs?: number;\n gatingDurationMs?: number;\n validationDurationMs?: number;\n executionDurationMs?: number;\n status: DecisionRecordStatus;\n};\n\nenum DecisionOutcome {\n DO_NOTHING\n\n OPEN_POSITION\n\n ADD_TO_POSITION\n\n REDUCE_POSITION\n\n CLOSE_POSITION\n\n REVERSE_POSITION\n\n MODIFY_ORDERS\n\n CANCEL_ORDERS\n\n REBALANCE\n\n MUTATE_POLICY\n\n ESCALATE_FOR_APPROVAL\n\n SKIP_INELIGIBLE\n}\n\nenum DecisionRecordStatus {\n PENDING\n\n EXECUTING\n\n COMPLETED\n\n FAILED\n\n CANCELLED\n\n ESCALATED\n}\n\n";
62
62
  readonly decisionMemorySummary: "\n// Your response should adhere to the following type definition for the \"DecisionMemorySummary\" 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 DecisionMemorySummary = {\n symbol?: string;\n sector?: string;\n assetClass?: string;\n summary: string;\n keyFactors?: any;\n outcome: DecisionMemoryOutcome;\n outcomeDetails?: any;\n relevanceScore: number;\n expiresAt?: Date;\n};\n\nenum DecisionMemoryOutcome {\n PENDING\n\n PROFITABLE\n\n UNPROFITABLE\n\n STOPPED_OUT\n\n CANCELLED\n}\n\n";
63
63
  readonly equityBar: "\n// Your response should adhere to the following type definition for the \"EquityBar\" 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 EquityBar = {\n symbol: string;\n timeStamp: any;\n timespan: EquityBarTimespan;\n open: number;\n high: number;\n low: number;\n close: number;\n vol: number;\n vwap?: number;\n trades?: number;\n source: string;\n};\n\nenum EquityBarTimespan {\n second\n\n minute\n\n hour\n\n day\n}\n\n";