@ultimat3/cli 30.8.0 → 31.0.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 (197) hide show
  1. package/CLAUDE.md +75 -64
  2. package/README.md +4 -1
  3. package/package.json +30 -29
  4. package/src/admin-registration.ts +1 -1
  5. package/src/affected.ts +5 -1
  6. package/src/app-boundaries.ts +88 -9
  7. package/src/app-load-async.ts +133 -0
  8. package/src/app-load-batch.ts +203 -0
  9. package/src/app-load-prebuilt.ts +147 -0
  10. package/src/app-load-register.ts +175 -0
  11. package/src/app-load.ts +143 -175
  12. package/src/app-loader-imports.ts +31 -0
  13. package/src/app-root.ts +13 -0
  14. package/src/app-runtime.ts +5 -1
  15. package/src/boundary-findings.ts +12 -0
  16. package/src/browser-launcher-port.ts +3 -7
  17. package/src/browser-launcher.ts +1 -1
  18. package/src/budgets-scan.ts +8 -0
  19. package/src/budgets.ts +10 -1
  20. package/src/build-registry-background.ts +59 -0
  21. package/src/build-registry.ts +207 -0
  22. package/src/cdp-shot-clock.ts +3 -11
  23. package/src/cdp-shot-driver.ts +3 -2
  24. package/src/cdp-shot-element.ts +3 -2
  25. package/src/cdp-shot-page.ts +2 -2
  26. package/src/cdp-shot-watch.ts +4 -3
  27. package/src/cmd-auth.ts +3 -3
  28. package/src/cmd-db-recount.ts +15 -0
  29. package/src/cmd-drill.ts +10 -6
  30. package/src/cmd-exercise.ts +2 -1
  31. package/src/cmd-generate-spec.ts +6 -0
  32. package/src/cmd-generate.ts +22 -4
  33. package/src/cmd-mail.ts +1 -1
  34. package/src/cmd-routes.ts +2 -2
  35. package/src/cmd-secrets-spec.ts +4 -1
  36. package/src/cmd-shot.ts +14 -4
  37. package/src/cmd-verify-spec.ts +21 -1
  38. package/src/cmd-verify.ts +16 -4
  39. package/src/coverage-source.ts +4 -1
  40. package/src/db-diagnostics.ts +8 -1
  41. package/src/dev-boot.ts +29 -15
  42. package/src/dev-dashboard-invalidations.ts +43 -0
  43. package/src/dev-dashboard.ts +13 -16
  44. package/src/dev-n-plus-one.ts +7 -3
  45. package/src/dev-rebuild.ts +2 -1
  46. package/src/dev-route-table.ts +1 -1
  47. package/src/dev-traces.ts +16 -15
  48. package/src/document-options.ts +12 -1
  49. package/src/drift-store.ts +55 -0
  50. package/src/error-catalog.ts +8 -3
  51. package/src/error-codes-boundary.ts +32 -0
  52. package/src/error-codes.ts +23 -19
  53. package/src/errors.ts +17 -7
  54. package/src/exercise-database.ts +13 -1
  55. package/src/exercise-findings.ts +36 -18
  56. package/src/exercise-services.ts +84 -0
  57. package/src/exercise-subject.ts +38 -13
  58. package/src/failure-capture-boot.ts +9 -5
  59. package/src/framework-schema.ts +5 -5
  60. package/src/generate-exercise.ts +1 -1
  61. package/src/generate-files.ts +27 -7
  62. package/src/generate-kinds.ts +5 -0
  63. package/src/generate-refresh.ts +53 -0
  64. package/src/generate-workspace.ts +169 -0
  65. package/src/generate-write.ts +8 -2
  66. package/src/hold.ts +19 -8
  67. package/src/image-prepare.ts +6 -2
  68. package/src/index.ts +5 -20
  69. package/src/island-bundle.ts +7 -3
  70. package/src/island-capture.ts +2 -2
  71. package/src/island-harness.ts +1 -1
  72. package/src/job-registration.ts +43 -6
  73. package/src/jobs-driver.ts +4 -5
  74. package/src/mcp-errors.ts +18 -4
  75. package/src/mcp-host.ts +5 -1
  76. package/src/mcp-ui-interact.ts +3 -0
  77. package/src/messages-gate.ts +4 -0
  78. package/src/new-shapes-generate.ts +1 -1
  79. package/src/otlp-export.ts +94 -29
  80. package/src/output.ts +3 -7
  81. package/src/page-sync.ts +3 -1
  82. package/src/role-load.ts +17 -11
  83. package/src/role-start.ts +5 -4
  84. package/src/role-sync.ts +7 -8
  85. package/src/route-islands-preload.ts +46 -0
  86. package/src/route-islands.ts +6 -2
  87. package/src/runtime-admin.ts +5 -1
  88. package/src/runtime-bindings.ts +25 -19
  89. package/src/runtime-boot-ports.ts +66 -0
  90. package/src/runtime-bus.ts +29 -5
  91. package/src/runtime-cache-bus.ts +53 -0
  92. package/src/runtime-cache.ts +43 -13
  93. package/src/runtime-isr-outcome.ts +5 -4
  94. package/src/runtime-jobs.ts +2 -2
  95. package/src/runtime-keys.ts +37 -0
  96. package/src/runtime-overrides.ts +148 -42
  97. package/src/runtime-port-bindings-queue.ts +36 -0
  98. package/src/runtime-port-bindings.ts +117 -0
  99. package/src/runtime-ports.ts +164 -0
  100. package/src/runtime-purge.ts +41 -28
  101. package/src/runtime-push.ts +7 -3
  102. package/src/runtime-queue.ts +70 -55
  103. package/src/runtime-realtime.ts +5 -5
  104. package/src/runtime-render-document.ts +4 -1
  105. package/src/runtime-services.ts +110 -158
  106. package/src/runtime-storage-boot.ts +111 -0
  107. package/src/runtime-storage-upload.ts +9 -7
  108. package/src/runtime-storage.ts +7 -1
  109. package/src/serve-boot.ts +8 -4
  110. package/src/serve-entry.ts +3 -0
  111. package/src/serve-env.ts +47 -14
  112. package/src/serve-prebuilt-paths.ts +3 -0
  113. package/src/serve-prebuilt.ts +15 -4
  114. package/src/serve.ts +2 -2
  115. package/src/static-cards.ts +3 -2
  116. package/src/static-report.ts +2 -2
  117. package/src/style-bundle.ts +1 -1
  118. package/src/sync-authenticator.ts +17 -18
  119. package/src/templates/action-tests.ts +4 -4
  120. package/src/templates/backfill.ts +5 -8
  121. package/src/templates/entity.ts +3 -0
  122. package/src/templates/github/ci.yml.ts +3 -1
  123. package/src/templates/github/dependabot.yml.ts +73 -0
  124. package/src/templates/job.ts +13 -22
  125. package/src/templates/naming.ts +20 -1
  126. package/src/templates/pinned/docker-compose.yml +1 -1
  127. package/src/templates/query.ts +7 -8
  128. package/src/templates/route.ts +5 -3
  129. package/src/templates/scaffold-api.ts +1 -1
  130. package/src/templates/scaffold-auth.ts +5 -3
  131. package/src/templates/scaffold-claude-commands.ts +6 -3
  132. package/src/templates/scaffold-claude.ts +4 -4
  133. package/src/templates/scaffold-container-compose.ts +2 -4
  134. package/src/templates/scaffold-domain-package.ts +1 -1
  135. package/src/templates/scaffold-entries.ts +6 -1
  136. package/src/templates/scaffold-helm-fences.ts +3 -2
  137. package/src/templates/scaffold-helm.ts +35 -6
  138. package/src/templates/scaffold-repo.ts +47 -135
  139. package/src/templates/scaffold-runtime-ports.ts +62 -0
  140. package/src/templates/scaffold-verify-floor.ts +97 -0
  141. package/src/templates/shapes/overlay.ts +1 -1
  142. package/src/templates/sign-in-oidc.ts +5 -3
  143. package/src/templates/sign-in-shared.ts +28 -10
  144. package/src/templates/workspace.ts +75 -0
  145. package/src/test-ignores.ts +5 -2
  146. package/src/test-select.ts +4 -1
  147. package/src/upgrade-gate.ts +30 -5
  148. package/src/upgrade-report.ts +7 -1
  149. package/src/verify-changed-facts.ts +53 -0
  150. package/src/verify-changed-scope.ts +161 -0
  151. package/src/verify-changed.ts +174 -0
  152. package/src/verify-checks.ts +31 -19
  153. package/src/verify-drift-owner.ts +30 -0
  154. package/src/verify-e2e.ts +2 -1
  155. package/src/verify-factories.ts +86 -0
  156. package/src/verify-run.ts +13 -11
  157. package/src/verify-step.ts +13 -0
  158. package/src/verify-tests.ts +58 -6
  159. package/src/write-line.ts +21 -6
  160. package/wiki/Actions.md +2 -2
  161. package/wiki/Adapters.md +400 -0
  162. package/wiki/Admin-Dashboard.md +2 -1
  163. package/wiki/Agents.md +9 -9
  164. package/wiki/Auth.md +78 -2
  165. package/wiki/Building-Your-Own-Base.md +1 -1
  166. package/wiki/CLI-Reference.md +34 -7
  167. package/wiki/Caching-And-Invalidation.md +17 -5
  168. package/wiki/Compared.md +8 -2
  169. package/wiki/Configuration.md +14 -14
  170. package/wiki/Deployment.md +28 -1
  171. package/wiki/Entities-And-Migrations.md +48 -2
  172. package/wiki/FAQ.md +8 -2
  173. package/wiki/Feature-Flags.md +1 -1
  174. package/wiki/Home.md +3 -2
  175. package/wiki/Jobs-And-Workflows.md +107 -6
  176. package/wiki/Known-Gaps.md +4 -3
  177. package/wiki/MCP-And-AI.md +18 -4
  178. package/wiki/Mail.md +14 -5
  179. package/wiki/Migrations-And-Backfills.md +31 -4
  180. package/wiki/Money.md +2 -0
  181. package/wiki/N-Plus-One-Detection.md +24 -22
  182. package/wiki/Notify.md +28 -4
  183. package/wiki/Observability.md +121 -15
  184. package/wiki/Queries-And-Live-Queries.md +2 -2
  185. package/wiki/Realtime.md +9 -4
  186. package/wiki/Routes-And-Render-Modes.md +5 -0
  187. package/wiki/Scraping.md +57 -11
  188. package/wiki/Shapes.md +2 -2
  189. package/wiki/Stability.md +7 -5
  190. package/wiki/Storage-And-Uploads.md +56 -4
  191. package/wiki/Testing.md +69 -56
  192. package/wiki/Troubleshooting.md +1 -1
  193. package/wiki/Tutorial-01-First-App.md +1 -1
  194. package/wiki/Tutorial-04-Jobs-And-Realtime.md +1 -1
  195. package/wiki/Tutorial-05-Deploy-Free.md +1 -1
  196. package/wiki/Tutorial-06-Growing-Up.md +8 -8
  197. package/wiki/Upgrading.md +129 -4
package/wiki/Actions.md CHANGED
@@ -30,7 +30,7 @@ Declared one per file in a feature's `actions/` (`actions/publish-post.ts`, what
30
30
  | `mcp.expose` | `boolean` | no (opt-in) | only a literal `true` makes the action a tool; silence exposes nothing. One predicate answers it everywhere — the tool, the LLM tool list, `describe().mcp.expose`, and `openapi.json`'s `x-ultimate.mcpTool` (which is `null` when there is no tool). Listing an un-exposed action in `defineAppMcp` is `X_MCP_TOOL_UNDECLARED` at boot |
31
31
  | `mcp.description` | `string` | no | the tool description an agent reads, and the OpenAPI `summary`. Contract text, so it stays outside `t()` — `openapi.json` must not depend on a locale. Write it for a stranger |
32
32
  | `mcp.visibleTo` | `readonly string[]` | no | roles that may see the projected tool; a caller whose role is not named gets ToolNotFound, never Forbidden — the policy still decides every call |
33
- | `rateLimit` | `{ limit: number \| (({ ctx }) => number \| Promise<number>); windowMs: number }` | no | `limit` may be resolved **per call** from `ctx` (the tenant's plan, read by the app), before any bucket is touched; a resolver answering `NaN`, `0`, `Infinity` or a non-number is `X_RATE_LIMIT_INVALID`, never allow-all. A per-call limit publishes as `rateLimit: null` + `rateLimitPerCall: { windowMs }` in `describe()` and `x-ultimate.rateLimit.limit: 'per-call'` in `openapi.json`. Spent **inside `invoke`**, so the HTTP route, the MCP tool, the in-app agent's tool call and `.job()` draw on ONE bucket — the third call to a `limit: 2` action is `X_RATE_LIMITED` whichever surface it came through; a direct in-process call spends nothing. Keyed actor → org → IP; counted in `@ultimat3/http`'s installed store (`installRateLimitStore()`, filled by the boot on every role with the same instance `httpServer({ rateLimitStore })` holds). Over HTTP the refusal is `429` + `Retry-After` and `RateLimit-*`, and the route is not also capped by the `default` bucket; the same `toBucket` conversion feeds `openapi.json`, so the published numbers are the enforced ones. `/mcp` additionally buckets by verb class (`MCP_RATE_LIMITS`, read 120/min, write 20/min per token) |
33
+ | `rateLimit` | `{ limit: number \| (({ ctx }) => number \| Promise<number>); windowMs: number }` | no | `limit` may be resolved **per call** from `ctx` (the tenant's plan, read by the app), before any bucket is touched; a resolver answering `NaN`, `0`, `Infinity` or a non-number is `X_RATE_LIMIT_INVALID`, never allow-all. A per-call limit publishes as `rateLimit: null` + `rateLimitPerCall: { windowMs }` in `describe()` and `x-ultimate.rateLimit.limit: 'per-call'` in `openapi.json`. Spent **inside `invoke`**, so the HTTP route, the MCP tool, the in-app agent's tool call and `.job()` draw on ONE bucket — the third call to a `limit: 2` action is `X_RATE_LIMITED` whichever surface it came through; a direct in-process call spends nothing. Keyed actor → org → IP; counted in `@ultimat3/http`'s installed store — the `rateLimitStore` adapter port, filled by the boot on every role, `postgresRateLimitStore` unless `apps/<app>/runtime.ts` names one ([Adapters](Adapters#ratelimitstore)). Over HTTP the refusal is `429` + `Retry-After` and `RateLimit-*`, and the route is not also capped by the `default` bucket; the same `toBucket` conversion feeds `openapi.json`, so the published numbers are the enforced ones. `/mcp` additionally buckets by verb class (`MCP_RATE_LIMITS`, read 120/min, write 20/min per token) |
34
34
  | `meter` | `{ name, period: 'hour' \| 'day' \| 'month', limit, warnAt?, onWarn? }` | no | a durable per-period allowance — see [Usage meters](#usage-meters-meter). Drawn on **every** surface, `server` included, after the policy and before `handle`; spent, `X_METER_EXCEEDED` (429) |
35
35
  | `idempotent` | `boolean` | no — **required `true` on a `mutator`** | marks the action safe to retry with an `Idempotency-Key` header — over MCP, the tool's optional `idempotencyKey` argument. Inside a transaction the Postgres store settles the record with the write's own `COMMIT`, so a rollback never leaves a `settled` record behind. A field core redacts by name (`apiKey`, `password`, `*Token`…) or a `Secret` is stored as `[redacted]`, and the replay of such an answer is `X_IDEMPOTENT_REPLAY_REDACTED` |
36
36
  | `http.path` | `string` | no | pins the URL whatever the app's `pathStyle` derives — for a path a caller already holds (`'/api/uploads/signed'`) or a resource-shaped one (`'/orders/:id/refund'`). Lowercase static segments and `:param`s, never `/_x`; each `:param` a REQUIRED `t.string` key of `input:`, else `X_ACTION_HTTP_PATH_INVALID` at registration. The URL's value joins the body before the input is parsed, so the schema, the policy, `row` and the handler read one object; a body naming the key with another value is **400** `X_HTTP_PATH_INPUT_CONFLICT`, never overridden. Under a bearer mount the pin is served at the prefix (`/v1/orders/:id/refund`) — and still at its own path, with the cookie session, as every pin is; the policy decides both. `derivePath(name)` refuses a template; `actionHttpPath(name, { id })` fills it. A `deprecated.replacedBy` naming one is `X_ACTION_DEPRECATION_INVALID`. An inbound webhook is not this door: it is `webhookReceiver()` ([Jobs and workflows](Jobs-And-Workflows#inbound-webhooks)) |
@@ -133,7 +133,7 @@ Every projection this package owns is a method on the action — `publishPost.op
133
133
 
134
134
  `handle` and `row` — the declaration's two functions — are unreachable by design: neither lifted nor described. The declaration lives in a private store inside `invoke.ts` and `@ultimat3/action` exports no reader for it, so `invoke` is the only thing that can run them — one execution path and one authz path, structurally rather than by convention. A hand-rolled object with `kind: 'action'` is `X_ACTION_FOREIGN`, never a registered action.
135
135
 
136
- Every projection needs the name `registerActions()` stamps on. It names the export in place, so `import { publishPost }` is the action that projects once the app has booted — there is no second, differently-named twin to remember.
136
+ Every projection needs the name `defineApi({ actions })` stamps on at boot. It names the export in place, so `import { publishPost }` is the action that projects once the app has booted — there is no second, differently-named twin to remember.
137
137
 
138
138
  ## Six generated artifacts
139
139
 
@@ -0,0 +1,400 @@
1
+ # Adapters
2
+
3
+ <!-- generated: bun run scripts/adapter-ports.ts --write — from ADAPTER_PORTS in packages/core/src/registrar.ts; the boundaries step refuses an edit by hand (X_ADAPTER_PORT_INCOMPLETE) -->
4
+
5
+ Every backend an app may swap is an **adapter port**: one row of `ADAPTER_PORTS` (`packages/core/src/registrar.ts`), one field of `apps/web/runtime.ts`. That file is the ONE place a backend is swapped — no setter on a package barrel, no env switch beside the default, no plugin API. Leave a field out and the boot builds the default the row names from the environment.
6
+
7
+ Writing your own adapter is four steps, the same for every port:
8
+
9
+ 1. **Implement** the interface, imported from the owning package's `/adapter` subpath.
10
+ 2. **Copy** the in-repo reference below — the memory one, where one ships.
11
+ 3. **Prove** it: `behavesLike(<suite>, () => subject)` in a test, the suite from `@ultimat3/testing/conformance`, `behavesLike` from `@ultimat3/testing`. The subject is your adapter, or — where a check needs more than the port to observe it — the suite's own `<X>Subject` object around it; each section below names its fields.
12
+ 4. **Wire** it: one field of `apps/web/runtime.ts`, which `x dev` and the container both read before a port is bound.
13
+
14
+ ```ts
15
+ import type { RuntimeOverrides } from '@ultimat3/cli/serve';
16
+ import { memoryJobDriver } from '@ultimat3/jobs';
17
+
18
+ export const runtime = {
19
+ jobs: memoryJobDriver(),
20
+ } satisfies RuntimeOverrides;
21
+ ```
22
+
23
+ `runtime.ts` runs BEFORE its own ports are installed: import no app module that seals a secret or builds auth at module scope. In a test, `await swapAdapter(port, impl)` from `@ultimat3/testing` installs one for that test alone, through the same installer the boot calls; a port it cannot swap is listed in its `UNSWAPPED` with what a test does instead.
24
+
25
+ `bun run scripts/adapter-ports.ts --json` lists every port with its five parts; a part missing is `X_ADAPTER_PORT_INCOMPLETE` on the `boundaries` step. A part marked *pending* below is on that guard's ratchet (`scripts/lib/adapter-port-pins.ts`) and is being built.
26
+
27
+ | Port | Interface | Package |
28
+ |---|---|---|
29
+ | [`aiGateway`](#aigateway) | `Gateway` | `@ultimat3/ai` |
30
+ | [`auditSink`](#auditsink) | `AuditSink` | `@ultimat3/core` |
31
+ | [`authLimiter`](#authlimiter) | `AuthLimiterFactory` | `@ultimat3/auth` |
32
+ | [`authServerStore`](#authserverstore) | `AuthServerStore` | `@ultimat3/auth` |
33
+ | [`cacheTiers`](#cachetiers) | `CacheTier` | `@ultimat3/cache` |
34
+ | [`clock`](#clock) | `SleepClock` | `@ultimat3/core` |
35
+ | [`embedder`](#embedder) | `Embedder` | `@ultimat3/ai` |
36
+ | [`errorReporter`](#errorreporter) | `ErrorReporter` | `@ultimat3/core` |
37
+ | [`eventBus`](#eventbus) | `EventBus` | `@ultimat3/jobs` |
38
+ | [`failureStore`](#failurestore) | `FailureStore` | `@ultimat3/core` |
39
+ | [`idempotencyStore`](#idempotencystore) | `IdempotencyStore` | `@ultimat3/action` |
40
+ | [`images`](#images) | `ImageTransformDriver` | `@ultimat3/seo` |
41
+ | [`isrStore`](#isrstore) | `IsrStore` | `@ultimat3/render` |
42
+ | [`jobs`](#jobs) | `JobDriver` | `@ultimat3/jobs` |
43
+ | [`mail`](#mail) | `MailDriver` | `@ultimat3/mail` |
44
+ | [`mcpConfirmationStore`](#mcpconfirmationstore) | `McpConfirmationStore` | `@ultimat3/mcp` |
45
+ | [`meterStore`](#meterstore) | `MeterStore` | `@ultimat3/action` |
46
+ | [`notifyStores`](#notifystores) | `NotifyStores` | `@ultimat3/notify` |
47
+ | [`outboxStore`](#outboxstore) | `OutboxStore` | `@ultimat3/jobs` |
48
+ | [`purge`](#purge) | `PurgeDriver` | `@ultimat3/cache` |
49
+ | [`pushSubscriptionStore`](#pushsubscriptionstore) | `PushSubscriptionStore` | `@ultimat3/pwa` |
50
+ | [`rateLimitStore`](#ratelimitstore) | `RateLimitStore` | `@ultimat3/http` |
51
+ | [`scrapeDriver`](#scrapedriver) | `ScrapeDriver` | `@ultimat3/scraping` |
52
+ | [`searchIndex`](#searchindex) | `SearchIndex` | `@ultimat3/entity` |
53
+ | [`secretSource`](#secretsource) | `SecretSource` | `@ultimat3/core` |
54
+ | [`semanticCache`](#semanticcache) | `SemanticCacheFactory` | `@ultimat3/ai` |
55
+ | [`smsTransport`](#smstransport) | `SmsTransport` | `@ultimat3/notify` |
56
+ | [`storage`](#storage) | `StorageDriver` | `@ultimat3/storage` |
57
+ | [`totpReplay`](#totpreplay) | `TotpReplayGuard` | `@ultimat3/auth` |
58
+ | [`transport`](#transport) | `Transport` | `@ultimat3/realtime` |
59
+ | [`uploadScanner`](#uploadscanner) | `UploadScanner` | `@ultimat3/storage` |
60
+
61
+ ## aiGateway
62
+
63
+ | Part | Value |
64
+ |---|---|
65
+ | Interface | `Gateway` from `@ultimat3/ai/adapter` |
66
+ | Default | none: the first model call is refused (X_AI_GATEWAY_MISSING) |
67
+ | Copy | [`providerGateway`](https://github.com/developerz-ai/ultimate/blob/main/packages/ai/src/gateway.ts) in `packages/ai/src/gateway.ts` — over `echoProvider()` (`packages/ai/src/echo-provider.ts`): a gateway that never leaves the process |
68
+ | Prove | `behavesLike(gatewayConformance, () => ({ gateway, model }))` |
69
+ | Wire | `aiGateway: …` in `apps/web/runtime.ts`, typed `Gateway` |
70
+ | Boot | installed by `installAiGateway` (services phase) |
71
+
72
+ ## auditSink
73
+
74
+ | Part | Value |
75
+ |---|---|
76
+ | Interface | `AuditSink` from `@ultimat3/core/adapter` |
77
+ | Default | none: an audit: true primitive is refused (X_AUDIT_SINK_MISSING) |
78
+ | Copy | [`memoryAuditSink`](https://github.com/developerz-ai/ultimate/blob/main/packages/action/src/audit-memory.ts) in `packages/action/src/audit-memory.ts` |
79
+ | Prove | `behavesLike(auditSinkConformance, () => ({ sink, kept, persists }))` |
80
+ | Wire | `auditSink: …` in `apps/web/runtime.ts`, typed `AuditSink` |
81
+ | Boot | installed by `installAuditSink` (services phase) |
82
+
83
+ ## authLimiter
84
+
85
+ | Part | Value |
86
+ |---|---|
87
+ | Interface | `AuthLimiterFactory` from `@ultimat3/auth/adapter` |
88
+ | Default | postgresAuthLimiter over DATABASE_URL |
89
+ | Copy | [`memoryAuthLimiter`](https://github.com/developerz-ai/ultimate/blob/main/packages/auth/src/rate-limit.ts) in `packages/auth/src/rate-limit.ts` — the port is the factory: `(policy) => memoryAuthLimiter(clock, policy)` |
90
+ | Prove | `behavesLike(authLimiterFactoryConformance, () => ({ factory, clock }))` |
91
+ | Wire | `authLimiter: …` in `apps/web/runtime.ts`, typed `AuthLimiterFactory` |
92
+ | Boot | installed by `installAuthLimiters` (services phase) |
93
+
94
+ ## authServerStore
95
+
96
+ | Part | Value |
97
+ |---|---|
98
+ | Interface | `AuthServerStore` from `@ultimat3/auth/adapter` |
99
+ | Default | postgresAuthServerStore over DATABASE_URL |
100
+ | Copy | [`memoryAuthServerStore`](https://github.com/developerz-ai/ultimate/blob/main/packages/auth/src/authorization-server-store.ts) in `packages/auth/src/authorization-server-store.ts` |
101
+ | Prove | `behavesLike(authServerStoreConformance, () => store)` |
102
+ | Wire | `authServerStore: …` in `apps/web/runtime.ts`, typed `AuthServerStore` |
103
+ | Boot | installed by `installAuthServerStore` (services phase) |
104
+
105
+ ## cacheTiers
106
+
107
+ | Part | Value |
108
+ |---|---|
109
+ | Interface | `CacheTier` from `@ultimat3/cache/adapter` |
110
+ | Default | the rungs cache.tiers names; 'redis' reads REDIS_URL |
111
+ | Copy | [`lruTier`](https://github.com/developerz-ai/ultimate/blob/main/packages/cache/src/lru.ts) in `packages/cache/src/lru.ts` |
112
+ | Prove | `behavesLike(cacheTierConformance, () => tier)` |
113
+ | Wire | `cacheTiers: …` in `apps/web/runtime.ts`, typed `readonly CacheTier[]` |
114
+ | Boot | read as a value by `runtime-cache.ts, each replacing the rung of its own name` |
115
+
116
+ ## clock
117
+
118
+ | Part | Value |
119
+ |---|---|
120
+ | Interface | `SleepClock` from `@ultimat3/core/adapter` |
121
+ | Default | systemClock |
122
+ | Copy | [`systemClock`](https://github.com/developerz-ai/ultimate/blob/main/packages/core/src/sleep-clock.ts) in `packages/core/src/sleep-clock.ts` — `noWaitClock` beside it is the one a test hands a run that must not wait |
123
+ | Prove | `behavesLike(sleepClockConformance, () => clock)` |
124
+ | Wire | `clock: …` in `apps/web/runtime.ts`, typed `SleepClock` |
125
+ | Boot | installed by `installClock` (boot phase) |
126
+
127
+ ## embedder
128
+
129
+ | Part | Value |
130
+ |---|---|
131
+ | Interface | `Embedder` from `@ultimat3/ai/adapter` |
132
+ | Default | hashEmbedder: deterministic, offline and lexical, never a network call |
133
+ | Copy | [`hashEmbedder`](https://github.com/developerz-ai/ultimate/blob/main/packages/ai/src/embeddings.ts) in `packages/ai/src/embeddings.ts` — a network embedder is `remoteEmbedder` (`packages/ai/src/remote-embedder.ts`) |
134
+ | Prove | `behavesLike(embedderConformance, () => embedder)` |
135
+ | Wire | `embedder: …` in `apps/web/runtime.ts`, typed `Embedder` |
136
+ | Boot | installed by `installAiEmbedder` (services phase) |
137
+
138
+ ## errorReporter
139
+
140
+ | Part | Value |
141
+ |---|---|
142
+ | Interface | `ErrorReporter` from `@ultimat3/core/adapter` |
143
+ | Default | SENTRY_DSN set: sentryErrorReporter; unset: the log line only |
144
+ | Copy | [`memoryErrorReporter`](https://github.com/developerz-ai/ultimate/blob/main/packages/core/src/error-reporter.ts) in `packages/core/src/error-reporter.ts` |
145
+ | Prove | `behavesLike(errorReporterConformance, () => reporter)` |
146
+ | Wire | `errorReporter: …` in `apps/web/runtime.ts`, typed `ErrorReporter` |
147
+ | Boot | installed by `installErrorReporter` (services phase) |
148
+
149
+ ## eventBus
150
+
151
+ | Part | Value |
152
+ |---|---|
153
+ | Interface | `EventBus` from `@ultimat3/jobs/adapter` |
154
+ | Default | postgresEventBus over DATABASE_URL |
155
+ | Copy | [`memoryEventBus`](https://github.com/developerz-ai/ultimate/blob/main/packages/jobs/src/events.ts) in `packages/jobs/src/events.ts` |
156
+ | Prove | `behavesLike(eventBusConformance, () => ({ bus, elapse }))` |
157
+ | Wire | `eventBus: …` in `apps/web/runtime.ts`, typed `EventBus` |
158
+ | Boot | installed by `installEventBus` (queue phase) |
159
+
160
+ ## failureStore
161
+
162
+ | Part | Value |
163
+ |---|---|
164
+ | Interface | `FailureStore` from `@ultimat3/core/adapter` |
165
+ | Default | postgresFailureStore over DATABASE_URL, while failureCapture is on |
166
+ | Copy | [`postgresFailureStore`](https://github.com/developerz-ai/ultimate/blob/main/packages/db/src/failure-store-pg.ts) in `packages/db/src/failure-store-pg.ts` — no memory store ships: the Postgres one is the reference |
167
+ | Prove | `behavesLike(failureStoreConformance, () => ({ store, find, client }))` |
168
+ | Wire | `failureStore: …` in `apps/web/runtime.ts`, typed `FailureStore` |
169
+ | Boot | read as a value by `failure-capture-boot.ts, while failureCapture is on` |
170
+
171
+ ## idempotencyStore
172
+
173
+ | Part | Value |
174
+ |---|---|
175
+ | Interface | `IdempotencyStore` from `@ultimat3/action/adapter` |
176
+ | Default | postgresIdempotencyStore over DATABASE_URL |
177
+ | Copy | [`memoryIdempotencyStore`](https://github.com/developerz-ai/ultimate/blob/main/packages/action/src/idempotency-memory.ts) in `packages/action/src/idempotency-memory.ts` |
178
+ | Prove | `behavesLike(idempotencyStoreConformance, () => ({ store, client, reclaimAfterMs, age, reset }))` |
179
+ | Wire | `idempotencyStore: …` in `apps/web/runtime.ts`, typed `IdempotencyStore` |
180
+ | Boot | installed by `installIdempotencyStore` (queue phase) |
181
+
182
+ ## images
183
+
184
+ | Part | Value |
185
+ |---|---|
186
+ | Interface | `ImageTransformDriver` from `@ultimat3/seo/adapter` |
187
+ | Default | builtinImageDriver |
188
+ | Copy | [`builtinImageDriver`](https://github.com/developerz-ai/ultimate/blob/main/packages/seo/src/image-driver.ts) in `packages/seo/src/image-driver.ts` |
189
+ | Prove | `behavesLike(imageTransformDriverConformance, () => driver)` |
190
+ | Wire | `images: …` in `apps/web/runtime.ts`, typed `ImageTransformDriver` |
191
+ | Boot | read as a value by `serve-web.ts, the /media/* transform` |
192
+
193
+ ## isrStore
194
+
195
+ | Part | Value |
196
+ |---|---|
197
+ | Interface | `IsrStore` from `@ultimat3/render/adapter` |
198
+ | Default | a memory store per process |
199
+ | Copy | [`memoryIsrStore`](https://github.com/developerz-ai/ultimate/blob/main/packages/render/src/render-isr-store.ts) in `packages/render/src/render-isr-store.ts` |
200
+ | Prove | `behavesLike(isrStoreConformance, () => store)` |
201
+ | Wire | `isrStore: …` in `apps/web/runtime.ts`, typed `IsrStore` |
202
+ | Boot | read as a value by `serve-web.ts, the ISR controller` |
203
+
204
+ ## jobs
205
+
206
+ | Part | Value |
207
+ |---|---|
208
+ | Interface | `JobDriver` from `@ultimat3/jobs/adapter` |
209
+ | Default | postgresJobDriver over DATABASE_URL |
210
+ | Copy | [`memoryJobDriver`](https://github.com/developerz-ai/ultimate/blob/main/packages/jobs/src/driver-memory.ts) in `packages/jobs/src/driver-memory.ts` |
211
+ | Prove | `behavesLike(jobDriverConformance, () => driver)` |
212
+ | Wire | `jobs: …` in `apps/web/runtime.ts`, typed `JobDriver` |
213
+ | Boot | installed by `installJobDriver` (queue phase) |
214
+
215
+ ## mail
216
+
217
+ | Part | Value |
218
+ |---|---|
219
+ | Interface | `MailDriver` from `@ultimat3/mail/adapter` |
220
+ | Default | SMTP_URL: smtp; RESEND_API_KEY: resend; SES_REGION: ses; none: memory in development/test, refused at the first send elsewhere |
221
+ | Copy | [`memoryMailDriver`](https://github.com/developerz-ai/ultimate/blob/main/packages/mail/src/driver.ts) in `packages/mail/src/driver.ts` |
222
+ | Prove | `behavesLike(mailDriverConformance, () => driver)` |
223
+ | Wire | `mail: …` in `apps/web/runtime.ts`, typed `MailDriver` |
224
+ | Boot | installed by `installMailDriver` (services phase) |
225
+
226
+ ## mcpConfirmationStore
227
+
228
+ | Part | Value |
229
+ |---|---|
230
+ | Interface | `McpConfirmationStore` from `@ultimat3/mcp/adapter` |
231
+ | Default | postgresConfirmationStore over DATABASE_URL |
232
+ | Copy | [`memoryConfirmationStore`](https://github.com/developerz-ai/ultimate/blob/main/packages/mcp/src/confirmation-store.ts) in `packages/mcp/src/confirmation-store.ts` |
233
+ | Prove | `behavesLike(mcpConfirmationStoreConformance, () => store)` |
234
+ | Wire | `mcpConfirmationStore: …` in `apps/web/runtime.ts`, typed `McpConfirmationStore` |
235
+ | Boot | installed by `installConfirmationStore` (services phase) |
236
+
237
+ ## meterStore
238
+
239
+ | Part | Value |
240
+ |---|---|
241
+ | Interface | `MeterStore` from `@ultimat3/action/adapter` |
242
+ | Default | postgresMeterStore over DATABASE_URL |
243
+ | Copy | [`memoryMeterStore`](https://github.com/developerz-ai/ultimate/blob/main/packages/action/src/meter-memory.ts) in `packages/action/src/meter-memory.ts` |
244
+ | Prove | `behavesLike(meterStoreConformance, () => store)` |
245
+ | Wire | `meterStore: …` in `apps/web/runtime.ts`, typed `MeterStore` |
246
+ | Boot | installed by `installMeterStore` (queue phase) |
247
+
248
+ ## notifyStores
249
+
250
+ | Part | Value |
251
+ |---|---|
252
+ | Interface | `NotifyStores` from `@ultimat3/notify/adapter` |
253
+ | Default | Postgres delivery ledger when the app has a database; memory in development/test; refused elsewhere (X_NOTIFY_STORE_MISSING); allow-all preferences, no inbox, no digest |
254
+ | Copy | [`memoryDeliveryLedger`](https://github.com/developerz-ai/ultimate/blob/main/packages/notify/src/ledger.ts) in `packages/notify/src/ledger.ts` — one member of four: `memoryPreferenceStore`, `memoryInboxStore` and `memoryDigestStore` are the others, one file each |
255
+ | Prove | `behavesLike(notifyStoresConformance, () => ({ ledger, inbox, preferences, digest }))` |
256
+ | Wire | `notifyStores: …` in `apps/web/runtime.ts`, typed `NotifyStores` |
257
+ | Boot | installed by `installNotifyStores` (services phase) |
258
+
259
+ ## outboxStore
260
+
261
+ | Part | Value |
262
+ |---|---|
263
+ | Interface | `OutboxStore` from `@ultimat3/jobs/adapter` |
264
+ | Default | postgresOutboxStore over DATABASE_URL |
265
+ | Copy | [`memoryOutboxStore`](https://github.com/developerz-ai/ultimate/blob/main/packages/jobs/src/outbox.ts) in `packages/jobs/src/outbox.ts` |
266
+ | Prove | `behavesLike(outboxStoreConformance, () => ({ relay, claimLeaseMs, transaction, elapse }))` |
267
+ | Wire | `outboxStore: …` in `apps/web/runtime.ts`, typed `OutboxStore` |
268
+ | Boot | read as a value by `runtime-queue.ts, behind the jobs facade with the jobs port` |
269
+
270
+ ## purge
271
+
272
+ | Part | Value |
273
+ |---|---|
274
+ | Interface | `PurgeDriver` from `@ultimat3/cache/adapter` |
275
+ | Default | CLOUDFLARE_API_TOKEN + CLOUDFLARE_ZONE_ID: cloudflare; FASTLY_API_TOKEN + FASTLY_SERVICE_ID: fastly; neither: none |
276
+ | Copy | [`noopPurgeDriver`](https://github.com/developerz-ai/ultimate/blob/main/packages/cache/src/cdn.ts) in `packages/cache/src/cdn.ts` |
277
+ | Prove | `behavesLike(purgeDriverConformance, () => ({ driver, refused }))` |
278
+ | Wire | `purge: …` in `apps/web/runtime.ts`, typed `PurgeDriver` |
279
+ | Boot | read as a value by `runtime-cache.ts, the cdn tier` |
280
+
281
+ ## pushSubscriptionStore
282
+
283
+ | Part | Value |
284
+ |---|---|
285
+ | Interface | `PushSubscriptionStore` from `@ultimat3/pwa/adapter` |
286
+ | Default | postgresPushSubscriptionStore over DATABASE_URL, while VAPID keys are set |
287
+ | Copy | [`memoryPushSubscriptionStore`](https://github.com/developerz-ai/ultimate/blob/main/packages/pwa/src/push-store.ts) in `packages/pwa/src/push-store.ts` |
288
+ | Prove | `behavesLike(pushSubscriptionStoreConformance, () => store)` |
289
+ | Wire | `pushSubscriptionStore: …` in `apps/web/runtime.ts`, typed `PushSubscriptionStore` |
290
+ | Boot | read as a value by `runtime-push.ts, while pwa.vapid is set` |
291
+
292
+ ## rateLimitStore
293
+
294
+ | Part | Value |
295
+ |---|---|
296
+ | Interface | `RateLimitStore` from `@ultimat3/http/adapter` |
297
+ | Default | postgresRateLimitStore over DATABASE_URL |
298
+ | Copy | [`memoryRateLimitStore`](https://github.com/developerz-ai/ultimate/blob/main/packages/http/src/rate-limit.ts) in `packages/http/src/rate-limit.ts` |
299
+ | Prove | `behavesLike(rateLimitStoreConformance, () => store)` |
300
+ | Wire | `rateLimitStore: …` in `apps/web/runtime.ts`, typed `RateLimitStore` |
301
+ | Boot | installed by `installRateLimitStore` (services phase) |
302
+
303
+ ## scrapeDriver
304
+
305
+ | Part | Value |
306
+ |---|---|
307
+ | Interface | `ScrapeDriver` from `@ultimat3/scraping/adapter` |
308
+ | Default | none: a scrape() declaring no driver is refused at its first run |
309
+ | Copy | [`fakeBrowser`](https://github.com/developerz-ai/ultimate/blob/main/packages/scraping/src/driver-fake.ts) in `packages/scraping/src/driver-fake.ts` |
310
+ | Prove | `behavesLike(scrapeDriverConformance, () => driver)` |
311
+ | Wire | `scrapeDriver: …` in `apps/web/runtime.ts`, typed `ScrapeDriver` |
312
+ | Boot | installed by `installScrapeDriver` (services phase) |
313
+
314
+ ## searchIndex
315
+
316
+ | Part | Value |
317
+ |---|---|
318
+ | Interface | `SearchIndex` from `@ultimat3/entity/adapter` |
319
+ | Default | postgresSearchIndex: .searchable()'s generated tsvector, over the app's pool |
320
+ | Copy | [`memorySearchIndex`](https://github.com/developerz-ai/ultimate/blob/main/packages/entity/src/search-index-memory.ts) in `packages/entity/src/search-index-memory.ts` — the built-in `postgresSearchIndex` (`search-index-postgres.ts`) reads `.searchable()`'s generated tsvector and writes nothing on `index` |
321
+ | Prove | `behavesLike(searchIndexConformance, () => ({ index, entity, store, drop }))` |
322
+ | Wire | `searchIndex: …` in `apps/web/runtime.ts`, typed `SearchIndex` |
323
+ | Boot | installed by `installSearchIndex` (services phase) |
324
+
325
+ ## secretSource
326
+
327
+ | Part | Value |
328
+ |---|---|
329
+ | Interface | `SecretSource` from `@ultimat3/core/adapter` |
330
+ | Default | ULTIMATE_SECRETS_KEY, then the .secrets.key file |
331
+ | Copy | [`envSecretSource`](https://github.com/developerz-ai/ultimate/blob/main/packages/core/src/secret-source.ts) in `packages/core/src/secret-source.ts` |
332
+ | Prove | `behavesLike(secretSourceConformance, () => ({ source, holding, empty }))` |
333
+ | Wire | `secretSource: …` in `apps/web/runtime.ts`, typed `SecretSource` |
334
+ | Boot | installed by `installSecretSource` (boot phase) |
335
+
336
+ ## semanticCache
337
+
338
+ | Part | Value |
339
+ |---|---|
340
+ | Interface | `SemanticCacheFactory` from `@ultimat3/ai/adapter` |
341
+ | Default | a memorySemanticCache per scope, per process |
342
+ | Copy | [`memorySemanticCache`](https://github.com/developerz-ai/ultimate/blob/main/packages/cache/src/semantic.ts) in `packages/cache/src/semantic.ts` — the port is the factory: `(scope) => memorySemanticCache()`, one cache per scope |
343
+ | Prove | `behavesLike(semanticCacheFactoryConformance, () => factory)` |
344
+ | Wire | `semanticCache: …` in `apps/web/runtime.ts`, typed `SemanticCacheFactory` |
345
+ | Boot | installed by `installSemanticCache` (services phase) |
346
+
347
+ ## smsTransport
348
+
349
+ | Part | Value |
350
+ |---|---|
351
+ | Interface | `SmsTransport` from `@ultimat3/notify/adapter` |
352
+ | Default | memory in development/test; refused at the first send elsewhere (X_NOTIFY_SMS_TRANSPORT_MISSING) |
353
+ | Copy | [`memorySmsTransport`](https://github.com/developerz-ai/ultimate/blob/main/packages/notify/src/sms-transport.ts) in `packages/notify/src/sms-transport.ts` |
354
+ | Prove | `behavesLike(smsTransportConformance, () => transport)` |
355
+ | Wire | `smsTransport: …` in `apps/web/runtime.ts`, typed `SmsTransport` |
356
+ | Boot | installed by `installSmsTransport` (services phase) |
357
+
358
+ ## storage
359
+
360
+ | Part | Value |
361
+ |---|---|
362
+ | Interface | `StorageDriver` from `@ultimat3/storage/adapter` |
363
+ | Default | S3_ENDPOINT set: s3; unset: the embedded disk |
364
+ | Copy | [`memoryStorageDriver`](https://github.com/developerz-ai/ultimate/blob/main/packages/storage/src/driver-memory.ts) in `packages/storage/src/driver-memory.ts` |
365
+ | Prove | `behavesLike(storageDriverConformance, () => driver)` |
366
+ | Wire | `storage: …` in `apps/web/runtime.ts`, typed `StorageDriver` |
367
+ | Boot | read as a value by `runtime-storage-boot.ts, the default disk` |
368
+
369
+ ## totpReplay
370
+
371
+ | Part | Value |
372
+ |---|---|
373
+ | Interface | `TotpReplayGuard` from `@ultimat3/auth/adapter` |
374
+ | Default | postgresTotpReplayGuard over DATABASE_URL |
375
+ | Copy | [`memoryTotpReplayGuard`](https://github.com/developerz-ai/ultimate/blob/main/packages/auth/src/mfa.ts) in `packages/auth/src/mfa.ts` |
376
+ | Prove | `behavesLike(totpReplayGuardConformance, () => guard)` |
377
+ | Wire | `totpReplay: …` in `apps/web/runtime.ts`, typed `TotpReplayGuard` |
378
+ | Boot | installed by `installTotpReplay` (services phase) |
379
+
380
+ ## transport
381
+
382
+ | Part | Value |
383
+ |---|---|
384
+ | Interface | `Transport` from `@ultimat3/realtime/adapter` |
385
+ | Default | NATS_URL set: nats; unset: memory (one node) |
386
+ | Copy | [`InProcessTransport`](https://github.com/developerz-ai/ultimate/blob/main/packages/realtime/src/fanout.ts) in `packages/realtime/src/fanout.ts` |
387
+ | Prove | `behavesLike(transportConformance, () => transport)` |
388
+ | Wire | `transport: …` in `apps/web/runtime.ts`, typed `Transport` |
389
+ | Boot | read as a value by `runtime-bus.ts, which installs the channel transport it dials` |
390
+
391
+ ## uploadScanner
392
+
393
+ | Part | Value |
394
+ |---|---|
395
+ | Interface | `UploadScanner` from `@ultimat3/storage/adapter` |
396
+ | Default | none: promoteAttachment scans nothing |
397
+ | Copy | [`memoryUploadScanner`](https://github.com/developerz-ai/ultimate/blob/main/packages/storage/src/upload-scanner-memory.ts) in `packages/storage/src/upload-scanner-memory.ts` |
398
+ | Prove | `behavesLike(uploadScannerConformance, () => scanner)` |
399
+ | Wire | `uploadScanner: …` in `apps/web/runtime.ts`, typed `UploadScanner` |
400
+ | Boot | installed by `installUploadScanner` (services phase) |
@@ -131,7 +131,7 @@ An edit form carries the row's version (`_version`); a row someone changed after
131
131
  | Redaction | a `sensitive` or sealed value is only ever `[redacted]`, in the diff and on screen |
132
132
  | Where it shows | the detail page's history card — `audit.entries({ entity, entityId, changes: true })`, keyset by `?history=`; `/admin/audit` (`audit:read`) for the whole trail, 100 per page, older pages by keyset. Both read only the actor's tenant's entries (`orgId`) when the actor has an org |
133
133
  | Searching the trail | `As of 2026-11`. `/admin/audit` is one native GET form: `?entity=` `?actor=` `?outcome=allowed\|denied\|failed` `?since=` `?until=` (ISO-8601 with an offset or `Z`, `YYYY-MM-DD` as that day's first UTC instant, or the form's `YYYY-MM-DDTHH:mm`, read as the UTC its label says; `until` exclusive). A store (`AuditQuery`) takes only the first two: a zoneless time is refused `?changes=1` `?before=<at>~<id>`. The older link carries the filters. Any other parameter — `?org=` included, the tenant is the actor's — or an unreadable value is a 400, `X_ADMIN_FILTER_INVALID`, never the unfiltered trail. `auditHref(path, request)` builds a link to a filtered trail. An entry links to its row when the resource is mounted and the actor may open it. No CSV: an `AdminCustomPage` with `exportRows()` composes one |
134
- | A copy elsewhere | `memoryAuditLog({ sinks })` / `postgresAuditLog({ sinks })` — each `AuditSink` gets a copy of every entry; a sink is write-only and never read back |
134
+ | A copy elsewhere | `memoryAuditLog({ sinks })` / `postgresAuditLog({ sinks })` — each `AuditSink` (`@ultimat3/core/adapter`'s, the one audit port since 31.0.0) gets a copy of every entry; a sink is write-only and never read back |
135
135
 
136
136
  ## Errors
137
137
 
@@ -283,6 +283,7 @@ export const mcp = adminMcp({
283
283
  | `include: 'exposed'` | every action and query with `mcp: { expose: true }`, projected as on `/mcp` (opt-in, the one predicate), each under its kind's admin scope: a query `admin:read`, an action `admin:write` |
284
284
  | `actor({ token, facts })` | `facts` is how the request arrived (address, `Origin`) — what a development token is decided on |
285
285
  | where it is built | `apps/<app>/mcp.ts`, never under `apps/admin/app/`: the scan evaluates the former after every primitive registered; one built earlier is `X_MCP_INCLUDE_EARLY` at the mount |
286
+ | a CRUD tool's arguments | one per form field, typed by the field; a `.nullable()` column's also takes `null` (`anyOf [type, null]`), a NOT NULL one does not. A `json()` / `arrayOf()` field is typed by the column's OWN schema — an array, an object, a scalar, `null` where the schema admits it — and untyped (`{}`) where the schema cannot be described; never a blanket `object`. `As of 2026-11` |
286
287
 
287
288
  ### Tool scopes
288
289
 
package/wiki/Agents.md CHANGED
@@ -9,8 +9,8 @@
9
9
  **The app names every model an agent runs on, and the provider that serves it.** `As of 2026-10`. The framework ships the mechanism — the `Provider` contract, two wire-format adapters as peers, the gateway, budgets, `registerModel` — and no vendor choice. Full reference: [`packages/ai/README.md`](https://github.com/developerz-ai/ultimate/blob/main/packages/ai/README.md).
10
10
 
11
11
  ```ts
12
- // app.config.ts, or any module the boot imports
13
- import { configureAi, providerGateway, openAiProvider, registerModel } from '@ultimat3/ai';
12
+ // apps/web/runtime.ts — the boot installs `aiGateway` (31.0.0; `configureAi` takes no gateway)
13
+ import { providerGateway, openAiProvider, registerModel } from '@ultimat3/ai';
14
14
 
15
15
  registerModel({
16
16
  id: 'house-large',
@@ -22,8 +22,8 @@ registerModel({
22
22
  reasoning: { effort: true, adaptive: false, disableThinkingUpTo: undefined },
23
23
  });
24
24
 
25
- configureAi({
26
- gateway: providerGateway({
25
+ export const runtime = {
26
+ aiGateway: providerGateway({
27
27
  providers: [
28
28
  openAiProvider({
29
29
  apiKey: Bun.env['LLM_TOKEN'] ?? '',
@@ -33,7 +33,7 @@ configureAi({
33
33
  ],
34
34
  defaultModel: 'house-large',
35
35
  }),
36
- });
36
+ };
37
37
  ```
38
38
 
39
39
  | Provider | Speaks |
@@ -138,7 +138,7 @@ export const supportAgent = agent({
138
138
  | `maxToolResultChars` | no | **4,000** | one tool result's ceiling; truncation says so in the transcript |
139
139
  | `maxRepeatedToolCalls` | no | **3** | consecutive turns that may repeat the same calls **and** results; reaching it is `X_AGENT_TOOL_LOOP` → [Unattended runs](#unattended-runs) |
140
140
  | `deadlineMs` | no | none | wall-clock ceiling for the whole run; passing it is `X_AGENT_DEADLINE` |
141
- | `temperature`, `seed` | no | not sent | determinism knobs for a verifier or a classifier (`temperature` 0 to 2, `seed` a whole number). **Sent only to a model whose row takes them** — `registerModel({ …, sampling: { temperature: true, seed: true } })`; to any other they are left out, because a reasoning model answers a sampling parameter with a 400, and the `llm.sampling.ignored` span attribute names what was left out. `seed` exists on the chat-completions wire only (the Messages API has none) and is best effort where it exists; `temperature: 0` narrows variation, it does not promise identical answers. Same two keys on `llm()` |
141
+ | `temperature`, `seed` | no | not sent | determinism knobs for a verifier or a classifier (`temperature` 0 to 2, `seed` a whole number). **Sent only to a model whose row takes them** — `registerModel({ …, sampling: { temperature: true, seed: true } })`; to any other they are left out, because a reasoning model answers a sampling parameter with a 400, and the `ultimate.llm.sampling.ignored` span attribute names what was left out. `seed` exists on the chat-completions wire only (the Messages API has none) and is best effort where it exists; `temperature: 0` narrows variation, it does not promise identical answers. Same two keys on `llm()` |
142
142
  | `system` | no | — | system text loaded at run time, as `{ stable?, run? }` → [Provider prompt caching](#provider-prompt-caching) |
143
143
  | `promptCache` | no | **`'auto'`** | `'auto'` \| `'off'` \| `{ session }` — asks the provider to cache each turn's prefix |
144
144
  | `compact` | no | **`'auto'`** | `'auto'` \| `'off'` \| `{ at, keepTurns, model, maxSummaryTokens }` — summarise older turns before a request that would outgrow the context window → [Auto-compaction](#auto-compaction-compact) |
@@ -432,7 +432,7 @@ chat-completions — is `X_AI_REQUEST_INVALID` when the provider is built.
432
432
  | `llm()` is **off** by default | `promptCache: 'auto'` on an `llm()` that is called many times with one long `system`. A one-shot call that marks its prefix pays the write premium for a cache nothing reads |
433
433
  | A direct `gateway.generate()` call | `system: { stable, run }` and `promptCache: {}` on the request — the same two fields the loop sets |
434
434
 
435
- **Reading it back.** `onTurn`'s `usage` carries `cacheReadTokens` and `cacheWriteTokens` per turn, `run` carries the running total (`run.usage`, `run.cost`), and the `agent.turn` span event carries `llm.cache.read_tokens` / `llm.cache.write_tokens`. A run whose later turns read nothing has an unstable prefix.
435
+ **Reading it back.** `onTurn`'s `usage` carries `cacheReadTokens` and `cacheWriteTokens` per turn, `run` carries the running total (`run.usage`, `run.cost`), and the `agent.turn` span event carries `ultimate.llm.cache.read_tokens` / `ultimate.llm.cache.write_tokens`. A run whose later turns read nothing has an unstable prefix.
436
436
 
437
437
  **What it costs.** `costOf` prices a read at the model row's `cacheReadPerMillion` (absent: 0.1x input) and a write at `cacheWritePerMillion` (absent: 1.25x input). A token budget (`tokensPerRun`, `tokensIn`, the gateway's actor and org ceilings) counts **every** token the provider processed — input, output, cache read and cache write, each as one — so caching lowers what a run costs, not how many tokens it is allowed. The pre-flight estimate prices the prompt as a cache write **only when a provider serving the model would actually mark the request** (an Anthropic model; not Gemini, OpenAI or an unknown host, whose estimate is what it was), and at the dearer of the write and input rates — so `costPerCall` holds on turn one.
438
438
 
@@ -877,7 +877,7 @@ describeAgents();
877
877
 
878
878
  An agent projects to an `ActionDescriptor` like every other action, and that descriptor knows nothing about turns or tools — so "how far can this loop, and what may it call" had no answer outside the source. `tools` is the agent's **blast radius**, sorted. `promptHash` is there because an agent's behaviour is its prompt: a row without one records which agent ran and not which agent it *was*. `modelFrom` says which place answered `model` — `declaration`, `prompt` or `gateway`, or `run` (with `model: null`) when `model` is a function each run asks; both are `null` when none names one yet (a call in that state is refused). `gateway` and `null` are as of the gateway installed when the row is read. Reading a row never throws.
879
879
 
880
- Names are read when you ask, not when the agent was declared: `registerAction` stamps them at boot, long after `agent()` ran at module scope. An agent nothing registered has **no row**, and that is not a silent drop — an action with no name reaches no route, no tool catalogue and no queue, so there is no capability for a row to describe. Register it: `registerAction('supportAgent', support)`.
880
+ Names are read when you ask, not when the agent was declared: `defineApi` stamps them at boot, long after `agent()` ran at module scope. An agent nothing registered has **no row**, and that is not a silent drop — an action with no name reaches no route, no tool catalogue and no queue, so there is no capability for a row to describe. Register it: list its module in `defineApi({ actions })` (`apps/<app>/api/index.ts`).
881
881
 
882
882
  ## No semantic cache
883
883
 
@@ -904,7 +904,7 @@ Similar prompts do not have similar answers once the answer depends on what `loo
904
904
  | `X_HIVE_EMPTY` | `split()` produced zero members | return at least one member input, or guard the call site |
905
905
  | `X_AI_BUDGET_EXCEEDED` | refused pre-flight, naming the scope and what remains | raise that scope's ceiling, or shorten the prompt |
906
906
  | `X_AI_PROMPT_SECRET` | `vars()` returned a `Secret` | drop the key from `vars()` and the template, or `revealSecret(value)` if the model genuinely has to read it |
907
- | `X_AI_GATEWAY_MISSING` | the agent ran before `configureAi`; the cause lists the peer providers | `configureAi({ gateway: providerGateway({ providers: [provider] }) })` at boot, with `provider` your choice — [above](#register-your-models-pick-your-provider) |
907
+ | `X_AI_GATEWAY_MISSING` | the agent ran with no gateway installed; the cause lists the peer providers | `apps/<app>/runtime.ts: export const runtime = { aiGateway: providerGateway({ providers: [provider] }) }` — in a test, `installAiGateway(gateway)` from `@ultimat3/ai/adapter`, with `provider` your choice — [above](#register-your-models-pick-your-provider) |
908
908
  | `X_ABORTED` | `ctx.signal` fired mid-run | pass a longer deadline, or run it as a job |
909
909
 
910
910
  Full list: [Error codes](Error-Codes).
package/wiki/Auth.md CHANGED
@@ -19,7 +19,7 @@ export const auth = defineAuth({
19
19
  });
20
20
 
21
21
  const { actor, token, cookie } = await login(auth, { email, password, ip });
22
- const { start, callback } = oauthLogin(auth); // /auth/oauth/:provider and its callback
22
+ const { start, callback } = oauthLogin(auth); // /auth/sso/:provider and its callback
23
23
  ```
24
24
 
25
25
  The tables (`x_users`, `x_sessions`, `x_accounts`, `x_verifications`, `x_api_keys`, and the
@@ -80,6 +80,82 @@ bound to its provider. An id token is verified against the provider's JWKS. An i
80
80
  | a public client (`As of 2026-10-18`) | `tokenEndpointAuth: 'none'` on the provider, `discoverOAuthProvider` or `credentials`: no `<PROVIDER>_CLIENT_SECRET` is read and no `client_secret` is sent; PKCE still is. `'client_secret_basic'` sends the pair in `Authorization: Basic`. Absent: `'client_secret_post'`, unchanged |
81
81
  | `apple` | not a built-in since 26.0.0 ([#709](https://github.com/developerz-ai/ultimate/issues/709)): Apple POSTs its callback and both callback routes are GET, so it could never complete a sign-in. An app that needs it registers its own with `registerOAuthProvider` |
82
82
 
83
+ ## SSO: OIDC and SAML behind one `IdentityProvider` port
84
+
85
+ Rule: every federated sign-in is an `IdentityProvider` (`@ultimat3/auth`), and `signInWithIdentity(auth, identity)` is the one path from it to a session — the same account-link, MFA and grant rules as [OAuth](#oauth). `As of 2026-11-09`.
86
+
87
+ | Member | Shape |
88
+ |---|---|
89
+ | `begin({ callbackUrl, clock })` | `{ location, state }` |
90
+ | `answers(state, params)` | whether `params` answer THIS browser's state — RelayState for SAML, `state` for OIDC — in constant time, nothing verified beyond it. The routes clear the state cookie only on an answer bound to it, so a junk cross-site form cannot end a sign-in in flight |
91
+ | `complete({ state, params, callbackUrl, clock, replay })` | `{ profile, expiresAt, claims }` |
92
+ | adapters | `samlIdentityProvider(config)`, `oidcIdentityProvider({ provider })` |
93
+ | your own | `behavesLike(identityProviderConformance, () => harness)` from `@ultimat3/testing/conformance` |
94
+
95
+ `identityProviderRoutes(auth, { providers })` mounts both kinds:
96
+
97
+ | Route | Method | Purpose |
98
+ |---|---|---|
99
+ | `/auth/sso/:provider` | GET | `begin`, seal the state in `__Host-x_sso_<id>`, 302 to the IdP |
100
+ | `/auth/sso/:provider/callback` | POST | the SAML ACS — register this URL at the IdP. The state cookie is `SameSite=None`: the IdP posts cross-site |
101
+ | `/auth/sso/:provider/callback` | GET | the OIDC `redirect_uri` |
102
+
103
+ ```ts
104
+ import type { Auth } from '@ultimat3/auth';
105
+ import {
106
+ identityProviderRoutes,
107
+ oidcIdentityProvider,
108
+ parseSamlMetadata,
109
+ samlIdentityProvider,
110
+ } from '@ultimat3/auth';
111
+
112
+ declare const auth: Auth;
113
+ declare const corpMetadataXml: string; // the IdP's metadata document, read at boot
114
+
115
+ export const sso = identityProviderRoutes(auth, {
116
+ providers: [
117
+ samlIdentityProvider({
118
+ id: 'corp',
119
+ idp: parseSamlMetadata(corpMetadataXml),
120
+ spEntityId: 'https://app.example/saml/metadata',
121
+ trustEmail: true,
122
+ emailDomains: ['corp.example'], // the exact domains this IdP owns
123
+ }),
124
+ oidcIdentityProvider({ provider: 'github' }),
125
+ ],
126
+ successPath: '/app',
127
+ });
128
+ ```
129
+
130
+ `defineAuth({ providers })` lists both ids; an unknown or not-enabled id is `X_IDENTITY_PROVIDER_UNKNOWN` (404).
131
+
132
+ **OIDC replay.** `oidcIdentityProvider` claims the handshake's `state` once in the shared replay store before it spends the code, keyed on when the handshake was issued: a callback lifted from a browser is `X_OAUTH_STATE_INVALID` even inside the cookie's lifetime, and so is any answer more than 10 minutes after `begin` (`DEFAULT_HANDSHAKE_TTL_MS`).
133
+
134
+ Mount each leg with its `meta` verbatim — `{ method: leg.method, path: leg.path, handler: (request) => leg.handle(request.raw), meta: leg.meta }`. The ACS (POST) declares `csrf: 'cookieless'` and `authenticate: () => null`: the IdP answers with an auto-submitted cross-site form, which the csrf stage refuses on any other route (`403 X_CSRF_BLOCKED`). CSRF is held there by the protocol instead — the answer must carry this browser's RelayState, checked against the HMAC-sealed state cookie, and its assertion must answer this request's ID.
135
+
136
+ **SAML scope.** SP-initiated only: an AuthnRequest over HTTP-Redirect with RelayState, the response over HTTP-POST. Signed assertions are required; encrypted assertions, SHA-1 and RSA under 2,048 bits are refused; `trustEmail` is required, because SAML has no `email_verified`, and `trustEmail: true` requires `emailDomains` — an IdP's admin can assert any address, so only an address in a listed domain (exact; list each subdomain) is verified, and one outside it can neither link to an existing account nor create one (`trustEmail: true` with no domains is a type error and `X_CONFIG_INVALID` at construction); clock skew is ±60 s (`skewMs`). `parseSamlMetadata(xml)` → `{ entityId, ssoUrl, certificates }`, refused as `X_SAML_METADATA_INVALID` with no HTTP-Redirect SSO, no signing certificate, or an RSA key under 2,048 bits. Verification is in-package, no dependency ([build vs wrap](https://github.com/developerz-ai/ultimate/blob/main/docs/idea/18-build-vs-wrap.md)). Every refusal is `X_SAML_RESPONSE_INVALID` with `meta.check`:
137
+
138
+ | Check | `meta.check` |
139
+ |---|---|
140
+ | a DOCTYPE, an entity, a processing instruction, over 512 KiB, more than 64 namespace declarations, one attribute twice | `xml` |
141
+ | more than one Assertion, one not a direct child, a `ds:Object` in a Signature | `structure` |
142
+ | one ID on two elements | `id-duplicate` |
143
+ | an EncryptedAssertion or EncryptedID | `encrypted` |
144
+ | the assertion unsigned (a signed response alone is refused) | `signature-missing` |
145
+ | not RSA-SHA256 / SHA-256 / exc-c14n + enveloped | `algorithm` |
146
+ | the Reference URI is not the assertion's own ID | `reference` |
147
+ | no metadata certificate verifies (KeyInfo is never read) | `signature` |
148
+ | content altered | `digest` |
149
+ | Status is not Success | `status` |
150
+ | Issuer is not the metadata's entityID | `issuer` |
151
+ | Destination / Recipient is not the ACS URL | `destination` / `recipient` |
152
+ | InResponseTo is not our AuthnRequest's ID | `in-response-to` |
153
+ | Audience is not `spEntityId` | `audience` |
154
+ | NotBefore / NotOnOrAfter | `not-before` / `expired` |
155
+ | a transient or empty NameID | `subject` |
156
+ | RelayState is not the browser's | `relay-state` |
157
+ | an assertion already consumed (`auth.totpReplay`, shared) | `replay` |
158
+
83
159
  ## Passkeys
84
160
 
85
161
  **WebAuthn, verified by hand on WebCrypto — no dependency** (`As of 2026-11`). Two uses, one
@@ -179,7 +255,7 @@ const resolveToken = oauthBearerResolver(oauth, { actor: (grant) => actorFor(gra
179
255
  |---|---|
180
256
  | redirect URIs match byte for byte | `authorization-server-request.test.ts` |
181
257
  | S256 only; an absent method is `plain` and refused | same |
182
- | a code lives 2 minutes, is stored hashed, is single use; a replay revokes what it minted | `authorization-server.test.ts`, `authorization-server-store.contract.test.ts` (racing redemptions on Postgres) |
258
+ | a code lives 2 minutes, is stored hashed, is single use; a replay revokes what it minted | `authorization-server.test.ts`, `authServerStoreConformance` from `@ultimat3/testing/conformance` (racing redemptions, run on memory and on Postgres by `auth-server-store-conformance-postgres.live.test.ts`) |
183
259
  | refresh rotates; a retired one's replay revokes the grant; idle past `refreshIdleDays` is dead | `authorization-server.test.ts` |
184
260
  | `resource` (RFC 8707) binds the grant; one not in `resources` is `invalid_target` | `authorization-server-request.test.ts`, `oauth-bearer-resolver.test.ts` |
185
261
  | tokens are opaque and stored hashed, never a JWT, so `revoke` holds on the next lookup | `token-endpoints.test.ts` |
@@ -113,7 +113,7 @@ the one evaluation. The same shape works over `action()`, `job()` and `query()`.
113
113
  |---|---|
114
114
  | the entity registry | `entity()` calls `registerEntity` itself, so registration happens whenever your factory calls it |
115
115
  | `isAction()` | structural — a function, `kind === 'action'`, a stashed declaration. It asks whether `action()` built the value, never where |
116
- | `registerActions(module)` | names the export **in place**, so `getAction('issueInvoice') === issueInvoice` by identity, not a copy |
116
+ | `defineApi({ actions })` | names each export **in place**, so `getAction('issueInvoice') === issueInvoice` by identity, not a copy |
117
117
  | `x verify` | no step matches source text for `action(` / `entity(` / `mutator(`. Every primitive fact reaches the gate by importing the module and reading the runtime registries. The only text scanning is for `X_*` codes |
118
118
  | manifest · admin CRUD · MCP · the five projections | all read those same registries |
119
119