@ultimat3/testing 31.27.0 → 31.28.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.
package/CLAUDE.md CHANGED
@@ -54,7 +54,7 @@ the off-barrel entry points `registry-isolation.ts`, `conformance.ts`. Full rule
54
54
  | Every `e2eTest` is audited | `e2e-a11y*.ts`, `ax-node.ts`; no switch, `allow` needs a `because` † |
55
55
  | The exercise pass runs what is registered | `exercise.ts` (`runExercisePass`): every action, query, job once, own tenant pair; overrides only via `defineExercise` † |
56
56
  | A route `load` is exercised like a read | `exercise-route-loads.ts`: after the primitives, own tenant pair, swept and planned with them; its record is `RouteLoadRecord`, never in `records`; the crash proof's runs pace on the frozen clock (`exercise-crash.ts`) |
57
- | Route entries, push | `defineExercise(…, { routes })` (`define-exercise-routes.ts`); a push is a `push` effect (`exercise-report.ts`) |
57
+ | Route entries, push, storage | `defineExercise(…, { routes })` (`define-exercise-routes.ts`); a push is a `push` effect (`exercise-report.ts`), a disk write a `storage` one (`exercise-room-storage.ts`) |
58
58
  | An override `input` is awaited, as the call's actor | `exercise-override-input.ts`: inside the call's own request — the one way to a signed input † |
59
59
  | A passkey test signs for real | `softAuthenticator` is `@ultimat3/auth/soft-authenticator`'s, never re-exported here (one value, one path: `flight-copies`) and never a second one (auth's own suites need it, and auth cannot import testing) |
60
60
  | A reached job is crash-proven | `exercise-crash.ts`: only `diverged` is red (`X_JOB_CRASH_DIVERGED`) † |
package/README.md CHANGED
@@ -43,6 +43,7 @@ unitTest('the clock moves only when the test moves it', ({ clock }) => {
43
43
  | `define-exercise-routes.ts` · `exercise-route-override.ts` | `defineExercise(…, { routes: { '<pattern>': { params?, search?, actor?, statements?, empty? } \| { off } } })` — a route load's entry, keyed by its URL pattern: `params`/`search` (values or functions) and an `actor` function (of the seated actor: the app's request-boundary resolution, facts and all) run in the load's own request before the observed call; `off` makes the record `off`; an unknown pattern is `X_DECLARATION_UNKNOWN` before a row; a blank reason `X_CONTRACT_EXERCISE_UNDECLARED`. `empty: '<why>'` on any entry rides the record as `empty` |
44
44
  | `exercise-shard.ts` | `runExercisePass({ …, shard: { index, total } })` — the `index`-th of `total` disjoint slices (primitives, then routes, by registry position); ignored beside `only` |
45
45
  | `exercise-report.ts` (push) | `{ kind: 'push', host, count }`: each `outbound.request` with vendor `push` the observed call made — a pusher that sends nothing leaves none |
46
+ | `exercise-room-storage.ts` | `{ kind: 'storage', disk, op: 'put' \| 'copy' \| 'delete', count }`: each `storage.<verb>` write the observed call made through a `defineStorage` disk; a read, or a write the driver refused, leaves none |
46
47
  | `exercise-setup.ts` | `withExerciseSetup(room, setup)`: the app's `setup` run inside the sealed room before the first row, its handle disposed before the room restores the network; an `allowHost` in it is `X_EXERCISE_SETUP_UNSEALED`. Types `ExerciseSetup`, `ExerciseSetupHandle` |
47
48
  | `exercise-actor.ts` · `exercise-input.ts` · `exercise-report.ts` | the first `x policy explain` actor the policy allows, minted in the primitive's tenant · the input: override, then a seeded id by field stem, then the minimal draw (`@ultimat3/schema/sample`, loaded dynamically) · the room one run executes in (network sealed, mail captured, clock frozen) and its record |
48
49
  | `exercise-override-line.ts` | `overrideLine`, the entry an unreached record says to paste: valid TS — the actor the pass ran as (`testActor(name, { roles, permissions }).actor`, `null` signed out, left out when the entry declares one) and each id field bound to the seeded row the pass used; an id it could not bind is the string `UNBOUND_ID` |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultimat3/testing",
3
- "version": "31.27.0",
3
+ "version": "31.28.0",
4
4
  "description": "Test harness: cloned template DBs per worker, frozen clock, sealed network, 6 test types",
5
5
  "keywords": [
6
6
  "ultimate",
@@ -47,26 +47,29 @@
47
47
  "test": "bun test"
48
48
  },
49
49
  "dependencies": {
50
- "@ultimat3/action": "31.27.0",
51
- "@ultimat3/ai": "31.27.0",
52
- "@ultimat3/auth": "31.27.0",
53
- "@ultimat3/cache": "31.27.0",
54
- "@ultimat3/core": "31.27.0",
55
- "@ultimat3/db": "31.27.0",
56
- "@ultimat3/entity": "31.27.0",
57
- "@ultimat3/http": "31.27.0",
58
- "@ultimat3/i18n": "31.27.0",
59
- "@ultimat3/jobs": "31.27.0",
60
- "@ultimat3/mail": "31.27.0",
61
- "@ultimat3/notify": "31.27.0",
62
- "@ultimat3/policy": "31.27.0",
63
- "@ultimat3/pwa": "31.27.0",
64
- "@ultimat3/query": "31.27.0",
65
- "@ultimat3/realtime": "31.27.0",
66
- "@ultimat3/render": "31.27.0",
67
- "@ultimat3/schema": "31.27.0",
68
- "@ultimat3/scraping": "31.27.0",
69
- "@ultimat3/seo": "31.27.0",
70
- "@ultimat3/time": "31.27.0"
50
+ "@ultimat3/action": "31.28.0",
51
+ "@ultimat3/ai": "31.28.0",
52
+ "@ultimat3/auth": "31.28.0",
53
+ "@ultimat3/cache": "31.28.0",
54
+ "@ultimat3/core": "31.28.0",
55
+ "@ultimat3/db": "31.28.0",
56
+ "@ultimat3/entity": "31.28.0",
57
+ "@ultimat3/http": "31.28.0",
58
+ "@ultimat3/i18n": "31.28.0",
59
+ "@ultimat3/jobs": "31.28.0",
60
+ "@ultimat3/mail": "31.28.0",
61
+ "@ultimat3/notify": "31.28.0",
62
+ "@ultimat3/policy": "31.28.0",
63
+ "@ultimat3/pwa": "31.28.0",
64
+ "@ultimat3/query": "31.28.0",
65
+ "@ultimat3/realtime": "31.28.0",
66
+ "@ultimat3/render": "31.28.0",
67
+ "@ultimat3/schema": "31.28.0",
68
+ "@ultimat3/scraping": "31.28.0",
69
+ "@ultimat3/seo": "31.28.0",
70
+ "@ultimat3/time": "31.28.0"
71
+ },
72
+ "peerDependencies": {
73
+ "solid-js": "^1.9.18"
71
74
  }
72
75
  }
@@ -12,6 +12,7 @@ const countKey = (effect: ExerciseEffect): string | undefined => {
12
12
  if (effect.kind === 'mail') return `mail\u0000${effect.mail}`;
13
13
  if (effect.kind === 'enqueue') return `enqueue\u0000${effect.job}`;
14
14
  if (effect.kind === 'push') return `push\u0000${effect.host}`;
15
+ if (effect.kind === 'storage') return `storage\u0000${effect.disk}\u0000${effect.op}`;
15
16
  return undefined;
16
17
  };
17
18
 
@@ -24,6 +25,8 @@ const added = (one: ExerciseEffect, other: ExerciseEffect): ExerciseEffect => {
24
25
  }
25
26
  if (one.kind === 'push' && other.kind === 'push')
26
27
  return { ...one, count: one.count + other.count };
28
+ if (one.kind === 'storage' && other.kind === 'storage')
29
+ return { ...one, count: one.count + other.count };
27
30
  return one;
28
31
  };
29
32
 
@@ -9,6 +9,8 @@ import { expectedSeqScanReason, statementFingerprint } from '@ultimat3/db';
9
9
  import { captureDeterminism, installDeterminism, restoreCapturedDeterminism } from './determinism';
10
10
  import type { ExerciseDefect } from './exercise-defect';
11
11
  import { roomMail } from './exercise-room-mail';
12
+ import type { StorageWrite } from './exercise-room-storage';
13
+ import { roomStorage } from './exercise-room-storage';
12
14
  import type { StatementCeilingProof } from './exercise-statement-ceiling';
13
15
  import { routeMatches } from './mock-route';
14
16
  import type { PlanProof, SentStatement } from './plan-sweep';
@@ -36,7 +38,14 @@ export type ExerciseEffect =
36
38
  }
37
39
  | { readonly kind: 'enqueue'; readonly job: string; readonly count: number }
38
40
  /** Web Push messages sent to `host`'s push service: a notifier that pushes nothing has none. */
39
- | { readonly kind: 'push'; readonly host: string; readonly count: number };
41
+ | { readonly kind: 'push'; readonly host: string; readonly count: number }
42
+ /** Objects `disk` was written, copied into or deleted from, or an upload session it changed. */
43
+ | {
44
+ readonly kind: 'storage';
45
+ readonly disk: string;
46
+ readonly op: StorageWrite;
47
+ readonly count: number;
48
+ };
40
49
 
41
50
  export type ExerciseOutcome = 'reached' | 'refused' | 'unreached' | 'off';
42
51
 
@@ -299,6 +308,8 @@ export async function openExerciseRoom(): Promise<ExerciseRoom> {
299
308
  const offPushes = subscribe('outbound.request', (event) => {
300
309
  if (owns() && event.payload.vendor === 'push') pushes.push(event.payload.host);
301
310
  });
311
+ // A disk write: `storage.<verb>` is reported in the writer's own context, after its await.
312
+ const objects = roomStorage(owns);
302
313
 
303
314
  const begin = (name: string | undefined): object => {
304
315
  subject = name;
@@ -309,6 +320,7 @@ export async function openExerciseRoom(): Promise<ExerciseRoom> {
309
320
  rows.length = 0;
310
321
  calls.length = 0;
311
322
  pushes.length = 0;
323
+ objects.clear();
312
324
  mail.clear();
313
325
  marker = {};
314
326
  return marker;
@@ -336,6 +348,7 @@ export async function openExerciseRoom(): Promise<ExerciseRoom> {
336
348
  }),
337
349
  ),
338
350
  ...[...tally(pushes)].map(([host, count]): ExerciseEffect => ({ kind: 'push', host, count })),
351
+ ...objects.effects(),
339
352
  ];
340
353
  const refusedHosts = calls.filter(refused).map((c) => hostOf(c.url));
341
354
  const payloads: EffectPayload[] = [
@@ -381,6 +394,7 @@ export async function openExerciseRoom(): Promise<ExerciseRoom> {
381
394
  try {
382
395
  mail[Symbol.dispose]();
383
396
  } finally {
397
+ objects.off();
384
398
  offPushes();
385
399
  offDials();
386
400
  offRows();
@@ -0,0 +1,58 @@
1
+ // The exercise room's storage seam: every object a disk wrote, copied or deleted while the observed
2
+ // call was in flight, read off core's `storage.<verb>` events. A write is the call's effect as a
3
+ // row or a mail is — an upload action that only stores an object is a reach that did something.
4
+
5
+ import { subscribe } from '@ultimat3/core';
6
+ import type { ExerciseEffect } from './exercise-report';
7
+
8
+ /** The verbs that change what a disk holds, each by its event; a get, stat or list leaves it be. */
9
+ const WRITES = [
10
+ ['put', 'storage.put'],
11
+ ['copy', 'storage.copy'],
12
+ ['delete', 'storage.delete'],
13
+ ] as const;
14
+
15
+ /** A write's effect `op`: the verb, or `multipart.<op>` for a change to an upload session. */
16
+ export type StorageWrite =
17
+ | (typeof WRITES)[number][0]
18
+ | `multipart.${'create' | 'part' | 'complete' | 'abort'}`;
19
+
20
+ interface WriteEvent {
21
+ readonly payload: { readonly disk: string; readonly error?: unknown };
22
+ }
23
+
24
+ export interface RoomStorage {
25
+ /** The observed call's writes since `clear()`: one effect per disk and verb, counted. */
26
+ effects(): readonly ExerciseEffect[];
27
+ clear(): void;
28
+ /** Releases the subscriptions; the bus's other subscribers are untouched. */
29
+ off(): void;
30
+ }
31
+
32
+ /** Subscribe to every write verb, keeping those made while `owns()` answers true. */
33
+ export function roomStorage(owns: () => boolean): RoomStorage {
34
+ const kept = new Map<string, { disk: string; op: StorageWrite; count: number }>();
35
+ const keep =
36
+ (verb: StorageWrite) =>
37
+ (event: WriteEvent): void => {
38
+ // A refused write changed nothing, so it is no effect: the error is the call's answer.
39
+ if (!owns() || event.payload.error !== undefined) return;
40
+ const { disk } = event.payload;
41
+ const key = `${disk}\u0000${verb}`;
42
+ const known = kept.get(key) ?? { disk, op: verb, count: 0 };
43
+ known.count += 1;
44
+ kept.set(key, known);
45
+ };
46
+ const offs = [
47
+ ...WRITES.map(([verb, event]) => subscribe(event, keep(verb))),
48
+ subscribe('storage.multipart', (event) => keep(`multipart.${event.payload.op}`)(event)),
49
+ ];
50
+ return {
51
+ effects: () =>
52
+ [...kept.values()].map(({ disk, op, count }) => ({ kind: 'storage', disk, op, count })),
53
+ clear: () => kept.clear(),
54
+ off: () => {
55
+ for (const off of offs) off();
56
+ },
57
+ };
58
+ }