@adaptic/backend-legacy 0.0.1057 → 0.0.1059

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 (114) hide show
  1. package/auth/authorization-map.cjs +306 -0
  2. package/auth/authorization-map.d.ts +143 -0
  3. package/auth/cortex-auth-checker.cjs +172 -0
  4. package/auth/cortex-auth-checker.d.ts +114 -0
  5. package/auth/credential-fields.cjs +51 -0
  6. package/auth/credential-fields.d.ts +19 -0
  7. package/auth/credential-redaction.cjs +134 -0
  8. package/auth/credential-redaction.d.ts +60 -0
  9. package/auth/graphql-auth-shadow.cjs +317 -0
  10. package/auth/graphql-auth-shadow.d.ts +194 -0
  11. package/auth/membership-write-authority.cjs +131 -0
  12. package/auth/membership-write-authority.d.ts +110 -0
  13. package/auth/mutation-authorization.cjs +376 -0
  14. package/auth/mutation-authorization.d.ts +261 -0
  15. package/auth/nested-write-inspector.cjs +189 -0
  16. package/auth/nested-write-inspector.d.ts +94 -0
  17. package/auth/nested-write-policy.cjs +189 -0
  18. package/auth/nested-write-policy.d.ts +99 -0
  19. package/auth/service-token.cjs +339 -0
  20. package/auth/service-token.d.ts +106 -0
  21. package/auth/tenancy-scope.cjs +736 -0
  22. package/auth/tenancy-scope.d.ts +347 -0
  23. package/auth/token-verifier.cjs +451 -0
  24. package/auth/token-verifier.d.ts +153 -0
  25. package/auth/totp.cjs +265 -0
  26. package/auth/totp.d.ts +111 -0
  27. package/auth/user-write-content.cjs +116 -0
  28. package/auth/user-write-content.d.ts +47 -0
  29. package/auth/ws-auth-context.cjs +75 -0
  30. package/auth/ws-auth-context.d.ts +69 -0
  31. package/config/jwtConfig.cjs +57 -0
  32. package/config/jwtConfig.d.ts +16 -0
  33. package/config/metrics.cjs +356 -0
  34. package/config/metrics.d.ts +128 -0
  35. package/config/persisted-queries.cjs +122 -0
  36. package/config/persisted-queries.d.ts +40 -0
  37. package/config/server-only-models.cjs +166 -0
  38. package/config/server-only-models.d.ts +89 -0
  39. package/config/tracing.d.ts +24 -0
  40. package/esm/auth/service-token.d.ts +12 -0
  41. package/esm/auth/service-token.mjs +27 -5
  42. package/esm/config/jwtConfig.mjs +5 -1
  43. package/generated/typegraphql-prisma/enhance.cjs +3 -3
  44. package/generated/typegraphql-prisma/index.cjs +6 -6
  45. package/generated/typegraphql-prisma/resolvers/crud/args.index.cjs +95 -95
  46. package/generated/typegraphql-prisma/resolvers/outputs/index.cjs +1 -1
  47. package/generated/typegraphql-prisma/resolvers/relations/args.index.cjs +32 -32
  48. package/middleware/audit-log-write-redaction.cjs +143 -0
  49. package/middleware/audit-log-write-redaction.d.ts +82 -0
  50. package/middleware/audit-logger.cjs +378 -0
  51. package/middleware/audit-logger.d.ts +158 -0
  52. package/middleware/audit-payload-guard.cjs +107 -0
  53. package/middleware/audit-payload-guard.d.ts +85 -0
  54. package/middleware/auth.cjs +66 -0
  55. package/middleware/auth.d.ts +41 -0
  56. package/middleware/credential-field-guard.cjs +514 -0
  57. package/middleware/credential-field-guard.d.ts +173 -0
  58. package/middleware/generated-type-names.cjs +77 -0
  59. package/middleware/generated-type-names.d.ts +44 -0
  60. package/middleware/graphql-validation-plugin.cjs +310 -0
  61. package/middleware/graphql-validation-plugin.d.ts +98 -0
  62. package/middleware/guard-log-throttle.cjs +89 -0
  63. package/middleware/guard-log-throttle.d.ts +80 -0
  64. package/middleware/index.cjs +57 -0
  65. package/middleware/index.d.ts +14 -0
  66. package/middleware/input-validator.cjs +220 -0
  67. package/middleware/input-validator.d.ts +63 -0
  68. package/middleware/mandate-version-validation.cjs +131 -0
  69. package/middleware/mandate-version-validation.d.ts +41 -0
  70. package/middleware/mutation-account-facts.cjs +223 -0
  71. package/middleware/mutation-account-facts.d.ts +143 -0
  72. package/middleware/mutation-auth-guard.cjs +536 -0
  73. package/middleware/mutation-auth-guard.d.ts +100 -0
  74. package/middleware/mutation-membership-facts.cjs +276 -0
  75. package/middleware/mutation-membership-facts.d.ts +133 -0
  76. package/middleware/mutation-tenant-facts.cjs +132 -0
  77. package/middleware/mutation-tenant-facts.d.ts +81 -0
  78. package/middleware/query-complexity.cjs +182 -0
  79. package/middleware/query-complexity.d.ts +56 -0
  80. package/middleware/rate-limiter.cjs +223 -0
  81. package/middleware/rate-limiter.d.ts +93 -0
  82. package/middleware/rate-tier.cjs +111 -0
  83. package/middleware/rate-tier.d.ts +56 -0
  84. package/middleware/soft-delete.cjs +175 -0
  85. package/middleware/soft-delete.d.ts +146 -0
  86. package/middleware/tenancy-scoping.cjs +229 -0
  87. package/middleware/tenancy-scoping.d.ts +67 -0
  88. package/middleware/trading-policy-audit.cjs +353 -0
  89. package/middleware/trading-policy-audit.d.ts +184 -0
  90. package/middleware/types.cjs +17 -0
  91. package/middleware/types.d.ts +87 -0
  92. package/middleware/validation-examples.cjs +398 -0
  93. package/middleware/validation-examples.d.ts +76 -0
  94. package/package.json +10 -2
  95. package/readers/index.cjs +15 -0
  96. package/readers/index.d.ts +10 -0
  97. package/readers/intraday-lane-prefs.cjs +76 -0
  98. package/readers/intraday-lane-prefs.d.ts +45 -0
  99. package/esm/config/__tests__/server-only-surface.harness.d.ts +0 -12
  100. package/esm/config/__tests__/server-only-surface.harness.mjs +0 -41
  101. package/esm/middleware/__tests__/audit-log-write-redaction.harness.d.ts +0 -144
  102. package/esm/middleware/__tests__/audit-log-write-redaction.harness.mjs +0 -920
  103. package/esm/middleware/__tests__/credential-field-coverage.harness.d.ts +0 -55
  104. package/esm/middleware/__tests__/credential-field-coverage.harness.mjs +0 -440
  105. package/esm/middleware/__tests__/credential-field-guard.harness.d.ts +0 -34
  106. package/esm/middleware/__tests__/credential-field-guard.harness.mjs +0 -212
  107. package/esm/middleware/__tests__/mutation-auth-guard.harness.d.ts +0 -56
  108. package/esm/middleware/__tests__/mutation-auth-guard.harness.mjs +0 -575
  109. package/esm/middleware/__tests__/rate-limit-test-utils.d.ts +0 -60
  110. package/esm/middleware/__tests__/rate-limit-test-utils.mjs +0 -85
  111. package/esm/middleware/__tests__/ts-node-harness.d.ts +0 -10
  112. package/esm/middleware/__tests__/ts-node-harness.mjs +0 -71
  113. package/health.cjs +0 -274
  114. package/server.cjs +0 -607
@@ -0,0 +1,347 @@
1
+ /**
2
+ * Row-level tenancy scoping — pure domain logic (SP2-G7 / SOC2 hardening).
3
+ *
4
+ * The auto-generated typegraphql-prisma CRUD resolvers expose the org → fund →
5
+ * brokerageAccount tenancy graph (and the notification pipeline) to ANY
6
+ * authenticated principal with a caller-supplied `where` clause. App-side
7
+ * authorization (platform `fund-authorization.ts`) does not protect direct
8
+ * GraphQL calls, so a user-scoped JWT can read/mutate another org's rows.
9
+ *
10
+ * This module contains the transport-agnostic decision logic used by the
11
+ * TypeGraphQL global middleware in `src/middleware/tenancy-scoping.ts`:
12
+ *
13
+ * - {@link resolveEntitlement} — turns a `userId` into the set of org and
14
+ * fund ids the caller is entitled to, by reading their OrgMembership and
15
+ * FundAssignment rows.
16
+ * - {@link classifyGovernedField} — maps a generated resolver field name
17
+ * (e.g. `funds`, `updateOneBrokerageAccount`) to the governed model and
18
+ * operation kind, or `null` for anything not tenancy-governed.
19
+ * - {@link buildScopeWhere} — the Prisma `where` fragment restricting a read
20
+ * to entitled rows.
21
+ * - {@link injectScopeWhere} — AND-composes the scope fragment onto a
22
+ * caller-supplied `where`, preserving any top-level unique selector so
23
+ * `findUnique`/`update`/`delete` keep working (Prisma extendedWhereUnique).
24
+ * - {@link dataInScope} — whether a create/upsert payload lands in an
25
+ * entitled tenant.
26
+ * - {@link evaluateAccess} — the shadow/enforce decision for one operation.
27
+ *
28
+ * By design this module imports nothing from `graphql`, `type-graphql`, or
29
+ * `@apollo/server`; it is a pure function library the middleware wires into the
30
+ * request lifecycle. Service (`SERVER_AUTH_TOKEN`) and admin principals are
31
+ * NEVER passed here — the middleware bypasses them before this code runs — so
32
+ * the engine's server-to-server `adaptic.*` traffic is never scoped.
33
+ */
34
+ /**
35
+ * Operating mode for row-level tenancy scoping, mirroring the engine WS
36
+ * channel-auth shadow→enforce rollout:
37
+ *
38
+ * - `off` — no-op; the middleware returns immediately.
39
+ * - `shadow` — execute the query UNCHANGED, but log + count every access
40
+ * that `enforce` WOULD restrict or deny. Used to prove the
41
+ * engine service path and every legitimate platform query is
42
+ * never caught before flipping to `enforce`.
43
+ * - `enforce` — inject the scoping predicate on reads and deny cross-tenant
44
+ * create/upsert with a clear `FORBIDDEN` GraphQL error.
45
+ */
46
+ export type TenancyScopingMode = 'off' | 'shadow' | 'enforce';
47
+ /** Default mode when `TENANCY_SCOPING_MODE` is unset or unrecognised. */
48
+ export declare const DEFAULT_TENANCY_SCOPING_MODE: TenancyScopingMode;
49
+ /**
50
+ * Resolve the current scoping mode from `TENANCY_SCOPING_MODE`. Read fresh on
51
+ * each call (cheap env read) so the mode can be flipped operationally without a
52
+ * process restart — the same pattern the engine uses to graduate a shadowed
53
+ * guard to enforcement. Unknown values fall back to the safe default (shadow),
54
+ * which never changes query behaviour.
55
+ *
56
+ * @param env - Environment source (defaults to `process.env`); injectable for tests.
57
+ * @returns The resolved {@link TenancyScopingMode}.
58
+ */
59
+ export declare function getTenancyScopingMode(env?: Record<string, string | undefined>): TenancyScopingMode;
60
+ /**
61
+ * The trading-desk models. They are tenancy-governed like the models above
62
+ * them, and additionally ALWAYS enforced (see {@link ALWAYS_ENFORCED_MODELS}).
63
+ *
64
+ * Ownership: Follow, PushSubscription and UserTotp belong to a user
65
+ * (`userId`); AdaConversation belongs to its author and is readable by the
66
+ * fund's members only when `sharedWithOrg`; AdaMessage inherits its
67
+ * conversation's scope; DeskDecision and AutoFollowRule belong to a fund;
68
+ * FeatureFlagOverride belongs to a user or an organization.
69
+ */
70
+ export declare const DESK_MODELS: readonly ["Follow", "AutoFollowRule", "PushSubscription", "AdaConversation", "AdaMessage", "UserTotp", "DeskDecision", "FeatureFlagOverride"];
71
+ /**
72
+ * Models scoped on READ only: the middleware classifies their read fields and
73
+ * none of their writes.
74
+ *
75
+ * `Strategy` holds two kinds of row. A SYSTEM strategy (`kind` NULL) is the
76
+ * platform's catalog and stays readable as it always was. An authored
77
+ * strategy (`kind` set, written by the strategy builder) belongs to one fund
78
+ * (`fundId`) and is readable only by that fund's members, so a draft never
79
+ * reaches a person outside the fund it was written in.
80
+ *
81
+ * Writes are decided elsewhere, and more narrowly: every generated `Strategy`
82
+ * mutation is `service_only` for a user in the mutation guard, and the draft
83
+ * mutations hold the author and the fund themselves
84
+ * (`src/resolvers/custom/strategy-draft-service.ts`, through
85
+ * {@link buildWriteScopeWhere}). The model is kept out of
86
+ * {@link GOVERNED_MODELS} on purpose: that list also gives each model a
87
+ * user-write rule (`tenant_scoped`, or `membership_authority` for the
88
+ * entitlement rows; `src/auth/mutation-authorization.ts`),
89
+ * which would make the generated `Strategy` writes user-writable.
90
+ *
91
+ * Scoped in every mode ({@link ALWAYS_ENFORCED_MODELS}): the predicate leaves
92
+ * every SYSTEM row exactly as readable as before, so a staged rollout has no
93
+ * existing reader to protect, and holding it in shadow would serve every
94
+ * fund's drafts to any signed-in user.
95
+ */
96
+ export declare const READ_SCOPED_MODELS: readonly ["Strategy"];
97
+ /** A model scoped on read only (see {@link READ_SCOPED_MODELS}). */
98
+ export type ReadScopedModel = (typeof READ_SCOPED_MODELS)[number];
99
+ /**
100
+ * The tenancy, notification and desk models subject to row-level scoping.
101
+ * Everything else (AlpacaAccount, Trade, User, …) is intentionally out of
102
+ * scope for this change — see the SP2-G7 gap and the follow-ups in the
103
+ * middleware docs.
104
+ */
105
+ export declare const GOVERNED_MODELS: readonly ["Organization", "OrgMembership", "Fund", "FundAssignment", "BrokerageAccount", "NotificationEvent", "NotificationDelivery", "NotificationPreference", "Follow", "AutoFollowRule", "PushSubscription", "AdaConversation", "AdaMessage", "UserTotp", "DeskDecision", "FeatureFlagOverride"];
106
+ /**
107
+ * Governed models whose scoping is enforced in every mode, `off` included,
108
+ * and which refuse an unauthenticated caller outright.
109
+ *
110
+ * `TENANCY_SCOPING_MODE` stages the rollout for models that had live traffic
111
+ * before scoping existed: shadow proves no legitimate caller is caught before
112
+ * enforcement can break one, and `off` rolls back to the unscoped behaviour.
113
+ * The desk models were born after the guard and have never been served
114
+ * unscoped, so there is no caller for shadow to protect and no unscoped
115
+ * behaviour for `off` to restore. Holding them in shadow would only serve a
116
+ * user's conversations, push endpoints and second-factor state to whoever
117
+ * asks while the shadow series accumulated.
118
+ */
119
+ export declare const ALWAYS_ENFORCED_MODELS: ReadonlySet<string>;
120
+ /** Whether a governed model is scoped in every mode (see {@link ALWAYS_ENFORCED_MODELS}). */
121
+ export declare function isAlwaysEnforced(model: string): boolean;
122
+ /** A model name subject to row-level tenancy scoping on reads and writes. */
123
+ export type GovernedModel = (typeof GOVERNED_MODELS)[number];
124
+ /** Any model the tenancy middleware scopes: governed, or read-scoped only. */
125
+ export type ScopedModel = GovernedModel | ReadScopedModel;
126
+ /**
127
+ * Operation family for a governed resolver field:
128
+ *
129
+ * - `whereScope` — carries a `where` argument; enforce AND-injects the scope
130
+ * fragment (reads narrow to entitled rows; update/delete of a cross-tenant
131
+ * row raise Prisma `P2025`). Covers the find, aggregate, groupBy, update,
132
+ * and delete operation families.
133
+ * - `createScope` — carries a `data` argument; enforce denies when the target
134
+ * tenant is not entitled. Covers createOne/createMany/createManyAndReturn.
135
+ * - `upsertScope` — carries both `where` and create `data`; enforce injects
136
+ * the where scope AND verifies the create payload.
137
+ */
138
+ export type GovernedOpKind = 'whereScope' | 'createScope' | 'upsertScope';
139
+ /** Resolution of a resolver field name onto its governed model + op kind. */
140
+ export interface GovernedField {
141
+ readonly model: ScopedModel;
142
+ readonly opKind: GovernedOpKind;
143
+ }
144
+ /**
145
+ * Classify a root Query/Mutation field name as a governed tenancy operation.
146
+ *
147
+ * @param fieldName - The GraphQL field name (`info.fieldName`).
148
+ * @returns The {@link GovernedField}, or `null` when the field is not governed.
149
+ */
150
+ export declare function classifyGovernedField(fieldName: string): GovernedField | null;
151
+ /**
152
+ * The set of tenants a user-scoped caller is entitled to. `orgIds` come from
153
+ * their OrgMembership rows; `fundIds` are the union of funds owned by those
154
+ * orgs and funds they are directly assigned to via FundAssignment.
155
+ */
156
+ export interface Entitlement {
157
+ readonly userId: string;
158
+ readonly orgIds: readonly string[];
159
+ readonly fundIds: readonly string[];
160
+ }
161
+ /**
162
+ * Minimal structural subset of the Prisma client used to resolve entitlement.
163
+ * Declared narrowly so the resolver can be unit-tested with a fake and so this
164
+ * pure module never depends on the generated `PrismaClient` type.
165
+ */
166
+ export interface EntitlementPrismaClient {
167
+ orgMembership: {
168
+ findMany(args: {
169
+ where: {
170
+ userId: string;
171
+ };
172
+ select: {
173
+ organizationId: true;
174
+ };
175
+ }): Promise<Array<{
176
+ organizationId: string;
177
+ }>>;
178
+ };
179
+ fund: {
180
+ findMany(args: {
181
+ where: {
182
+ organizationId: {
183
+ in: string[];
184
+ };
185
+ };
186
+ select: {
187
+ id: true;
188
+ };
189
+ }): Promise<Array<{
190
+ id: string;
191
+ }>>;
192
+ };
193
+ fundAssignment: {
194
+ findMany(args: {
195
+ where: {
196
+ userId: string;
197
+ };
198
+ select: {
199
+ fundId: true;
200
+ };
201
+ }): Promise<Array<{
202
+ fundId: string;
203
+ }>>;
204
+ };
205
+ }
206
+ /**
207
+ * Resolve the {@link Entitlement} for a user id by reading their org
208
+ * memberships, the funds owned by those orgs, and any directly-assigned funds.
209
+ *
210
+ * A user with no memberships resolves to empty id sets, which makes every
211
+ * governed read return nothing under enforcement — the correct fail-closed
212
+ * posture for a caller entitled to no tenants.
213
+ *
214
+ * @param prisma - Prisma client (or a structural subset).
215
+ * @param userId - The caller's user id (JWT `sub`).
216
+ * @returns The resolved entitlement.
217
+ */
218
+ export declare function resolveEntitlement(prisma: EntitlementPrismaClient, userId: string): Promise<Entitlement>;
219
+ /** A Prisma `where`-fragment object. */
220
+ export type WhereFragment = Record<string, unknown>;
221
+ /**
222
+ * Build the Prisma `where` fragment that restricts reads/writes of a governed
223
+ * model to the caller's entitled rows:
224
+ *
225
+ * - Organization → `id ∈ orgIds`
226
+ * - OrgMembership → `organizationId ∈ orgIds`
227
+ * - Fund → `organizationId ∈ orgIds` OR `id ∈ fundIds` (covers assigned funds
228
+ * in an org the user is not a member of)
229
+ * - FundAssignment / BrokerageAccount → `fundId ∈ fundIds`
230
+ * - NotificationEvent → `orgId ∈ orgIds` OR `fundId ∈ fundIds` OR
231
+ * `actorUserId == userId`
232
+ * - NotificationDelivery → `recipientUserId == userId`
233
+ * - NotificationPreference → `userId == userId`
234
+ *
235
+ * @param model - The governed model.
236
+ * @param ent - The caller's entitlement.
237
+ * @returns A Prisma `where` fragment.
238
+ */
239
+ export declare function buildScopeWhere(model: ScopedModel, ent: Entitlement): WhereFragment;
240
+ /**
241
+ * The scope a WRITE (update, upsert, delete) must stay inside. Identical to
242
+ * {@link buildScopeWhere} except for Ada conversations: a conversation shared
243
+ * with the organization is readable by its members but writable only by its
244
+ * author, and the same holds for its messages. A Strategy is written by a
245
+ * user only as their own authored draft, in a fund they belong to; a SYSTEM
246
+ * strategy is never in a user's write scope.
247
+ *
248
+ * @param model - The governed model.
249
+ * @param ent - The caller's entitlement.
250
+ * @returns A Prisma `where` fragment.
251
+ */
252
+ export declare function buildWriteScopeWhere(model: ScopedModel, ent: Entitlement): WhereFragment;
253
+ /**
254
+ * The scope an UNAUTHENTICATED read of a model is held to, or `null` when the
255
+ * model has none (it is then passed or refused by the middleware's mode
256
+ * rules). A caller with no identity belongs to no fund, so it reads only the
257
+ * SYSTEM strategies and never an authored one.
258
+ *
259
+ * @param model - The scoped model.
260
+ * @returns A Prisma `where` fragment, or `null`.
261
+ */
262
+ export declare function anonymousScopeWhere(model: ScopedModel): WhereFragment | null;
263
+ /**
264
+ * AND-compose a scope fragment onto a caller-supplied `where`, preserving any
265
+ * top-level fields (including a unique selector such as `id`/`slug`) so
266
+ * `findUnique`/`update`/`delete` remain valid under Prisma extendedWhereUnique.
267
+ * The scope is appended to the `AND` array rather than overwriting caller keys.
268
+ *
269
+ * @param where - The caller-supplied `where` (may be `undefined`).
270
+ * @param scope - The scope fragment from {@link buildScopeWhere}.
271
+ * @returns A new `where` object with the scope ANDed in.
272
+ */
273
+ export declare function injectScopeWhere(where: WhereFragment | undefined, scope: WhereFragment): WhereFragment;
274
+ /** Minimal delegate for reading a parent row under a scope fragment. */
275
+ export interface ParentScopeReader {
276
+ findFirst(args: {
277
+ where: WhereFragment;
278
+ select: {
279
+ id: true;
280
+ };
281
+ }): Promise<{
282
+ id: string;
283
+ } | null>;
284
+ }
285
+ /** The parent delegates {@link parentScopedCreateInScope} reads. */
286
+ export interface ParentScopePrismaClient {
287
+ adaConversation: ParentScopeReader;
288
+ }
289
+ /** Whether a model's create is scoped by a parent row (see {@link parentScopedCreateInScope}). */
290
+ export declare function hasCreateParent(model: ScopedModel): boolean;
291
+ /**
292
+ * Whether a create payload (or every element of a createMany payload) names a
293
+ * parent row the caller may WRITE. Used for models whose tenant is their
294
+ * parent's, which {@link dataInScope} cannot decide from the payload alone.
295
+ *
296
+ * @param prisma - A client exposing the parent delegates.
297
+ * @param model - The governed model being created.
298
+ * @param data - The create payload (object or array).
299
+ * @param ent - The caller's entitlement.
300
+ * @returns `false` for a model with no parent rule, a payload naming no
301
+ * parent, or a parent outside the caller's write scope.
302
+ */
303
+ export declare function parentScopedCreateInScope(prisma: ParentScopePrismaClient, model: ScopedModel, data: unknown, ent: Entitlement): Promise<boolean>;
304
+ /**
305
+ * Whether a create/createMany/upsert payload is entirely within the caller's
306
+ * entitlement. Accepts a single object or an array (createMany), requiring
307
+ * every element to be in scope.
308
+ *
309
+ * @param model - The governed model.
310
+ * @param data - The create payload (object or array).
311
+ * @param ent - The caller's entitlement.
312
+ * @returns `true` when every element lands in an entitled tenant.
313
+ */
314
+ export declare function dataInScope(model: ScopedModel, data: unknown, ent: Entitlement): boolean;
315
+ /**
316
+ * The scoping decision for one governed operation:
317
+ *
318
+ * - `allow` — the caller-supplied filter already constrains the query
319
+ * within their entitlement (read), or the create payload is in scope;
320
+ * enforcement is a no-op and shadow mode logs nothing.
321
+ * - `restrict` — a read whose caller-supplied `where` does not prove it is
322
+ * within entitlement; enforce narrows results (shadow logs this).
323
+ * - `deny` — a create/upsert whose payload targets a non-entitled tenant;
324
+ * enforce raises `FORBIDDEN` (shadow logs this).
325
+ */
326
+ export type ScopeDecision = 'allow' | 'restrict' | 'deny';
327
+ /** The outcome of {@link evaluateAccess}. */
328
+ export interface AccessAssessment {
329
+ readonly decision: ScopeDecision;
330
+ /** Short machine-readable reason, for structured logs. */
331
+ readonly reason: string;
332
+ }
333
+ /**
334
+ * Evaluate the scoping decision for one governed operation. Pure: it inspects
335
+ * the args but does not mutate them and performs no I/O.
336
+ *
337
+ * @param field - The classified governed field.
338
+ * @param args - The resolver args (`where` and/or `data`).
339
+ * @param ent - The caller's entitlement.
340
+ * @returns The {@link AccessAssessment}.
341
+ */
342
+ export declare function evaluateAccess(field: GovernedField, args: {
343
+ where?: unknown;
344
+ data?: unknown;
345
+ create?: unknown;
346
+ }, ent: Entitlement): AccessAssessment;
347
+ //# sourceMappingURL=tenancy-scope.d.ts.map