@ultimat3/cli 31.49.0 → 31.50.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 (53) hide show
  1. package/package.json +30 -30
  2. package/src/api-registration.ts +18 -1
  3. package/src/api-routes.ts +1 -0
  4. package/src/app-load.ts +1 -2
  5. package/src/app-openapi.ts +7 -1
  6. package/src/budgets.ts +2 -1
  7. package/src/cmd-i18n.ts +33 -1
  8. package/src/codemods/engine-fs.ts +9 -2
  9. package/src/codemods/merge-drivers.ts +85 -4
  10. package/src/exercise-services.ts +13 -3
  11. package/src/framework-schema.ts +15 -5
  12. package/src/guard-sources.ts +1 -2
  13. package/src/messages-upgrade.ts +4 -0
  14. package/src/page-navigation.ts +5 -2
  15. package/src/pwa-artifacts.ts +1 -1
  16. package/src/retained-assets-boot.ts +1 -1
  17. package/src/runtime-assets-site.ts +2 -2
  18. package/src/runtime-assets.ts +1 -1
  19. package/src/runtime-render-document.ts +1 -2
  20. package/src/site-asset-routes.ts +2 -2
  21. package/src/site-assets.ts +5 -158
  22. package/src/sw-precache-plan.ts +1 -1
  23. package/src/templates/guard-raw-motion.ts +96 -0
  24. package/src/templates/guard-released-forms.ts +4 -1
  25. package/src/templates/scaffold-repo.ts +1 -1
  26. package/src/test-only-shipped.ts +29 -2
  27. package/src/test-shards.ts +20 -8
  28. package/src/upgrade-coverage-ratchet.ts +95 -0
  29. package/src/upgrade-gate.ts +31 -11
  30. package/src/upgrade-report.ts +14 -0
  31. package/src/verify-e2e.ts +21 -3
  32. package/src/workspace-checks.ts +4 -1
  33. package/wiki/Actions.md +64 -2
  34. package/wiki/Auth.md +6 -2
  35. package/wiki/CLI-Reference.md +8 -2
  36. package/wiki/Client-Navigation.md +34 -4
  37. package/wiki/Configuration.md +2 -1
  38. package/wiki/Entities-And-Migrations.md +12 -2
  39. package/wiki/Home.md +2 -2
  40. package/wiki/I18n.md +1 -1
  41. package/wiki/Interface-Rules.md +3 -1
  42. package/wiki/Known-Gaps.md +1 -1
  43. package/wiki/MCP-And-AI.md +41 -9
  44. package/wiki/Notify.md +4 -2
  45. package/wiki/Outbound-HTTP.md +53 -2
  46. package/wiki/Policies-And-Authz.md +1 -1
  47. package/wiki/Realtime.md +14 -6
  48. package/wiki/Routes-And-Render-Modes.md +1 -1
  49. package/wiki/Static-Assets.md +5 -3
  50. package/wiki/Testing.md +57 -3
  51. package/wiki/Theming.md +6 -3
  52. package/wiki/UI-Components.md +1 -0
  53. package/wiki/Upgrading.md +1 -0
@@ -108,12 +108,25 @@ None of them is exposed in `ROLE=web`. `db.query` accepts one statement, whose l
108
108
 
109
109
  | Request | Era | Answered |
110
110
  |---|---|---|
111
- | `params._meta["io.modelcontextprotocol/protocolVersion"]` in `MCP_MODERN_VERSIONS` (`2026-07-28`) | modern, stateless | `server/discover` and the seven shared methods. Every result carries `resultType: 'complete'` and `_meta["io.modelcontextprotocol/serverInfo"]`; the lists, `resources/read` and `server/discover` add `ttlMs: 0`, `cacheScope: 'private'`. No `initialize`, no `ping` |
111
+ | `params._meta["io.modelcontextprotocol/protocolVersion"]` in `MCP_MODERN_VERSIONS` (`2026-07-28`) | modern, stateless | `server/discover` and the seven shared methods. Every result carries `resultType: 'complete'` — or `'input_required'` for a `tools/call` answered with the URL prompt below, so branch on `resultType` before reading `content` — and `_meta["io.modelcontextprotocol/serverInfo"]`; the lists, `resources/read` and `server/discover` add `ttlMs: 0`, `cacheScope: 'private'`. No `initialize`, no `ping` |
112
112
  | no `_meta` version, or one in `MCP_LEGACY_VERSIONS` (`2025-11-25`, `2025-06-18`, `2025-03-26`) | legacy | `initialize` echoes an offered legacy revision, else answers `2025-11-25`; `ping`; the seven shared methods |
113
113
  | any other `_meta` version | — | `-32022` `X_MCP_PROTOCOL_UNSUPPORTED`, `data: { supported, requested }` |
114
114
 
115
- `MCP_PROTOCOL_VERSION` is gone (`As of 2026-11`): name the era — `MCP_MODERN_VERSIONS[0]`, or `MCP_LEGACY_VERSIONS`. `resources/templates/list` is `{ resourceTemplates: [] }` on both eras. A resource not found, hidden or absent, is one answer: `-32601` legacy, `-32602` modern. Not served and not advertised: `subscriptions/listen`, multi-round-trip input, the tasks extension, `x-mcp-header`, SSE responses; every `listChanged` is `false`.
115
+ `MCP_PROTOCOL_VERSION` is gone (`As of 2026-11`): name the era — `MCP_MODERN_VERSIONS[0]`, or `MCP_LEGACY_VERSIONS`. `resources/templates/list` is `{ resourceTemplates: [] }` on both eras. A resource not found, hidden or absent, is one answer: `-32601` legacy, `-32602` modern. Not served and not advertised: `subscriptions/listen`, multi-round-trip input other than the URL prompt below, the tasks extension, `x-mcp-header`, SSE responses; every `listChanged` is `false`.
116
+
117
+ A tool asks the person to open a page with `withUrlElicitation(output, { url, message })` (`As of 2026-11`; spec `client/elicitation`, `basic/patterns/mrtr`):
118
+
119
+ | `tools/call` | Answer |
120
+ |---|---|
121
+ | modern, and the request's `_meta["io.modelcontextprotocol/clientCapabilities"].elicitation.url` is an object | `resultType: 'input_required'` with `inputRequests.url_elicitation`: `elicitation/create`, `mode: 'url'`, `url` (parsed, `new URL(url).href`), `message`. No `content`, no `requestState` |
122
+ | its retry, carrying `inputResponses.url_elicitation.action` of `accept`, `decline` or `cancel` | the tool runs again and its result is the answer — asked once per call, whichever of the three the person chose. Any other `action` is no answer: an ask the rerun makes is sent, not suppressed; a rerun that no longer asks answers its result |
123
+ | the tool failed (`isError`) | the failure, for every caller: never hidden behind a prompt, and an ask beside it is not checked |
124
+ | modern without the capability, and every legacy request | the tool's result: `output` says in text what the prompt would have. `-32042` is never sent, since a legacy capability is declared on `initialize` and no handshake is kept |
125
+ | a URL that is not absolute `https:` (`http:` on `localhost`, `127.0.0.1` or `[::1]`), carries credentials, or has no message | `X_MCP_ELICITATION_URL_INVALID`, for every caller |
126
+
127
+ The ask belongs to the call that made it. The handler reruns on the retry whatever the answer, so a write before the ask runs twice: keep writes behind a completion check the handler makes itself. A retry under the same `idempotencyKey` replays the first result and never sees the page finished; check completion in a call without that key. Nothing about the person goes in the URL, and the page checks that whoever opened it is the caller the tool asked.
116
128
 
129
+ Over HTTP:
117
130
  Over HTTP:
118
131
 
119
132
  | Request | Answer |
@@ -198,7 +211,13 @@ confirmed_by_user }` — without `live: true` it answers a preview (the framewor
198
211
  only on `confirmed_by_user: true`) replace `manage_resource`, for clients and directories that
199
212
  refuse a dispatcher which both reads and writes. A grouped write without an effect fails boot
200
213
  (`X_MCP_EFFECT_UNDECLARED`); an action called on the wrong dispatcher is `X_MCP_WRONG_TOOL`
201
- naming the right one; an unconfirmed commit is `X_MCP_USER_CONFIRMATION_REQUIRED`. Full contract:
214
+ naming the right one; an unconfirmed commit is `X_MCP_USER_CONFIRMATION_REQUIRED`.
215
+ `delete_resource` is the stricter door (`As of 2026-11`): a `write` action sent to it is previewed
216
+ and confirmed the same way, and `write_resource` is never widened. `split: { fields, stricter }`
217
+ adds the app's own string fields to the dispatcher envelopes (a `reason`: validated there, handed
218
+ to a tool as `door.fields`, never in the action input) and a hook that sends one call to
219
+ `delete_resource` by its arguments — `X_MCP_WRONG_TOOL` naming it on the other two, and the one
220
+ way a read runs there. The audit line carries `door`. `X_MCP_SPLIT_INVALID` at boot. Full contract:
202
221
  [`packages/mcp/README.md`](https://github.com/developerz-ai/ultimate/blob/main/packages/mcp/README.md).
203
222
 
204
223
  **What the model reads is compact.** A tool's text block is one-line JSON (the 2-space form until
@@ -465,8 +484,12 @@ gates as every other tool:
465
484
  |---|---|---|
466
485
  | `catalog: (caller) => ({ tools, groups? })` | tools that exist per caller (a tenant's connectors), each a `runtimeTool({ name, description, inputSchema, permission, run })` borrowing a **declared** permission; asked on every `tools/list` and `tools/call`, never cached | `X_MCP_CATALOG_TOOL_DUPLICATE` (a name taken twice), `X_MCP_CATALOG_UNRESOLVED` (the resolver threw, or answered something unservable) — the request fails, never a smaller list |
467
486
  | `tenant: { arg, resolve, list }` | the token resolves to a person; every call names its tenant under `arg`, stripped before validation; `resolve` builds the call's actor, so policy and tenancy guards see one org per call; `list_tenants` lists them | `X_MCP_TENANT_REQUIRED` (no tenant named — fix `list_tenants({})`), `X_MCP_TENANT_UNRESOLVED` (the lookup threw), `X_MCP_TENANT_INVALID` (boot: a tool declares the arg) |
487
+ | `tenant: { …, discover: 'list_resources' }` | the named tool lists the tenants in place of `list_tenants`, which is then not registered: called with no `arg` it answers `{ tenants, next }` as the person, called with one it is the tool it always was. `list_resources` (surface `'meta'` or `'meta-split'`, never a function) or an ungrouped tool of `tools:` with no `visibleTo` | `X_MCP_TENANT_INVALID` (boot: the name is no such tool); `X_MCP_TENANT_REQUIRED` then points at the discover tool |
488
+ | `tenant: { …, optional: ['docs'] }` | the named ungrouped tools run as the person when a call names no tenant, and as the tenant actor when it names one; `tools/list` publishes the arg on them, not as required | `X_MCP_TENANT_INVALID` (boot: a name that is not an ungrouped tool of `tools:`, or the discover tool) |
468
489
 
469
- A tenant the person is not in (`resolve` answers `null`) gets exactly the answer a hidden tool gets.
490
+ A tenant the person is not in (`resolve` answers `null`) gets exactly the answer a hidden tool gets,
491
+ on the discover and the optional tools too. Only an absent `arg` reaches the tenant list or the
492
+ person: a present, unusable one is `X_MCP_TENANT_REQUIRED`.
470
493
  Another caller's runtime tool is an absent tool. The audit line carries `tenant`.
471
494
 
472
495
  **`tools/list` is person-scoped, and not a promise.** MCP's `tools/list` names no tenant, so `visibleTo` (function form), `can()` and `catalog` run there as the person; `tools/call` runs them as the tenant actor and is authoritative. A tool visible to the person but not the tenant actor is listed and answers as a hidden tool; one visible only through a tenant role or a tenant's catalog row is unlisted and still runs when called by name.
@@ -534,13 +557,21 @@ The reference app's `draftReview` (`examples/dummy/apps/web/mcp-tools.ts`) queue
534
557
  | The prefix | with `recipes:`, `resources:` may not hold `docs://recipes/` (`X_MCP_RECIPE_URI_RESERVED`) |
535
558
  | Error links | `defineError({ docs: 'docs://recipes/<name>' })` must name a recipe some endpoint serves — `X_MCP_RECIPE_UNKNOWN` at mount; a throw-site link to none is dropped from the render and logged |
536
559
 
537
- **From a markdown folder.** `recipes: await markdownRecipes({ dir: join(import.meta.dir, 'docs') })` reads one `*.md` per recipe and serves its body verbatim. The file name is the recipe name. `title:` and `description:` come from `---` frontmatter, else from the first `# ` heading and the paragraph under it. A fence tagged `call` holds one step, `tool {"arg": "value"}`, and is checked at boot like any `step.example`. A whole `"<postId>"` value is a placeholder, so any value passes at boot. A `docs://recipes/<name>` link in the text that names no recipe is `X_MCP_RECIPE_LINK_DANGLING`.
560
+ **From a markdown folder.** `recipes: await markdownRecipes({ dir: join(import.meta.dir, 'docs') })` reads one `*.md` per recipe and serves its body as written, line ends normalised to LF and outer blank lines trimmed. The file name is the recipe name. `title:`, `description:` and `aliases:` come from `---` frontmatter, else the title and description come from the first `# ` heading and the paragraph under it. A fence tagged `call` holds one step, `tool {"arg": "value"}`, and is checked at boot like any `step.example`. A whole `"<postId>"` value is a placeholder, so any value passes at boot. A `docs://<section>/` link in the text, into a section the recipes serve, that names no recipe is `X_MCP_RECIPE_LINK_DANGLING`; the link's whole path is checked.
561
+
562
+ **Sections.** A recipe's `section` (default `recipes`) is its URI prefix: `{ name: 'errors', section: 'ref' }` is `docs://ref/errors`. In a markdown folder, one sub-folder level is the section: `ref/errors.md` is `docs://ref/errors`, and `recipes/<name>.md` is the same URI as `<name>.md`. A section, like a name, is lowercase letters and digits in groups joined by single `-` (`ref-v2`; never `-ref`, `ref-` or `ref--v2`), so no section steps out of `docs://<section>/` (`X_MCP_RECIPE_URI_RESERVED`). Every section a declared recipe uses is owned by `recipes:`: a `resources:` URI under it is refused. A body link into a served section must name a recipe; a link to any other `docs://` prefix is not judged. Error links (`defineError({ docs })`) still name `docs://recipes/<name>` only.
563
+
564
+ | `docsTool:` | Effect |
565
+ |---|---|
566
+ | `description: '…'` | replaces the `docs` tool's default description |
567
+ | `index: 'map'` | `docs({})` answers plain text: `# <section>`, then one `<uri> <title>` line per recipe, ` (yours)` on a caller's own |
568
+ | `index: 'json'` (default) | `docs({})` answers `{ recipes: [{ name, title, description, uri, source }] }` |
538
569
 
539
- **Searching.** `docs({})` lists what this caller can follow. `docs({ name })` and `docs({ uri })` read one recipe. `docs({ q })` inlines the best match (`q` at most 1,000 characters, else `X_INPUT_INVALID`; a miss compares its first 16 words, 64 characters each, for the nearest — `As of 2026-11-19`), scoring 3 for each word in the name or title, 2 in the description and 1 in the body. On a miss it names the nearest recipes, so a caller with any visible recipe never gets an empty answer.
570
+ **Searching.** `docs({})` lists what this caller can follow. `docs({ name })` and `docs({ uri })` read one recipe; `name` is the bare name in `recipes` and `<section>/<name>` in any other section. `docs({ q })` inlines the best match (`q` at most 1,000 characters, else `X_INPUT_INVALID`; a miss compares its first 16 words, 64 characters each, for the nearest — `As of 2026-11-19`), scoring 3 for each word in the name, title or aliases, 2 in the description and 1 in the body. On a miss it names the nearest recipes, so a caller with any visible recipe never gets an empty answer.
540
571
 
541
- **Per caller.** `extraRecipes: (caller) => recipes` adds the caller's own recipes, such as a tenant's runbooks. They are listed as `source: 'caller'` on `docs`, and on `resources/list` and `resources/read` to that caller only. They are not checked at boot. A recipe that names a tool the caller cannot call is not shown.
572
+ **Per caller.** `extraRecipes: (caller) => recipes` adds the caller's own recipes, such as a tenant's runbooks. They are listed as `source: 'caller'` on `docs`, and on `resources/list` and `resources/read` to that caller only. They may use a section no app recipe uses; another caller reads it as not found, byte for byte. They are not checked at boot. A recipe that names a tool the caller cannot call is not shown.
542
573
 
543
- **Replayed.** In a contract test, `await replayRecipes(server, recipes, { caller, placeholders })` calls every step's example through the real server as `caller` and reads every link. Three answers fail it with `X_MCP_RECIPE_EXAMPLE_INVALID`: no such tool, refused arguments, and a policy that refuses that caller. A dangling link fails it with `X_MCP_RECIPE_LINK_DANGLING`. A tool's own refusal (`X_NOT_FOUND` for a sample id) counts as the tool working. The reference app replays its recipes as an org owner: `examples/dummy/packages/mcp/src/recipes-replay.contract.test.ts`.
574
+ **Replayed.** In a contract test, `await replayRecipes(server, recipes, { caller, placeholders, sections })` calls every step's example through the real server as `caller` and reads every link into a section `recipes` uses or `sections` names: replaying a subset, `sections` names the server's other sections, else a link into one only the rest use goes unread. Three answers fail it with `X_MCP_RECIPE_EXAMPLE_INVALID`: no such tool, refused arguments, and a policy that refuses that caller. A dangling link fails it with `X_MCP_RECIPE_LINK_DANGLING`. A tool's own refusal (`X_NOT_FOUND` for a sample id) counts as the tool working. The reference app replays its recipes as an org owner: `examples/dummy/packages/mcp/src/recipes-replay.contract.test.ts`.
544
575
 
545
576
  ### Consuming another server: `mcpTools()`
546
577
 
@@ -551,8 +582,9 @@ Remote MCP tools as this app's actions — the app's `policy`, rate limit, confi
551
582
  | Declared | `mcpTools({ name, url, auth, allow, policy, lock })` → `tools: Map<remoteName, Action>`, action names `<name>_<tool>`. `policy` is an app `resource:verb` permission, as a hand-written tool takes: the input is the remote's schema, so a predicate over it would decide nothing |
552
583
  | Reviewed | `allow` is required; `lock` is the committed `tools.lock.json` written by `x mcp lock <name>`; `x mcp lock <name> --check` writes nothing and fails on drift |
553
584
  | Drift | a missing, re-described or re-shaped tool is `X_MCP_REMOTE_TOOL_CHANGED` — at declaration against the lock, before the first call against the live server |
554
- | Wire | `outbound()` (`dial: 'public'` by default, deadline, size cap); modern era first, then legacy `initialize` + `Mcp-Session-Id`; JSON or SSE answers |
585
+ | Wire | `outbound()` (`dial: 'public'` by default, deadline, size cap `maxBytes`, default 16 MiB); modern era first, then legacy `initialize` + `Mcp-Session-Id`; JSON or SSE answers |
555
586
  | Era fallback | the legacy handshake only when the first modern call is refused for its era: a `400`/`404`/`405`, JSON-RPC `-32022`/`-32601`/`-32600`/`-32602`, or a body that is no answer. Never on a `429`, `408` or `403`, a refusal of the moment. Concurrent first calls share one handshake; a failed handshake leaves the era undecided, so the next call tries again (`eraRefusal`, `packages/mcp/src/remote-client.ts`, `As of 2026-11`) |
587
+ | Transport | `fetch` swaps the transport under `outbound()`, in production as in a test. The client keeps the dial screen, deadline, `maxBytes` and redirect refusal: the transport is handed the screened address and `redirect: 'manual'`, and an answer it reached by following a redirect itself is refused (`X_OUTBOUND_TRANSPORT_REDIRECTED` as the source). A transport that dials anywhere else takes the screen over — [Outbound HTTP → transport](Outbound-HTTP#depsfetch-the-transport) |
556
588
  | Paging | `listTools()` follows `nextCursor` for at most 50 pages; a cursor still open past that is `X_MCP_REMOTE_REFUSED`, `meta.failure: 'malformed'`, never a truncated list |
557
589
  | Cancel | a legacy server hears `notifications/cancelled` for the aborted call's own request id, and only when the request was already sent |
558
590
  | Untrusted | the answer arrives as `{ untrusted, isError }`, fenced `<untrusted source="mcp:<name>/<tool>">`, middle-cut past `maxResultChars`; invisible format characters stripped, then every `<` (and full-width `<`, small `﹤`) written `&lt;` — no spelling of `</untrusted>` survives |
package/wiki/Notify.md CHANGED
@@ -236,11 +236,13 @@ export const approvalRequested = notifier({
236
236
  | devices | `x_push_devices`, keyed `(platform, token)` — a phone a second person signs in on is theirs now |
237
237
  | register | `registerDevice` on every launch; `previousToken` when the OS rotated it. `unregisterDevice` on sign-out. Stored against `ctx.actor.id`; an agent never registers |
238
238
  | data-only | `pushChannel({ pusher, data })` — APNs `background`, priority 5, `content-available: 1`; FCM with no `notification`. ≤ 8 string keys, ≤ 256 characters, no reserved key: else `X_NOTIFY_PUSH_MESSAGE_INVALID`. `webPush()` cannot take it — a type error |
239
- | visible | `pushChannel({ pusher, message })`, the same `NotifyPushMessage` as the web: rendered per device locale |
239
+ | visible | `pushChannel({ pusher, message })`, the same `NotifyPushMessage` as the web: rendered per device locale. `urgency` sets APNs `apns-priority` (10, or 5 for `low`/`very-low`) and FCM `android.priority` (`high`/`normal`) |
240
+ | native-only fields | on the same message, ignored by `webPush()`: `sound` → APNs `aps.sound` and FCM `android.notification.sound`: `'default'` for the platform's sound, or a bundled one — APNs reads its file name (`chime.caf`), FCM its `res/raw` resource name without the extension (`chime`), and on Android 8 and later the notification channel sets the sound; unset, no sound is requested and APNs alerts silently; `interruptionLevel` (`passive`, `active`, `time-sensitive`, `critical` — the last needs Apple's entitlement) → `aps.interruption-level`; `category` → `aps.category`; `channelId` → `android.notification.channel_id`. A name is 1–64 of `A-Za-z0-9._-`, in any position, else `X_NOTIFY_PUSH_MESSAGE_INVALID` with `meta.field`, before any device. Unset, nothing is added: the wire is byte identical to a message without them. `As of 2026-11-23` |
241
+ | report | `nativePush({ onReport })` is called with `{ to, kind: 'alert' \| 'data', report }` once each send (`'alert'`) or `sendData` (`'data'`) settles; `report` is a `NativePushReport` — `{ accepted, refused, removed, skipped }`, one count per device. `accepted` is what APNs or FCM took (a 2xx), never what a device showed: no provider reports delivery. `removed`: rows deleted (gone, a bad token at its limit, an unsendable token); `skipped`: no provider configured for its platform. A credential refusal rejects the whole send (`X_NOTIFY_PUSH_PROVIDER_REFUSED`), so no report carries the devices it stopped. A send nothing accepted and something refused still rejects, and reports nothing. A throw from `onReport` is reported (`notify.push.on_report`) and the send still settles: the providers took it, so a retry would push it twice |
240
242
 
241
243
  | Provider answer | Outcome |
242
244
  |---|---|
243
- | 2xx | delivered |
245
+ | 2xx | accepted by the provider |
244
246
  | APNs 410 · FCM `UNREGISTERED` | `X_NOTIFY_PUSH_DEVICE_GONE` — the device row is deleted, the delivery settles |
245
247
  | other 4xx | `X_NOTIFY_PUSH_PROVIDER_REFUSED` — logged, next device tried; fails the delivery when no device took it. 401/403 also drops the cached credential |
246
248
  | 429 · 5xx · timeout | rethrown after every other device was tried: `X_NOTIFY_DELIVERY_FAILED`, the job retries |
@@ -33,7 +33,7 @@ export async function chargeStatus(id: string): Promise<{ id: string; status: st
33
33
  | `Retry-After` | a retryable status that states a delay waits that delay (clamped by the policy's `max`) |
34
34
  | body | read under an idle watchdog (`idleMs`, default 30 s) and a byte cap (`maxBytes`, default 16 MiB). `read: 'stream'` hands the body over under both |
35
35
  | redirects | `redirect: 'error'` by default. `'follow'` takes at most 5 hops and screens EVERY hop after the first as a public dial, `'named'` included; at an origin change only `accept`, `content-type` and `user-agent` travel |
36
- | redaction | a cause, `meta` and the `outbound.attempt` log line carry vendor, method, origin and the path's FIRST segment plus the length of the rest (`/services/…(21 chars)`: a webhook keeps its token in the path), never the query or a header. A refusal's body reaches `meta.detail` only as a JSON object, credential-named fields redacted, 200 characters; anything else (a form, an array, HTML, a cut body) is dropped |
36
+ | redaction | a cause, `meta` and the `outbound.attempt` log line carry vendor, method, origin and the path's FIRST segment plus the length of the rest (`/services/…(21 chars)`: a webhook keeps its token in the path), never the query or a header. A refusal's body reaches `meta.detail` only as a JSON object, credential-named fields redacted, 200 characters; anything else (a form, an array, HTML, a cut body) is dropped. [`refusal`](#refusal-what-a-non-2xx-body-becomes) declares the fields to keep from the whole body, or drops `meta.detail` |
37
37
  | breaker | `breaker: breaker({ name, failures, cooldownMs })` from `@ultimat3/core`, recorded once per call after the retries. See below |
38
38
 
39
39
  ## `dial`: which network a URL may reach
@@ -84,6 +84,23 @@ await outbound({
84
84
  });
85
85
  ```
86
86
 
87
+ ## `deps.fetch`: the transport
88
+
89
+ `outbound(request, { fetch })` swaps the transport, for a test or in production (a client with its
90
+ own sockets, an instrumented one). It sits UNDER `outbound()`, so every rule above stays the call's.
91
+
92
+ | The transport is handed | The transport must |
93
+ |---|---|
94
+ | the SCREENED url: under `dial: 'public'` the approved address, with `host` and `tls.serverName` naming the name | dial that url, nowhere else |
95
+ | `init` with `signal` and `redirect: 'manual'` | pass `init` through; a hop is `outbound()`'s to take (`redirect: 'follow'`) |
96
+
97
+ - **A transport that followed a redirect itself is refused**: an answer with `redirected: true` is
98
+ `X_OUTBOUND_TRANSPORT_REDIRECTED`, under `redirect: 'error'` and `'follow'` alike — no screen saw
99
+ that hop (`outbound-transport.test.ts`).
100
+ - `maxBytes`, `idleMs` and `deadlineMs` cut the body the transport streams, whatever it does.
101
+ - **A transport that reaches another address (a tunnel, a relay) takes the screen over**: the app
102
+ proves it, as for a proxy it names.
103
+
87
104
  `screenDial(url, { resolve, allowPrivate })` is the screen alone, for a transport that keeps its own
88
105
  codes: `@ultimat3/jobs`' webhook target and `@ultimat3/scraping`'s wildcard leg call it.
89
106
 
@@ -95,14 +112,48 @@ codes: `@ultimat3/jobs`' webhook target and `@ultimat3/scraping`'s wildcard leg
95
112
  | `X_OUTBOUND_UNREACHABLE` | retryable | DNS, connect, TLS or reset: no response |
96
113
  | `X_OUTBOUND_THROTTLED` | retry-after | a retryable status with `Retry-After` (`meta.retryAfterSeconds`) |
97
114
  | `X_OUTBOUND_UNAVAILABLE` | retryable | 5xx, 408, 409, 425, 429 with no stated delay (`meta.status`) |
98
- | `X_OUTBOUND_REFUSED` | terminal | any other non-2xx (`meta.status`, `meta.detail`) |
115
+ | `X_OUTBOUND_REFUSED` | terminal | any other non-2xx (`meta.status`, `meta.detail`, `meta.fields` under `refusal.schema`) |
99
116
  | `X_OUTBOUND_TOO_LARGE` | terminal | the body passed `maxBytes` |
100
117
  | `X_OUTBOUND_HOST_BLOCKED` | terminal | `dial: 'public'` refused an address class, a scheme or a hop |
101
118
  | `X_OUTBOUND_REDIRECTED` | terminal | a 3xx under `redirect: 'error'`, or more than 5 hops (`meta.location`, no query) |
119
+ | `X_OUTBOUND_TRANSPORT_REDIRECTED` | terminal | the transport in `deps.fetch` answered `redirected: true`: it followed a hop itself (`meta.location`, no query) |
102
120
  | `X_OUTBOUND_RETRY_UNSAFE` | terminal | `retry` on POST or PATCH without `idempotent: true` |
103
121
  | `X_OUTBOUND_BODY_INVALID` | terminal | `answer.json(schema)` refused the body (`meta.issues`) |
104
122
  | `X_OUTBOUND_PROXY_INVALID` | terminal | `proxy` is not an `http:`/`https:` URL, or its resolver threw (`meta.reason`, never the URL) |
105
123
 
124
+ ### `refusal`: what a non-2xx body becomes
125
+
126
+ `X_OUTBOUND_REFUSED`, `X_OUTBOUND_UNAVAILABLE` and `X_OUTBOUND_THROTTLED` read the body once, per
127
+ the call's `refusal`:
128
+
129
+ | `refusal` | Read | On the error |
130
+ |---|---|---|
131
+ | unset (default) | chunks until 1,024 characters are decoded, the rest cancelled (a whole chunk is kept, so one large chunk is read whole) | `meta.detail`: a JSON object, credential-named fields redacted, 200 characters; else `''`. A large error object that arrives in pieces is cut, does not parse, and is `''` |
132
+ | `{ schema }` | the whole body, up to the call's `maxBytes` | `meta.fields`: the schema's answer, credential-named fields redacted at any depth; absent when the body is not JSON, does not fit or passes `maxBytes`. `meta.detail` is the 200-character excerpt of that whole body |
133
+ | `{ detail: false }` | nothing for the excerpt | `meta.detail: ''`: the excerpt, and the free text it carries (an address, a name), never kept. Combines with `schema`; it does not filter `meta.fields`, so a schema keeps only fields that are safe to log |
134
+
135
+ ```ts
136
+ import { isUltimateError } from '@ultimat3/core';
137
+ import { outbound } from '@ultimat3/core/outbound';
138
+ import { t } from '@ultimat3/schema';
139
+
140
+ declare const url: string;
141
+ declare const body: string;
142
+
143
+ const decline = t.object({ error: t.object({ decline_code: t.string }) });
144
+ try {
145
+ await outbound({ url, vendor: 'payments', dial: 'named', deadlineMs: 10_000, method: 'POST',
146
+ body, refusal: { schema: decline, detail: false } });
147
+ } catch (error) {
148
+ // meta.fields is unknown on the error: the schema that declared it reads it back typed.
149
+ if (isUltimateError(error) && error.code === 'X_OUTBOUND_REFUSED') {
150
+ console.log(decline.safeParse(error.meta?.['fields']));
151
+ }
152
+ }
153
+ ```
154
+
155
+ The schema is the whole of what `meta.fields` keeps: undeclared keys never reach it. `meta.detail` is a separate excerpt of the raw body and may still carry an undeclared field (an `error.message` holding an email): set `detail: false` to keep only what the schema declares.
156
+
106
157
  **A 401 is `X_OUTBOUND_REFUSED` with `meta.status: 401`.** There is no refresh hook: the app's own
107
158
  wrapper refreshes its token and calls again. Token storage and single-flight stay the app's.
108
159
 
@@ -297,7 +297,7 @@ Then `x db gen "row security"`, commit the migration and `packages/db/schema/`,
297
297
  | roles, PGlite | its one session is a superuser; the migrate step (`x db migrate`, `ROLE=migrate`) holds `x_migrator` and takes over what the superuser owned in `public`; `x dev` and a served role switch to `x_app` at boot (`serveAsAppRole`) and grant it DML on every table already there |
298
298
  | roles, production | the operator's: `DATABASE_URL` of a serving role is a `nosuperuser nobypassrls` role owning nothing; `ROLE=migrate`'s owns the tables. Grants on tables, the `x_*` ones included, are the operator's too |
299
299
  | `x doctor` | with the flag on, connects as `DATABASE_URL` and names `X_DB_ROW_SECURITY_BYPASSED`; the drift half rides the drift probe |
300
- | policy | `enable` + `force row level security`, one `ultimate_tenant` policy: `org_id = nullif(current_setting('x.tenant', true), '')::<type> or current_setting('x.cross', true) = 'on'`, as `using` AND `with check`. Unset fails closed: no rows |
300
+ | policy | `enable` + `force row level security`, one `ultimate_tenant` policy: `case when current_setting('x.cross', true) = 'on' then true else org_id = nullif(current_setting('x.tenant', true), '')::<type> end`, as `using` AND `with check`. Unset fails closed: no rows. A `case`, not an `or`, `As of 2026-11`: same rows, but an `or`'s guessed selectivity made a tenant's keyset page (`where org_id = $1 order by … limit n` on an `(org_id, …)` index) a bitmap scan plus a sort for the runtime role; the `case` keeps the ordered index scan. A policy generated before keeps the `or` until a migration drops and re-creates it with this text |
301
301
  | the tenant | set per transaction through `setLocal` — `select set_config($1, $2, true)`, parameter-bound and local, so a pooled connection hands nothing on (pooler transaction mode is safe). `crossTenant()` sets `x.cross` |
302
302
  | bare statements | wrapped in one transaction: `BEGIN`, `set_config`, the statement, `COMMIT` |
303
303
  | who is subject | a role that is `nosuperuser nobypassrls` and owns no table. Anything else is `X_DB_ROW_SECURITY_BYPASSED` at boot. The migrator (`bypassrls`) owns the tables, so a backfill still sees every row |
package/wiki/Realtime.md CHANGED
@@ -11,7 +11,7 @@ rather than a convention — the barrels are disjoint, and a test asserts it.
11
11
 
12
12
  | Entry | Holds | Reaches |
13
13
  |---|---|---|
14
- | `@ultimat3/realtime` | `useQuery`, `useRecord`, `useMutation`, `useConnection`, `installRealtime`, `hasPageSocket`, `RecordStore`, `channel()` and `topic()`, the offline queue, the wire protocol, cursors | an island, a browser bundle |
14
+ | `@ultimat3/realtime` | `useQuery`, `useRecord`, `useMutation`, `useConnection`, `installRealtime`, `hasPageSocket`, `hasSyncTarget`, `RecordStore`, `channel()` and `topic()`, the offline queue, the wire protocol, cursors | an island, a browser bundle |
15
15
  | `@ultimat3/realtime/server` | `syncNode`, `ChannelHub`, `SocketRegistry`, `LiveQueryRegistry`, `NatsTransport`, `openNatsClient`, the replicator, the change feed, pg replication | a `sync` node, a worker, `server.ts` |
16
16
 
17
17
  ```ts
@@ -19,7 +19,7 @@ import { useQuery } from '@ultimat3/realtime'; // island
19
19
  import { syncNode } from '@ultimat3/realtime/server'; // sync node
20
20
  ```
21
21
 
22
- A server render is not a missing install. With no DOM, every read hook answers `pending` with no subscription, and `useMutation()` refuses with `X_LIVE_SERVER_RENDER`. `hasPageSocket()` answers `false` there, every time, so it is **not** a guard that makes a page-body read safe: a browser-only read in code no island imports is `X_LIVE_ROUTE_NO_ISLAND` at the `budgets` step, `hasPageSocket()` included. In a **browser**, a hook in a bundle that never called `installRealtime()` is `X_REALTIME_UNINSTALLED`.
22
+ A server render is not a missing install. With no DOM, every read hook answers `pending` with no subscription, and `useMutation()` refuses with `X_LIVE_SERVER_RENDER`. `hasPageSocket()` answers `false` there, every time, so it is **not** a guard that makes a page-body read safe: a browser-only read in code no island imports is `X_LIVE_ROUTE_NO_ISLAND` at the `budgets` step, `hasPageSocket()` included. In a **browser**, a hook in a bundle that never called `installRealtime()` is `X_REALTIME_UNINSTALLED`. To ask, before any hook ran, whether a live hook could reach a sync node at all, call `hasSyncTarget()`: `true` when `installRealtime` was given a target or the document carries `<meta name="ultimate-sync">`; asking dials nothing. A page without one would answer `useChannel` with `X_SYNC_UNCONFIGURED`, so an island renders its static fallback instead. An events-only channel names no read: `channelRef('typing', { params: ['orgId'] })`.
23
23
 
24
24
  A file that needs both writes both imports. **Nothing was deleted in the split** — if an import
25
25
  stops resolving after upgrading to 8.0.0, the name moved to `./server`.
@@ -216,7 +216,7 @@ kept) until it mounts over the restored store.
216
216
  |---|---|---|
217
217
  | takes `useQuery`, `useRecord`, `useRecords`, `useMutation`, `useMutationQueue`, `useOutbox`, or any other name not listed below, anywhere in its own graph | yes — until it mounts, 3 s at most | yes, 1 s at most (`FIRST_PAINT_HOLD_MS`) |
218
218
  | takes `useQuery` or `useRecord` (and otherwise only the follow list below), in an app that declares no `persist: true` entity | **no** — the boot restores no record they could show | no |
219
- | takes only `useChannel`, `usePresence`, `useConnection`, `hasPageSocket`, `useRecordChanges`, `pollEvery`, `readPresence`, `channel`, `channelRef`, `topic` | **no** — its server markup is on screen from the first byte | no — it mounts as soon as the page runtime is there |
219
+ | takes only `useChannel`, `usePresence`, `useConnection`, `hasPageSocket`, `hasSyncTarget`, `useRecordChanges`, `pollEvery`, `readPresence`, `channel`, `channelRef`, `topic` | **no** — its server markup is on screen from the first byte | no — it mounts as soon as the page runtime is there |
220
220
  | takes the barrel with no list of names (`import * as`, `export *`, `import()`) | yes | yes |
221
221
  | reaches no realtime | no | no |
222
222
 
@@ -721,8 +721,8 @@ A client on build `A` connecting to a `sync` node on build `B` is **accepted**,
721
721
 
722
722
  A long-lived socket for a client that is **not a browser** — a device agent that dials out and
723
723
  receives work. `deviceSocket()` is a factory over `route`: the value is a websocket mount (`path`,
724
- `fetch`, `websocket`) plus `request()`, which reaches one connected device from any process.
725
- From `@ultimat3/realtime/server`, `As of 2026-11-06`.
724
+ `fetch`, `websocket`) plus `request()`, which reaches one connected device from any process, and
725
+ `disconnect()`, which closes one from any process. From `@ultimat3/realtime/server`, `As of 2026-11-23`.
726
726
 
727
727
  ```ts
728
728
  import { userActor } from '@ultimat3/core';
@@ -735,11 +735,16 @@ export const deviceLink = deviceSocket({
735
735
  maxSocketsPerActor: 10,
736
736
  heartbeatMs: 15_000,
737
737
  onFrame: ({ frame, device }) => ({ ack: device.deviceId, received: frame }),
738
+ onOpen: ({ device, ctx }) => ctx.logger.info('device.online', { device: device.deviceId }),
739
+ onClose: ({ device, ctx, reason }) =>
740
+ ctx.logger.info('device.offline', { device: device.deviceId, reason }),
738
741
  });
739
742
 
740
743
  // From any action or job, on any node — scoped to the caller's tenant:
741
744
  export const ask = (ctx: { readonly actor: ReturnType<typeof userActor> }) =>
742
745
  deviceLink.request(ctx, 'desk-7', { job: 'sync' }, { deadlineMs: 30_000 });
746
+ export const revoke = (ctx: { readonly actor: ReturnType<typeof userActor> }) =>
747
+ deviceLink.disconnect?.(ctx, 'desk-7', 'revoked'); // true: closed; false: no socket under this tenant
743
748
  ```
744
749
 
745
750
  | Concern | Rule |
@@ -751,6 +756,9 @@ export const ask = (ctx: { readonly actor: ReturnType<typeof userActor> }) =>
751
756
  | Frames | JSON text. `DEVICE_FRAME_MAX_BYTES` (256 KiB) is the framework's and is not an option: Bun's `maxPayloadLength` and the handler both enforce it (`1009 X_DEVICE_FRAME_TOO_LARGE`); a `request()` over it throws before sending. `onFrame` runs one frame at a time per socket, as the device's actor; past 32 queued the socket closes `X_FRAME_RATE_LIMIT` |
752
757
  | Heartbeat | the node names `heartbeatMs` in its `hello`; a device silent for two beats is closed `4001` |
753
758
  | Addressing | the holder registers the device in the bus's shared set (TTL three beats) under `(tenant, deviceId)`; `request()` looks it up and publishes to that node. Nobody holds it, or another tenant does: `X_DEVICE_OFFLINE` at once. No answer in `deadlineMs` (default 30 s, max 600 s): `X_DEVICE_REQUEST_TIMEOUT`. A socket that closes answers its open requests `X_DEVICE_OFFLINE` |
759
+ | Open and close | `onOpen({ device, ctx })` and `onClose({ device, ctx, reason })` run as the device's actor, beside the socket and never in its path: a throw is reported (`device.on_open` / `device.on_close`) and the socket goes on. A socket's `onClose` runs after its `onOpen` settles. `reason` is the node's own close reason (`replaced`, `no beat`, `grant expired`, `drain`, a `disconnect()` reason, …) or `disconnected` when the device or its network ended it. At least once: a duplicate is possible, a missing close is not |
760
+ | A node that dies | with `onClose` declared, each socket is a record in the bus's shared set, kept on the holder's beat. Each beat the serving node with the lowest live id reads them, and a record whose node left the roster (three beats silent) is dropped and closed there: `reason: 'node lost'` (`DEVICE_NODE_LOST`), `ctx.actor` carrying kind, id and org only. A holder whose record was dropped while alive writes it again, with a second `onOpen`. No `onClose`, no record and no write |
761
+ | Disconnect | `disconnect(ctx, deviceId, reason)` from any role: the holding node closes the socket `1008` with `reason` (1 to 123 UTF-8 bytes, `DEVICE_CLOSE_REASON_MAX_BYTES`, else `X_CONFIG_INVALID`). `true` once closed; `false` when nobody holds it under the caller's tenant, as for another tenant's device. A holder that does not confirm within `DEVICE_DISCONNECT_DEADLINE_MS` (5 s): `X_DEVICE_REQUEST_TIMEOUT`. The device may redial: revoke its token first. Optional in the `DeviceSocket` type only, so an app's own implementation still compiles; `deviceSocket()` always sets it |
754
762
  | Drain | SIGTERM: stop accepting, then the sync node's own `drainPlan` + `reconnect` frame per socket, then close `1001` |
755
763
  | Reconnect | `deviceAgent()` (a Bun client) redials on realtime's one jittered backoff, or at the slot a `reconnect` frame assigned |
756
764
 
@@ -800,7 +808,7 @@ the listener's websocket paths are fixed when it binds. A container scans once,
800
808
  | `X_TRANSPORT_UNAVAILABLE` | the fanout bus is down. At boot only for `sync` and the replicator, after a bounded wait; on `web`, `worker` and `scheduler` it is what a publish rejects with while the bus is away ([what each role needs](#what-each-role-needs-from-the-bus)); on a socket it is the one refusal a client treats as transient ([a bus outage, seen from an open page](#a-bus-outage-seen-from-an-open-page)) | `x doctor — then check NATS_URL points at a reachable nats-server` |
801
809
  | `X_TRANSPORT_PROTOCOL` | the bus answers in a protocol this build does not speak | `the bus must be nats-server >= 2.11 with JetStream enabled (nats-server -js)` |
802
810
  | `X_DEVICE_OFFLINE` | `deviceLink.request()` named a device no node holds a socket for under the caller's tenant | `x doctor --json`, then retry once the device redials |
803
- | `X_DEVICE_REQUEST_TIMEOUT` | the device took the request and sent no `response` with its id before `deadlineMs` | a longer `deadlineMs`, or answer every request the node sends the device |
811
+ | `X_DEVICE_REQUEST_TIMEOUT` | the device took the request and sent no `response` with its id before `deadlineMs`; or the holding node did not confirm a `disconnect()` | a longer `deadlineMs`, or answer every request the node sends the device; a disconnect: retry, a dead holder closes on its own |
804
812
  | `X_DEVICE_FRAME_TOO_LARGE` | a device frame, or a `request()` frame, past `DEVICE_FRAME_MAX_BYTES` | split the payload, or store the bytes and send their key |
805
813
  | `X_BUILD_SKEW` | client build's contract is incompatible with the server's | reload the client; see the fix line on the error |
806
814
 
@@ -342,7 +342,7 @@ In a VDOM framework a streaming shell still pays for hydrating the whole tree, w
342
342
  | Async component | `X_ROUTE_ASYNC_PAGE` applies to `Page`, never to what renders under a hole |
343
343
  | A hole's island | hydrates from its chunk: the chunk carries the hydration runtime after its reveal, and the realtime boot if this is the first island that needs it |
344
344
  | A shell island while a hole is open | live: the runtime is `<script type="module" async>`, so it does not wait for parsing to end. With a realtime boot in the document it stays deferred ([Known gaps](Known-Gaps)) |
345
- | Client router | a soft visit reads the whole answer before it swaps ([Known gaps](Known-Gaps)); every reveal still runs |
345
+ | Client router | a soft visit swaps the shell in as soon as it arrives, then fills each hole as its chunk lands, through the same reveal ([Client navigation](Client-Navigation#the-swap)). A click that reuses a prefetch in flight waits for the whole answer: a prefetch reads it whole |
346
346
  | A hand-rolled swap | the reveal is an inline `<script>`, and a document parsed by `DOMParser` or set through `innerHTML` runs none, so its holes keep their fallback. Re-run the scripts, or call `refresh()` / `scheduleRefresh()` from `@ultimat3/render/client`, which the router swaps through (`navigation-swap.ts`'s `runScripts`) |
347
347
  | CSP | every chunk's inline script is a body `inlineScriptSources()` already hashes |
348
348
 
@@ -62,8 +62,10 @@ hashed URL, in `x dev`, the container and `x build --target static` alike.
62
62
  → `src: url("/assets/fonts/inter-var.9c1d2e3f.woff2") format("woff2")`. A missing file or a path
63
63
  outside `assets/` is `X_ASSET_MISSING` at compile time, naming the path — not a Sass stack. The Sass
64
64
  disk cache re-checks every asset a cached sheet named, so a replaced font is never served under its
65
- old hash. Sass has no table without an app loaded, so a unit test that compiles such a sheet
66
- installs one with `setAssetResolver`, as below.
65
+ old hash. In a test process run from the app root, `@ultimat3/testing/preload` installs the app's
66
+ own table (again at every file boundary), so a test importing a module whose sheet calls `asset()`
67
+ compiles it to the URL the app serves, and a missing file is still `X_ASSET_MISSING`. Only a test
68
+ run outside an app root installs one itself, with `setAssetResolver`.
67
69
 
68
70
  ## Served types
69
71
 
@@ -90,7 +92,7 @@ unsatisfiable range gets a `416`. Safari will not play a `<video>` without this.
90
92
 
91
93
  | Question | Answer |
92
94
  |---|---|
93
- | the table | `packages/cli/src/site-assets.ts`: one table per app root, installed into `asset()` by `loadApp` |
95
+ | the table | `packages/render/src/site-assets.ts` (`@ultimat3/render/server`): one table per app root, installed into `asset()` by `loadApp`, and by `@ultimat3/testing/preload` in a test process at an app root |
94
96
  | the route | `packages/cli/src/site-asset-routes.ts`: `GET /assets/*file`, mounted by `assetRoutes()`, which both `x dev` and the container compose |
95
97
  | the export | `writeSiteAssets(root, out)` copies every asset to `out/assets/…/<name>.<hash>.<ext>` |
96
98
  | the helper | `packages/render/src/asset.ts`: `asset()`, `setAssetResolver()`, `assetPathProblem()` |
package/wiki/Testing.md CHANGED
@@ -393,6 +393,30 @@ test('the vendor map renders', async () => {
393
393
 
394
394
  An entry covers the reads after the call and ends with the test; a blank `because` is refused, as in `e2eTest`. Each `goto` now spends five CDP deadlines, not three (`E2E_GOTO_MS`), for the audit's two reads. Source: `packages/testing/src/e2e-a11y.ts` (rules), `e2e-a11y-run.ts` (one test's run), `e2e-a11y-tabs.ts` (raw tabs), `ax-node.ts` (the tree reader).
395
395
 
396
+ ## Passkeys and a second person in the e2e browser
397
+
398
+ `As of 2026-11`. Two free functions over the harness's own objects — `e2eBrowser()` in an app's e2e suite, `openE2eBrowser()` beside it — never a member a hand-rolled tab would lack:
399
+
400
+ ```ts
401
+ import { addVirtualAuthenticator, e2eBaseUrl, e2eBrowser, expect, newBrowserContext } from '@ultimat3/testing';
402
+
403
+ const { page, session } = e2eBrowser();
404
+ const passkey = await addVirtualAuthenticator(page); // CTAP2, resident key, user verified
405
+ // … the app's own register / sign-in buttons run navigator.credentials.create/get, unprompted
406
+ expect((await passkey.credentials()).map((one) => one.rpId)).toEqual(['localhost']);
407
+
408
+ const invitee = await newBrowserContext(session); // no cookie or storage of the first profile
409
+ const tab = await invitee.newTab();
410
+ await tab.goto(`${e2eBaseUrl()}/invite/accept`);
411
+ await invitee.close();
412
+ ```
413
+
414
+ | Call | Is |
415
+ |---|---|
416
+ | `addVirtualAuthenticator(tab, { transport?, residentKey?, userVerified? })` | CDP `WebAuthn` on that tab: `{ id, credentials(), setUserVerified(verified), remove() }`. Per tab, presence simulated; `userVerified: false` makes every user-verification fail. The rp id the ceremony names must be the page's host or a parent domain of it (`login.example.com` may register for `example.com`) and never an IP; locally, serve on `localhost`. `remove()` detaches that authenticator only |
417
+ | `newBrowserContext(session)` | `Target.createBrowserContext`: `{ id, newTab(), close() }`. Its tabs are attached, configured (offline switch, init scripts, `Accept-Language`) and audited as `session.newTab()`'s are; `close()` disposes every tab in it |
418
+ | a tab or session the harness did not build | `X_TEST_FIXTURE_UNAVAILABLE`, naming what it needs |
419
+
396
420
  ## Matchers
397
421
 
398
422
  Installed by the preload on `expect`.
@@ -450,11 +474,17 @@ unitTest('the dashboard counts the posts of the org that is looking', async () =
450
474
  | Answer | Is |
451
475
  |---|---|
452
476
  | `view.html` | the markup, as the document carries it |
453
- | `view.text` | what a reader sees — tags and script/style bodies removed, entities decoded. Compare it with `t('<key>')` |
477
+ | `view.text` | what a reader sees — tags and script/style bodies removed, character references decoded (every numeric one, and the common named ones: `&quot;`, `&apos;`, `&nbsp;`, typographic quotes and dashes …) as a browser reads them; a no-break space is kept. Compare it with `t('<key>')` |
454
478
  | `view.data` · `view.meta` | what `load` resolved, and what `meta` answered for that same object |
455
479
  | `view.islands` | the islands the render emitted. Empty on a page that ships no JavaScript |
456
480
 
457
- `actor` runs `load` and the page inside a request context holding that actor. `renderView` refuses
481
+ `actor` runs `load` and the page inside a request context holding that actor. A `url` whose first
482
+ segment is a routed locale (`https://example.test/es/precios`) renders `load`, `meta` and the page
483
+ in that locale, as the router reads the prefix. Unprefixed and with no `actor`, no request context is
484
+ opened: standalone that is the default locale, inside your own `runWithContext` it is that context's.
485
+ `cookies: { sid: '…' }` runs them inside a GET request for `url` carrying those cookies, read by
486
+ `useRequestCookie(name)` as a browser's are (`As of 2026-11`); with `actor` or a locale prefix too,
487
+ the actor still acts and the locale still holds. `renderView` refuses
458
488
  a component that renders an `island()` — its hydration timing is a route's. `As of 2026-10`.
459
489
 
460
490
  ## Asserting on what an element carries
@@ -623,6 +653,29 @@ What the rendered result is then held to: [Interface rules](Interface-Rules).
623
653
  | `subscribe` | one subscriber's `rows()` `patches()` `settled()` `lsn()` | a replicator |
624
654
  | `seed`, and anything else | the app's own graph | the app's `scripts/test-setup.ts` |
625
655
 
656
+ **Keys and the console: `pressKey(page, key)`, `consoleMessages(page)`, `expectNoConsoleErrors(page)`** (`@ultimat3/testing`). Free functions over the `page` an `e2eTest` or the `{ page }` fixture hands you, so `PageLike` itself does not grow:
657
+
658
+ ```ts
659
+ import { e2eTest, expect, expectNoConsoleErrors, pressKey } from '@ultimat3/testing';
660
+
661
+ e2eTest('the dialog is keyboard-reachable and the page logs no error', async ({ page }) => {
662
+ await page.goto('/settings');
663
+ await pressKey(page, 'Tab'); // a real key: focus moves, Enter submits
664
+ await pressKey(page, 'Control+k'); // a chord: Alt, Control, Meta, Shift held
665
+ await pressKey(page, 'Escape');
666
+ expect(await page.evaluate(() => document.activeElement?.id)).toBe('search');
667
+ await expectNoConsoleErrors(page); // X_E2E_CONSOLE_ERRORS, quoting each
668
+ });
669
+ ```
670
+
671
+ | Call | Answers |
672
+ |---|---|
673
+ | `pressKey(page, key)` | a trusted key press at the focused element: a name in `PRESS_KEYS` (`Tab` `Enter` `Escape` `Backspace` `Delete` `Home` `End` `PageUp` `PageDown` the arrows, `' '`), one ASCII letter or digit, or a chord `Mod+…+key` (`Shift+Tab`, `Control+k`) — Shift makes the key a US keyboard makes (`Shift+1` is `!`), Control/Meta/Alt type nothing. A chord the grammar refuses is `X_SCRAPE_KEY_INVALID` (the one chord grammar, `@ultimat3/scraping`'s); a key it does not know, `X_CDP_CALL_FAILED` |
674
+ | `consoleMessages(page)` | `readonly E2eConsoleMessage[]`, `{ level: 'debug' \| 'log' \| 'info' \| 'warning' \| 'error', text, source: 'console' \| 'exception' }`, since the running test began — each `e2eTest` and each test that takes the `{ page }` fixture starts it, after flushing the previous test's lines in flight — and after one round trip, so a line printed just before is in it. A cross-site iframe's console counts. `text` is the raw arguments joined by a space (no `%d` substitution). The tab keeps 1,000 lines of 2,000 characters at most, dropping the oldest non-error first, so an error survives a noisy page |
675
+ | `expectNoConsoleErrors(page)` | resolves when no `error` arrived since the test began (`console.error`, a failed `console.assert`, an uncaught throw); else `X_E2E_CONSOLE_ERRORS` listing them all. Warnings pass; filter `consoleMessages` for another rule |
676
+
677
+ A page no e2e driver built, or a hand-rolled `E2eBrowserPage` without `press` / `consoleMessages` (with `clearConsole` to start each test's console), is refused by name (`X_TEST_FIXTURE_UNAVAILABLE`). `As of 2026-11`.
678
+
626
679
  **`waitForServiceWorker({ timeoutMs? })` hands the first page over** (25.0.0, #678). The framework's register script runs on `load`, so the first page of a run is committed before its worker activates and `clients.claim()` can miss it: `ready` resolves and no `controllerchange` ever fires. The wait answers `ready`, gives the claim a second (`CLAIM_GRACE_MS`), and reloads an uncontrolled page ONCE — that navigation is answered by the worker — within one budget (`serviceWorkerTimeoutMs`, 10 s, or this call's `timeoutMs`). A page with no worker is refused without a reload, and a reload still uncontrolled is refused saying so (`X_E2E_SERVICE_WORKER_ABSENT`). Proven against a real worker that never claims: `packages/testing/e2e/service-worker-handover.e2e.test.ts`.
627
680
 
628
681
  The last five are **declared, not built**. The framework does not bundle a browser, so the name resolves and asking for it without a driver fails as `X_TEST_FIXTURE_UNAVAILABLE` naming what is missing — different from `X_TEST_FIXTURE_UNKNOWN`, whose fix ("register it") would have the app inventing its own idea of what a page is. A driver installs through the same registry:
@@ -1151,6 +1204,7 @@ shape, same unreached code. `As of 2026-11`.
1151
1204
  | Rule | |
1152
1205
  |---|---|
1153
1206
  | Database | a scratch one with the framework tables and every migration applied; never the developer's. The pass commits, so the tenant proof can read rows after the call |
1207
+ | Services | what a server's boot installs beside its database, over the scratch one: a memory storage disk (unless the app defined its own), the fleet-wide rate-limit store, the fleet-wide auth limiter (`postgresAuthLimiter` per declared policy, so `defineAuth({ rateLimit: { scope: 'shared' } })` is judged, not refused with `X_AUTH_LIMITER_NOT_SHARED`, `As of 2026-11`), and a Web Push runtime whose sends are captured |
1154
1208
  | Rows | one seed graph for the pass, a fresh pair of tenants per primitive in it — the first the actor's (A), the second the tenant proof's intruder (B); every table seeded off its declaration, parents first, same-tenant keys (`x db seed --generate`'s graph). A view and a `readOnly: '<why>'` table get no row; a NOT NULL key into a `readOnly` one is `X_SEED_GRAPH_UNSATISFIED` naming it ([Read-only tables](Entities-And-Migrations#read-only-tables)) |
1155
1209
  | Actor | the entry's `actor` when it declares one, seated in the primitive's tenant — and a top-level value of its bound input — or of its `facts`, a string or an array holding it — equal to the org the entry declared becomes that tenant too, so `input: (drawn) => ({ ...drawn, orgId: '<the actor's org>' })` holds in every tenant the pass seeds; otherwise the first of `x policy explain`'s actors the policy allows, in the primitive's tenant (an `{ input }`-only entry keeps this pick and still binds its input). None allowed is `refused`, by design. Its id has a user's shape: a uuid per role × tenant, the same on every run (`exerciseActorId`), never the role's name. Where the database has `x_users` (the framework schema every pass database is built with) each actor the pass acts as gets its row first — `<id>@exercise.invalid`, its tenant, roles, permissions, scopes — so `findUserById(ctx.actor.id)` finds it; a refused insert is `X_EXERCISE_ACTOR_USER_UNSEATED`. `defineExercise(…, { actor: members })` makes the id a seeded row's key instead (`As of 2026-11-08`) |
1156
1210
  | Input | the override, then an id field whose stem names a seeded entity (`postId` → `posts`), then the schema's minimal draw. A wrong guess shows as `unreached` |
@@ -1268,7 +1322,7 @@ Source: `packages/testing/src/scale-sweep*.ts`, `plan-oracle.ts`, `plan-sweep*.t
1268
1322
  | Sweep | What | Red |
1269
1323
  |---|---|---|
1270
1324
  | scale | every reached primitive once more in a tenant at 2 rows a table, once in one at 8; per statement shape, the counts compared. Each sized seed is written beside the graph before it: row positions (a generated integer, a factory's `index`) continue past that graph's, so ``code: `c${index}` `` on a unique column never repeats the pass's own row | a shape sent more often at 8 than at 2, where it was sent at least once: `X_QUERY_SCALES_WITH_ROWS`, fix `preload()` or `expectedQueryLoop('<why>', fn)`. A shape sent only at 8, nothing else grown, is another path (a branch on the handed row), `unproven` (`As of 31.16.0`); the 8-row graph opens on the 2-row graph's values in every non-unique column, so the handed row is the same at both sizes |
1271
- | plans | every distinct statement whose first relation is an app table, `PREPARE`d and explained as a generic plan with `enable_seqscan`, `enable_bitmapscan` off — and, for a statement with a `Limit`, planned again with `enable_sort` off for its sort alone — in a read-only transaction | `Seq Scan`, or an index scan with no `Index Cond` no `Limit` stops: `X_QUERY_UNINDEXED`. `Sort` under `Limit`: `X_QUERY_SORT_UNSERVED`, on the table its key names. Each prints an `indexes:` entry, one per arm for an `or`; a sort no declarable index serves (an expression, an aggregate, a derived column, keys across tables, mixed directions) or an index the entity already declares prints a rewrite or `expectedSeqScan` instead |
1325
+ | plans | every distinct statement whose first relation is an app table, `PREPARE`d and explained as a generic plan with `enable_seqscan`, `enable_bitmapscan` off — and, for a statement with a `Limit`, planned again with `enable_sort` off for its sort alone — in a read-only transaction | `Seq Scan`, or an index scan with no `Index Cond` no `Limit` stops: `X_QUERY_UNINDEXED`. `Sort` under `Limit`: `X_QUERY_SORT_UNSERVED`, on the table its key names. Each prints an `indexes:` entry, one per arm for an `or`; a sort no declarable index serves (an expression, an aggregate, a derived column, keys across tables, mixed directions) or an index the entity already declares prints a rewrite or `expectedSeqScan` instead. An index WALK that an index the entity already holds would serve (its equality columns, then the order) is green: on a seed of a few rows a partial index such as `where revoked_at is null` costs as little as the keyed one and the generic plan walks it. A schema heuristic, not a promise about production plans: with many revoked rows sharing a key and few active ones, the walk can stay cheaper at volume (`As of 2026-11`) |
1272
1326
 
1273
1327
  With the planner's scans and sorts disabled it picks one only when no index can answer, so the
1274
1328
  verdict reads the schema on empty tables — no volume, no statistics. Never red: `scale.verdict`
package/wiki/Theming.md CHANGED
@@ -228,8 +228,9 @@ brandStyleTag(brand); // '<style>…</style>' — for a page you render yo
228
228
  | `shadows` | `Partial<Record<'light' \| 'dark', Partial<Record<ShadowName, string>>>>` | elevation is themed like colour |
229
229
  | `radius` | `Partial<Record<RadiusName, string>>` | `none sm md lg xl pill full` |
230
230
  | `font` | `Partial<Record<'sans' \| 'mono' \| 'data', string>>` | the font slots |
231
+ | `motion` | `{ duration?: Partial<Record<DurationName, string>>; easing?: Partial<Record<EasingName, string>> }` | the app's own tempo: `t.duration(base)` reads `--duration-base`, so one rung re-times every component. Declaring `--duration-base` with a literal time (`180ms`, `.5s`; lowercase `ms` or `s`) or `cubic-bezier(…)` in a stylesheet is `X_RAW_MOTION`, whose fix names this slot with the value spelled as the slot takes it; a zero (`0ms`) or a plain `var(--…)` read is not reported, but a literal nested in one (`var(--x, calc(180ms * 2))`) is |
231
232
 
232
- Returns a frozen `{ css: string }`. It emits `:root`, `html[data-theme='light']`, the `prefers-color-scheme: dark` block and `html[data-theme='dark']` — radius and font ride `:root` only. Output is ordered by the canonical scale arrays rather than by your object, so re-rendering the same input is byte-identical. Empty input gives `css: ''`, which the framework emits nothing for.
233
+ Returns a frozen `{ css: string }`. It emits `:root`, `html[data-theme='light']`, the `prefers-color-scheme: dark` block and `html[data-theme='dark']` — radius, font and motion ride `:root` only. Output is ordered by the canonical scale arrays rather than by your object, so re-rendering the same input is byte-identical. Empty input gives `css: ''`, which the framework emits nothing for.
233
234
 
234
235
  ### Values are validated, never escaped
235
236
 
@@ -239,12 +240,14 @@ The output can land in a `<style>` element (`brandStyleTag`), so a value that co
239
240
  |---|---|---|
240
241
  | colour | `^\d{1,3} \d{1,3} \d{1,3}$`, each channel ≤ 255 | `#1e6eb2`, `rgb(1,2,3)`, `1 1 1; } html { display: none }` |
241
242
  | radius | `^(0\|\d+(\.\d+)?(px\|rem\|em\|ch\|%))$` | `calc(…)`, `var(…)`, `1` with no unit |
243
+ | duration | `^(0\|\d+(\.\d+)?(ms\|s))$`; `0` is emitted as `0ms`, a unitless zero being no CSS time | `180`, `calc(…)`, `-10ms` |
244
+ | easing | `cubic-bezier(x1, y1, x2, y2)`, numbers only, x1 and x2 in [0, 1] | `ease-in`, `steps(4)`, `cubic-bezier(1.2, 0, 0, 1)` |
242
245
  | font | `^[\w\s,'"-]{1,200}$` | anything with `;` `}` `<` `>` `(` `)` `/` `:` — so `Menlo</style><script>` cannot get through |
243
246
 
244
247
  | Failure | Code | Means |
245
248
  |---|---|---|
246
- | unknown role, radius name or font slot | `X_TOKEN_UNKNOWN` | the key is not in the scale; `cause` lists every name that is |
247
- | known key, unusable value | `X_UI_INVALID_VALUE` | `cause` names the slot and what was expected |
249
+ | unknown role, radius name, font slot, motion scale or rung | `X_TOKEN_UNKNOWN` | the key is not in the scale; `cause` lists every name that is |
250
+ | known key, unusable value — or a `motion`, `duration` or `easing` that is not an object (`null` from JSON) | `X_UI_INVALID_VALUE` | `cause` names the slot and what was expected |
248
251
 
249
252
  ## Resolution and first paint
250
253
 
@@ -151,6 +151,7 @@ One mode per use, and the type holds it: `hrefFor` beside `onCursor`, `onPage`,
151
151
  - **Which list, when.** Records with columns: `DataTable`. Thousands of one-shape rows: `VirtualList` (no script, every row renders; with script, under 100 mounted). Things inside things: `Tree` — `hrefFor` is `<details>` and links at 0 B, `onSelect` is the island's `role="tree"`. What happened: `Timeline` (+ `InfiniteScroll` + `RelativeTime` is the activity feed; there is no feed component). Facts about one thing: `DescriptionList`, never a two-column `Table`.
152
152
  - **Dates are the native input first.** `DatePicker`/`DateRangePicker` are `<input type="date">` with a `Calendar` popover only on a fine pointer with script. A date is a `PlainDate`; a window (`TimeRangePicker`, `timeRangeUrl`) is instants and takes a REQUIRED `timeZone`. Presets are the app's. `Slider` is `<input type="range">`; a segmented control is `Radio appearance="segmented"`; there is no number stepper.
153
153
  - **Reordering is `SortableList` and `Board`, a split is `SplitPane`** — one Pointer Events gesture, never HTML5 drag. A drop calls `onMove` once and is a request: the row holds until it settles, a rejection restores it and says so. `canDrop(item, group)` is the one seam for a WIP limit or a status machine. With `action`, each row is a real `<form>` (Up/Down, or a target `select` per card). The handle alone has `touch-action: none`, so a phone still scrolls from a row's body. `SplitPane` is one column below `md`; `onResize` + `value` is how a split persists — storage is the app's.
154
+ - **Selecting rows is `selection` on `DataTable` and `Board`, one shape for both** (`As of 2026-11`). `selection: { name, form?, value, onChange?, label, matching?, actions? }`. Scripting off, every row is a native checkbox posting its key under `name` in one `form`, and the caller's `actions` in the `BulkBar` submit it. With `onChange`: Shift+click ranges from the last row clicked; on a row's box Down/Up move, Shift+Down/Up extend, Ctrl/Cmd+A ticks the page, Escape clears (the ARIA grid pattern; Space stays the checkbox's); a table adds a tick-all header box; a finger held on a board card ticks it. `value` is a `RowSelection`: `{ kind: 'keys', keys }` or `{ kind: 'matching', filter }`. **"All matching" carries the filter, never ids** — its box posts `matching.filter` under `matching.name`, and a server that receives it re-runs the filter and ignores the keys beside it. A key that left `rows`, or a `matching` from another filter, is pruned through `onChange` (never while a first page loads), and with `onChange` the bar's status region counts the ticked rows still on the list — or, under "all matching", the filter's whole `matching.count`; scripting off it shows no count, which could not follow the boxes. `matching.name` must differ from `name` (`X_UI_INVALID_VALUE`). A `Board` with `action` already draws a `<form>` per card, so its bulk form stands apart from the board, named by `form`, with its submit buttons carrying the same `form`. The bar is `BulkBar`, usable alone.
154
155
  - **What a model wrote is `Markdown`; code is `CodeBlock`; never `innerHTML`.** Raw HTML prints as text, links only http/https/mailto/relative, a remote image prints its alt as a link unless `resolveImage` vouches for it, `baseLevel` defaults to 2. Fences go through `CodeBlock`, highlighted only by the `languages` the caller passes (`allLanguages` on a server page; one named language in an island). Structured payloads are `JsonView`, changes `DiffView` (two texts or a unified patch), structured logs `LogViewer`, terminal output `TerminalView` (SGR colours as roles). A rich-text editor is `Textarea` plus a `Markdown` preview.
155
156
 
156
157
  ## Error codes
package/wiki/Upgrading.md CHANGED
@@ -330,6 +330,7 @@ A setter still on a package's `.` barrel is `X_ADAPTER_PORT_INCOMPLETE` on the `
330
330
  | `x upgrade` stops requiring an `e2e` suite no codemod wrote (**31.47.1**): an app with pages but no `apps/web/site/page.tsx` was left on `X_VERIFY_SUITE_VANISHED`. Rerunning `x upgrade` at the target no longer replays every codemod | nothing: `x upgrade` applies codemod `e2e-suite-floor`, which writes a `page.e2e.test.ts` beside the shortest parameter-free page, or moves `e2e` to `skip` with its why when no page can be visited. To apply codemods an older CLI left behind: `x upgrade codemods --from 0.0.0 --json` |
331
331
  | 24 shipped guards' fixes change (**31.49.0**), built in; their findings do not: `animated-layout-property`, `bare-error`, `error-declared`, `focus-visible`, `image-dimensions`, `island-mount-clears`, `native-confirm`, `raw-breakpoint`, `raw-colour`, `raw-fetch`, `raw-interval`, `raw-length`, `raw-motion`, `raw-shadow`, `raw-z-index`, `repo-await-in-loop`, `repo-raw-sql`, `repo-unbounded`, `runtime-pin`, `semantic-interactive`, `unbounded-fanout`, `undeclared-custom-property`, `undefined-style-class` and `unzoned-date` end their fix on the one step that re-checks it (`then: x verify --only boundaries`) in place of `then: x verify`, which started the whole gate. A copy still in `guards/` keeps the old text until `x upgrade` migrates it to the release after 31.48.0 | nothing |
332
332
  | **Upgrading to the next release: what to check**, in this order. `As of 2026-11-19`; each row below names one check, and [`CHANGELOG.md`](https://github.com/developerz-ai/ultimate/blob/main/CHANGELOG.md)'s `[Unreleased]` carries the detail. Five `app.config.ts` keys that were validated and read by nothing are **read** now (the next row) | run the rows in order, then `x verify` |
333
+ | the shipped `raw-motion` guard's fix changes (**31.50.0**), built in; its findings do not: a stylesheet re-declaring a motion scale property (`--duration-base: 180ms`, `--easing-out: cubic-bezier(…)`) is still `X_RAW_MOTION`, and the fix now names `defineTheme({ motion: { duration: { base: '180ms' } } })` in `apps/web/shared/theme.ts` instead of a token that reads the property itself. A copy still in `guards/` keeps the old text until `x upgrade` migrates it to the release after 31.49.0 | nothing; an app that wants its own tempo moves the declaration into `defineTheme({ motion })` |
333
334
  | `app.config.ts` keys now read (**31.49.0**): `roles` — a `ROLE` it does not list refuses to boot (`X_CONFIG_INVALID`, `meta.key: 'roles'`; `ROLE=migrate` exempt); `database.ssl: true` adds `sslmode=require` on **every** pool — serving roles, `x dev`, migrate, the replicator's `DATABASE_URL` and `REPLICATION_URL`, `x doctor`'s probes, `x db branch`, `x deploy verify` — unless the URL or `PGSSLMODE` states a mode; `cache.defaultTtlMs` sets the boot-built `lru`/`redis` lease (a Redis rung held such values 300 s, now 60 s by default; `0` is refused); `jobs.maxAttempts` (default now `3`, not the documented `5`) and `jobs.backoff` apply to every job declaring no `retry` | `grep -n 'roles\|ssl\|defaultTtlMs\|maxAttempts\|backoff' app.config.ts`. `roles`: every `ROLE` your compose services, Helm values or platform processes start is listed, or drop the key. `ssl: true` against a Postgres without TLS: `database: { ssl: false }` or `?sslmode=disable` in each URL. `defaultTtlMs: 0`: a positive lease. `maxAttempts` / `backoff`: keep them only if they are the retry you want for every job declaring none |
334
335
  | `pwa.enabled`, `pwa.backgroundSync` and `pwa.push` must be real booleans (**31.49.0**), checked even when `enabled` is false: `'false'` used to turn the PWA **on**; a non-list `pwa.categories` / `shortcuts` / `screenshots`, a non-string `neverCache` entry or `site.favicon` are refused too — `X_CONFIG_INVALID` at boot | each a literal `true` or `false` in `app.config.ts`'s `pwa` block |
335
336
  | a records channel keyed by a param that is not the tenant column (a `roomId` topic) delivers a tenanted row only to members of that row's tenant, live and on replay (**31.49.0**); every other member receives the seq alone | nothing, unless a channel deliberately fanned one org's rows out to members of other orgs: that feed needs its own untenanted table or a channel keyed by the tenant column |