@ultimat3/cli 30.8.0 → 31.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +75 -64
- package/README.md +4 -1
- package/package.json +30 -29
- package/src/admin-registration.ts +1 -1
- package/src/affected.ts +5 -1
- package/src/app-boundaries.ts +88 -9
- package/src/app-load-async.ts +133 -0
- package/src/app-load-batch.ts +203 -0
- package/src/app-load-prebuilt.ts +147 -0
- package/src/app-load-register.ts +175 -0
- package/src/app-load.ts +143 -175
- package/src/app-loader-imports.ts +31 -0
- package/src/app-root.ts +13 -0
- package/src/app-runtime.ts +5 -1
- package/src/boundary-findings.ts +12 -0
- package/src/browser-launcher-port.ts +3 -7
- package/src/browser-launcher.ts +1 -1
- package/src/budgets-scan.ts +8 -0
- package/src/budgets.ts +10 -1
- package/src/build-registry-background.ts +59 -0
- package/src/build-registry.ts +207 -0
- package/src/cdp-shot-clock.ts +3 -11
- package/src/cdp-shot-driver.ts +3 -2
- package/src/cdp-shot-element.ts +3 -2
- package/src/cdp-shot-page.ts +2 -2
- package/src/cdp-shot-watch.ts +4 -3
- package/src/cmd-auth.ts +3 -3
- package/src/cmd-db-recount.ts +15 -0
- package/src/cmd-drill.ts +10 -6
- package/src/cmd-exercise.ts +2 -1
- package/src/cmd-generate-spec.ts +6 -0
- package/src/cmd-generate.ts +22 -4
- package/src/cmd-mail.ts +1 -1
- package/src/cmd-routes.ts +2 -2
- package/src/cmd-secrets-spec.ts +4 -1
- package/src/cmd-shot.ts +14 -4
- package/src/cmd-verify-spec.ts +21 -1
- package/src/cmd-verify.ts +16 -4
- package/src/coverage-source.ts +4 -1
- package/src/db-diagnostics.ts +8 -1
- package/src/dev-boot.ts +29 -15
- package/src/dev-dashboard-invalidations.ts +43 -0
- package/src/dev-dashboard.ts +13 -16
- package/src/dev-n-plus-one.ts +7 -3
- package/src/dev-rebuild.ts +2 -1
- package/src/dev-route-table.ts +1 -1
- package/src/dev-traces.ts +16 -15
- package/src/document-options.ts +12 -1
- package/src/drift-store.ts +55 -0
- package/src/error-catalog.ts +8 -3
- package/src/error-codes-boundary.ts +32 -0
- package/src/error-codes.ts +23 -19
- package/src/errors.ts +17 -7
- package/src/exercise-database.ts +13 -1
- package/src/exercise-findings.ts +36 -18
- package/src/exercise-services.ts +84 -0
- package/src/exercise-subject.ts +38 -13
- package/src/failure-capture-boot.ts +9 -5
- package/src/framework-schema.ts +5 -5
- package/src/generate-exercise.ts +1 -1
- package/src/generate-files.ts +27 -7
- package/src/generate-kinds.ts +5 -0
- package/src/generate-refresh.ts +53 -0
- package/src/generate-workspace.ts +169 -0
- package/src/generate-write.ts +8 -2
- package/src/hold.ts +19 -8
- package/src/image-prepare.ts +6 -2
- package/src/index.ts +5 -20
- package/src/island-bundle.ts +7 -3
- package/src/island-capture.ts +2 -2
- package/src/island-harness.ts +1 -1
- package/src/job-registration.ts +43 -6
- package/src/jobs-driver.ts +4 -5
- package/src/mcp-errors.ts +18 -4
- package/src/mcp-host.ts +5 -1
- package/src/mcp-ui-interact.ts +3 -0
- package/src/messages-gate.ts +4 -0
- package/src/new-shapes-generate.ts +1 -1
- package/src/otlp-export.ts +94 -29
- package/src/output.ts +3 -7
- package/src/page-sync.ts +3 -1
- package/src/role-load.ts +17 -11
- package/src/role-start.ts +5 -4
- package/src/role-sync.ts +7 -8
- package/src/route-islands-preload.ts +46 -0
- package/src/route-islands.ts +6 -2
- package/src/runtime-admin.ts +5 -1
- package/src/runtime-bindings.ts +25 -19
- package/src/runtime-boot-ports.ts +66 -0
- package/src/runtime-bus.ts +29 -5
- package/src/runtime-cache-bus.ts +53 -0
- package/src/runtime-cache.ts +43 -13
- package/src/runtime-isr-outcome.ts +5 -4
- package/src/runtime-jobs.ts +2 -2
- package/src/runtime-keys.ts +37 -0
- package/src/runtime-overrides.ts +148 -42
- package/src/runtime-port-bindings-queue.ts +36 -0
- package/src/runtime-port-bindings.ts +117 -0
- package/src/runtime-ports.ts +164 -0
- package/src/runtime-purge.ts +41 -28
- package/src/runtime-push.ts +7 -3
- package/src/runtime-queue.ts +70 -55
- package/src/runtime-realtime.ts +5 -5
- package/src/runtime-render-document.ts +4 -1
- package/src/runtime-services.ts +110 -158
- package/src/runtime-storage-boot.ts +111 -0
- package/src/runtime-storage-upload.ts +9 -7
- package/src/runtime-storage.ts +7 -1
- package/src/serve-boot.ts +8 -4
- package/src/serve-entry.ts +3 -0
- package/src/serve-env.ts +47 -14
- package/src/serve-prebuilt-paths.ts +3 -0
- package/src/serve-prebuilt.ts +15 -4
- package/src/serve.ts +2 -2
- package/src/static-cards.ts +3 -2
- package/src/static-report.ts +2 -2
- package/src/style-bundle.ts +1 -1
- package/src/sync-authenticator.ts +17 -18
- package/src/templates/action-tests.ts +4 -4
- package/src/templates/backfill.ts +5 -8
- package/src/templates/entity.ts +3 -0
- package/src/templates/github/ci.yml.ts +3 -1
- package/src/templates/github/dependabot.yml.ts +73 -0
- package/src/templates/job.ts +13 -22
- package/src/templates/naming.ts +20 -1
- package/src/templates/pinned/docker-compose.yml +1 -1
- package/src/templates/query.ts +7 -8
- package/src/templates/route.ts +5 -3
- package/src/templates/scaffold-api.ts +1 -1
- package/src/templates/scaffold-auth.ts +5 -3
- package/src/templates/scaffold-claude-commands.ts +6 -3
- package/src/templates/scaffold-claude.ts +4 -4
- package/src/templates/scaffold-container-compose.ts +2 -4
- package/src/templates/scaffold-domain-package.ts +1 -1
- package/src/templates/scaffold-entries.ts +6 -1
- package/src/templates/scaffold-helm-fences.ts +3 -2
- package/src/templates/scaffold-helm.ts +35 -6
- package/src/templates/scaffold-repo.ts +47 -135
- package/src/templates/scaffold-runtime-ports.ts +62 -0
- package/src/templates/scaffold-verify-floor.ts +97 -0
- package/src/templates/shapes/overlay.ts +1 -1
- package/src/templates/sign-in-oidc.ts +5 -3
- package/src/templates/sign-in-shared.ts +28 -10
- package/src/templates/workspace.ts +75 -0
- package/src/test-ignores.ts +5 -2
- package/src/test-select.ts +4 -1
- package/src/upgrade-gate.ts +30 -5
- package/src/upgrade-report.ts +7 -1
- package/src/verify-changed-facts.ts +53 -0
- package/src/verify-changed-scope.ts +161 -0
- package/src/verify-changed.ts +174 -0
- package/src/verify-checks.ts +31 -19
- package/src/verify-drift-owner.ts +30 -0
- package/src/verify-e2e.ts +2 -1
- package/src/verify-factories.ts +86 -0
- package/src/verify-run.ts +13 -11
- package/src/verify-step.ts +13 -0
- package/src/verify-tests.ts +58 -6
- package/src/write-line.ts +21 -6
- package/wiki/Actions.md +2 -2
- package/wiki/Adapters.md +400 -0
- package/wiki/Admin-Dashboard.md +2 -1
- package/wiki/Agents.md +9 -9
- package/wiki/Auth.md +78 -2
- package/wiki/Building-Your-Own-Base.md +1 -1
- package/wiki/CLI-Reference.md +34 -7
- package/wiki/Caching-And-Invalidation.md +17 -5
- package/wiki/Compared.md +8 -2
- package/wiki/Configuration.md +14 -14
- package/wiki/Deployment.md +28 -1
- package/wiki/Entities-And-Migrations.md +48 -2
- package/wiki/FAQ.md +8 -2
- package/wiki/Feature-Flags.md +1 -1
- package/wiki/Home.md +3 -2
- package/wiki/Jobs-And-Workflows.md +107 -6
- package/wiki/Known-Gaps.md +4 -3
- package/wiki/MCP-And-AI.md +18 -4
- package/wiki/Mail.md +14 -5
- package/wiki/Migrations-And-Backfills.md +31 -4
- package/wiki/Money.md +2 -0
- package/wiki/N-Plus-One-Detection.md +24 -22
- package/wiki/Notify.md +28 -4
- package/wiki/Observability.md +121 -15
- package/wiki/Queries-And-Live-Queries.md +2 -2
- package/wiki/Realtime.md +9 -4
- package/wiki/Routes-And-Render-Modes.md +5 -0
- package/wiki/Scraping.md +57 -11
- package/wiki/Shapes.md +2 -2
- package/wiki/Stability.md +7 -5
- package/wiki/Storage-And-Uploads.md +56 -4
- package/wiki/Testing.md +69 -56
- package/wiki/Troubleshooting.md +1 -1
- package/wiki/Tutorial-01-First-App.md +1 -1
- package/wiki/Tutorial-04-Jobs-And-Realtime.md +1 -1
- package/wiki/Tutorial-05-Deploy-Free.md +1 -1
- package/wiki/Tutorial-06-Growing-Up.md +8 -8
- package/wiki/Upgrading.md +129 -4
package/wiki/Testing.md
CHANGED
|
@@ -91,8 +91,8 @@ Any test that can pass twice and fail the third time is worse than no test — i
|
|
|
91
91
|
| **Seeds** | `seed(name)` builds a named, deterministic fixture graph via entity factories. Same input → identical rows, identical UUIDs |
|
|
92
92
|
| **Frozen clock** | time starts at a fixed instant. `clock.advance('3d')` moves it, and it also drives `step.sleep` and cron in tests |
|
|
93
93
|
| **Seeded RNG** | `Math.random`, `crypto.randomUUID`, and Bun's RNG are seeded per test file from its path — reproducible, distinct across files |
|
|
94
|
-
| **Sealed network** | a `fetch`, a `new WebSocket(…)
|
|
95
|
-
| **Sealed names** | `
|
|
94
|
+
| **Sealed network** | a `fetch`, a `new WebSocket(…)`, a `Bun.connect(…)` or a `node:net` / `node:tls` / `node:http` / `node:https` / `node:http2` connection (all dial through `net.Socket#connect`, sealed there) to anywhere not explicitly mocked or allowed **fails the test** with `X_TEST_NETWORK_SEALED`, naming the URL and the fix — every dial shares one gate, so the allow-list (`allowHost('host:port')` for a socket) and `offline()` apply to all of them — `offline()` refuses a loopback dial too (`X_TEST_NETWORK_OFFLINE`). A `node:*` refusal is the socket's `error` event, as a failed real dial is. A `mockFetch` route answers `fetch` only: a `node:http` request to a mocked host is refused, never dialled. A `Bun.udpSocket` send (and `node:dgram`, which sends through it) asks the same gate per datagram, the connected peer included: a refusal throws from `send`/`sendMany` as Bun's own UDP failures do, a refused `connect` option rejects, and `dgram` hands it to the send callback — or emits `error` when there is none. A unix socket is never sealed |
|
|
95
|
+
| **Sealed names** | Every resolution path asks the same gate — `lookup`, every `resolve*`, `reverse`, `lookupService` (by `node:dns`, `node:dns/promises` or `Bun.dns`, a named import bound before the seal included), both `Resolver` classes and `Bun.dns.prefetch`: a host a `mockFetch` route names answers an address query (`lookup`, `A`, `ANY`) with `MOCKED_HOST_ADDRESS` (`11.11.11.11`, public, so an SSRF screen such as `screenDial` passes it and the dial it pins still meets the mock by its `Host`) and any other record type (`MX`, `TXT`, …) with `X_TEST_NETWORK_SEALED` — a mock declares an endpoint, not a zone; this machine, an `allowHost` name and a `lookup` of an address literal resolve for real (a `reverse` of a public address is sealed: it is a query); offline refuses every name (`X_TEST_NETWORK_OFFLINE`); any other name is `X_TEST_NETWORK_SEALED` — its fix opens with `mockFetch(…)` for an address query and with `allowHost('<name>')` for a record or reverse query, which no mock answers. A RegExp route names a host it matches at the origin or spells in its source |
|
|
96
96
|
| **Fixed timezone + locale** | `UTC` and `en-US` unless a test declares otherwise; a tz-dependent bug fails deterministically |
|
|
97
97
|
| **Ordered concurrency** | job workers in tests run deterministically; `runJobs()` drains the queue synchronously |
|
|
98
98
|
| **Per-test reset** | before EVERY test, not every file, the preload puts the jobs event bus back (`installPerTestReset()`): an answer one test published never resumes the next test's waiting run, with or without `runJobs`. A test that never loaded `@ultimat3/jobs` pays nothing. `As of 2026-10` |
|
|
@@ -619,7 +619,8 @@ A `compensates: true` job is also forced to fail for good and killed while it un
|
|
|
619
619
|
`echoProvider()` answers text; it cannot call a tool. A test that drives an `agent()` through its tools scripts the model with `scriptedProvider({ turns })`: each provider call answers the next turn, and `.seen` keeps every request in order.
|
|
620
620
|
|
|
621
621
|
```ts
|
|
622
|
-
import {
|
|
622
|
+
import { meteredRun, providerGateway, scriptedProvider } from '@ultimat3/ai';
|
|
623
|
+
import { installAiGateway } from '@ultimat3/ai/adapter';
|
|
623
624
|
|
|
624
625
|
declare const draft: { id: string; orgId: string };
|
|
625
626
|
declare function reviewDraft(input: { postId: string; orgId: string }): Promise<unknown>;
|
|
@@ -631,7 +632,7 @@ const model = scriptedProvider({
|
|
|
631
632
|
{ answer: { verdict: 'revise', notes: 'Say which rounding rule the body defends.' } },
|
|
632
633
|
],
|
|
633
634
|
});
|
|
634
|
-
|
|
635
|
+
const release = installAiGateway(providerGateway({ providers: [model] })); // release() in the afterEach
|
|
635
636
|
|
|
636
637
|
// The agent's turns and its tool's model call, as one bill: three calls.
|
|
637
638
|
const { billed } = await meteredRun(() => reviewDraft({ postId: draft.id, orgId: draft.orgId }));
|
|
@@ -747,7 +748,7 @@ empty `users` are `X_INVARIANT`.
|
|
|
747
748
|
|
|
748
749
|
## Log lines under test
|
|
749
750
|
|
|
750
|
-
| `LOG_LEVEL` | The terminal shows | A
|
|
751
|
+
| `LOG_LEVEL` | The terminal shows | A sink a test installs with `installLogSink` receives |
|
|
751
752
|
|---|---|---|
|
|
752
753
|
| unset | nothing | `info` and above |
|
|
753
754
|
| `info` · `debug` · `trace` | that level and above | that level and above |
|
|
@@ -759,7 +760,7 @@ terminal and never the logger, so a test asserting on an `info` audit line passe
|
|
|
759
760
|
|
|
760
761
|
## An N+1 fails the test it happened in
|
|
761
762
|
|
|
762
|
-
`x dev` warns about a query loop; CI is where nobody is watching. Destructuring `statements` installs the same detector in **
|
|
763
|
+
`x dev` warns about a query loop; CI is where nobody is watching. Destructuring `statements` installs the same detector in **strict** mode for the length of one test:
|
|
763
764
|
|
|
764
765
|
```ts
|
|
765
766
|
test('the feed reads its authors once', async ({ statements }) => {
|
|
@@ -770,7 +771,7 @@ test('the feed reads its authors once', async ({ statements }) => {
|
|
|
770
771
|
});
|
|
771
772
|
```
|
|
772
773
|
|
|
773
|
-
The loop
|
|
774
|
+
The loop runs to its end and the verdict is raised when the fixture is disposed — the bus never lets an observer fail the read it observes — naming the shape and its count; `statements.verdicts()` reads it earlier. Opting in is naming the fixture: there is no `strict: true` to remember and no switch left on for the next file.
|
|
774
775
|
|
|
775
776
|
| What | Rule |
|
|
776
777
|
|---|---|
|
|
@@ -789,64 +790,73 @@ await expectedQueryLoop('one indexed lookup per searchable field', () => searchE
|
|
|
789
790
|
|
|
790
791
|
## Factories
|
|
791
792
|
|
|
792
|
-
One row shape per entity, deterministic, with named variations. `defineFactory` is the only entry point — there is no bare `factory()`.
|
|
793
|
+
One row shape per entity, deterministic, with named variations, FactoryBot-grade (`As of 31.0.0`). `defineFactory` is the only entry point — there is no bare `factory()`.
|
|
793
794
|
|
|
794
795
|
```ts
|
|
795
|
-
import {
|
|
796
|
-
import {
|
|
796
|
+
import { belongsTo, defineFactory, hasMany } from '@ultimat3/testing';
|
|
797
|
+
import { entity, text, timestamp, uuid } from '@ultimat3/entity';
|
|
797
798
|
|
|
798
|
-
const
|
|
799
|
-
|
|
799
|
+
const orgs = entity('orgs', {
|
|
800
|
+
columns: { id: uuid().primaryKey(), slug: text(), name: text() },
|
|
801
|
+
});
|
|
802
|
+
const posts = entity('posts', {
|
|
800
803
|
columns: {
|
|
801
804
|
id: uuid().primaryKey(),
|
|
802
|
-
orgId: uuid().references(() =>
|
|
805
|
+
orgId: uuid().references(() => orgs.id).tenant(),
|
|
806
|
+
slug: text(),
|
|
803
807
|
title: text(),
|
|
804
|
-
|
|
805
|
-
|
|
808
|
+
status: text().default('draft'),
|
|
809
|
+
publishedAt: timestamp().nullable(),
|
|
806
810
|
},
|
|
807
811
|
});
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
812
|
+
const comments = entity('comments', {
|
|
813
|
+
columns: {
|
|
814
|
+
id: uuid().primaryKey(),
|
|
815
|
+
orgId: uuid().references(() => orgs.id).tenant(),
|
|
816
|
+
postId: uuid().references(() => posts.id),
|
|
817
|
+
body: text(),
|
|
818
|
+
},
|
|
811
819
|
});
|
|
812
820
|
|
|
813
|
-
const
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
})
|
|
822
|
-
|
|
823
|
-
published: { published: true },
|
|
824
|
-
popular: (index) => ({ views: index * 100 }),
|
|
821
|
+
const orgFactory = defineFactory(orgs, {
|
|
822
|
+
defaults: (n, ids) => ({ id: ids.uuid(), slug: `org-${n}`, name: `Org ${n}` }),
|
|
823
|
+
});
|
|
824
|
+
const postBase = defineFactory(posts, {
|
|
825
|
+
defaults: (n, ids) => ({ id: ids.uuid(), orgId: '', slug: `post-${n}`, title: `Post ${n}` }),
|
|
826
|
+
traits: { published: { status: 'published', publishedAt: new Date('2026-01-05T09:00:00Z') } },
|
|
827
|
+
transient: { shout: false },
|
|
828
|
+
belongsTo: { org: belongsTo(orgFactory, 'orgId') },
|
|
829
|
+
afterBuild: (post, { transient }) => {
|
|
830
|
+
if (transient.shout) post.title = post.title.toUpperCase();
|
|
825
831
|
},
|
|
826
|
-
associations: { orgId: associate(orgFactory, (row) => row.id) },
|
|
827
832
|
});
|
|
833
|
+
const commentFactory = defineFactory(comments, {
|
|
834
|
+
defaults: (n, ids) => ({ id: ids.uuid(), orgId: '', postId: '', body: `Comment ${n}` }),
|
|
835
|
+
belongsTo: { post: belongsTo(postBase, 'postId') },
|
|
836
|
+
});
|
|
837
|
+
const postFactory = postBase.extend({ hasMany: { comments: hasMany(commentFactory, 'postId') } });
|
|
838
|
+
|
|
839
|
+
postFactory.build(); // memory: org built alongside, nothing written
|
|
840
|
+
const post = await postFactory.with('published').create({ comments: 2 }); // the STORED row
|
|
841
|
+
const org = await orgFactory.create();
|
|
842
|
+
await postFactory.createList(3, { org }); // reuses that org, makes none
|
|
843
|
+
postFactory.attributesFor(); // an action input: no id, no orgId
|
|
828
844
|
```
|
|
829
845
|
|
|
830
|
-
|
|
|
846
|
+
| | |
|
|
831
847
|
|---|---|
|
|
832
|
-
| `build(
|
|
833
|
-
| `
|
|
834
|
-
| `
|
|
835
|
-
|
|
|
836
|
-
| `
|
|
837
|
-
| `traits`
|
|
838
|
-
|
|
|
839
|
-
| `
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
A view from `with()` **shares the base sequence**, so ids never repeat across views of one factory. An unknown trait throws `X_TEST_FACTORY_TRAIT_UNKNOWN` **at the `with()` call**, not three calls later, and `cause` lists every declared trait — a typo and a trait nobody added have the same symptom, and the list is what separates them.
|
|
846
|
-
|
|
847
|
-
### Associations
|
|
848
|
-
|
|
849
|
-
A column whose value comes from another factory, built with the **same strategy**: `build()` builds the parent, `create()` creates it. Parents are created **sequentially, never `Promise.all`** — concurrent parents would interleave draws from the shared seeded generators and the ids would stop being reproducible. An association is skipped entirely when the caller supplies that column.
|
|
848
|
+
| **strategies** | `build` (memory, never a database), `create` (writes, answers the row AS STORED: declared defaults, generated columns, timestamps), `attributesFor` (an input: no primary key, no `belongsTo` key, no transient), `buildList` / `createList` |
|
|
849
|
+
| **sequence** | `index` (`n` above), per factory, shared by every `with()` view and `extend()` child — ids never repeat |
|
|
850
|
+
| **trait** | a named partial (or `(n, ids, transient) => partial`). `with('a', 'b')` composes left to right; a call's override wins. An undeclared one fails at `with()` (`X_TEST_FACTORY_TRAIT_UNKNOWN`), and `cause` lists every declared trait |
|
|
851
|
+
| **transient** | declared defaults a call may override; read by `defaults`, traits and callbacks; never written |
|
|
852
|
+
| **callbacks** | `afterBuild(row, ctx)` on both strategies before any write; `afterCreate(storedRow, ctx)` after the row and its children are stored |
|
|
853
|
+
| **inheritance** | `factory.extend({ defaults, traits, transient, hasMany, afterBuild, afterCreate })` — same table, same sequence, its defaults over the parent's, callbacks chained after |
|
|
854
|
+
| **`belongsTo`** | the parent made with the child's strategy; `{ org: row }` reuses a row; `{ orgId }` makes none. The `defaults` must name the key, so a key that is not a column does not compile. Parents are made **sequentially, never `Promise.all`**: concurrent parents would interleave draws from the seeded generators |
|
|
855
|
+
| **`hasMany`** | `{ comments: 2 }` or `{ comments: [{ body: 'a' }, {}] }`: made after the parent, key set from the stored parent; on the answer as a non-enumerable `post.comments`, so the row itself `toEqual`s a read of the table |
|
|
856
|
+
| **tenant** | the tenant column follows the parent; the tenant's own association resolves first, so a comment, its post and its post's org share one org |
|
|
857
|
+
| **seeded per table** | the default seed is derived from the table name, so two tables never draw the same uuid |
|
|
858
|
+
| **lint** | `await assertFactoriesValid({ orgFactory, postFactory, … })` (or `lintFactories`, which answers the findings): every factory and each trait alone, built and created against its entity on a throwaway driver; one `X_TEST_FACTORY_INVALID` naming each `factory.with('trait').strategy()` and the entity's own code |
|
|
859
|
+
| **seeds** | `factorySeed('demo', async ({ id }) => { await postFactory.create({ org: await orgFactory.create({ id: id('org:acme') }) }) })` is a `Seed` (`x db seed demo`, or `.run({ driver })`): every sequence restarts, every write is the seed's idempotent insert — a replay writes nothing |
|
|
850
860
|
|
|
851
861
|
### Determinism
|
|
852
862
|
|
|
@@ -858,14 +868,17 @@ A column whose value comes from another factory, built with the **same strategy*
|
|
|
858
868
|
|
|
859
869
|
### Persisting
|
|
860
870
|
|
|
861
|
-
`create()`
|
|
871
|
+
`create()` writes through the entity's own repository on `defaultDriver()` — no setup for an app on the default driver. An app that names its own driver installs it once, in its test preload:
|
|
862
872
|
|
|
863
873
|
```ts
|
|
864
874
|
// scripts/test-setup.ts
|
|
865
|
-
|
|
875
|
+
import { entityPersister, usePersister } from '@ultimat3/testing';
|
|
876
|
+
import { driver } from '@app/db';
|
|
877
|
+
|
|
878
|
+
usePersister(entityPersister({ driver })); // or { client }
|
|
866
879
|
```
|
|
867
880
|
|
|
868
|
-
|
|
881
|
+
`build()` needs no persister. `clearPersister()` and `persisterInstalled()` round out the seam.
|
|
869
882
|
|
|
870
883
|
### A whole graph: `seedGraph`
|
|
871
884
|
|
|
@@ -930,7 +943,7 @@ describe(testName('unit', 'publishPost'), () => {
|
|
|
930
943
|
|
|
931
944
|
`behavesLike` wraps the body in `describe('behaves like <name>')`, so a failure reads `publishPost > behaves like an authenticated action > denies an anonymous actor` — the subject and the contract both named. Because it calls `describe`, it belongs at declaration scope and never inside a test body. The body runs once per `behavesLike` call.
|
|
932
945
|
|
|
933
|
-
|
|
946
|
+
Every adapter port's contract ships as shared examples on `@ultimat3/testing/conformance` — never `.` (31.0.0, Upgrading #46), one suite per `ADAPTER_PORTS` row, named as its `conformance` field: `behavesLike(jobDriverConformance, () => myDriver)` holds a custom `JobDriver` to claim / ack / nack, the claim fence, lease expiry and the burial of a row whose lease lapsed on its final attempt (`onExhausted`, `dropExhausted`); `behavesLike(budgetStoreConformance, () => myStore)` races 24 concurrent `take`s on one key against an `@ultimat3/ai` `BudgetStore`. Every suite and its subject: [the README's table](https://github.com/developerz-ai/ultimate/blob/main/packages/testing/README.md#conformance-a-ports-contract); per port, with the reference to copy: [Adapters](Adapters).
|
|
934
947
|
|
|
935
948
|
## Generated scaffolds
|
|
936
949
|
|
|
@@ -1000,7 +1013,7 @@ shape, same unreached code. `As of 2026-11`.
|
|
|
1000
1013
|
| A job's org | the field(s) its `tenant(input)` reads — any name, nested, left out of the draw, or under a parent the draw left out (a scoped backfill's `payload.input.orgId`) — are set to the tenant it is enqueued in, found by reading them: A's for the control, B's for the tenant proof (B's own job, carrying A's ids). A `tenant` no input field moves (one fixed org) is `unreached`, `X_JOB_TENANT_MISMATCH`, its `fix:` the declaration: `tenant: (input) => input.orgId` |
|
|
1001
1014
|
| A job's run | its own execution alone: enqueued on a queue holding nothing else, run by one worker pass. What it enqueues is left queued, as an action's is — an `enqueue` effect on its record, searched by the tenant proof, never run in its room. Its `statements`, effects, verdict and scale and plan sweeps are its own body's: a job that queues one child per row is flat, a body that reads each row is still `X_QUERY_SCALES_WITH_ROWS`. A child is judged as its own primitive. The crash proof too: its clean and killed runs claim only the job's own row, a child compared as its `enqueue:` effect |
|
|
1002
1015
|
| A job's failure | judged by the action rule: a coded refusal under 500 (an app's 409) is `unreached` under its own code, never a defect; an uncoded throw or a coded 5xx is `X_CONTRACT_DEFECT` |
|
|
1003
|
-
| Async input | an override's `input` may be `async`: it is awaited inside the call's request, as the call's actor, so it can mint what the action checks (a one-time token, a passkey assertion).
|
|
1016
|
+
| Async input | an override's `input` may be `async`: it is awaited inside the call's request, as the call's actor, so it can mint what the action checks (a one-time token, a passkey assertion). App code in it that enqueues always has a job driver. In the control and the scale sweep it binds on the queue of the call it feeds, so a job it enqueues is there when the call looks it up by id (`jobDriver()`, a cancel, a requeue); only what the CALL adds counts as the primitive's `enqueue` effect, never what the input queued. The tenant proof's first input binds on a queue of its own: it feeds B's calls, each on B's own queue (`As of 2026-11-08`). Its rows are committed, as the call's are: a unique value it inserts is drawn per call. What it sends — a select, a row, a mail — is never the primitive's: each call is recorded alone, so it is not in the record's `statements` or `effects` and the plan sweep never plans it as the primitive's. One that throws is that primitive `unreached` under the throw's own code (an uncoded one `X_EXERCISE_INPUT_THREW`), its `fix` the entry to repair; the rest of the pass runs (`As of 2026-11-08`). `x drill`'s load skips an `async` input and says why |
|
|
1004
1017
|
| Room | network sealed, mail captured, jobs in memory, clock frozen — from before the app loads and the scratch database boots, as `bun test`'s preload does, so the embedded Postgres never sees its clock jump. A call out is refused and counted, so the primitive is `unreached` |
|
|
1005
1018
|
| Cost | rows are primitives × tables; statements are not: the graph is written one `insertAll` per table, each tenant-proof snapshot is one statement, and a primitive reads only its own pair's rows of the graph |
|
|
1006
1019
|
| Overrides | `apps/web/exercise.ts`: `export const exercise = defineExercise({ publishPost: { actor, input }, sendInvoice: { off: '<why>' } })`. The same value is what every contract test hands `.contract({ exercise })` ([one declaration](#the-exercise-assertion)). A key is a registered name or a kind-qualified one — `'job:eraseAccount'`, `'action:eraseAccount'`, `'query:…'` — which is that kind's alone and wins over the bare name — in `x exercise`, the contract step and `x drill` alike: an action and a job sharing a name each get their own entry, and the paste line a shared name prints is the qualified key (`As of 2026-11-08`). An unknown name, or a kind the name is not registered as, is `X_DECLARATION_UNKNOWN`; a blank `off` is `X_CONTRACT_EXERCISE_UNDECLARED` |
|
|
@@ -1105,7 +1118,7 @@ Source: `packages/testing/src/scale-sweep*.ts`, `plan-oracle.ts`, `plan-sweep*.t
|
|
|
1105
1118
|
| Sweep | What | Red |
|
|
1106
1119
|
|---|---|---|
|
|
1107
1120
|
| 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)` |
|
|
1108
|
-
| plans | every distinct statement whose first relation is an app table, `PREPARE`d and explained as a generic plan with `enable_seqscan`, `enable_bitmapscan`, `enable_sort` off
|
|
1121
|
+
| 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 |
|
|
1109
1122
|
|
|
1110
1123
|
With the planner's scans and sorts disabled it picks one only when no index can answer, so the
|
|
1111
1124
|
verdict reads the schema on empty tables — no volume, no statistics. Never red: `scale.verdict`
|
package/wiki/Troubleshooting.md
CHANGED
|
@@ -23,7 +23,7 @@ The `--json` form is the same content as the terminal form. Paste the JSON into
|
|
|
23
23
|
| Symptom | Likely cause | Fix |
|
|
24
24
|
|---|---|---|
|
|
25
25
|
| Process exits in ~40ms, `X_ENV_MISSING` | a key in the `defineEnv` schema is missing, or present but fails its schema (short secret, non-URL, bad enum) | the cause names every offending key and its constraint at once; `x doctor --json` lists them too |
|
|
26
|
-
| `X_CONFIG_INVALID` at load | `app.config.ts` field invalid — `defaultLocale` not in `locales`, `db.pool < 1`, non-IANA `timeZone`,
|
|
26
|
+
| `X_CONFIG_INVALID` at load | `app.config.ts` field invalid — `defaultLocale` not in `locales`, `db.pool < 1`, non-IANA `timeZone`, a removed key such as `realtime.transport` | `x config show --json`, then edit the field named in `cause` |
|
|
27
27
|
| `X_ROLE_INVALID` | `ROLE` is not one of `web sync worker scheduler migrate replicator all` | fix the env var on that service |
|
|
28
28
|
| `X_BUN_VERSION` | below the Bun floor, `>= 1.4.4` (`engines.bun`) | `bun upgrade` |
|
|
29
29
|
| Container starts then loops | `/readyz` failing, not `/healthz` — a registered check answers `failing`, and which one is in the body | `curl /readyz` **from the container itself** (`docker exec`, `kubectl exec`, a port-forward — the detail goes to `healthDetailPeers`, default `['loopback']`) and read `checks`, a map of name → `ok`/`failing`: `database` is registered always, `transport` whenever it can report a connection, so a disconnected NATS node fails on that one. Read `registered` with it: `0` means nothing was checked, so the 200 meant only that the socket was bound |
|
|
@@ -163,7 +163,7 @@ bunx x dev --once --port 3100
|
|
|
163
163
|
```text
|
|
164
164
|
{"ts":"2026-11-03T16:48:57.124Z","level":"info","msg":"ultimate web listening on http://localhost:3100"}
|
|
165
165
|
{"ts":"2026-11-03T16:48:57.118Z","level":"info","msg":"sync node ready","buildId":"e6af64a2077e5d60","path":"/_x/sync"}
|
|
166
|
-
{"ts":"2026-11-03T16:48:57.134Z","level":"info","msg":"jobs.worker.started","workerId":"worker-01a1a250-…","queues":["
|
|
166
|
+
{"ts":"2026-11-03T16:48:57.134Z","level":"info","msg":"jobs.worker.started","workerId":"worker-01a1a250-…","queues":["default"]}
|
|
167
167
|
{"ts":"2026-11-03T16:48:57.137Z","level":"info","msg":"jobs.scheduler.started","tasks":1}
|
|
168
168
|
{"ts":"2026-11-03T16:48:57.142Z","level":"info","msg":"live feed in-process","detail":"the embedded database has no walsender; repository writes in this process reach subscribers"}
|
|
169
169
|
roles web, sync, worker, scheduler
|
|
@@ -86,7 +86,7 @@ export const dailyDigest = task({
|
|
|
86
86
|
|
|
87
87
|
### Registration names it
|
|
88
88
|
|
|
89
|
-
Export names become primitive names, and only `defineApi`
|
|
89
|
+
Export names become primitive names, and only `defineApi` stamps them. A task no `defineApi` lists keeps a positional name (`anonymous-task-1`, enqueuing `anonymous-job-2`); `x verify`'s `manifest` step refuses that job as `X_JOB_UNREGISTERED`. With the generator's edit to `apps/web/api/index.ts` in place:
|
|
90
90
|
|
|
91
91
|
```bash
|
|
92
92
|
bunx x tasks list
|
|
@@ -221,7 +221,7 @@ Scaling the two serving roles is the next rung, and it is not an edit to this fi
|
|
|
221
221
|
| `/metrics` on the **app** port | `X_ROUTE_NOT_FOUND`, and that is deliberate. Every role — `web` included — serves `/metrics` on `METRICS_PORT`, default **9090**, because the Helm ingress routes `/` with no path exclusion and metrics on 3000 would be public. Scrape `http://<host>:9090/metrics`, not `:3000/metrics` |
|
|
222
222
|
| `x logs tail` | planned — `X_NOT_IMPLEMENTED`, with `x dev` → the `/_x` timeline panel as its fix |
|
|
223
223
|
| `x status` | planned — `x doctor --json` is the shipped answer |
|
|
224
|
-
| OTLP export, on by default |
|
|
224
|
+
| OTLP export, on by default | on when **configured**: the production boot (`apps/web/server.ts`, every `ROLE`) wires traces, metrics and logs (OTLP/HTTP JSON) from `OTEL_EXPORTER_OTLP_ENDPOINT` set to a collector's HTTP receiver (`:4318` — `:4317` is gRPC and is refused). Unset, nothing leaves the process; there is no code to write |
|
|
225
225
|
| a Helm chart in your app | **`x new` writes one** `As of 2026-11-03` — `docker/helm`, 10 files — so `x deploy --method helm` works here. On 3.0.0 and below it writes none: copy [`docker/helm`](https://github.com/developerz-ai/ultimate/tree/main/docker/helm) from the framework repo, or stay on `--method compose` |
|
|
226
226
|
|
|
227
227
|
## Next
|
|
@@ -24,7 +24,7 @@ Skipping a rung to look serious buys a second product to maintain. A Kubernetes
|
|
|
24
24
|
|---|---|
|
|
25
25
|
| `DATABASE_URL`, `REDIS_URL`, `NATS_URL`, `S3_ENDPOINT` | any file under `apps/` or `packages/` |
|
|
26
26
|
| `ROLE` — which process this container is | the eight primitives, their shapes, their authz |
|
|
27
|
-
| driver constructors at boot (`
|
|
27
|
+
| driver constructors at boot (`apps/<app>/runtime.ts`, `setDbClient`, `configureTelemetry`) | call sites: `db()`, `ctx.jobs.enqueue()`, `query()`, `live()` |
|
|
28
28
|
| replica counts, HPA targets | the manifest, the OpenAPI, the typed client, the MCP tools |
|
|
29
29
|
| `app.config.ts` declarations | migrations already applied |
|
|
30
30
|
|
|
@@ -95,27 +95,27 @@ Per-role HPAs target `rps`, `connections` and `queue_demand` — CPU is a laggin
|
|
|
95
95
|
| custom Kubernetes over a managed chart | node pools with real taints, affinity to node-local storage, an ingress you control | wanting the chart to look impressive |
|
|
96
96
|
| distributed SQL over one Postgres | multi-region **write** locality; surviving a zone loss with no manual failover | write throughput one Postgres has not actually failed to deliver |
|
|
97
97
|
|
|
98
|
-
Observability is the part that is not optional here, and the framework's half is done `As of 2026-
|
|
98
|
+
Observability is the part that is not optional here, and the framework's half is done `As of 2026-11`: there is no code to write. The production boot (`apps/web/server.ts`, every `ROLE`) reads the variables the OpenTelemetry SDKs read and wires all three signals — traces, metrics and **logs** — from them at boot:
|
|
99
99
|
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
```sh
|
|
101
|
+
OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4318 # all three signals
|
|
102
|
+
OTEL_LOGS_EXPORTER=none # optional: one signal off
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
-
Point
|
|
105
|
+
Point it at your collector's **HTTP** receiver, `:4318` — `:4317` is gRPC and is refused with `X_OTLP_PROTOCOL_UNSUPPORTED`, permanently, because HTTP/2 plus protobuf is a dependency and a second wire format. A credential goes in `OTEL_EXPORTER_OTLP_HEADERS`, never in the URL (`X_OTLP_ENDPOINT_INVALID`). `OTEL_SDK_DISABLED=true` turns all three off. Metrics also stay scrapeable at `METRICS_PORT` if you prefer an agent. [`docs/ops/03-observability.md`](https://github.com/developerz-ai/ultimate/blob/main/docs/ops/03-observability.md) says what to scrape and what to alert on; anything else that wants the stream subscribes to it — `subscribe('span.end', …)`, `subscribe('log.record', …)` ([Observability](Observability)).
|
|
106
106
|
|
|
107
107
|
## The seams, so nothing surprises you
|
|
108
108
|
|
|
109
109
|
| Concern | Interface | Decided by |
|
|
110
110
|
|---|---|---|
|
|
111
111
|
| rows | `@ultimat3/db` · `DbClient` | `DATABASE_URL` — unset is PGlite, and PGlite is `x dev` only |
|
|
112
|
-
| job queue | `@ultimat3/jobs` · `JobDriver` | `
|
|
112
|
+
| job queue | `@ultimat3/jobs` · `JobDriver` | `postgresJobDriver()`, installed by the boot; another is `jobs:` in `apps/<app>/runtime.ts` — there is no `jobs.driver` config line, and 5.0.0 deleted the one that never worked. Redis is an interface-complete stub that throws `X_NOT_IMPLEMENTED`; there is no NATS job driver since 25.0.0 |
|
|
113
113
|
| realtime fanout | `@ultimat3/realtime` · `Transport` | `NATS_URL` |
|
|
114
114
|
| change feed | `@ultimat3/realtime` · `ChangeFeed` | `REPLICATION_*` |
|
|
115
115
|
| cache | `@ultimat3/cache` · `CacheTier` | `cache.tiers` + `REDIS_URL` |
|
|
116
116
|
| object storage | `@ultimat3/storage` · `Driver` | `S3_ENDPOINT` |
|
|
117
117
|
| mail | `@ultimat3/mail` · `Driver` | mail env |
|
|
118
|
-
| tracing | `@ultimat3/core` · `SpanExporter` | `
|
|
118
|
+
| tracing | `@ultimat3/core` · `SpanExporter`, a `span.end` subscriber | `OTEL_EXPORTER_OTLP_ENDPOINT` — unset exports nothing |
|
|
119
119
|
|
|
120
120
|
Every one keys on env or a boot-time constructor. One image resolves `x dev`, a Compose host and a cluster identically.
|
|
121
121
|
|