@ultimat3/cli 31.25.0 → 31.27.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 (123) hide show
  1. package/CLAUDE.md +44 -36
  2. package/README.md +5 -4
  3. package/package.json +29 -29
  4. package/src/app-mcp.ts +17 -3
  5. package/src/cmd-cache-spec.ts +5 -2
  6. package/src/cmd-db-recount.ts +7 -0
  7. package/src/cmd-db-spec.ts +2 -3
  8. package/src/cmd-db.ts +0 -2
  9. package/src/cmd-deploy-verify-sample.ts +93 -0
  10. package/src/cmd-deploy-verify.ts +2 -41
  11. package/src/cmd-dev-spec.ts +15 -1
  12. package/src/cmd-dev.ts +31 -4
  13. package/src/cmd-doctor.ts +4 -1
  14. package/src/cmd-exercise-spec.ts +7 -1
  15. package/src/cmd-exercise.ts +22 -10
  16. package/src/cmd-generate.ts +2 -0
  17. package/src/cmd-jobs-spec.ts +3 -6
  18. package/src/cmd-jobs.ts +1 -7
  19. package/src/cmd-logs-spec.ts +2 -1
  20. package/src/cmd-logs.ts +9 -28
  21. package/src/cmd-planned.ts +11 -45
  22. package/src/cmd-profile-frames.ts +99 -0
  23. package/src/cmd-profile-spec.ts +24 -0
  24. package/src/cmd-profile.ts +164 -0
  25. package/src/cmd-status-sample.ts +57 -0
  26. package/src/cmd-status-spec.ts +30 -0
  27. package/src/cmd-status.ts +108 -0
  28. package/src/cmd-token-spec.ts +5 -2
  29. package/src/cmd-token.ts +7 -3
  30. package/src/coverage-island.ts +121 -0
  31. package/src/coverage-lcov.ts +49 -5
  32. package/src/coverage-remap.ts +146 -0
  33. package/src/db-replay-engine-prepared.ts +66 -0
  34. package/src/db-replay-engine-template.ts +156 -0
  35. package/src/db-replay-engine.ts +4 -0
  36. package/src/db-replay-scratch-reap.ts +54 -0
  37. package/src/deploy-verify-flags.ts +9 -2
  38. package/src/deploy-verify-grade.ts +10 -3
  39. package/src/dev-boot.ts +14 -1
  40. package/src/dev-dashboard-guard.ts +57 -10
  41. package/src/dev-host.ts +46 -0
  42. package/src/dev-tls-cache.ts +103 -0
  43. package/src/dev-tls-der.ts +69 -0
  44. package/src/dev-tls.ts +120 -0
  45. package/src/dispatch.ts +6 -1
  46. package/src/doctor-browser.ts +60 -0
  47. package/src/error-codes-verify.ts +47 -0
  48. package/src/error-codes.ts +14 -23
  49. package/src/exercise-database.ts +40 -7
  50. package/src/exercise-push-device.ts +51 -0
  51. package/src/exercise-route-api.ts +74 -0
  52. package/src/exercise-routes.ts +14 -5
  53. package/src/exercise-services.ts +3 -1
  54. package/src/exercise-shard-flag.ts +47 -0
  55. package/src/fix-command.ts +2 -2
  56. package/src/generate-factories.ts +9 -11
  57. package/src/generate-feature-required.ts +9 -4
  58. package/src/generate-files.ts +20 -2
  59. package/src/generate-kinds.ts +5 -1
  60. package/src/guards.ts +21 -6
  61. package/src/island-bundle-options.ts +48 -0
  62. package/src/island-bundle.ts +18 -46
  63. package/src/island-link.ts +5 -0
  64. package/src/island-outputs.ts +5 -0
  65. package/src/mcp-errors-verify.ts +35 -0
  66. package/src/mcp-errors.ts +10 -19
  67. package/src/mcp-host-logs.ts +121 -0
  68. package/src/mcp-host.ts +12 -73
  69. package/src/messages-floor.ts +19 -0
  70. package/src/messages-status.ts +10 -0
  71. package/src/messages.ts +21 -0
  72. package/src/registry.ts +4 -0
  73. package/src/role-start-types.ts +7 -0
  74. package/src/role-start.ts +4 -0
  75. package/src/serve-boot.ts +7 -1
  76. package/src/serve-env-tls.ts +57 -0
  77. package/src/solid-loader.ts +27 -10
  78. package/src/templates/generate-export-rows.ts +136 -0
  79. package/src/templates/generate-import-rows.ts +186 -0
  80. package/src/templates/generate-rows-slice.ts +95 -0
  81. package/src/templates/github/ci.yml.ts +4 -0
  82. package/src/templates/scaffold-db-package.ts +3 -0
  83. package/src/templates/scaffold-docs.ts +8 -6
  84. package/src/templates/scaffold-repo.ts +2 -7
  85. package/src/templates/scaffold-site.ts +4 -1
  86. package/src/templates/scaffold-suites.ts +72 -0
  87. package/src/templates/scaffold-test-services.ts +35 -10
  88. package/src/templates/scaffold-verify-floor.ts +53 -31
  89. package/src/templates/shapes/api.ts +4 -0
  90. package/src/templates/slice-foundation.ts +3 -3
  91. package/src/unthrown-codes.ts +1 -1
  92. package/src/upgrade-gate.ts +6 -1
  93. package/src/upgrade-guards-baseline.ts +43 -0
  94. package/src/upgrade-guards.ts +37 -2
  95. package/src/upgrade-report.ts +3 -0
  96. package/src/verify-coverage-run.ts +42 -11
  97. package/src/verify-e2e.ts +115 -4
  98. package/src/verify-floor.ts +27 -0
  99. package/src/verify-guard-baseline.ts +109 -0
  100. package/src/verify-live.ts +72 -0
  101. package/src/verify-merge-skips.ts +51 -0
  102. package/src/verify-merge.ts +36 -2
  103. package/src/verify-run.ts +48 -7
  104. package/src/verify-services.ts +287 -0
  105. package/src/verify-skip-reason.ts +53 -0
  106. package/src/verify-strict.ts +108 -0
  107. package/src/verify-test-command.ts +129 -0
  108. package/src/verify-tests.ts +39 -126
  109. package/types/babel-modules.d.ts +2 -0
  110. package/wiki/Agents.md +2 -5
  111. package/wiki/CLI-Reference.md +142 -23
  112. package/wiki/Caching-And-Invalidation.md +1 -1
  113. package/wiki/Entities-And-Migrations.md +1 -1
  114. package/wiki/Interface-Rules.md +5 -0
  115. package/wiki/Jobs-And-Workflows.md +3 -3
  116. package/wiki/Known-Gaps.md +5 -1
  117. package/wiki/MCP-And-AI.md +103 -2
  118. package/wiki/Mail.md +52 -0
  119. package/wiki/PWA-And-Offline.md +1 -1
  120. package/wiki/Scraping.md +19 -4
  121. package/wiki/Troubleshooting.md +3 -3
  122. package/wiki/Tutorial-05-Deploy-Free.md +2 -2
  123. package/wiki/Upgrading.md +3 -0
@@ -125,6 +125,10 @@ ${SETUP_STEPS}
125
125
  run: |
126
126
  docker compose -f ${TEST_COMPOSE_PATH} up -d --wait
127
127
  cat ${TEST_ENV_PATH} >> "$GITHUB_ENV"
128
+ # ubuntu-latest ships Chrome, and the \`e2e\` step finds it. Required here, so a runner that
129
+ # has none (a \`CI_RUNNER\` label) is red with the command that locates one — never a skip.
130
+ - if: contains(matrix.only, 'e2e')
131
+ run: echo "E2E_BROWSER_REQUIRED=1" >> "$GITHUB_ENV"
128
132
  # Under $RUNNER_TEMP, never in the checkout, where \`lint\` would walk the open file.
129
133
  - env:
130
134
  PART: \${{ matrix.part }}
@@ -13,6 +13,7 @@ import { sortedImports } from './imports';
13
13
  import type { GeneratedFile, NameSet } from './naming';
14
14
  import { dbClientFiles } from './scaffold-db-client';
15
15
  import { packageShapeFiles, workspacePackageJson } from './scaffold-package-shape';
16
+ import { liveSuiteFiles } from './scaffold-suites';
16
17
 
17
18
  const DESCRIPTION = 'Entity re-exports and SQL migrations, no business logic';
18
19
 
@@ -231,4 +232,6 @@ export const dbPackageFiles = (app: NameSet, example: boolean): readonly Generat
231
232
  { path: 'packages/db/src/schema.ts', contents: dbSchema(app, example) },
232
233
  { path: 'packages/db/src/seed.ts', contents: dbSeed(app, example) },
233
234
  { path: 'packages/db/src/seed.test.ts', contents: dbSeedTest(app, example) },
235
+ // The production driver against a real Postgres: the `live` step every scaffold runs.
236
+ ...liveSuiteFiles(),
234
237
  ];
@@ -86,13 +86,14 @@ branch whose test cannot fail is worse than an uncovered one, because it reads a
86
86
  \`exclude\` entry under \`coverage\` is for code a unit test cannot execute — an island's
87
87
  browser-only mount, a container entry point — carries its \`why\`, and is printed by \`bunx x doctor\`.
88
88
 
89
- Every test the scaffold and the generators write is the idiom to copy. All of them run on the
90
- \`unit\` step — in process, on the in-memory driver, with no database, browser or server.
89
+ Every test the scaffold and the generators write is the idiom to copy. A \`*.live.test.ts\` runs
90
+ on a real Postgres, a \`*.e2e.test.ts\` in a real browser; the rest on \`unit\`, in memory.
91
91
 
92
92
  A suite that needs a real server reads it from \`docker/test-services.env\`: Postgres 18, Redis, NATS
93
- and S3 from \`docker/docker-compose.test.yml\`, in RAM, with durability and logging off — CI starts
94
- it before \`bun run verify\`, a laptop with \`docker compose -f docker/docker-compose.test.yml up -d
95
- --wait\` then \`set -a; . docker/test-services.env; set +a\`. A resource a test opens is held with
93
+ and S3 from \`docker/docker-compose.test.yml\`, in RAM, with durability and logging off.
94
+ \`bun run verify\` starts it itself when nothing answers at \`TEST_DATABASE_URL\` and Docker is
95
+ there; by hand it is \`docker compose -f docker/docker-compose.test.yml up -d --wait\` then
96
+ \`set -a; . docker/test-services.env; set +a\`. A resource a test opens is held with
96
97
  \`await using\` — \`await using db = await acquireWorkerDatabase()\` drops its database however
97
98
  the test ends:
98
99
 
@@ -151,7 +152,8 @@ bun run dev # all roles in one process, embedded Postgres, /_x mounted
151
152
  bun run verify # the gate: typecheck, lint, boundaries, tests, drift, budgets (it builds to weigh)
152
153
  \`\`\`
153
154
 
154
- Tests against real servers — Postgres 18, Redis, NATS, S3, in RAM and silent, as CI runs them:
155
+ Tests against real servers — Postgres 18, Redis, NATS, S3, in RAM and silent, as CI runs them.
156
+ \`bun run verify\` starts them when nothing answers and Docker is there; by hand:
155
157
 
156
158
  \`\`\`sh
157
159
  docker compose -f docker/docker-compose.test.yml up -d --wait
@@ -107,6 +107,7 @@ const rootPackage = (app: NameSet, version: string): string => `{
107
107
  "@ultimat3/render": "^${version}",
108
108
  "@ultimat3/schema": "^${version}",
109
109
  "@ultimat3/seo": "^${version}",
110
+ "@ultimat3/storage": "^${version}",
110
111
  "@ultimat3/ui": "^${version}",
111
112
  "solid-js": "${SOLID_VERSION}"
112
113
  },
@@ -320,12 +321,6 @@ const bunfig = (): string => `[test]
320
321
  root = "."
321
322
  # Frozen clock, seeded RNG, sealed network — nondeterminism in a test is a bug.
322
323
  preload = ["@ultimat3/testing/preload"]
323
- # An island is mounted from a BUILT chunk that \`mountIsland\` writes to a temp .mjs, so
324
- # \`bun test --coverage\` reports that file: two minified lines, under a name no source has. Bun
325
- # does not remap a pre-built module through its sourcemap (measured on 1.4.0, and the build does
326
- # emit one), so the row can only ever be noise — the island's own .island.tsx is not what it
327
- # describes. Ignoring it removes the phantom; it hides no line any test was covering.
328
- coveragePathIgnorePatterns = ["**/*.mjs"]
329
324
  `;
330
325
 
331
326
  const scssTypes =
@@ -393,7 +388,7 @@ export function repoFiles(
393
388
  { path: 'biome.json', contents: biome() },
394
389
  { path: 'bunfig.toml', contents: bunfig() },
395
390
  { path: 'app.config.ts', contents: appConfig(app) },
396
- { path: VERIFY_FLOOR_FILE, contents: verifyFloor(example) },
391
+ { path: VERIFY_FLOOR_FILE, contents: verifyFloor({ jobs: example, pages: true }) },
397
392
  { path: 'types/scss.d.ts', contents: scssTypes() },
398
393
  { path: '.gitignore', contents: gitignore() },
399
394
  // Every text file LF whatever `core.autocrlf` says — a Windows checkout is otherwise CRLF.
@@ -6,6 +6,7 @@
6
6
 
7
7
  import { sortedImports } from './imports';
8
8
  import type { GeneratedFile, NameSet } from './naming';
9
+ import { e2eSuiteFiles } from './scaffold-suites';
9
10
 
10
11
  // Plain strings for the framework lines, never template literals: the workspace-dependency scanner
11
12
  // blanks a string's contents but not a nested template's, so a template here would bill the CLI
@@ -305,9 +306,11 @@ unitTest('it ships zero JS and declares the metadata a search result renders', a
305
306
  });
306
307
  `;
307
308
 
308
- /** The landing page, its stylesheet and its test. */
309
+ /** The landing page, its stylesheet, its test and its e2e suite. */
309
310
  export const siteFiles = (app: NameSet): readonly GeneratedFile[] => [
310
311
  { path: 'apps/web/site/page.tsx', contents: sitePage(app) },
311
312
  { path: 'apps/web/site/page.module.scss', contents: siteStyle() },
312
313
  { path: 'apps/web/site/page.test.ts', contents: sitePageTest(app) },
314
+ // The same page in a real browser: the `e2e` step every scaffold with a page runs.
315
+ ...e2eSuiteFiles(),
313
316
  ];
@@ -0,0 +1,72 @@
1
+ // The two suites every scaffold ships for what a unit test cannot answer: the production driver
2
+ // against a real Postgres (`live`), and the landing page in a real browser (`e2e`). With both, a
3
+ // fresh app's gate runs its `live` and `e2e` steps from the first commit, example slice or not.
4
+
5
+ import type { GeneratedFile } from './naming';
6
+
7
+ /** Where the live suite lands: beside the handle it vouches for. */
8
+ export const LIVE_SUITE_PATH = 'packages/db/src/client.live.test.ts';
9
+
10
+ /** Where the e2e suite lands: beside the page it drives (a shape that drops the page drops it). */
11
+ export const E2E_SUITE_PATH = 'apps/web/site/page.e2e.test.ts';
12
+
13
+ const liveSuite =
14
+ (): string => `// The production driver against a real Postgres — the half the embedded database cannot vouch for.
15
+ // A \`uuid[]\`, a \`timestamptz\`, a \`jsonb\` and a \`bigint\` decoded over the wire, so a decode that
16
+ // differs from PGlite's is red here and not on the first deploy. \`needs\` skips it, naming the
17
+ // command that starts the database, when TEST_DATABASE_URL is unset.
18
+ import { postgresClient, sql } from '@ultimat3/db';
19
+ import { expect, liveTest } from '@ultimat3/testing';
20
+
21
+ const ids = ['00000000-0000-4000-8000-000000000001', '00000000-0000-4000-8000-000000000002'];
22
+
23
+ interface Decoded {
24
+ readonly ids: readonly string[];
25
+ readonly at: Date;
26
+ readonly doc: { readonly n: number };
27
+ readonly big: string;
28
+ }
29
+
30
+ liveTest(
31
+ 'the production driver decodes what the app stores',
32
+ async () => {
33
+ const { TEST_DATABASE_URL: url } = Bun.env;
34
+ const client = postgresClient({ url });
35
+ try {
36
+ const [row] = await client.query<Decoded>(
37
+ sql\`select \${ids}::uuid[] as ids, '2026-01-01T00:00:00Z'::timestamptz as at, '{"n":1}'::jsonb as doc, 9007199254740993::bigint as big\`,
38
+ );
39
+ expect(row?.ids).toEqual(ids);
40
+ expect(row?.at.toISOString()).toBe('2026-01-01T00:00:00.000Z');
41
+ expect(row?.doc).toEqual({ n: 1 });
42
+ // Past 2^53: a bigint that came back as a number would have lost its last digit.
43
+ expect(row?.big).toBe('9007199254740993');
44
+ } finally {
45
+ await client.close();
46
+ }
47
+ },
48
+ { needs: ['postgres'] },
49
+ );
50
+ `;
51
+
52
+ const e2eSuite =
53
+ (): string => `// The landing page in a real browser, against the BUILT output — what \`renderRoute\` in
54
+ // page.test.ts cannot see: the document a browser parses and the title its tab shows. Its own file
55
+ // because the gate types a test by its FILENAME — an e2eTest in page.test.ts is a unit test.
56
+ import { e2eTest, expect } from '@ultimat3/testing';
57
+
58
+ e2eTest('/ loads in a browser and names itself', async ({ page }) => {
59
+ await page.goto('/');
60
+ expect(await page.title()).not.toBe('');
61
+ });
62
+ `;
63
+
64
+ /** The live suite, in the db package every scaffold writes. */
65
+ export const liveSuiteFiles = (): readonly GeneratedFile[] => [
66
+ { path: LIVE_SUITE_PATH, contents: liveSuite() },
67
+ ];
68
+
69
+ /** The e2e suite, beside the landing page. */
70
+ export const e2eSuiteFiles = (): readonly GeneratedFile[] => [
71
+ { path: E2E_SUITE_PATH, contents: e2eSuite() },
72
+ ];
@@ -3,17 +3,40 @@
3
3
  // `docker/docker-compose.test.yml`, cut to what an app has. Ports sit apart from the dev stack's
4
4
  // so both can run at once; `ci.yml` starts this file before `bun run verify`.
5
5
 
6
+ import { fnv1a } from '@ultimat3/core';
6
7
  import type { GeneratedFile, NameSet } from './naming';
7
8
  import { S3_GATEWAY_IMAGE } from './pinned-images';
8
9
 
9
10
  export const TEST_COMPOSE_PATH = 'docker/docker-compose.test.yml';
10
11
  export const TEST_ENV_PATH = 'docker/test-services.env';
11
12
 
12
- /** Host ports, one place: the compose file publishes them and the env file names them. */
13
+ /** Each service's band start: the dev stack's port plus 50000, so both stacks run at once. */
13
14
  export const TEST_PORTS = { postgres: 55432, redis: 56379, nats: 54222, s3: 59000 } as const;
14
15
 
16
+ /** How wide each band is: the bands stay disjoint, and two apps collide 1 time in 500. */
17
+ export const TEST_PORT_SPREAD = 500;
18
+
19
+ type TestPorts = { readonly [K in keyof typeof TEST_PORTS]: number };
20
+
21
+ /**
22
+ * This app's host ports, one place: the compose file publishes them and the env file names them.
23
+ * One fixed set made two scaffolds on one machine share 55432, so the second app's live suites
24
+ * dialled the first app's container; the app's name now picks its offset into each band.
25
+ */
26
+ export const testPorts = (app: NameSet): TestPorts => {
27
+ // FNV-1a over the app's name: stable across machines and runs.
28
+ const offset = fnv1a(app.kebab) % TEST_PORT_SPREAD;
29
+ return {
30
+ postgres: TEST_PORTS.postgres + offset,
31
+ redis: TEST_PORTS.redis + offset,
32
+ nats: TEST_PORTS.nats + offset,
33
+ s3: TEST_PORTS.s3 + offset,
34
+ };
35
+ };
36
+
15
37
  const composeTest = (
16
38
  app: NameSet,
39
+ ports: TestPorts = testPorts(app),
17
40
  ): string => `# The services the test suites run against — in RAM, and silent.
18
41
  #
19
42
  # docker compose -f ${TEST_COMPOSE_PATH} up -d --wait
@@ -22,7 +45,8 @@ const composeTest = (
22
45
  #
23
46
  # \`--wait\` returns once every healthcheck passes. CI runs the same lines (.github/workflows/ci.yml).
24
47
  # None of it is required: with no TEST_* variable set the unit suite runs on the in-memory driver,
25
- # and a suite that needs a real server skips. Ports are the dev stack's plus 50000, so both run.
48
+ # and a suite that needs a real server skips. Ports are this app's own (its name picks
49
+ # them), above the dev stack's, so both stacks — and two apps — run at once.
26
50
  #
27
51
  # Three rules, on every service:
28
52
  #
@@ -71,7 +95,7 @@ services:
71
95
  -c min_wal_size=32MB
72
96
  -c max_wal_size=256MB
73
97
  tmpfs: [/var/lib/postgresql]
74
- ports: ['127.0.0.1:${TEST_PORTS.postgres}:5432']
98
+ ports: ['127.0.0.1:${ports.postgres}:5432']
75
99
  healthcheck:
76
100
  # TCP, never the socket: the entrypoint's temporary init server listens on the socket only.
77
101
  test: ['CMD-SHELL', 'pg_isready -U ${app.kebab} -h 127.0.0.1 -p 5432']
@@ -84,7 +108,7 @@ services:
84
108
  image: redis:8-alpine
85
109
  command: ['redis-server', '--save', '', '--appendonly', 'no', '--loglevel', 'nothing']
86
110
  tmpfs: [/data]
87
- ports: ['127.0.0.1:${TEST_PORTS.redis}:6379']
111
+ ports: ['127.0.0.1:${ports.redis}:6379']
88
112
  healthcheck:
89
113
  test: ['CMD', 'redis-cli', 'ping']
90
114
  interval: 1s
@@ -97,7 +121,7 @@ services:
97
121
  image: nats:2-alpine
98
122
  command: ['-js', '-sd', '/data', '-m', '8222', '-l', '/dev/null']
99
123
  tmpfs: [/data]
100
- ports: ['127.0.0.1:${TEST_PORTS.nats}:4222']
124
+ ports: ['127.0.0.1:${ports.nats}:4222']
101
125
  healthcheck:
102
126
  test: ['CMD', 'wget', '-q', '--spider', 'http://127.0.0.1:8222/healthz']
103
127
  interval: 1s
@@ -117,7 +141,7 @@ services:
117
141
  ROOT_ACCESS_KEY: ${app.kebab}
118
142
  ROOT_SECRET_KEY: ${app.kebab}-test
119
143
  tmpfs: [/data/${app.kebab}-test]
120
- ports: ['127.0.0.1:${TEST_PORTS.s3}:9000']
144
+ ports: ['127.0.0.1:${ports.s3}:9000']
121
145
  healthcheck:
122
146
  test: ['CMD', 'nc', '-z', '127.0.0.1', '9000']
123
147
  interval: 1s
@@ -127,13 +151,14 @@ services:
127
151
 
128
152
  const testEnv = (
129
153
  app: NameSet,
154
+ ports: TestPorts = testPorts(app),
130
155
  ): string => `# Where the suites find the services ${TEST_COMPOSE_PATH} starts — the one place these URLs are
131
156
  # written. A laptop sources it (\`set -a; . ${TEST_ENV_PATH}; set +a\`); CI appends it to $GITHUB_ENV.
132
157
  # TEST_DATABASE_URL is what @ultimat3/testing clones one database per test worker from.
133
- TEST_DATABASE_URL=postgres://${app.kebab}:${app.kebab}-test@127.0.0.1:${TEST_PORTS.postgres}/postgres
134
- TEST_REDIS_URL=redis://127.0.0.1:${TEST_PORTS.redis}
135
- TEST_NATS_URL=nats://127.0.0.1:${TEST_PORTS.nats}
136
- TEST_S3_URL=http://${app.kebab}:${app.kebab}-test@127.0.0.1:${TEST_PORTS.s3}/${app.kebab}-test
158
+ TEST_DATABASE_URL=postgres://${app.kebab}:${app.kebab}-test@127.0.0.1:${ports.postgres}/postgres
159
+ TEST_REDIS_URL=redis://127.0.0.1:${ports.redis}
160
+ TEST_NATS_URL=nats://127.0.0.1:${ports.nats}
161
+ TEST_S3_URL=http://${app.kebab}:${app.kebab}-test@127.0.0.1:${ports.s3}/${app.kebab}-test
137
162
  `;
138
163
 
139
164
  /** The test stack and its env file. */
@@ -7,30 +7,21 @@ import { COVERAGE_BAR } from '../coverage-floor';
7
7
  import type { VerifyStepName } from '../verify-step';
8
8
 
9
9
  /**
10
- * The suite ratchet, committed on day one. Without it `readVerifyFloor` answers "no file is no
11
- * floor" and a deleted suite turns its step from green into skipped-and-green — so
12
- * `X_VERIFY_SUITE_VANISHED` was unreachable in every generated app, in the one repo shape that
13
- * grows suites fastest.
10
+ * The suite ratchet, committed on day one, naming ALL of the gate: every step is either required in
11
+ * `steps` or excused in `skip` with a written why (`verify-strict.ts`), and
12
+ * `scaffold-verify-floor.test.ts` refuses a scaffold that leaves one in neither. Without a floor
13
+ * `readVerifyFloor` answers "no file is no floor" and a deleted suite turns its step from green into
14
+ * skipped-and-green. Typed as `VerifyStepName`, so a name the gate does not run is a compile error.
14
15
  *
15
- * Every name here is a step this scaffold has proved it can run: the SIX that declare no `applies`
16
- * at all — typecheck, lint, boundaries, filesize, errors, manifest — plus `package-shape` (five
17
- * workspace packages), `unit` (every generator emits a `<file>.test.ts`; like every suite step it
18
- * applies on its own file list, `verify-tests.ts`), and `eval`, `drift` and `budgets`, which apply
19
- * to any root with an `app.config.ts`. Typed as `VerifyStepName`, so a name the gate does not run
20
- * is a compile error rather than a floor that covers nothing.
16
+ * `live` and `e2e` are required of every scaffold with the files that make them run
17
+ * (`scaffold-suites.ts`): the production driver against the test Postgres `x verify` starts, the
18
+ * landing page in a real browser. No browser is red with the command that locates one, never a
19
+ * green step that checked nothing. `contract-diff` applies once `bun run setup` has written
20
+ * `x.manifest.json`, which is the first command the README gives.
21
21
  *
22
- * Plus `contract`, which every variant now ships a file for — `apps/web/api/health.contract.test.ts`
23
- * — and, with the example slice, `live` and `job`: its query is a `liveTest` and its job a
24
- * `jobTest`, and both were written into plain `<name>.test.ts` files that the `unit` step ran while
25
- * `x test live` and `x test job` answered X_TEST_NO_FILES. This is the commit that makes the app's
26
- * own gate run them, which is what the paragraph below always said the condition was.
27
- *
28
- * Two remain absent. `e2e` has a scaffolded file and it is an `e2eTest` — `test.skip` until the app
29
- * registers a browser driver, so the step would run zero tests and fail the ratchet on the
30
- * scaffold's own placeholder. Its absence is visible rather than silent: a suite that executed
31
- * nothing reports as a SKIPPED step, not the green check it printed until #434, so the app's own
32
- * gate line says `- e2e` and names it in the summary until a driver makes it run. `contract-diff` needs a committed `x.manifest.json`, which
33
- * `x manifest` writes later. Each joins the list in the commit that makes the app's gate run it.
22
+ * And `strict: true`: a step that ran nothing is red unless `skip` carries its why
23
+ * (`X_VERIFY_STRICT_UNRUN`). Measured on a fresh `x new` / `--no-example`: `roadmap` everywhere,
24
+ * `job` without the example slice, `e2e` in the `api` shape — exactly the `WHY` rows below.
34
25
  */
35
26
  const SCAFFOLD_FLOOR: readonly VerifyStepName[] = [
36
27
  'typecheck',
@@ -41,11 +32,18 @@ const SCAFFOLD_FLOOR: readonly VerifyStepName[] = [
41
32
  'errors',
42
33
  'unit',
43
34
  'contract',
35
+ // `packages/db/src/client.live.test.ts`, in every scaffold — and the example's live query.
36
+ 'live',
44
37
  // Every app has an `app.config.ts` and primitives to run: `x new` writes `apps/web/exercise.ts`.
45
38
  'exercise',
39
+ // `apps/web/site/page.e2e.test.ts` — dropped, with this name, by a shape that serves no page.
40
+ 'e2e',
46
41
  'eval',
47
42
  'drift',
43
+ 'contract-diff',
48
44
  'budgets',
45
+ 'seo',
46
+ 'i18n',
49
47
  // Always applicable to a scaffolded app — it has an `app.config.ts`, roles and two guarded
50
48
  // routes — so a run that reports it skipped is a gate that lost the step, not an app with
51
49
  // nothing to check. It is the step that would have caught the 500 `x new` used to ship.
@@ -53,19 +51,42 @@ const SCAFFOLD_FLOOR: readonly VerifyStepName[] = [
53
51
  'manifest',
54
52
  ];
55
53
 
56
- /** The two suites only the example slice writes a file for — a floor step with no file is red. */
57
- const EXAMPLE_FLOOR: readonly VerifyStepName[] = ['live', 'job'];
54
+ /** Each step a scaffold may not run, with the why its `skip` carries. */
55
+ const WHY = {
56
+ roadmap:
57
+ 'a framework-repository step: it checks docs/idea/14-roadmap.md, which only the Ultimate monorepo ships',
58
+ job: 'this app declares no job yet: x g job <name> writes one with its .job.test.ts, and then job moves from "skip" to "steps"',
59
+ e2e: 'this app serves no page for a browser to load: x g route <name> --surface site writes one, and then e2e moves from "skip" to "steps"',
60
+ } as const satisfies Partial<Record<VerifyStepName, string>>;
61
+
62
+ /** What a scaffold ships suites for: a job (the example slice) and a page (every shape but `api`). */
63
+ export interface FloorSuites {
64
+ readonly jobs: boolean;
65
+ readonly pages: boolean;
66
+ }
67
+
68
+ /** The floor's `steps` and `skip` for one scaffold, derived from the suites it ships. */
69
+ export function floorSteps(suites: FloorSuites): {
70
+ readonly steps: readonly VerifyStepName[];
71
+ readonly skip: Readonly<Partial<Record<VerifyStepName, string>>>;
72
+ } {
73
+ const steps = SCAFFOLD_FLOOR.filter((step) => step !== 'e2e' || suites.pages);
74
+ return {
75
+ steps: suites.jobs ? [...steps, 'job'] : steps,
76
+ skip: {
77
+ ...(suites.jobs ? {} : { job: WHY.job }),
78
+ ...(suites.pages ? {} : { e2e: WHY.e2e }),
79
+ roadmap: WHY.roadmap,
80
+ },
81
+ };
82
+ }
58
83
 
59
84
  /**
60
85
  * What a unit test cannot execute in a scaffolded app, each with its reason — `x doctor` prints
61
- * them. Two kinds and no more: a file here is a file the floor does not see, so the list is not
86
+ * them. Entry points only: a file here is a file the floor does not see, so the list is not
62
87
  * a place to put code that merely has no test yet.
63
88
  */
64
89
  export const SCAFFOLD_COVERAGE_EXCLUDE: readonly CoverageExclude[] = [
65
- {
66
- glob: 'apps/**/*.island.tsx',
67
- why: 'an island runs in a browser: its test mounts a BUILT chunk (mountIsland), and Bun cannot map that chunk back to this source — its states are held by guards/island-without-states.ts and photographed by x shot --island',
68
- },
69
90
  {
70
91
  glob: 'apps/*/server.ts',
71
92
  why: 'the container entry point: it boots the roles and lives as long as the process — bun run dev and the image exercise it',
@@ -81,10 +102,11 @@ export const SCAFFOLD_COVERAGE_EXCLUDE: readonly CoverageExclude[] = [
81
102
  * to (`COVERAGE_BAR`), not a softer one for apps. `scaffold-smoke` runs the app's own `x verify`,
82
103
  * so the scaffold is green at it on what it generates or the job is red.
83
104
  */
84
- export const verifyFloor = (example: boolean): string =>
105
+ export const verifyFloor = (suites: FloorSuites): string =>
85
106
  `${JSON.stringify(
86
107
  {
87
- steps: example ? [...SCAFFOLD_FLOOR, ...EXAMPLE_FLOOR] : SCAFFOLD_FLOOR,
108
+ ...floorSteps(suites),
109
+ strict: true,
88
110
  coverage: {
89
111
  lines: COVERAGE_BAR,
90
112
  funcs: COVERAGE_BAR,
@@ -3,7 +3,9 @@
3
3
  // documents and the offline fallback, no island, no app UI. `/admin` stays: it is the operator's
4
4
  // console. The PWA block stays too: a page `x g` writes into this app is tested offline.
5
5
 
6
+ import { VERIFY_FLOOR_FILE } from '../../verify-floor';
6
7
  import type { GeneratedFile, NameSet } from '../naming';
8
+ import { verifyFloor } from '../scaffold-verify-floor';
7
9
  import { apiKeyFiles } from './api-keys';
8
10
  import type { ShapeEdit, ShapeOverlay } from './overlay';
9
11
  import { claudeRows, shapeLines } from './shared-edits';
@@ -97,5 +99,7 @@ export const apiShape: ShapeOverlay = {
97
99
  ...apiKeyFiles(),
98
100
  { path: 'apps/web/api/index.ts', contents: apiIndex(app) },
99
101
  { path: 'apps/web/api/index.test.ts', contents: apiIndexTest() },
102
+ // No page, so no browser suite: `e2e` is excused with its why rather than required of nothing.
103
+ { path: VERIFY_FLOOR_FILE, contents: verifyFloor({ jobs: true, pages: false }) },
100
104
  ],
101
105
  };
@@ -29,9 +29,9 @@ const notFoundCode = (feature: NameSet): string =>
29
29
  * The emitted `fix:` cites `x queries list`, and which command it cites is the whole point: a
30
30
  * scaffolded app runs the same `errors` step this repo does, so a fix naming a command the build
31
31
  * does not ship writes a fresh X_ERROR_FIX_INVALID into the app on every `x g action`. It cited
32
- * `x db studio`, which is in `PLANNED_SUBCOMMANDS` and exits X_NOT_IMPLEMENTED — the generator was
33
- * breaking the one rule it exists to demonstrate. `x queries list` ships, and a read is where a
34
- * caller gets an id that exists.
32
+ * `x db studio`, then planned and exiting X_NOT_IMPLEMENTED (it left the registry 2026-11-15) —
33
+ * the generator was breaking the one rule it exists to demonstrate. `x queries list` ships, and a
34
+ * read is where a caller gets an id that exists.
35
35
  */
36
36
  const errorsSource = (feature: NameSet): string => {
37
37
  const errorCode = notFoundCode(feature);
@@ -12,7 +12,7 @@ export const UNTHROWN_CODES_FILE = 'packages/cli/src/unthrown-codes.ts';
12
12
  * `X_ERROR_CODE_UNTHROWN_STALE`.
13
13
  */
14
14
  export const UNTHROWN_CODES: ReadonlySet<string> = new Set([
15
- // `x db studio` is planned and unreleased; it exits X_NOT_IMPLEMENTED.
15
+ // `studio` left `x db` (2026-11-15, wiki/Known-Gaps.md): nothing runs that could fail.
16
16
  'X_DB_STUDIO_FAILED',
17
17
  // 21.0.0: there is no LiveClient to register (X_REALTIME_UNINSTALLED replaced it).
18
18
  'X_LIVE_CLIENT_MISSING',
@@ -15,7 +15,7 @@ import { rebaselineCoverage, statedCoverage } from './upgrade-coverage';
15
15
  import { documentIn } from './upgrade-document';
16
16
  import type { HopExerciseFloor } from './upgrade-exercise-floor';
17
17
  import { ratchetExerciseFloor } from './upgrade-exercise-floor';
18
- import type { WithheldGuard } from './upgrade-guards';
18
+ import type { BaselinedGuard, WithheldGuard } from './upgrade-guards';
19
19
  import { installMissingGuards } from './upgrade-guards';
20
20
  import { parseJson } from './upgrade-registry';
21
21
 
@@ -101,6 +101,11 @@ export interface HopGuards {
101
101
  readonly installed: readonly string[];
102
102
  /** Not written, with how many findings each would have added (`upgrade-guards.ts`). */
103
103
  readonly withheld: readonly WithheldGuard[];
104
+ /**
105
+ * Also in `installed`: kept at its measured count, `guardBaseline` in `x.verify.json`. Absent
106
+ * when none, so `--json` of a hop that baselined nothing is unchanged.
107
+ */
108
+ readonly baselined?: readonly BaselinedGuard[];
104
109
  }
105
110
 
106
111
  /**
@@ -0,0 +1,43 @@
1
+ // A withheld guard's measured count, merged into `x.verify.json` as `guardBaseline` so the hop can
2
+ // keep it on disk at that count (`verify-guard-baseline.ts` judges it). The app's own keys are never
3
+ // touched: a baseline it already wrote for that guard, or a file that is not a JSON object, refuses.
4
+
5
+ // why: Bun exposes no path-join primitive; `x.verify.json` sits at the app root.
6
+ import { join } from 'node:path';
7
+ import { parseJson } from './upgrade-registry';
8
+ import { VERIFY_FLOOR_FILE } from './verify-floor';
9
+ import { GUARD_BASELINE_FIELD } from './verify-guard-baseline';
10
+
11
+ /** The floor's bytes before the write, or null when there was no file: what a rollback restores. */
12
+ export type FloorPrior = string | null;
13
+
14
+ const isRecord = (value: unknown): value is Record<string, unknown> =>
15
+ typeof value === 'object' && value !== null && !Array.isArray(value);
16
+
17
+ /**
18
+ * Writes `guardBaseline[name] = findings`; the prior bytes, or undefined when it refused. No file
19
+ * is a floor requiring no step, so the one written changes nothing but the baseline.
20
+ */
21
+ export async function writeGuardBaseline(
22
+ root: string,
23
+ name: string,
24
+ findings: number,
25
+ ): Promise<{ readonly prior: FloorPrior } | undefined> {
26
+ const file = Bun.file(join(root, VERIFY_FLOOR_FILE));
27
+ const prior = (await file.exists()) ? await file.text() : null;
28
+ const payload = prior === null ? { steps: [] } : parseJson(prior);
29
+ if (!isRecord(payload)) return undefined;
30
+ const current = payload[GUARD_BASELINE_FIELD];
31
+ if (current !== undefined && !isRecord(current)) return undefined;
32
+ if (current !== undefined && Object.hasOwn(current, name)) return undefined;
33
+ const next = { ...payload, [GUARD_BASELINE_FIELD]: { ...(current ?? {}), [name]: findings } };
34
+ await Bun.write(file, `${JSON.stringify(next, null, 2)}\n`);
35
+ return { prior };
36
+ }
37
+
38
+ /** Puts the floor back as it was: rewritten, or deleted when the write created it. */
39
+ export async function restoreFloor(root: string, prior: FloorPrior): Promise<void> {
40
+ const file = Bun.file(join(root, VERIFY_FLOOR_FILE));
41
+ if (prior !== null) await Bun.write(file, prior);
42
+ else if (await file.exists()) await file.delete();
43
+ }
@@ -9,6 +9,7 @@ import { MANIFEST_FILENAME } from '@ultimat3/manifest';
9
9
  import { t } from '@ultimat3/schema';
10
10
  import type { ExecResult } from './exec';
11
11
  import { documentIn } from './upgrade-document';
12
+ import { restoreFloor, writeGuardBaseline } from './upgrade-guards-baseline';
12
13
 
13
14
  const GENERATED = t.object({
14
15
  data: t.optional(t.object({ files: t.optional(t.array(t.string)) })),
@@ -28,9 +29,20 @@ export interface WithheldGuard {
28
29
  readonly findings: number | null;
29
30
  }
30
31
 
32
+ /** A guard the tree breaks, installed anyway at its measured count (`guardBaseline`). */
33
+ export interface BaselinedGuard {
34
+ readonly name: string;
35
+ readonly findings: number;
36
+ }
37
+
31
38
  export interface GuardInstall {
32
39
  readonly installed: readonly string[];
33
40
  readonly withheld: readonly WithheldGuard[];
41
+ /**
42
+ * Also in `installed`: kept because `x.verify.json` now holds it at this many findings. Absent
43
+ * when none, so a hop that baselined nothing reports exactly what it always did.
44
+ */
45
+ readonly baselined?: readonly BaselinedGuard[];
34
46
  }
35
47
 
36
48
  /** Runs the installed CLI with these arguments in the app root. */
@@ -122,7 +134,9 @@ export async function installMissingGuards(input: {
122
134
  findings: null,
123
135
  });
124
136
  const base = await boundariesCount(cli);
125
- if (base === undefined) return { installed: [], withheld: missing.map(unmeasured) };
137
+ if (base === undefined) {
138
+ return { installed: [], withheld: missing.map(unmeasured) };
139
+ }
126
140
 
127
141
  const written = new Map<string, Generated>();
128
142
  const withheld: WithheldGuard[] = [];
@@ -140,6 +154,7 @@ export async function installMissingGuards(input: {
140
154
  // Newest first, so each artifact ends at the bytes it held before the first run.
141
155
  for (const run of [...written.values()].reverse()) await rollback(root, run);
142
156
  const installed: string[] = [];
157
+ const baselined: BaselinedGuard[] = [];
143
158
  let held = base;
144
159
  for (const guard of missing.filter(({ name }) => written.has(name))) {
145
160
  const run = await generate(cli, root, guard.name);
@@ -149,10 +164,30 @@ export async function installMissingGuards(input: {
149
164
  held = count;
150
165
  continue;
151
166
  }
167
+ // Measured and over: held at its own count, kept only if this CLI's `boundaries` then finds
168
+ // no more than before — a release that ignores `guardBaseline` leaves it withheld, as it was.
169
+ if (run !== undefined && count !== undefined) {
170
+ const findings = count - held;
171
+ const floor = await writeGuardBaseline(root, guard.name, findings);
172
+ if (floor !== undefined) {
173
+ const recount = await boundariesCount(cli);
174
+ if (recount !== undefined && recount <= held) {
175
+ installed.push(guard.name);
176
+ baselined.push({ name: guard.name, findings });
177
+ held = recount;
178
+ continue;
179
+ }
180
+ await restoreFloor(root, floor.prior);
181
+ }
182
+ }
152
183
  await rollback(root, run);
153
184
  withheld.push({ ...guard, findings: count === undefined ? null : count - held });
154
185
  }
155
- return { installed, withheld: sortByName(withheld) };
186
+ return {
187
+ installed,
188
+ withheld: sortByName(withheld),
189
+ ...(baselined.length === 0 ? {} : { baselined }),
190
+ };
156
191
  }
157
192
 
158
193
  const sortByName = (list: readonly WithheldGuard[]): readonly WithheldGuard[] =>
@@ -89,6 +89,9 @@ export const humanLines = (input: {
89
89
  ? [msg(agentsMd === 'link' ? 'cli.upgrade.agentsMd.link' : 'cli.upgrade.agentsMd.differs')]
90
90
  : []),
91
91
  ...(gate?.guards.installed ?? []).map((name) => msg('cli.upgrade.guardInstalled', { name })),
92
+ ...(gate?.guards.baselined ?? []).map((guard) =>
93
+ msg('cli.upgrade.guardBaselined', { name: guard.name, count: guard.findings }),
94
+ ),
92
95
  ...(gate?.guards.withheld ?? []).map((guard) =>
93
96
  guard.findings === null
94
97
  ? msg('cli.upgrade.guardUnmeasured', { fix: guard.add })