@ultimat3/cli 31.47.1 → 31.49.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 (276) hide show
  1. package/CLAUDE.md +30 -23
  2. package/README.md +96 -4
  3. package/package.json +29 -29
  4. package/src/api-registration.ts +28 -14
  5. package/src/app-load.ts +6 -1
  6. package/src/app-root.ts +7 -1
  7. package/src/clean-services.ts +142 -0
  8. package/src/cmd-auth.ts +3 -0
  9. package/src/cmd-clean-spec.ts +10 -3
  10. package/src/cmd-clean.ts +23 -9
  11. package/src/cmd-db-backfill.ts +6 -0
  12. package/src/cmd-db-branch.ts +10 -4
  13. package/src/cmd-db-recount.ts +5 -12
  14. package/src/cmd-db-rollback.ts +77 -0
  15. package/src/cmd-db-spec.ts +18 -2
  16. package/src/cmd-db-status.ts +5 -10
  17. package/src/cmd-db.ts +105 -33
  18. package/src/cmd-deploy-verify.ts +14 -6
  19. package/src/cmd-docs-topic.ts +94 -0
  20. package/src/cmd-docs.ts +15 -1
  21. package/src/cmd-doctor.ts +109 -41
  22. package/src/cmd-drill.ts +100 -19
  23. package/src/cmd-env.ts +30 -8
  24. package/src/cmd-errors-app.ts +63 -0
  25. package/src/cmd-errors.ts +50 -14
  26. package/src/cmd-generate.ts +17 -4
  27. package/src/cmd-heavy-spec.ts +36 -0
  28. package/src/cmd-heavy.ts +244 -0
  29. package/src/cmd-jobs.ts +27 -1
  30. package/src/cmd-merge-driver-spec.ts +12 -0
  31. package/src/cmd-merge-driver.ts +95 -0
  32. package/src/cmd-new.ts +23 -3
  33. package/src/cmd-policy-spec.ts +9 -1
  34. package/src/cmd-policy.ts +72 -17
  35. package/src/cmd-stop.ts +18 -4
  36. package/src/cmd-tasks-run.ts +87 -0
  37. package/src/cmd-tasks-spec.ts +10 -3
  38. package/src/cmd-tasks.ts +8 -5
  39. package/src/cmd-test.ts +15 -4
  40. package/src/cmd-upgrade-spec.ts +8 -1
  41. package/src/cmd-upgrade.ts +32 -5
  42. package/src/cmd-verify.ts +9 -41
  43. package/src/codemods/agents-doc-row.ts +73 -0
  44. package/src/codemods/define-error-leaf.ts +37 -12
  45. package/src/codemods/docs-many-agents.ts +26 -0
  46. package/src/codemods/docs-worker-commands.ts +26 -0
  47. package/src/codemods/index.ts +6 -0
  48. package/src/codemods/merge-drivers.ts +66 -0
  49. package/src/command.ts +3 -0
  50. package/src/db-applied-edits.ts +117 -0
  51. package/src/db-dev-wire.ts +18 -0
  52. package/src/db-diagnostics.ts +5 -10
  53. package/src/db-generate.ts +82 -7
  54. package/src/db-migrate-pass.ts +51 -0
  55. package/src/db-migrate-through-dev.ts +209 -0
  56. package/src/db-rollback-consent.ts +128 -0
  57. package/src/db-rollback-pass.ts +76 -0
  58. package/src/db-seed-generate.ts +5 -1
  59. package/src/db-seed.ts +7 -1
  60. package/src/deploy-verify-findings.ts +3 -0
  61. package/src/deploy-verify-grade.ts +3 -0
  62. package/src/deploy-verify-processes.ts +32 -0
  63. package/src/dev-boot.ts +3 -0
  64. package/src/dev-db-migrate.ts +155 -0
  65. package/src/dev-db-rollback.ts +33 -0
  66. package/src/dev-db-settled.ts +22 -0
  67. package/src/dev-lock-errors.ts +78 -0
  68. package/src/dev-lock-holder-dir.ts +64 -0
  69. package/src/dev-lock-live.ts +44 -0
  70. package/src/dev-lock.ts +59 -84
  71. package/src/dev-policy.ts +11 -8
  72. package/src/dev-rebuild-schema.ts +116 -13
  73. package/src/dev-rebuild.ts +13 -4
  74. package/src/dev-route-table.ts +7 -0
  75. package/src/dispatch.ts +21 -1
  76. package/src/doctor-advisory-floors.ts +30 -8
  77. package/src/doctor-api-listing.ts +114 -0
  78. package/src/doctor-guarded.ts +41 -0
  79. package/src/doctor-port.ts +90 -17
  80. package/src/doctor-probe.ts +36 -5
  81. package/src/doctor-processes-probe.ts +127 -0
  82. package/src/doctor-processes.ts +136 -0
  83. package/src/doctor-warnings.ts +17 -0
  84. package/src/error-codes-agents.ts +35 -0
  85. package/src/error-codes-processes.ts +30 -0
  86. package/src/error-codes-tooling.ts +11 -3
  87. package/src/error-codes.ts +12 -13
  88. package/src/errors-suite.ts +27 -0
  89. package/src/errors.ts +18 -22
  90. package/src/exec.ts +11 -3
  91. package/src/exercise-registration.ts +4 -3
  92. package/src/framework-env.ts +7 -3
  93. package/src/generate-files.ts +1 -0
  94. package/src/generate-grant-findings.ts +7 -5
  95. package/src/generate-grants.ts +9 -8
  96. package/src/generate-kinds.ts +30 -6
  97. package/src/generate-roles-file.ts +30 -0
  98. package/src/generate-slice-policy.ts +3 -3
  99. package/src/guards.ts +2 -2
  100. package/src/heavy-cores.ts +51 -0
  101. package/src/heavy-env.ts +21 -0
  102. package/src/heavy-errors.ts +54 -0
  103. package/src/heavy-flock.ts +73 -0
  104. package/src/heavy-holders.ts +78 -0
  105. package/src/heavy-ledger.ts +400 -0
  106. package/src/heavy-memory.ts +67 -0
  107. package/src/heavy-pressure.ts +104 -0
  108. package/src/heavy-weights.ts +47 -0
  109. package/src/heavy.ts +308 -0
  110. package/src/i18n-registration.ts +22 -2
  111. package/src/island-harness.ts +2 -2
  112. package/src/job-budget.ts +4 -2
  113. package/src/job-registration.ts +64 -8
  114. package/src/jobs-queue-known.ts +43 -0
  115. package/src/local-cli.ts +6 -5
  116. package/src/mcp-errors-agents.ts +20 -0
  117. package/src/mcp-errors-doctor.ts +27 -0
  118. package/src/mcp-errors-processes.ts +23 -0
  119. package/src/mcp-errors.ts +18 -29
  120. package/src/mcp-host.ts +2 -2
  121. package/src/merge-driver-catalog.ts +58 -0
  122. package/src/merge-driver-config.ts +43 -0
  123. package/src/merge-driver-lines.ts +140 -0
  124. package/src/merge-state.ts +105 -0
  125. package/src/messages-db.ts +22 -1
  126. package/src/messages-processes.ts +13 -0
  127. package/src/messages-upgrade.ts +6 -0
  128. package/src/messages.ts +62 -1
  129. package/src/output-findings.ts +48 -21
  130. package/src/parse.ts +37 -6
  131. package/src/policy-facts.ts +38 -21
  132. package/src/policy-row.ts +99 -0
  133. package/src/port-pair-free.ts +28 -0
  134. package/src/registry-lines.ts +110 -0
  135. package/src/registry.ts +4 -0
  136. package/src/retain-sweep.ts +1 -1
  137. package/src/role-replicator.ts +9 -4
  138. package/src/role-select.ts +86 -0
  139. package/src/role-start.ts +13 -55
  140. package/src/role-sync.ts +10 -5
  141. package/src/runtime-cache-frame.ts +46 -0
  142. package/src/runtime-cache-ttl.ts +23 -0
  143. package/src/runtime-cache.ts +56 -18
  144. package/src/runtime-database-ssl.ts +84 -0
  145. package/src/runtime-idempotency-scope.ts +16 -2
  146. package/src/runtime-jobs-share.ts +52 -0
  147. package/src/runtime-jobs.ts +43 -12
  148. package/src/runtime-overrides.ts +4 -2
  149. package/src/runtime-queue.ts +18 -3
  150. package/src/runtime-services.ts +8 -1
  151. package/src/schema-drift.ts +19 -2
  152. package/src/schema-dump-drift.ts +4 -1
  153. package/src/serve-boot-probe.ts +30 -2
  154. package/src/serve-boot.ts +11 -1
  155. package/src/serve-env.ts +39 -3
  156. package/src/serve.ts +61 -10
  157. package/src/stop-run-start.ts +12 -0
  158. package/src/supervise-boot.ts +61 -0
  159. package/src/supervise-cgroup.ts +84 -0
  160. package/src/supervise-child.ts +206 -0
  161. package/src/supervise-count.ts +244 -0
  162. package/src/supervise-errors.ts +83 -0
  163. package/src/supervise-facts.ts +40 -0
  164. package/src/supervise-messages.ts +84 -0
  165. package/src/supervise-policy.ts +46 -0
  166. package/src/supervise-pool.ts +10 -0
  167. package/src/supervise-probe.ts +158 -0
  168. package/src/supervise-run.ts +54 -0
  169. package/src/supervise.ts +383 -0
  170. package/src/templates/generate-purge.ts +6 -6
  171. package/src/templates/guard-animated-layout-property.ts +2 -2
  172. package/src/templates/guard-bare-error.ts +1 -1
  173. package/src/templates/guard-error-declared.ts +2 -2
  174. package/src/templates/guard-focus-visible.ts +1 -1
  175. package/src/templates/guard-image-dimensions.ts +2 -2
  176. package/src/templates/guard-island-mount-clears.ts +1 -1
  177. package/src/templates/guard-native-confirm.ts +1 -1
  178. package/src/templates/guard-raw-breakpoint.ts +2 -2
  179. package/src/templates/guard-raw-colour.ts +2 -2
  180. package/src/templates/guard-raw-fetch.ts +1 -1
  181. package/src/templates/guard-raw-interval.ts +1 -1
  182. package/src/templates/guard-raw-length.ts +3 -3
  183. package/src/templates/guard-raw-motion.ts +1 -1
  184. package/src/templates/guard-raw-shadow.ts +1 -1
  185. package/src/templates/guard-raw-z-index.ts +1 -1
  186. package/src/templates/guard-released-forms.ts +59 -13
  187. package/src/templates/guard-repo-await-in-loop.ts +1 -1
  188. package/src/templates/guard-repo-raw-sql.ts +4 -4
  189. package/src/templates/guard-repo-unbounded.ts +1 -1
  190. package/src/templates/guard-runtime-pin.ts +1 -1
  191. package/src/templates/guard-semantic-interactive.ts +2 -2
  192. package/src/templates/guard-unbounded-fanout.ts +1 -1
  193. package/src/templates/guard-undeclared-custom-property.ts +3 -3
  194. package/src/templates/guard-undefined-style-class.ts +3 -3
  195. package/src/templates/guard-unzoned-date.ts +3 -3
  196. package/src/templates/query-slice.ts +82 -0
  197. package/src/templates/query.ts +76 -30
  198. package/src/templates/resource-page.ts +3 -2
  199. package/src/templates/scaffold-bin.ts +2 -0
  200. package/src/templates/scaffold-claude-agents.ts +9 -6
  201. package/src/templates/scaffold-claude-commands.ts +7 -1
  202. package/src/templates/scaffold-claude.ts +4 -4
  203. package/src/templates/scaffold-container-compose.ts +47 -7
  204. package/src/templates/scaffold-docs.ts +11 -6
  205. package/src/templates/scaffold-gitattributes.ts +18 -1
  206. package/src/templates/scaffold-helm-templates.ts +9 -0
  207. package/src/templates/scaffold-repo.ts +4 -1
  208. package/src/templates/scaffold-test-services.ts +33 -11
  209. package/src/templates/shapes/offline.ts +0 -7
  210. package/src/templates/shapes/realtime.ts +2 -6
  211. package/src/templates/sign-in-action-tests.ts +6 -4
  212. package/src/templates/sign-in-challenge.ts +62 -0
  213. package/src/templates/sign-in-oidc-mfa.ts +31 -0
  214. package/src/templates/sign-in-oidc.ts +11 -3
  215. package/src/templates/sign-in-password.ts +18 -56
  216. package/src/test-batches.ts +9 -3
  217. package/src/test-shards.ts +117 -37
  218. package/src/test-slots.ts +35 -161
  219. package/src/test-verdict.ts +79 -0
  220. package/src/test-workers.ts +15 -0
  221. package/src/upgrade-gate-codemods.ts +5 -3
  222. package/src/upgrade-gate.ts +19 -1
  223. package/src/upgrade-merge-drivers.ts +25 -0
  224. package/src/upgrade-report.ts +18 -4
  225. package/src/upgrade-scope.ts +62 -0
  226. package/src/verify-checks.ts +6 -11
  227. package/src/verify-coverage-run.ts +9 -5
  228. package/src/verify-deadline.ts +18 -2
  229. package/src/verify-heavy-steps.ts +26 -0
  230. package/src/verify-live.ts +38 -14
  231. package/src/verify-only.ts +67 -0
  232. package/src/verify-progress.ts +7 -3
  233. package/src/verify-run.ts +20 -2
  234. package/src/verify-services-stack.ts +165 -0
  235. package/src/verify-services.ts +84 -2
  236. package/src/verify-test-run.ts +9 -9
  237. package/src/verify-tests.ts +35 -22
  238. package/src/verify-typecheck.ts +25 -2
  239. package/wiki/Actions.md +2 -1
  240. package/wiki/Admin-Dashboard.md +2 -2
  241. package/wiki/Agents.md +5 -5
  242. package/wiki/Auth.md +15 -5
  243. package/wiki/Bare-VM.md +1 -1
  244. package/wiki/Building-Your-Own-Base.md +15 -2
  245. package/wiki/CI-Parallel-Gate.md +4 -4
  246. package/wiki/CLI-Reference.md +127 -48
  247. package/wiki/Caching-And-Invalidation.md +2 -2
  248. package/wiki/Client-Navigation.md +1 -1
  249. package/wiki/Configuration.md +32 -13
  250. package/wiki/Deployment.md +44 -4
  251. package/wiki/Entities-And-Migrations.md +5 -1
  252. package/wiki/FAQ.md +1 -1
  253. package/wiki/Getting-Started.md +2 -2
  254. package/wiki/Home.md +2 -1
  255. package/wiki/I18n.md +5 -3
  256. package/wiki/Installation.md +12 -11
  257. package/wiki/Interface-Rules.md +1 -1
  258. package/wiki/Jobs-And-Workflows.md +24 -4
  259. package/wiki/Known-Gaps.md +2 -2
  260. package/wiki/MCP-And-AI.md +8 -5
  261. package/wiki/Mail.md +1 -1
  262. package/wiki/Many-Agents.md +127 -0
  263. package/wiki/Migrations-And-Backfills.md +18 -0
  264. package/wiki/Notify.md +1 -1
  265. package/wiki/Observability.md +13 -0
  266. package/wiki/Queries-And-Live-Queries.md +2 -2
  267. package/wiki/Realtime.md +10 -1
  268. package/wiki/Routes-And-Render-Modes.md +1 -1
  269. package/wiki/Scheduled-Tasks.md +4 -1
  270. package/wiki/Testing.md +12 -9
  271. package/wiki/Timezones-And-Dates.md +5 -1
  272. package/wiki/Troubleshooting.md +1 -0
  273. package/wiki/Tutorial-01-First-App.md +5 -5
  274. package/wiki/Tutorial-02-First-Feature.md +1 -1
  275. package/wiki/Tutorial-03-Auth-And-Admin.md +7 -6
  276. package/wiki/Upgrading.md +37 -0
@@ -48,7 +48,7 @@ Everything derivable from code is **not** in this file — routes, actions, poli
48
48
  | ~~`defaultTimeZone`~~ | — | — | **Deleted in 25.0.0** — read by nothing but its own validator, and an ambient zone is what the framework forbids. Pass the zone at the call: `formatDate(at, { locale, zone })`, `task({ tz })`, the actor's `tz` (`userActor({ id, locale, tz })`). Refused at boot like the two above |
49
49
  | ~~`defaultCurrency`~~ | — | — | **Deleted in 25.0.0** — read by nothing; every `Money` carries its own `currency`. An app that wants a default declares its own constant. Refused at boot like the three above |
50
50
  | `theme.defaultMode` | `'light' \| 'dark' \| 'system'` | `'system'` | what a visitor with no stored choice gets. The boot inlines the no-flash theme script into every document with this as its fallback and admits it to the CSP — `As of 20.2.0`; before that the key was read by nothing. ~~`theme.tokens`~~ was **deleted in 25.0.0** (read by nothing; the theme is `export const brand = defineTheme(…)` from `@ultimat3/ui` in `apps/web/shared/theme.ts`) and is refused at boot |
51
- | `roles` | `Role[]` | every `ROLE` | which runtime roles this app runs. Empty is `X_CONFIG_INVALID` |
51
+ | `roles` | `Role[]` | every `ROLE` | which runtime roles this app runs. A process started with a `ROLE` outside the list refuses to boot (`X_CONFIG_INVALID`, `meta.key: 'roles'`); `ROLE=migrate` is exempt, so `x db migrate` runs whatever the list says. Unset, every role may start. Empty is `X_CONFIG_INVALID`. `As of 2026-11` (before, the list was validated and read by nothing) — `packages/cli/src/serve-env.ts` |
52
52
 
53
53
  There is no `url` field. The canonical origin is an env key the app reads at its point of use (`APP_URL`), so the same image deploys to every environment.
54
54
 
@@ -59,11 +59,11 @@ There is no `url` field. The canonical origin is an env key the app reads at its
59
59
  | field | type | default | notes |
60
60
  |---|---|---|---|
61
61
  | `database.driver` | `'postgres'` | `'postgres'` | one driver; `postgresDriver()` from `@ultimat3/entity` is its only implementation |
62
- | `database.ssl` | `boolean` | `false` | `true` on managed Postgres |
62
+ | `database.ssl` | `boolean` | `false` | `true` on managed Postgres: the pool the boot opens (every serving role, `x dev`, the migrate step, `x db status`/`recount`/`diagnostics`) adds `sslmode=require` to `DATABASE_URL` and its replica's URL, so a server with no TLS is refused. Added only where no mode is stated: a URL's own `sslmode` (or `ssl`) and a set `PGSSLMODE` always win, in either direction; an empty `sslmode=` states nothing, and the names match case-insensitively (`As of 2026-11-19`) (`withRequiredTls`, `packages/cli/src/runtime-database-ssl.ts`). The same rule reaches every other pool, `As of 2026-11-19`: the replicator's `DATABASE_URL` and `REPLICATION_URL` sessions, `x doctor`'s database probes, `x db branch` and `x deploy verify`'s queue read (`withAppTls`). The embedded database has no wire and ignores it. `As of 2026-11`; before, the key was read by nothing |
63
63
  | `database.rowSecurity` | `boolean` | `false` | every `tenant:` table carries a forced row-security policy (`x db gen`), and a serving role Postgres exempts from it is refused at boot (`X_DB_ROW_SECURITY_BYPASSED`) |
64
64
  | `database.slowStatementMs` | whole ms ≥ 0 | unset: 500 | `As of 31.17.0`. A statement at or over it writes one `db.statement.slow` warn line in **production** — the normalised shape (never a bound value), duration, rows, the request/job id; one line per shape per 10 s, the rest counted as `suppressed`. `0` is off; `NaN`, a negative or a fraction is `X_CONFIG_INVALID` at boot. Outside production the line is off whatever the key says: a test suite's deliberately slow statements are not an incident |
65
65
  | ~~`database.urlEnv`~~ | — | — | **Deleted 2026-08.** Refused at boot since 25.0.0 (`X_CONFIG_INVALID`, naming the replacement). `@ultimat3/db`'s `client.ts` reads `process.env['DATABASE_URL']` as a hardcoded literal, so a different key here could never be honoured. Migration: delete the key; the connection string is `DATABASE_URL` |
66
- | ~~`database.poolSize`~~ | — | — | **Deleted 2026-08.** Refused at boot since 25.0.0 (`X_CONFIG_INVALID`, naming the replacement). A second, non-functioning spelling of `DATABASE_POOL_MAX`, which `baseClient()` layers over the role profile and which works. Migration: delete the key; set `DATABASE_POOL_MAX`. The sizing rule is unchanged — the pool is per PROCESS, so keep `replicas × poolMax` under Postgres `max_connections` |
66
+ | ~~`database.poolSize`~~ | — | — | **Deleted 2026-08.** Refused at boot since 25.0.0 (`X_CONFIG_INVALID`, naming the replacement). A second, non-functioning spelling of `DATABASE_POOL_MAX`, which `baseClient()` layers over the role profile and which works. Migration: delete the key; set `DATABASE_POOL_MAX`. The sizing rule: the pool is per CONTAINER (`As of 2026-11`: split across its processes, never multiplied — [Processes per container](Deployment#processes-per-container)), so keep `replicas × poolMax`, plus one LISTEN session per worker process, under Postgres `max_connections`; `x doctor` prints both per role |
67
67
  | ~~`database.schema`~~ | — | — | **Deleted 2026-08.** Refused at boot since 25.0.0 (`X_CONFIG_INVALID`, naming the replacement). Nothing emits `SET search_path`. Migration: delete the key; there is no replacement, and `entity()` tables live in `public` |
68
68
 
69
69
  Wiring the three instead would have needed a tier-0 → tier-1 read the tier table forbids. Deleting is axiom 3 applied to configuration: a value that produces neither a build error nor a runtime effect is worse than no field, because an SRE sets `poolSize: 3`, redeploys, and nothing changes.
@@ -134,10 +134,10 @@ There is no `auth.trustedOrigins` in either place, and passkeys are `defineAuth`
134
134
  |---|---|---|---|
135
135
  | ~~`jobs.driver`~~ | — | — | **Deleted in 5.0.0.** It accepted `'postgres' \| 'redis' \| 'nats'` and was read by nothing: boot always built the Postgres driver, so `jobs: { driver: 'redis' }` did not throw, did not warn, and silently gave you Postgres. Which driver runs is `jobs:` in `apps/<app>/runtime.ts` and only that — absent, the boot installs `postgresJobDriver()`; a test uses `installJobDriver(memoryJobDriver())` from `@ultimat3/jobs/adapter` ([Jobs and workflows](Jobs-And-Workflows)). Since 25.0.0 a config still writing it is refused at boot, `X_CONFIG_INVALID` naming that seam |
136
136
  | `jobs.queues` | `string[]` | `['default']` | the queue a `job()` naming none lands on (`['<name>-default']` until 31.0.0). A `worker` serves these **and** every queue a registered `job()` is enqueued on (the union, so a job naming no queue is never stranded on `default`). A Deployment that sets [`WORKER_QUEUES`](#env-vars) serves exactly that list instead. Empty is `X_CONFIG_INVALID` |
137
- | `jobs.concurrency` | `number \| Record<queue, number>` | `8` (`JOBS_CONCURRENCY_DEFAULT`) | slots per queue, per worker process. A number applies to every queue served; a table gives each its own (`{ banks: 4, 'banks-long': 2 }`), and a served queue the table does not name runs at `8`. `As of 25.0.0`. A count below 1 or not whole, an empty table or a blank queue name is `X_CONFIG_INVALID` naming the entry (`jobs.concurrency.banks`). An overlay's table replaces the base's whole |
138
- | `jobs.maxInFlight` | `number` | unset (no process cap) | runs one worker **process** holds at once across every queue it serves — Sidekiq's `concurrency`; `jobs.concurrency` still bounds each queue under it. At the cap the worker claims nothing; each run that ends frees one claim, given to the next queue in turn that has work, so no queue starves. `jobWorker`'s `maxInFlight`. `As of 2026-10-28`. Not a whole number of at least 1: `X_CONFIG_INVALID` |
139
- | `jobs.maxAttempts` | `number` | `5` | per-job `retry` overrides it |
140
- | `jobs.backoff` | `'exponential' \| 'fixed'` | `'exponential'` | **two values, not three** — there is no `'linear'` |
137
+ | `jobs.concurrency` | `number \| Record<queue, number>` | `8` (`JOBS_CONCURRENCY_DEFAULT`) | slots per queue, per worker **container** (`As of 2026-11`): a container running N processes splits each total across them, and a queue whose total is below N is served only by the children with index < total, so `concurrency: 1` stays serial across the container. One process per container (every container without a CPU budget) is the old meaning exactly. A number applies to every queue served; a table gives each its own (`{ banks: 4, 'banks-long': 2 }`), and a served queue the table does not name runs at `8`. `As of 25.0.0`. A count below 1 or not whole, an empty table or a blank queue name is `X_CONFIG_INVALID` naming the entry (`jobs.concurrency.banks`). An overlay's table replaces the base's whole |
138
+ | `jobs.maxInFlight` | `number` | unset (no cap) | runs one worker **container** holds at once across every queue it serves, split across its processes as `jobs.concurrency` is (`As of 2026-11`; a process past the total claims nothing) — Sidekiq's `concurrency`; `jobs.concurrency` still bounds each queue under it. At the cap the worker claims nothing; each run that ends frees one claim, given to the next queue in turn that has work, so no queue starves. `jobWorker`'s `maxInFlight`. `As of 2026-10-28`. Not a whole number of at least 1: `X_CONFIG_INVALID` |
139
+ | `jobs.maxAttempts` | `number` | `3` | attempts for a job that declares no `retry` — a factory's job whose `retry` was omitted (`purge()`, `backfill()`, `rollup()`, …). A plain `job()` requires `retry.attempts`, so it always states its own and this key never reaches it. Installed by the boot in every role (`installJobsRetry`, `packages/cli/src/runtime-jobs.ts`): the enqueuing process stamps `max_attempts` by the same policy the worker retries by. `As of 2026-11` (documented as `5` before, a value nothing read: 3 is what always ran). Below 1 or not whole: `X_CONFIG_INVALID` |
140
+ | `jobs.backoff` | `'exponential' \| 'fixed'` | `'exponential'` | the curve between attempts of a job that declares no `retry`, **and** of a `retry` that names no `backoff` (`retry: { attempts: 5 }` takes it); a job's own `retry.backoff` wins (`resolvedRetry`, `packages/jobs/src/retry-default.ts`, `As of 2026-11`). **Two values, not three** — there is no `'linear'` here; a job's own `retry.backoff` may still say `'linear'` |
141
141
  | `jobs.visibilityTimeoutMs` | `number` | `30000` | milliseconds, not a duration string. Lease length; expiry is how a killed worker's job resumes |
142
142
  | `jobs.doneRetentionMs` | `number` | `1209600000` (14 days, `JOBS_DONE_RETENTION_MS_DEFAULT`) | age (from the row's last settle, `updated_at`) past which the hourly `x.purge` deletes a `done` job and its `x_job_steps`. Batched: at most 50 batches of 1,000 rows per pass, each batch one statement plus a follow-up when two sweeps split a run, and one statement per pass for step records whose run has no row left. A job input can hold personal data (`mail.send`: the address and the body), so this has a default, unlike the inbox windows. `As of 2026-10-17` |
143
143
  | `jobs.deadRetentionMs` | `number` | `7776000000` (90 days, `JOBS_DEAD_RETENTION_MS_DEFAULT`) | the same for `dead`, `failed` and `cancelled` rows, which staff read to explain a failure. A live row (`ready`, `delayed`, `running`, `suspended`) is never deleted, and neither is one an unpublished `x_outbox` row or a `running` `x_backfills` row still names. Not a whole number of at least 1: `X_CONFIG_INVALID` |
@@ -226,19 +226,36 @@ its config into a variable first.
226
226
 
227
227
  | field | type | default | notes |
228
228
  |---|---|---|---|
229
- | `cache.defaultTtlMs` | `number` | `60000` | milliseconds, not a duration string |
229
+ | `cache.defaultTtlMs` | `number` | `60000` | milliseconds, not a duration string, at least 1 (`0` is `X_CONFIG_INVALID`: no rung holds a lease of no length). The lease of a value set with no `ttlMs`, on the `lru` and `redis` rungs the boot builds; a rung supplied in `runtime.ts`'s `cacheTiers` keeps its own |
230
230
  | `cache.tiers` | `CacheTierName[]` | `['request-memo', 'lru']` | `'request-memo' \| 'lru' \| 'redis' \| 'cdn'`; order is fixed regardless of listing order, an EMPTY list is refused (`X_CONFIG_INVALID`), and a rung the environment cannot supply refuses the boot |
231
231
  | ~~`cache.driver`~~ | — | — | **Deleted in 9.0.0.** Refused at boot since 25.0.0 (`X_CONFIG_INVALID`, naming the replacement). It was the second way to ask for Redis and the losing one: the ladder is built from `cache.tiers`, so `driver: 'redis'` beside `tiers: ['request-memo', 'lru']` asked for a rung nothing built. Name `redis` in `tiers` |
232
232
  | ~~`cache.urlEnv`~~ | — | — | **Deleted in 9.0.0** and refused at boot since 25.0.0, `database.urlEnv`'s defect verbatim: the Redis tier reads the literal `REDIS_URL`, so `urlEnv: 'MY_REDIS'` made nothing read `MY_REDIS` |
233
233
 
234
- **The per-tier byte caps and TTLs are constructor options, not config** — the same shape as the realtime caps above. `cache.memo.maxBytes`, `cache.lru.maxBytes`, `cache.redis.*` and `cache.ttl.*` are not fields and never were; writing one is `TS2353`, excess property on `Input<CacheConfig>`, and `X_CONFIG_INVALID` at boot.
234
+ **A rung's limits are constructor options, set in `runtime.ts`, never config** `As of 2026-11`. The boot builds `lru` and `redis` with their defaults; `cacheTiers` replaces the rung of the same name, and that is the one way to change a limit:
235
+
236
+ ```ts
237
+ // apps/web/runtime.ts — `cache.tiers` still decides which rungs exist
238
+ import { lruTier, redisTier } from '@ultimat3/cache';
239
+
240
+ export const runtime = {
241
+ cacheTiers: [
242
+ lruTier({ maxBytes: 128 * 1024 * 1024 }),
243
+ redisTier({ maxValueBytes: 2 * 1024 * 1024, jitterFraction: 0.1 }),
244
+ ],
245
+ };
246
+ ```
247
+
248
+ `cache.memo.maxBytes`, `cache.lru.maxBytes`, `cache.redis.*` and `cache.ttl.*` are not fields and never were: writing one is `TS2353`, excess property on `Input<CacheConfig>`, and `X_CONFIG_INVALID` at boot. A bad value is refused where the tier is built (`X_CACHE_LIMIT_INVALID`, `X_CACHE_JITTER_INVALID`). There is no entry-count limit: both rungs are bounded in bytes.
249
+
250
+ A supplied `redisTier` with no `client` uses core's client: `REDIS_URL`, then `VALKEY_URL`, then `redis://localhost:6379`. The refusal the boot's own `redis` rung gets for an unset URL does not apply to it; the boot logs `cache.tier.default-redis` instead.
235
251
 
236
252
  | Option | Where | Default | Effect |
237
253
  |---|---|---|---|
238
254
  | `maxBytes` | `lruTier({ … })` | 64 MiB | byte budget for the whole tier; a single value over it is `X_CACHE_TOO_LARGE` rather than a silent drop |
239
- | `defaultTtlMs` | same | `60_000` | applied when a `set` omits `ttlMs` |
240
- | `jitterFraction` | same | `DEFAULT_TTL_JITTER_FRACTION` | TTL spread in `[0, 1)`; `0` disables it, which is how a stampede is reproduced in a test |
241
- | `clock` / `rng` | same | system | injected so a jittered expiry is deterministic |
255
+ | `maxValueBytes` | `redisTier({ … })` | 1 MiB | the largest encoded value one `set` may write; over it is `X_CACHE_TOO_LARGE` |
256
+ | `defaultTtlMs` | `lruTier({ … })` | `60_000` | applied when a `set` omits `ttlMs` |
257
+ | `jitterFraction` | `lruTier({ … })`, `redisTier({ … })` | `DEFAULT_TTL_JITTER_FRACTION` | TTL spread in `[0, 1)`; `0` disables it, which is how a stampede is reproduced in a test |
258
+ | `clock` / `rng` | `lruTier({ … })`, `redisTier({ … })` | system | injected so a jittered expiry is deterministic |
242
259
  | `loadDeadlineMs` | `cacheStack(tiers, { … })` | `30_000` | how long one `load()` may hold its key before a later reader starts its own. Frees the KEY, never the load — the wedged call runs on. Anchored to `http`'s own request timeout: a load still running at 30 s has no reader left to serve |
243
260
  | `schedule` | same | `setTimeout` | injected so the deadline above is provable without a test waiting one out |
244
261
 
@@ -323,7 +340,7 @@ Only the exact environment `production` emits the configured robots groups and a
323
340
 
324
341
  ## `pwa`
325
342
 
326
- `offline` is a **block**, not a string, `As of 2026-08` — see [Upgrading](Upgrading). Three booleans, two blocks; every field is optional except `pwa.name`, `pwa.colors` and `pwa.offline.fallback`, which `enabled: true` makes required, and `pwa.vapid.subject`, which a `pwa.vapid` block does.
343
+ `offline` is a **block**, not a string, `As of 2026-08` — see [Upgrading](Upgrading). Three booleans, two blocks. Each switch — `enabled`, `backgroundSync`, `push` — must be a real `boolean`, checked even when `enabled` is false: `'false'`, `'true'` or `1` is `X_CONFIG_INVALID` (`As of 2026-11-19`; before, `enabled: 'false'` turned the PWA **on**). `pwa.categories` must be a list of strings, `pwa.offline.neverCache` entries strings, and `pwa.shortcuts` / `pwa.screenshots` lists, else `X_CONFIG_INVALID`. Every field is optional except `pwa.name`, `pwa.colors` and `pwa.offline.fallback`, which `enabled: true` makes required, and `pwa.vapid.subject`, which a `pwa.vapid` block does.
327
344
 
328
345
  ```ts
329
346
  pwa: {
@@ -526,6 +543,7 @@ mail: { retainMime: { maxBytes: 262_144 } },
526
543
  | `SES_CONFIGURATION_SET` | — | SES only, optional: the configuration set that publishes delivery events |
527
544
  | `MAIL_FROM` | — | required by SMTP, Resend and SES; the memory and unconfigured drivers do not read it. `Name <addr>`; also the envelope sender and the `Message-ID` domain |
528
545
  | `MAIL_POOL_SIZE` | — | SMTP connections open at once. Default `4`, whole number ≥ 1 |
546
+ | `MAIL_TIMEOUT_MS` | — | SMTP only: the deadline for any single read or write. Default `30000`, whole number from 1 to 2147483647 (the most a timer holds); anything else is `X_CONFIG_INVALID` at boot |
529
547
 
530
548
  The list is `MAIL_ENV_KEYS` in `packages/mail/src/driver-env.ts`, `As of 2026-10`. More than one of
531
549
  `SMTP_URL`, `RESEND_API_KEY` and `SES_REGION` is `X_CONFIG_INVALID`: a process delivers through
@@ -765,6 +783,7 @@ One typed schema, declared with `defineEnv` at module scope **in `app.config.ts`
765
783
  | `ULTIMATE_STATE_DIR` | all, under `x dev` | no — default `<app>/.x` | relocates the whole of `.x/` (the embedded database, the local disk, the dev lock) for one process tree. The e2e step uses it to boot the app on a throwaway database beside a running `x dev` (`packages/cli/src/runtime-bindings.ts`). 21.0.0 |
766
784
  | `SYNC_URL` | `web` | no — unset dials `/_x/sync` on the page's own origin | where the page's one socket dials, rendered into every document as `<meta name="ultimate-sync">`. Must be `ws://` or `wss://`; anything else is `X_CONFIG_INVALID` at boot. **Required on the Compose rung**, where `sync` is published on its own port with no proxy in front: `SYNC_URL=ws://<host>:3001/_x/sync`. The shipped compose file refuses to start `web` without it. `x dev`, a combined-role container and the Helm chart's ingress all serve `/_x/sync` on the page origin, so they need nothing. `As of 2026-09-22` (21.0.0) |
767
785
  | `WORKER_QUEUES` | `worker` | no — unset or blank serves `jobs.queues` plus every registered job's queue | comma-separated, trimmed, deduplicated. Set, it is the EXACT list this worker claims — `jobs.queues` and the registered queues are not added (`As of 25.0.0`; documented here before then and read by nothing). An empty entry (`banks,,long`) is `X_CONFIG_INVALID` at boot; an entry that is neither in `jobs.queues` nor a registered job's queue — a typo, or a pattern such as `banks-*`, which is never expanded — is `X_WORKER_QUEUE_UNKNOWN` at worker start (`As of 29.0.0`). See [Splitting queues across Deployments](#jobs) |
786
+ | `ULTIMATE_PROCESSES` | `web`, `sync`, `worker` | no — unset, blank or `auto` | `As of 2026-11`: how many processes this production container runs on its one port. `auto` is the container's CPU quota in whole CPUs (1 with none declared), clamped by memory at 256 MiB per process, the pool, per-process state and the platform; a positive whole number is honoured and checked. Anything else is `X_PROCESSES_INVALID`. `x dev`, tests and every environment but `production`/`staging` run one process. Every clamp and refusal: [Processes per container](Deployment#processes-per-container) |
768
787
  | `NATS_URL` | `sync`, `replicator` | no — unset is in-process fanout | one node only; a second replica shares nothing. Unreachable → `X_TRANSPORT_UNAVAILABLE` at boot, not at readiness |
769
788
  | `NATS_KV_BUCKET` | `sync` | no — default `x_presence` | the JetStream KV bucket presence lives in. `[a-zA-Z0-9_-]+`; anything else is `X_TRANSPORT_PROTOCOL` at boot |
770
789
  | `REPLICATION_URL` | `replicator` | no — defaults to `DATABASE_URL` | the connection the WAL is read from; this role must have `REPLICATION` privilege |
@@ -128,7 +128,7 @@ helm upgrade app docker/helm --set roles.worker.retireSeconds=7200 \
128
128
  --set drain.workerDeadlineSeconds=7500 # 2 h worker; `x deploy --method helm` sets both itself
129
129
  ```
130
130
 
131
- **`x verify` holds the job to it**: a job whose declared `timeout` exceeds the worker's budget (`drain.workerRetireMs` when above 0, else `drain.workerDeadlineMs`, else `drain.deadlineMs`) reds the `manifest` step with `X_JOB_OUTLASTS_DRAIN`, naming the job, its limit and the budget. A job with no `timeout` is not graded.
131
+ **`x verify` holds the job to it**: a job whose declared `timeout` exceeds the worker's budget (`drain.workerRetireMs` when above 0, else when the drain cancels a held job: `drain.workerDeadlineMs`, else `drain.deadlineMs`, less the later hooks' reserve and the 2 s cut-off margin — 21 s of 25 s, `As of 2026-11-19`) reds the `manifest` step with `X_JOB_OUTLASTS_DRAIN`, naming the job, its limit and the budget. A job with no `timeout` is not graded.
132
132
 
133
133
  **Compose stays SIGTERM with `stop_grace_period`**: it has no `preStop`, and a SIGKILL mid-job is worse than a handed-back claim, so size `stop_grace_period` to the drain as below. It is the single-node rung, and makes no such claim → [scale ladder](https://github.com/developerz-ai/ultimate/blob/main/docs/idea/17-scale-ladder.md).
134
134
 
@@ -304,15 +304,53 @@ services:
304
304
 
305
305
  **The `/app/.x` tmpfs is owned by the image's user** (`As of 30.0.0`): `'/app/.x:uid=1000,gid=1000'` in the scaffold (its `USER 1000:1000`), `uid=65532` in the framework's specimen (distroless `nonroot`). A tmpfs mounts root-owned under `read_only: true`, so before this every role refused at boot with `X_STORAGE_UNWRITABLE … EACCES mkdir '/app/.x/storage'`. An app scaffolded earlier edits that one line.
306
306
 
307
- > **`web` and `sync` are one replica each, and the file says so** `As of 2026-08`. Both publish a host port, one host port has exactly one binder, so both declare `replicas: 1` — a ceiling that is declared rather than discovered when the second container dies on `port is already allocated`. `worker`, `scheduler` and `replicator` publish nothing; `worker` scales freely.
307
+ > **`web` and `sync` are one container each, and the file says so** `As of 2026-11`. Both publish a host port, one host port has exactly one binder, so both declare `replicas: 1` — a ceiling that is declared rather than discovered when the second container dies on `port is already allocated`. One container is no longer one core: it runs one process per declared CPU on one port ([Processes per container](#processes-per-container)). `worker`, `scheduler` and `replicator` publish nothing; `worker` scales freely.
308
308
  >
309
309
  > | Want | Do |
310
310
  > |---|---|
311
- > | more `web`/`sync` on the same box | delete their `ports:` lines, add a reverse proxy of your choosing to the compose file, point it at the service names — compose DNS resolves each to every replica |
311
+ > | more cores for `web`/`sync` on the same box | raise the service's `cpus:` (and `mem_limit` at 256 MiB per process): the container runs that many processes on its one port |
312
+ > | more `web`/`sync` containers on the same box | delete their `ports:` lines, add a reverse proxy of your choosing to the compose file, point it at the service names — compose DNS resolves each to every replica |
312
313
  > | more `web`/`sync`, full stop | the Helm chart below, which carries a per-role HPA and an Ingress |
313
314
  >
314
315
  > The framework ships neither proxy: a proxy image in `docker-compose.prod.yml` is a dependency every app inherits and a second answer to "how does traffic reach a role" beside the chart's Ingress. This is the rung-1 ceiling → [`docs/idea/17-scale-ladder.md`](https://github.com/developerz-ai/ultimate/blob/main/docs/idea/17-scale-ladder.md).
315
316
 
317
+ ## Processes per container
318
+
319
+ **A production container runs one process per declared CPU, on one port** `As of 2026-11`. The process the platform starts becomes a supervisor: it opens `METRICS_PORT`, spawns N copies of the same entry point (`ULTIMATE_CHILD=<i>/<N>` in each), and the children share the role's port through `SO_REUSEPORT` — the kernel hands each new connection to one of them. One process per core is how a serving path uses a second core: a process runs its requests, jobs and sockets on one JavaScript thread (a `Worker` beside it — `transformImageBytes`' raster worker — takes work off that thread, never requests).
320
+
321
+ **Production containers only.** `x dev`, the test runner and every environment other than `production` and `staging` run one process; a count set there is ignored with one `info` line, never refused (a `.env` shared with production must not stop a laptop).
322
+
323
+ **`ULTIMATE_PROCESSES`** = `auto` (the default, also unset or blank) or a positive whole number, per service. Anything else is `X_PROCESSES_INVALID`. The boot names the count and the clamp that bound it in one line: `ultimate processes` with `count`, `binding` and each clamp's value.
324
+
325
+ `auto` is the minimum of:
326
+
327
+ | Clamp (`binding`) | Value |
328
+ |---|---|
329
+ | `environment` | 1 outside `production` / `staging` |
330
+ | `platform` | 1 off Linux: Bun ignores `reusePort` on macOS and Windows |
331
+ | `role` | 1 for `scheduler`, `replicator`, `migrate` (a lease row, a replication slot, run-once) |
332
+ | `cpu` | the cgroup's CPU quota in whole CPUs, floored, at least 1 (`cpus: '1.5'` → 1), and no more than `navigator.hardwareConcurrency`. **No quota declared (`cpu.max` = `max`) → 1**, whatever the host has |
333
+ | `memory` | `floor((memory limit − 32 MiB) / 256 MiB)`, at least 1; no bound when unlimited |
334
+ | `pool` | `DATABASE_POOL_MAX`, else the role's profile (web 20, sync 10, worker 8): every child needs a connection |
335
+ | `shared-state` | 1 if any per-process state would split: the `lru` cache tier with neither `NATS_URL` nor `REDIS_URL`/`VALKEY_URL`, a `runtime.ts` store whose `scope` is not `'shared'`, the embedded database (no `DATABASE_URL`), `sync` without `NATS_URL` or a crossing transport |
336
+ | `image` | 1 when the image carries no prebuilt store (`X_IMAGE_NOT_PREBUILT`): each child would compile the islands |
337
+
338
+ An explicit count is honoured and checked: 1 always runs; above 1 it is refused for a singleton role (`X_PROCESSES_ROLE_SINGLETON`), off Linux (`X_PROCESSES_UNBALANCED`), over per-process state (`X_PROCESSES_UNSHARED_STATE`) and above the pool (`X_PROCESSES_OVER_POOL`); above the memory fit it runs with a `warn` line. A child whose boot is refused for a reason the same image and environment meet again — a missing or malformed variable (`X_ENV_MISSING`, `X_ROLE_UNKNOWN`, `X_PORT_INVALID`), `X_CONFIG_INVALID`, a secrets or seal key that does not match, an unresolved import, every `X_PROCESSES_*` refusal — is not restarted: it logs `ultimate child refused to boot` with its own code and fix, the siblings drain and the container exits 1 at once (`FATAL_BOOT_CODES`, `packages/cli/src/supervise-child.ts`). What can heal by itself — a database, Redis or NATS still starting, migrations not yet applied, a port still held — is restarted with backoff. A child that exits unexpectedly 5 times in 5 minutes is `X_PROCESS_CRASH_LOOP`: the siblings drain and the container exits 1 for the platform to restart.
339
+
340
+ **Per container, never per process**: `DATABASE_POOL_MAX` (each child gets its `childShare`, so the container's connections do not grow with N), `jobs.concurrency` and `jobs.maxInFlight` (split the same way; a queue whose total is below N is served only by children with index < total, so `concurrency: 1` stays serial across the container). Each worker child holds its own LISTEN session: connections per container = pool + N for `worker`. `x doctor` prints both per role; `x deploy verify` reports N registry rows per worker container (`data.queues.containers`). Per-process still, and so N× per container: `perTenant` / `ratePerTenant` job caps and the per-actor socket caps — as with N containers today.
341
+
342
+ | What | Rule |
343
+ |---|---|
344
+ | `cpus:` | the knob `auto` reads. The shipped compose files declare `web: '2'`, `sync: '1'`, `worker: '1'` per replica (raise it for CPU-heavy queues), `scheduler: '0.5'`, and the framework's `replicator: '0.5'` (the scaffold writes no `replicator` service) |
345
+ | memory | 256 MiB per child plus headroom. Measured private memory of a reference-app web child: 104–106 MiB idle, 227 MiB peak under load; worker and sync 97–100 MiB idle; the supervisor about 3 MiB (`As of 2026-11`, Bun 1.4.4, Linux) |
346
+ | `init: true` | on every service. Bun as PID 1 never reaps an orphaned grandchild (zombies stay) and ignores SIGTERM until a handler is installed (`docker stop` waited out its grace and SIGKILLed); Docker's init fixes both |
347
+ | `sysctls: { net.ipv4.tcp_migrate_req: 1 }` | **an opt-in, commented out** on `web` and `sync` in the shipped files, never active: on a kernel older than Linux 5.14 (RHEL 8, Ubuntu 20.04, Amazon Linux 2) the knob does not exist and Docker refuses to create the container. Uncomment it on a host ≥ 5.14 where the container runs more than one process: closing a shared-port listener — a drain, a crash — otherwise resets every connection still queued on it (93–109 of 200 reset with the host default 0, 0 of 200 with the sysctl; per network namespace). At N = 1 it buys nothing. `x doctor` warns when N > 1 and the knob exists and reads 0 |
348
+ | a proxy in front | nginx and Caddy defaults need nothing: under load an HTTP/1.1 proxy opens one upstream connection per in-flight request, and CPU-bound work split 24–26 % per child at N=4. The upstream needs **at least 4 × N concurrent connections at peak**: with about 2N or fewer long-lived connections some child often gets none (balancing is per connection, by hash) and 20–40 % of throughput is lost. Do not cap upstream connections near N (`max_conns`, a tunnel with a fixed connection count). An HTTP/2-multiplexed upstream (one connection) is **unsupported for N > 1**: unmeasured, and the worst case puts everything on one child |
349
+ | probes | the supervisor answers `METRICS_PORT`: `/healthz` (alive, not in a crash loop), `/readyz` (at least one child ready, every other one ready or draining, the container not stopping), `/metrics` (every child's, merged with a `child` label → [Observability](Observability)). The image's `HEALTHCHECK` on `$PORT/readyz` reaches one child at random. A child opens no boot probe on the shared port: a plain bind would refuse its siblings (EADDRINUSE) and a shared one would take real traffic to answer 503 |
350
+ | drain | SIGTERM, SIGINT and SIGUSR2 (worker retire) go to every child at once; each child's budget starts at its `draining` acknowledgement (a CPU-saturated child heard the signal 1.9–5.2 s late, measured) and it is SIGKILLed 2 s past it; one outer ceiling, the longest budget + 6 s from the signal, bounds the container. Children drain in parallel, so `stop_grace_period` and `terminationGracePeriodSeconds` do not change. Exit 0 if every child exited 0, 70 if any hit its drain deadline |
351
+
352
+ What it buys, measured (`As of 2026-11`, Bun 1.4.4, Linux, 8 cores, a box shared with other agents — read the ratios, not the absolutes): a handler burning ~2 ms of CPU went from 523 rps at N=1 to 1,485–1,711 at N=4 (2.9–3.3×); the reference app spends 0.24–0.34 CPU-ms per request and one process saturates one core at 3.4–4.7k rps, so `web` sits in the CPU-bound row. A pure-wait handler gains nothing until one process saturates (~50k rps here). The full table: [`docs/idea/17-scale-ladder.md`](https://github.com/developerz-ai/ultimate/blob/main/docs/idea/17-scale-ladder.md).
353
+
316
354
  ## Helm
317
355
 
318
356
  **`x new` writes it**, `As of 2026-08-19` — `docker/helm`, one `Deployment` per role, 8 files: `Chart.yaml`, `values.yaml` and 6 templates. There is still no `--helm` flag on `x build`; the chart is a scaffold artifact like `docker/Dockerfile`, not a build target.
@@ -326,6 +364,8 @@ services:
326
364
  | `replicator` | none — `replicas: 1` | 1 | owns the slot; `strategy: Recreate`, because a surged pod can only stand by unready and `maxUnavailable: 0` would never retire the holder |
327
365
  | `migrate` | n/a | — | pre-install/pre-upgrade `Job` hook; blocks the release on failure |
328
366
 
367
+ **One process per pod**: both charts set `ULTIMATE_PROCESSES: "1"` on every role (`env.ULTIMATE_PROCESSES` in values wins). Per-pod parallelism is the HPA's; the chart sets CPU requests and no limits, so `auto` already resolves to 1 there — the pin makes the count explicit, and a CPU limit added later cannot raise it.
368
+
329
369
  CPU autoscaling is wrong for `sync` and `worker`: a node holding 80k idle sockets is near-zero CPU and near-capacity, and a worker blocked on a slow HTTP call is idle CPU with a growing backlog. The framework **declares** both series — `connections` and `queue_demand`, with `rps` derived from the monotonic `http_requests_total` — and `SCALING_METRICS` maps each role's signal to its series so the chart and the role table cannot drift. `As of 2026-08` every role serves `/metrics` on `METRICS_PORT` (default 9090) and `http`/`realtime`/`jobs` call the recorders, so the signals exist. **The chart's half is closed in 2.0.0**: `values.yaml` declares `metricsPort: 9090`, `_helpers.tpl` emits a container port named `metrics` on every role but `migrate`, `service.yaml` publishes it by name and `templates/servicemonitor.yaml` ships the scrape target. `serviceMonitor.enabled` is `auto`: the object renders wherever the cluster serves the Prometheus operator's kind and is skipped where it does not, so `helm install` never fails on an unknown kind — and `templates/alert-rules.yaml` ships the mechanism alerts the same way (`alerts.enabled: auto`). One thing remains, and it is not the chart's: turning scraped series into the `Pods` metrics an HPA reads needs a **custom-metrics adapter**. Do not hand-add a metrics container port — the chart already emits one and a duplicate is rejected by the API server → [Observability](Observability).
330
370
 
331
371
  `x deploy --method helm` works in a fresh app `As of 2026-08-19`: the command implements helm
@@ -419,7 +459,7 @@ Then reopen the pooler's server connections: a role setting applies at login.
419
459
  | Role | Under `DATABASE_POOLER=transaction` |
420
460
  |---|---|
421
461
  | `web`, `sync`, `scheduler` | runs |
422
- | `worker` | runs on the poll: no wake, pickup within `idlePollMaxMs`, `jobs.wake.unverified` once. For the wake, a direct or session-pooled `DATABASE_URL` and `DATABASE_POOLER` unset or `session` for that role |
462
+ | `worker` | runs on the poll: no wake, pickup within `idlePollMaxMs`, `jobs.wake.unverified` once. For the wake, a direct or session-pooled `DATABASE_URL` and `DATABASE_POOLER` unset or `session` for that role. A proven wake is re-proven every 10 s (`reproveEveryMs`): a session that stops delivering logs `jobs.wake.lost` and the worker returns to the 2 s poll |
423
463
  | `migrate`, `replicator`, `x db migrate` | `X_DB_POOLER_SESSION_REQUIRED`, before a socket: point `DATABASE_URL` at the server's own port and unset the switch for that role |
424
464
 
425
465
  `x doctor --json` reports the bound as the session reads it (`data.statementBound`). A bound that
@@ -179,6 +179,10 @@ constructs where the two engines disagree are **refused at declaration**:
179
179
  | `\s` `\S` | `'\u00a0'` is whitespace to JS, not to Postgres | `[ \t\n\r\f\v]` |
180
180
  | `\A` `\Z` | anchors in Postgres, letters in JS | `^` `$` |
181
181
  | `\1`–`\9`, `(?<name>…)`, `(?i)`, `[[:alpha:]]`, a non-ASCII range endpoint | backreference, named group, embedded flag, POSIX class, collation-ordered range | a predicate |
182
+ | a surrogate escape `\uD800`–`\uDFFF` (any astral character written in a regex literal) | JS matches the pair as one character, Postgres reads two code points no text holds — its CHECK refused every row. `As of 2026-11-19` | a predicate |
183
+ | a repetition bound above 255 (`{256}`) | Postgres refuses the migration: invalid repetition count. `As of 2026-11-19` | a smaller bound, or a predicate on `length` |
184
+ | a `-` straight after a range or `\d`/`\D` inside a class, not last (`[a-z-9]`, `[\d-z]`) | Postgres refuses an invalid range; JS reads a literal `-`. `As of 2026-11-19` | `-` last in the class: `[a-z9-]` |
185
+ | a quantified lookaround (`(?=…)*`, `(?!…){2}`) | JS allows it (Annex B), Postgres refuses the operand. `As of 2026-11-19` | the lookaround unquantified |
182
186
 
183
187
  The refusal is `X_INVARIANT_VIOLATED` at `entity()` time — before a migration exists — and names the
184
188
  construct, its index, both readings, and the portable spelling where there is one. The subset is
@@ -1386,7 +1390,7 @@ Rule: `.search(term)` on a chain asks the INSTALLED `SearchIndex` — one search
1386
1390
  | Index | How `.search(term)` answers |
1387
1391
  |---|---|
1388
1392
  | the built-in Postgres one (default) | inside the statement, its `matches` predicate over the `.searchable()` columns — the same SQL as before the port; costs a write nothing |
1389
- | an external one (`searchIndex` in `apps/<app>/runtime.ts`: Meilisearch, Typesense, the app's adapter) | ids first, then the chain reads those rows — tenancy, soft delete, order and cursor still apply, so a hit can never widen what the chain sees |
1393
+ | an external one (`searchIndex` in `apps/<app>/runtime.ts`: Meilisearch, Typesense, the app's adapter) | ids first, then the chain reads those rows — tenancy, soft delete, order and cursor still apply, so a hit can never widen what the chain sees. Asked one tenant at a time: the chain's `eq` on the tenant column, else the actor's org. Inside `crossTenant()` an `andWhere('<tenant>', 'in', [...])` asks it once per listed tenant, and a chain naming no tenant is `X_INVARIANT_VIOLATED` — before `As of 2026-11-19` it silently answered the actor's org alone |
1390
1394
 
1391
1395
  | Fact | Detail |
1392
1396
  |---|---|
package/wiki/FAQ.md CHANGED
@@ -97,7 +97,7 @@ Yes. CI runs exactly `x verify` — no bespoke pipeline steps, because a check t
97
97
 
98
98
  ### Do I need Docker to develop?
99
99
 
100
- No. `x dev` uses embedded PGlite, in-process events, and a local directory in place of S3. `bunx create-ultimate myapp && cd myapp && bun run setup && bun run dev` — no Docker install, no `.env` scavenger hunt. `bun run setup` is six steps — `bun install`, an `.env.development.local` touch, `x db gen "initial"`, `x db migrate`, `x db seed`, `x manifest` — and is not optional: `x new` installs nothing ([Getting started](Getting-Started), [Bare VM](Bare-VM)). The compose files exist for parity debugging and CI jobs that want real services ([Deployment](Deployment)).
100
+ No. `x dev` uses embedded PGlite, in-process events, and a local directory in place of S3. `bunx create-ultimate myapp && cd myapp && bun run setup && bun run dev` — no Docker install, no `.env` scavenger hunt. `bun run setup` is seven steps — `bun install`, `x merge-driver install`, an `.env.development.local` touch, `x db gen "initial"`, `x db migrate`, `x db seed`, `x manifest` — and is not optional: `x new` installs nothing ([Getting started](Getting-Started), [Bare VM](Bare-VM)). The compose files exist for parity debugging and CI jobs that want real services ([Deployment](Deployment)).
101
101
 
102
102
  ### Do I need Redis or NATS?
103
103
 
@@ -7,8 +7,8 @@ bunx create-ultimate myapp && cd myapp && bun run setup && bun run dev
7
7
  Building a blog or an API rather than a dashboard? Add `--shape blog` or `--shape api` to the
8
8
  first command: [Shapes](Shapes) says what each writes and leaves out.
9
9
 
10
- **Four commands, and `bun run setup` is one of them.** It is the scaffold's own script, six steps —
11
- `bun install`, an `.env.development.local` touch, `x db gen "initial"` when
10
+ **Four commands, and `bun run setup` is one of them.** It is the scaffold's own script, seven steps —
11
+ `bun install`, `x merge-driver install`, an `.env.development.local` touch, `x db gen "initial"` when
12
12
  `packages/db/migrations` holds no `.sql`, `x db migrate`, `x db seed`, `x manifest` — idempotent, so
13
13
  re-running it after a pull is safe. The last step is not optional either: `x.manifest.json` is a
14
14
  projection of the loaded app, nothing else ever runs the command, and `x verify`'s `manifest` step
package/wiki/Home.md CHANGED
@@ -53,7 +53,7 @@ Those facts are repeated on several pages because the wiki is plain markdown wit
53
53
 
54
54
  ## Tutorials
55
55
 
56
- Follow in order. Each page states what it was executed against in its own first line — tutorial 1 its own measurement. `As of 2026-11-03`, 2–4 were re-run by hand, whole, in the app tutorial 1 leaves, and 5 with Docker up to the point a real host is needed. `scripts/tutorial-run.ts` (workflow `tutorial-run.yml`, on `main`) runs 1–4 in order and never 5; it has not yet run green. A workaround for a gap fixed since has been removed rather than left to mislead.
56
+ Follow in order. Each page states what it was executed against in its own first line — tutorial 1 its own measurement. `As of 2026-11-03`, 2–4 were re-run by hand, whole, in the app tutorial 1 leaves, and 5 with Docker up to the point a real host is needed. `scripts/tutorial-run.ts` (workflow `tutorial-run.yml`, on `main` and weekly since 2026-11-19) runs 1–4 in order and never 5; it has not yet run green. A workaround for a gap fixed since has been removed rather than left to mislead.
57
57
 
58
58
  | Page | You end with |
59
59
  |---|---|
@@ -91,6 +91,7 @@ Follow in order. Each page states what it was executed against in its own first
91
91
  | [Client navigation](Client-Navigation) | soft navigation over server-rendered pages: one config line per surface, swap, prefetch, history, focus |
92
92
  | [MCP and AI](MCP-And-AI) | the dev MCP server, every action as a tool, the `llm()` gateway, evals |
93
93
  | [Agents](Agents) | `agent()` as an action factory, tools as real actions, `hive()`, `agentJob()`, and the at-least-once trap |
94
+ | [Working with many agents](Many-Agents) | a worker runs its own files, the coordinator runs the gate once; the machine's memory ledger and core cap |
94
95
  | [Admin dashboard](Admin-Dashboard) | `defineAdmin()` serving list, detail and form per entity with no host code; filters, scopes, sections, related rows, actions with `when` and `batch`, the audit log, the jobs dashboard; zero JavaScript; its MCP surface |
95
96
  | [Scraping](Scraping) | `scrape()` as a job factory, the driver-blind page vocabulary, robots and host gates, per-run egress, a rented CDP browser, usage, sealed sessions, mid-run prompts |
96
97
  | [Auth](Auth) | sessions, OAuth, MFA, API keys and service tokens — the output is an `Actor` |
package/wiki/I18n.md CHANGED
@@ -118,8 +118,10 @@ translator over it (`As of 2026-10`):
118
118
  | page (server) | `catalogSubset(t, ['app.post.likes'])` from `@ultimat3/i18n`; `uiCatalog(t)` from `@ultimat3/ui` for every `ui.*` key |
119
119
  | island | `subsetTranslator(props.strings)` from `@ultimat3/i18n/subset`; `<UiProvider t={subsetTranslator(props.ui)}>` |
120
120
 
121
- The slice carries every plural variant of each key, and a key it lacks renders `⟦key⟧` in the
122
- island exactly as on the server.
121
+ The slice carries every plural variant of each key and every `_select_*` / `_ordinal_*` family
122
+ member (`packages/i18n/src/subset.ts`, `As of 2026-11`; before, an island rendered `⟦key⟧` for a
123
+ select or ordinal the server rendered). A key it lacks renders `⟦key⟧` in the island exactly as on
124
+ the server.
123
125
 
124
126
  **A form's validation messages key on the issue's `rule`**, never on its English `message` — the
125
127
  framework's diagnostic text changes without a semver signal, the rule names do not
@@ -182,7 +184,7 @@ A dynamic call contributes its static head (`plans.`) as a runtime-key prefix, s
182
184
  | Static export | `x build --target static` renders each `site/` page once per routed locale, in that locale's context: `index.html` (`lang="es-co"`), `en/index.html` (`lang="en"`), `en/precios/index.html`. Every static host serves `/en/precios` from that layout with no rewrite |
183
185
  | Cookie | `x_locale`, written only by an explicit language switcher |
184
186
  | Unsupported tag | skipped, not thrown — a stale cookie must never 500 a page. `assertSupportedLocale` throws `X_LOCALE_UNSUPPORTED` where an unknown tag is a caller bug |
185
- | Direction | `currentDirection()` returns `'rtl'` for `ar`, `he`, `fa`, `ur`, … and is written to `<html dir>` |
187
+ | Direction | `currentDirection()` returns `'rtl'` for `ar`, `he`, `fa`, `ur`, … and is written to `<html dir>`. An explicit script subtag decides first: `az-Arab` is `rtl`, `ks-Deva` `ltr`. Bare `ku` is `ltr` (Kurmanji, Latin script); Kurdish in Arabic script is `ku-Arab` or `ckb` (`isRtl`, `packages/core/src/locale-direction.ts`, `As of 2026-11`) |
186
188
 
187
189
  | API | From | Answers |
188
190
  |---|---|---|
@@ -47,16 +47,17 @@ TypeScript that Bun executes, no bash and no WSL — and `bun run dev` and `bun
47
47
 
48
48
  **`bun run setup` is not optional.** `x new` writes files and installs nothing, so `cd myapp && x dev`
49
49
  stops on `X_BUILD_FAILED` naming `bun install` (measured `As of 2026-08-23`; this page said
50
- otherwise until then). `bun run setup` is six steps, idempotent and safe to re-run:
50
+ otherwise until then). `bun run setup` is seven steps, idempotent and safe to re-run:
51
51
 
52
52
  | # | Step | Why it is in the script |
53
53
  |---|---|---|
54
54
  | 1 | `bun install` | `x new` writes files and installs nothing |
55
- | 2 | touch `.env.development.local` | per-box secrets, gitignored, wins over the committed `.env.development` |
56
- | 3 | `x db gen "initial"` | skipped when `packages/db/migrations` already holds a `.sql` — `x db gen` is that directory's only writer |
57
- | 4 | `x db migrate` | applies them, then diffs the live schema against the ledger |
58
- | 5 | `x db seed` | run through the CLI, never `bun run`: the CLI owns the connection, so it reaches the same embedded database the migration just wrote to |
59
- | 6 | `x manifest` | `x.manifest.json` is a projection of the loaded app, so `x new` cannot write it. Nothing else ever ran the command, and `x verify`'s `manifest` step now refuses its absence with `X_MANIFEST_MISSING` |
55
+ | 2 | `x merge-driver install` | git keeps merge drivers in `.git/config`, which no clone inherits: [Merging two features](Many-Agents#merging-two-features) |
56
+ | 3 | touch `.env.development.local` | per-box secrets, gitignored, wins over the committed `.env.development` |
57
+ | 4 | `x db gen "initial"` | skipped when `packages/db/migrations` already holds a `.sql` — `x db gen` is that directory's only writer |
58
+ | 5 | `x db migrate` | applies them, then diffs the live schema against the ledger |
59
+ | 6 | `x db seed` | run through the CLI, never `bun run`: the CLI owns the connection, so it reaches the same embedded database the migration just wrote to |
60
+ | 7 | `x manifest` | `x.manifest.json` is a projection of the loaded app, so `x new` cannot write it. Nothing else ever ran the command, and `x verify`'s `manifest` step now refuses its absence with `X_MANIFEST_MISSING` |
60
61
 
61
62
  Every flag, from the registry — `bun run x -- help new`, or `x help new` in an app. There are six,
62
63
  each with a default, so **`x new` asks nothing**: an agent cannot answer a prompt and is never given
@@ -118,18 +119,18 @@ Boot parses this before any listener binds. Failure costs ~40ms and exit 1 — n
118
119
 
119
120
  ```
120
121
  X_ENV_MISSING: required environment variables are missing or invalid
121
- cause: STRIPE_KEY missing; NATS_URL is not a URL ("nats:4222")
122
- fix: add STRIPE_KEY, NATS_URL to .env (copy .env.example), then run: x env check
122
+ cause: STRIPE_KEY is missing (expected a non-empty string); NATS_URL is not an absolute URL (received a string of 4 characters)
123
+ fix: echo 'STRIPE_KEY=<value>' >> .env.development.local # STRIPE_KEY: a non-empty string; also malformed, where grep -n -e '^NATS_URL=' .env* finds them: NATS_URL (an absolute URL)
123
124
  ```
124
125
 
125
- The `fix:` is per-key and built from your own declarations ([`packages/core/src/env.ts:237`](https://github.com/developerz-ai/ultimate/blob/main/packages/core/src/env.ts)); a `fix` on one `envSchema` entry overrides it for that key.
126
+ The fix is the line to add, in the file this environment loads: `.env.development.local` in development, `.env.test.local` under test, `.env.production` for a deploy (`envFileFor`, [`packages/core/src/env.ts`](https://github.com/developerz-ai/ultimate/blob/main/packages/core/src/env.ts)). Several missing keys are one `printf '%s\n' 'A=<value>' 'B=<value>' >> <file>`; a malformed key is found where it is set (`grep -n -e '^KEY=' .env*`). The cause names each value's shape, never its content. A `fix` on one `envSchema` entry overrides it for that key. `As of 2026-11-19`.
126
127
 
127
128
  | Property | Behavior |
128
129
  |---|---|
129
130
  | Access | `env.STRIPE_KEY` is typed. A `process.env` read outside the schema is a lint error |
130
131
  | Per-role | a role requires only the keys it uses — `ROLE=worker` does not fail on a missing `VAPID` |
131
132
  | Repair | `x env example` regenerates `.env.example` from the schema; copy the keys it names into `.env.development.local` in dev, or into your platform's secret store in production. There is **no** `x env --fix` — `x env` declares `check` and `example` and no flags, so `x env check --fix` dies at the parser with `X_CLI_BAD_FLAG` |
132
- | CI | `x verify`'s `manifest` step holds `.env.example` to the schema's projection (`X_ENV_EXAMPLE_DRIFT`); `x env check` is not a gate step — run it against the deploy's own environment (`ULTIMATE_ENV=production x env check`), where it also reports the framework's deploy-required secrets |
133
+ | CI | `x verify`'s `manifest` step holds `.env.example` to the schema's projection (`X_ENV_EXAMPLE_DRIFT`); `x env check` is not a gate step — run it against the deploy's own environment (`ULTIMATE_ENV=production x env check`), where it also reports the framework's deploy-required secrets. With no `ULTIMATE_ENV` or `NODE_ENV` set it checks as development (as `x dev` runs), except under `CI`, where it checks as production (`As of 2026-11-19`) |
133
134
  | Provenance | `/_x` → **Env** shows every resolved key and which source it came from |
134
135
 
135
136
  ## What Bun natives replace
@@ -194,7 +195,7 @@ server itself rather than counted here. The core of it:
194
195
  | `verify.run` | guessing whether the work is shippable |
195
196
  | `logs.tail` | scrollback archaeology |
196
197
 
197
- Read tools are unrestricted in dev; write tools are scoped to branch environments. The dev server is never exposed under `ROLE=web`. `db.query` refuses a batch, a write keyword anywhere at statement level (a data-modifying CTE included), a locking clause, `EXPLAIN ANALYZE`, and the banned function families matched by prefix (`pg_read_*`, `pg_ls_*`, `lo_*`, `pg_advisory_*`, `pg_sleep*`, `set_config`, …) — `X_MCP_QUERY_REJECTED`, before the host sees the string. Use `x mcp` for a standalone server (CI, remote agents). Editor config: Biome is the only formatter/linter — one binary, one config, no ESLint or Prettier.
198
+ Read tools are unrestricted in dev; write tools are scoped to branch environments. The dev server is never exposed under `ROLE=web`. `db.query` refuses a batch, a write keyword anywhere at statement level (a data-modifying CTE included), a locking clause, `EXPLAIN ANALYZE` (or `ANALYSE`), and the banned function families matched by prefix (`pg_read_*`, `pg_ls_*`, `lo_*`, `pg_advisory_*`, `pg_sleep*`, `set_config`, `pg_copy_*`, `pg_sync_replication_*`, `pg_backup_*`, `pg_start_backup`, `pg_stop_backup`, `pg_restore_*`, `pg_clear_*`, …) — `X_MCP_QUERY_REJECTED`, before the host sees the string. Use `x mcp` for a standalone server (CI, remote agents). Editor config: Biome is the only formatter/linter — one binary, one config, no ESLint or Prettier.
198
199
 
199
200
  ## Upgrading and removal
200
201
 
@@ -346,7 +346,7 @@ Read as a review checklist. Each one is a defect on sight.
346
346
  | live regions and the focus trap | `packages/ui/src/a11y.ts` |
347
347
  | the toast queue's rules | `packages/ui/src/toast/toast-state.ts` |
348
348
  | a list's URL state (sort, cursor, limit, `q`) | `packages/ui/src/list-url.ts` |
349
- | your app's guards | `guards/` in the app root — `x new` writes every name in `SHIPPED_GUARD_NAMES`, `x g guard <name>` adds one, `x doctor` lists the shipped ones missing |
349
+ | your app's guards | `guards/` in the app root — `x new` writes only `guards/shipped.json`, `x g guard <name>` adds one of your own, `x doctor` lists any copy of a shipped guard still held |
350
350
 
351
351
  Components, props and token vocabulary: [UI components](UI-Components). Colour roles and the
352
352
  contrast table: [Theming](Theming). Seeing a component in a state you cannot click to:
@@ -256,9 +256,9 @@ export const syncCrm = job({
256
256
  | `concurrency: { key, limit }` | max simultaneous runs **sharing one key** — "one run per account" | the same lease rows, one set per `key(input)`. `key` answers a non-empty string of at most 200 characters; `limit` is a whole number, 1 or more |
257
257
  | `concurrency.whenBusy` | what a claim over the cap does. `'wait'` (default): the run stays queued, no attempt burned. `'fail'`: the run settles **`failed`** with `X_JOB_KEY_BUSY`, its body never runs, nothing retries it, and it is not a dead letter | the worker, at claim. A plain number always waits |
258
258
  | `limiter: vendorApi` | a **named fleet budget** several jobs share — "the payment provider takes 10 calls a second and 4 at once, whichever job makes them". Declare `export const vendorApi = limiter('vendor-api', { rate: { limit: 10, windowMs: 1_000 }, concurrency: 4 })` ONCE at module scope and import it into every `job({ limiter })`. `rate` is at most `limit` starts in any `windowMs` (sliding, no burst past it); `concurrency` is runs holding it at once. Either or both. `As of 2026-11-14` | the installed driver's `JobDriver.leases` — `x_job_leases` rows keyed `limiter:<name>:rate` (one per start, TTL the window) and `:concurrency` (one per held slot, renewed, released at the end) — gated around the BODY, ahead of the first `step.run`. A run over it throws `X_RATE_LIMITED`, deferred to when the oldest start lapses (1 s for a full concurrency cap) with the attempt **uncounted**. A start is an entry before any step completed or suspended: a resume after `step.sleep`/`waitForEvent`, or a retry past a completed step, spends no rate; a retry after a failed first step spends again. The slot's TTL and renewal are the worker's (visibility timeout, heartbeat, `schedule`). Whole numbers ≥ 1, `rate.limit` and `concurrency` ≤ 1,000, one set of numbers per name: `X_JOB_DECLARATION_INVALID`. No lease store: `X_JOB_CONCURRENCY_UNENFORCEABLE` at worker start. `.describe().limiter` is `{ name, rate, concurrency }`. Pinned by `limiter.live.test.ts` (two replicas, one Postgres) |
259
- | per-process rate | starts per window, per tenant, in ONE worker | `concurrencyLimiter({ ratePerTenant })` on the worker — **per process**, multiplied by the replica count; a fleet budget is `limiter` above. A start is a body that ran: a claim handed back over `job.concurrency`, or refused by its key, spends none |
259
+ | per-process rate | starts per window, per tenant, in ONE worker | `concurrencyLimiter({ ratePerTenant })` on the worker — **per process**, multiplied by the replica count and by each container's processes; a fleet budget is `limiter` above. A start is a body that ran: a claim handed back over `job.concurrency`, or refused by its key, spends none |
260
260
  | a budget keyed by **request data** (per customer, per API key) | one bucket per key every worker spends | `@ultimat3/http`'s limiter over the store the boot installs on every role, as the body's FIRST lines, ahead of the first `step.run`: `const vendor = rateLimiter({ config, store: installedRateLimitStore() }); assertRateLimitScope(config, vendor); await vendor.assert(key, bucket)`, with `config = resolveRateLimitConfig({ scope: 'shared', buckets: { vendor: toBucket('<job>', { limit, windowMs }) }, defaultBucket: 'vendor' })` at module scope. `assertRateLimitScope` refuses one process' memory under `'shared'` (`X_RATE_LIMIT_NOT_SHARED`). A refusal is `X_RATE_LIMITED`, deferred uncounted like `limiter`'s. Pinned by `rate-recipe.job.test.ts` |
261
- | `maxInFlight` | max simultaneous runs in **one worker process**, across every queue it serves — Sidekiq's `concurrency`. `jobs.maxInFlight` in `app.config.ts`, or `jobWorker({ maxInFlight })`; unset, no process cap | read before every claim, so a worker at the cap claims nothing; each run that ends frees one claim at once. The per-queue `jobs.concurrency` slots still bound each queue under it. A pass splits its room over the queues (`ceil(room / queues left)`), hands what an empty queue leaves to the next, and starts after the last queue served — no queue starves. `worker.stats().maxInFlight`, gauges `job_worker_in_flight` / `job_worker_capacity`. `0`, fractional, `NaN`, `Infinity`: `X_INVARIANT` / `X_CONFIG_INVALID` |
261
+ | `maxInFlight` | max simultaneous runs in **one worker container**, across every queue it serves — Sidekiq's `concurrency`; a container running N processes splits it across them (`As of 2026-11`). `jobs.maxInFlight` in `app.config.ts`, or `jobWorker({ maxInFlight })`; unset, no process cap | read before every claim, so a worker at the cap claims nothing; each run that ends frees one claim at once. The per-queue `jobs.concurrency` slots still bound each queue under it. A pass splits its room over the queues (`ceil(room / queues left)`), hands what an empty queue leaves to the next, and starts after the last queue served — no queue starves. `worker.stats().maxInFlight`, gauges `job_worker_in_flight` / `job_worker_capacity`. `0`, fractional, `NaN`, `Infinity`: `X_INVARIANT` / `X_CONFIG_INVALID` |
262
262
  | `maxPending` | back-pressure: an enqueue onto a queue already holding that many `ready` + `delayed` rows is `X_JOB_BACKLOG_FULL`, a 429 (`JobBacklogFullError`); an `enqueueMany` that would cross it is refused whole, nothing written. Omitted, no ceiling. `As of 2026-11-12` | one capped count before the write (`JobDriver.backlog`, `SQL_BACKLOG`), on the direct and the staged path, plus the rows the caller's own transaction already staged for the queue (a key staged twice counts once). An enqueue that adds no row — a dedupe, or a replace onto the key's live holder (`JobDriver.holds`, asked only once full) — is never refused. Soft, not a quota: concurrent producers can overshoot by their number, and committed rows the relay has not yet published are counted by nobody. A driver with no `backlog` refuses a job declaring it at enqueue (`X_INVARIANT`) |
263
263
  | `queue` | named pool; the `worker` role runs one pool per config (`WORKER_QUEUES=default,integrations`) | worker pool sizing, see [Deployment](Deployment) |
264
264
  | priority | **a separate queue**, never a field: `queue: 'urgent'` on the job, and workers whose `WORKER_QUEUES` lists it (with its own `jobs.concurrency` slots, or a pool of its own). Inside one queue the claim takes the earliest `runAt` first, and nothing reorders it. `As of 2026-11`: no `priority` column — it would widen the claim index of the hottest table for an order a second queue already gives, and isolates better (a flood of low-priority work cannot hold the slots) | the claim, per queue |
@@ -272,6 +272,25 @@ export const syncCrm = job({
272
272
 
273
273
  A job over a tenant, queue or global cap, or over a `'wait'` concurrency cap, is **deferred, never dropped** — it stays queued with a later `runAt`. `whenBusy: 'fail'` is the one declared exception. `'wait'` holds the cap and states no order: a later enqueue can start first.
274
274
 
275
+ ### CPU-bound handlers
276
+
277
+ **A synchronous section blocks every job in its process, and their lease renewals with it** `As of 2026-11`. `jobs.concurrency` slots are async slots on one JavaScript thread; while a handler computes, nothing else in that process runs — no I/O completes, no claim, no renewal (the heartbeat fires every `visibilityTimeoutMs / 3`, 10 s by default), and the `/healthz` on the same thread answers late.
278
+
279
+ | Synchronous for | What happens |
280
+ |---|---|
281
+ | under 10 s | every other job in the process stalls for that long |
282
+ | 10–30 s | renewals for **every** in-flight job of the process arrive late; the loop's heartbeat can turn `/healthz` 503 |
283
+ | 30 s or more | `visible_at` passes: another worker claims the row and **the job runs twice**. When the first process yields it sees the lease lost, aborts `ctx.signal` and refuses further step writes — but side effects outside steps already happened, and every other job of that process lapsed too |
284
+
285
+ Processes contain it: a container with `cpus: '2'` runs two worker processes ([Processes per container](Deployment#processes-per-container)), each with its share of the container's `jobs.concurrency`, and a burn in one leaves the other's jobs and renewals running. Pinned by `runtime-jobs-processes.live.test.ts` (Linux, a real Postgres): two jobs burning 1.5 s of CPU each run at the same time, one per process, where one process runs them back to back (5.4 s of wall time for the pair, on a loaded box); and an I/O job on the other process renews its lease at least three times during a burn, none lost.
286
+
287
+ | For CPU-heavy work | Do |
288
+ |---|---|
289
+ | a queue of its own | `queue: 'heavy'` on the job, a worker service with `WORKER_QUEUES=heavy` and its own `cpus:` |
290
+ | slots per container | `jobs.concurrency: { heavy: <processes> }`: one slot per process, so a burn stalls only itself |
291
+ | chunks | break the section into chunks and `await lease.renew()` between them ([Observability](#observability)), or `step.run` per chunk |
292
+ | a longer lease | raise `visibilityTimeoutMs` above the longest synchronous section, knowing a crashed worker's jobs wait that long to be re-run |
293
+
275
294
  ### A lock — `withLock()`
276
295
 
277
296
  `withLock(key, fn, { ttl, wait?, poll?, store?, signal? })`: one holder fleet-wide, held as one slot `lock:<key>` in the job driver's `LeaseStore` (`x_job_leases` on Postgres) — no table of its own, no Redis. `fn` receives `{ key, token, signal }`. `As of 2026-11-09`.
@@ -478,6 +497,7 @@ export const syncAccount = job({
478
497
  | at most one notification per queue per 250 ms | Postgres serialises every notifying commit behind one lock. A row its slot kept silent is found by the woken worker's next pass, one `pollIntervalMs` later — never worse than a fixed 250 ms poll |
479
498
  | the poll is the guarantee | a notification is lost with the session that would have carried it; the driver re-dials and the poll covers the gap. With the wake proven the poll is a rest of up to 60 s, cut to the 2 s poll within one 2 s slice once the session is lost |
480
499
  | the wake has to be proven | a probe sent through the pool must come back on the session: `jobs.wake.live`. If it does not — PgBouncer in `pool_mode = transaction` delivers no notification — the log says `jobs.wake.unverified` once and the ceiling stays 2 s. Give the `worker` role a direct or session-pooled `DATABASE_URL` ([`docs/ops/04-datastores.md`](https://github.com/developerz-ai/ultimate/blob/main/docs/ops/04-datastores.md#pooling-and-the-trap-under-it)) |
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` |
481
501
  | a queue pause | read by the claim statement itself, so it holds from each worker's next claim; a resume announces the queue |
482
502
 
483
503
  ## Exports and imports — `exportRows()` and `importRows()`
@@ -882,14 +902,14 @@ Three implementations ship, `As of 2026-11-18`: `postgresJobDriver()`, `redisJob
882
902
  | Driver | Status `As of 2026-11-18` | When | Trade-off |
883
903
  |---|---|---|---|
884
904
  | `postgres` (default) | **shipped** | always, up to ~thousands of jobs/sec. `x dev` runs it too, against the embedded PGlite | outbox is free (same DB, same tx); `SELECT ... FOR UPDATE SKIP LOCKED` claiming; zero extra infra |
885
- | `redis` | **shipped** | a queue off the database, `jobs: redisJobDriver()` | one Lua script per operation; no `introspect`, `backfills` or `leases`, so a job declaring `concurrency` refuses `jobWorker().start()` (`X_JOB_CONCURRENCY_UNENFORCEABLE`); the outbox still stages in Postgres |
905
+ | `redis` | **shipped** | a queue off the database, `jobs: redisJobDriver()` | one Lua script per operation; no `introspect`, `backfills` or `leases`, so a job declaring `concurrency` refuses `jobWorker().start()` (`X_JOB_CONCURRENCY_UNENFORCEABLE`); the outbox still stages in Postgres. `As of 2026-11-19`: failed, dead and expired rows, their steps and debounce fences expire after `deadTtlMs` (default 90 days, pg's `jobs.deadRetentionMs`; `redisJobDriver({ deadTtlMs: 0 })` keeps them forever), and with no `clock` injected every lease, retry, settle debt and gauge is measured on the Redis server's clock (`TIME`), as pg's `now()` — skewed pods can no longer both hold one job |
886
906
  | `memory` | **shipped**; there is no config value for any driver | tests and fixtures, through `memoryJobDriver()` | in-process; nothing survives a restart — which is why it was never a safe drain target |
887
907
 
888
908
  **There is no `jobs.driver`, and 5.0.0 is where it went.** It accepted `'postgres' | 'redis' | 'nats'` and had **no reader anywhere** — boot always built `postgresJobDriver`, stated in [`packages/jobs/src/driver.ts`](https://github.com/developerz-ai/ultimate/blob/main/packages/jobs/src/driver.ts)'s own header. So setting it to `redis` changed nothing at all and you silently got Postgres, which is the more dangerous behaviour because nothing reports it. From 5.0.0 to 24.x a stale key still rode through untyped; **25.0.0 refuses it** at `defineConfig`, naming the driver seam. Deleting it from `app.config.ts` is the whole of the upgrade.
889
909
 
890
910
  **The seam that does work is `jobs:` in `export const runtime = { … }`** (`apps/<app>/runtime.ts`; 31.0.0 deleted `setJobDriver`) — swap the driver, zero job-code change, which is what the interface buys; a test swaps one for itself with `await swapAdapter('jobs', driver)` from `@ultimat3/testing`. Every swappable backend works this way: [Adapters](Adapters). `redisJobDriver()` is the second durable driver (`As of 2026-10`, #710): `jobs: redisJobDriver()` on core's `redisClient()` — while Redis is down an `enqueue` is `X_DRIVER_UNAVAILABLE` at once, never a wait — imported from `@ultimat3/jobs/redis`, held to the same conformance suite as Postgres, without the operator surface (`x jobs show`, `retry`, `cancel`), backfill bookkeeping or fleet-wide `concurrency` — [`packages/jobs/README.md`](https://github.com/developerz-ai/ultimate/blob/main/packages/jobs/README.md#drivers) has the table. There is no NATS jobs driver.
891
911
 
892
- **`x jobs` has no `drain`, `As of 2026-11-15`.** It was planned from 25.0.0 and left the registry ([Known gaps](Known-Gaps#open-by-decision)): moving in-flight rows between drivers is a migration no command owns. To stop a queue for maintenance, `x jobs pause <queue>`, then `x jobs list --queue <queue> --state running --json` until it is empty. Its two former `--to` values, `redis` and `nats`, were all-throw stubs — until 2026-10 a drain leased the whole pending batch for five minutes, failed every enqueue and nacked it back, nothing moved, and no worker could claim those jobs meanwhile. 25.0.0 deleted the stubs and the unreachable drain body. A drain that returns is new code, and owes the lesson of `--to memory`, a target until 2026-09: `memoryJobDriver()` is a `Map` inside the command's own process, so the drain enqueued each job into it, acked the durable row off the source, printed `ok: true`, and lost every copy when the command exited.
912
+ **`x jobs` has no `drain`, `As of 2026-11-15`.** It was planned from 25.0.0 and left the registry ([Known gaps](Known-Gaps#open-by-decision)): moving in-flight rows between drivers is a migration no command owns. To stop a queue for maintenance, `x jobs pause <queue>` (a queue the app does not serve is refused `X_CLI_BAD_FLAG` with the nearest name, `As of 2026-11-19` — before, a typo paused nothing and reported success), then `x jobs list --queue <queue> --state running --json` until it is empty. Its two former `--to` values, `redis` and `nats`, were all-throw stubs — until 2026-10 a drain leased the whole pending batch for five minutes, failed every enqueue and nacked it back, nothing moved, and no worker could claim those jobs meanwhile. 25.0.0 deleted the stubs and the unreachable drain body. A drain that returns is new code, and owes the lesson of `--to memory`, a target until 2026-09: `memoryJobDriver()` is a `Map` inside the command's own process, so the drain enqueued each job into it, acked the durable row off the source, printed `ok: true`, and lost every copy when the command exited.
893
913
 
894
914
  So the framework ships no cross-driver migration procedure: moving queued jobs from one driver to another is the application's to do.
895
915
 
@@ -46,7 +46,7 @@ Each of these is a defect, or a target, somebody has already argued about, and t
46
46
  |---|---|
47
47
  | `x token`'s `grant` | removed from the registry `As of 2026-11-15`, where it was planned and exited `X_NOT_IMPLEMENTED`; now `X_CLI_UNKNOWN_COMMAND`, exit 1 as before. A key's scopes are fixed when it is issued (`AuthApiKeyRecord.scopes`, never widened; `ApiKeyStore` has no update), so a grant is a new key: `x token create --scopes post:read,post:write --json`, then `x token revoke <old-id>`. A second verb for that pair would be the second path axiom 1 refuses |
48
48
  | `x db`'s `studio` | removed from the registry `As of 2026-11-15`, where it was planned and exited `X_NOT_IMPLEMENTED`; now `X_CLI_UNKNOWN_COMMAND`, exit 1 as before. The schema browser is the `/_x` db panel (`x dev`): schema, rows and a guarded SQL console. `X_DB_STUDIO_FAILED` stays reserved and unthrown; the old `bunx drizzle-kit studio` shell-out was a second schema engine for one subcommand |
49
- | `x jobs`'s `drain` | removed from the registry `As of 2026-11-15`, where it was planned and exited `X_NOT_IMPLEMENTED`; now `X_CLI_UNKNOWN_COMMAND`, exit 1 as before. 25.0.0 deleted the drain body with the all-throw Redis and NATS stubs, and moving in-flight rows between drivers is a migration no command owns. To stop a queue for maintenance: `x jobs pause <queue>`, then `x jobs list --queue <queue> --state running --json` until it is empty |
49
+ | `x jobs`'s `drain` | removed from the registry `As of 2026-11-15`, where it was planned and exited `X_NOT_IMPLEMENTED`; now `X_CLI_UNKNOWN_COMMAND`, exit 1 as before. 25.0.0 deleted the drain body with the all-throw Redis and NATS stubs, and moving in-flight rows between drivers is a migration no command owns. To stop a queue for maintenance: `x jobs pause <queue>` (a queue the app does not serve is refused, `As of 2026-11-19`), then `x jobs list --queue <queue> --state running --json` until it is empty |
50
50
  | A local write that died after its last rename is listed with no content type until the key is written again | `As of 2026-10`. `localDriver` commits in four steps (marker, sidecar, bytes, clear marker) and a marker left behind means "re-check this pair". `get()` and `stat()` do re-check against the bytes and answer correctly; `list()` never reads bytes, so it reports that object with no `contentType` and `etag: ''` — honest, and it stays that way until the next `put()` of that key. `stream()` returns bytes only and checks nothing. Two files cannot be committed in one step without changing the on-disk layout |
51
51
  | A `delete_resource` preview checks only the policy's actor half | `As of 2026-10-18`. Without `live: true` the framework answers a preview without running the action, so the part of a policy that reads the input never runs; a preview can be granted for a call the commit then refuses. Running the policy would mean running the action. An action that needs an exact preview declares `live` in its input and answers its own |
52
52
  | `localDriver` cannot hold a key and a key beneath it (`a` and `a/b`) | `As of 2026-10`. An object is a file at its key, and a POSIX path is a file or a directory. The second `put()` is refused by code (`X_STORAGE_KEY_CONFLICT`) where it used to be a bare `ENOTDIR`; `s3Driver` and `memoryStorageDriver` hold both. Storing objects under suffixed names would lift it, at the price of a layout migration for every existing root — and the keys `grantUpload` and `scopedKey` build never nest an object under another, so the limit is met only by hand-built keys |
@@ -83,7 +83,7 @@ Each of these is a defect, or a target, somebody has already argued about, and t
83
83
  | 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. **Why it stays** (`As of 2026-11-18`): An action's `input` is one static schema shared by the form, the MCP tool and the audit entry, so it has no per-row list of choices to offer. **Do instead:** copy the step name from the run's `steps` section on the same page. |
84
84
  | 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. **Why it stays** (`As of 2026-11-18`): An agent names every row it changes, so the per-row gate and the `<entity>:<n> rows` confirmation state a set it chose. "All matching" stays a control a person reads the list beside. **Do instead:** list the rows with `admin.<entity>.list` and its `where`, then pass their ids. |
85
85
  | 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. **Why it stays** (`As of 2026-11-18`): A per-tenant count per tab is one more read per state on every page view, over a column with no leading index (the org-scoped runs-list row). **Do instead:** a platform operator reads the overview tiles; an org-scoped operator reads a tab's own page. |
86
- | `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) **Why it stays** (`As of 2026-11-18`): A drill runs where a CI runner or one machine can hold the whole fleet. A real standby, bucket or CDN is a staging environment, which is the app's. **Do instead:** 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) |
86
+ | `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` (one `sync` for `nats-down`, and one of every role for `roll-before-migrate`) 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) **Why it stays** (`As of 2026-11-18`): A drill runs where a CI runner or one machine can hold the whole fleet. A real standby, bucket or CDN is a staging environment, which is the app's. **Do instead:** 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) |
87
87
  | `x cache`'s `stats` | removed from the registry `As of 2026-11-15`, where it was planned and exited `X_NOT_IMPLEMENTED`; now `X_CLI_UNKNOWN_COMMAND`, exit 1 as before. A hit rate is `cache.hit`/`cache.miss` on each serving process's instrumentation bus (`packages/cache/src/tiers.ts`), and no process aggregates them: the `/_x` cache panel shows the tag graph and the invalidation log, not hits. The route is a counter on each role's `/metrics`, read by whatever scrapes it; a CLI process has served nothing to count |
88
88
  | `x status` for sync, scheduler and replicator | `As of 2026-11-15`, `x status` reads every live worker's build from `x_job_workers` and samples each `--url` origin's `/readyz` for `x-ultimate-build`. No fleet-wide record exists for the other roles: a sync node keeps its connected clients' builds in its own memory (the `/_x` live panel in `x dev`), and the scheduler and replicator write no row. Each answers `/readyz` on its health port, so `x status --url http://<pod>:9091` reads one pod; the build-ID distribution of connected clients needs an aggregate the realtime package does not keep (`data.unrecorded` names these roles) |
89
89
  | `api/**/route.ts` | not a file kind — owner decision 1 ([#648](https://github.com/developerz-ai/ultimate/issues/648)), `As of 2026-10`. `api/` holds the action and query projections `defineApi()` collects; a route file there is refused at registration (`X_ROUTE_FILE_INVALID`), and 26.0.0 deleted `ROUTE_FILENAME`'s `api` row ([#709](https://github.com/developerz-ai/ultimate/issues/709)). A wire format an action cannot speak — a webhook receiver, an OAuth endpoint — is a plain HTTP route in the `routes` runtime override ([Configuration](Configuration)) |