@ultimat3/cli 31.51.0 → 31.52.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 (65) hide show
  1. package/README.md +9 -9
  2. package/package.json +29 -29
  3. package/src/catalog-layout.ts +194 -0
  4. package/src/cmd-i18n-spec.ts +4 -4
  5. package/src/cmd-i18n-split.ts +133 -0
  6. package/src/cmd-i18n.ts +46 -66
  7. package/src/config-redact.ts +20 -4
  8. package/src/db-rollback-pass.ts +4 -1
  9. package/src/dev-child-watch.ts +16 -0
  10. package/src/dev-db-migrate.ts +27 -46
  11. package/src/dev-db-migrator-hold.ts +131 -0
  12. package/src/dev-db-rollback.ts +11 -2
  13. package/src/dev-rebuild-schema.ts +7 -24
  14. package/src/generate-catalog-locales.ts +25 -2
  15. package/src/generate-follow-ups.ts +8 -3
  16. package/src/i18n-audit.ts +17 -33
  17. package/src/i18n-index.ts +108 -31
  18. package/src/i18n-locale-parity.ts +14 -6
  19. package/src/i18n-new-locale.ts +75 -0
  20. package/src/i18n-registration.ts +52 -27
  21. package/src/island-capture.ts +36 -7
  22. package/src/merge-state.ts +3 -2
  23. package/src/messages-floor.ts +2 -0
  24. package/src/messages.ts +2 -0
  25. package/src/serve-boot-telemetry.ts +106 -0
  26. package/src/serve-boot.ts +23 -4
  27. package/src/shot-blank.ts +70 -0
  28. package/src/templates/catalog-barrel.ts +84 -0
  29. package/src/templates/guard-released-forms.ts +2 -1
  30. package/src/templates/guard-untranslated-string.ts +27 -6
  31. package/src/templates/locales.ts +6 -0
  32. package/src/templates/scaffold-gitattributes.ts +9 -2
  33. package/src/templates/scaffold-i18n.ts +10 -6
  34. package/src/templates/shapes/offline.ts +5 -2
  35. package/src/test-ignores.ts +3 -2
  36. package/src/verify-floor.ts +9 -1
  37. package/src/verify-local-only.ts +66 -0
  38. package/src/verify-run.ts +17 -2
  39. package/wiki/Actions.md +1 -1
  40. package/wiki/Auth.md +3 -3
  41. package/wiki/Batching-And-Preloading.md +1 -0
  42. package/wiki/CLI-Reference-Data.md +241 -0
  43. package/wiki/CLI-Reference-Gate.md +572 -0
  44. package/wiki/CLI-Reference-Project.md +414 -0
  45. package/wiki/CLI-Reference-Ship.md +348 -0
  46. package/wiki/CLI-Reference-Tools.md +666 -0
  47. package/wiki/CLI-Reference.md +14 -2225
  48. package/wiki/Compared.md +8 -8
  49. package/wiki/Configuration.md +26 -2
  50. package/wiki/Deployment.md +1 -1
  51. package/wiki/Entities-And-Migrations.md +3 -2
  52. package/wiki/I18n.md +39 -5
  53. package/wiki/Installation.md +1 -1
  54. package/wiki/Jobs-And-Workflows.md +29 -1
  55. package/wiki/Known-Gaps.md +3 -0
  56. package/wiki/Observability.md +15 -1
  57. package/wiki/Outbound-HTTP.md +62 -2
  58. package/wiki/PWA-And-Offline.md +1 -1
  59. package/wiki/Policies-And-Authz.md +10 -0
  60. package/wiki/Realtime.md +29 -2
  61. package/wiki/Static-Assets.md +1 -1
  62. package/wiki/Testing.md +33 -0
  63. package/wiki/Theming.md +31 -8
  64. package/wiki/Troubleshooting.md +1 -1
  65. package/wiki/Upgrading.md +5 -1
package/wiki/Compared.md CHANGED
@@ -28,20 +28,20 @@ Who uses it:
28
28
 
29
29
  ## Measured, and how to reproduce it
30
30
 
31
- Medians of five runs on a 4-core GitHub `ubuntu-latest` runner, `As of 2026-11-18`; the method, the
31
+ Medians of five runs on a 4-core GitHub `ubuntu-latest` runner, `As of 2026-11-23`; the method, the
32
32
  box and the caveats are [`scripts/bench/results/README.md`](https://github.com/developerz-ai/ultimate/blob/main/scripts/bench/results/README.md),
33
33
  and every number below is held to the committed JSON by `bun run scripts/bench-claims.ts`
34
34
  (`X_BENCH_CLAIM_STALE`).
35
35
 
36
36
  | Figure | Measured |
37
37
  |---|---|
38
- | scaffold, published `create-ultimate` (31.46.0) | 1.5 s |
39
- | `bun run setup`, cold Bun cache | 8.0 s |
40
- | `node_modules` after setup | 197 MB |
41
- | first `bun run verify` | green in all five runs, median 23.1 s |
42
- | `/` under `x dev`, one client, concurrency 16 | median 1,147 req/s, p99 26.86 ms |
43
- | a typed read, `/_x/query/post-list` | median 875 req/s, p99 35.3 ms |
44
- | cold start to the first 2xx (`x dev`) | 1.1 s |
38
+ | scaffold, published `create-ultimate` (31.49.0) | 1.8 s |
39
+ | `bun run setup`, cold Bun cache | 9.0 s |
40
+ | `node_modules` after setup | 196 MB |
41
+ | first `bun run verify` | green in all five runs, median 29.5 s |
42
+ | `/` under `x dev`, one client, concurrency 16 | median 1,125 req/s, p99 33.2 ms |
43
+ | a typed read, `/_x/query/post-list` | median 889 req/s, p99 45.13 ms |
44
+ | cold start to the first 2xx (`x dev`) | 1.6 s |
45
45
 
46
46
  `x dev` is the development server — every role and an embedded Postgres in one process — so these
47
47
  are a CI runner's first-hour numbers, not a production capacity claim. The previous figures came from
@@ -596,6 +596,7 @@ Two disks may not share one driver **instance**: a driver learns its disk name a
596
596
 
597
597
  | var | notes |
598
598
  |---|---|
599
+ | `OTEL_SERVICE_NAME` / `OTEL_RESOURCE_ATTRIBUTES` | the service identity: name `OTEL_SERVICE_NAME` › `service.name` in the attributes › `app.config.ts`'s `name`; version `service.version` in the attributes › the build id › `APP_VERSION` → [Observability](Observability#the-service-identity) |
599
600
  | `OTEL_EXPORTER_OTLP_ENDPOINT` | OTLP/HTTP **JSON** only, port `:4318`. Absent = spans still recorded, exported nowhere. Invalid → `X_OTLP_ENDPOINT_INVALID` |
600
601
  | `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` / `..._METRICS_ENDPOINT` | per-signal override |
601
602
  | `OTEL_EXPORTER_OTLP_PROTOCOL` | anything but `http/json` → `X_OTLP_PROTOCOL_UNSUPPORTED`, naming `:4318`. gRPC (`:4317`) needs HTTP/2 and protobuf and is out of scope |
@@ -673,6 +674,27 @@ export const config = defineConfig({ name: 'my-app', time: { detect: true } });
673
674
 
674
675
  No default zone is a key here, and none ever is: the process default is `configureTime({ defaultZone })`, and every format call names its zone → [Timezones and dates](Timezones-And-Dates).
675
676
 
677
+ ## `outbound`
678
+
679
+ The app-wide egress proxy: every `outbound()` call with no `proxy` of its own goes through it, the framework's senders and the AI providers included → [Outbound HTTP](Outbound-HTTP#the-app-wide-proxy-outbound-in-appconfigts). `As of 2026-11`.
680
+
681
+ ```ts
682
+ import { defineConfig, defineEnv } from '@ultimat3/core';
683
+
684
+ export const env = defineEnv({
685
+ EGRESS_PROXY: { type: 'url', required: false, secret: true, description: 'The egress proxy.' },
686
+ });
687
+ export const config = defineConfig({
688
+ name: 'my-app',
689
+ outbound: { proxy: env.EGRESS_PROXY, direct: ['svc.cluster.local'] },
690
+ });
691
+ ```
692
+
693
+ | Key | Type | Default | Effect |
694
+ |---|---|---|---|
695
+ | `outbound.proxy` | `string` (`http:`/`https:` URL) | unset — every call dials as it says | **read** by the container boot (`configureOutboundProxy`). A call's own `proxy` wins; `proxy: () => undefined` dials direct. Any other scheme, or not a URL → `X_CONFIG_INVALID`, the value never echoed. A credential rides the URL: take it from the env, never a literal. `x config show` hides its whole userinfo (a token as the user included). A plain-`http:` target the proxy carries crosses it in cleartext, `Authorization` and SigV4 included: the first use per host logs one `ultimate outbound proxy cleartext` warn line (host and port only) naming `outbound.direct` — routing is not changed for you |
696
+ | `outbound.direct` | `string[]` (bare host names, IP literals) | `[]` | hosts never sent through the proxy, each with every name under it, per label. `localhost`, `*.localhost` and loopback are always direct. A scheme, path, port or `*` → `X_CONFIG_INVALID` |
697
+
676
698
  ## `drain`
677
699
 
678
700
  How a SIGTERM'd process leaves: `DrainConfig` in [`packages/core/src/config-health.ts`](https://github.com/developerz-ai/ultimate/blob/main/packages/core/src/config-health.ts). The production boot applies it to **every role** (`lifecycleForRole`, `packages/cli/src/serve-boot.ts`), not only to the web server.
@@ -793,6 +815,8 @@ One typed schema, declared with `defineEnv` at module scope **in `app.config.ts`
793
815
  | `BUILD_ID` | all | set by `x build` | content hash. Never a timestamp, never `latest` |
794
816
  | `LOG_LEVEL` | all | no — unset or empty is `info` | `trace \| debug \| info \| warn \| error \| fatal \| silent`, lowercase. Any other value — `DEBUG`, `verbose` — is REFUSED at import (`X_INVARIANT`), never read as `info` |
795
817
  | `TRUSTED_PROXY_HOPS` | `web`, `sync` | no — unset trusts no proxy header | how many proxies **append** to `x-forwarded-for` between the client and this process: 1 for a single ingress or ALB, 2 for a CDN in front of one. Decimal digits, 1–64 (`@ultimat3/http`'s `MAX_PROXY_HOPS`); anything else is `X_TRUSTED_PROXY_HOPS_INVALID`, refused rather than defaulted, because reading the header at the wrong index is trusting a value the client typed. Unset means `ctx.ip` is the socket address, `ctx.peer` is `null` and no inbound `x-request-id` is echoed |
818
+ | `OTEL_SERVICE_NAME` | all | no — unset falls to `OTEL_RESOURCE_ATTRIBUTES`, then `name` | `service.name` on every span, log, metric and Sentry event; empty is unset → [Observability](Observability#the-service-identity) |
819
+ | `OTEL_RESOURCE_ATTRIBUTES` | all | no | `key=value,…`, values percent-decoded: its `service.name` is used when `OTEL_SERVICE_NAME` is unset, its `service.version` beats the build id (`BUILD_ID`) and `APP_VERSION`. One malformed pair discards the whole variable, with one warn line |
796
820
  | `OTEL_EXPORTER_OTLP_ENDPOINT` | all | no | the OTLP collector. There is no `otel` config block for it to override — see [`otel`](#otel) |
797
821
 
798
822
  Rules:
@@ -905,7 +929,7 @@ x verify --json # the gate
905
929
 
906
930
  ## The gate's file — `x.verify.json`
907
931
 
908
- Not configuration of the app: what `x verify` holds it to, committed at the repo root. Every key is in [CLI reference](CLI-Reference#x-verify); the `exercise` key, `As of 31.16.0`:
932
+ Not configuration of the app: what `x verify` holds it to, committed at the repo root. Every key is in [CLI reference](CLI-Reference-Gate#x-verify); the `exercise` key, `As of 31.16.0`:
909
933
 
910
934
  | Key | Value | Absent |
911
935
  |---|---|---|
@@ -916,7 +940,7 @@ Not configuration of the app: what `x verify` holds it to, committed at the repo
916
940
  { "exercise": { "unprovenMax": 0, "statementsMax": 100 } }
917
941
  ```
918
942
 
919
- `x new` writes exactly that; `x upgrade` writes the figures the hop measured into a file that states none, so the floor only falls; a figure the app already wrote is never changed, even when the pass's constant seed (31.47.0) lands above it → [Upgrading](Upgrading). A malformed value is a `manifest`-step problem naming the shape → [CLI reference](CLI-Reference#x-exercise).
943
+ `x new` writes exactly that; `x upgrade` writes the figures the hop measured into a file that states none, so the floor only falls; a figure the app already wrote is never changed, even when the pass's constant seed (31.47.0) lands above it → [Upgrading](Upgrading). A malformed value is a `manifest`-step problem naming the shape → [CLI reference](CLI-Reference-Gate#x-exercise).
920
944
 
921
945
  `x config show --json` prints the resolved config — defaults merged, credentials redacted; `--section database` for one key (since 31.17.0) → [CLI reference](CLI-Reference).
922
946
 
@@ -68,7 +68,7 @@ The body is `{ state, ready, role }` for everyone, and `{ state, ready, uptimeMs
68
68
 
69
69
  **A check has three answers: `ok`, `degraded`, `failing`** (`As of 2026-10`). `degraded` is a dependency the role serves without — today, the bus on a role that only publishes to it. It never turns `/readyz` into a 503, in either mode, so a NATS outage cannot pull every web pod from the ingress; `/readyz?deep=1` is strict and answers 503 for it. An app registers its own with `registerReadinessCheck(name, check, { onFailure: 'degraded' })`.
70
70
 
71
- **Which build answers is a header, on every health answer** (`As of 27.2.3`). `/healthz`, `/readyz` and `/readyz?deep=1` send `x-ultimate-build` — the same header every page sends — on the web port, the sync port and the metrics listener alike, whoever asks. The body does not change: a stranger still reads `{ state, ready, role }`. A deploy check that waits for the new build runs [`x deploy verify --url https://<host>`](CLI-Reference#x-deploy-verify) (`As of 30.0.0`): it samples this header until the build holds, then grades the queues. Two cases send none: a web role whose `buildId` is `null` (no `BUILD_ID` and none from the boot), and the metrics listener in the moments before its boot has computed the id — a container opens it first, so a cold pod's probe gets the status without the header.
71
+ **Which build answers is a header, on every health answer** (`As of 27.2.3`). `/healthz`, `/readyz` and `/readyz?deep=1` send `x-ultimate-build` — the same header every page sends — on the web port, the sync port and the metrics listener alike, whoever asks. The body does not change: a stranger still reads `{ state, ready, role }`. A deploy check that waits for the new build runs [`x deploy verify --url https://<host>`](CLI-Reference-Ship#x-deploy-verify) (`As of 30.0.0`): it samples this header until the build holds, then grades the queues. Two cases send none: a web role whose `buildId` is `null` (no `BUILD_ID` and none from the boot), and the metrics listener in the moments before its boot has computed the id — a container opens it first, so a cold pod's probe gets the status without the header.
72
72
 
73
73
  **`registered: 0` is a real answer, not an error.** An empty registry is still ready, so a 200 means no more than "the socket is bound" — which is what the chart's and compose's healthchecks route traffic on. Read `registered` before you trust `checks: {}`.
74
74
 
@@ -1020,7 +1020,8 @@ export const parkUnpublished = (authorId: string): Promise<number> =>
1020
1020
  | One plan | `updateWhere(filter, patch)` / `deleteWhere(filter)` and the chain build the same plan (`write-where.ts`): tenancy, soft-delete reach, invariant judging, `onUpdateNow()`, sealing, the search mirror and the `entity.bulk` report cannot differ. The filter is the chain's equalities |
1021
1021
  | Unbounded | no predicate is `X_WRITE_UNFILTERED`. So is a chain predicate whose value is `undefined` — dropped, it would widen the write to everything the rest of the chain matches; `.andWhere('<col>', 'is-null')` is SQL NULL. In `updateWhere`'s filter an `undefined` is dropped, as it always was |
1022
1022
  | No page | `limit()`, `after()` and `search()` on a write chain are `X_INVARIANT_VIOLATED`: a write reaches every match, and a search index answers a bounded sample of ids. `orderBy`, `select` and `preload` are ignored |
1023
- | Sealed columns | a lookup column matched as a read matches it; a null test passes; any other predicate on a sealed column is refused |
1023
+ | Sealed columns | on a chain, a lookup column matched as a read matches it; a null test passes; any other predicate on a sealed column is refused. In `updateWhere`'s or `deleteWhere`'s filter every sealed column is refused, lookup included |
1024
+ | The rows back | `updateWhereReturning(filter, patch)` is `updateWhere` resolving `readonly Row[]`: on Postgres one `update … returning *` decides, with no explicit lock, and `[]` is nothing matched. It takes the equality filter, not a chain, and `updateWhere`'s guards: a sealed column in that filter is `X_ENTITY_SEALED_PREDICATE`, a lookup column included (the row above is a chain's). On Postgres a `count(*)` goes first unless the filter names the whole primary key and no rule only the app can judge is declared; a count past `MAX_ASSERTED_ROWS` is refused (`X_INVARIANT_VIOLATED`). A transaction rolls back if concurrent changes increase the result past that bound. A `defineDriver` store refuses before writing because it reports counts only. On a hand-written `Repo` it is optional: absent, the call is refused with nothing written |
1024
1025
 
1025
1026
  ### A different value per row is `updateMany`
1026
1027
 
@@ -1100,7 +1101,7 @@ well as data for one.
1100
1101
 
1101
1102
  | Rule | Detail |
1102
1103
  |---|---|
1103
- | Tier | `reference` ships to production through this same command; `dev` is fixture data and is the default. `x db seed` runs `reference` alone under `ULTIMATE_ENV=production` — naming `--tier dev` (or `ULTIMATE_SEED_TIER=dev`) is both the selection and the consent → [CLI reference](CLI-Reference#x-db) |
1104
+ | Tier | `reference` ships to production through this same command; `dev` is fixture data and is the default. `x db seed` runs `reference` alone under `ULTIMATE_ENV=production` — naming `--tier dev` (or `ULTIMATE_SEED_TIER=dev`) is both the selection and the consent → [CLI reference](CLI-Reference-Data#x-db) |
1104
1105
  | Transaction | one per seed, never one around the run: a seed that throws must not roll back the seeds that already landed |
1105
1106
  | `createdAt` | an `upsert` that lands on a stored row does **not** overwrite it. A replay must not move when a row first arrived; `preserve: [...]` names other columns to spare |
1106
1107
  | Tenancy | `upsert` on a tenant-scoped entity needs the tenant column inside `by`, else `X_TENANCY_UNSCOPED` — the same rule `upsertAll` carries. `insert` has no such requirement: `do nothing` writes nothing to a row it does not own |
package/wiki/I18n.md CHANGED
@@ -1,15 +1,18 @@
1
1
  # I18n
2
2
 
3
- Flat key catalog, one JSON file per locale. Loud misses. `Intl.*` for anything that is not a string.
3
+ Flat key catalog: one JSON file per locale, or one directory per locale with a file per namespace. Loud misses. `Intl.*` for anything that is not a string.
4
4
 
5
5
  Zero hardcoded user-facing strings — every string an end user can read goes through `t()`. A literal in JSX or in an error message is a lint failure and fails `x verify`.
6
6
 
7
7
  ## Catalogs
8
8
 
9
- One file per locale, flat dot-keys after load, nested for authoring.
9
+ One file per locale, or one directory of namespace files per locale; flat dot-keys after load, nested for authoring.
10
10
 
11
11
  ```
12
12
  packages/i18n/src/catalogs/en.json # framework strings — ships inside @ultimat3/i18n
13
+ packages/i18n/src/catalogs/ro.json # …and in Romanian, Spanish, Brazilian Portuguese
14
+ packages/i18n/src/catalogs/es.json
15
+ packages/i18n/src/catalogs/pt-BR.json
13
16
  packages/i18n/catalogs/en.json # the app's own catalogs, same shape
14
17
  packages/i18n/catalogs/es.json
15
18
  ```
@@ -31,9 +34,39 @@ packages/i18n/catalogs/es.json
31
34
  | Key segments | `/^[A-Za-z0-9_-]+$/` — anything else is `X_CATALOG_INVALID` |
32
35
  | Leaves | strings only. An array or a number leaf is `X_CATALOG_INVALID` |
33
36
  | Collisions | a nested branch and a dotted key that flatten to the same path throw |
34
- | Merge order | framework catalog first, app catalog last — apps override framework keys. **Under `en` only**: the framework catalog is English, so `defineCatalogs` seats it under core's `DEFAULT_LOCALE` (`en`) and nowhere else. An app shipping only `es` renders `⟦errors.notFound.title⟧` for a framework key it has not translated, which is the golden rule working — it used to be served English with `isMiss` reading `false`, a fallback locale chain wearing registration as a disguise |
37
+ | Merge order | framework catalog first, app catalog last — apps override framework keys. **Each under the language it is written in**: the framework ships `en`, `ro`, `es` and `pt-BR` (`FRAMEWORK_CATALOGS`, `As of 2026-11`), and an app catalog stands on the one in its LANGUAGE, matched on the canonical tag — `pt-br` on `pt-BR`, `es-MX` on `es`. Nothing to wire: `defineCatalogs({ locales: { ro } })` is enough for `ui.*`, `errors.*`, `auth.*`, `admin.*` in Romanian. Only `en` is seated on its own; `ro` is never in `registeredLocales()` of an app that did not register it. A language the framework does not ship (`de`) renders `⟦errors.notFound.title⟧` for a framework key the app has not translated — the golden rule working, never English with `isMiss` reading `false` |
38
+ | Framework locales | every shipped catalog carries every `en` key with the same `{placeholders}`, plus a language's own plural forms (`ro`'s `_few`); `framework-locales.test.ts` refuses a gap |
35
39
  | `en` | the reference locale. Its key set is what every other locale is diffed against |
36
40
 
41
+ ### Split catalogs
42
+
43
+ A locale is ONE of two forms, never both. `As of 2026-11`.
44
+
45
+ | Form | On disk | Index imports |
46
+ |---|---|---|
47
+ | flat (what `x new` writes) | `packages/i18n/catalogs/<locale>.json` — every namespace in one file | `import en from '../catalogs/en.json';` |
48
+ | split | `packages/i18n/catalogs/<locale>/<namespace>.json` — one file per namespace, holding that namespace's subtree, plus a generated `index.ts` | `import { catalog as en } from '../catalogs/en';` |
49
+
50
+ ```
51
+ packages/i18n/catalogs/en/billing.json # { "plans": { "pro": "Pro" } } → billing.plans.pro
52
+ packages/i18n/catalogs/en/site.json # { "footer": "…" } → site.footer
53
+ packages/i18n/catalogs/en/site/home.json # { "title": "Home" } → site.home.title
54
+ packages/i18n/catalogs/en/index.ts # generated: joins the three, never hand-edited
55
+ ```
56
+
57
+ Split when one file gets too long to review or every branch collides in it: each feature then edits its own namespace file.
58
+
59
+ | Rule | Detail |
60
+ |---|---|
61
+ | Migrate | `bunx x i18n split` moves every flat locale (`bunx x i18n split es`: one) into its directory, rewrites `packages/i18n/src/index.ts`'s import, widens `.gitattributes`' catalog merge rule, and deletes the flat file. Lossless — the files join back to the exact catalog — and idempotent: on a split locale it only re-derives the barrel. No reverse command |
62
+ | A file's keys | its path under the locale directory is the key prefix: `site/home.json` holds `site.home.*`. A folder is a deeper namespace, opt-in: move a subtree into it by hand, then `bunx x i18n split <locale>` re-derives the barrel |
63
+ | Top-level keys | a split locale has none: every key lives under a namespace. `split` refuses a flat catalog with a top-level string key (`X_CATALOG_INVALID`) — nest it first (`common.<key>`) |
64
+ | Both forms | `<locale>.json` beside `<locale>/` is `X_CATALOG_LAYOUT_MIXED` on every read; `bunx x i18n split <locale>` folds the file into the directory |
65
+ | One key, two files | the same key in two files, or a leaf one file defines that another file nests under (`site.home` in `site.json`, `site/home.json` beside it), is `X_CATALOG_KEY_DUPLICATE`, naming both files |
66
+ | The barrel | `catalogs/<locale>/index.ts`: one import and one object entry per file, so `typeof en` is still the typed key space and Bun builds it like any module. Every `x i18n` command and every `x g` re-derives it; `x merge-driver` merges two branches' new namespaces in it |
67
+ | Writers | `x i18n sync` and `x g` put each key in the existing file of its longest prefix, else in its namespace's own file, created; `x i18n add <locale>` starts the new locale in the default locale's form, one file per namespace the default has |
68
+ | Findings | name the locale directory (`es/`), and the parity findings the namespace file (`es/billing.json`) |
69
+
37
70
  ## `t()`
38
71
 
39
72
  ```ts
@@ -133,9 +166,10 @@ framework's diagnostic text changes without a semver signal, the rule names do n
133
166
 
134
167
  | Command | Does |
135
168
  |---|---|
136
- | `x i18n add <locale>` | create `catalogs/<locale>.json` seeded with every default-locale key, each value copied inside `⟦…⟧` |
169
+ | `x i18n add <locale>` | create `catalogs/<locale>.json` (or `catalogs/<locale>/`, when the default locale is split) seeded with every default-locale key, each value copied inside `⟦…⟧` |
137
170
  | `x i18n sync <locale>` | add keys the locale is missing; a key it already has is never overwritten, translated or not; never deletes. An admin key it adds that the default locale's file lacks is added there too, with the string that locale renders, so every catalog keeps one key set |
138
171
  | `x i18n check --json` | extract keys from source, diff against every catalog and against `en`, report missing / unused / dynamic / slot mismatch / untranslated |
172
+ | `x i18n split [<locale>]` | move flat catalogs into one file per namespace ([Split catalogs](#split-catalogs)) |
139
173
 
140
174
  Every command supports `--json`. `add` and `sync` copy the source value inside the marker, so the text sits where the translation goes and `x i18n check` counts the key as missing until a person replaces it. Source means every shape below; a key only a mail or a push names is a key.
141
175
 
@@ -158,7 +192,7 @@ Any other value of these is listed `dynamic`.
158
192
  | `slot mismatch` | two locales define one key with different interpolation slots — the slot sets are compared by name, so the same slots in another order are not a mismatch | non-zero, one `X_CATALOG_SLOT_MISMATCH` finding per direction |
159
193
  | `untranslated` | a locale still carries the reference locale's value — byte-identical to it and longer than 24 characters | non-zero, one `X_CATALOG_UNTRANSLATED` finding per key |
160
194
 
161
- The last two are the parity rules, and both compare a locale with the reference locale `en` (`As of 2026-10`). A key `en` defines and another locale lacks is a missing key, not a parity finding, and that holds for a key only reached dynamically (`t(`plans.${plan}.name`)`). A key only another locale defines is `unused` there. A `⟦key⟧` placeholder is a missing key too — never a copy. Every finding names the locale, the catalog key and the file `packages/i18n/catalogs/<locale>.json`; `x verify`'s `i18n` step and `x i18n check` report them from one implementation, so the command and the gate answer about an app with one voice.
195
+ The last two are the parity rules, and both compare a locale with the reference locale `en` (`As of 2026-10`). A key `en` defines and another locale lacks is a missing key, not a parity finding, and that holds for a key only reached dynamically (`t(`plans.${plan}.name`)`). A key only another locale defines is `unused` there. A `⟦key⟧` placeholder is a missing key too — never a copy. Every finding names the locale, the catalog key and the file `packages/i18n/catalogs/<locale>.json` (a split locale: its namespace file); `x verify`'s `i18n` step and `x i18n check` report them from one implementation, so the command and the gate answer about an app with one voice.
162
196
 
163
197
  Before any of the five, `check` resolves `@ultimat3/i18n` from the app root, from every workspace and from the CLI itself. Two real directories is `X_PACKAGE_DUPLICATED`, and every registration gap is then reported as the install's fault with the install's fix (pin one version, `bun install`) — not as a misplaced `defineCatalogs()`: each copy keeps its own registry, so the app registers into one and the check reads the other.
164
198
 
@@ -201,7 +201,7 @@ Read tools are unrestricted in dev; write tools are scoped to branch environment
201
201
 
202
202
  | Task | Command |
203
203
  |---|---|
204
- | Framework version bump | `x upgrade --json`, one major per run ([CLI reference](CLI-Reference#x-upgrade)). An app below 30.0.0 has no such command yet: `bunx @ultimat3/cli@latest upgrade --json` |
204
+ | Framework version bump | `x upgrade --json`, one major per run ([CLI reference](CLI-Reference-Tools#x-upgrade)). An app below 30.0.0 has no such command yet: `bunx @ultimat3/cli@latest upgrade --json` |
205
205
  | Check what a bump would change | `x upgrade --dry-run --json`: the pins, the Bun floor edits and the section to read. Writes nothing, runs no gate |
206
206
  | Remove dev state (embedded PG, storage, caches) | `rm -rf .x` |
207
207
  | Remove the CLI | it ships with the app; deleting the repo is the uninstall |
@@ -500,6 +500,33 @@ export const syncAccount = job({
500
500
  | a proven wake is proven again | every `reproveEveryMs` (10 s) one notification per channel that wakes no loop. A session that stops delivering with no re-dial (half-open) announces nothing; not back within `verifyTimeoutMs` (5 s) of the SEND, the wake is un-proven, `jobs.wake.lost` (`warn`) is logged and the loops return to the 2 s poll until a notification crosses again (`jobs.wake.live`). A pool that has not sent the proof by then is no verdict: a saturated pool cannot be told from a dead session, so the wake stays proven and the proof is sent again, with its own window, once the pool answers. `startQueueWake`, `packages/jobs/src/queue-wake.ts`, `As of 2026-11` |
501
501
  | a queue pause | read by the claim statement itself, so it holds from each worker's next claim; a resume announces the queue |
502
502
 
503
+ ### A tenant's own job — `jobStatusFor` and `cancelJobFor`
504
+
505
+ The operator surface takes an id and no tenant. An end user's status page or cancel button takes these two (`As of 2026-11-27`), from the app's own `query` and `action` under its own policy — functions, not a factory: who may read or cancel is policy.
506
+
507
+ ```ts
508
+ import type { JobDriver } from '@ultimat3/jobs';
509
+ import { cancelJobFor, jobStatusFor } from '@ultimat3/jobs';
510
+
511
+ declare const driver: JobDriver;
512
+ declare const jobId: string;
513
+ declare const orgId: string;
514
+ declare const actorId: string;
515
+
516
+ const status = await jobStatusFor(driver, { jobId, tenantId: orgId, name: 'posts.export' });
517
+ const after = await cancelJobFor(driver, { jobId, tenantId: orgId, reason: `by ${actorId}` });
518
+ ```
519
+
520
+ | Rule | |
521
+ |---|---|
522
+ | what `JobStatus` carries | `id`, `name`, `state`, `attempt`, `maxAttempts`, `progress`, `runAt`, `createdAt`, `updatedAt` — never `input`, `lastError`, its stack, `traceparent` or `enqueuedBy` |
523
+ | another tenant's job, a `tenant: 'none'` job, a missing id | all `undefined`: the fence is in the store (`JobDriver.tenantJobs` — Postgres, Redis and memory), one lookup, one answer |
524
+ | `name` | part of the fence when given: an export endpoint answers for exports only |
525
+ | `cancelJobFor` | cancels a LIVE job only and answers it as it now stands (`cancelled`, or how it had already ended); another tenant's job is a no-op answering `undefined`, never `X_JOB_NOT_CANCELLABLE` |
526
+ | a hand-rolled driver with no `tenantJobs` | `X_JOB_INTROSPECTION_UNSUPPORTED` |
527
+
528
+ The worked recipe: the reference app's `postsExportStatus` query and `cancelPostsExport` action (`examples/dummy/apps/web/app/posts/export-job.ts`) — `requestPostsExport` answers the `jobId`, an id the org does not own is one 404, `X_POSTS_EXPORT_NOT_FOUND`, whether it exists or not.
529
+
503
530
  ## Exports and imports — `exportRows()` and `importRows()`
504
531
 
505
532
  **A bulk file in either direction is a job.** `exportRows()` streams a paged read to object
@@ -602,6 +629,7 @@ export const exportMember = subjectExport({
602
629
  | a kept row under a deleted parent is refused | it would block the delete (`restrict`) or be cascaded away; `'delete'`, or anonymize the key to `null` |
603
630
  | children first, the subject last; one step per page of parent keys | a killed run resumes at the page it stopped on; every write is an equality on one key, so a replay changes nothing twice |
604
631
  | a loop of deleted tables needs one nullable key | it is cleared first; none is `X_SUBJECT_CYCLE` |
632
+ | the subject may be the tenant itself (`defineSubject(orgs, …)`) | a child whose tenant column is the foreign key to it is read with `eq` on the actor's org, the one predicate the tenant guard accepts there; the job's `tenant` must be that org |
605
633
  | a table with no foreign key to the person is invisible | list it: `columns: { audit_copies: 'memberId' }`, then it needs a treatment too |
606
634
  | a deleted or anonymized table's `<table>_history` is reached too (`As of 2026-11`) | the write records the person in one more before image, and `row_id` is no foreign key. `'delete'` removes every history row whose `before` or `after` image names the subject (`@>` on the parent's key column, tenant-scoped — so a row deleted, soft-deleted or inserted before the erase is reached too) in the parent's own step and transaction, after the write — the one delete the append-only guard lets through (`x.purge` on Postgres, `purgingHistory` in memory); `{ retain: '<why>' }` keeps and counts the same rows; `anonymize` is `X_SUBJECT_TREATMENT_INVALID`, undeclared `X_SUBJECT_TABLE_UNDECLARED`. |
607
635
  | a deleted table's own delete purges the images Postgres writes into a child's history (`As of 2026-11`) | `on delete set null` or `cascade` rewrites a child row, and the child's trigger records the person's key in its before image. A child history declared `'delete'` loses those images in the parent's step and transaction (`orphansOf`, `packages/jobs/src/subject-plan.ts:341`; `packages/jobs/src/subject-erase-history.ts`). Limits: the memory driver applies no `onDelete` action, so a kept child keeps the erased key there; a child history declared `{ retain }` is counted only for writes to its own table — the images a set-null or cascade write records into it are neither purged nor counted |
@@ -933,7 +961,7 @@ Draining a worker mid-job does **not** finish the current step (`As of 2026-09-0
933
961
  | `/_x` dev panel | queue depth per queue, in-flight, failed, step timeline per job, and the whole `x_backfills` ledger with a live count |
934
962
  | `x jobs list --json` | one row per job: state, queue, attempts, `runAt`, idempotency key — plus the `backfill()` passes **in flight**, with rows so far and cursor |
935
963
  | `x jobs show <id> --json` | machine-readable state, step results, next retry, dead-letter reason, and this run's ledger row under `backfill` when the job is a backfill |
936
- | `x db backfill --list --json` | the whole ledger: one row per pass, newest first → [CLI reference](CLI-Reference#x-db) |
964
+ | `x db backfill --list --json` | the whole ledger: one row per pass, newest first → [CLI reference](CLI-Reference-Data#x-db) |
937
965
  | MCP dev tools | `jobs.inspect` (definitions, retry policy, steps) and `queue.depth` (pending/running/failed per queue) — scope `dev:read`, never reachable in `ROLE=web` |
938
966
  | OpenTelemetry | one span per job, one child span per step, trace linked to the enqueuing request |
939
967
  | Metrics | `queue_depth{queue}`, `queue_demand{queue}` (what the worker HPA reads), `jobs_total{queue,outcome}`, `jobs_retried_total{job,code}` (one per retried attempt; `code` is the thrown `X_*`, or `uncoded`), `job_leases_lost_total{queue}` → [Observability](Observability) |
@@ -37,6 +37,9 @@ Every row carries its decision, `As of 2026-11-18`: **build** is owed work, a de
37
37
  | Every role evaluates all of `@ultimat3/jobs` — 96 modules (`As of 2026-10-02`, by file) — whatever it runs | deferred | `As of 2026-10-01`, read off the serve graph by the names each role's code uses: a `web` pod needs 43 of them (enqueue, the outbox relay, the purge task), a `scheduler` 46, a `worker` 62. The rest ride the barrel: `worker.ts` and its eighteen dependencies in a web pod, the `backfill()` / `exportJob()` / `webhook()` factories (17 modules, 123 kB of source) in an app that declares none, and the memory driver (3 modules) outside a test. ~1.6 Mi per web pod at the measured 34 kB a module. Closing it means subpath entries (`@ultimat3/jobs/worker`, one per factory) and every importer rewritten — a breaking move for a saving the per-role bundle above makes moot, so it waits on that decision. The operator surface is **not** in this list: `JobIntrospection` is a member of the driver, and the worker announces itself and counts settles through it pin: none — a module count read off a role's serve graph, measured rather than asserted | nothing to do in an app |
38
38
  | `onSettled` for a completion that **returned a value** runs at most once across a crash | deferred | `As of 2026-11-14`. Every other ending is at least once: the write that settles the row records the debt (`x_jobs.settle_owed`) and the scheduler leader re-drives a dead worker's with `redriven: true, reason: 'lost'` — failures, dead letters, refusals, completions whose body returned `undefined`, and the rows the CLAIM settles (a final-attempt lease lapse buried `dead`, an expired row: `ClaimOptions.settleOwed`, `packages/jobs/src/claim-exhausted.ts`). A body's return value is never stored (`x_jobs` has no result column), so a re-drive could only hand `result: undefined` to a hook typed for a value; on a minor that would break every `onSettled` reading `result`. Storing the result, and so at-least-once for every completion, is planned for `next` [pin](https://github.com/developerz-ai/ultimate/blob/main/packages/jobs/src/settle-redrive.test.ts#a%20completion%20that%20returned%20a%20value%20owes%20nothing%3A%20told%20once%2C%20at%20most%20once) | write what must be recorded for certain inside the body, in a `step.run`; or have the body return nothing and read what it wrote from there |
39
39
  | A `step.run` output past 256 KiB is stored with a warning, not refused | deferred | `As of 2026-11-12`. Undeclared, `STEP_OUTPUT_MAX_BYTES` logs `jobs.step.output-too-large` (`X_STEP_OUTPUT_TOO_LARGE`) once per job and step and stores the output, because refusing by default would fail shipped jobs on a minor; every attempt still loads it. Refusal by default is planned for `next` [pin](https://github.com/developerz-ai/ultimate/blob/main/packages/jobs/src/steps-output.test.ts#the%20default%20256%20KiB%20warns%20once%20per%20job%20and%20step%2C%20with%20the%20code%2C%20and%20still%20stores) | declare `job({ stepOutputMax: 262_144 })` to be refused now, and persist the payload, returning its key from the step |
40
+ | A live cursor with no signature still resumes from where it left off | deferred | `As of 2026-11-27`. Since 31.52.0 a cursor carries `sig`, an HMAC over its position; a mismatched one cold-starts. A cursor with no `sig` — a client built before it, or one that removed its own — still takes the delta path and is counted (`registry.unsignedCursors`, `onUnsignedCursor`), because refusing it would cold-start every open tab on a minor. Treating anything but a matching `sig` as a cold start flips on `next` (#1280) [pin](https://github.com/developerz-ai/ultimate/blob/main/packages/realtime/src/live-resume-signed.test.ts#takes%20the%20legacy%20path%20%E2%80%94%20a%20delta%20%E2%80%94%20and%20is%20counted) | watch `onUnsignedCursor`: it counts every resume that sends no `sig` at all — an old build, or a client that stripped its own — so zero means nothing resumes unsigned, not only that every client is upgraded |
41
+ | An input key the schema does not declare is dropped with a warning, not refused | deferred | `As of 2026-11-27`. An action's or query's parse logs `X_INPUT_UNKNOWN_KEY` once per primitive and path set, naming the nearest declared key, and answers exactly as without the key: refusing it would fail shipped callers on a minor. The refusal (`X_INPUT_INVALID` naming the nearest key) flips on `next` (#1281) [pin](https://github.com/developerz-ai/ultimate/blob/main/packages/action/src/validate-unknown-keys.test.ts#over%20HTTP%3A%20200%2C%20the%20same%20bytes%20as%20without%20it%2C%20and%20one%20warning%20naming%20%60limit%60) | grep the logs for `input.unknown_key` and fix each caller before the major |
42
+ | A device hello with no `v` is read as wire version 1 | deferred | `As of 2026-11-27`. `DEVICE_WIRE_VERSION` is 1 and a hello may omit `v`, because every node shipped before it does; a newer `v` is closed with `X_DEVICE_WIRE_VERSION`. Requiring `v` flips on `next` [pin](https://github.com/developerz-ai/ultimate/blob/main/packages/realtime/src/device-agent.test.ts#a%20hello%20at%20the%20spoken%20version%2C%20or%20with%20no%20v%2C%20beats%20and%20stays%20open) | send `v: 1` in every hello (`@ultimat3/realtime/wire/device-v1.json`) |
40
43
 
41
44
  ## Open by decision
42
45
 
@@ -108,6 +108,20 @@ Proof, `As of 2026-11-09`: `packages/cli/src/otlp-export.live.test.ts` sends one
108
108
 
109
109
  **Span cost.** An unsampled span costs 3.3 µs (root) / 2.0 µs (child), against a 1 µs target (`scripts/bench/results/span-overhead.json`, `As of 2026-11-09`): ids and clock reads are still paid before the sampling decision is known. Known gap, pinned by `scripts/bench/span-overhead.bench.test.ts`.
110
110
 
111
+ ### The service identity
112
+
113
+ Every span, log record, metric collection, `target_info` line and Sentry event carries one resource. The container boot names it (`serve-boot-telemetry.ts`), env first — before `app.config.ts` loads, so a span the config's own import opens already carries what the deploy said. `As of 2026-11`.
114
+
115
+ | Attribute | First that is set wins |
116
+ |---|---|
117
+ | `service.name` | `OTEL_SERVICE_NAME` · `service.name` in `OTEL_RESOURCE_ATTRIBUTES` · `name` in `app.config.ts` |
118
+ | `service.version` | `service.version` in `OTEL_RESOURCE_ATTRIBUTES` · the build id (`BUILD_ID`, or the manifest hash an unstamped image computes — the `x-ultimate-build` value) · `APP_VERSION` (`dev` unset) |
119
+
120
+ - Empty is unset. `OTEL_RESOURCE_ATTRIBUTES` is `key=value,key=value`, values percent-decoded; one malformed pair discards the whole variable with one warn line (the OTel SDK rule), the value never echoed.
121
+ - Before the config loads, only the env can answer: a span opened then carries the env's name (or `unknown_service`) and the stamped `BUILD_ID` (else `APP_VERSION`).
122
+ - Unbooted — a script, a test — the resource is OTel's own `unknown_service` at `dev`. `configureTelemetry({ serviceName, serviceVersion })` returns its release; `resetTelemetry()` forgets the identity too.
123
+ - `x dev` keeps its own recorder and does not name the service.
124
+
111
125
  ## Instruments
112
126
 
113
127
  ```ts
@@ -279,7 +293,7 @@ CPU autoscaling is wrong for `sync` and `worker`: a node holding 80k idle socket
279
293
 
280
294
  ## The database, on demand
281
295
 
282
- `x db diagnostics --json` (`As of 2026-11`) answers what the series cannot: who blocks whom (`data.blockers.rows[].blockedBy`), what each session is doing, the slowest statements (`pg_stat_statements`, when an operator installed it), unused and invalid indexes, `NOT VALID` constraints, dead tuples and the last autovacuum. Facts only, exit 0; `/readyz` stays the one-`select 1` probe. Read-only, 2 s per statement, no user table read, literals printed as `?`; whoever runs it sees the redacted SQL of every session on the app's database role → [CLI reference](CLI-Reference#x-db). The same report is `dbDiagnostics()` from `@ultimat3/db`.
296
+ `x db diagnostics --json` (`As of 2026-11`) answers what the series cannot: who blocks whom (`data.blockers.rows[].blockedBy`), what each session is doing, the slowest statements (`pg_stat_statements`, when an operator installed it), unused and invalid indexes, `NOT VALID` constraints, dead tuples and the last autovacuum. Facts only, exit 0; `/readyz` stays the one-`select 1` probe. Read-only, 2 s per statement, no user table read, literals printed as `?`; whoever runs it sees the redacted SQL of every session on the app's database role → [CLI reference](CLI-Reference-Data#x-db). The same report is `dbDiagnostics()` from `@ultimat3/db`.
283
297
 
284
298
  ## Spans and logs, in detail
285
299
 
@@ -68,6 +68,7 @@ re-screen each redirect. All of it is in this one option.
68
68
  transport's message (`//…@`), and the proxy is never recorded.
69
69
  - With no `proxy`, Bun's own `HTTPS_PROXY` / `HTTP_PROXY` / `NO_PROXY` still apply, as for any `fetch`.
70
70
  - **Which proxy, and rotating them, is app code** (axiom 8): a resolver over your own inventory.
71
+ - `proxy: () => undefined` dials direct, past the app-wide proxy below.
71
72
 
72
73
  ```ts
73
74
  import { outbound } from '@ultimat3/core/outbound';
@@ -84,6 +85,64 @@ await outbound({
84
85
  });
85
86
  ```
86
87
 
88
+ ### The app-wide proxy: `outbound` in `app.config.ts`
89
+
90
+ A deploy behind an egress gateway declares it once; every `outbound()` call with no `proxy` of its
91
+ own goes through it — the framework's senders included (APNs, FCM, Web Push, OAuth, MCP, webhooks,
92
+ CDN purge), with no call-site change. `As of 2026-11`.
93
+
94
+ ```ts
95
+ import type { EnvSchema } from '@ultimat3/core';
96
+ import { defineConfig, defineEnv } from '@ultimat3/core';
97
+
98
+ export const envSchema = {
99
+ // http(s)://user:pass@egress:3128 — a credential: the environment's, never a literal here.
100
+ EGRESS_PROXY: { type: 'url', required: false, secret: true, description: 'The egress proxy.' },
101
+ } satisfies EnvSchema;
102
+ export const env = defineEnv(envSchema);
103
+
104
+ export const config = defineConfig({
105
+ name: 'shop',
106
+ outbound: {
107
+ proxy: env.EGRESS_PROXY,
108
+ direct: ['otel-collector.observability', 'svc.cluster.local'],
109
+ },
110
+ });
111
+ ```
112
+
113
+ | A call's `proxy` | Goes through |
114
+ |---|---|
115
+ | unset | `outbound.proxy` — unless the hop's host is loopback or a `direct` host |
116
+ | a URL, `{ url, headers }` or a resolver | that, as above: the call's own choice always wins |
117
+ | `null` | nothing: direct |
118
+
119
+ - **Never proxied:** `localhost`, `*.localhost`, a loopback literal, and each `outbound.direct` entry
120
+ with every name under it, per label (`cluster.local` covers `a.svc.cluster.local`, never
121
+ `notcluster.local`). Asked per hop with the NAMED host, so a redirect is judged again.
122
+ - `direct` entries are bare host names or IP literals: a scheme, path, port or `*` is
123
+ `X_CONFIG_INVALID`. So is a `proxy` that is not an `http:`/`https:` URL — refused at
124
+ `defineConfig`, the credential never echoed; one installed by hand is still refused per hop
125
+ (`X_OUTBOUND_PROXY_INVALID`).
126
+ - **A plain-`http:` target through the proxy is cleartext** — the proxy reads every header, a
127
+ bearer token or a SigV4 signature included. Routing stays as declared; the first use per host logs
128
+ one `ultimate outbound proxy cleartext` warn line (host and port, never the path or the proxy URL)
129
+ whose fix is `defineConfig({ outbound: { direct: ['<host>'] } })`. An in-cluster gateway or MinIO belongs in `direct`.
130
+ - Installed by the container boot (`configureOutboundProxy`, `@ultimat3/core/outbound`), released at
131
+ stop; an app never calls it. The boot logs `ultimate outbound proxy` with the URL's userinfo as
132
+ `***`.
133
+
134
+ Transports that are not `outbound()` ask the same answer through `ambientProxyFor(url)`
135
+ (`@ultimat3/core/outbound`) and hand it to Bun's `fetch` as `init.proxy`:
136
+
137
+ | Transport | Takes `outbound.proxy` |
138
+ |---|---|
139
+ | `@ultimat3/ai`'s Anthropic and OpenAI-format providers (`baseUrl` included) | yes, same direct-host rule |
140
+ | `@ultimat3/storage`'s signed S3 requests: a PUT with metadata, `Cache-Control`, SSE or object lock; ranged and streamed reads; multipart; copies; retention reads | yes, same direct-host rule |
141
+ | `@ultimat3/storage`'s plain S3 calls on `Bun.S3Client` (`put`, `get`, `exists`, `delete`, `list`, `stat`) | **no.** `Bun.S3Client` takes no `proxy` option (measured, Bun 1.4.4): it ignores one, and honours only the process-wide `HTTPS_PROXY` / `HTTP_PROXY` / `NO_PROXY`. An egress-locked deploy using S3 sets those as well, with `NO_PROXY` naming the `direct` hosts |
142
+ | `@ultimat3/mail`'s SMTP driver (`Bun.connect`) | **no**: SMTP, not HTTP |
143
+ | `@ultimat3/scraping`'s browser (CDP) | **no**: the session's own `proxy` (`egress`) |
144
+ | core's OTLP exporter, the `x` CLI | **no**, on purpose: in-cluster collector, this machine |
145
+
87
146
  ## `deps.fetch`: the transport
88
147
 
89
148
  `outbound(request, { fetch })` swaps the transport, for a test or in production (a client with its
@@ -131,6 +190,7 @@ the call's `refusal`:
131
190
  | unset (default) | chunks until 1,024 characters are decoded, the rest cancelled (a whole chunk is kept, so one large chunk is read whole) | `meta.detail`: a JSON object, credential-named fields redacted, 200 characters; else `''`. A large error object that arrives in pieces is cut, does not parse, and is `''` |
132
191
  | `{ schema }` | the whole body, up to the call's `maxBytes` | `meta.fields`: the schema's answer, credential-named fields redacted at any depth; absent when the body is not JSON, does not fit or passes `maxBytes`. `meta.detail` is the 200-character excerpt of that whole body |
133
192
  | `{ detail: false }` | nothing for the excerpt | `meta.detail: ''`: the excerpt, and the free text it carries (an address, a name), never kept. Combines with `schema`; it does not filter `meta.fields`, so a schema keeps only fields that are safe to log |
193
+ | `{ headers: ['x-request-id'] }` | the answer's headers; body handling is unchanged | `meta.headers`: a record of lowercased name to value for each asked-for header the answer carries (`{}` when none), each value redacted and cut at 200 characters. Names are case-insensitive, at most 16, each at most 64 characters. A credential-named header (`set-cookie`, `authorization`, `www-authenticate`, `x-api-key` …), an overlong name or a name that is not a header is `X_INVARIANT` at the call, before a byte is sent. Combines with `schema` and `detail`; unset, no header is kept (`As of 2026-11`) |
134
194
 
135
195
  ```ts
136
196
  import { isUltimateError } from '@ultimat3/core';
@@ -152,7 +212,7 @@ try {
152
212
  }
153
213
  ```
154
214
 
155
- The schema is the whole of what `meta.fields` keeps: undeclared keys never reach it. `meta.detail` is a separate excerpt of the raw body and may still carry an undeclared field (an `error.message` holding an email): set `detail: false` to keep only what the schema declares.
215
+ The schema is the whole of what `meta.fields` keeps: undeclared keys never reach it. `meta.detail` is a separate excerpt of the raw body and may still carry an undeclared field (an `error.message` holding an email): set `detail: false` to keep only what the schema declares. With `detail: false` and no schema, the body is not read, including when headers are requested.
156
216
 
157
217
  **A 401 is `X_OUTBOUND_REFUSED` with `meta.status: 401`.** There is no refresh hook: the app's own
158
218
  wrapper refreshes its token and calls again. Token storage and single-flight stay the app's.
@@ -196,5 +256,5 @@ Manual use: `const ticket = gate.admit()`, then `succeeded(ticket)`, `failed(tic
196
256
  |---|---|
197
257
  | `@ultimat3/jobs` webhook delivery | the job's signal outlives the drain on purpose, and a 3xx is an answer, never a hop |
198
258
  | `@ultimat3/scraping`'s HTTP leg | session-bound: browser cookies and a hop chain it owns |
199
- | `@ultimat3/ai` provider calls | own retry across providers, in-band stream errors |
259
+ | `@ultimat3/ai` provider calls | own retry across providers, in-band stream errors; the app-wide proxy still applies (`ambientProxyFor`) |
200
260
  | core's OTLP exporter, `x` CLI transports | an exporter must not log through itself; the CLI dials this machine |
@@ -342,7 +342,7 @@ ES256) signing on WebCrypto. `As of 26.1.0`.
342
342
  | Piece | What | Where |
343
343
  |---|---|---|
344
344
  | config | `pwa: { push: true, vapid: { subject: 'mailto:ops@example.com' } }` — a `subject` push services accept (`mailto:` or `https:`), required with `push`, refused without it | [Configuration](Configuration) |
345
- | key pair | `ULTIMATE_VAPID_PUBLIC_KEY` + `ULTIMATE_VAPID_PRIVATE_KEY`, never config. `x vapid create` mints a P-256 pair and seals BOTH into `secrets.enc.json` in one write; `x vapid show` names the pair in force. Locally, neither set signs with a published development pair; a deployed boot refuses it, half a pair, or two halves that do not sign for each other (`X_PWA_VAPID_KEY_MISSING`, `X_PWA_VAPID_KEY_INVALID`) — at boot, before any service starts | [CLI reference](CLI-Reference#x-vapid) |
345
+ | key pair | `ULTIMATE_VAPID_PUBLIC_KEY` + `ULTIMATE_VAPID_PRIVATE_KEY`, never config. `x vapid create` mints a P-256 pair and seals BOTH into `secrets.enc.json` in one write; `x vapid show` names the pair in force. Locally, neither set signs with a published development pair; a deployed boot refuses it, half a pair, or two halves that do not sign for each other (`X_PWA_VAPID_KEY_MISSING`, `X_PWA_VAPID_KEY_INVALID`) — at boot, before any service starts | [CLI reference](CLI-Reference-Ship#x-vapid) |
346
346
  | subscriptions | `x_push_subscriptions`, a framework table every boot applies; keyed by endpoint (a browser subscribed by a second person is theirs now), with the locale and zone it subscribed in | `@ultimat3/pwa/schema` |
347
347
  | subscribe | `pushSubscribe({ permission })` / `pushUnsubscribe({ permission })` — factories returning real actions an app exports from its own actions module: route, OpenAPI, typed client, contract tests, the one policy path. Stored against `ctx.actor.id`; an agent is refused | `apps/web/app/<slice>/actions.ts` |
348
348
  | the button | `subscribeToPush({ save: client.subscribePush })` from `@ultimat3/pwa/client` (an import-free subpath an island can afford), on a click; answers `subscribed`, `denied`, `unsupported` or `unconfigured` | an island |
@@ -44,6 +44,16 @@ Policies live in `<feature>/policy.ts` and are referenced by name from the featu
44
44
 
45
45
  The decision is surface-blind. The surface selects only how a denial is *rendered* — never whether authz runs, and never how input was validated.
46
46
 
47
+ ### Many rows in one action — `decide(rows)`
48
+
49
+ A handler acting on a batch asks the action's own policy once per row: `handle({ input, ctx,
50
+ decide })`, `decide(rows) → { allowed, denied: [{ row, code, reason }] }`. Same rule, same
51
+ surface as the call, one `policy.decision` event per row (`evaluateEach` in `@ultimat3/policy`). Rows
52
+ are its only parameter — another policy cannot be named. Only an exact allow allows; a throwing
53
+ predicate fails the call; a `null`/`undefined` row is denied without asking. The call's own guard
54
+ asks the rule with `row: null` first, so a batch rule answers `row === null` as "may this actor do
55
+ this at all". Skip-denied or abort-all is the app's choice (axiom 8): no bulk-action factory ships.
56
+
47
57
  | Aspect | Rule |
48
58
  |---|---|
49
59
  | Projects to | HTTP guard, live-query row filter, job actor check, MCP tool gate, admin visibility |
package/wiki/Realtime.md CHANGED
@@ -516,7 +516,33 @@ Every frame carries an LSN. The client's last-seen LSN is what makes reconnect a
516
516
  | Reconnect outside the window | one bounded snapshot query at a current LSN. Never WAL history traversal |
517
517
  | Cursor unusable and no snapshot path supplied | `X_CURSOR_STALE` |
518
518
  | Ordering | LSN is monotonic per DB, so a client can never apply an older change over a newer one |
519
- | What a cursor carries | `{ qid, lsn, ids, at }` and nothing else, `As of 2026-08-24`. `digest` and `count` were written by every snapshot, encoded and validated on every `subscribe` frame, and **read by nothing** — `digest` cost a canonical-JSON render plus a hash over EVERY ROW of every snapshot, paid once per live query per reconnecting socket in the restart storm this package is measured on, and `count` would have been wrong had it ever gained a reader, because `advance` seeds its set from the already-truncated `ids`. Both are deleted, and that is what moved the wire version ([below](#wire-protocol-version)) |
519
+ | What a cursor carries | `{ qid, lsn, ids, at }` and the node's optional `sig` over the first three ([below](#a-cursor-is-signed), `As of 2026-11`), nothing else. `As of 2026-08-24`: `digest` and `count` were written by every snapshot, encoded and validated on every `subscribe` frame, and **read by nothing** — `digest` cost a canonical-JSON render plus a hash over EVERY ROW of every snapshot, paid once per live query per reconnecting socket in the restart storm this package is measured on, and `count` would have been wrong had it ever gained a reader, because `advance` seeds its set from the already-truncated `ids`. Both are deleted, and that is what moved the wire version ([below](#wire-protocol-version)) |
520
+
521
+ ### A cursor is signed
522
+
523
+ `As of 2026-11` (#1280). A cursor's `ids` are read as **rows this subscriber holds**: a delete, or a row a policy now refuses, is sent only to a subscriber holding it. On a resume the cursor is client data, so an id added to it was handed that row's `delete` — that the row exists, and when it went. The node signs what it hands out, and trusts ids only under its own signature.
524
+
525
+ | | |
526
+ |---|---|
527
+ | What is signed | the window (`qid`), the `lsn`, a SHA-256 of the sorted `ids`, and the subscriber — its actor id and tenant. Never `at` (the client's clock), never the `sid` (a reconnect uses a new one) |
528
+ | With what | `@ultimat3/core`'s `keyedFingerprint` under the app's signing secret (`ULTIMATE_CURSOR_SECRET`), with its own derived key. Every `sync` node of one app shares the secret, so a cursor signed on one node resumes on another |
529
+ | Where it rides | down: `snapshot.cursor.sig`, and `patch.sig` — the signature of the cursor that patch leaves the subscriber on. Up: `subscribe.target.cursor.sig` |
530
+ | The client | stores the `sig` of the last frame beside its cursor and echoes it. It never computes one, and holds no key to. A patch that carries none clears it |
531
+ | The browser bundle | carries no signing code: `cursor-sign.ts` is reachable from `@ultimat3/realtime/server` only (`cursor-sign.test.ts` walks the import graph) |
532
+
533
+ | The `sig` on a resume | What the node does | Counter (`LiveQueryRegistry`) |
534
+ |---|---|---|
535
+ | this cursor's, for this subscriber | resumes from it: a delta inside the window, a snapshot outside. A row really held, revoked while away, is still withdrawn | — |
536
+ | present and not this cursor's: edited `ids` or `lsn`, another subscriber's cursor, another window's, a secret rotated since, or a value that is no sig at all | a **cold start** — one snapshot of what this subscriber may see, no replay, no `delete` for an id it named | `cursorsRefused` · `onCursorRefused` |
537
+ | absent — no `sig` key at all: a client built before 2026-11, or one that stripped its own | resumes as it always did, ids trusted | `unsignedCursors` · `onUnsignedCursor` |
538
+
539
+ - **No honest client sends a mismatched `sig`** — only the node mints one — so the cold start is not a break. A steady `cursorsRefused` outside a secret rotation is somebody editing cursors.
540
+ - **The unsigned row is open on `main`**, on purpose: refusing it is a break, and it flips on `next` (an unsigned cursor cold-starts). `unsignedCursors` counts resumes that sent no `sig` — old builds, or a client stripping its own; at zero, nothing resumes unsigned.
541
+ - **Rotating the signing secret costs every open subscription one snapshot** on its next resume, as it invalidates every pagination cursor.
542
+ - **A subscriber's own older cursor still verifies.** It names rows it really held at that position; replaying it reveals nothing it was not sent.
543
+ - **Never the obvious fix**: intersecting `ids` with what the policy admits now cannot tell a forged id from a row held and since revoked, and drops the withdraw the second one is owed.
544
+ - **Optional on the wire, so no `PROTOCOL_VERSION` bump**: an older node sends no `sig` and ignores one. Only an **absent** `sig` is unsigned. One that is present and is no sig — not a string, `null`, longer than 64 characters, outside `[a-z0-9:]` — is kept by the decoder as a marker that verifies for nobody: a cold start, counted in `cursorsRefused`, never a refused frame and never the legacy path.
545
+ - **Cost**: one keyed fingerprint per subscriber per patch frame, ≈ 11 µs (measured 2026-11-27, one core); the ids digest is cached per ids array, and an update moves no id.
520
546
 
521
547
  ## Inbound frame order
522
548
 
@@ -711,7 +737,7 @@ No channel kind carries an ordered, two-way byte stream to a browser — a termi
711
737
  | old node ← new client (v3) | the same, at the other end |
712
738
  | v1 ↔ v2 (2026-08-24) | the old node's `cursor()` reads `digest` through a `str()` that **throws on an absent field**, which is precisely why that was a version and not a silent widening |
713
739
 
714
- **The version guards incompatibility, never novelty.** Two earlier realtime changes deliberately did not move it: an additive optional field (`snapshot.entity`) and a removed field read through `list()` (`hello.resume`) are both readable in either direction, because `decode` builds a whitelist object and `list()` answers `[]` for an absent key. `cursor()` is the other kind of reader — `str`/`num` throw — so removing a field it reads is the one shape that needs the number.
740
+ **The version guards incompatibility, never novelty.** Two earlier realtime changes deliberately did not move it: an additive optional field (`snapshot.entity`; `cursor.sig` and `patch.sig` since) and a removed field read through `list()` (`hello.resume`) are both readable in either direction, because `decode` builds a whitelist object and `list()` answers `[]` for an absent key. `cursor()` is the other kind of reader — `str`/`num` throw — so removing a field it reads is the one shape that needs the number.
715
741
 
716
742
  ## Build skew
717
743
 
@@ -810,6 +836,7 @@ the listener's websocket paths are fixed when it binds. A container scans once,
810
836
  | `X_DEVICE_OFFLINE` | `deviceLink.request()` named a device no node holds a socket for under the caller's tenant | `x doctor --json`, then retry once the device redials |
811
837
  | `X_DEVICE_REQUEST_TIMEOUT` | the device took the request and sent no `response` with its id before `deadlineMs`; or the holding node did not confirm a `disconnect()` | a longer `deadlineMs`, or answer every request the node sends the device; a disconnect: retry, a dead holder closes on its own |
812
838
  | `X_DEVICE_FRAME_TOO_LARGE` | a device frame, or a `request()` frame, past `DEVICE_FRAME_MAX_BYTES` | split the payload, or store the bytes and send their key |
839
+ | `X_DEVICE_WIRE_VERSION` | a `deviceAgent` read a node `hello` whose `v` is above the `DEVICE_WIRE_VERSION` it speaks (1; a hello with no `v` reads as 1). Server-only: raised in the agent, never on a browser's wire | `bun update @ultimat3/realtime` on the agent side, then restart it — or pin the node to the version the device firmware speaks |
813
840
  | `X_BUILD_SKEW` | client build's contract is incompatible with the server's | reload the client; see the fix line on the error |
814
841
 
815
842
  Verbatim shapes: [`packages/realtime/src/errors.ts`](https://github.com/developerz-ai/ultimate/blob/main/packages/realtime/src/errors.ts). Full index: [Error codes](Error-Codes).
@@ -193,4 +193,4 @@ afterAll(() => setAssetResolver(undefined));
193
193
  `x shot <route> --locale en` photographs `/en/<route>` with `Accept-Language: en`. With no
194
194
  `--locale`, `Accept-Language` is still pinned to the app's default locale. `x shot --matrix`
195
195
  photographs every site route in every locale, in light and dark, at 390 and 1440 px, into
196
- `.x/shot/matrix/`, with an `index.html` contact sheet. See [CLI reference](CLI-Reference#x-shot).
196
+ `.x/shot/matrix/`, with an `index.html` contact sheet. See [CLI reference](CLI-Reference-Tools#x-shot).
package/wiki/Testing.md CHANGED
@@ -1387,6 +1387,39 @@ export const exercise = defineExercise(
1387
1387
  );
1388
1388
  ```
1389
1389
 
1390
+ ### A plan budget, and a race
1391
+
1392
+ `As of 2026-11`. `expectPlanWithin(sql\`…\`, { maxCost, maxSortRows }, { client?, entities? })` plans one
1393
+ statement with its real parameters (`explain (format json)` in a read-only transaction; never
1394
+ `analyze`, so nothing runs) and refuses a root `Total Cost` or a `Sort` over more estimated rows
1395
+ than the budget. Both numbers are required: a budget is a measurement of your schema, not a
1396
+ default. Over budget it throws `X_QUERY_PLAN_OVER_BUDGET` (meta `totalCost`, `sortRows`, `node`,
1397
+ `table`); given `entities`, the fix names the `indexes:` entry the plan sweep would, else `analyze`.
1398
+
1399
+ ```ts
1400
+ import { sql } from '@ultimat3/db';
1401
+ import { entity, text, uuid } from '@ultimat3/entity';
1402
+ import { expectPlanWithin } from '@ultimat3/testing';
1403
+
1404
+ const posts = entity('posts', { columns: { id: uuid().primaryKey(), orgId: uuid(), title: text({ max: 80 }) } });
1405
+ const org = '0b9f6c1e-0000-4000-8000-000000000000';
1406
+
1407
+ await expectPlanWithin(
1408
+ sql`select * from posts where org_id = ${org} order by title limit 20`,
1409
+ { maxCost: 60, maxSortRows: 0 },
1410
+ { entities: [posts] },
1411
+ );
1412
+ ```
1413
+
1414
+ Analyze after seeding, and keep one budget per engine: PGlite and Postgres cost the same plan
1415
+ differently, and a table never analyzed is costed as a guess.
1416
+
1417
+ `raceActions(calls, { rounds })` fires `calls` (functions returning promises) together, `rounds`
1418
+ times, and returns `{ settled, serializationFailures }`: every `40P01` or `40001` is listed as
1419
+ `X_DB_SERIALIZATION_FAILURE` with its round and call; assert the list is empty. A call's own
1420
+ failure is never thrown, it is in `settled`. `expectPartial(await decide(rows), { allowed, denied:
1421
+ [{ row, code?, reason? }] })` states a `decide()` answer; a failure is a bun `expect` diff.
1422
+
1390
1423
  ### The statement ceiling
1391
1424
 
1392
1425
  `As of 31.16.0`. The scale sweep judges growth; this judges the count. One call of an action, query