@cosmicdrift/kumiko-framework 0.290.0 → 0.292.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/package.json +4 -4
  2. package/src/__tests__/pii-personal-migration-report-codemod.test.ts +160 -0
  3. package/src/api/__tests__/server-error-logging.test.ts +168 -17
  4. package/src/api/request-context.ts +3 -0
  5. package/src/api/request-id-middleware.ts +2 -1
  6. package/src/api/routes.ts +35 -3
  7. package/src/changes.json +63 -0
  8. package/src/crypto/__tests__/event-pii.test.ts +110 -9
  9. package/src/crypto/__tests__/subject-resolver.test.ts +23 -2
  10. package/src/crypto/subject-resolver.ts +25 -8
  11. package/src/db/queries/shadow-swap.ts +35 -0
  12. package/src/engine/__tests__/boot-validator-pii-retention.test.ts +122 -0
  13. package/src/engine/__tests__/boot-validator-projection-list.test.ts +93 -0
  14. package/src/engine/__tests__/boot-validator.test.ts +226 -0
  15. package/src/engine/__tests__/build-app-schema.test.ts +18 -0
  16. package/src/engine/__tests__/engine.test.ts +87 -0
  17. package/src/engine/__tests__/form-money-currency-types.test.ts +90 -0
  18. package/src/engine/boot-validator/entity-handler.ts +44 -0
  19. package/src/engine/boot-validator/index.ts +10 -4
  20. package/src/engine/boot-validator/pii-retention.ts +8 -0
  21. package/src/engine/boot-validator/projection-list-screens.ts +52 -2
  22. package/src/engine/boot-validator/screens.ts +50 -0
  23. package/src/engine/create-app.ts +54 -0
  24. package/src/engine/extension-names.ts +10 -0
  25. package/src/engine/feature-config-events-jobs.ts +19 -0
  26. package/src/engine/index.ts +3 -0
  27. package/src/engine/screen-helpers.ts +1 -0
  28. package/src/engine/system-user.ts +3 -5
  29. package/src/event-store/__tests__/backfill-pii.integration.test.ts +30 -6
  30. package/src/files/provider-resolver.ts +9 -2
  31. package/src/i18n/required-surface-keys.ts +1 -0
  32. package/src/jobs/__tests__/job-last-success.integration.test.ts +135 -0
  33. package/src/jobs/index.ts +7 -1
  34. package/src/jobs/job-runner.ts +94 -4
  35. package/src/logging/utils.ts +14 -1
  36. package/src/observability/index.ts +1 -0
  37. package/src/observability/standard-metrics.ts +20 -0
  38. package/src/pipeline/__tests__/blind-index-rebuild-guard.integration.test.ts +96 -0
  39. package/src/pipeline/projection-rebuild.ts +7 -0
  40. package/src/schema-cli.ts +21 -0
  41. package/src/scripts/codemod/pii-personal-migration.ts +242 -2
  42. package/src/ui-types/list-row-meta.ts +4 -1
@@ -30,6 +30,12 @@ const attemptSchema = z.object({
30
30
  status: z.string(),
31
31
  });
32
32
 
33
+ const requiredOwnerSchema = z.object({
34
+ recipientId: z.string(),
35
+ recipientAddress: z.string().nullable(),
36
+ status: z.string(),
37
+ });
38
+
33
39
  const EVENT_TYPE = "mailer:event:attempt";
34
40
 
35
41
  const ENVELOPE: EventSubjectEnvelope = {
@@ -54,18 +60,28 @@ describe("normalizeEventPiiSubject", () => {
54
60
  expect(normalizeEventPiiSubject({ personal: { of: "recipientId" } })).toEqual({
55
61
  kind: "user",
56
62
  ownerField: "recipientId",
63
+ whenAbsent: undefined,
57
64
  });
58
65
  expect(normalizeEventPiiSubject({ subjectField: "recipientId" })).toEqual({
59
66
  kind: "user",
60
67
  ownerField: "recipientId",
68
+ whenAbsent: undefined,
61
69
  });
62
70
  });
71
+
72
+ test("whenAbsent rides along on the canonical form", () => {
73
+ expect(
74
+ normalizeEventPiiSubject({ personal: { of: "recipientId", whenAbsent: "tenant" } }),
75
+ ).toEqual({ kind: "user", ownerField: "recipientId", whenAbsent: "tenant" });
76
+ });
63
77
  });
64
78
 
65
79
  describe("defineEvent piiFields validation", () => {
66
80
  test("valid piiFields land on the EventDef and in the registry catalog", () => {
81
+ // The deprecated subjectField form cannot express whenAbsent, so it only
82
+ // registers against a schema whose owner field is always populated.
67
83
  const feature = defineFeature("mailer", (r) => {
68
- r.defineEvent("attempt", attemptSchema, {
84
+ r.defineEvent("attempt", requiredOwnerSchema, {
69
85
  piiFields: { recipientAddress: { subjectField: "recipientId" } },
70
86
  });
71
87
  });
@@ -108,12 +124,12 @@ describe("defineEvent piiFields validation", () => {
108
124
  test("valid canonical personal.of piiFields land on the EventDef and in the registry catalog", () => {
109
125
  const feature = defineFeature("mailer", (r) => {
110
126
  r.defineEvent("attempt", attemptSchema, {
111
- piiFields: { recipientAddress: { personal: { of: "recipientId" } } },
127
+ piiFields: { recipientAddress: { personal: { of: "recipientId", whenAbsent: "tenant" } } },
112
128
  });
113
129
  });
114
130
  createRegistry([feature]);
115
131
  expect(configuredEventPiiCatalog().get(EVENT_TYPE)).toEqual({
116
- recipientAddress: { personal: { of: "recipientId" } },
132
+ recipientAddress: { personal: { of: "recipientId", whenAbsent: "tenant" } },
117
133
  });
118
134
  });
119
135
 
@@ -206,6 +222,41 @@ describe("defineEvent piiFields validation", () => {
206
222
  }),
207
223
  ).toThrow(/piiFields references "nope"/);
208
224
  });
225
+
226
+ test("a nullable owner field without a whenAbsent stance fails registration", () => {
227
+ expect(() =>
228
+ defineFeature("mailer", (r) => {
229
+ r.defineEvent("attempt", attemptSchema, {
230
+ piiFields: { recipientAddress: { personal: { of: "recipientId" } } },
231
+ });
232
+ }),
233
+ ).toThrow(/allows to be null\/undefined/);
234
+ });
235
+
236
+ test("a nullable owner field with a declared whenAbsent registers", () => {
237
+ const feature = defineFeature("mailer", (r) => {
238
+ r.defineEvent("attempt", attemptSchema, {
239
+ piiFields: { recipientAddress: { personal: { of: "recipientId", whenAbsent: "tenant" } } },
240
+ });
241
+ });
242
+ expect(feature.events["attempt"]?.piiFields).toEqual({
243
+ recipientAddress: { personal: { of: "recipientId", whenAbsent: "tenant" } },
244
+ });
245
+ });
246
+
247
+ test("a non-nullable owner field needs no whenAbsent", () => {
248
+ const required = z.object({
249
+ recipientId: z.string(),
250
+ recipientAddress: z.string(),
251
+ });
252
+ expect(() =>
253
+ defineFeature("mailer", (r) => {
254
+ r.defineEvent("attempt", required, {
255
+ piiFields: { recipientAddress: { personal: { of: "recipientId" } } },
256
+ });
257
+ }),
258
+ ).not.toThrow();
259
+ });
209
260
  });
210
261
 
211
262
  describe("encryptEventPayloadPii", () => {
@@ -255,17 +306,67 @@ describe("encryptEventPayloadPii", () => {
255
306
  expect(String(canonical["recipientAddress"])).toContain("user:u-1");
256
307
  });
257
308
 
258
- test("null subject field → value stays plaintext (no user key to shred)", async () => {
309
+ const systemPayload = {
310
+ recipientId: null,
311
+ recipientAddress: "ops@example.com",
312
+ status: "sent",
313
+ };
314
+
315
+ test("null subject field without a whenAbsent stance fails the append closed", async () => {
259
316
  catalogWithAttempt();
260
317
  configurePiiSubjectKms(new InMemoryKmsAdapter());
261
- const systemPayload = {
262
- recipientId: null,
263
- recipientAddress: "ops@example.com",
264
- status: "sent",
265
- };
318
+ expect(encryptEventPayloadPii(EVENT_TYPE, systemPayload, ENVELOPE)).rejects.toThrow(
319
+ /carries no id and the event declares no whenAbsent fallback/,
320
+ );
321
+ });
322
+
323
+ test('null subject field with whenAbsent: "tenant" encrypts under the envelope tenant key', async () => {
324
+ configureEventPiiCatalog(
325
+ new Map([
326
+ [
327
+ EVENT_TYPE,
328
+ { recipientAddress: { personal: { of: "recipientId", whenAbsent: "tenant" } } },
329
+ ],
330
+ ]),
331
+ );
332
+ const kms = new InMemoryKmsAdapter();
333
+ configurePiiSubjectKms(kms);
334
+
335
+ const out = await encryptEventPayloadPii(EVENT_TYPE, systemPayload, ENVELOPE);
336
+ expect(isPiiCiphertext(out["recipientAddress"])).toBe(true);
337
+ expect(String(out["recipientAddress"])).toContain(`tenant:${ENVELOPE.tenantId}`);
338
+
339
+ const back = await decryptPiiFieldValues(out, ["recipientAddress"], kms, { requestId: "test" });
340
+ expect(back["recipientAddress"]).toBe("ops@example.com");
341
+ });
342
+
343
+ test('null subject field with whenAbsent: "plaintext" is an acknowledged passthrough', async () => {
344
+ configureEventPiiCatalog(
345
+ new Map([
346
+ [
347
+ EVENT_TYPE,
348
+ { recipientAddress: { personal: { of: "recipientId", whenAbsent: "plaintext" } } },
349
+ ],
350
+ ]),
351
+ );
352
+ configurePiiSubjectKms(new InMemoryKmsAdapter());
266
353
  expect(await encryptEventPayloadPii(EVENT_TYPE, systemPayload, ENVELOPE)).toBe(systemPayload);
267
354
  });
268
355
 
356
+ test('whenAbsent: "tenant" still prefers the user key when the owner field is populated', async () => {
357
+ configureEventPiiCatalog(
358
+ new Map([
359
+ [
360
+ EVENT_TYPE,
361
+ { recipientAddress: { personal: { of: "recipientId", whenAbsent: "tenant" } } },
362
+ ],
363
+ ]),
364
+ );
365
+ configurePiiSubjectKms(new InMemoryKmsAdapter());
366
+ const out = await encryptEventPayloadPii(EVENT_TYPE, payload, ENVELOPE);
367
+ expect(String(out["recipientAddress"])).toContain("user:u-1");
368
+ });
369
+
269
370
  test("null pii value passes through", async () => {
270
371
  catalogWithAttempt();
271
372
  configurePiiSubjectKms(new InMemoryKmsAdapter());
@@ -154,16 +154,37 @@ describe("resolveEventSubject (fw#2801)", () => {
154
154
  expect(subject).toEqual({ kind: "user", userId: UUID_A });
155
155
  });
156
156
 
157
- test("personal: { of } with a missing owner value → null, no throw (system-triggered event)", () => {
157
+ test("personal: { of } with a missing owner value and no whenAbsent → throws (fw#2776)", () => {
158
+ expect(() =>
159
+ resolveEventSubject(
160
+ "note",
161
+ { personal: { of: "authorId" } },
162
+ { authorId: null },
163
+ { tenantId: EVENT_TENANT, aggregateType: "note", aggregateId: UUID_B },
164
+ ),
165
+ ).toThrow(/carries no id and the event declares no whenAbsent fallback/);
166
+ });
167
+
168
+ test('personal: { of, whenAbsent: "plaintext" } with a missing owner → null (fw#2776)', () => {
158
169
  const subject = resolveEventSubject(
159
170
  "note",
160
- { personal: { of: "authorId" } },
171
+ { personal: { of: "authorId", whenAbsent: "plaintext" } },
161
172
  { authorId: null },
162
173
  { tenantId: EVENT_TENANT, aggregateType: "note", aggregateId: UUID_B },
163
174
  );
164
175
  expect(subject).toBeNull();
165
176
  });
166
177
 
178
+ test('personal: { of, whenAbsent: "tenant" } with a missing owner → envelope tenant (fw#2776)', () => {
179
+ const subject = resolveEventSubject(
180
+ "note",
181
+ { personal: { of: "authorId", whenAbsent: "tenant" } },
182
+ { authorId: null },
183
+ { tenantId: EVENT_TENANT, aggregateType: "note", aggregateId: UUID_B },
184
+ );
185
+ expect(subject).toEqual({ kind: "tenant", tenantId: EVENT_TENANT });
186
+ });
187
+
167
188
  test('personal: "tenant" → subject from the envelope tenantId', () => {
168
189
  const subject = resolveEventSubject(
169
190
  "note",
@@ -135,11 +135,19 @@ export interface EventSubjectEnvelope {
135
135
  readonly aggregateId: string;
136
136
  }
137
137
 
138
+ function resolveEnvelopeTenant(fieldName: string, envelope: EventSubjectEnvelope): SubjectId {
139
+ if (nonEmptyString(envelope.tenantId) === null) {
140
+ throw new SubjectResolutionError(fieldName, "event envelope tenantId is empty");
141
+ }
142
+ return { kind: "tenant", tenantId: envelope.tenantId };
143
+ }
144
+
138
145
  // Same resolver for the live-append path (encryptEventPayloadPii) and the
139
146
  // backfill catalog path (backfillEventPiiEncryption) — the reason the two
140
- // can never encrypt the same field under different subjects. "user" returns
141
- // null on a missing owner (no key to shred for system-triggered events);
142
- // "tenant"/"self" throw instead, since their envelope facts are structural.
147
+ // can never encrypt the same field under different subjects. A "user"
148
+ // subject whose owner field is empty falls back to the declared whenAbsent
149
+ // stance and throws when none is declared (fw#2776); "tenant"/"self" throw
150
+ // on an empty envelope, since their facts are structural.
143
151
  export function resolveEventSubject(
144
152
  fieldName: string,
145
153
  spec: EventPiiSubject,
@@ -150,14 +158,23 @@ export function resolveEventSubject(
150
158
 
151
159
  if (normalized.kind === "user") {
152
160
  const userId = nonEmptyString(payload[normalized.ownerField]);
153
- return userId === null ? null : { kind: "user", userId };
161
+ if (userId !== null) return { kind: "user", userId };
162
+ if (normalized.whenAbsent === "tenant") return resolveEnvelopeTenant(fieldName, envelope);
163
+ if (normalized.whenAbsent === "plaintext") {
164
+ // skip: author declared whenAbsent: "plaintext" — value ships unencrypted by decision
165
+ return null;
166
+ }
167
+ throw new SubjectResolutionError(
168
+ fieldName,
169
+ `owner field "${normalized.ownerField}" carries no id and the event declares no whenAbsent fallback — ` +
170
+ `refusing to append plaintext PII. Declare { personal: { of: "${normalized.ownerField}", ` +
171
+ `whenAbsent: "tenant" } } to encrypt under the envelope tenant key, or whenAbsent: "plaintext" ` +
172
+ "to acknowledge that this value cannot be crypto-shredded (fw#2776).",
173
+ );
154
174
  }
155
175
 
156
176
  if (normalized.kind === "tenant") {
157
- if (nonEmptyString(envelope.tenantId) === null) {
158
- throw new SubjectResolutionError(fieldName, "event envelope tenantId is empty");
159
- }
160
- return { kind: "tenant", tenantId: envelope.tenantId };
177
+ return resolveEnvelopeTenant(fieldName, envelope);
161
178
  }
162
179
 
163
180
  if (normalized.kind === "self") {
@@ -18,6 +18,7 @@
18
18
  // expressed in meta (hand-added in a migration) is not reconstructed, and a
19
19
  // partial index whose WHERE the renderer can't express is rejected up-front.
20
20
 
21
+ import { configuredBlindIndexKey } from "../../crypto";
21
22
  import type { DbConnection, DbTx } from "../connection";
22
23
  import type { EntityTableMeta } from "../entity-table-meta";
23
24
  import { type AnyDb, asEntityTableMeta, asRawClient } from "../query";
@@ -247,6 +248,40 @@ export async function assertNoUnreachableLiveRows(
247
248
  );
248
249
  }
249
250
 
251
+ // The bidx column is schema-driven, not key-driven: it exists NULL in a
252
+ // plaintext install and in the fw#1610 case (KMS configured, no index key),
253
+ // both of which are correct as-is. Only a POPULATED column with no key
254
+ // configured in THIS process means the rebuild is about to overwrite proof
255
+ // of a real index with NULL — that's the one provable data-loss case.
256
+ export async function assertNoBlindIndexLoss(
257
+ tx: AnyDb,
258
+ tableName: string,
259
+ meta: EntityTableMeta,
260
+ projectionName: string,
261
+ ): Promise<void> {
262
+ // skip: a key is configured — the replay recomputes every bidx column with it
263
+ if (configuredBlindIndexKey() !== undefined) return;
264
+ const bidxCols = meta.columns.filter((c) => c.name.endsWith("_bidx"));
265
+ // skip: no blind-index column on this table — nothing the rebuild could lose
266
+ if (bidxCols.length === 0) return;
267
+ const t = quoteTableIdent(tableName);
268
+ const raw = asRawClient(tx);
269
+ const where = bidxCols.map((c) => `${quoteTableIdent(c.name)} IS NOT NULL`).join(" OR ");
270
+ const rows = await raw.unsafe<{ total: string }>(
271
+ `SELECT count(*)::text AS total FROM public.${t} WHERE ${where}`,
272
+ );
273
+ const count = Number(rows[0]?.total ?? "0");
274
+ // skip: every bidx column is already NULL — nothing for the rebuild to lose
275
+ if (count === 0) return;
276
+ throw new Error(
277
+ `projection-rebuild "${projectionName}": "${tableName}" has ${count} row(s) with a populated ` +
278
+ `blind-index column, but KUMIKO_BLIND_INDEX_KEY is not configured in this process. The rebuild ` +
279
+ `would recompute those columns to NULL, and equality lookups on that field (login, password ` +
280
+ `reset) would stop matching afterward. Configure the blind-index key before this apply/rebuild ` +
281
+ `runs. See fw#3091. Rebuild aborted; live table untouched.`,
282
+ );
283
+ }
284
+
250
285
  // Columns ignored by countColumnDrift — the one PROVABLY legitimate class of
251
286
  // live-vs-shadow divergence. A blind-index column (`<field>_bidx`) is
252
287
  // recomputed to NULL on GDPR key-shredding; the NULL is the intended end
@@ -603,6 +603,128 @@ describe("validateBoot — PII annotations", () => {
603
603
  );
604
604
  expect(matchingWarn).toBeDefined();
605
605
  });
606
+
607
+ // --- #2918: deprecation warning for text fields without any stance ---
608
+
609
+ const NO_STANCE = "declares no personal stance";
610
+
611
+ test("text field without a personal stance warns, naming feature, entity and field", () => {
612
+ const feature = defineFeature("test", (r) => {
613
+ r.entity(
614
+ "invoice",
615
+ createEntity({
616
+ fields: {
617
+ externalRef: { ...unannotatedText },
618
+ },
619
+ }),
620
+ );
621
+ });
622
+ validateBoot([feature]);
623
+ const matchingWarn = warnSpy.mock.calls.find((args: unknown[]) =>
624
+ String(args[0]).includes(NO_STANCE),
625
+ );
626
+ expect(matchingWarn).toBeDefined();
627
+ const message = String((matchingWarn as unknown[])[0]);
628
+ expect(message).toContain("[Feature test]");
629
+ expect(message).toContain('Field "externalRef" on entity "invoice"');
630
+ expect(message).toContain('{ reason: "..." }');
631
+ });
632
+
633
+ test("longText field without a personal stance warns", () => {
634
+ const feature = defineFeature("test", (r) => {
635
+ r.entity(
636
+ "invoice",
637
+ createEntity({
638
+ fields: {
639
+ remarks: { ...unannotatedLongText },
640
+ },
641
+ }),
642
+ );
643
+ });
644
+ validateBoot([feature]);
645
+ const matchingWarn = warnSpy.mock.calls.find((args: unknown[]) =>
646
+ String(args[0]).includes(NO_STANCE),
647
+ );
648
+ expect(matchingWarn).toBeDefined();
649
+ });
650
+
651
+ test("personal: false with a reason silences the stance warning", () => {
652
+ const feature = defineFeature("test", (r) => {
653
+ r.entity(
654
+ "invoice",
655
+ createEntity({
656
+ fields: {
657
+ externalRef: createTextField({
658
+ personal: false,
659
+ reason: "is_business_data",
660
+ }),
661
+ },
662
+ }),
663
+ );
664
+ });
665
+ validateBoot([feature]);
666
+ const matchingWarn = warnSpy.mock.calls.find((args: unknown[]) =>
667
+ String(args[0]).includes(NO_STANCE),
668
+ );
669
+ expect(matchingWarn).toBeUndefined();
670
+ });
671
+
672
+ test("personal: self silences the stance warning", () => {
673
+ const feature = defineFeature("test", (r) => {
674
+ r.entity(
675
+ "invoice",
676
+ createEntity({
677
+ fields: {
678
+ externalRef: createTextField({
679
+ personal: "self",
680
+ find: "none",
681
+ }),
682
+ },
683
+ }),
684
+ );
685
+ });
686
+ validateBoot([feature]);
687
+ const matchingWarn = warnSpy.mock.calls.find((args: unknown[]) =>
688
+ String(args[0]).includes(NO_STANCE),
689
+ );
690
+ expect(matchingWarn).toBeUndefined();
691
+ });
692
+
693
+ test("personal: ref silences the stance warning", () => {
694
+ const feature = defineFeature("test", (r) => {
695
+ r.entity(
696
+ "invoice",
697
+ createEntity({
698
+ fields: {
699
+ ownerRef: createTextField({ personal: "ref" }),
700
+ },
701
+ }),
702
+ );
703
+ });
704
+ validateBoot([feature]);
705
+ const matchingWarn = warnSpy.mock.calls.find((args: unknown[]) =>
706
+ String(args[0]).includes(NO_STANCE),
707
+ );
708
+ expect(matchingWarn).toBeUndefined();
709
+ });
710
+
711
+ test("number field without a personal stance does not warn", () => {
712
+ const feature = defineFeature("test", (r) => {
713
+ r.entity(
714
+ "invoice",
715
+ createEntity({
716
+ fields: {
717
+ total: { type: "number", required: false },
718
+ },
719
+ }),
720
+ );
721
+ });
722
+ validateBoot([feature]);
723
+ const matchingWarn = warnSpy.mock.calls.find((args: unknown[]) =>
724
+ String(args[0]).includes(NO_STANCE),
725
+ );
726
+ expect(matchingWarn).toBeUndefined();
727
+ });
606
728
  });
607
729
 
608
730
  describe("validateBoot — retention", () => {
@@ -443,6 +443,99 @@ describe("validateBoot — projectionList screens", () => {
443
443
  expect(() => validateBoot([feature])).not.toThrow();
444
444
  });
445
445
 
446
+ // fw#3104: a dateRange facet sends its two bounds as the top-level params
447
+ // it names, so `filters` is the wrong thing to require — the declared
448
+ // param names are.
449
+ test("a dateRange facet on a query that can't narrow by time is rejected at boot", () => {
450
+ const feature = defineFeature("ledger", (r) => {
451
+ r.queryHandler(
452
+ "schedule:list",
453
+ z.object({ from: z.iso.datetime().optional() }),
454
+ async () => ({ rows: [], nextCursor: null }),
455
+ { access: { openToAll: { reason: "test handler callable by any signed-in test user" } } },
456
+ );
457
+ r.screen({
458
+ id: "schedule-list",
459
+ type: "projectionList",
460
+ query: "ledger:query:schedule:list",
461
+ columns: ["dueAt"],
462
+ facets: [
463
+ {
464
+ field: "dueAt",
465
+ type: "dateRange",
466
+ label: "Due",
467
+ params: { from: "from", to: "to" },
468
+ },
469
+ ],
470
+ });
471
+ r.translations({
472
+ keys: { "screen:schedule-list.title": { de: "Liste", en: "List" } },
473
+ });
474
+ });
475
+ expect(() => validateBoot([feature])).toThrow(/no "to" parameter/);
476
+ });
477
+
478
+ test('a dateRange facet does NOT require a "filters" parameter', () => {
479
+ const feature = defineFeature("ledger", (r) => {
480
+ r.queryHandler(
481
+ "schedule:list",
482
+ z.object({
483
+ since: z.iso.datetime().optional(),
484
+ until: z.iso.datetime().optional(),
485
+ }),
486
+ async () => ({ rows: [], nextCursor: null }),
487
+ { access: { openToAll: { reason: "test handler callable by any signed-in test user" } } },
488
+ );
489
+ r.screen({
490
+ id: "schedule-list",
491
+ type: "projectionList",
492
+ query: "ledger:query:schedule:list",
493
+ columns: ["dueAt"],
494
+ facets: [
495
+ {
496
+ field: "dueAt",
497
+ type: "dateRange",
498
+ label: "Due",
499
+ params: { from: "since", to: "until" },
500
+ },
501
+ ],
502
+ });
503
+ r.translations({
504
+ keys: { "screen:schedule-list.title": { de: "Liste", en: "List" } },
505
+ });
506
+ });
507
+ expect(() => validateBoot([feature])).not.toThrow();
508
+ });
509
+
510
+ test("a dateRange facet naming a reserved list-payload key is rejected", () => {
511
+ const feature = defineFeature("ledger", (r) => {
512
+ r.queryHandler(
513
+ "schedule:list",
514
+ z.object({ limit: z.number().optional(), to: z.iso.datetime().optional() }),
515
+ async () => ({ rows: [], nextCursor: null }),
516
+ { access: { openToAll: { reason: "test handler callable by any signed-in test user" } } },
517
+ );
518
+ r.screen({
519
+ id: "schedule-list",
520
+ type: "projectionList",
521
+ query: "ledger:query:schedule:list",
522
+ columns: ["dueAt"],
523
+ facets: [
524
+ {
525
+ field: "dueAt",
526
+ type: "dateRange",
527
+ label: "Due",
528
+ params: { from: "limit", to: "to" },
529
+ },
530
+ ],
531
+ });
532
+ r.translations({
533
+ keys: { "screen:schedule-list.title": { de: "Liste", en: "List" } },
534
+ });
535
+ });
536
+ expect(() => validateBoot([feature])).toThrow(/reserved list-payload key/);
537
+ });
538
+
446
539
  test("a reference facet targeting an unknown entity is rejected", () => {
447
540
  const feature = defineFeature("ledger", (r) => {
448
541
  r.queryHandler(