@ultimat3/cli 31.17.0 → 31.18.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.
@@ -322,6 +322,7 @@ x g admin:page <name> --permission <perm> [--at <dir>] # a custom admin screen
322
322
  x g guard <name> # a convention this app enforces, as a build error
323
323
  x g sign-in --password | --oidc <provider> # the app's one sign-in: pages, actions, boot guard
324
324
  x g chart-alerts [--print] # the chart's ServiceMonitor + alert rules, backfilled
325
+ x g chart-dashboard [--print] # the chart's Grafana dashboard + its ConfigMap, backfilled
325
326
  x g app <name> # one more app workspace: apps/<name>/
326
327
  x g package <name> # one more shared package: packages/<name>/
327
328
  ```
@@ -339,6 +340,8 @@ The boot guard is generated, app-owned: `apps/web/runtime.ts` calls `assertSignI
339
340
 
340
341
  **`x g chart-alerts`** (`As of 2026-11`) writes the two monitoring templates `x new`'s chart carries into an app chart that predates them — `docker/helm/templates/servicemonitor.yaml` and `alert-rules.yaml`, named after `Chart.yaml`'s `name` — and appends the `serviceMonitor:` / `alerts:` blocks `values.yaml` lacks. Only what is missing: a template already there is kept (`--force` rewrites both), and a values key already there — `enabled: false` included — is never touched; both templates read a missing block as `auto`, rendering only where the cluster serves the Prometheus operator's kinds. A second run writes nothing. No `<name>`, and any other `x g` flag but `--force`/`--dry-run` is `X_CLI_BAD_FLAG`. **`--print`** writes nothing and needs no chart: the same rules as plain Prometheus rule groups, defaults in place, for a loader outside Kubernetes (`--json`: `data.rules`, the YAML text). No `docker/helm/Chart.yaml` is `X_CHART_MISSING`, fix `x g chart-alerts --print --json`. `x doctor` lists the missing templates. The rules: [Observability](Observability).
341
342
 
343
+ **`x g chart-dashboard`** (`As of 2026-11`) is the same backfill for the chart's Grafana dashboard: `docker/helm/dashboards/ultimate-app.json` (one column of panels over the series the framework declares — requests, latency by route, statements, pool, jobs, realtime, the process) and `templates/dashboard-configmap.yaml`, which ships it as a ConfigMap a Grafana sidecar provisions by label — plus the `dashboard:` block `values.yaml` lacks, `enabled: false` (`x new`'s chart writes the same three). The same rules as `chart-alerts`: only what is missing, `--force` rewrites, no `<name>`, `X_CHART_MISSING` with no chart. **`--print`** writes nothing and needs no chart: the dashboard JSON, to import into a Grafana outside Kubernetes (`--json`: `data.dashboard`).
344
+
342
345
  `x g guard <name>` writes `guards/<name>.ts` and its test. A name the framework ships a guard under — `raw-length`, `raw-breakpoint`, `raw-z-index`, `raw-shadow`, `raw-motion`, `undefined-style-class`, `undeclared-custom-property`, `repo-raw-sql` and every other name in `SHIPPED_GUARD_NAMES` (`packages/cli/src/templates/scaffold-guards.ts`) — writes THAT guard, which is how an app adopts one it does not hold; any other name writes the blank template. `x doctor` lists the shipped ones missing, and the held ones that differ from the current template ([Interface rules](Interface-Rules#stylesheets)).
343
346
 
344
347
  **`x g cron-job` · `x g purge` · `x g webhook-receiver`** (`As of 31.17.0`) scaffold a primitive *factory*'s one declaration — each a factory over `job()`, never a ninth primitive — with its tests, into the feature's slice, listed in `apps/web/api/index.ts`'s `jobs:`. None reads a table, so a slice with no `entity.ts` is fine.
@@ -369,7 +372,7 @@ is a word (`a-z`, `0-9`, `-`, `_`) or `[param]` / `[...rest]`; `..`, `.` and emp
369
372
  | `--locales` | string | every locale with a catalog in `packages/i18n/catalogs/`, else `en` | comma-separated locales; lands each generator's catalog entry in every one. **Never starts a catalog** in an app that has any: a non-default locale with no `packages/i18n/catalogs/<locale>.json` is `X_CLI_BAD_FLAG`, `fix: x i18n add <locale>`, before a file is planned — a catalog a generator started would hold only its own keys. A non-default locale's new keys land marked `⟦…⟧`, as `x i18n add` seeds them, so `x i18n check` reports them until translated. In an app with no catalogs yet, a first `--locales en,es` writes `en` bare and `es` marked. `As of 2026-10-06` (`localiseCatalogs`, `packages/cli/src/generate-catalog-locales.ts`) |
370
373
  | `--password` | boolean | `false` | `sign-in` only: an address and a password over `login()` |
371
374
  | `--oidc` | string | — | `sign-in` only: an OpenID Connect provider id (`corp-sso`; lowercase, digits, hyphens, not a built-in), discovered from `<PROVIDER>_ISSUER` |
372
- | `--print` | boolean | `false` | `chart-alerts` only: print the alert rules as plain Prometheus rule groups, write nothing. On any other generator it is `X_CLI_BAD_FLAG` |
375
+ | `--print` | boolean | `false` | `chart-alerts` and `chart-dashboard` only: print the alert rules as plain Prometheus rule groups, or the dashboard as Grafana JSON, write nothing. On any other generator it is `X_CLI_BAD_FLAG` |
373
376
  | `--force` | boolean | `false` | overwrite existing files |
374
377
  | `--dry-run` | boolean | `false` | the write plan, nothing written: **every file the run would touch** — the ones it creates (a slice module already on disk is skipped, not listed) and, `As of 27.6.2`, the ones it EDITS outside the slice (role map, typed handle, API index, manifests, catalogs, the i18n index), in the order the run lists them. `--json`: `data.files` is that list, `data.edits` the subset that already exists, `data.refreshes` the committed contracts (`x.manifest.json`, `openapi.json`) a real run re-projects. `ok: false` with every finding the real run would report — an existing file, an API-index binding already held, a grant or a handle entry it cannot place |
375
378
 
@@ -1244,7 +1247,7 @@ Four warnings about how the app is held, `As of 31.16.0` — beside the verdict,
1244
1247
  | `X_FRAMEWORK_PIN_RANGE` | an `@ultimat3/*` dependency in any of the app's manifests is anything but an exact version or a `workspace:`/`file:`/`link:` path (`^31.0.0`, `*`, `latest`, `>=31 <32`; an `npm:` alias by its own spec), one finding per manifest | the exact version `bun install` resolved, at the line named; then `bun install` |
1245
1248
  | `X_ENV_NAME_RESERVED` | a name the app declares in `envSchema` or seals in `secrets.enc.json` is one `FRAMEWORK_ENV` (`@ultimat3/core`) lists as a `switch` or `internal` name — setting it for the app also switches that package's behaviour. Deploy-contract names (`DATABASE_URL`, `PORT`) and host names are not collisions | rename it `APP_<name>` (or delete it where the value is meant for the framework); then `x env example` |
1246
1249
 
1247
- **The chart's monitoring templates**, the same way (`As of 2026-11`): an app with a `docker/helm/Chart.yaml` and no `templates/servicemonitor.yaml` or `templates/alert-rules.yaml` gets one line per missing file, then `x g chart-alerts`, which writes only those (`--json`: `data.chartAlerts`, `{ missing[], add }`). A chart that dropped them on purpose keeps a green verdict; an app with no chart is listed nothing.
1250
+ **The chart's monitoring templates**, the same way (`As of 2026-11`): an app with a `docker/helm/Chart.yaml` and no `templates/servicemonitor.yaml` or `templates/alert-rules.yaml` gets one line per missing file, then `x g chart-alerts`, which writes only those (`--json`: `data.chartAlerts`, `{ missing[], add }`). The dashboard is its own row: no `dashboards/ultimate-app.json` or `templates/dashboard-configmap.yaml` lists them, then `x g chart-dashboard` (`data.chartDashboard`, the same shape). A chart that dropped them on purpose keeps a green verdict; an app with no chart is listed nothing.
1248
1251
 
1249
1252
  The embedded half is the bare-VM case: the external-database probe answers nothing the moment `DATABASE_URL` is unset, and that silence *is* the configuration a fresh box has. So `x doctor` also asks whether `@electric-sql/pglite` resolves from the app root — a resolve, never an import, because loading it boots the WASM build and takes the single-writer lock the next command needs. Red only where both hold: `DATABASE_URL` unset **and** the peer unresolvable, reported as `X_DB_UNAVAILABLE` with `@ultimat3/db`'s own sentence and its own runnable fix ([Bare VM](Bare-VM)). The snapshot half is `As of 2026-08` and separate from drift on purpose: they are two questions with two remedies, and `x db gen`'s own `X_MIGRATION_SNAPSHOT_MISSING` was a condition this diagnostic could not see at all, so `x doctor --json` — the `fix:` of the `X_CLI_UNEXPECTED` an author reaches it through — ran clean over a broken app.
1250
1253
 
@@ -233,6 +233,7 @@ Declared in `process-metrics.ts` and `packages/db/src/pool-gauge.ts`, started by
233
233
  | `process_event_loop_lag_seconds` | histogram | `s` | none | how late a 1,000 ms timer fired, one sample a second |
234
234
  | `process_start_time_seconds` | gauge | `s` | none | Unix time the process started |
235
235
  | `process_info` | gauge | `1` | `role` | always 1; `role` is `ROLE`, or `x dev`'s roles joined by `+` |
236
+ | `process_memory_limit_bytes` | gauge | `By` | none | the container's memory limit, cgroup v2 `memory.max`, read once per start (`As of 2026-11`). **Absent** where there is none: `max`, no cgroup v2 file, not Linux. `process_resident_memory_bytes / process_memory_limit_bytes` is how near the pod is to its OOMKill |
236
237
  | `db_pool_max` | gauge | `{connection}` | none | connections this process may open, summed over its pools |
237
238
  | `db_pool_in_use` | gauge | `{connection}` | none | connections running a statement or pinned by a transaction |
238
239
  | `db_pool_waiting` | gauge | `{statement}` | none | statements and pins queued because the pool is at `max` |
@@ -243,6 +244,10 @@ Declared in `process-metrics.ts` and `packages/db/src/pool-gauge.ts`, started by
243
244
  - **`queue_wake_live`** (gauge, `worker` only): 1 once a notification has crossed the worker's `LISTEN` session, 0 while jobs start on the poll alone — a transaction-pooling proxy disables the wake without an error.
244
245
  - **What grows?** `process_resident_memory_bytes` rising with `process_heap_used_bytes` flat is memory outside the heap (`process_external_memory_bytes`, or the allocator); both rising is a retained structure.
245
246
 
247
+ ### Alerts and the dashboard the chart ships
248
+
249
+ `As of 2026-11`. The Helm chart's `alert-rules.yaml` holds the mechanism alerts, now with multi-window error-budget burn: `UltimateErrorBudgetFastBurn` (the 5xx share above 14.4 × the budget over 1h and 5m) and `UltimateErrorBudgetSlowBurn` (6 × over 6h and 30m). Both are measured against `alerts.objective`, in percent, default 99.9. Saturation rules sit beside them: `UltimateJobFailures`, `UltimatePoolSaturated`, `UltimateEventLoopLag` and `UltimateMemoryNearLimit`. The chart also ships one Grafana dashboard, off by default (`dashboard.enabled`), as a ConfigMap for a Grafana sidecar. `x g chart-alerts` / `x g chart-dashboard` backfill an older chart, and `--print` serves a loader outside Kubernetes. Every rule and panel is held to a declared series (`scripts/chart-alerts.test.ts`, `scripts/chart-dashboard.test.ts`). The full table and the runbooks: [`docs/ops/03-observability.md`](https://github.com/developerz-ai/ultimate/blob/main/docs/ops/03-observability.md#alerts-on-the-apps-own-metrics).
250
+
246
251
  ### The one series a `sync` node adds
247
252
 
248
253
  | Instrument | Name | Kind | Unit | Labels |
@@ -269,7 +274,7 @@ CPU autoscaling is wrong for `sync` and `worker`: a node holding 80k idle socket
269
274
  | Head sampling | `otel.sampling`, default `0.1`; errors are always sampled |
270
275
  | OTLP delivery | a 429, 502, 503, 504 or a transport failure is retried, 3 attempts with full jitter and `Retry-After` honoured, inside the exporter's `timeoutMs` (default 10 s, the whole export); any other status is one POST. One `otlp export rejected`/`failed` line per batch, with `attempts`. A collector that accepted and then answered 503 receives that batch twice; span ids dedupe it |
271
276
  | Error grouping | `errorFingerprint(report)`: 16 hex over `code`, `source`, `scope.operation`, plus the top application frame (function and root-relative path, no line) for `X_INTERNAL`. Never the cause or an id, so two throws differing in a row id are one group, and a deploy is not a new one. The Sentry envelope sends it as `fingerprint` |
272
- | Log level | `LOG_LEVEL`, default `info` |
277
+ | Log level | `LOG_LEVEL`, default `info`. The framework's own policy (`As of 2026-11`): a routine per-unit event (one per request, job, fire or message) is `debug`; `info` is lifecycle and rare outcomes; `warn` asks an operator to act. `scripts/log-levels.ts` refuses an unstated per-unit `info` line in the framework (`X_LOG_LEVEL_UNSTATED`) |
273
278
  | Secret redaction | a `Secret` is redacted by value before every other branch, at any depth → [Configuration](Configuration) |
274
279
  | Request context | the ALS context carries the request id every log line and span inherits |
275
280
  | Live queries | the realtime client puts a `traceparent` on the `subscribe` frame (`LiveClient({ traceparent })`); the snapshot that subscribe causes is the span `live.snapshot <query>`, a CHILD of it, and a re-read a change forces is `live.rerun <query>`, which LINKS to it and parents on the change. A value that is not a valid W3C header is ignored, never refused: telemetry never fails a subscribe. The page boot sends none (`As of 2026-11`): a browser holds no trace |
package/wiki/Testing.md CHANGED
@@ -926,6 +926,38 @@ await insertSeedGraph(graph, writer);
926
926
 
927
927
  `X_SEED_GRAPH_UNSATISFIED` names the table, the columns to supply and the `defineFactory` call. `As of 2026-11-05`, `seed-graph.live.test.ts` inserts both tracked apps' schemas into Postgres with no factory, and `seed-graph-pglite.test.ts` the same into PGlite, in the unit step. Source: `packages/testing/src/seed-graph*.ts`.
928
928
 
929
+ ## Property checks
930
+
931
+ `As of 2026-11`. `property(gen, fn, { runs, seed, maxShrinks })` checks a claim against `runs` (200) seeded draws. A throw or a `false` fails it as `X_TEST_PROPERTY_FAILED`. The failure carries the input shrunk by halving to the smallest that still fails, plus a `fix:` whose `{ seed, runs }` replays exactly that draw.
932
+
933
+ ```ts
934
+ import { decodeCursor, encodeCursor } from '@ultimat3/core';
935
+ import { expect, gen, property, unitTest } from '@ultimat3/testing';
936
+
937
+ const position = gen.map(
938
+ gen.tuple(gen.string({ maxLength: 24 }), gen.string(), gen.array(gen.int(-100, 100))),
939
+ ([scope, id, key]) => ({ scope, id, key }),
940
+ );
941
+
942
+ unitTest('a cursor round-trips any position', () => {
943
+ property(position, (payload) => {
944
+ expect(decodeCursor(encodeCursor(payload), payload.scope)).toEqual(payload);
945
+ });
946
+ });
947
+ ```
948
+
949
+ | Fact | Why |
950
+ |---|---|
951
+ | the default seed is fixed | the gate never flakes; pass another `seed` to explore |
952
+ | draw *n*'s size never depends on `runs` | so `{ runs: n }` replays draw *n* |
953
+ | a promise returned is refused (`PropertyAsyncError`, the same code) | every draw would pass before its assertion ran |
954
+ | `gen`: `int` `oneOf` `union` `map` `constant` `array` `tuple` `string` `bytes` `json`; `HOSTILE_CHARS` | each draw carries its shrinks, so a mapped value shrinks through its source |
955
+ | the framework's own: `packages/testing/src/property-*.test.ts` | cursor, canonical JSON, money, byte range, cookie, pgoutput, interpolate, `estimateBytes`. They found two shipped bugs (fixed in 31.18.0): `parseAmount` refused BHD formatted in `ar-EG`, and the pgoutput decoder accepted a negative length |
956
+
957
+ ## The heap canary
958
+
959
+ `As of 2026-11`. `soak({ fetch, requests, total, warmup, maxGrowthBytes })` sends `total` (20,000) requests round-robin through an in-process handler, after `warmup` (2,000). It then compares the live heap after `Bun.gc(true)`; growth past `maxGrowthBytes` is `X_TEST_SOAK_HEAP_GROWTH`. Every response status is counted, because a soak that only ever answered 500 soaked nothing. The bound is a measurement: three runs, the largest × 1.5, written beside it. `measureSoak` reports without a verdict. The framework's own canary is `packages/testing/src/soak.live.test.ts` (SSR, an action, a query, a 404, a 400), in the `live` step.
960
+
929
961
  ## Shared examples
930
962
 
931
963
  One contract, asserted against many subjects, with the subject passed as a **thunk** so a `beforeAll`-built value is read at test time rather than at declaration time.
package/wiki/Upgrading.md CHANGED
@@ -276,6 +276,10 @@ A setter still on a package's `.` barrel is `X_ADAPTER_PORT_INCOMPLETE` on the `
276
276
  | `x exercise` prints new **warning lines** (**31.17.0**): one per route `load` it ran or could not run (`route <path> (<file>) · …`, `routes[]` in `.x/exercise.json`), and `X_EXERCISE_EMPTY_REACH` for primitives reached with no statement and no effect. Never red — no `x.verify.json` key opts a page read in yet | nothing. To clear the empty-reach line, give each named primitive an input in `apps/web/exercise.ts` that reaches its work, or `{ off: '<why>' }` |
277
277
  | A worker, scheduler or sync container no longer logs the web role's boot warnings (**31.17.0**); every container logs `boot.phase { role, name, ms }` per phase; `/readyz` pings the database at most once a second | nothing. A log alert keyed on a warning in a non-web role stops firing: re-point it at the `web` role |
278
278
  | `x dev` sets aside an embedded data directory that will not open (**31.17.0**): `.x/pgdata` becomes `.x/pgdata.unopenable-<UTC>` and the boot starts an empty database (`X_DEV_DATA_UNOPENABLE`) | `x db migrate`, then `x db seed` if the app has one. The moved directory holds the old rows; delete it once they are not needed |
279
+ | the admin's search box, a list's `contains` filter and a reference lookup now ignore case (**31.18.0**). Each is the entity's own `contains`, a bound `ilike`, so `acme` finds `Acme Ltd`. A `contains` your app DECLARES, in `rows` or in a scope's `where`, is unchanged: still case-sensitive on the read and the write, because a row scope is authorization | nothing. On a large table, serve the search with a trigram index on the searched column: `indexes: [{ on: ['title'], using: 'gin', operatorClass: 'gin_trgm_ops' }]` on the entity, then `x db gen` (the plan sweep's `X_QUERY_UNINDEXED` names the column) |
280
+ | a hand-written `AdminRepo` receives `caseSensitive: true` on each `contains` filter the app declared (`rows`, a scope's `where`), and a bare `contains` from what an operator typed (**31.18.0**). The admin's search also reads up to four resources at once instead of one after another | nothing for `adminRepoFor`. A custom repo that compiles `contains` itself: keep the exact, case-sensitive match where `filter.caseSensitive === true`, and fold case otherwise to match the entity repo. A custom repo must already allow concurrent reads, which every pool does |
281
+ | the framework's Helm chart (`docker/helm`) and `x new`'s chart request less memory for web and worker and more for the scheduler (**31.18.0**): web 256Mi → 128Mi, worker 256Mi → 160Mi, scheduler 128Mi → 160Mi. These are measured idle plus headroom. Limits are unchanged | nothing. To keep the old requests on the framework's chart: `--set roles.web.resources.requests.memory=256Mi` (and `roles.worker…`/`roles.scheduler…`). An app chart `x new` wrote keeps its own values until you edit them |
282
+ | the chart has six new alert rules (**31.18.0**): `UltimateErrorBudgetFastBurn` / `UltimateErrorBudgetSlowBurn` against `alerts.objective` (default 99.9), plus `UltimateJobFailures`, `UltimatePoolSaturated`, `UltimateEventLoopLag` and `UltimateMemoryNearLimit`. It also has an opt-in Grafana dashboard (`dashboard.enabled: false`). Every process on a memory-limited container now emits `process_memory_limit_bytes` | nothing; an older app chart keeps its rules. To adopt the new rules: `x g chart-alerts --force`. To add the dashboard: `x g chart-dashboard`, then set `dashboard.enabled: true` where a Grafana sidecar runs. `x doctor` lists the dashboard files while the chart lacks them. To disable one rule: `alerts: { rules: { UltimateEventLoopLag: { enabled: false } } }` |
279
283
 
280
284
  ## 29.x → 30.0.0, entry by entry
281
285