@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
package/CLAUDE.md CHANGED
@@ -55,7 +55,7 @@ Commands: `bun test ./packages/cli/` (repo root: the preload),
55
55
  | `verify-factories.ts` | `unit` lints `<app>/packages/db/factories.ts` (`X_TEST_FACTORY_INVALID`) |
56
56
  | `boundary-findings.ts` / `app-boundaries.ts` / `boundary-cuts.ts` / `package-boundaries.ts` | surface + layer rules, `X_BOUNDARY_PACKAGE_TO_APP`; a `fix:` is the concrete cut † |
57
57
  | `app-boundaries.ts` (workspaces) | `@<scope>/<app>/<rest>` resolves onto `apps/<app>/<rest>` when that is an app source, so the surface rules hold across app workspaces |
58
- | `app-transport.ts` / `browser-transport.ts` / `transport-calls.ts` / `import-closure.ts` / `server-barrels.ts` | `boundaries`, built in: one browser transport; never a `guards/` file † |
58
+ | `app-transport.ts` / `browser-transport.ts` / `transport-calls.ts` / `transport-values.ts` / `binding-names.ts` / `import-closure.ts` / `server-barrels.ts` | `boundaries`, built in: one browser transport; never a `guards/` file † |
59
59
  | `guards.ts` / `guard-sources.ts` | an app's `guards/*.ts`, run on `boundaries`; ONE shared walk (`GuardSources`) † |
60
60
  | `templates/scaffold-guards.ts` | `SHIPPED`, the one list of shipped guards (`x new`, `x g guard`, `doctor-guards.ts`) † |
61
61
  | `error-contract.ts` / `ts-scan.ts` / `fix-scan.ts` / `fix-imports.ts` / `fix-command.ts` / `fix-path.ts` | the `errors` step: every `fix:` names a runnable command, call or existing file |
@@ -116,7 +116,7 @@ Commands: `bun test ./packages/cli/` (repo root: the preload),
116
116
  | `generate-refresh.ts` | `x g` refreshes the manifest only when a written file needs it |
117
117
  | `role-load.ts` / `document-graph.ts` / `serve-web.ts` | a role imports what it runs: `ROLE_LOADS` (`X_ROLE_LOAD_INCOMPLETE`) † |
118
118
  | `module-imports.ts` | a module's imports, resolved once for both graphs: `referenced` (reload), `evaluated` (document) |
119
- | `cmd-dev.ts` / `dev-boot.ts` / `dev-rebuild.ts` / `dev-route-table.ts` | `x dev`: every role in one process, `/_x`, the watcher; one save = one generation † |
119
+ | `cmd-dev.ts` / `dev-boot.ts` / `dev-rebuild.ts` / `dev-route-table.ts` | `x dev`: every role in one process, `/_x`, the watcher; one save = one generation, and the boot is the first: `buildGeneration` builds the manifest and the islands at once † |
120
120
  | `runtime-bindings.ts` | which service each binding points at (embedded or external); events follow `NATS_URL` |
121
121
  | `runtime-queue.ts` / `runtime-services.ts` / `runtime-bus.ts` | db + queue; every other accessor; the bus |
122
122
  | `framework-schema-apply.ts` / `framework-schema-stamp.ts` | the framework tables, applied in one locked transaction † |
@@ -141,7 +141,7 @@ Commands: `bun test ./packages/cli/` (repo root: the preload),
141
141
  | `page-navigation.ts` | the client router for `navigation.client` surfaces — built, routed and named ONCE for `x dev`, the container and the static export; none opted in builds nothing |
142
142
  | `page-speculation.ts` | Speculation Rules for documents WITHOUT the router (`navigation.speculation`): an allow-list of pure-read pages ‡ |
143
143
  | `static-document.ts` | a served `static` page: `304` on `If-None-Match`; container keeps the document (never `x dev`) † |
144
- | `island-{bundle,store,sources,runtime}.ts` / `island-realtime*.ts` / `solid-loader.ts` | islands: one `Bun.build` each, source-addressed † |
144
+ | `island-{bundle,groups,outputs,build-pool,group-cache,cache-inputs,store,sources,runtime}.ts` / `island-realtime*.ts` / `solid-loader.ts` | islands, source-addressed: one `Bun.build` per route group — islands on exactly the same routes split together, every other alone; groups read from `page.tsx` sources, the one input every caller has before rendering (`islands.sharedChunks` = one group). A group's output is reused from `.x/cache/islands/` while every file it read (Sass partials included), every directory listing it resolved in and the lockfile/tsconfig/`package.json` environment hash the same (`reuse: false` for a determinism test) † |
145
145
  | `local-cli.ts` / `local-cli-handoff.ts` | a global `x` hands over to the app's own CLI (`local-cli.ts` decides whether; `x upgrade` alone stays when the app's is strictly older — `upgrade-handover.test.ts`) |
146
146
  | `serve-prebuilt.ts` / `serve-prebuilt-paths.ts` | the image's prebuilt store; a boot that built anything logs `X_IMAGE_NOT_PREBUILT` † |
147
147
  | `dev-*.ts` | `x dev` only: dashboard sources, traces, the N+1 ledger, watcher, reload, lock, port |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultimat3/cli",
3
- "version": "31.1.0",
3
+ "version": "31.3.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.1.0",
57
- "@ultimat3/admin": "31.1.0",
58
- "@ultimat3/ai": "31.1.0",
59
- "@ultimat3/auth": "31.1.0",
60
- "@ultimat3/cache": "31.1.0",
61
- "@ultimat3/core": "31.1.0",
62
- "@ultimat3/db": "31.1.0",
63
- "@ultimat3/entity": "31.1.0",
64
- "@ultimat3/flags": "31.1.0",
65
- "@ultimat3/http": "31.1.0",
66
- "@ultimat3/i18n": "31.1.0",
67
- "@ultimat3/jobs": "31.1.0",
68
- "@ultimat3/mail": "31.1.0",
69
- "@ultimat3/manifest": "31.1.0",
70
- "@ultimat3/mcp": "31.1.0",
71
- "@ultimat3/money": "31.1.0",
72
- "@ultimat3/notify": "31.1.0",
73
- "@ultimat3/policy": "31.1.0",
74
- "@ultimat3/pwa": "31.1.0",
75
- "@ultimat3/query": "31.1.0",
76
- "@ultimat3/realtime": "31.1.0",
77
- "@ultimat3/render": "31.1.0",
78
- "@ultimat3/schema": "31.1.0",
79
- "@ultimat3/scraping": "31.1.0",
80
- "@ultimat3/seo": "31.1.0",
81
- "@ultimat3/storage": "31.1.0",
82
- "@ultimat3/testing": "31.1.0",
83
- "@ultimat3/time": "31.1.0",
56
+ "@ultimat3/action": "31.3.0",
57
+ "@ultimat3/admin": "31.3.0",
58
+ "@ultimat3/ai": "31.3.0",
59
+ "@ultimat3/auth": "31.3.0",
60
+ "@ultimat3/cache": "31.3.0",
61
+ "@ultimat3/core": "31.3.0",
62
+ "@ultimat3/db": "31.3.0",
63
+ "@ultimat3/entity": "31.3.0",
64
+ "@ultimat3/flags": "31.3.0",
65
+ "@ultimat3/http": "31.3.0",
66
+ "@ultimat3/i18n": "31.3.0",
67
+ "@ultimat3/jobs": "31.3.0",
68
+ "@ultimat3/mail": "31.3.0",
69
+ "@ultimat3/manifest": "31.3.0",
70
+ "@ultimat3/mcp": "31.3.0",
71
+ "@ultimat3/money": "31.3.0",
72
+ "@ultimat3/notify": "31.3.0",
73
+ "@ultimat3/policy": "31.3.0",
74
+ "@ultimat3/pwa": "31.3.0",
75
+ "@ultimat3/query": "31.3.0",
76
+ "@ultimat3/realtime": "31.3.0",
77
+ "@ultimat3/render": "31.3.0",
78
+ "@ultimat3/schema": "31.3.0",
79
+ "@ultimat3/scraping": "31.3.0",
80
+ "@ultimat3/seo": "31.3.0",
81
+ "@ultimat3/storage": "31.3.0",
82
+ "@ultimat3/testing": "31.3.0",
83
+ "@ultimat3/time": "31.3.0",
84
84
  "babel-preset-solid": "^1.9.16"
85
85
  }
86
86
  }
package/src/app-load.ts CHANGED
@@ -209,9 +209,10 @@ export function isScannedModule(root: string, absolute: string): boolean {
209
209
  // `~/dev/node_modules-experiments/myapp` answered `includes('node_modules')` for every
210
210
  // file it holds, so this loop imported none of them and the app registered nothing.
211
211
  // The ROOT-RELATIVE path is tested, never the absolute one: an app checked out under
212
- // `~/work/my.test.app` matched `.test.` on every file and loaded none of them.
212
+ // `~/work/my.test.app` matched `.test.` on every file and loaded none of them, and one under
213
+ // `<anything>/node_modules/<app>` matched the segment on every file the same way.
213
214
  const file = posixRelative(root, absolute);
214
- if (hasPathSegment(absolute, 'node_modules') || isTest(file)) return false;
215
+ if (hasPathSegment(file, 'node_modules') || isTest(file)) return false;
215
216
  return !(
216
217
  ENTRY_POINT.test(file) ||
217
218
  EXERCISE_FILE.test(file) ||
@@ -0,0 +1,124 @@
1
+ // The names an object destructuring BINDS, read off masked source: `{ fetch: f }` binds `f`, never
2
+ // `fetch`; `{ fetch }`, `{ fetch = d }`, `{ a: { fetch } }` and `{ ...fetch }` bind `fetch`. Only a
3
+ // pattern in a binding position counts — a `const`/`let`/`var` declaration or a parameter list —
4
+ // so `make({ fetch })`, the very hand-off the transport rule reports, binds nothing.
5
+
6
+ /** Opening bracket → its closer. A `Map`: a char read off source never reaches a prototype. */
7
+ const PAIRS: ReadonlyMap<string, string> = new Map([
8
+ ['(', ')'],
9
+ ['[', ']'],
10
+ ['{', '}'],
11
+ ]);
12
+
13
+ /** The index of the bracket closing the one at `open`, or `-1`. Exact on masked text only. */
14
+ function closing(masked: string, open: number): number {
15
+ const stack: string[] = [];
16
+ for (let at = open; at < masked.length; at += 1) {
17
+ const char = masked[at] ?? '';
18
+ const close = PAIRS.get(char);
19
+ if (close !== undefined) stack.push(close);
20
+ else if (char === stack[stack.length - 1]) {
21
+ stack.pop();
22
+ if (stack.length === 0) return at;
23
+ }
24
+ }
25
+ return -1;
26
+ }
27
+
28
+ /** The index of the unmatched `(` enclosing `index`, or `-1`. */
29
+ function enclosingParen(masked: string, index: number): number {
30
+ let depth = 0;
31
+ for (let at = index - 1; at >= 0; at -= 1) {
32
+ const char = masked[at] ?? '';
33
+ if (char === ')' || char === ']' || char === '}') depth += 1;
34
+ else if (char === '(' || char === '[' || char === '{') {
35
+ if (depth === 0) return char === '(' ? at : -1;
36
+ depth -= 1;
37
+ }
38
+ }
39
+ return -1;
40
+ }
41
+
42
+ /** `text` split on commas at depth zero — a pattern's entries. */
43
+ function topLevel(text: string, separator: string): readonly string[] {
44
+ const parts: string[] = [];
45
+ let depth = 0;
46
+ let from = 0;
47
+ for (let at = 0; at < text.length; at += 1) {
48
+ const char = text[at] ?? '';
49
+ if ('([{'.includes(char)) depth += 1;
50
+ else if (')]}'.includes(char)) depth -= 1;
51
+ else if (char === separator && depth === 0) {
52
+ parts.push(text.slice(from, at));
53
+ from = at + 1;
54
+ }
55
+ }
56
+ parts.push(text.slice(from));
57
+ return parts;
58
+ }
59
+
60
+ /** The first `=` at depth zero that is no `==`/`=>`, or `-1`: where a default starts. */
61
+ function defaultAt(text: string): number {
62
+ let depth = 0;
63
+ for (let at = 0; at < text.length; at += 1) {
64
+ const char = text[at] ?? '';
65
+ if ('([{'.includes(char)) depth += 1;
66
+ else if (')]}'.includes(char)) depth -= 1;
67
+ else if (char === '=' && depth === 0 && !/[=>]/.test(text[at + 1] ?? '')) {
68
+ return /[=!<>]/.test(text[at - 1] ?? '') ? -1 : at;
69
+ }
70
+ }
71
+ return -1;
72
+ }
73
+
74
+ /** The names one binding target binds: an identifier, or a nested object or array pattern. */
75
+ function targetNames(raw: string): readonly string[] {
76
+ const cut = defaultAt(raw);
77
+ const target = (cut < 0 ? raw : raw.slice(0, cut))
78
+ .trim()
79
+ .replace(/^\.\.\./, '')
80
+ .trim();
81
+ if (target.startsWith('{')) return patternNames(target.slice(1, -1), 'object');
82
+ if (target.startsWith('[')) return patternNames(target.slice(1, -1), 'array');
83
+ const name = /^[\w$]+/.exec(target)?.[0];
84
+ return name === undefined ? [] : [name];
85
+ }
86
+
87
+ function patternNames(body: string, kind: 'object' | 'array'): readonly string[] {
88
+ return topLevel(body, ',').flatMap((entry) => {
89
+ if (kind === 'array') return targetNames(entry);
90
+ const [key, ...rest] = topLevel(entry, ':');
91
+ // `key: target` binds the target; a shorthand `name` or `name = d` binds the name.
92
+ return rest.length === 0 ? targetNames(key ?? '') : targetNames(rest.join(':'));
93
+ });
94
+ }
95
+
96
+ /** Cheap, before any bracket is matched: a declaration keyword, or a `(`/`,` a parameter follows. */
97
+ function mayBind(masked: string, open: number): 'declared' | 'parameter' | undefined {
98
+ const head = masked.slice(Math.max(0, open - 8), open);
99
+ if (/\b(?:const|let|var)\s*$/.test(head)) return 'declared';
100
+ return /[(,]\s*$/.test(masked.slice(Math.max(0, open - 64), open)) ? 'parameter' : undefined;
101
+ }
102
+
103
+ /** A `{` after `(`/`,` is a parameter when its list is followed by a body, an arrow or a type. */
104
+ function isParameter(masked: string, open: number, close: number): boolean {
105
+ const paren = enclosingParen(masked, open);
106
+ if (paren < 0) return false;
107
+ const end = closing(masked, paren);
108
+ if (end < close) return false;
109
+ // A call's arguments are followed by neither: `make({ fetch }).then(go)`, `make({ fetch });`.
110
+ return /^\s*(?:=>|\{|:(?!:))/.test(masked.slice(end + 1, end + 64));
111
+ }
112
+
113
+ /** Every name the object patterns in binding positions of `masked` bind. */
114
+ export function destructuredNames(masked: string): ReadonlySet<string> {
115
+ const names = new Set<string>();
116
+ for (let open = masked.indexOf('{'); open >= 0; open = masked.indexOf('{', open + 1)) {
117
+ const position = mayBind(masked, open);
118
+ if (position === undefined) continue;
119
+ const close = closing(masked, open);
120
+ if (close < 0 || (position === 'parameter' && !isParameter(masked, open, close))) continue;
121
+ for (const name of patternNames(masked.slice(open + 1, close), 'object')) names.add(name);
122
+ }
123
+ return names;
124
+ }
@@ -13,6 +13,9 @@
13
13
  // imported by either; a request made inside an installed package (the walk ends at the package
14
14
  // boundary); a fetch reached through a computed member (`globalThis['fetch']`); and a bare
15
15
  // `fetch(` in a file that also binds a local `fetch` (`bindsFetch`). A floor, not a proof.
16
+ //
17
+ // The global `fetch` PASSED ON — `rpc({ fetch })`, `const f = window.fetch` — is the same bypass
18
+ // one module later (`transport-values.ts`), reported with a fix that removes the hand-off.
16
19
 
17
20
  import { ERROR_DOCS_URL, maskLiterals } from '@ultimat3/core';
18
21
  import { commentSafe } from './comment-safe';
@@ -24,9 +27,12 @@ import { barrelImports } from './server-barrels';
24
27
  import { isTest } from './source-files';
25
28
  import type { TransportCall, TransportShape } from './transport-calls';
26
29
  import { transportCalls } from './transport-calls';
30
+ import { fetchValues } from './transport-values';
27
31
 
28
32
  export interface Bypass extends TransportCall {
29
33
  readonly file: string;
34
+ /** The global handed on as a value rather than called here (`transport-values.ts`). */
35
+ readonly passed?: boolean;
30
36
  }
31
37
 
32
38
  export interface ServerBarrel extends BarrelImport {
@@ -90,6 +96,10 @@ export function checkBrowserTransport(input: TransportInput): {
90
96
  if (input.seams.get(call.shape) === file) continue;
91
97
  bypasses.push({ ...call, file });
92
98
  }
99
+ for (const value of fetchValues(source)) {
100
+ if (input.seams.get(value.shape) === file) continue;
101
+ bypasses.push({ ...value, file, passed: true });
102
+ }
93
103
  for (const found of barrelImports(source, input.barrels)) {
94
104
  if (input.ownsBarrel?.(file, found.barrel) === true) continue;
95
105
  barrels.push({ ...found, file });
@@ -137,6 +147,7 @@ const siteOf = (site: { readonly file: string; readonly line: number }): string
137
147
  * command re-reads the tree; the comment is the edit, because only the finding knows the line.
138
148
  */
139
149
  export function bypassFinding(bypass: Bypass, context: FindingContext): Finding {
150
+ if (bypass.passed === true) return passedFinding(bypass, context);
140
151
  const holder = context.holder(bypass.shape);
141
152
  const site = siteOf(bypass);
142
153
  return {
@@ -148,6 +159,23 @@ export function bypassFinding(bypass: Bypass, context: FindingContext): Finding
148
159
  };
149
160
  }
150
161
 
162
+ /**
163
+ * The global handed to another module: the request happens THERE, through a property no rule reads,
164
+ * so the edit is here — stop handing it on (a typed client already sends through the seam) — and
165
+ * the module that took it is the one to move onto the replacement.
166
+ */
167
+ function passedFinding(bypass: Bypass, context: FindingContext): Finding {
168
+ const holder = context.holder(bypass.shape);
169
+ const site = siteOf(bypass);
170
+ return {
171
+ code: 'X_BROWSER_TRANSPORT_BYPASS',
172
+ at: `${bypass.file}:${bypass.line}`,
173
+ cause: `${site} passes the global ${bypass.spelled} as a value in browser-reachable code; whatever receives it calls it directly, and ${holder === undefined ? 'no module may' : `only ${holder} may`}, so those requests skip the page's record store, idempotency header and principal fence`,
174
+ fix: `${context.rerun} # after deleting ${bypass.spelled} at ${site} (rpc() and queryClient() send through clientTransport when given none) and making the module that took it use ${REPLACEMENT.get(bypass.shape) ?? ''}`,
175
+ docs: ERROR_DOCS_URL,
176
+ };
177
+ }
178
+
151
179
  export function barrelFinding(site: ServerBarrel, context: FindingContext): Finding {
152
180
  const at = siteOf(site);
153
181
  return {
package/src/cmd-doctor.ts CHANGED
@@ -25,6 +25,7 @@ import { rollingSinceProbe, withRollingReminder } from './doctor-rolling';
25
25
  import { rowSecurityProbe } from './doctor-row-security';
26
26
  import type { SealedKeysFact } from './doctor-sealed';
27
27
  import { sealedKeyFindings, sealedKeysProbe } from './doctor-sealed';
28
+ import { typescriptFindings, typescriptProbe } from './doctor-typescript';
28
29
  import { PORT_RANGE, portPairAfter, readIntFlag } from './flag-number';
29
30
  import { machineSecretFindings } from './framework-env';
30
31
  import { ICON_SOURCE } from './icon-assets';
@@ -37,6 +38,7 @@ import { syncPortFor } from './role-sync';
37
38
  import { checkMigrationDrift } from './schema-drift';
38
39
  import { portFromEnv } from './serve-env';
39
40
  import { quoteArg } from './shell-quote';
41
+ import type { TypescriptLag } from './typescript-floor';
40
42
 
41
43
  /**
42
44
  * The injection seam `runDoctor` reads instead of the environment. Not a semver surface —
@@ -106,6 +108,8 @@ export interface DoctorProbe {
106
108
  authStorage(): Promise<AuthStorageFact>;
107
109
  /** The statement bound the session really reads, and what a pooler refused (`doctor-pooler.ts`). */
108
110
  pooler(): Promise<PoolerFact>;
111
+ /** Each manifest whose `typescript` range lags the scaffold's (`doctor-typescript.ts`). */
112
+ typescript(): Promise<readonly TypescriptLag[]>;
109
113
  /** With `database.rowSecurity` on, whether the serving role is exempt (`doctor-row-security.ts`). */
110
114
  rowSecurity?(): Promise<readonly Finding[]>;
111
115
  }
@@ -221,6 +225,9 @@ export async function runDoctor(probe: DoctorProbe): Promise<readonly Finding[]>
221
225
  );
222
226
  return findings;
223
227
  }
228
+ // Right after the runtime and for its reason: a compiler a major behind reds typecheck and build
229
+ // on the framework's own files, and every finding below is read through a gate that cannot pass.
230
+ findings.push(...typescriptFindings(await probe.typescript()));
224
231
  if (!probe.exists(ENV_DEVELOPMENT)) {
225
232
  findings.push(
226
233
  finding(
@@ -421,6 +428,7 @@ export function probeFor(
421
428
  root === undefined ? { columns: undefined, keys: undefined } : sealedKeysProbe(root),
422
429
  authStorage: () => authStorageProbe(process.env['DATABASE_URL'], env),
423
430
  pooler: () => poolerProbe(process.env['DATABASE_URL'], env),
431
+ typescript: async () => (root === undefined ? [] : typescriptProbe(root)),
424
432
  rowSecurity: async () =>
425
433
  root === undefined ? [] : rowSecurityProbe(root, process.env['DATABASE_URL'], env),
426
434
  };
@@ -36,6 +36,7 @@ import { entityTenantFindings } from './exercise-static';
36
36
  import { subjectFindings, subjectProofFindings } from './exercise-subject';
37
37
  import { readIntFlag } from './flag-number';
38
38
  import { msg } from './messages';
39
+ import { withOfflinePorts } from './offline-ports';
39
40
  import type { CommandResult, JsonValue } from './output';
40
41
 
41
42
  /**
@@ -70,8 +71,19 @@ async function exercise(
70
71
  root: string,
71
72
  seed: number | undefined,
72
73
  ): Promise<CommandResult> {
73
- const only = ctx.args.positionals[0];
74
74
  const loaded = await loadApp(root);
75
+ // `runtime.ts`'s ports, as a boot reads them — an `auditSink` declared there is what lets an
76
+ // `audit: true` primitive run — through `offline-ports.ts`, so the pass reaches no real backend.
77
+ return withOfflinePorts(root, () => exercisePass(ctx, root, seed, loaded));
78
+ }
79
+
80
+ async function exercisePass(
81
+ ctx: CommandContext,
82
+ root: string,
83
+ seed: number | undefined,
84
+ loaded: Awaited<ReturnType<typeof loadApp>>,
85
+ ): Promise<CommandResult> {
86
+ const only = ctx.args.positionals[0];
75
87
  const overrides = await readExerciseOverrides(root);
76
88
  const cores = registeredEntityCores();
77
89
  const entities: readonly SeedEntity[] = Object.values(cores);
@@ -17,6 +17,7 @@ import { msg } from './messages';
17
17
  import type { CommandResult } from './output';
18
18
  import { flagBool, flagString } from './parse';
19
19
  import { posixRelative } from './posix-path';
20
+ import { typescriptLags } from './typescript-floor';
20
21
  import { applyAgentsLink, planAgentsLink } from './upgrade-agents-link';
21
22
  import type { BunEdit, BunManual } from './upgrade-bun-floor';
22
23
  import { editBunSites, floorOf, isBunSite } from './upgrade-bun-floor';
@@ -154,6 +155,8 @@ export const createUpgradeCommand = (write: (line: string) => void): CliCommand
154
155
  const top = await requireCleanTree(ctx.runner, root);
155
156
  const manifests = await readManifests(root);
156
157
  const pins = readPins(manifests);
158
+ // Reported, never written: a compiler is the app's to move, and the line names the command.
159
+ const typescript = typescriptLags(manifests);
157
160
  const versions = await publishedVersions(ctx.runner, root);
158
161
  const hop = planHop({ pins, versions, ...(to === undefined ? {} : { to }) });
159
162
 
@@ -176,8 +179,12 @@ export const createUpgradeCommand = (write: (line: string) => void): CliCommand
176
179
  gate: undefined,
177
180
  scripts: [],
178
181
  then,
182
+ typescript,
179
183
  }),
180
- lines: [msg('cli.upgrade.then', { then })],
184
+ lines: [
185
+ ...typescript.map((lag) => msg('cli.upgrade.typescript', { ...lag })),
186
+ msg('cli.upgrade.then', { then }),
187
+ ],
181
188
  });
182
189
  }
183
190
 
@@ -199,7 +206,16 @@ export const createUpgradeCommand = (write: (line: string) => void): CliCommand
199
206
  const held = manifests.find((manifest) => manifest.file === 'package.json')?.text ?? '';
200
207
  const bunFrom = /"engines"\s*:\s*\{[^}]*?"bun"\s*:\s*"([^"]*)"/.exec(held)?.[1] ?? null;
201
208
  const agentsMd = await planAgentsLink(root);
202
- const shared = { hop, pins, bunFrom, bunTo: bunRange ?? null, writes, app, agentsMd };
209
+ const shared = {
210
+ hop,
211
+ pins,
212
+ bunFrom,
213
+ bunTo: bunRange ?? null,
214
+ writes,
215
+ app,
216
+ agentsMd,
217
+ typescript,
218
+ };
203
219
  const scriptNames = app ? [] : repoScripts(held);
204
220
 
205
221
  if (dryRun) {
@@ -214,7 +230,15 @@ export const createUpgradeCommand = (write: (line: string) => void): CliCommand
214
230
  scripts: named,
215
231
  then,
216
232
  }),
217
- lines: humanLines({ hop, writes, gate: undefined, scripts: named, then, agentsMd }),
233
+ lines: humanLines({
234
+ hop,
235
+ writes,
236
+ gate: undefined,
237
+ scripts: named,
238
+ then,
239
+ agentsMd,
240
+ typescript,
241
+ }),
218
242
  });
219
243
  }
220
244
 
@@ -248,7 +272,7 @@ export const createUpgradeCommand = (write: (line: string) => void): CliCommand
248
272
  const then = thenLine({ hop, dryRun: false, app, gate, scripts });
249
273
  const extra = {
250
274
  data: report({ ...shared, done, dryRun: false, gate, scripts, then }),
251
- lines: humanLines({ hop, writes, gate, scripts, then, agentsMd }),
275
+ lines: humanLines({ hop, writes, gate, scripts, then, agentsMd, typescript }),
252
276
  };
253
277
  const span = { from: hop.from, to: hop.to };
254
278
  if (gate !== undefined) {
package/src/dev-boot.ts CHANGED
@@ -10,7 +10,6 @@ import type { OverlayNotice, RequestContext } from '@ultimat3/http';
10
10
  import { asCtx } from '@ultimat3/http';
11
11
  import { loadSignInPath } from './app-auth';
12
12
  import { loadAppConfig } from './app-config-load';
13
- import { appManifest } from './app-manifest';
14
13
  import type { StalePin } from './app-reload-graph';
15
14
  import { enableReloadTracking } from './app-reload-graph';
16
15
  import { loadAppRuntime } from './app-runtime';
@@ -20,12 +19,11 @@ import { createInvalidationLog } from './dev-dashboard-invalidations';
20
19
  import { declareDevEnvironment, needsDevEnvironmentDeclaration } from './dev-environment';
21
20
  import { createStatementLedger } from './dev-n-plus-one';
22
21
  import type { DevState } from './dev-rebuild';
23
- import { devRebuilder } from './dev-rebuild';
22
+ import { buildGeneration, devRebuilder } from './dev-rebuild';
24
23
  import { devRouteTable } from './dev-route-table';
25
24
  import { createTraceRecorder } from './dev-traces';
26
25
  import { watchTree } from './dev-watch-tree';
27
26
  import { armFailureCapture } from './failure-capture-boot';
28
- import { buildIslands } from './island-bundle';
29
27
  import { FRAME_STYLE } from './island-harness';
30
28
  import type { Finding } from './output';
31
29
  import { plainRoutes } from './plain-routes';
@@ -184,13 +182,14 @@ async function bootDev(
184
182
  // two projections of one scan. Until 2026-09-07 this was `loadApp` for the findings and then
185
183
  // `appManifest` — which loads again — for the manifest, so a save landing between the two put
186
184
  // `/_x`'s findings and its manifest on different registration states.
187
- const app = await appManifest(options.root);
185
+ // The islands are built beside that load, never after it: `buildGeneration`, as every save does.
186
+ const app = await buildGeneration(options.root);
188
187
  const state: DevState = {
189
188
  manifest: app.manifest,
190
189
  reloads: 0,
191
190
  reloadFinding: undefined,
192
191
  appFindings: app.findings,
193
- islands: await buildIslands(options.root),
192
+ islands: app.islands,
194
193
  };
195
194
  // `serve-boot.ts`'s guard, at its point: after the app's modules, before any role serves. On
196
195
  // PGlite the boot serves as `x_app`; on an external database a role that bypasses is refused.
@@ -5,14 +5,16 @@
5
5
  import type { Manifest } from '@ultimat3/manifest';
6
6
  import { beginDeviceSocketGeneration } from '@ultimat3/realtime/server';
7
7
  import type { IsrController } from '@ultimat3/render/server';
8
+ import type { AppManifest } from './app-manifest';
8
9
  import { appManifest } from './app-manifest';
9
10
  import type { StalePin } from './app-reload-graph';
10
11
  import { takeStalePins } from './app-reload-graph';
11
12
  import type { ReloadTrigger } from './dev-reload';
12
13
  import { coalesceReloads } from './dev-reload';
13
14
  import { restartFinding } from './dev-supervisor';
14
- import type { IslandBundle } from './island-bundle';
15
+ import type { BuildIslandsOptions, IslandBundle } from './island-bundle';
15
16
  import { buildIslands } from './island-bundle';
17
+ import { appPersistsRecords } from './island-realtime-state';
16
18
  import type { Finding } from './output';
17
19
  import { findingFrom } from './output';
18
20
 
@@ -36,6 +38,40 @@ export interface DevState {
36
38
  islands: IslandBundle;
37
39
  }
38
40
 
41
+ /** The two builders of one generation — the seam a test times them through. */
42
+ export interface GenerationBuilders {
43
+ readonly manifest: (root: string) => Promise<AppManifest>;
44
+ readonly islands: (root: string, options: BuildIslandsOptions) => Promise<IslandBundle>;
45
+ }
46
+
47
+ const BUILDERS: GenerationBuilders = { manifest: appManifest, islands: buildIslands };
48
+
49
+ /**
50
+ * One generation — the app's manifest and its island bundle — both builders started at once, at
51
+ * the boot as on every save. The island build is Bun's bundler, off the JS thread, and the app
52
+ * load is imports on it: one after the other, a 5,000-file app's boot paid ~4 s and ~12 s in sum
53
+ * before its first 200 (`scripts/bench/results/boot-large-app.json`).
54
+ */
55
+ export async function buildGeneration(
56
+ root: string,
57
+ build: GenerationBuilders = BUILDERS,
58
+ ): Promise<AppManifest & { readonly islands: IslandBundle }> {
59
+ const loaded = build.manifest(root);
60
+ // The one answer the island build takes from the app — whether it persists records — read only
61
+ // once the load has settled: before it the registry is empty, and every reader island would be
62
+ // built as one that restores (`island-realtime.ts`). Only realtime groups wait for it.
63
+ const persists = (): Promise<boolean | undefined> =>
64
+ loaded.then(
65
+ () => appPersistsRecords(),
66
+ () => undefined,
67
+ );
68
+ const [{ manifest, findings }, islands] = await Promise.all([
69
+ loaded,
70
+ build.islands(root, { persists }),
71
+ ]);
72
+ return { manifest, findings, islands };
73
+ }
74
+
39
75
  /** What a rebuild reports to, read off `StartDevOptions`. */
40
76
  export interface DevRebuildOptions {
41
77
  readonly root: string;
@@ -73,10 +109,7 @@ export function devRebuilder(
73
109
  async (file) => {
74
110
  const started = performance.now();
75
111
  beginDeviceSocketGeneration();
76
- const [{ manifest, findings }, islands] = await Promise.all([
77
- appManifest(options.root),
78
- buildIslands(options.root),
79
- ]);
112
+ const { manifest, findings, islands } = await buildGeneration(options.root);
80
113
  state.manifest = manifest;
81
114
  state.appFindings = findings;
82
115
  state.islands = islands;
@@ -0,0 +1,31 @@
1
+ // `x doctor`'s TypeScript check: every manifest whose `typescript` range lags the one `x new`
2
+ // scaffolds is `X_TYPESCRIPT_VERSION`, its fix the `bun add` that moves exactly that manifest.
3
+ // The rule is `typescript-floor.ts`'s; this file reads the manifests and words the finding.
4
+
5
+ import { ERROR_DOCS_URL } from '@ultimat3/core';
6
+ import type { Finding } from './output';
7
+ import type { TypescriptLag } from './typescript-floor';
8
+ import { typescriptLags } from './typescript-floor';
9
+ import { readManifests } from './upgrade-pins';
10
+
11
+ /**
12
+ * The I/O half: the root manifest and every workspace's, the set `x upgrade` moves pins in. An
13
+ * unreadable root manifest is not this check's to report — `bun install` names its line — so it
14
+ * reads as nothing to judge rather than a second finding about the same file.
15
+ */
16
+ export async function typescriptProbe(root: string): Promise<readonly TypescriptLag[]> {
17
+ try {
18
+ return typescriptLags(await readManifests(root));
19
+ } catch {
20
+ return [];
21
+ }
22
+ }
23
+
24
+ export const typescriptFindings = (lags: readonly TypescriptLag[]): readonly Finding[] =>
25
+ lags.map((lag) => ({
26
+ code: 'X_TYPESCRIPT_VERSION',
27
+ at: lag.file,
28
+ cause: `${lag.file} declares ${lag.field}.typescript ${JSON.stringify(lag.from)}, below the ${lag.to} \`x new\` scaffolds; @ultimat3/* ships source and .d.ts checked by that compiler, so typecheck and build go red on framework files this app never wrote`,
29
+ fix: lag.fix,
30
+ docs: ERROR_DOCS_URL,
31
+ }));
@@ -236,6 +236,7 @@ export const CLI_OWNED_ERROR_CODES = [
236
236
  'X_APP_ROOT_NESTED',
237
237
  'X_WORKSPACE_NAME_TAKEN',
238
238
  'X_PARTITIONS_UNMAINTAINED',
239
+ 'X_TYPESCRIPT_VERSION',
239
240
  ] as const;
240
241
 
241
242
  /**
@@ -458,6 +459,7 @@ export const CLI_ERROR_TITLES: Readonly<Record<CliListedErrorCode, string>> = {
458
459
  X_WORKSPACE_NAME_TAKEN:
459
460
  'x g app or x g package was given a name the other workspace kind already holds',
460
461
  X_PARTITIONS_UNMAINTAINED: 'a partitioned entity with no partitions() job',
462
+ X_TYPESCRIPT_VERSION: 'The app declares a TypeScript older than the one x new scaffolds',
461
463
  };
462
464
 
463
465
  // One unconditional call, so a second package claiming one of the CLI's codes throws
@@ -0,0 +1,35 @@
1
+ // The pool the island build runs its groups through: at most `width` at once, answers in item
2
+ // order, and stopped by its first failure.
3
+
4
+ /**
5
+ * `run` over `items`, at most `width` at a time, answers in `items` order. 159 builds at once (the
6
+ * bench app) bought nothing over twelve — the plugins' callbacks share one JS thread — and held
7
+ * every build's graph in memory together.
8
+ */
9
+ export async function boundedMap<T, R>(
10
+ items: readonly T[],
11
+ width: number,
12
+ run: (item: T) => Promise<R>,
13
+ ): Promise<R[]> {
14
+ const results: R[] = new Array(items.length);
15
+ let next = 0;
16
+ // Set by the first rejection and read before every start: the builds already in flight finish
17
+ // (a `Bun.build` cannot be cancelled), but no idle worker takes another group — in `x dev` one
18
+ // island's syntax error left every remaining group bundling, ~12 s, into the next generation.
19
+ // And the call answers only once those in flight HAVE finished: each registers stylesheets and
20
+ // pins chunk bytes process-wide, so one outliving the call would write into the next generation.
21
+ let failure: { readonly error: unknown } | undefined;
22
+ const worker = async (): Promise<void> => {
23
+ for (let index = next++; failure === undefined && index < items.length; index = next++) {
24
+ try {
25
+ results[index] = await run(items[index] as T);
26
+ } catch (error) {
27
+ if (failure === undefined) failure = { error };
28
+ }
29
+ }
30
+ };
31
+ const workers = Math.max(1, Math.min(width, items.length));
32
+ await Promise.all(Array.from({ length: items.length === 0 ? 0 : workers }, worker));
33
+ if (failure !== undefined) throw failure.error;
34
+ return results;
35
+ }