@ultimat3/cli 30.9.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 +1 -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 +47 -1
- 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 +29 -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 +65 -52
- 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
|
@@ -80,7 +80,7 @@ External brokers are not exempted: the outbox table stays the transactional reco
|
|
|
80
80
|
| `step.run(name, fn, { compensate })` | `compensate(output, { signal })` undoes the step if the run fails **for good** — never on a retry, a cancel, a drain or a suspension. Needs `job({ compensates: true })`, else `X_JOB_DECLARATION_INVALID`. See [Compensation](#compensation) |
|
|
81
81
|
| `step.run(name, fn, { once: true })` | at most once, ever: `started` is persisted **before** `fn`; a replay finding it (or `failed`) without `completed` stops with terminal `X_STEP_OUTCOME_UNKNOWN` and never calls `fn`. `x jobs resolve-step <id> <step> --ran --output '<json>'` or `--not-ran`, then `x jobs retry <id>` |
|
|
82
82
|
| `step.sleep(duration)` | persists a wake time, releases the worker, and the job resumes in a fresh process. No held connection, no timer in memory. `'3d'` is safe |
|
|
83
|
-
| `step.waitForEvent(name, event, { schema, match, timeout })` | suspends until a matching event arrives (webhook, another action, a user click) or the timeout fires. Returns the payload parsed by the required `schema`, or `undefined` on a timeout. A payload the schema refuses is `X_JOB_EVENT_INVALID`, terminal, on a hit or a replay. `publishEvent` inside a transaction commits and rolls back with it. "After the wait began" is read off the event bus's own clock — the database's, on the stored bus — so a worker whose clock runs ahead still sees an event published a moment later. **On the Postgres bus the publish wakes its waiters in the same statement** (as booted over the app's own queue): the run resumes on the worker's next pass, and the backstop poll is 15 min (96 replays per 24 h wait, was 2,880). Any other bus polls every 30 s. A declared `eventPoll` wins either way |
|
|
83
|
+
| `step.waitForEvent(name, event, { schema, match, timeout })` | suspends until a matching event arrives (webhook, another action, a user click) or the timeout fires. Returns the payload parsed by the required `schema`, or `undefined` on a timeout. A payload the schema refuses is `X_JOB_EVENT_INVALID`, terminal, on a hit or a replay. `publishEvent` inside a transaction commits and rolls back with it. **An event committed after the wait began is that wait's, whatever its stamp**: the wait records the database snapshot it began under and also matches every event that snapshot could not see. "After the wait began" is read off the event bus's own clock — the database's, on the stored bus — so a worker whose clock runs ahead still sees an event published a moment later. **On the Postgres bus the publish wakes its waiters in the same statement** (as booted over the app's own queue): the run resumes on the worker's next pass, and the backstop poll is 15 min (96 replays per 24 h wait, was 2,880). Any other bus polls every 30 s. A declared `eventPoll` wins either way |
|
|
84
84
|
|
|
85
85
|
**The step is the retry unit, not the job.** A failure in `nudge` re-enters `run`, replays `provision` and `welcome-email` from storage in microseconds, and retries only `nudge`. That is why an onboarding flow can retry on day 3 without re-provisioning or re-emailing.
|
|
86
86
|
|
|
@@ -204,13 +204,37 @@ export const syncCrm = job({
|
|
|
204
204
|
| `maxInFlight` | max simultaneous runs in **one worker process**, across every queue it serves — Sidekiq's `concurrency`. `jobs.maxInFlight` in `app.config.ts`, or `jobWorker({ maxInFlight })`; unset, no process cap | read before every claim, so a worker at the cap claims nothing; each run that ends frees one claim at once. The per-queue `jobs.concurrency` slots still bound each queue under it. A pass splits its room over the queues (`ceil(room / queues left)`), hands what an empty queue leaves to the next, and starts after the last queue served — no queue starves. `worker.stats().maxInFlight`, gauges `job_worker_in_flight` / `job_worker_capacity`. `0`, fractional, `NaN`, `Infinity`: `X_INVARIANT` / `X_CONFIG_INVALID` |
|
|
205
205
|
| `queue` | named pool; the `worker` role runs one pool per config (`WORKER_QUEUES=default,integrations`) | worker pool sizing, see [Deployment](Deployment) |
|
|
206
206
|
| `retry.attempts` / `backoff` | `'exponential' \| 'linear' \| 'fixed'` | driver scheduler |
|
|
207
|
-
| `retry.jitter` |
|
|
207
|
+
| `retry.jitter` | core's `JitterMode`: `'equal'` by default — half fixed, half rolled — so a job that has already failed twice is never handed a near-zero wait; `'none'` and `'full'` on request. A boolean was the v30 shape ([Upgrading](Upgrading) entry 60) | driver scheduler |
|
|
208
208
|
| a **`terminal`** thrown code | stops on the attempt that failed, before `attempts` is reached — the same code run again is the same answer, and the attempts left are a queue slot, a provider bill, or three more wrong passwords at a site that locks the account after three. `lastError` records `— not retried: this code is classified terminal`, so an early stop is never silent | the code's `retry` classification, `registerErrorRetry({ X_YOUR_CODE: 'terminal' })`. An **unclassified** code is unaffected |
|
|
209
209
|
| a **`retry-after`** thrown code | the responder's `meta.retryAfterSeconds` replaces the delay, clamped by `maxDelay` — never the attempt count | same |
|
|
210
210
|
| attempts exhausted | moves to dead-letter with the full step trace | `x jobs retry <id>` replays from the failed step |
|
|
211
211
|
|
|
212
212
|
A job over a tenant, queue or global cap, or over a `'wait'` concurrency cap, is **deferred, never dropped** — it stays queued with a later `runAt`. `whenBusy: 'fail'` is the one declared exception. `'wait'` holds the cap and states no order: a later enqueue can start first.
|
|
213
213
|
|
|
214
|
+
### A lock — `withLock()`
|
|
215
|
+
|
|
216
|
+
`withLock(key, fn, { ttl, wait?, poll?, store?, signal? })`: one holder fleet-wide, held as one slot `lock:<key>` in the job driver's `LeaseStore` (`x_job_leases` on Postgres) — no table of its own, no Redis. `fn` receives `{ key, token, signal }`. `As of 2026-11-09`.
|
|
217
|
+
|
|
218
|
+
| Fact | Meaning |
|
|
219
|
+
|---|---|
|
|
220
|
+
| `ttl` (required) | how long a dead holder keeps the key; renewed at ttl/3 while `fn` runs |
|
|
221
|
+
| `wait` (default one ttl; `0` = one try) | then `X_LOCK_NOT_ACQUIRED` (409, retryable), naming the holder |
|
|
222
|
+
| `token` | the FENCING token: a number the store hands this grant (the database's counter, never a clock), greater than every token any earlier holder of any key got. Write it beside whatever `fn` changes and refuse a write carrying a smaller one — that stops a holder that paused past its `ttl` (GC, a frozen VM) from writing after the next one took over |
|
|
223
|
+
| no renewal landing within the ttl, or one refused | `signal` aborts with `X_LOCK_LOST`; the call rejects with it even if `fn` resolved |
|
|
224
|
+
| no store | `X_LOCK_STORE_MISSING` — `jobs: postgresJobDriver()` in `runtime.ts`, or `{ store }` |
|
|
225
|
+
|
|
226
|
+
```ts
|
|
227
|
+
import { withLock } from '@ultimat3/jobs';
|
|
228
|
+
|
|
229
|
+
declare function sendDigest(orgId: string, options: { signal: AbortSignal }): Promise<void>;
|
|
230
|
+
declare const orgId: string;
|
|
231
|
+
|
|
232
|
+
await withLock(`digest:${orgId}`, ({ signal }) => sendDigest(orgId, { signal }), {
|
|
233
|
+
ttl: '2m',
|
|
234
|
+
wait: 0,
|
|
235
|
+
});
|
|
236
|
+
```
|
|
237
|
+
|
|
214
238
|
### One run per key
|
|
215
239
|
|
|
216
240
|
| Case under `whenBusy: 'fail'` | Answer |
|
|
@@ -499,6 +523,18 @@ export const exportMember = subjectExport({
|
|
|
499
523
|
generated person, and searches every stored row. Their value outside a `retain` is
|
|
500
524
|
`X_SUBJECT_ERASE_INCOMPLETE`, naming the table and column.
|
|
501
525
|
|
|
526
|
+
### `personalData()` coverage
|
|
527
|
+
|
|
528
|
+
Rule: `.personalData(kind)` on a column (`@ultimat3/entity`) adds NO second export or erase path — `subjectExport`/`subjectErase` stay the one. It is the proof that the declared subjects cover every marked column. `As of 2026-11-09`.
|
|
529
|
+
|
|
530
|
+
| Check (`@ultimat3/jobs`) | Refuses |
|
|
531
|
+
|---|---|
|
|
532
|
+
| `unerasedPersonalData(plan)` | a reached table whose `{ anonymize }` names fewer than every marked column — `X_PERSONAL_DATA_UNERASED`. `'delete'` clears the row; `{ retain: '<why>' }` is a stated reason |
|
|
533
|
+
| `unreachedPersonalData(plans)` | a marked entity no subject's walk reaches — `X_PERSONAL_DATA_UNREACHED` |
|
|
534
|
+
| `personalDataProblems()` | both, over every `defineSubject()` and every marked entity |
|
|
535
|
+
|
|
536
|
+
Enforced twice: a subject run refuses `X_PERSONAL_DATA_UNERASED` before it touches a row, and `x exercise` lists `X_PERSONAL_DATA_UNERASED` / `X_PERSONAL_DATA_UNREACHED` as findings. With an `auditSink` installed, `subjectErase` writes one `allowed` record per completed erase (`primitive: 'action'`, `surface: 'job'`, `input: { subject, run }` — the subject's entity and the run id, never the key, which an app may make an email) and one `failed` record per attempt that threw; a sink that refuses fails the run. At least once: a sink dedupes on the record's `idempotencyKey`, `<job>:<runId>`.
|
|
537
|
+
|
|
502
538
|
## Rollups and materialized views
|
|
503
539
|
|
|
504
540
|
Two factories over `job()`, two jobs, `As of 2026-11`. A time window over append-mostly rows is
|
|
@@ -566,6 +602,20 @@ export const refreshPostTotals = refreshView({
|
|
|
566
602
|
| `concurrently` | readers keep the old rows meanwhile; needs a unique index on the view (`.unique()`) |
|
|
567
603
|
| Refused at declaration | a table, a plain view, `concurrently` with no unique index — `X_JOB_REFRESH_VIEW_INVALID` |
|
|
568
604
|
|
|
605
|
+
## Rebuilding a search index — `reindex()`
|
|
606
|
+
|
|
607
|
+
`reindex({ name, entity, source, tenant, index? })` is a `backfill()` in two phases, one durable step per page. Rows: each row's `searchDocumentOf(entity, row)` goes to the `searchIndex` port (default: the installed one). Sweep: every document the index `list`s whose row `source` no longer reads — deleted while the index was down, moved to another tenant — is removed, tombstoned one millisecond above the listed version, so an id written again meanwhile keeps its newer document. `source` is the WHOLE table: a narrowed source empties the index of the rest. `tenant: 'none'` sweeps every tenant; a declared tenant, its own. Run it after swapping Postgres' built-in index for Meilisearch or Typesense, or after an index lost data. An entity with no `.searchable()` column is refused at declaration (`X_INVARIANT`). `As of 2026-11-10`.
|
|
608
|
+
|
|
609
|
+
## Partition maintenance — `partitions()`
|
|
610
|
+
|
|
611
|
+
`partitions({ name?, cron?, tz?, clock? })` keeps every `entity({ partitionBy })` table ready: one durable step per partitioned entity runs `@ultimat3/db`'s `maintainPartitions` — creation under a 5 s `lock_timeout` (`PARTITION_LOCK_TIMEOUT_MS`; a `55P03` is `X_DB_LOCK_TIMEOUT`, retryable, so a long report query delays the run rather than queueing every write behind ACCESS EXCLUSIVE on the parent), then each expired partition retired by `detach … concurrently` (outside any transaction, as Postgres requires) and dropped. It creates `ahead` partitions past the current one and retires those `retain` expired. A job plus a `.schedule` `task()` (`<name>.schedule`, default `'17 3 * * *'` UTC, daily), as `consumer()` carries `.supervisor`. `now` is the job's clock, so a test moves it; a second run at one instant changes nothing. Report: `{ tables: [{ table, created, dropped }] }`. Moving older rows in: enqueue it once with `{ from: '<the oldest row’s ISO instant>' }` — that run creates every partition back to it and retires nothing, and its idempotency key is its own, so it never folds into the schedule's — then run the `backfill()`. `As of 2026-11-09`.
|
|
612
|
+
|
|
613
|
+
```ts
|
|
614
|
+
import { partitions } from '@ultimat3/jobs';
|
|
615
|
+
|
|
616
|
+
export const maintainPartitions = partitions(); // list it in defineApi({ jobs })
|
|
617
|
+
```
|
|
618
|
+
|
|
569
619
|
## Outbound webhooks — `webhook()`
|
|
570
620
|
|
|
571
621
|
**An outbound webhook is a job: `webhook()` is a factory over `job()` that delivers one event to
|
|
@@ -666,9 +716,59 @@ Codes: `X_WEBHOOK_ENDPOINT_UNKNOWN`, `X_WEBHOOK_ENDPOINT_INVALID`, `X_WEBHOOK_EN
|
|
|
666
716
|
`X_WEBHOOK_EVENT_UNKNOWN`, `X_WEBHOOK_EVENT_INVALID`, `X_WEBHOOK_DELIVERY_FAILED`,
|
|
667
717
|
`X_WEBHOOK_DELIVERY_THROTTLED`, `X_WEBHOOK_DELIVERY_REJECTED` ([Error codes](Error-Codes)).
|
|
668
718
|
|
|
719
|
+
## Double-entry postings — `ledger()`
|
|
720
|
+
|
|
721
|
+
`ledger({ name, tenant, book })` is a factory over `job()`. Input: `{ key, entries: [{ account, amount: Money }], orgId? }`. The run refuses anything that is not balanced Money before a line is written, then writes every line in ONE durable step through the app's `LedgerBook`. No provider, account plan or currency policy ships (axiom 8). `As of 2026-11-09`.
|
|
722
|
+
|
|
723
|
+
| Rule | Code |
|
|
724
|
+
|---|---|
|
|
725
|
+
| each currency's entries sum to zero on their own (an FX posting balances its EUR legs and its USD legs separately) | `X_LEDGER_UNBALANCED` (422, terminal) |
|
|
726
|
+
| integer `minor`, an ISO 4217 currency, one `scale` per currency, a non-blank account, two entries or more | `X_LEDGER_ENTRY_INVALID` (422, terminal) |
|
|
727
|
+
| idempotent by key: the live key is `<name>:<key>`; `entityLedgerBook` is one `insert … on conflict (posting_key, line) do nothing`. A replay of the same lines writes 0 | — |
|
|
728
|
+
| the key is already stored with OTHER lines — another count, another line | `X_LEDGER_POSTING_CONFLICT` (409, terminal); nothing is written, because the new lines beside the stored ones would unbalance the book |
|
|
729
|
+
| `assertBalancedPosting(posting)` | the enqueuing action refuses at the request |
|
|
730
|
+
|
|
731
|
+
A provider's payment webhook is a `webhookReceiver()` whose `handle` enqueues the posting keyed by the provider's id: the receiver dedupes the delivery, the ledger dedupes the posting.
|
|
732
|
+
|
|
733
|
+
```ts
|
|
734
|
+
import type { LedgerBook } from '@ultimat3/jobs';
|
|
735
|
+
import { ledger, webhookReceiver } from '@ultimat3/jobs';
|
|
736
|
+
|
|
737
|
+
declare const book: LedgerBook; // entityLedgerBook({ driver, entity: ledgerLines }) in an app
|
|
738
|
+
declare function verifyPayment(bytes: Uint8Array, signature: string | null): {
|
|
739
|
+
id: string;
|
|
740
|
+
amountMinor: number;
|
|
741
|
+
currency: string;
|
|
742
|
+
};
|
|
743
|
+
|
|
744
|
+
export const postPayment = ledger({ name: 'payments.post', tenant: 'none', book: () => book });
|
|
745
|
+
|
|
746
|
+
export const paymentEvents = webhookReceiver({
|
|
747
|
+
name: 'payments.events',
|
|
748
|
+
path: '/hooks/payments',
|
|
749
|
+
tenant: 'none',
|
|
750
|
+
verify: (inbound) => {
|
|
751
|
+
const event = verifyPayment(inbound.bytes, inbound.headers.get('x-signature'));
|
|
752
|
+
return { eventId: event.id, payload: event };
|
|
753
|
+
},
|
|
754
|
+
handle: async ({ eventId, payload, step }) => {
|
|
755
|
+
const { amountMinor, currency } = payload as { amountMinor: number; currency: string };
|
|
756
|
+
await step.run('post', () =>
|
|
757
|
+
postPayment.enqueue({
|
|
758
|
+
key: eventId,
|
|
759
|
+
entries: [
|
|
760
|
+
{ account: 'cash', amount: { minor: amountMinor, currency } },
|
|
761
|
+
{ account: 'revenue', amount: { minor: -amountMinor, currency } },
|
|
762
|
+
],
|
|
763
|
+
}),
|
|
764
|
+
);
|
|
765
|
+
},
|
|
766
|
+
});
|
|
767
|
+
```
|
|
768
|
+
|
|
669
769
|
## Driver interface
|
|
670
770
|
|
|
671
|
-
One interface. **Job code never changes.** Step persistence hangs off the same object (`steps`), so it is identical on every implementation.
|
|
771
|
+
One interface. **Job code never changes.** Step persistence hangs off the same object (`steps`), so it is identical on every implementation. It is the `jobs` adapter port: the interface is on `@ultimat3/jobs/adapter`, `memoryJobDriver` is the driver to copy, `behavesLike(jobDriverConformance, () => yourDriver())` proves one, and `jobs:` in `apps/<app>/runtime.ts` wires it — [Adapters](Adapters#jobs). The bus `step.waitForEvent` resumes from (`eventBus`) and the store behind the outbox (`outboxStore`) are two more ports, swapped the same way and no other: [Adapters](Adapters#eventbus), [Adapters](Adapters#outboxstore).
|
|
672
772
|
|
|
673
773
|
```ts
|
|
674
774
|
export interface JobDriver {
|
|
@@ -702,9 +802,9 @@ Two implementations ship, `As of 25.0.0`: `postgresJobDriver()` and `memoryJobDr
|
|
|
702
802
|
| `postgres` (default) | **shipped** | always, up to ~thousands of jobs/sec. `x dev` runs it too, against the embedded PGlite | outbox is free (same DB, same tx); `SELECT ... FOR UPDATE SKIP LOCKED` claiming; zero extra infra |
|
|
703
803
|
| `memory` | **shipped**; there is no config value for any driver | tests and fixtures, through `memoryJobDriver()` | in-process; nothing survives a restart — which is why it was never a safe `x jobs drain` target |
|
|
704
804
|
|
|
705
|
-
**There is no `jobs.driver`, and 5.0.0 is where it went.** It accepted `'postgres' | 'redis' | 'nats'` and had **no reader anywhere** — boot always built `postgresJobDriver`, stated in [`packages/jobs/src/driver.ts`](https://github.com/developerz-ai/ultimate/blob/main/packages/jobs/src/driver.ts)'s own header. So setting it to `redis` changed nothing at all and you silently got Postgres, which is the more dangerous behaviour because nothing reports it. From 5.0.0 to 24.x a stale key still rode through untyped; **25.0.0 refuses it** at `defineConfig`, naming
|
|
805
|
+
**There is no `jobs.driver`, and 5.0.0 is where it went.** It accepted `'postgres' | 'redis' | 'nats'` and had **no reader anywhere** — boot always built `postgresJobDriver`, stated in [`packages/jobs/src/driver.ts`](https://github.com/developerz-ai/ultimate/blob/main/packages/jobs/src/driver.ts)'s own header. So setting it to `redis` changed nothing at all and you silently got Postgres, which is the more dangerous behaviour because nothing reports it. From 5.0.0 to 24.x a stale key still rode through untyped; **25.0.0 refuses it** at `defineConfig`, naming the driver seam. Deleting it from `app.config.ts` is the whole of the upgrade.
|
|
706
806
|
|
|
707
|
-
**The seam that does work is `setJobDriver
|
|
807
|
+
**The seam that does work is `jobs:` in `export const runtime = { … }`** (`apps/<app>/runtime.ts`; 31.0.0 deleted `setJobDriver`) — swap the driver, zero job-code change, which is what the interface buys; a test swaps one for itself with `await swapAdapter('jobs', driver)` from `@ultimat3/testing`. Every swappable backend works this way: [Adapters](Adapters). `redisJobDriver()` is the second durable driver (`As of 2026-10`, #710): `jobs: redisJobDriver()` on core's `redisClient()` — while Redis is down an `enqueue` is `X_DRIVER_UNAVAILABLE` at once, never a wait — imported from `@ultimat3/jobs/redis`, held to the same conformance suite as Postgres, without the operator surface (`x jobs show`, `retry`, `cancel`), backfill bookkeeping or fleet-wide `concurrency` — [`packages/jobs/README.md`](https://github.com/developerz-ai/ultimate/blob/main/packages/jobs/README.md#drivers) has the table. There is no NATS jobs driver.
|
|
708
808
|
|
|
709
809
|
**`x jobs drain` is planned, `As of 25.0.0`.** It exits `X_NOT_IMPLEMENTED` before the queue boots, pointing at `x jobs list --json`: with Postgres the one durable driver, there is nowhere to drain to. Its two former `--to` values, `redis` and `nats`, were all-throw stubs — until 2026-10 a drain leased the whole pending batch for five minutes, failed every enqueue and nacked it back, nothing moved, and no worker could claim those jobs meanwhile. 25.0.0 deleted the stubs and the unreachable drain body behind the planned answer. A drain that returns with a real second driver is new code, and owes the lesson of `--to memory`, a target until 2026-09: `memoryJobDriver()` is a `Map` inside the command's own process, so the drain enqueued each job into it, acked the durable row off the source, printed `ok: true`, and lost every copy when the command exited.
|
|
710
810
|
|
|
@@ -750,7 +850,7 @@ Every command supports `--json`. See [CLI reference](CLI-Reference).
|
|
|
750
850
|
| `X_IDEMPOTENCY_CONFLICT` | same key, different payload, or still in flight | fresh key for a different payload; otherwise retry after the first settles |
|
|
751
851
|
| `X_DRAINING` | the worker holding the job received SIGTERM — it is the reason on `ctx.signal`, and a body that unwinds on it is `interrupted` with the attempt uncounted | none — the job goes straight back to the queue and another worker claims it. Pass `ctx.signal` to outbound calls and `throwIfAborted(ctx)` between steps, so the body unwinds inside the drain budget instead of being killed at it |
|
|
752
852
|
| `X_FORBIDDEN` | the job's actor fails the originating action's policy | grant the permission, or enqueue as a system actor |
|
|
753
|
-
| `X_NOT_IMPLEMENTED` | introspection or the operator surface reached a driver with no `introspect` — a hand-rolled one |
|
|
853
|
+
| `X_NOT_IMPLEMENTED` | introspection or the operator surface reached a driver with no `introspect` — a hand-rolled one | drop the `jobs:` field from `apps/<app>/runtime.ts` so the boot installs `postgresJobDriver()`, or `installJobDriver(memoryJobDriver())` from `@ultimat3/jobs/adapter` in a test. There is no config line to edit: `jobs.driver` was deleted in 5.0.0 because it never had a reader |
|
|
754
854
|
|
|
755
855
|
Full index: [Error codes](Error-Codes). Verbatim error shapes live in each package's `src/errors.ts`.
|
|
756
856
|
|
|
@@ -778,6 +878,7 @@ What a crash does to a job is asked by `crashProof(job, input)` — killed at ev
|
|
|
778
878
|
## Rules
|
|
779
879
|
|
|
780
880
|
- Never assume a job runs once. Assume at-least-once. A `backfill()`'s `handle` is the same rule one level down: it runs *before* its checkpoint lands, so an attempt cancelled between the two hands that page to the next one — write through `upsertAll`, `updateWhere` or a statement whose second run changes nothing.
|
|
881
|
+
- At-least-once has two JS-shaped edges. A body that ignores `ctx.signal` keeps running past a lost fleet slot, so `concurrency` is exceeded until it returns. A synchronous step that blocks the event loop longer than the 30 s visibility timeout starves the heartbeat: the lease lapses and another worker runs the job again. Await I/O, honour `signal`, and split CPU work into steps.
|
|
781
882
|
- Never put durable business state only in the payload.
|
|
782
883
|
- Never do slow work inline in an action — enqueue a job.
|
|
783
884
|
- A job never renders, redirects, or reads headers. Actor and tenant come from `ctx`.
|
package/wiki/Known-Gaps.md
CHANGED
|
@@ -22,7 +22,7 @@ are on an earlier version, treat those rows as open and take the workaround. `[U
|
|
|
22
22
|
truth for what the next release carries, and most of what it fixes was never a row here. Read that section rather than this sentence: `grep -n '^## '
|
|
23
23
|
CHANGELOG.md` finds its bounds, and it changes on any commit.
|
|
24
24
|
|
|
25
|
-
**Publication is not a gap.** All 31 workspaces are on the registry `As of 2026-
|
|
25
|
+
**Publication is not a gap.** All 31 workspaces are on the registry, every one with a provenance attestation, `As of 2026-11-10` by `bun run scripts/registry-audit.ts --json`, which `registry-audit.yml` re-runs daily;
|
|
26
26
|
`@ultimat3/scraping` was the last never-published package and was bootstrapped by hand at 2.0.0
|
|
27
27
|
([`PUBLISHING.md`](https://github.com/developerz-ai/ultimate/blob/main/PUBLISHING.md) step 1).
|
|
28
28
|
`bun add @ultimat3/scraping` resolves — check it with `npm view @ultimat3/scraping version`.
|
|
@@ -31,10 +31,11 @@ CHANGELOG.md` finds its bounds, and it changes on any commit.
|
|
|
31
31
|
|
|
32
32
|
| Gap | Symptom | Work around it by |
|
|
33
33
|
|---|---|---|
|
|
34
|
+
| `pdf()` prints with no session of its own | `As of 2026-11-09`. The Chrome that `pdf()` drives opens the app's route as nobody: no cookie jar is handed across, so a route behind a session answers exactly as it would a signed-out visitor — its 4xx is `X_SCRAPE_PDF_ROUTE_FAILED`, a sign-in page it renders is what gets printed. pin: none — the gap is an absence no assertion can hold (nothing hands the browser a cookie); the workaround is held by `packages/scraping/src/pdf-render-fence.test.ts`, 'a same-origin request carries the headers; a cross-origin one is blocked without them' | issue a short-lived token the print route accepts and send it through `pdf({ headers })` — [Scraping](Scraping#a-route-printed-to-pdf--pdf) |
|
|
34
35
|
| A purge that a replica never hears is bounded by `ttl`, not by the next request | `As of 2026-10-10`. The purge reaches the other replicas through the invalidation broadcast. With the bus down, a replica with its own store answers its copy as a fresh hit until that copy's `ttl` (and tells an edge the ttl's remainder), then renders. `'purge'` therefore requires a `ttl` | choose the `ttl` as the longest a missed purge may last; or share one `runtime.isrStore` with a `tagFence`, where the delete is every replica's at once |
|
|
35
36
|
| A bust purges by the **route's** tags | `As of 2026-10-10`. A stored `isr` page records no tags of its own, so `post:1` reaches every stored page of a route tagged `post` — one render too many per page, never one too few. Each bust reads the store's keys once; the route of each key is remembered, not re-matched [pin](https://github.com/developerz-ai/ultimate/blob/main/packages/render/src/render-isr-purge.test.ts#every%20stored%20key%20of%20the%20route%20goes%3A%20both%20locales%2C%20and%20every%20keyed%20query) | tag a route as narrowly as its data allows; a very large shared store pays one `paths()` per bust per replica |
|
|
36
37
|
| A declared `isr` query parameter's **values** are unbounded | `As of 2026-10-10`. `query: ['page']` puts `page` in the key, and `?page=1` … `?page=999999` are each a key: the framework cannot know which values name a page. The store is bounded (least recently generated out first), so it thrashes rather than grows [pin](https://github.com/developerz-ai/ultimate/blob/main/packages/render/src/render-isr-query.test.ts#only%20a%20declared%20parameter%20is%20part%20of%20the%20key%2C%20and%20of%20the%20URL%20load%20is%20given) | answer `withStatus(404, …)` from `load` for a value that names nothing, and rate-limit the route at the ingress; put a small closed set in the path instead (`/blog/page/[n]` with `prerender()`) |
|
|
37
|
-
| A `grantUpload` with a `target` is never sniffed | `As of 2026-11-02`. A presigned PUT signs `host` and the size, so on an s3 disk the uploader chooses the stored type and the bytes. `promoteAttachment` is what checks them (`X_STORAGE_TYPE_REJECTED`), and a grant with a `target` lands straight on the row's key with no promotion step. Served, it is contained: `objectResponse` sandboxes a type a browser would run, and a false `image/png` is shown under `nosniff` [pin](https://github.com/developerz-ai/ultimate/blob/main/packages/storage/src/grant.test.ts#naming%20a%20target%20puts%20the%20key%20on%20the%20row%20instead%20of%20in%20pending) | grant with no `target` and call `promoteAttachment({ …, policy })`; for a targeted grant, read the head yourself with `validateStoredHead(…)` before writing the key to the row → [Storage and uploads](Storage-And-Uploads) |
|
|
38
|
+
| A `grantUpload` with a `target` is never sniffed | `As of 2026-11-02`. A presigned PUT signs `host` and the size, so on an s3 disk the uploader chooses the stored type and the bytes. `promoteAttachment` is what checks them (`X_STORAGE_TYPE_REJECTED`), and a grant with a `target` lands straight on the row's key with no promotion step. With an `uploadScanner` installed such a grant is refused outright (`X_STORAGE_TARGET_UNSCANNED`, `As of 31.0.0`), so the gap is only an app's with no scanner. Served, it is contained: `objectResponse` sandboxes a type a browser would run, and a false `image/png` is shown under `nosniff` [pin](https://github.com/developerz-ai/ultimate/blob/main/packages/storage/src/grant.test.ts#naming%20a%20target%20puts%20the%20key%20on%20the%20row%20instead%20of%20in%20pending) | grant with no `target` and call `promoteAttachment({ …, policy })`; for a targeted grant, read the head yourself with `validateStoredHead(…)` before writing the key to the row → [Storage and uploads](Storage-And-Uploads) |
|
|
38
39
|
| A queued offline write is not bound to its principal **on the server** | `As of 2026-10`. The fence is in the page: a principal change abandons the running replay, refuses a write in flight (`X_OFFLINE_QUEUE_ABANDONED`) and wipes the queue. A second TAB whose replay is already past its store read when another tab changes the session cookie still sends its remaining entry under the new session — one entry, one in-flight pass, on a shared browser | sign out by full navigation (`signOutHeaders()` clears site data, and every boot wipes other principals' queues); do not share a browser profile between accounts with offline writes queued |
|
|
39
40
|
| Presence leaves past the lease roster cap | the sweep leader ships at most 4,096 member ids on its lease (`PRESENCE_LEASE_ROSTER_LIMIT`). When the leader's node dies, members beyond that whose TTL expired before the successor's first leading pass are never announced as left. A successor cannot diff against the shared store: the expired members are already gone from it | nothing to do: each client's next beat is answered with the whole roster, so it heals within one beat (10 s by default) |
|
|
40
41
|
| An **offline** scrape reads `/robots.txt` over the real network | every `fakeBrowser` / `fixtureBrowser` run takes the default `robots: 'obey'`, and the gate reads `https://<host>/robots.txt` with the platform `fetch` before the first navigation, so outside `bun test` one request still leaves the process. **The silent half is closed `As of 2026-10-04`**: an unreachable robots.txt (5xx, 429, network error, timeout) now refuses the origin with `X_SCRAPE_ROBOTS_DISALLOWED` (RFC 9309 §2.3.1.4 for 5xx, network error and timeout; refusing on `429` is Ultimate's stricter policy — the RFC calls a `4xx` unavailable), so under `bun test` the sealed network's refusal turns the run red instead of reading as allow-everything | declare the policy in the definition under test — `robots: { ignore: 'fixture host, no live origin' }` — which returns a gate that reads nothing at all. There is no boolean and no ambient off switch, by design — see [Scraping](Scraping#testing-offline) |
|
|
@@ -50,7 +51,7 @@ CHANGELOG.md` finds its bounds, and it changes on any commit.
|
|
|
50
51
|
| Every role evaluates all of `@ultimat3/jobs` — 96 modules (`As of 2026-10-02`, by file) — whatever it runs | `As of 2026-10-01`, read off the serve graph by the names each role's code uses: a `web` pod needs 43 of them (enqueue, the outbox relay, the purge task), a `scheduler` 46, a `worker` 62. The rest ride the barrel: `worker.ts` and its eighteen dependencies in a web pod, the `backfill()` / `exportJob()` / `webhook()` factories (17 modules, 123 kB of source) in an app that declares none, and the memory driver (3 modules) outside a test. ~1.6 Mi per web pod at the measured 34 kB a module. Closing it means subpath entries (`@ultimat3/jobs/worker`, one per factory) and every importer rewritten — a breaking move for a saving the per-role bundle above makes moot, so it waits on that decision. The operator surface is **not** in this list: `JobIntrospection` is a member of the driver, and the worker announces itself and counts settles through it pin: none — a module count read off a role's serve graph, measured rather than asserted | nothing to do in an app |
|
|
51
52
|
| 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 | NTP on every pod; for a deadline tighter than the ceiling, enqueue at the moment the work is due rather than with `runAt` |
|
|
52
53
|
| `onSettled` runs at most once across a crash | `As of 2026-10`, by decision of the first cut: the hook runs after the settle, inline, by the worker whose settle landed. A worker killed between the settle and the hook does not run it, and nothing re-drives it | record what must be recorded for certain inside the body, in a `step.run`, and use `onSettled` for what may be lost |
|
|
53
|
-
| The CDP driver
|
|
54
|
+
| 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) | 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 |
|
|
54
55
|
| `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`) | treat `bytesIn` as a lower bound; a provider's own byte count, returned through the resolver's `cost`, is the billable one |
|
|
55
56
|
| An org-scoped operator's runs list reads `x_jobs` with no index on `tenant_id` | `As of 2026-10`. The jobs dashboard keeps an actor with an `orgId` to its own org's runs through `JobFilter.tenantId`, and `x_jobs.tenant_id` is a plain column: the only index naming it is the idempotency one, led by `name` (`packages/jobs/src/driver-pg-ddl.ts`). A platform operator's list is unaffected [pin](https://github.com/developerz-ai/ultimate/blob/main/packages/jobs/src/driver-pg-sql.test.ts#no%20x_jobs%20index%20leads%20with%20tenant_id%3A%20an%20org-scoped%20runs%20list%20scans) | on a large queue, add `create index on x_jobs (tenant_id, created_at desc, id desc)` in an app migration, or operate the dashboard as a platform operator (an actor with no `orgId`) |
|
|
56
57
|
| Retry-from-step on the jobs dashboard is a free-text field | `As of 2026-10`. `job.retry-from-step` takes `{ step: t.string.min(1) }` (`packages/admin/src/jobs/job-actions.ts`); the run's detail page shows its steps, but the form does not offer them as a choice. | copy the step name from the run's `steps` section on the same page |
|
package/wiki/MCP-And-AI.md
CHANGED
|
@@ -200,6 +200,13 @@ posts (query scope app:use; action scope posts:write) — Blog posts
|
|
|
200
200
|
publishPost (action; confirms) {postId: string} — Publish a draft post
|
|
201
201
|
```
|
|
202
202
|
|
|
203
|
+
**A catalog too big for that: `catalogDetail: 'compact'`**, once, in `defineAppMcp` (`As of 2026-11`). Each resource line stays; its actions become ONE line of names, grouped by kind tag, with `confirms` and an unhoisted scope still on the action. Descriptions and parameter hints move to `describe_resource`, which the header tells the model to read before a resource's first call. Measured on a 46-resource, 322-action catalog: 95,318 characters full, 13,085 compact. Refused on a server no caller reads `list_resources` from (`X_MCP_SURFACE_INVALID`).
|
|
204
|
+
|
|
205
|
+
```text
|
|
206
|
+
posts (query scope app:use; action scope posts:write) — Blog posts
|
|
207
|
+
listPosts; action: publishPost (confirms), archivePost
|
|
208
|
+
```
|
|
209
|
+
|
|
203
210
|
The same catalog as data, for a test: `mcp.server.catalog(caller)` — every action keeps its own
|
|
204
211
|
`scope` there. `describe_resource` stays compact JSON with the full schema — a schema is JSON.
|
|
205
212
|
|
|
@@ -333,7 +340,12 @@ mounted after the framework's routes and before the pages, through the whole pip
|
|
|
333
340
|
### OAuth discovery for remote connectors
|
|
334
341
|
|
|
335
342
|
`defineAppMcp({ oauth })` makes the endpoint an OAuth 2.1 protected resource per the MCP
|
|
336
|
-
authorization spec (
|
|
343
|
+
authorization spec (`As of 2026-11`, served at modern `2026-07-28` and the legacy handshake
|
|
344
|
+
revisions `2025-11-25` / `2025-06-18` / `2025-03-26`) and RFC 9728 (`As of 22.6.0`). Discovery is
|
|
345
|
+
not the same in each: RFC 9728 protected-resource metadata is required from `2025-06-18` on;
|
|
346
|
+
`2025-11-25` made the 401's `WWW-Authenticate` optional with a `.well-known` fallback (SEP-985)
|
|
347
|
+
where `2025-06-18` required it; `2025-03-26` defines none, its discovery being RFC 8414
|
|
348
|
+
authorization-server metadata at the origin:
|
|
337
349
|
|
|
338
350
|
```ts
|
|
339
351
|
export const mcp = defineAppMcp({
|
|
@@ -492,7 +504,9 @@ Remote MCP tools as this app's actions — the app's `policy`, rate limit, confi
|
|
|
492
504
|
| 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 |
|
|
493
505
|
| 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 |
|
|
494
506
|
| Wire | `outbound()` (`dial: 'public'` by default, deadline, size cap); modern era first, then legacy `initialize` + `Mcp-Session-Id`; JSON or SSE answers |
|
|
495
|
-
| Untrusted | the answer arrives as `{ untrusted, isError }`, fenced `<untrusted source="mcp:<name>/<tool>">`, middle-cut past `maxResultChars
|
|
507
|
+
| 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 `<` — no spelling of `</untrusted>` survives |
|
|
508
|
+
| Exposed | `expose` defaults to `false`: the actions are this app's, not its `/mcp`'s, so `include: 'exposed'` leaves them out; they are declared `agents: true`, so this app's own `agent()`s are offered them anyway. `expose: true` opts one remote server in, and this app's `/mcp` then answers for a third party's tools |
|
|
509
|
+
| Re-checked | the live list is held to the lock before the first call, on every `list_changed`, and again once a verdict is `reverifyMs` old (default 3,600,000) — a remote that changes silently is caught within the hour |
|
|
496
510
|
| Read-only | only when a reviewer sets `readOnly: true` in the lock — the remote's hint is never trusted |
|
|
497
511
|
| Failure | `X_MCP_REMOTE_REFUSED` (502), the cause names the status |
|
|
498
512
|
|
|
@@ -593,7 +607,7 @@ export const summarize = llm({
|
|
|
593
607
|
| Caching | semantic cache from [Caching and invalidation](Caching-And-Invalidation) |
|
|
594
608
|
| Provider prompt caching | the provider keeps a request's stable prefix; on by default for `agent()`, off for `llm()` → [Agents](Agents#provider-prompt-caching) |
|
|
595
609
|
| Tracing | one OTel span per call with model, tokens, cache hit, prompt version |
|
|
596
|
-
| Fallback | ordered provider list per model; the provider that answered is on the span as `
|
|
610
|
+
| Fallback | ordered provider list per model; the provider that answered is on the span as `gen_ai.provider.name`, never silent. A refusal names a more capable model for the declaration to adopt — models are never swapped at runtime |
|
|
597
611
|
| Money | `Money = { minor, currency }` — never a float → [Money](Money) |
|
|
598
612
|
|
|
599
613
|
**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.
|
|
@@ -626,7 +640,7 @@ A tool in `mcpConfirmations({ tools })` waits for a person on **both** surfaces:
|
|
|
626
640
|
|
|
627
641
|
| Option | What it holds |
|
|
628
642
|
|---|---|
|
|
629
|
-
| `approvers: ({ args }) => ({ quorum, from })` | N of M distinct approvers matching `'role:<name>'` / `'actor:<id>'`, resolved per call from the validated arguments and stored on the row. The requesting actor never counts (nor an impersonated decider): `X_FORBIDDEN`. One approver counts once. Short of the quorum, the agent's repeat answers `X_MCP_CONFIRMATION_QUORUM_PENDING
|
|
643
|
+
| `approvers: ({ args }) => ({ quorum, from })` | N of M distinct approvers matching `'role:<name>'` / `'actor:<id>'`, resolved per call from the validated arguments and stored on the row. The requesting actor never counts (nor an impersonated decider): `X_FORBIDDEN`. One approver counts once. Short of the quorum, the agent's repeat answers `X_MCP_CONFIRMATION_QUORUM_PENDING`, whose `meta.outstanding` names the selectors still able to vote (never the requester or one who already voted); a bar nobody can meet is `X_MCP_CONFIRMATION_QUORUM_INVALID` before a row opens |
|
|
630
644
|
| `evidence: { verify }` | every vote carries `signature` over the `signingPayload` the view returns (confirmation id, tool, keyed argument digest), checked by the app's `verify` against keys registered to the approver. A missing or failing one stores no vote; the stored row is re-verified before the call runs, so a row written around the decision runs nothing. Both are `X_MCP_CONFIRMATION_EVIDENCE_INVALID` |
|
|
631
645
|
|
|
632
646
|
`verifyConfirmationEvidence(row, { evidence, quorum, from, arguments })` is exported so a separate process that executes the action re-checks the stored evidence with public keys alone. `ttlMs` expires a partly approved row like any other; one rejection rejects. The full table: [`@ultimat3/mcp` README](https://github.com/developerz-ai/ultimate/blob/main/packages/mcp/README.md#quorum-and-signed-decisions).
|
package/wiki/Mail.md
CHANGED
|
@@ -55,7 +55,7 @@ between environments — the credential does.
|
|
|
55
55
|
|
|
56
56
|
Every key, with what it means: [Configuration → `mail`](Configuration#mail). More than one of
|
|
57
57
|
`SMTP_URL`, `RESEND_API_KEY` and `SES_REGION` is `X_CONFIG_INVALID` rather than a silent winner.
|
|
58
|
-
`
|
|
58
|
+
`mail:` in `export const runtime = { … }` (`apps/<app>/runtime.ts`) is the one seam for an app that builds its own — the `mail` adapter port: `MailDriver` from `@ultimat3/mail/adapter`, `memoryMailDriver` to copy, `behavesLike(mailDriverConformance, () => yourDriver())` to prove it ([Adapters](Adapters#mail)). There is no `setMailDriver` (31.0.0); a test swaps one for itself with `await swapAdapter('mail', driver)` from `@ultimat3/testing`.
|
|
59
59
|
|
|
60
60
|
## Keeping the sent bytes: `mail.retainMime`
|
|
61
61
|
|
|
@@ -122,11 +122,20 @@ The `/_x` mail panel lists every registered mail beside the caught ones (`templa
|
|
|
122
122
|
listed with `hasPreview: false`. `?template=<id>` selects one; `x dev`'s panel and its `--json`
|
|
123
123
|
payload are the same facts.
|
|
124
124
|
|
|
125
|
-
##
|
|
125
|
+
## No framework mails
|
|
126
126
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
Rule: `@ultimat3/mail` registers no mail. `As of 31.0.0`. Every mail an app sends is its own
|
|
128
|
+
`defineMail()`, with its `mail.<id>.*` keys in the app's catalog; the base catalog carries
|
|
129
|
+
`mail.footer.*` only. `registeredMails()` lists what the app declared; `renderMessage()` renders one
|
|
130
|
+
without sending.
|
|
131
|
+
|
|
132
|
+
| Mail | Where it comes from |
|
|
133
|
+
|---|---|
|
|
134
|
+
| email verification, password reset | `@ultimat3/auth` sends `auth.email-verify` / `auth.password-reset` through the app's `MailSender`, keys in the app catalog |
|
|
135
|
+
| welcome, invite, security alert, anything else | the app's own `defineMail()` — business convention, never shipped (axiom 8) |
|
|
136
|
+
|
|
137
|
+
The six v30 mails (`welcome`, `verify-email`, `reset-password`, `invite`, `mfa-enrolled`,
|
|
138
|
+
`security-alert`, `FRAMEWORK_MAILS`) are deleted: [Upgrading](Upgrading) entry 54.
|
|
130
139
|
|
|
131
140
|
## Errors
|
|
132
141
|
|
|
@@ -140,16 +140,41 @@ A hand-written migration with `create index concurrently`, `drop index concurren
|
|
|
140
140
|
|
|
141
141
|
## Partitioned tables
|
|
142
142
|
|
|
143
|
-
Rule:
|
|
144
|
-
|
|
145
|
-
|
|
143
|
+
Rule: declare it on the entity — `partitionBy: { column, interval, ahead?, retain? }` — and
|
|
144
|
+
`x db gen` writes the partitioned table. `As of 2026-11-09`. The hand edit at the end of this
|
|
145
|
+
section is the pre-31 recipe, still valid for a table `partitionBy` cannot describe (list or hash
|
|
146
|
+
partitioning, a non-time key).
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
import { entity, text, timestamp, uuid } from '@ultimat3/entity';
|
|
150
|
+
|
|
151
|
+
export const events = entity('events', {
|
|
152
|
+
columns: { id: uuid(), at: timestamp().defaultNow(), orgId: uuid().tenant(), kind: text() },
|
|
153
|
+
primaryKey: ['id', 'at'],
|
|
154
|
+
partitionBy: { column: 'at', interval: 'month', ahead: 3, retain: { after: '400d' } },
|
|
155
|
+
});
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
| Question | Answer |
|
|
159
|
+
|---|---|
|
|
160
|
+
| Refused at declaration | `X_ENTITY_PARTITION_INVALID`: the key or a unique index/invariant lacks the column; the column is no `timestamp()`/`date()`; an interval outside `day` · `week` · `month` · `year`; a row `retain` beside it; a view |
|
|
161
|
+
| What `x db gen` writes | `create table … partition by range ("at")`, the function `ultimate_partitions`, and a call creating the current partition plus `ahead` more AT APPLY TIME |
|
|
162
|
+
| Names | `<table>_pYYYYMMDD` (the lower bound, UTC); `week` is ISO, Monday first |
|
|
163
|
+
| Creating ahead, dropping old | `partitions()` from `@ultimat3/jobs`, daily ([Jobs](Jobs-And-Workflows#partition-maintenance--partitions)), runs `@ultimat3/db`'s `maintainPartitions`: creation under a 5 s `lock_timeout` (`X_DB_LOCK_TIMEOUT`, retried), then `retain.after` retires whole partitions whose upper bound it passed by `detach … concurrently`, then `drop` — never an ACCESS EXCLUSIVE queue on the parent. Idempotent; only `_pYYYYMMDD` children are touched |
|
|
164
|
+
| A row past every partition | refused by Postgres (`23514`). No default partition, by decision: one forbids `detach … concurrently`, and creating the month it caught moves rows under ACCESS EXCLUSIVE. Size `ahead × interval` to at least the scheduler outage you tolerate |
|
|
165
|
+
| Moving older rows in | enqueue `partitions()` once with `{ from: '<the oldest row’s ISO instant>' }` — it creates every partition back to it and retires nothing — then `backfill()` |
|
|
166
|
+
| Adopting on an existing plain table | refused at migrate time, `X_MIGRATION_PARTITION_CHANGE` (Postgres cannot partition in place: a new entity plus a `backfill()`); changing the interval or removing `partitionBy` is refused by `x db gen`, same code. A table the hand recipe already partitioned adopts cleanly |
|
|
167
|
+
|
|
168
|
+
The hand recipe: declare it as an entity, `x db gen`, then hand-edit the generated `create table`'s
|
|
169
|
+
closing `);` to `) partition by range ("at");`. Attach, default partition and retention are then the
|
|
170
|
+
app's choices.
|
|
146
171
|
|
|
147
172
|
| Question | Answer |
|
|
148
173
|
|---|---|
|
|
149
174
|
| Primary key | must hold the partition key — `primaryKey: ['id', 'at']`. Postgres refuses any unique index that does not (`0A000`) |
|
|
150
175
|
| Drift | the PARENT is judged: columns, key, indexes, checks, triggers. A partition is not app schema (`pg_class.relispartition`), so next month's is no `unexpected-table` and its `fix:` is never `drop table`. A key Postgres clones per partition (`conparentid <> 0`) is not counted. `introspectSchema()` marks the parent `partitioned: true` |
|
|
151
176
|
| A reference INTO one | no `.references()`. A one-column key is `42830` (no unique index on `id` alone can exist) and a same-tenant key's `(org_id, id)` index is `0A000`. Hand-write the composite key into the migration — `alter table "notes" add constraint "notes_event_fkey" foreign key ("event_id", "event_at") references "events" ("id", "at");` — drift judges declared keys only, so it is no finding. The repository's tenant filter still holds on reads; the database does not enforce the same tenant |
|
|
152
|
-
| Retention | `detach`, then `drop`, in the app's own job
|
|
177
|
+
| Retention | `partitionBy.retain` — never row `retain`, never a `delete`. By hand: `detach`, then `drop`, in the app's own job |
|
|
153
178
|
| Next month | an app `task` on a monthly cron (`tz: 'UTC'`) enqueuing a job that runs the statement below, `if not exists` so a double fire is a no-op |
|
|
154
179
|
| `create index concurrently` | refused on a parent (`0A000`): `X_MIGRATION_CONCURRENT_PARTITIONED`, whose fix is the sequence — each partition concurrently, the parent `on only`, then `alter index … attach partition`, in a `-- transaction: false` migration |
|
|
155
180
|
| Schema dump | rendered: the parent with `partition by`, each partition `partition of … for values` in the parent's file. A partition's attached indexes, cloned keys and cloned triggers are not written: the parent's recreate them |
|
package/wiki/Money.md
CHANGED
|
@@ -20,6 +20,7 @@ Integer minor units + a three-letter uppercase code — the ISO-4217 rows the fr
|
|
|
20
20
|
| Where the refusal fires | Code |
|
|
21
21
|
|---|---|
|
|
22
22
|
| a value built in code — `fromMinor()`, arithmetic, `fromDecimal` | `X_MONEY_NOT_INTEGER` |
|
|
23
|
+
| a `fromDecimal` input that is no plain decimal string — `12.99` as a number, `null`, `'1,299.00'`, `'1e3'` | `X_MONEY_NOT_DECIMAL` (422) |
|
|
23
24
|
| a value off the wire — `t.money`, and therefore the OpenAPI contract | the boundary's own issue, with the field path |
|
|
24
25
|
| a value read back off a `bigint` column past ±2^53 | `X_INVARIANT_VIOLATED`, naming the value |
|
|
25
26
|
|
|
@@ -316,6 +317,7 @@ See [MCP and AI](MCP-And-AI).
|
|
|
316
317
|
| Code | Cause | Fix |
|
|
317
318
|
|---|---|---|
|
|
318
319
|
| `X_MONEY_NOT_INTEGER` | `minor` is not a safe integer, or a decimal string is more precise than the currency | `fromDecimal(...)`, or pass an explicit rounding mode |
|
|
320
|
+
| `X_MONEY_NOT_DECIMAL` | `fromDecimal` was handed a non-string (a JSON number, `null`, `undefined`) or a string with grouping, a symbol or an exponent | send the amount as a decimal string: `fromDecimal('12.99', 'USD')`; text a person typed goes through `parseAmount(text, { currency, locale })` |
|
|
319
321
|
| `X_CURRENCY_UNKNOWN` | the code is neither a shipped ISO row nor registered by this process | pick one `currencyCodes()` lists, or declare it at boot with `registerCurrency({ code, exponent, name })` |
|
|
320
322
|
| `X_CURRENCY_MISMATCH` | combining two currencies — an `X_INVARIANT`-class violation | `convert(...)` first, then combine |
|
|
321
323
|
| `X_CURRENCY_INVALID` | a `registerCurrency` declaration that cannot become a currency — bad code shape, an exponent outside `0…15`, or an empty name | fix the declaration: three A–Z letters, a whole exponent, a non-empty name |
|
|
@@ -19,7 +19,7 @@ Who *raises* it is a separate question, and the answer differs by surface:
|
|
|
19
19
|
|
|
20
20
|
| Surface | What happens at the threshold |
|
|
21
21
|
|---|---|
|
|
22
|
-
| `testStatements` (`@ultimat3/testing`) | **
|
|
22
|
+
| `testStatements` (`@ultimat3/testing`) | **records** `nPlusOne(…)` per shape and **throws it at disposal**, so the test fails — a bus subscriber's throw is contained, never the read's failure |
|
|
23
23
|
| `x dev` (`packages/cli/src/dev-n-plus-one.ts`) | **records a verdict and logs one warning** per request per code — it never throws, because a reporting-only observer that threw would break the app it is watching |
|
|
24
24
|
| `/_x` and the browser overlay | render the recorded verdict; they raise nothing |
|
|
25
25
|
|
|
@@ -81,22 +81,22 @@ Everything else about them differs, deliberately:
|
|
|
81
81
|
| | `x dev`'s ledger | `testStatements` |
|
|
82
82
|
|---|---|---|
|
|
83
83
|
| Counting window | one `Ctx` — a `WeakMap` keyed on the request, which dies with it | fixture creation → disposal, including statements sent outside any request |
|
|
84
|
-
| At the threshold | records a verdict, logs once per request per code |
|
|
85
|
-
| `expectedQueryLoop` statements | not counted at all — this ledger *is* the verdict | counted by `count()` and `shapes()`, excluded only from the `unexpected` tally the
|
|
84
|
+
| At the threshold | records a verdict, logs once per request per code | records a verdict, once per shape; disposal throws the first |
|
|
85
|
+
| `expectedQueryLoop` statements | not counted at all — this ledger *is* the verdict | counted by `count()` and `shapes()`, excluded only from the `unexpected` tally the verdict reads |
|
|
86
86
|
|
|
87
87
|
So a shape can be visible in a test's `shapes()` and absent from `x dev`'s verdict list for the
|
|
88
88
|
same run, and neither is wrong: one is measuring, the other is judging.
|
|
89
89
|
|
|
90
90
|
## The seam it rides on
|
|
91
91
|
|
|
92
|
-
None of this reaches into the driver.
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
92
|
+
None of this reaches into the driver. Every statement is a `db.statement` event on core's
|
|
93
|
+
instrumentation bus, emitted by `traceStatement()` (`packages/db/src/statement-span.ts`), which
|
|
94
|
+
both statement funnels (`runOn` in `statement-funnel.ts`, `statement()` in `pglite.ts`) call after
|
|
95
|
+
every statement settles, success or failure; the memory driver emits one per repository operation.
|
|
96
|
+
`subscribe('db.statement', handler)` hears it, beside every other subscriber. The emitter guards
|
|
97
|
+
first — `subscribed('db.statement')` — and builds a `DbStatementEvent` only when something listens:
|
|
98
|
+
one map read with no subscriber, which is what makes this free in production (axiom 6). `serve.ts`
|
|
99
|
+
subscribes none. The statement's `db.<verb>` span opens either way. `As of 2026-11` (v31).
|
|
100
100
|
|
|
101
101
|
`@ultimat3/entity`'s `postgresRepo` (`packages/entity/src/pg-driver.ts`) is what attaches an
|
|
102
102
|
`entity`/`op` pair to each statement, via `withStatementAttribution(entity.$name, op, send)`. It is
|
|
@@ -109,11 +109,12 @@ it one-per-step by design, so a job of five steps is not a verdict against the f
|
|
|
109
109
|
## Where it installs: dev only
|
|
110
110
|
|
|
111
111
|
`x dev` — `startDev()` in `packages/cli/src/cmd-dev.ts` — builds a `StatementLedger`
|
|
112
|
-
(`createStatementLedger()`, `packages/cli/src/dev-n-plus-one.ts`) and
|
|
113
|
-
boot, before the app's own
|
|
112
|
+
(`createStatementLedger()`, `packages/cli/src/dev-n-plus-one.ts`) and subscribes it at
|
|
113
|
+
boot (`subscribe('db.statement', …)` in `packages/cli/src/dev-boot.ts`), before the app's own
|
|
114
|
+
modules load, alongside the trace recorder. The ledger keys its
|
|
114
115
|
per-shape counts on the request's `Ctx` object in a `WeakMap`, so state dies with the request it
|
|
115
116
|
belongs to and nothing needs sweeping. `packages/cli/src/serve.ts` — the production entry point —
|
|
116
|
-
never
|
|
117
|
+
never subscribes it. There is no flag to disable this in dev and no flag to
|
|
117
118
|
enable it in prod; the wiring itself is the switch.
|
|
118
119
|
|
|
119
120
|
## Silencing a genuine one-per-row loop
|
|
@@ -159,7 +160,7 @@ one migration per transaction, one statement at a time, inside a scope naming wh
|
|
|
159
160
|
|
|
160
161
|
`x dev` warns; CI is not attended. `@ultimat3/testing`'s `statements` fixture
|
|
161
162
|
(`testStatements`, `packages/testing/src/fixture-statements.ts`) installs the identical
|
|
162
|
-
detector in **
|
|
163
|
+
detector in **strict** mode for the length of one test — its verdict fails the test at teardown — destructuring `statements` is the whole
|
|
163
164
|
opt-in, there is no `strict: true` flag to forget:
|
|
164
165
|
|
|
165
166
|
```ts
|
|
@@ -174,19 +175,20 @@ test('the feed reads its authors once', async ({ statements }) => {
|
|
|
174
175
|
It counts from the moment the fixture is built, not from a request boundary — a plain unit test
|
|
175
176
|
calling `posts.findById(id)` in a loop has no `Ctx` anywhere, and that is exactly the loop this
|
|
176
177
|
fixture exists to catch, unlike the dev ledger which only counts inside a request. The verdict
|
|
177
|
-
still only counts unexpected statements — an `expectedQueryLoop` scope suppresses the
|
|
178
|
+
still only counts unexpected statements — an `expectedQueryLoop` scope suppresses the verdict the
|
|
178
179
|
same way it suppresses the dev warning — while `count()` and `shapes()` report every statement sent,
|
|
179
180
|
expected ones included, because a test asserting "this page issues two statements" must not see a
|
|
180
|
-
different number depending on who declared what.
|
|
181
|
-
crosses the threshold
|
|
182
|
-
|
|
181
|
+
different number depending on who declared what. One verdict per shape, recorded at the statement
|
|
182
|
+
that crosses the threshold and raised when the fixture is disposed — the bus contains a
|
|
183
|
+
subscriber's throw, so an observer can never fail the read it observes. The error names the shape
|
|
184
|
+
and its count; `verdicts()` reads them before teardown, and `shapes()` reports the whole loop.
|
|
183
185
|
|
|
184
186
|
## Why this costs production nothing
|
|
185
187
|
|
|
186
|
-
Three separate facts add up to zero production cost, not one flag: the `
|
|
187
|
-
guard-first and allocates nothing
|
|
188
|
+
Three separate facts add up to zero production cost, not one flag: the `db.statement` emitter is
|
|
189
|
+
guard-first and allocates nothing with no subscriber; `withStatementAttribution` is the same shape,
|
|
188
190
|
guarding before it even opens its `AsyncLocalStorage` scope; and `serve.ts` — the only production
|
|
189
|
-
entry point — never
|
|
191
|
+
entry point — never subscribes the ledger. Turning the detector on is entirely a fact about
|
|
190
192
|
which binary is running: `x dev` wires it; `apps/web/server.ts` under any `ROLE` never does. There is no `x serve` command — the production entry is the scaffolded `server.ts`, run directly or through `x build`'s artifact.
|
|
191
193
|
|
|
192
194
|
## See also
|
package/wiki/Notify.md
CHANGED
|
@@ -33,12 +33,12 @@ await commentPosted.enqueue({ params: { postId, orgId, author } });
|
|
|
33
33
|
|
|
34
34
|
## The stores
|
|
35
35
|
|
|
36
|
-
`
|
|
36
|
+
`notifyStores: { ledger, inbox, digest, preferences }` in `export const runtime = { … }` (`apps/<app>/runtime.ts`), installed once by the boot, whole-object replacement (a test: `installNotifyStores` from `@ultimat3/notify/adapter`):
|
|
37
37
|
|
|
38
38
|
| Store | Default | Postgres |
|
|
39
39
|
|---|---|---|
|
|
40
40
|
| `ledger` — the delivery claim | in-memory (one process is genuinely deduped) | `postgresDeliveryLedger({ executor, windowMs })` — `windowMs` never shorter than your idempotency window |
|
|
41
|
-
| `preferences` — the gate | allow all | yours: **the gate ships, what it reads never does** — your taxonomy, your quiet hours |
|
|
41
|
+
| `preferences` — the gate | allow all | yours: **the gate ships, what it reads never does** — your taxonomy, your quiet hours. One method, `allowsMany({ recipients, notifier, channel, event, ctx })`, asked once per chunk of at most `NOTIFY_CHUNK_SIZE` (500) recipients per channel: answer the ids that may be reached. An omitted id is suppressed on that channel only |
|
|
42
42
|
| `inbox` | none — `X_NOTIFY_STORE_MISSING` | `postgresInboxStore({ executor })` |
|
|
43
43
|
| `digest` | none — `X_NOTIFY_STORE_MISSING` | `postgresDigestStore({ executor })` — one window per slot across replicas; `memoryDigestStore()` for one process |
|
|
44
44
|
|
|
@@ -56,8 +56,11 @@ message disappears is your decision ([Configuration](Configuration)).
|
|
|
56
56
|
are two facts, and the unread count is derived, never stored.
|
|
57
57
|
- A recipient id named twice in the audience is one recipient: the list is deduplicated by `id`,
|
|
58
58
|
first entry kept, before any channel runs.
|
|
59
|
-
- A replay does not send twice: the step checkpoint per channel and
|
|
60
|
-
atomic claim on `(notifier, key, channel,
|
|
59
|
+
- A replay does not send twice: the step checkpoint per channel and chunk of 500 recipients
|
|
60
|
+
(`deliver:<channel>:chunk-<n>`), and the ledger's atomic claim on `(notifier, key, channel,
|
|
61
|
+
recipient)` taken before each send — a chunk that failed part-way re-sends nobody it reached.
|
|
62
|
+
10k recipients on two channels is 40 preference reads and 40 delivery steps. A digest's append
|
|
63
|
+
and drain stay one step per recipient; its send is one step per chunk.
|
|
61
64
|
- Two attempts at once: one sends. The other raises `X_NOTIFY_DELIVERY_HELD` and retries past the
|
|
62
65
|
holder's `reclaimAfterMs` (5 minutes by default), so a crashed attempt's recipient is still sent to
|
|
63
66
|
and a late `settle` moves nothing.
|
|
@@ -68,6 +71,27 @@ Codes: `X_NOTIFY_CHANNELS_EMPTY`, `X_NOTIFY_CHANNEL_DUPLICATE`, `X_NOTIFY_DIGEST
|
|
|
68
71
|
`X_NOTIFY_DELIVERY_FAILED`, and native push's `X_NOTIFY_PUSH_DEVICE_GONE`,
|
|
69
72
|
`X_NOTIFY_PUSH_PROVIDER_REFUSED`, `X_NOTIFY_PUSH_MESSAGE_INVALID` — [Error codes](Error-Codes).
|
|
70
73
|
|
|
74
|
+
## SMS
|
|
75
|
+
|
|
76
|
+
Rule: an SMS is a channel over the `smsTransport` port; no provider ships (axiom 8). `As of 2026-11-09`.
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
import { smsChannel } from '@ultimat3/notify';
|
|
80
|
+
|
|
81
|
+
export const loginCodeSms = smsChannel<{ code: string }>({
|
|
82
|
+
message: ({ event }) => ({ key: 'sms.login_code', params: { code: event.params.code } }),
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
| Fact | Detail |
|
|
87
|
+
|---|---|
|
|
88
|
+
| the port | `smsTransport` in `apps/<app>/runtime.ts` — `SmsTransport` on `@ultimat3/notify/adapter`: `send({ to, body, idempotencyKey, signal })` → `{ transport, id, to, idempotencyKey }` |
|
|
89
|
+
| default | memory in development and test; elsewhere `X_NOTIFY_SMS_TRANSPORT_MISSING` (terminal) |
|
|
90
|
+
| prove yours | `behavesLike(smsTransportConformance, () => yours)`; a transport calls `assertSmsNumber(to)` first, and the suite checks it does |
|
|
91
|
+
| the body | the catalog key, rendered in `recipient.locale`, else the app's fallback |
|
|
92
|
+
| the number | `numberOf(recipient)`, default `recipient.to`, E.164. Not E.164 → `X_NOTIFY_SMS_NUMBER_INVALID` (terminal; the number is never in the cause). None → skipped, logged `notify.address_missing` |
|
|
93
|
+
| retries | `smsIdempotencyKey(notifier, key, channel, recipient)` is the same on every attempt |
|
|
94
|
+
|
|
71
95
|
## Push
|
|
72
96
|
|
|
73
97
|
`pushChannel` delivers one notification to **every device the recipient subscribed**, each in the
|