@ultimat3/cli 31.28.0 → 31.30.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 (43) hide show
  1. package/CLAUDE.md +1 -0
  2. package/package.json +29 -29
  3. package/src/app-migrations-verdict.ts +85 -0
  4. package/src/cmd-db-recount.ts +38 -43
  5. package/src/cmd-db-spec.ts +3 -2
  6. package/src/cmd-db-status.ts +80 -0
  7. package/src/cmd-db.ts +4 -2
  8. package/src/cmd-drill.ts +23 -9
  9. package/src/codemods/helm-alerts-deploy.ts +85 -0
  10. package/src/codemods/index.ts +4 -0
  11. package/src/codemods/migrate-job-ordered.ts +81 -0
  12. package/src/codemods/migrate-job-stock.ts +41 -0
  13. package/src/db-client-displace.ts +65 -0
  14. package/src/db-diagnostics.ts +25 -28
  15. package/src/db-status.ts +185 -0
  16. package/src/drill-schema-behind.ts +26 -0
  17. package/src/error-codes.ts +3 -0
  18. package/src/framework-schema-apply.ts +7 -19
  19. package/src/framework-schema-stamp.ts +38 -3
  20. package/src/framework-schema-verify.ts +120 -0
  21. package/src/framework-schema-wait.ts +125 -0
  22. package/src/mcp-errors.ts +4 -3
  23. package/src/messages-db.ts +12 -0
  24. package/src/role-pg-stats.ts +21 -0
  25. package/src/role-start.ts +4 -0
  26. package/src/runtime-queue.ts +47 -8
  27. package/src/serve-boot-probe.ts +97 -0
  28. package/src/serve-boot.ts +26 -1
  29. package/src/serve-retire.ts +16 -3
  30. package/src/templates/chart-dashboard-panels.ts +178 -0
  31. package/src/templates/chart-dashboard.ts +9 -135
  32. package/src/templates/scaffold-container.ts +2 -2
  33. package/src/templates/scaffold-helm-alert-deploy.ts +105 -0
  34. package/src/templates/scaffold-helm-alert-rules.ts +7 -1
  35. package/src/templates/scaffold-helm-alerts.ts +3 -0
  36. package/src/templates/scaffold-helm-migrate.ts +85 -0
  37. package/src/templates/scaffold-helm-templates.ts +2 -36
  38. package/src/templates/scaffold-helm.ts +1 -0
  39. package/wiki/CLI-Reference.md +14 -1
  40. package/wiki/Deployment.md +2 -1
  41. package/wiki/Known-Gaps.md +1 -1
  42. package/wiki/Scraping.md +20 -0
  43. package/wiki/Upgrading.md +1 -0
@@ -51,7 +51,7 @@ x version # CLI version
51
51
  | `x tasks` | cron tasks, their timezone and their next run | shipped |
52
52
  | `x policy` | which clause decided a permission, and why | shipped |
53
53
  | `x exercise [<name>] [--seed n] [--shard i/n]` | run every action, query, job and route `load` once on generated rows, with no test written; the gate's `exercise` step | shipped |
54
- | `x drill [<name>] [--list] [--budget-ms n]` | the app's `web` and `worker` roles as real processes on real Postgres, Redis and NATS, each dependency faulted through a proxy or each role signalled, red on any framework contract that does not hold. Not a gate step: it needs the services | shipped |
54
+ | `x drill [<name>] [--list] [--budget-ms n]` | the app's roles as real processes on real Postgres, Redis and NATS, each dependency faulted through a proxy, each role signalled, or every role started before `ROLE=migrate`, red on any framework contract that does not hold. Not a gate step: it needs the services | shipped |
55
55
  | `x i18n` | add, sync, check catalogs | shipped |
56
56
  | `x mail preview <id>` | render a mail's declared `preview` in every locale, nothing sent | shipped |
57
57
  | `x test <type>` | run one of the six test types, or the whole suite | shipped |
@@ -485,6 +485,7 @@ x db gen "add publish_at" | migrate | reset
485
485
  | backfill --pending [--json]
486
486
  | backfill <name>|--all [--write] [--force] [--json]
487
487
  | diagnostics [--limit n] [--json]
488
+ | status [--json]
488
489
  ```
489
490
 
490
491
  | Subcommand | Does | Notes |
@@ -501,6 +502,7 @@ x db gen "add publish_at" | migrate | reset
501
502
  | `backfill <name>` / `backfill --all` | gate one sweep (or every pending one) and enqueue it | **dry run by default** — `--write` is never implied. `--write` enqueues; the workers perform the pass, because the queue is a job's execution surface. `--all` isolates per name and continues past a failure, exiting non-zero naming each |
502
503
  | `diagnostics` | what the database is doing now: `blockers` (each waiting `pid` and the `blockedBy` pid holding it, at `data.blockers.rows[]`), `activity`, `slowQueries`, `unusedIndexes`, `invalidIndexes`, `notValidConstraints`, `deadTuples` | **facts, never a verdict: exit 0** whatever they say. The one failure is a connection that never opens, `X_DB_UNAVAILABLE`. Every section is one catalog read in its own `BEGIN READ ONLY` with a 2 s `statement_timeout`, capped at `--limit` rows (default 20, at most 1000). A section that fails is `{ available: false, code, reason, fix }` in place and the other six still answer; `slowQueries` is unavailable until an operator installs `pg_stat_statements` (never on the embedded database). No user table is read; session SQL is printed with every literal as `?`; a credential in a reason is masked. **Whoever runs it sees the redacted SQL of every session on the app's database role** (every role, when it holds `pg_read_all_stats`): statement shape and identifiers, never values. `unusedIndexes` skips unique and primary indexes and carries `statsAgeSeconds` and `replica`. Opens the database without applying the framework tables; an embedded one `x dev` holds is refused (`X_DEV_ALREADY_RUNNING`). `--json`: `data.<section>`. Arbitrary read-only SQL is `db.query` over [`x mcp serve`](MCP-And-AI) |
503
504
  | `recount <entity>.<column>` | compare a `countedIn` counter with the true count of its child rows | **dry run by default**: lists the drifted rows (at most 50, the count whole) and exits non-zero with `X_LIFECYCLE_TRIGGER_MISSING` when any drifted. The parent is walked in windows of 1,000 keys, in key order, each window one cross-tenant transaction (`As of 31.23`). `--write` repairs each window's drift inside its transaction and exits 0. An unknown `<entity>.<column>` is `X_CLI_BAD_FLAG`. `--json`: `data` = `{ target, write, drifted, batches, rows }` |
505
+ | `status` | is this database at this build? The app migrations this build ships against the `x_migrations` ledger (`pending`: shipped, not applied; `ahead`: applied, not shipped; `edited`: applied, the file now hashes otherwise), and the framework stamp (`framework.applied`, the newest build it records, a major skew) | **one read, no writes**, `As of 2026-11-15`: the stamp comment and the ledger rows, judged by the rules a serving role's boot applies (`appMigrationsVerdict`, `stampVerdict`). No DDL, no ledger created, no migrate lock; an embedded database never created is reported as nothing applied without being initialised, one `x dev` holds is refused (`X_DEV_ALREADY_RUNNING`). **Non-zero exit** with the boot's own findings when behind — `X_FRAMEWORK_SCHEMA_UNAPPLIED`, `X_APP_MIGRATIONS_UNAPPLIED` (fix `x db migrate`) — and the ledger judged as `x db migrate` judges it (`ledgerAheadOfBuild`, then `auditLedger`): an edited migration, or an `ahead` row that is not exactly a rollback — one sorting before the newest migration this build ships, or beside a pending one — is `X_MIGRATION_CONFLICT`; a rollback over a row recorded destructive is `X_MIGRATION_ROLLBACK_DESTRUCTIVE` unless `ROLLBACK_ALLOW_DESTRUCTIVE` names it. An `ahead` that is exactly a rollback exits 0: `x db migrate` accepts it and a serving role serves it with a warning (a rollback, or a rollout's old pods). `--json`: `data` = `{ shipped, applied, pending, ahead, edited, framework: { version, schema, applied, newest, skew, aheadByMajor } }`, `applied` `null` when no ledger exists |
504
506
 
505
507
  A bare `x db backfill` is `X_CLI_BAD_FLAG` naming a shape that works: the four answer four different questions, and defaulting to one of them is the ambiguity axiom 1 refuses.
506
508
 
@@ -1597,6 +1599,17 @@ sampled throughout.
1597
1599
  | `worker-sigkill` | `SIGKILL` the worker, then a fresh one | `jobs-terminal`, `jobs-once`, `requests-coded` |
1598
1600
  | `worker-sigterm` | `SIGTERM` the worker, then a fresh one | `role-exits`, `jobs-terminal`, `jobs-once` |
1599
1601
  | `web-sigterm` | `SIGTERM` the web role under load | `requests-ok`, `role-exits` |
1602
+ | `roll-before-migrate` | the roles started before `ROLE=migrate`, on a schema stamped by an older build | `roles-wait`, `serves-after-migrate`, `one-wait-line` |
1603
+
1604
+ `roll-before-migrate`, `As of 2026-11-15`, is the rollout order a deploy cannot always hold: no
1605
+ proxy and no load. The scratch database is migrated, its framework stamp (`x_jobs`' table comment)
1606
+ is rewound to name only an older build, then `web`, `worker` and `scheduler` start on it without
1607
+ waiting for readiness. Once each has logged its wait (or exited), they are held 3 s and
1608
+ `ROLE=migrate` runs again. Each must stay up (`roles-wait`: an exit is a crash-loop), log exactly
1609
+ one line naming `X_FRAMEWORK_SCHEMA_UNAPPLIED` (`one-wait-line`), and answer `/readyz` 200 once
1610
+ migrate has run (`serves-after-migrate`). `ULTIMATE_SCHEMA_WAIT_MS` is inherited: `0` — refuse at
1611
+ once — turns it red. Its evidence is `evidence.rollout.roles[]`, each
1612
+ `{ role, exit, ready, waitLines, logTail }`.
1600
1613
 
1601
1614
  Thresholds come from the app: the request deadline (`@ultimat3/http`'s default, 30 s, because
1602
1615
  `configureHttp` is runtime code the CLI does not run), `drain.deadlineMs` plus
@@ -508,12 +508,13 @@ The framework depends on none of this; it is the operations manual for the app y
508
508
  | [`docs/ops/04-datastores.md`](https://github.com/developerz-ai/ultimate/blob/main/docs/ops/04-datastores.md) | sizing Postgres, NATS and object storage for a given rung |
509
509
  | [`docs/ops/05-disaster-recovery.md`](https://github.com/developerz-ai/ultimate/blob/main/docs/ops/05-disaster-recovery.md) | backups, PITR, restore drills, replication-slot recovery |
510
510
  | [`docs/ops/06-runbooks.md`](https://github.com/developerz-ai/ultimate/blob/main/docs/ops/06-runbooks.md) | symptom → page → action, per role |
511
+ | [`docs/ops/07-deploy-contract.md`](https://github.com/developerz-ai/ultimate/blob/main/docs/ops/07-deploy-contract.md) | what a deploy guarantees: order, a role over a schema that is behind, drain, the skew window, rollback, each failure's alert |
511
512
 
512
513
  Two design-only companions — **specification, not shipped behaviour**: [`docs/idea/16-app-targets.md`](https://github.com/developerz-ai/ultimate/blob/main/docs/idea/16-app-targets.md) (three targets, one backend, two view layers) and [`docs/idea/17-scale-ladder.md`](https://github.com/developerz-ai/ultimate/blob/main/docs/idea/17-scale-ladder.md) (why the app code is identical at rung 0 and rung 4).
513
514
 
514
515
  ## Rollback
515
516
 
516
- Redeploy the previous image tag. Inside an `assets.retain` window (below) a rollback 404s nobody mid-session; without one, a tab holding the other build's document reloads.
517
+ Redeploy the previous image tag: `x deploy --image <previous> --json`. `helm rollback` runs the older build's migrate first only onto a revision a 31.29+ chart rendered (a `pre-rollback` hook; Helm runs the target revision's hooks); onto an older one it skips the checks below → [Kubernetes migrations](https://github.com/developerz-ai/ultimate/blob/main/docs/ops/01-kubernetes.md#migrations). Inside an `assets.retain` window (below) a rollback 404s nobody mid-session; without one, a tab holding the other build's document reloads.
517
518
 
518
519
  The older image's migrate role decides whether the schema allows it (`As of 2026-11`). Over ledger rows the newer build applied it applies nothing and logs them (`ahead`). Over a row the newer build RECORDED as destructive (`x_migrations.destructive`, written at apply) it refuses before anything serves:
519
520
 
@@ -58,7 +58,7 @@ CHANGELOG.md` finds its bounds, and it changes on any commit.
58
58
  | Retry-from-step on the jobs dashboard is a free-text field | `As of 2026-10`. `job.retry-from-step` takes `{ step: t.string.min(1) }` (`packages/admin/src/jobs/job-actions.ts`); the run's detail page shows its steps, but the form does not offer them as a choice. | copy the step name from the run's `steps` section on the same page |
59
59
  | The admin MCP batch tool takes `ids` only | `As of 2026-10`. A `batch` action is one MCP tool, `admin.action.<name>`, and it takes the rows by id; "all matching" — the list's own filter — is a screen control only | list the rows with `admin.<entity>.list` and its `where`, then pass their ids |
60
60
  | No counts on the jobs dashboard's state tabs | `As of 2026-10`. `stats()` counts per queue across every tenant, so a count on a tab would show an org-scoped operator other orgs' numbers; the tabs carry none and the overview's tiles carry the counts, for a platform operator only. A per-tenant count is a second query nothing issues yet | a platform operator reads the overview tiles; an org-scoped operator reads a tab's own page |
61
- | `x drill` proves one node per role on one machine, and drills no object store and no CDN | `As of 2026-11-06`. The fleet is one `web`, one `worker` (and one `sync` for `nats-down`) on one host, every dependency a local container behind a Bun TCP proxy: a multi-node NATS cluster, a Postgres failover to a real standby, a real S3 bucket and a real CDN in front of the web role are never faulted. `nats-down`'s sync lane is proven on a stand-in node (`packages/testing/src/drill-sync.test.ts`), not on `examples/dummy`, whose transport is in-memory; its client subscribes to nothing by default, so a gap counts only what the node volunteers. CI runs three of the eight (`fault-drills`) [pin](https://github.com/developerz-ai/ultimate/blob/main/packages/testing/src/drills.test.ts#the%20eight%20drills%2C%20once%20each) | the rest by hand: `x drill --list --json`, then `x drill <name> --json` with `docker/test-services.env` loaded. A multi-node or object-store fault is a staging drill of your own, against [`docs/ops/06-runbooks.md`](https://github.com/developerz-ai/ultimate/blob/main/docs/ops/06-runbooks.md) |
61
+ | `x drill` proves one node per role on one machine, and drills no object store and no CDN | `As of 2026-11-06`. The fleet is one `web`, one `worker` (and one `sync` for `nats-down`) on one host, every dependency a local container behind a Bun TCP proxy: a multi-node NATS cluster, a Postgres failover to a real standby, a real S3 bucket and a real CDN in front of the web role are never faulted. `nats-down`'s sync lane is proven on a stand-in node (`packages/testing/src/drill-sync.test.ts`), not on `examples/dummy`, whose transport is in-memory; its client subscribes to nothing by default, so a gap counts only what the node volunteers. CI runs four of the nine (`fault-drills`, `roll-before-migrate` among them) [pin](https://github.com/developerz-ai/ultimate/blob/main/packages/testing/src/drills.test.ts#the%20nine%20drills%2C%20once%20each) | the rest by hand: `x drill --list --json`, then `x drill <name> --json` with `docker/test-services.env` loaded. A multi-node or object-store fault is a staging drill of your own, against [`docs/ops/06-runbooks.md`](https://github.com/developerz-ai/ultimate/blob/main/docs/ops/06-runbooks.md) |
62
62
 
63
63
  ## Open by decision
64
64
 
package/wiki/Scraping.md CHANGED
@@ -549,6 +549,26 @@ A test passes `renderer:` (any `PdfRenderer`); `chromePdfRenderer({ launch })` t
549
549
 
550
550
  **The CDP launcher moved.** `findChrome`, `launchChrome`, `launchFoundChrome`, `cdpConnect`, `cdpConnectOver`, the `Cdp*Error` classes and the `CHROME_*` / `LAUNCH_*` constants live in `@ultimat3/scraping/cdp` since 31.0.0 (its own entry, importing core only), and `X_CDP_*` are registered by scraping. It is their one import path: `@ultimat3/testing` no longer re-exports them, and `E2E_BROWSER_CLOSE_MS` is `LAUNCHED_CLOSE_MS` here ([Upgrading](Upgrading) #53).
551
551
 
552
+ **A test launches through `launchReady`** (`As of 2026-11-15`), from the same entry: `launchChrome`, then ready once the page it was handed EXISTS — heard as `Target.targetCreated`, never polled for, so a cold start (a Windows runner) is waited for rather than read early. The test takes `launchTestMs(launchTimeoutMs)` as its deadline — `LAUNCH_TEST_MS` at the default — so the launch's own `X_CDP_LAUNCH_FAILED` is what a slow browser reports, never Bun's timeout:
553
+
554
+ ```ts
555
+ import { test } from 'bun:test';
556
+ import { findChrome, LAUNCH_TEST_MS, launchReady } from '@ultimat3/scraping/cdp';
557
+
558
+ const executable = await findChrome(process.env);
559
+
560
+ test.skipIf(executable === undefined)('the page the browser was handed', async () => {
561
+ const browser = await launchReady({ executable: executable ?? '', timeoutMs: 20_000 });
562
+ try {
563
+ await browser.connection.send('Target.getTargets');
564
+ } finally {
565
+ await browser.close();
566
+ }
567
+ }, LAUNCH_TEST_MS);
568
+ ```
569
+
570
+ `bun run scripts/launch-deadline.ts` refuses a test that awaits a launch under a deadline of its own (`X_TEST_LAUNCH_DEADLINE`).
571
+
552
572
  A social card for a row published at runtime is the same shape: `page.screenshot()` of the row's
553
573
  1200 x 630 card page, `disk().put()`, then `og: { image }` — [SEO](SEO#a-card-the-build-photographs-ogcapture)
554
574
  covers the cards a static build takes itself. `examples/dummy`'s `runs/jobs/print-statement.ts` is
package/wiki/Upgrading.md CHANGED
@@ -298,6 +298,7 @@ A setter still on a package's `.` barrel is `X_ADAPTER_PORT_INCOMPLETE` on the `
298
298
  | a new shipped guard, `runtime-pin` (**31.28.0**), built in: it reports where the app's Bun pins disagree — `engines.bun`, `packageManager`, `.bun-version`, CI's `bun-version:`, the Dockerfile's `oven/bun` image and its digest | `x upgrade --json` (its `runtime-pin` codemod moves a scaffold-written pin onto today's; a pin you wrote is reported, never rewritten), then `x verify --only boundaries --json`; to opt out, `"runtime-pin": "off"` in `guards/shipped.json` |
299
299
  | `x upgrade` applies **codemods** from **31.28.0**: every scaffold-owned change between your version and the target is carried as a codemod (`data.codemods`); a file you edited is listed with its diff and never overwritten. After a hop an older CLI drove, apply them with `x upgrade codemods --from <old version> --json` | nothing; read `data.codemods.skipped` after each hop |
300
300
  | a stopped `x upgrade` (**31.28.0**) leaves `.x/upgrade.json`; rerunning it to the same `--to` finishes the hop — install, codemods, gate — and a second `x upgrade` in the same app is refused while one runs (`X_UPGRADE_LOCKED`). Ctrl-C or SIGTERM now stops the hop's own children too | stash a stopped hop's tree, never commit it: `git stash push --include-untracked`, then `x upgrade --to <same version> --json` |
301
+ | a serving role over a schema behind its build **waits** for the migrate step (**31.29.0**) instead of exiting — framework stamp and app migrations alike — and exits after `ULTIMATE_SCHEMA_WAIT_MS` (default 300000); the chart's migrate Job is an Argo CD `Sync` hook in wave −1, named by a hash of its image, its migrate settings and the chart version, deleted on success, and runs on `helm rollback` too | `x upgrade --json` (codemods `migrate-job-ordered`, `helm-alerts-deploy`); after a pre-31.29 chart, `kubectl delete job <release>-migrate` once; `ULTIMATE_SCHEMA_WAIT_MS=0` keeps the old refuse-at-once |
301
302
  | `overrides` an app carries for `seroval`, `seroval-plugins` or `source-map-js` are no longer needed from **31.28.0**: `@ultimat3/ui`'s `solid-js` peer is `^1.9.18`, which requires the patched `seroval`; `source-map-js` and `immutable` arrive through `sass` and need a refreshed lockfile. `x doctor` warns below each floor (`X_ADVISORY_FLOOR_UNMET`) | drop those `overrides`, then `x upgrade --json` (its `solid-floor` codemod raises `solid-js`) and `bun update source-map-js immutable` |
302
303
 
303
304
  ## 29.x → 30.0.0, entry by entry