@vxil/feature-configs 0.7.0 → 0.7.1
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.
- package/dist/apiState.d.ts +2 -2
- package/dist/apiState.js +2 -2
- package/dist/hooks.d.ts +2 -2
- package/dist/hooks.js +1 -1
- package/dist/index.d.ts +16 -16
- package/dist/index.js +167 -176
- package/dist/readmodels.d.ts +1 -1
- package/dist/readmodels.js +1 -1
- package/package.json +1 -1
- package/src/apiState.ts +5 -7
- package/src/hooks.ts +2 -2
- package/src/index.ts +178 -187
- package/src/readmodels.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Per-feature TypeBox config schemas + the 15-leaf cap analyzer.
|
|
2
|
-
// Location note
|
|
3
|
-
//
|
|
4
|
-
//
|
|
2
|
+
// Location note: each schema belongs to its feature, but the config-write
|
|
3
|
+
// path must validate writes against the same schema, so schemas live in this
|
|
4
|
+
// shared package
|
|
5
5
|
// and feature Workers import from here — one definition, two consumers.
|
|
6
6
|
import { FormatRegistry, OptionalKind, Type } from '@sinclair/typebox';
|
|
7
7
|
import { Value } from '@sinclair/typebox/value';
|
|
@@ -14,7 +14,7 @@ export * from './hooks.js';
|
|
|
14
14
|
// Re-export the cms-rel read-model/cdc config gates (the pure-mirror split:
|
|
15
15
|
// grammar validated here at config-write; field existence at runtime).
|
|
16
16
|
export * from './readmodels.js';
|
|
17
|
-
// Re-export the DECLARED API STATE planner
|
|
17
|
+
// Re-export the DECLARED API STATE planner: pure
|
|
18
18
|
// declared-vs-live reconciliation, shared by the control-plane apply path and
|
|
19
19
|
// the CLI (`vxil plan/diff/push`), so the two push paths can never diverge.
|
|
20
20
|
export * from './apiState.js';
|
|
@@ -26,7 +26,7 @@ export * from './canonicalJson.js';
|
|
|
26
26
|
if (!FormatRegistry.Has('email')) {
|
|
27
27
|
FormatRegistry.Set('email', (v) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(v));
|
|
28
28
|
}
|
|
29
|
-
// ── RESERVED (vxil-COGS) CREDIT TYPES — single source of truth
|
|
29
|
+
// ── RESERVED (vxil-COGS) CREDIT TYPES — single source of truth ─────────────────
|
|
30
30
|
// `fn_cpu_ms` funds vxil's OWN function-compute cost-of-goods (the
|
|
31
31
|
// functions "recover-by-price" meter). It must NEVER be grantable or consumable
|
|
32
32
|
// by a tenant's own `payments:write` key, NOR mapped-in via ledger config — a
|
|
@@ -36,7 +36,7 @@ if (!FormatRegistry.Has('email')) {
|
|
|
36
36
|
// config-write gate AND payments-v1 import) so the runtime choke point and the
|
|
37
37
|
// config-write refusal share ONE list. payments-v1/core.ts re-exports these.
|
|
38
38
|
export const RESERVED_CREDIT_TYPES = new Set(['fn_cpu_ms']);
|
|
39
|
-
/**
|
|
39
|
+
/** A function binding's `retry.maxAttempts` ceiling, and the
|
|
40
40
|
* binding kinds that may carry `retry` — the platform-delivered event lanes
|
|
41
41
|
* (an http invoke returns its own status; a cron tick's retry would overlap
|
|
42
42
|
* the next tick). Read by the schema, the deploy clamp and the CLI. */
|
|
@@ -47,7 +47,7 @@ export const FN_RETRY_BINDING_KINDS = new Set(['queue', 'webhook', 'cmsHook', 'a
|
|
|
47
47
|
export function isReservedCreditType(creditType) {
|
|
48
48
|
return RESERVED_CREDIT_TYPES.has(creditType);
|
|
49
49
|
}
|
|
50
|
-
// ── notifications template catalog (
|
|
50
|
+
// ── notifications template catalog (per-locale overrides) ────────────────────
|
|
51
51
|
// The SHIPPED template ids and the placeholders each body may interpolate. The
|
|
52
52
|
// renderer itself lives in workers/notifications-v1/src/templates.ts (templates
|
|
53
53
|
// are code, not rows); this table is the CONFIG-TIME half so a `vxil push` that
|
|
@@ -72,7 +72,7 @@ export const NOTIFICATION_TEMPLATE_PLACEHOLDERS = {
|
|
|
72
72
|
export const NOTIFICATION_TEMPLATE_SLOT_PLACEHOLDERS = {
|
|
73
73
|
transactional: ['cta'],
|
|
74
74
|
};
|
|
75
|
-
/** Per-override caps
|
|
75
|
+
/** Per-override caps. Bodies are emails, not documents. */
|
|
76
76
|
export const NOTIF_OVERRIDE_SUBJECT_MAX = 500;
|
|
77
77
|
export const NOTIF_OVERRIDE_BODY_MAX = 20_000;
|
|
78
78
|
/** Whole-map caps: keeps one manifest (and the KV row every send reads) small. */
|
|
@@ -84,7 +84,7 @@ const NOTIF_PLACEHOLDER_RE = /\{\{\s*([a-zA-Z0-9_]+)\s*\}\}/g;
|
|
|
84
84
|
/** Same permissive BCP-47-ish shape the worker's auto-locale resolver accepts. */
|
|
85
85
|
const NOTIF_LOCALE_RE = /^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8}){0,3}$/;
|
|
86
86
|
/**
|
|
87
|
-
*
|
|
87
|
+
* Validate `templates.overrides` at CONFIG-WRITE time. Returns [] when the
|
|
88
88
|
* bag is absent or clean. Every rule fails LOUD rather than shipping something
|
|
89
89
|
* that silently renders wrong in a customer's inbox:
|
|
90
90
|
* • overrides present with `allowOverride:false` → rejected (never inert);
|
|
@@ -173,12 +173,12 @@ export const NotificationsConfigSchema = Type.Object({
|
|
|
173
173
|
// need no email account, so the mock path is zero-config. A cross-field
|
|
174
174
|
// check in validateFeatureConfig requires it only when provider === 'resend'.
|
|
175
175
|
resendApiKeyRef: Type.Optional(Type.String()),
|
|
176
|
-
// Optional per-tenant Resend/Svix ENDPOINT secret ref (
|
|
177
|
-
//
|
|
176
|
+
// Optional per-tenant Resend/Svix ENDPOINT secret ref (a pointer into the
|
|
177
|
+
// tenant's encrypted secret store — same store as resendApiKeyRef).
|
|
178
178
|
// When set, inbound Resend webhooks are verified with THIS tenant's secret
|
|
179
179
|
// instead of the platform-wide PROVIDER_WEBHOOK_SECRET, binding the signature
|
|
180
180
|
// to the tenant so a signed event for tenant A can never validate at tenant
|
|
181
|
-
// B's webhook URL (
|
|
181
|
+
// B's webhook URL (mirrors payments revenuecat.webhookSecretRef).
|
|
182
182
|
webhookSecretRef: Type.Optional(Type.String()),
|
|
183
183
|
// 'mock' exists for staging/e2e (deterministic provider); 'resend' is MVP;
|
|
184
184
|
// 'ses' (2026-09-19) is the second real provider — Amazon SES v2, BYO IAM
|
|
@@ -190,7 +190,7 @@ export const NotificationsConfigSchema = Type.Object({
|
|
|
190
190
|
// cap rule — funded by folding `rateLimit` into an Optional bag below);
|
|
191
191
|
// NO `default: {}` so an absent bag stays absent (the auth `security`
|
|
192
192
|
// precedent). Both refs are `secret:<name>` POINTERS into
|
|
193
|
-
//
|
|
193
|
+
// the tenant's encrypted secret store (feature='notifications') —
|
|
194
194
|
// exactly how resendApiKeyRef resolves; the region is plain config (not a
|
|
195
195
|
// secret) and is pattern-pinned to the AWS region grammar so a typo fails
|
|
196
196
|
// at `vxil push` instead of as a DNS error on the first send. Required
|
|
@@ -212,7 +212,7 @@ export const NotificationsConfigSchema = Type.Object({
|
|
|
212
212
|
// nested objects carry `default: {}` so Value.Default can materialize them
|
|
213
213
|
// and then recurse into the leaf defaults.
|
|
214
214
|
// `retry` became an OPTIONAL bag (2 leaves → 1, countLeaves counts an
|
|
215
|
-
// Optional object as ONE) to fund `broadcast` below (
|
|
215
|
+
// Optional object as ONE) to fund `broadcast` below (2026-07-18).
|
|
216
216
|
// It KEEPS `default: {}`, which Value.Default still materializes — so every
|
|
217
217
|
// persisted manifest carries retry.{maxAttempts,backoff} exactly as before
|
|
218
218
|
// (zero behavioral delta); only the TS type is now optional (workers read
|
|
@@ -224,7 +224,7 @@ export const NotificationsConfigSchema = Type.Object({
|
|
|
224
224
|
}),
|
|
225
225
|
}, { default: {} })),
|
|
226
226
|
suppression: Type.Object({ softBounceThreshold: Type.Integer({ default: 3 }) }, { default: {} }),
|
|
227
|
-
// `rateLimit` became an OPTIONAL bag (2 leaves → 1, the
|
|
227
|
+
// `rateLimit` became an OPTIONAL bag (2 leaves → 1, the `retry` trick)
|
|
228
228
|
// on 2026-09-19 to fund the `ses` credential bag above. It KEEPS
|
|
229
229
|
// `default: {}`, so Value.Default still materializes
|
|
230
230
|
// rateLimit.{perDay,perTenantSec} into every persisted manifest exactly as
|
|
@@ -234,15 +234,15 @@ export const NotificationsConfigSchema = Type.Object({
|
|
|
234
234
|
perDay: Type.Integer({ default: 100000 }),
|
|
235
235
|
perTenantSec: Type.Integer({ default: 50 }),
|
|
236
236
|
}, { default: {} })),
|
|
237
|
-
// `templates` became an OPTIONAL bag (1 leaf, the same
|
|
238
|
-
// uses) to fund the
|
|
237
|
+
// `templates` became an OPTIONAL bag (1 leaf, the same trick `retry`
|
|
238
|
+
// uses) to fund the per-locale `overrides` map WITHOUT moving the count:
|
|
239
239
|
// countLeaves scores an Optional object as ONE. `default: {}` is KEPT, so
|
|
240
240
|
// Value.Default still materializes `templates.allowOverride` into every
|
|
241
241
|
// persisted manifest exactly as before — zero behavioral delta; only the TS
|
|
242
242
|
// type is optional (workers read via core.ts `templatesOf()`).
|
|
243
243
|
templates: Type.Optional(Type.Object({
|
|
244
244
|
allowOverride: Type.Boolean({ default: false }),
|
|
245
|
-
//
|
|
245
|
+
// (2026-09-10) TENANT-AUTHORED PER-LOCALE OVERRIDES of the SHIPPED
|
|
246
246
|
// template ids, as config DATA (a Record = 1 leaf, catalog size never
|
|
247
247
|
// moves the count). Shape: { [templateId]: { [locale]: { subject?,
|
|
248
248
|
// html?, text? } } }. Same escaped `{{placeholder}}` grammar as the
|
|
@@ -267,10 +267,10 @@ export const NotificationsConfigSchema = Type.Object({
|
|
|
267
267
|
}, { default: {} })),
|
|
268
268
|
/** in-app inbox channel (send with channel: 'inbox' | 'both') */
|
|
269
269
|
inboxEnabled: Type.Boolean({ default: false }),
|
|
270
|
-
/**
|
|
270
|
+
/** Broadcast campaigns channel. Optional bag (= 1 leaf): absent means
|
|
271
271
|
* disabled; per-campaign quiet_hours / freq_cap overrides live on the
|
|
272
272
|
* notifications.campaigns ROW (tenant data), not here. Folded into the
|
|
273
|
-
* canonical schema 2026-07-18 (
|
|
273
|
+
* canonical schema 2026-07-18 (Value.Clean previously STRIPPED the
|
|
274
274
|
* worker-local extension, so campaigns 403'd via the real config path). */
|
|
275
275
|
broadcast: Type.Optional(Type.Object({
|
|
276
276
|
enabled: Type.Boolean({ default: false }),
|
|
@@ -290,16 +290,14 @@ export const NotificationsConfigSchema = Type.Object({
|
|
|
290
290
|
})),
|
|
291
291
|
});
|
|
292
292
|
// ── jobs `generation` block: the ONE declaration of its defaults and bounds ──
|
|
293
|
-
// (
|
|
294
|
-
// copy"). The JobsConfigSchema `generation` leaf reads these for its
|
|
293
|
+
// (2026-09-25 — one copy of the generation defaults, not two). The JobsConfigSchema `generation` leaf reads these for its
|
|
295
294
|
// `default` / `minimum` / `maximum`, and workers/jobs-v1/src/generation.ts
|
|
296
295
|
// imports them (jobs-v1 already depends on @vxil/feature-configs; this package
|
|
297
296
|
// has no @vxil/types dependency, so the shared value lives here — the
|
|
298
297
|
// RESERVED_CREDIT_TYPES precedent). A future edit changes one object; the
|
|
299
|
-
// feature-configs unit test pins schema ↔ constant, and
|
|
300
|
-
//
|
|
301
|
-
|
|
302
|
-
/** Generation-lifecycle config defaults (jobs.md §11 / §5 ≤15-flag budget). */
|
|
298
|
+
// feature-configs unit test pins schema ↔ constant, and a CI gate pins that no
|
|
299
|
+
// second object-literal declaration of the constant reappears anywhere.
|
|
300
|
+
/** Generation-lifecycle config defaults (guide ch. 6, jobs). */
|
|
303
301
|
export const GENERATION_DEFAULTS = {
|
|
304
302
|
/** per-tenant in-flight generation cap (separate budget from queue jobs) */
|
|
305
303
|
maxConcurrent: 20,
|
|
@@ -339,7 +337,7 @@ export const JobsConfigSchema = Type.Object({
|
|
|
339
337
|
dlqDailyQuota: Type.Integer({ default: 0, minimum: 0, maximum: 100_000 }),
|
|
340
338
|
schedules: Type.Object({ maxPerTenant: Type.Integer({ default: 50, minimum: 1, maximum: 1000 }) }, { default: {} }),
|
|
341
339
|
concurrency: Type.Object({ maxConcurrent: Type.Integer({ default: 10, minimum: 1, maximum: 100 }) }, { default: {} }),
|
|
342
|
-
//
|
|
340
|
+
// Generation lifecycle knobs (guide ch. 6, jobs). The defaults and bounds are
|
|
343
341
|
// declared ONCE, as GENERATION_DEFAULTS / GENERATION_BOUNDS below this schema
|
|
344
342
|
// (2026-09-25): jobs-v1's resolveGenerationConfig imports them and clamps a
|
|
345
343
|
// pre-fold manifest to the same numbers — a hand-mirrored copy used to live
|
|
@@ -353,14 +351,14 @@ export const JobsConfigSchema = Type.Object({
|
|
|
353
351
|
maxTimeoutMs: Type.Integer({ default: GENERATION_DEFAULTS.maxTimeoutMs, minimum: GENERATION_BOUNDS.maxTimeoutMs.min, maximum: GENERATION_BOUNDS.maxTimeoutMs.max }),
|
|
354
352
|
/** poll-mode: how many poll cycles before giving up (→ terminal-fail) */
|
|
355
353
|
pollMaxAttempts: Type.Integer({ default: GENERATION_DEFAULTS.pollMaxAttempts, minimum: GENERATION_BOUNDS.pollMaxAttempts.min, maximum: GENERATION_BOUNDS.pollMaxAttempts.max }),
|
|
356
|
-
/** MANDATORY per-hold cap on a generation `reserve_credits.amount`
|
|
357
|
-
*
|
|
354
|
+
/** MANDATORY per-hold cap on a generation `reserve_credits.amount`
|
|
355
|
+
* (guide ch. 6, jobs). Every requested amount is CLAMPED to this (never rejected) — a
|
|
358
356
|
* conservative default so an untrusted deployed function that carries a
|
|
359
357
|
* reserve block can never hold more than a bounded amount per run without
|
|
360
358
|
* any tenant action. */
|
|
361
359
|
maxReserveCredits: Type.Integer({ default: GENERATION_DEFAULTS.maxReserveCredits, minimum: GENERATION_BOUNDS.maxReserveCredits.min, maximum: GENERATION_BOUNDS.maxReserveCredits.max }),
|
|
362
360
|
/** MANDATORY per-tenant ceiling on the SUM of un-settled provisional
|
|
363
|
-
* reserve holds across all in-flight generation runs (
|
|
361
|
+
* reserve holds across all in-flight generation runs (guide ch. 6, jobs): a
|
|
364
362
|
* reserve whose amount would push the tenant's outstanding-holds total over
|
|
365
363
|
* this is rejected 429, so a runaway function cannot hold every user at
|
|
366
364
|
* once. Defaulted so no tenant action is required to be safe. */
|
|
@@ -368,43 +366,42 @@ export const JobsConfigSchema = Type.Object({
|
|
|
368
366
|
}, { default: {} }),
|
|
369
367
|
});
|
|
370
368
|
// One social-provider's BYO credential block. The *Ref fields are POINTERS into
|
|
371
|
-
//
|
|
372
|
-
//
|
|
369
|
+
// the tenant's encrypted secret store — never raw secrets (guide ch. 6, auth).
|
|
370
|
+
// google/github/facebook share the clientId/secret shape; apple is distinct
|
|
373
371
|
// (Sign in with Apple has no static secret — it mints an ES256 client_secret from
|
|
374
|
-
// the .p8, so it carries servicesId/teamId/keyId + a p8 keyRef
|
|
372
|
+
// the .p8, so it carries servicesId/teamId/keyId + a p8 keyRef).
|
|
375
373
|
const OAuthRefsSchema = Type.Object({
|
|
376
374
|
// clientId/secret refs are OPTIONAL at the schema layer: a tenant may stage a
|
|
377
375
|
// partial block, and the worker enforces presence at use (→ 501 if missing),
|
|
378
376
|
// matching the worker's OAuthProviderRefs shape (core.ts). They stay POINTERS
|
|
379
|
-
// into
|
|
377
|
+
// into the tenant's secret store — never raw secrets (guide ch. 6, auth).
|
|
380
378
|
clientIdRef: Type.Optional(Type.String()),
|
|
381
379
|
clientSecretRef: Type.Optional(Type.String()),
|
|
382
380
|
// extra native-aud allow-list entries (iOS/web client ids that differ from the
|
|
383
|
-
// primary clientIdRef) — also
|
|
381
|
+
// primary clientIdRef) — also secret-store refs (guide ch. 6, auth).
|
|
384
382
|
audRefs: Type.Optional(Type.Array(Type.String(), { maxItems: 16 })),
|
|
385
383
|
});
|
|
386
384
|
const AppleRefsSchema = Type.Object({
|
|
387
385
|
servicesId: Type.String(), // the OAuth client_id / native aud (NOT a secret)
|
|
388
386
|
teamId: Type.String(),
|
|
389
387
|
keyId: Type.String(),
|
|
390
|
-
p8KeyRef: Type.String(), //
|
|
388
|
+
p8KeyRef: Type.String(), // secret-store ref → the encrypted .p8 PEM
|
|
391
389
|
// extra native-aud allow-list entries: genuine iOS ASAuthorization id_tokens
|
|
392
|
-
// carry the app BUNDLE ID as aud, not the Services ID (
|
|
390
|
+
// carry the app BUNDLE ID as aud, not the Services ID (guide ch. 6, auth). Plain
|
|
393
391
|
// config values — bundle ids are not secrets. The worker already honors them
|
|
394
392
|
// (oauthCore.ts nativeAudAllowList); declaring them here is what stops
|
|
395
393
|
// Value.Clean stripping the field out of PUT /v1/config/auth.
|
|
396
394
|
bundleIds: Type.Optional(Type.Array(Type.String(), { maxItems: 16 })),
|
|
397
395
|
});
|
|
398
|
-
//
|
|
399
|
-
// §6.7). ONE tenant-supplied issuer, declared INSIDE the existing `providers`
|
|
396
|
+
// The generic OIDC / SSO bridge (guide ch. 6, auth). ONE tenant-supplied issuer, declared INSIDE the existing `providers`
|
|
400
397
|
// bag so it spends NO leaf (an Optional object bag = ONE leaf; auth stays 11).
|
|
401
398
|
// Declarative + opt-in: the block's PRESENCE enables the `oidc` provider (no
|
|
402
399
|
// methods.* toggle — a `default:false` flag would re-materialize every published
|
|
403
|
-
// manifest, breaking the
|
|
400
|
+
// manifest, breaking the byte-identical fold). The worker discovers the
|
|
404
401
|
// endpoints + JWKS from `{issuer}/.well-known/openid-configuration` and verifies
|
|
405
402
|
// iss (byte-equal) / aud (= clientId) / nonce / exp / iat strictly, fail-closed.
|
|
406
403
|
// `clientId` is NOT a secret (it rides every authorize URL); `clientSecretRef`
|
|
407
|
-
// is a
|
|
404
|
+
// is a secret-store POINTER (feature 'auth'), never the value. A SAML IdP
|
|
408
405
|
// plugs in through a broker (Okta / Entra / Auth0 / WorkOS) that speaks OIDC —
|
|
409
406
|
// there is deliberately NO native SAML.
|
|
410
407
|
const OidcProviderSchema = Type.Object({
|
|
@@ -428,7 +425,7 @@ const OidcProviderSchema = Type.Object({
|
|
|
428
425
|
// marks the email verified (the tenant declared the issuer authoritative).
|
|
429
426
|
allowedDomains: Type.Optional(Type.Array(Type.String({ minLength: 3, maxLength: 253, pattern: '^[a-z0-9][a-z0-9.-]*\\.[a-z]{2,}$' }), { maxItems: 32 })),
|
|
430
427
|
// default true: an identity whose VERIFIED email matches an existing user is
|
|
431
|
-
// linked to it (the shipped
|
|
428
|
+
// linked to it (the shipped social sign-in rule). false: link only by the stable
|
|
432
429
|
// (issuer, sub) anchor; a matching email that is not yet linked → 409.
|
|
433
430
|
autoLink: Type.Optional(Type.Boolean()),
|
|
434
431
|
});
|
|
@@ -437,7 +434,7 @@ const OidcProviderSchema = Type.Object({
|
|
|
437
434
|
// on every caller-supplied `redirect_url` / `redirect_uri` (core.ts
|
|
438
435
|
// `isAllowedRedirectUrl`) must agree on WHICH schemes a sign-in link may be
|
|
439
436
|
// delivered to, or a tenant could allow-list an origin the worker then refuses
|
|
440
|
-
// (or the reverse). The rule (
|
|
437
|
+
// (or the reverse). The rule (2026-09-19): `https://` on any
|
|
441
438
|
// host, plus PLAIN `http://` ONLY on the two loopback names — `localhost` and
|
|
442
439
|
// `127.0.0.1`, any port — so a local dev server can complete a magic link
|
|
443
440
|
// without a staging origin. Any other `http://` (a LAN host, `*.local`, a
|
|
@@ -448,7 +445,7 @@ const OidcProviderSchema = Type.Object({
|
|
|
448
445
|
// with THIS predicate, and auth-v1 calls it on the parsed URL — the parity test
|
|
449
446
|
// in index.test.ts / redirectRule.test.ts holds the two together. The CLI's
|
|
450
447
|
// production promotion gate still refuses any `http://` origin on a
|
|
451
|
-
// production push
|
|
448
|
+
// production push, so a loopback entry is a DEV-tenant affair.
|
|
452
449
|
export const REDIRECT_ORIGIN_PATTERN = '^(https://[^/?#\\s]+|http://(localhost|127\\.0\\.0\\.1)(:[0-9]{1,5})?)$';
|
|
453
450
|
/** THE scheme rule for a redirect/return URL: https anywhere, http on loopback
|
|
454
451
|
* only. Takes the parsed URL (or any {protocol, hostname} pair) so the config
|
|
@@ -473,13 +470,13 @@ export function isAllowedRedirectOriginEntry(entry) {
|
|
|
473
470
|
}
|
|
474
471
|
export const AuthConfigSchema = Type.Object({
|
|
475
472
|
enabled: Type.Boolean({ default: true }),
|
|
476
|
-
//
|
|
473
|
+
// (2026-09-10) the six method toggles collapsed into ONE
|
|
477
474
|
// Optional bag (6 leaves → 1, countLeaves counts an Optional object as ONE) —
|
|
478
475
|
// the notifications `retry`/`broadcast` precedent. It KEEPS `default: {}`,
|
|
479
476
|
// which Value.Default still materializes, so every persisted manifest carries
|
|
480
477
|
// methods.{emailPassword,magicLink,google,github,apple,facebook} with the
|
|
481
478
|
// SAME keys and defaults as before — byte-identical folds for existing
|
|
482
|
-
// tenants (index.test.ts
|
|
479
|
+
// tenants (index.test.ts pins the fold bytes). Only the TS type is now optional;
|
|
483
480
|
// the worker's gate() normalizes an absent bag to the defaults so every
|
|
484
481
|
// reader (config.methods.<flag>) is unchanged.
|
|
485
482
|
methods: Type.Optional(Type.Object({
|
|
@@ -494,12 +491,12 @@ export const AuthConfigSchema = Type.Object({
|
|
|
494
491
|
// rule) keyed by provider, so the four provider blocks (and any future one)
|
|
495
492
|
// never inflate the flag count — the prior shape spent a leaf per top-level
|
|
496
493
|
// google/github block. This bag REPLACES those two top-level blocks (−2, +1
|
|
497
|
-
// for the bag) and EXTENDS the accepted providers to apple + facebook
|
|
494
|
+
// for the bag) and EXTENDS the accepted providers to apple + facebook:
|
|
498
495
|
// • google/github/facebook → { clientIdRef, clientSecretRef, audRefs? }
|
|
499
496
|
// • apple → { servicesId, teamId, keyId, p8KeyRef }
|
|
500
|
-
// All *Ref fields are
|
|
497
|
+
// All *Ref fields are secret-store POINTERS, never raw secrets. The
|
|
501
498
|
// worker reads config.providers?.{google,github,apple,facebook} (oauthCore.ts).
|
|
502
|
-
// The
|
|
499
|
+
// The runtime sign-in flow for apple/facebook is SHIPPED in oauthCore.ts
|
|
503
500
|
// (id_token/access_token verification + ES256 Apple client_secret minting);
|
|
504
501
|
// methods.{apple,facebook} above are the enable toggles it gates on.
|
|
505
502
|
providers: Type.Optional(Type.Object({
|
|
@@ -507,18 +504,18 @@ export const AuthConfigSchema = Type.Object({
|
|
|
507
504
|
github: Type.Optional(OAuthRefsSchema),
|
|
508
505
|
apple: Type.Optional(AppleRefsSchema),
|
|
509
506
|
facebook: Type.Optional(OAuthRefsSchema),
|
|
510
|
-
//
|
|
507
|
+
// the generic OIDC / SSO issuer (presence = enabled; see above)
|
|
511
508
|
oidc: Type.Optional(OidcProviderSchema),
|
|
512
509
|
})),
|
|
513
510
|
// session/password are OPTIONAL bags (= ONE leaf each per the cap rule) since
|
|
514
|
-
// the OTP/anonymous/orgClaims
|
|
511
|
+
// the OTP/anonymous/orgClaims release — the `{ default: {} }` keeps the inner
|
|
515
512
|
// defaults materializing on publish, so the worker still reads fully-populated
|
|
516
513
|
// manifests; its `config.session?.ttlMinutes ?? 60` fallbacks cover sparse
|
|
517
514
|
// hand-built manifests only.
|
|
518
515
|
session: Type.Optional(Type.Object({
|
|
519
516
|
ttlMinutes: Type.Integer({ default: 60, minimum: 5, maximum: 1440 }),
|
|
520
517
|
refreshTtlDays: Type.Integer({ default: 30, minimum: 1, maximum: 365 }),
|
|
521
|
-
//
|
|
518
|
+
// (2026-09-10) concurrent-session cap per user with
|
|
522
519
|
// TAKE-OVER — a new sign-in revokes the OLDEST sessions past the cap
|
|
523
520
|
// (revoked_reason 'device_cap', edge cache written) and reports them as
|
|
524
521
|
// `took_over: [session_id…]`. Optional WITHOUT a default so existing
|
|
@@ -529,12 +526,12 @@ export const AuthConfigSchema = Type.Object({
|
|
|
529
526
|
minLength: Type.Integer({ default: 8, minimum: 6, maximum: 128 }),
|
|
530
527
|
requireMixed: Type.Boolean({ default: false }),
|
|
531
528
|
}, { default: {} })),
|
|
532
|
-
//
|
|
529
|
+
// Note: emailVerification.tokenTtlHours was DROPPED —
|
|
533
530
|
// consumer-less (grep-verified: only this schema + dist mentioned it; the
|
|
534
531
|
// verify-email token flow it would bound was never built). Same precedent as
|
|
535
|
-
// the removed `redirects` block below. Its leaf funds the OTP
|
|
532
|
+
// the removed `redirects` block below. Its leaf funds the OTP sign-in bag.
|
|
536
533
|
emailVerification: Type.Object({ required: Type.Boolean({ default: false }) }, { default: {} }),
|
|
537
|
-
//
|
|
534
|
+
// (2026-09-18) magicLink is now an OPTIONAL bag (= ONE leaf however
|
|
538
535
|
// many knobs it holds — the methods/session/password precedent) so the
|
|
539
536
|
// request cooldown could land without spending a second leaf. It KEEPS
|
|
540
537
|
// `default: {}`, so Value.Default still materializes
|
|
@@ -542,7 +539,7 @@ export const AuthConfigSchema = Type.Object({
|
|
|
542
539
|
// folds byte-identically.
|
|
543
540
|
magicLink: Type.Optional(Type.Object({
|
|
544
541
|
tokenTtlMinutes: Type.Integer({ default: 15, minimum: 5, maximum: 60 }),
|
|
545
|
-
//
|
|
542
|
+
// the per-(tenant, identifier) magic-link REQUEST cooldown — the
|
|
546
543
|
// `otp.resendCooldownSec` twin, same bounds so the two knobs read the
|
|
547
544
|
// same. A second request for the same address inside the window is a 429
|
|
548
545
|
// `magic_link_rate_limited` with a Retry-After header. Type.Optional with
|
|
@@ -551,19 +548,19 @@ export const AuthConfigSchema = Type.Object({
|
|
|
551
548
|
// auth feature at read time. 0 disables the cooldown.
|
|
552
549
|
resendCooldownSec: Type.Optional(Type.Integer({ minimum: 0, maximum: 600 })),
|
|
553
550
|
}, { default: {} })),
|
|
554
|
-
//
|
|
551
|
+
// Identity continuity (2026-09-18) — OPT-IN registry adoption. When
|
|
555
552
|
// true, a sign-in by a method that PROVES control of the address — magic
|
|
556
553
|
// link, email OTP, or OAuth with a provider-verified address — reuses the id
|
|
557
554
|
// of the one matching pre-registered end-user (POST /v1/users) that has no
|
|
558
555
|
// account yet, instead of minting a fresh `user_<ulid>` and leaving the
|
|
559
556
|
// tenant with two records for one person. Password SIGN-UP never adopts: it
|
|
560
|
-
// proves nothing about the address (
|
|
557
|
+
// proves nothing about the address (guide ch. 6, auth).
|
|
561
558
|
// OFF by default, and Type.Optional with NO default: adoption means whoever
|
|
562
559
|
// proves control of a pre-registered address becomes that record — a change
|
|
563
560
|
// of security semantics for a tenant that bulk-imports contacts, whose
|
|
564
561
|
// addresses vxil never verified.
|
|
565
562
|
registryAdopt: Type.Optional(Type.Boolean()),
|
|
566
|
-
// Email OTP sign-in
|
|
563
|
+
// Email OTP sign-in + the knobs step-up re-auth shares.
|
|
567
564
|
// OPTIONAL bag = 1 leaf; absent ⇒ disabled (the worker gates on
|
|
568
565
|
// otp?.enabled === true).
|
|
569
566
|
otp: Type.Optional(Type.Object({
|
|
@@ -571,7 +568,7 @@ export const AuthConfigSchema = Type.Object({
|
|
|
571
568
|
codeTtlMinutes: Type.Integer({ default: 10, minimum: 1, maximum: 60 }),
|
|
572
569
|
maxAttempts: Type.Integer({ default: 5, minimum: 3, maximum: 10 }),
|
|
573
570
|
resendCooldownSec: Type.Integer({ default: 60, minimum: 0, maximum: 600 }),
|
|
574
|
-
//
|
|
571
|
+
// (2026-09-10) test recipients — an OTP / step-up / email-
|
|
575
572
|
// claim request whose address matches an entry sends NO mail and returns
|
|
576
573
|
// the code as `test_code` (audit auth.otp.test_issued). Entries: an exact
|
|
577
574
|
// email, a `*@domain` glob, or a +E.164 number (accepted for the SMS
|
|
@@ -580,11 +577,11 @@ export const AuthConfigSchema = Type.Object({
|
|
|
580
577
|
// only — never a real user's address.
|
|
581
578
|
testRecipients: Type.Optional(Type.Array(Type.String({ minLength: 3, maxLength: 320 }), { maxItems: 20 })),
|
|
582
579
|
})),
|
|
583
|
-
// Anonymous (guest) sign-in
|
|
580
|
+
// Anonymous (guest) sign-in. OPTIONAL bag = 1 leaf.
|
|
584
581
|
anonymous: Type.Optional(Type.Object({
|
|
585
582
|
enabled: Type.Boolean({ default: false }),
|
|
586
583
|
})),
|
|
587
|
-
// Org claims embedded in session JWTs at mint/refresh
|
|
584
|
+
// Org claims embedded in session JWTs at mint/refresh:
|
|
588
585
|
// when enabled, auth-v1 fetches the user's active-org membership from orgs
|
|
589
586
|
// over the EDGE and embeds { org_id, role, perms[] } as the `org` claim.
|
|
590
587
|
// Fail-open: an orgs outage mints WITHOUT claims (sign-in never breaks).
|
|
@@ -593,23 +590,22 @@ export const AuthConfigSchema = Type.Object({
|
|
|
593
590
|
orgClaims: Type.Optional(Type.Object({
|
|
594
591
|
enabled: Type.Boolean({ default: false }),
|
|
595
592
|
})),
|
|
596
|
-
//
|
|
593
|
+
// Note: the earlier `redirects` block was DROPPED entirely —
|
|
597
594
|
// it had zero consumers (grep-verified: no worker reads config.redirects) and
|
|
598
595
|
// its leaf was spent on the methods.{apple,facebook} toggles the shipped
|
|
599
|
-
//
|
|
596
|
+
// social sign-in flow actually gates on. Re-adding it requires headroom or a
|
|
600
597
|
// collapse elsewhere.
|
|
601
598
|
//
|
|
602
|
-
// Account-security controls (
|
|
603
|
-
// §4b). ONE optional bag = 1 leaf; NO `default: {}` so an absent bag stays
|
|
599
|
+
// Account-security controls (2026-09-10; guide ch. 6, auth). ONE optional bag = 1 leaf; NO `default: {}` so an absent bag stays
|
|
604
600
|
// absent (existing manifests fold byte-identically) and every control is
|
|
605
601
|
// opt-in:
|
|
606
602
|
// • lockout — present ⇒ per-(tenant, identifier) failure lockout on password
|
|
607
603
|
// sign-in + OTP verify (429 account_locked + Retry-After); a bounded
|
|
608
|
-
// counter
|
|
604
|
+
// stored counter survives restarts.
|
|
609
605
|
// • breachedPasswords — HIBP k-anonymity range check (first 5 SHA-1 hex
|
|
610
606
|
// chars leave the worker, never the password) at sign-up / reset-confirm;
|
|
611
607
|
// fail-OPEN on network error → 422 password_breached.
|
|
612
|
-
// • captchaSecretRef — a
|
|
608
|
+
// • captchaSecretRef — a secret-store ref (feature 'auth') holding the
|
|
613
609
|
// Turnstile secret; when set, sign-up / OTP request / magic-link request
|
|
614
610
|
// require `captcha_token` (403 captcha_failed otherwise).
|
|
615
611
|
// • allowedRedirectOrigins — when non-empty, EVERY caller-supplied
|
|
@@ -629,10 +625,10 @@ export const AuthConfigSchema = Type.Object({
|
|
|
629
625
|
allowedRedirectOrigins: Type.Optional(Type.Array(Type.String({ minLength: 8, maxLength: 253, pattern: REDIRECT_ORIGIN_PATTERN }), { maxItems: 32 })),
|
|
630
626
|
})),
|
|
631
627
|
});
|
|
632
|
-
// ── DECLARED API STATE (
|
|
628
|
+
// ── DECLARED API STATE (2026-09-23) ──────────────────────────────────────────
|
|
633
629
|
// A rate-limit policy is a ROW in the feature's own KV store, written by
|
|
634
630
|
// POST/PUT/DELETE /v1/rate-limits/policies. It used to be API state OUTSIDE
|
|
635
|
-
// vxil.config (
|
|
631
|
+
// vxil.config (by the old rule "one writer per datum, and the writer is
|
|
636
632
|
// the route"), which made a second environment non-reproducible — every tenant
|
|
637
633
|
// ended up with an `ensure-rate-limit-policies.ts` + a nightly assert. The
|
|
638
634
|
// rule is unchanged — one writer per datum — but the writer is now THE
|
|
@@ -670,7 +666,7 @@ export const RateLimitsConfigSchema = Type.Object({
|
|
|
670
666
|
});
|
|
671
667
|
export const FilesConfigSchema = Type.Object({
|
|
672
668
|
enabled: Type.Boolean({ default: true }),
|
|
673
|
-
//
|
|
669
|
+
// `bucketRef` was DELETED (2026-09-11): the object-storage bucket is a platform
|
|
674
670
|
// binding on files-v1, never tenant-selectable, and no code ever read the
|
|
675
671
|
// leaf — declaring it invited "point files at my own bucket", which vxil does
|
|
676
672
|
// not offer. A persisted manifest that still carries it folds (Value.Clean).
|
|
@@ -678,8 +674,8 @@ export const FilesConfigSchema = Type.Object({
|
|
|
678
674
|
downloadUrlTtl: Type.Integer({ default: 900, minimum: 60, maximum: 86400 }),
|
|
679
675
|
quotas: Type.Object({
|
|
680
676
|
// maximum caps are a defense-in-depth ceiling on tenant-editable storage —
|
|
681
|
-
// object storage is cheap but the
|
|
682
|
-
// 2026-07-10). 5 GiB/object, 1 TiB/tenant absolute; true PER-TIER clamps
|
|
677
|
+
// object storage is cheap but the database-resident metadata + abuse aren't
|
|
678
|
+
// (pricing review 2026-07-10). 5 GiB/object, 1 TiB/tenant absolute; true PER-TIER clamps
|
|
683
679
|
// (Free/Dev 10 GB · Team 50 GB · Business 256 GB) are a follow-up needing the
|
|
684
680
|
// tenant tier threaded to files-v1 (plan tiers).
|
|
685
681
|
maxObjectBytes: Type.Integer({ default: 100 * 1024 * 1024, minimum: 1, maximum: 5 * 1024 * 1024 * 1024 }),
|
|
@@ -687,7 +683,7 @@ export const FilesConfigSchema = Type.Object({
|
|
|
687
683
|
maxObjectCount: Type.Integer({ default: 100000, minimum: 1, maximum: 100_000_000 }),
|
|
688
684
|
}, { default: {} }),
|
|
689
685
|
allowedContentTypes: Type.Array(Type.String(), { default: ['*'], maxItems: 100 }),
|
|
690
|
-
// (
|
|
686
|
+
// (2026-09-11) the `contentScan` bag ({enabled, quarantineOnFail}) was DELETED:
|
|
691
687
|
// there is no malware/content scanner in files-v1 (it was a "V1.5" placeholder
|
|
692
688
|
// neither leaf was ever read), so the knob promised quarantine that never
|
|
693
689
|
// happened. Re-declare it in the same change as a real scanner, not before.
|
|
@@ -695,7 +691,7 @@ export const FilesConfigSchema = Type.Object({
|
|
|
695
691
|
enabled: Type.Boolean({ default: true }),
|
|
696
692
|
maxTtl: Type.Integer({ default: 7 * 24 * 3600 }),
|
|
697
693
|
}, { default: {} }),
|
|
698
|
-
// Wave-2 extensions (
|
|
694
|
+
// Wave-2 extensions (guide ch. 6, files: OCR + TTL) — the merge of
|
|
699
695
|
// workers/files-v1/src/ext.ts FilesExtensionsConfigSchema promised by its
|
|
700
696
|
// 'wiring phase' comment. Each is an OPTIONAL bag (= ONE leaf per the cap
|
|
701
697
|
// rule); files-v1 already reads both defensively (FilesConfigWithExt), so
|
|
@@ -710,16 +706,15 @@ export const FilesConfigSchema = Type.Object({
|
|
|
710
706
|
extractText: Type.Optional(Type.Object({
|
|
711
707
|
enabled: Type.Boolean({ default: false }),
|
|
712
708
|
provider: Type.Union([Type.Literal('gcv'), Type.Literal('textract'), Type.Literal('azure-di'), Type.Literal('mock')], { default: 'mock' }),
|
|
713
|
-
// provider key is BYO +
|
|
714
|
-
// config flag. keyRef names the
|
|
709
|
+
// provider key is BYO + encrypted in the tenant's secret store — NOT a
|
|
710
|
+
// config flag. keyRef names the stored secret (like ai's keyRefs).
|
|
715
711
|
keyRef: Type.Optional(Type.String()),
|
|
716
712
|
asyncOverJobs: Type.Boolean({ default: true }), // large/multi-page → jobs
|
|
717
713
|
boundingBoxes: Type.Boolean({ default: false }),
|
|
718
714
|
})),
|
|
719
715
|
});
|
|
720
716
|
// webhooks-out (wishlist feature): outbound event fan-out over the jobs delivery
|
|
721
|
-
// engine. Subscriptions live in their own
|
|
722
|
-
// per datum); config is just the capability gate + a cap.
|
|
717
|
+
// engine. Subscriptions live in their own store (one writer per datum); config is just the capability gate + a cap.
|
|
723
718
|
export const DeclaredWebhookSubscriptionSchema = Type.Object({
|
|
724
719
|
target_url: Type.String({ minLength: 9, maxLength: 2000 }),
|
|
725
720
|
event_prefixes: Type.Optional(Type.Array(Type.String({ minLength: 1, maxLength: 100 }), { maxItems: 20 })),
|
|
@@ -728,14 +723,14 @@ export const WebhooksConfigSchema = Type.Object({
|
|
|
728
723
|
enabled: Type.Boolean({ default: true }),
|
|
729
724
|
maxSubscriptions: Type.Integer({ default: 20, minimum: 1, maximum: 200 }),
|
|
730
725
|
maxSources: Type.Integer({ default: 20, minimum: 1, maximum: 200 }),
|
|
731
|
-
// FAILURE-ALERT DIGEST
|
|
726
|
+
// FAILURE-ALERT DIGEST. Outbound subscriptions are the real-time
|
|
732
727
|
// channel; this is the "nobody is consuming them yet" fallback — a periodic
|
|
733
728
|
// e-mail summary of the tenant's FAILURE-class audit events (the level:
|
|
734
729
|
// 'failure' rows of the generated event catalog). Read by
|
|
735
730
|
// workers/control-plane/src/alertDigest.ts on the minute cron.
|
|
736
731
|
//
|
|
737
|
-
// RECIPIENTS ARE DELIBERATELY NOT CONFIGURABLE, and this
|
|
738
|
-
//
|
|
732
|
+
// RECIPIENTS ARE DELIBERATELY NOT CONFIGURABLE, and this decision is
|
|
733
|
+
// recorded here the way RateLimitsConfigSchema records its own: an
|
|
739
734
|
// arbitrary `to` would turn vxil's own sending identity into a relay for
|
|
740
735
|
// tenant-authored content and open a PII egress path out of the audit trail.
|
|
741
736
|
// The digest goes to the OWNER-role dashboard accounts of the project (cap
|
|
@@ -745,7 +740,7 @@ export const WebhooksConfigSchema = Type.Object({
|
|
|
745
740
|
//
|
|
746
741
|
// An Optional object bag counts as ONE leaf (the countLeaves rule).
|
|
747
742
|
//
|
|
748
|
-
// `digestMinutes: 0` is IMMEDIATE (
|
|
743
|
+
// `digestMinutes: 0` is IMMEDIATE (2026-09-23): the
|
|
749
744
|
// pass runs every minute for the tenant and mails the `error`-level failure
|
|
750
745
|
// rows that landed since its last mail — at most one mail per minute, still
|
|
751
746
|
// to the owner accounts. 1–4 are clamped up to 5 by the reader.
|
|
@@ -754,11 +749,11 @@ export const WebhooksConfigSchema = Type.Object({
|
|
|
754
749
|
minLevel: Type.Union([Type.Literal('warn'), Type.Literal('error')], { default: 'error' }),
|
|
755
750
|
digestMinutes: Type.Integer({ default: 15, minimum: 0, maximum: 1440 }),
|
|
756
751
|
})),
|
|
757
|
-
// DECLARED API STATE (
|
|
752
|
+
// DECLARED API STATE (2026-09-23): the tenant's OUTBOUND
|
|
758
753
|
// subscriptions as config. Keyed by `target_url` — the only stable identity a
|
|
759
754
|
// subscription has (there is no name column). A changed prefix set is an
|
|
760
755
|
// in-place update — PATCH /v1/webhooks/subscriptions/:subId, same sub_id and
|
|
761
|
-
// cursor (2026-09-25). `vxil push` / `POST /v1/apply` converge
|
|
756
|
+
// cursor (2026-09-25). `vxil push` / `POST /v1/apply` converge the live subscriptions
|
|
762
757
|
// onto this list (handlers/apiState.ts); undeclared live rows are LEFT and
|
|
763
758
|
// reported (deleted only under --allow-destructive). Rows on the platform's
|
|
764
759
|
// signed function-delivery lanes (/v1/internal/fn/…) are NEVER declared here
|
|
@@ -775,16 +770,16 @@ export const CommentsConfigSchema = Type.Object({
|
|
|
775
770
|
/** Author edits allowed this long after posting; 0 disables editing. */
|
|
776
771
|
editWindowMinutes: Type.Integer({ default: 15, minimum: 0, maximum: 10_080 }),
|
|
777
772
|
});
|
|
778
|
-
// content feature (
|
|
773
|
+
// content feature (guide ch. 4): flags govern LIMITS, never the
|
|
779
774
|
// content model — the model itself is data (cms.collections / cms.fields via
|
|
780
|
-
// the REST surface). versioning/localization/publicRead land later
|
|
775
|
+
// the REST surface). versioning/localization/publicRead land later.
|
|
781
776
|
export const CmsConfigSchema = Type.Object({
|
|
782
777
|
enabled: Type.Boolean({ default: true }),
|
|
783
778
|
draftPublish: Type.Boolean({ default: true }),
|
|
784
|
-
// cms end-user default-deny fail-safe (
|
|
779
|
+
// cms end-user default-deny fail-safe (guide ch. 4). When ON,
|
|
785
780
|
// a VERIFIED end-user key (owner-scope mode) is DENIED access to any
|
|
786
781
|
// collection that declares no owner_field — `403 server_only` on read AND
|
|
787
|
-
// write (
|
|
782
|
+
// write (2026-09-20; reads used to be a 404) — instead of the
|
|
788
783
|
// default tenant-wide-shared behavior. Server-caller mode is a
|
|
789
784
|
// byte-for-byte no-op. Default OFF preserves today's shared semantics
|
|
790
785
|
// (owner.int.test.ts's shared-collection invariant). A collection that DOES
|
|
@@ -800,7 +795,7 @@ export const CmsConfigSchema = Type.Object({
|
|
|
800
795
|
maxPageSize: Type.Integer({ default: 100, minimum: 1, maximum: 500 }),
|
|
801
796
|
defaultPageSize: Type.Integer({ default: 25, minimum: 1, maximum: 500 }),
|
|
802
797
|
}, { default: {} }),
|
|
803
|
-
// cms ENRICHMENT (
|
|
798
|
+
// cms ENRICHMENT (guide ch. 4): the read-time relation budget. The worker
|
|
804
799
|
// clamps via resolveRelationsConfig (enrich.ts) with the SAME defaults +
|
|
805
800
|
// hard ceilings, so an out-of-range value can never widen the bound.
|
|
806
801
|
relations: Type.Object({
|
|
@@ -832,7 +827,7 @@ export const CmsConfigSchema = Type.Object({
|
|
|
832
827
|
message: Type.Optional(Type.String({ maxLength: 200 })),
|
|
833
828
|
enabled: Type.Optional(Type.Boolean()),
|
|
834
829
|
}))),
|
|
835
|
-
// Declarative relational read-models (
|
|
830
|
+
// Declarative relational read-models (guide ch. 4).
|
|
836
831
|
// Each is a NAMED, closed-grammar aggregate/rank spec, optionally
|
|
837
832
|
// materialized to a rollup collection on the EXISTING jobs cron (the
|
|
838
833
|
// fn-cron:* reconciler idiom → cms-rollup:* schedules). Grammar is validated
|
|
@@ -841,7 +836,7 @@ export const CmsConfigSchema = Type.Object({
|
|
|
841
836
|
readModels: Type.Optional(Type.Record(Type.String({ maxLength: 64 }), Type.Object({
|
|
842
837
|
collection: Type.String({ maxLength: 64 }),
|
|
843
838
|
kind: Type.Union([Type.Literal('aggregate'), Type.Literal('rank')]),
|
|
844
|
-
// the
|
|
839
|
+
// the aggregate/rank query body minus limit — Type.Unknown so Value.Clean keeps it
|
|
845
840
|
// (the functions `signature` idiom); shape checked by the cross-field rule.
|
|
846
841
|
spec: Type.Unknown(),
|
|
847
842
|
materialize: Type.Optional(Type.Object({
|
|
@@ -865,13 +860,13 @@ export const CmsConfigSchema = Type.Object({
|
|
|
865
860
|
enabled: Type.Optional(Type.Boolean()),
|
|
866
861
|
}))),
|
|
867
862
|
});
|
|
868
|
-
// mcp feature (
|
|
863
|
+
// mcp feature (guide ch. 10): the aggregation surface's own knobs. Default-enabled —
|
|
869
864
|
// a tenant with no mcp config row still gets the aggregated tool list.
|
|
870
865
|
export const McpConfigSchema = Type.Object({
|
|
871
866
|
enabled: Type.Boolean({ default: true }),
|
|
872
867
|
exposureLevel: Type.Union([Type.Literal('all'), Type.Literal('read-only'), Type.Literal('custom')], { default: 'all' }),
|
|
873
868
|
allowToolList: Type.Optional(Type.Array(Type.String(), { maxItems: 200 })),
|
|
874
|
-
// (
|
|
869
|
+
// (2026-09-11) the `scopedKey.perAgentKeys` leaf was DELETED: it was documented as
|
|
875
870
|
// a "dashboard-UI hint only" that no dashboard ever read, and key minting is a
|
|
876
871
|
// control-plane concern independent of MCP exposure — per-agent keys already
|
|
877
872
|
// work for every tenant, gated by nothing here.
|
|
@@ -880,7 +875,7 @@ export const McpConfigSchema = Type.Object({
|
|
|
880
875
|
serverName: Type.String({ default: 'Vxil' }),
|
|
881
876
|
serverInstructions: Type.Optional(Type.String({ maxLength: 4000 })),
|
|
882
877
|
}, { default: {} }),
|
|
883
|
-
// Tenant-authored CUSTOM tools (
|
|
878
|
+
// Tenant-authored CUSTOM tools (guide ch. 10): name → tenant-owned https
|
|
884
879
|
// endpoint. mcp-v1 lists each as `custom_<name>` and POSTs the tool
|
|
885
880
|
// arguments to `url`, HMAC-signed with the per-tenant key from
|
|
886
881
|
// GET /v1/mcp/signing-secret (X-Vxil-Mcp-Signature; the caller's vxil bearer
|
|
@@ -896,7 +891,7 @@ export const McpConfigSchema = Type.Object({
|
|
|
896
891
|
inputSchema: Type.Optional(Type.Unknown()),
|
|
897
892
|
timeoutMs: Type.Optional(Type.Integer({ minimum: 1000, maximum: 20_000 })),
|
|
898
893
|
}))),
|
|
899
|
-
// Config-declared MCP PROMPTS (
|
|
894
|
+
// Config-declared MCP PROMPTS (guide ch. 10): name → template with
|
|
900
895
|
// {{placeholder}} interpolation. Served verbatim by mcp-v1 prompts/list +
|
|
901
896
|
// prompts/get. ONE Type.Record leaf; placeholder ↔ arguments consistency is
|
|
902
897
|
// a cross-field rule below.
|
|
@@ -926,7 +921,7 @@ export const OrgsConfigSchema = Type.Object({
|
|
|
926
921
|
maxMembersPerOrg: Type.Integer({ default: 1000, minimum: 1, maximum: 100_000 }),
|
|
927
922
|
invitationTtlHours: Type.Integer({ default: 168, minimum: 1, maximum: 720 }),
|
|
928
923
|
});
|
|
929
|
-
// activity-feed feature (
|
|
924
|
+
// activity-feed feature (guide ch. 6, activity-feed): a GetStream-class activity-
|
|
930
925
|
// streams engine + a Knock/Novu-class in-app notification FEED. Flags govern
|
|
931
926
|
// the fan-out throttle, the follow/aggregation caps, and the cross-channel /
|
|
932
927
|
// realtime gates — NEVER the verb vocabulary or the personalized ranker (the
|
|
@@ -943,8 +938,8 @@ export const ActivityFeedConfigSchema = Type.Object({
|
|
|
943
938
|
Type.Literal('aggregated'),
|
|
944
939
|
Type.Literal('notification'),
|
|
945
940
|
]),
|
|
946
|
-
aggregation: Type.Optional(Type.String()), // group-format rule
|
|
947
|
-
ranking: Type.Optional(Type.String()), // 'chronological' | 'decay'
|
|
941
|
+
aggregation: Type.Optional(Type.String()), // group-format rule; required for aggregated/notification
|
|
942
|
+
ranking: Type.Optional(Type.String()), // 'chronological' | 'decay'; flat-only; default chronological
|
|
948
943
|
}), {
|
|
949
944
|
default: {
|
|
950
945
|
user: { type: 'flat' },
|
|
@@ -958,14 +953,14 @@ export const ActivityFeedConfigSchema = Type.Object({
|
|
|
958
953
|
fanout: Type.Object({
|
|
959
954
|
celebrityThreshold: Type.Integer({ default: 10_000, minimum: 0 }), // ≥ → pull (read-side); < → push (write-side)
|
|
960
955
|
maxFanoutPerJob: Type.Integer({ default: 1000, minimum: 1, maximum: 10_000 }), // follower batch size per jobs task
|
|
961
|
-
maxConcurrentTasks: Type.Integer({ default: 20, minimum: 1, maximum: 1000 }), // per-tenant in-flight cap (
|
|
956
|
+
maxConcurrentTasks: Type.Integer({ default: 20, minimum: 1, maximum: 1000 }), // per-tenant in-flight cap (local throttle)
|
|
962
957
|
pendingCeiling: Type.Integer({ default: 50_000, minimum: 1 }), // pending-fan-out-depth back-pressure ceiling
|
|
963
958
|
}, { default: {} }),
|
|
964
959
|
follow: Type.Object({
|
|
965
960
|
copyLimit: Type.Integer({ default: 100, minimum: 0, maximum: 1000 }), // backfill budget on follow
|
|
966
961
|
maxFollowing: Type.Integer({ default: 10_000, minimum: 0 }), // per-feed following cap
|
|
967
962
|
}, { default: {} }),
|
|
968
|
-
// (
|
|
963
|
+
// (2026-09-11) the `aggregation.maxGroupActivities` leaf was DELETED: nothing kept
|
|
969
964
|
// or returned a per-group activity LIST — an aggregated read returns the group
|
|
970
965
|
// rollup (activity_count/actor_count/last_actor), so there was never an N to
|
|
971
966
|
// bound and no code read the leaf. Re-declare it with a group-detail route.
|
|
@@ -973,16 +968,16 @@ export const ActivityFeedConfigSchema = Type.Object({
|
|
|
973
968
|
enabled: Type.Boolean({ default: true }), // live new-activity + count push over the realtime ChannelDO
|
|
974
969
|
}, { default: {} }),
|
|
975
970
|
crossChannel: Type.Object({
|
|
976
|
-
enabled: Type.Boolean({ default: false }), // master gate for the notifications push/email trigger
|
|
971
|
+
enabled: Type.Boolean({ default: false }), // master gate for the notifications push/email trigger
|
|
977
972
|
digestCadence: Type.Union([Type.Literal('off'), Type.Literal('hourly'), Type.Literal('daily')], { default: 'off' }), // digest roll-up window (feed owns the roll-up, rides notifications' live single-send)
|
|
978
973
|
}, { default: {} }),
|
|
979
|
-
// (
|
|
974
|
+
// (2026-09-11) the `rateLimit.addPerSec` leaf was DELETED: activity-feed-v1 has no
|
|
980
975
|
// rate-limiter binding and never read it, so the declared per-tenant write
|
|
981
976
|
// burst was enforced by nothing (the edge front-door limiter and the
|
|
982
977
|
// per-tenant request meter are the real bounds). Re-declare it together with
|
|
983
978
|
// the binding that enforces it.
|
|
984
979
|
});
|
|
985
|
-
// vector-search feature (
|
|
980
|
+
// vector-search feature (guide ch. 6, vector-search). Re-declared here to match the
|
|
986
981
|
// schema the worker EXPORTS from workers/vector-search-v1/src/config.ts — the
|
|
987
982
|
// control plane validates writes against this shared copy (the same
|
|
988
983
|
// one-definition / two-consumers note as the other features above; this package owns
|
|
@@ -991,7 +986,7 @@ export const ActivityFeedConfigSchema = Type.Object({
|
|
|
991
986
|
// synthesis / relevance tuning (the tenant's moat). An OPTIONAL leaf = ONE flag.
|
|
992
987
|
export const VectorSearchConfigSchema = Type.Object({
|
|
993
988
|
enabled: Type.Boolean({ default: true }),
|
|
994
|
-
// 'auto' resolves to the default managed vector backend for the tier
|
|
989
|
+
// 'auto' resolves to the default managed vector backend for the tier.
|
|
995
990
|
backend: Type.Union([Type.Literal('auto'), Type.Literal('lakebase'), Type.Literal('pgvector')], { default: 'auto' }),
|
|
996
991
|
// 'byov'/'mock' need NO provider key (zero-config default); openai/cohere read a
|
|
997
992
|
// BYO key from tenant secrets via apiKeyRef (encrypted at rest).
|
|
@@ -1025,7 +1020,7 @@ export const VectorSearchConfigSchema = Type.Object({
|
|
|
1025
1020
|
provider: Type.Union([Type.Literal('mock'), Type.Literal('cohere'), Type.Literal('voyage')]),
|
|
1026
1021
|
model: Type.Optional(Type.String({ maxLength: 128 })), // cohere 'rerank-v3.5' / voyage 'rerank-2'
|
|
1027
1022
|
topN: Type.Optional(Type.Integer({ default: 50, minimum: 1, maximum: 200 })),
|
|
1028
|
-
apiKeyRef: Type.Optional(Type.String({ maxLength: 128 })), // 'secret:<name>'
|
|
1023
|
+
apiKeyRef: Type.Optional(Type.String({ maxLength: 128 })), // 'secret:<name>' in the tenant's secret store
|
|
1029
1024
|
})),
|
|
1030
1025
|
// Config-driven auto-embedding sync from cms collections: the control plane
|
|
1031
1026
|
// reconciles one `vs-sync:` jobs schedule per entry on every config commit;
|
|
@@ -1042,12 +1037,12 @@ export const VectorSearchConfigSchema = Type.Object({
|
|
|
1042
1037
|
cron: Type.Optional(Type.String({ pattern: '^\\S+ \\S+ \\S+ \\S+ \\S+$' })),
|
|
1043
1038
|
}), { maxItems: 8 })),
|
|
1044
1039
|
});
|
|
1045
|
-
// ai feature (
|
|
1040
|
+
// ai feature (guide ch. 6, ai). Re-declared to match workers/ai-v1/src/core.ts's
|
|
1046
1041
|
// exported AiConfigSchema. vxil owns the call SCAFFOLDING (routing, streaming,
|
|
1047
1042
|
// token accounting, caching, the reserve→settle budget); the tenant owns the
|
|
1048
1043
|
// intelligence (prompt TEMPLATES are config-as-code, stored/rendered but never
|
|
1049
1044
|
// authored). 'mock' is the deterministic default until a BYO key is provisioned;
|
|
1050
|
-
// the real providers route via
|
|
1045
|
+
// the real providers route via secret-store keyRefs.
|
|
1051
1046
|
export const AI_TEMPLATE_NAME_PATTERN = '^[a-zA-Z0-9_.\\-]+$';
|
|
1052
1047
|
export const AI_MAX_DECLARED_TEMPLATES = 50;
|
|
1053
1048
|
export const DeclaredAiTemplateSchema = Type.Object({
|
|
@@ -1063,7 +1058,7 @@ export const AiConfigSchema = Type.Object({
|
|
|
1063
1058
|
// meta-provider (BYO key under providers.compat.openrouterKeyRef).
|
|
1064
1059
|
defaultProvider: Type.Union([Type.Literal('mock'), Type.Literal('openai'), Type.Literal('anthropic'),
|
|
1065
1060
|
Type.Literal('gemini'), Type.Literal('azure'), Type.Literal('openrouter')], { default: 'mock' }),
|
|
1066
|
-
// BYO keyRefs →
|
|
1061
|
+
// BYO keyRefs → the tenant's encrypted secret store. The block is NOT
|
|
1067
1062
|
// optional (the worker declares it plain), so its three optional refs each count
|
|
1068
1063
|
// as a leaf. The nested blocks carry `default: {}` (this package's convention)
|
|
1069
1064
|
// so Value.Default materializes them + recurses into the leaf defaults when a
|
|
@@ -1075,7 +1070,7 @@ export const AiConfigSchema = Type.Object({
|
|
|
1075
1070
|
geminiKeyRef: Type.Optional(Type.String()),
|
|
1076
1071
|
// The openai-compatible extension surface — ONE optional object = ONE config
|
|
1077
1072
|
// leaf (countLeaves collapses optional objects; 15-leaf cap discipline).
|
|
1078
|
-
// compat.openrouterKeyRef: BYO OpenRouter key (
|
|
1073
|
+
// compat.openrouterKeyRef: BYO OpenRouter key (a secret-store ref).
|
|
1079
1074
|
// compat.openaiBaseUrl: point the openai adapter at ANY openai-compatible
|
|
1080
1075
|
// host (DeepSeek, vLLM, an Azure-compatible proxy). Public-https validated
|
|
1081
1076
|
// at config WRITE (publicHttpsUrlError below) AND at USE (@vxil/runtime
|
|
@@ -1095,7 +1090,7 @@ export const AiConfigSchema = Type.Object({
|
|
|
1095
1090
|
tokensPerUserPerDay: Type.Integer({ default: 0, minimum: 0 }), // 0 = unlimited
|
|
1096
1091
|
consumeCredits: Type.Boolean({ default: false }), // LIVE: reserve→settle against the payments credit ledger (a job-routed generation reserves pre-generation and 402s insufficient_credits)
|
|
1097
1092
|
}, { default: {} }),
|
|
1098
|
-
// `streaming` became an OPTIONAL bag (3 leaves → 1, the
|
|
1093
|
+
// `streaming` became an OPTIONAL bag (3 leaves → 1, the `retry` trick)
|
|
1099
1094
|
// on 2026-09-23 to fund the declared `templates[]` below. It KEEPS
|
|
1100
1095
|
// `default: {}`, so Value.Default still materializes
|
|
1101
1096
|
// streaming.{enabled,replayBufferFrames,flushMs} into every persisted
|
|
@@ -1104,12 +1099,11 @@ export const AiConfigSchema = Type.Object({
|
|
|
1104
1099
|
// here is optional.
|
|
1105
1100
|
streaming: Type.Optional(Type.Object({
|
|
1106
1101
|
enabled: Type.Boolean({ default: true }),
|
|
1107
|
-
replayBufferFrames: Type.Integer({ default: 256, minimum: 1 }), //
|
|
1108
|
-
flushMs: Type.Integer({ default: 50, minimum: 0 }), //
|
|
1102
|
+
replayBufferFrames: Type.Integer({ default: 256, minimum: 1 }), // replay ring-buffer depth
|
|
1103
|
+
flushMs: Type.Integer({ default: 50, minimum: 0 }), // token→frame coalesce window
|
|
1109
1104
|
}, { default: {} })),
|
|
1110
|
-
// DECLARED API STATE (
|
|
1111
|
-
// prompt templates as config. vxil STORES + versions, never authors (
|
|
1112
|
-
// §0) — declaring them here changes WHO writes the row (the repository, via
|
|
1105
|
+
// DECLARED API STATE (2026-09-23): the tenant's stored
|
|
1106
|
+
// prompt templates as config. vxil STORES + versions, never authors — declaring them here changes WHO writes the row (the repository, via
|
|
1113
1107
|
// `vxil push`), not what vxil does with it. Converged by CONTENT: the
|
|
1114
1108
|
// control-plane hashes each declared entry (@vxil/runtime
|
|
1115
1109
|
// aiTemplateContentSha256) against the `content_sha256` GET /v1/ai/templates
|
|
@@ -1118,11 +1112,11 @@ export const AiConfigSchema = Type.Object({
|
|
|
1118
1112
|
// Item shape mirrors ai-v1 core.ts TemplateBody exactly (`template` is the
|
|
1119
1113
|
// name). Stored templates the config does not declare are reported and left
|
|
1120
1114
|
// in place — RETIRED (soft: hidden from list + render, history kept) only
|
|
1121
|
-
// under --allow-destructive (
|
|
1115
|
+
// under --allow-destructive (2026-10-01). Bounded to 50 entries: the
|
|
1122
1116
|
// manifest rides the 1 MiB config body cap. An Optional ARRAY is ONE leaf.
|
|
1123
1117
|
templates: Type.Optional(Type.Array(DeclaredAiTemplateSchema, { maxItems: AI_MAX_DECLARED_TEMPLATES })),
|
|
1124
1118
|
});
|
|
1125
|
-
// rag feature (
|
|
1119
|
+
// rag feature (guide ch. 6, rag). Re-declared to match workers/rag-v1/src/config.ts's
|
|
1126
1120
|
// exported RagConfigSchema. rag owns the PIPELINE knobs only — retrieval budget,
|
|
1127
1121
|
// context budget + strategy + tokenizer, the citation/stream gates — NEVER the
|
|
1128
1122
|
// prompt, the synthesis, or relevance tuning (the tenant's `ai` template owns those).
|
|
@@ -1140,7 +1134,7 @@ export const RagConfigSchema = Type.Object({
|
|
|
1140
1134
|
rerank: Type.Boolean({ default: false }),
|
|
1141
1135
|
}, { default: {} }),
|
|
1142
1136
|
// declarative per-metadata-field relevance boosts applied in rag AFTER
|
|
1143
|
-
// retrieval, BEFORE minScore/budget/grounding (
|
|
1137
|
+
// retrieval, BEFORE minScore/budget/grounding (guide ch. 6, rag). ONE Type.Record
|
|
1144
1138
|
// leaf (the activity-feed feedGroups precedent).
|
|
1145
1139
|
boosts: Type.Record(Type.String(), Type.Union([
|
|
1146
1140
|
Type.Object({
|
|
@@ -1154,13 +1148,13 @@ export const RagConfigSchema = Type.Object({
|
|
|
1154
1148
|
}),
|
|
1155
1149
|
]), { default: {} }),
|
|
1156
1150
|
context: Type.Object({
|
|
1157
|
-
// bounded context budget — enforced via the
|
|
1151
|
+
// bounded context budget — enforced via the tokenizer, BEFORE the ai call.
|
|
1158
1152
|
maxTokens: Type.Integer({ default: 4000, minimum: 1, maximum: 1_000_000 }),
|
|
1159
1153
|
strategy: Type.Union([Type.Literal('topk'), Type.Literal('mmr')], {
|
|
1160
1154
|
default: 'topk',
|
|
1161
1155
|
}),
|
|
1162
1156
|
// 'provider' = the resolved ai provider's tokenizer; 'heuristic' = portable
|
|
1163
|
-
// ~chars/4 with a safety margin
|
|
1157
|
+
// ~chars/4 with a safety margin.
|
|
1164
1158
|
tokenizer: Type.Union([Type.Literal('provider'), Type.Literal('heuristic')], {
|
|
1165
1159
|
default: 'provider',
|
|
1166
1160
|
}),
|
|
@@ -1170,7 +1164,7 @@ export const RagConfigSchema = Type.Object({
|
|
|
1170
1164
|
citations: Type.Boolean({ default: true }),
|
|
1171
1165
|
streaming: Type.Boolean({ default: true }),
|
|
1172
1166
|
});
|
|
1173
|
-
// payments feature (
|
|
1167
|
+
// payments feature (guide ch. 6, payments). Re-declared to match the schema the
|
|
1174
1168
|
// worker EXPORTS from workers/payments-v1/src/core.ts — the control plane
|
|
1175
1169
|
// validates writes against this shared copy (one-definition / two-consumers,
|
|
1176
1170
|
// like the other features). Two co-equal pillars: (A) provider payments (the
|
|
@@ -1186,9 +1180,9 @@ export const PaymentsConfigSchema = Type.Object({
|
|
|
1186
1180
|
// events) so the ENTIRE ledger path is testable WITHOUT real provider keys.
|
|
1187
1181
|
provider: Type.Union([Type.Literal('mock'), Type.Literal('stripe'), Type.Literal('paddle'),
|
|
1188
1182
|
Type.Literal('revenuecat'), Type.Literal('paypal')], { default: 'mock' }),
|
|
1189
|
-
// BYO-key credential blocks →
|
|
1183
|
+
// BYO-key credential blocks → the tenant's encrypted secret store.
|
|
1190
1184
|
// Each OPTIONAL object counts as ONE leaf (the tenant's decision is
|
|
1191
|
-
// "configure it or not", not each inner ref —
|
|
1185
|
+
// "configure it or not", not each inner ref — guide ch. 6, auth).
|
|
1192
1186
|
stripe: Type.Optional(Type.Object({
|
|
1193
1187
|
secretKeyRef: Type.String(),
|
|
1194
1188
|
webhookSecretRef: Type.String(),
|
|
@@ -1203,25 +1197,24 @@ export const PaymentsConfigSchema = Type.Object({
|
|
|
1203
1197
|
projectId: Type.String(),
|
|
1204
1198
|
publicSdkKey: Type.String(),
|
|
1205
1199
|
secretApiKeyRef: Type.String(),
|
|
1206
|
-
// Per-tenant webhook secret ref (
|
|
1200
|
+
// Per-tenant webhook secret ref (secret store). Inbound RevenueCat
|
|
1207
1201
|
// webhooks are verified against THIS ref and nothing else: there is no
|
|
1208
1202
|
// platform-wide PROVIDER_WEBHOOK_SECRET fallback for a real payment provider
|
|
1209
|
-
// (that fallback WAS
|
|
1210
|
-
// frozen out by tests/ci/src/provider-webhook-secret-fallback.test.ts, which
|
|
1203
|
+
// (that fallback WAS a cross-tenant webhook-forgery vector; a CI gate now
|
|
1211
1204
|
// permits `secrets.webhookSecret` only in makeProvider's mock/default arm).
|
|
1212
1205
|
// Optional at the SCHEMA level only — leaving it unset does not disable
|
|
1213
1206
|
// verification, it fails CLOSED: every delivery is 401 bad_signature with a
|
|
1214
1207
|
// `sig_failed` row that can never be reprocessed. Mirrors stripe/paddle
|
|
1215
1208
|
// webhookSecretRef.
|
|
1216
1209
|
webhookSecretRef: Type.Optional(Type.String()),
|
|
1217
|
-
// Environment integrity
|
|
1210
|
+
// Environment integrity. RevenueCat posts SANDBOX
|
|
1218
1211
|
// and PRODUCTION events to the SAME webhook with the same auth header, so a
|
|
1219
1212
|
// sandbox purchase would otherwise fold into production entitlements. A
|
|
1220
1213
|
// sandbox event is persisted as outcome 'rejected_environment' (200, never
|
|
1221
1214
|
// folded) unless the tenant opts in here. Stripe/Paddle/PayPal separate
|
|
1222
1215
|
// environments by signing secret / API base, so only RC carries this knob.
|
|
1223
1216
|
acceptSandbox: Type.Boolean({ default: false }),
|
|
1224
|
-
// (2026-10-01
|
|
1217
|
+
// (2026-10-01) Store-review purchases on a PRODUCTION tenant:
|
|
1225
1218
|
// the reviewer accounts' RevenueCat `app_user_id`s (≤ 20). A SANDBOX event
|
|
1226
1219
|
// whose subject (and, for a TRANSFER, every source user) is listed here
|
|
1227
1220
|
// folds — recorded `environment: 'sandbox'` on the delivery, the
|
|
@@ -1242,9 +1235,9 @@ export const PaymentsConfigSchema = Type.Object({
|
|
|
1242
1235
|
// Where a provider-hosted flow sends the payer back (Stripe billing-portal
|
|
1243
1236
|
// return, PayPal approval return/cancel) — the TENANT's own app URL,
|
|
1244
1237
|
// https-only. Absent ⇒ the worker's WEB_BASE_URL env (vxil's site), never a
|
|
1245
|
-
// hardcoded host (
|
|
1238
|
+
// hardcoded host (2026-07-10: the old fallback pointed at a dead apex).
|
|
1246
1239
|
returnUrl: Type.Optional(Type.String({ pattern: '^https://', maxLength: 512 })),
|
|
1247
|
-
// NB (
|
|
1240
|
+
// NB (2026-09-11): the former `prices.catalogRef` leaf was DELETED —
|
|
1248
1241
|
// it named nothing (prices resolve from ledger.priceMap; no code path ever
|
|
1249
1242
|
// read it). A persisted manifest that still carries `prices` folds:
|
|
1250
1243
|
// validateFeatureConfig's Value.Clean strips the stray key.
|
|
@@ -1259,11 +1252,11 @@ export const PaymentsConfigSchema = Type.Object({
|
|
|
1259
1252
|
// product_id → what the purchase GRANTS. ONE Type.Record leaf (the rag
|
|
1260
1253
|
// `boosts` Record-of-Union precedent) with two rule shapes:
|
|
1261
1254
|
// { creditType, amount, period } a credit grant (the original rule)
|
|
1262
|
-
// { tier, durationDays } (2026-09-25
|
|
1255
|
+
// { tier, durationDays } (2026-09-25) a TIME-BOXED
|
|
1263
1256
|
// ENTITLEMENT: the buyer gets `tier` (a tierMap key — cross-checked
|
|
1264
1257
|
// below) for `durationDays`, as a charge-linked manual-style row that
|
|
1265
1258
|
// STACKS behind the user's live same-tier manual rows that have an end
|
|
1266
|
-
// (earlier passes AND comp grants since 2026-09-25
|
|
1259
|
+
// (earlier passes AND comp grants since 2026-09-25 — never a row
|
|
1267
1260
|
// linked to the same charge, an open-ended grant or a provider
|
|
1268
1261
|
// subscription) and is ENDED by that charge's full refund / chargeback.
|
|
1269
1262
|
// No defaults in either shape, so an existing manifest is
|
|
@@ -1271,7 +1264,7 @@ export const PaymentsConfigSchema = Type.Object({
|
|
|
1271
1264
|
productMap: Type.Record(Type.String(), Type.Union([
|
|
1272
1265
|
Type.Object({
|
|
1273
1266
|
creditType: Type.String({ minLength: 1 }),
|
|
1274
|
-
amount: Type.Integer({ minimum: 1 }), //
|
|
1267
|
+
amount: Type.Integer({ minimum: 1 }), // a grant only ADDS
|
|
1275
1268
|
period: Type.Union([Type.Literal('once'), Type.Literal('monthly'),
|
|
1276
1269
|
Type.Literal('annual')]),
|
|
1277
1270
|
}),
|
|
@@ -1282,13 +1275,13 @@ export const PaymentsConfigSchema = Type.Object({
|
|
|
1282
1275
|
])),
|
|
1283
1276
|
tierMap: Type.Record(Type.String(), Type.Object({
|
|
1284
1277
|
entitlements: Type.Array(Type.String()),
|
|
1285
|
-
quotas: Type.Record(Type.String(), Type.Integer({ minimum: 0 })), //
|
|
1286
|
-
rank: Type.Optional(Type.Integer({ minimum: 0 })), // precedence for the multi-sub fold
|
|
1278
|
+
quotas: Type.Record(Type.String(), Type.Integer({ minimum: 0 })), // no negative quota
|
|
1279
|
+
rank: Type.Optional(Type.Integer({ minimum: 0 })), // precedence for the multi-sub fold
|
|
1287
1280
|
grants: Type.Optional(Type.Array(Type.Object({
|
|
1288
1281
|
creditType: Type.String({ minLength: 1 }),
|
|
1289
|
-
amount: Type.Integer({ minimum: 1 }), //
|
|
1282
|
+
amount: Type.Integer({ minimum: 1 }), // a grant only ADDS
|
|
1290
1283
|
period: Type.String(),
|
|
1291
|
-
// (2026-10-01
|
|
1284
|
+
// (2026-10-01) 'add' (the reader's default, today's
|
|
1292
1285
|
// behaviour) ADDS `amount` each period; 'reset' makes the period's
|
|
1293
1286
|
// grant REPLACE what is left: the unspent available balance of
|
|
1294
1287
|
// `creditType` is written off as one `expire` ledger row and `amount`
|
|
@@ -1304,7 +1297,7 @@ export const PaymentsConfigSchema = Type.Object({
|
|
|
1304
1297
|
// fold (refoldEntitlements WHERE tier IS NOT NULL) reflects the subscription.
|
|
1305
1298
|
priceMap: Type.Optional(Type.Record(Type.String(), Type.String())),
|
|
1306
1299
|
autoRefundOnJobFailure: Type.Boolean({ default: true }), // consume(jobId) reverses on DLQ/timeout
|
|
1307
|
-
// Grace window
|
|
1300
|
+
// Grace window: a `past_due` subscription stays
|
|
1308
1301
|
// entitled for this many days AFTER its current_period_end (the dunning
|
|
1309
1302
|
// window the provider is retrying inside). 0 = today's behaviour (a past_due
|
|
1310
1303
|
// row is never entitled). ONE predicate in the fold — NOT a dunning ladder:
|
|
@@ -1312,8 +1305,7 @@ export const PaymentsConfigSchema = Type.Object({
|
|
|
1312
1305
|
grace: Type.Optional(Type.Object({
|
|
1313
1306
|
pastDueDays: Type.Integer({ default: 0, minimum: 0, maximum: 90 }),
|
|
1314
1307
|
})),
|
|
1315
|
-
// Opt-in period-end enforcement (
|
|
1316
|
-
// option a). ABSENT (the default) = today's behaviour: a subscription whose
|
|
1308
|
+
// Opt-in period-end enforcement. ABSENT (the default) = today's behaviour: a subscription whose
|
|
1317
1309
|
// current_period_end passed with no provider event stays entitled forever
|
|
1318
1310
|
// (the provider is the only clock). PRESENT = the nightly reconcile sweep
|
|
1319
1311
|
// flips an `active`/`trialing` row whose current_period_end + slackHours
|
|
@@ -1348,28 +1340,28 @@ export const PaymentsConfigSchema = Type.Object({
|
|
|
1348
1340
|
// (`config.ledger?.unmappedProduct ?? 'error'`), which is the one definition.
|
|
1349
1341
|
unmappedProduct: Type.Optional(Type.Union([Type.Literal('error'), Type.Literal('ignore')])),
|
|
1350
1342
|
})),
|
|
1351
|
-
// NB
|
|
1343
|
+
// NB: the former `webhooks.forwardToTenantUrl` leaf
|
|
1352
1344
|
// was DELETED — it had zero readers (never forwarded anything). Outbound
|
|
1353
|
-
// delivery of payments state changes rides the
|
|
1354
|
-
//
|
|
1345
|
+
// delivery of payments state changes rides the audit stream → outbound
|
|
1346
|
+
// webhooks: subscribe to the `payments.` event prefix (guide ch. 6, payments).
|
|
1355
1347
|
});
|
|
1356
|
-
// functions feature (
|
|
1348
|
+
// functions feature (guide ch. 8). Tenant-deployed backend edge
|
|
1357
1349
|
// functions on the managed serverless runtime. The FUNCTION owns its identity (bundle via
|
|
1358
1350
|
// scriptRef, scopes, secrets, egress, limits, runtime) + a SET of trigger
|
|
1359
1351
|
// bindings; every other surface (e.g. cms.hooks) REFERENCES a function BY NAME and
|
|
1360
1352
|
// never re-embeds deploy config. The per-function bag is ONE Type.Record leaf
|
|
1361
1353
|
// (cms.hooks / payments.ledger precedent), so any number of deployed functions
|
|
1362
|
-
// never grows the flag cap.
|
|
1354
|
+
// never grows the flag cap. Tenant code on the platform — paid, tier-walled,
|
|
1363
1355
|
// opt-in (enabled defaults to false), egress-guarded.
|
|
1364
1356
|
export const FunctionsConfigSchema = Type.Object({
|
|
1365
1357
|
enabled: Type.Boolean({ default: false }),
|
|
1366
|
-
// (
|
|
1367
|
-
// is
|
|
1358
|
+
// (2026-09-11) `runtime` ('isolate' | 'container') was DELETED: the container lane
|
|
1359
|
+
// is not built, nothing read the leaf, and accepting 'container' silently
|
|
1368
1360
|
// ran the isolate anyway. It comes back with the lane, not before.
|
|
1369
1361
|
defaultLimits: Type.Object({
|
|
1370
1362
|
// cpuMs is the ONLY per-dispatch limit the managed runtime accepts and the
|
|
1371
1363
|
// only one anything reads (functions-v1 meter.ts + the dispatch cap).
|
|
1372
|
-
// (
|
|
1364
|
+
// (2026-09-11) `timeoutMs` and `memoryMb` were DELETED: memory is fixed by the
|
|
1373
1365
|
// runtime and not tenant-selectable, and no wall-clock abort was ever
|
|
1374
1366
|
// applied — a declared 10s default that nothing enforced.
|
|
1375
1367
|
cpuMs: Type.Integer({ default: 50, minimum: 5, maximum: 300_000 }),
|
|
@@ -1410,7 +1402,7 @@ export const FunctionsConfigSchema = Type.Object({
|
|
|
1410
1402
|
source: Type.Optional(Type.String()), // webhook/queue: source/queue id
|
|
1411
1403
|
collection: Type.Optional(Type.String()), // cmsHook: the CMS collection slug
|
|
1412
1404
|
event: Type.Optional(Type.String()), // cmsHook: beforeCreate|beforeUpdate|beforeWrite · authHook: 'user.created'
|
|
1413
|
-
//
|
|
1405
|
+
// (2026-09-25) the per-binding opt-in to re-delivery on
|
|
1414
1406
|
// queue / webhook / cmsHook / authHook (the cross-field rule
|
|
1415
1407
|
// rejects it on http / cron). Absent = the ACK-200 default. The
|
|
1416
1408
|
// receiver answers a failed attempt as an enveloped 503 (ladder)
|
|
@@ -1434,7 +1426,7 @@ export const FunctionsConfigSchema = Type.Object({
|
|
|
1434
1426
|
// the settings it was deployed and tested with, not today's. Absent =
|
|
1435
1427
|
// the legacy settings (@vxil/types FUNCTIONS_RUNTIME_LEGACY). Unbounded
|
|
1436
1428
|
// strings on purpose (the deploy writes them from the one constant).
|
|
1437
|
-
// cpuMs (
|
|
1429
|
+
// cpuMs (2026-10-01): the per-invoke CPU limit the script was
|
|
1438
1430
|
// uploaded with (limits.cpu_ms = min(declared limits.cpuMs, the tier's
|
|
1439
1431
|
// cpuMsPerInvoke, FN_MAX_CPU_MS)) — server-set; the nightly plan pass
|
|
1440
1432
|
// rewrites it after a tier change. Absent = the platform default.
|
|
@@ -1473,10 +1465,9 @@ export const FunctionsConfigSchema = Type.Object({
|
|
|
1473
1465
|
// egress guard as an outbound parameter. NOT an invocation
|
|
1474
1466
|
// budget: the INVOCATION is bounded by the platform's own
|
|
1475
1467
|
// FN_MAX_INVOKE_MS deadline (default >= 5 min), which a
|
|
1476
|
-
// bigger per-fetch budget widens with you
|
|
1477
|
-
// (
|
|
1478
|
-
//
|
|
1479
|
-
// per-dispatch option; the WfP dispatch bag takes { cpuMs, subRequests }.
|
|
1468
|
+
// bigger per-fetch budget widens with you.
|
|
1469
|
+
// (`memoryMb` is deleted — memory is fixed by the managed runtime and is
|
|
1470
|
+
// not a per-dispatch option; a dispatch takes { cpuMs, subRequests }.
|
|
1480
1471
|
// Value.Clean strips it from an old config, so such a config still loads
|
|
1481
1472
|
// and `vxil plan --explain` marks the key DROPPED.)
|
|
1482
1473
|
limits: Type.Optional(Type.Object({
|
|
@@ -1484,7 +1475,7 @@ export const FunctionsConfigSchema = Type.Object({
|
|
|
1484
1475
|
timeoutMs: Type.Optional(Type.Integer()),
|
|
1485
1476
|
})),
|
|
1486
1477
|
enabled: Type.Optional(Type.Boolean()),
|
|
1487
|
-
// Level-1 typed I/O (
|
|
1478
|
+
// Level-1 typed I/O (guide ch. 8): the declared input/output
|
|
1488
1479
|
// contract, persisted by the deploy body so ONLINE `vxil gen` emits the
|
|
1489
1480
|
// same typed fn client as --offline. Opaque JSON-schema-ish payloads —
|
|
1490
1481
|
// the CLI's lowerSig lowers them; the platform never interprets them.
|
|
@@ -1558,14 +1549,14 @@ export const CopilotConfigSchema = Type.Object({
|
|
|
1558
1549
|
guestToolAllow: Type.Optional(Type.Array(Type.String({ maxLength: 64 }), { maxItems: 16, default: [] })),
|
|
1559
1550
|
})),
|
|
1560
1551
|
}), { default: {} }),
|
|
1561
|
-
// (
|
|
1552
|
+
// (2026-09-11) the `escalation` bag ({enabled, handler, notifyTemplate}) was
|
|
1562
1553
|
// DELETED: the human hand-off it declared was never built — copilot-v1 read
|
|
1563
1554
|
// none of the three leaves, so a tenant who turned it on got silence. The
|
|
1564
1555
|
// shipped hand-off path is a tenant function on the conversation events.
|
|
1565
1556
|
// ── limits: DELEGATE token/credit accounting to ai-v1 ─────────────────────
|
|
1566
1557
|
limits: Type.Object({
|
|
1567
1558
|
consumeCredits: Type.Boolean({ default: false }),
|
|
1568
|
-
// (
|
|
1559
|
+
// (2026-09-11) `tokensPerUserPerDay` was DELETED here: token accounting is
|
|
1569
1560
|
// delegated to ai-v1 (this bag's own doctrine) and only `ai`'s
|
|
1570
1561
|
// limits.tokensPerUserPerDay is enforced — the copilot twin read nothing.
|
|
1571
1562
|
}, { default: {} }),
|
|
@@ -1599,11 +1590,11 @@ export const FEATURE_SCHEMAS = {
|
|
|
1599
1590
|
copilot: CopilotConfigSchema,
|
|
1600
1591
|
};
|
|
1601
1592
|
export const CONFIG_FLAG_CAP = 15;
|
|
1602
|
-
/** Counts leaf flags in a TypeBox object schema
|
|
1603
|
-
* Per
|
|
1593
|
+
/** Counts leaf flags in a TypeBox object schema.
|
|
1594
|
+
* Per guide ch. 6, auth: an OPTIONAL object (e.g. a provider credential
|
|
1604
1595
|
* block) counts as ONE flag — the tenant's decision is "configure it or
|
|
1605
1596
|
* not", not each inner ref. */
|
|
1606
|
-
/** The auth lifecycle events an `authHook` binding may name
|
|
1597
|
+
/** The auth lifecycle events an `authHook` binding may name — the
|
|
1607
1598
|
* closed union `packages/config` types as AuthHookEvent; the control-plane
|
|
1608
1599
|
* reconciler maps each to its `auth.<event>` audit-event prefix. */
|
|
1609
1600
|
export const AUTH_HOOK_EVENTS = ['user.created', 'session.created', 'session.revoked', 'signin.failure'];
|
|
@@ -1614,7 +1605,7 @@ export const AUTH_HOOK_EVENTS = ['user.created', 'session.created', 'session.rev
|
|
|
1614
1605
|
* else is refused at config write (E-CMSHOOK, 2026-10-01): an unknown name used
|
|
1615
1606
|
* to fall back to beforeWrite at delivery, so a typo like 'afterCreate' or
|
|
1616
1607
|
* 'beforeDelete' silently subscribed the function to creates AND updates.
|
|
1617
|
-
*
|
|
1608
|
+
* A CI gate pins every copy to this list. */
|
|
1618
1609
|
export const CMS_HOOK_EVENTS = ['beforeCreate', 'beforeUpdate', 'beforeWrite'];
|
|
1619
1610
|
/** The ONE refusal text for an unknown cmsHook binding event (the config
|
|
1620
1611
|
* validator and the deploy route's early 422 both use it). */
|
|
@@ -1625,7 +1616,7 @@ export function cmsHookEventError(event) {
|
|
|
1625
1616
|
return null;
|
|
1626
1617
|
return `a 'cmsHook' binding's event must be one of ${CMS_HOOK_EVENTS.join(' | ')} (or omitted = beforeWrite), not ${JSON.stringify(event)}`;
|
|
1627
1618
|
}
|
|
1628
|
-
/**
|
|
1619
|
+
/** The OTP test-recipient entry grammar (shared by the validator and auth-v1's
|
|
1629
1620
|
* matcher): an exact email, a `*@domain` glob, or a +E.164 phone number. */
|
|
1630
1621
|
export const TEST_RECIPIENT_EMAIL_RE = /^[^\s@*]+@[^\s@]+\.[^\s@]+$/;
|
|
1631
1622
|
export const TEST_RECIPIENT_GLOB_RE = /^\*@[^\s@*]+\.[^\s@*]+$/;
|
|
@@ -1678,7 +1669,7 @@ export function setKnownMcpTools(names) {
|
|
|
1678
1669
|
knownMcpTools = new Set(names);
|
|
1679
1670
|
}
|
|
1680
1671
|
// ── mcp custom-tool / prompt caps + the pure public-https check ──────────────
|
|
1681
|
-
// (
|
|
1672
|
+
// (guide ch. 10) Caps are deliberately tighter than the 200-tool listing cap:
|
|
1682
1673
|
// each custom tool is a platform-signed egress target, so the bag stays small.
|
|
1683
1674
|
export const MCP_MAX_CUSTOM_TOOLS = 32;
|
|
1684
1675
|
export const MCP_MAX_PROMPTS = 32;
|
|
@@ -1734,7 +1725,7 @@ function publicHttpsUrlError(url) {
|
|
|
1734
1725
|
* stays ALLOWED (fn→fn composition). Source of truth for both the config-write
|
|
1735
1726
|
* validation below and the control-plane deploy clamp. */
|
|
1736
1727
|
export const DENY_FUNCTION_SCOPES = new Set(['admin', '*', 'features:write', 'functions:write', 'secrets:write']);
|
|
1737
|
-
// ── declared API state — config-write validators
|
|
1728
|
+
// ── declared API state — config-write validators ────────────────────────────
|
|
1738
1729
|
/** `{var}` names of a rate-limit key template (rate-limits-v1 core.ts
|
|
1739
1730
|
* templateVars parity). */
|
|
1740
1731
|
export function rlTemplateVars(template) {
|
|
@@ -1828,12 +1819,12 @@ export function validateFeatureConfig(feature, raw) {
|
|
|
1828
1819
|
return { ok: false, errors: [`schema for '${feature}' exceeds the ${CONFIG_FLAG_CAP}-flag cap`] };
|
|
1829
1820
|
}
|
|
1830
1821
|
// Apply defaults to a clone, then STRIP any property the schema does not
|
|
1831
|
-
// declare, then check. Value.Clean makes the validator TOTAL
|
|
1822
|
+
// declare, then check. Value.Clean makes the validator TOTAL:
|
|
1832
1823
|
// the schemas are open Type.Object()s, so without it Value.Check passes on —
|
|
1833
1824
|
// and putConfig would persist — arbitrary unknown keys. Clean runs AFTER
|
|
1834
1825
|
// Default so materialized nested defaults survive but stray top-level/nested
|
|
1835
1826
|
// keys are dropped. This also removes the CLI dry-run idempotency drift
|
|
1836
|
-
//
|
|
1827
|
+
// too: plan/push diff the same cleaned manifest the server stores.
|
|
1837
1828
|
const withDefaults = Value.Clean(schema, Value.Default(schema, Value.Clone(raw)));
|
|
1838
1829
|
if (!Value.Check(schema, withDefaults)) {
|
|
1839
1830
|
const errors = [...Value.Errors(schema, withDefaults)].map((e) => `${e.path || '/'}: ${e.message}`);
|
|
@@ -1865,7 +1856,7 @@ export function validateFeatureConfig(feature, raw) {
|
|
|
1865
1856
|
}
|
|
1866
1857
|
// Cross-field rule: a REAL payments provider needs its credential block; the
|
|
1867
1858
|
// 'mock' provider (the deterministic default) stays zero-config so the whole
|
|
1868
|
-
// ledger path is testable without real keys (
|
|
1859
|
+
// ledger path is testable without real keys (guide ch. 6, payments).
|
|
1869
1860
|
if (feature === 'payments') {
|
|
1870
1861
|
const v = withDefaults;
|
|
1871
1862
|
const needsBlock = {
|
|
@@ -1880,7 +1871,7 @@ export function validateFeatureConfig(feature, raw) {
|
|
|
1880
1871
|
}
|
|
1881
1872
|
// A reserved (vxil-COGS) credit_type must NEVER appear in a ledger grant map:
|
|
1882
1873
|
// the webhook/subscription reducers would otherwise credit `fn_cpu_ms` to a
|
|
1883
|
-
// user, running vxil-billed functions for free
|
|
1874
|
+
// user, running vxil-billed functions for free. Rejected at write
|
|
1884
1875
|
// time so the tenant gets a clear `vxil push` error, not a silent runtime skip.
|
|
1885
1876
|
const ledgerErrs = [];
|
|
1886
1877
|
const tierKeysForProducts = new Set(Object.keys(v.ledger?.tierMap ?? {}));
|
|
@@ -1888,7 +1879,7 @@ export function validateFeatureConfig(feature, raw) {
|
|
|
1888
1879
|
if (rule.creditType && isReservedCreditType(rule.creditType)) {
|
|
1889
1880
|
ledgerErrs.push(`/ledger/productMap/${productId}/creditType: '${rule.creditType}' is a reserved vxil-COGS credit type and cannot be granted via config`);
|
|
1890
1881
|
}
|
|
1891
|
-
// (2026-09-25
|
|
1882
|
+
// (2026-09-25) an entitlement rule must name a declared tier — the
|
|
1892
1883
|
// write-time mirror of the runtime's unknown-tier refusal (a purchase for
|
|
1893
1884
|
// a tier nobody declared would land the delivery `error`).
|
|
1894
1885
|
if (rule.tier !== undefined && !tierKeysForProducts.has(rule.tier)) {
|
|
@@ -1933,7 +1924,7 @@ export function validateFeatureConfig(feature, raw) {
|
|
|
1933
1924
|
ledgerErrs.push(`/ledger/productMap/${productId}/creditType: '${rule.creditType}' is reset each period by ${by} (mode 'reset' writes off purchased credits of that type) — sell packs on their own credit type and spend with credit_types`);
|
|
1934
1925
|
}
|
|
1935
1926
|
}
|
|
1936
|
-
//
|
|
1927
|
+
// An UNMAPPED price silently revoked a paying
|
|
1937
1928
|
// customer (priceMap miss → tier NULL → refold excluded the row). The
|
|
1938
1929
|
// reducer now stamps such an event outcome 'error' (reprocessable), and
|
|
1939
1930
|
// this lint catches the config half at `vxil push` time: every priceMap
|
|
@@ -1981,7 +1972,7 @@ export function validateFeatureConfig(feature, raw) {
|
|
|
1981
1972
|
if (rmErrors.length)
|
|
1982
1973
|
return { ok: false, errors: rmErrors.slice(0, 10) };
|
|
1983
1974
|
}
|
|
1984
|
-
// Cross-field rules: mcp custom tools + prompts (
|
|
1975
|
+
// Cross-field rules: mcp custom tools + prompts (guide ch. 10). The URL
|
|
1985
1976
|
// check here is a PURE mirror of @vxil/runtime assertPublicHttpsUrl (this
|
|
1986
1977
|
// package is typebox-only) — the authoritative runtime guard re-runs in
|
|
1987
1978
|
// mcp-v1 at call time; this gate rejects obviously-internal targets BEFORE
|
|
@@ -2046,7 +2037,7 @@ export function validateFeatureConfig(feature, raw) {
|
|
|
2046
2037
|
if (tplErrs.length)
|
|
2047
2038
|
return { ok: false, errors: tplErrs.slice(0, 10) };
|
|
2048
2039
|
}
|
|
2049
|
-
// Cross-field rules: declared API state
|
|
2040
|
+
// Cross-field rules: declared API state. Each list is
|
|
2050
2041
|
// converged by NAME/URL, so a duplicate key is ambiguous and refused at push;
|
|
2051
2042
|
// the per-item rules mirror the feature route's own validation so a declared
|
|
2052
2043
|
// entry can never be one the converge would 422 on.
|
|
@@ -2062,7 +2053,7 @@ export function validateFeatureConfig(feature, raw) {
|
|
|
2062
2053
|
if (errs.length)
|
|
2063
2054
|
return { ok: false, errors: errs.slice(0, 10) };
|
|
2064
2055
|
}
|
|
2065
|
-
// Cross-field rule: auth otp.testRecipients
|
|
2056
|
+
// Cross-field rule: auth otp.testRecipients — every entry must be an
|
|
2066
2057
|
// email, an `*@domain` glob, or a +E.164 number; anything else would never
|
|
2067
2058
|
// match and silently do nothing.
|
|
2068
2059
|
if (feature === 'auth') {
|
|
@@ -2107,7 +2098,7 @@ export function validateFeatureConfig(feature, raw) {
|
|
|
2107
2098
|
if (b.overlap !== undefined && b.kind !== 'cron') {
|
|
2108
2099
|
errs.push(`/functions/${name}/bindings/${i}: 'overlap' applies to cron bindings only (not '${b.kind}')`);
|
|
2109
2100
|
}
|
|
2110
|
-
//
|
|
2101
|
+
// retry is an opt-in for the platform-delivered event lanes only —
|
|
2111
2102
|
// an http invoke returns its real status to its caller, and a cron
|
|
2112
2103
|
// tick's retry would overlap the next tick.
|
|
2113
2104
|
if (b.retry !== undefined && !FN_RETRY_BINDING_KINDS.has(b.kind)) {
|
|
@@ -2121,7 +2112,7 @@ export function validateFeatureConfig(feature, raw) {
|
|
|
2121
2112
|
const cmsEventErr = b.kind === 'cmsHook' ? cmsHookEventError(b.event) : null;
|
|
2122
2113
|
if (cmsEventErr)
|
|
2123
2114
|
errs.push(`/functions/${name}/bindings/${i}: ${cmsEventErr}`);
|
|
2124
|
-
// authHook: a CLOSED event union
|
|
2115
|
+
// authHook: a CLOSED event union — reject typos at write time
|
|
2125
2116
|
// so a binding never silently subscribes to nothing.
|
|
2126
2117
|
if (b.kind === 'authHook' && b.event !== undefined && !AUTH_HOOK_EVENTS.includes(b.event)) {
|
|
2127
2118
|
errs.push(`/functions/${name}/bindings/${i}: an 'authHook' binding's event must be one of ${AUTH_HOOK_EVENTS.join(' | ')} (or omitted = user.created)`);
|