@ultimat3/cli 31.14.0 → 31.16.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 (69) hide show
  1. package/CLAUDE.md +1 -1
  2. package/README.md +3 -2
  3. package/package.json +29 -29
  4. package/src/budgets-requests.ts +37 -0
  5. package/src/budgets.ts +20 -1
  6. package/src/cmd-doctor.ts +47 -37
  7. package/src/cmd-exercise.ts +14 -1
  8. package/src/cmd-upgrade.ts +19 -2
  9. package/src/coverage-floor.ts +2 -2
  10. package/src/dev-boot.ts +2 -2
  11. package/src/dev-route-table.ts +5 -9
  12. package/src/doctor-env-reserved.ts +111 -0
  13. package/src/doctor-floor.ts +62 -0
  14. package/src/doctor-pins.ts +101 -0
  15. package/src/doctor-probe.ts +21 -1
  16. package/src/doctor-row-security.ts +119 -4
  17. package/src/doctor-warnings.ts +55 -0
  18. package/src/document-options.ts +0 -7
  19. package/src/error-codes-doctor.ts +24 -0
  20. package/src/error-codes.ts +5 -0
  21. package/src/exercise-floor-report.ts +138 -0
  22. package/src/exercise-floor-verdict.ts +98 -0
  23. package/src/exercise-floor.ts +158 -0
  24. package/src/island-bundle.ts +52 -12
  25. package/src/island-disposer.ts +1 -1
  26. package/src/island-group-cache.ts +4 -0
  27. package/src/island-link-check.ts +73 -0
  28. package/src/island-vendor.ts +183 -0
  29. package/src/mcp-errors.ts +11 -1
  30. package/src/messages-upgrade.ts +13 -0
  31. package/src/messages.ts +3 -0
  32. package/src/prerender.ts +7 -7
  33. package/src/route-islands-preload.ts +54 -11
  34. package/src/runtime-admin.ts +2 -4
  35. package/src/runtime-render-document.ts +34 -13
  36. package/src/runtime-render.ts +58 -30
  37. package/src/serve-web.ts +8 -11
  38. package/src/static-images.ts +25 -4
  39. package/src/static-precompress.ts +57 -0
  40. package/src/style-bundle.ts +28 -6
  41. package/src/templates/guard-island-mount-clears.ts +151 -0
  42. package/src/templates/island.ts +8 -7
  43. package/src/templates/resource-form-island.ts +12 -9
  44. package/src/templates/scaffold-docs.ts +1 -0
  45. package/src/templates/scaffold-guards.ts +4 -1
  46. package/src/templates/scaffold-shell.ts +12 -9
  47. package/src/templates/scaffold-verify-floor.ts +4 -0
  48. package/src/test-dotenv.ts +15 -2
  49. package/src/theme-brand.ts +18 -20
  50. package/src/upgrade-coverage.ts +109 -0
  51. package/src/upgrade-document.ts +18 -0
  52. package/src/upgrade-exercise-floor.ts +53 -0
  53. package/src/upgrade-gate.ts +68 -25
  54. package/src/upgrade-guards.ts +159 -0
  55. package/src/upgrade-report.ts +29 -1
  56. package/src/verify-checks.ts +3 -1
  57. package/src/verify-floor.ts +13 -0
  58. package/wiki/CLI-Reference.md +26 -3
  59. package/wiki/Client-Data.md +52 -0
  60. package/wiki/Configuration.md +17 -0
  61. package/wiki/MCP-And-AI.md +42 -1
  62. package/wiki/Notify.md +6 -0
  63. package/wiki/PWA-And-Offline.md +11 -0
  64. package/wiki/Realtime.md +4 -3
  65. package/wiki/SEO.md +1 -1
  66. package/wiki/Static-Assets.md +30 -3
  67. package/wiki/Testing.md +64 -2
  68. package/wiki/Theming.md +6 -6
  69. package/wiki/Upgrading.md +11 -0
package/CLAUDE.md CHANGED
@@ -149,7 +149,7 @@ Commands: `bun test ./packages/cli/` (repo root: the preload),
149
149
  | `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 |
150
150
  | `page-speculation.ts` | Speculation Rules for documents WITHOUT the router (`navigation.speculation`): an allow-list of pure-read pages ‡ |
151
151
  | `static-document.ts` | a served `static` page: `304` on `If-None-Match`; container keeps the document (never `x dev`) † |
152
- | `island-{bundle,groups,outputs,build-pool,group-cache,cache-inputs,store,sources,runtime}.ts` / `island-realtime*.ts` / `solid-loader.ts` | islands, named by their final bytes (#1075): 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) † |
152
+ | `island-{bundle,groups,outputs,build-pool,group-cache,cache-inputs,store,sources,runtime}.ts` / `island-realtime*.ts` / `solid-loader.ts` | islands, named by their final bytes (#1075): 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). `islands.vendorSolid` (`island-vendor.ts`, off: a regression on every tracked app) builds Solid once as `vendor-solid.<hash>.js` every island imports; `island-link-check.ts` refuses a merged bundle whose import names bind nothing (#1075's smoke) † |
153
153
  | `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`) |
154
154
  | `serve-prebuilt.ts` / `serve-prebuilt-paths.ts` | the image's prebuilt store; a boot that built anything logs `X_IMAGE_NOT_PREBUILT` † |
155
155
  | `dev-*.ts` | `x dev` only: dashboard sources, traces, the N+1 ledger, watcher, reload, lock, port |
package/README.md CHANGED
@@ -21,7 +21,7 @@ Commands and the `x verify` step count, `As of 2026-08`:
21
21
  | `x build --target docker\|binary\|static` | one artifact | `ROLE` selects behaviour at start |
22
22
  | `x build --target prebuilt` | the store a container boots from: island chunks, compiled stylesheets | a `RUN` line in the image build, never run by hand |
23
23
  | `x verify` | **the gate** | 21 named steps, each with pass/fail + duration; `budgets` runs `x build --target static` first when its stats are missing or older than the source |
24
- | `x exercise [<name>] [--seed n]` | every action, query and job run once on generated rows, no test written | a scratch database; `.x/exercise.json`; an `unreached` primitive is `X_CONTRACT_EXERCISE_UNREACHED` with the override to paste into `apps/web/exercise.ts` — the gate's `exercise` step |
24
+ | `x exercise [<name>] [--seed n]` | every action, query and job run once on generated rows, no test written | a scratch database; `.x/exercise.json`; an `unreached` primitive is `X_CONTRACT_EXERCISE_UNREACHED` with the override to paste into `apps/web/exercise.ts` — the gate's `exercise` step. `x.verify.json` `exercise: { unprovenMax, statementsMax }` turns unproven proofs and over-ceiling calls red; absent, warning lines |
25
25
  | `x drill [<name>] [--list] [--budget-ms n]` | the app's roles as real processes on real services, each fault played through a proxy or a signal, judged on framework contracts only | a scratch database per drill; load = anonymous site pages plus every action an anonymous POST reaches (`data.skippedWrites` names the rest and why); `X_DRILL_FAILED` per property that did not hold, `X_DRILL_SERVICE_MISSING` before anything starts. Not a gate step — CI's `fault-drills` job runs three on `examples/dummy` |
26
26
  | `x g <primitive> <name>` | scaffolds a primitive **with a passing test** | never a TODO stub |
27
27
  | `x db gen\|migrate\|reset\|branch\|backfill` | everything DB | `branch` = copy-on-write clone + preview URL; `backfill` dry-runs unless `--write`. `x db studio` is **planned** — it parses, and exits `X_NOT_IMPLEMENTED` naming `/_x`'s db panel |
@@ -81,7 +81,8 @@ weigh measures the page a holder of that role is served. Any other refusal (a mi
81
81
 
82
82
  While the export renders, `@ultimat3/seo`'s static seam is installed (`static-capture.ts`). Every
83
83
  `responsiveImage()` candidate an exported document names is written to `/_img/<hash>-<w>.<ext>`
84
- (`static-images.ts`) — a `src` the export lacks is `X_IMAGE_SOURCE_UNREADABLE`, an `avif` is
84
+ (`static-images.ts`; the hash is of the source bytes, width, format and encoder — framework and Bun
85
+ version — so an upgrade that may re-encode renames the file rather than reuse an `immutable` URL) — a `src` the export lacks is `X_IMAGE_SOURCE_UNREADABLE`, an `avif` is
85
86
  `X_IMAGE_UNSUPPORTED`. Every `og.capture` card is photographed from its exported page at 1200 x 630
86
87
  into `/_og/<path>.png` over the CLI's own CDP driver (`static-cards.ts`); no such page is
87
88
  `X_SEO_CARD_ROUTE_UNKNOWN`, no browser `X_SEO_CARD_BROWSER_MISSING`. `--no-capture` stamps the same
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultimat3/cli",
3
- "version": "31.14.0",
3
+ "version": "31.16.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.14.0",
57
- "@ultimat3/admin": "31.14.0",
58
- "@ultimat3/ai": "31.14.0",
59
- "@ultimat3/auth": "31.14.0",
60
- "@ultimat3/cache": "31.14.0",
61
- "@ultimat3/core": "31.14.0",
62
- "@ultimat3/db": "31.14.0",
63
- "@ultimat3/entity": "31.14.0",
64
- "@ultimat3/flags": "31.14.0",
65
- "@ultimat3/http": "31.14.0",
66
- "@ultimat3/i18n": "31.14.0",
67
- "@ultimat3/jobs": "31.14.0",
68
- "@ultimat3/mail": "31.14.0",
69
- "@ultimat3/manifest": "31.14.0",
70
- "@ultimat3/mcp": "31.14.0",
71
- "@ultimat3/money": "31.14.0",
72
- "@ultimat3/notify": "31.14.0",
73
- "@ultimat3/policy": "31.14.0",
74
- "@ultimat3/pwa": "31.14.0",
75
- "@ultimat3/query": "31.14.0",
76
- "@ultimat3/realtime": "31.14.0",
77
- "@ultimat3/render": "31.14.0",
78
- "@ultimat3/schema": "31.14.0",
79
- "@ultimat3/scraping": "31.14.0",
80
- "@ultimat3/seo": "31.14.0",
81
- "@ultimat3/storage": "31.14.0",
82
- "@ultimat3/testing": "31.14.0",
83
- "@ultimat3/time": "31.14.0",
56
+ "@ultimat3/action": "31.16.0",
57
+ "@ultimat3/admin": "31.16.0",
58
+ "@ultimat3/ai": "31.16.0",
59
+ "@ultimat3/auth": "31.16.0",
60
+ "@ultimat3/cache": "31.16.0",
61
+ "@ultimat3/core": "31.16.0",
62
+ "@ultimat3/db": "31.16.0",
63
+ "@ultimat3/entity": "31.16.0",
64
+ "@ultimat3/flags": "31.16.0",
65
+ "@ultimat3/http": "31.16.0",
66
+ "@ultimat3/i18n": "31.16.0",
67
+ "@ultimat3/jobs": "31.16.0",
68
+ "@ultimat3/mail": "31.16.0",
69
+ "@ultimat3/manifest": "31.16.0",
70
+ "@ultimat3/mcp": "31.16.0",
71
+ "@ultimat3/money": "31.16.0",
72
+ "@ultimat3/notify": "31.16.0",
73
+ "@ultimat3/policy": "31.16.0",
74
+ "@ultimat3/pwa": "31.16.0",
75
+ "@ultimat3/query": "31.16.0",
76
+ "@ultimat3/realtime": "31.16.0",
77
+ "@ultimat3/render": "31.16.0",
78
+ "@ultimat3/schema": "31.16.0",
79
+ "@ultimat3/scraping": "31.16.0",
80
+ "@ultimat3/seo": "31.16.0",
81
+ "@ultimat3/storage": "31.16.0",
82
+ "@ultimat3/testing": "31.16.0",
83
+ "@ultimat3/time": "31.16.0",
84
84
  "babel-preset-solid": "^1.9.16"
85
85
  }
86
86
  }
@@ -0,0 +1,37 @@
1
+ // Requests per route: how many fetches one document makes before it is whole — itself, every
2
+ // script file (`measureDocumentJs` counts those as it weighs them) and every stylesheet. Reported
3
+ // in the stats row beside the bytes, never budgeted: a ceiling is the app's declaration to make.
4
+
5
+ import { artifactPath, HREF_ATTR } from './budgets-scan';
6
+
7
+ /** A `<link>` whose `rel` list holds `stylesheet` — the one link a browser fetches to paint. */
8
+ const STYLESHEET_TAG = /<link\s[^>]*\brel="(?:[^"]*\s)?stylesheet(?:\s[^"]*)?"[^>]*>/g;
9
+
10
+ /** The requests one document makes, as the stats row records them. */
11
+ export interface RouteRequests {
12
+ readonly documents: 1;
13
+ /** Distinct same-origin script files fetched: entries, the chunks they import, framework files. */
14
+ readonly scripts: number;
15
+ /** Distinct same-origin stylesheets. */
16
+ readonly styles: number;
17
+ readonly total: number;
18
+ }
19
+
20
+ /**
21
+ * Distinct same-origin stylesheets `html` links, by the path a browser fetches — the unit
22
+ * `measureDocumentJs` dedupes scripts by. A cross-origin sheet is not this build's to count, and
23
+ * a `rel="preload"` of a sheet is the same fetch the stylesheet link then reuses.
24
+ */
25
+ export function stylesheetRequests(html: string): number {
26
+ const paths = new Set<string>();
27
+ for (const match of html.matchAll(STYLESHEET_TAG)) {
28
+ const href = HREF_ATTR.exec(match[0])?.groups?.['href'];
29
+ const path = href === undefined ? undefined : artifactPath(href);
30
+ if (path !== undefined) paths.add(path);
31
+ }
32
+ return paths.size;
33
+ }
34
+
35
+ export function routeRequests(scripts: number, styles: number): RouteRequests {
36
+ return { documents: 1, scripts, styles, total: 1 + scripts + styles };
37
+ }
package/src/budgets.ts CHANGED
@@ -13,6 +13,8 @@ import type { Manifest, RouteFact } from '@ultimat3/manifest';
13
13
  import { describePages, parseByteBudget, themeScriptBody } from '@ultimat3/render';
14
14
  import type { ChargedFile } from './budgets-charged';
15
15
  import { chargedClause, chargedMeta, heaviestFirst } from './budgets-charged';
16
+ import type { RouteRequests } from './budgets-requests';
17
+ import { routeRequests, stylesheetRequests } from './budgets-requests';
16
18
  import {
17
19
  artifactPath,
18
20
  carriesJson,
@@ -55,6 +57,11 @@ export interface RouteStats {
55
57
  readonly charged?: readonly ChargedFile[];
56
58
  /** The app's inline script bytes inside `jsBytes` — the part no file in `charged` accounts for. */
57
59
  readonly inlineJsBytes?: number;
60
+ /**
61
+ * The fetches the document makes — itself, its script files, its stylesheets. A measurement,
62
+ * never a budget. Optional for `frameworkJsBytes`' reason: an older row did not count them.
63
+ */
64
+ readonly requests?: RouteRequests;
58
65
  }
59
66
 
60
67
  export interface BuildStats {
@@ -276,6 +283,10 @@ export interface MeasuredJs {
276
283
  readonly inlineBytes: number;
277
284
  /** Every APP `src=`/`data-x-entry=` module, so a finding can name the heaviest by file. */
278
285
  readonly entries: readonly MeasuredEntry[];
286
+ /** Distinct same-origin script files the document fetches, framework files included. */
287
+ readonly scriptRequests: number;
288
+ /** Distinct same-origin stylesheets it links (`budgets-requests.ts`). */
289
+ readonly styleRequests: number;
279
290
  }
280
291
 
281
292
  /**
@@ -422,7 +433,14 @@ export async function measureDocumentJs(
422
433
  const href = HREF_ATTR.exec(match[0])?.groups?.['href'];
423
434
  if (href !== undefined) await weigh(href);
424
435
  }
425
- return { jsBytes, frameworkBytes, inlineBytes, entries };
436
+ return {
437
+ jsBytes,
438
+ frameworkBytes,
439
+ inlineBytes,
440
+ entries,
441
+ scriptRequests: fetched.size,
442
+ styleRequests: stylesheetRequests(html),
443
+ };
426
444
  }
427
445
 
428
446
  /**
@@ -441,6 +459,7 @@ export function routeStatsRow(
441
459
  ...(chain === undefined ? {} : { heaviestChain: chain }),
442
460
  charged: heaviestFirst(measured.entries),
443
461
  inlineJsBytes: measured.inlineBytes,
462
+ requests: routeRequests(measured.scriptRequests, measured.styleRequests),
444
463
  };
445
464
  }
446
465
 
package/src/cmd-doctor.ts CHANGED
@@ -20,6 +20,7 @@ import { probeFor } from './doctor-probe';
20
20
  import { rollingSinceProbe, withRollingReminder } from './doctor-rolling';
21
21
  import { sealedKeyFindings } from './doctor-sealed';
22
22
  import { typescriptFindings } from './doctor-typescript';
23
+ import { doctorWarnings, withDoctorWarnings } from './doctor-warnings';
23
24
  import { ICON_SOURCE } from './icon-assets';
24
25
  import { msg } from './messages';
25
26
  import type { CommandResult, Finding } from './output';
@@ -131,48 +132,57 @@ export async function runDoctor(probe: DoctorProbe): Promise<readonly Finding[]>
131
132
  // Sealed columns against the key ring: no key at all, or a rotation whose re-seal is pending.
132
133
  findings.push(...sealedKeyFindings(await probe.sealedKeys()));
133
134
  findings.push(...authStorageFindings(await probe.authStorage()));
135
+ // `X_FRAMEWORK_PIN_RANGE`, `X_ENV_NAME_RESERVED`, `X_DB_ROW_SECURITY_OFF` and
136
+ // `X_VERIFY_STEP_UNFLOORED` are not here: on `main` they warn beside the verdict
137
+ // (`doctor-warnings.ts`), so an upgrade with no change keeps this green.
134
138
  return findings;
135
139
  }
136
140
 
141
+ /** The whole report over one probe: the verdict, then the listings and warnings beside it. */
142
+ export async function reportDoctor(probe: DoctorProbe): Promise<CommandResult> {
143
+ // Asked once: `runDoctor` reads the verdict and the report beside it reads the numbers.
144
+ const pooler = probe.root === undefined ? NO_POOLER_FACT : await probe.pooler();
145
+ const findings = await runDoctor({ ...probe, pooler: async () => pooler });
146
+ const listed = withGuardListing(
147
+ {
148
+ ok: findings.length === 0,
149
+ command: 'doctor',
150
+ summary:
151
+ findings.length === 0
152
+ ? msg('cli.doctor.clean')
153
+ : msg('cli.doctor.findings', { count: findings.length }),
154
+ findings,
155
+ data: { count: findings.length, codes: findings.map((entry) => entry.code) },
156
+ },
157
+ // A listing beside the verdict, never part of it (`doctor-guards.ts` says why).
158
+ probe.root === undefined ? [] : await shippedGuardsProbe(probe.root),
159
+ );
160
+ // The second listing: what the coverage floor does not see (`doctor-coverage.ts`).
161
+ const covered = withCoverageExcludes(
162
+ listed,
163
+ probe.root === undefined ? [] : await coverageExcludesProbe(probe.root),
164
+ );
165
+ // The third: the monitoring templates the app's chart predates (`doctor-chart-alerts.ts`).
166
+ const charted = withChartAlertsListing(
167
+ covered,
168
+ probe.root === undefined ? [] : chartAlertsProbe(probe.root),
169
+ );
170
+ // A reminder, not a finding: the rolling rail is off until this is set (`doctor-rolling.ts`).
171
+ const reminded = withPoolerReport(
172
+ withRollingReminder(
173
+ charted,
174
+ probe.root === undefined ? undefined : await rollingSinceProbe(probe.root),
175
+ ),
176
+ pooler,
177
+ );
178
+ // Last, and beside the verdict on `main`: the 31.16.0 checks (`doctor-warnings.ts`).
179
+ return withDoctorWarnings(reminded, await doctorWarnings(probe));
180
+ }
181
+
137
182
  export const doctorCommand: CliCommand = {
138
183
  spec: doctorSpec,
139
- async run(ctx: CommandContext): Promise<CommandResult> {
184
+ run(ctx: CommandContext): Promise<CommandResult> {
140
185
  const port = doctorPort(ctx.args, ctx.env);
141
- const probe = probeFor(ctx.cwd, ctx.bunVersion, port, ctx.env);
142
- // Asked once: `runDoctor` reads the verdict and the report beside it reads the numbers.
143
- const pooler = probe.root === undefined ? NO_POOLER_FACT : await probe.pooler();
144
- const findings = await runDoctor({ ...probe, pooler: async () => pooler });
145
- const listed = withGuardListing(
146
- {
147
- ok: findings.length === 0,
148
- command: 'doctor',
149
- summary:
150
- findings.length === 0
151
- ? msg('cli.doctor.clean')
152
- : msg('cli.doctor.findings', { count: findings.length }),
153
- findings,
154
- data: { count: findings.length, codes: findings.map((entry) => entry.code) },
155
- },
156
- // A listing beside the verdict, never part of it (`doctor-guards.ts` says why).
157
- probe.root === undefined ? [] : await shippedGuardsProbe(probe.root),
158
- );
159
- // The second listing: what the coverage floor does not see (`doctor-coverage.ts`).
160
- const covered = withCoverageExcludes(
161
- listed,
162
- probe.root === undefined ? [] : await coverageExcludesProbe(probe.root),
163
- );
164
- // The third: the monitoring templates the app's chart predates (`doctor-chart-alerts.ts`).
165
- const charted = withChartAlertsListing(
166
- covered,
167
- probe.root === undefined ? [] : chartAlertsProbe(probe.root),
168
- );
169
- // A reminder, not a finding: the rolling rail is off until this is set (`doctor-rolling.ts`).
170
- return withPoolerReport(
171
- withRollingReminder(
172
- charted,
173
- probe.root === undefined ? undefined : await rollingSinceProbe(probe.root),
174
- ),
175
- pooler,
176
- );
186
+ return reportDoctor(probeFor(ctx.cwd, ctx.bunVersion, port, ctx.env));
177
187
  },
178
188
  };
@@ -31,6 +31,7 @@ import {
31
31
  renderExerciseTable,
32
32
  slowestProofLines,
33
33
  } from './exercise-findings';
34
+ import { exerciseFloorVerdict } from './exercise-floor-verdict';
34
35
  import { readExerciseOverrides } from './exercise-overrides';
35
36
  import { entityTenantFindings } from './exercise-static';
36
37
  import { subjectFindings, subjectProofFindings } from './exercise-subject';
@@ -38,6 +39,7 @@ import { readIntFlag } from './flag-number';
38
39
  import { msg } from './messages';
39
40
  import { withOfflinePorts } from './offline-ports';
40
41
  import type { CommandResult, JsonValue } from './output';
42
+ import { readVerifyFloor } from './verify-floor';
41
43
 
42
44
  /**
43
45
  * The actors `x policy explain` evaluates — `devActors()`, the `/_x` panel's own set — each a
@@ -122,6 +124,12 @@ async function exercisePass(
122
124
  // The whole pass, not a one-primitive run's slice of it, is what the file is for — but a
123
125
  // one-primitive run is still a fact worth keeping, so it is written either way.
124
126
  await Bun.write(join(root, EXERCISE_REPORT_FILE), `${JSON.stringify(report, null, 2)}\n`);
127
+ // `x.verify.json`'s `exercise` key: red where the app opted in, a warning line where it has not.
128
+ // A whole-pass floor, so never judged on a `<name>` run's slice: 1 of 1 unproven is no ratio.
129
+ const floor =
130
+ only === undefined
131
+ ? exerciseFloorVerdict(records, (await readVerifyFloor(root))?.exercise)
132
+ : { findings: [], warnings: [] };
125
133
  const findings = [
126
134
  ...loaded.findings,
127
135
  // The static half of the tenant proof (`exercise-static.ts`): the pass's own question,
@@ -131,6 +139,7 @@ async function exercisePass(
131
139
  ...subjectProofs,
132
140
  // The fix pastes into the file the app has, or hands it the file it lacks.
133
141
  ...exerciseFindings(records, overrides === undefined ? 'absent' : 'present'),
142
+ ...floor.findings,
134
143
  ];
135
144
  return {
136
145
  ok: findings.length === 0,
@@ -146,8 +155,12 @@ async function exercisePass(
146
155
  ...tenantFindingLines(records),
147
156
  ...crashFindingLines(records),
148
157
  ...planSweepLines(records),
158
+ ...floor.warnings.map((warning) => `! ${warning}`),
149
159
  ].map((line) => ` ${line}`),
150
160
  findings,
151
- data: report as unknown as JsonValue,
161
+ // The warning lines ride in `--json` too (`lines` never holds what the document lacks).
162
+ data: (floor.warnings.length === 0
163
+ ? report
164
+ : { ...report, warnings: floor.warnings }) as unknown as JsonValue,
152
165
  };
153
166
  }
@@ -146,7 +146,14 @@ async function withHeartbeat<T>(
146
146
  }
147
147
  }
148
148
 
149
- export const createUpgradeCommand = (write: (line: string) => void): CliCommand => ({
149
+ /** `YYYY-MM-DD` in UTC: the day a rebaselined floor's `why` names. */
150
+ const utcDay = (at: Date): string => at.toISOString().slice(0, 10);
151
+
152
+ export const createUpgradeCommand = (
153
+ write: (line: string) => void,
154
+ /** The clock a rebaselined coverage floor is dated by; a test pins it. */
155
+ now: () => Date = () => new Date(),
156
+ ): CliCommand => ({
150
157
  spec: upgradeSpec,
151
158
  async run(ctx: CommandContext): Promise<CommandResult> {
152
159
  const { dir: root, app } = await findUpgradeRoot(ctx.cwd);
@@ -261,7 +268,17 @@ export const createUpgradeCommand = (write: (line: string) => void): CliCommand
261
268
  });
262
269
  return { gate: undefined, scripts: ran };
263
270
  }
264
- const hopGate = await runHopGate({ runner: ctx.runner, root, onStage: stageReached });
271
+ // Bun 1.4.4 counted functions differently: a hop that moves the floor re-measures coverage.
272
+ const bunMoved =
273
+ bunRange === undefined || bunRange === bunFrom
274
+ ? undefined
275
+ : { release: hop.to, bunFrom, bunTo: bunRange, today: utcDay(now()) };
276
+ const hopGate = await runHopGate({
277
+ runner: ctx.runner,
278
+ root,
279
+ onStage: stageReached,
280
+ ...(bunMoved === undefined ? {} : { bunMoved }),
281
+ });
265
282
  return { gate: hopGate, scripts: [] };
266
283
  });
267
284
 
@@ -188,14 +188,14 @@ export async function measureCoverage(
188
188
  }
189
189
 
190
190
  /** One decimal, rounded DOWN: a printed number never claims more than was measured. */
191
- const shown = (value: number): string => (Math.floor(value * 10) / 10).toFixed(1);
191
+ export const shown = (value: number): string => (Math.floor(value * 10) / 10).toFixed(1);
192
192
 
193
193
  /**
194
194
  * The floor a measured number supports: the bar once it clears it, the whole number under it
195
195
  * below — up to a point of room, so one uncovered line in an unrelated file is not a red gate,
196
196
  * and less than `FLOOR_SLACK`, so the floor it writes is never stale the moment it is written.
197
197
  */
198
- const floorFor = (measured: number): number =>
198
+ export const floorFor = (measured: number): number =>
199
199
  measured >= COVERAGE_BAR ? COVERAGE_BAR : Math.floor(measured);
200
200
 
201
201
  const WHY_PLACEHOLDER = '<what is uncovered and who closes it>';
package/src/dev-boot.ts CHANGED
@@ -279,8 +279,8 @@ async function bootDev(
279
279
  signInPath: await loadSignInPath(options.root),
280
280
  // The same seam `serve.ts` passes: the app's own error page is a FILE under this root.
281
281
  root: options.root,
282
- // The `/_x` shell, the harness's frame, the app's own error pages and its brand — the inline
283
- // bodies this process serves; the app's surfaces are content-hashed files `'self'` admits.
282
+ // The `/_x` shell, the harness's frame and the app's own error pages — the inline bodies this
283
+ // process serves; the app's surfaces, brand included, are hashed files `'self'` admits.
284
284
  inlineStyles: [await devShellStyle(), FRAME_STYLE, ...inlineStyles],
285
285
  inlineScripts: [
286
286
  theme.cspSource,
@@ -78,8 +78,8 @@ export interface DevRouteTable {
78
78
  /** The zone script (`time.detect`), admitted the same way — `undefined` when the app left it off. */
79
79
  readonly zone: ZoneBoot | undefined;
80
80
  /**
81
- * Every inline `<style>` body these routes put in a document: the app's error pages' and its
82
- * brand's (`theme-brand.ts`) — what `startRoles({ inlineStyles })` hashes into `style-src`.
81
+ * Every inline `<style>` body these routes put in a document: the app's error pages' — what
82
+ * `startRoles({ inlineStyles })` hashes into `style-src`. The brand rides the stylesheet.
83
83
  */
84
84
  readonly inlineStyles: readonly string[];
85
85
  /** Where the app's default MCP endpoint was mounted, or `null`. */
@@ -94,7 +94,8 @@ export async function devRouteTable(input: DevRouteTableInput): Promise<DevRoute
94
94
  const pwa = await loadPwaArtifacts(input.root);
95
95
  const theme = themeBoot(await loadThemeMode(input.root));
96
96
  // Read at boot, like the theme mode: a save to the theme module is applied on the next `x dev`.
97
- const brand = await loadThemeBrand(input.root);
97
+ // Onto every surface stylesheet, before the first `styleBundle()` below.
98
+ await loadThemeBrand(input.root);
98
99
  // `site.origin` and `seo.robots.disallow`: the absolute URLs every document and the sitemap carry.
99
100
  const site = await loadSiteSettings(input.root);
100
101
  const origin = publicOrigin(input.env, site);
@@ -114,10 +115,7 @@ export async function devRouteTable(input: DevRouteTableInput): Promise<DevRoute
114
115
  client: declared.surfaces,
115
116
  localeSegments: otherLocaleSegments(await appLocaleSet(input.root)),
116
117
  });
117
- const inlineStyles = [
118
- ...(await errorPageStyleBodies(input.root)),
119
- ...(brand === undefined ? [] : [brand.style]),
120
- ];
118
+ const inlineStyles = await errorPageStyleBodies(input.root);
121
119
  // Built once at boot and NOT rebuilt with the islands on a watcher tick: a service worker that
122
120
  // changes under a page it controls is the update path, and one per keystroke exercises it per save.
123
121
  const serviceWorker =
@@ -200,7 +198,6 @@ export async function devRouteTable(input: DevRouteTableInput): Promise<DevRoute
200
198
  ...adminMountRoutes({
201
199
  buildId: input.buildId,
202
200
  themeHead: theme.head,
203
- ...(brand === undefined ? {} : { brandHead: brand.head }),
204
201
  ...(origin === undefined ? {} : { origin }),
205
202
  }),
206
203
  ...appRoutes({
@@ -214,7 +211,6 @@ export async function devRouteTable(input: DevRouteTableInput): Promise<DevRoute
214
211
  persisted: sync.persisted,
215
212
  ...(navigation.head === undefined ? {} : { navigation: navigation.head }),
216
213
  themeHead: theme.head,
217
- ...(brand === undefined ? {} : { brandHead: brand.head }),
218
214
  ...(speculation === undefined ? {} : { speculationHead: speculation.head }),
219
215
  ...(origin === undefined ? {} : { origin }),
220
216
  ...(pwa === undefined
@@ -0,0 +1,111 @@
1
+ // `x doctor`'s env-name check: an app's own variable — declared in `envSchema` or sealed in the
2
+ // secrets file — on a name the framework reads as a switch or for itself (`FRAMEWORK_ENV`). An
3
+ // adapter's settings (`S3_BUCKET`, `SMTP_URL`) are the contract: declaring them is the configuring.
4
+
5
+ // why: Bun exposes no path-join primitive; Bun.file takes one already joined.
6
+ import { join } from 'node:path';
7
+ import type { FrameworkEnvName } from '@ultimat3/core';
8
+ import {
9
+ APP_CONFIG_FILE,
10
+ ERROR_DOCS_URL,
11
+ findMasterKey,
12
+ frameworkEnvEntry,
13
+ readSecretsFile,
14
+ secretsFileExists,
15
+ } from '@ultimat3/core';
16
+ import { ENV_SCHEMA_EXPORT, loadEnvSchema } from './app-env';
17
+ import type { Finding } from './output';
18
+
19
+ /** Where the app names its variables: what it declared, and what it sealed. */
20
+ export interface AppEnvNamesFact {
21
+ readonly declared: readonly string[];
22
+ /** The 1-based line of each declared key in `app.config.ts`, where the probe found one. */
23
+ readonly lines?: ReadonlyMap<string, number>;
24
+ /** Names in `secrets.enc.json`; empty when this machine has no key to open it with. */
25
+ readonly sealed: readonly string[];
26
+ }
27
+
28
+ export const NO_APP_ENV_NAMES: AppEnvNamesFact = Object.freeze({ declared: [], sealed: [] });
29
+
30
+ export const ENV_NAME_RESERVED = 'X_ENV_NAME_RESERVED';
31
+
32
+ /** The prefix a renamed key takes: no framework entry starts with it. */
33
+ export const APP_ENV_PREFIX = 'APP_';
34
+
35
+ /**
36
+ * A collision is a name the framework reads as a `switch` (its presence turns a behaviour on) or
37
+ * `internal` (the framework sets it, or a harness does). The deploy contract (`DATABASE_URL`,
38
+ * `PORT`) is what an app is meant to declare, and a `host` name is the platform's.
39
+ */
40
+ const collides = (name: string): FrameworkEnvName | undefined => {
41
+ const entry = frameworkEnvEntry(name);
42
+ return entry !== undefined && (entry.use === 'switch' || entry.use === 'internal')
43
+ ? entry
44
+ : undefined;
45
+ };
46
+
47
+ const what = (name: string, entry: FrameworkEnvName): string =>
48
+ entry.use === 'switch'
49
+ ? `@ultimat3/${entry.owner} also reads ${name}: set, it switches that package's behaviour on with this value`
50
+ : `${entry.prefix === true ? `every ${entry.name}* name` : name} is @ultimat3/${entry.owner}'s own, set by the framework or its harness`;
51
+
52
+ /** The rule, pure. One finding per name, a sealed name and a declared one apart. */
53
+ export function reservedEnvFindings(fact: AppEnvNamesFact): readonly Finding[] {
54
+ const findings: Finding[] = [];
55
+ for (const name of [...new Set(fact.declared)].sort()) {
56
+ const entry = collides(name);
57
+ if (entry === undefined) continue;
58
+ findings.push({
59
+ code: ENV_NAME_RESERVED,
60
+ cause: `${ENV_SCHEMA_EXPORT} in ${APP_CONFIG_FILE} declares ${name}, and ${what(name, entry)}`,
61
+ // A rename, never an allow: a name meant for the framework needs no app declaration at all.
62
+ fix: `edit ${APP_CONFIG_FILE}:${fact.lines?.get(name) ?? 1} — rename ${name} in ${ENV_SCHEMA_EXPORT} to ${APP_ENV_PREFIX}${name} (or delete it where the value is meant for @ultimat3/${entry.owner}); then: x env example --json && x doctor --json`,
63
+ docs: ERROR_DOCS_URL,
64
+ at: APP_CONFIG_FILE,
65
+ });
66
+ }
67
+ for (const name of [...new Set(fact.sealed)].sort()) {
68
+ const entry = collides(name);
69
+ if (entry === undefined) continue;
70
+ findings.push({
71
+ code: ENV_NAME_RESERVED,
72
+ cause: `secrets.enc.json seals ${name}, and ${what(name, entry)}`,
73
+ fix: `x secrets edit # rename ${name} to ${APP_ENV_PREFIX}${name} unless the value is meant for @ultimat3/${entry.owner}; then: x doctor --json`,
74
+ docs: ERROR_DOCS_URL,
75
+ at: 'secrets.enc.json',
76
+ });
77
+ }
78
+ return findings;
79
+ }
80
+
81
+ /**
82
+ * The I/O half. A config that will not import, or a secrets file this key cannot open, is another
83
+ * probe's finding (`snapshots`, `sealedKeys`); here it is simply nothing to judge.
84
+ */
85
+ export async function appEnvNamesProbe(
86
+ root: string,
87
+ env: Readonly<Record<string, string | undefined>>,
88
+ ): Promise<AppEnvNamesFact> {
89
+ const declared = await loadEnvSchema(root).then(
90
+ (schema) => Object.keys(schema ?? {}),
91
+ () => [],
92
+ );
93
+ const config = await Bun.file(join(root, APP_CONFIG_FILE))
94
+ .text()
95
+ .catch(() => '');
96
+ const lines = new Map<string, number>();
97
+ // A key that is not a plain identifier is never a framework name, and never a regex here.
98
+ for (const name of declared.filter((key) => /^[A-Za-z_]\w*$/.test(key))) {
99
+ const at = config.search(new RegExp(`^\\s*['"]?${name}['"]?\\s*:`, 'm'));
100
+ if (at >= 0) lines.set(name, config.slice(0, at).split('\n').length);
101
+ }
102
+ const key = findMasterKey(root, { ...env });
103
+ const sealed =
104
+ key === undefined || !secretsFileExists(root)
105
+ ? []
106
+ : await readSecretsFile(root, key).then(
107
+ (values) => Object.keys(values),
108
+ () => [],
109
+ );
110
+ return { declared, lines, sealed };
111
+ }
@@ -0,0 +1,62 @@
1
+ // `x doctor`'s floor check: a gate step that applies to this app — its suite files exist, its
2
+ // input is committed — and that `x.verify.json`'s `steps` does not hold. Unfloored, deleting the
3
+ // suite turns the step from green into skipped-and-green; floored, it is `X_VERIFY_SUITE_VANISHED`.
4
+
5
+ import { ERROR_DOCS_URL } from '@ultimat3/core';
6
+ import type { Runner } from './exec';
7
+ import type { Finding } from './output';
8
+ import { quoteArg } from './shell-quote';
9
+ import { VERIFY_STEPS } from './verify-checks';
10
+ import { floorRequires, readVerifyFloor, VERIFY_FLOOR_FILE } from './verify-floor';
11
+ import type { VerifyStep, VerifyStepName } from './verify-step';
12
+
13
+ export const STEP_UNFLOORED = 'X_VERIFY_STEP_UNFLOORED';
14
+
15
+ /**
16
+ * Never proposed. `x new` writes `e2e` as an `e2eTest` that skips until the app registers a
17
+ * browser driver, so its file exists while the step runs nothing: flooring it reds a fresh app's
18
+ * gate on the scaffold's own placeholder (`scaffold-verify-floor.ts`). The gate's summary already
19
+ * names it as skipped; the floor is the app's call once a driver makes it run.
20
+ */
21
+ const NEVER_PROPOSED: ReadonlySet<VerifyStepName> = new Set<VerifyStepName>(['e2e']);
22
+
23
+ /** `applies` reads the disk alone: a step that spawned here would be asking the wrong question. */
24
+ const noRunner: Runner = async (command) => ({
25
+ command,
26
+ code: 1,
27
+ ok: false,
28
+ stdout: '',
29
+ stderr: '',
30
+ durationMs: 0,
31
+ });
32
+
33
+ /** The I/O half: each step with an `applies`, asked of this root, that the floor does not hold. */
34
+ export async function unflooredStepsProbe(
35
+ root: string,
36
+ steps: readonly VerifyStep[] = VERIFY_STEPS,
37
+ ): Promise<readonly VerifyStepName[]> {
38
+ const floor = await readVerifyFloor(root);
39
+ const unfloored: VerifyStepName[] = [];
40
+ for (const step of steps) {
41
+ if (step.applies === undefined || NEVER_PROPOSED.has(step.name)) continue;
42
+ if (floorRequires(floor, step.name)) continue;
43
+ const applies = await step.applies({ root, runner: noRunner }).catch(() => false);
44
+ if (applies) unfloored.push(step.name);
45
+ }
46
+ return unfloored;
47
+ }
48
+
49
+ /** The rule, pure: one finding naming every unfloored step, run-first, so the edit is proven. */
50
+ export function unflooredStepFindings(steps: readonly VerifyStepName[]): readonly Finding[] {
51
+ if (steps.length === 0) return [];
52
+ return [
53
+ {
54
+ code: STEP_UNFLOORED,
55
+ cause: `${steps.join(', ')} ${steps.length === 1 ? 'applies' : 'apply'} to this app and ${VERIFY_FLOOR_FILE} "steps" does not hold ${steps.length === 1 ? 'it' : 'them'}, so a deleted suite reads as skipped and the gate stays green`,
56
+ // Run first: a step that skips here would red the gate the moment the floor names it.
57
+ fix: `x verify --only ${quoteArg(steps.join(','))} --json # then add each step that passed, not skipped, to "steps" in ${VERIFY_FLOOR_FILE}`,
58
+ docs: ERROR_DOCS_URL,
59
+ at: VERIFY_FLOOR_FILE,
60
+ },
61
+ ];
62
+ }