@ultimat3/cli 31.49.0 → 31.51.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 (68) hide show
  1. package/CLAUDE.md +1 -1
  2. package/package.json +30 -30
  3. package/src/api-registration.ts +18 -1
  4. package/src/api-routes.ts +1 -0
  5. package/src/app-boundaries.ts +2 -0
  6. package/src/app-dev-imports.ts +77 -0
  7. package/src/app-load-import-chain.ts +112 -0
  8. package/src/app-load-unresolved.ts +173 -16
  9. package/src/app-load.ts +23 -7
  10. package/src/app-openapi.ts +7 -1
  11. package/src/budgets.ts +2 -1
  12. package/src/cmd-i18n.ts +33 -1
  13. package/src/codemods/engine-fs.ts +9 -2
  14. package/src/codemods/merge-drivers.ts +85 -4
  15. package/src/dev-only-imports.ts +59 -0
  16. package/src/error-codes-boundary.ts +2 -0
  17. package/src/evaluated-walk.ts +103 -0
  18. package/src/exercise-services.ts +13 -3
  19. package/src/framework-schema.ts +15 -5
  20. package/src/guard-sources.ts +1 -2
  21. package/src/index.ts +2 -0
  22. package/src/mcp-errors.ts +3 -1
  23. package/src/messages-upgrade.ts +4 -0
  24. package/src/module-imports.ts +26 -15
  25. package/src/page-navigation.ts +5 -2
  26. package/src/page-route.ts +75 -0
  27. package/src/pwa-artifacts.ts +1 -1
  28. package/src/retained-assets-boot.ts +1 -1
  29. package/src/runtime-assets-site.ts +2 -2
  30. package/src/runtime-assets.ts +1 -1
  31. package/src/runtime-render-document.ts +1 -2
  32. package/src/scan-ways.ts +145 -0
  33. package/src/site-asset-routes.ts +2 -2
  34. package/src/site-assets.ts +5 -158
  35. package/src/sw-precache-plan.ts +1 -1
  36. package/src/templates/guard-raw-motion.ts +96 -0
  37. package/src/templates/guard-released-forms.ts +4 -1
  38. package/src/templates/scaffold-repo.ts +1 -1
  39. package/src/test-only-shipped.ts +29 -2
  40. package/src/test-shards.ts +20 -8
  41. package/src/upgrade-coverage-ratchet.ts +95 -0
  42. package/src/upgrade-gate.ts +31 -11
  43. package/src/upgrade-report.ts +14 -0
  44. package/src/verify-checks.ts +7 -3
  45. package/src/verify-e2e.ts +21 -3
  46. package/src/workspace-checks.ts +4 -1
  47. package/wiki/Actions.md +64 -2
  48. package/wiki/Auth.md +6 -2
  49. package/wiki/CLI-Reference.md +8 -2
  50. package/wiki/Client-Navigation.md +34 -4
  51. package/wiki/Configuration.md +2 -1
  52. package/wiki/Entities-And-Migrations.md +12 -2
  53. package/wiki/Home.md +2 -2
  54. package/wiki/I18n.md +1 -1
  55. package/wiki/Interface-Rules.md +3 -1
  56. package/wiki/Known-Gaps.md +1 -1
  57. package/wiki/MCP-And-AI.md +41 -9
  58. package/wiki/Notify.md +4 -2
  59. package/wiki/Outbound-HTTP.md +53 -2
  60. package/wiki/Policies-And-Authz.md +1 -1
  61. package/wiki/Realtime.md +14 -6
  62. package/wiki/Routes-And-Render-Modes.md +1 -1
  63. package/wiki/Static-Assets.md +5 -3
  64. package/wiki/Testing.md +82 -3
  65. package/wiki/Theming.md +6 -3
  66. package/wiki/Troubleshooting.md +1 -1
  67. package/wiki/UI-Components.md +1 -0
  68. package/wiki/Upgrading.md +2 -0
@@ -54,8 +54,9 @@ prefetch: 'intent' }` — only for a GET that does nothing but render.** A plain
54
54
  unprefetched: a modal is often a form, and its GET may prepare one (a draft, a token, a reserved
55
55
  slot). One spelling per meaning: the object takes exactly those two keys and values, anything else
56
56
  is `X_ROUTE_NAVIGATION_INVALID`, and `{ modal: true }` alone is refused — that is `'modal'`.
57
- Declaring any of them on a surface without client navigation refuses the boot
58
- (`X_ROUTE_NAVIGATION_INVALID`).
57
+ A `navigation` key on a page of a surface `navigation.client` does not list is refused at boot,
58
+ since no router runs there — except `'document'`, which asks for the real load such a surface
59
+ already gives and is honoured on every surface (`As of 2026-11`).
59
60
 
60
61
  An opted-in document (every page of the surface except a `'document'` one) carries:
61
62
 
@@ -66,7 +67,9 @@ An opted-in document (every page of the surface except a `'document'` one) carri
66
67
  | `<script src="/_x/assets/navigation/<hash>.js" defer>` | the router: one classic script, content-addressed, `immutable`, `'self'` under the default CSP. `x dev`, the container and `x build --target static` all serve or write it |
67
68
  | `<meta name="ultimate-modals" content='{"routes":[…],"close":"…","loading":"…"}'>` | only on a surface with a `'modal'` route: the modal patterns, most specific first, with `!<pattern>` for a page that outranks one (`/runs/new/peek` over `/runs/:id/peek`), and the frame's two words in the document's locale (`ui.close`, `ui.loading` — override them in the app's catalog). What lets a click open the dialog before the answer ([Modals](#opening-on-the-click)) |
68
69
 
69
- **Budget:** the router is 27,845 B minified (10,094 B gzip) `As of 29.1.0` — 24,448 B (9,028 B
70
+ **Budget:** the router is 32,699 B minified (11,809 B gzip) `As of 2026-11` — 31,904 B (11,507 B
71
+ gzip) before a stream's late fragment, its recovery and keep-alive frames were handled (+795 B);
72
+ 29,955 B (10,817 B gzip) before a soft visit read as it streams (+1,949 B); 27,845 B (10,094 B gzip) at 29.1.0, 24,448 B (9,028 B
70
73
  gzip) before the modal that opens on the click and its popover opening (+3,397 B), and 19,966 B
71
74
  before route-presented modals and navigating from code (+4,092 B, 26.1.0). It is **charged** to
72
75
  every route on the surface, like realtime's page boot, because it is interactivity the app opted
@@ -88,6 +91,15 @@ before any hook, before the handler**:
88
91
  | any router request answered with a 3xx (a form's 303, a sign-in wall, a `load`'s `setRedirect`, an OAuth or payment hop) | any | `204` + `x-ultimate-location: <target>`, cookies kept. The handler ran once; the router follows a same-origin target as its own next request, and hands another origin to the browser. A target that is not `http:`/`https:` (or will not parse) is never handed over: the header names the requested URL instead, as a path |
89
92
  | POST | any | never gated: it is the form's submission |
90
93
 
94
+ A principal is the actor's kind and id, who is really acting (an impersonator), and the actor's
95
+ `orgId` when it has one: the same person in two orgs is two principals, so a soft GET never swaps
96
+ a page rendered in one org into a document of the other, and the client store it fences is never
97
+ shared. The one exception is a POST answered in place: a form that switches org and renders its
98
+ page instead of redirecting is swapped in, since it cannot be repeated; the router then empties
99
+ every tab's cache and stops swapping (the POST row under
100
+ [What happens to the answer](#what-happens-to-the-answer)). An actor with no `orgId` keeps the scope id it had before the org joined it (`As of
101
+ 2026-11`; `packages/core/src/client-scope-id.ts`).
102
+
91
103
  A soft GET across a principal change runs auth and rate-limit **twice** — once before the `204` of
92
104
  the principal row above, once for the real load. Expected and harmless (auth and rate-limit only;
93
105
  the handler and `load` run once), but a tight per-actor rate limit should budget one extra request
@@ -170,6 +182,23 @@ In one order, so no frame is unstyled and no island runs twice:
170
182
  one only the previous page had is removed. Every inline script, head or body, still needs its
171
183
  CSP hash — the router re-inserts the same text, and the policy judges it as on a full load.
172
184
 
185
+ **A `stream` page paints before its slowest hole** (`As of 2026-11`). A soft visit reads the
186
+ answer as it arrives: the swap above runs once the shell is in (the server ends it with a flush
187
+ mark), with each hole's fallback on screen, and on a page (not a modal) `ultimate:navigated` fires
188
+ then, after the shell's scripts and before any hole's. Each hole's chunk is appended to the body as it lands and
189
+ its scripts run — the `$X()` reveal and the hole's own islands — so a hole fills, or shows its
190
+ `error` markup, as on a full load. A link to a fragment the shell does not have (`/feed#post-7`,
191
+ the post inside a hole) is scrolled to when the hole that carries it lands, unless the visitor
192
+ scrolled first. The next swap, or `stop()` (from an `ultimate:navigated` listener too), cancels
193
+ the request: the server aborts each open hole's signal, and a read that passes that signal on
194
+ (`fetch(url, { signal: useContext().signal })`) stops — one that ignores it runs to its end, and
195
+ its result is dropped. Nothing of a page left lands in the next one. A stream that breaks under the
196
+ page on screen is loaded for real (a GET, reloaded when only its fragment differs) or reported as
197
+ `ultimate:navigation-error` (a POST, never re-sent); while the visitor's next page is on its way,
198
+ the break waits for it, and is recovered only if that page never took the tab. A prefetch still
199
+ reads the whole answer, so a click that reuses one in flight waits for every hole; a modal is shown
200
+ whole. Measured: [Known gaps](Known-Gaps).
201
+
173
202
  Inside `document.startViewTransition` when the browser has it and `prefers-reduced-motion` is not
174
203
  `reduce`. Style the transition with the standard `::view-transition-*` pseudo-elements. While it
175
204
  animates the browser hit-tests every press to `<html>` (Chrome does whatever `pointer-events` the
@@ -480,7 +509,7 @@ Dispatched on `document`:
480
509
  | Event | When | `detail` |
481
510
  |---|---|---|
482
511
  | `ultimate:navigate` | before the fetch. **Cancelable**: `preventDefault()` keeps the tab where it is | `{ url, method }` |
483
- | `ultimate:navigated` | after the swap, the scroll and the new scripts — and after a modal opens, its `url` the modal's | `{ url }` |
512
+ | `ultimate:navigated` | after the swap, the scroll and the new scripts — and after a modal opens, its `url` the modal's. On a `stream` page swapped in as a page, the shell's scripts only: each hole's run when its chunk lands, so a hole's element may still be its fallback. A `stream` modal is shown whole, holes included | `{ url }` |
484
513
  | `ultimate:navigation-error` | a POST that failed or could not be shown, a swap that failed on a POST. **Cancelable**: the default is a GET of the current page | `{ url, method, reason }` |
485
514
 
486
515
  The three event names are on `@ultimat3/render/client` too — what an island listens with. The event
@@ -510,6 +539,7 @@ names and attributes are exported from `@ultimat3/render` (`NAVIGATE_EVENT`,
510
539
  | the server gate and the redirect hand-over, counting handler runs | `packages/http/src/navigation.test.ts` |
511
540
  | speculation rules: which pages are candidates, the tag on a router-less document only, the CSP hash of the served bytes | `packages/cli/src/page-speculation.test.ts`, `packages/render/src/speculation-rules.test.ts` |
512
541
  | real pages: prefetch and `'document'` run no `load`, another principal or app is refused, a misplaced key refuses the boot | `packages/cli/src/page-navigation.test.ts` |
542
+ | a soft visit to a `stream` page: the shell before an open hole, the hole filling and hydrating, its error branch, a second navigation cancelling the first | `packages/cli/e2e/stream-hole.e2e.test.ts`, `packages/render/src/navigation-stream.test.ts` |
513
543
  | writes announced after they settle | `packages/core/src/client-writes.test.ts` |
514
544
  | in a real Chrome, through the real pipeline under an enforced CSP: every rule above, counted in route executions | `packages/cli/e2e/client-navigation-*.e2e.test.ts` |
515
545
  | the reference app, opted in: real pages, sign-out, a like after a round trip, the editor as a modal over the feed, scripting off | `examples/dummy/apps/web/e2e/client-navigation.e2e.test.ts` |
@@ -124,7 +124,7 @@ await withReplicaReads(async () => {
124
124
  | `totpReplay` | `TotpReplayGuard` | which TOTP steps are spent, one atomic `claim(subject, step, at)`, called by `completeMfa`. Omitted means the guard the host installed: a framework boot's is `postgresTotpReplayGuard` (`x_totp_steps`), so a code is single-use across the fleet. With no host, `memoryTotpReplayGuard()`, single-use per replica. A guard with no `claim` is `X_CONFIG_INVALID` |
125
125
  | `providers` | `OAuthProviderId[]` | **defaults to `[]`**, `As of 2026-08-23` — an empty list is "no OAuth", and every `/auth/sso/<id>` answers `X_OAUTH_PROVIDER_UNKNOWN`. Never the live registry: that would let any dependency that calls `registerOAuthProvider` turn on a login route this app never enabled |
126
126
  | `link` | `OAuthLinkPolicy` | defaults to `'verified-email'` |
127
- | `passkeys` | `PasskeyPolicyInput` | `{ rpId, origins, rpName?, challengeTtlMs? }` (`As of 2026-11`): the relying party every WebAuthn ceremony verifies against. `rpId` a bare lowercase host, never a URL or an IP; each origin exact (`URL.origin` round-trips it), https or `http://localhost`, on `rpId` or a subdomain; `challengeTtlMs` 5 min. Anything else is `X_CONFIG_INVALID` at `defineAuth`. Absent means no passkeys: `passkeyLogin(auth)` / `passkeyStepUp(auth)` refuse at definition ([Auth](Auth#passkeys)) |
127
+ | `passkeys` | `PasskeyPolicyInput` | `{ rpId, origins, rpName?, challengeTtlMs? }` (`As of 2026-11`): the relying party every WebAuthn ceremony verifies against. `rpId` a bare lowercase host, never a URL or an IP; each origin exact (`URL.origin` round-trips it) with a DNS host — a wildcard `*` matches no origin a browser sends, so it is refused — https or `http://localhost`, on `rpId` or a subdomain; `challengeTtlMs` 5 min. Anything else is `X_CONFIG_INVALID` at `defineAuth`. Absent means no passkeys: `passkeyLogin(auth)` / `passkeyStepUp(auth)` refuse at definition ([Auth](Auth#passkeys)) |
128
128
 
129
129
  There is no `auth.trustedOrigins` in either place, and passkeys are `defineAuth`'s, never `app.config.ts`'s, `As of 2026-11`.
130
130
 
@@ -802,6 +802,7 @@ Rules:
802
802
  | Secrets are env or a mounted file | the framework never talks to a vendor secret API ([axiom 7](Home)) |
803
803
  | `env.X` reads through `defineEnv`'s schema | a declared key that is missing or malformed is `X_ENV_MISSING` at boot, every offender in one error. A `process.env` read outside the schema is a lint error, never a runtime one |
804
804
  | `X_CONFIG_INVALID` is env **and** `app.config.ts` | one code for a configuration that cannot boot: what `defineConfig`'s own validation throws — a bad locale or two spellings of one, an unknown time zone, a section or list of the wrong shape (`jobs: null`), a value outside its closed set (`roles`, `jobs.backoff`, `theme.defaultMode`), a switch that is not a boolean (`database.ssl: 'false'`), `jobs.concurrency < 1`, a removed key such as `realtime.transport`, a `cache.tiers` entry the environment cannot supply — and any env **combination** no boot can resolve, thrown by the selector that reads it. Both CDN pairs or half a pair (`selectPurgeDriver`), more than one of `SMTP_URL` / `RESEND_API_KEY` / `SES_REGION`, or a transport with no `MAIL_FROM` (`selectMailDriver`), or `REPLICATION_URL` naming a different host, port or database than `DATABASE_URL` (`selectChangeFeed`) |
805
+ | Required where it is needed | `role: 'sync'` (or a list) requires a key only on that role; `required: false, requiredIn: ['staging', 'production']` is optional except in those environments (`ULTIMATE_ENV`, else `NODE_ENV`), so a deploy cannot boot without it and a laptop or test run reads `undefined` (`As of 2026-11`). An environment no reader can name is a deploy: required. A `default` still answers an absent key first, and a `role` still narrows it. `describeEnv` reports it as `requiredIn`. `required: false` is optional everywhere |
805
806
  | `X_ENV_MISSING` is one key, `X_CONFIG_INVALID` is the shape | absent or malformed key → `X_ENV_MISSING` at the `defineEnv` gate. Keys that each parse but contradict each other → `X_CONFIG_INVALID`. The two never overlap |
806
807
  | No runtime mutation | config is frozen after `defineConfig`; there is no `setConfig` |
807
808
  | Same image, all environments | only env differs. That is what makes staging a real rehearsal ([Deployment](Deployment)) |
@@ -145,15 +145,25 @@ migration or a psql session can violate.
145
145
  | Written as | Reaches SQL | Note |
146
146
  |---|---|---|
147
147
  | `c.title.trimmed().minLength(1)` · `c.likeCount.atLeast(0)` · `c.email.contains('@')` · `c.a.eq(c.b)` · `c.flag.isTrue()` · `c.publishedAt.isNull()` / `.isNotNull()` | yes | `CHECK`. `trimmed()` strips leading and trailing **spaces** only, as one-argument `btrim` does — a tab is a character on both sides. `atLeast` / `eq(<number>)` compare the number the column holds, so a `bigint()` or `decimal()` row (a decimal string) is judged by its digits |
148
- | `iff(c.status.eq('published'), c.publishedAt.isNotNull())` | yes | `(a) = (b)` — a rule that holds *exactly when* another does. The **one** combinator: `and`/`or`/`not` are deliberately absent |
148
+ | `iff(c.status.eq('published'), c.publishedAt.isNotNull())` | yes | `(a) = (b)` — a rule that holds *exactly when* another does |
149
+ | `allOf(c.a.isNull(), c.b.isNull())` · `anyOf(c.a.isNull(), c.b.isNull())` | yes | `(a) and (b)` / `(a) or (b)`, two or more operands, three-valued as SQL's (`As of 2026-11`): "both unset", "at most one set". Two invariants are already a conjunction; `allOf` is for where ONE predicate must say it — an index `where: (c) => allOf(…)`, or inside `anyOf`/`iff`. One app-only operand makes the whole rule `sql: null`; a `unique` operand, or fewer than two, is `X_INVARIANT_VIOLATED`. `not` stays absent: `isNull`/`isNotNull` are the negations a CHECK needs |
149
150
  | `c.unique(['orgId', 'userId'])` | yes | `UNIQUE`, not a CHECK — a single row cannot see a duplicate |
150
151
  | `c.slug.matches(SLUG_PATTERN)` — a **`RegExp`** | yes | `slug ~ '…'` |
151
152
  | `c.slug.matches(isValidSlug)` — a **function** | **no** | `sql: null` |
152
153
  | `c.satisfies(fn, ['status', 'publishedAt'])` | **no** | `sql: null`, by construction — a JS function over several columns |
153
154
 
155
+ **A patch is refused as the row would be.** `insert` judges the whole row before its statement; an
156
+ `update` or `updateWhere` patch only becomes a row on the server, so there the CHECK judges first,
157
+ and its `23514` on a rule this entity declares answers `X_INVARIANT_VIOLATED` naming that rule (a
158
+ 422), the same as `insert`. A CHECK no invariant declares stays `X_DB_STATEMENT_FAILED`. As of
159
+ 2026-11; before it a refused patch was a 500.
160
+
154
161
  **A rule over a nullable column passes `NULL`, in the app as in the CHECK.** Every operator but
155
162
  `isNull()`/`isNotNull()` answers SQL's *unknown* for a NULL operand, in TypeScript too, and a rule
156
- holds unless it is false — so `c.slug.matches(SLUG_PATTERN)` on a `.nullable()` slug accepts a
163
+ holds unless its FINAL verdict is false. That is per comparison: a composite decides by its own
164
+ three-valued logic, so `allOf(c.a.eq(1), c.b.eq(1))` refuses `a = NULL, b = 2` (false beats
165
+ unknown) while `anyOf(c.a.eq(1), c.b.eq(1))` passes it (no operand true, one unknown) — in both
166
+ halves. So `c.slug.matches(SLUG_PATTERN)` on a `.nullable()` slug accepts a
157
167
  NULL in `$assert`, the memory driver and Postgres alike (`invariant-null.test.ts`, every operator on
158
168
  PGlite). To refuse NULL, declare the column NOT NULL or add `.isNotNull()`. As of 31.3; before it
159
169
  the app refused the NULL its CHECK stored.
package/wiki/Home.md CHANGED
@@ -108,7 +108,7 @@ Follow in order. Each page states what it was executed against in its own first
108
108
  | [I18n](I18n) | flat catalogs, loud misses, locale routing, `hreflang` |
109
109
  | [Theming](Theming) | 24 semantic colour roles as RGB channels, every token scale, breakpoint and layout mixins, `defineTheme()`, what contrast is gated |
110
110
  | [Interface rules](Interface-Rules) | how a screen must behave, and which of the app's `guards/` refuses each rule |
111
- | [UI components](UI-Components) | the four page composites, and the generated catalog of 99 source-derived UI components |
111
+ | [UI components](UI-Components) | the four page composites, and the generated catalog of 100 source-derived UI components |
112
112
  | [Timezones and dates](Timezones-And-Dates) | store UTC, format with an explicit IANA zone, frozen clocks in tests |
113
113
  | [Money](Money) | `Money = { minor, currency }`, never a float |
114
114
  | [Outbound HTTP](Outbound-HTTP) | `outbound()`: one vendor call with a whole-call deadline, the caller's signal, safe-only retry, idle and byte bounds, `dial: 'public'` pinning, and `breaker()` |
@@ -157,6 +157,6 @@ Follow in order. Each page states what it was executed against in its own first
157
157
  | [`docs/ops/`](https://github.com/developerz-ai/ultimate/tree/main/docs/ops) | running an app for real: the PaaS → Compose → Kubernetes ladder, secrets, observability, datastore sizing, disaster recovery, runbooks. **Recommendations only** — the framework depends on none of it |
158
158
  | [`docs/idea/16-app-targets.md`](https://github.com/developerz-ai/ultimate/blob/main/docs/idea/16-app-targets.md) | three targets, one backend, two view layers — **design only, not shipped behaviour** |
159
159
  | [`docs/idea/17-scale-ladder.md`](https://github.com/developerz-ai/ultimate/blob/main/docs/idea/17-scale-ladder.md) | why the app code is identical at rung 0 and rung 4 — **shipped, not design only**: all 26 seam rows are marked shipped, rungs 0–2 are real, and the places the invariant breaks today are named |
160
- | [`packages/ui/CATALOG.md`](https://github.com/developerz-ai/ultimate/blob/main/packages/ui/CATALOG.md) | the full catalog of 99 source-derived UI components with every prop, generated from source and drift-tested |
160
+ | [`packages/ui/CATALOG.md`](https://github.com/developerz-ai/ultimate/blob/main/packages/ui/CATALOG.md) | the full catalog of 100 source-derived UI components with every prop, generated from source and drift-tested |
161
161
  | [`framework.manifest.json`](https://github.com/developerz-ai/ultimate/blob/main/framework.manifest.json) | every package, tier, and `X_*` code with its owner — generated |
162
162
  | [llms.txt](https://github.com/developerz-ai/ultimate/blob/main/llms.txt) | the machine-readable repo map for agents |
package/wiki/I18n.md CHANGED
@@ -134,7 +134,7 @@ framework's diagnostic text changes without a semver signal, the rule names do n
134
134
  | Command | Does |
135
135
  |---|---|
136
136
  | `x i18n add <locale>` | create `catalogs/<locale>.json` seeded with every default-locale key, each value copied inside `⟦…⟧` |
137
- | `x i18n sync <locale>` | add keys the locale is missing; a key it already has is never overwritten, translated or not; never deletes |
137
+ | `x i18n sync <locale>` | add keys the locale is missing; a key it already has is never overwritten, translated or not; never deletes. An admin key it adds that the default locale's file lacks is added there too, with the string that locale renders, so every catalog keeps one key set |
138
138
  | `x i18n check --json` | extract keys from source, diff against every catalog and against `en`, report missing / unused / dynamic / slot mismatch / untranslated |
139
139
 
140
140
  Every command supports `--json`. `add` and `sync` copy the source value inside the marker, so the text sits where the translation goes and `x i18n check` counts the key as missing until a person replaces it. Source means every shape below; a key only a mail or a push names is a key.
@@ -47,6 +47,8 @@ noticed.
47
47
  | A refetch keeps the previous data on screen | `asyncStateOf` — `loading` beside a defined `data` is `refreshing`, never `pending` |
48
48
  | A failure beats stale data: report the error, do not re-render rows the failed request did not answer | `asyncBranch` tests `failed` first |
49
49
  | Placeholder, error, empty and content land in the same box | `reserveBlockSize` is emitted as `--async-reserve` on the region in every branch |
50
+ | A person never reads a shell command: a failure in a page for an end user is the app's own screen | **judgement**: supply `AsyncRegionProps.failed(error, retry)` on every end-user page; it replaces `ErrorState` (code, cause, fix — the developer's report) on that branch. Nothing enforces it: a page that omits `failed` still typechecks and renders `ErrorState` with its shell fix, `As of 2026-11` |
51
+ | A state's title is in the outline when it is a destination | `EmptyState` and `Alert` take `level` (1-6): the title is `role="heading"` with that `aria-level` — an outline entry without six per-level templates in every island; absent, a paragraph |
50
52
  | The region carries `aria-busy` while in flight | `AsyncRegion` derives it from `isBusyBranch` |
51
53
  | `data: undefined` means nothing has arrived. An empty array is data | `asyncStateOf` |
52
54
  | A `{ total: 0, items: [] }` envelope passes its own `isEmpty` — `isEmptyData` does not guess at an envelope | `AsyncRegionProps.isEmpty` |
@@ -267,7 +269,7 @@ Biome does not read `.scss`. These seven guards are the only thing that does. `A
267
269
  | A viewport query names a rung of the one ladder | `guards/raw-breakpoint.ts` — `@media` with a `width` feature | `@include tokens.respond-to(md)` / `respond-down(md)` / `respond-between(md, lg)` |
268
270
  | A layer is a name | `guards/raw-z-index.ts` — a number in `z-index` | `z-index: tokens.z(dropdown)`; behind its own stacking context, `calc(-1 * #{tokens.z(raised)})` |
269
271
  | Elevation comes off the themed shadow scale | `guards/raw-shadow.ts` — a hand-written length in `box-shadow`, `text-shadow` or `drop-shadow()` | `box-shadow: tokens.shadow('sm')`, or `@include tokens.surface` |
270
- | One tempo | `guards/raw-motion.ts` — a duration or `cubic-bezier()` literal in `transition*` / `animation*`, or assigned to a custom property (`--ease: cubic-bezier(…)`) | `transition: opacity tokens.duration(fast) tokens.easing(out)`; in a custom property, interpolated: `--ease: #{tokens.easing(out)}` |
272
+ | One tempo | `guards/raw-motion.ts` — a duration or `cubic-bezier()` literal in `transition*` / `animation*`, or assigned to a custom property (`--ease: cubic-bezier(…)`) | `transition: opacity tokens.duration(fast) tokens.easing(out)`; in a custom property, interpolated: `--ease: #{tokens.easing(out)}`; the app's own tempo for a rung (`--duration-base: 180ms`): `defineTheme({ motion: { duration: { base: '180ms' } } })` |
271
273
  | A class a component reads is a class its sheet compiles | `guards/undefined-style-class.ts` — `styles.x` / `styles['x-y']` against the COMPILED `.module.scss` | the nearest class the sheet declares, or the rule to add |
272
274
  | A custom property a sheet reads is one the app declares | `guards/undeclared-custom-property.ts` — `var(--x)` in the compiled CSS with no declaration anywhere and no fallback | the steps the scale really has: `tokens.space(7)` → `0 \| 1 \| 2 \| …` |
273
275
  | A guard that reads compiled sheets never passes by reading nothing | `guards/undeclared-custom-property.ts` and `guards/undefined-style-class.ts` — a sheet that does not compile, or an imported one that does not exist, is a finding quoting the compiler's first line; while one is broken, no `var()` read is judged | repair the Sass at the error quoted |
@@ -75,7 +75,6 @@ Each of these is a defect, or a target, somebody has already argued about, and t
75
75
  | A local `typecheck` step can report green on a tree CI fails, on the same commit — **one sighting, unreproduced** | `As of 2026-10`. Observed once (2026-09-17, TypeScript 7.0.2): after a `git stash -u` → branch switch → `x verify` on the other branch → switch back → `stash pop` sequence, a type error that surfaces in an UNCHANGED file (a widened index signature in a file it imports) passed locally and failed CI; deleting `tsconfig.tsbuildinfo` then reproduced CI's red locally. Five faithful reproduction attempts against 7.0.2 all stayed correctly red ([#450](https://github.com/developerz-ai/ultimate/issues/450)). **[#450](https://github.com/developerz-ai/ultimate/issues/450) itself is closed `As of 2026-09-23`** — read from the shipped fix, not from the tracker: plan 101 row 14 r ("Close #450", `docs/plans/2026/09/23/101-framework-deep-sweep/14-guards-gate.md:37`; plan `status.yml` `complete`), recorded in `CHANGELOG.md` under 22.0.0 and pinned by `packages/cli/src/verify-typecheck.test.ts`. `tsc -b` decides "up to date" by **mtime**, and Bun installs a dependency as **hardlinks** carrying its cache's old mtimes, so an upgrade to an already-cached version left every input older than the buildinfo and a root without `references` — every scaffolded app — skipped the program and reported green while a cold CI was red. A scaffolded app's `typecheck` is now `tsc -p .` ([`packages/cli/src/templates/scaffold-repo.ts`](https://github.com/developerz-ai/ultimate/blob/main/packages/cli/src/templates/scaffold-repo.ts), its `"typecheck"` script), which is incremental by **content hash**, and `x verify`'s `typecheck` step picks `-p .` over `-b` for any such root ([`packages/cli/src/verify-typecheck.ts`](https://github.com/developerz-ai/ultimate/blob/main/packages/cli/src/verify-typecheck.ts)); the framework root keeps `-b`. **Still open**: a *second* `tsc` racing the same buildinfo is the one suspect not excluded, and no cause for it has been shown. `x verify` has no `--cold` flag: one sighting, and five faithful reproductions stayed red. **Why it stays** (`As of 2026-11-18`): There is no cause to fix: the one known mechanism is fixed, and no reproduction of the remainder exists. CI, always cold, is the judge of record. **Do instead:** CI is always cold and is the judge of record. If a local `typecheck` disagrees with it again, capture the command, its argv and its exit code before deleting any `tsconfig.tsbuildinfo`. |
76
76
  | A `stream` page with a realtime island keeps every island on the page inert until its slowest hole closes | `As of 2026-11-02`. The runtime goes `async` so a shell island answers while a hole is open, but only with no realtime boot in the document: the boot (`script defer`) has to run first (`bootScript`, [`packages/cli/src/route-islands.ts`](https://github.com/developerz-ai/ultimate/blob/main/packages/cli/src/route-islands.ts)), and a deferred script waits for parsing to end. Bound by the hole's 15 s deadline. **Why it stays** (`As of 2026-11-18`): The realtime boot has to run before the hydration runtime (`streamScripts`, `packages/cli/src/route-islands.ts`), or an island mounts over a store not yet restored, and a deferred script waits for parsing to end. `DEFAULT_HOLE_TIMEOUT_MS` bounds the wait. **Do instead:** keep the slow read out of such a page's holes, or give it a short deadline of its own: `fetch(url, { signal: AbortSignal.timeout(2_000) })`. |
77
77
  | An open tab can meet a dead island across a deploy | `As of 2026-11-12`. A web process serves only the hashed files it built, so with `assets.retain` unset (the default) a tab holding the previous build's document gets a `no-store` 404 for its stylesheet, or for its island chunk on the first click, after every deploy; during a rolling update a new document that reaches an old pod gets no stylesheet either. What the framework does about the stylesheet half without a window: a soft navigation whose next sheet fails never swaps an unstyled page in (a GET becomes a full load, the old sheet stays) [pin](https://github.com/developerz-ai/ultimate/blob/main/packages/render/src/navigation-stylesheet-skew.test.ts#a%20GET%20is%20loaded%20by%20the%20browser%3B%20the%20page%20on%20screen%20keeps%20its%20sheet); a full load whose sheet 404s stays unstyled — the framework does not reload it, as a reload it cannot tell from a missing file offline or under a test harness is a navigation nobody asked for. A web role booted outside development and test with no window logs `X_ASSET_RETAIN_UNDECLARED` [pin](https://github.com/developerz-ai/ultimate/blob/main/packages/cli/src/retained-assets-boot.test.ts#undeclared%3A%20nothing%20is%20published%20and%20there%20is%20no%20reader). Declared, a tab survives six deploys with build 0's island alive [evidence](https://github.com/developerz-ai/ultimate/blob/main/packages/cli/e2e/six-deploys.e2e.test.ts#with%20assets.retain%2C%20the%20click%20boots%20build%200%E2%80%99s%20island%3A%20its%20chunk%20200%2C%20no%20404%2C%20an%20update%20offered) **Why it stays** (`As of 2026-11-18`): Retention needs a disk every web pod reads, and only the app can name one. Undeclared, boot says so by code. **Do instead:** declare `assets: { retain: { disk, builds } }` over a disk every web pod reads → [Deployment](Deployment#hashed-assets-across-a-deploy--assetsretain) |
78
- | A soft visit waits for the slowest hole | `As of 2026-11-02`. The client router reads `response.text()` ([`packages/render/src/navigation-fetch.ts`](https://github.com/developerz-ai/ultimate/blob/main/packages/render/src/navigation-fetch.ts)) and swaps the whole answer, so holes fill through the re-run scripts and the first paint of an in-app navigation is as late as a full `ssr` render. A full load streams. No incremental parse here [pin](https://github.com/developerz-ai/ultimate/blob/main/packages/render/src/navigation-fetch.test.ts#a%20page%3A%20its%20text%2C%20its%20build%2C%20no-store%20read%20off%20cache-control) **Why it stays** (`As of 2026-11-18`): The router swaps one whole answer, so head, scripts and holes land together. The extension point is the route's `navigation` declaration. **Do instead:** nothing to do in an app; a page that must paint first on a soft visit declares `navigation: 'document'`. |
79
78
  | A job's `runAt` is stamped from the enqueuer's clock | `As of 2026-10`. An enqueuer running ahead of the database delays its own "immediate" jobs; up to 1 s ahead still wakes a worker, beyond that the job starts on the poll. A delayed job enqueued by another process starts within the idle ceiling after its `runAt` — 5 s with a proven wake, 2 s without; only a retry or a sleep the worker itself handed back gets a due-time timer. **Why it stays** (`As of 2026-11-18`): `runAt` comes from the injected `Clock` (`packages/jobs/src/driver-pg.ts`, `enqueue-record.ts`), the one a frozen-clock test drives and the outbox stamps at stage time, before any row exists. A database clock would split those. **Do instead:** NTP on every pod; for a deadline tighter than the ceiling, enqueue at the moment the work is due rather than with `runAt`. |
80
79
  | The CDP driver cannot PIN a name, and a page's WebSocket is not screened at all | `As of 2026-11`. Measured on Chrome 150 with `localBrowser()`: interception (page-level and the browser-level `Fetch` that now covers popups) never pauses a WebSocket handshake, so `new WebSocket('ws://off-list/…')` from a scraped page connects. Since 31.0.0 a host a wildcard admitted is resolved before the browser leg releases it, and an inward or unresolvable answer is refused (`packages/scraping/src/browser-dial.ts`). But the browser then resolves again for itself, so a name that answers public to the screen and private to Chrome (DNS rebinding) is reached — the HTTP leg and the robots read resolve and pin (`packages/scraping/src/pinned-host.ts`), the browser cannot be pinned through this port — [pin](https://github.com/developerz-ai/ultimate/blob/main/packages/scraping/src/cdp-arm-dial.test.ts#a%20screened%20name%20is%20continued%20by%20request%20id%20only%2C%20never%20pinned%20to%20the%20approved%20address) **Why it stays** (`As of 2026-11-18`): Interception never pauses the handshake and this port cannot hand Chrome a resolved address, so no driver code closes it. The boundary that can is the network's: the `egress` proxy. **Do instead:** list exact hosts rather than `'*'` on a scrape that runs where private addresses are reachable, and dial a scrape through an `egress` proxy outside that network. |
81
80
  | `ScrapeReport.usage.bytesIn` counts the HTTP leg only | `As of 2026-10`. The CDP port subscribes to requests, not to their sizes, so the browser leg's bytes are not in the figure (`packages/scraping/src/usage.ts`) **Why it stays** (`As of 2026-11-18`): The field is defined as the HTTP leg (`packages/scraping/src/usage.ts`): this port sees requests, not sizes, and a browser figure would be a guess. The extension point is the resolver's `cost`. **Do instead:** treat `bytesIn` as a lower bound; a provider's own byte count, returned through the resolver's `cost`, is the billable one. |
@@ -169,6 +168,7 @@ the release that fixed it. Upgrading is the fix, and the breaking entries are th
169
168
 
170
169
  | Gap | Fixed in | If you are pinned below that |
171
170
  |---|---|---|
171
+ | A soft visit waited for the slowest hole | **31.50.0** | The client router read the whole answer before swapping, so an in-app navigation to a `stream` page painted as late as a full `ssr` render. It now reads the answer as it arrives: the shell is swapped in at the server's first flush mark, and each hole fills as its chunk lands, through the same `$X()` reveal and scripts a full load runs; a newer navigation cancels the request, so the server aborts each hole's signal and a read that honours it stops. A click that reuses a prefetch still in flight waits for the whole answer, as a prefetch reads it whole. Measured on a page with holes at 300 ms, 1 s and 2 s, 20 soft visits in Chrome: the shell paints at 65 ms p95 (2,041 ms before), the last hole at 2,026 ms p95 (2,045 ms before) — the gain is the slowest hole, 1,976 ms. The router grows by 1,949 B minified (691 B gzip) [pin](https://github.com/developerz-ai/ultimate/blob/main/packages/cli/e2e/stream-hole.e2e.test.ts#a%20soft%20visit%20paints%20its%20shell%20while%20the%20hole%20is%20open%3B%20the%20hole%20then%20fills%20and%20hydrates). Below it: a page that must paint first on a soft visit declares `navigation: 'document'` |
172
172
  | A queued offline write was not bound to its principal on the server: a second tab's sign-in could send it as the new session | **31.47.0** | A replay now names its queue's principal in `x-ultimate-replay-scope`, and the action route refuses any other session with `409 X_REPLAY_PRINCIPAL_MISMATCH` before the body is read. The entry stays `pending` for its owner, as it does on a 401 to a signed-in queue, and is sent when that account is back; entries stored by older builds are bound by the queue that holds them [pin](https://github.com/developerz-ai/ultimate/blob/main/packages/realtime/src/page-outbox-principal.test.ts#the%20entry%20behind%20the%20one%20on%20the%20wire%20is%20refused%2C%20kept%2C%20and%20sent%20once%20its%20owner%20is%20back). Loading a page as another account still wipes the queue, deliberately. Below 31.47.0: sign out by full navigation, and do not share a browser profile between accounts with offline writes queued |
173
173
  | A browser's own `<form method="post">` to an action got JSON back on a refusal — `setRedirect` covered success only (deferred by plan 101: 234 wrapper calls in 142 files of one app) | **31.11.0** | `action({ native: { success, refusal? } })`: a `303` either way, the outcome in a one-read flash `useActionAnswer()` reads in `load`; a `page.tsx` form posting to an action without it is an `X_NATIVE_FORM_UNANSWERED` warning ([Actions](Actions#native-forms-native)). Below it: `if ((useRequestHeader('accept') ?? '').includes('text/html')) setRedirect(next)` in `handle` (both from `@ultimat3/http`) answers success; a refusal still answers the error page |
174
174
  | `bun run error-render` could not see a `catch (error)` binding | **8.0.0** | The gate matched a **parameter** annotated `unknown`/`any`; a `catch (error)` binding is `unknown` by inference and carries no annotation, which is how `String(error)` echoing a caller's request body into a 422 `cause:` stayed green in `packages/http/src/request.ts` through 3.0.0. `error-render` now joins `catchRenderFindings` ([`scripts/catch-render.ts`](https://github.com/developerz-ai/ultimate/blob/main/scripts/catch-render.ts)), which reads the catch binding and a `.catch((error: unknown) => …)` callback; its header lists what it still cannot see (a helper in a third file, a field laundered by another package). Below it: review every `catch` by hand — a caught value reaches a `cause:`/`fix:` only through `renderThrowable(error)` from `@ultimat3/core` |
@@ -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()` |