@ultimat3/cli 31.26.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.
- package/CLAUDE.md +44 -36
- package/README.md +5 -4
- package/package.json +29 -29
- package/src/app-mcp.ts +17 -3
- package/src/cmd-cache-spec.ts +5 -2
- package/src/cmd-db-spec.ts +2 -3
- package/src/cmd-db.ts +0 -2
- package/src/cmd-deploy-verify-sample.ts +93 -0
- package/src/cmd-deploy-verify.ts +2 -41
- package/src/cmd-dev-spec.ts +15 -1
- package/src/cmd-dev.ts +31 -4
- package/src/cmd-doctor.ts +4 -1
- package/src/cmd-exercise-spec.ts +7 -1
- package/src/cmd-exercise.ts +22 -10
- package/src/cmd-generate.ts +2 -0
- package/src/cmd-jobs-spec.ts +3 -6
- package/src/cmd-jobs.ts +1 -7
- package/src/cmd-logs-spec.ts +2 -1
- package/src/cmd-logs.ts +9 -28
- package/src/cmd-planned.ts +11 -45
- package/src/cmd-profile-frames.ts +99 -0
- package/src/cmd-profile-spec.ts +24 -0
- package/src/cmd-profile.ts +164 -0
- package/src/cmd-status-sample.ts +57 -0
- package/src/cmd-status-spec.ts +30 -0
- package/src/cmd-status.ts +108 -0
- package/src/cmd-token-spec.ts +5 -2
- package/src/cmd-token.ts +7 -3
- package/src/coverage-island.ts +121 -0
- package/src/coverage-lcov.ts +49 -5
- package/src/coverage-remap.ts +146 -0
- package/src/db-replay-engine-prepared.ts +66 -0
- package/src/db-replay-engine-template.ts +156 -0
- package/src/db-replay-engine.ts +4 -0
- package/src/db-replay-scratch-reap.ts +54 -0
- package/src/deploy-verify-flags.ts +9 -2
- package/src/deploy-verify-grade.ts +10 -3
- package/src/dev-boot.ts +14 -1
- package/src/dev-dashboard-guard.ts +57 -10
- package/src/dev-host.ts +46 -0
- package/src/dev-tls-cache.ts +103 -0
- package/src/dev-tls-der.ts +69 -0
- package/src/dev-tls.ts +120 -0
- package/src/doctor-browser.ts +60 -0
- package/src/error-codes-verify.ts +47 -0
- package/src/error-codes.ts +14 -23
- package/src/exercise-database.ts +40 -7
- package/src/exercise-push-device.ts +51 -0
- package/src/exercise-route-api.ts +74 -0
- package/src/exercise-routes.ts +14 -5
- package/src/exercise-services.ts +3 -1
- package/src/exercise-shard-flag.ts +47 -0
- package/src/fix-command.ts +2 -2
- package/src/generate-factories.ts +5 -11
- package/src/generate-feature-required.ts +9 -4
- package/src/generate-files.ts +20 -2
- package/src/generate-kinds.ts +5 -1
- package/src/guards.ts +21 -6
- package/src/island-bundle-options.ts +48 -0
- package/src/island-bundle.ts +18 -46
- package/src/island-link.ts +5 -0
- package/src/island-outputs.ts +5 -0
- package/src/mcp-errors-verify.ts +35 -0
- package/src/mcp-errors.ts +10 -19
- package/src/mcp-host-logs.ts +121 -0
- package/src/mcp-host.ts +12 -73
- package/src/messages-floor.ts +19 -0
- package/src/messages-status.ts +10 -0
- package/src/messages.ts +21 -0
- package/src/registry.ts +4 -0
- package/src/role-start-types.ts +7 -0
- package/src/role-start.ts +4 -0
- package/src/serve-boot.ts +7 -1
- package/src/serve-env-tls.ts +57 -0
- package/src/solid-loader.ts +27 -10
- package/src/templates/generate-export-rows.ts +136 -0
- package/src/templates/generate-import-rows.ts +186 -0
- package/src/templates/generate-rows-slice.ts +95 -0
- package/src/templates/github/ci.yml.ts +4 -0
- package/src/templates/scaffold-db-package.ts +3 -0
- package/src/templates/scaffold-docs.ts +8 -6
- package/src/templates/scaffold-repo.ts +2 -7
- package/src/templates/scaffold-site.ts +4 -1
- package/src/templates/scaffold-suites.ts +72 -0
- package/src/templates/scaffold-test-services.ts +35 -10
- package/src/templates/scaffold-verify-floor.ts +53 -31
- package/src/templates/shapes/api.ts +4 -0
- package/src/templates/slice-foundation.ts +3 -3
- package/src/unthrown-codes.ts +1 -1
- package/src/upgrade-gate.ts +6 -1
- package/src/upgrade-guards-baseline.ts +43 -0
- package/src/upgrade-guards.ts +37 -2
- package/src/upgrade-report.ts +3 -0
- package/src/verify-coverage-run.ts +42 -11
- package/src/verify-e2e.ts +115 -4
- package/src/verify-floor.ts +27 -0
- package/src/verify-guard-baseline.ts +109 -0
- package/src/verify-live.ts +72 -0
- package/src/verify-merge-skips.ts +51 -0
- package/src/verify-merge.ts +36 -2
- package/src/verify-run.ts +48 -7
- package/src/verify-services.ts +287 -0
- package/src/verify-skip-reason.ts +53 -0
- package/src/verify-strict.ts +108 -0
- package/src/verify-test-command.ts +129 -0
- package/src/verify-tests.ts +39 -126
- package/types/babel-modules.d.ts +2 -0
- package/wiki/CLI-Reference.md +142 -23
- package/wiki/Caching-And-Invalidation.md +1 -1
- package/wiki/Entities-And-Migrations.md +1 -1
- package/wiki/Jobs-And-Workflows.md +3 -3
- package/wiki/Known-Gaps.md +5 -1
- package/wiki/MCP-And-AI.md +1 -1
- package/wiki/PWA-And-Offline.md +1 -1
- package/wiki/Troubleshooting.md +3 -3
- package/wiki/Tutorial-05-Deploy-Free.md +2 -2
- package/wiki/Upgrading.md +3 -0
package/CLAUDE.md
CHANGED
|
@@ -18,20 +18,20 @@ Commands: `bun test ./packages/cli/` (repo root: the preload),
|
|
|
18
18
|
| Registry | `registry.ts`: every declaration static (`cmd-<name>-spec.ts`), every body `await import()`ed when that command runs ‡ |
|
|
19
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 |
|
|
20
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 |
|
|
21
|
-
| stdout / stderr | `write-line.ts`'s `writeLine` / `writeErrorLine
|
|
21
|
+
| stdout / stderr | `write-line.ts`'s `writeLine` / `writeErrorLine`, never `process.stdout.write`; `stream: 'stderr'` → fd 2 ‡ |
|
|
22
22
|
| `--json` | every command; `dispatch.ts` sets core's log stream to stderr under it. Same data as the human render |
|
|
23
23
|
| I/O | only `dispatch.ts` renders or exits; commands return `CommandResult`. `ok()` / `failed()` write `ok` after the `extra` spread — the verdict cannot be overturned |
|
|
24
24
|
| Staying up | a command still listening when `run` resolves returns `hold` (`hold.ts`); the release runs inside the drain's own deadline |
|
|
25
|
-
| Test execution | `test-shards.ts`'s `testArgs` — one `bun test --parallel=N` per pass (`test-passes.ts`); `live`/`e2e` run serially (`SERIAL_TYPES`, `test-workers.ts`) |
|
|
25
|
+
| Test execution | `test-shards.ts`'s `testArgs` — one `bun test --parallel=N` per pass (`test-passes.ts`); `live`/`e2e` run serially (`SERIAL_TYPES`, `test-workers.ts`); a file's type and each step's argv: `verify-test-command.ts` |
|
|
26
26
|
| Numeric flags | `flag-number.ts` — one reader for `--port` / `--workers` / `--shard` |
|
|
27
27
|
| Shell quoting | `shell-quote.ts`'s `quoteArg` for every value pasted into a `fix:` or a reproduce line |
|
|
28
|
-
| Missing input | `MissingPositionalError
|
|
28
|
+
| Missing input | `MissingPositionalError`; a bare subcommand needs a declared `defaultSubcommand` (`MissingSubcommandError`) ‡ |
|
|
29
29
|
| Closed flag values | read through a function that refuses the rest (`readTarget`, `readMethod`, `readSurfaceFilter`, `isTransport`), from the framework's own set where one exists |
|
|
30
30
|
| Passthrough | declared per command (`CommandSpec.passthrough`); every other command refuses a `--` tail with `X_CLI_BAD_FLAG` |
|
|
31
31
|
| App root | `CommandSpec.requiresApp`, enforced by `dispatch.ts` before `run` |
|
|
32
32
|
| Declared flags | every flag a command declares is read in this package's source — `flag-reads.test.ts` (`X_CLI_FLAG_UNREAD`) |
|
|
33
33
|
| Planned commands | `PLANNED_COMMANDS` / `PLANNED_SUBCOMMANDS` (`cmd-planned.ts`): in the registry, exit `X_NOT_IMPLEMENTED` with a fix naming a shipped command |
|
|
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` |
|
|
34
|
+
| Errors | codes + titles in `error-codes.ts`, a runnable line per code in `mcp-errors.ts` (typed over `CliErrorCode`); a family at the ceiling moves to `error-codes-<family>.ts` / `mcp-errors-<family>.ts` (`-verify`: the gate's floor, run and split); classes in `errors.ts` or beside their one thrower when `errors.ts` is at its ceiling. Never a bare `Error` |
|
|
35
35
|
| Subprocesses | only through `exec.ts`'s injectable `Runner`; `gh` through `ctx.runner` with a required `fix` |
|
|
36
36
|
| Templates | `templates/*.ts` return strings, pre-formatted for Biome (`wrap.ts`'s `wrapList` / `wrapImport` / `sortSpecifiers`); no fixture files on disk |
|
|
37
37
|
| Strings | rendered output through `messages.ts` (missing key renders `⟦key⟧`) ‡ |
|
|
@@ -49,21 +49,25 @@ Commands: `bun test ./packages/cli/` (repo root: the preload),
|
|
|
49
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 |
|
|
50
50
|
| `verify-exercise.ts` / `cmd-exercise.ts` / `exercise-*.ts` | `exercise`: `x exercise --json` as a child, red on its findings |
|
|
51
51
|
| `verify-floor.ts` | `x.verify.json`: a floor step that ran zero tests is `X_VERIFY_SUITE_VANISHED` |
|
|
52
|
-
| `
|
|
52
|
+
| `verify-strict.ts` / `verify-skip-reason.ts` / `verify-guard-baseline.ts` / `verify-merge-skips.ts` | `strict` + `skip` (`X_VERIFY_STRICT_UNRUN`), each zero-check step's reason, per-guard `guardBaseline` † |
|
|
53
|
+
| `verify-live.ts` / `verify-services.ts` | `live`: nothing answering → the gate starts `docker/docker-compose.test.yml`; can't → `X_TEST_SERVICES_UNAVAILABLE` warning |
|
|
54
|
+
| `verify-e2e.ts` / `doctor-browser.ts` | `e2e` floored with no Chrome is `X_VERIFY_E2E_BROWSER_MISSING`; `x doctor` reports the browser |
|
|
55
|
+
| `coverage-remap.ts` / `coverage-island.ts` / `island-bundle-options.ts` | under a coverage build, island chunk lines credited to their sources via the chunk's source map |
|
|
56
|
+
| `coverage-{floor,lcov,source,island,remap}.ts` / `verify-coverage-run.ts` | an app's `unit` coverage floor; `coverage-lcov.ts` is the ONE lcov reader † |
|
|
53
57
|
| `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 † |
|
|
54
|
-
| `load-findings.ts` | a module-load failure is reported once, by `manifest`;
|
|
55
|
-
| `verify-contract-diff.ts` | `contract-diff`: baseline `x.manifest.json` at HEAD
|
|
58
|
+
| `load-findings.ts` | a module-load failure is reported once, by `manifest`; each step that loads the app stands down (`blockedByLoad`) † |
|
|
59
|
+
| `verify-contract-diff.ts` | `contract-diff`: baseline `x.manifest.json` at HEAD, in CI at the merge base † |
|
|
56
60
|
| `verify-factories.ts` | `unit` lints `<app>/packages/db/factories.ts` (`X_TEST_FACTORY_INVALID`) |
|
|
57
|
-
| `verify-seeds.ts` / `verify-seeds-probe.ts` | `unit` runs the seeds in a child on
|
|
61
|
+
| `verify-seeds.ts` / `verify-seeds-probe.ts` | `unit` runs the seeds in a child on `x exercise`'s scratch database; an uncoded throw is `X_SEED_FAILED` † |
|
|
58
62
|
| `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 † |
|
|
59
63
|
| `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 |
|
|
60
|
-
| `app-transport.ts` / `browser-transport.ts` / `transport-calls
|
|
64
|
+
| `app-transport.ts` / `browser-{transport,import-chain,barrel-cut}.ts` / `transport-{calls,values}.ts` / `binding-names.ts` / `import-closure.ts` / `server-barrels.ts` | `boundaries`, built in: one browser transport; a server barrel below an island is cut at its first hop † |
|
|
61
65
|
| `guards.ts` / `guard-sources.ts` | an app's `guards/*.ts`, run on `boundaries`; ONE shared walk (`GuardSources`) † |
|
|
62
66
|
| `templates/scaffold-guards.ts` | `SHIPPED`, the one list of shipped guards (`x new`, `x g guard`, `doctor-guards.ts`) † |
|
|
63
|
-
| `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
|
|
64
|
-
| `fix-sequence.ts` | `errors`: a
|
|
67
|
+
| `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 † |
|
|
68
|
+
| `fix-sequence.ts` | `errors`: a deferring, re-run-only or `--force` fix is `X_ERROR_FIX_INVALID`, ratcheted per file † |
|
|
65
69
|
| `workspace-checks.ts` / `test-only-shipped.ts` / `workspace-graph.ts` / `tsconfig-references.ts` / `publish-closure.ts` | `package-shape`, `filesize` ‡ |
|
|
66
|
-
| `workspace-external-deps.ts` · `tsconfig-aliases.ts` · `error-codes-package.ts` | `package-shape`:
|
|
70
|
+
| `workspace-external-deps.ts` · `tsconfig-aliases.ts` · `error-codes-package.ts` | `package-shape`: an undeclared registry import is `X_WORKSPACE_EXTERNAL_DEP_UNDECLARED`; the step family's codes † |
|
|
67
71
|
| `app-permissions*.ts` / `permission-grants.ts` | `policy`: `X_PERMISSION_UNGRANTED`, `X_PERMISSION_BORROWED` † |
|
|
68
72
|
| `job-registration.ts` | `manifest`: no job or task under a positional `anonymous-*` name (`X_JOB_UNREGISTERED`) |
|
|
69
73
|
| `unscanned-admin.ts` | `manifest`: a `defineAdmin()` outside the app scan (`apps/*/src/`) is `X_ADMIN_UNSCANNED` |
|
|
@@ -76,20 +80,20 @@ Commands: `bun test ./packages/cli/` (repo root: the preload),
|
|
|
76
80
|
| `db-rolling.ts` / `doctor-rolling.ts` | `drift`'s rolling rail (`X_MIGRATION_ROLLING_UNSAFE`) † |
|
|
77
81
|
| `redundant-indexes.ts` / `doctor-redundant-indexes.ts` | covered indexes: `gen --drop-redundant` drops, `drift` excuses, `x doctor` lists |
|
|
78
82
|
| `schema-dump-drift.ts` | also the dump-vs-newest-snapshot rail, no database (`X_DB_DRIFT`) ‡ |
|
|
79
|
-
| `i18n-registration.ts` / `i18n-audit.ts` / `admin-catalog-keys.ts` | `i18n`; a mounted admin's keys
|
|
80
|
-
| `error-unthrown.ts` / `unthrown-codes.ts` | host check: a registered code nothing throws is listed in `UNTHROWN_CODES
|
|
83
|
+
| `i18n-registration.ts` / `i18n-audit.ts` / `admin-catalog-keys.ts` | `i18n`; a mounted admin's keys come from `AdminApp.catalogKeys()` (`X_CATALOG_MISSING_KEYS`) † |
|
|
84
|
+
| `error-unthrown.ts` / `unthrown-codes.ts` | host check: a registered code nothing throws is listed in `UNTHROWN_CODES`; stale is `X_ERROR_CODE_UNTHROWN_STALE` † |
|
|
81
85
|
| `lint-findings.ts` | `lint`: `biome check --reporter=json` as one finding per diagnostic |
|
|
82
86
|
| `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 |
|
|
83
87
|
| `job-budget.ts` | `X_JOB_OUTLASTS_DRAIN` (`manifest`): `timeout` vs `workerBudgetMs(drain)`, from the registry † |
|
|
84
88
|
| `output-findings.ts` | render layer only: `runnableFix` (`bunx x`, decided by `dispatch.ts`'s `readerFor`) and `collapseFindings`. Throw sites keep `x …` |
|
|
85
89
|
| `app-load-unresolved.ts` | `X_APP_IMPORT_UNRESOLVED`, read by the scan, `findingFrom` and `x doctor`'s `snapshots` probe |
|
|
86
|
-
| `fix-truth.test.ts` / `fix-truth-fixture.ts` / `db-fix-truth.job.test.ts` | a printed fix, executed
|
|
90
|
+
| `fix-truth.test.ts` / `fix-truth-fixture.ts` / `db-fix-truth.job.test.ts` | a printed fix, executed against a broken scaffold † |
|
|
87
91
|
|
|
88
92
|
### Generators (`x g`, `x new`)
|
|
89
93
|
|
|
90
94
|
| File | Job |
|
|
91
95
|
|---|---|
|
|
92
|
-
| `cmd-generate.ts` / `generate-files.ts` / `generate-kinds.ts` / `generate-write.ts` | argv → pure file list →
|
|
96
|
+
| `cmd-generate.ts` / `generate-files.ts` / `generate-kinds.ts` / `generate-write.ts` | argv → pure file list → conflict-checked writes † |
|
|
93
97
|
| `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 |
|
|
94
98
|
| `write-generated.ts` | `x new`'s writer: a `link` file is a relative symlink, a copy only on a refusing win32 |
|
|
95
99
|
| `generate-feature.ts` | a `--feature` naming no slice is `X_FEATURE_UNKNOWN`; nothing invents an entity |
|
|
@@ -97,7 +101,7 @@ Commands: `bun test ./packages/cli/` (repo root: the preload),
|
|
|
97
101
|
| `generate-plural.ts` | a planned `entity.ts` in an already-plural slice (`posts` → `postses`) is `X_CLI_BAD_FLAG`; the fix names the singular |
|
|
98
102
|
| `generate-catalog-locales.ts` | `--locales` never starts a catalog; missing locale is `X_CLI_BAD_FLAG` † |
|
|
99
103
|
| `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) |
|
|
100
|
-
| `generate-grants.ts` | a written `policy.ts` grants the set the run wrote
|
|
104
|
+
| `generate-grants.ts` | a written `policy.ts` grants the set the run wrote, never one already in the file ‡ † |
|
|
101
105
|
| `policy-append.ts` | a second `x g policy` appends its set; the same set again is the conflict, fix another set |
|
|
102
106
|
| `scaffold-growth.contract.test.ts` | an entity gaining a defaulted and a nullable column breaks no generated insert (`Insertable`) |
|
|
103
107
|
| `api-registration.ts` | a written job or task is listed in `apps/web/api/index.ts` |
|
|
@@ -112,51 +116,53 @@ Commands: `bun test ./packages/cli/` (repo root: the preload),
|
|
|
112
116
|
| `generate-invite*.ts`, `templates/invite*.ts` | `x g invite`: no name; three actions + two pages over `defineMemberInvite` |
|
|
113
117
|
| `generate-format-written.ts` | the app's Biome over the TypeScript a run created, best effort; `lint` judges |
|
|
114
118
|
| `templates/scaffold-mcp-{json,endpoint,admin}.ts` | `.mcp.json` (`bunx @ultimat3/cli mcp serve`, never `bunx x`) and the refusing MCP endpoints ‡ |
|
|
119
|
+
| `templates/scaffold-suites.ts` | the `live` + `e2e` suites every scaffold ships: both steps run from the first commit |
|
|
115
120
|
|
|
116
121
|
### Boot (`x dev`, the container)
|
|
117
122
|
|
|
118
123
|
| File | Job |
|
|
119
124
|
|---|---|
|
|
120
125
|
| `serve.ts` / `serve-boot.ts` / `serve-entry.ts` / `serve-env.ts` | the production entry: `ROLE`, env bindings, `ROLE=migrate`; `X_APP_MODULE_LOAD_FAILED` † |
|
|
121
|
-
| `app-load-batch.ts` / `app-load-register.ts` | one hook module per app module,
|
|
122
|
-
| `app-load-prebuilt.ts` / `build-registry.ts` / `build-registry-background.ts` | every serving role boots from the prebuilt registry (`
|
|
126
|
+
| `app-load-batch.ts` / `app-load-register.ts` | one hook module per app module, registered in order; registration state † |
|
|
127
|
+
| `app-load-prebuilt.ts` / `build-registry.ts` / `build-registry-background.ts` | every serving role boots from the prebuilt registry (`x build`); stale → scan † |
|
|
123
128
|
| `generate-refresh.ts` | `x g` refreshes the manifest only when a written file needs it |
|
|
124
129
|
| `role-load.ts` / `document-graph.ts` / `serve-web.ts` | a role imports what it runs: `ROLE_LOADS` (`X_ROLE_LOAD_INCOMPLETE`) † |
|
|
125
130
|
| `module-imports.ts` | a module's imports, resolved once for both graphs: `referenced` (reload), `evaluated` (document) |
|
|
126
|
-
| `dev-rebuild-remount.ts` / `dev-rebuild-schema.ts` | a save that changes what `x dev` mounted
|
|
131
|
+
| `dev-rebuild-remount.ts` / `dev-rebuild-schema.ts` | a save that changes what `x dev` mounted is a restart; entities ahead of migrations are `X_DB_DRIFT` † |
|
|
127
132
|
| `dev-log.ts` | every logger line to `<stateDir>/dev.log` (`logs.tail`); `dev.log.1` at 16 MiB |
|
|
128
|
-
| `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
|
|
133
|
+
| `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 † |
|
|
129
134
|
| `runtime-bindings.ts` | which service each binding points at (embedded or external); events follow `NATS_URL` |
|
|
130
135
|
| `runtime-queue.ts` / `runtime-services.ts` / `runtime-bus.ts` | db + queue; every other accessor; the bus |
|
|
131
136
|
| `framework-schema-apply.ts` / `framework-schema-stamp.ts` | the framework tables, applied in one locked transaction † |
|
|
132
|
-
| `runtime-isr.ts` | the ISR controller both boots serve through,
|
|
133
|
-
| `runtime-mfa-warning.ts` / `runtime-idempotency-scope.ts` | boot warnings: unsealed MFA secrets
|
|
137
|
+
| `runtime-isr.ts` | the ISR controller both boots serve through, attached to `invalidateTags` (`attachedIsr`) † |
|
|
138
|
+
| `runtime-mfa-warning.ts` / `runtime-idempotency-scope.ts` | boot warnings: unsealed MFA secrets, a per-process idempotency store † |
|
|
134
139
|
| `app-config-load.ts` | the ONE reader of `app.config.ts` (`loadAppConfig`) † |
|
|
135
140
|
| `theme-brand.ts` | the ONE reader of an app's theme (`brand` in `apps/web/shared/theme.ts`) † |
|
|
136
141
|
| `runtime-{jobs,realtime,notify-retention,cache,purge,replica}.ts` | the `app.config.ts` sections the boot obeys (`*Of(config)`) † |
|
|
137
|
-
| `runtime-cache-bus.ts` | which bus carries cache/ISR invalidations
|
|
138
|
-
| `runtime-jobs.ts` (queues) | `
|
|
142
|
+
| `runtime-cache-bus.ts` | which bus carries cache/ISR invalidations across replicas; one `cache.broadcast` boot line † |
|
|
143
|
+
| `runtime-jobs.ts` (queues) | `WORKER_QUEUES` = the EXACT set, else `X_WORKER_QUEUE_UNKNOWN`; `-unserved.ts`: what no worker serves † |
|
|
139
144
|
| `serve-retire.ts` / `dev-restart-retire.ts` | the worker retire (SIGUSR2, before an `x dev` restart's drain) † |
|
|
140
145
|
| `role-start*.ts` / `role-realtime.ts` | `--role` selection, start/stop per role, device mounts † |
|
|
141
146
|
| `role-wake.ts` | the worker's LISTEN session (`@ultimat3/jobs`' `startQueueWake`) — worker role only, only over a client that `canListen` — and `queue_wake_live` |
|
|
142
147
|
| `role-sync.ts` / `role-replicator.ts` / `runtime-live-feed.ts` | the sync node, the change feed |
|
|
143
148
|
| `runtime-render*.ts` / `runtime-{isr-outcome,assets,storage,hooks}.ts` / `route-islands.ts` / `api-routes.ts` | the HTTP surface both boots mount † |
|
|
144
|
-
| `asset-route-meta.ts` | the ONE writer of an asset route's `tags: ['assets']` + `rateLimit: 'assets'
|
|
149
|
+
| `asset-route-meta.ts` | the ONE writer of an asset route's `tags: ['assets']` + `rateLimit: 'assets'` † |
|
|
145
150
|
| `client-{errors,vitals}-*.ts` | `clientErrors` (and `.vitals`): the script on `app/` (vitals: listed) documents, its `POST` route, mounted by BOTH boots ‡ |
|
|
146
151
|
| `retained-assets.ts` / `-layout.ts` / `-sweep.ts` / `-read.ts` / `-boot.ts` / `-warned.ts` | `assets.retain`: the web boot publishes this build's hashed files before `/readyz` † |
|
|
147
|
-
| `runtime-overrides.ts` / `runtime-ports.ts` / `runtime-port-bindings.ts` | `runtime.ts`: a field per `ADAPTER_PORTS` row
|
|
152
|
+
| `runtime-overrides.ts` / `runtime-ports.ts` / `runtime-port-bindings.ts` | `runtime.ts`: a field per `ADAPTER_PORTS` row; unbound row = build error † |
|
|
148
153
|
| `plain-routes.ts` | the plain routes both boots mount and `x routes` lists: `runtime.routes`, then every declared `webhookReceiver()`'s, each once |
|
|
149
154
|
| `app-openapi.ts` | `openapi.json` (complete when `defineApi({ openapi })` is declared) and each bearer mount's own document; staleness for all of them |
|
|
150
155
|
| `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 |
|
|
151
|
-
| `page-navigation.ts` | the client router for `navigation.client` surfaces
|
|
152
|
-
| `page-speculation.ts` | Speculation Rules for documents
|
|
156
|
+
| `page-navigation.ts` | the client router for `navigation.client` surfaces, built once for every target † |
|
|
157
|
+
| `page-speculation.ts` | Speculation Rules for documents without the router (`navigation.speculation`) ‡ † |
|
|
153
158
|
| `static-document.ts` | a served `static` page: `304` on `If-None-Match`; container keeps the document (never `x dev`) † |
|
|
154
|
-
| `island-{bundle,groups,outputs,build-pool,group-cache,cache-inputs,store,sources,runtime}.ts` / `island-realtime*.ts` / `solid-loader.ts` | islands, named by their final bytes
|
|
155
|
-
| `local-cli.ts` / `local-cli-handoff.ts` | a global `x` hands over to the app's own CLI
|
|
159
|
+
| `island-{bundle,groups,outputs,build-pool,group-cache,cache-inputs,store,sources,runtime}.ts` / `island-realtime*.ts` / `solid-loader.ts` | islands, named by their final bytes: one `Bun.build` per route group, cached in `.x/cache/islands/` † |
|
|
160
|
+
| `local-cli.ts` / `local-cli-handoff.ts` | a global `x` hands over to the app's own CLI † |
|
|
156
161
|
| `serve-prebuilt.ts` / `serve-prebuilt-paths.ts` | the image's prebuilt store; a boot that built anything logs `X_IMAGE_NOT_PREBUILT` † |
|
|
157
162
|
| `dev-*.ts` | `x dev` only: dashboard sources, traces, the N+1 ledger, watcher, reload, lock, port |
|
|
158
163
|
| `cmd-stop.ts` / `cmd-stop-spec.ts` | `x stop`: the lock's pid only, SIGTERM, wait; `X_DEV_STOP_TIMEOUT` † |
|
|
159
|
-
| `dev-dashboard-guard.ts` / `loopback-host.ts` | `/_x
|
|
164
|
+
| `dev-dashboard-guard.ts` / `loopback-host.ts` | `/_x`: loopback `Host` (`X_DEV_HOST_REFUSED`) and peer (`X_DEV_PEER_REFUSED`) † |
|
|
165
|
+
| `dev-host.ts` / `dev-tls*.ts` | `x dev --host` (loopback default) and `--tls`: a cached self-signed cert in `.x/tls/`, WebCrypto + hand-written DER |
|
|
160
166
|
| `doctor-pooler.ts` / `runtime-statement-bound.ts` | the statement bound and a pooler's refusal, one finding, one boot line † |
|
|
161
167
|
|
|
162
168
|
### Build and data
|
|
@@ -176,18 +182,20 @@ Commands: `bun test ./packages/cli/` (repo root: the preload),
|
|
|
176
182
|
|---|---|
|
|
177
183
|
| `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 |
|
|
178
184
|
| `cmd-auth.ts` / `cmd-auth-spec.ts` / `doctor-auth.ts` | `x auth seal-mfa`: seals plaintext `x_users.mfa_secret` through auth's `sealMfaSecrets` |
|
|
179
|
-
| `cmd-mcp.ts` / `mcp-host
|
|
185
|
+
| `cmd-mcp.ts` / `mcp-host*.ts` / `mcp-errors.ts` / `mcp-db-target.ts` / `mcp-test-{output,run}.ts` | `x mcp serve`: 23 tools, two transports; `tests.run`/`verify.run` ARE `x test`/`x verify` † |
|
|
180
186
|
| `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 |
|
|
181
|
-
| `
|
|
187
|
+
| `cmd-profile*.ts` | `x profile <route>`: in-process JSC sampling profile of a route, hottest functions |
|
|
188
|
+
| `mcp-host-logs.ts` | `logs.tail` and `x logs tail`'s reader: path rule, end-first bounded read, per-role tail |
|
|
189
|
+
| `shot-route.ts` / `shot-run.ts` / `shot-gpu.ts` | `x shot`'s route argument, one capture, the page's GPU adapter (never gating) † |
|
|
182
190
|
| `cmd-pr.ts` / `cmd-ci.ts` / `ci-runs.ts` / `ci-tested.ts` | GitHub through `gh`, schema-parsed; not gate steps † |
|
|
183
191
|
| `pr-threads.ts` / `pr-activity.ts` | `x pr review`'s ONE GraphQL document: threads, plus every review (verdict, body) and issue comment |
|
|
184
192
|
| `pr-bots.ts` | which review bots posted a "did not review" notice (rate/review limit, skipped); `blocked` = no review of theirs after it |
|
|
185
|
-
| `ci-log.ts` | `x ci`'s log reader:
|
|
193
|
+
| `ci-log.ts` | `x ci`'s log reader: markers and fences undone, provenance `source: 'ci-log'` † |
|
|
186
194
|
| `error-catalog.ts` | imports every `@ultimat3/*` package so `x errors` answers for any code |
|
|
187
195
|
| `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 † |
|
|
188
196
|
| `cmd-env-init.ts` / `env-production.ts` / `cmd-deploy-preflight.ts` | the one writer of `.env.production`; compose pre-flight (`X_DEPLOY_ENV_MISSING`) † |
|
|
189
197
|
| `cmd-upgrade.ts` / `upgrade-*.ts` | `x upgrade`: one major per run; no `requiresApp` † |
|
|
190
|
-
| `cmd-deploy-verify.ts` / `deploy-verify-*.ts` | `x deploy verify`: the wait, the
|
|
198
|
+
| `cmd-deploy-verify.ts` / `deploy-verify-*.ts` / `cmd-status*.ts` | `x deploy verify`: the wait, the verdict, lazy sources † · `x status` |
|
|
191
199
|
|
|
192
200
|
## Adding a command
|
|
193
201
|
|
package/README.md
CHANGED
|
@@ -22,10 +22,10 @@ Commands and the `x verify` step count, `As of 2026-08`:
|
|
|
22
22
|
| `x build --target prebuilt` | the store a container boots from: island chunks, compiled stylesheets | a `RUN` line in the image build, never run by hand |
|
|
23
23
|
| `x verify` | **the gate** | 21 named steps, each with pass/fail + duration; `budgets` runs `x build --target static` first when its stats are missing or older than the source |
|
|
24
24
|
| `x verify plan [--parts n]` | the gate as CI parts | `data.matrix` is a GitHub `strategy.matrix` of `x verify --only … [--shard i/n]` parts; `x new`'s workflow reads it with `fromJSON`, and `x verify merge` folds the parts back |
|
|
25
|
-
| `x exercise [<name>] [--seed n]` | every action, query, job and route `load` run once on generated rows, no test written | a scratch database; `.x/exercise.json`; an `unreached` primitive is `X_CONTRACT_EXERCISE_UNREACHED` with the override to paste into `apps/web/exercise.ts` — the gate's `exercise` step. `x.verify.json` `exercise: { unprovenMax, statementsMax }` turns unproven proofs and over-ceiling calls red; absent, warning lines. Route loads land in `routes` beside `records`, their loops and seq scans as warning lines |
|
|
25
|
+
| `x exercise [<name>] [--seed n] [--shard i/n]` | every action, query, job and route `load` run once on generated rows, no test written | a scratch database; `.x/exercise.json`; an `unreached` primitive is `X_CONTRACT_EXERCISE_UNREACHED` with the override to paste into `apps/web/exercise.ts` — the gate's `exercise` step. `x.verify.json` `exercise: { unprovenMax, statementsMax }` turns unproven proofs and over-ceiling calls red; absent, warning lines. Route loads land in `routes` beside `records`, their loops and seq scans as warning lines; a load's own typed-client reads are answered in process, and `defineExercise(…, { routes })` gives a page its params, query, actor or `empty` reason. A sent push is a `push` effect. `--shard i/n` runs one of n disjoint slices into `.x/exercise.<i>-of-<n>.json` |
|
|
26
26
|
| `x drill [<name>] [--list] [--budget-ms n]` | the app's roles as real processes on real services, each fault played through a proxy or a signal, judged on framework contracts only | a scratch database per drill; load = anonymous site pages plus every action an anonymous POST reaches (`data.skippedWrites` names the rest and why); `X_DRILL_FAILED` per property that did not hold, `X_DRILL_SERVICE_MISSING` before anything starts. Not a gate step — CI's `fault-drills` job runs three on `examples/dummy` |
|
|
27
27
|
| `x g <primitive> <name>` | scaffolds a primitive **with a passing test** | never a TODO stub |
|
|
28
|
-
| `x db gen\|migrate\|reset\|branch\|backfill` | everything DB | `branch` = copy-on-write clone + preview URL; `backfill` dry-runs unless `--write`.
|
|
28
|
+
| `x db gen\|migrate\|reset\|branch\|backfill` | everything DB | `branch` = copy-on-write clone + preview URL; `backfill` dry-runs unless `--write`. The schema browser is `/_x`'s db panel (`x dev`); `studio` left the registry ([Known gaps](../../wiki/Known-Gaps.md#open-by-decision)) |
|
|
29
29
|
| `x mcp serve` | `@ultimat3/mcp`'s 19 dev tools, over stdio or HTTP | one catalog, one scope set, both transports |
|
|
30
30
|
| `x upgrade` | one major per run: exact pins, the Bun floor, `bun install`, the gate; an `AGENTS.md` byte-identical to `CLAUDE.md` becomes a symlink to it, a different one is reported in `data.agentsMd` and left | the `--json` report names the wiki section, the guards that differ and what the gate still says ([fields](../../wiki/CLI-Reference.md#x-upgrade)); `bunx @ultimat3/cli@latest upgrade` in an app that predates it; pins with no `app.config.ts` still hop, and `data.proof` says what checked them |
|
|
31
31
|
| `x doctor` | environment, ports, drift, PWA prerequisites, `APP_URL` | every finding carries a fix command; probes the port `x dev` binds ([which one](../../wiki/CLI-Reference.md#x-doctor)); the framework's deploy secrets only where the machine names `staging`/`production` |
|
|
@@ -48,11 +48,12 @@ Commands and the `x verify` step count, `As of 2026-08`:
|
|
|
48
48
|
| `x client vendor <name>` / `x client customer --out <dir>` | one OpenAPI compiler (`openapi-compile.ts`), two emitters: a vendor's document into `apps/web/clients/<name>/` (`outbound()` + `t`), or the app's published document into a client with no framework import | every generated file is stamped with its source and body hash; `drift` raises `X_CLIENT_STALE` / `X_CLIENT_EDITED` ([flags](../../wiki/CLI-Reference.md#x-client)) |
|
|
49
49
|
| `x fix boundary <file>` | the minimal cut for a crossed surface boundary | prints the plan and the `git mv`; never rewrites a file |
|
|
50
50
|
| `x ci [runs]` / `x ci tested` | CI triage through `gh`; `tested`: may this push reuse a green PR run of the same tree | `tested` exits 0 on every answer, `data.tested`; any doubt is `false`, a full run ([conditions](../../wiki/CLI-Reference.md#x-pr--x-ci)) |
|
|
51
|
-
| `x token create\|list\|revoke` | MCP / API tokens in `x_api_keys` | `create --scopes a,b` prints the plaintext once and stores its hash; `list --owner <id>` carries no secret; `grant
|
|
51
|
+
| `x token create\|list\|revoke` | MCP / API tokens in `x_api_keys` | `create --scopes a,b` prints the plaintext once and stores its hash; `list --owner <id>` carries no secret; no `grant`: a wider set is a new key ([details](../../wiki/CLI-Reference.md#x-token)) |
|
|
52
52
|
| `x config show [--section <key>]` | the resolved `app.config.ts` | defaults merged by `defineConfig`; credential keys, `secret()` values and URL passwords redacted |
|
|
53
53
|
| `x logs tail [--lines n] [--role <role>]` | the end of `.x/dev.log` or a role log | the `logs.tail` MCP tool's file and reader |
|
|
54
|
-
| `x cache graph\|bust <tag>\|clear` | the tag graph off the manifest; a bust through the app's own tiers and bus | an in-process bus is said in the summary; a failed tier is `X_CACHE_DRIVER_UNAVAILABLE
|
|
54
|
+
| `x cache graph\|bust <tag>\|clear` | the tag graph off the manifest; a bust through the app's own tiers and bus | an in-process bus is said in the summary; a failed tier is `X_CACHE_DRIVER_UNAVAILABLE` |
|
|
55
55
|
| `x explain <query> [--input <json>] [--org <id>]` | one query's statements, planned on the dev database | the `exercise` step's oracle (`sweepPlans`): an unindexed read is `X_QUERY_UNINDEXED` with the `indexes:` entry as its fix |
|
|
56
|
+
| `x status [--url <origin>] [--samples n]` | the build each live worker runs, and what each origin's `/readyz` answers | a read, exit 0; `data.unrecorded` names the roles no fleet-wide record covers ([details](../../wiki/CLI-Reference.md#x-status)) |
|
|
56
57
|
|
|
57
58
|
Everything in [CLI reference](../../wiki/CLI-Reference.md)'s planned table is also in the registry
|
|
58
59
|
and exits `X_NOT_IMPLEMENTED` with a `fix:` naming the closest shipped command — "not built yet"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultimat3/cli",
|
|
3
|
-
"version": "31.
|
|
3
|
+
"version": "31.27.0",
|
|
4
4
|
"description": "The `x` binary: new, dev, build, verify, generate, db, mcp, doctor, deploy",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ultimate",
|
|
@@ -53,34 +53,34 @@
|
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@babel/core": "^8.0.9",
|
|
56
|
-
"@ultimat3/action": "31.
|
|
57
|
-
"@ultimat3/admin": "31.
|
|
58
|
-
"@ultimat3/ai": "31.
|
|
59
|
-
"@ultimat3/auth": "31.
|
|
60
|
-
"@ultimat3/cache": "31.
|
|
61
|
-
"@ultimat3/core": "31.
|
|
62
|
-
"@ultimat3/db": "31.
|
|
63
|
-
"@ultimat3/entity": "31.
|
|
64
|
-
"@ultimat3/flags": "31.
|
|
65
|
-
"@ultimat3/http": "31.
|
|
66
|
-
"@ultimat3/i18n": "31.
|
|
67
|
-
"@ultimat3/jobs": "31.
|
|
68
|
-
"@ultimat3/mail": "31.
|
|
69
|
-
"@ultimat3/manifest": "31.
|
|
70
|
-
"@ultimat3/mcp": "31.
|
|
71
|
-
"@ultimat3/money": "31.
|
|
72
|
-
"@ultimat3/notify": "31.
|
|
73
|
-
"@ultimat3/policy": "31.
|
|
74
|
-
"@ultimat3/pwa": "31.
|
|
75
|
-
"@ultimat3/query": "31.
|
|
76
|
-
"@ultimat3/realtime": "31.
|
|
77
|
-
"@ultimat3/render": "31.
|
|
78
|
-
"@ultimat3/schema": "31.
|
|
79
|
-
"@ultimat3/scraping": "31.
|
|
80
|
-
"@ultimat3/seo": "31.
|
|
81
|
-
"@ultimat3/storage": "31.
|
|
82
|
-
"@ultimat3/testing": "31.
|
|
83
|
-
"@ultimat3/time": "31.
|
|
56
|
+
"@ultimat3/action": "31.27.0",
|
|
57
|
+
"@ultimat3/admin": "31.27.0",
|
|
58
|
+
"@ultimat3/ai": "31.27.0",
|
|
59
|
+
"@ultimat3/auth": "31.27.0",
|
|
60
|
+
"@ultimat3/cache": "31.27.0",
|
|
61
|
+
"@ultimat3/core": "31.27.0",
|
|
62
|
+
"@ultimat3/db": "31.27.0",
|
|
63
|
+
"@ultimat3/entity": "31.27.0",
|
|
64
|
+
"@ultimat3/flags": "31.27.0",
|
|
65
|
+
"@ultimat3/http": "31.27.0",
|
|
66
|
+
"@ultimat3/i18n": "31.27.0",
|
|
67
|
+
"@ultimat3/jobs": "31.27.0",
|
|
68
|
+
"@ultimat3/mail": "31.27.0",
|
|
69
|
+
"@ultimat3/manifest": "31.27.0",
|
|
70
|
+
"@ultimat3/mcp": "31.27.0",
|
|
71
|
+
"@ultimat3/money": "31.27.0",
|
|
72
|
+
"@ultimat3/notify": "31.27.0",
|
|
73
|
+
"@ultimat3/policy": "31.27.0",
|
|
74
|
+
"@ultimat3/pwa": "31.27.0",
|
|
75
|
+
"@ultimat3/query": "31.27.0",
|
|
76
|
+
"@ultimat3/realtime": "31.27.0",
|
|
77
|
+
"@ultimat3/render": "31.27.0",
|
|
78
|
+
"@ultimat3/schema": "31.27.0",
|
|
79
|
+
"@ultimat3/scraping": "31.27.0",
|
|
80
|
+
"@ultimat3/seo": "31.27.0",
|
|
81
|
+
"@ultimat3/storage": "31.27.0",
|
|
82
|
+
"@ultimat3/testing": "31.27.0",
|
|
83
|
+
"@ultimat3/time": "31.27.0",
|
|
84
84
|
"babel-preset-solid": "^1.9.16"
|
|
85
85
|
}
|
|
86
86
|
}
|
package/src/app-mcp.ts
CHANGED
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
import { existsSync } from 'node:fs';
|
|
13
13
|
// why: Bun exposes no path-join primitive; each candidate is joined to root.
|
|
14
14
|
import { join } from 'node:path';
|
|
15
|
-
import { logger } from '@ultimat3/core';
|
|
15
|
+
import { logger, peerAddressClass } from '@ultimat3/core';
|
|
16
16
|
import type { Route } from '@ultimat3/http';
|
|
17
|
-
import { jsonResponse, originListed, selfOrigin } from '@ultimat3/http';
|
|
17
|
+
import { callerLocality, jsonResponse, originListed, selfOrigin } from '@ultimat3/http';
|
|
18
18
|
import {
|
|
19
19
|
type AppMcp,
|
|
20
20
|
assertIncludeCurrent,
|
|
@@ -198,6 +198,20 @@ function mountEndpoints(files: readonly MountFile[]): AppMcpMount {
|
|
|
198
198
|
return { routes, path: paths[0] ?? null, paths, warning };
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
+
/**
|
|
202
|
+
* Where the endpoint's facts say the caller is. `ctx.ip`, except a RELAYED loopback answer: a LAN
|
|
203
|
+
* socket forging `x-forwarded-for: 127.0.0.1` past a declared hop, or a tunnel on this machine,
|
|
204
|
+
* resolves to 127.0.0.1 — and the scaffold honours its development token from loopback. Those
|
|
205
|
+
* callers are handed `::` (unspecified: never loopback, one shared failure bucket, as they already
|
|
206
|
+
* shared 127.0.0.1's), by http's one rule (`callerLocality`) that `/_x` and the overlay ask too.
|
|
207
|
+
*/
|
|
208
|
+
const RELAYED_LOOPBACK_ADDRESS = '::';
|
|
209
|
+
|
|
210
|
+
export function mcpCallerAddress(ip: string | null, headers: Headers): string | null {
|
|
211
|
+
if (ip === null || peerAddressClass(ip) !== 'loopback') return ip;
|
|
212
|
+
return callerLocality({ ip, headers }) === 'local' ? ip : RELAYED_LOOPBACK_ADDRESS;
|
|
213
|
+
}
|
|
214
|
+
|
|
201
215
|
type Descriptor = NonNullable<AppMcp['route']>;
|
|
202
216
|
|
|
203
217
|
/** One endpoint's `POST` and, when it declared `oauth`, its RFC 9728 metadata `GET`s. */
|
|
@@ -238,7 +252,7 @@ function endpointRoutes(route: Descriptor, path: string, index: number): readonl
|
|
|
238
252
|
handler: (request, ctx) =>
|
|
239
253
|
route.handle(request.raw, {
|
|
240
254
|
origin: selfOrigin(ctx.url, ctx.https),
|
|
241
|
-
address: ctx.ip ?? undefined,
|
|
255
|
+
address: mcpCallerAddress(ctx.ip ?? null, request.raw.headers) ?? undefined,
|
|
242
256
|
// A browser `Origin` is proven the way CSRF proves it: this origin, or one listed exactly.
|
|
243
257
|
listed: (origin) => originListed(ctx.config.cors, origin),
|
|
244
258
|
}),
|
package/src/cmd-cache-spec.ts
CHANGED
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|
|
|
4
4
|
import type { CommandSpec } from './parse';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* No `stats`: hits and misses are `cache.hit`/`cache.miss` events inside each serving process, and
|
|
8
|
+
* nothing aggregates them for a CLI process to read (`wiki/Known-Gaps.md`).
|
|
9
|
+
*/
|
|
10
|
+
export const CACHE_SUBCOMMANDS = ['graph', 'bust', 'clear'] as const;
|
|
8
11
|
|
|
9
12
|
export const cacheSpec: CommandSpec = {
|
|
10
13
|
name: 'cache',
|
package/src/cmd-db-spec.ts
CHANGED
|
@@ -9,7 +9,6 @@ export const DB_SUBCOMMANDS = [
|
|
|
9
9
|
'migrate',
|
|
10
10
|
'reset',
|
|
11
11
|
'seed',
|
|
12
|
-
'studio',
|
|
13
12
|
'branch',
|
|
14
13
|
'backfill',
|
|
15
14
|
'diagnostics',
|
|
@@ -18,9 +17,9 @@ export const DB_SUBCOMMANDS = [
|
|
|
18
17
|
|
|
19
18
|
export const dbSpec: CommandSpec = {
|
|
20
19
|
name: 'db',
|
|
21
|
-
summary: 'gen, migrate, reset, seed,
|
|
20
|
+
summary: 'gen, migrate, reset, seed, branch, backfill, diagnostics, recount',
|
|
22
21
|
usage:
|
|
23
|
-
'x db gen "add publish_at" [--drop-redundant] | migrate | reset | seed [<name>] [--tier reference|dev] [--dry-run] | seed --generate [--rows n] [--seed n] [--dry-run] |
|
|
22
|
+
'x db gen "add publish_at" [--drop-redundant] | migrate | reset | seed [<name>] [--tier reference|dev] [--dry-run] | seed --generate [--rows n] [--seed n] [--dry-run] | branch list | branch create <name> | branch delete <name> | backfill [<name>|--all] [--write] [--force] | backfill --pending | backfill --list [--name n] [--status s] [--limit n] | diagnostics [--limit n] | recount <entity>.<column> [--write]',
|
|
24
23
|
requiresApp: true,
|
|
25
24
|
subcommands: DB_SUBCOMMANDS,
|
|
26
25
|
// Declared from the constant `runBranchCommand` validates against, never a second literal: it
|
package/src/cmd-db.ts
CHANGED
|
@@ -20,7 +20,6 @@ import { runBackfillCommand } from './cmd-db-backfill';
|
|
|
20
20
|
import { runBranchCommand } from './cmd-db-branch';
|
|
21
21
|
import { runRecountCommand } from './cmd-db-recount';
|
|
22
22
|
import { DB_SUBCOMMANDS, dbSpec } from './cmd-db-spec';
|
|
23
|
-
import { plannedSubcommand } from './cmd-planned';
|
|
24
23
|
import type { CliCommand, CommandContext } from './command';
|
|
25
24
|
import { runDiagnostics } from './db-diagnostics';
|
|
26
25
|
import { stepFinding } from './db-finding';
|
|
@@ -68,7 +67,6 @@ export const dbCommand: CliCommand = {
|
|
|
68
67
|
if (sub === 'migrate') return runMigrate(ctx, root, msg('cli.db.migrate.applied'));
|
|
69
68
|
if (sub === 'reset') return runReset(ctx, root);
|
|
70
69
|
if (sub === 'seed') return runSeed(ctx, root);
|
|
71
|
-
if (sub === 'studio') throw plannedSubcommand('db', 'studio');
|
|
72
70
|
if (sub === 'backfill') return runBackfillCommand(ctx, root);
|
|
73
71
|
if (sub === 'branch') return runBranchCommand(ctx, root);
|
|
74
72
|
if (sub === 'diagnostics') return runDiagnostics(ctx, root);
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// One `GET /readyz` against an origin, as `x deploy verify` and `x status` both read it: a fresh
|
|
2
|
+
// connection, uncached, a redirect tallied rather than followed — the status, the build header, the
|
|
3
|
+
// role a health port names. One reader, so the two commands cannot sample the fleet differently.
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
BUILD_ID_HEADER,
|
|
7
|
+
isRole,
|
|
8
|
+
readWithinLimit,
|
|
9
|
+
renderThrowable,
|
|
10
|
+
stringField,
|
|
11
|
+
} from '@ultimat3/core';
|
|
12
|
+
|
|
13
|
+
export interface ReadyzAnswer {
|
|
14
|
+
/** `null`: nothing answered — refused, reset or timed out. */
|
|
15
|
+
readonly status: number | null;
|
|
16
|
+
/** `x-ultimate-build` as answered, on any status. `null`: no header, or an empty one. */
|
|
17
|
+
readonly build: string | null;
|
|
18
|
+
/** Answered from a cache (`Age` > 0): a CDN's copy says nothing about the fleet behind it. */
|
|
19
|
+
readonly cached: boolean;
|
|
20
|
+
/** The body's `role`, when it is one: a role's own health port says it; the web port does not. */
|
|
21
|
+
readonly role: string | null;
|
|
22
|
+
/** The transport's failure, rendered, when nothing answered. */
|
|
23
|
+
readonly failure?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** A `/readyz` body is a few dozen bytes; past this it is not parsed, and the role is unknown. */
|
|
27
|
+
const READYZ_BODY_LIMIT = 4_096;
|
|
28
|
+
|
|
29
|
+
/** The most of a build id a printed line carries; the rest is cut and marked `…`. */
|
|
30
|
+
const PRINTED_BUILD_MAX = 128;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A build id as it may be PRINTED — never as it is MATCHED. The origin is a stranger: a header
|
|
34
|
+
* carrying `\x9b` (CSI) or `\x1b` rewrites the terminal `x status` prints to, and JSON leaves a C1
|
|
35
|
+
* control unescaped. Every character outside visible ASCII and space is written `\uXXXX`, and the
|
|
36
|
+
* result is cut at 128 characters, so a legal id (`release 31.27.0`) prints as itself.
|
|
37
|
+
*/
|
|
38
|
+
export const printableBuild = (value: string): string => {
|
|
39
|
+
const escaped = value.replace(
|
|
40
|
+
/[^\x20-\x7e]/g,
|
|
41
|
+
(char) => `\\u${char.charCodeAt(0).toString(16).padStart(4, '0')}`,
|
|
42
|
+
);
|
|
43
|
+
return escaped.length > PRINTED_BUILD_MAX ? `${escaped.slice(0, PRINTED_BUILD_MAX)}…` : escaped;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/** A body that is not JSON, or names no role, is an answer with no role — never a failed sample. */
|
|
47
|
+
async function roleOf(response: Response): Promise<string | null> {
|
|
48
|
+
const read = await readWithinLimit(response.body, READYZ_BODY_LIMIT).catch(() => undefined);
|
|
49
|
+
if (read === undefined || !('bytes' in read)) return null;
|
|
50
|
+
let body: unknown;
|
|
51
|
+
try {
|
|
52
|
+
body = JSON.parse(new TextDecoder().decode(read.bytes));
|
|
53
|
+
} catch {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
// `stringField`, the total read: a parsed stranger's object is never `in`-guarded then read.
|
|
57
|
+
const role = stringField(body, 'role');
|
|
58
|
+
return role !== undefined && isRole(role) ? role : null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* One `GET /readyz` on a connection of its own, so the load balancer chooses again: a kept-alive
|
|
63
|
+
* socket would ask one pod the same question for the whole window. A redirect is an answer to tally,
|
|
64
|
+
* never to follow: another host's `/readyz` says nothing about this origin.
|
|
65
|
+
*/
|
|
66
|
+
export async function takeSample(origin: string, limitMs: number): Promise<ReadyzAnswer> {
|
|
67
|
+
try {
|
|
68
|
+
const response = await fetch(`${origin}/readyz`, {
|
|
69
|
+
keepalive: false,
|
|
70
|
+
redirect: 'manual',
|
|
71
|
+
// Past a CDN or a caching proxy: the question is the fleet, never a stored copy of it.
|
|
72
|
+
headers: { 'cache-control': 'no-cache', pragma: 'no-cache' },
|
|
73
|
+
signal: AbortSignal.timeout(limitMs),
|
|
74
|
+
});
|
|
75
|
+
const header = response.headers.get(BUILD_ID_HEADER);
|
|
76
|
+
const age = Number(response.headers.get('age') ?? '0');
|
|
77
|
+
return {
|
|
78
|
+
status: response.status,
|
|
79
|
+
// As sent: `x deploy verify` matches it against `--build`. Printing screens it, not this.
|
|
80
|
+
build: header === null || header === '' ? null : header,
|
|
81
|
+
cached: Number.isNaN(age) || age > 0,
|
|
82
|
+
role: await roleOf(response),
|
|
83
|
+
};
|
|
84
|
+
} catch (error) {
|
|
85
|
+
return {
|
|
86
|
+
status: null,
|
|
87
|
+
build: null,
|
|
88
|
+
cached: false,
|
|
89
|
+
role: null,
|
|
90
|
+
failure: renderThrowable(error),
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
}
|
package/src/cmd-deploy-verify.ts
CHANGED
|
@@ -3,16 +3,11 @@
|
|
|
3
3
|
// never enumerated, and a GitOps roll that never ran `x deploy` is checked the same way.
|
|
4
4
|
|
|
5
5
|
import type { Clock } from '@ultimat3/core';
|
|
6
|
-
import {
|
|
7
|
-
BUILD_ID_HEADER,
|
|
8
|
-
renderCauseValue,
|
|
9
|
-
renderThrowable,
|
|
10
|
-
systemClock,
|
|
11
|
-
UltimateError,
|
|
12
|
-
} from '@ultimat3/core';
|
|
6
|
+
import { renderCauseValue, renderThrowable, systemClock, UltimateError } from '@ultimat3/core';
|
|
13
7
|
import { deadlineSignal } from '@ultimat3/core/outbound';
|
|
14
8
|
import type { QueueDemand, WorkerRecord } from '@ultimat3/jobs';
|
|
15
9
|
import { requireAppRoot } from './app-root';
|
|
10
|
+
import { takeSample } from './cmd-deploy-verify-sample';
|
|
16
11
|
import type { CommandContext } from './command';
|
|
17
12
|
import { failed, ok } from './command';
|
|
18
13
|
import type { WaitOutcome } from './deploy-verify-findings';
|
|
@@ -113,40 +108,6 @@ const realDeps: DeployVerifyDeps = {
|
|
|
113
108
|
expire: expireAfter,
|
|
114
109
|
};
|
|
115
110
|
|
|
116
|
-
interface Answered {
|
|
117
|
-
readonly status: number | null;
|
|
118
|
-
readonly build: string | null;
|
|
119
|
-
readonly cached: boolean;
|
|
120
|
-
readonly failure?: string;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* One `GET /readyz` on a connection of its own, so the load balancer chooses again: a kept-alive
|
|
125
|
-
* socket would ask one pod the same question for the whole window. A redirect is an answer to tally,
|
|
126
|
-
* never to follow: another host's `/readyz` says nothing about this origin.
|
|
127
|
-
*/
|
|
128
|
-
async function takeSample(origin: string, limitMs: number): Promise<Answered> {
|
|
129
|
-
try {
|
|
130
|
-
const response = await fetch(`${origin}/readyz`, {
|
|
131
|
-
keepalive: false,
|
|
132
|
-
redirect: 'manual',
|
|
133
|
-
// Past a CDN or a caching proxy: the question is the fleet, never a stored copy of it.
|
|
134
|
-
headers: { 'cache-control': 'no-cache', pragma: 'no-cache' },
|
|
135
|
-
signal: AbortSignal.timeout(limitMs),
|
|
136
|
-
});
|
|
137
|
-
await response.body?.cancel();
|
|
138
|
-
const header = response.headers.get(BUILD_ID_HEADER);
|
|
139
|
-
const age = Number(response.headers.get('age') ?? '0');
|
|
140
|
-
return {
|
|
141
|
-
status: response.status,
|
|
142
|
-
build: header === null || header === '' ? null : header,
|
|
143
|
-
cached: Number.isNaN(age) || age > 0,
|
|
144
|
-
};
|
|
145
|
-
} catch (error) {
|
|
146
|
-
return { status: null, build: null, cached: false, failure: renderThrowable(error) };
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
111
|
/** The least time a database read gets, and the floor of its server-side `statement_timeout`. */
|
|
151
112
|
const READ_FLOOR_MS = 1_000;
|
|
152
113
|
|
package/src/cmd-dev-spec.ts
CHANGED
|
@@ -7,12 +7,20 @@ import { DEV_ROLES } from './role-start-types';
|
|
|
7
7
|
export const devSpec: CommandSpec = {
|
|
8
8
|
name: 'dev',
|
|
9
9
|
summary: 'all roles in one process: embedded services, sub-second reload, /_x mounted',
|
|
10
|
-
usage: 'x dev [--port 3000] [--role web,worker] [--once] [--json]',
|
|
10
|
+
usage: 'x dev [--port 3000] [--host 0.0.0.0] [--tls] [--role web,worker] [--once] [--json]',
|
|
11
11
|
requiresApp: true,
|
|
12
12
|
flags: [
|
|
13
13
|
// No `default`: a default reads exactly like a value the caller typed, and it outranked
|
|
14
14
|
// `PORT` from the app's `.env.development` — `devPortFor` supplies the 3000 last.
|
|
15
15
|
{ name: 'port', type: 'string', summary: 'HTTP port (default: PORT, else 3000)' },
|
|
16
|
+
// No `HOST` fallback, unlike the port: a container reads `HOST`, and an exported one in a
|
|
17
|
+
// developer's shell must not quietly widen `x dev` past loopback.
|
|
18
|
+
{
|
|
19
|
+
name: 'host',
|
|
20
|
+
type: 'string',
|
|
21
|
+
summary:
|
|
22
|
+
'interface to bind: an IP literal, 0.0.0.0 or :: (default: localhost; /_x stays loopback-only)',
|
|
23
|
+
},
|
|
16
24
|
{
|
|
17
25
|
name: 'role',
|
|
18
26
|
type: 'string',
|
|
@@ -20,6 +28,12 @@ export const devSpec: CommandSpec = {
|
|
|
20
28
|
// slot on a shared database, which is not something every `x dev` should do by starting.
|
|
21
29
|
summary: `roles to run (default: all of ${DEV_ROLES.join(',')}; replicator is opt-in)`,
|
|
22
30
|
},
|
|
31
|
+
{
|
|
32
|
+
name: 'tls',
|
|
33
|
+
type: 'boolean',
|
|
34
|
+
summary:
|
|
35
|
+
'serve https with a generated local certificate, cached in .x/tls/ (trust cert.pem once)',
|
|
36
|
+
},
|
|
23
37
|
{ name: 'once', type: 'boolean', summary: 'boot, report, exit — for smoke tests and CI' },
|
|
24
38
|
],
|
|
25
39
|
};
|