@ultimat3/cli 31.23.0 → 31.25.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 +4 -2
- package/README.md +1 -0
- package/package.json +29 -29
- package/src/cmd-db-recount.ts +81 -24
- package/src/cmd-db-spec.ts +9 -1
- package/src/cmd-db.ts +1 -0
- package/src/cmd-doctor.ts +7 -1
- package/src/cmd-generate-spec.ts +3 -2
- package/src/cmd-generate.ts +4 -0
- package/src/db-diagnostics.ts +6 -0
- package/src/db-generate.ts +14 -3
- package/src/doctor-guards.ts +5 -3
- package/src/doctor-redundant-indexes.ts +76 -0
- package/src/fix-sequence.ts +0 -1
- package/src/framework-schema.ts +5 -4
- package/src/generate-files.ts +10 -0
- package/src/generate-invite.ts +195 -0
- package/src/generate-kinds.ts +4 -0
- package/src/messages.ts +3 -0
- package/src/metrics-endpoint.ts +5 -3
- package/src/redundant-indexes.ts +101 -0
- package/src/retained-assets-boot.ts +28 -15
- package/src/role-replicator.ts +26 -4
- package/src/role-start.ts +13 -0
- package/src/runtime-boot-warnings.ts +65 -0
- package/src/runtime-cache.ts +14 -8
- package/src/runtime-liveness.ts +23 -0
- package/src/schema-drift.ts +5 -2
- package/src/serve-boot-warnings.ts +9 -8
- package/src/serve.ts +4 -1
- package/src/templates/guard-error-declared.ts +48 -11
- package/src/templates/guard-repo-unbounded.ts +29 -13
- package/src/templates/invite-pages.ts +151 -0
- package/src/templates/invite-tests.ts +228 -0
- package/src/templates/invite.ts +293 -0
- package/src/templates/scaffold-container-compose.ts +3 -2
- package/src/templates/scaffold-guards.ts +26 -3
- package/src/templates/scaffold-helm-templates.ts +1 -1
- package/src/templates/scaffold-repo.ts +1 -0
- package/wiki/Auth.md +24 -0
- package/wiki/Building-Your-Own-Base.md +20 -0
- package/wiki/CLI-Reference.md +7 -1
- package/wiki/Entities-And-Migrations.md +6 -2
- package/wiki/FAQ.md +2 -2
- package/wiki/Home.md +1 -1
- package/wiki/Jobs-And-Workflows.md +8 -6
- package/wiki/Known-Gaps.md +1 -2
- package/wiki/Migrations-And-Backfills.md +1 -1
- package/wiki/Observability.md +2 -1
- package/wiki/Outbound-HTTP.md +40 -0
- package/wiki/Policies-And-Authz.md +52 -20
- package/wiki/Realtime.md +18 -1
- package/wiki/Scheduled-Tasks.md +1 -1
- package/wiki/Shapes.md +3 -2
- package/wiki/Testing.md +1 -0
- package/wiki/Tutorial-04-Jobs-And-Realtime.md +1 -1
- package/wiki/Upgrading.md +2 -0
|
@@ -38,7 +38,7 @@ Every projection is a method on the job — `onboardOrg.enqueue({ orgId })`, nev
|
|
|
38
38
|
| `.parse(raw)` | the payload check | a raw queue payload against the declared `input` |
|
|
39
39
|
| `.idempotencyKeyFor(input)` | the dedupe key | whatever the declared `idempotencyKey` returned. An empty string throws `X_INVARIANT` at the call — an empty key makes every enqueue look like a duplicate of every other |
|
|
40
40
|
| `.concurrencyKeyFor(input)` | the concurrency key | `concurrency.key(input)` for a keyed cap, `undefined` otherwise. An empty or non-string key, or one over 200 characters, throws `X_JOB_DECLARATION_INVALID` — the enqueue asks it first, so the refusal reaches the caller |
|
|
41
|
-
| `.describe()` | the manifest row | `name`, `input` (JSON Schema), `queue`, `retry: { attempts, backoff }`, `steps`, `idempotent`, `concurrency: { limit, keyed, whenBusy } \| null`. Never a key: both keys are computed from an input, so they are app data |
|
|
41
|
+
| `.describe()` | the manifest row | `name`, `input` (JSON Schema), `queue`, `retry: { attempts, backoff }`, `steps`, `idempotent`, `concurrency: { limit, keyed, whenBusy } \| null`, `onSettled`, `limiter: { name, rate, concurrency } \| null`. Never a key: both keys are computed from an input, so they are app data |
|
|
42
42
|
| `.kind` `.name` `.queue` `.retry` `.concurrency` `.whenBusy` `.timeoutMs` `.stepTimeoutMs` `.eventPollMs` `.input` | the declaration, lifted | readable, and already **resolved**: `kind` is `'job'`, `queue` is `'default'` when undeclared, `retry` carries the framework defaults merged underneath, `concurrency` is the cap as a number whichever way it was declared (`whenBusy` is set exactly when it is per key), and `timeout` / `stepTimeout` / `eventPoll` are normalized to ms. `stepTimeout` is a ceiling on **one** `step.run`, distinct from `timeout`'s ceiling on the whole job; `eventPoll` is how often `step.waitForEvent` looks. Both were implemented and unreachable until 2.0.0 — a non-positive value is refused at declaration, because `<= 0` reads as "no ceiling" |
|
|
43
43
|
|
|
44
44
|
**One enqueue implementation.** `<job>.enqueue`, `<job>.as` and a [task](Scheduled-Tasks)'s own `enqueue()` all resolve the same ambient facade; the only other calls into a driver's `enqueue` are the outbox relay and the scheduler's occurrence dispatch. So "does this join the transaction?" has one answer for every enqueue an app writes, and there is no second path to forget about.
|
|
@@ -211,7 +211,7 @@ export async function onDocSaved(docId: string, revision: number): Promise<void>
|
|
|
211
211
|
|---|---|
|
|
212
212
|
| `onConflict: 'replace'` | debounce. A row of this job under the same key still `ready` or `delayed` takes this `input` and `runAt`, in one statement (`SQL_ENQUEUE_REPLACE`). A `running` or `suspended` holder is untouched — the enqueue is the plain dedupe. Answered `{ deduped: true }` with the holder's ids either way. The holder takes this request's `expiresAt` too — or none, when this request names none. Fenced by request order: a replace no newer than the input a row of the key already holds, live or finished, moves nothing and starts no run — an outbox row the relay publishes again after a crash never puts old input back |
|
|
213
213
|
| `onConflict: 'dedupe'` | the default: the first payload wins |
|
|
214
|
-
| `expiresAt` | epoch ms past which the work is worthless. A claim that finds the row still waiting after it settles it `failed`, `lastError` `JOB_EXPIRED` (`'expired'`), never running the body; `onSettled` hears `dropped`,
|
|
214
|
+
| `expiresAt` | epoch ms past which the work is worthless. A claim that finds the row still waiting after it settles it `failed`, `lastError` `JOB_EXPIRED` (`'expired'`), never running the body; `onSettled` hears `dropped`, at least once (the claim records the debt in the same write). Only a row never claimed expires: a started run — a retry waiting out its backoff included — never is. `x jobs retry` clears the expiry. Lazy: no index, no sweep — an expired row stays `ready`/`delayed` until a claim reaches it |
|
|
215
215
|
| inside a transaction | both are staged with the row (`x_outbox.on_conflict`, `x_outbox.expires_at`); the relay publishes such a row alone through `driver.enqueue`, in staged order, while plain rows around it keep batching |
|
|
216
216
|
|
|
217
217
|
## Concurrency, rate limits, queues, retry
|
|
@@ -235,12 +235,14 @@ export const syncCrm = job({
|
|
|
235
235
|
| `concurrency: 4` | max simultaneous runs of **this job**, fleet-wide | one `x_job_leases` row per **held slot**, keyed `(lease_key, slot)` — the primary key is what serialises two workers reaching for the same slot. A driver with no `LeaseStore` refuses the job at worker start (`X_JOB_CONCURRENCY_UNENFORCEABLE`) rather than capping per process |
|
|
236
236
|
| `concurrency: { key, limit }` | max simultaneous runs **sharing one key** — "one run per account" | the same lease rows, one set per `key(input)`. `key` answers a non-empty string of at most 200 characters; `limit` is a whole number, 1 or more |
|
|
237
237
|
| `concurrency.whenBusy` | what a claim over the cap does. `'wait'` (default): the run stays queued, no attempt burned. `'fail'`: the run settles **`failed`** with `X_JOB_KEY_BUSY`, its body never runs, nothing retries it, and it is not a dead letter | the worker, at claim. A plain number always waits |
|
|
238
|
-
|
|
|
239
|
-
|
|
|
238
|
+
| `limiter: vendorApi` | a **named fleet budget** several jobs share — "the payment provider takes 10 calls a second and 4 at once, whichever job makes them". Declare `export const vendorApi = limiter('vendor-api', { rate: { limit: 10, windowMs: 1_000 }, concurrency: 4 })` ONCE at module scope and import it into every `job({ limiter })`. `rate` is at most `limit` starts in any `windowMs` (sliding, no burst past it); `concurrency` is runs holding it at once. Either or both. `As of 2026-11-14` | the installed driver's `JobDriver.leases` — `x_job_leases` rows keyed `limiter:<name>:rate` (one per start, TTL the window) and `:concurrency` (one per held slot, renewed, released at the end) — gated around the BODY, ahead of the first `step.run`. A run over it throws `X_RATE_LIMITED`, deferred to when the oldest start lapses (1 s for a full concurrency cap) with the attempt **uncounted**. A start is an entry before any step completed or suspended: a resume after `step.sleep`/`waitForEvent`, or a retry past a completed step, spends no rate; a retry after a failed first step spends again. The slot's TTL and renewal are the worker's (visibility timeout, heartbeat, `schedule`). Whole numbers ≥ 1, `rate.limit` and `concurrency` ≤ 1,000, one set of numbers per name: `X_JOB_DECLARATION_INVALID`. No lease store: `X_JOB_CONCURRENCY_UNENFORCEABLE` at worker start. `.describe().limiter` is `{ name, rate, concurrency }`. Pinned by `limiter.live.test.ts` (two replicas, one Postgres) |
|
|
239
|
+
| per-process rate | starts per window, per tenant, in ONE worker | `concurrencyLimiter({ ratePerTenant })` on the worker — **per process**, multiplied by the replica count; a fleet budget is `limiter` above. A start is a body that ran: a claim handed back over `job.concurrency`, or refused by its key, spends none |
|
|
240
|
+
| a budget keyed by **request data** (per customer, per API key) | one bucket per key every worker spends | `@ultimat3/http`'s limiter over the store the boot installs on every role, as the body's FIRST lines, ahead of the first `step.run`: `const vendor = rateLimiter({ config, store: installedRateLimitStore() }); assertRateLimitScope(config, vendor); await vendor.assert(key, bucket)`, with `config = resolveRateLimitConfig({ scope: 'shared', buckets: { vendor: toBucket('<job>', { limit, windowMs }) }, defaultBucket: 'vendor' })` at module scope. `assertRateLimitScope` refuses one process' memory under `'shared'` (`X_RATE_LIMIT_NOT_SHARED`). A refusal is `X_RATE_LIMITED`, deferred uncounted like `limiter`'s. Pinned by `rate-recipe.job.test.ts` |
|
|
240
241
|
| `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` |
|
|
241
242
|
| `maxPending` | back-pressure: an enqueue onto a queue already holding that many `ready` + `delayed` rows is `X_JOB_BACKLOG_FULL`, a 429 (`JobBacklogFullError`); an `enqueueMany` that would cross it is refused whole, nothing written. Omitted, no ceiling. `As of 2026-11-12` | one capped count before the write (`JobDriver.backlog`, `SQL_BACKLOG`), on the direct and the staged path, plus the rows the caller's own transaction already staged for the queue (a key staged twice counts once). An enqueue that adds no row — a dedupe, or a replace onto the key's live holder (`JobDriver.holds`, asked only once full) — is never refused. Soft, not a quota: concurrent producers can overshoot by their number, and committed rows the relay has not yet published are counted by nobody. A driver with no `backlog` refuses a job declaring it at enqueue (`X_INVARIANT`) |
|
|
242
243
|
| `queue` | named pool; the `worker` role runs one pool per config (`WORKER_QUEUES=default,integrations`) | worker pool sizing, see [Deployment](Deployment) |
|
|
243
244
|
| priority | **a separate queue**, never a field: `queue: 'urgent'` on the job, and workers whose `WORKER_QUEUES` lists it (with its own `jobs.concurrency` slots, or a pool of its own). Inside one queue the claim takes the earliest `runAt` first, and nothing reorders it. `As of 2026-11`: no `priority` column — it would widen the claim index of the hottest table for an order a second queue already gives, and isolates better (a flood of low-priority work cannot hold the slots) | the claim, per queue |
|
|
245
|
+
| batches — a job that fans out and **awaits its children** | **durable steps, never a field**: `const ids = await step.run('fan-out', () => child.enqueueMany(inputs).then((r) => r.map((one) => one.id)))`, then one `step.waitForEvent(\`child:${id}\`, 'child.done', { schema, match: id })` per persisted id; the child's `onSettled` calls `publishEvent('child.done', { … }, { correlationKey: settled.jobId })`. The names come from a step's stored output, so they are stable across replays. No `batch()` primitive: the parent is a job, every child is a job, and the wait is a step (`As of 2026-11-14`) | `x jobs show <parent>` lists one wait per child |
|
|
244
246
|
| `retry.attempts` / `backoff` | `'exponential' \| 'linear' \| 'fixed'` | driver scheduler |
|
|
245
247
|
| `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 |
|
|
246
248
|
| 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 |
|
|
@@ -375,7 +377,7 @@ Every operator capability is a member of `JobIntrospection` (`driver.introspect`
|
|
|
375
377
|
| who is working | `workers()` — id, host, started, queues, slots, in-flight job ids, last heartbeat | a row expires `max(60 s, visibility timeout)` after its last renewal, renewed every third of that (20 s); a killed worker leaves by expiry, so it stays listed up to 60 s. As of 2026-11-12 |
|
|
376
378
|
| history | `counters({ job, sinceMs })`, `counterTotals(sinceMs)` — `done`, `retried`, `failed`, `dead`, `durationMs` | `COUNTER_TIERS`: 1-minute buckets for 24 h, 5-minute for 7 d, 1-hour for 30 d. On Postgres a process batches its settles' counts and writes them every 10 s and on `close()`: a read from the same process flushes first, one from another process can lag up to 10 s, and a crash loses at most 10 s of counts — never a job row's state |
|
|
377
379
|
| progress | `run({ progress })` → `progress(done, total, note?)`, on the row and in `x jobs show` | one write a second per run at most, and always the last before the run settles |
|
|
378
|
-
| how a run ended | `job({ onSettled })` — `completed` (with what `run` returned), `dead-lettered`, `dropped` or `refused`; after the row is settled, under the job's tenant, three tries of its own, on a live `ctx.signal` under `onSettledTimeout` (30 s by default): its `fetch` and its writes land | at least once across a crash (`redriven: true` on the re-drive), but at most once for a completion whose body returned a value
|
|
380
|
+
| how a run ended | `job({ onSettled })` — `completed` (with what `run` returned), `dead-lettered`, `dropped` or `refused`; after the row is settled, under the job's tenant, three tries of its own, on a live `ctx.signal` under `onSettledTimeout` (30 s by default): its `fetch` and its writes land | at least once across a crash (`redriven: true` on the re-drive), but at most once for a completion whose body returned a value; a hook that keeps failing is `X_JOB_ON_SETTLED_FAILED`, logged and reported, and the row is untouched. A cancel is not a settlement: whoever cancels is the observer |
|
|
379
381
|
|
|
380
382
|
```ts
|
|
381
383
|
export const syncAccount = job({
|
|
@@ -408,7 +410,7 @@ export const syncAccount = job({
|
|
|
408
410
|
| `dead-lettered` / `dropped` | failed for good; `dropped` is a job declaring `retry.deadLetter: false`. Carries `error` (the row's `lastError`), `code` (its `X_*` code, when it has one) and `input` — `undefined` when the stored payload no longer parses |
|
|
409
411
|
| `refused` | `whenBusy: 'fail'` over a busy key. The body never ran; `code` is `X_JOB_KEY_BUSY` |
|
|
410
412
|
| never called for | a retry, a suspension, a drain, a row cancelled or removed by a caller, a settle that did not land |
|
|
411
|
-
| delivery | **at least once** per ending a worker settles: a worker killed between the settle and the hook leaves a debt (`x_jobs.settle_owed`) the scheduler leader re-drives past `onSettledTimeout` × 3, with `redriven: true, reason: 'lost'` — write the hook to be repeated. **Except**, at most once: a completion whose body returned a value, as a result is never stored (planned for `next`)
|
|
413
|
+
| delivery | **at least once** per ending a worker settles: a worker killed between the settle and the hook leaves a debt (`x_jobs.settle_owed`) the scheduler leader re-drives past `onSettledTimeout` × 3, with `redriven: true, reason: 'lost'` — write the hook to be repeated. A row the claim settles itself — a final-attempt lease lapse buried `dead`, an expired row — owes it too, recorded by the claim. **Except**, at most once: a completion whose body returned a value, as a result is never stored (planned for `next`). What must be recorded for certain is written by the body, inside a `step.run` |
|
|
412
414
|
| failure | three tries back to back, all inside one `onSettledTimeout` (30 s by default), which aborts `ctx.signal` with `X_JOB_TIMEOUT` and gives the worker its slot back; then `X_JOB_ON_SETTLED_FAILED`. The job's outcome never changes |
|
|
413
415
|
|
|
414
416
|
| Fact | Detail |
|
package/wiki/Known-Gaps.md
CHANGED
|
@@ -50,7 +50,7 @@ CHANGELOG.md` finds its bounds, and it changes on any commit.
|
|
|
50
50
|
| A pod evaluates the framework from **source**, one module at a time — ~28 Mi of resident memory per pod that a bundle would not hold | `As of 2026-10-01`, measured on the framework serve graph alone: 1,071 modules from source settle at **80.4 Mi**; the same graph as one `bun build --target=bun` file is 5 modules and settles at **51.8 Mi** — ~34 kB of RSS per source module, the runtime's cost and not the code's. It is the largest saving left after the per-role load and the prebuilt store (a web pod of the demo app settles at 97–102 Mi, a worker at 80–85 Mi). **Not a patch**: a registry is a module instance, so the framework bundled apart from the app is two `@ultimat3/jobs`, two `@ultimat3/entity` — the app registers into one and the boot reads the other. The unit has to be the app **and** the framework as one graph, per role, built inside the image build from a generated entry that imports what `scanAppModules` would, with the `.tsx`/`.scss` loaders as build plugins. Containers only either way (axiom 7). Design note: [`docs/architecture/13-topology-runtime.md`](https://github.com/developerz-ai/ultimate/blob/main/docs/architecture/13-topology-runtime.md#not-built-one-bundle-per-role) pin: none — a resident-memory measurement of a running pod, not a behaviour a unit test can assert | nothing to do in an app. Size a pod's memory request from `process_resident_memory_bytes` on `/metrics`, not from a guess |
|
|
51
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 |
|
|
52
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` |
|
|
53
|
-
| `onSettled` for a completion that **returned a value
|
|
53
|
+
| `onSettled` for a completion that **returned a value** runs at most once across a crash | `As of 2026-11-14`. Every other ending is at least once: the write that settles the row records the debt (`x_jobs.settle_owed`) and the scheduler leader re-drives a dead worker's with `redriven: true, reason: 'lost'` — failures, dead letters, refusals, completions whose body returned `undefined`, and the rows the CLAIM settles (a final-attempt lease lapse buried `dead`, an expired row: `ClaimOptions.settleOwed`, `packages/jobs/src/claim-exhausted.ts`). A body's return value is never stored (`x_jobs` has no result column), so a re-drive could only hand `result: undefined` to a hook typed for a value; on a minor that would break every `onSettled` reading `result`. Storing the result, and so at-least-once for every completion, is planned for `next` [pin](https://github.com/developerz-ai/ultimate/blob/main/packages/jobs/src/settle-redrive.test.ts#a%20completion%20that%20returned%20a%20value%20owes%20nothing%3A%20told%20once%2C%20at%20most%20once) | write what must be recorded for certain inside the body, in a `step.run`; or have the body return nothing and read what it wrote from there |
|
|
54
54
|
| A `step.run` output past 256 KiB is stored with a warning, not refused | `As of 2026-11-12`. Undeclared, `STEP_OUTPUT_MAX_BYTES` logs `jobs.step.output-too-large` (`X_STEP_OUTPUT_TOO_LARGE`) once per job and step and stores the output, because refusing by default would fail shipped jobs on a minor; every attempt still loads it. Refusal by default is planned for `next` [pin](https://github.com/developerz-ai/ultimate/blob/main/packages/jobs/src/steps-output.test.ts#the%20default%20256%20KiB%20warns%20once%20per%20job%20and%20step%2C%20with%20the%20code%2C%20and%20still%20stores) | declare `job({ stepOutputMax: 262_144 })` to be refused now, and persist the payload, returning its key from the step |
|
|
55
55
|
| 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 |
|
|
56
56
|
| `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 |
|
|
@@ -79,7 +79,6 @@ Each of these is a defect somebody has already argued about, and the reasoning i
|
|
|
79
79
|
|
|
80
80
|
| Open | Where it stands |
|
|
81
81
|
|---|---|
|
|
82
|
-
| Multi-node realtime | the forced-restart benchmarks **are** measured, on one `sync` node over `InProcessTransport` — neither run crossed NATS and neither subscribes to a live query, so no cursor, snapshot or gap-repair path is under test. Fanout, throughput and per-node socket capacity across nodes remain targets → [Realtime](Realtime) |
|
|
83
82
|
| `x db studio` | planned. `X_DB_STUDIO_FAILED` is reserved and not thrown; the command exits `X_NOT_IMPLEMENTED` pointing at `x dev` → the `/_x` db panel. Keeping a `bunx drizzle-kit studio` shell-out would have meant a second schema engine for one subcommand |
|
|
84
83
|
| `api/**/route.ts` | not a file kind — owner decision 1 ([#648](https://github.com/developerz-ai/ultimate/issues/648)), `As of 2026-10`. `api/` holds the action and query projections `defineApi()` collects; a route file there is refused at registration (`X_ROUTE_FILE_INVALID`), and 26.0.0 deleted `ROUTE_FILENAME`'s `api` row ([#709](https://github.com/developerz-ai/ultimate/issues/709)). A wire format an action cannot speak — a webhook receiver, an OAuth endpoint — is a plain HTTP route in the `routes` runtime override ([Configuration](Configuration)) |
|
|
85
84
|
| Deferred, `As of 2026-10-07` | the plugin API and multi-region replication. The Redis **job** driver shipped (`redisJobDriver()`, #710) without the operator surface, backfill bookkeeping or fleet-wide `concurrency` — those answer on Postgres only; the NATS job driver stub that threw `X_NOT_IMPLEMENTED` was deleted in 25.0.0. |
|
|
@@ -537,7 +537,7 @@ Position in the plan is **necessary and not sufficient**: `docker compose up -d`
|
|
|
537
537
|
|
|
538
538
|
### `x db recount` — a counter, repaired
|
|
539
539
|
|
|
540
|
-
`x db recount <entity>.<column>` compares a `countedIn` counter with the count of child rows and lists the drifted rows; `--write` sets them
|
|
540
|
+
`x db recount <entity>.<column>` compares a `countedIn` counter with the count of child rows — under its `where`, when it declares one — and lists the drifted rows; `--write` sets them. A counter drifts only while its trigger was missing (`X_LIFECYCLE_TRIGGER_MISSING`). The parent is walked in key-range windows of 1,000 rows, one cross-tenant transaction each, so a big table never holds one long lock; the dry run reads the same windows and writes nothing. Batched in the command itself, not through `backfill()`: that factory declares a job for a worker, and a recount names its counter at run time. As of 31.23.
|
|
541
541
|
|
|
542
542
|
### `x g backfill` — the generator
|
|
543
543
|
|
package/wiki/Observability.md
CHANGED
|
@@ -209,7 +209,7 @@ Declared in `runtime-metrics.ts`, so the role table, the Helm chart and the scra
|
|
|
209
209
|
|
|
210
210
|
Recorders: `recordRequest({ method, route, status, durationMs })`, `recordConnection(delta)`, `recordQueueDepth(queue, depth)`, `recordJob(queue, outcome)`, `recordLeaseLost(queue)`.
|
|
211
211
|
|
|
212
|
-
Beside them, `@ultimat3/jobs` declares its own: `jobs_retried_total{job,code}` (counter, `{attempt}`) — one per attempt that failed and went back to the queue, `code` the thrown `X_*` or `uncoded`. A retry is counted there and **not** sent to the `ErrorReporter`; a dead letter is, once, as `error`. A job opts its retries into the reporter, as `warning`, with `retry: { report: 'every-attempt' }` ([Jobs](Jobs-And-Workflows#concurrency-rate-limits-queues-retry)). A polling loop that fails every tick logs one line when the streak opens and one with the count when it closes: `jobs.{scheduler,worker,outbox}.tick-failed` / `.tick-recovered`,
|
|
212
|
+
Beside them, `@ultimat3/jobs` declares its own: `jobs_retried_total{job,code}` (counter, `{attempt}`) — one per attempt that failed and went back to the queue, `code` the thrown `X_*` or `uncoded`. A retry is counted there and **not** sent to the `ErrorReporter`; a dead letter is, once, as `error`. A job opts its retries into the reporter, as `warning`, with `retry: { report: 'every-attempt' }` ([Jobs](Jobs-And-Workflows#concurrency-rate-limits-queues-retry)). A polling loop that fails every tick logs one line when the streak opens and one with the count when it closes: `jobs.{scheduler,worker,outbox}.tick-failed` / `.tick-recovered`, `db.listen.redial_failed` / `db.listen.redialed`, `jobs.wake.{listen,probe}-failed` / `-recovered`, and `cache.broadcast.deferred-failed` / `-recovered` — core's `failureStreak` (`@ultimat3/core`), one line per cause, for a loop of your own.
|
|
213
213
|
|
|
214
214
|
All five recorders are wired `As of 2026-08`, each in the package that owns the event:
|
|
215
215
|
|
|
@@ -278,6 +278,7 @@ CPU autoscaling is wrong for `sync` and `worker`: a node holding 80k idle socket
|
|
|
278
278
|
| Error grouping | `errorFingerprint(report)`: 16 hex over `code`, `source`, `scope.operation`, plus the top application frame (function and root-relative path, no line) for `X_INTERNAL`. Never the cause or an id, so two throws differing in a row id are one group, and a deploy is not a new one. The Sentry envelope sends it as `fingerprint` |
|
|
279
279
|
| Log level | `LOG_LEVEL`, default `info`. The framework's own policy (`As of 2026-11`): a routine per-unit event (one per request, job, fire or message) is `debug`; `info` is lifecycle and rare outcomes; `warn` asks an operator to act. `scripts/log-levels.ts` refuses an unstated per-unit `info` line in the framework (`X_LOG_LEVEL_UNSTATED`) |
|
|
280
280
|
| Secret redaction | a `Secret` is redacted by value before every other branch, at any depth → [Configuration](Configuration) |
|
|
281
|
+
| Value redaction | `redactValues([{ pattern: /acct_[0-9]{10}/g, replace: '[account]' }])`, once at boot (`As of 2026-11`): every match is rewritten in the log line's message and field strings, an `Error`'s message, and the monitor envelope's exception value, `fix`, `stack`, extras and `meta`, a span's exception event and status message, and a failure bundle's captured values. Key redaction (`redactKeys`) cannot see a value inside a message; this can. The `g` flag is required; a sticky pattern, one matching the empty string, or a repeated group holding a repeating quantifier (`(a+)+`, `(a+){2,40}`; only `?`/`{0,1}` do not repeat) is refused with `X_REDACT_PATTERN_UNSAFE`, and the whole list with it. Appends, like `redactKeys`; the framework registers no pattern |
|
|
281
282
|
| Request context | the ALS context carries the request id every log line and span inherits |
|
|
282
283
|
| Live queries | the realtime client puts a `traceparent` on the `subscribe` frame (`LiveClient({ traceparent })`); the snapshot that subscribe causes is the span `live.snapshot <query>`, a CHILD of it, and a re-read a change forces is `live.rerun <query>`, which LINKS to it and parents on the change. A value that is not a valid W3C header is ignored, never refused: telemetry never fails a subscribe. The page boot sends none (`As of 2026-11`): a browser holds no trace |
|
|
283
284
|
| Request span name | `GET /r/:token` — the route PATTERN, never the concrete URL (a token in a path would reach every collector); `http.route` carries the same pattern, and an unmatched request is named by its method alone with `http.route: unmatched` (`As of 22.6.0`) |
|
package/wiki/Outbound-HTTP.md
CHANGED
|
@@ -45,6 +45,45 @@ Required, a decision per call.
|
|
|
45
45
|
| `'named'` | a host the app names in code or config: a vendor API, a sidecar | dialled as written |
|
|
46
46
|
| `'public'` | a URL a tenant or a user supplied | https only outside a local environment, no URL credentials, every address the name answers must be public, the connection pinned to the approved address with `tls.serverName`. Refusal: `X_OUTBOUND_HOST_BLOCKED` |
|
|
47
47
|
|
|
48
|
+
**Writing your own public-dial guard is the bug this option exists to prevent.** A URL a tenant
|
|
49
|
+
supplied (a webhook, an avatar, a feed) is `dial: 'public'`: resolve, classify every address, pin,
|
|
50
|
+
re-screen each redirect. All of it is in this one option.
|
|
51
|
+
|
|
52
|
+
## `proxy`: send the call through an HTTP proxy
|
|
53
|
+
|
|
54
|
+
| Form | What happens |
|
|
55
|
+
|---|---|
|
|
56
|
+
| `proxy: 'http://user:pass@proxy:3128'` (or a `URL`) | every hop goes through it: `CONNECT` for `https:`, an absolute-form request for `http:` |
|
|
57
|
+
| `proxy: { url, headers }` | the same, `headers` sent on the `CONNECT` (`proxy-authorization: Bearer …`) |
|
|
58
|
+
| `proxy: (target) => … \| undefined` | asked once per hop with that hop's NAMED url (never the pinned address); `undefined` dials the hop direct. May be async, and is bounded by `deadlineMs` |
|
|
59
|
+
|
|
60
|
+
- **Beside `dial: 'public'`, the screen still runs FIRST.** A refused host never reaches the proxy or
|
|
61
|
+
your resolver; an approved one is tunnelled to the screened ADDRESS (`CONNECT 93.184.216.34:443`),
|
|
62
|
+
so the proxy resolves nothing itself. `tls.serverName` survives the tunnel: the certificate is
|
|
63
|
+
still proven against the name (measured on Bun 1.4.4, `outbound-proxy-tunnel.test.ts`).
|
|
64
|
+
- **The proxy is the app's own choice**, like a `'named'` host: it is not screened.
|
|
65
|
+
- `http:` and `https:` proxies only. Anything else, or a resolver that throws, is
|
|
66
|
+
`X_OUTBOUND_PROXY_INVALID` before a byte, never retried.
|
|
67
|
+
- **The proxy's credential is in no cause, log line, span or event**: URL userinfo is cut from a
|
|
68
|
+
transport's message (`//…@`), and the proxy is never recorded.
|
|
69
|
+
- With no `proxy`, Bun's own `HTTPS_PROXY` / `HTTP_PROXY` / `NO_PROXY` still apply, as for any `fetch`.
|
|
70
|
+
- **Which proxy, and rotating them, is app code** (axiom 8): a resolver over your own inventory.
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
import { outbound } from '@ultimat3/core/outbound';
|
|
74
|
+
|
|
75
|
+
declare const url: string;
|
|
76
|
+
const proxies = ['http://u:p@egress-a:3128', 'http://u:p@egress-b:3128'];
|
|
77
|
+
let next = 0;
|
|
78
|
+
await outbound({
|
|
79
|
+
url,
|
|
80
|
+
vendor: 'feed',
|
|
81
|
+
dial: 'public',
|
|
82
|
+
deadlineMs: 10_000,
|
|
83
|
+
proxy: () => proxies[next++ % proxies.length],
|
|
84
|
+
});
|
|
85
|
+
```
|
|
86
|
+
|
|
48
87
|
`screenDial(url, { resolve, allowPrivate })` is the screen alone, for a transport that keeps its own
|
|
49
88
|
codes: `@ultimat3/jobs`' webhook target and `@ultimat3/scraping`'s wildcard leg call it.
|
|
50
89
|
|
|
@@ -62,6 +101,7 @@ codes: `@ultimat3/jobs`' webhook target and `@ultimat3/scraping`'s wildcard leg
|
|
|
62
101
|
| `X_OUTBOUND_REDIRECTED` | terminal | a 3xx under `redirect: 'error'`, or more than 5 hops (`meta.location`, no query) |
|
|
63
102
|
| `X_OUTBOUND_RETRY_UNSAFE` | terminal | `retry` on POST or PATCH without `idempotent: true` |
|
|
64
103
|
| `X_OUTBOUND_BODY_INVALID` | terminal | `answer.json(schema)` refused the body (`meta.issues`) |
|
|
104
|
+
| `X_OUTBOUND_PROXY_INVALID` | terminal | `proxy` is not an `http:`/`https:` URL, or its resolver threw (`meta.reason`, never the URL) |
|
|
65
105
|
|
|
66
106
|
**A 401 is `X_OUTBOUND_REFUSED` with `meta.status: 401`.** There is no refresh hook: the app's own
|
|
67
107
|
wrapper refreshes its token and calls again. Token storage and single-flight stay the app's.
|
|
@@ -119,17 +119,17 @@ The matrix runs **outside a request**: no input, no row. A rule that reads eithe
|
|
|
119
119
|
## Scope — a policy's database filter
|
|
120
120
|
|
|
121
121
|
`scoped(policy, scope)` attaches `scope(actor) → where` to a policy, `As of 2026-11`: the
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
before; the JS rule stays the authority.
|
|
122
|
+
predicate a read hands the database, so the visible rows arrive as ONE statement's page rather than
|
|
123
|
+
a JS filter over an over-fetch that leaves a viewer a short page. The policy decides exactly as
|
|
124
|
+
before; the JS rule stays the authority and still runs on every row returned.
|
|
125
125
|
|
|
126
126
|
```ts
|
|
127
127
|
import type { Actor, Policy } from '@ultimat3/policy';
|
|
128
128
|
import { policyScope, scoped } from '@ultimat3/policy';
|
|
129
129
|
|
|
130
130
|
interface Post {
|
|
131
|
-
readonly
|
|
132
|
-
readonly audience: 'public' | '
|
|
131
|
+
readonly authorId: string;
|
|
132
|
+
readonly audience: 'public' | 'friends';
|
|
133
133
|
}
|
|
134
134
|
declare const postRule: Policy<unknown, Post>;
|
|
135
135
|
declare const actor: Actor | null;
|
|
@@ -137,34 +137,64 @@ declare const actor: Actor | null;
|
|
|
137
137
|
export const seePost = scoped(postRule, (who) =>
|
|
138
138
|
who === null
|
|
139
139
|
? [{ column: 'audience', op: 'eq', value: 'public' }]
|
|
140
|
-
: [
|
|
140
|
+
: [
|
|
141
|
+
{
|
|
142
|
+
or: [
|
|
143
|
+
{ column: 'authorId', op: 'eq', value: who.id },
|
|
144
|
+
{ column: 'audience', op: 'eq', value: 'public' },
|
|
145
|
+
{
|
|
146
|
+
and: [
|
|
147
|
+
{ column: 'audience', op: 'eq', value: 'friends' },
|
|
148
|
+
{
|
|
149
|
+
via: { column: 'authorId', entity: 'friendships', target: 'friendId' },
|
|
150
|
+
where: [{ column: 'userId', op: 'eq', value: who.id }],
|
|
151
|
+
},
|
|
152
|
+
],
|
|
153
|
+
},
|
|
154
|
+
],
|
|
155
|
+
},
|
|
156
|
+
],
|
|
141
157
|
);
|
|
142
|
-
policyScope(seePost, actor); // the frozen
|
|
158
|
+
policyScope(seePost, actor); // the tree, frozen at every depth, or undefined for an unscoped policy
|
|
143
159
|
```
|
|
144
160
|
|
|
161
|
+
| Node | Means |
|
|
162
|
+
|---|---|
|
|
163
|
+
| `{ column, op, value? }` | a condition. `column` is typed by the policy's row; `op` is one of `eq` `neq` `in` `gt` `gte` `lt` `lte` `is-null` `is-not-null`; `value` is always bound |
|
|
164
|
+
| `{ or: [...] }` | any member holds; `[]` holds for no row |
|
|
165
|
+
| `{ and: [...] }` | every member holds — the arm of an `or` that needs two conditions |
|
|
166
|
+
| `{ via: { column, entity, target }, where: [...] }` | `column in (select target from entity where …)`; `entity` is a registered entity NAME |
|
|
167
|
+
|
|
145
168
|
| `policyScope(policy, actor)` answers | Means |
|
|
146
169
|
|---|---|
|
|
147
170
|
| `undefined` | no scope declared: nothing is handed down |
|
|
148
171
|
| `[]` | every row (an admin): the empty conjunction |
|
|
149
|
-
| `[
|
|
150
|
-
|
|
172
|
+
| `[node, …]` | every top-level node must hold; at most four levels deep (`X_ENTITY_PREDICATE_NODE_INVALID`) |
|
|
173
|
+
|
|
174
|
+
- **One statement.** `@ultimat3/entity`'s `.andWhereNode(node)` takes the tree on a repository
|
|
175
|
+
chain — `db.posts.where({ deletedAt: null }).andWhereNode(node)` — and compiles it into the one
|
|
176
|
+
select, a `via` as a subselect.
|
|
177
|
+
- **A `via` cannot cross tenants.** Its subselect is planned through the TARGET's tenant guard, the
|
|
178
|
+
acting actor's tenant and the target's soft delete applied inside; outside a request its `where`
|
|
179
|
+
must name the tenant, as a read of that table must. An untenanted target behind a tenanted source
|
|
180
|
+
must declare `shared:` or `global:`, else `X_TENANCY_UNSCOPED`.
|
|
181
|
+
- **A query read composes it**, `As of 31.11.0`: a `query({ policy: seePost, sql })` whose `sql`
|
|
182
|
+
returns `from()` gets each condition as a filter and each `or`/`and`/`via` node on
|
|
183
|
+
`RowWindow.nodes`, which a repository provider hands to `.andWhereNode(node)` —
|
|
184
|
+
[Queries: a scoped policy narrows the read](Queries-And-Live-Queries#a-scoped-policy-narrows-the-read).
|
|
185
|
+
Refused (`X_QUERY_SCOPE_UNCOMPOSABLE`), never served unscoped: another `SqlSource`, a tree on a live
|
|
186
|
+
read (the matcher patches a flat shape), and a `via` over `from()` given a list of rows.
|
|
187
|
+
- **A custom store** (`defineDriver`) takes a tree only when it declares `predicate:or` /
|
|
188
|
+
`predicate:via`; otherwise `X_DRIVER_UNSUPPORTED`, before the store is called.
|
|
151
189
|
- **The scope belongs to the clause it is declared on.** `and`/`or`/`not` over a scoped policy
|
|
152
190
|
carry none: the conjunction of children's scopes is not the scope of `or`. Scope the outermost
|
|
153
191
|
policy.
|
|
154
192
|
- **Tenant scoping is not scope.** Tenancy stays the entity layer's (the tenant predicate every
|
|
155
193
|
repository applies, [below](#tenancy)); a scope narrows what one actor sees inside a tenant and
|
|
156
194
|
never replaces it.
|
|
157
|
-
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
Another `SqlSource` is `X_QUERY_SCOPE_UNCOMPOSABLE`. An action, or a repository read outside a
|
|
161
|
-
query, composes nothing: there `policyScope` is the read an app composes itself, e.g.
|
|
162
|
-
`db.posts.where({ orgId })` plus each condition as `andWhere`.
|
|
163
|
-
- **AND-only, by decision** (2026-11, `packages/policy/src/scope.ts`). A scope lands as query
|
|
164
|
-
filters, so it reaches the live matcher's shape, every provider's `RowWindow.filters` and the
|
|
165
|
-
entity chain, each a conjunction; an `or` group would widen all of them at once. A rule whose
|
|
166
|
-
visibility is a disjunction (a friend OR the author OR public, minus a block set) stays unscoped
|
|
167
|
-
and keeps the JS rule over what it reads.
|
|
195
|
+
- **`or` and `via` by decision** (2026-11, reversing the AND-only decision of earlier that month,
|
|
196
|
+
`packages/policy/src/scope.ts`): apps whose visibility is a disjunction over a graph over-fetched a
|
|
197
|
+
feed and ORed in JS — the short page `scope` exists to end.
|
|
168
198
|
- **Planned, not shipped:** a finding for a scope that admits other rows than its rule on the
|
|
169
199
|
exercise seed (`X_POLICY_SCOPE_MISMATCH`, not registered yet). Until then, a scope wider than its
|
|
170
200
|
rule costs rows the rule then drops — a short page again — and a narrower one hides rows the rule
|
|
@@ -203,6 +233,7 @@ X_ENTITY_TENANT_UNDECLARED: a child of a tenant-owned table has no tenant
|
|
|
203
233
|
|---|---|
|
|
204
234
|
| `orgId: uuid().tenant()`, then `x db gen '<table> tenant'` | the rows belong to an org. A table that already holds rows backfills the column: `x g backfill <name> --feature <slice>` |
|
|
205
235
|
| `entity('<name>', { shared: '<why>' })` | the rows belong to no org — a price list, a catalog. A blank reason is refused at `entity()`; a `shared` entity is not walked through ([Entities](Entities-And-Migrations#shape)) |
|
|
236
|
+
| `entity('<name>', { global: '<why>' })` | the rows belong to no org and reference none — a plan catalog, a stream cursor. Not a fix for this finding: a table that hangs off a tenant's row is `shared` or tenant-owned, so a `global` one with such a reference is still reported. It turns a read over it from `unproven` into `global` ([below](#the-dynamic-tenant-proof)) |
|
|
206
237
|
|
|
207
238
|
Reported in the `exercise` step, not `policy`: the policy step asks whether a permission exists. Source: `packages/cli/src/exercise-static.ts`.
|
|
208
239
|
|
|
@@ -231,6 +262,7 @@ X_TENANT_LEAK: another tenant's row reached a call's output or effect
|
|
|
231
262
|
| `public` | the policy admits an anonymous caller: what it returns, anyone may read. The read half is skipped; a crossed **write** is still red |
|
|
232
263
|
| `public`, as a declared sweep | a job that reads every org on purpose says so with `crossTenant(reason, fn)`, and its input names no org's rows. The proof sees the scope and quotes the reason; the read half is skipped, a crossed **write** is still red. The same scope in an action or a query, or in a job handed A's id, is still `X_TENANT_LEAK` |
|
|
233
264
|
| `public`, as a tenantless job | a job declaring `tenant: 'none'` whose input names none of A's rows — a nightly cleanup across every org, input `{ occurrenceMs }`. No org and no id of B's choosing reaches its run, so B's run is A's run: what it writes it writes for every enqueuer. The **write** half is skipped, the read half kept. Handed one of A's ids it is crossed as ever; an action or a query handed no id still crosses, since B's org runs it |
|
|
265
|
+
| `global` | a query whose every statement read an `entity('<name>', { global: '<why>' })` table — a plan catalog the same for every org. No row of A's exists to come back, so the reasons are quoted; a crossed **write** is still red. One other entity, or one hand-written statement, and it stays `unproven` |
|
|
234
266
|
| `unproven` | A's own call was not reached (that record is already red as `X_CONTRACT_EXERCISE_UNREACHED`), or a query answered A none of A's rows — B's empty answer then proves nothing |
|
|
235
267
|
|
|
236
268
|
B holds the role A held, minus `tenancy:cross`. **Not checked**: a `route` `load` and a `task`
|
package/wiki/Realtime.md
CHANGED
|
@@ -459,6 +459,7 @@ One outage is one fact. Each condition below is written on its 1st, 2nd, 4th, 8t
|
|
|
459
459
|
| `cache.invalidate.partial` `{ …report, failures }` | `warn` | a publisher | refusals 1, 2, 4, 8, … **per failing tier** (`broadcast`, `redis`, …). Every bust's report still carries its `errors`, and `/_x` still records every bust |
|
|
460
460
|
| `cache.invalidate.partial recovered` `{ tier, after }` | `info` | a publisher | once, when that tier clears again |
|
|
461
461
|
| `cache.broadcast.subscribe-failed` `{ attempt, error }` · `… recovered` `{ after }` | `warn` · `info` | every role | silent for the first 10 s of the boot subscribe (`FIRST_DIAL_GRACE_MS`: the bus's first dial is still in progress, and the subscribe lands within it on a healthy pod); past that the first refusal and then attempts 2, 4, 8, … warn, and the landing is said once at info — only after a warning. `As of 2026-10-17` |
|
|
462
|
+
| `cache.broadcast.deferred-failed` `{ error, code? }` · `cache.broadcast.deferred-recovered` `{ failures }` | `warn` · `info` | a publisher | publishing the busts a bus outage deferred, on each reconnect: once per cause (a new one carries `previous`), then once when a settle lands, with the count. `As of 2026-11-14` |
|
|
462
463
|
| `live.bus_reconnected` `{ desynced, channelGaps }` | `warn` | `sync` | once per recovery: how many windows and topics were told to re-read |
|
|
463
464
|
|
|
464
465
|
Until 2026-10-10 a three-minute outage wrote `presence.sweep failed` at `error` every 10 s on every `sync` node (19 lines on one), sent the monitor one event per refused beat per socket, and wrote `cache.invalidate.partial` once per bust on every publisher. A failure that is **not** the bus being away — a policy that threw inside a presence leave — is still written every time, as `<operation> failed`.
|
|
@@ -598,7 +599,23 @@ arrived meanwhile after it. A dropped `events` frame is ephemeral by design and
|
|
|
598
599
|
already repairs the same drop, as it has since 2026-08: the subscriber is marked desynced, and the
|
|
599
600
|
next change re-snapshots it.
|
|
600
601
|
|
|
601
|
-
What it is **not**: a multi-node result — neither run crossed NATS, so this is **per-node recovery**, not fanout. Not a throughput figure either: no requests/sec, no message rate, no sustained-load number. Per-node socket capacity in the tables above this section is still a target derived from Bun's native WebSocket implementation, not a benchmark result. Long-running Bun processes are also less battle-proven than Node's; sustained-socket memory profiling is explicit roadmap work.
|
|
602
|
+
What it is **not**: a multi-node result — neither run crossed NATS, so this is **per-node recovery**, not fanout; the cross-node claims are the next section's, proven by a test and not by this benchmark. Not a throughput figure either: no requests/sec, no message rate, no sustained-load number. Per-node socket capacity in the tables above this section is still a target derived from Bun's native WebSocket implementation, not a benchmark result. Long-running Bun processes are also less battle-proven than Node's; sustained-socket memory profiling is explicit roadmap work.
|
|
603
|
+
|
|
604
|
+
## Across nodes, over a real bus
|
|
605
|
+
|
|
606
|
+
`As of 2026-11-14`, proven by `bun test ./packages/realtime/src/multi-node.live.test.ts` (needs `TEST_NATS_URL`): two `sync` nodes, each on its own NATS connection and its own port, the replicator on a third, pages on real websockets through `LiveClient`. Loss and duplication are read off the frames each page received, never off its state.
|
|
607
|
+
|
|
608
|
+
| Claim | What the suite does |
|
|
609
|
+
|---|---|
|
|
610
|
+
| An event published on one node reaches a member on another, in publish order | 50 `publishEvent` calls through node A's hub, the member seated on node B: all 50, in order |
|
|
611
|
+
| A replicated change reaches every node's pages, each in lsn order | 40 commits, a page on each node: one snapshot each, then 40 patches, none at or below the position already held |
|
|
612
|
+
| A page whose node dies resumes on a survivor **from its cursor** — no loss, no duplicate | node A's sockets ended with no `reconnect` frame and its bus dropped mid-stream; the page redials node B once, and B replays its retained window: still one snapshot in total, each of the 60 commits exactly once |
|
|
613
|
+
| A node restarted empty serves the returning page one snapshot, and the stream goes on from it | the page's cursor names a window the new node never held: one snapshot holding what was written while it was down, then patches above it |
|
|
614
|
+
| A node that misses changes on the bus detects it and re-serves its pages **with no later write** | only that node's bus is cut (a relay); 20 commits go past it, then nothing. On reconnect (`live.bus_reconnected`) every window is re-read at once and its pages re-snapshotted |
|
|
615
|
+
|
|
616
|
+
The last row was a defect the suite found: a bus reconnect or a replicator resync marked every window and repaired it only on the next change the node heard, so a quiet query showed its pre-outage rows until a write or the idle sweep (`idleTimeoutMs / 4`, 30 s by default). Both now repair at once (`sync-bus-handlers.ts`, `sync-bus-repair.test.ts`). A gap seen on a message needed no change: that message's delivery reaches every stale window.
|
|
617
|
+
|
|
618
|
+
Delivery is at most once on the bus and exactly once to the page: a lost bus message is a gap the node detects (`SeqGapDetector`, or the reconnect itself) and answers with a snapshot, and a patch at or below the cursor is refused by the window's lsn guard. The "kill" is in-process — listener stopped with its sockets, node stopped, bus closed, no drain — which is what a `SIGKILL` leaves the page and the bus to find. **Still targets, not results:** cross-node fanout throughput and per-node socket capacity; nothing here measures a rate.
|
|
602
619
|
|
|
603
620
|
## `sync` drain
|
|
604
621
|
|
package/wiki/Scheduled-Tasks.md
CHANGED
|
@@ -135,7 +135,7 @@ Fixed **1**. Cron dispatch only.
|
|
|
135
135
|
| Renewal | `acquire()` **is** the renewal, sent every `ttlMs / 3` (20s) — tick 1s, lease TTL `DEFAULT_LEADER_TTL_MS` = 60s. A node that stops renewing loses the lease by expiry, with nothing to clean up: a killed leader's standby takes over up to ~80s later (the 60s lease, then its next ask), a drained one's within 20s (the drain deletes the row; the standby's next ask takes it). As of 2026-11-12 |
|
|
136
136
|
| Second instance | a warm standby, not a duplicate. It calls `acquire()` every `renewEveryMs` (20s), the cadence the leader renews on, not every round; while another node holds an unexpired row it acquires nothing and dispatches nothing, and its first ask after that row expires takes the row and makes it the leader |
|
|
137
137
|
| Leadership lost | logged once as `jobs.scheduler.leadership-lost`; the node keeps polling and takes over on its first ask (every 20s) after the holder's lease expires. **The process does not exit**, and neither does a `replicator` container that loses its lock: it stands by unready and re-asks. Only `x dev --role replicator` refuses (`X_REPLICATOR_SLOT_HELD`) |
|
|
138
|
-
| `/readyz` on the standby |
|
|
138
|
+
| `/readyz` on the standby | on the metrics port only: `ROLE=scheduler` binds `METRICS_PORT` (default 9090) and no HTTP server. Liveness is `/healthz` there, 503 once the dispatch loop stops turning — the probe [`docs/ops/01-kubernetes.md`](https://github.com/developerz-ai/ultimate/blob/main/docs/ops/01-kubernetes.md) declares. Nothing routes request traffic to a scheduler in the first place |
|
|
139
139
|
| Missed tick (leader down, node paused, clock jump) | **fires late rather than being skipped** |
|
|
140
140
|
| Double fire during handover | absorbed by the enqueued job's `idempotencyKey` — the second enqueue returns the existing handle, no new row |
|
|
141
141
|
| Drain on SIGTERM | registered at the `accept` phase: stop dispatching, wait out the dispatch round in flight, then delete the lease row — the standby promotes on its next round rather than waiting out the TTL, and never onto an occurrence this node is still enqueueing for |
|
package/wiki/Shapes.md
CHANGED
|
@@ -57,7 +57,8 @@ its output: `--dry-run` lists those runs under `data.generate`.
|
|
|
57
57
|
| `bun run setup && bun run verify` green on the first pass, then again over every generator | `scaffold-smoke` in `.github/workflows/ci.yml`, one row per shape — `scripts/ci-workflow-shape.test.ts` refuses a shape with no row |
|
|
58
58
|
|
|
59
59
|
`As of 2026-11-06`. Five shapes are planned (`saas` and `agent` beside these three); a shape is
|
|
60
|
-
listed here, and accepted by `--shape`, only once its row gates green. `saas` waits on a
|
|
61
|
-
|
|
60
|
+
listed here, and accepted by `--shape`, only once its row gates green. `saas` waits on a billing
|
|
61
|
+
seam no slice has landed — its member invite ships, as `defineMemberInvite` and `x g invite`
|
|
62
|
+
([Auth](Auth#member-invites), `As of 2026-11-14`); `agent` on a model and provider an app names by
|
|
62
63
|
environment alone, which no shipped seam takes without a provider SDK or a model row the scaffold
|
|
63
64
|
would have to invent.
|
package/wiki/Testing.md
CHANGED
|
@@ -1090,6 +1090,7 @@ only what came back and what changed.
|
|
|
1090
1090
|
| `public` | the policy admits an anonymous caller with an empty input: read half skipped, write half kept | no |
|
|
1091
1091
|
| `public` | a **job** whose B leg opened `crossTenant(reason, fn)` and whose input carried none of A's marks — a declared sweep, `sendDigest` fanning out one delivery per org. The reason is quoted in the verdict; read half skipped, write half kept | no |
|
|
1092
1092
|
| `public` | a **job** declaring `tenant: 'none'` whose input carried none of A's marks — a nightly cleanup across every org, input `{ occurrenceMs }`. No org and no id B chose reaches its run, so B's run is A's run: write half skipped (no snapshots taken), read half kept. Handed one of A's ids, crossed as ever. Both this and a declared sweep: both reasons, `; `-joined | no |
|
|
1093
|
+
| `global` | a **query** every statement of whose A call was a repository read of an `entity({ global: '<why>' })` table, `As of 2026-11-14` — a plan catalog. There is no row of A's to hand back, so the reasons are quoted in the verdict; the legs are still searched and the write half kept. One other entity (a policy's membership read included) or one hand-written statement, and it is the `unproven` below | no |
|
|
1093
1094
|
| `unproven` | a query whose A answer held none of A's marks: B's empty answer proves nothing | no |
|
|
1094
1095
|
| `proven` | otherwise | no |
|
|
1095
1096
|
|
|
@@ -252,7 +252,7 @@ The same run logs `sync reachable` with the node on `ws://localhost:3101/_x/sync
|
|
|
252
252
|
|
|
253
253
|
**Delivery.** A second run, 10,000 clients and a probe every 200ms, counting gaps in each client's received sequence: **1,666,882 channel patches received, 0 observed sequence gaps** ([`10k-restart-seq.json`](https://github.com/developerz-ai/ultimate/blob/main/scripts/bench/results/10k-restart-seq.json)). A first-patch timer cannot see a lost patch, which is why the second run exists — `As of 2026-08` it is the only one with delivery accounting. It says nothing about 50,000, and its zero is a lower bound: a gap needs a received frame on each side of it, so "no client observed a loss" is the claim, not "nothing was lost" ([Realtime](Realtime)).
|
|
254
254
|
|
|
255
|
-
Both are per-node recovery — neither run crossed NATS, so neither is a multi-node result nor a throughput figure. Detail and limits: [Realtime](Realtime).
|
|
255
|
+
Both are per-node recovery — neither run crossed NATS, so neither is a multi-node result nor a throughput figure. What *is* proven across nodes (delivery, ordering, resume, gap repair over a real bus) and what is still unmeasured (throughput, socket capacity): [Realtime](Realtime#across-nodes-over-a-real-bus). Detail and limits: [Realtime](Realtime).
|
|
256
256
|
|
|
257
257
|
Realtime tier 3 (local-first) shipped in 21.0.0, and it is declared on the **entity**, not the query: `entity(name, { persist: true })`, default `false`, keeps its records in IndexedDB beside the one outbox ([Realtime](Realtime#tier-3-shipped-in-2100)). `persist` is not a `query()` field — writing it there is a `TS2353` excess property.
|
|
258
258
|
|
package/wiki/Upgrading.md
CHANGED
|
@@ -289,6 +289,8 @@ A setter still on a package's `.` barrel is `X_ADAPTER_PORT_INCOMPLETE` on the `
|
|
|
289
289
|
| `x verify` without `--json` prints its per-step stderr lines for a person (**31.22.0**): `✓ lint 22.0s`, and for a red step its narrowest re-run — no longer `{"step":…}` JSON | a script that parses those lines passes `--json`, which keeps them JSON |
|
|
290
290
|
| `x verify`'s `lint` step reports every format and import-order miss as one `X_LINT_FAILED` (**31.22.0**), its fix a single `bunx biome check --write <file…>`; a reader counting one finding per file sees fewer | nothing; run the one command |
|
|
291
291
|
| `x verify --changed` gives a route's `page.tsx` its own rule, `page` (**31.22.0**): typecheck, lint, boundaries, filesize, i18n and that route's tests, where it ran every step but `drift` | nothing; `x verify` with no flag is still the verdict |
|
|
292
|
+
| `x doctor` lists `error-declared` as differing from the shipped template after the **31.24.0** hop: its `fix:` is now one pasteable call per class — `export const PostNotFound = defineError({ code: 'X_POST_NOT_FOUND', title, status, cause, fix, problemMeta: [...] })`, the binding and the code read off the finding — because `defineError` now takes `problemMeta` and `publicCause: true`, which replace a hand-written class's `registerErrorStatus` / `registerProblemMeta` rows. The rule is the same; nothing new is reported | optional: `x g guard error-declared --force` — it rewrites `guards/error-declared.ts` **and** its `.test.ts`, so review the diff and keep any rule you edited on purpose. Then `x verify` |
|
|
293
|
+
| `repo-unbounded` fails the gate in a **new** app from **31.24.0** (`x new` and `x g guard` write it with no `severity` line); an existing app's report-only copy still reads as current in `x doctor`. A bare `.all()` also logs `X_ENTITY_ALL_TRUNCATED` with its call site in dev and test | optional: `x g guard repo-unbounded --force` to make your copy fail the gate on a bare `.all()` — add `.limit(n)` or page with `.page()` at every site it then lists. Then `x verify` |
|
|
292
294
|
|
|
293
295
|
## 29.x → 30.0.0, entry by entry
|
|
294
296
|
|