@ultimat3/cli 31.1.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.
Files changed (42) hide show
  1. package/CLAUDE.md +3 -3
  2. package/package.json +29 -29
  3. package/src/app-load.ts +3 -2
  4. package/src/binding-names.ts +124 -0
  5. package/src/browser-transport.ts +28 -0
  6. package/src/cmd-doctor.ts +8 -0
  7. package/src/cmd-exercise.ts +13 -1
  8. package/src/cmd-upgrade.ts +28 -4
  9. package/src/dev-boot.ts +4 -5
  10. package/src/dev-rebuild.ts +38 -5
  11. package/src/doctor-typescript.ts +31 -0
  12. package/src/error-codes.ts +2 -0
  13. package/src/island-build-pool.ts +35 -0
  14. package/src/island-bundle.ts +137 -176
  15. package/src/island-cache-inputs.ts +141 -0
  16. package/src/island-duplicates.ts +36 -0
  17. package/src/island-group-cache.ts +289 -0
  18. package/src/island-groups.ts +117 -0
  19. package/src/island-outputs.ts +153 -0
  20. package/src/island-runtime.ts +5 -0
  21. package/src/island-styles.ts +68 -19
  22. package/src/mcp-errors-shot.ts +49 -0
  23. package/src/mcp-errors.ts +5 -41
  24. package/src/measure-scope.ts +17 -4
  25. package/src/messages-upgrade.ts +2 -0
  26. package/src/offline-ports.ts +106 -0
  27. package/src/prerender.ts +2 -2
  28. package/src/runtime-storage-boot.ts +41 -7
  29. package/src/templates/scaffold-repo.ts +2 -1
  30. package/src/templates/sign-in-oidc.ts +24 -9
  31. package/src/transport-calls.ts +7 -3
  32. package/src/transport-values.ts +59 -0
  33. package/src/typescript-floor.ts +83 -0
  34. package/src/upgrade-report.ts +8 -1
  35. package/src/verify-e2e.ts +17 -5
  36. package/wiki/Client-Data.md +14 -8
  37. package/wiki/Configuration.md +1 -1
  38. package/wiki/Deployment.md +1 -1
  39. package/wiki/Entities-And-Migrations.md +15 -10
  40. package/wiki/Storage-And-Uploads.md +1 -1
  41. package/wiki/Testing.md +1 -0
  42. package/wiki/Upgrading.md +17 -4
@@ -0,0 +1,59 @@
1
+ // The global `fetch` handed on as a VALUE in one file's text — `rpc({ fetch })`, `fetch: fetch`,
2
+ // `const f = window.fetch`, `make(globalThis.fetch)` — the bypass `transportCalls` cannot see: the
3
+ // call happens in the module it was passed to, as `options.fetch(url)`, a property no rule reads.
4
+ // Pure, beside `transport-calls.ts`; the caller decides which file may hold it.
5
+
6
+ import { maskLiterals } from '@ultimat3/core';
7
+ import type { TransportCall } from './transport-calls';
8
+ import { bindsFetch } from './transport-calls';
9
+ import { lineIndex } from './ts-scan';
10
+
11
+ /**
12
+ * `fetch` not after `.`/a word char (a property on another object, `prefetch`), optionally behind
13
+ * the global object, not followed by a word char (`fetchUser`) — and never a call, which is
14
+ * `transportCalls`' finding already.
15
+ */
16
+ const VALUE =
17
+ /(?<![\w$.])((?:(?:globalThis|window|self)\s*\.\s*)?)fetch(?![\w$])(?!\s*(?:\?\.\s*)?\()/g;
18
+
19
+ /** Every blank from `lastIndex` on, sticky: the scan stops at the next token, never the file end. */
20
+ const BLANK = /\s*/y;
21
+
22
+ /** The last non-blank character before `index`, or `''`. */
23
+ function before(masked: string, index: number): string {
24
+ for (let at = index - 1; at >= 0; at -= 1) {
25
+ const char = masked[at] ?? '';
26
+ if (!/\s/.test(char)) return char;
27
+ }
28
+ return '';
29
+ }
30
+
31
+ /** Where the name sits is no value: a type, an object/interface key, an assignment target. */
32
+ function isNotAValue(masked: string, start: number, end: number): boolean {
33
+ // `typeof fetch`, `typeof globalThis.fetch` — a type position (or a feature probe, no request).
34
+ if (/\btypeof\s*$/.test(masked.slice(Math.max(0, start - 12), start))) return true;
35
+ // Through every blank: masking turned comments into spaces, so `fetch /* c */ :` is a key too.
36
+ BLANK.lastIndex = end;
37
+ BLANK.test(masked);
38
+ const after = masked.slice(BLANK.lastIndex, BLANK.lastIndex + 3);
39
+ // `{ fetch: impl }`, `fetch?: Fn` — a key; `a ? fetch : b` is the ternary's value.
40
+ if (/^\??\s*:(?!:)/.test(after) && before(masked, start) !== '?') return true;
41
+ // `window.fetch = wrapped`, `<C fetch={…}>` — the name is written to, not read.
42
+ return /^=(?![=>])/.test(after);
43
+ }
44
+
45
+ export function fetchValues(source: string): readonly TransportCall[] {
46
+ if (!source.includes('fetch')) return [];
47
+ // Comments and strings blanked, offsets kept: `'fetch'` in a message is not the global.
48
+ const masked = maskLiterals(source);
49
+ const lineAt = lineIndex(masked);
50
+ const shadowed = bindsFetch(masked);
51
+ const values: TransportCall[] = [];
52
+ for (const found of masked.matchAll(VALUE)) {
53
+ const global = (found[1] ?? '').replace(/\s/g, '');
54
+ if (global === '' && shadowed) continue;
55
+ if (isNotAValue(masked, found.index, found.index + found[0].length)) continue;
56
+ values.push({ shape: 'fetch', line: lineAt(found.index), spelled: `${global}fetch` });
57
+ }
58
+ return values;
59
+ }
@@ -0,0 +1,83 @@
1
+ // The TypeScript an EXISTING app declares, held to the one `x new` scaffolds (`TYPESCRIPT_VERSION`).
2
+ // `@ultimat3/*` ships source and `.d.ts` checked by that compiler: an app a major behind is red on
3
+ // the framework's own files (TS2769 in `cdp-shot-keys.ts` under 6.0.3), whatever its own code says.
4
+ // Pure over manifest text; `x upgrade` and `x doctor` each report what it returns.
5
+
6
+ import { quoteArg } from './shell-quote';
7
+ import { TYPESCRIPT_VERSION } from './templates/scaffold-repo';
8
+
9
+ export interface TypescriptLag {
10
+ /** The manifest declaring it, relative to the app root, POSIX. */
11
+ readonly file: string;
12
+ readonly field: 'dependencies' | 'devDependencies';
13
+ readonly from: string;
14
+ readonly to: string;
15
+ /** The one command that moves it, run from the app root. */
16
+ readonly fix: string;
17
+ }
18
+
19
+ /** The floor a plain range admits: `^6.0.3`, `~6.0`, `>=5.4`, `6.0.3` → its numbers; else none. */
20
+ const PLAIN = /^\s*(?:\^|~|>=|=)?\s*v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:-[\w.]+)?\s*$/;
21
+
22
+ export function lowerBound(range: string): readonly number[] | undefined {
23
+ const match = PLAIN.exec(range);
24
+ if (match === null) return undefined;
25
+ return [match[1], match[2], match[3]].map((part) => Number(part ?? '0'));
26
+ }
27
+
28
+ /** Strictly below, part by part. A prerelease of the floor itself reads as the floor. */
29
+ export function isBelow(held: readonly number[], floor: readonly number[]): boolean {
30
+ for (let at = 0; at < floor.length; at += 1) {
31
+ const left = held[at] ?? 0;
32
+ const right = floor[at] ?? 0;
33
+ if (left !== right) return left < right;
34
+ }
35
+ return false;
36
+ }
37
+
38
+ const FIELDS = ['devDependencies', 'dependencies'] as const;
39
+
40
+ const declared = (text: string, field: string): string | undefined => {
41
+ try {
42
+ const parsed: unknown = JSON.parse(text);
43
+ if (typeof parsed !== 'object' || parsed === null) return undefined;
44
+ const block: unknown = Reflect.get(parsed, field);
45
+ if (typeof block !== 'object' || block === null) return undefined;
46
+ const range: unknown = Reflect.get(block, 'typescript');
47
+ return typeof range === 'string' ? range : undefined;
48
+ } catch {
49
+ // An unreadable manifest is `bun install`'s finding, named with its line; here it says nothing.
50
+ return undefined;
51
+ }
52
+ };
53
+
54
+ /** `bun add` from the app root, `--cwd` into a workspace, `-d` where it was a devDependency. */
55
+ const fixFor = (file: string, field: TypescriptLag['field'], to: string): string => {
56
+ const dir = file.includes('/') ? file.slice(0, file.lastIndexOf('/')) : '';
57
+ return [
58
+ 'bun add',
59
+ ...(field === 'devDependencies' ? ['-d'] : []),
60
+ quoteArg(`typescript@${to}`),
61
+ ...(dir === '' ? [] : ['--cwd', quoteArg(dir)]),
62
+ ].join(' ');
63
+ };
64
+
65
+ /**
66
+ * Every manifest whose `typescript` range admits a compiler below the scaffold's. A range this
67
+ * cannot read (`latest`, `catalog:`, `workspace:*`, `5 || 6`) is not judged: no claim beats a
68
+ * wrong one, and `x verify`'s typecheck still answers for it.
69
+ */
70
+ export function typescriptLags(
71
+ manifests: readonly { readonly file: string; readonly text: string }[],
72
+ to: string = TYPESCRIPT_VERSION,
73
+ ): readonly TypescriptLag[] {
74
+ const floor = lowerBound(to) ?? [];
75
+ return manifests.flatMap(({ file, text }) =>
76
+ FIELDS.flatMap((field) => {
77
+ const from = declared(text, field);
78
+ const held = from === undefined ? undefined : lowerBound(from);
79
+ if (from === undefined || held === undefined || !isBelow(held, floor)) return [];
80
+ return [{ file, field, from, to, fix: fixFor(file, field, to) }];
81
+ }),
82
+ );
83
+ }
@@ -3,6 +3,7 @@
3
3
 
4
4
  import { msg } from './messages';
5
5
  import type { JsonValue } from './output';
6
+ import type { TypescriptLag } from './typescript-floor';
6
7
  import type { AgentsLinkState } from './upgrade-agents-link';
7
8
  import type { BunEdit, BunManual } from './upgrade-bun-floor';
8
9
  import type { GateFinding, HopGate, RepoScript } from './upgrade-gate';
@@ -69,8 +70,10 @@ export const humanLines = (input: {
69
70
  readonly scripts: readonly RepoScript[];
70
71
  readonly then: string;
71
72
  readonly agentsMd?: AgentsLinkState;
73
+ /** Manifests whose TypeScript lags the scaffold's: by hand, the hop never moves a compiler. */
74
+ readonly typescript: readonly TypescriptLag[];
72
75
  }): readonly string[] => {
73
- const { hop, writes, gate, scripts, then, agentsMd } = input;
76
+ const { hop, writes, gate, scripts, then, agentsMd, typescript } = input;
74
77
  return [
75
78
  ...(hop.section === null
76
79
  ? []
@@ -81,6 +84,7 @@ export const humanLines = (input: {
81
84
  ...writes.manual.map((site) =>
82
85
  msg('cli.upgrade.bunManual', { path: site.path, line: site.line, why: site.why }),
83
86
  ),
87
+ ...typescript.map((lag) => msg('cli.upgrade.typescript', { ...lag })),
84
88
  ...(agentsMd === 'link' || agentsMd === 'differs'
85
89
  ? [msg(agentsMd === 'link' ? 'cli.upgrade.agentsMd.link' : 'cli.upgrade.agentsMd.differs')]
86
90
  : []),
@@ -118,6 +122,8 @@ export const report = (input: {
118
122
  readonly then: string;
119
123
  /** What the hop does to `AGENTS.md` (`upgrade-agents-link.ts`); absent when no hop is planned. */
120
124
  readonly agentsMd?: AgentsLinkState;
125
+ /** `typescript-floor.ts`'s lags — reported on every outcome, an at-target app's included. */
126
+ readonly typescript: readonly TypescriptLag[];
121
127
  }): JsonValue => {
122
128
  const { hop, done, dryRun, pins, bunFrom, bunTo, writes, app, gate, scripts, then } = input;
123
129
  return asJson({
@@ -135,6 +141,7 @@ export const report = (input: {
135
141
  .filter((pin) => pinMoves(pin.spec, hop.to))
136
142
  .map((pin) => ({ file: pin.file, name: pin.name, from: pin.spec, to: hop.to })),
137
143
  bun: { from: bunFrom, to: bunTo, edited: writes.edited, manual: writes.manual },
144
+ typescript: input.typescript,
138
145
  agentsMd: input.agentsMd ?? null,
139
146
  guards: gate?.guards ?? null,
140
147
  manifest: gate?.manifest ?? null,
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
- const [bun = 'bun', test = 'test', ...rest] = input.command;
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
  }
@@ -177,18 +177,24 @@ Full rows: [Error codes](Error-Codes).
177
177
 
178
178
  ## Shared island chunks
179
179
 
180
- **`islands: { sharedChunks: true }` in `app.config.ts` builds every island in one split build**, so
181
- a module two islands import is one `/islands/chunk-<hash>.js` a page fetches once. Off by default,
182
- by measurement (`packages/core/src/config-islands.ts`): tree shaking across one build keeps what
183
- any importer uses, so an island that takes one helper from a module the others use heavily pays for
184
- all of it — the reference app's plain-DOM update banner went 712 → 16,288 B with it on.
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
- | one surface's pages render several islands over one shared graph (the same form kit, the same chart) | an island is small and plain-DOM, or the islands share little |
189
- | `x build --target static`, then `x verify --only budgets`, shows the routes that render several islands getting smaller | any route's `budget.js` grows past its budget |
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-10`.
199
+ 2026-11`.
194
200
 
@@ -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` builds each island alone, self-contained. Off by default because tree shaking across one split build keeps what ANY importer uses: 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 where pages render several islands over one graph, then weigh the routes with `x verify`. A non-boolean → `X_CONFIG_INVALID` |
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
 
@@ -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
- **`iff` renders `=`, not `IS NOT DISTINCT FROM`, and that is not an oversight.** Every operator in
92
- this language is *false* on a null operand in TypeScript, and `=` between two booleans where either
93
- is NULL yields NULL — which a CHECK **passes**. The total form fixes that row and breaks a worse
94
- one: with a partial operand it makes Postgres **refuse a row TypeScript accepted**, which reaches
95
- the caller as a raw `23514` instead of `X_INVARIANT_VIOLATED`. `=` keeps the disagreement in the
96
- direction where the app refuses first, so no write reaches a CHECK that would have refused it.
97
- Where both operands are total — a non-nullable column, an `IS NOT NULL` — the two spellings are the
98
- same predicate, measured.
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 — what a `hold` is decided by. "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 |
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` |
package/wiki/Upgrading.md CHANGED
@@ -65,6 +65,8 @@ Each entry changes a surface the table below covers.
65
65
 
66
66
  `As of 2026-11-10`, released: the 74 breaking entries of `CHANGELOG.md`'s `## 31.0.0` section, in their order. No legacy path, no codemod, no shim. v31 is the stable line — the next major waits for its window ([Stability](Stability)).
67
67
 
68
+ **Move TypeScript to `^7.0.2` first** — `bun add -d typescript@^7.0.2` in every workspace that declares it, then `bun install`. `@ultimat3/cli` ships its `.ts` source, and your typecheck reads it: under TypeScript 6 with `exactOptionalPropertyTypes` (on in every `x new` tsconfig), `node_modules/@ultimat3/cli/src/cdp-shot-keys.ts` fails TS2769 at 26:43, so the gate is red before any entry below applies. Since 22.0.0 ([the `22.0.0` section](#21x--2200-entry-by-entry)); `x upgrade` moves the `@ultimat3/*` pins, never `typescript`. From 31.2.0, `x doctor` raises `X_TYPESCRIPT_VERSION` per lagging manifest, its fix the exact `bun add`, and `x upgrade` reports the same lag in `data.typescript` — reported only, never written. `x new` scaffolds `TYPESCRIPT_VERSION` (`packages/cli/src/templates/scaffold-repo.ts`). `As of 2026-11`, measured: TypeScript 6.0.3 reports TS2769 on that file, 7.0.2 nothing.
69
+
68
70
  ### The upgrade, top to bottom
69
71
 
70
72
  | # | Do | What you see until you do | Entries |
@@ -72,7 +74,7 @@ Each entry changes a surface the table below covers.
72
74
  | 1 | commit, then `bunx @ultimat3/cli@latest upgrade --json`: it pins every `@ultimat3/*`, installs and runs the gate | `X_UPGRADE_DIRTY_TREE` on a dirty tree | — |
73
75
  | 2 | `x verify --only typecheck` and close every error: a hand-written `AuthServerStore` or `PreferenceStore`, an import of a removed Redis script or of `MAX_WIRE_ISSUES`, a hand-built `ActionDeniedError`/`QueryDeniedError`, a `set*` job/event-bus/mail/idempotency/meter/notify setter (a `runtime.ts` field), a factory's `associate()` or `buildMany`, a `setAuditSink`/`configureKdfGate`/`configureErrorReporting({ reporter })` call, a `runtime.storage` built with `defineStorage`, a `PushSubscriptionRecord` with `actorId: null`, a `configureAi({ embedder, semanticCache })` or `configureMetrics({ exporter })` call, an import of a framework mail or `noopMetricExporter`, an exhaustive `switch` over `AuditPrimitive` or `ScanVerdict`, `grantUpload({ quarantine })` or `releaseQuarantine`, an import of a name that left a package's `.` (entry 74's list), a gateway `retry` or realtime `backoff` in the old field names, a boolean job `retry.jitter`, a `setLogSink` call, realtime's `Row`, `Surface` from seo or `SURFACES` from render, a hand-written `SearchIndex` without `list`, a `registerActions`/`registerQuery` call | TS2741, TS2554, TS2305, TS2322 | 1, 6, 10, 14, 18, 29, 36, 40, 43–45, 48, 50, 51, 54–65, 67, 71, 72, 74 |
74
76
  | 3 | `x verify --only unit,contract`: shorten a name over 63 bytes, write each `cors.origins` entry as its own `URL.origin`, rename an unsafe storage key or header value, switch a `fromDecimal` branch to `X_MONEY_NOT_DECIMAL`, read a truncated validation through `issuesTruncated`, pass `expose: true` to an `mcpTools()` whose tools your `/mcp` serves, name `localhost` exactly in an `allowHosts` that reaches it through `'*'`, compare a resolved disk by `.name`, advance the version in a custom store's `upsert`, drop `target` from a grant while a scanner is installed | `X_SQL_UNSAFE`, `X_CORS_CONFIG_INVALID` at boot, `X_STORAGE_PATH_UNSAFE`, `X_INVARIANT`, `X_MONEY_NOT_DECIMAL`, a remote tool missing from your `tools/list`, `X_SCRAPE_HOST_BLOCKED` for a `localhost` URL, `X_STORAGE_TARGET_UNSCANNED` | 2, 4, 7, 9, 11, 12, 19, 22, 27, 69, 70 |
75
- | 4 | **before the deploy:** list stored objects whose keys the new rule refuses and copy them; cache a projection where a value passes 1 MiB; keep `redisTier`'s default `buildId` or plan the one-time bust; on `docker/helm`, move a pod that reads the metadata endpoint to a workload identity; name a Postgres `notifyStores.ledger` in `runtime.ts` if a notifier runs; add `/auth/sso/<provider>/callback` as a redirect URI at every OAuth IdP and point sign-in links at `/auth/sso/<provider>`; with objects still under `org/*/pending/quarantine/`, install an `uploadScanner` answering `hold` for them | a read of an old key refused; a cache miss logged `X_CACHE_TOO_LARGE`; stale tagged keys until their TTL; a metadata-endpoint timeout; `X_NOTIFY_STORE_MISSING` on the first notification | 5, 6, 11, 16, 49, 52, 57 |
77
+ | 4 | **before the deploy:** list stored objects whose keys the new rule refuses and copy them; cache a projection where a value passes 1 MiB; keep `redisTier`'s default `buildId` or plan the one-time bust; on `docker/helm`, move a pod that reads the metadata endpoint to a workload identity; name a Postgres `notifyStores.ledger` in `runtime.ts` if a notifier runs; add `https://<origin>/auth/sso/<provider>/callback` as a redirect URI at every OAuth IdP **before the new image rolls**, keep `/auth/oauth/<provider>/callback` registered until the last old pod is gone, and point sign-in links at `/auth/sso/<provider>`; with objects still under `org/*/pending/quarantine/`, install an `uploadScanner` answering `hold` for them | a read of an old key refused; a cache miss logged `X_CACHE_TOO_LARGE`; stale tagged keys until their TTL; a metadata-endpoint timeout; `X_NOTIFY_STORE_MISSING` on the first notification | 5, 6, 11, 16, 49, 52, 57 |
76
78
  | 5 | **after the deploy:** declare `maxPage` on a read a client pages past 500 rows (`X_INPUT_INVALID` until you do); treat exit `70` as "drained, work abandoned" in alerts; read rate-limit keys through `addressNetwork`; switch on `denial.surface === 'mcp'` for an MCP read; honour `{ etag }` in a hand-written storage driver; give the collector a logs pipeline or set `OTEL_LOGS_EXPORTER=none`; with an external search index, run each `reindex()` once with `x db backfill <name> --write --force --json` so its sweep drops what the table lost | nothing fails: an alert, a dashboard filter or an ETag answers differently | 3, 8, 13, 14, 17, 28, 30, 66, 73 |
77
79
  | 6 | `x db gen "tenant indexes"`, commit `packages/db/migrations` and `packages/db/schema/`; the new index builds `concurrently`, so a hot table keeps taking writes | `X_DB_DRIFT` from `x verify --only drift` | 20 |
78
80
 
@@ -121,10 +123,10 @@ Tier 0 — `@ultimat3/core` (3), (23), (25), (31), (33–35), (43), (51), (55),
121
123
  | 37 | `httpServer({ rateLimitStore })`, `installRateLimitStore`, `adoptRateLimitStore` (`@ultimat3/http`), `configureAuthLimiters`, `configureTotpReplay` (`@ultimat3/auth`), `setScrapeDriver` (`@ultimat3/scraping`), and their resets | you passed a store to `httpServer` or called an installer yourself: TS2353/TS2305 — set `rateLimitStore`, `authLimiter`, `totpReplay` or `scrapeDriver` in `export const runtime = { … }` (`apps/<app>/runtime.ts`); every server's limiter counts in that one store. A boot or test harness imports `installRateLimitStore` from `@ultimat3/http/adapter`, `installAuthLimiters`/`installTotpReplay` (renamed from `configure*`) from `@ultimat3/auth/adapter`, `installScrapeDriver` from `@ultimat3/scraping/adapter` — each answers its release — and `resetRateLimitStore`, `resetAuthLimiters`, `resetTotpReplay`, `resetScrapeDriver` from the same subpaths, never `.` |
122
124
  | 38 | `ScrapeClock`, `TestScrapeClock`, `systemScrapeClock`, `noWaitClock`, `testScrapeClock`, `scrapeClock`, `setScrapeClock`, `resetScrapeClock` (`@ultimat3/scraping`), `configureFlags({ clock })` (`@ultimat3/flags`) | TS2305 / TS2353 — import `SleepClock`, `FrozenClock`, `systemClock`, `noWaitClock`, `frozenClock`, `ambientClock` from `@ultimat3/core`; replace `setScrapeClock(c)` … `resetScrapeClock()` with `const release = installClock(c)` (`@ultimat3/core/adapter`) … `release()`; drop `clock` from `configureFlags` and set `clock` in `apps/<app>/runtime.ts`. A test that asserted a frozen clock advanced on an already-aborted sleep now reads 0 |
123
125
  | 39 | `AuditSink` (`@ultimat3/admin`) | TS2305 on the import — `import type { AuditSink } from '@ultimat3/core/adapter'` and type the sink `AuditSink<AuditEntry>` |
124
- | 40 | `associate`, `associations`, `Association`, `AssociationMap`, `buildMany`, `createMany`, `Persister` (`@ultimat3/testing`) | TS2305/TS2353/TS2339 — `associations: { orgId: associate(orgs, (o) => o.id) }` becomes `belongsTo: { org: belongsTo(orgs, 'orgId') }` (keep `orgId` in `defaults`); rename `buildMany`/`createMany` to `buildList`/`createList`; a hand-written persister is `insert(entity, row)` answering the stored row — or delete it and `usePersister(entityPersister({ driver }))`. A test that asserted `create()` returned the BUILT row now sees the stored one (defaults filled); a test that expected `X_TEST_FACTORY_NOT_PERSISTED` for a real `entity()` now writes to `defaultDriver()` |
126
+ | 40 | `associate`, `associations`, `Association`, `AssociationMap`, `buildMany`, `createMany`, `Persister` (`@ultimat3/testing`) | TS2305/TS2353/TS2339 — `associations: { orgId: associate(orgs, (o) => o.id) }` becomes `belongsTo: { org: belongsTo(orgs, 'orgId') }` (keep `orgId` in `defaults`); rename `buildMany`/`createMany` to `buildList`/`createList`; a hand-written persister is `insert(entity, row)` answering the stored row — or delete it and `usePersister(entityPersister({ driver }))`. A test that asserted `create()` returned the BUILT row now sees the stored one (defaults filled); a test that expected `X_TEST_FACTORY_NOT_PERSISTED` for a real `entity()` now writes to `defaultDriver()`. 31.0.0–31.1.0 widened a string literal in `defaults` to `string` (TS2322 on an `enumerated` column); 31.2.0 keeps it, so an `as const` added for that can go |
125
127
  | 41 | `configureAi({ gateway })` (`@ultimat3/ai`) | TS2353 on `gateway` — set `aiGateway` in `export const runtime = { … }` (`apps/<app>/runtime.ts`); keep `configureAi` for `embedder`, `semanticCache`, `redact` only. A test installs one with `const release = installAiGateway(gateway)` from `@ultimat3/ai/adapter` and calls `release()` after |
126
128
  | 42 | `RuntimeOverrides.syncAuthenticate` (`@ultimat3/cli`) | TS2353 on `syncAuthenticate` in `runtime.ts` — delete it; state a token's lifetime as `configureAuthenticator(resolve, { credentialTtlMs })`. A `<app>/packages/db/factories.ts` exporting `factories` is now linted by `unit`: `X_TEST_FACTORY_INVALID` names the factory and trait to fix |
127
- | 43 | `setAuditSink`, `resetAuditSink`, `configureErrorReporting({ reporter })` (`@ultimat3/core`) | TS2305 / TS2322 (`reporter` is `never`) — set `auditSink` / `errorReporter` in `export const runtime = { … }` (`apps/<app>/runtime.ts`), not at module scope. A test: `const release = installAuditSink(sink)` / `installErrorReporter(reporter)` from `@ultimat3/core/adapter`, `release()` after — or `swapAdapter('auditSink', sink)` from `@ultimat3/testing`. `configureErrorReporting` keeps `clock`, `release`, `environment`, `enabled` |
129
+ | 43 | `setAuditSink`, `resetAuditSink`, `configureErrorReporting({ reporter })` (`@ultimat3/core`) | TS2305 / TS2322 (`reporter` is `never`) — set `auditSink` / `errorReporter` in `export const runtime = { … }` (`apps/<app>/runtime.ts`), not at module scope. A test: `const release = installAuditSink(sink)` / `installErrorReporter(reporter)` from `@ultimat3/core/adapter`, `release()` after — or `swapAdapter('auditSink', sink)` from `@ultimat3/testing`. `configureErrorReporting` keeps `clock`, `release`, `environment`, `enabled`. Through 31.1.0, `x exercise` and `x build`'s measurement did not read `runtime.ts`, so the sink declared there was missing in both ("Not breaking, but you will see it", below); 31.2.0 reads it, and a memory sink installed in `apps/web/exercise.ts` or `prerender.ts` as the workaround can be deleted |
128
130
  | 44 | `configureKdfGate`, `resetKdfGate` (`@ultimat3/auth`) | TS2305 — `const release = installKdfGate({ maxConcurrent, maxQueued })` from `@ultimat3/auth/adapter`, `release()` (or `resetKdfGate()`, same subpath) after |
129
131
  | 45 | `RuntimeOverrides.storage` (`@ultimat3/cli`) | TS2322 when `runtime.ts` passes `defineStorage({ … })` — pass the driver (`storage: s3Driver({ … })`): it is the default disk under the driver's `name`. Several disks: `defineStorage()` in `app.config.ts`, which wins |
130
132
  | 46 | `jobDriverConformance`, `budgetStoreConformance`, `BudgetStoreLike` (`@ultimat3/testing`) | TS2305 — import them from `@ultimat3/testing/conformance`, where every port's suite lives; `behavesLike` stays on `@ultimat3/testing` |
@@ -133,7 +135,7 @@ Tier 0 — `@ultimat3/core` (3), (23), (25), (31), (33–35), (43), (51), (55),
133
135
  | 49 | the default delivery ledger (`@ultimat3/notify`) | you deploy (staging or production) with no `notifyStores.ledger` in `runtime.ts` and a notifier runs: its first claim is `X_NOTIFY_STORE_MISSING`, where a memory ledger answered — one per process, so a replay on another replica or after a restart sent twice. Set `notifyStores: { ledger: postgresDeliveryLedger({ executor: dbExecutor() }) }` in `export const runtime = { … }` (`apps/<app>/runtime.ts`); the boot already applies `x_notify_deliveries`. Name every store you keep in that one object — it replaces, never merges. Development and test keep the memory default |
134
136
  | 50 | `configureAi({ embedder, semanticCache })` (`@ultimat3/ai`) | TS2353 on `embedder` / `semanticCache` — set them in `export const runtime = { embedder, semanticCache }` (`apps/<app>/runtime.ts`); `semanticCache` is the same `(scope) => SemanticCache` factory. `configureAi` keeps `redact` only. A test: `const release = installAiEmbedder(embedder)` / `installSemanticCache(factory)` from `@ultimat3/ai/adapter`, `release()` after — or `swapAdapter('embedder', …)` from `@ultimat3/testing`. Prove one with `embedderConformance` / `semanticCacheFactoryConformance` from `@ultimat3/testing/conformance` |
135
137
  | 51 | `configureMetrics({ exporter })` (`@ultimat3/core`) | TS2353 on `exporter` — subscribe it: `const release = subscribe('metric.export', (event) => exporter.export(event.payload))`, `release()` to uninstall; `exportMetrics()` / `startMetricExport(ms)` publish the tick as before. `configureMetrics` keeps `clock` and `enabled`. With `OTEL_EXPORTER_OTLP_ENDPOINT` set the boot already subscribes `otlpMetricExporter()` |
136
- | 52 | `oauthLogin` (`@ultimat3/auth`) — its paths, cookie and `restartAt` | the routes moved from `/auth/oauth/:provider[/callback]` to `/auth/sso/:provider[/callback]` (`oauthStartPath`/`oauthCallbackPath`/`OAUTH_*_ROUTE_PATH` answer the new values; the call and its options are unchanged). **Before deploying, add `https://<origin>/auth/sso/<provider>/callback` as an allowed redirect URI at each IdP** (GitHub, Google, your OP) — keep the old one until the deploy is out — and point every sign-in link at `/auth/sso/<provider>`. A login started before the deploy fails its callback once (`X_OAUTH_STATE_INVALID`: the state cookie is now `__Host-x_sso_<provider>`); the user starts again. `restartAt(provider)` and every OAuth `fix:` name `/auth/sso/<provider>`. `oauthDenied` and `OAUTH_ROUTE_STATUS` keep their names on `@ultimat3/auth`; a deep import from `./oauth-route` moves to the barrel |
138
+ | 52 | `oauthLogin` (`@ultimat3/auth`) — its paths, cookie and `restartAt` | the routes moved from `/auth/oauth/:provider[/callback]` to `/auth/sso/:provider[/callback]` (`oauthStartPath`/`oauthCallbackPath`/`OAUTH_*_ROUTE_PATH` answer the new values; the call and its options are unchanged). **Before deploying, add `https://<origin>/auth/sso/<provider>/callback` as an allowed redirect URI at each IdP** (GitHub, Google, your OP) — keep the old one until the deploy is out — and point every sign-in link at `/auth/sso/<provider>`. A login started before the deploy fails its callback once (`X_OAUTH_STATE_INVALID`: the state cookie is now `__Host-x_sso_<provider>`); the user starts again. `restartAt(provider)` and every OAuth `fix:` name `/auth/sso/<provider>`. `oauthDenied` and `OAUTH_ROUTE_STATUS` keep their names on `@ultimat3/auth`; a deep import from `./oauth-route` moves to the barrel. The base path is fixed (`OAUTH_BASE_PATH`, `packages/auth/src/oauth-paths.ts`): a mid-roll pod answers on one path only, so both URIs stay registered until the roll completes. **Can't re-register the redirect URI at your IdP?** Keep the old one: `oauthLogin(auth, { callbackPath: '/auth/oauth/:provider/callback' })`, then mount `callback.path` (not `OAUTH_CALLBACK_ROUTE_PATH`); the start link stays `/auth/sso/<provider>`. **Hand-built callback?** From 31.2.0, `readHandshakeCookie` opens the cookie `oauthLogin().start` sets, so a `beginOAuth` + `handshakeCookie` start leg written as a workaround can be deleted; its in-flight cookies (`__Host-x_oauth_<p>`) are still read until 32.0.0 |
137
139
  | 53 | the raw-CDP launcher (`@ultimat3/testing` → `@ultimat3/scraping/cdp`) | an e2e suite imports `findChrome`, `launchChrome`, `CHROME_PATH_ENV`, a `Cdp*Error` or `E2E_BROWSER_CLOSE_MS` from `@ultimat3/testing` (TS2305, no exported member): `bun add -d @ultimat3/scraping`, then `import { findChrome, LAUNCHED_CLOSE_MS } from '@ultimat3/scraping/cdp';` — `E2E_BROWSER_CLOSE_MS` is `LAUNCHED_CLOSE_MS`, the same value. Everything e2e-shaped (`openE2eBrowser`, `E2E_BROWSER_OPEN_MS`, `installE2eDriver`, …) stays on `@ultimat3/testing` |
138
140
  | 54 | `welcomeMail`, `verifyEmailMail`, `resetPasswordMail`, `inviteMail`, `mfaEnrolledMail`, `securityAlertMail`, their `*Input` schemas and types, `MFA_METHODS`, `FRAMEWORK_MAILS` (`@ultimat3/mail`) | you import one (TS2305), or send a mail by one of the ids `welcome`, `verify-email`, `reset-password`, `invite`, `mfa-enrolled`, `security-alert` without declaring it — importing the package no longer registers them. Declare your own: `export const welcomeMail = defineMail<{ name: string }>({ id: 'welcome', subject: 'mail.welcome.subject', input: t.object({ name: t.string }), template: ({ data }) => [blocks.heading('mail.welcome.heading', { name: data.name })] })`, and carry every `mail.<id>.*` key it renders in `packages/i18n/catalogs/<locale>.json` — the base catalog keeps `mail.footer.*` only. Email verification and password reset are untouched: `@ultimat3/auth` sends `auth.email-verify` / `auth.password-reset` from your catalog, as before |
139
141
  | 55 | `noopMetricExporter` (`@ultimat3/core`) | you import it (TS2305): delete the import and what it was handed to — exporting nothing is subscribing nothing to `metric.export` (entry 51). A test that needs an exporter value uses `memoryMetricExporter()` |
@@ -190,6 +192,11 @@ A setter still on a package's `.` barrel is `X_ADAPTER_PORT_INCOMPLETE` on the `
190
192
  | What moved | Do |
191
193
  |---|---|
192
194
  | `x verify`'s `manifest` step is red, `X_MCP_APP_UNMOUNTED`, when `ai.mcp.expose` is `true` — **the default**, so an `app.config.ts` that never names it counts — and no `apps/web/mcp.ts` exports `mcp` (`As of 30.4.0`; before, the boot only logged it while `POST /mcp` answered 404). An app scaffolded before `x new` wrote that file hits it on its first 31.0.0 gate | mount it as `x new` does: `apps/web/mcp.ts` exporting `export const mcp = appMcp({ resolveToken: resolveAgentToken })`, `appMcp` from your `@<app>/mcp` package and `resolveAgentToken` from `./app/auth/agent-token` — copy those files (and `packages/mcp/src/index.ts`, if you have no `@<app>/mcp`) from a fresh `bunx create-ultimate`. With no catalog package, the error's own fix is the whole file: `export const mcp = defineAppMcp({ include: 'exposed', resolveToken })` (`@ultimat3/mcp`), `resolveToken` answering an agent or `null`. No agent surface wanted: `ai: { mcp: { expose: false } }` in `app.config.ts` |
195
+ | `verifyApiKey` (`@ultimat3/auth`) refuses every key with `X_API_KEY_INVALID` when the stored `prefix` is not the one the bearer parses to: since 31.0.0 it compares `parseApiKey(bearer).prefix` — always `ult_<env>_<id>` — to `record.prefix` (`packages/auth/src/api-keys.ts`, `verifyApiKey`). An app that minted keys itself, or stores a display prefix of its own (`acme_<env>_<id>`, a truncated `ult_prod`), passed on 30.x and fails every key now. A bearer not shaped `ult_<env>_<id>_<secret>` was already refused by `parseApiKey` before 31 | list the rows that cannot match: `psql "$DATABASE_URL" -c "select id, prefix from x_api_keys where prefix !~ ('^ult_[a-z0-9-]+_' \|\| id \|\| '$')"`; for each, `update x_api_keys set prefix = 'ult_<env>_' \|\| id where id = '<id>'`, `<env>` the second segment of the bearer that key's holder sends. A custom `ApiKeyStore` answers `prefix` exactly as `issueApiKey` wrote it |
196
+ | a unique collision under the memory driver — what a factory's `create()` writes to in a test since entry 40 — is `X_DB_UNIQUE_VIOLATION` with no SQLSTATE: `sqlState(e)` (`@ultimat3/db`) answers `undefined`, where Postgres answers `23505`, so a race handler matching `sqlState(e) === '23505'` passes in production and fails its test (`packages/entity/src/driver-errors.ts`, `entityUniqueViolation`) | match the code, which both drivers raise: `isUltimateError(e) && e.code === 'X_DB_UNIQUE_VIOLATION'` (`isUltimateError` from `@ultimat3/core`); `meta.constraint` names the constraint on both. Through 31.1.0 only the code matches under memory; fixed in **31.2.0**, from which the memory driver and every `defineDriver` store carry `23505` too and `sqlState(e) === SQLSTATE.uniqueViolation` (`@ultimat3/db`) also matches |
197
+ | `x exercise` reports `X_AUDIT_SINK_MISSING` (`X_QUERY_AUDIT_SINK_MISSING` for a query) on every `audit: true` primitive, and `x build` lists each page whose render runs one under `unmeasured`: entry 43 moved `auditSink` into `runtime.ts`, and neither pass installs `runtime.ts` | fixed in **31.2.0**: both read `apps/<app>/runtime.ts` through the boot's own loader, a memory sink standing in for the declared one so neither writes to it. On 31.0.0–31.1.0, install a memory sink at the top of `apps/web/exercise.ts` and `apps/web/prerender.ts` — `installAuditSink(memoryAuditSink())`, `installAuditSink` from `@ultimat3/core/adapter`, `memoryAuditSink` from `@ultimat3/action`; on 31.2.0, delete it |
198
+ | `defineFactory` (`@ultimat3/testing`, entry 40) widens a string literal in `defaults` or a trait to `string`, so an `enumerated([…])` column is TS2322 — `Type 'string' is not assignable to type '"closed" \| "open"'` | `'open' as const` on the literal. Fixed in **31.2.0**: from it, an `as const` or per-literal annotation added for this TS2322 can be deleted — kept, it is harmless |
199
+ | `disk('<name>')` is `X_STORAGE_DISK_UNKNOWN` for a disk your own `defineStorage({ disks: { … } })` declares, when an app module reached from `runtime.ts` makes that call: the boot installed its one-disk registry over it | fixed in **31.2.0**: the boot keeps a registry the app declared, and the app's `defineStorage()` wins over `runtime.storage`. Upgrade to it; no workaround is verified for 31.0.0–31.1.0 |
193
200
 
194
201
  ## 29.x → 30.0.0, entry by entry
195
202
 
@@ -1786,6 +1793,12 @@ dependency you can drop, entry 22 is one `x db gen` if `drift` asks for it, and
1786
1793
  edit. 22.0.0 is plan 101's deep sweep: every framework package, both tracked apps and the deploy
1787
1794
  path.
1788
1795
 
1796
+ **TypeScript 7 from here on — move it before this hop.** 22.0.0 added
1797
+ `packages/cli/src/cdp-shot-keys.ts`, and `@ultimat3/cli` ships its `.ts` source: under TypeScript 6
1798
+ with `exactOptionalPropertyTypes` it fails TS2769 at 26:43, in your typecheck, on every release from
1799
+ 22.0.0 through 31. `bun add -d typescript@^7.0.2` in every workspace that declares it — what `x new`
1800
+ has scaffolded since 20.0.0 (`TYPESCRIPT_VERSION`). Not a `CHANGELOG.md` entry, so not counted above.
1801
+
1789
1802
  | # | Surface | Costs you an edit if |
1790
1803
  |---|---|---|
1791
1804
  | 1 | `t.date` | you send a date that is not ISO-8601 in shape (`'March 14, 2026'`, `'3/14/2026'`, `'12'`). It is refused at validation now (`coerceQuery` no longer rewrites it). `new Date` read it at the host's local midnight, so the stored day depended on `TZ`. Send `'2026-03-14'`. Epoch-ms numbers and `Date` objects are unchanged |