@ultimat3/cli 31.48.0 → 31.50.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 +30 -23
- package/README.md +96 -4
- package/package.json +30 -30
- package/src/api-registration.ts +45 -14
- package/src/api-routes.ts +1 -0
- package/src/app-load.ts +7 -3
- package/src/app-openapi.ts +7 -1
- package/src/app-root.ts +7 -1
- package/src/budgets.ts +2 -1
- package/src/clean-services.ts +142 -0
- package/src/cmd-auth.ts +3 -0
- package/src/cmd-clean-spec.ts +10 -3
- package/src/cmd-clean.ts +23 -9
- package/src/cmd-db-backfill.ts +6 -0
- package/src/cmd-db-branch.ts +10 -4
- package/src/cmd-db-recount.ts +5 -12
- package/src/cmd-db-rollback.ts +77 -0
- package/src/cmd-db-spec.ts +18 -2
- package/src/cmd-db-status.ts +5 -10
- package/src/cmd-db.ts +105 -33
- package/src/cmd-deploy-verify.ts +14 -6
- package/src/cmd-docs-topic.ts +94 -0
- package/src/cmd-docs.ts +15 -1
- package/src/cmd-doctor.ts +109 -41
- package/src/cmd-drill.ts +80 -18
- package/src/cmd-env.ts +30 -8
- package/src/cmd-errors-app.ts +63 -0
- package/src/cmd-errors.ts +50 -14
- package/src/cmd-generate.ts +17 -4
- package/src/cmd-heavy-spec.ts +9 -1
- package/src/cmd-heavy.ts +111 -27
- package/src/cmd-i18n.ts +33 -1
- package/src/cmd-jobs.ts +27 -1
- package/src/cmd-merge-driver-spec.ts +12 -0
- package/src/cmd-merge-driver.ts +95 -0
- package/src/cmd-new.ts +23 -3
- package/src/cmd-policy-spec.ts +9 -1
- package/src/cmd-policy.ts +72 -17
- package/src/cmd-stop.ts +18 -4
- package/src/cmd-tasks-run.ts +87 -0
- package/src/cmd-tasks-spec.ts +10 -3
- package/src/cmd-tasks.ts +8 -5
- package/src/cmd-test.ts +2 -1
- package/src/cmd-upgrade-spec.ts +8 -1
- package/src/cmd-upgrade.ts +15 -1
- package/src/cmd-verify.ts +9 -41
- package/src/codemods/agents-doc-row.ts +73 -0
- package/src/codemods/define-error-leaf.ts +37 -12
- package/src/codemods/docs-many-agents.ts +11 -15
- package/src/codemods/docs-worker-commands.ts +26 -0
- package/src/codemods/engine-fs.ts +9 -2
- package/src/codemods/index.ts +4 -0
- package/src/codemods/merge-drivers.ts +147 -0
- package/src/command.ts +3 -0
- package/src/db-applied-edits.ts +117 -0
- package/src/db-dev-wire.ts +18 -0
- package/src/db-diagnostics.ts +5 -10
- package/src/db-generate.ts +82 -7
- package/src/db-migrate-pass.ts +51 -0
- package/src/db-migrate-through-dev.ts +209 -0
- package/src/db-rollback-consent.ts +128 -0
- package/src/db-rollback-pass.ts +76 -0
- package/src/db-seed-generate.ts +5 -1
- package/src/db-seed.ts +7 -1
- package/src/deploy-verify-findings.ts +3 -0
- package/src/deploy-verify-grade.ts +3 -0
- package/src/deploy-verify-processes.ts +32 -0
- package/src/dev-boot.ts +3 -0
- package/src/dev-db-migrate.ts +155 -0
- package/src/dev-db-rollback.ts +33 -0
- package/src/dev-db-settled.ts +22 -0
- package/src/dev-lock-errors.ts +78 -0
- package/src/dev-lock-holder-dir.ts +64 -0
- package/src/dev-lock-live.ts +44 -0
- package/src/dev-lock.ts +59 -84
- package/src/dev-policy.ts +11 -8
- package/src/dev-rebuild-schema.ts +116 -13
- package/src/dev-rebuild.ts +13 -4
- package/src/dev-route-table.ts +7 -0
- package/src/dispatch.ts +21 -1
- package/src/doctor-api-listing.ts +114 -0
- package/src/doctor-guarded.ts +41 -0
- package/src/doctor-port.ts +90 -17
- package/src/doctor-probe.ts +36 -5
- package/src/doctor-processes-probe.ts +127 -0
- package/src/doctor-processes.ts +136 -0
- package/src/doctor-warnings.ts +17 -0
- package/src/error-codes-agents.ts +35 -0
- package/src/error-codes-processes.ts +30 -0
- package/src/error-codes-tooling.ts +2 -0
- package/src/error-codes.ts +12 -13
- package/src/errors-suite.ts +27 -0
- package/src/errors.ts +18 -22
- package/src/exercise-registration.ts +4 -3
- package/src/exercise-services.ts +13 -3
- package/src/framework-env.ts +7 -3
- package/src/framework-schema.ts +15 -5
- package/src/generate-files.ts +1 -0
- package/src/generate-grant-findings.ts +7 -5
- package/src/generate-grants.ts +9 -8
- package/src/generate-kinds.ts +30 -6
- package/src/generate-roles-file.ts +30 -0
- package/src/generate-slice-policy.ts +3 -3
- package/src/guard-sources.ts +1 -2
- package/src/guards.ts +2 -2
- package/src/heavy-env.ts +2 -0
- package/src/heavy-errors.ts +18 -0
- package/src/heavy-holders.ts +78 -0
- package/src/heavy-ledger.ts +56 -14
- package/src/heavy-pressure.ts +104 -0
- package/src/heavy.ts +31 -13
- package/src/i18n-registration.ts +22 -2
- package/src/island-harness.ts +2 -2
- package/src/job-budget.ts +4 -2
- package/src/job-registration.ts +64 -8
- package/src/jobs-queue-known.ts +43 -0
- package/src/mcp-errors-agents.ts +20 -0
- package/src/mcp-errors-doctor.ts +27 -0
- package/src/mcp-errors-processes.ts +23 -0
- package/src/mcp-errors.ts +15 -29
- package/src/mcp-host.ts +2 -2
- package/src/merge-driver-catalog.ts +58 -0
- package/src/merge-driver-config.ts +43 -0
- package/src/merge-driver-lines.ts +140 -0
- package/src/merge-state.ts +105 -0
- package/src/messages-db.ts +22 -1
- package/src/messages-processes.ts +13 -0
- package/src/messages-upgrade.ts +10 -0
- package/src/messages.ts +54 -4
- package/src/output-findings.ts +48 -21
- package/src/page-navigation.ts +5 -2
- package/src/parse.ts +37 -6
- package/src/policy-facts.ts +38 -21
- package/src/policy-row.ts +99 -0
- package/src/port-pair-free.ts +28 -0
- package/src/pwa-artifacts.ts +1 -1
- package/src/registry-lines.ts +110 -0
- package/src/registry.ts +2 -0
- package/src/retain-sweep.ts +1 -1
- package/src/retained-assets-boot.ts +1 -1
- package/src/role-replicator.ts +4 -1
- package/src/role-select.ts +86 -0
- package/src/role-start.ts +13 -55
- package/src/role-sync.ts +10 -5
- package/src/runtime-assets-site.ts +2 -2
- package/src/runtime-assets.ts +1 -1
- package/src/runtime-cache-frame.ts +46 -0
- package/src/runtime-cache-ttl.ts +23 -0
- package/src/runtime-cache.ts +33 -16
- package/src/runtime-database-ssl.ts +84 -0
- package/src/runtime-idempotency-scope.ts +16 -2
- package/src/runtime-jobs-share.ts +52 -0
- package/src/runtime-jobs.ts +43 -12
- package/src/runtime-queue.ts +18 -3
- package/src/runtime-render-document.ts +1 -2
- package/src/runtime-services.ts +8 -1
- package/src/schema-drift.ts +19 -2
- package/src/schema-dump-drift.ts +4 -1
- package/src/serve-boot-probe.ts +30 -2
- package/src/serve-boot.ts +11 -1
- package/src/serve-env.ts +39 -3
- package/src/serve.ts +61 -10
- package/src/site-asset-routes.ts +2 -2
- package/src/site-assets.ts +5 -158
- package/src/stop-run-start.ts +12 -0
- package/src/supervise-boot.ts +61 -0
- package/src/supervise-cgroup.ts +84 -0
- package/src/supervise-child.ts +206 -0
- package/src/supervise-count.ts +244 -0
- package/src/supervise-errors.ts +83 -0
- package/src/supervise-facts.ts +40 -0
- package/src/supervise-messages.ts +84 -0
- package/src/supervise-policy.ts +46 -0
- package/src/supervise-pool.ts +10 -0
- package/src/supervise-probe.ts +158 -0
- package/src/supervise-run.ts +54 -0
- package/src/supervise.ts +383 -0
- package/src/sw-precache-plan.ts +1 -1
- package/src/templates/generate-purge.ts +6 -6
- package/src/templates/guard-animated-layout-property.ts +2 -2
- package/src/templates/guard-bare-error.ts +1 -1
- package/src/templates/guard-error-declared.ts +2 -2
- package/src/templates/guard-focus-visible.ts +1 -1
- package/src/templates/guard-image-dimensions.ts +2 -2
- package/src/templates/guard-island-mount-clears.ts +1 -1
- package/src/templates/guard-native-confirm.ts +1 -1
- package/src/templates/guard-raw-breakpoint.ts +2 -2
- package/src/templates/guard-raw-colour.ts +2 -2
- package/src/templates/guard-raw-fetch.ts +1 -1
- package/src/templates/guard-raw-interval.ts +1 -1
- package/src/templates/guard-raw-length.ts +3 -3
- package/src/templates/guard-raw-motion.ts +97 -1
- package/src/templates/guard-raw-shadow.ts +1 -1
- package/src/templates/guard-raw-z-index.ts +1 -1
- package/src/templates/guard-released-forms.ts +58 -9
- package/src/templates/guard-repo-await-in-loop.ts +1 -1
- package/src/templates/guard-repo-raw-sql.ts +4 -4
- package/src/templates/guard-repo-unbounded.ts +1 -1
- package/src/templates/guard-runtime-pin.ts +1 -1
- package/src/templates/guard-semantic-interactive.ts +2 -2
- package/src/templates/guard-unbounded-fanout.ts +1 -1
- package/src/templates/guard-undeclared-custom-property.ts +3 -3
- package/src/templates/guard-undefined-style-class.ts +3 -3
- package/src/templates/guard-unzoned-date.ts +3 -3
- package/src/templates/query-slice.ts +82 -0
- package/src/templates/query.ts +76 -30
- package/src/templates/resource-page.ts +3 -2
- package/src/templates/scaffold-bin.ts +2 -0
- package/src/templates/scaffold-claude-commands.ts +6 -0
- package/src/templates/scaffold-claude.ts +4 -4
- package/src/templates/scaffold-container-compose.ts +47 -7
- package/src/templates/scaffold-docs.ts +7 -3
- package/src/templates/scaffold-gitattributes.ts +18 -1
- package/src/templates/scaffold-helm-templates.ts +9 -0
- package/src/templates/scaffold-repo.ts +5 -2
- package/src/templates/scaffold-test-services.ts +33 -11
- package/src/templates/shapes/offline.ts +0 -7
- package/src/templates/shapes/realtime.ts +2 -6
- package/src/templates/sign-in-action-tests.ts +6 -4
- package/src/templates/sign-in-challenge.ts +62 -0
- package/src/templates/sign-in-oidc-mfa.ts +31 -0
- package/src/templates/sign-in-oidc.ts +11 -3
- package/src/templates/sign-in-password.ts +18 -56
- package/src/test-only-shipped.ts +29 -2
- package/src/test-shards.ts +134 -42
- package/src/test-verdict.ts +79 -0
- package/src/test-workers.ts +15 -0
- package/src/upgrade-coverage-ratchet.ts +95 -0
- package/src/upgrade-gate-codemods.ts +5 -3
- package/src/upgrade-gate.ts +42 -4
- package/src/upgrade-merge-drivers.ts +25 -0
- package/src/upgrade-report.ts +32 -4
- package/src/upgrade-scope.ts +62 -0
- package/src/verify-checks.ts +2 -8
- package/src/verify-coverage-run.ts +4 -1
- package/src/verify-e2e.ts +21 -3
- package/src/verify-live.ts +38 -14
- package/src/verify-only.ts +67 -0
- package/src/verify-progress.ts +7 -3
- package/src/verify-run.ts +20 -2
- package/src/verify-services-stack.ts +165 -0
- package/src/verify-services.ts +84 -2
- package/src/verify-test-run.ts +6 -7
- package/src/verify-tests.ts +8 -2
- package/src/verify-typecheck.ts +25 -2
- package/src/workspace-checks.ts +4 -1
- package/wiki/Actions.md +66 -3
- package/wiki/Admin-Dashboard.md +2 -2
- package/wiki/Agents.md +5 -5
- package/wiki/Auth.md +20 -6
- package/wiki/Bare-VM.md +1 -1
- package/wiki/CI-Parallel-Gate.md +2 -1
- package/wiki/CLI-Reference.md +115 -42
- package/wiki/Caching-And-Invalidation.md +1 -1
- package/wiki/Client-Navigation.md +35 -5
- package/wiki/Configuration.md +12 -10
- package/wiki/Deployment.md +44 -4
- package/wiki/Entities-And-Migrations.md +17 -3
- package/wiki/FAQ.md +1 -1
- package/wiki/Getting-Started.md +2 -2
- package/wiki/Home.md +3 -3
- package/wiki/I18n.md +6 -4
- package/wiki/Installation.md +12 -11
- package/wiki/Interface-Rules.md +3 -1
- package/wiki/Jobs-And-Workflows.md +24 -4
- package/wiki/Known-Gaps.md +2 -2
- package/wiki/MCP-And-AI.md +48 -13
- package/wiki/Many-Agents.md +69 -2
- package/wiki/Migrations-And-Backfills.md +18 -0
- package/wiki/Notify.md +5 -3
- package/wiki/Observability.md +13 -0
- package/wiki/Outbound-HTTP.md +53 -2
- package/wiki/Policies-And-Authz.md +1 -1
- package/wiki/Queries-And-Live-Queries.md +2 -2
- package/wiki/Realtime.md +24 -7
- package/wiki/Routes-And-Render-Modes.md +2 -2
- package/wiki/Scheduled-Tasks.md +4 -1
- package/wiki/Static-Assets.md +5 -3
- package/wiki/Testing.md +64 -7
- package/wiki/Theming.md +6 -3
- package/wiki/Timezones-And-Dates.md +5 -1
- package/wiki/Troubleshooting.md +1 -0
- package/wiki/Tutorial-01-First-App.md +3 -3
- package/wiki/Tutorial-02-First-Feature.md +1 -1
- package/wiki/Tutorial-03-Auth-And-Admin.md +7 -6
- package/wiki/UI-Components.md +1 -0
- package/wiki/Upgrading.md +38 -0
|
@@ -256,9 +256,9 @@ export const syncCrm = job({
|
|
|
256
256
|
| `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 |
|
|
257
257
|
| `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 |
|
|
258
258
|
| `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) |
|
|
259
|
-
| 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 |
|
|
259
|
+
| per-process rate | starts per window, per tenant, in ONE worker | `concurrencyLimiter({ ratePerTenant })` on the worker — **per process**, multiplied by the replica count and by each container's processes; 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 |
|
|
260
260
|
| 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` |
|
|
261
|
-
| `maxInFlight` | max simultaneous runs in **one worker
|
|
261
|
+
| `maxInFlight` | max simultaneous runs in **one worker container**, across every queue it serves — Sidekiq's `concurrency`; a container running N processes splits it across them (`As of 2026-11`). `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` |
|
|
262
262
|
| `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`) |
|
|
263
263
|
| `queue` | named pool; the `worker` role runs one pool per config (`WORKER_QUEUES=default,integrations`) | worker pool sizing, see [Deployment](Deployment) |
|
|
264
264
|
| 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 |
|
|
@@ -272,6 +272,25 @@ export const syncCrm = job({
|
|
|
272
272
|
|
|
273
273
|
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.
|
|
274
274
|
|
|
275
|
+
### CPU-bound handlers
|
|
276
|
+
|
|
277
|
+
**A synchronous section blocks every job in its process, and their lease renewals with it** `As of 2026-11`. `jobs.concurrency` slots are async slots on one JavaScript thread; while a handler computes, nothing else in that process runs — no I/O completes, no claim, no renewal (the heartbeat fires every `visibilityTimeoutMs / 3`, 10 s by default), and the `/healthz` on the same thread answers late.
|
|
278
|
+
|
|
279
|
+
| Synchronous for | What happens |
|
|
280
|
+
|---|---|
|
|
281
|
+
| under 10 s | every other job in the process stalls for that long |
|
|
282
|
+
| 10–30 s | renewals for **every** in-flight job of the process arrive late; the loop's heartbeat can turn `/healthz` 503 |
|
|
283
|
+
| 30 s or more | `visible_at` passes: another worker claims the row and **the job runs twice**. When the first process yields it sees the lease lost, aborts `ctx.signal` and refuses further step writes — but side effects outside steps already happened, and every other job of that process lapsed too |
|
|
284
|
+
|
|
285
|
+
Processes contain it: a container with `cpus: '2'` runs two worker processes ([Processes per container](Deployment#processes-per-container)), each with its share of the container's `jobs.concurrency`, and a burn in one leaves the other's jobs and renewals running. Pinned by `runtime-jobs-processes.live.test.ts` (Linux, a real Postgres): two jobs burning 1.5 s of CPU each run at the same time, one per process, where one process runs them back to back (5.4 s of wall time for the pair, on a loaded box); and an I/O job on the other process renews its lease at least three times during a burn, none lost.
|
|
286
|
+
|
|
287
|
+
| For CPU-heavy work | Do |
|
|
288
|
+
|---|---|
|
|
289
|
+
| a queue of its own | `queue: 'heavy'` on the job, a worker service with `WORKER_QUEUES=heavy` and its own `cpus:` |
|
|
290
|
+
| slots per container | `jobs.concurrency: { heavy: <processes> }`: one slot per process, so a burn stalls only itself |
|
|
291
|
+
| chunks | break the section into chunks and `await lease.renew()` between them ([Observability](#observability)), or `step.run` per chunk |
|
|
292
|
+
| a longer lease | raise `visibilityTimeoutMs` above the longest synchronous section, knowing a crashed worker's jobs wait that long to be re-run |
|
|
293
|
+
|
|
275
294
|
### A lock — `withLock()`
|
|
276
295
|
|
|
277
296
|
`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`.
|
|
@@ -478,6 +497,7 @@ export const syncAccount = job({
|
|
|
478
497
|
| at most one notification per queue per 250 ms | Postgres serialises every notifying commit behind one lock. A row its slot kept silent is found by the woken worker's next pass, one `pollIntervalMs` later — never worse than a fixed 250 ms poll |
|
|
479
498
|
| the poll is the guarantee | a notification is lost with the session that would have carried it; the driver re-dials and the poll covers the gap. With the wake proven the poll is a rest of up to 60 s, cut to the 2 s poll within one 2 s slice once the session is lost |
|
|
480
499
|
| the wake has to be proven | a probe sent through the pool must come back on the session: `jobs.wake.live`. If it does not — PgBouncer in `pool_mode = transaction` delivers no notification — the log says `jobs.wake.unverified` once and the ceiling stays 2 s. Give the `worker` role a direct or session-pooled `DATABASE_URL` ([`docs/ops/04-datastores.md`](https://github.com/developerz-ai/ultimate/blob/main/docs/ops/04-datastores.md#pooling-and-the-trap-under-it)) |
|
|
500
|
+
| a proven wake is proven again | every `reproveEveryMs` (10 s) one notification per channel that wakes no loop. A session that stops delivering with no re-dial (half-open) announces nothing; not back within `verifyTimeoutMs` (5 s) of the SEND, the wake is un-proven, `jobs.wake.lost` (`warn`) is logged and the loops return to the 2 s poll until a notification crosses again (`jobs.wake.live`). A pool that has not sent the proof by then is no verdict: a saturated pool cannot be told from a dead session, so the wake stays proven and the proof is sent again, with its own window, once the pool answers. `startQueueWake`, `packages/jobs/src/queue-wake.ts`, `As of 2026-11` |
|
|
481
501
|
| a queue pause | read by the claim statement itself, so it holds from each worker's next claim; a resume announces the queue |
|
|
482
502
|
|
|
483
503
|
## Exports and imports — `exportRows()` and `importRows()`
|
|
@@ -882,14 +902,14 @@ Three implementations ship, `As of 2026-11-18`: `postgresJobDriver()`, `redisJob
|
|
|
882
902
|
| Driver | Status `As of 2026-11-18` | When | Trade-off |
|
|
883
903
|
|---|---|---|---|
|
|
884
904
|
| `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 |
|
|
885
|
-
| `redis` | **shipped** | a queue off the database, `jobs: redisJobDriver()` | one Lua script per operation; no `introspect`, `backfills` or `leases`, so a job declaring `concurrency` refuses `jobWorker().start()` (`X_JOB_CONCURRENCY_UNENFORCEABLE`); the outbox still stages in Postgres |
|
|
905
|
+
| `redis` | **shipped** | a queue off the database, `jobs: redisJobDriver()` | one Lua script per operation; no `introspect`, `backfills` or `leases`, so a job declaring `concurrency` refuses `jobWorker().start()` (`X_JOB_CONCURRENCY_UNENFORCEABLE`); the outbox still stages in Postgres. `As of 2026-11-19`: failed, dead and expired rows, their steps and debounce fences expire after `deadTtlMs` (default 90 days, pg's `jobs.deadRetentionMs`; `redisJobDriver({ deadTtlMs: 0 })` keeps them forever), and with no `clock` injected every lease, retry, settle debt and gauge is measured on the Redis server's clock (`TIME`), as pg's `now()` — skewed pods can no longer both hold one job |
|
|
886
906
|
| `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 drain target |
|
|
887
907
|
|
|
888
908
|
**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.
|
|
889
909
|
|
|
890
910
|
**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.
|
|
891
911
|
|
|
892
|
-
**`x jobs` has no `drain`, `As of 2026-11-15`.** It was planned from 25.0.0 and left the registry ([Known gaps](Known-Gaps#open-by-decision)): moving in-flight rows between drivers is a migration no command owns. To stop a queue for maintenance, `x jobs pause <queue
|
|
912
|
+
**`x jobs` has no `drain`, `As of 2026-11-15`.** It was planned from 25.0.0 and left the registry ([Known gaps](Known-Gaps#open-by-decision)): moving in-flight rows between drivers is a migration no command owns. To stop a queue for maintenance, `x jobs pause <queue>` (a queue the app does not serve is refused `X_CLI_BAD_FLAG` with the nearest name, `As of 2026-11-19` — before, a typo paused nothing and reported success), then `x jobs list --queue <queue> --state running --json` until it is empty. 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. A drain that returns 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.
|
|
893
913
|
|
|
894
914
|
So the framework ships no cross-driver migration procedure: moving queued jobs from one driver to another is the application's to do.
|
|
895
915
|
|
package/wiki/Known-Gaps.md
CHANGED
|
@@ -46,7 +46,7 @@ Each of these is a defect, or a target, somebody has already argued about, and t
|
|
|
46
46
|
|---|---|
|
|
47
47
|
| `x token`'s `grant` | removed from the registry `As of 2026-11-15`, where it was planned and exited `X_NOT_IMPLEMENTED`; now `X_CLI_UNKNOWN_COMMAND`, exit 1 as before. A key's scopes are fixed when it is issued (`AuthApiKeyRecord.scopes`, never widened; `ApiKeyStore` has no update), so a grant is a new key: `x token create --scopes post:read,post:write --json`, then `x token revoke <old-id>`. A second verb for that pair would be the second path axiom 1 refuses |
|
|
48
48
|
| `x db`'s `studio` | removed from the registry `As of 2026-11-15`, where it was planned and exited `X_NOT_IMPLEMENTED`; now `X_CLI_UNKNOWN_COMMAND`, exit 1 as before. The schema browser is the `/_x` db panel (`x dev`): schema, rows and a guarded SQL console. `X_DB_STUDIO_FAILED` stays reserved and unthrown; the old `bunx drizzle-kit studio` shell-out was a second schema engine for one subcommand |
|
|
49
|
-
| `x jobs`'s `drain` | removed from the registry `As of 2026-11-15`, where it was planned and exited `X_NOT_IMPLEMENTED`; now `X_CLI_UNKNOWN_COMMAND`, exit 1 as before. 25.0.0 deleted the drain body with the all-throw Redis and NATS stubs, and moving in-flight rows between drivers is a migration no command owns. To stop a queue for maintenance: `x jobs pause <queue
|
|
49
|
+
| `x jobs`'s `drain` | removed from the registry `As of 2026-11-15`, where it was planned and exited `X_NOT_IMPLEMENTED`; now `X_CLI_UNKNOWN_COMMAND`, exit 1 as before. 25.0.0 deleted the drain body with the all-throw Redis and NATS stubs, and moving in-flight rows between drivers is a migration no command owns. To stop a queue for maintenance: `x jobs pause <queue>` (a queue the app does not serve is refused, `As of 2026-11-19`), then `x jobs list --queue <queue> --state running --json` until it is empty |
|
|
50
50
|
| A local write that died after its last rename is listed with no content type until the key is written again | `As of 2026-10`. `localDriver` commits in four steps (marker, sidecar, bytes, clear marker) and a marker left behind means "re-check this pair". `get()` and `stat()` do re-check against the bytes and answer correctly; `list()` never reads bytes, so it reports that object with no `contentType` and `etag: ''` — honest, and it stays that way until the next `put()` of that key. `stream()` returns bytes only and checks nothing. Two files cannot be committed in one step without changing the on-disk layout |
|
|
51
51
|
| A `delete_resource` preview checks only the policy's actor half | `As of 2026-10-18`. Without `live: true` the framework answers a preview without running the action, so the part of a policy that reads the input never runs; a preview can be granted for a call the commit then refuses. Running the policy would mean running the action. An action that needs an exact preview declares `live` in its input and answers its own |
|
|
52
52
|
| `localDriver` cannot hold a key and a key beneath it (`a` and `a/b`) | `As of 2026-10`. An object is a file at its key, and a POSIX path is a file or a directory. The second `put()` is refused by code (`X_STORAGE_KEY_CONFLICT`) where it used to be a bare `ENOTDIR`; `s3Driver` and `memoryStorageDriver` hold both. Storing objects under suffixed names would lift it, at the price of a layout migration for every existing root — and the keys `grantUpload` and `scopedKey` build never nest an object under another, so the limit is met only by hand-built keys |
|
|
@@ -75,7 +75,6 @@ Each of these is a defect, or a target, somebody has already argued about, and t
|
|
|
75
75
|
| A local `typecheck` step can report green on a tree CI fails, on the same commit — **one sighting, unreproduced** | `As of 2026-10`. Observed once (2026-09-17, TypeScript 7.0.2): after a `git stash -u` → branch switch → `x verify` on the other branch → switch back → `stash pop` sequence, a type error that surfaces in an UNCHANGED file (a widened index signature in a file it imports) passed locally and failed CI; deleting `tsconfig.tsbuildinfo` then reproduced CI's red locally. Five faithful reproduction attempts against 7.0.2 all stayed correctly red ([#450](https://github.com/developerz-ai/ultimate/issues/450)). **[#450](https://github.com/developerz-ai/ultimate/issues/450) itself is closed `As of 2026-09-23`** — read from the shipped fix, not from the tracker: plan 101 row 14 r ("Close #450", `docs/plans/2026/09/23/101-framework-deep-sweep/14-guards-gate.md:37`; plan `status.yml` `complete`), recorded in `CHANGELOG.md` under 22.0.0 and pinned by `packages/cli/src/verify-typecheck.test.ts`. `tsc -b` decides "up to date" by **mtime**, and Bun installs a dependency as **hardlinks** carrying its cache's old mtimes, so an upgrade to an already-cached version left every input older than the buildinfo and a root without `references` — every scaffolded app — skipped the program and reported green while a cold CI was red. A scaffolded app's `typecheck` is now `tsc -p .` ([`packages/cli/src/templates/scaffold-repo.ts`](https://github.com/developerz-ai/ultimate/blob/main/packages/cli/src/templates/scaffold-repo.ts), its `"typecheck"` script), which is incremental by **content hash**, and `x verify`'s `typecheck` step picks `-p .` over `-b` for any such root ([`packages/cli/src/verify-typecheck.ts`](https://github.com/developerz-ai/ultimate/blob/main/packages/cli/src/verify-typecheck.ts)); the framework root keeps `-b`. **Still open**: a *second* `tsc` racing the same buildinfo is the one suspect not excluded, and no cause for it has been shown. `x verify` has no `--cold` flag: one sighting, and five faithful reproductions stayed red. **Why it stays** (`As of 2026-11-18`): There is no cause to fix: the one known mechanism is fixed, and no reproduction of the remainder exists. CI, always cold, is the judge of record. **Do instead:** CI is always cold and is the judge of record. If a local `typecheck` disagrees with it again, capture the command, its argv and its exit code before deleting any `tsconfig.tsbuildinfo`. |
|
|
76
76
|
| A `stream` page with a realtime island keeps every island on the page inert until its slowest hole closes | `As of 2026-11-02`. The runtime goes `async` so a shell island answers while a hole is open, but only with no realtime boot in the document: the boot (`script defer`) has to run first (`bootScript`, [`packages/cli/src/route-islands.ts`](https://github.com/developerz-ai/ultimate/blob/main/packages/cli/src/route-islands.ts)), and a deferred script waits for parsing to end. Bound by the hole's 15 s deadline. **Why it stays** (`As of 2026-11-18`): The realtime boot has to run before the hydration runtime (`streamScripts`, `packages/cli/src/route-islands.ts`), or an island mounts over a store not yet restored, and a deferred script waits for parsing to end. `DEFAULT_HOLE_TIMEOUT_MS` bounds the wait. **Do instead:** keep the slow read out of such a page's holes, or give it a short deadline of its own: `fetch(url, { signal: AbortSignal.timeout(2_000) })`. |
|
|
77
77
|
| An open tab can meet a dead island across a deploy | `As of 2026-11-12`. A web process serves only the hashed files it built, so with `assets.retain` unset (the default) a tab holding the previous build's document gets a `no-store` 404 for its stylesheet, or for its island chunk on the first click, after every deploy; during a rolling update a new document that reaches an old pod gets no stylesheet either. What the framework does about the stylesheet half without a window: a soft navigation whose next sheet fails never swaps an unstyled page in (a GET becomes a full load, the old sheet stays) [pin](https://github.com/developerz-ai/ultimate/blob/main/packages/render/src/navigation-stylesheet-skew.test.ts#a%20GET%20is%20loaded%20by%20the%20browser%3B%20the%20page%20on%20screen%20keeps%20its%20sheet); a full load whose sheet 404s stays unstyled — the framework does not reload it, as a reload it cannot tell from a missing file offline or under a test harness is a navigation nobody asked for. A web role booted outside development and test with no window logs `X_ASSET_RETAIN_UNDECLARED` [pin](https://github.com/developerz-ai/ultimate/blob/main/packages/cli/src/retained-assets-boot.test.ts#undeclared%3A%20nothing%20is%20published%20and%20there%20is%20no%20reader). Declared, a tab survives six deploys with build 0's island alive [evidence](https://github.com/developerz-ai/ultimate/blob/main/packages/cli/e2e/six-deploys.e2e.test.ts#with%20assets.retain%2C%20the%20click%20boots%20build%200%E2%80%99s%20island%3A%20its%20chunk%20200%2C%20no%20404%2C%20an%20update%20offered) **Why it stays** (`As of 2026-11-18`): Retention needs a disk every web pod reads, and only the app can name one. Undeclared, boot says so by code. **Do instead:** declare `assets: { retain: { disk, builds } }` over a disk every web pod reads → [Deployment](Deployment#hashed-assets-across-a-deploy--assetsretain) |
|
|
78
|
-
| A soft visit waits for the slowest hole | `As of 2026-11-02`. The client router reads `response.text()` ([`packages/render/src/navigation-fetch.ts`](https://github.com/developerz-ai/ultimate/blob/main/packages/render/src/navigation-fetch.ts)) and swaps the whole answer, so holes fill through the re-run scripts and the first paint of an in-app navigation is as late as a full `ssr` render. A full load streams. No incremental parse here [pin](https://github.com/developerz-ai/ultimate/blob/main/packages/render/src/navigation-fetch.test.ts#a%20page%3A%20its%20text%2C%20its%20build%2C%20no-store%20read%20off%20cache-control) **Why it stays** (`As of 2026-11-18`): The router swaps one whole answer, so head, scripts and holes land together. The extension point is the route's `navigation` declaration. **Do instead:** nothing to do in an app; a page that must paint first on a soft visit declares `navigation: 'document'`. |
|
|
79
78
|
| A job's `runAt` is stamped from the enqueuer's clock | `As of 2026-10`. An enqueuer running ahead of the database delays its own "immediate" jobs; up to 1 s ahead still wakes a worker, beyond that the job starts on the poll. A delayed job enqueued by another process starts within the idle ceiling after its `runAt` — 5 s with a proven wake, 2 s without; only a retry or a sleep the worker itself handed back gets a due-time timer. **Why it stays** (`As of 2026-11-18`): `runAt` comes from the injected `Clock` (`packages/jobs/src/driver-pg.ts`, `enqueue-record.ts`), the one a frozen-clock test drives and the outbox stamps at stage time, before any row exists. A database clock would split those. **Do instead:** NTP on every pod; for a deadline tighter than the ceiling, enqueue at the moment the work is due rather than with `runAt`. |
|
|
80
79
|
| The CDP driver cannot PIN a name, and a page's WebSocket is not screened at all | `As of 2026-11`. Measured on Chrome 150 with `localBrowser()`: interception (page-level and the browser-level `Fetch` that now covers popups) never pauses a WebSocket handshake, so `new WebSocket('ws://off-list/…')` from a scraped page connects. Since 31.0.0 a host a wildcard admitted is resolved before the browser leg releases it, and an inward or unresolvable answer is refused (`packages/scraping/src/browser-dial.ts`). But the browser then resolves again for itself, so a name that answers public to the screen and private to Chrome (DNS rebinding) is reached — the HTTP leg and the robots read resolve and pin (`packages/scraping/src/pinned-host.ts`), the browser cannot be pinned through this port — [pin](https://github.com/developerz-ai/ultimate/blob/main/packages/scraping/src/cdp-arm-dial.test.ts#a%20screened%20name%20is%20continued%20by%20request%20id%20only%2C%20never%20pinned%20to%20the%20approved%20address) **Why it stays** (`As of 2026-11-18`): Interception never pauses the handshake and this port cannot hand Chrome a resolved address, so no driver code closes it. The boundary that can is the network's: the `egress` proxy. **Do instead:** list exact hosts rather than `'*'` on a scrape that runs where private addresses are reachable, and dial a scrape through an `egress` proxy outside that network. |
|
|
81
80
|
| `ScrapeReport.usage.bytesIn` counts the HTTP leg only | `As of 2026-10`. The CDP port subscribes to requests, not to their sizes, so the browser leg's bytes are not in the figure (`packages/scraping/src/usage.ts`) **Why it stays** (`As of 2026-11-18`): The field is defined as the HTTP leg (`packages/scraping/src/usage.ts`): this port sees requests, not sizes, and a browser figure would be a guess. The extension point is the resolver's `cost`. **Do instead:** treat `bytesIn` as a lower bound; a provider's own byte count, returned through the resolver's `cost`, is the billable one. |
|
|
@@ -169,6 +168,7 @@ the release that fixed it. Upgrading is the fix, and the breaking entries are th
|
|
|
169
168
|
|
|
170
169
|
| Gap | Fixed in | If you are pinned below that |
|
|
171
170
|
|---|---|---|
|
|
171
|
+
| A soft visit waited for the slowest hole | **31.50.0** | The client router read the whole answer before swapping, so an in-app navigation to a `stream` page painted as late as a full `ssr` render. It now reads the answer as it arrives: the shell is swapped in at the server's first flush mark, and each hole fills as its chunk lands, through the same `$X()` reveal and scripts a full load runs; a newer navigation cancels the request, so the server aborts each hole's signal and a read that honours it stops. A click that reuses a prefetch still in flight waits for the whole answer, as a prefetch reads it whole. Measured on a page with holes at 300 ms, 1 s and 2 s, 20 soft visits in Chrome: the shell paints at 65 ms p95 (2,041 ms before), the last hole at 2,026 ms p95 (2,045 ms before) — the gain is the slowest hole, 1,976 ms. The router grows by 1,949 B minified (691 B gzip) [pin](https://github.com/developerz-ai/ultimate/blob/main/packages/cli/e2e/stream-hole.e2e.test.ts#a%20soft%20visit%20paints%20its%20shell%20while%20the%20hole%20is%20open%3B%20the%20hole%20then%20fills%20and%20hydrates). Below it: a page that must paint first on a soft visit declares `navigation: 'document'` |
|
|
172
172
|
| A queued offline write was not bound to its principal on the server: a second tab's sign-in could send it as the new session | **31.47.0** | A replay now names its queue's principal in `x-ultimate-replay-scope`, and the action route refuses any other session with `409 X_REPLAY_PRINCIPAL_MISMATCH` before the body is read. The entry stays `pending` for its owner, as it does on a 401 to a signed-in queue, and is sent when that account is back; entries stored by older builds are bound by the queue that holds them [pin](https://github.com/developerz-ai/ultimate/blob/main/packages/realtime/src/page-outbox-principal.test.ts#the%20entry%20behind%20the%20one%20on%20the%20wire%20is%20refused%2C%20kept%2C%20and%20sent%20once%20its%20owner%20is%20back). Loading a page as another account still wipes the queue, deliberately. Below 31.47.0: sign out by full navigation, and do not share a browser profile between accounts with offline writes queued |
|
|
173
173
|
| A browser's own `<form method="post">` to an action got JSON back on a refusal — `setRedirect` covered success only (deferred by plan 101: 234 wrapper calls in 142 files of one app) | **31.11.0** | `action({ native: { success, refusal? } })`: a `303` either way, the outcome in a one-read flash `useActionAnswer()` reads in `load`; a `page.tsx` form posting to an action without it is an `X_NATIVE_FORM_UNANSWERED` warning ([Actions](Actions#native-forms-native)). Below it: `if ((useRequestHeader('accept') ?? '').includes('text/html')) setRedirect(next)` in `handle` (both from `@ultimat3/http`) answers success; a refusal still answers the error page |
|
|
174
174
|
| `bun run error-render` could not see a `catch (error)` binding | **8.0.0** | The gate matched a **parameter** annotated `unknown`/`any`; a `catch (error)` binding is `unknown` by inference and carries no annotation, which is how `String(error)` echoing a caller's request body into a 422 `cause:` stayed green in `packages/http/src/request.ts` through 3.0.0. `error-render` now joins `catchRenderFindings` ([`scripts/catch-render.ts`](https://github.com/developerz-ai/ultimate/blob/main/scripts/catch-render.ts)), which reads the catch binding and a `.catch((error: unknown) => …)` callback; its header lists what it still cannot see (a helper in a third file, a field laundered by another package). Below it: review every `catch` by hand — a caught value reaches a `cause:`/`fix:` only through `renderThrowable(error)` from `@ultimat3/core` |
|
package/wiki/MCP-And-AI.md
CHANGED
|
@@ -43,7 +43,7 @@ The whole catalog, spelled exactly as each tool must be called; `bunx x mcp tool
|
|
|
43
43
|
| executes code | `tests.run`, `verify.run`, `ui.shot`, `ui.island`, `ui.inspect`, `ui.interact` | scope `dev:test`; all six declare `destructive: true`, so none is metered as read chatter — the four `ui.*` tools launch a browser |
|
|
44
44
|
| write | `db.migrate` | scope `db:migrate`, **branch environments only** |
|
|
45
45
|
|
|
46
|
-
None of them is exposed in `ROLE=web`. `db.query` accepts one statement, whose leading keyword must be `SELECT`/`WITH`/`EXPLAIN`/`SHOW`/`TABLE`/`VALUES` — necessary, never sufficient. Batches, any write keyword at statement level (a data-modifying CTE included), locking clauses (`FOR UPDATE`/`FOR SHARE`), `EXPLAIN ANALYZE
|
|
46
|
+
None of them is exposed in `ROLE=web`. `db.query` accepts one statement, whose leading keyword must be `SELECT`/`WITH`/`EXPLAIN`/`SHOW`/`TABLE`/`VALUES` — necessary, never sufficient. Batches, any write keyword at statement level (a data-modifying CTE included), locking clauses (`FOR UPDATE`/`FOR SHARE`), `EXPLAIN ANALYZE` (and its `ANALYSE` spelling), and whole function families matched by prefix of the called name, quoted and schema-qualified spellings included — file access (`pg_read_*`, `pg_ls_*`, `lo_*`, `dblink`), locks (`pg_advisory_*`), session settings (`set_config`), sleeps (`pg_sleep*`), catalog writes (`pg_import_*`, `pg_restore_*`, `pg_clear_*`), replication and backup control (`pg_copy_*`, `pg_sync_replication_*`, `pg_backup_*`, `pg_start_backup`, `pg_stop_backup`; `As of 2026-11-19`) and the functions that run a query handed to them as text (`query_to_xml*`, `cursor_to_xml*`, `table_to_xml*`, `schema_to_xml*`, `database_to_xml*`, `ts_stat`, `ts_rewrite`) — are **refused**, not discouraged — `X_MCP_QUERY_REJECTED`, enforced before the host sees the string. What the scan cannot read is refused, never decoded: a Unicode-escaped quoted identifier (`U&"…"`) is `X_MCP_QUERY_REJECTED` (`As of 2026-10`). A keyword is matched as Postgres lexes an identifier, so a column `set2` is a column, not `SET`. Its Postgres SELECT-only role is conditional on the connection's own rights; the answer's `guards` array names the defences that engaged. `db.migrate` refuses a target that is not a branch database — `X_MCP_NOT_BRANCH_DB`.
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
### Client config
|
|
@@ -108,12 +108,25 @@ None of them is exposed in `ROLE=web`. `db.query` accepts one statement, whose l
|
|
|
108
108
|
|
|
109
109
|
| Request | Era | Answered |
|
|
110
110
|
|---|---|---|
|
|
111
|
-
| `params._meta["io.modelcontextprotocol/protocolVersion"]` in `MCP_MODERN_VERSIONS` (`2026-07-28`) | modern, stateless | `server/discover` and the seven shared methods. Every result carries `resultType: 'complete'` and `_meta["io.modelcontextprotocol/serverInfo"]`; the lists, `resources/read` and `server/discover` add `ttlMs: 0`, `cacheScope: 'private'`. No `initialize`, no `ping` |
|
|
111
|
+
| `params._meta["io.modelcontextprotocol/protocolVersion"]` in `MCP_MODERN_VERSIONS` (`2026-07-28`) | modern, stateless | `server/discover` and the seven shared methods. Every result carries `resultType: 'complete'` — or `'input_required'` for a `tools/call` answered with the URL prompt below, so branch on `resultType` before reading `content` — and `_meta["io.modelcontextprotocol/serverInfo"]`; the lists, `resources/read` and `server/discover` add `ttlMs: 0`, `cacheScope: 'private'`. No `initialize`, no `ping` |
|
|
112
112
|
| no `_meta` version, or one in `MCP_LEGACY_VERSIONS` (`2025-11-25`, `2025-06-18`, `2025-03-26`) | legacy | `initialize` echoes an offered legacy revision, else answers `2025-11-25`; `ping`; the seven shared methods |
|
|
113
113
|
| any other `_meta` version | — | `-32022` `X_MCP_PROTOCOL_UNSUPPORTED`, `data: { supported, requested }` |
|
|
114
114
|
|
|
115
|
-
`MCP_PROTOCOL_VERSION` is gone (`As of 2026-11`): name the era — `MCP_MODERN_VERSIONS[0]`, or `MCP_LEGACY_VERSIONS`. `resources/templates/list` is `{ resourceTemplates: [] }` on both eras. A resource not found, hidden or absent, is one answer: `-32601` legacy, `-32602` modern. Not served and not advertised: `subscriptions/listen`, multi-round-trip input, the tasks extension, `x-mcp-header`, SSE responses; every `listChanged` is `false`.
|
|
115
|
+
`MCP_PROTOCOL_VERSION` is gone (`As of 2026-11`): name the era — `MCP_MODERN_VERSIONS[0]`, or `MCP_LEGACY_VERSIONS`. `resources/templates/list` is `{ resourceTemplates: [] }` on both eras. A resource not found, hidden or absent, is one answer: `-32601` legacy, `-32602` modern. Not served and not advertised: `subscriptions/listen`, multi-round-trip input other than the URL prompt below, the tasks extension, `x-mcp-header`, SSE responses; every `listChanged` is `false`.
|
|
116
|
+
|
|
117
|
+
A tool asks the person to open a page with `withUrlElicitation(output, { url, message })` (`As of 2026-11`; spec `client/elicitation`, `basic/patterns/mrtr`):
|
|
118
|
+
|
|
119
|
+
| `tools/call` | Answer |
|
|
120
|
+
|---|---|
|
|
121
|
+
| modern, and the request's `_meta["io.modelcontextprotocol/clientCapabilities"].elicitation.url` is an object | `resultType: 'input_required'` with `inputRequests.url_elicitation`: `elicitation/create`, `mode: 'url'`, `url` (parsed, `new URL(url).href`), `message`. No `content`, no `requestState` |
|
|
122
|
+
| its retry, carrying `inputResponses.url_elicitation.action` of `accept`, `decline` or `cancel` | the tool runs again and its result is the answer — asked once per call, whichever of the three the person chose. Any other `action` is no answer: an ask the rerun makes is sent, not suppressed; a rerun that no longer asks answers its result |
|
|
123
|
+
| the tool failed (`isError`) | the failure, for every caller: never hidden behind a prompt, and an ask beside it is not checked |
|
|
124
|
+
| modern without the capability, and every legacy request | the tool's result: `output` says in text what the prompt would have. `-32042` is never sent, since a legacy capability is declared on `initialize` and no handshake is kept |
|
|
125
|
+
| a URL that is not absolute `https:` (`http:` on `localhost`, `127.0.0.1` or `[::1]`), carries credentials, or has no message | `X_MCP_ELICITATION_URL_INVALID`, for every caller |
|
|
126
|
+
|
|
127
|
+
The ask belongs to the call that made it. The handler reruns on the retry whatever the answer, so a write before the ask runs twice: keep writes behind a completion check the handler makes itself. A retry under the same `idempotencyKey` replays the first result and never sees the page finished; check completion in a call without that key. Nothing about the person goes in the URL, and the page checks that whoever opened it is the caller the tool asked.
|
|
116
128
|
|
|
129
|
+
Over HTTP:
|
|
117
130
|
Over HTTP:
|
|
118
131
|
|
|
119
132
|
| Request | Answer |
|
|
@@ -198,7 +211,13 @@ confirmed_by_user }` — without `live: true` it answers a preview (the framewor
|
|
|
198
211
|
only on `confirmed_by_user: true`) replace `manage_resource`, for clients and directories that
|
|
199
212
|
refuse a dispatcher which both reads and writes. A grouped write without an effect fails boot
|
|
200
213
|
(`X_MCP_EFFECT_UNDECLARED`); an action called on the wrong dispatcher is `X_MCP_WRONG_TOOL`
|
|
201
|
-
naming the right one; an unconfirmed commit is `X_MCP_USER_CONFIRMATION_REQUIRED`.
|
|
214
|
+
naming the right one; an unconfirmed commit is `X_MCP_USER_CONFIRMATION_REQUIRED`.
|
|
215
|
+
`delete_resource` is the stricter door (`As of 2026-11`): a `write` action sent to it is previewed
|
|
216
|
+
and confirmed the same way, and `write_resource` is never widened. `split: { fields, stricter }`
|
|
217
|
+
adds the app's own string fields to the dispatcher envelopes (a `reason`: validated there, handed
|
|
218
|
+
to a tool as `door.fields`, never in the action input) and a hook that sends one call to
|
|
219
|
+
`delete_resource` by its arguments — `X_MCP_WRONG_TOOL` naming it on the other two, and the one
|
|
220
|
+
way a read runs there. The audit line carries `door`. `X_MCP_SPLIT_INVALID` at boot. Full contract:
|
|
202
221
|
[`packages/mcp/README.md`](https://github.com/developerz-ai/ultimate/blob/main/packages/mcp/README.md).
|
|
203
222
|
|
|
204
223
|
**What the model reads is compact.** A tool's text block is one-line JSON (the 2-space form until
|
|
@@ -465,8 +484,12 @@ gates as every other tool:
|
|
|
465
484
|
|---|---|---|
|
|
466
485
|
| `catalog: (caller) => ({ tools, groups? })` | tools that exist per caller (a tenant's connectors), each a `runtimeTool({ name, description, inputSchema, permission, run })` borrowing a **declared** permission; asked on every `tools/list` and `tools/call`, never cached | `X_MCP_CATALOG_TOOL_DUPLICATE` (a name taken twice), `X_MCP_CATALOG_UNRESOLVED` (the resolver threw, or answered something unservable) — the request fails, never a smaller list |
|
|
467
486
|
| `tenant: { arg, resolve, list }` | the token resolves to a person; every call names its tenant under `arg`, stripped before validation; `resolve` builds the call's actor, so policy and tenancy guards see one org per call; `list_tenants` lists them | `X_MCP_TENANT_REQUIRED` (no tenant named — fix `list_tenants({})`), `X_MCP_TENANT_UNRESOLVED` (the lookup threw), `X_MCP_TENANT_INVALID` (boot: a tool declares the arg) |
|
|
487
|
+
| `tenant: { …, discover: 'list_resources' }` | the named tool lists the tenants in place of `list_tenants`, which is then not registered: called with no `arg` it answers `{ tenants, next }` as the person, called with one it is the tool it always was. `list_resources` (surface `'meta'` or `'meta-split'`, never a function) or an ungrouped tool of `tools:` with no `visibleTo` | `X_MCP_TENANT_INVALID` (boot: the name is no such tool); `X_MCP_TENANT_REQUIRED` then points at the discover tool |
|
|
488
|
+
| `tenant: { …, optional: ['docs'] }` | the named ungrouped tools run as the person when a call names no tenant, and as the tenant actor when it names one; `tools/list` publishes the arg on them, not as required | `X_MCP_TENANT_INVALID` (boot: a name that is not an ungrouped tool of `tools:`, or the discover tool) |
|
|
468
489
|
|
|
469
|
-
A tenant the person is not in (`resolve` answers `null`) gets exactly the answer a hidden tool gets
|
|
490
|
+
A tenant the person is not in (`resolve` answers `null`) gets exactly the answer a hidden tool gets,
|
|
491
|
+
on the discover and the optional tools too. Only an absent `arg` reaches the tenant list or the
|
|
492
|
+
person: a present, unusable one is `X_MCP_TENANT_REQUIRED`.
|
|
470
493
|
Another caller's runtime tool is an absent tool. The audit line carries `tenant`.
|
|
471
494
|
|
|
472
495
|
**`tools/list` is person-scoped, and not a promise.** MCP's `tools/list` names no tenant, so `visibleTo` (function form), `can()` and `catalog` run there as the person; `tools/call` runs them as the tenant actor and is authoritative. A tool visible to the person but not the tenant actor is listed and answers as a hidden tool; one visible only through a tenant role or a tenant's catalog row is unlisted and still runs when called by name.
|
|
@@ -534,13 +557,21 @@ The reference app's `draftReview` (`examples/dummy/apps/web/mcp-tools.ts`) queue
|
|
|
534
557
|
| The prefix | with `recipes:`, `resources:` may not hold `docs://recipes/` (`X_MCP_RECIPE_URI_RESERVED`) |
|
|
535
558
|
| Error links | `defineError({ docs: 'docs://recipes/<name>' })` must name a recipe some endpoint serves — `X_MCP_RECIPE_UNKNOWN` at mount; a throw-site link to none is dropped from the render and logged |
|
|
536
559
|
|
|
537
|
-
**From a markdown folder.** `recipes: await markdownRecipes({ dir: join(import.meta.dir, 'docs') })` reads one `*.md` per recipe and serves its body
|
|
560
|
+
**From a markdown folder.** `recipes: await markdownRecipes({ dir: join(import.meta.dir, 'docs') })` reads one `*.md` per recipe and serves its body as written, line ends normalised to LF and outer blank lines trimmed. The file name is the recipe name. `title:`, `description:` and `aliases:` come from `---` frontmatter, else the title and description come from the first `# ` heading and the paragraph under it. A fence tagged `call` holds one step, `tool {"arg": "value"}`, and is checked at boot like any `step.example`. A whole `"<postId>"` value is a placeholder, so any value passes at boot. A `docs://<section>/` link in the text, into a section the recipes serve, that names no recipe is `X_MCP_RECIPE_LINK_DANGLING`; the link's whole path is checked.
|
|
561
|
+
|
|
562
|
+
**Sections.** A recipe's `section` (default `recipes`) is its URI prefix: `{ name: 'errors', section: 'ref' }` is `docs://ref/errors`. In a markdown folder, one sub-folder level is the section: `ref/errors.md` is `docs://ref/errors`, and `recipes/<name>.md` is the same URI as `<name>.md`. A section, like a name, is lowercase letters and digits in groups joined by single `-` (`ref-v2`; never `-ref`, `ref-` or `ref--v2`), so no section steps out of `docs://<section>/` (`X_MCP_RECIPE_URI_RESERVED`). Every section a declared recipe uses is owned by `recipes:`: a `resources:` URI under it is refused. A body link into a served section must name a recipe; a link to any other `docs://` prefix is not judged. Error links (`defineError({ docs })`) still name `docs://recipes/<name>` only.
|
|
563
|
+
|
|
564
|
+
| `docsTool:` | Effect |
|
|
565
|
+
|---|---|
|
|
566
|
+
| `description: '…'` | replaces the `docs` tool's default description |
|
|
567
|
+
| `index: 'map'` | `docs({})` answers plain text: `# <section>`, then one `<uri> <title>` line per recipe, ` (yours)` on a caller's own |
|
|
568
|
+
| `index: 'json'` (default) | `docs({})` answers `{ recipes: [{ name, title, description, uri, source }] }` |
|
|
538
569
|
|
|
539
|
-
**Searching.** `docs({})` lists what this caller can follow. `docs({ name })` and `docs({ uri })` read one recipe. `docs({ q })` inlines the best match, scoring 3 for each word in the name or
|
|
570
|
+
**Searching.** `docs({})` lists what this caller can follow. `docs({ name })` and `docs({ uri })` read one recipe; `name` is the bare name in `recipes` and `<section>/<name>` in any other section. `docs({ q })` inlines the best match (`q` at most 1,000 characters, else `X_INPUT_INVALID`; a miss compares its first 16 words, 64 characters each, for the nearest — `As of 2026-11-19`), scoring 3 for each word in the name, title or aliases, 2 in the description and 1 in the body. On a miss it names the nearest recipes, so a caller with any visible recipe never gets an empty answer.
|
|
540
571
|
|
|
541
|
-
**Per caller.** `extraRecipes: (caller) => recipes` adds the caller's own recipes, such as a tenant's runbooks. They are listed as `source: 'caller'` on `docs`, and on `resources/list` and `resources/read` to that caller only. They are not checked at boot. A recipe that names a tool the caller cannot call is not shown.
|
|
572
|
+
**Per caller.** `extraRecipes: (caller) => recipes` adds the caller's own recipes, such as a tenant's runbooks. They are listed as `source: 'caller'` on `docs`, and on `resources/list` and `resources/read` to that caller only. They may use a section no app recipe uses; another caller reads it as not found, byte for byte. They are not checked at boot. A recipe that names a tool the caller cannot call is not shown.
|
|
542
573
|
|
|
543
|
-
**Replayed.** In a contract test, `await replayRecipes(server, recipes, { caller, placeholders })` calls every step's example through the real server as `caller` and reads every link. Three answers fail it with `X_MCP_RECIPE_EXAMPLE_INVALID`: no such tool, refused arguments, and a policy that refuses that caller. A dangling link fails it with `X_MCP_RECIPE_LINK_DANGLING`. A tool's own refusal (`X_NOT_FOUND` for a sample id) counts as the tool working. The reference app replays its recipes as an org owner: `examples/dummy/packages/mcp/src/recipes-replay.contract.test.ts`.
|
|
574
|
+
**Replayed.** In a contract test, `await replayRecipes(server, recipes, { caller, placeholders, sections })` calls every step's example through the real server as `caller` and reads every link into a section `recipes` uses or `sections` names: replaying a subset, `sections` names the server's other sections, else a link into one only the rest use goes unread. Three answers fail it with `X_MCP_RECIPE_EXAMPLE_INVALID`: no such tool, refused arguments, and a policy that refuses that caller. A dangling link fails it with `X_MCP_RECIPE_LINK_DANGLING`. A tool's own refusal (`X_NOT_FOUND` for a sample id) counts as the tool working. The reference app replays its recipes as an org owner: `examples/dummy/packages/mcp/src/recipes-replay.contract.test.ts`.
|
|
544
575
|
|
|
545
576
|
### Consuming another server: `mcpTools()`
|
|
546
577
|
|
|
@@ -551,7 +582,11 @@ Remote MCP tools as this app's actions — the app's `policy`, rate limit, confi
|
|
|
551
582
|
| Declared | `mcpTools({ name, url, auth, allow, policy, lock })` → `tools: Map<remoteName, Action>`, action names `<name>_<tool>`. `policy` is an app `resource:verb` permission, as a hand-written tool takes: the input is the remote's schema, so a predicate over it would decide nothing |
|
|
552
583
|
| Reviewed | `allow` is required; `lock` is the committed `tools.lock.json` written by `x mcp lock <name>`; `x mcp lock <name> --check` writes nothing and fails on drift |
|
|
553
584
|
| Drift | a missing, re-described or re-shaped tool is `X_MCP_REMOTE_TOOL_CHANGED` — at declaration against the lock, before the first call against the live server |
|
|
554
|
-
| Wire | `outbound()` (`dial: 'public'` by default, deadline, size cap); modern era first, then legacy `initialize` + `Mcp-Session-Id`; JSON or SSE answers |
|
|
585
|
+
| Wire | `outbound()` (`dial: 'public'` by default, deadline, size cap `maxBytes`, default 16 MiB); modern era first, then legacy `initialize` + `Mcp-Session-Id`; JSON or SSE answers |
|
|
586
|
+
| Era fallback | the legacy handshake only when the first modern call is refused for its era: a `400`/`404`/`405`, JSON-RPC `-32022`/`-32601`/`-32600`/`-32602`, or a body that is no answer. Never on a `429`, `408` or `403`, a refusal of the moment. Concurrent first calls share one handshake; a failed handshake leaves the era undecided, so the next call tries again (`eraRefusal`, `packages/mcp/src/remote-client.ts`, `As of 2026-11`) |
|
|
587
|
+
| Transport | `fetch` swaps the transport under `outbound()`, in production as in a test. The client keeps the dial screen, deadline, `maxBytes` and redirect refusal: the transport is handed the screened address and `redirect: 'manual'`, and an answer it reached by following a redirect itself is refused (`X_OUTBOUND_TRANSPORT_REDIRECTED` as the source). A transport that dials anywhere else takes the screen over — [Outbound HTTP → transport](Outbound-HTTP#depsfetch-the-transport) |
|
|
588
|
+
| Paging | `listTools()` follows `nextCursor` for at most 50 pages; a cursor still open past that is `X_MCP_REMOTE_REFUSED`, `meta.failure: 'malformed'`, never a truncated list |
|
|
589
|
+
| Cancel | a legacy server hears `notifications/cancelled` for the aborted call's own request id, and only when the request was already sent |
|
|
555
590
|
| Untrusted | the answer arrives as `{ untrusted, isError }`, fenced `<untrusted source="mcp:<name>/<tool>">`, middle-cut past `maxResultChars`; invisible format characters stripped, then every `<` (and full-width `<`, small `﹤`) written `<` — no spelling of `</untrusted>` survives |
|
|
556
591
|
| 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 |
|
|
557
592
|
| 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 |
|
|
@@ -576,13 +611,13 @@ Remote MCP tools as this app's actions — the app's `policy`, rate limit, confi
|
|
|
576
611
|
|
|
577
612
|
1. `begin(serverUrl)` reads the server's RFC 9728 protected-resource document, then its authorization server's RFC 8414 metadata. It answers `{ authorizeUrl, handshake }`, with PKCE S256 from `@ultimat3/auth` and `resource` per RFC 8707.
|
|
578
613
|
2. Redirect the person to `authorizeUrl`. Keep `handshake` server-side, in the person's session.
|
|
579
|
-
3. On the callback, `exchange(handshake, { code, state })` answers `{ accessToken, refreshToken, expiresIn }`. `refresh(handshake, refreshToken)` answers the same shape
|
|
614
|
+
3. On the callback, `exchange(handshake, { code, state })` answers `{ accessToken, refreshToken, expiresIn }`. `refresh(handshake, refreshToken)` answers the same shape; when the server's answer carries no `refresh_token`, `refresh` answers the one it was passed (RFC 6749 §6), never `null`.
|
|
580
615
|
4. Store the tokens per connection. Return the access token from `mcpTools({ auth })`, which is read on every call, so a rotated token is never cached.
|
|
581
616
|
|
|
582
617
|
`begin` refuses, as `X_MCP_REMOTE_REFUSED`, metadata it cannot trust: a document that is not a URL,
|
|
583
618
|
resource metadata naming another resource (RFC 9728 §3.3), authorization-server metadata answering
|
|
584
619
|
for another issuer (RFC 8414 §3.3), no PKCE S256, and an `authorization_endpoint` or `token_endpoint`
|
|
585
|
-
that is not `https:` — `http:` only on a loopback host (`localhost`, `127.0.0.1`, `[::1]`, RFC 8252).
|
|
620
|
+
that is not `https:` — `http:` only on a loopback host (`localhost`, `127.0.0.1`, `[::1]`, RFC 8252). The same rule holds for the server URL and the authorization-server issuer, checked before either's metadata is fetched (`As of 2026-11-19`).
|
|
586
621
|
`authorizeUrl` is handed to a person as a link, so a `javascript:` endpoint would run in the app's
|
|
587
622
|
origin. `As of 31.15.0`.
|
|
588
623
|
|
|
@@ -856,7 +891,7 @@ pgvector in the same Postgres. No second datastore.
|
|
|
856
891
|
| Embeddings | an `Embedder` value, never an entity option: `remoteEmbedder({ name, dimension, baseUrl? })` speaks the `/v1/embeddings` shape (`EMBEDDINGS_API_KEY`), `hashEmbedder()` is the offline default |
|
|
857
892
|
| Writing | `indexDocument({ store, embedder, document })` chunks, embeds, upserts and prunes the stale tail; a sweep over many rows is the app's `backfill()` calling it per page |
|
|
858
893
|
| Index | HNSW: `postgresVectorStore({ name, dimension }).ddl()` prints the table and both indexes, pasted into a migration by the app |
|
|
859
|
-
| Hybrid search | one `query` primitive fusing pgvector cosine + Postgres FTS with Reciprocal Rank Fusion; weights are config |
|
|
894
|
+
| Hybrid search | one `query` primitive fusing pgvector cosine + Postgres FTS with Reciprocal Rank Fusion; weights are config. The lexical leg (`searchText`, `hybrid`) matches **any** word of the query, one `phraseto_tsquery` per whitespace-separated word OR-ed, as `memoryVectorStore()` does (`As of 2026-11-19`; before, every word had to match, so a whole question matched nothing). Nothing typed is query syntax: `"quoted phrase"`, `-word` and `or` are plain text, and an identifier the parser splits (`x_vector_drift`) still matches as one phrase |
|
|
860
895
|
| Filtering | tenant + policy filters applied **in SQL**, so vector search cannot leak across tenants; a store with no tenant bound, read inside a request acting for an org, is `X_VECTOR_UNSCOPED` — a backfill opts in with `scope: UNSCOPED` |
|
|
861
896
|
| HNSW recall | a search returns `k` hits for a small tenant on a large shared table: on pgvector ≥ 0.8 it runs with `hnsw.iterative_scan = relaxed_order`, before that with `hnsw.ef_search` raised to `max(40, k × 10)`, capped at 1,000 — the setting scoped to a read-only transaction the search opens (2–3 round trips), or to the caller's own, put back after (`pg-vector-recall.ts`). Without it pgvector took the 40 nearest rows and filtered afterwards, so a tenant holding a small share of the table got fewer than `k`, often none. `As of 31.15.0` |
|
|
862
897
|
| Re-embed | `indexDocument` again: every chunk is embedded on each call, so a job decides when text changed |
|
package/wiki/Many-Agents.md
CHANGED
|
@@ -32,13 +32,78 @@ Every entry is an `flock(2)`, and a holder hands the locked descriptor to the co
|
|
|
32
32
|
x heavy status # who runs, who waits, load, memory
|
|
33
33
|
x heavy status --json
|
|
34
34
|
x heavy run --label suite --mb 4096 -- bun run test # any command, in any repository
|
|
35
|
+
x heavy run --max-wait 300 -- bun run test # give up after 5 minutes in the queue
|
|
35
36
|
```
|
|
36
37
|
|
|
37
|
-
A waiter prints one line on stderr saying its position
|
|
38
|
+
**A waiter needs nothing from you: leave it running, it starts by itself.** It prints one line on stderr saying its position, who holds the memory and that, and again only when that changes, so `--json` output stays one document. Killing a waiter loses its place, so a harness with a short command timeout should run the command in the background. To bound the wait, `x heavy run --max-wait <seconds>` stops with `X_HEAVY_WAIT_EXPIRED` and exit 75, without starting the command; `0` is one attempt.
|
|
39
|
+
|
|
40
|
+
`x heavy status` names each reservation's processes. After `kill -9` of a wrapper it reads `wrapper pid N exited, command pid M`: M is what still holds the memory, and `--json` carries the same as `wrapperAlive` and `childPids`.
|
|
41
|
+
|
|
42
|
+
`x heavy run` passes the exit code through and forwards stop signals. A process started inside a reservation inherits it (`ULTIMATE_HEAVY_HOLD`) and never queues behind its own parent. Time spent queued does not count against an `x verify` step's deadline.
|
|
43
|
+
|
|
44
|
+
## Merging two features
|
|
45
|
+
|
|
46
|
+
**Two branches that each ran `x g resource` merge with no hand edit.** `bun run setup` installs the drivers (`x merge-driver install`); `.gitattributes` says which file takes which. `As of 2026-11-19`.
|
|
47
|
+
|
|
48
|
+
| Files | On a merge | After it |
|
|
49
|
+
|---|---|---|
|
|
50
|
+
| `apps/web/api/index.ts`, `apps/web/exercise.ts`, `apps/web/shared/roles.ts`, `packages/db/src/client.ts` | what both sides **added** is kept, sorted, so either merge direction writes the same bytes | nothing |
|
|
51
|
+
| `packages/i18n/catalogs/*.json` | three-way by key | nothing |
|
|
52
|
+
| `x.manifest.json`, `openapi.json` | our copy is kept | `bunx x manifest`, then commit |
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
git merge feature-b
|
|
56
|
+
bunx x manifest
|
|
57
|
+
bunx x verify
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**What stays a conflict, on purpose:**
|
|
61
|
+
|
|
62
|
+
| Both branches | Why a person decides |
|
|
63
|
+
|---|---|
|
|
64
|
+
| changed or removed one existing line | `merge=union` would keep both, so a revoked grant in `roles.ts` would come back |
|
|
65
|
+
| declared one key, or one import name, differently | either could be the right one |
|
|
66
|
+
| gave one catalog key two wordings | which text ships is a decision |
|
|
67
|
+
|
|
68
|
+
`X_MERGE_UNRESOLVED` lists what is left: `git diff --name-only --diff-filter=U`. Resolve each, `git add` it, finish the merge.
|
|
69
|
+
|
|
70
|
+
- **Why one entry per line.** Registries are written that way (`x new`, and the `merge-drivers` codemod on `x upgrade`), because a list on one line is one line both sides changed. Keep the comment inside the list: it is what stops Biome joining the list back up.
|
|
71
|
+
- **Where the drivers do not run.** A hosted merge button and a clone that never ran setup use git's plain text merge, so the same files conflict there and nothing is lost. Merge locally. `x doctor` warns `X_MERGE_DRIVER_UNSET` on such a clone.
|
|
72
|
+
- **Migrations: `bunx x db gen --merge-fork`.** Two branches that each ran `x db gen` fork the chain: the newest snapshot lacks the other branch's table. `x db gen`, `x db migrate` and the gate's `drift` step refuse it as `X_MIGRATION_FORKED`, before any `record …` migration is suggested. `--merge-fork` corrects the newest `.snapshot.json` only: no SQL changes and nothing is deleted, so it is safe after either migration was applied. Two creates of one table are the exception: run `bunx x db status --json` on every database first, and remove a migration only if `data.pending` lists it on all of them ([Migrations](Migrations-And-Backfills)).
|
|
73
|
+
- **One `x db gen` at a time per checkout.** A second run waits on the checkout's `db-gen` lock instead of diffing the same sidecar and writing a second `create table`. With several agents in one checkout, one run's migration can still record another agent's new entity: the success line names the migration and its tables, and "no migration needed" names the migration that already records them.
|
|
74
|
+
|
|
75
|
+
## CPU pressure
|
|
76
|
+
|
|
77
|
+
Memory alone does not bound a machine: at 14.3 of 15.9 GB reserved, an 8-core box sat at load 74 with 69 runnable tasks and `cpu some avg10` at 95.8 (`As of 2026-11-18`). So the queue's head also waits while the CPU is saturated **and** another heavy run is admitted:
|
|
78
|
+
|
|
79
|
+
| Signal | Waits at |
|
|
80
|
+
|---|---|
|
|
81
|
+
| PSI `cpu some avg10` (`/proc/pressure/cpu`) | 80% |
|
|
82
|
+
| without PSI: runnable tasks per core | 2 |
|
|
83
|
+
|
|
84
|
+
First come, first served still holds: only the head is judged. With nothing admitted one run always starts, whatever the pressure and wherever it comes from, and a head held back by CPU alone goes anyway after 5 minutes, so a long holder cannot starve the queue. The wait line then reads `waits for CPU … CPU pressure 96% (new runs wait at 80%)`; `x heavy status` prints the reading as `cpu:`, and `--json` carries `data.machine.cpu` and `data.cpuGate`. Off in CI, inside a test run, and with `ULTIMATE_HEAVY_CPU=0`. The figures and the reasoning: `packages/cli/src/heavy-pressure.ts`.
|
|
38
85
|
|
|
39
86
|
## Cores
|
|
40
87
|
|
|
41
|
-
Locally a run takes **at most 4 cores**, fewer when other sessions' runnable tasks already fill the machine, and never below 2. Test workers are capped per batch, so a run narrows and widens as the machine changes; `tsc` and `biome` get the cap as `GOMAXPROCS` and `RAYON_NUM_THREADS`. `--workers N` is taken as written. CI takes every core.
|
|
88
|
+
Locally a run takes **at most 4 cores**, fewer when other sessions' runnable tasks already fill the machine, and never below 2. Test workers are capped per batch, so a run narrows and widens as the machine changes; `tsc` and `biome` get the cap as `GOMAXPROCS` and `RAYON_NUM_THREADS`. `--workers N` is taken as written. CI takes every core. A run held below its plan says `ran 2 at once (peak), planned 4`; `x test --json` carries it as `data.peakWorkers`.
|
|
89
|
+
|
|
90
|
+
## Neighbouring dev servers
|
|
91
|
+
|
|
92
|
+
`x dev` on a taken port refuses with `X_PORT_IN_USE`, naming the holder's pid and directory, and its fix names a pair of ports that is free when asked. `x doctor` reports a port held from **another checkout** as a warning, because nothing is wrong with this environment. A port held from this checkout, or by a process the OS will not name, stays a finding.
|
|
93
|
+
|
|
94
|
+
## Test service stacks
|
|
95
|
+
|
|
96
|
+
The `live` step prints one line on stderr for the stack it got:
|
|
97
|
+
|
|
98
|
+
| Line | Meaning |
|
|
99
|
+
|---|---|
|
|
100
|
+
| `services: started <project>` | this run started containers, and leaves them running for the next |
|
|
101
|
+
| `services: reused <project>` | they were already up, from this checkout |
|
|
102
|
+
| `services: shared <project> with <dir>` | another checkout of this app started them (same first commit, or same `origin`), or `ULTIMATE_TEST_SERVICES_SHARED=1` says the share is intended |
|
|
103
|
+
|
|
104
|
+
The compose project is the `name:` in `docker/docker-compose.test.yml`. An app `x new` wrote before 31.49.0 states `<app>-test`, so two different apps with one name land on the same stack; from 31.49.0 `x new` writes `<app>-test-<hash of the scaffold directory>` and picks the ports from both, so they do not (`As of 2026-11-19`). A shared name is refused: the step reports `X_TEST_SERVICES_UNAVAILABLE` naming the other directory — a stack that is stopped is said to be stopped, its fix `docker compose -p <project> down --volumes` — compose is not run, and the live suites run without the stack (red when the floor holds `live` and nothing ran). Checkouts git cannot tie together count as different apps. For good: give the app its own `name:` and ports, in the compose file and `docker/test-services.env`.
|
|
105
|
+
|
|
106
|
+
`x clean --services` stops this checkout's stack, keeps one another living checkout started, and lists every other test stack on the machine with its stop command, marking those whose checkout is gone. It stops nothing else.
|
|
42
107
|
|
|
43
108
|
## Switches
|
|
44
109
|
|
|
@@ -46,8 +111,10 @@ Locally a run takes **at most 4 cores**, fewer when other sessions' runnable tas
|
|
|
46
111
|
|---|---|
|
|
47
112
|
| `ULTIMATE_HEAVY_MEMORY=8g` | what the ledger admits; `0` turns it off |
|
|
48
113
|
| `ULTIMATE_HEAVY_CORES=6` | the local core ceiling |
|
|
114
|
+
| `ULTIMATE_HEAVY_CPU=0` | no waiting on CPU pressure; memory still applies |
|
|
49
115
|
| `ULTIMATE_HEAVY_DIR=<path>` | another ledger; also opts a test run in |
|
|
50
116
|
| `ULTIMATE_TEST_SLOTS=0` | test workers skip the ledger |
|
|
117
|
+
| `ULTIMATE_TEST_SERVICES_SHARED=1` | another app's test stack under this app's project name is shared on purpose |
|
|
51
118
|
|
|
52
119
|
Admission is off under `CI`, inside `bun test` (a fixture's `x test` must not queue behind real work), and on **Windows**, which has no `flock`: the core cap still applies there and `x heavy status` says why admission is off. A ledger that cannot work is reported as `X_HEAVY_LEDGER_UNAVAILABLE` and the command goes ahead; it never fails a run.
|
|
53
120
|
|
|
@@ -55,6 +55,19 @@ Every migration applies inside its own transaction, recorded into `x_migrations`
|
|
|
55
55
|
|
|
56
56
|
Its two remedies, in the order they are safe to run: `git checkout -- packages/db/migrations/<id>.snapshot.json`, or, when the file was never written, `rm packages/db/migrations/<id>.* && x db gen "<name>"`. The delete comes first because `x db gen` against the migration that is still there raises this same code. Until 2026-08 the `fix:` said "restore … from version control" alone while `x db migrate`'s `unknown-schema` difference answered `x db gen "snapshot <name>"` — each naming the command that raises the other, with nothing to restore in an app whose sidecar was never written.
|
|
57
57
|
|
|
58
|
+
### Two branches, one chain — `X_MIGRATION_FORKED`
|
|
59
|
+
|
|
60
|
+
Two branches that each run `x db gen` from one parent leave valid SQL and a wrong sidecar: the newest `.snapshot.json` has never heard of the other branch's work. `As of 2026-11` every reader refuses that chain before acting on it: `x db gen`, `x db migrate`, `x db reset`, the `drift` step and `x doctor`.
|
|
61
|
+
|
|
62
|
+
| The chain holds | Fix | What it touches |
|
|
63
|
+
|---|---|---|
|
|
64
|
+
| an object the newest sidecar omits, or one it still records after another migration dropped it | `x db gen --merge-fork` | the newest `.snapshot.json`, then the `.hash` and the schema dump. No `.sql`, so no checksum moves, and it is safe after either migration was applied |
|
|
65
|
+
| two unguarded creates of one table or column, so a replay stops at `42P07` / `42701` | `x db status --json` on **every** database first | remove a migration only if `data.pending` lists it on all of them, then `x db gen --merge-fork`. A migration any database applied stays |
|
|
66
|
+
|
|
67
|
+
The detector folds the chain: each sidecar adds what it records, each `up` removes what it drops, and what survives is what a replay builds (tables, columns, indexes, foreign keys, checks, views). A migration with no sidecar was written by hand and ends what earlier sidecars can claim. Never answer a fork with a new migration: `create table` for a table the chain already builds is the statement that cannot replay.
|
|
68
|
+
|
|
69
|
+
`x db gen` also runs one at a time per checkout, `As of 2026-11`: two overlapping runs diffed one sidecar and each wrote every new table. The entities are one registry, so the first run's migration carries a second agent's table too: its summary names the tables, and the later run's names the newest migration. The lock is the machine ledger's, so it is off under `CI`, on Windows and with `ULTIMATE_HEAVY_MEMORY=0`; there, a collision is what `X_MIGRATION_FORKED` reports afterwards.
|
|
70
|
+
|
|
58
71
|
### Foreign keys are their own statement
|
|
59
72
|
|
|
60
73
|
Every foreign key is `alter table … add constraint`, emitted **after** every table statement, and
|
|
@@ -294,6 +307,10 @@ A NOT NULL contract is the same story. On an empty table — a fresh or `x db re
|
|
|
294
307
|
| `X_MIGRATION_ROLLING_UNSAFE` | a column leaves the entity without having been retired, with or without `--allow-destructive`. Also a retired name no migration records or `columns` still declares, a NOT NULL column with no default or a key column (the new release's inserts would fail, so relax it first), a committed `drop`/`rename` when the `drift` rail is on, and a retire and its drop both pending on a live production database |
|
|
295
308
|
| `X_MIGRATION_IRREVERSIBLE` | the retired column is removed without `--allow-destructive`. Retiring is not consent to losing the rows |
|
|
296
309
|
|
|
310
|
+
**A plain column made `generated` is a drop**, `As of 2026-11-19`: Postgres has no `set expression` for it, so the migration drops the column and adds it back computed, and the stored values are gone. `x db gen` asks the same two consents: `X_MIGRATION_ROLLING_UNSAFE` unless the column was retired first (or `--rolling-unsafe`), then `X_MIGRATION_IRREVERSIBLE` unless `--allow-destructive`. Before, it wrote the migration unasked.
|
|
311
|
+
|
|
312
|
+
**A drop's `down` restores the column's indexes and foreign keys**, `As of 2026-11-19` — those the previous `.snapshot.json` recorded over it, for every dropped column, retired or not. The rows, NOT NULL and the default are not restored. Only newly generated migrations change.
|
|
313
|
+
|
|
297
314
|
An app that stops before it starts (one instance, `strategy: Recreate`) says so: `x db gen "drop legacy" --allow-destructive --rolling-unsafe` writes `-- rolling-unsafe: true` and needs no retire.
|
|
298
315
|
|
|
299
316
|
**The rail.** `rollingSince: "<migration id>"` in `x.verify.json` turns on the `drift` step's fifth rail for every migration after that id: a `drop column` with no `-- retires` in an earlier file, a `rename column`, a `rename table`. A closed list, on statements and not on prose. `x new` writes `"0"`. Unset, the rail does not run, because an applied migration cannot gain a marker (checksum); `x doctor` prints one line naming the id to set. A retire before the bound still earns the drop after it.
|
|
@@ -568,6 +585,7 @@ Scaffolds a working pair, never a stub: `x g backfill <name> --feature <slice>`
|
|
|
568
585
|
| `X_MIGRATION_CONFLICT` | the ledger disagrees with this build — a foreign app-version row that is not a rollback (rows all newer than the build are accepted), or an applied migration whose checksum moved | deploy the version `cause` names, or `x db gen "fix <migration>"` — never edit an applied migration |
|
|
569
586
|
| `X_MIGRATION_IRREVERSIBLE` | a generated plan drops a column or table and its `down` cannot restore the rows | `x db gen "<name>" --allow-destructive`, or put the column back in `columns` and keep it |
|
|
570
587
|
| `X_MIGRATION_DESTRUCTIVE` | a committed migration's `up` destroys data with no `-- destructive: true` line | add the marker, or regenerate with `--allow-destructive` — before the migration is applied |
|
|
588
|
+
| `X_MIGRATION_FORKED` | two branches generated from one parent and were merged, so the newest sidecar is wrong or two migrations create one object | `x db gen --merge-fork`, which changes no SQL and deletes nothing. A collision: `x db status --json` on every database first, and never delete a migration any of them applied |
|
|
571
589
|
| `X_MIGRATION_SNAPSHOT_MISSING` | the newest migration on disk carries no `.snapshot.json` sidecar to diff against | `git checkout -- packages/db/migrations/<id>.snapshot.json` — or, when it was never written, `rm packages/db/migrations/<id>.* && x db gen "<name>"`, the delete first |
|
|
572
590
|
| `X_MIGRATION_CONCURRENT_IN_TRANSACTION` | a migration without `-- transaction: false` holds a concurrent index statement, which Postgres refuses inside a transaction block (`25001`) | `sed -i '1i -- transaction: false' packages/db/migrations/<id>.sql` before it is applied, or move the statement into a migration of its own. Refused before `BEGIN`, so nothing is applied |
|
|
573
591
|
| `X_MIGRATION_VIEW_DEPENDS` | a view is compiled against a column this migration retypes — Postgres answers `0A000` and rolls the whole migration back | `drop view "<v>";` then `x db migrate`, then re-create it from the `create view` the `fix` line carries verbatim. Caught by a **preflight** inside the migration's own transaction, before its first statement, so nothing partial is applied |
|
package/wiki/Notify.md
CHANGED
|
@@ -167,7 +167,7 @@ What each push-service answer does:
|
|
|
167
167
|
| 404 / 410, or an expired subscription | the subscription is deleted; nothing is retried |
|
|
168
168
|
| 429 / 5xx / no connection | `X_PWA_PUSH_FAILED` — thrown after every other device was tried, so the delivery fails as `X_NOTIFY_DELIVERY_FAILED` and the notifier job retries on its own backoff |
|
|
169
169
|
| 400 / 413 | `X_PWA_PUSH_REJECTED` — logged and counted, never retried |
|
|
170
|
-
| 401 / 403 | `X_PWA_PUSH_REJECTED
|
|
170
|
+
| 401 / 403 | `X_PWA_PUSH_REJECTED` — logged with its code and counted as `refused`; the subscription is **kept** (`As of 2026-11-19`): a push service answers a fault in this server's token (a `pwa.vapid.subject` it refuses, a skewed clock) the same way as a rotated key, and deleting on it unsubscribed every device a send reached. After a real key rotation `subscribeToPush` (or the emitted `subscribePush`) replaces such a browser's subscription the next time it asks |
|
|
171
171
|
|
|
172
172
|
A retry re-sends to the devices that already got it; the `tag` makes that a replacement on the device
|
|
173
173
|
rather than a second notification. `renotify` without a `tag` is dropped with a warning — the spec
|
|
@@ -236,11 +236,13 @@ export const approvalRequested = notifier({
|
|
|
236
236
|
| devices | `x_push_devices`, keyed `(platform, token)` — a phone a second person signs in on is theirs now |
|
|
237
237
|
| register | `registerDevice` on every launch; `previousToken` when the OS rotated it. `unregisterDevice` on sign-out. Stored against `ctx.actor.id`; an agent never registers |
|
|
238
238
|
| data-only | `pushChannel({ pusher, data })` — APNs `background`, priority 5, `content-available: 1`; FCM with no `notification`. ≤ 8 string keys, ≤ 256 characters, no reserved key: else `X_NOTIFY_PUSH_MESSAGE_INVALID`. `webPush()` cannot take it — a type error |
|
|
239
|
-
| visible | `pushChannel({ pusher, message })`, the same `NotifyPushMessage` as the web: rendered per device locale |
|
|
239
|
+
| visible | `pushChannel({ pusher, message })`, the same `NotifyPushMessage` as the web: rendered per device locale. `urgency` sets APNs `apns-priority` (10, or 5 for `low`/`very-low`) and FCM `android.priority` (`high`/`normal`) |
|
|
240
|
+
| native-only fields | on the same message, ignored by `webPush()`: `sound` → APNs `aps.sound` and FCM `android.notification.sound`: `'default'` for the platform's sound, or a bundled one — APNs reads its file name (`chime.caf`), FCM its `res/raw` resource name without the extension (`chime`), and on Android 8 and later the notification channel sets the sound; unset, no sound is requested and APNs alerts silently; `interruptionLevel` (`passive`, `active`, `time-sensitive`, `critical` — the last needs Apple's entitlement) → `aps.interruption-level`; `category` → `aps.category`; `channelId` → `android.notification.channel_id`. A name is 1–64 of `A-Za-z0-9._-`, in any position, else `X_NOTIFY_PUSH_MESSAGE_INVALID` with `meta.field`, before any device. Unset, nothing is added: the wire is byte identical to a message without them. `As of 2026-11-23` |
|
|
241
|
+
| report | `nativePush({ onReport })` is called with `{ to, kind: 'alert' \| 'data', report }` once each send (`'alert'`) or `sendData` (`'data'`) settles; `report` is a `NativePushReport` — `{ accepted, refused, removed, skipped }`, one count per device. `accepted` is what APNs or FCM took (a 2xx), never what a device showed: no provider reports delivery. `removed`: rows deleted (gone, a bad token at its limit, an unsendable token); `skipped`: no provider configured for its platform. A credential refusal rejects the whole send (`X_NOTIFY_PUSH_PROVIDER_REFUSED`), so no report carries the devices it stopped. A send nothing accepted and something refused still rejects, and reports nothing. A throw from `onReport` is reported (`notify.push.on_report`) and the send still settles: the providers took it, so a retry would push it twice |
|
|
240
242
|
|
|
241
243
|
| Provider answer | Outcome |
|
|
242
244
|
|---|---|
|
|
243
|
-
| 2xx |
|
|
245
|
+
| 2xx | accepted by the provider |
|
|
244
246
|
| APNs 410 · FCM `UNREGISTERED` | `X_NOTIFY_PUSH_DEVICE_GONE` — the device row is deleted, the delivery settles |
|
|
245
247
|
| other 4xx | `X_NOTIFY_PUSH_PROVIDER_REFUSED` — logged, next device tried; fails the delivery when no device took it. 401/403 also drops the cached credential |
|
|
246
248
|
| 429 · 5xx · timeout | rethrown after every other device was tried: `X_NOTIFY_DELIVERY_FAILED`, the job retries |
|
package/wiki/Observability.md
CHANGED
|
@@ -192,6 +192,18 @@ The body always opens with a `target_info` gauge carrying the service identity,
|
|
|
192
192
|
| `x dev` with no `METRICS_PORT` moves off a taken port | two apps on one laptop both default to 9090: the second binds a free port, logs `ultimate metrics port taken`, and reports the real URL in `x dev --json`'s `metrics`. A declared `METRICS_PORT`, and every container, refuses with `X_PORT_IN_USE` — a scraper was told that port |
|
|
193
193
|
| Answered outside the request pipeline | no auth stage, no rate limit, no locale — a saturated or draining process must still be able to say how saturated it is. Same shape as `/healthz` |
|
|
194
194
|
|
|
195
|
+
### A container running N processes
|
|
196
|
+
|
|
197
|
+
`As of 2026-11`, a production container with a CPU budget runs one process per CPU ([Processes per container](Deployment#processes-per-container)). The scrape stays one target:
|
|
198
|
+
|
|
199
|
+
| Signal | Shape |
|
|
200
|
+
|---|---|
|
|
201
|
+
| `/metrics` on `METRICS_PORT` | the supervisor's: each child's own scrape (loopback, an ephemeral port), merged under one `# HELP` / `# TYPE` per family, every sample labelled `child="<i>"`. A child that does not answer within 2 s is left out of that scrape |
|
|
202
|
+
| counters and histograms | per child: `sum by (…)` over `child` is the container's total, as it is over pods |
|
|
203
|
+
| **process-global gauges** | appear **N times**, once per child — `queue_demand`, `queue_depth`, `queue_oldest_ready_seconds` and the `db_server_*` gauges are each child's reading of one shared fact. **Use `max`, never `sum`**: a sum reads N× the backlog and scales the fleet N× |
|
|
204
|
+
| log lines | every line a child writes carries `"child": <i>`; the supervisor's carry `"child": "supervisor"`. A caller's own `child` field moves to `field.child`. A child whose boot throws says so first as `ultimate child refused to boot` (`error`, with the code, cause and fix) — the line `X_PROCESS_CRASH_LOOP` sends you to |
|
|
205
|
+
| `/healthz`, `/readyz` | the supervisor's: alive and not in a crash loop; at least one child ready, every other one ready or draining, the container not stopping |
|
|
206
|
+
|
|
195
207
|
## The series autoscaling reads
|
|
196
208
|
|
|
197
209
|
Declared in `runtime-metrics.ts`, so the role table, the Helm chart and the scrape cannot drift apart.
|
|
@@ -277,6 +289,7 @@ CPU autoscaling is wrong for `sync` and `worker`: a node holding 80k idle socket
|
|
|
277
289
|
| Head sampling | `otel.sampling`, default `0.1`; errors are always sampled |
|
|
278
290
|
| OTLP delivery | a 429, 502, 503, 504 or a transport failure is retried, 3 attempts with full jitter and `Retry-After` honoured, inside the exporter's `timeoutMs` (default 10 s, the whole export); any other status is one POST. One `otlp export rejected`/`failed` line per batch, with `attempts`. A collector that accepted and then answered 503 receives that batch twice; span ids dedupe it |
|
|
279
291
|
| 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` |
|
|
292
|
+
| Monitor delivery | the `SENTRY_DSN` transport (`sentryErrorReporter`) reads each answer, `As of 2026-11-19`: one `warn` line per refused status (`error reporter delivery refused; events are being dropped`, with `status`), a 429 pauses sends for its `Retry-After` — 60 s when it states none — and reports in the pause are dropped, every answer's body is cancelled, and a throw while reading is logged, never an unhandled rejection. `X_ERROR_REPORTER_DSN_INVALID` names the DSN with its userinfo removed |
|
|
280
293
|
| 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`) |
|
|
281
294
|
| Secret redaction | a `Secret` is redacted by value before every other branch, at any depth → [Configuration](Configuration) |
|
|
282
295
|
| 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 |
|
package/wiki/Outbound-HTTP.md
CHANGED
|
@@ -33,7 +33,7 @@ export async function chargeStatus(id: string): Promise<{ id: string; status: st
|
|
|
33
33
|
| `Retry-After` | a retryable status that states a delay waits that delay (clamped by the policy's `max`) |
|
|
34
34
|
| body | read under an idle watchdog (`idleMs`, default 30 s) and a byte cap (`maxBytes`, default 16 MiB). `read: 'stream'` hands the body over under both |
|
|
35
35
|
| redirects | `redirect: 'error'` by default. `'follow'` takes at most 5 hops and screens EVERY hop after the first as a public dial, `'named'` included; at an origin change only `accept`, `content-type` and `user-agent` travel |
|
|
36
|
-
| redaction | a cause, `meta` and the `outbound.attempt` log line carry vendor, method, origin and the path's FIRST segment plus the length of the rest (`/services/…(21 chars)`: a webhook keeps its token in the path), never the query or a header. A refusal's body reaches `meta.detail` only as a JSON object, credential-named fields redacted, 200 characters; anything else (a form, an array, HTML, a cut body) is dropped |
|
|
36
|
+
| redaction | a cause, `meta` and the `outbound.attempt` log line carry vendor, method, origin and the path's FIRST segment plus the length of the rest (`/services/…(21 chars)`: a webhook keeps its token in the path), never the query or a header. A refusal's body reaches `meta.detail` only as a JSON object, credential-named fields redacted, 200 characters; anything else (a form, an array, HTML, a cut body) is dropped. [`refusal`](#refusal-what-a-non-2xx-body-becomes) declares the fields to keep from the whole body, or drops `meta.detail` |
|
|
37
37
|
| breaker | `breaker: breaker({ name, failures, cooldownMs })` from `@ultimat3/core`, recorded once per call after the retries. See below |
|
|
38
38
|
|
|
39
39
|
## `dial`: which network a URL may reach
|
|
@@ -84,6 +84,23 @@ await outbound({
|
|
|
84
84
|
});
|
|
85
85
|
```
|
|
86
86
|
|
|
87
|
+
## `deps.fetch`: the transport
|
|
88
|
+
|
|
89
|
+
`outbound(request, { fetch })` swaps the transport, for a test or in production (a client with its
|
|
90
|
+
own sockets, an instrumented one). It sits UNDER `outbound()`, so every rule above stays the call's.
|
|
91
|
+
|
|
92
|
+
| The transport is handed | The transport must |
|
|
93
|
+
|---|---|
|
|
94
|
+
| the SCREENED url: under `dial: 'public'` the approved address, with `host` and `tls.serverName` naming the name | dial that url, nowhere else |
|
|
95
|
+
| `init` with `signal` and `redirect: 'manual'` | pass `init` through; a hop is `outbound()`'s to take (`redirect: 'follow'`) |
|
|
96
|
+
|
|
97
|
+
- **A transport that followed a redirect itself is refused**: an answer with `redirected: true` is
|
|
98
|
+
`X_OUTBOUND_TRANSPORT_REDIRECTED`, under `redirect: 'error'` and `'follow'` alike — no screen saw
|
|
99
|
+
that hop (`outbound-transport.test.ts`).
|
|
100
|
+
- `maxBytes`, `idleMs` and `deadlineMs` cut the body the transport streams, whatever it does.
|
|
101
|
+
- **A transport that reaches another address (a tunnel, a relay) takes the screen over**: the app
|
|
102
|
+
proves it, as for a proxy it names.
|
|
103
|
+
|
|
87
104
|
`screenDial(url, { resolve, allowPrivate })` is the screen alone, for a transport that keeps its own
|
|
88
105
|
codes: `@ultimat3/jobs`' webhook target and `@ultimat3/scraping`'s wildcard leg call it.
|
|
89
106
|
|
|
@@ -95,14 +112,48 @@ codes: `@ultimat3/jobs`' webhook target and `@ultimat3/scraping`'s wildcard leg
|
|
|
95
112
|
| `X_OUTBOUND_UNREACHABLE` | retryable | DNS, connect, TLS or reset: no response |
|
|
96
113
|
| `X_OUTBOUND_THROTTLED` | retry-after | a retryable status with `Retry-After` (`meta.retryAfterSeconds`) |
|
|
97
114
|
| `X_OUTBOUND_UNAVAILABLE` | retryable | 5xx, 408, 409, 425, 429 with no stated delay (`meta.status`) |
|
|
98
|
-
| `X_OUTBOUND_REFUSED` | terminal | any other non-2xx (`meta.status`, `meta.detail`) |
|
|
115
|
+
| `X_OUTBOUND_REFUSED` | terminal | any other non-2xx (`meta.status`, `meta.detail`, `meta.fields` under `refusal.schema`) |
|
|
99
116
|
| `X_OUTBOUND_TOO_LARGE` | terminal | the body passed `maxBytes` |
|
|
100
117
|
| `X_OUTBOUND_HOST_BLOCKED` | terminal | `dial: 'public'` refused an address class, a scheme or a hop |
|
|
101
118
|
| `X_OUTBOUND_REDIRECTED` | terminal | a 3xx under `redirect: 'error'`, or more than 5 hops (`meta.location`, no query) |
|
|
119
|
+
| `X_OUTBOUND_TRANSPORT_REDIRECTED` | terminal | the transport in `deps.fetch` answered `redirected: true`: it followed a hop itself (`meta.location`, no query) |
|
|
102
120
|
| `X_OUTBOUND_RETRY_UNSAFE` | terminal | `retry` on POST or PATCH without `idempotent: true` |
|
|
103
121
|
| `X_OUTBOUND_BODY_INVALID` | terminal | `answer.json(schema)` refused the body (`meta.issues`) |
|
|
104
122
|
| `X_OUTBOUND_PROXY_INVALID` | terminal | `proxy` is not an `http:`/`https:` URL, or its resolver threw (`meta.reason`, never the URL) |
|
|
105
123
|
|
|
124
|
+
### `refusal`: what a non-2xx body becomes
|
|
125
|
+
|
|
126
|
+
`X_OUTBOUND_REFUSED`, `X_OUTBOUND_UNAVAILABLE` and `X_OUTBOUND_THROTTLED` read the body once, per
|
|
127
|
+
the call's `refusal`:
|
|
128
|
+
|
|
129
|
+
| `refusal` | Read | On the error |
|
|
130
|
+
|---|---|---|
|
|
131
|
+
| unset (default) | chunks until 1,024 characters are decoded, the rest cancelled (a whole chunk is kept, so one large chunk is read whole) | `meta.detail`: a JSON object, credential-named fields redacted, 200 characters; else `''`. A large error object that arrives in pieces is cut, does not parse, and is `''` |
|
|
132
|
+
| `{ schema }` | the whole body, up to the call's `maxBytes` | `meta.fields`: the schema's answer, credential-named fields redacted at any depth; absent when the body is not JSON, does not fit or passes `maxBytes`. `meta.detail` is the 200-character excerpt of that whole body |
|
|
133
|
+
| `{ detail: false }` | nothing for the excerpt | `meta.detail: ''`: the excerpt, and the free text it carries (an address, a name), never kept. Combines with `schema`; it does not filter `meta.fields`, so a schema keeps only fields that are safe to log |
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
import { isUltimateError } from '@ultimat3/core';
|
|
137
|
+
import { outbound } from '@ultimat3/core/outbound';
|
|
138
|
+
import { t } from '@ultimat3/schema';
|
|
139
|
+
|
|
140
|
+
declare const url: string;
|
|
141
|
+
declare const body: string;
|
|
142
|
+
|
|
143
|
+
const decline = t.object({ error: t.object({ decline_code: t.string }) });
|
|
144
|
+
try {
|
|
145
|
+
await outbound({ url, vendor: 'payments', dial: 'named', deadlineMs: 10_000, method: 'POST',
|
|
146
|
+
body, refusal: { schema: decline, detail: false } });
|
|
147
|
+
} catch (error) {
|
|
148
|
+
// meta.fields is unknown on the error: the schema that declared it reads it back typed.
|
|
149
|
+
if (isUltimateError(error) && error.code === 'X_OUTBOUND_REFUSED') {
|
|
150
|
+
console.log(decline.safeParse(error.meta?.['fields']));
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
The schema is the whole of what `meta.fields` keeps: undeclared keys never reach it. `meta.detail` is a separate excerpt of the raw body and may still carry an undeclared field (an `error.message` holding an email): set `detail: false` to keep only what the schema declares.
|
|
156
|
+
|
|
106
157
|
**A 401 is `X_OUTBOUND_REFUSED` with `meta.status: 401`.** There is no refresh hook: the app's own
|
|
107
158
|
wrapper refreshes its token and calls again. Token storage and single-flight stay the app's.
|
|
108
159
|
|