@ultimat3/cli 31.10.0 → 31.12.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultimat3/cli",
3
- "version": "31.10.0",
3
+ "version": "31.12.0",
4
4
  "description": "The `x` binary: new, dev, build, verify, generate, db, mcp, doctor, deploy",
5
5
  "keywords": [
6
6
  "ultimate",
@@ -53,34 +53,34 @@
53
53
  },
54
54
  "dependencies": {
55
55
  "@babel/core": "^8.0.9",
56
- "@ultimat3/action": "31.10.0",
57
- "@ultimat3/admin": "31.10.0",
58
- "@ultimat3/ai": "31.10.0",
59
- "@ultimat3/auth": "31.10.0",
60
- "@ultimat3/cache": "31.10.0",
61
- "@ultimat3/core": "31.10.0",
62
- "@ultimat3/db": "31.10.0",
63
- "@ultimat3/entity": "31.10.0",
64
- "@ultimat3/flags": "31.10.0",
65
- "@ultimat3/http": "31.10.0",
66
- "@ultimat3/i18n": "31.10.0",
67
- "@ultimat3/jobs": "31.10.0",
68
- "@ultimat3/mail": "31.10.0",
69
- "@ultimat3/manifest": "31.10.0",
70
- "@ultimat3/mcp": "31.10.0",
71
- "@ultimat3/money": "31.10.0",
72
- "@ultimat3/notify": "31.10.0",
73
- "@ultimat3/policy": "31.10.0",
74
- "@ultimat3/pwa": "31.10.0",
75
- "@ultimat3/query": "31.10.0",
76
- "@ultimat3/realtime": "31.10.0",
77
- "@ultimat3/render": "31.10.0",
78
- "@ultimat3/schema": "31.10.0",
79
- "@ultimat3/scraping": "31.10.0",
80
- "@ultimat3/seo": "31.10.0",
81
- "@ultimat3/storage": "31.10.0",
82
- "@ultimat3/testing": "31.10.0",
83
- "@ultimat3/time": "31.10.0",
56
+ "@ultimat3/action": "31.12.0",
57
+ "@ultimat3/admin": "31.12.0",
58
+ "@ultimat3/ai": "31.12.0",
59
+ "@ultimat3/auth": "31.12.0",
60
+ "@ultimat3/cache": "31.12.0",
61
+ "@ultimat3/core": "31.12.0",
62
+ "@ultimat3/db": "31.12.0",
63
+ "@ultimat3/entity": "31.12.0",
64
+ "@ultimat3/flags": "31.12.0",
65
+ "@ultimat3/http": "31.12.0",
66
+ "@ultimat3/i18n": "31.12.0",
67
+ "@ultimat3/jobs": "31.12.0",
68
+ "@ultimat3/mail": "31.12.0",
69
+ "@ultimat3/manifest": "31.12.0",
70
+ "@ultimat3/mcp": "31.12.0",
71
+ "@ultimat3/money": "31.12.0",
72
+ "@ultimat3/notify": "31.12.0",
73
+ "@ultimat3/policy": "31.12.0",
74
+ "@ultimat3/pwa": "31.12.0",
75
+ "@ultimat3/query": "31.12.0",
76
+ "@ultimat3/realtime": "31.12.0",
77
+ "@ultimat3/render": "31.12.0",
78
+ "@ultimat3/schema": "31.12.0",
79
+ "@ultimat3/scraping": "31.12.0",
80
+ "@ultimat3/seo": "31.12.0",
81
+ "@ultimat3/storage": "31.12.0",
82
+ "@ultimat3/testing": "31.12.0",
83
+ "@ultimat3/time": "31.12.0",
84
84
  "babel-preset-solid": "^1.9.16"
85
85
  }
86
86
  }
@@ -238,6 +238,8 @@ export const CLI_OWNED_ERROR_CODES = [
238
238
  'X_PARTITIONS_UNMAINTAINED',
239
239
  'X_TYPESCRIPT_VERSION',
240
240
  'X_SEED_FAILED',
241
+ 'X_NATIVE_FORM_UNANSWERED',
242
+ 'X_ASSET_RETAIN_UNDECLARED',
241
243
  ] as const;
242
244
 
243
245
  /**
@@ -462,6 +464,8 @@ export const CLI_ERROR_TITLES: Readonly<Record<CliListedErrorCode, string>> = {
462
464
  X_PARTITIONS_UNMAINTAINED: 'a partitioned entity with no partitions() job',
463
465
  X_TYPESCRIPT_VERSION: 'The app declares a TypeScript older than the one x new scaffolds',
464
466
  X_SEED_FAILED: 'a seed threw an uncoded error',
467
+ X_NATIVE_FORM_UNANSWERED: 'a page form posts to an action that declares no native answer',
468
+ X_ASSET_RETAIN_UNDECLARED: "A served build keeps no earlier build's assets",
465
469
  };
466
470
 
467
471
  // One unconditional call, so a second package claiming one of the CLI's codes throws
package/src/mcp-errors.ts CHANGED
@@ -380,6 +380,10 @@ const CLI_FIXES: Readonly<Record<CliErrorCode, string>> = {
380
380
  X_TYPESCRIPT_VERSION:
381
381
  'x doctor --json # each X_TYPESCRIPT_VERSION finding names its manifest and the bun add that moves it',
382
382
  X_SEED_FAILED: 'bun --eval \'await (await import("./packages/db/seeds/dev.ts")).dev.run()\'',
383
+ X_NATIVE_FORM_UNANSWERED:
384
+ "native: { success: (output) => '/where-it-lands' } in the action's declaration, then x verify --only manifest",
385
+ X_ASSET_RETAIN_UNDECLARED:
386
+ "edit app.config.ts: add assets: { retain: { disk: 'assets', builds: 3 } }, naming a disk your defineStorage({ disks }) declares that every web pod reads",
383
387
  };
384
388
 
385
389
  const isCliCode = (code: string): code is CliErrorCode =>
@@ -0,0 +1,119 @@
1
+ // Which action a page's `<form method="post">` posts to, read from the page's SOURCE: a literal
2
+ // path, `derivePath(name).path`, `actionHttpPath(name, …).path`, or a same-file `const` holding one
3
+ // of those. Pure text in, targets out — `verify-native-form.ts` matches them to registered actions.
4
+
5
+ /** A form's target: an action named outright, or a URL path to match against the routes. */
6
+ export type FormTarget =
7
+ | { readonly kind: 'name'; readonly value: string }
8
+ | { readonly kind: 'path'; readonly value: string };
9
+
10
+ export interface PostForm {
11
+ readonly line: number;
12
+ readonly target: FormTarget;
13
+ }
14
+
15
+ /** How many `const` hops a value is followed through; a page that needs more is not read. */
16
+ const MAX_HOPS = 3;
17
+
18
+ const PATH_CALL = /^(?:derivePath|actionHttpPath)\(\s*([^,)]+?)\s*[,)]/;
19
+ const STRING = /^(['"])([^'"`]*)\1/;
20
+
21
+ /** The text up to the `>` that closes this tag, quotes and `{…}` skipped whole; `undefined` if open. */
22
+ function openingTag(source: string, from: number): string | undefined {
23
+ let depth = 0;
24
+ let quote: string | null = null;
25
+ for (let i = from; i < source.length; i++) {
26
+ const ch = source[i];
27
+ if (quote !== null) {
28
+ if (ch === quote) quote = null;
29
+ } else if (ch === '"' || ch === "'" || ch === '`') quote = ch;
30
+ else if (ch === '{') depth++;
31
+ else if (ch === '}') depth--;
32
+ else if (ch === '>' && depth === 0) return source.slice(from, i);
33
+ }
34
+ return undefined;
35
+ }
36
+
37
+ /** An attribute's raw value: a quoted string's text, or a `{…}` expression's, balanced. */
38
+ function attribute(tag: string, name: string): { quoted: boolean; text: string } | undefined {
39
+ const at = new RegExp(`\\s${name}\\s*=\\s*`).exec(tag);
40
+ if (at === null) return undefined;
41
+ const start = at.index + at[0].length;
42
+ const open = tag[start];
43
+ if (open === '"' || open === "'") {
44
+ const end = tag.indexOf(open, start + 1);
45
+ return end === -1 ? undefined : { quoted: true, text: tag.slice(start + 1, end) };
46
+ }
47
+ if (open !== '{') return undefined;
48
+ let depth = 0;
49
+ for (let i = start; i < tag.length; i++) {
50
+ if (tag[i] === '{') depth++;
51
+ else if (tag[i] === '}' && --depth === 0)
52
+ return { quoted: false, text: tag.slice(start + 1, i) };
53
+ }
54
+ return undefined;
55
+ }
56
+
57
+ /** `const NAME = <expr>;` in this file, or `undefined`. */
58
+ function constValue(source: string, name: string): string | undefined {
59
+ const match = new RegExp(`\\bconst\\s+${name}\\s*=\\s*([^;]+);`).exec(source);
60
+ return match?.[1]?.trim();
61
+ }
62
+
63
+ /** A string an expression evaluates to — a literal (`satisfies` ignored) or a const holding one. */
64
+ function stringOf(source: string, expression: string, hops: number): string | undefined {
65
+ const text = expression.trim();
66
+ const literal = STRING.exec(text);
67
+ if (literal !== null) return literal[2];
68
+ if (hops >= MAX_HOPS || !/^[A-Za-z_$][\w$]*$/.test(text)) return undefined;
69
+ const held = constValue(source, text);
70
+ return held === undefined ? undefined : stringOf(source, held, hops + 1);
71
+ }
72
+
73
+ /** What an `action={…}` expression names, followed through same-file consts. */
74
+ export function targetOf(source: string, expression: string, hops = 0): FormTarget | undefined {
75
+ const text = expression.trim();
76
+ const call = PATH_CALL.exec(text);
77
+ if (call !== null) {
78
+ const name = stringOf(source, call[1] ?? '', 0);
79
+ return name === undefined ? undefined : { kind: 'name', value: name };
80
+ }
81
+ const literal = STRING.exec(text);
82
+ if (literal !== null) {
83
+ const value = literal[2] ?? '';
84
+ return value.startsWith('/') ? { kind: 'path', value } : undefined;
85
+ }
86
+ if (hops >= MAX_HOPS || !/^[A-Za-z_$][\w$]*$/.test(text)) return undefined;
87
+ const held = constValue(source, text);
88
+ return held === undefined ? undefined : targetOf(source, held, hops + 1);
89
+ }
90
+
91
+ /** Every `<form method="post" action=…>` in a page whose target can be read. */
92
+ export function postForms(source: string): readonly PostForm[] {
93
+ const forms: PostForm[] = [];
94
+ for (const match of source.matchAll(/<form\b/g)) {
95
+ const tag = openingTag(source, match.index);
96
+ if (tag === undefined) continue;
97
+ const method = attribute(tag, 'method');
98
+ const verb = method?.quoted === true ? method.text : stringOf(source, method?.text ?? '', 0);
99
+ if (verb?.toLowerCase() !== 'post') continue;
100
+ const action = attribute(tag, 'action');
101
+ if (action === undefined) continue;
102
+ const target = action.quoted
103
+ ? action.text.startsWith('/')
104
+ ? ({ kind: 'path', value: action.text } as const)
105
+ : undefined
106
+ : targetOf(source, action.text);
107
+ if (target === undefined) continue;
108
+ forms.push({ line: source.slice(0, match.index).split('\n').length, target });
109
+ }
110
+ return forms;
111
+ }
112
+
113
+ /** Does a route path (`/orders/:id/refund`) answer this URL path? Query and fragment ignored. */
114
+ export function pathMatches(route: string, path: string): boolean {
115
+ const want = route.split('/');
116
+ const got = (path.split(/[?#]/)[0] ?? '').split('/');
117
+ if (want.length !== got.length) return false;
118
+ return want.every((segment, i) => segment.startsWith(':') || segment === got[i]);
119
+ }
@@ -3,7 +3,7 @@
3
3
  // binds, so before `/readyz` can say ready — and hand back the reader the asset routes miss into.
4
4
 
5
5
  import type { AppConfig, AssetsRetainConfig } from '@ultimat3/core';
6
- import { ConfigInvalidError, renderFixLiteral } from '@ultimat3/core';
6
+ import { ConfigInvalidError, logger, renderFixLiteral, UltimateError } from '@ultimat3/core';
7
7
  import type { Storage } from '@ultimat3/storage';
8
8
  import type { IslandBundle } from './island-bundle';
9
9
  import type { BuildAsset, PublishReport, RetainLog } from './retained-assets';
@@ -60,6 +60,35 @@ export function buildAssetsOf(surface: BuiltSurface): readonly BuildAsset[] {
60
60
  return [...new Map(assets.map((asset) => [asset.url, asset] as const)).values()];
61
61
  }
62
62
 
63
+ /**
64
+ * A served build that keeps no earlier build's hashed files. Logged, never thrown: one replica
65
+ * serving its own build is correct until the next deploy, and the boot cannot see how many
66
+ * replicas the platform runs — only that nothing would answer a URL another build named.
67
+ */
68
+ export class AssetRetainUndeclaredError extends UltimateError {
69
+ constructor(input: { readonly environment: string; readonly disks: readonly string[] }) {
70
+ const disk = renderFixLiteral(input.disks[0], '"assets"');
71
+ super({
72
+ code: 'X_ASSET_RETAIN_UNDECLARED',
73
+ cause: `this web role serves the ${input.environment} environment with no assets.retain, so it answers only its own build's hashed files: across a rolling deploy with more than one replica, or after any deploy, a page can name a stylesheet or island chunk the answering replica 404s, and renders unstyled`,
74
+ fix: `assets: { retain: { disk: ${disk}, builds: 3 } } # in app.config.ts, over a disk every web pod reads${input.disks.length === 0 ? ' (declare one with defineStorage({ disks }))' : ''}`,
75
+ meta: { environment: input.environment },
76
+ });
77
+ }
78
+ }
79
+
80
+ /** Where a boot has no rolling deploy to survive: a laptop, a test run. */
81
+ const LOCAL_ENVIRONMENTS: ReadonlySet<string> = new Set(['development', 'test']);
82
+
83
+ function warnUndeclared(input: RetainBootInput): void {
84
+ if (LOCAL_ENVIRONMENTS.has(input.environment) || buildAssetsOf(input).length === 0) return;
85
+ const warning = new AssetRetainUndeclaredError({
86
+ environment: input.environment,
87
+ disks: input.storage.diskNames,
88
+ });
89
+ (input.log ?? logger).warn(warning.format(), { code: warning.code, ...warning.meta });
90
+ }
91
+
63
92
  export interface RetainBootInput extends BuiltSurface {
64
93
  readonly config: AppConfig | undefined;
65
94
  /** The disks the app's routes read (`servedStorage`) — `retain.disk` must be one of them. */
@@ -79,15 +108,20 @@ export interface RetainedBoot {
79
108
  }
80
109
 
81
110
  /**
82
- * `undefined` when the app declared no window. A misnamed disk refuses the boot: it is the app's
83
- * config, wrong, and every pod of the deploy would otherwise run without the window it asked for.
111
+ * `undefined` when the app declared no window — and, outside development and test, one
112
+ * `X_ASSET_RETAIN_UNDECLARED` warning naming the edit (`warnUndeclared`). A misnamed disk refuses
113
+ * the boot: it is the app's config, wrong, and every pod of the deploy would otherwise run without
114
+ * the window it asked for.
84
115
  * A disk that refuses a write does NOT: `publishBuildAssets` logs it and the pod serves, reading
85
116
  * earlier builds' files all the same. The scope is `config.name` and the environment, so staging
86
117
  * and production on one bucket never sweep or serve each other.
87
118
  */
88
119
  export async function retainBuildAssets(input: RetainBootInput): Promise<RetainedBoot | undefined> {
89
120
  const retain = retainOf(input.config);
90
- if (input.config === undefined || retain === undefined) return undefined;
121
+ if (input.config === undefined || retain === undefined) {
122
+ warnUndeclared(input);
123
+ return undefined;
124
+ }
91
125
  const names = input.storage.diskNames;
92
126
  if (!names.includes(retain.disk)) {
93
127
  throw new ConfigInvalidError({
@@ -56,6 +56,7 @@ import { nestedAppRootFindings } from './verify-drift-owner';
56
56
  import { exerciseStep } from './verify-exercise';
57
57
  import { floorProblemFindings, readVerifyFloor } from './verify-floor';
58
58
  import { mcpMountFindings } from './verify-mcp-mount';
59
+ import { nativeFormWarnings } from './verify-native-form';
59
60
  import { roleLoadFindings } from './verify-role-load';
60
61
  import type { VerifyStep } from './verify-step';
61
62
  import { fromExec, fromFindings, hostFindings } from './verify-step';
@@ -421,10 +422,14 @@ export const VERIFY_STEPS: readonly VerifyStep[] = [
421
422
  ...agents.warnings.map((warning) => `${AGENTS_MD_FILENAME}: ${warning}`),
422
423
  ...remote.warnings,
423
424
  ];
425
+ // A page's `<form method="post">` to an action with no `native`: a JSON dead end. Advice on
426
+ // `main` — refusing it would redden an app that passed yesterday (X_BREAKING_ON_MAIN).
427
+ const warnings = app ? await nativeFormWarnings(ctx.root) : [];
424
428
  return {
425
429
  ok: findings.length === 0,
426
430
  findings,
427
431
  ...(output.length === 0 ? {} : { output: output.join('\n') }),
432
+ ...(warnings.length === 0 ? {} : { warnings }),
428
433
  };
429
434
  },
430
435
  },
@@ -0,0 +1,94 @@
1
+ // The `manifest` step's native-form rider: a page's `<form method="post">` that posts to an action
2
+ // declaring no `native` leaves a reader with scripting off staring at JSON. On `main` it is a
3
+ // WARNING naming `X_NATIVE_FORM_UNANSWERED` (a red gate on an existing app is X_BREAKING_ON_MAIN);
4
+ // the refusal lands on `next`. The form's target is read by `native-form-scan.ts`.
5
+
6
+ // why: Bun exposes no path-join primitive; Bun.file takes one already joined.
7
+ import { join } from 'node:path';
8
+ import type { AnyAction } from '@ultimat3/action';
9
+ import { answersNatively, listActions } from '@ultimat3/action';
10
+ import { loadApp } from './app-load';
11
+ import type { AppLoader } from './app-permissions';
12
+ import type { PostForm } from './native-form-scan';
13
+ import { pathMatches, postForms } from './native-form-scan';
14
+ import type { Finding } from './output';
15
+
16
+ /** Every page an app serves: the directory is the URL, the file is always `page.tsx`. */
17
+ export const PAGE_GLOB = 'apps/*/{app,site}/**/page.tsx';
18
+
19
+ /** The registered action a form posts to, if any — by name, or by the route path it answers. */
20
+ function actionFor(form: PostForm, actions: readonly AnyAction[]): AnyAction | undefined {
21
+ if (form.target.kind === 'name') {
22
+ const { value } = form.target;
23
+ return actions.find((one) => one.name === value);
24
+ }
25
+ const { value } = form.target;
26
+ return actions.find((one) => pathMatches(one.describe().path, value));
27
+ }
28
+
29
+ /** An unanswered form: the action it posts to, and where. */
30
+ interface UnansweredForm {
31
+ readonly action: string;
32
+ readonly page: string;
33
+ readonly line: number;
34
+ }
35
+
36
+ export function nativeFormFinding(action: string, page: string, line: number): Finding {
37
+ return {
38
+ code: 'X_NATIVE_FORM_UNANSWERED',
39
+ cause: `${page}:${line} posts a <form method="post"> to action "${action}", which declares no native answer — a browser submitting it lands on JSON`,
40
+ fix: `native: { success: (output) => '/where-it-lands' } # in action "${action}"'s declaration, then x verify --only manifest`,
41
+ at: page,
42
+ };
43
+ }
44
+
45
+ /** Every unanswered form, after the app loaded — a short registry is the load's finding. */
46
+ async function unansweredForms(
47
+ root: string,
48
+ load: AppLoader,
49
+ actions: () => readonly AnyAction[],
50
+ ): Promise<readonly UnansweredForm[]> {
51
+ if ((await load(root)).findings.length > 0) return [];
52
+ const registered = actions();
53
+ const pages: string[] = [];
54
+ for await (const page of new Bun.Glob(PAGE_GLOB).scan({ cwd: root })) {
55
+ pages.push(page.replaceAll('\\', '/'));
56
+ }
57
+ const unanswered: UnansweredForm[] = [];
58
+ for (const page of pages.sort()) {
59
+ const source = await Bun.file(join(root, page)).text();
60
+ for (const form of postForms(source)) {
61
+ const target = actionFor(form, registered);
62
+ if (target !== undefined && !answersNatively(target)) {
63
+ unanswered.push({ action: target.name, page, line: form.line });
64
+ }
65
+ }
66
+ }
67
+ return unanswered;
68
+ }
69
+
70
+ /** The findings the refusal on `next` will report — the same facts the warnings print. */
71
+ export async function nativeFormFindings(
72
+ root: string,
73
+ load: AppLoader = loadApp,
74
+ actions: () => readonly AnyAction[] = listActions,
75
+ ): Promise<readonly Finding[]> {
76
+ return (await unansweredForms(root, load, actions)).map((form) =>
77
+ nativeFormFinding(form.action, form.page, form.line),
78
+ );
79
+ }
80
+
81
+ /**
82
+ * What the `manifest` step carries on `main`: one line per unanswered form — the code, the cause
83
+ * (which opens with `page:line`) and the fix — advice in `StepOutcome.warnings`, never a failed step.
84
+ */
85
+ export async function nativeFormWarnings(
86
+ root: string,
87
+ load: AppLoader = loadApp,
88
+ actions: () => readonly AnyAction[] = listActions,
89
+ ): Promise<readonly string[]> {
90
+ return (await unansweredForms(root, load, actions)).map((form) => {
91
+ const finding = nativeFormFinding(form.action, form.page, form.line);
92
+ return `${finding.code} ${finding.cause} — fix: ${finding.fix}`;
93
+ });
94
+ }
package/wiki/Actions.md CHANGED
@@ -36,6 +36,7 @@ Declared one per file in a feature's `actions/` (`actions/publish-post.ts`, what
36
36
  | `http.path` | `string` | no | pins the URL whatever the app's `pathStyle` derives — for a path a caller already holds (`'/api/uploads/signed'`) or a resource-shaped one (`'/orders/:id/refund'`). Lowercase static segments and `:param`s, never `/_x`; each `:param` a REQUIRED `t.string` key of `input:`, else `X_ACTION_HTTP_PATH_INVALID` at registration. The URL's value joins the body before the input is parsed, so the schema, the policy, `row` and the handler read one object; a body naming the key with another value is **400** `X_HTTP_PATH_INPUT_CONFLICT`, never overridden. Under a bearer mount the pin is served at the prefix (`/v1/orders/:id/refund`) — and still at its own path, with the cookie session, as every pin is; the policy decides both. `derivePath(name)` refuses a template; `actionHttpPath(name, { id })` fills it. A `deprecated.replacedBy` naming one is `X_ACTION_DEPRECATION_INVALID`. An inbound webhook is not this door: it is `webhookReceiver()` ([Jobs and workflows](Jobs-And-Workflows#inbound-webhooks)) |
37
37
  | `http.method` | `'POST'` · `'PUT'` · `'PATCH'` · `'DELETE'` | no — `'POST'` | the verb the pin answers; needs `http.path`. `X_ACTION_PATH_DUPLICATE` keys on method and path, so `PUT /orders/:id` and `DELETE /orders/:id` are two actions. `action.client()` sends it and fills the URL from the input (each value one encoded segment, the key left out of the body); `rpc()` by name cannot see a pin. In `openapi.json`: `{id}`, an `in: path` required parameter, the key gone from the request body, the operation under the declared verb. `x.manifest.json` writes `http: { path, method }` for a pin only; moving it is breaking. `As of 2026-11` |
38
38
  | `errors` | `readonly string[]` | no — `x g action` writes `errors: []` | the refusals a caller may branch on, each a registered 4xx code listed once (`X_ACTION_ERRORS_INVALID` otherwise, at `action()`). Declared, the list is CLOSED — see [Declared refusals](#declared-refusals-errors). Absent: today's open contract, bytes unchanged. `As of 2026-11` |
39
+ | `native` | `{ success: (output) => path; refusal?: (refusal) => path }` | no — expected on an action a `page.tsx` `<form method="post">` posts to: `X_NATIVE_FORM_UNANSWERED` is a warning on `main`, a refusal planned for `next` | the answer a browser's own form submission gets: `303` to a path, the outcome in a one-read flash. A fetch or MCP caller is answered exactly as before — see [Native forms](#native-forms-native). `As of 2026-11` |
39
40
  | `handle({ input, ctx })` | `(args) => Promise<Output>` | yes | the body. Parsed `input`, ambient `ctx`. Returns `output`-shaped data |
40
41
 
41
42
  **`.sensitive()` on an input field** — `cardPan: t.string.sensitive()` — means sent in, never
@@ -116,6 +117,59 @@ An action that answers in pieces declares `stream: <chunk schema>` and writes `h
116
117
 
117
118
  A chunk its schema refuses, or `stream:` beside a handle that is not a generator, is `X_ACTION_STREAM_INVALID`. The OpenAPI 200 lists `text/event-stream` beside `application/json` for a streaming action only. `agent()` streams this way.
118
119
 
120
+ ## Native forms: `native:`
121
+
122
+ A `<form method="post" action>` with scripting off gets a page back, never `{"ok":true}`. One declaration on the action; the action, its route and its JSON answer are unchanged.
123
+
124
+ ```ts
125
+ import { action, t } from '@ultimat3/action';
126
+ import { can } from '@ultimat3/policy';
127
+
128
+ export const createPost = action({
129
+ input: t.object({ title: t.string.min(3) }),
130
+ output: t.object({ id: t.string }),
131
+ policy: can('post:create'),
132
+ errors: [],
133
+ native: {
134
+ success: (post) => `/posts/${post.id}`,
135
+ refusal: () => '/posts/new', // omitted: back to the form's own page (a `Referer` on this host)
136
+ },
137
+ handle: async ({ input }) => ({ id: input.title }),
138
+ });
139
+ ```
140
+
141
+ | Caller | Answer |
142
+ |---|---|
143
+ | a browser form POST — `accept` names `text/html` and the body is `application/x-www-form-urlencoded` or `multipart/form-data` (the client router's submit included) | succeeded: `303` to `success(output)`; a `setRedirect()` inside `handle` still wins for that request (a sign-in's `next`). Refused with a 4xx other than `X_UNAUTHENTICATED` (a sign-in's own 401, a wrong password, included): `303` to `refusal(refusal)`, else the path and query of a `Referer` on this host (`http`/`https`, the request's own host and port). Either way a flash cookie carries the outcome |
144
+ | the same POST refused with `X_UNAUTHENTICATED`, a 5xx, or a refusal with no `refusal` and no `Referer` on this host | the ordinary error path: the sign-in redirect, the error page |
145
+ | `fetch` / the typed client / `rpc()` / MCP / `.job()` / a direct call | unchanged — JSON, the problem document, the output. `native` is read by the HTTP projection alone |
146
+
147
+ **The flash.** `x_action_answer`: `HttpOnly`, `SameSite=Lax`, `Max-Age=60`. It holds the action's name, the outcome and, for a refusal, its `code` and each field issue's `path`, `rule` and `params` — never a submitted value or an English message. Read it once, in the next page's `load`:
148
+
149
+ ```ts
150
+ import type { ActionAnswer, AnyAction } from '@ultimat3/action';
151
+ import { useActionAnswer } from '@ultimat3/action';
152
+
153
+ declare const createPost: AnyAction; // the action above
154
+
155
+ // `load:` of the form page's `defineRoute({ render: 'ssr', … })`
156
+ export const load = async (): Promise<{ readonly answer: ActionAnswer | null }> => ({
157
+ answer: useActionAnswer(createPost),
158
+ });
159
+ // answer: null | { action, outcome: 'success' } | { action, outcome: 'refusal', code, issues, truncated }
160
+ ```
161
+
162
+ | Rule | Why |
163
+ |---|---|
164
+ | read in `load`, never in a component | the read clears the cookie, and a header after the first flush is `X_STREAM_ALREADY_FLUSHED` |
165
+ | `useActionAnswer(createPost)` answers only that action's outcome — or by name, `useActionAnswer('createPost' satisfies keyof Api['actions'])`, from a page that may not import the action; `useActionAnswer()` any | two forms on one page |
166
+ | a cookie that is not one this package wrote reads as `null` | it arrives from the browser: parsed, bounded, never trusted |
167
+ | `static` / `isr` pages read `null` | a shared document is rendered as nobody, with no inbound cookie |
168
+ | translate on `code` and `issues[].rule` with `t()` | the flash carries no prose, so no locale |
169
+ | field values are not carried back | a password or a card number does not belong in a cookie; the form re-renders empty, or the page keeps a draft |
170
+
171
+ **Enforced.** The `manifest` step of `x verify` reads every `page.tsx` for a `<form method="post">` whose `action` names an action — a literal path, `derivePath(name).path`, `actionHttpPath(name, …).path`, or a `const` in the same file holding one — and reports one with no `native` as `X_NATIVE_FORM_UNANSWERED`, the page's `file:line` and the fix. On `main` it is a **warning** — listed under the step's `warnings` in `--json`, the step stays green — because refusing it would turn an app's gate red between two minors (`X_BREAKING_ON_MAIN`); the refusal is planned for `next`. A form inside a component other than the page is not read. `As of 2026-11`.
172
+
119
173
  ## The fluent surface
120
174
 
121
175
  Every projection this package owns is a method on the action — `publishPost.openapi()`, never `toOpenApiOperation(publishPost)`. The MCP tool is the exception by tier: `@ultimat3/mcp`'s one projection, `toolFrom(publishPost)` (`As of 25.0.0` there is no `.tool()`). Exactly four declared fields are lifted onto it as readable properties: `input`, `output`, `policy`, `mcp`. The rest of the declaration is structured metadata, reachable through `describe()` and nowhere else. An action has no `.def`.
@@ -527,7 +527,9 @@ The refusal is the ROLLED-BACK image's code, so it protects from the release aft
527
527
 
528
528
  ### Hashed assets across a deploy — `assets.retain`
529
529
 
530
- A web process serves only the hashed files it built: `/styles/<hash>.css`, `/islands/<island>-<hash>.js`, `/_x/assets/<script>/<hash>.js`, `/assets/<name>.<hash>.<ext>`. With no window, an open tab holding the previous build's document gets a 404 for its stylesheet, or for its island chunk on the first click, after every deploy, one replica or many. During a rolling update both directions fail: a new document that reaches an old pod also gets no stylesheet. Declare a window over a disk every web pod can read:
530
+ A web process serves only the hashed files it built: `/styles/<hash>.css`, `/islands/<island>-<hash>.js`, `/_x/assets/<script>/<hash>.js`, `/assets/<name>.<hash>.<ext>`. With no window, an open tab holding the previous build's document gets a 404 for its stylesheet, or for its island chunk on the first click, after every deploy, one replica or many. During a rolling update with more than one web replica both directions fail on every page load, not only in old tabs: the document and its stylesheet are two requests, the load balancer may send them to pods of different builds, and the page renders with no CSS at all (the AppShell's "Skip to content" link as its first line).
531
+
532
+ Without a window the framework only limits the damage (`As of 2026-11-12`): a soft navigation whose next sheet fails becomes a full load and never retires the working sheet. A full load whose sheet 404s stays unstyled: nothing reloads it for you. A web role booted outside `development` and `test` with no window logs `X_ASSET_RETAIN_UNDECLARED`. The window is the fix. Declare it over a disk every web pod can read:
531
533
 
532
534
  ```ts
533
535
  // app.config.ts — `deploys` is a disk from the app's defineStorage({ disks })
@@ -991,7 +991,39 @@ refuses it at the wire first, as a 400. `As of 2026-09-29`.
991
991
 
992
992
  Chain: `.primaryKey()` · `.nullable()` · `.unique()` · `.default(v)` · `.defaultNow()` ·
993
993
  `.onUpdateNow()` · `.references(() => other.id, { onDelete })` · `.tenant()` · `.column(name)` ·
994
- `.sealed()` on `text()` — [Sealed columns](#sealed-columns).
994
+ `.sealed()` on `text()` — [Sealed columns](#sealed-columns) · `.collate('C')` on `text()` — [below](#code-point-collation).
995
+
996
+ ### Code-point collation
997
+
998
+ `text().collate('C')` declares `collate "C"`, `As of 31.11.0`: the column orders and compares by
999
+ code point — the order the memory driver and a live window's matcher already keep. Without it
1000
+ Postgres orders by the database's collation (`en_US.utf8`: `apple` before `Banana`), which is why a
1001
+ live query ordered by such a column logs `query.live.order_collation`
1002
+ ([Queries](Queries-And-Live-Queries#live-true-requires-deterministic-bounded-sql)).
1003
+
1004
+ ```ts
1005
+ import { entity, text, uuid } from '@ultimat3/entity';
1006
+
1007
+ export const tags = entity('tags', {
1008
+ columns: {
1009
+ id: uuid().primaryKey(),
1010
+ name: text({ max: 40 }).collate('C'), // a live list may .orderBy('name')
1011
+ },
1012
+ });
1013
+ ```
1014
+
1015
+ | Rule | Where |
1016
+ |---|---|
1017
+ | `'C'` is the only collation a column may declare; another is `X_INVARIANT_VIOLATED` at `entity()` | `packages/entity/src/sealed-column.ts` (`declaredCollation`) |
1018
+ | only `text()` has `.collate()`; `enumerated()`, `url()`, `tz()`, `locale()` store text and do not | `TextColumn` in `packages/entity/src/types.ts` |
1019
+ | `x db gen` writes `collate "C"` after the type on `create table` and `add column`; declaring or dropping it on an existing column is one in-place `alter column … type text collate "C"` (or `"default"`), its reverse in `down`; a retype restates it, since Postgres resets a collation on a type change | `packages/db/src/generate-collation.test.ts` |
1020
+ | the snapshot records `collation` only when declared, so no existing snapshot moves | same |
1021
+ | drift does not read a live column's collation, as it reads no column type: a hand-set collation is not reported | `packages/db/README.md`, "A declared collation" |
1022
+
1023
+ Declaring it changes the visible order of every read of that column, not only the live one. On an
1024
+ existing table the `alter` is Postgres' `alter column … type`: an `ACCESS EXCLUSIVE` lock while every
1025
+ index on the column is rebuilt. `X_MIGRATION_LOCK_HEAVY` does not flag it — a large table wants a
1026
+ quiet window.
995
1027
 
996
1028
  **A date is not an instant.** `effective_on` is the date a rate applies, not a moment; stored as a
997
1029
  `timestamptz` it is a different date on either side of midnight for half the planet. `PlainDate`
@@ -35,7 +35,7 @@ CHANGELOG.md` finds its bounds, and it changes on any commit.
35
35
  | A purge that a replica never hears is bounded by `ttl`, not by the next request | `As of 2026-10-10`. The purge reaches the other replicas through the invalidation broadcast. With the bus down, a replica with its own store answers its copy as a fresh hit until that copy's `ttl` (and tells an edge the ttl's remainder), then renders. `'purge'` therefore requires a `ttl` | choose the `ttl` as the longest a missed purge may last; or share one `runtime.isrStore` with a `tagFence`, where the delete is every replica's at once |
36
36
  | A bust purges by the **route's** tags | `As of 2026-10-10`. A stored `isr` page records no tags of its own, so `post:1` reaches every stored page of a route tagged `post` — one render too many per page, never one too few. Each bust reads the store's keys once; the route of each key is remembered, not re-matched [pin](https://github.com/developerz-ai/ultimate/blob/main/packages/render/src/render-isr-purge.test.ts#every%20stored%20key%20of%20the%20route%20goes%3A%20both%20locales%2C%20and%20every%20keyed%20query) | tag a route as narrowly as its data allows; a very large shared store pays one `paths()` per bust per replica |
37
37
  | A declared `isr` query parameter's **values** are unbounded | `As of 2026-10-10`. `query: ['page']` puts `page` in the key, and `?page=1` … `?page=999999` are each a key: the framework cannot know which values name a page. The store is bounded (least recently generated out first), so it thrashes rather than grows [pin](https://github.com/developerz-ai/ultimate/blob/main/packages/render/src/render-isr-query.test.ts#only%20a%20declared%20parameter%20is%20part%20of%20the%20key%2C%20and%20of%20the%20URL%20load%20is%20given) | answer `withStatus(404, …)` from `load` for a value that names nothing, and rate-limit the route at the ingress; put a small closed set in the path instead (`/blog/page/[n]` with `prerender()`) |
38
- | A `grantUpload` with a `target` is never sniffed | `As of 2026-11-02`. A presigned PUT signs `host` and the size, so on an s3 disk the uploader chooses the stored type and the bytes. `promoteAttachment` is what checks them (`X_STORAGE_TYPE_REJECTED`), and a grant with a `target` lands straight on the row's key with no promotion step. With an `uploadScanner` installed such a grant is refused outright (`X_STORAGE_TARGET_UNSCANNED`, `As of 31.0.0`), so the gap is only an app's with no scanner. Served, it is contained: `objectResponse` sandboxes a type a browser would run, and a false `image/png` is shown under `nosniff` [pin](https://github.com/developerz-ai/ultimate/blob/main/packages/storage/src/grant.test.ts#naming%20a%20target%20puts%20the%20key%20on%20the%20row%20instead%20of%20in%20pending) | grant with no `target` and call `promoteAttachment({ …, policy })`; for a targeted grant, read the head yourself with `validateStoredHead(…)` before writing the key to the row → [Storage and uploads](Storage-And-Uploads) |
38
+ | A `grantUpload` with a `target` is never sniffed | `As of 2026-11-02`. A presigned PUT signs `host` and the size, so on an s3 disk the uploader chooses the stored type and the bytes. `promoteAttachment` is what checks them (`X_STORAGE_TYPE_REJECTED`), and a grant with a `target` lands straight on the row's key with no promotion step. With an `uploadScanner` installed such a grant is refused outright (`X_STORAGE_TARGET_UNSCANNED`, `As of 31.0.0`), so the gap is only an app's with no scanner. Served, it is contained: `objectResponse` sandboxes a type a browser would run, and a false `image/png` is shown under `nosniff` [pin](https://github.com/developerz-ai/ultimate/blob/main/packages/storage/src/grant.test.ts#naming%20a%20target%20puts%20the%20key%20on%20the%20row%20instead%20of%20in%20pending) | declare the pair with `uploadFlow()` (`@ultimat3/action`, `As of 31.11.0`), which never grants a target and sniffs at `confirm`; or by hand, grant with no `target` and call `promoteAttachment({ …, policy })`. Keeping a targeted grant: read the head yourself with `validateStoredHead(…)` before writing the key to the row → [Storage and uploads](Storage-And-Uploads) |
39
39
  | A queued offline write is not bound to its principal **on the server** | `As of 2026-10`. The fence is in the page: a principal change abandons the running replay, refuses a write in flight (`X_OFFLINE_QUEUE_ABANDONED`) and wipes the queue. A second TAB whose replay is already past its store read when another tab changes the session cookie still sends its remaining entry under the new session — one entry, one in-flight pass, on a shared browser | sign out by full navigation (`signOutHeaders()` clears site data, and every boot wipes other principals' queues); do not share a browser profile between accounts with offline writes queued |
40
40
  | Presence leaves past the lease roster cap | the sweep leader ships at most 4,096 member ids on its lease (`PRESENCE_LEASE_ROSTER_LIMIT`). When the leader's node dies, members beyond that whose TTL expired before the successor's first leading pass are never announced as left. A successor cannot diff against the shared store: the expired members are already gone from it | nothing to do: each client's next beat is answered with the whole roster, so it heals within one beat (10 s by default) |
41
41
  | An **offline** scrape reads `/robots.txt` over the real network | every `fakeBrowser` / `fixtureBrowser` run takes the default `robots: 'obey'`, and the gate reads `https://<host>/robots.txt` with the platform `fetch` before the first navigation, so outside `bun test` one request still leaves the process. **The silent half is closed `As of 2026-10-04`**: an unreachable robots.txt (5xx, 429, network error, timeout) now refuses the origin with `X_SCRAPE_ROBOTS_DISALLOWED` (RFC 9309 §2.3.1.4 for 5xx, network error and timeout; refusing on `429` is Ultimate's stricter policy — the RFC calls a `4xx` unavailable), so under `bun test` the sealed network's refusal turns the run red instead of reading as allow-everything | declare the policy in the definition under test — `robots: { ignore: 'fixture host, no live origin' }` — which returns a gate that reads nothing at all. There is no boolean and no ambient off switch, by design — see [Scraping](Scraping#testing-offline) |
@@ -45,7 +45,7 @@ CHANGELOG.md` finds its bounds, and it changes on any commit.
45
45
  | `--target binary` is a **launcher** for an app tree, and has never been served from a bare VM | `As of 2026-10-06`. It boots: `x build --target binary` compiles `apps/web/server.ts` with `--compile-autoload-package-json`, `--compile-autoload-tsconfig` and `@ultimat3/*` external (`binaryArgs`, `packages/cli/src/cmd-build.ts`), and the required `windows` CI job starts the result from a scaffold and gets `200` from `/healthz`; `packages/cli/e2e/binary-launch.e2e.test.ts` proves the same on Linux. **It is not a self-contained artifact**: at run time it reads the app's `package.json` and `tsconfig.json`, imports `app.config.ts` and every module under `apps/*`, and loads the framework from the app's `node_modules` — one instance, so the app's registrations reach the server. Unmeasured: a scaffold compiled, copied with its tree to a VM with no Bun, and served under systemd [pin](https://github.com/developerz-ai/ultimate/blob/main/packages/cli/e2e/binary-launch.e2e.test.ts#the%20compiled%20launcher%20resolves%20its%20app%20tree%20at%20run%20time%2C%20against%20ONE%20framework%20instance) | ship the app root, its installed `node_modules` (installed for the target OS and CPU) and the binary together, and start the binary from that root. Prove it for your own app first — `./app --version`, then `ROLE=web PORT=3000 ./app` and `curl /readyz`. Prefer `--target docker`, the self-contained artifact → [Deployment](Deployment) |
46
46
  | A local `typecheck` step can report green on a tree CI fails, on the same commit — **one sighting, unreproduced** | `As of 2026-10`. Observed once (2026-09-17, TypeScript 7.0.2): after a `git stash -u` → branch switch → `x verify` on the other branch → switch back → `stash pop` sequence, a type error that surfaces in an UNCHANGED file (a widened index signature in a file it imports) passed locally and failed CI; deleting `tsconfig.tsbuildinfo` then reproduced CI's red locally. Five faithful reproduction attempts against 7.0.2 all stayed correctly red ([#450](https://github.com/developerz-ai/ultimate/issues/450)). **[#450](https://github.com/developerz-ai/ultimate/issues/450) itself is closed `As of 2026-09-23`** — read from the shipped fix, not from the tracker: plan 101 row 14 r ("Close #450", `docs/plans/2026/09/23/101-framework-deep-sweep/14-guards-gate.md:37`; plan `status.yml` `complete`), recorded in `CHANGELOG.md` under 22.0.0 and pinned by `packages/cli/src/verify-typecheck.test.ts`. `tsc -b` decides "up to date" by **mtime**, and Bun installs a dependency as **hardlinks** carrying its cache's old mtimes, so an upgrade to an already-cached version left every input older than the buildinfo and a root without `references` — every scaffolded app — skipped the program and reported green while a cold CI was red. A scaffolded app's `typecheck` is now `tsc -p .` ([`packages/cli/src/templates/scaffold-repo.ts`](https://github.com/developerz-ai/ultimate/blob/main/packages/cli/src/templates/scaffold-repo.ts), its `"typecheck"` script), which is incremental by **content hash**, and `x verify`'s `typecheck` step picks `-p .` over `-b` for any such root ([`packages/cli/src/verify-typecheck.ts`](https://github.com/developerz-ai/ultimate/blob/main/packages/cli/src/verify-typecheck.ts)); the framework root keeps `-b`. **Still open**: a *second* `tsc` racing the same buildinfo is the one suspect not excluded, and no cause for it has been shown. `x verify` deliberately takes two flags and no `--cold` pin: none — one sighting, and five faithful reproductions stayed red, so no test can hold it | CI is always cold and is the judge of record. If a local `typecheck` disagrees with it again, capture the command, its argv and its exit code before deleting any `tsconfig.tsbuildinfo` |
47
47
  | A `stream` page with a realtime island keeps every island on the page inert until its slowest hole closes | `As of 2026-11-02`. The runtime goes `async` so a shell island answers while a hole is open, but only with no realtime boot in the document: the boot (`script defer`) has to run first (`bootScript`, [`packages/cli/src/route-islands.ts`](https://github.com/developerz-ai/ultimate/blob/main/packages/cli/src/route-islands.ts)), and a deferred script waits for parsing to end. Bound by the hole's 15 s deadline | keep the slow read out of such a page's holes, or give it a short deadline of its own: `fetch(url, { signal: AbortSignal.timeout(2_000) })` |
48
- | An open tab can meet a dead island across a deploy | `As of 2026-11-03`. A web process serves only the hashed files it built, so with `assets.retain` unset (the default) a tab holding the previous build's document gets a `no-store` 404 for its stylesheet, or for its island chunk on the first click, after every deploy; during a rolling update a new document that reaches an old pod gets no stylesheet either [pin](https://github.com/developerz-ai/ultimate/blob/main/packages/cli/src/retained-assets-boot.test.ts#undeclared%3A%20nothing%20is%20published%20and%20there%20is%20no%20reader). Declared, a tab survives six deploys with build 0's island alive [evidence](https://github.com/developerz-ai/ultimate/blob/main/packages/cli/e2e/six-deploys.e2e.test.ts#with%20assets.retain%2C%20the%20click%20boots%20build%200%E2%80%99s%20island%3A%20its%20chunk%20200%2C%20no%20404%2C%20an%20update%20offered) | declare `assets: { retain: { disk, builds } }` over a disk every web pod reads → [Deployment](Deployment#hashed-assets-across-a-deploy--assetsretain) |
48
+ | An open tab can meet a dead island across a deploy | `As of 2026-11-12`. A web process serves only the hashed files it built, so with `assets.retain` unset (the default) a tab holding the previous build's document gets a `no-store` 404 for its stylesheet, or for its island chunk on the first click, after every deploy; during a rolling update a new document that reaches an old pod gets no stylesheet either. What the framework does about the stylesheet half without a window: a soft navigation whose next sheet fails never swaps an unstyled page in (a GET becomes a full load, the old sheet stays) [pin](https://github.com/developerz-ai/ultimate/blob/main/packages/render/src/navigation-stylesheet-skew.test.ts#a%20GET%20is%20loaded%20by%20the%20browser%3B%20the%20page%20on%20screen%20keeps%20its%20sheet); a full load whose sheet 404s stays unstyled — the framework does not reload it, as a reload it cannot tell from a missing file offline or under a test harness is a navigation nobody asked for. A web role booted outside development and test with no window logs `X_ASSET_RETAIN_UNDECLARED` [pin](https://github.com/developerz-ai/ultimate/blob/main/packages/cli/src/retained-assets-boot.test.ts#undeclared%3A%20nothing%20is%20published%20and%20there%20is%20no%20reader). Declared, a tab survives six deploys with build 0's island alive [evidence](https://github.com/developerz-ai/ultimate/blob/main/packages/cli/e2e/six-deploys.e2e.test.ts#with%20assets.retain%2C%20the%20click%20boots%20build%200%E2%80%99s%20island%3A%20its%20chunk%20200%2C%20no%20404%2C%20an%20update%20offered) | declare `assets: { retain: { disk, builds } }` over a disk every web pod reads → [Deployment](Deployment#hashed-assets-across-a-deploy--assetsretain) |
49
49
  | A soft visit waits for the slowest hole | `As of 2026-11-02`. The client router reads `response.text()` ([`packages/render/src/navigation-fetch.ts`](https://github.com/developerz-ai/ultimate/blob/main/packages/render/src/navigation-fetch.ts)) and swaps the whole answer, so holes fill through the re-run scripts and the first paint of an in-app navigation is as late as a full `ssr` render. A full load streams. No incremental parse here [pin](https://github.com/developerz-ai/ultimate/blob/main/packages/render/src/navigation-fetch.test.ts#a%20page%3A%20its%20text%2C%20its%20build%2C%20no-store%20read%20off%20cache-control) | nothing to do in an app; a page that must paint first on a soft visit declares `navigation: 'document'` |
50
50
  | A pod evaluates the framework from **source**, one module at a time — ~28 Mi of resident memory per pod that a bundle would not hold | `As of 2026-10-01`, measured on the framework serve graph alone: 1,071 modules from source settle at **80.4 Mi**; the same graph as one `bun build --target=bun` file is 5 modules and settles at **51.8 Mi** — ~34 kB of RSS per source module, the runtime's cost and not the code's. It is the largest saving left after the per-role load and the prebuilt store (a web pod of the demo app settles at 97–102 Mi, a worker at 80–85 Mi). **Not a patch**: a registry is a module instance, so the framework bundled apart from the app is two `@ultimat3/jobs`, two `@ultimat3/entity` — the app registers into one and the boot reads the other. The unit has to be the app **and** the framework as one graph, per role, built inside the image build from a generated entry that imports what `scanAppModules` would, with the `.tsx`/`.scss` loaders as build plugins. Containers only either way (axiom 7). Design note: [`docs/architecture/13-topology-runtime.md`](https://github.com/developerz-ai/ultimate/blob/main/docs/architecture/13-topology-runtime.md#not-built-one-bundle-per-role) pin: none — a resident-memory measurement of a running pod, not a behaviour a unit test can assert | nothing to do in an app. Size a pod's memory request from `process_resident_memory_bytes` on `/metrics`, not from a guess |
51
51
  | Every role evaluates all of `@ultimat3/jobs` — 96 modules (`As of 2026-10-02`, by file) — whatever it runs | `As of 2026-10-01`, read off the serve graph by the names each role's code uses: a `web` pod needs 43 of them (enqueue, the outbox relay, the purge task), a `scheduler` 46, a `worker` 62. The rest ride the barrel: `worker.ts` and its eighteen dependencies in a web pod, the `backfill()` / `exportJob()` / `webhook()` factories (17 modules, 123 kB of source) in an app that declares none, and the memory driver (3 modules) outside a test. ~1.6 Mi per web pod at the measured 34 kB a module. Closing it means subpath entries (`@ultimat3/jobs/worker`, one per factory) and every importer rewritten — a breaking move for a saving the per-role bundle above makes moot, so it waits on that decision. The operator surface is **not** in this list: `JobIntrospection` is a member of the driver, and the worker announces itself and counts settles through it pin: none — a module count read off a role's serve graph, measured rather than asserted | nothing to do in an app |
@@ -101,7 +101,6 @@ downstream app on Ultimate and of systems built without it; no row is a defect i
101
101
 
102
102
  | Gap | Evidence | Precedent |
103
103
  |---|---|---|
104
- | a native form's refusal answer — `setRedirect` covers success (`packages/http/src/redirect.ts`) | 234 wrapper calls in 142 files | Rails' form convention: 303 on success, 422 re-rendering the form with its errors; `flash` |
105
104
  | route-group defaults | 111 routes × ~25 repeated lines | layouts, `before_action`, controller inheritance |
106
105
  | a view-scoped lazy lookup for `t()` inside an island — the subset itself ships (`catalogSubset` / `subsetTranslator`, #710), named key by key | 94 label types, 3,092 lines of label files | lazy lookup `t('.title')` scoped to the view |
107
106
  | a server-first dialog, menu and combobox with a small enhancer | ~2,200 app-side lines; 13 catalog components at 0 imports | HTML first, a small controller second |
@@ -122,6 +121,7 @@ the release that fixed it. Upgrading is the fix, and the breaking entries are th
122
121
 
123
122
  | Gap | Fixed in | If you are pinned below that |
124
123
  |---|---|---|
124
+ | A browser's own `<form method="post">` to an action got JSON back on a refusal — `setRedirect` covered success only (deferred by plan 101: 234 wrapper calls in 142 files of one app) | **31.11.0** | `action({ native: { success, refusal? } })`: a `303` either way, the outcome in a one-read flash `useActionAnswer()` reads in `load`; a `page.tsx` form posting to an action without it is an `X_NATIVE_FORM_UNANSWERED` warning ([Actions](Actions#native-forms-native)). Below it: `if ((useRequestHeader('accept') ?? '').includes('text/html')) setRedirect(next)` in `handle` (both from `@ultimat3/http`) answers success; a refusal still answers the error page |
125
125
  | `bun run error-render` could not see a `catch (error)` binding | **8.0.0** | The gate matched a **parameter** annotated `unknown`/`any`; a `catch (error)` binding is `unknown` by inference and carries no annotation, which is how `String(error)` echoing a caller's request body into a 422 `cause:` stayed green in `packages/http/src/request.ts` through 3.0.0. `error-render` now joins `catchRenderFindings` ([`scripts/catch-render.ts`](https://github.com/developerz-ai/ultimate/blob/main/scripts/catch-render.ts)), which reads the catch binding and a `.catch((error: unknown) => …)` callback; its header lists what it still cannot see (a helper in a third file, a field laundered by another package). Below it: review every `catch` by hand — a caught value reaches a `cause:`/`fix:` only through `renderThrowable(error)` from `@ultimat3/core` |
126
126
  | The manifest did not record an admin action's `readonly` or `matching`, a scope's `count`, or a resource's permission noun | **25.0.0** | [B29](https://github.com/developerz-ai/ultimate/blob/main/docs/plans/2026/10/04/101-squeaky-clean-sweep/10-carried-backlog.md), #691. `AdminActionFact` records `readonly` and `matching` and `x manifest diff` reports the gate moving between `admin:write` and `admin:read` ([`packages/manifest/src/diff-admin.ts`](https://github.com/developerz-ai/ultimate/blob/main/packages/manifest/src/diff-admin.ts)); a scope's `count` is diffed; the permission noun reaches the diff through each admin route's `permissions` (`<noun>:read`). Below it: read them from the declaration in `apps/admin/app/admin/admin.ts` |
127
127
  | The two-platform deploy proof (milestone 11) was undemonstrated | **22.1.0** | Not a defect in what shipped: the build targets, compose files and chart all shipped, the proof did not. `.github/workflows/ci.yml`'s `deploy-proof` job (`docker/deploy-proof/run.sh`) installs a scaffolded app into kind with `x deploy --method helm` and upgrades it under mixed GET/POST load, failing on one non-2xx ([roadmap](https://github.com/developerz-ai/ultimate/blob/main/docs/idea/14-roadmap.md)). Nothing to work around below it |
@@ -154,9 +154,21 @@ policyScope(seePost, actor); // the frozen conditions, or undefined for an unsco
154
154
  - **Tenant scoping is not scope.** Tenancy stays the entity layer's (the tenant predicate every
155
155
  repository applies, [below](#tenancy)); a scope narrows what one actor sees inside a tenant and
156
156
  never replaces it.
157
- - **Planned, not shipped:** composing a scope into `@ultimat3/query` reads, and a finding for a
158
- scope that admits other rows than its rule on the exercise seed. Until then `policyScope` is the
159
- read an app composes itself, e.g. `db.posts.where({ orgId })` plus each condition as `andWhere`.
157
+ - **A query read composes it**, `As of 31.11.0`: a `query({ policy: seePost, sql })` whose `sql`
158
+ returns `from()` gets each condition as a filter before the page is cut, and still runs the rule
159
+ on every row — [Queries: a scoped policy narrows the read](Queries-And-Live-Queries#a-scoped-policy-narrows-the-read).
160
+ Another `SqlSource` is `X_QUERY_SCOPE_UNCOMPOSABLE`. An action, or a repository read outside a
161
+ query, composes nothing: there `policyScope` is the read an app composes itself, e.g.
162
+ `db.posts.where({ orgId })` plus each condition as `andWhere`.
163
+ - **AND-only, by decision** (2026-11, `packages/policy/src/scope.ts`). A scope lands as query
164
+ filters, so it reaches the live matcher's shape, every provider's `RowWindow.filters` and the
165
+ entity chain, each a conjunction; an `or` group would widen all of them at once. A rule whose
166
+ visibility is a disjunction (a friend OR the author OR public, minus a block set) stays unscoped
167
+ and keeps the JS rule over what it reads.
168
+ - **Planned, not shipped:** a finding for a scope that admits other rows than its rule on the
169
+ exercise seed (`X_POLICY_SCOPE_MISMATCH`, not registered yet). Until then, a scope wider than its
170
+ rule costs rows the rule then drops — a short page again — and a narrower one hides rows the rule
171
+ would admit, silently.
160
172
 
161
173
  ## Tenancy
162
174
 
@@ -256,6 +256,22 @@ the `DownloadFile` and `await runRecording.url(input, { ctx })` the path.
256
256
 
257
257
  **A patched row lands where `order by` returns it** (`As of 2026-10`). The matcher, `from()`'s in-memory execution and the cursor fallback compare two values by the column's DECLARED kind, through `@ultimat3/entity`'s own comparator — `@ultimat3/query` has none. A `bigint()` or `decimal()` column orders by its digits (its row value is decimal text: `'9'` before `'10'`), a `uuid()` is a value whatever its case, a `timestamp()` is an instant. The kinds resolve from the entity declared on the table `from(name, …)` names; a relation no entity declares has none, and its digits compare as text — as a `text` column's do. A custom `SqlSource` calling `compareRows`, `matchesFilter` or `isAfterKey` passes `kindsOf(shape.entity)`; `compareValues` is gone.
258
258
 
259
+ **A text order is warned until it is code-point order**, `As of 31.11.0`. The matcher orders a
260
+ text value by code point; Postgres orders it by the column's collation, and on an
261
+ `en_US.utf8` cluster that is `apple` before `Banana`. A patched row then lands where the next read
262
+ does not put it, and a full window evicts the wrong row. So a live query ordered by a declared text
263
+ column — `text()`, or `enumerated()`, `url()`, `tz()`, `locale()`, which store text — not declared `.collate('C')` logs `query.live.order_collation` (`X_LIVE_ORDER_COLLATION`) at
264
+ subscribe — in development and test, once per query, never thrown; staging and production are
265
+ silent (`packages/query/src/live-collation.ts`). A refusal at subscribe is planned for `next`.
266
+
267
+ | Fix | Cost |
268
+ |---|---|
269
+ | `name: text().collate('C')` on a `text()` column, then `x db gen "<table> name collate C"` | an in-place `alter column … collate "C"`; every read of that column orders by code point, not only the live one ([Code-point collation](Entities-And-Migrations#code-point-collation)) |
270
+ | order the live read by a non-text key: `.orderBy('createdAt', 'desc').orderBy('id')` | none; the text column can still be filtered on. The only fix for `enumerated()`, `url()`, `tz()`, `locale()`: they have no `.collate()` |
271
+
272
+ Not warned: a relation no entity declares (it has no kinds), and a text primary key reached only as
273
+ the automatic `id` tiebreak.
274
+
259
275
  A page is served `order by <declared keys>, "id" asc`, and so is a live window — `As of 2026-08`,
260
276
  the initial window, the matcher's patch positions and the keyset re-read a reconnect resumes with
261
277
  are one ordering. A row tied on every declared key lands where its id puts it, not after the tie
@@ -300,6 +316,26 @@ Policy is not a subscribe-time gate that then trusts the stream.
300
316
 
301
317
  One authz system. A live query cannot become a second door into your data — that is the failure mode that killed the `allow`/`deny` generation of frameworks ([The eight primitives](The-Eight-Primitives)).
302
318
 
319
+
320
+ ## A scoped policy narrows the read
321
+
322
+ A policy built with `scoped(rule, (actor) => conditions)` ([Policies](Policies-And-Authz#scope--a-policys-database-filter))
323
+ hands its conditions to every read it guards, `As of 31.11.0` (`packages/query/src/scope-compose.ts`).
324
+ Without it the rule filters after the page is cut, so a viewer whose hidden rows precede their
325
+ visible ones gets a short page.
326
+
327
+ | What happens | Where |
328
+ |---|---|
329
+ | each condition becomes a `.compare()` filter on the `from()` builder `sql` returned, before the page is cut | the SQL text, the live shape and the provider's `RowWindow.filters`, exactly as a `.where()` would |
330
+ | the rule still runs on every row returned; a row it refuses is dropped, never served | a scope wider than its rule costs rows, never leaks them (`read-scope.test.ts`) |
331
+ | the read's cache key is the actor's, whatever `cache.scope` says | the rows are that actor's |
332
+ | a `sql` that returns a hand-written `SqlSource`, not `from()` | `X_QUERY_SCOPE_UNCOMPOSABLE` (500) on the call — never served unscoped |
333
+ | a build with `sourceFor(…, { unenforced })`, and the shared live window a sync node reads per org | no scope: there is no admitted actor to scope by. Each subscriber's rows are still filtered by the rule, as above |
334
+
335
+ Conditions are a conjunction only — no `or` group, by decision (`packages/policy/src/scope.ts`): the
336
+ builder's filters, the live matcher's shape, `RowWindow.filters` and the entity chain are all
337
+ conjunctive. A rule whose visibility is a disjunction stays unscoped and keeps the per-row filter.
338
+
303
339
  ## NULL
304
340
 
305
341
  `As of 2026-08`, one rule for the generated SQL, the in-memory source behind `from()` and the live
@@ -364,6 +400,7 @@ Fifty *counts* collapse neither way — one `count()` per row is fifty different
364
400
  | Not recorded | `explainQuery()`, `describeSql()`, the shared live window: built `unenforced`, no caller to attribute |
365
401
  | No sink installed | `X_QUERY_AUDIT_SINK_MISSING`, before the input parse |
366
402
  | The sink refuses | a denied/failed record: logged (`audit.sink.failed`), the caller gets the original error. An allowed record: the rows are withheld, `X_QUERY_AUDIT_SINK_FAILED` — a read commits nothing, so retry |
403
+ | Group commit | opt-in, `As of 31.11.0`: `postgresAuditSink({ executor, groupCommit: true })` (`@ultimat3/action`) queues each record up to 5 ms or 256 records (`{ maxRecords, maxDelayMs }` to change either) and writes the batch as one `x_audit` insert. Each call waits on its own batch, so the rule above holds per call: a failed batch is `X_QUERY_AUDIT_SINK_FAILED` (an action's, `X_AUDIT_SINK_FAILED`) on every allowed call it carried. Flushed on drain, before the pool closes. Any sink with a `writeMany(records)`: `batchedAuditSink(sink, opts)` from `@ultimat3/action/adapter` |
367
404
 
368
405
  ## Every cached query carries a tag
369
406
 
@@ -119,6 +119,15 @@ They go straight to the disk, in three calls — and **the client never names th
119
119
  | 2. browser | `uploadFile({ file, grant, onProgress })` | a PUT with real progress; `storage/upload-client.ts` is the one XHR seam in the browser |
120
120
  | 3. server, at `PUT /_storage/:disk/*key` | mounted by the framework in `x dev` and `runRole`, around `acceptSignedUpload`. Answers `201 { key }` | refuses a bad or expired signature, a key outside the actor's org, more bytes or another type than was granted, or magic bytes that contradict the type |
121
121
 
122
+ **The two server halves are one declaration: `uploadFlow()`** from `@ultimat3/action`, `As of
123
+ 31.11.0`. It returns `{ request, confirm }`, two actions — hop 1 as `request`, and `confirm` as
124
+ `promoteAttachment` onto the row, the stored object measured against `maxBytes`, sniffed against
125
+ `accept` (`X_STORAGE_TYPE_REJECTED`, left pending) and scanned when an `uploadScanner` is installed.
126
+ `request` never grants onto the row's key, so the targeted-grant gap below does not apply to it. A
127
+ doubled `confirm` answers the attached object; `attached` (write the key to the row there) runs
128
+ once. Hop 2 is unchanged — `grant` is `request`'s typed-client method: `uploadFile({ file, grant: client.requestPostCover })`. Declaration and
129
+ rules: [`@ultimat3/action` README, `uploadFlow()`](https://github.com/developerz-ai/ultimate/blob/main/packages/action/README.md#uploadflow--an-upload-as-one-declaration).
130
+
122
131
  **The mounted `PUT`** (`As of 2026-09-24`, #523) requires a signed-in actor, like the `GET`. It
123
132
  needs no permission: the grant is the authorization, and the action that minted it ran its own
124
133
  policy. The route checks the signature and the expiry, and it checks that the key is inside the
@@ -341,7 +350,7 @@ does not pass. Bytes past the window are not sniffed on any path through promoti
341
350
  | over 4,096 bytes of leading whitespace (`MAX_LEADING_WHITESPACE`), on every path | no real file opens that way, and past the window nothing is seen |
342
351
  | a disk whose `maxGetBytes` is under the window | its own `X_STORAGE_TOO_LARGE`: the ceiling bounds the range |
343
352
 
344
- A grant with a `target` has no promotion step: [Known gaps](Known-Gaps). With an `uploadScanner` installed it is refused outright, by `grantUpload` and `grantMultipart` alike (`X_STORAGE_TARGET_UNSCANNED`, 500): grant with no `target` and promote.
353
+ A grant with a `target` has no promotion step: [Known gaps](Known-Gaps). With an `uploadScanner` installed it is refused outright, by `grantUpload` and `grantMultipart` alike (`X_STORAGE_TARGET_UNSCANNED`, 500): grant with no `target` and promote — `uploadFlow()` (above) is that pair, declared once.
345
354
 
346
355
  ## Scanning uploads — the `uploadScanner` port
347
356
 
package/wiki/Upgrading.md CHANGED
@@ -239,6 +239,11 @@ A setter still on a package's `.` barrel is `X_ADAPTER_PORT_INCOMPLETE` on the `
239
239
  | a `countedIn` child write publishes an `entity.row` `update` for the parent row on memory and Postgres, PGlite in `x dev` included (**31.10.0**), so a live view of the count moves by itself | nothing. A mutator that recounted only to move a live view (`countBy` then `update`) can drop the recount |
240
240
  | `AuthAdapter` gains the optional `getSessionWithUser(id)` (**31.10.0**); `postgresAuthAdapter` and `memoryAuthAdapter` implement it, taking `authenticate` from two statements to one | nothing. A hand-written adapter may add it — `{ session, user \| null }` or `null`, what `getSession` then `findUserById` answer — and run `authAdapterConformance` on it |
241
241
  | an entity that adds `version: '<column>'` (**31.10.0**, opt-in) refuses `update(id)` without the version, setting it in `updateWhere`, and `upsertAll` with the default `onMatch: 'update'` — a seed's `upsertAll` included (`X_ENTITY_VERSION_INVALID`) | carry the version read: `update(id, { …patch, lockVersion: row.lockVersion })`; a seed uses `upsertAll(rows, { onConflict, onMatch: 'nothing' })` |
242
+ | a read whose policy is `scoped()` (`@ultimat3/policy`, **31.10.0**) has the scope composed into its `from()` source before the page is cut (**31.11.0**): a page that came back short because the rule dropped rows after the cut now comes back full, so a page's rows and its `nextCursor` can differ from 31.10.x. The rule still runs on every row. Such a read is cached per actor, whatever its `cache.scope`. A scoped policy on a read whose `sql` returns a hand-written `SqlSource` is `X_QUERY_SCOPE_UNCOMPOSABLE` (500) on every call | nothing for a `from()` read. Under `X_QUERY_SCOPE_UNCOMPOSABLE`: return `from(entity, (window) => repo.window(window))` from `sql`, or keep the hand-written source and declare the policy without `scoped()` |
243
+ | a `development` or `test` process logs `query.live.order_collation` (`X_LIVE_ORDER_COLLATION`) once per live query ordered by a declared text column (`text()`, `enumerated()`, `url()`, `tz()`, `locale()`) not `.collate('C')` (**31.11.0**). Nothing is refused and nothing else changes; staging and production stay silent. A refusal at subscribe is planned for `next` | for a `text()` column, declare it `text().collate('C')` and run `x db gen "<table> <column> collate C"` (an in-place `alter column … collate "C"`; the column's visible order becomes code-point order everywhere it is read), or order the live read by a non-text key: `.orderBy('createdAt', 'desc').orderBy('id')` — the only fix for `enumerated()`/`url()`/`tz()`/`locale()`, which have no `.collate()` |
244
+ | `x verify`'s `manifest` step lists `X_NATIVE_FORM_UNANSWERED` under `warnings` for each `page.tsx` `<form method="post">` posting to an action with no `native` (**31.11.0**). The step stays green; a refusal is planned for `next` | add `native: { success: (output) => '/where-it-lands' }` to that action's declaration, then `x verify --only manifest` |
245
+ | an action that declares `native` answers a refusal with a 4xx other than `X_UNAUTHENTICATED` to a browser form POST as a `303` (**31.11.0**). `X_UNAUTHENTICATED` keeps the sign-in redirect, so a protected form posted signed-out lands on sign-in as before; a sign-in action's own 401 (a wrong password) is a refusal and lands back on its form with its code. Without `native` nothing changes | nothing. A sign-in page that showed its failure some other way reads `useActionAnswer('<action>')` in its route's `load`: `outcome: 'refusal'` and the `code` the sign-in threw. Any 401 a sign-in throws must use its own code, never `X_UNAUTHENTICATED`, or it takes the sign-in redirect |
246
+ | an action that answers a browser form by sniffing `accept` itself (**31.11.0**, optional) | delete the hand-written `if (accept includes 'text/html') setRedirect(next)` from `handle` and declare `native: { success: (output) => output.next }` on the action. A `setRedirect()` still in `handle` keeps winning on success, so a sign-in's per-request `next` can stay where it is |
242
247
 
243
248
  ## 29.x → 30.0.0, entry by entry
244
249