@ultimat3/cli 31.14.0 → 31.16.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 (69) hide show
  1. package/CLAUDE.md +1 -1
  2. package/README.md +3 -2
  3. package/package.json +29 -29
  4. package/src/budgets-requests.ts +37 -0
  5. package/src/budgets.ts +20 -1
  6. package/src/cmd-doctor.ts +47 -37
  7. package/src/cmd-exercise.ts +14 -1
  8. package/src/cmd-upgrade.ts +19 -2
  9. package/src/coverage-floor.ts +2 -2
  10. package/src/dev-boot.ts +2 -2
  11. package/src/dev-route-table.ts +5 -9
  12. package/src/doctor-env-reserved.ts +111 -0
  13. package/src/doctor-floor.ts +62 -0
  14. package/src/doctor-pins.ts +101 -0
  15. package/src/doctor-probe.ts +21 -1
  16. package/src/doctor-row-security.ts +119 -4
  17. package/src/doctor-warnings.ts +55 -0
  18. package/src/document-options.ts +0 -7
  19. package/src/error-codes-doctor.ts +24 -0
  20. package/src/error-codes.ts +5 -0
  21. package/src/exercise-floor-report.ts +138 -0
  22. package/src/exercise-floor-verdict.ts +98 -0
  23. package/src/exercise-floor.ts +158 -0
  24. package/src/island-bundle.ts +52 -12
  25. package/src/island-disposer.ts +1 -1
  26. package/src/island-group-cache.ts +4 -0
  27. package/src/island-link-check.ts +73 -0
  28. package/src/island-vendor.ts +183 -0
  29. package/src/mcp-errors.ts +11 -1
  30. package/src/messages-upgrade.ts +13 -0
  31. package/src/messages.ts +3 -0
  32. package/src/prerender.ts +7 -7
  33. package/src/route-islands-preload.ts +54 -11
  34. package/src/runtime-admin.ts +2 -4
  35. package/src/runtime-render-document.ts +34 -13
  36. package/src/runtime-render.ts +58 -30
  37. package/src/serve-web.ts +8 -11
  38. package/src/static-images.ts +25 -4
  39. package/src/static-precompress.ts +57 -0
  40. package/src/style-bundle.ts +28 -6
  41. package/src/templates/guard-island-mount-clears.ts +151 -0
  42. package/src/templates/island.ts +8 -7
  43. package/src/templates/resource-form-island.ts +12 -9
  44. package/src/templates/scaffold-docs.ts +1 -0
  45. package/src/templates/scaffold-guards.ts +4 -1
  46. package/src/templates/scaffold-shell.ts +12 -9
  47. package/src/templates/scaffold-verify-floor.ts +4 -0
  48. package/src/test-dotenv.ts +15 -2
  49. package/src/theme-brand.ts +18 -20
  50. package/src/upgrade-coverage.ts +109 -0
  51. package/src/upgrade-document.ts +18 -0
  52. package/src/upgrade-exercise-floor.ts +53 -0
  53. package/src/upgrade-gate.ts +68 -25
  54. package/src/upgrade-guards.ts +159 -0
  55. package/src/upgrade-report.ts +29 -1
  56. package/src/verify-checks.ts +3 -1
  57. package/src/verify-floor.ts +13 -0
  58. package/wiki/CLI-Reference.md +26 -3
  59. package/wiki/Client-Data.md +52 -0
  60. package/wiki/Configuration.md +17 -0
  61. package/wiki/MCP-And-AI.md +42 -1
  62. package/wiki/Notify.md +6 -0
  63. package/wiki/PWA-And-Offline.md +11 -0
  64. package/wiki/Realtime.md +4 -3
  65. package/wiki/SEO.md +1 -1
  66. package/wiki/Static-Assets.md +30 -3
  67. package/wiki/Testing.md +64 -2
  68. package/wiki/Theming.md +6 -6
  69. package/wiki/Upgrading.md +11 -0
@@ -66,6 +66,19 @@ None of them is exposed in `ROLE=web`. `db.query` accepts one statement, whose l
66
66
 
67
67
  **`bunx @ultimat3/cli`, never `bunx x`, in a client config.** A client may spawn the command outside the installed app, and there `bunx x` fetches an unrelated npm package named `x`. Inside an app's shell, `bunx x` resolves the app's own CLI. `scaffold-mcp-json.test.ts` pins the spelling, and CI's `scaffold-smoke` spawns the file's own command and asks it `initialize` and `tools/list` on every push.
68
68
 
69
+ ### The stdio wire
70
+
71
+ `x mcp serve --transport stdio` speaks newline-delimited JSON-RPC (`packages/mcp/src/transport-stdio.ts`).
72
+ `As of 31.15.0`:
73
+
74
+ | Rule | Detail |
75
+ |---|---|
76
+ | no call blocks another | each request is dispatched without waiting for the one before; answers are written one at a time, never interleaved |
77
+ | at most 16 at once | `STDIO_MAX_IN_FLIGHT`; past it a request waits in a queue of 64 (`STDIO_MAX_QUEUED`), and only a full queue stops the reader |
78
+ | `ping` is always answered | it never queues, so a busy server still says it is alive |
79
+ | `notifications/cancelled` aborts the named call | heard at the cap too: the tool's `ctx.signal` (a hand-written tool: `handle`'s optional third argument) aborts, a queued request never runs, and a cancelled request gets no answer |
80
+ | one message ≤ `lineLimitBytes` | 1 MiB by default, counted in BYTES before decoding; an over-long line is one `-32600` `X_MCP_BODY_TOO_LARGE` frame |
81
+
69
82
  ### Rate limits on the HTTP transport
70
83
 
71
84
  **Enforced `As of 2026-08-24`.** `mcpHttpRoute` meters itself, per caller, per class, per minute. It has to: all MCP traffic is one `POST /mcp`, so the HTTP pipeline's own buckets — which key on the route — cannot tell an `initialize` handshake from a migration.
@@ -74,7 +87,7 @@ None of them is exposed in `ROLE=web`. `db.query` accepts one statement, whose l
74
87
  |---|---|---|
75
88
  | `read` | 120 / minute | every method that is not `tools/call`, plus any tool that does not declare `destructive: true` |
76
89
  | `write` | 20 / minute | a `tools/call` naming a `destructive: true` tool, and **any call this server cannot resolve** — fail-closed, so a probing client never gets the cheap bucket |
77
- | `unauthenticated` | 20 / minute, per **address** | a missing token, or one `resolveToken` answers `null`. Past it the address is refused `429` **before** `resolveToken` runs — a valid guess included, so the answer says nothing about the token (`As of 2026-10`). Keyed on `handle(request, { address })` — the host's resolved client address; a host that passes none is not metered here |
90
+ | `unauthenticated` | 20 / minute, per **address** — an IPv6 /64 is one address (`addressNetwork`, `As of 31.15.0`) | a missing token, or one `resolveToken` answers `null`. Past it the address is refused `429` **before** `resolveToken` runs — a valid guess included, so the answer says nothing about the token (`As of 2026-10`). Keyed on `handle(request, { address })` — the host's resolved client address; a host that passes none is not metered here |
78
91
 
79
92
  | Rule | Detail |
80
93
  |---|---|
@@ -130,6 +143,14 @@ That line is the entire integration. From the existing declaration:
130
143
 
131
144
  The projected tool's `run` **is** `invoke` — the same entry point the HTTP route calls (`packages/mcp/src/projectable.ts`). Policy runs inside it, so there is nothing to keep in sync. The projection itself adds **no** MCP scope: a second gate hard-coded into the projection would sit in front of the only gate that matters, and the two would eventually disagree. `defineAppMcp`'s `scopes:` map may still attach one from outside — a property of the connection's token, never invented by the projection.
132
145
 
146
+ **An exposed LIST query answers one bounded page.** Its tool reads through the query's own
147
+ `.page()`: at most 500 rows (`MAX_WIRE_PAGE_SIZE`) and 256 KiB of JSON (`QUERY_LIMITS.maxBytes`),
148
+ `db.query`'s own ceilings. An answer that fits is the bare rows, as before. One cut short says so —
149
+ `truncated` (`'rows'` or `'bytes'`) and a `nextCursor` — and the agent asks for the next page by
150
+ passing that cursor back as the tool's optional `_after` argument, published in its `inputSchema`
151
+ (`packages/mcp/src/query-page.ts`). `As of 31.15.0`: a read with no `.limit()` dumped every row into
152
+ the model's context.
153
+
133
154
  No MCP-specific permission table, no service account with broad rights. Exposure is opt-in; silence exposes nothing.
134
155
 
135
156
  The user's own agents can therefore operate the user's product — refund an order, re-run an import, publish a post — with the exact permissions that user has in the UI. See [Admin dashboard](Admin-Dashboard) and [Actions](Actions).
@@ -531,6 +552,13 @@ Remote MCP tools as this app's actions — the app's `policy`, rate limit, confi
531
552
  3. On the callback, `exchange(handshake, { code, state })` answers `{ accessToken, refreshToken, expiresIn }`. `refresh(handshake, refreshToken)` answers the same shape.
532
553
  4. Store the tokens per connection. Return the access token from `mcpTools({ auth })`, which is read on every call, so a rotated token is never cached.
533
554
 
555
+ `begin` refuses, as `X_MCP_REMOTE_REFUSED`, metadata it cannot trust: a document that is not a URL,
556
+ resource metadata naming another resource (RFC 9728 §3.3), authorization-server metadata answering
557
+ for another issuer (RFC 8414 §3.3), no PKCE S256, and an `authorization_endpoint` or `token_endpoint`
558
+ that is not `https:` — `http:` only on a loopback host (`localhost`, `127.0.0.1`, `[::1]`, RFC 8252).
559
+ `authorizeUrl` is handed to a person as a link, so a `javascript:` endpoint would run in the app's
560
+ origin. `As of 31.15.0`.
561
+
534
562
  `clientId` is the HTTPS URL at which this app serves `metadata()` (a client ID metadata document), or an id the authorization server issued when the app was registered by hand. A `401` mid-session is `X_MCP_REMOTE_AUTH_REQUIRED`: run the handshake again.
535
563
 
536
564
  **Proved on itself.** `examples/dummy/packages/mcp/src/remote-self.contract.test.ts` points `mcpTools()` at the reference app's own MCP route. It locks the live list, calls `seatReport`, and meets three refusals: the remote policy's `X_FORBIDDEN` as a result, a stolen token as `X_MCP_REMOTE_AUTH_REQUIRED`, and a schema moved since the lock as `X_MCP_REMOTE_TOOL_CHANGED`.
@@ -612,6 +640,18 @@ export const summarize = llm({
612
640
 
613
641
  **A stream is the same action over a different transport, with one difference that is forced rather than chosen: there is no repair turn.** The non-streaming call retries once on a parse failure; a stream cannot, because the tokens are already on the reader's screen and a second answer is two answers to one question. So a stream yields **unvalidated** text increments plus one final `done` carrying the value that did satisfy `output`, and a schema disagreement is `X_LLM_STREAM_INVALID` naming the non-streaming call as the fix. A structured schema wants the non-streaming call.
614
642
 
643
+ **A call that stops early still costs what the provider billed.** Every budget — `tokensPerRun`,
644
+ `costPerRun`, the actor and org ceilings — is charged on these paths (`packages/ai/src/gateway.ts`,
645
+ `stream-bill.ts`). `As of 31.15.0`:
646
+
647
+ | The call | Recorded |
648
+ |---|---|
649
+ | reaches `done` | the provider's own counts |
650
+ | a stream abandoned, cut or aborted after its first provider byte | the running usage the wire reported: the prompt from `message_start` (OpenAI-format: estimated) plus the output streamed so far |
651
+ | aborted after its request left the process, before any answer (`generate` or `stream`) | the prompt's estimate (`estimateInputTokens`): the provider has read it |
652
+ | aborted before the request was sent, or refused by the provider (a 4xx) | nothing: the reservation is released |
653
+ | a `done` whose ledger record throws | never booked a second time from the running bill |
654
+
615
655
  **Showing what a model wrote is `Markdown` from `@ultimat3/ui`**, never `innerHTML`: the text is
616
656
  parsed to a tree and rendered as elements, so a `<script>` or a `javascript:` link in an answer is
617
657
  text, and a streaming answer re-parses per token while finished blocks keep their nodes. Tool calls
@@ -673,6 +713,7 @@ pgvector in the same Postgres. No second datastore.
673
713
  | Index | HNSW: `postgresVectorStore({ name, dimension }).ddl()` prints the table and both indexes, pasted into a migration by the app |
674
714
  | Hybrid search | one `query` primitive fusing pgvector cosine + Postgres FTS with Reciprocal Rank Fusion; weights are config |
675
715
  | Filtering | tenant + policy filters applied **in SQL**, so vector search cannot leak across tenants; a store with no tenant bound, read inside a request acting for an org, is `X_VECTOR_UNSCOPED` — a backfill opts in with `scope: UNSCOPED` |
716
+ | HNSW recall | a search returns `k` hits for a small tenant on a large shared table: on pgvector ≥ 0.8 it runs with `hnsw.iterative_scan = relaxed_order`, before that with `hnsw.ef_search` raised to `max(40, k × 10)`, capped at 1,000 — the setting scoped to a read-only transaction the search opens (2–3 round trips), or to the caller's own, put back after (`pg-vector-recall.ts`). Without it pgvector took the 40 nearest rows and filtered afterwards, so a tenant holding a small share of the table got fewer than `k`, often none. `As of 31.15.0` |
676
717
  | Re-embed | `indexDocument` again: every chunk is embedded on each call, so a job decides when text changed |
677
718
 
678
719
  ## Evals as a test type
package/wiki/Notify.md CHANGED
@@ -61,6 +61,12 @@ message disappears is your decision ([Configuration](Configuration)).
61
61
  recipient)` taken before each send — a chunk that failed part-way re-sends nobody it reached.
62
62
  10k recipients on two channels is 40 preference reads and 40 delivery steps. A digest's append
63
63
  and drain stay one step per recipient; its send is one step per chunk.
64
+ - Inside a chunk, deliveries run 16 at a time (`NOTIFY_DELIVERY_WIDTH`), each with its own ledger
65
+ claim. One failing recipient never stops its neighbours: they go out and settle `sent`, then the
66
+ step fails (a retryable failure first) and the retry re-sends the failed one alone. A drain (the
67
+ run's signal aborting) claims nobody new and waits for every send already claimed to settle
68
+ before the step answers, so no row is left `sending` behind an exiting process. Measured
69
+ `As of 2026-11-12`: 100 recipients on a 50 ms channel, 5.1 s → 0.36 s.
64
70
  - Two attempts at once: one sends. The other raises `X_NOTIFY_DELIVERY_HELD` and retries past the
65
71
  holder's `reclaimAfterMs` (5 minutes by default), so a crashed attempt's recipient is still sent to
66
72
  and a late `settle` moves nothing.
@@ -64,6 +64,17 @@ export const config = defineRoute({
64
64
  | Fonts, icons, and `priority` images they reference | asset graph |
65
65
  | The offline fallback route | required (see below) |
66
66
 
67
+ **The worker answers a precached asset from the precache**, ahead of every route rule
68
+ (`packages/pwa/src/precached-asset-source.ts`): a content-addressed URL (an island chunk, a
69
+ `/styles/<hash>.css`) from the cache, the network only on a miss; any other precached asset from the
70
+ network, the precache answering offline. Before `31.15.0` nothing read them: an offline document
71
+ rendered unstyled beside its own stylesheet, and a precached chunk was downloaded twice.
72
+
73
+ **Each build's pages cache keeps at most 50 documents** (`PAGES_CACHE_MAX`), the oldest WRITTEN out
74
+ first — a page visited again is written again and outlives pages visited once since. One write at a
75
+ time, so a trim never deletes the page a refresh just stored. Unbounded, `x-pages-<id>` grew until
76
+ the next deploy or the browser's quota, and a quota eviction takes the origin's whole storage.
77
+
67
78
  Excluded always: `api/` responses and every personal route (a policy, a `stream`, a `no-store`/`private` cache) — even with `offline: 'precache'`, `As of 22.3.3`.
68
79
 
69
80
  Total precache size is a **warning, not a budget, `As of 2026-08`**: `buildPrecacheManifest` puts `DEFAULT_PRECACHE_WARN_BYTES` overruns on `PrecacheManifest.warnings`, and **nothing reads that field** — no `x verify` step loads a precache manifest, because nothing builds one. Designed as a budget; not one today.
package/wiki/Realtime.md CHANGED
@@ -142,15 +142,16 @@ adapter, its sync URL and its `LiveClient`: the page's one socket is the framewo
142
142
  ```tsx
143
143
  // app/feed/feed.island.tsx — the only module of /feed a browser downloads
144
144
  import { useConnection, useQuery } from '@ultimat3/realtime';
145
+ import { mountOver } from '@ultimat3/render/client';
145
146
  import { For, Match, Switch } from 'solid-js';
146
147
  import { render } from 'solid-js/web';
147
148
 
148
149
  type FeedRow = { id: string; title: string };
149
150
  const LIVE_FEED = { name: 'liveFeed', live: true } as const;
150
151
 
151
- export function mount(el: HTMLElement, props: { orgId: string }) {
152
- el.textContent = ''; // Solid's render APPENDS; the server's loading shell goes first
153
- render(() => <Feed orgId={props.orgId} />, el);
152
+ // mountOver clears the server's loading shell (Solid's render APPENDS) and puts it back on a throw.
153
+ export function mount(el: HTMLElement, props: { orgId: string }): () => void {
154
+ return mountOver(el, (root) => render(() => <Feed orgId={props.orgId} />, root));
154
155
  }
155
156
 
156
157
  function Feed(props: { orgId: string }) {
package/wiki/SEO.md CHANGED
@@ -140,7 +140,7 @@ card page, `page.screenshot()`, `disk.put()`, then `og: { image }` with the stor
140
140
  | `buildFeed()` | RSS 2.0, Atom and JSON Feed from one item list. The channel's `author`, `copyright` and `icon` reach Atom as `<author>`, `<rights>` and `<icon>`; an item's `author` is `<author>` in Atom and, in RSS, `<author>` with an email or `<dc:creator>` without one; an item's `image` is an Atom enclosure link and an RSS `<media:content>`. An item date must be ISO-8601 with an offset or `Z`; one that is not is treated as absent (and an offsetless one is logged as `seo.feed.date_offsetless`), never read through the server's zone |
141
141
  | `builtinImageDriver({ read })` | resize and blur placeholder over core's pipeline — decodes `png`, `jpeg`, `webp`, `gif`; encodes `png`, `jpeg`, `webp`. `avif` needs a CDN driver (`X_IMAGE_UNSUPPORTED`), so `responsiveImage()` offers `webp` only unless given `formats`, and no width past 8192 (`MAX_IMAGE_WIDTH`). `As of 2026-10` |
142
142
  | `parseImageQuery()` | the one reader of the `?w=&f=&q=` a responsive image URL carries (`X_IMAGE_QUERY_INVALID`) |
143
- | `setStaticExport()` | the static build's seam: while it renders, `responsiveImage()` names `/_img/<source hash>-<width>.<ext>` files and `og.capture` names `/_og/<path>.png`. Unset in a served process — [Static assets](Static-Assets#responsive-images-in-a-static-export) |
143
+ | `setStaticExport()` | the static build's seam: while it renders, `responsiveImage()` names `/_img/<variant hash>-<width>.<ext>` files (source bytes, width, format and encoder) and `og.capture` names `/_og/<path>.png`. Unset in a served process — [Static assets](Static-Assets#responsive-images-in-a-static-export) |
144
144
 
145
145
  Every `X_SEO_*` and image code is in [Error codes](Error-Codes).
146
146
 
@@ -98,6 +98,30 @@ unsatisfiable range gets a `416`. Safari will not play a `<video>` without this.
98
98
  `favicon.ico` stays at `apps/web/site/favicon.ico` and the install icon at `apps/web/site/icon.png`.
99
99
  Browsers ask for those at fixed URLs, so they are not hashed.
100
100
 
101
+ ## Precompressed siblings in a static export
102
+
103
+ `x build --target static` writes `<file>.br` (brotli 11) and `<file>.gz` (gzip 9) beside every
104
+ island chunk (`/islands/*.js`) and surface stylesheet (`/styles/*.css`). Each sibling decodes to its
105
+ file byte for byte. A file under 1 KiB, or one a coding would not shrink, gets none. The coders
106
+ are `@ultimat3/http`'s `PRECODERS`, the same ones the container uses to precode its immutable
107
+ answers. `packages/cli/src/static-precompress.ts`. `As of 2026-11`.
108
+
109
+ A host serves the siblings only if it is configured to. The rules, for any host:
110
+
111
+ | Rule | Why |
112
+ |---|---|
113
+ | answer `<file>.br` when `Accept-Encoding` names `br`, else `<file>.gz` for `gzip`, else `<file>` | a client that refused a coding must never be handed it |
114
+ | `Content-Encoding: br` / `gzip` on the sibling, and the ORIGINAL's `Content-Type` (`text/css`, `text/javascript`) | `application/x-brotli` is a download, not a stylesheet |
115
+ | `Vary: Accept-Encoding` on all three answers | otherwise a shared cache hands one client's coding to the next |
116
+ | `Cache-Control: public, max-age=31536000, immutable` on `/islands/*` and `/styles/*` | the name is the content hash, so the bytes never change under it |
117
+ | never serve a `.br`/`.gz` URL directly as its own resource | it exists to be negotiated, not linked |
118
+
119
+ | Host | Setting |
120
+ |---|---|
121
+ | nginx | `gzip_static on;` and, with the brotli module, `brotli_static on;` |
122
+ | Caddy | `file_server { precompressed br gzip }` |
123
+ | a host or CDN that compresses on its own | ignores the siblings. They are extra bytes in the artifact and change nothing |
124
+
101
125
  ## `<Image>`
102
126
 
103
127
  | Prop | Meaning |
@@ -116,7 +140,7 @@ Everything else is `loading="lazy"`, `fetchpriority="auto"` and `decoding="async
116
140
 
117
141
  `responsiveImage()` from `@ultimat3/seo` mints `?w=&f=` URLs, which only `/media` answers — a dumb
118
142
  file server ignores the query and hands back the full original under `<source type="image/webp">`.
119
- So under `x build --target static` every candidate is a FILE instead: `/_img/<source hash>-<width>.<ext>`,
143
+ So under `x build --target static` every candidate is a FILE instead: `/_img/<variant hash>-<width>.<ext>`,
120
144
  written through core's pipeline after the documents render, one per width in every offered format.
121
145
  `As of 2026-11`.
122
146
 
@@ -128,8 +152,11 @@ written through core's pipeline after the documents render, one per width in eve
128
152
  | what is written | only the candidates an EXPORTED document names: a page rendered just to be weighed writes nothing |
129
153
  | a served page | keeps the `?w=&f=` URLs, which `/assets` answers itself — [below](#responsive-images-on-a-served-page). The seam is installed by the export alone |
130
154
 
131
- The name is the source's content hash, so a changed image is a new URL and every file can be served
132
- `immutable`. `examples/dummy`'s landing page (`apps/web/site/page.tsx`) is the worked example.
155
+ The name hashes everything the variant's bytes are a function of: the source's bytes, the width,
156
+ the format and the encoder (the framework version and Bun's, `imageEncoderIdentity()` in
157
+ `packages/cli/src/static-images.ts`). A changed image is a new URL, and so is an upgrade that may
158
+ re-encode it, so every file can be served `immutable` and one URL is always one byte string — the
159
+ #1075 rule islands follow. `As of 31.15.0` every `/_img/` URL changed once. `examples/dummy`'s landing page (`apps/web/site/page.tsx`) is the worked example.
133
160
 
134
161
  ## Responsive images on a served page
135
162
 
package/wiki/Testing.md CHANGED
@@ -1118,13 +1118,13 @@ Source: `packages/testing/src/scale-sweep*.ts`, `plan-oracle.ts`, `plan-sweep*.t
1118
1118
 
1119
1119
  | Sweep | What | Red |
1120
1120
  |---|---|---|
1121
- | 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: `X_QUERY_SCALES_WITH_ROWS`, fix `preload()` or `expectedQueryLoop('<why>', fn)` |
1121
+ | 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 |
1122
1122
  | 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 |
1123
1123
 
1124
1124
  With the planner's scans and sorts disabled it picks one only when no index can answer, so the
1125
1125
  verdict reads the schema on empty tables — no volume, no statistics. Never red: `scale.verdict`
1126
1126
  `flat` (a declared loop listed in `expected` with its reason) or `unproven` (a call that did not
1127
- answer at both sizes); a statement whose equality pins a unique key; one a partial index serves once
1127
+ answer at both sizes, or took another path at 8); a statement whose equality pins a unique key; one a partial index serves once
1128
1128
  its value is bound; a whole read beside a join whose join column leads a declared index on that
1129
1129
  side, while the other side is bound by its own key — on empty tables a partial index the statement
1130
1130
  implies looks like one row, so the planner walks it rather than probe it per row (`As of
@@ -1137,6 +1137,68 @@ under `expectedSeqScan('<why>', fn)` or on an entity with `scan: '<why>'`
1137
1137
  x db gen posts-orgId-createdAt-id-index # after indexes: [{ on: ['orgId', 'createdAt', 'id'] }] in entity("posts")
1138
1138
  ```
1139
1139
 
1140
+ **Seed isolation** (`As of 31.16.0`). A sized-seed table the database refuses — usually a unique
1141
+ column the default factory repeats — is that table's failure alone: the primitives whose statements
1142
+ read it are `unproven`, the failure on their `scale.seed` (`{ entity, cause }`), and every other
1143
+ primitive is still scale-judged. `scaleSeedFindings(records)` folds them into one
1144
+ `X_EXERCISE_SEED_FAILED` per table, naming the entity, the driver's words and up to ten readers; the
1145
+ fix is the factory to declare. Before, one refused table left every primitive `unproven` with the
1146
+ same reason.
1147
+
1148
+ ```ts
1149
+ import { entity, text, uuid } from '@ultimat3/entity';
1150
+ import { defineExercise, defineFactory } from '@ultimat3/testing';
1151
+
1152
+ const posts = entity('posts', {
1153
+ columns: { id: uuid().primaryKey(), slug: text({ max: 80 }).unique() },
1154
+ });
1155
+
1156
+ export const exercise = defineExercise(
1157
+ {},
1158
+ { factories: { posts: defineFactory(posts, { defaults: (index) => ({ slug: `post-${index}` }) }) } },
1159
+ );
1160
+ ```
1161
+
1162
+ ### The statement ceiling
1163
+
1164
+ `As of 31.16.0`. The scale sweep judges growth; this judges the count. One call of an action, query
1165
+ or job may send `STATEMENTS_MAX` — 100 — statements; the busiest of its calls is the one judged,
1166
+ never the runs' sum. Over it the record carries `statementCeiling: { verdict: 'over', statements,
1167
+ max, top }` — `top` its three most-sent shapes, what a `preload()` would fold — and
1168
+ `statementCeilingFindings(records)` reports `X_STATEMENTS_OVER_BUDGET`. A flat 300-statement call is
1169
+ never `X_QUERY_SCALES_WITH_ROWS`, and it is still slow.
1170
+
1171
+ Only statements no `expectedQueryLoop` declared are counted, as in the scale sweep: the loop's reason
1172
+ is its argument. A `backfill()` pass writes every row it visits under the factory's own loop, so a
1173
+ sweep over 500 seeded rows judges its page reads, never the seed's size; the excluded count is
1174
+ `statementCeiling.expected`, named in the finding.
1175
+
1176
+ One primitive's ceiling, raised or lowered with a reason; a blank `why` (or none) is
1177
+ `X_CONTRACT_EXERCISE_UNDECLARED`, and `max` is a whole number ≥ 1:
1178
+
1179
+ ```ts
1180
+ import { defineExercise } from '@ultimat3/testing';
1181
+
1182
+ export const exercise = defineExercise({
1183
+ importRows: { statements: { max: 140, why: 'one insert per line, bounded by the 140-line form' } },
1184
+ });
1185
+ ```
1186
+
1187
+ ### The floor: `unprovenMax` and `statementsMax`
1188
+
1189
+ What is red is `x.verify.json`'s call ([Configuration](Configuration#the-gates-file--xverifyjson)):
1190
+ `x exercise` and the gate's `exercise` step read its `exercise` key.
1191
+
1192
+ | Key | Red above it | Without the key |
1193
+ |---|---|---|
1194
+ | `unprovenMax` | `X_EXERCISE_UNPROVEN_ABOVE_FLOOR` — unproven ÷ reached, rounded up to four places, names the first three; the sized-seed findings behind it are red with it | a warning line naming the figure to write |
1195
+ | `statementsMax` | `X_STATEMENTS_OVER_BUDGET` for every primitive over it whose entry declares no `statements` (an entry's own ceiling stands) | the ceiling is 100 and each finding is a warning line |
1196
+
1197
+ `x new` writes `{ "unprovenMax": 0, "statementsMax": 100 }`. An app scaffolded before 31.16.0 stays
1198
+ green with warnings until it opts in, and `x upgrade` writes the figures its hop measured — the
1199
+ busiest undeclared call, never under 100 — so the floor starts where the app is. A figure the run
1200
+ beats is a warning naming the lower number: the floor only falls.
1201
+
1140
1202
  ## Memory, width and isolation
1141
1203
 
1142
1204
  `As of 22.7`. The gate is built for the machines it runs on — 8-16 GB, 2-8 cores, often two agents'
package/wiki/Theming.md CHANGED
@@ -194,11 +194,11 @@ export const brand = defineTheme({ preset: 'scifi' });
194
194
  | Who | Does |
195
195
  |---|---|
196
196
  | the app | exports `brand` from `apps/web/shared/theme.ts`. Nothing else: no `<style>` in a layout, no CSP edit |
197
- | `x dev`, the container (`ROLE=web`), `x build`'s static export | inline `brandStyleTag(brand)` in the `<head>` of every document — `ssr`, `stream`, `static`, `isr`, and every `/admin` screen — **after** the surface stylesheet `<link>`, so the brand wins the cascade at equal specificity |
198
- | the served processes | admit the same body to `style-src` as a `sha256` source (`brandStyleCspSource(brand)`), so the enforced policy a container sends never blocks it |
199
- | an app with no `shared/theme.ts`, or one whose brand renders no CSS | nothing: no tag, no hash, no bytes |
197
+ | `x dev`, the container (`ROLE=web`), `x build`'s static export | append `brand.css` to the END of every surface stylesheet (`/styles/<hash>.css`), so every document — `ssr`, `stream`, `static`, `isr`, and every `/admin` screen — gets it from the `<link>` it already has, last in the cascade, and the brand wins at equal specificity. No inline `<style>` (`As of 2026-11`; before, a 6,130-byte `<style>` rode every document) |
198
+ | the served processes | nothing for `style-src`: the stylesheet is a same-origin file `'self'` admits, so no `sha256` source is added |
199
+ | an app with no `shared/theme.ts`, or one whose brand renders no CSS | nothing: the sheets are unchanged |
200
200
 
201
- One file, one reader: `packages/cli/src/theme-brand.ts`. The `/_x` dev dashboard is framework chrome, not an app document, and keeps the shipped palette. No JavaScript is added: the brand is CSS, and the theme toggle and dark mode work as before — the brand answers `html[data-theme]` and `prefers-color-scheme` at every level `theme.scss` does, so the boot script and `ThemeToggle` flip between the brand's two palettes. A save to `theme.ts` is applied on the next `x dev`.
201
+ One file, one reader: `packages/cli/src/theme-brand.ts`; the append is `packages/cli/src/style-bundle.ts`. Every page that links the `app/` sheet gets the brand, including the `/_x` dev dashboard and `x shot`'s harness. A change to the brand is a new sheet hash, so a cached old sheet is never served under it. No JavaScript is added: the brand is CSS, and the theme toggle and dark mode work as before — the brand answers `html[data-theme]` and `prefers-color-scheme` at every level `theme.scss` does, so the boot script and `ThemeToggle` flip between the brand's two palettes. A save to `theme.ts` is applied on the next `x dev`.
202
202
 
203
203
  | Failure | Code | When |
204
204
  |---|---|---|
@@ -218,7 +218,7 @@ const brand = defineTheme({
218
218
  });
219
219
 
220
220
  brand.css; // the four CSS blocks, as a string
221
- brandStyleTag(brand); // '<style>…</style>' — exactly what the framework inlines
221
+ brandStyleTag(brand); // '<style>…</style>' — for a page you render yourself; the framework links it in the sheet
222
222
  ```
223
223
 
224
224
  | Field | Shape | Notes |
@@ -233,7 +233,7 @@ Returns a frozen `{ css: string }`. It emits `:root`, `html[data-theme='light']`
233
233
 
234
234
  ### Values are validated, never escaped
235
235
 
236
- The output lands in a `<style>` element, so a value that could close it is refused rather than sanitised.
236
+ The output can land in a `<style>` element (`brandStyleTag`), so a value that could close it is refused rather than sanitised.
237
237
 
238
238
  | Slot | Accepted | Refused |
239
239
  |---|---|---|
package/wiki/Upgrading.md CHANGED
@@ -259,6 +259,17 @@ A setter still on a package's `.` barrel is `X_ADAPTER_PORT_INCOMPLETE` on the `
259
259
  | a realtime hook created inside a component is released when that component is disposed (**31.14.0**): `x build`'s island bootstrap calls `installRealtime({ signal: createSignal, cleanup: onCleanup })`, and every `use*` hook registers its own `release()` through it. Before, it lived until the island called `release()` — or, forgotten, until the page unloaded, holding a socket subscription and a cap slot. A handle the island kept using after its component went (stored in a module variable or a parent's state) now reads nothing new | create a long-lived handle outside any component — at module scope or in `mount`, before `render()`: no owner, nothing registered, its `release()` is yours. A hand-built island (one that calls `installRealtime` itself) adds `cleanup: onCleanup` from its own `solid-js`; without it every `release()` stays the island's. An `onCleanup(() => h.release())` already written is harmless: a release runs once. Optional: delete it |
260
260
  | `x doctor` lists `raw-interval` as differing from the shipped template after the **31.14.0** hop: its `fix:` now names `useQuery(ref, input, { poll: pollEvery(ms) })` for a query's timed re-read, before `visibleInterval(run, ms)`. The rule is the same; nothing new is reported | `x g guard raw-interval --force` — it rewrites `guards/raw-interval.ts` **and** its `.test.ts`, so review the diff and keep any rule you edited on purpose. Then `x verify` |
261
261
  | a replicator restart chains (**31.14.0**): the change envelope is version 2 — a run's first envelope carries `from`, and a clean stop publishes a handover on `x.change.-handover` — so a deploy of the `replicator` role after a clean stop re-snapshots no live window. A crash still costs one re-read per window. During a roll, an old node reading a new replicator, or a new node reading an old one, reads the restart as a gap, exactly as before | roll the `sync` role before the `replicator` role. Either order is safe; only nodes already on 31.14.0 chain the replicator's own restart. A custom `ChangeFeed` (`@ultimat3/realtime/server`) chains only once it implements the optional `position()` and `onResume` |
262
+ | an island whose render throws can show its server HTML instead of a blank box (**31.15.0**): `mountOver(el, draw)` from `@ultimat3/render/client` clears the wrapper, draws, and puts the server markup back on a throw (then rethrows, so `data-x-failed` and `clientErrors` still fire). `x g island`, `x new` and the resource form island write it; an older island keeps working as it was | `x g guard island-mount-clears`, then `x verify --only boundaries`: for each finding delete `el.textContent = ''` and end `mount` with `return mountOver(el, (root) => render(() => <Island {...props} />, root))`, adding `import { mountOver } from '@ultimat3/render/client'` |
263
+ | every `/_img/` URL a static export writes changes once (**31.15.0**): a variant is named by the hash of its source bytes, width, format and encoder (framework + Bun version), no longer the source hash alone, so an upgrade that may re-encode an image never serves other bytes under an `immutable` name | nothing. A CDN fetches each image once again |
264
+ | an exposed LIST query's MCP tool answers at most 500 rows and 256 KiB of JSON per call (**31.15.0**), with `truncated` and a `nextCursor` when cut short; an agent or test that read every row from one call now gets the first page | follow `nextCursor`: call the tool again with `_after: <nextCursor>` until it is `null`. An answer that fits is the bare rows, as before |
265
+ | unauthenticated MCP failures are counted per IPv6 /64, not per address (**31.15.0**) — the key `@ultimat3/http`'s limiter uses — and `mcp.auth.*` lines log that network, never the full address; `mcp.auth.missing-token` logs at `info` | IPv6 clients sharing a /64 now share one allowance of 20 a minute: where that is legitimate traffic, raise `defineAppMcp({ rateLimits: { unauthenticated } })` (or `mcpHttpRoute`'s). An alert keyed on `mcp.auth.missing-token` at `warn` keys on `info` |
266
+ | an `llm()` / `generate` / `stream` call that stops early now spends budget (**31.15.0**): a stream abandoned, cut or aborted after its first provider byte records the running usage; any call aborted after its request was sent records the prompt's estimate. Before, all of these released the whole reservation. Only a call never sent, or refused by the provider, is free | raise `tokensPerRun`, `costPerRun` or an actor/org ceiling that was tuned against the old under-count. A custom `Provider` reports nothing and keeps the old release |
267
+ | a `postgresVectorStore` search runs in a read-only transaction that widens the HNSW scan (**31.15.0**: `hnsw.iterative_scan = relaxed_order` on pgvector ≥ 0.8, else `hnsw.ef_search = max(40, k × 10)`), 2–3 round trips where it was 1, so a small tenant gets `k` hits | nothing. On pgvector < 0.8, upgrade the extension for the cheaper iterative scan |
268
+ | `x build --target static` writes `.br` (brotli 11) and `.gz` (gzip 9) siblings beside each island chunk and stylesheet (**31.15.0**), and the app brand ships at the end of each surface stylesheet instead of an inline `<style>` | a static host may serve the siblings (nginx `gzip_static on;` / `brotli_static on;`, Caddy `file_server { precompressed br gzip }`, with `Vary: Accept-Encoding`) or ignore them — [Static assets](Static-Assets#precompressed-siblings-in-a-static-export). A hand-written CSP that allowed the brand's `sha256` may drop it |
269
+ | a cacheable `ssr` document (not `no-store`) carries a strong content `ETag` and answers `If-None-Match` with `304` (**31.15.0**); every document sends a `Link` header (stylesheet preload + the modulepreloads its tags name) a CDN turns into 103 Early Hints | nothing. A test that expected `200` to `If-None-Match: *` on such a page expects `304` |
270
+ | `x exercise` and `x verify`'s `exercise` step print `X_EXERCISE_UNPROVEN_ABOVE_FLOOR`, `X_EXERCISE_SEED_FAILED` and `X_STATEMENTS_OVER_BUDGET` as **warning lines** (**31.16.0**): one call over 100 statements, or primitives left `unproven`, in an app whose `x.verify.json` has no `exercise` key. The step stays green; each is red only once the key opts in | nothing. `x upgrade` to 31.16.0 writes the figures the hop's own `x exercise` measured (`"exercise": { "unprovenMax": <measured>, "statementsMax": <busiest call, ≥ 100> }`), so the hop stays green and the floor only falls; `x new` writes the strict `{ "unprovenMax": 0, "statementsMax": 100 }`. A primitive that needs more statements per call: `defineExercise({ <name>: { statements: { max: <n>, why: '<why one call sends that many>' } } })` in `apps/web/exercise.ts` |
271
+ | `x upgrade` writes files it used to print (**31.16.0**): each missing shipped guard whose rule the tree already meets is installed as `guards/<name>.ts` (+ its test), and a hop that moves the Bun floor rewrites `x.verify.json`'s `coverage` floor to the measurement, with a dated `why`, when unit coverage measured under it. Both are in the hop's diff and in `--json` (`data.guards.installed` / `data.guards.withheld`, `data.coverage`) | review the diff before committing it. A guard you do not want: delete its file. A withheld guard is listed with its finding count and the `x g guard <name>` that adds it |
272
+ | `x doctor` prints four new **warnings** (**31.16.0**): `X_DB_ROW_SECURITY_OFF`, `X_VERIFY_STEP_UNFLOORED`, `X_FRAMEWORK_PIN_RANGE`, `X_ENV_NAME_RESERVED`, one line each under `N warning(s)` and in `--json` as `data.warnings[]` (`{ code, cause, fix, docs, at }`). Its exit status, `findings` and `data.codes` are unchanged, so a CI step or `x upgrade` hop running `x doctor` stays green; they join the verdict (red) on the next major, `next`. `x verify` is unchanged — none of them is a gate step | nothing now. Before the next major, clear them: each warning's `fix:` is the edit. A reserved env name: rename it to `APP_<name>` in `envSchema` (or `x secrets edit`); an unfloored step: `x verify --only <steps> --json`, then add each step that passed to `"steps"` |
262
273
 
263
274
  ## 29.x → 30.0.0, entry by entry
264
275