@ultimat3/cli 5.0.0 → 6.0.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/src/cmd-i18n.ts CHANGED
@@ -8,7 +8,7 @@
8
8
  // would, and `node:path` because Bun exposes no path API to build what either of them takes.
9
9
  import { type FileHandle, mkdir, open } from 'node:fs/promises';
10
10
  import { dirname, join } from 'node:path';
11
- import { catalogKeys, catalogMissingKeys } from '@ultimat3/i18n';
11
+ import { catalogKeys } from '@ultimat3/i18n';
12
12
  import { loadApp } from './app-load';
13
13
  import { requireAppRoot } from './app-root';
14
14
  import type { CliCommand, CommandContext } from './command';
@@ -21,9 +21,9 @@ import {
21
21
  serializeCatalog,
22
22
  syncCatalog,
23
23
  } from './i18n-audit';
24
+ import { checkRegistration, missingKeyFindings } from './i18n-registration';
24
25
  import { msg } from './messages';
25
26
  import type { CommandResult, Finding, JsonValue } from './output';
26
- import { findingFrom } from './output';
27
27
  import { renderTable } from './table';
28
28
  import { catalogPath, resolveLocales } from './templates/locales';
29
29
 
@@ -102,21 +102,24 @@ function resolveOneLocale(ctx: CommandContext, sub: string): string {
102
102
  }
103
103
 
104
104
  async function runCheck(root: string): Promise<CommandResult> {
105
- const { report, catalogs } = await auditApp(root);
106
-
107
- const findings: Finding[] = report.locales
108
- .filter((audit) => audit.missing.length > 0)
109
- .map((audit) => ({
110
- ...findingFrom(catalogMissingKeys(audit.locale, audit.missing)),
111
- at: catalogPath(audit.locale),
112
- }));
113
-
114
- const header = ['locale', 'keys', 'missing', 'unused'];
105
+ const { report, catalogs, extraction, ignoreUnused } = await auditApp(root);
106
+ // The runtime question, asked after the file question and never instead of it: a catalog can be
107
+ // complete on disk, used everywhere in source, and reach no registry at all (issue #249).
108
+ const registration = await checkRegistration({ root, catalogs, extraction, ignoreUnused });
109
+
110
+ const findings: Finding[] = [...missingKeyFindings(report), ...registration.findings];
111
+
112
+ // Whether the LOCALE has a catalog is the wrong question — the framework's own `en` is always
113
+ // registered, so a locale-presence column reads `yes` for an app whose every key is a loud miss.
114
+ // The column answers the key-level one: does the registry hold what this file defines?
115
+ const unregistered = new Set(registration.unregisteredLocales);
116
+ const header = ['locale', 'keys', 'missing', 'unused', 'registered'];
115
117
  const rows = report.locales.map((audit) => [
116
118
  audit.locale,
117
119
  String(catalogKeys(catalogs[audit.locale] ?? {}).length),
118
120
  String(audit.missing.length),
119
121
  String(audit.unused.length),
122
+ unregistered.has(audit.locale) ? 'no' : 'yes',
120
123
  ]);
121
124
  const lines = renderTable(header, rows).map((line) => ` ${line}`);
122
125
 
@@ -135,13 +138,26 @@ async function runCheck(root: string): Promise<CommandResult> {
135
138
  }
136
139
  }
137
140
 
138
- const gapLocales = report.locales.filter((audit) => audit.missing.length > 0).length;
139
- const missingTotal = report.locales.reduce((sum, audit) => sum + audit.missing.length, 0);
140
- const summary = report.ok
141
+ // A key that renders a loud miss counts once, whichever half of the check found it: a missing
142
+ // catalog entry and an entry no registry holds are the same `⟦key⟧` on the same page.
143
+ const gapLocales =
144
+ report.locales.filter((audit) => audit.missing.length > 0).length + registration.locales;
145
+ const missingTotal =
146
+ report.locales.reduce((sum, audit) => sum + audit.missing.length, 0) +
147
+ registration.unregistered;
148
+ const ok = report.ok && registration.ok;
149
+ const summary = ok
141
150
  ? msg('cli.i18n.ok', { locales: report.locales.length, keys: report.used.length })
142
151
  : msg('cli.i18n.gaps', { missing: missingTotal, locales: gapLocales });
143
152
 
144
- return { ok: report.ok, command: 'i18n', summary, lines, findings, data: asJson(report) };
153
+ return {
154
+ ok,
155
+ command: 'i18n',
156
+ summary,
157
+ lines,
158
+ findings,
159
+ data: { ...asJson(report), ok, registered: [...registration.registered] },
160
+ };
145
161
  }
146
162
 
147
163
  async function runAdd(root: string, ctx: CommandContext): Promise<CommandResult> {
package/src/cmd-verify.ts CHANGED
@@ -3,438 +3,21 @@
3
3
  // shippable (axiom 5): one step list, no second checklist, no CI-only step, and no way to narrow
4
4
  // the run — `--only` and `--skip` would make "green" mean whatever the caller chose.
5
5
 
6
- import { existsSync } from 'node:fs';
7
- import { join } from 'node:path';
8
- import { renderThrowable } from '@ultimat3/core';
9
- import type { Manifest } from '@ultimat3/manifest';
10
- import {
11
- AGENTS_MD_FILENAME,
12
- assertNoDrift,
13
- MANIFEST_FILENAME,
14
- verifyContract,
15
- } from '@ultimat3/manifest';
16
- import type { MetaIssue } from '@ultimat3/seo';
17
- import { validateMeta } from '@ultimat3/seo';
18
- import { checkAgentsMd } from './app-agents-md';
19
- import { checkAppBoundaries } from './app-boundaries';
20
- import { envExampleFindings } from './app-env';
21
- import { appManifest, readAppManifest } from './app-manifest';
22
- import { OPENAPI_FILE, openApiJson } from './app-openapi';
23
- import { APP_CONFIG_FILE, requireAppRoot } from './app-root';
24
- import { checkBudgets, readBuildStats } from './budgets';
6
+ import { requireAppRoot } from './app-root';
25
7
  import type { CliCommand, CommandContext } from './command';
26
- import { checkDestructiveMigrations } from './db-destructive';
27
- import { checkDocumentStyles, documentSurfaces } from './document-styles';
28
- import { checkSourceDrift } from './drift';
29
- import { checkErrorFixReport } from './error-contract';
30
8
  import { readIntFlag } from './flag-number';
31
- import { guardFindings } from './guards';
32
- import { msg } from './messages';
33
- import type { CommandResult, Finding, StepResult } from './output';
34
- import { findingFrom } from './output';
9
+ import type { CommandResult } from './output';
35
10
  import type { ParsedArgs } from './parse';
36
- import { scanSiteMeta } from './seo-meta';
37
11
  import { WORKER_CEILING, WORKER_FLOOR, WORKER_OVERSUBSCRIBE } from './test-workers';
38
- import {
39
- floorProblemFindings,
40
- floorRequires,
41
- readVerifyFloor,
42
- skippedSuiteFinding,
43
- vanishedSuiteFinding,
44
- } from './verify-floor';
45
- import type { StepOutcome, VerifyContext, VerifyStep, VerifyStepName } from './verify-step';
46
- import { fromExec, fromFindings, hostFindings } from './verify-step';
47
- import { TEST_STEPS } from './verify-tests';
48
- import { checkFileSizes, checkPackageShape, hasWorkspacePackages } from './workspace-checks';
12
+ import { VERIFY_STEPS } from './verify-checks';
13
+ import { runVerify } from './verify-run';
14
+ import type { VerifyStepName } from './verify-step';
49
15
 
50
- /** The whole contract, in cost order. Every check the framework knows how to make lives here. */
51
- /** The one file that makes the `roadmap` step answerable, and therefore what `applies` reads. */
52
- const ROADMAP_FILE = join('docs', 'idea', '14-roadmap.md');
53
-
54
- export const VERIFY_STEPS: readonly VerifyStep[] = [
55
- {
56
- name: 'typecheck',
57
- summary: 'tsc -b across every project the root references',
58
- async run(ctx) {
59
- const result = await ctx.runner(['bunx', 'tsc', '-b', '--pretty', 'false'], {
60
- cwd: ctx.root,
61
- });
62
- return fromExec(result, {
63
- code: 'X_TYPECHECK_FAILED',
64
- cause: 'the project does not typecheck',
65
- fix: 'bunx tsc -b --pretty false',
66
- });
67
- },
68
- },
69
- {
70
- name: 'lint',
71
- // Only what biome actually enforces. It claimed "no default exports" while the rule was off
72
- // (it is not in `recommended`) and "no raw colours" over a file type biome ignores entirely —
73
- // two thirds of the line were enforced by nothing. `noDefaultExport` is now on in `biome.json`;
74
- // the colour rule is `packages/ui/src/tokens/tokens.test.ts`, and rides on the `unit` step.
75
- summary: 'biome: format, no any, no default exports, no unused imports',
76
- async run(ctx) {
77
- const result = await ctx.runner(['bunx', 'biome', 'check', '.'], { cwd: ctx.root });
78
- return fromExec(result, {
79
- code: 'X_LINT_FAILED',
80
- cause: 'biome reported problems',
81
- fix: 'bunx biome check --write .',
82
- });
83
- },
84
- },
85
- {
86
- name: 'boundaries',
87
- summary: "surface, layer and package-tier imports, and the app's own guards",
88
- // An app's `guards/` rides here rather than becoming an eighteenth step, for the reason the
89
- // seam already states: a host adds findings to a step, it can never add, remove, reorder or
90
- // skip one — so "green" keeps meaning exactly what it meant. This is the step whose host slot
91
- // already carries "rules this repo makes about itself that the framework cannot know" (the
92
- // monorepo's tier table arrives through it), and it runs third, before any suite, so a
93
- // convention failure is reported in seconds rather than after the tests.
94
- //
95
- // Discovered, not registered: `guardFindings` reads the directory. A guard that had to
96
- // announce itself is a guard an app can forget to announce, which is the coupling axiom 8's
97
- // extension model rejects.
98
- run: async (ctx) =>
99
- fromFindings([
100
- ...(await checkAppBoundaries(ctx.root)),
101
- ...(await guardFindings(ctx.root)),
102
- ...(await hostFindings(ctx, 'boundaries')),
103
- ]),
104
- },
105
- {
106
- name: 'filesize',
107
- summary: 'one file, one job',
108
- run: async (ctx) => fromFindings(await checkFileSizes(ctx.root)),
109
- },
110
- {
111
- name: 'package-shape',
112
- summary: 'every package ships the same contract files',
113
- applies: (ctx) => hasWorkspacePackages(ctx.root),
114
- run: async (ctx) => fromFindings(await checkPackageShape(ctx.root)),
115
- },
116
- {
117
- name: 'errors',
118
- summary: 'every X_* code has a runnable fix and a docs page',
119
- // The fix-line half runs anywhere source does. The docs half needs a reference page to check
120
- // against, and which file that is belongs to the host repo — hence `hostFindings`.
121
- //
122
- // The coverage line rides in `output`, which `--json` carries verbatim: a scan without a
123
- // parser cannot read every fix, and a step that reports only findings claims a completeness
124
- // it does not have. "checked 412, could not read 27" is what a reader can act on.
125
- async run(ctx) {
126
- const report = await checkErrorFixReport(ctx.root);
127
- const findings = [...report.findings, ...(await hostFindings(ctx, 'errors'))];
128
- return {
129
- ...fromFindings(findings),
130
- output: msg('cli.verify.fixCoverage', {
131
- checked: report.checked,
132
- unreadable: report.unreadable,
133
- }),
134
- };
135
- },
136
- },
137
- ...TEST_STEPS,
138
- {
139
- name: 'drift',
140
- summary: 'schema source vs migrations, and every destructive statement declared',
141
- // Only an app owns migrations; a package monorepo's `packages/db` is the driver, not a schema.
142
- // Source, not database: the gate runs in CI with nothing listening, and the database half is
143
- // the post-migrate verification `runMigrations` performs where a connection is already open.
144
- //
145
- // The destructive rail rides here rather than becoming an eighteenth step because it asks this
146
- // step's own question — do the committed migrations still describe what the app is doing to its
147
- // schema? — off the same directory, in the same pass, with no database either.
148
- applies: async (ctx) => existsSync(join(ctx.root, APP_CONFIG_FILE)),
149
- run: async (ctx) =>
150
- fromFindings([
151
- ...(await checkSourceDrift(ctx.root)),
152
- ...(await checkDestructiveMigrations(ctx.root)),
153
- ]),
154
- },
155
- {
156
- name: 'contract-diff',
157
- summary: 'the published contract vs the committed manifest',
158
- // Either file is a published contract on its own: `openapi.json` generates the typed client,
159
- // so gating on the manifest alone let a stale spec ship a wrong client unchecked.
160
- applies: async (ctx) =>
161
- existsSync(join(ctx.root, MANIFEST_FILENAME)) || existsSync(join(ctx.root, OPENAPI_FILE)),
162
- async run(ctx) {
163
- const committed = await readAppManifest(ctx.root);
164
- const { manifest, findings } = await appManifest(ctx.root);
165
- return fromFindings([
166
- ...findings,
167
- ...(committed === undefined ? [] : contractFindings(committed, manifest)),
168
- ...(await specFindings(ctx.root, manifest)),
169
- ]);
170
- },
171
- },
172
- {
173
- name: 'budgets',
174
- summary: 'per-route JS bytes and LCP, and the global style layer every document carries',
175
- // The global-style assertion rides here rather than becoming an eighteenth step, because this
176
- // step already asks the one question it asks: what does the document this build emits actually
177
- // contain? It is also the same app load — `appManifest` fills render's stylesheet registry on
178
- // its way through — so a separate step would pay for a second one to answer half a question.
179
- //
180
- // A repo with no `app.config.ts` is the framework monorepo, which renders no documents and has
181
- // no stylesheet registry to read; there is nothing for either half to weigh.
182
- applies: async (ctx) => existsSync(join(ctx.root, APP_CONFIG_FILE)),
183
- async run(ctx) {
184
- // No stats file is NOT "nothing to weigh" — it is every declared budget unmeasured, which is
185
- // the case `checkBudgets` already names per route (`X_BUDGET_UNMEASURED`). Skipping the half
186
- // entirely is how a step that has never run once reported green: `.x/` is gitignored, so no
187
- // CI run and neither gated app has ever had a `build-stats.json` for it to read.
188
- //
189
- // Handed over as `undefined` and never as `?? { routes: [] }`: "no build has run here" and
190
- // "a build ran and could not weigh this route" are two different instructions, and only the
191
- // caller knows which of them is true. The step still does not BUILD — measuring here would
192
- // make `x verify` a static build on every run (8.2s on `dummy/social-media-clone`, and 5.9s
193
- // to a hard `X_PRERENDER_FAILED` on `examples/dummy`), and it would be a second builder
194
- // beside `apps/web/prerender.ts`, which is where an app reads `SITE_ORIGIN`.
195
- const stats = await readBuildStats(ctx.root);
196
- // The load's own findings, FIRST and never dropped. A module that would not import registers
197
- // no route, so its budget is missing from the manifest and every route it declared reads as
198
- // `X_BUDGET_UNMEASURED` — the symptom, pointing the reader at `x build` for a file that will
199
- // not compile. `contract-diff` reports these too when it applies; two red steps naming one
200
- // broken module is honest, and one of them silently green over it is the false green.
201
- const { manifest, findings } = await appManifest(ctx.root);
202
- return fromFindings([
203
- ...findings,
204
- ...checkDocumentStyles(documentSurfaces()),
205
- ...checkBudgets(manifest, stats),
206
- ]);
207
- },
208
- },
209
- {
210
- name: 'seo',
211
- summary: 'every indexable site/ route has a title and a description a search result can render',
212
- // The SEO checkers shipped in `@ultimat3/seo` with no caller anywhere — `validateMeta` and its
213
- // asserts were reachable only by an app that called them itself, which is what
214
- // `packages/seo/src/errors.ts`'s own header said. This is the caller.
215
- //
216
- // Its own step rather than a rider on `budgets`: that step asks what a document WEIGHS and
217
- // this one asks what it SAYS, and a missing `<title>` reported under `budgets` would hand the
218
- // reader a fix for the wrong question (axiom 4). It costs no second app load — `loadApp`
219
- // imports each module once per process, so this runs on the registries `budgets` just filled.
220
- applies: async (ctx) => existsSync(join(ctx.root, APP_CONFIG_FILE)),
221
- async run(ctx) {
222
- const scan = await scanSiteMeta(ctx.root);
223
- // No `baseUrl`: an app declares no base URL anywhere (`packages/core/src/config.ts` has no
224
- // such key), so canonical checks are skipped rather than run against an origin this file
225
- // invented. `seo-meta.ts` spells out why that is the honest half.
226
- const report = validateMeta(scan.records);
227
- return {
228
- ok: scan.findings.length === 0 && report.ok,
229
- findings: [...scan.findings, ...report.issues.map(seoFinding)],
230
- };
231
- },
232
- },
233
- {
234
- name: 'manifest',
235
- summary: 'the files an agent reads: generated facts, hand-written conventions, the env example',
236
- // No `applies`. The drift half has nothing to compare against until `x manifest` has run
237
- // once, and says so by finding nothing — but `AGENTS.md` is required of every repo the gate
238
- // runs in, so the step always has a question to answer and must never report as skipped.
239
- //
240
- // `.env.example` joins this step rather than becoming an eighteenth: the question is the same
241
- // one — "does a committed, generated file still describe the code?" — and the step list is the
242
- // definition of shippable, so it grows only when a genuinely new question needs asking.
243
- //
244
- // `x.verify.json` is here for that same question and no other: this step judges the floor
245
- // FILE, `runVerify` judges the suites against it. A name the gate does not run can never
246
- // vanish, so a typo in the floor covers nothing — which is the false green the floor exists to
247
- // close, and it is only visible if something reads the file for its own sake.
248
- async run(ctx) {
249
- const agents = await checkAgentsMd(ctx.root);
250
- const findings = [
251
- ...(await driftFindings(ctx.root)),
252
- ...(await envExampleFindings(ctx.root)),
253
- ...floorProblemFindings(await readVerifyFloor(ctx.root)),
254
- ...agents.findings,
255
- ...(await hostFindings(ctx, 'manifest')),
256
- ];
257
- // Warnings are not findings: `AGENTS.md` tabulating a route table is a smell a human
258
- // judges, not a build error. They ride in `output`, which `--json` carries verbatim.
259
- const output = agents.warnings.map((warning) => `${AGENTS_MD_FILENAME}: ${warning}`);
260
- return {
261
- ok: findings.length === 0,
262
- findings,
263
- ...(output.length === 0 ? {} : { output: output.join('\n') }),
264
- };
265
- },
266
- },
267
- {
268
- name: 'roadmap',
269
- summary: "every roadmap milestone's status marker matches what is actually on disk",
270
- // A generated app ships no `docs/idea/14-roadmap.md` — only the framework monorepo does, so
271
- // the FILE is what decides. It keyed on `ctx.hostChecks?.roadmap` until `As of 2026-08`, which
272
- // is a fact about the CALL: a caller of the exported `runVerify(VERIFY_STEPS, ctx)` passing no
273
- // `hostChecks`, in a repo whose committed `x.verify.json` names `roadmap`, got
274
- // `X_VERIFY_SUITE_VANISHED` — whose `fix:` is the command that had just failed.
275
- applies: async (ctx) => existsSync(join(ctx.root, ROADMAP_FILE)),
276
- run: async (ctx) => fromFindings(await hostFindings(ctx, 'roadmap')),
277
- },
278
- ];
279
-
280
- /** `assertNoDrift` throws `X_MANIFEST_DRIFT`; a step reports, so the error becomes a finding. */
281
- async function driftFindings(root: string): Promise<readonly Finding[]> {
282
- const path = join(root, MANIFEST_FILENAME);
283
- if (!existsSync(path)) return [];
284
- const { manifest, findings } = await appManifest(root);
285
- try {
286
- await assertNoDrift({ manifest, path });
287
- return findings;
288
- } catch (error) {
289
- return [...findings, { ...findingFrom(error), at: MANIFEST_FILENAME }];
290
- }
291
- }
292
-
293
- /** A breaking change is allowed — with a major bump. `verifyContract` is the one that decides. */
294
- function contractFindings(before: Manifest, after: Manifest): readonly Finding[] {
295
- try {
296
- verifyContract({ before, after });
297
- return [];
298
- } catch (error) {
299
- return [{ ...findingFrom(error), at: MANIFEST_FILENAME }];
300
- }
301
- }
302
-
303
- /** The typed client is generated from `openapi.json`, so a stale spec ships a wrong client. */
304
- async function specFindings(root: string, manifest: Manifest): Promise<readonly Finding[]> {
305
- const path = join(root, OPENAPI_FILE);
306
- if (!existsSync(path)) return [];
307
- if ((await Bun.file(path).text()) === openApiJson(manifest)) return [];
308
- return [
309
- {
310
- code: 'X_MANIFEST_STALE',
311
- cause: `${OPENAPI_FILE} does not match the actions the code registers`,
312
- fix: 'x manifest',
313
- docs: 'https://ultimate.dev/errors/X_MANIFEST_STALE',
314
- at: OPENAPI_FILE,
315
- },
316
- ];
317
- }
318
-
319
- /**
320
- * Run every step in order, never bailing early: an agent fixing three things at once needs all
321
- * three findings from one run, not one per round-trip.
322
- */
323
- export async function runVerify(
324
- steps: readonly VerifyStep[],
325
- ctx: VerifyContext,
326
- ): Promise<CommandResult> {
327
- const floor = await readVerifyFloor(ctx.root);
328
- const results: StepResult[] = [];
329
- for (const step of steps) {
330
- const applies = step.applies === undefined ? true : await step.applies(ctx);
331
- if (!applies) {
332
- // A skip this repo already ruled out is not a skip. The step ran here before — the floor is
333
- // that claim, committed — so "nothing to check" now means the suite was deleted, and the
334
- // gate says so on the step's own line rather than counting one more thing not to worry
335
- // about. Recorded as failed and NOT as skipped, so every reader of a step table sees it:
336
- // the summary, `data.failed`, and the reference-app gate's own red list.
337
- const required = floorRequires(floor, step.name);
338
- results.push({
339
- name: step.name,
340
- ok: !required,
341
- durationMs: 0,
342
- skipped: !required,
343
- findings: required ? [vanishedSuiteFinding(step.name)] : [],
344
- });
345
- continue;
346
- }
347
- const started = performance.now();
348
- const outcome = await step.run(ctx).catch(
349
- (error: unknown): StepOutcome => ({
350
- ok: false,
351
- findings: [findingOf(error, step.name)],
352
- }),
353
- );
354
- // A step the floor requires whose suite executed nothing is the same vanished suite as a step
355
- // with no files at all — the run just had to finish before it could be seen. Appended to the
356
- // step's own findings so `data.failed`, the counts and every gate reading this table carry it.
357
- const vanished =
358
- floorRequires(floor, step.name) && outcome.tests !== undefined && outcome.tests.ran === 0
359
- ? [skippedSuiteFinding(step.name, outcome.tests.skipped)]
360
- : [];
361
- results.push({
362
- name: step.name,
363
- ok: outcome.ok && vanished.length === 0,
364
- durationMs: Math.round(performance.now() - started),
365
- findings: [...outcome.findings, ...vanished],
366
- ...(outcome.output === undefined ? {} : { output: outcome.output }),
367
- ...(outcome.workers === undefined ? {} : { workers: outcome.workers }),
368
- });
369
- }
370
- const failedSteps = results.filter((step) => !step.ok).map((step) => step.name);
371
- const skippedSteps = results.filter((step) => step.skipped === true).map((step) => step.name);
372
- const totalMs = results.reduce((sum, step) => sum + step.durationMs, 0);
373
- return {
374
- ok: failedSteps.length === 0,
375
- command: 'verify',
376
- summary: verifySummary({ results, failed: failedSteps, skipped: skippedSteps, totalMs }),
377
- steps: results,
378
- // `skipped` is a list beside `failed` and not a count, because the two answer the same kind of
379
- // question — *which* steps, not how many — and a caller ratcheting on coverage needs the names.
380
- data: { failed: failedSteps, skipped: skippedSteps, durationMs: totalMs },
381
- exitCode: failedSteps.length === 0 ? 0 : 1,
382
- };
383
- }
384
-
385
- /**
386
- * What the counts are allowed to claim. A step that does not apply is recorded green so the run
387
- * continues, and the summary counted it among the "all 17 steps passed" — so a repo whose `job`
388
- * and `eval` suites do not exist reported the same line as a repo where both ran. `--json` carried
389
- * the per-step flag all along; the one line every reader actually sees did not, which is how a
390
- * vacuous gate stayed invisible. It names the skipped steps, not just how many: "17/17" is worth
391
- * something only when the gap is visible in the same glance.
392
- */
393
- function verifySummary(input: {
394
- readonly results: readonly StepResult[];
395
- readonly failed: readonly string[];
396
- readonly skipped: readonly string[];
397
- readonly totalMs: number;
398
- }): string {
399
- const params = {
400
- count: input.results.length,
401
- passed: input.results.filter((step) => step.ok && step.skipped !== true).length,
402
- failed: input.failed.length,
403
- skipped: input.skipped.length,
404
- names: input.skipped.join(', '),
405
- ms: input.totalMs,
406
- };
407
- const clean = input.skipped.length === 0;
408
- if (input.failed.length === 0) {
409
- return msg(clean ? 'cli.verify.pass' : 'cli.verify.passSkipped', params);
410
- }
411
- return msg(clean ? 'cli.verify.fail' : 'cli.verify.failSkipped', params);
412
- }
413
-
414
- function findingOf(error: unknown, step: string): Finding {
415
- // A step may throw anything, including an Error that fights being read: `instanceof` runs a
416
- // Proxy's `getPrototypeOf` trap and `.message` runs a getter, so a hostile throw would take the
417
- // gate's own report down with it — the one message that may never be lost.
418
- const cause = renderThrowable(error);
419
- return {
420
- code: 'X_VERIFY_FAILED',
421
- cause: `step "${step}" threw: ${cause}`,
422
- fix: 'x verify --json',
423
- docs: 'https://ultimate.dev/errors/X_VERIFY_FAILED',
424
- };
425
- }
426
-
427
- /**
428
- * One `MetaIssue` as the gate reports it. `at` is the route FILE and never the URL: every seo error
429
- * already names the file in its cause, and `at` is what an agent opens.
430
- */
431
- const seoFinding = (issue: MetaIssue): Finding => ({
432
- code: issue.code,
433
- cause: issue.cause,
434
- fix: issue.fix,
435
- docs: `https://ultimate.dev/errors/${issue.code}`,
436
- at: issue.file,
437
- });
16
+ // One import path for the gate, unchanged by the split: `index.ts`, `x build` and the MCP host all
17
+ // reach the list and the runner through this module, and a second path to either would be the
18
+ // ambiguity axiom 1 forbids.
19
+ export { VERIFY_STEPS } from './verify-checks';
20
+ export { runVerify } from './verify-run';
438
21
 
439
22
  export const verifyCommand: CliCommand = {
440
23
  spec: {
@@ -0,0 +1,34 @@
1
+ // The specifiers every `bun build --compile` in this repo must refuse to resolve. One list, because
2
+ // the flag is repeated at each compile site — `binaryArgs`, `docker/Dockerfile`, the boot e2e — and
3
+ // three copies of a resolver allowlist is three chances for one of them to be the stale one.
4
+
5
+ /**
6
+ * `@babel/preset-typescript` is reached from `@babel/core`'s `.cts`-config loader and from nowhere
7
+ * else. `config/files/module-types.js` `require`s it twice — once for the preset, once for its
8
+ * `package.json` inside a `catch` — and both sit in `loadCtsDefault`, which only runs while Babel
9
+ * loads a `.cts` CONFIG FILE. `solid-loader.ts` passes `babelrc: false, configFile: false`, so no
10
+ * config file is ever loaded and neither line is reachable at run time. The bundler walks them
11
+ * anyway, and that is the whole failure: Bun 1.3 (what CI pins and what `docker/Dockerfile` builds
12
+ * on) refuses the build with `Could not resolve: "@babel/preset-typescript/package.json"`, while
13
+ * Bun 1.4 bundles the unresolvable `require` as a runtime throw — so one tree compiled on a laptop
14
+ * and did not in CI.
15
+ *
16
+ * Marking the dead specifier external rather than the two live ones: `serve.ts` calls
17
+ * `buildIslands` on every boot, unconditionally, so a binary with `@babel/core` external is a
18
+ * binary that dies at start with `Cannot find module '@babel/core' from '/$bunfs/root/app'` —
19
+ * measured. And rather than installing `@babel/preset-typescript`: that is a real dependency, in
20
+ * the lockfile and in every published tarball's resolution graph, bought to make one unreachable
21
+ * line resolvable.
22
+ *
23
+ * A lazy `await import('@babel/core')` does not help and was measured too — Bun's bundler follows a
24
+ * literal dynamic specifier into `--compile`, so the graph still reaches the same require.
25
+ */
26
+ export const COMPILE_EXTERNALS: readonly string[] = ['@babel/preset-typescript'];
27
+
28
+ /**
29
+ * `--external <specifier>` per entry, flattened into the argv shape every compile site splices in.
30
+ * A function and not a frozen array so a caller cannot hold a reference it then mutates.
31
+ */
32
+ export function externalArgs(): readonly string[] {
33
+ return COMPILE_EXTERNALS.flatMap((specifier) => ['--external', specifier]);
34
+ }