@ultimat3/cli 30.9.0 → 31.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.
Files changed (197) hide show
  1. package/CLAUDE.md +75 -64
  2. package/README.md +4 -1
  3. package/package.json +30 -29
  4. package/src/admin-registration.ts +1 -1
  5. package/src/affected.ts +5 -1
  6. package/src/app-boundaries.ts +88 -9
  7. package/src/app-load-async.ts +133 -0
  8. package/src/app-load-batch.ts +203 -0
  9. package/src/app-load-prebuilt.ts +147 -0
  10. package/src/app-load-register.ts +175 -0
  11. package/src/app-load.ts +143 -175
  12. package/src/app-loader-imports.ts +31 -0
  13. package/src/app-root.ts +13 -0
  14. package/src/app-runtime.ts +5 -1
  15. package/src/boundary-findings.ts +12 -0
  16. package/src/browser-launcher-port.ts +3 -7
  17. package/src/browser-launcher.ts +1 -1
  18. package/src/budgets-scan.ts +8 -0
  19. package/src/budgets.ts +10 -1
  20. package/src/build-registry-background.ts +59 -0
  21. package/src/build-registry.ts +207 -0
  22. package/src/cdp-shot-clock.ts +3 -11
  23. package/src/cdp-shot-driver.ts +3 -2
  24. package/src/cdp-shot-element.ts +3 -2
  25. package/src/cdp-shot-page.ts +2 -2
  26. package/src/cdp-shot-watch.ts +4 -3
  27. package/src/cmd-auth.ts +3 -3
  28. package/src/cmd-db-recount.ts +15 -0
  29. package/src/cmd-drill.ts +10 -6
  30. package/src/cmd-exercise.ts +2 -1
  31. package/src/cmd-generate-spec.ts +6 -0
  32. package/src/cmd-generate.ts +22 -4
  33. package/src/cmd-mail.ts +1 -1
  34. package/src/cmd-routes.ts +2 -2
  35. package/src/cmd-secrets-spec.ts +4 -1
  36. package/src/cmd-shot.ts +14 -4
  37. package/src/cmd-verify-spec.ts +21 -1
  38. package/src/cmd-verify.ts +16 -4
  39. package/src/coverage-source.ts +4 -1
  40. package/src/db-diagnostics.ts +8 -1
  41. package/src/dev-boot.ts +29 -15
  42. package/src/dev-dashboard-invalidations.ts +43 -0
  43. package/src/dev-dashboard.ts +13 -16
  44. package/src/dev-n-plus-one.ts +7 -3
  45. package/src/dev-rebuild.ts +2 -1
  46. package/src/dev-route-table.ts +1 -1
  47. package/src/dev-traces.ts +16 -15
  48. package/src/document-options.ts +12 -1
  49. package/src/drift-store.ts +55 -0
  50. package/src/error-catalog.ts +8 -3
  51. package/src/error-codes-boundary.ts +32 -0
  52. package/src/error-codes.ts +23 -19
  53. package/src/errors.ts +17 -7
  54. package/src/exercise-database.ts +13 -1
  55. package/src/exercise-findings.ts +36 -18
  56. package/src/exercise-services.ts +84 -0
  57. package/src/exercise-subject.ts +38 -13
  58. package/src/failure-capture-boot.ts +9 -5
  59. package/src/framework-schema.ts +5 -5
  60. package/src/generate-exercise.ts +1 -1
  61. package/src/generate-files.ts +27 -7
  62. package/src/generate-kinds.ts +5 -0
  63. package/src/generate-refresh.ts +53 -0
  64. package/src/generate-workspace.ts +169 -0
  65. package/src/generate-write.ts +8 -2
  66. package/src/hold.ts +19 -8
  67. package/src/image-prepare.ts +6 -2
  68. package/src/index.ts +5 -20
  69. package/src/island-bundle.ts +7 -3
  70. package/src/island-capture.ts +2 -2
  71. package/src/island-harness.ts +1 -1
  72. package/src/job-registration.ts +43 -6
  73. package/src/jobs-driver.ts +4 -5
  74. package/src/mcp-errors.ts +18 -4
  75. package/src/mcp-host.ts +5 -1
  76. package/src/mcp-ui-interact.ts +3 -0
  77. package/src/messages-gate.ts +4 -0
  78. package/src/new-shapes-generate.ts +1 -1
  79. package/src/otlp-export.ts +94 -29
  80. package/src/output.ts +3 -7
  81. package/src/page-sync.ts +3 -1
  82. package/src/role-load.ts +17 -11
  83. package/src/role-start.ts +5 -4
  84. package/src/role-sync.ts +7 -8
  85. package/src/route-islands-preload.ts +46 -0
  86. package/src/route-islands.ts +6 -2
  87. package/src/runtime-admin.ts +5 -1
  88. package/src/runtime-bindings.ts +25 -19
  89. package/src/runtime-boot-ports.ts +66 -0
  90. package/src/runtime-bus.ts +29 -5
  91. package/src/runtime-cache-bus.ts +53 -0
  92. package/src/runtime-cache.ts +43 -13
  93. package/src/runtime-isr-outcome.ts +5 -4
  94. package/src/runtime-jobs.ts +2 -2
  95. package/src/runtime-keys.ts +37 -0
  96. package/src/runtime-overrides.ts +148 -42
  97. package/src/runtime-port-bindings-queue.ts +36 -0
  98. package/src/runtime-port-bindings.ts +117 -0
  99. package/src/runtime-ports.ts +164 -0
  100. package/src/runtime-purge.ts +41 -28
  101. package/src/runtime-push.ts +7 -3
  102. package/src/runtime-queue.ts +70 -55
  103. package/src/runtime-realtime.ts +5 -5
  104. package/src/runtime-render-document.ts +4 -1
  105. package/src/runtime-services.ts +110 -158
  106. package/src/runtime-storage-boot.ts +111 -0
  107. package/src/runtime-storage-upload.ts +9 -7
  108. package/src/runtime-storage.ts +7 -1
  109. package/src/serve-boot.ts +8 -4
  110. package/src/serve-entry.ts +3 -0
  111. package/src/serve-env.ts +47 -14
  112. package/src/serve-prebuilt-paths.ts +3 -0
  113. package/src/serve-prebuilt.ts +15 -4
  114. package/src/serve.ts +2 -2
  115. package/src/static-cards.ts +3 -2
  116. package/src/static-report.ts +2 -2
  117. package/src/style-bundle.ts +1 -1
  118. package/src/sync-authenticator.ts +17 -18
  119. package/src/templates/action-tests.ts +4 -4
  120. package/src/templates/backfill.ts +5 -8
  121. package/src/templates/entity.ts +3 -0
  122. package/src/templates/github/ci.yml.ts +3 -1
  123. package/src/templates/github/dependabot.yml.ts +73 -0
  124. package/src/templates/job.ts +13 -22
  125. package/src/templates/naming.ts +20 -1
  126. package/src/templates/pinned/docker-compose.yml +1 -1
  127. package/src/templates/query.ts +7 -8
  128. package/src/templates/route.ts +5 -3
  129. package/src/templates/scaffold-api.ts +1 -1
  130. package/src/templates/scaffold-auth.ts +5 -3
  131. package/src/templates/scaffold-claude-commands.ts +6 -3
  132. package/src/templates/scaffold-claude.ts +4 -4
  133. package/src/templates/scaffold-container-compose.ts +2 -4
  134. package/src/templates/scaffold-domain-package.ts +1 -1
  135. package/src/templates/scaffold-entries.ts +6 -1
  136. package/src/templates/scaffold-helm-fences.ts +3 -2
  137. package/src/templates/scaffold-helm.ts +35 -6
  138. package/src/templates/scaffold-repo.ts +47 -135
  139. package/src/templates/scaffold-runtime-ports.ts +62 -0
  140. package/src/templates/scaffold-verify-floor.ts +97 -0
  141. package/src/templates/shapes/overlay.ts +1 -1
  142. package/src/templates/sign-in-oidc.ts +5 -3
  143. package/src/templates/sign-in-shared.ts +28 -10
  144. package/src/templates/workspace.ts +75 -0
  145. package/src/test-ignores.ts +5 -2
  146. package/src/test-select.ts +4 -1
  147. package/src/upgrade-gate.ts +30 -5
  148. package/src/upgrade-report.ts +7 -1
  149. package/src/verify-changed-facts.ts +53 -0
  150. package/src/verify-changed-scope.ts +161 -0
  151. package/src/verify-changed.ts +174 -0
  152. package/src/verify-checks.ts +31 -19
  153. package/src/verify-drift-owner.ts +30 -0
  154. package/src/verify-e2e.ts +2 -1
  155. package/src/verify-factories.ts +86 -0
  156. package/src/verify-run.ts +13 -11
  157. package/src/verify-step.ts +13 -0
  158. package/src/verify-tests.ts +58 -6
  159. package/src/write-line.ts +21 -6
  160. package/wiki/Actions.md +2 -2
  161. package/wiki/Adapters.md +400 -0
  162. package/wiki/Admin-Dashboard.md +1 -1
  163. package/wiki/Agents.md +9 -9
  164. package/wiki/Auth.md +78 -2
  165. package/wiki/Building-Your-Own-Base.md +1 -1
  166. package/wiki/CLI-Reference.md +34 -7
  167. package/wiki/Caching-And-Invalidation.md +17 -5
  168. package/wiki/Compared.md +8 -2
  169. package/wiki/Configuration.md +14 -14
  170. package/wiki/Deployment.md +28 -1
  171. package/wiki/Entities-And-Migrations.md +47 -1
  172. package/wiki/FAQ.md +8 -2
  173. package/wiki/Feature-Flags.md +1 -1
  174. package/wiki/Home.md +3 -2
  175. package/wiki/Jobs-And-Workflows.md +107 -6
  176. package/wiki/Known-Gaps.md +4 -3
  177. package/wiki/MCP-And-AI.md +18 -4
  178. package/wiki/Mail.md +14 -5
  179. package/wiki/Migrations-And-Backfills.md +29 -4
  180. package/wiki/Money.md +2 -0
  181. package/wiki/N-Plus-One-Detection.md +24 -22
  182. package/wiki/Notify.md +28 -4
  183. package/wiki/Observability.md +121 -15
  184. package/wiki/Queries-And-Live-Queries.md +2 -2
  185. package/wiki/Realtime.md +9 -4
  186. package/wiki/Routes-And-Render-Modes.md +5 -0
  187. package/wiki/Scraping.md +57 -11
  188. package/wiki/Shapes.md +2 -2
  189. package/wiki/Stability.md +7 -5
  190. package/wiki/Storage-And-Uploads.md +56 -4
  191. package/wiki/Testing.md +65 -52
  192. package/wiki/Troubleshooting.md +1 -1
  193. package/wiki/Tutorial-01-First-App.md +1 -1
  194. package/wiki/Tutorial-04-Jobs-And-Realtime.md +1 -1
  195. package/wiki/Tutorial-05-Deploy-Free.md +1 -1
  196. package/wiki/Tutorial-06-Growing-Up.md +8 -8
  197. package/wiki/Upgrading.md +129 -4
package/CLAUDE.md CHANGED
@@ -1,19 +1,21 @@
1
1
  # @ultimat3/cli — boundary
2
2
 
3
3
  Tier 5. May import tiers 0–4. Declared sideways edges: `cli → admin` (`x dev` mounts the `/_x`
4
- dashboard), `cli → testing` (islands, the e2e step, `x shot`'s `launchChrome`). Nothing imports
4
+ dashboard), `cli → testing` (islands, the e2e step); `x shot` launches via `@ultimat3/scraping/cdp`. Nothing imports
5
5
  this except `create-ultimate`. The reasoning behind every rule below, verbatim and dated, is
6
- [`docs/history/cli.md`](../../docs/history/cli.md); where the two disagree this file wins.
6
+ [`docs/history/cli.md`](../../docs/history/cli.md) (`‡` marks a row whose rule is there); `†` marks a
7
+ row whose full text is in [`docs/history/cli-file-map.md`](../../docs/history/cli-file-map.md).
8
+ Where they disagree this file wins.
7
9
 
8
- Commands: `bun test packages/cli` (from the repo root: the preload),
10
+ Commands: `bun test ./packages/cli/` (repo root: the preload),
9
11
  `bunx tsc --noEmit -p packages/cli/tsconfig.json`.
10
12
 
11
13
  ## Rules
12
14
 
13
15
  | Rule | Detail |
14
16
  |---|---|
15
- | Entry | `src/bin.ts` — argv, stdout, exit code only. Full rule: `docs/history/cli.md` |
16
- | Registry | `registry.ts`: every declaration static (`cmd-<name>-spec.ts`), every body `await import()`ed when that command runs. Full rule: `docs/history/cli.md` |
17
+ | Entry | `src/bin.ts` — argv, stdout, exit code only ‡ |
18
+ | Registry | `registry.ts`: every declaration static (`cmd-<name>-spec.ts`), every body `await import()`ed when that command runs ‡ |
17
19
  | Startup cost | `sass` loads on the first stylesheet compile (`@ultimat3/render`'s `compileStylesheet`), Babel on the first island transform (`solid-loader.ts`); both pinned by `*-lazy.test.ts` in a child process |
18
20
  | Module names | `role-*` / `runtime-*` are booted by `serve.ts` in production; `dev-*` is `x dev`'s alone. Derived from the import graph by `module-naming.test.ts`, never listed |
19
21
  | stdout / stderr | `write-line.ts`'s `writeLine` / `writeErrorLine` — synchronous fd writes, never `process.stdout.write` (truncates at the pipe buffer before `process.exit`). A `CommandResult` with `stream: 'stderr'` goes to fd 2 (`x mcp serve --transport stdio`) |
@@ -32,9 +34,9 @@ Commands: `bun test packages/cli` (from the repo root: the preload),
32
34
  | Errors | codes + titles in `error-codes.ts`, a runnable line per code in `mcp-errors.ts` (typed over `CliErrorCode`), classes in `errors.ts` or beside their one thrower when `errors.ts` is at its ceiling. Never a bare `Error` |
33
35
  | Subprocesses | only through `exec.ts`'s injectable `Runner`; `gh` through `ctx.runner` with a required `fix` |
34
36
  | Templates | `templates/*.ts` return strings, pre-formatted for Biome (`wrap.ts`'s `wrapList` / `wrapImport` / `sortSpecifiers`); no fixture files on disk |
35
- | Strings | rendered output through `messages.ts` (missing key renders `⟦key⟧`). Full rule: `docs/history/cli.md` |
37
+ | Strings | rendered output through `messages.ts` (missing key renders `⟦key⟧`) ‡ |
36
38
  | Facts | load the app (`app-load.ts`), then project a framework package's registry — never parse source for primitives, never re-derive a fact another package owns |
37
- | Public API | `src/index.ts`, explicit re-exports only. Full rule: `docs/history/cli.md` |
39
+ | Public API | `src/index.ts`, explicit re-exports only ‡ |
38
40
 
39
41
  ## File map
40
42
 
@@ -43,33 +45,37 @@ Commands: `bun test packages/cli` (from the repo root: the preload),
43
45
  | File | Job |
44
46
  |---|---|
45
47
  | `verify-checks.ts` / `verify-step.ts` / `verify-run.ts` / `verify-e2e-lane.ts` | steps, outcome, order (`BESIDE_SERIAL_SUITES`, e2e lane) |
48
+ | `verify-changed*.ts` | `x verify --changed`: file → rule → steps, fail-open; `drift` only when reached † |
49
+ | `verify-drift-owner.ts` | `drift`: an `app.config.ts` under `apps/`/`packages/` is `X_APP_ROOT_NESTED` — one repo, one app, one image, one migration owner |
46
50
  | `verify-exercise.ts` / `cmd-exercise.ts` / `exercise-*.ts` | `exercise`: `x exercise --json` as a child, red on its findings |
47
51
  | `verify-floor.ts` | `x.verify.json`: a floor step that ran zero tests is `X_VERIFY_SUITE_VANISHED` |
48
- | `coverage-floor.ts` / `coverage-lcov.ts` / `coverage-source.ts` / `verify-coverage-run.ts` | an APP's `unit` step holds `coverage` in `x.verify.json` over its whole source tree, in fixed slices, never `--parallel --coverage`; `coverage-lcov.ts` is the ONE lcov reader. Full rule: `docs/history/cli.md` |
49
- | `verify-deadline.ts` / `verify-stalled.ts` / `verify-progress.ts` | a step past its deadline is `X_VERIFY_STEP_TIMEOUT`: its children carry `ULTIMATE_VERIFY_STEP` and are killed by that tag; the finding names the test file `bun test` had not finished. Full rule: `docs/history/cli.md` |
52
+ | `coverage-{floor,lcov,source}.ts` / `verify-coverage-run.ts` | an app's `unit` coverage floor; `coverage-lcov.ts` is the ONE lcov reader † |
53
+ | `verify-deadline.ts` / `verify-stalled.ts` / `verify-progress.ts` | a step past its deadline is `X_VERIFY_STEP_TIMEOUT`; its children are killed by tag † |
50
54
  | `load-findings.ts` | module-load failures are reported once, by `manifest`; other steps point there |
51
- | `boundary-findings.ts` / `app-boundaries.ts` / `boundary-cuts.ts` / `package-boundaries.ts` | `package-boundaries.ts`: `X_BOUNDARY_PACKAGE_TO_APP`, its own read of `packages/`, never `readAppSources`. surface + layer rules; a finding's `fix:` is the concrete cut |
52
- | `app-transport.ts` / `browser-transport.ts` / `transport-calls.ts` / `import-closure.ts` / `server-barrels.ts` | `boundaries`, built in: one browser transport. Never a `guards/` file: an app must not be able to delete it. Full rule: `docs/history/cli.md` |
53
- | `guards.ts` / `guard-sources.ts` | an app's `guards/*.ts`, discovered, run on `boundaries`, held to the error contract; every `check(root, sources)` shares ONE walk, read and Sass compile per file (`GuardSources`) |
54
- | `templates/scaffold-guards.ts` | `SHIPPED` — the one list of the twenty-one shipped guards: `x new` writes all, `x g guard <name>` writes one, `doctor-guards.ts` lists the ones an app lacks (a listing, never a finding). Full rule: `docs/history/cli.md` |
55
+ | `verify-factories.ts` | `unit` lints `<app>/packages/db/factories.ts` (`X_TEST_FACTORY_INVALID`) |
56
+ | `boundary-findings.ts` / `app-boundaries.ts` / `boundary-cuts.ts` / `package-boundaries.ts` | surface + layer rules, `X_BOUNDARY_PACKAGE_TO_APP`; a `fix:` is the concrete cut † |
57
+ | `app-boundaries.ts` (workspaces) | `@<scope>/<app>/<rest>` resolves onto `apps/<app>/<rest>` when that is an app source, so the surface rules hold across app workspaces |
58
+ | `app-transport.ts` / `browser-transport.ts` / `transport-calls.ts` / `import-closure.ts` / `server-barrels.ts` | `boundaries`, built in: one browser transport; never a `guards/` file † |
59
+ | `guards.ts` / `guard-sources.ts` | an app's `guards/*.ts`, run on `boundaries`; ONE shared walk (`GuardSources`) † |
60
+ | `templates/scaffold-guards.ts` | `SHIPPED`, the one list of shipped guards (`x new`, `x g guard`, `doctor-guards.ts`) † |
55
61
  | `error-contract.ts` / `ts-scan.ts` / `fix-scan.ts` / `fix-imports.ts` / `fix-command.ts` / `fix-path.ts` | the `errors` step: every `fix:` names a runnable command, call or existing file |
56
- | `workspace-checks.ts` / `test-only-shipped.ts` / `workspace-graph.ts` / `tsconfig-references.ts` / `publish-closure.ts` | `package-shape`, `filesize`. Full rule: `docs/history/cli.md` |
57
- | `app-permissions.ts` / `permission-grants.ts` / `app-permissions-borrowed.ts` / `app-permissions-site.ts` | `policy`: every permission granted or required is declared and granted (`X_PERMISSION_UNGRANTED`, `X_PERMISSION_BORROWED`). Full rule: `docs/history/cli.md` |
62
+ | `workspace-checks.ts` / `test-only-shipped.ts` / `workspace-graph.ts` / `tsconfig-references.ts` / `publish-closure.ts` | `package-shape`, `filesize` ‡ |
63
+ | `app-permissions*.ts` / `permission-grants.ts` | `policy`: `X_PERMISSION_UNGRANTED`, `X_PERMISSION_BORROWED` † |
58
64
  | `job-registration.ts` | `manifest`: no job or task under a positional `anonymous-*` name (`X_JOB_UNREGISTERED`) |
59
65
  | `unscanned-admin.ts` | `manifest`: a `defineAdmin()` outside the app scan (`apps/*/src/`) is `X_ADMIN_UNSCANNED` |
60
66
  | `tool-gate-names.ts` · `verify-mcp-mount.ts` | `manifest`: a gate on no tool · `expose` and no `POST /mcp` |
61
- | `verify-role-load.ts` / `verify-role-load-probe.ts` | `manifest`: a child imports the app as a worker does, then the rest module by module; a registration only a document-reaching module makes is `X_ROLE_LOAD_INCOMPLETE` with the module and the import the API index lacks |
62
- | `async-pages.ts` / `live-routes.ts` / `budgets.ts` / `budgets-unmeasured.ts` | `budgets` riders: an async `Page` with no `load`, a live read no island imports, bytes per route; an unweighed route's finding names a refused measurement actor and `defineMeasurementActor()` |
63
- | `budgets-freshness.ts` / `verify-budgets-build.ts` | the step builds first when stats are missing, of an old rule, or older than source: `x build --target static --no-preflight --out .x/verify-static` through `ctx.runner` |
64
- | `app-agents-md.ts` / `app-env.ts` / `app-openapi.ts` / `app-manifest.ts` | `manifest` and `contract-diff`. Full rule: `docs/history/cli.md` |
65
- | `schema-drift.ts` / `drift.ts` / `drift-replica-identity.ts` / `db-destructive.ts` / `db-ungeneratable.ts` | `drift`: snapshot vs declarations, the source hash, the header markers. Full rule: `docs/history/cli.md` |
66
- | `db-rolling.ts` / `doctor-rolling.ts` | `drift`'s fifth rail: what the previous release trips over (`X_MIGRATION_ROLLING_UNSAFE`, `@ultimat3/db`'s classifier), for migrations after `rollingSince` in `x.verify.json` (`x new` writes `"0"`). Full rule: `docs/history/cli.md` |
67
- | `schema-dump-drift.ts` | also the dump-vs-newest-snapshot rail, no database (`X_DB_DRIFT`). Full rule: `docs/history/cli.md` |
67
+ | `verify-role-load.ts` / `verify-role-load-probe.ts` | `manifest`: what a worker never registers (`X_ROLE_LOAD_INCOMPLETE`) † |
68
+ | `async-pages.ts` / `live-routes.ts` / `budgets.ts` / `budgets-unmeasured.ts` | `budgets` riders: async `Page` with no `load`, unimported live read, bytes per route, unweighed routes † |
69
+ | `budgets-freshness.ts` / `verify-budgets-build.ts` | stale or missing stats: the step builds first (`x build --target static`) † |
70
+ | `app-agents-md.ts` / `app-env.ts` / `app-openapi.ts` / `app-manifest.ts` | `manifest` and `contract-diff` ‡ |
71
+ | `schema-drift.ts` / `drift.ts` / `drift-replica-identity.ts` / `db-destructive.ts` / `db-ungeneratable.ts` | `drift`: snapshot vs declarations, the source hash, the header markers ‡ |
72
+ | `db-rolling.ts` / `doctor-rolling.ts` | `drift`'s rolling rail (`X_MIGRATION_ROLLING_UNSAFE`) † |
73
+ | `schema-dump-drift.ts` | also the dump-vs-newest-snapshot rail, no database (`X_DB_DRIFT`) ‡ |
68
74
  | `i18n-registration.ts` / `i18n-audit.ts` / `admin-catalog-keys.ts` | `i18n`; a mounted admin's keys are `AdminApp.catalogKeys()`, asked of every app catalog — never re-derived here (`X_CATALOG_MISSING_KEYS`) |
69
75
  | `error-unthrown.ts` / `unthrown-codes.ts` | host check: a registered code nothing throws is listed in `UNTHROWN_CODES` (a row's wording waives nothing); a listed code thrown again is `X_ERROR_CODE_UNTHROWN_STALE` |
70
76
  | `lint-findings.ts` | `lint`: `biome check --reporter=json` as one finding per diagnostic |
71
77
  | `i18n-app-key-shapes.ts` | every shape whose literal is a catalog key; `i18n-app-key-shapes.test.ts` reads `blocks`, so a new block reds until listed |
72
- | `job-budget.ts` | `X_JOB_OUTLASTS_DRAIN`, the `manifest` step: a job's `timeout` against `workerBudgetMs(drain)`, read from the registry after `loadApp`, never from `x.manifest.json`, which carries no `timeoutMs` |
78
+ | `job-budget.ts` | `X_JOB_OUTLASTS_DRAIN` (`manifest`): `timeout` vs `workerBudgetMs(drain)`, from the registry † |
73
79
  | `output-findings.ts` | render layer only: `runnableFix` (`bunx x`, decided by `dispatch.ts`'s `readerFor`) and `collapseFindings`. Throw sites keep `x …` |
74
80
  | `app-load-unresolved.ts` | `X_APP_IMPORT_UNRESOLVED`, read by the scan, `findingFrom` and `x doctor`'s `snapshots` probe |
75
81
  | `fix-truth.test.ts` / `fix-truth-fixture.ts` / `db-fix-truth.job.test.ts` | a printed fix, executed: each row breaks a scaffold, asserts the code and runs the line |
@@ -79,74 +85,79 @@ Commands: `bun test packages/cli` (from the repo root: the preload),
79
85
  | File | Job |
80
86
  |---|---|
81
87
  | `cmd-generate.ts` / `generate-files.ts` / `generate-kinds.ts` / `generate-write.ts` | argv → pure file list → writes (conflict-checked, `merge: 'json'` / `'if-absent'`) |
88
+ | `templates/workspace.ts` | `x g app` / `x g package`: a workspace the root globs and the one tsconfig alias (`@<app>/*` → `packages/*/src`, then `apps/*`) already reach |
82
89
  | `write-generated.ts` | `x new`'s writer: a `link` file is a relative symlink, a copy only on a refusing win32 |
83
90
  | `generate-feature.ts` | a `--feature` naming no slice is `X_FEATURE_UNKNOWN`; nothing invents an entity |
84
- | `generate-shadow.ts` | a name whose type spelling a planned file also uses as a global or local type (`promise`, `row`), or whose camel VALUE a planned file both imports and declares (`x g job job`, TS2440), is `X_CLI_BAD_FLAG`, decided on the planned files |
91
+ | `generate-shadow.ts` | a name that shadows a type or value in a planned file is `X_CLI_BAD_FLAG` † |
85
92
  | `generate-plural.ts` | a planned `entity.ts` in an already-plural slice (`posts` → `postses`) is `X_CLI_BAD_FLAG`; the fix names the singular |
86
- | `generate-catalog-locales.ts` | `--locales` never starts a catalog in an app with any: a missing non-default locale is `X_CLI_BAD_FLAG`, `fix: x i18n add <locale>`; non-default values land `⟦…⟧`-marked (`seedCatalog`) |
93
+ | `generate-catalog-locales.ts` | `--locales` never starts a catalog; missing locale is `X_CLI_BAD_FLAG` † |
87
94
  | `app-name.ts` | `x new`'s slug is asked of core's `defineConfig`, never a copied pattern; refused with a suggested name (`9lives` → `app-9lives`, `a` → `a-app`, cut at 64) |
88
- | `generate-grants.ts` | a written `policy.ts` or `entity.ts` declares and grants its permissions in `apps/web/shared/roles.ts`. Full rule: `docs/history/cli.md` |
95
+ | `generate-grants.ts` | a written `policy.ts` or `entity.ts` declares and grants its permissions in `apps/web/shared/roles.ts` ‡ |
89
96
  | `api-registration.ts` | a written job or task is listed in `apps/web/api/index.ts` |
90
97
  | `generate-exercise.ts` | a contract test's entry in `apps/web/exercise.ts` (`exercise-entry-edit.ts`) |
91
- | `handle-registration.ts` / `workspace-dep-edit.ts` / `templates/scaffold-db-client.ts` | a written entity joins `entities` in `packages/db/src/client.ts` (`X_DB_HANDLE_UNREGISTERED` carries the lines). Full rule: `docs/history/cli.md` |
92
- | `generated-imports.ts` | every sibling workspace a written file imports is declared in the manifest it landed under (`x g admin:page`'s `@<app>/i18n` in `apps/admin`) — `package-shape` would otherwise refuse the generator's own output (`X_WORKSPACE_DEP_UNDECLARED`) |
93
- | `admin-registration.ts` / `templates/admin-catalog.ts` / `source-edit.ts` | `--admin` wires the override it wrote into `admin.ts` (`X_ADMIN_RESOURCE_UNWIRED`) and the labels its screen reads. Full rule: `docs/history/cli.md` |
98
+ | `handle-registration.ts` / `workspace-dep-edit.ts` / `templates/scaffold-db-client.ts` | a written entity joins `entities` (`X_DB_HANDLE_UNREGISTERED`) † |
99
+ | `generated-imports.ts` | a written file's sibling-workspace imports are declared where it landed (`X_WORKSPACE_DEP_UNDECLARED`) † |
100
+ | `admin-registration.ts` / `templates/admin-catalog.ts` / `source-edit.ts` | `--admin` wires its override (`X_ADMIN_RESOURCE_UNWIRED`) † |
94
101
  | `app-artifacts.ts` | `x.manifest.json` + `openapi.json`, written together (`x g`, `x manifest`) |
95
102
  | `templates/` | every emitted file; `scaffold-*.ts` for `x new`, one per generator otherwise. See history |
96
103
  | `generate-feature-required.ts` | `x g query`/`backfill` with no slice holding an `entity.ts` is `X_FEATURE_REQUIRED` |
97
104
  | `generate-sign-in*.ts` | `x g sign-in`: one flag, no name; OIDC swaps only `x new`'s bytes |
98
105
  | `generate-format-written.ts` | the app's Biome over the TypeScript a run created, best effort; `lint` judges |
99
- | `templates/scaffold-mcp-{json,endpoint,admin}.ts` | `.mcp.json` (`bunx @ultimat3/cli mcp serve`, never `bunx x`) and the refusing MCP endpoints. Full rule: `docs/history/cli.md` |
106
+ | `templates/scaffold-mcp-{json,endpoint,admin}.ts` | `.mcp.json` (`bunx @ultimat3/cli mcp serve`, never `bunx x`) and the refusing MCP endpoints ‡ |
100
107
 
101
108
  ### Boot (`x dev`, the container)
102
109
 
103
110
  | File | Job |
104
111
  |---|---|
105
- | `serve.ts` / `serve-boot.ts` / `serve-entry.ts` / `serve-env.ts` | the production entry: roles from `ROLE`, bindings from env, `ROLE=migrate` = `x db migrate`; a module that fails to load stops it (`X_APP_MODULE_LOAD_FAILED`) |
106
- | `role-load.ts` / `document-graph.ts` / `serve-web.ts` | a role imports what it runs: `ROLE_LOADS`, verified against `x.manifest.json` (`X_ROLE_LOAD_INCOMPLETE` imports everything); `serve-web.ts` behind `await import()`. Full rule: `docs/history/cli.md` |
107
- | `module-imports.ts` | the files a module's source imports, resolved once for both graphs: `referenced` (reload) and `evaluated` (document) |
108
- | `cmd-dev.ts` / `dev-boot.ts` / `dev-rebuild.ts` / `dev-route-table.ts` | `x dev`: the command (`cmd-dev.ts`, re-exports `startDev`); the boot — every role in one process, `/_x`, the watcher (`dev-boot.ts`); one save rebuilt as one generation (`dev-rebuild.ts`) |
109
- | `runtime-bindings.ts` | which service each binding points at (embedded or external); events follow `realtime.transport` / `urlEnv` |
112
+ | `serve.ts` / `serve-boot.ts` / `serve-entry.ts` / `serve-env.ts` | the production entry: `ROLE`, env bindings, `ROLE=migrate`; `X_APP_MODULE_LOAD_FAILED` † |
113
+ | `app-load-batch.ts` / `app-load-register.ts` | one hook module per app module, each registered before the next evaluates: serial order kept, top-level await isolated; registration state |
114
+ | `app-load-prebuilt.ts` / `build-registry.ts` / `build-registry-background.ts` | every serving role boots from the prebuilt registry (`node_modules/.cache/ultimate/registry`, `x build`), format 3: the whole app, and the worker/scheduler subset under a stamp; an older format or `X_PREBUILT_REGISTRY_STALE` → scan |
115
+ | `generate-refresh.ts` | `x g` refreshes the manifest only when a written file needs it |
116
+ | `role-load.ts` / `document-graph.ts` / `serve-web.ts` | a role imports what it runs: `ROLE_LOADS` (`X_ROLE_LOAD_INCOMPLETE`) † |
117
+ | `module-imports.ts` | a module's imports, resolved once for both graphs: `referenced` (reload), `evaluated` (document) |
118
+ | `cmd-dev.ts` / `dev-boot.ts` / `dev-rebuild.ts` / `dev-route-table.ts` | `x dev`: every role in one process, `/_x`, the watcher; one save = one generation † |
119
+ | `runtime-bindings.ts` | which service each binding points at (embedded or external); events follow `NATS_URL` |
110
120
  | `runtime-queue.ts` / `runtime-services.ts` / `runtime-bus.ts` | db + queue; every other accessor; the bus |
111
- | `framework-schema-apply.ts` / `framework-schema-stamp.ts` | the framework tables: `ROLE=migrate`, `x dev` and every CLI command APPLY them in one transaction behind `MIGRATION_LOCK_KEY` (`pg_advisory_xact_lock`) with a bounded `lock_timeout`. Full rule: `docs/history/cli.md` |
121
+ | `framework-schema-apply.ts` / `framework-schema-stamp.ts` | the framework tables, applied in one locked transaction † |
112
122
  | `runtime-isr.ts` | the ISR controller both boots serve through, ATTACHED to `invalidateTags` and released on stop (`attachedIsr`); `appRoutes` without one builds and attaches its own |
113
- | `runtime-mfa-warning.ts` / `runtime-idempotency-scope.ts` | boot warnings an operator can act on: unsealed MFA secrets (web role, `x auth seal-mfa`), a per-process idempotency store after the app loaded |
114
- | `app-config-load.ts` | the ONE reader of an app's `app.config.ts`: `loadAppConfig(root)` — the `config` export through core's `defineConfig`, so validated and default-merged; `undefined` with no file; no `config` object is `X_CONFIG_INVALID`. Full rule: `docs/history/cli.md` |
115
- | `theme-brand.ts` | the ONE reader of an app's theme: `export const brand` in `apps/web/shared/theme.ts` (ui's `defineTheme`), inlined after the surface stylesheet with its hash in `style-src`; none → nothing emitted |
116
- | `runtime-jobs.ts` / `runtime-realtime.ts` / `runtime-notify-retention.ts` / `runtime-cache.ts` / `runtime-purge.ts` / `runtime-replica.ts` | `app.config.ts` sections the boot obeys (`*Of(config)` over the one loaded config), and what each wires |
123
+ | `runtime-mfa-warning.ts` / `runtime-idempotency-scope.ts` | boot warnings: unsealed MFA secrets (web role, `x auth seal-mfa`), a per-process idempotency store after the app loaded |
124
+ | `app-config-load.ts` | the ONE reader of `app.config.ts` (`loadAppConfig`) † |
125
+ | `theme-brand.ts` | the ONE reader of an app's theme (`brand` in `apps/web/shared/theme.ts`) † |
126
+ | `runtime-{jobs,realtime,notify-retention,cache,purge,replica}.ts` | the `app.config.ts` sections the boot obeys (`*Of(config)`) † |
127
+ | `runtime-cache-bus.ts` | which bus carries cache/ISR invalidations: transport if it crosses processes, else Redis pub/sub on `REDIS_URL`, else in-process; one `cache.broadcast` boot line † |
117
128
  | `runtime-jobs.ts` (queues) | `jobs.queues` ∪ registered; `WORKER_QUEUES` = the EXACT set, each in that union or `X_WORKER_QUEUE_UNKNOWN`; `-unserved.ts`: what no live worker serves |
118
- | `serve-retire.ts` / `dev-restart-retire.ts` | the worker retire, `stop()` claiming and aborting nothing: SIGUSR2 under `runRole`, and before a supervised `x dev` restart's drain (#677). Full rule: `docs/history/cli.md` |
119
- | `role-start.ts` / `role-start-types.ts` / `role-realtime.ts` / `role-start-devices.ts` | `--role` selection and start/stop for `web`, `sync`, `worker`, `scheduler`; `realtime.enabled: false` drops `sync` and `replicator`; device mounts, swapped per path on save |
129
+ | `serve-retire.ts` / `dev-restart-retire.ts` | the worker retire (SIGUSR2, before an `x dev` restart's drain) † |
130
+ | `role-start*.ts` / `role-realtime.ts` | `--role` selection, start/stop per role, device mounts † |
120
131
  | `role-wake.ts` | the worker's LISTEN session (`@ultimat3/jobs`' `startQueueWake`) — worker role only, only over a client that `canListen` — and `queue_wake_live` |
121
132
  | `role-sync.ts` / `role-replicator.ts` / `runtime-live-feed.ts` | the sync node, the change feed |
122
- | `runtime-render.ts` / `runtime-render-document.ts` / `runtime-isr-outcome.ts` / `route-islands.ts` / `runtime-assets.ts` / `runtime-storage.ts` / `runtime-hooks.ts` / `api-routes.ts` | the HTTP surface: pages, `/icons` + `/media`, `/_storage`, authz, the app's API, bearer mounts and pages' bound `POST`s, mounted by BOTH boots. `isr` and `static` render as nobody. Full rule: `docs/history/cli.md` |
123
- | `client-{errors,vitals}-*.ts` | `clientErrors` (and `.vitals`): the script on `app/` (vitals: listed) documents, its `POST` route, mounted by BOTH boots. Full rule: `docs/history/cli.md` |
124
- | `retained-assets.ts` / `-layout.ts` / `-sweep.ts` / `-read.ts` / `-boot.ts` | `assets.retain`: the web boot publishes this build's hashed files before `/readyz`; `withRetainedAssets` answers an assets 404 a retained manifest names. `x dev` never wraps. Full rule: `docs/history/cli.md` |
125
- | `runtime-overrides.ts` | the one field a host hands the framework a driver through — and `routes`, the plain routes for a wire format no primitive speaks (OAuth token endpoint); a webhook receiver needs no line here |
133
+ | `runtime-render*.ts` / `runtime-{isr-outcome,assets,storage,hooks}.ts` / `route-islands.ts` / `api-routes.ts` | the HTTP surface both boots mount † |
134
+ | `client-{errors,vitals}-*.ts` | `clientErrors` (and `.vitals`): the script on `app/` (vitals: listed) documents, its `POST` route, mounted by BOTH boots ‡ |
135
+ | `retained-assets.ts` / `-layout.ts` / `-sweep.ts` / `-read.ts` / `-boot.ts` | `assets.retain`: the web boot publishes this build's hashed files before `/readyz` † |
136
+ | `runtime-overrides.ts` / `runtime-ports.ts` / `runtime-port-bindings.ts` | `runtime.ts`: a field per `ADAPTER_PORTS` row, installed by ONE loop or read where used; unbound row = build error. Plus `routes`. `docs/history/cli-adapter-ports.md` |
126
137
  | `plain-routes.ts` | the plain routes both boots mount and `x routes` lists: `runtime.routes`, then every declared `webhookReceiver()`'s, each once |
127
138
  | `app-openapi.ts` | `openapi.json` (complete when `defineApi({ openapi })` is declared) and each bearer mount's own document; staleness for all of them |
128
139
  | `script-csp.ts` / `style-csp.ts` / `style-bundle.ts` / `page-sync.ts` / `worker-bundle.ts` | CSP hashes, the CSS file, the page's sync target and worker |
129
140
  | `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 |
130
- | `page-speculation.ts` | Speculation Rules for documents WITHOUT the router (`navigation.speculation`): an allow-list of pure-read pages. Full rule: `docs/history/cli.md` |
131
- | `static-document.ts` | a served `static` page: `304` on a matching `If-None-Match`, and (container only, `memoStatic`) the document kept after its first render. Never `x dev` — a save moves the stylesheet URL the kept document names |
132
- | `island-bundle.ts` / `island-store.ts` / `island-sources.ts` / `island-realtime.ts` / `island-realtime-state.ts` / `island-runtime.ts` / `solid-loader.ts` | islands: one `Bun.build` each, source-addressed; the image build writes a verified store, and an edit since the build is a rebuild, never the old chunk |
141
+ | `page-speculation.ts` | Speculation Rules for documents WITHOUT the router (`navigation.speculation`): an allow-list of pure-read pages ‡ |
142
+ | `static-document.ts` | a served `static` page: `304` on `If-None-Match`; container keeps the document (never `x dev`) † |
143
+ | `island-{bundle,store,sources,runtime}.ts` / `island-realtime*.ts` / `solid-loader.ts` | islands: one `Bun.build` each, source-addressed † |
133
144
  | `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`) |
134
- | `serve-prebuilt.ts` / `serve-prebuilt-paths.ts` | the image's prebuilt store (`node_modules/.cache/ultimate`, never `.x/` — state, tmpfs): every role adopts its compiled stylesheets before importing the app; a boot that built an island or ran Sass logs `X_IMAGE_NOT_PREBUILT` once |
145
+ | `serve-prebuilt.ts` / `serve-prebuilt-paths.ts` | the image's prebuilt store; a boot that built anything logs `X_IMAGE_NOT_PREBUILT` † |
135
146
  | `dev-*.ts` | `x dev` only: dashboard sources, traces, the N+1 ledger, watcher, reload, lock, port |
136
- | `cmd-stop.ts` / `cmd-stop-spec.ts` | `x stop`: the lock's pid only (its recorded start time must match), SIGTERM, then wait for pid gone and lock clear; Windows clears the lock (`drained: false`); `X_DEV_STOP_TIMEOUT` |
137
- | `dev-dashboard-guard.ts` / `loopback-host.ts` | `/_x` answers a loopback `Host` only (`X_DEV_HOST_REFUSED`, 421 — DNS rebinding); the SQL panel runs on a same-origin `POST /_x/db` only, through admin's `readOnlySql` |
138
- | `doctor-pooler.ts` / `runtime-statement-bound.ts` | the applied bound on demand (`data.statementBound`), a pooler's refusal as the one database finding; the one boot line, total. `startDb` hands `poolerFromEnv(env)` to both pools |
147
+ | `cmd-stop.ts` / `cmd-stop-spec.ts` | `x stop`: the lock's pid only, SIGTERM, wait; `X_DEV_STOP_TIMEOUT` † |
148
+ | `dev-dashboard-guard.ts` / `loopback-host.ts` | `/_x` loopback `Host` only (`X_DEV_HOST_REFUSED`, 421) † |
149
+ | `doctor-pooler.ts` / `runtime-statement-bound.ts` | the statement bound and a pooler's refusal, one finding, one boot line † |
139
150
 
140
151
  ### Build and data
141
152
 
142
153
  | File | Job |
143
154
  |---|---|
144
- | `cmd-build.ts` / `image-prepare.ts` | `x build`: static gate first; `docker` stamps `BUILD_ID`; `prebuilt` is the Dockerfile's own `RUN` — islands and stylesheets, written by the image's Bun at the image's paths, no gate and no subprocess |
145
- | `prerender.ts` / `measure-scope.ts` / `static-report.ts` / `static-*.ts` | the static export; a weigh-only render runs as core's `measurementActor()`, API in process (`withInProcessFetch`); SEO reads as nobody; `/_img/` + `/_og/` files; `--no-capture` the gate's |
155
+ | `cmd-build.ts` / `image-prepare.ts` | `x build`: static gate first; `prebuilt` is the Dockerfile's own `RUN` † |
156
+ | `prerender.ts` / `measure-scope.ts` / `static-report.ts` / `static-*.ts` | the static export; weigh-only renders as `measurementActor()` † |
146
157
  | `sw-artifacts.ts` / `pwa-artifacts.ts` / `favicon.ts` | the service worker, the web manifest, `/favicon.ico` |
147
- | `cmd-db.ts` / `migrations.ts` / `db-generate.ts` / `db-branch.ts` / `db-seed.ts` / `db-seed-generate.ts` / `db-backfill.ts` / `db-subscribes.ts` / `db-accept-created.ts` | one migration engine for `x db` and `ROLE=migrate` |
148
- | `db-diagnostics.ts` | `x db diagnostics`: `startDb` (never `startQueue`, which applies the framework tables), `@ultimat3/db/diagnostics`'s `dbDiagnostics`, one table per section; exit 0 whatever it says; an embedded database `x dev` holds is `X_DEV_ALREADY_RUNNING` |
149
- | `db-schema-dump.ts` / `db-schema-refresh.ts` / `db-replay-engine.ts` / `migration-extensions.ts` / `db-object-drift.ts` | the schema dump: replay on a scratch database (full rule: history), written by `x db gen` and `x db migrate`. `migration-extensions.ts` is also what `runtime-queue.ts` links `x dev`'s database with |
158
+ | `cmd-db.ts` / `migrations.ts` / `db-*.ts` (generate, branch, seed, backfill, subscribes, accept-created) | one migration engine for `x db` and `ROLE=migrate` † |
159
+ | `db-diagnostics.ts` | `x db diagnostics`: `startDb`, never `startQueue`; exit 0 whatever it says † |
160
+ | `db-schema-dump.ts` / `db-schema-refresh.ts` / `db-replay-engine.ts` / `migration-extensions.ts` / `db-object-drift.ts` | the schema dump, replayed on a scratch database † |
150
161
 
151
162
  ### Introspection and tools
152
163
 
@@ -154,14 +165,14 @@ Commands: `bun test packages/cli` (from the repo root: the preload),
154
165
  |---|---|
155
166
  | `cmd-registries.ts` / `cmd-jobs.ts` / `cmd-tasks.ts` / `cmd-policy.ts` / `cmd-i18n.ts` | project a framework registry; each pairs CLI wiring with a facts module |
156
167
  | `cmd-auth.ts` / `cmd-auth-spec.ts` / `doctor-auth.ts` | `x auth seal-mfa`: seals plaintext `x_users.mfa_secret` through auth's `sealMfaSecrets` |
157
- | `cmd-mcp.ts` / `mcp-host.ts` / `mcp-errors.ts` / `mcp-db-target.ts` | `x mcp serve`: 19 tools, two transports; a taken port is `X_PORT_IN_USE`; over HTTP a non-loopback Host is 421 `X_MCP_HOST_REFUSED` first, `GET`/`DELETE` http's 405. `mcp-test-run.ts` folds `bun test`'s `N errors` line and exit code into `tests.run` |
168
+ | `cmd-mcp.ts` / `mcp-host.ts` / `mcp-errors.ts` / `mcp-db-target.ts` | `x mcp serve`: 19 tools, two transports † |
158
169
  | `cmd-shot*.ts` / `cdp-shot-*.ts` / `browser-launcher*.ts` / `island-*` | `x shot` over raw CDP; `verdict.json` names its own blind spots. Not a gate step |
159
- | `cmd-pr.ts` / `cmd-ci.ts` / `ci-runs.ts` / `ci-tested.ts` | GitHub through `gh`, parsed against a schema. Not gate steps. `x ci tested` is a pure predicate over three injected reads; every doubt is `tested: false`, exit 0 |
170
+ | `cmd-pr.ts` / `cmd-ci.ts` / `ci-runs.ts` / `ci-tested.ts` | GitHub through `gh`, schema-parsed; not gate steps † |
160
171
  | `error-catalog.ts` | imports every `@ultimat3/*` package so `x errors` answers for any code |
161
- | `cmd-docs.ts` / `docs-sources.ts` / `docs-section.ts` | `x docs`: the app's `@ultimat3` scope plus the CLI's own (Bun's isolated layout), the wiki at `<cli>/wiki` (tarball) or `<cli>/../../wiki` (checkout); `Page#anchor` prints a whole section |
162
- | `cmd-env-init.ts` / `env-production.ts` / `cmd-deploy-preflight.ts` | `x env init --production`, the one writer of `.env.production` (values from `cmd-deploy-compose.ts`); compose's pre-flight (`X_DEPLOY_ENV_MISSING`) and a failed step's container line |
163
- | `cmd-upgrade.ts` / `upgrade-*.ts` | `x upgrade`: one major per run; declares no `requiresApp` (`upgrade-root.ts`), and with no app runs the root's `typecheck`/`test` scripts and says so in `data.proof`; `upgrade-agents-link.ts`: `data.agentsMd` |
164
- | `cmd-deploy-verify.ts` / `deploy-verify-*.ts` | `x deploy verify`: the wait (samples, window, queues), the pure verdict, flags refused before a sample, the `--json` shape, the real sources (lazy, so the build verdict loads neither). `DATABASE_URL` from the env only, never `resolveServices` (full rule: history) |
172
+ | `cmd-docs.ts` / `docs-sources.ts` / `docs-section.ts` | `x docs`: the app's and the CLI's `@ultimat3` docs; `Page#anchor` prints a section † |
173
+ | `cmd-env-init.ts` / `env-production.ts` / `cmd-deploy-preflight.ts` | the one writer of `.env.production`; compose pre-flight (`X_DEPLOY_ENV_MISSING`) † |
174
+ | `cmd-upgrade.ts` / `upgrade-*.ts` | `x upgrade`: one major per run; no `requiresApp` † |
175
+ | `cmd-deploy-verify.ts` / `deploy-verify-*.ts` | `x deploy verify`: the wait, the pure verdict, lazy real sources † |
165
176
 
166
177
  ## Adding a command
167
178
 
package/README.md CHANGED
@@ -192,6 +192,8 @@ that name where there is one (`x new` writes all twenty), the blank template oth
192
192
  | `app-load.ts` | import an app's modules so the framework registries hold it |
193
193
  | `app-mcp.ts` | the app's own MCP endpoint: `apps/<app>/mcp.ts` exports `mcp`, and both boots mount `POST` at each endpoint's own `defineAppMcp({ path })` through this one call |
194
194
  | `app-runtime.ts` | the app's `RuntimeOverrides`: `apps/<app>/runtime.ts` exports `runtime`, read by `x dev` and by `runRole` when its caller passed none |
195
+ | `runtime-overrides.ts` / `runtime-ports.ts` / `runtime-port-bindings.ts` | one `RuntimeOverrides` field per `ADAPTER_PORTS` row (`PortValues`), and where the boot honours each: installed by ONE loop over the table (`boot` → `queue` → `services` phases), or read as a value where used — every row, as of 31.0 (a future row may stand `pending`, naming the package that owes an installer). A row core adds without a binding is a build error (`PortBindings` is a `Record` over `AdapterPortName`). `import type { RuntimeOverrides } from '@ultimat3/cli/serve'` types an app's `runtime.ts` |
196
+ | `verify-factories.ts` | the `unit` step's factory lint: `<app>/packages/db/factories.ts` exporting `factories` is linted in a child from the app root (`X_TEST_FACTORY_INVALID`, naming the factory and trait); no file, no lint |
195
197
  | `local-cli.ts` | which `x` runs: a global CLI inside an app hands over to the app's own, because a second module instance is an empty registry |
196
198
  | `measurement-actor.ts` | the actor a weigh-and-discard render runs as — every permission, never served |
197
199
  | `runtime-live-feed.ts` | what feeds the sync node this process booted: the in-process row observer under the embedded database, the WAL decoder with a real one, nothing without the role — `live=` on the ready line |
@@ -237,7 +239,8 @@ apps/web/{site,app}/<path>/<name>.island.tsx # x g island <name> --at <dir>
237
239
  apps/admin/app/admin/pages/<name>.tsx # x g admin:page <name> --permission p
238
240
  guards/<name>.ts # x g guard <name>
239
241
  apps/web/app/auth/{sign-in,actions,…} # x g sign-in --password | --oidc <provider>
240
- apps/web/runtime.ts # …and the boot guard it calls
242
+ apps/web/runtime.ts # …and the boot guard it calls (x new writes the
243
+ # port-commented one; replaced only while untouched)
241
244
  docker/helm/templates/{servicemonitor,alert-rules}.yaml # x g chart-alerts [--print]
242
245
  ```
243
246
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultimat3/cli",
3
- "version": "30.9.0",
3
+ "version": "31.0.0",
4
4
  "description": "The `x` binary: new, dev, build, verify, generate, db, mcp, doctor, deploy",
5
5
  "keywords": [
6
6
  "ultimate",
@@ -52,34 +52,35 @@
52
52
  "dev": "bun run src/bin.ts dev"
53
53
  },
54
54
  "dependencies": {
55
- "@babel/core": "^8.0.7",
56
- "@ultimat3/action": "30.9.0",
57
- "@ultimat3/admin": "30.9.0",
58
- "@ultimat3/ai": "30.9.0",
59
- "@ultimat3/auth": "30.9.0",
60
- "@ultimat3/cache": "30.9.0",
61
- "@ultimat3/core": "30.9.0",
62
- "@ultimat3/db": "30.9.0",
63
- "@ultimat3/entity": "30.9.0",
64
- "@ultimat3/flags": "30.9.0",
65
- "@ultimat3/http": "30.9.0",
66
- "@ultimat3/i18n": "30.9.0",
67
- "@ultimat3/jobs": "30.9.0",
68
- "@ultimat3/mail": "30.9.0",
69
- "@ultimat3/manifest": "30.9.0",
70
- "@ultimat3/mcp": "30.9.0",
71
- "@ultimat3/money": "30.9.0",
72
- "@ultimat3/notify": "30.9.0",
73
- "@ultimat3/policy": "30.9.0",
74
- "@ultimat3/pwa": "30.9.0",
75
- "@ultimat3/query": "30.9.0",
76
- "@ultimat3/realtime": "30.9.0",
77
- "@ultimat3/render": "30.9.0",
78
- "@ultimat3/schema": "30.9.0",
79
- "@ultimat3/seo": "30.9.0",
80
- "@ultimat3/storage": "30.9.0",
81
- "@ultimat3/testing": "30.9.0",
82
- "@ultimat3/time": "30.9.0",
55
+ "@babel/core": "^8.0.9",
56
+ "@ultimat3/action": "31.0.0",
57
+ "@ultimat3/admin": "31.0.0",
58
+ "@ultimat3/ai": "31.0.0",
59
+ "@ultimat3/auth": "31.0.0",
60
+ "@ultimat3/cache": "31.0.0",
61
+ "@ultimat3/core": "31.0.0",
62
+ "@ultimat3/db": "31.0.0",
63
+ "@ultimat3/entity": "31.0.0",
64
+ "@ultimat3/flags": "31.0.0",
65
+ "@ultimat3/http": "31.0.0",
66
+ "@ultimat3/i18n": "31.0.0",
67
+ "@ultimat3/jobs": "31.0.0",
68
+ "@ultimat3/mail": "31.0.0",
69
+ "@ultimat3/manifest": "31.0.0",
70
+ "@ultimat3/mcp": "31.0.0",
71
+ "@ultimat3/money": "31.0.0",
72
+ "@ultimat3/notify": "31.0.0",
73
+ "@ultimat3/policy": "31.0.0",
74
+ "@ultimat3/pwa": "31.0.0",
75
+ "@ultimat3/query": "31.0.0",
76
+ "@ultimat3/realtime": "31.0.0",
77
+ "@ultimat3/render": "31.0.0",
78
+ "@ultimat3/schema": "31.0.0",
79
+ "@ultimat3/scraping": "31.0.0",
80
+ "@ultimat3/seo": "31.0.0",
81
+ "@ultimat3/storage": "31.0.0",
82
+ "@ultimat3/testing": "31.0.0",
83
+ "@ultimat3/time": "31.0.0",
83
84
  "babel-preset-solid": "^1.9.16"
84
85
  }
85
86
  }
@@ -41,7 +41,7 @@ export const adminResourceUnwiredFinding = (
41
41
  ): Finding => ({
42
42
  code: 'X_ADMIN_RESOURCE_UNWIRED',
43
43
  cause: `${ADMIN_FILE} ${reason}, so the override ${entry.binding} is read by nothing and /admin/${entry.table} keeps its derived defaults`,
44
- fix: `add ${importLine(entry)} and "resources: { ${entry.table}: ${entry.binding} }" to the defineAdmin() call in ${ADMIN_FILE}`,
44
+ fix: `import { ${entry.binding} } from '${entry.specifier}'; # at the top of ${ADMIN_FILE}, then resources: { ${entry.table}: ${entry.binding} } in its defineAdmin() call`,
45
45
  docs: ERROR_DOCS_URL,
46
46
  at: ADMIN_FILE,
47
47
  });
package/src/affected.ts CHANGED
@@ -155,7 +155,11 @@ export function planAffected(
155
155
  * narrows nothing — so a fix line that dropped it would reproduce its own failure, verbatim.
156
156
  */
157
157
  const invocationOf = (command: string): string =>
158
- command === 'affected' ? 'x affected' : `x ${command} --affected`;
158
+ command === 'affected'
159
+ ? 'x affected'
160
+ : command === 'verify'
161
+ ? 'x verify --changed'
162
+ : `x ${command} --affected`;
159
163
 
160
164
  export interface AffectedSelection {
161
165
  readonly base: string;
@@ -18,9 +18,10 @@
18
18
  import { join as joinPath } from 'node:path';
19
19
  // The POSIX variants resolve specifiers against import-graph keys, which are POSIX on every host.
20
20
  import { dirname, join, normalize, relative } from 'node:path/posix';
21
- import { ERROR_DOCS_URL } from '@ultimat3/core';
22
- import type { BoundaryRule, ImportGraph } from '@ultimat3/render';
23
- import { checkSurfaceBoundary, importGraph, SURFACES } from '@ultimat3/render';
21
+ import { ADAPTER_PORTS, ERROR_DOCS_URL, SURFACES } from '@ultimat3/core';
22
+ import type { BoundaryRule, ImportGraph, ImportRef } from '@ultimat3/render';
23
+ import { checkSurfaceBoundary, importGraph, surfaceOf } from '@ultimat3/render';
24
+ import { loaderImportFindings } from './app-loader-imports';
24
25
  import { commentSafe } from './comment-safe';
25
26
  import { scanRuntimeImports, stripShebang } from './import-scan';
26
27
  import type { Finding } from './output';
@@ -35,6 +36,8 @@ export const BOUNDARY_CODES = [
35
36
  'X_BOUNDARY_ROUTE_TO_DB',
36
37
  'X_BOUNDARY_SERVICE_TO_HTTP',
37
38
  'X_BOUNDARY_SURFACE_IMPORT',
39
+ 'X_BOUNDARY_ADAPTER_IMPORT',
40
+ 'X_BOUNDARY_LOADER_IMPORT',
38
41
  // `package-boundaries.ts`'s: it reads `packages/`, which this module's surface graph never holds.
39
42
  'X_BOUNDARY_PACKAGE_TO_APP',
40
43
  ] as const;
@@ -103,7 +106,7 @@ export function resolveSpecifier(
103
106
  specifier: string,
104
107
  keys: ReadonlySet<string>,
105
108
  ): string {
106
- if (!specifier.startsWith('.')) return specifier;
109
+ if (!specifier.startsWith('.')) return workspaceKey(specifier, keys) ?? specifier;
107
110
  const base = normalize(join(dirname(fromFile), specifier));
108
111
  for (const suffix of CANDIDATE_SUFFIXES) {
109
112
  if (keys.has(`${base}${suffix}`)) return `${base}${suffix}`;
@@ -111,6 +114,21 @@ export function resolveSpecifier(
111
114
  return base;
112
115
  }
113
116
 
117
+ /**
118
+ * `@<scope>/<app>/<rest>` → `apps/<app>/<rest>` when that lands on an app source: the spelling one
119
+ * app workspace reaches another by (`x new`'s root alias `@<app>/*` → `packages/*\/src`, then
120
+ * `apps/*`). Left unresolved, `apps/api/site/` importing `@acme/web/app/…` was an edge to nowhere
121
+ * and `X_BOUNDARY_SITE_TO_APP` never fired. Matched against the graph's own keys — a framework or
122
+ * package specifier lands on none — so a workspace whose package name differs from its directory
123
+ * is the one spelling this cannot see.
124
+ */
125
+ const workspaceKey = (specifier: string, keys: ReadonlySet<string>): string | undefined => {
126
+ const [, app, rest] = /^@[^/]+\/([^/]+)\/(.+)$/.exec(specifier) ?? [];
127
+ if (app === undefined || rest === undefined) return undefined;
128
+ const base = `apps/${app}/${rest}`;
129
+ return CANDIDATE_SUFFIXES.map((suffix) => `${base}${suffix}`).find((key) => keys.has(key));
130
+ };
131
+
114
132
  /**
115
133
  * The specifier `fromFile` must write to reach `target` — `resolveSpecifier` run backwards, and
116
134
  * what every import of a file has to become once that file moves. Extensionless, because that is
@@ -138,9 +156,36 @@ function scan(files: readonly SourceFile[]): readonly ScannedFile[] {
138
156
  }));
139
157
  }
140
158
 
159
+ /** `apps/<ws>/…` → `<ws>`, or `undefined` outside an app workspace. */
160
+ const workspaceOf = (path: string): string | undefined => /^apps\/([^/]+)\//.exec(path)?.[1];
161
+
162
+ /**
163
+ * An `app/` module reaching a SIBLING app's `api/` registry. `app/ → api/` is types-only inside
164
+ * one app because that app's `api/index.ts` imports its own `app/` slices — a value edge back is a
165
+ * cycle. Across workspaces there is none: `apps/admin` projecting `apps/web`'s actions through its
166
+ * `api` is the documented pattern. Such an edge enters the graph as declaration-only, which the
167
+ * table admits for `app` and still refuses for `site` (`SURFACE_SPECS`).
168
+ */
169
+ const isSiblingRegistry = (from: string, to: string): boolean => {
170
+ const own = workspaceOf(from);
171
+ const other = workspaceOf(to);
172
+ return (
173
+ own !== undefined &&
174
+ other !== undefined &&
175
+ own !== other &&
176
+ surfaceOf(from) === 'app' &&
177
+ surfaceOf(to) === 'api'
178
+ );
179
+ };
180
+
141
181
  function graphOf(scanned: readonly ScannedFile[]): ImportGraph {
142
- const record: Record<string, readonly string[]> = {};
143
- for (const file of scanned) record[file.path] = file.imports;
182
+ const record: Record<string, readonly ImportRef[]> = {};
183
+ for (const file of scanned) {
184
+ record[file.path] = file.imports.map((to) => ({
185
+ file: to,
186
+ type: isSiblingRegistry(file.path, to),
187
+ }));
188
+ }
144
189
  return importGraph(record);
145
190
  }
146
191
 
@@ -220,6 +265,21 @@ const routeToDbFix = (path: string, specifier: string): string => {
220
265
  return `x g query ${query} --feature ${quoteArg(slice)} # ${then}`;
221
266
  };
222
267
 
268
+ /** A package's `./adapter` subpath: the installers `runtime.ts` and the boot own, never an app module. */
269
+ const ADAPTER_SUBPATH = /^@ultimat3\/[a-z-]+\/adapter$/;
270
+
271
+ /**
272
+ * The `runtime.ts` field an import of `specifier` stands in for: the port named after its package
273
+ * (`@ultimat3/jobs/adapter` → `jobs`), else that package's first row. A real field, never a
274
+ * placeholder — the fix's runnable half is pasted as it stands.
275
+ */
276
+ const portOf = (specifier: string): string => {
277
+ const pkg = specifier.slice(0, -'/adapter'.length);
278
+ const rows = ADAPTER_PORTS.filter((row) => row.pkg === pkg);
279
+ const named = rows.find((row) => `@ultimat3/${row.port}` === pkg);
280
+ return (named ?? rows[0])?.port ?? 'jobs';
281
+ };
282
+
223
283
  /**
224
284
  * Both fixes are one runnable line, with the rest of the instruction behind a `#` — a fix a
225
285
  * caller has to edit before it runs is prose, and prose is what "errors are instructions" bans.
@@ -228,6 +288,16 @@ function layerFindings(scanned: readonly ScannedFile[]): readonly Finding[] {
228
288
  const findings: Finding[] = [];
229
289
  for (const file of scanned) {
230
290
  for (const specifier of file.imports) {
291
+ // `file.imports` is runtime imports only: `import type { Gateway }` from an adapter is fine.
292
+ if (ADAPTER_SUBPATH.test(specifier)) {
293
+ findings.push({
294
+ code: 'X_BOUNDARY_ADAPTER_IMPORT',
295
+ cause: `an app module imports "${specifier}" at runtime — its installers are the boot's, and one called from here races it (X_RUNTIME_DRIVER_SPLIT)`,
296
+ fix: `export const runtime = { ${quoteArg(portOf(specifier))}: yourDriver } satisfies RuntimeOverrides; # in apps/web/runtime.ts, then delete the import from ${commentSafe(file.path)}`,
297
+ docs: ERROR_DOCS_URL,
298
+ at: file.path,
299
+ });
300
+ }
231
301
  if (isRoute(file.path) && isDbSpecifier(specifier)) {
232
302
  findings.push({
233
303
  code: 'X_BOUNDARY_ROUTE_TO_DB',
@@ -257,7 +327,11 @@ function layerFindings(scanned: readonly ScannedFile[]): readonly Finding[] {
257
327
  */
258
328
  export function checkImportRules(files: readonly SourceFile[]): readonly Finding[] {
259
329
  const scanned = scan(files);
260
- return [...surfaceFindings(graphOf(scanned)), ...layerFindings(scanned)];
330
+ return [
331
+ ...surfaceFindings(graphOf(scanned)),
332
+ ...layerFindings(scanned),
333
+ ...loaderImportFindings(files),
334
+ ];
261
335
  }
262
336
 
263
337
  const APP_GLOBS = ['apps/*/{site,app,api,shared}/**/*.{ts,tsx}'];
@@ -267,12 +341,17 @@ const APP_GLOBS = ['apps/*/{site,app,api,shared}/**/*.{ts,tsx}'];
267
341
  * only I/O in this module, and the one definition of "which files are the app's sources" —
268
342
  * `appBoundaryFindings` reads through this, and so does `x fix boundary`, never a second glob.
269
343
  */
270
- export async function readAppSources(root: string): Promise<readonly SourceFile[]> {
344
+ export async function readAppSources(
345
+ root: string,
346
+ /** `tests`: the same surfaces' `.test.` files instead — read by the loader rule alone. */
347
+ which: 'sources' | 'tests' = 'sources',
348
+ ): Promise<readonly SourceFile[]> {
271
349
  const files: SourceFile[] = [];
272
350
  for (const pattern of APP_GLOBS) {
273
351
  const glob = new Bun.Glob(pattern);
274
352
  for await (const path of glob.scan({ cwd: root, absolute: false })) {
275
- if (hasPathSegment(path, 'node_modules') || path.includes('.test.')) continue;
353
+ if (hasPathSegment(path, 'node_modules')) continue;
354
+ if (path.includes('.test.') !== (which === 'tests')) continue;
276
355
  const posix = toPosix(path);
277
356
  files.push({ path: posix, source: await Bun.file(joinPath(root, posix)).text() });
278
357
  }