@ultimat3/cli 31.2.0 → 31.3.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 +2 -2
- package/package.json +29 -29
- package/src/app-load.ts +3 -2
- package/src/dev-boot.ts +4 -5
- package/src/dev-rebuild.ts +38 -5
- package/src/island-build-pool.ts +35 -0
- package/src/island-bundle.ts +137 -176
- package/src/island-cache-inputs.ts +141 -0
- package/src/island-duplicates.ts +36 -0
- package/src/island-group-cache.ts +289 -0
- package/src/island-groups.ts +117 -0
- package/src/island-outputs.ts +153 -0
- package/src/island-runtime.ts +5 -0
- package/src/island-styles.ts +68 -19
- package/src/verify-e2e.ts +17 -5
- package/wiki/Client-Data.md +14 -8
- package/wiki/Configuration.md +1 -1
- package/wiki/Deployment.md +1 -1
- package/wiki/Entities-And-Migrations.md +15 -10
- package/wiki/Storage-And-Uploads.md +1 -1
- package/wiki/Testing.md +1 -0
package/src/island-styles.ts
CHANGED
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
// default loader answers the asset PATH — a string — so `styles['track']` is `undefined`, every
|
|
4
4
|
// element renders unclassed, and `Bun.build` reports `success: true` with no log.
|
|
5
5
|
|
|
6
|
+
// why: Bun ships no path API; the bundler names its inputs relative to the building process's cwd.
|
|
7
|
+
import { resolve } from 'node:path';
|
|
6
8
|
import { renderThrowable, UltimateError } from '@ultimat3/core';
|
|
7
|
-
import { loadStylesheet } from '@ultimat3/render/server';
|
|
9
|
+
import { compileStylesheet, loadStylesheet, registeredStylesheets } from '@ultimat3/render/server';
|
|
8
10
|
import type { BunPlugin } from 'bun';
|
|
9
11
|
import { IslandBuildFailedError } from './errors';
|
|
10
12
|
|
|
@@ -16,6 +18,9 @@ import { IslandBuildFailedError } from './errors';
|
|
|
16
18
|
*/
|
|
17
19
|
const STYLESHEET = /\.s?css$/;
|
|
18
20
|
|
|
21
|
+
/** Whether `path` is a stylesheet by the one spelling the loader and the bundler share. */
|
|
22
|
+
export const isStylesheet = (path: string): boolean => STYLESHEET.test(path);
|
|
23
|
+
|
|
19
24
|
/**
|
|
20
25
|
* Every stylesheet an island build has loaded in this process, absolute. `x build --target docker`
|
|
21
26
|
* writes them into the island store, so a container that serves the stored chunks registers the
|
|
@@ -26,27 +31,71 @@ const islandSheets = new Set<string>();
|
|
|
26
31
|
/** Sorted, so the store index is byte-identical for identical input. */
|
|
27
32
|
export const islandStylesheets = (): readonly string[] => [...islandSheets].sort();
|
|
28
33
|
|
|
34
|
+
/** Registers one island stylesheet: what the plugin does on a load, and a cached group's hit. */
|
|
35
|
+
export function registerIslandStylesheet(path: string, source: string): string {
|
|
36
|
+
islandSheets.add(path);
|
|
37
|
+
return loadStylesheet(path, source, 'island');
|
|
38
|
+
}
|
|
39
|
+
|
|
29
40
|
/**
|
|
30
41
|
* `loadStylesheet`, not `compileStylesheet`: compiling alone answers the class names and drops the
|
|
31
42
|
* RULES on the floor, and an island is the one importer a document's own module graph never sees.
|
|
32
43
|
* Registering here is what puts them in `stylesFor(surface)` — `buildIslands` runs before the first
|
|
33
44
|
* document is rendered, in `x dev` and in `prerenderSite` alike.
|
|
45
|
+
*
|
|
46
|
+
* One plugin per `buildIslands` call, holding each sheet's answer for that call: every group's
|
|
47
|
+
* build loads the design system's sheets again, and compiling them once per group was 6.0 s of a
|
|
48
|
+
* 19.6 s build of the 159-island bench app (one CPU profile, As of 2026-11-10). Per call and never
|
|
49
|
+
* per process, so a `x dev` rebuild compiles an edited sheet — or a partial it `@use`s — afresh.
|
|
50
|
+
*/
|
|
51
|
+
/** The plugin, and the Sass partials each sheet it loaded read — what a cache entry must rehash. */
|
|
52
|
+
export interface IslandStyles extends BunPlugin {
|
|
53
|
+
dependenciesOf(sheets: readonly string[]): readonly string[];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function islandStylesPlugin(): IslandStyles {
|
|
57
|
+
const compiled = new Map<string, Promise<string>>();
|
|
58
|
+
const partials = new Map<string, readonly string[]>();
|
|
59
|
+
const load = async (path: string): Promise<string> => {
|
|
60
|
+
const source = await Bun.file(path).text();
|
|
61
|
+
try {
|
|
62
|
+
const classes = registerIslandStylesheet(path, source);
|
|
63
|
+
// A partial `@use`d by the sheet moves its class hashes and is no bundler input: read off the
|
|
64
|
+
// registry the load just wrote, compiled again only for a sheet with no rules to register.
|
|
65
|
+
const held = registeredStylesheets().find((sheet) => sheet.file === path);
|
|
66
|
+
partials.set(path, held?.dependencies ?? compileStylesheet(path, source).dependencies);
|
|
67
|
+
return classes;
|
|
68
|
+
} catch (error) {
|
|
69
|
+
// A coded failure already names the file and carries a fix — re-wrapping it would bury
|
|
70
|
+
// both. Anything else is rendered through `renderThrowable`, because this is the plugin's
|
|
71
|
+
// last frame and a value that fights being read would escape a Bun plugin as a bare throw.
|
|
72
|
+
if (error instanceof UltimateError) throw error;
|
|
73
|
+
throw new IslandBuildFailedError({ file: path, logs: renderThrowable(error) });
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
return {
|
|
77
|
+
name: 'ultimate-island-styles',
|
|
78
|
+
dependenciesOf: (sheets) => [...new Set(sheets.flatMap((one) => partials.get(one) ?? []))],
|
|
79
|
+
setup(build): void {
|
|
80
|
+
build.onLoad({ filter: STYLESHEET }, async ({ path }) => {
|
|
81
|
+
let contents = compiled.get(path);
|
|
82
|
+
if (contents === undefined) {
|
|
83
|
+
contents = load(path);
|
|
84
|
+
compiled.set(path, contents);
|
|
85
|
+
}
|
|
86
|
+
return { contents: await contents, loader: 'js' };
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The stylesheets among a build's metafile inputs (cwd-relative), absolute — a package's own
|
|
94
|
+
* included, which a cached group must register again exactly as the build's plugin did.
|
|
34
95
|
*/
|
|
35
|
-
export
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
islandSheets.add(path);
|
|
42
|
-
return { contents: loadStylesheet(path, source, 'island'), loader: 'js' };
|
|
43
|
-
} catch (error) {
|
|
44
|
-
// A coded failure already names the file and carries a fix — re-wrapping it would bury
|
|
45
|
-
// both. Anything else is rendered through `renderThrowable`, because this is the plugin's
|
|
46
|
-
// last frame and a value that fights being read would escape a Bun plugin as a bare throw.
|
|
47
|
-
if (error instanceof UltimateError) throw error;
|
|
48
|
-
throw new IslandBuildFailedError({ file: path, logs: renderThrowable(error) });
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
},
|
|
52
|
-
};
|
|
96
|
+
export function stylesheetsOf(inputs: readonly string[]): readonly string[] {
|
|
97
|
+
const cwd = process.cwd();
|
|
98
|
+
return [
|
|
99
|
+
...new Set(inputs.filter((one) => STYLESHEET.test(one)).map((one) => resolve(cwd, one))),
|
|
100
|
+
].sort();
|
|
101
|
+
}
|
package/src/verify-e2e.ts
CHANGED
|
@@ -17,11 +17,27 @@ import type { ExecResult } from './exec';
|
|
|
17
17
|
export const e2ePreload = (): string =>
|
|
18
18
|
Bun.resolveSync('@ultimat3/testing/e2e-preload', import.meta.dir);
|
|
19
19
|
|
|
20
|
+
/** The device zone every browser-backed app e2e run uses, never the runner's ambient zone. */
|
|
21
|
+
export const E2E_TIME_ZONE = 'America/Los_Angeles';
|
|
22
|
+
|
|
20
23
|
export interface E2eRun {
|
|
21
24
|
readonly command: readonly string[];
|
|
22
25
|
readonly env: Readonly<Record<string, string | undefined>>;
|
|
23
26
|
}
|
|
24
27
|
|
|
28
|
+
/** Add the app preload and its deterministic device zone after a browser was found. */
|
|
29
|
+
export function appE2eRun(input: {
|
|
30
|
+
readonly root: string;
|
|
31
|
+
readonly command: readonly string[];
|
|
32
|
+
readonly env: Readonly<Record<string, string | undefined>>;
|
|
33
|
+
}): E2eRun {
|
|
34
|
+
const [bun = 'bun', test = 'test', ...rest] = input.command;
|
|
35
|
+
return {
|
|
36
|
+
command: [bun, test, '--preload', e2ePreload(), ...rest],
|
|
37
|
+
env: { ...input.env, [E2E_ROOT_ENV]: input.root, TZ: E2E_TIME_ZONE },
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
25
41
|
/** Wrap one e2e `bun test` invocation: `run` receives the command and extra environment to use. */
|
|
26
42
|
export async function withE2eApp(
|
|
27
43
|
input: {
|
|
@@ -34,9 +50,5 @@ export async function withE2eApp(
|
|
|
34
50
|
): Promise<ExecResult> {
|
|
35
51
|
const chrome = input.isApp ? await findChrome(Bun.env) : undefined;
|
|
36
52
|
if (chrome === undefined) return run({ command: input.command, env: input.env });
|
|
37
|
-
|
|
38
|
-
return run({
|
|
39
|
-
command: [bun, test, '--preload', e2ePreload(), ...rest],
|
|
40
|
-
env: { ...input.env, [E2E_ROOT_ENV]: input.root },
|
|
41
|
-
});
|
|
53
|
+
return run(appE2eRun(input));
|
|
42
54
|
}
|
package/wiki/Client-Data.md
CHANGED
|
@@ -177,18 +177,24 @@ Full rows: [Error codes](Error-Codes).
|
|
|
177
177
|
|
|
178
178
|
## Shared island chunks
|
|
179
179
|
|
|
180
|
-
|
|
181
|
-
a module
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
180
|
+
**By default the build groups islands by route.** Islands rendered on exactly the same set of
|
|
181
|
+
routes are one split build: a module they share is one `/islands/chunk-<hash>.js` the page fetches
|
|
182
|
+
once. Every other island is built alone, self-contained, so no route pays for an island it does
|
|
183
|
+
not render. The groups are read from each `page.tsx`'s `island({ src })` declarations
|
|
184
|
+
(`packages/cli/src/island-groups.ts`). Measured `As of 2026-11-10`: the reference app's
|
|
185
|
+
`/posts/:id` (three islands on that route only) 95,754 → 65,676 B; every other route unchanged.
|
|
186
|
+
|
|
187
|
+
**`islands: { sharedChunks: true }` in `app.config.ts` is one group holding every island.** Off by
|
|
188
|
+
default, by measurement (`packages/core/src/config-islands.ts`): tree shaking across one build
|
|
189
|
+
keeps what any importer uses, so an island that takes one helper from a module the others use
|
|
190
|
+
heavily pays for all of it — the reference app's plain-DOM update banner went 712 → 16,288 B.
|
|
185
191
|
|
|
186
192
|
| Turn it on when | Leave it off when |
|
|
187
193
|
|---|---|
|
|
188
|
-
|
|
|
189
|
-
| `x build --target static`, then `x verify --only budgets`, shows
|
|
194
|
+
| shared code cached across pages is worth more than each page's first-visit bytes | an island is small and plain-DOM, or the islands share little |
|
|
195
|
+
| `x build --target static`, then `x verify --only budgets`, shows no route growing | any route's `budget.js` grows past its budget |
|
|
190
196
|
|
|
191
197
|
Layering: the last config layer that states `sharedChunks` wins; absent everywhere is `false`
|
|
192
198
|
(`mergeIslands`). A value that is not a boolean is refused at boot (`X_CONFIG_INVALID`). `As of
|
|
193
|
-
2026-
|
|
199
|
+
2026-11`.
|
|
194
200
|
|
package/wiki/Configuration.md
CHANGED
|
@@ -373,7 +373,7 @@ islands: { sharedChunks: true },
|
|
|
373
373
|
|
|
374
374
|
| field | type | default | notes |
|
|
375
375
|
|---|---|---|---|
|
|
376
|
-
| `islands.sharedChunks` | `boolean` | `false` | **read** by `x dev`, the container and `x build`: `true` builds every island in one split bundle, so a module two islands import is one `/islands/chunk-<hash>.js` a page fetches once and a browser caches across pages; each route's `budget.js` counts it once. `false`
|
|
376
|
+
| `islands.sharedChunks` | `boolean` | `false` | **read** by `x dev`, the container and `x build`: `true` builds every island in one split bundle, so a module two islands import is one `/islands/chunk-<hash>.js` a page fetches once and a browser caches across pages; each route's `budget.js` counts it once. `false` (the default) groups by route: islands rendered on exactly the same set of routes are one split build sharing their modules, every other island is built alone, self-contained ([Client data](Client-Data#shared-island-chunks)). `true` is one group holding every island: tree shaking across one split build keeps what ANY importer uses, so a small island importing a helper from a module other islands use heavily pays for all of it (`examples/dummy`'s update banner 712 → 16,288 B). Turn it on only when cross-page caching of shared code is worth that, then weigh the routes with `x verify`. A non-boolean → `X_CONFIG_INVALID` |
|
|
377
377
|
|
|
378
378
|
## `clientErrors`
|
|
379
379
|
|
package/wiki/Deployment.md
CHANGED
|
@@ -222,7 +222,7 @@ own file. Add it; the boot log names it until you do ([Upgrading](Upgrading)).
|
|
|
222
222
|
| the registry came from another Bun | ignores it and scans |
|
|
223
223
|
| a module would not import at build time | no registry was written; the boot scans and refuses with that module's cause (`X_APP_MODULE_LOAD_FAILED`) |
|
|
224
224
|
|
|
225
|
-
Every scan without a registry — tools, `x dev`'s first load, `x build` — imports in batches of 256 through one generated entry module per batch, in the serial scan's evaluation order (`packages/cli/src/app-load-order.test.ts`). Measured cold module load, 5,000 synthetic modules: serial 3,258 ms, batched 1,259 ms ([`boot-vs-files.json`](https://github.com/developerz-ai/ultimate/blob/main/scripts/bench/results/boot-vs-files.json)).
|
|
225
|
+
Every scan without a registry — tools, `x dev`'s first load, `x build` — imports in batches of 256 through one generated entry module per batch, in the serial scan's evaluation order (`packages/cli/src/app-load-order.test.ts`). Measured cold module load, 5,000 synthetic modules: serial 3,258 ms, batched 1,259 ms ([`boot-vs-files.json`](https://github.com/developerz-ai/ultimate/blob/main/scripts/bench/results/boot-vs-files.json)). A whole `web` pod boot, `As of 2026-11-10`, on a 5,124-file app (the reference app plus 150 generated resources): 2.4 s to the first 200 from the prebuilt registry, 3.3 s scanning instead — the image's entry and store on one busy host, not inside a container ([`boot-large-app.json`](https://github.com/developerz-ai/ultimate/blob/main/scripts/bench/results/boot-large-app.json), `bun run scripts/bench/boot-large-app.bench.ts`).
|
|
226
226
|
|
|
227
227
|
All targets share one build ID (content hash), stamped into the image, the HTML, the assets, `x.manifest.json` — **and `sw.js`**, `As of 2026-08`: the worker's cache names carry the build id, so a deploy retires the previous build's caches instead of serving them ([#390](https://github.com/developerz-ai/ultimate/issues/390)). Every target that serves or writes a document emits `manifest.webmanifest`, `sw.js` and `x-sw-register.js` alike ([PWA and offline](PWA-And-Offline)).
|
|
228
228
|
|
|
@@ -88,14 +88,18 @@ migration or a psql session can violate.
|
|
|
88
88
|
| `c.slug.matches(isValidSlug)` — a **function** | **no** | `sql: null` |
|
|
89
89
|
| `c.satisfies(fn, ['status', 'publishedAt'])` | **no** | `sql: null`, by construction — a JS function over several columns |
|
|
90
90
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
91
|
+
**A rule over a nullable column passes `NULL`, in the app as in the CHECK.** Every operator but
|
|
92
|
+
`isNull()`/`isNotNull()` answers SQL's *unknown* for a NULL operand, in TypeScript too, and a rule
|
|
93
|
+
holds unless it is false — so `c.slug.matches(SLUG_PATTERN)` on a `.nullable()` slug accepts a
|
|
94
|
+
NULL in `$assert`, the memory driver and Postgres alike (`invariant-null.test.ts`, every operator on
|
|
95
|
+
PGlite). To refuse NULL, declare the column NOT NULL or add `.isNotNull()`. As of 31.3; before it
|
|
96
|
+
the app refused the NULL its CHECK stored.
|
|
97
|
+
|
|
98
|
+
**`iff` renders `=`, not `IS NOT DISTINCT FROM`, and that is not an oversight.** `=` between two
|
|
99
|
+
booleans where either is NULL yields NULL, which a CHECK **passes** and the app now passes too. The
|
|
100
|
+
total form would make Postgres **refuse a row TypeScript accepted**, which reaches the caller as a
|
|
101
|
+
raw `23514` instead of `X_INVARIANT_VIOLATED`. Where both operands are total — a non-nullable
|
|
102
|
+
column, an `IS NOT NULL` — the two spellings are the same predicate, measured.
|
|
99
103
|
|
|
100
104
|
Pass the pattern, not a function wrapping it. `matches(isValidSlug)` and `matches(SLUG_PATTERN)`
|
|
101
105
|
read almost identically and only one of them reaches a constraint.
|
|
@@ -913,7 +917,7 @@ Three declarations on the entity, each compiled to a trigger or a purge target,
|
|
|
913
917
|
| Declaration | Compiles to | Refused when |
|
|
914
918
|
|---|---|---|
|
|
915
919
|
| `retain: { after: '90d', on: 'createdAt' }` | a `PurgeTarget` per entity — batched, cross-tenant `delete … where created_at < now - after` | no window (`X_ENTITY_RETAIN_INVALID`), `on` not an indexed `timestamp()` (`X_ENTITY_RETAIN_UNINDEXED`), beside `appendOnly`, or on a table the catalog holds partitioned (drift, `X_ENTITY_RETAIN_INVALID`: detach partitions in a `task`) |
|
|
916
|
-
| `history: true` · `history: { retain: { after: '365d' } }` | `<table>_history (id, <tenant>, row_id, op, at, actor_id, request_id, before, after)` — a registered entity (`posts.$history`), written by the `ultimate_history` trigger, guarded by `ultimate_history_guard` | a composite primary key, `appendOnly` (`X_INVARIANT_VIOLATED`) |
|
|
920
|
+
| `history: true` · `history: { retain: { after: '365d' }, ignore: ['likeCount', 'updatedAt'] }` | `<table>_history (id, <tenant>, row_id, op, at, actor_id, request_id, before, after)` — a registered entity (`posts.$history`), written by the `ultimate_history` trigger, guarded by `ultimate_history_guard` | a composite primary key, `appendOnly` (`X_INVARIANT_VIOLATED`) |
|
|
917
921
|
| `references(() => posts.id, { countedIn: () => posts.likeCount })` | a trigger on the child moving `posts.like_count` by one in the write's own transaction | the column is no `integer()`, or the key points at no single primary key (`X_ENTITY_COUNTS_INVALID`) |
|
|
918
922
|
|
|
919
923
|
```ts
|
|
@@ -935,7 +939,8 @@ export const likes = entity('likes', {
|
|
|
935
939
|
```
|
|
936
940
|
|
|
937
941
|
- **Retention is a promise `x verify` checks.** A `retain` no `purge()` covers is `X_ENTITY_RETAIN_UNSWEPT` in the `manifest` step. `purge({ entities: 'declared' })` covers every one, history tables included, and needs no line per entity.
|
|
938
|
-
- **History is recorded by trigger**, so `updateWhere`, a cascade and raw SQL are recorded too. An update that changes nothing records nothing; a change to a counted column alone records nothing. `.sealed()` columns stay ciphertext in the images. `actor_id`/`request_id` are what the WRITE'S transaction set (`x.actor`, `x.request`): the repository sets them before its first write to a history entity inside a transaction; an autocommit write records `null`, never a guess. Update of a history row is refused always; delete only under `x.purge` naming that table, which the retention sweep sets (`X_ENTITY_APPEND_ONLY`, SQLSTATE `23001`). Reading it is an ordinary, tenant-scoped, cursor-paged read: `database({ posts, postsHistory: posts.$history })`.
|
|
942
|
+
- **History is recorded by trigger**, so `updateWhere`, a cascade and raw SQL are recorded too. An update that changes nothing records nothing; a change to a counted column, or to columns `history: { ignore }` names, alone records nothing — on both drivers (`history-ignore.test.ts`). `ignore` takes the entity's own columns, typed; another name is `X_INVARIANT_VIOLATED`. Declaring it changes the trigger's arguments, so `x db gen` writes the migration that reinstalls it. `.sealed()` columns stay ciphertext in the images. `actor_id`/`request_id` are what the WRITE'S transaction set (`x.actor`, `x.request`): the repository sets them before its first write to a history entity inside a transaction; an autocommit write records `null`, never a guess. Update of a history row is refused always; delete only under `x.purge` naming that table, which the retention sweep sets (`X_ENTITY_APPEND_ONLY`, SQLSTATE `23001`). Reading it is an ordinary, tenant-scoped, cursor-paged read: `database({ posts, postsHistory: posts.$history })`.
|
|
943
|
+
- **One row's history is `history(db.postsHistory, id)`**: every version, oldest first, each numbered `version` from 1 — ordered by chaining each `before` onto the previous `after` across every version, `at` only breaking ties: `at` is the transaction's START, so a transaction that began first and committed last carries the earlier `at` and the later image. `history(table, id, { limit: n })` reads the `n` versions with the latest `at` (ties at the edge kept), numbered as the whole history numbers them — chosen by transaction start, so a transaction that began before that window and committed inside it can fall outside. The read is the history table's, so another tenant's row reads back `[]`; the policy is the query or action that calls it. `version` counts what is retained: after a `retain` sweep, 1 is the oldest kept. As of 31.3.
|
|
939
944
|
- **A counter locks its parent row.** A hot parent serializes its writers; where that matters, `countBy` plus a cache is the alternative. A soft-deleted child is not counted. A new counter's migration recounts once, so an existing table starts true; `x db recount posts.likeCount` reports drift and `--write` repairs it.
|
|
940
945
|
- **A counter's write is the trigger's, not the repository's.** The WAL replicator reports it; the in-process `entity.row` event (what `x dev` on PGlite and the memory driver feed live queries from) does not, so a live view of the counter on those does not move until the parent row is written again. A counter a page shows live stays the mutator's job until that event reports trigger writes. As of 2026-11.
|
|
941
946
|
- **Memory answers as Postgres does**: the memory driver records history and moves counters in its repository (`counter.test.ts`, `history.test.ts` are the parity tables).
|
|
@@ -355,7 +355,7 @@ Rule: an `uploadScanner` returned from `apps/<app>/runtime.ts` is asked about ev
|
|
|
355
355
|
|
|
356
356
|
| Fact | Detail |
|
|
357
357
|
|---|---|
|
|
358
|
-
| the port | `UploadScanner = { name, holds?, scan({ key, pendingKey, size, contentType, body }) → Promise<ScanVerdict> }` on `@ultimat3/storage/adapter`. `key` is the per-attempt scan copy, `pendingKey` the upload's own key, stable across retries —
|
|
358
|
+
| the port | `UploadScanner = { name, holds?, scan({ key, pendingKey, revision, size, contentType, body }) → Promise<ScanVerdict> }` on `@ultimat3/storage/adapter`. `key` is the per-attempt scan copy, `pendingKey` the upload's own key, stable across retries, `revision` which bytes are under it (the etag, or `sha256:<hex>`) — a `hold` is decided by `(pendingKey, revision)`, because the upload URL stays valid and a rewrite is new bytes (31.3). "Cannot decide" is a rejection, never a verdict. A scanner that answers `hold` declares `holds: true`; a `hold` from one that did not is `X_INVARIANT`, nothing attached |
|
|
359
359
|
| the reference | `memoryUploadScanner()` flags the EICAR test string (`EICAR_TEST_STRING`), across chunk boundaries |
|
|
360
360
|
| prove yours | `behavesLike(uploadScannerConformance, () => yours)` from `@ultimat3/testing/conformance` |
|
|
361
361
|
| ClamAV | the app's adapter (axiom 8): stream `body` to clamd's `INSTREAM` over `Bun.connect`; `stream: OK` → clean, `stream: <sig> FOUND` → infected, anything else → reject |
|
package/wiki/Testing.md
CHANGED
|
@@ -918,6 +918,7 @@ await insertSeedGraph(graph, writer);
|
|
|
918
918
|
| soft delete | a soft-deleting table's `deletedAt` is `null` unless a factory builds it: seeded rows are live |
|
|
919
919
|
| `factories` | `{ factories: { posts: myFactory } }` — what the factory builds wins, except keys and the tenant column, which stay the graph's |
|
|
920
920
|
| determinism | defaults `tenants: 2`, `perTable: 3` (per tenant for a tenant-scoped table), `seed` the package's `DEFAULT_SEED`. Same seed, same bytes |
|
|
921
|
+
| partitions | an `entity({ partitionBy })` column takes values in the UTC bucket holding `now` — the partition the migration makes first, read off `$describe().partition` — a `date()` as `YYYY-MM-DD`, a `timestamp()` as an instant. `now` defaults to `systemClock.now()`; under a frozen test clock, pass the database's `select now()` (`As of 31.3`) |
|
|
921
922
|
| `beside` | `{ beside: earlier }` — a graph already written to the same database. Each table's row positions (the ordinal a generated integer, date or money is built from; a factory's `index`, reached by replaying its builds after `reset()`) continue past `earlier.next[table]`, so no value built from a position repeats one of its rows on a unique column. `graph.next` is cumulative: chain a third graph beside the second |
|
|
922
923
|
| canaries | each row's generated text carries a token; `graph.canaries` lists it per row with the columns holding it, so a later read can say whose row it saw |
|
|
923
924
|
| writing | `insertSeedGraph(graph, writer)`: every insert in order, then every update, sequentially. `entitySeedWriter({ entities, client })` (Postgres or PGlite) or `entitySeedWriter({ entities, driver? })` (a driver; default `defaultDriver()`) writes through each entity's own repository. A row whose entity the writer was not given is `X_SEED_GRAPH_ENTITY_UNKNOWN` |
|