@ultimat3/cli 30.8.0 → 31.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +75 -64
- package/README.md +4 -1
- package/package.json +30 -29
- package/src/admin-registration.ts +1 -1
- package/src/affected.ts +5 -1
- package/src/app-boundaries.ts +88 -9
- package/src/app-load-async.ts +133 -0
- package/src/app-load-batch.ts +203 -0
- package/src/app-load-prebuilt.ts +147 -0
- package/src/app-load-register.ts +175 -0
- package/src/app-load.ts +143 -175
- package/src/app-loader-imports.ts +31 -0
- package/src/app-root.ts +13 -0
- package/src/app-runtime.ts +5 -1
- package/src/boundary-findings.ts +12 -0
- package/src/browser-launcher-port.ts +3 -7
- package/src/browser-launcher.ts +1 -1
- package/src/budgets-scan.ts +8 -0
- package/src/budgets.ts +10 -1
- package/src/build-registry-background.ts +59 -0
- package/src/build-registry.ts +207 -0
- package/src/cdp-shot-clock.ts +3 -11
- package/src/cdp-shot-driver.ts +3 -2
- package/src/cdp-shot-element.ts +3 -2
- package/src/cdp-shot-page.ts +2 -2
- package/src/cdp-shot-watch.ts +4 -3
- package/src/cmd-auth.ts +3 -3
- package/src/cmd-db-recount.ts +15 -0
- package/src/cmd-drill.ts +10 -6
- package/src/cmd-exercise.ts +2 -1
- package/src/cmd-generate-spec.ts +6 -0
- package/src/cmd-generate.ts +22 -4
- package/src/cmd-mail.ts +1 -1
- package/src/cmd-routes.ts +2 -2
- package/src/cmd-secrets-spec.ts +4 -1
- package/src/cmd-shot.ts +14 -4
- package/src/cmd-verify-spec.ts +21 -1
- package/src/cmd-verify.ts +16 -4
- package/src/coverage-source.ts +4 -1
- package/src/db-diagnostics.ts +8 -1
- package/src/dev-boot.ts +29 -15
- package/src/dev-dashboard-invalidations.ts +43 -0
- package/src/dev-dashboard.ts +13 -16
- package/src/dev-n-plus-one.ts +7 -3
- package/src/dev-rebuild.ts +2 -1
- package/src/dev-route-table.ts +1 -1
- package/src/dev-traces.ts +16 -15
- package/src/document-options.ts +12 -1
- package/src/drift-store.ts +55 -0
- package/src/error-catalog.ts +8 -3
- package/src/error-codes-boundary.ts +32 -0
- package/src/error-codes.ts +23 -19
- package/src/errors.ts +17 -7
- package/src/exercise-database.ts +13 -1
- package/src/exercise-findings.ts +36 -18
- package/src/exercise-services.ts +84 -0
- package/src/exercise-subject.ts +38 -13
- package/src/failure-capture-boot.ts +9 -5
- package/src/framework-schema.ts +5 -5
- package/src/generate-exercise.ts +1 -1
- package/src/generate-files.ts +27 -7
- package/src/generate-kinds.ts +5 -0
- package/src/generate-refresh.ts +53 -0
- package/src/generate-workspace.ts +169 -0
- package/src/generate-write.ts +8 -2
- package/src/hold.ts +19 -8
- package/src/image-prepare.ts +6 -2
- package/src/index.ts +5 -20
- package/src/island-bundle.ts +7 -3
- package/src/island-capture.ts +2 -2
- package/src/island-harness.ts +1 -1
- package/src/job-registration.ts +43 -6
- package/src/jobs-driver.ts +4 -5
- package/src/mcp-errors.ts +18 -4
- package/src/mcp-host.ts +5 -1
- package/src/mcp-ui-interact.ts +3 -0
- package/src/messages-gate.ts +4 -0
- package/src/new-shapes-generate.ts +1 -1
- package/src/otlp-export.ts +94 -29
- package/src/output.ts +3 -7
- package/src/page-sync.ts +3 -1
- package/src/role-load.ts +17 -11
- package/src/role-start.ts +5 -4
- package/src/role-sync.ts +7 -8
- package/src/route-islands-preload.ts +46 -0
- package/src/route-islands.ts +6 -2
- package/src/runtime-admin.ts +5 -1
- package/src/runtime-bindings.ts +25 -19
- package/src/runtime-boot-ports.ts +66 -0
- package/src/runtime-bus.ts +29 -5
- package/src/runtime-cache-bus.ts +53 -0
- package/src/runtime-cache.ts +43 -13
- package/src/runtime-isr-outcome.ts +5 -4
- package/src/runtime-jobs.ts +2 -2
- package/src/runtime-keys.ts +37 -0
- package/src/runtime-overrides.ts +148 -42
- package/src/runtime-port-bindings-queue.ts +36 -0
- package/src/runtime-port-bindings.ts +117 -0
- package/src/runtime-ports.ts +164 -0
- package/src/runtime-purge.ts +41 -28
- package/src/runtime-push.ts +7 -3
- package/src/runtime-queue.ts +70 -55
- package/src/runtime-realtime.ts +5 -5
- package/src/runtime-render-document.ts +4 -1
- package/src/runtime-services.ts +110 -158
- package/src/runtime-storage-boot.ts +111 -0
- package/src/runtime-storage-upload.ts +9 -7
- package/src/runtime-storage.ts +7 -1
- package/src/serve-boot.ts +8 -4
- package/src/serve-entry.ts +3 -0
- package/src/serve-env.ts +47 -14
- package/src/serve-prebuilt-paths.ts +3 -0
- package/src/serve-prebuilt.ts +15 -4
- package/src/serve.ts +2 -2
- package/src/static-cards.ts +3 -2
- package/src/static-report.ts +2 -2
- package/src/style-bundle.ts +1 -1
- package/src/sync-authenticator.ts +17 -18
- package/src/templates/action-tests.ts +4 -4
- package/src/templates/backfill.ts +5 -8
- package/src/templates/entity.ts +3 -0
- package/src/templates/github/ci.yml.ts +3 -1
- package/src/templates/github/dependabot.yml.ts +73 -0
- package/src/templates/job.ts +13 -22
- package/src/templates/naming.ts +20 -1
- package/src/templates/pinned/docker-compose.yml +1 -1
- package/src/templates/query.ts +7 -8
- package/src/templates/route.ts +5 -3
- package/src/templates/scaffold-api.ts +1 -1
- package/src/templates/scaffold-auth.ts +5 -3
- package/src/templates/scaffold-claude-commands.ts +6 -3
- package/src/templates/scaffold-claude.ts +4 -4
- package/src/templates/scaffold-container-compose.ts +2 -4
- package/src/templates/scaffold-domain-package.ts +1 -1
- package/src/templates/scaffold-entries.ts +6 -1
- package/src/templates/scaffold-helm-fences.ts +3 -2
- package/src/templates/scaffold-helm.ts +35 -6
- package/src/templates/scaffold-repo.ts +47 -135
- package/src/templates/scaffold-runtime-ports.ts +62 -0
- package/src/templates/scaffold-verify-floor.ts +97 -0
- package/src/templates/shapes/overlay.ts +1 -1
- package/src/templates/sign-in-oidc.ts +5 -3
- package/src/templates/sign-in-shared.ts +28 -10
- package/src/templates/workspace.ts +75 -0
- package/src/test-ignores.ts +5 -2
- package/src/test-select.ts +4 -1
- package/src/upgrade-gate.ts +30 -5
- package/src/upgrade-report.ts +7 -1
- package/src/verify-changed-facts.ts +53 -0
- package/src/verify-changed-scope.ts +161 -0
- package/src/verify-changed.ts +174 -0
- package/src/verify-checks.ts +31 -19
- package/src/verify-drift-owner.ts +30 -0
- package/src/verify-e2e.ts +2 -1
- package/src/verify-factories.ts +86 -0
- package/src/verify-run.ts +13 -11
- package/src/verify-step.ts +13 -0
- package/src/verify-tests.ts +58 -6
- package/src/write-line.ts +21 -6
- package/wiki/Actions.md +2 -2
- package/wiki/Adapters.md +400 -0
- package/wiki/Admin-Dashboard.md +2 -1
- package/wiki/Agents.md +9 -9
- package/wiki/Auth.md +78 -2
- package/wiki/Building-Your-Own-Base.md +1 -1
- package/wiki/CLI-Reference.md +34 -7
- package/wiki/Caching-And-Invalidation.md +17 -5
- package/wiki/Compared.md +8 -2
- package/wiki/Configuration.md +14 -14
- package/wiki/Deployment.md +28 -1
- package/wiki/Entities-And-Migrations.md +48 -2
- package/wiki/FAQ.md +8 -2
- package/wiki/Feature-Flags.md +1 -1
- package/wiki/Home.md +3 -2
- package/wiki/Jobs-And-Workflows.md +107 -6
- package/wiki/Known-Gaps.md +4 -3
- package/wiki/MCP-And-AI.md +18 -4
- package/wiki/Mail.md +14 -5
- package/wiki/Migrations-And-Backfills.md +31 -4
- package/wiki/Money.md +2 -0
- package/wiki/N-Plus-One-Detection.md +24 -22
- package/wiki/Notify.md +28 -4
- package/wiki/Observability.md +121 -15
- package/wiki/Queries-And-Live-Queries.md +2 -2
- package/wiki/Realtime.md +9 -4
- package/wiki/Routes-And-Render-Modes.md +5 -0
- package/wiki/Scraping.md +57 -11
- package/wiki/Shapes.md +2 -2
- package/wiki/Stability.md +7 -5
- package/wiki/Storage-And-Uploads.md +56 -4
- package/wiki/Testing.md +69 -56
- package/wiki/Troubleshooting.md +1 -1
- package/wiki/Tutorial-01-First-App.md +1 -1
- package/wiki/Tutorial-04-Jobs-And-Realtime.md +1 -1
- package/wiki/Tutorial-05-Deploy-Free.md +1 -1
- package/wiki/Tutorial-06-Growing-Up.md +8 -8
- package/wiki/Upgrading.md +129 -4
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// The `boot` ports (`runtime.ts`'s `clock`, `secretSource`), installed by ONE helper on every path
|
|
2
|
+
// that reads `runtime.ts` — after that module (and all it imports) has evaluated on the defaults,
|
|
3
|
+
// before `app.config.ts` and the app's modules do. `startServices` and every queue-only command
|
|
4
|
+
// (`x jobs`, `x auth`, `ROLE=migrate`) call it; a path that skipped it ran on the wrong key.
|
|
5
|
+
|
|
6
|
+
import { loadAppRuntime } from './app-runtime';
|
|
7
|
+
import type { DevServices, Env } from './runtime-bindings';
|
|
8
|
+
import { resolveServices } from './runtime-bindings';
|
|
9
|
+
import type { RuntimeOverrides } from './runtime-overrides';
|
|
10
|
+
import { BOOT_PORT_BINDINGS } from './runtime-port-bindings-queue';
|
|
11
|
+
import { installPorts, type PortRelease } from './runtime-ports';
|
|
12
|
+
import { type RunningQueue, type SchemaMode, startQueue } from './runtime-queue';
|
|
13
|
+
|
|
14
|
+
/** Install `runtime.ts`'s boot ports; answers the releases, in install order. */
|
|
15
|
+
export const installBootPorts = (overrides: RuntimeOverrides | undefined): Promise<PortRelease[]> =>
|
|
16
|
+
installPorts(BOOT_PORT_BINDINGS, 'boot', {
|
|
17
|
+
clock: overrides?.clock,
|
|
18
|
+
secretSource: overrides?.secretSource,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
/** Newest first, every one, the first failure rethrown after the rest ran. */
|
|
22
|
+
async function releaseAll(releases: readonly PortRelease[]): Promise<void> {
|
|
23
|
+
let first: { readonly error: unknown } | undefined;
|
|
24
|
+
for (const release of [...releases].reverse()) {
|
|
25
|
+
try {
|
|
26
|
+
await release();
|
|
27
|
+
} catch (error) {
|
|
28
|
+
first ??= { error };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (first !== undefined) throw first.error;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The queue with `runtime.ts` honoured whole: its boot ports first, then its queue ports
|
|
36
|
+
* (`jobs`, `eventBus`, …) through `startQueue`. `stop()` releases the queue, then the boot ports.
|
|
37
|
+
*/
|
|
38
|
+
export async function startQueueWithBoot(
|
|
39
|
+
services: DevServices,
|
|
40
|
+
overrides: RuntimeOverrides | undefined,
|
|
41
|
+
env: Env,
|
|
42
|
+
schema?: SchemaMode,
|
|
43
|
+
): Promise<RunningQueue> {
|
|
44
|
+
const booted = await installBootPorts(overrides);
|
|
45
|
+
try {
|
|
46
|
+
const queue = await startQueue(services, overrides, env, schema);
|
|
47
|
+
return {
|
|
48
|
+
...queue,
|
|
49
|
+
async stop() {
|
|
50
|
+
try {
|
|
51
|
+
await queue.stop();
|
|
52
|
+
} finally {
|
|
53
|
+
await releaseAll(booted);
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
} catch (error) {
|
|
58
|
+
await releaseAll(booted).catch(() => undefined);
|
|
59
|
+
throw error;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** A command's queue over the app at `root`: its `runtime.ts` read, then `startQueueWithBoot`. */
|
|
64
|
+
export async function openAppQueue(root: string, env: Env): Promise<RunningQueue> {
|
|
65
|
+
return startQueueWithBoot(resolveServices(root, env), await loadAppRuntime(root), env);
|
|
66
|
+
}
|
package/src/runtime-bus.ts
CHANGED
|
@@ -17,8 +17,10 @@
|
|
|
17
17
|
|
|
18
18
|
import type { RealtimeConfig, Role } from '@ultimat3/core';
|
|
19
19
|
import { isUltimateError, logger, registerReadinessCheck } from '@ultimat3/core';
|
|
20
|
+
import { redisUrlSource } from '@ultimat3/core/redis';
|
|
21
|
+
import { installChannelTransport } from '@ultimat3/realtime/adapter';
|
|
20
22
|
import type { BusUse, SelectTransportOptions, Transport } from '@ultimat3/realtime/server';
|
|
21
|
-
import { selectTransport
|
|
23
|
+
import { selectTransport } from '@ultimat3/realtime/server';
|
|
22
24
|
import type { Env } from './runtime-bindings';
|
|
23
25
|
|
|
24
26
|
/**
|
|
@@ -99,17 +101,39 @@ export interface SelectBusInput {
|
|
|
99
101
|
}
|
|
100
102
|
|
|
101
103
|
/**
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
+
* A production boot on the in-process bus, said once. Since v31 nothing refuses it — the
|
|
105
|
+
* `realtime.transport` declaration is gone, and `NATS_URL` alone selects — so a forgotten variable
|
|
106
|
+
* is one replica's worth of fanout behind a load balancer. Warned, never refused: a single-replica
|
|
107
|
+
* deploy is legal, and `X_REALTIME_TOPOLOGY` stays the hard check for a topology that cannot work.
|
|
108
|
+
*/
|
|
109
|
+
function warnInProcessInProduction(input: SelectBusInput, mode: 'embedded' | 'external'): void {
|
|
110
|
+
if (input.env['NODE_ENV'] !== 'production' || mode !== 'embedded') return;
|
|
111
|
+
if (input.override !== undefined) return;
|
|
112
|
+
// With Redis the cache hop rides Redis pub/sub (`runtime-cache-bus.ts`): saying busts stay
|
|
113
|
+
// local would send an operator after a fault that is not there.
|
|
114
|
+
const redis = redisUrlSource(input.env);
|
|
115
|
+
logger.warn('ultimate bus is the in-process bus', {
|
|
116
|
+
cause:
|
|
117
|
+
redis === undefined
|
|
118
|
+
? 'NATS_URL is unset and apps/<app>/runtime.ts supplies no transport, so channel events, live queries and cache invalidations reach this replica only'
|
|
119
|
+
: `NATS_URL is unset and apps/<app>/runtime.ts supplies no transport, so channel events and live queries reach this replica only (cache invalidations ride ${redis.key}: see the cache.broadcast boot line)`,
|
|
120
|
+
fix: 'NATS_URL=nats://<host>:4222 # in the deploy environment of every role; or `transport` in apps/<app>/runtime.ts — leave both unset only for a single-replica deploy',
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Selection is pure — it parses env and constructs, it dials nothing — so nothing is refused for a
|
|
126
|
+
* bus that is merely away until a role that needs it dials (`selectTransport`).
|
|
104
127
|
*/
|
|
105
128
|
export function selectBus(input: SelectBusInput): SelectedBus {
|
|
106
129
|
const use = busUseFor(input.roles, input.realtime);
|
|
107
130
|
const tolerant = input.dev === true && use !== 'publish';
|
|
108
|
-
const selection = selectTransport(input.env,
|
|
131
|
+
const selection = selectTransport(input.env, {
|
|
109
132
|
...(tolerant ? { connectWithinMs: DEV_BUS_WAIT_MS } : {}),
|
|
110
133
|
...input.select,
|
|
111
134
|
use,
|
|
112
135
|
});
|
|
136
|
+
warnInProcessInProduction(input, selection.mode);
|
|
113
137
|
return {
|
|
114
138
|
use,
|
|
115
139
|
tolerant,
|
|
@@ -155,7 +179,7 @@ export function selectBus(input: SelectBusInput): SelectedBus {
|
|
|
155
179
|
// role: the hub is the `sync` role's, so a job or an action reached none, and an
|
|
156
180
|
// events-only channel — the one kind that needs no replicator — could be fed by nothing
|
|
157
181
|
// but a socket.
|
|
158
|
-
started.push(
|
|
182
|
+
started.push(installChannelTransport(transport));
|
|
159
183
|
// Only a transport that can be disconnected gets a check. `NatsTransport.connected` is a
|
|
160
184
|
// synchronous getter over the client's own state, so no probe is needed; the in-process
|
|
161
185
|
// bus has nothing to lose a connection to, and a check that can only answer `true` is a
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Which bus carries this process's cache invalidations to the other replicas — one rule, said once
|
|
2
|
+
// at boot. The fanout transport when it reaches other processes (NATS, or one `runtime.ts`
|
|
3
|
+
// supplied); Redis pub/sub when the transport is the in-process bus and `REDIS_URL` is set (rung
|
|
4
|
+
// 1: roles split, Redis, no NATS); else the in-process bus, which reaches this replica only.
|
|
5
|
+
|
|
6
|
+
import type { InvalidationBus } from '@ultimat3/cache';
|
|
7
|
+
import { redisPubSubAt } from '@ultimat3/cache';
|
|
8
|
+
import { logger } from '@ultimat3/core';
|
|
9
|
+
import { redisUrlSource } from '@ultimat3/core/redis';
|
|
10
|
+
import type { Transport } from '@ultimat3/realtime/server';
|
|
11
|
+
import { InProcessTransport } from '@ultimat3/realtime/server';
|
|
12
|
+
import type { Env } from './runtime-bindings';
|
|
13
|
+
|
|
14
|
+
export interface CacheBusSelection {
|
|
15
|
+
readonly bus: InvalidationBus;
|
|
16
|
+
/** What the boot line says: `redis`, `nats`, `in-process`, or a supplied transport's name. */
|
|
17
|
+
readonly label: string;
|
|
18
|
+
/** The env key that chose Redis, or `transport` — never the URL. */
|
|
19
|
+
readonly source: string;
|
|
20
|
+
/** Closes a bus this selection built. The fanout transport is the boot's to close, not this. */
|
|
21
|
+
release(): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface SelectCacheBusInput {
|
|
25
|
+
readonly env: Env;
|
|
26
|
+
readonly transport: Transport;
|
|
27
|
+
/** The Redis bus for a URL. Default `redisPubSubAt`; a test hands in one on its own server. */
|
|
28
|
+
readonly redisPubSub?: ((url: string) => InvalidationBus) | undefined;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Pure apart from the Redis bus it builds (which dials in the background). A transport that
|
|
33
|
+
* already crosses processes always wins: a second hop beside NATS would deliver every bust twice
|
|
34
|
+
* through two systems that can each be down on their own.
|
|
35
|
+
*/
|
|
36
|
+
export function selectCacheBus(input: SelectCacheBusInput): CacheBusSelection {
|
|
37
|
+
const redis = redisUrlSource(input.env);
|
|
38
|
+
if (input.transport instanceof InProcessTransport && redis !== undefined) {
|
|
39
|
+
const bus = (input.redisPubSub ?? redisPubSubAt)(redis.url);
|
|
40
|
+
return { bus, label: bus.name, source: redis.key, release: () => bus.close() };
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
bus: input.transport,
|
|
44
|
+
label: input.transport.name,
|
|
45
|
+
source: 'transport',
|
|
46
|
+
release: async () => undefined,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** The boot's one line about the hop: a script may parse `bus=` (a fixed vocabulary). */
|
|
51
|
+
export function logCacheBus(selection: CacheBusSelection): void {
|
|
52
|
+
logger.info('cache.broadcast', { bus: selection.label, source: selection.source });
|
|
53
|
+
}
|
package/src/runtime-cache.ts
CHANGED
|
@@ -4,7 +4,13 @@
|
|
|
4
4
|
// and lru unconditionally, redis on `REDIS_URL` and cdn on any real purge driver, so the key was
|
|
5
5
|
// declared, validated at boot, documented, and read by nothing.
|
|
6
6
|
|
|
7
|
-
import type {
|
|
7
|
+
import type {
|
|
8
|
+
CacheTier,
|
|
9
|
+
InvalidationBus,
|
|
10
|
+
InvalidationSubscription,
|
|
11
|
+
PurgeDriver,
|
|
12
|
+
RedisLike,
|
|
13
|
+
} from '@ultimat3/cache';
|
|
8
14
|
import {
|
|
9
15
|
CacheDriverUnavailableError,
|
|
10
16
|
cdnTier,
|
|
@@ -29,8 +35,9 @@ import {
|
|
|
29
35
|
renderThrowable,
|
|
30
36
|
} from '@ultimat3/core';
|
|
31
37
|
import { redisClient, redisUrlSource } from '@ultimat3/core/redis';
|
|
32
|
-
import type { Transport
|
|
38
|
+
import type { Transport } from '@ultimat3/realtime/server';
|
|
33
39
|
import type { Env } from './runtime-bindings';
|
|
40
|
+
import { logCacheBus, selectCacheBus } from './runtime-cache-bus';
|
|
34
41
|
|
|
35
42
|
/**
|
|
36
43
|
* The subject every replica of every app publishes tag invalidations on. One subject and not one
|
|
@@ -63,6 +70,12 @@ export interface CacheTiersOptions {
|
|
|
63
70
|
* a convention to remember. `cacheTiersOf` is what a boot holding the loaded config calls for it.
|
|
64
71
|
*/
|
|
65
72
|
readonly tiers: readonly CacheTierName[];
|
|
73
|
+
/**
|
|
74
|
+
* `runtime.ts`'s `cacheTiers`: each replaces the rung of its own `name` — built from nothing
|
|
75
|
+
* here, so a supplied `redis` tier needs no `REDIS_URL`. A supplied tier `tiers` does not name is
|
|
76
|
+
* logged (`cache.tier.unnamed`) and never registered: the declaration decides the ladder.
|
|
77
|
+
*/
|
|
78
|
+
readonly supplied?: readonly CacheTier[] | undefined;
|
|
66
79
|
/** The wait before re-subscribing after `attempt` failures (1-based). Injected by a test. */
|
|
67
80
|
readonly subscribeRetryMs?: ((attempt: number) => number) | undefined;
|
|
68
81
|
/**
|
|
@@ -72,6 +85,11 @@ export interface CacheTiersOptions {
|
|
|
72
85
|
readonly firstDialGraceMs?: number | undefined;
|
|
73
86
|
/** The client a `redis` rung reads, for the URL `env` names. Default core's `redisClient`. */
|
|
74
87
|
readonly redisClient?: ((url: string) => RedisLike) | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* The invalidation bus over Redis pub/sub, for the URL `env` names — used only when `transport`
|
|
90
|
+
* is the in-process bus (`selectCacheBus`). Default `@ultimat3/cache`'s `redisPubSubAt`.
|
|
91
|
+
*/
|
|
92
|
+
readonly redisPubSub?: ((url: string) => InvalidationBus) | undefined;
|
|
75
93
|
}
|
|
76
94
|
|
|
77
95
|
/**
|
|
@@ -167,6 +185,10 @@ function buildTier(name: CacheTierName, options: CacheTiersOptions): CacheTier {
|
|
|
167
185
|
*/
|
|
168
186
|
function warnUnnamed(options: CacheTiersOptions): void {
|
|
169
187
|
const named = new Set(options.tiers);
|
|
188
|
+
for (const tier of options.supplied ?? []) {
|
|
189
|
+
if (!named.has(tier.name))
|
|
190
|
+
logger.warn('cache.tier.unnamed', { tier: tier.name, source: 'runtime.ts' });
|
|
191
|
+
}
|
|
170
192
|
const redis = redisUrlSource(options.env);
|
|
171
193
|
if (!named.has('redis') && redis !== undefined) {
|
|
172
194
|
logger.warn('cache.tier.unnamed', { tier: 'redis', source: redis.key });
|
|
@@ -201,12 +223,22 @@ export function startCacheTiers(options: CacheTiersOptions): () => Promise<void>
|
|
|
201
223
|
// Nothing installs a read tier beyond these, and that is the point: `invalidateTags` fans out to
|
|
202
224
|
// registered tiers and to nothing else, so a read cache holding entries of its own was a
|
|
203
225
|
// `cache:` query an action's `invalidates` could never bust.
|
|
204
|
-
|
|
226
|
+
// A supplied rung is used as handed over; the last of one name wins, as `registerTier` would.
|
|
227
|
+
const supplied = new Map((options.supplied ?? []).map((tier) => [tier.name, tier] as const));
|
|
228
|
+
const built = options.tiers.map((name) => supplied.get(name) ?? buildTier(name, options));
|
|
205
229
|
for (const tier of built) registerTier(tier);
|
|
206
230
|
warnUnnamed(options);
|
|
231
|
+
// NATS (or a supplied transport) when it crosses processes; Redis pub/sub when the transport is
|
|
232
|
+
// the in-process bus and REDIS_URL is set; else in-process. One rule, one boot line.
|
|
233
|
+
const selected = selectCacheBus({
|
|
234
|
+
env: options.env,
|
|
235
|
+
transport: options.transport,
|
|
236
|
+
redisPubSub: options.redisPubSub,
|
|
237
|
+
});
|
|
238
|
+
logCacheBus(selected);
|
|
239
|
+
const bus = selected.bus;
|
|
207
240
|
|
|
208
|
-
const send = (payload: string): Promise<void> =>
|
|
209
|
-
options.transport.publish(CACHE_INVALIDATE_SUBJECT, payload);
|
|
241
|
+
const send = (payload: string): Promise<void> => bus.publish(CACHE_INVALIDATE_SUBJECT, payload);
|
|
210
242
|
// What the bus refused, kept for its return. A publish with no live connection is refused, not
|
|
211
243
|
// buffered (`NatsTransport`), so without this a bust made during a two-second NATS restart
|
|
212
244
|
// reached no peer at all. De-duplicated — a tag is a fact, not an event — and bounded.
|
|
@@ -311,15 +343,12 @@ export function startCacheTiers(options: CacheTiersOptions): () => Promise<void>
|
|
|
311
343
|
const bootedAt = performance.now();
|
|
312
344
|
/** Whether an operator has been told of this outage — what makes `recovered` worth a line. */
|
|
313
345
|
let warned = false;
|
|
314
|
-
const subscribing = (async (): Promise<
|
|
346
|
+
const subscribing = (async (): Promise<InvalidationSubscription | undefined> => {
|
|
315
347
|
for (let attempt = 1; !stopped; attempt += 1) {
|
|
316
348
|
try {
|
|
317
|
-
const subscription = await
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
void applyBroadcast(payload);
|
|
321
|
-
},
|
|
322
|
-
);
|
|
349
|
+
const subscription = await bus.subscribe(CACHE_INVALIDATE_SUBJECT, (payload: string) => {
|
|
350
|
+
void applyBroadcast(payload);
|
|
351
|
+
});
|
|
323
352
|
subscribed = true;
|
|
324
353
|
if (attempt > 1) {
|
|
325
354
|
// The outage's one closing line, beside the thinned warnings it ends — and only then: a
|
|
@@ -352,7 +381,7 @@ export function startCacheTiers(options: CacheTiersOptions): () => Promise<void>
|
|
|
352
381
|
})();
|
|
353
382
|
// The bus is (back) up. The subscription came back with the connection, so from here this
|
|
354
383
|
// process hears again: drop what it held while deaf, and say what it could not say.
|
|
355
|
-
const offReconnect =
|
|
384
|
+
const offReconnect = bus.onReconnect(() => {
|
|
356
385
|
wake();
|
|
357
386
|
if (subscribed) flushDeaf('cache.bus-reconnect');
|
|
358
387
|
settleQuietly();
|
|
@@ -366,6 +395,7 @@ export function startCacheTiers(options: CacheTiersOptions): () => Promise<void>
|
|
|
366
395
|
released.resolve(undefined);
|
|
367
396
|
(await subscribing)?.unsubscribe();
|
|
368
397
|
resetTiers();
|
|
398
|
+
await selected.release();
|
|
369
399
|
};
|
|
370
400
|
}
|
|
371
401
|
|
|
@@ -119,9 +119,10 @@ const isRedirectMarker = (entry: IsrEntry): boolean => {
|
|
|
119
119
|
* fence was sampled, and the controller refuses to store a render its fence no longer covers — so
|
|
120
120
|
* the marker this producer returns is never published, and never served from the store.
|
|
121
121
|
*/
|
|
122
|
-
function dropPage(isr: IsrController, key: string): void {
|
|
123
|
-
|
|
124
|
-
isr.
|
|
122
|
+
async function dropPage(isr: IsrController, key: string): Promise<void> {
|
|
123
|
+
// Awaited, so the producer returns only once a shared store has dropped it too.
|
|
124
|
+
await isr.store().delete(key);
|
|
125
|
+
await isr.markStale(key);
|
|
125
126
|
}
|
|
126
127
|
|
|
127
128
|
/**
|
|
@@ -181,7 +182,7 @@ export async function isrOutcome(arrived: IsrRequest): Promise<IsrOutcome> {
|
|
|
181
182
|
// Set by THIS request's producer only. On a stale page it runs behind the answer, and when it
|
|
182
183
|
// has already decided by the time `serve` returns, the redirect is still this request's own.
|
|
183
184
|
decided = to;
|
|
184
|
-
dropPage(isr, key);
|
|
185
|
+
await dropPage(isr, key);
|
|
185
186
|
return { html: '', status: to.status };
|
|
186
187
|
}),
|
|
187
188
|
);
|
package/src/runtime-jobs.ts
CHANGED
|
@@ -82,8 +82,8 @@ export function workerConfigOf(config: AppConfig | undefined, env: Env = {}): Wo
|
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
84
|
* The queues a worker serves: the configured ones, then every queue a registered job is enqueued
|
|
85
|
-
* on. The union and not the list, decided 2026-09-23:
|
|
86
|
-
* `
|
|
85
|
+
* on. The union and not the list, decided 2026-09-23: an app configured `['<app>-default']` (what
|
|
86
|
+
* `x new` wrote until 31.0.0) while a `job()` naming no queue lands on `default`, so the list alone
|
|
87
87
|
* would leave every such job queued for ever — the silent direction. `exact` (a Deployment that
|
|
88
88
|
* set `WORKER_QUEUES`) is the list alone: that operator split the queues across Deployments on
|
|
89
89
|
* purpose, and widening one to the rest is what made their grace periods mean nothing (#673).
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// The keys an app's `export const runtime` may carry, held to `RuntimeOverrides` at load: a key it
|
|
2
|
+
// does not declare is a backend the app believes it swapped, and a spread or a non-literal object
|
|
3
|
+
// gets past `satisfies`. Refused by name (`X_CONFIG_INVALID`), never ignored.
|
|
4
|
+
|
|
5
|
+
import { ADAPTER_PORT_NAMES, ConfigInvalidError, renderCauseValue } from '@ultimat3/core';
|
|
6
|
+
import { isWired } from './runtime-ports';
|
|
7
|
+
|
|
8
|
+
/** The fields beside the ports: app extensions, not backends. */
|
|
9
|
+
const EXTENSIONS: ReadonlySet<string> = new Set(['middleware', 'routes']);
|
|
10
|
+
|
|
11
|
+
/** Deleted fields, each with the one line that replaces it. */
|
|
12
|
+
const REMOVED: Readonly<Record<string, string>> = Object.freeze({
|
|
13
|
+
syncAuthenticate:
|
|
14
|
+
'configureAuthenticator(resolve, { credentialTtlMs }) // the sync socket uses the app authenticator; delete runtime.syncAuthenticate',
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const isPendingPort = (key: string): boolean =>
|
|
18
|
+
(ADAPTER_PORT_NAMES as readonly string[]).includes(key) && !isWired(key);
|
|
19
|
+
|
|
20
|
+
/** Throws on the first key `RuntimeOverrides` does not declare. `file` is root-relative. */
|
|
21
|
+
export function assertRuntimeKeys(file: string, runtime: Readonly<Record<string, unknown>>): void {
|
|
22
|
+
for (const key of Object.keys(runtime)) {
|
|
23
|
+
if (isWired(key) || EXTENSIONS.has(key)) continue;
|
|
24
|
+
const named = renderCauseValue(key);
|
|
25
|
+
const replacement = Object.hasOwn(REMOVED, key) ? REMOVED[key] : undefined;
|
|
26
|
+
throw new ConfigInvalidError({
|
|
27
|
+
cause: isPendingPort(key)
|
|
28
|
+
? `${file} sets runtime.${named}, which is not a runtime.ts field yet — the boot cannot install that port`
|
|
29
|
+
: replacement !== undefined
|
|
30
|
+
? `${file} sets runtime.${named}, removed in 31.0.0`
|
|
31
|
+
: `${file} sets runtime.${named}, which RuntimeOverrides does not declare, so no boot would read it`,
|
|
32
|
+
fix:
|
|
33
|
+
replacement ??
|
|
34
|
+
'export const runtime = { /* only RuntimeOverrides fields */ } satisfies RuntimeOverrides; // the type names every field',
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
package/src/runtime-overrides.ts
CHANGED
|
@@ -4,43 +4,113 @@
|
|
|
4
4
|
// its own. This type is the seam that removes the need to, and every field is read exactly once,
|
|
5
5
|
// as the first arm of `overrides?.x ?? <the env-selected default>`.
|
|
6
6
|
|
|
7
|
-
import type {
|
|
8
|
-
import type {
|
|
9
|
-
import type {
|
|
10
|
-
import type {
|
|
11
|
-
import type {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
import type { IdempotencyStore, MeterStore } from '@ultimat3/action/adapter';
|
|
8
|
+
import type { Embedder, Gateway, SemanticCacheFactory } from '@ultimat3/ai/adapter';
|
|
9
|
+
import type { AuthLimiterFactory, AuthServerStore, TotpReplayGuard } from '@ultimat3/auth/adapter';
|
|
10
|
+
import type { CacheTier, PurgeDriver } from '@ultimat3/cache/adapter';
|
|
11
|
+
import type {
|
|
12
|
+
AuditSink,
|
|
13
|
+
ErrorReporter,
|
|
14
|
+
FailureStore,
|
|
15
|
+
SecretSource,
|
|
16
|
+
SleepClock,
|
|
17
|
+
} from '@ultimat3/core/adapter';
|
|
18
|
+
import type { SearchIndex } from '@ultimat3/entity/adapter';
|
|
19
|
+
import type { Middleware, Route } from '@ultimat3/http';
|
|
20
|
+
import type { RateLimitStore } from '@ultimat3/http/adapter';
|
|
21
|
+
import type { OutboxStore } from '@ultimat3/jobs';
|
|
22
|
+
import type { EventBus, JobDriver } from '@ultimat3/jobs/adapter';
|
|
23
|
+
import type { MailDriver } from '@ultimat3/mail/adapter';
|
|
24
|
+
import type { McpConfirmationStore } from '@ultimat3/mcp/adapter';
|
|
25
|
+
import type { NotifyStores, SmsTransport } from '@ultimat3/notify/adapter';
|
|
26
|
+
import type { PushSubscriptionStore } from '@ultimat3/pwa/adapter';
|
|
27
|
+
import type { Transport } from '@ultimat3/realtime/adapter';
|
|
28
|
+
import type { IsrStore } from '@ultimat3/render/adapter';
|
|
29
|
+
import type { ScrapeDriver } from '@ultimat3/scraping/adapter';
|
|
30
|
+
import type { ImageTransformDriver } from '@ultimat3/seo/adapter';
|
|
31
|
+
import type { StorageDriver, UploadScanner } from '@ultimat3/storage/adapter';
|
|
15
32
|
|
|
16
33
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* env switch each one used to be is now the `??` arm of one expression, so there is exactly one
|
|
21
|
-
* answer to "which driver is this process running" (axiom 1). A field nothing consumes is not
|
|
22
|
-
* here — the entity `Driver` in particular, because `@ultimat3/entity` exposes no installer for
|
|
23
|
-
* one (`database(entities, { driver })` is the app's own call), and a slot the boot cannot honour
|
|
24
|
-
* is the class of defect this seam exists to end.
|
|
34
|
+
* One field per `ADAPTER_PORTS` row this boot honours, named by the row's `port`. Every field is
|
|
35
|
+
* read exactly once, as the first arm of `runtime.x ?? <the env default>`; `runtime-ports.ts`
|
|
36
|
+
* binds each to its installer or reader, and a row with no field here is listed there as pending.
|
|
25
37
|
*/
|
|
26
|
-
export interface
|
|
38
|
+
export interface PortValues {
|
|
39
|
+
/** The model gateway every `llm()`/`agent()` call goes through. No default: refused at first call. */
|
|
40
|
+
readonly aiGateway: Gateway;
|
|
41
|
+
/** Where `audit: true` primitives write. No default: an audited primitive is refused without one. */
|
|
42
|
+
readonly auditSink: AuditSink;
|
|
43
|
+
/**
|
|
44
|
+
* Where failed sign-ins are counted — a FACTORY, one limiter per policy, because `defineAuth`
|
|
45
|
+
* declares `maxAttempts`/`windowMs`/`lockoutMs` after this boot. Default `postgresAuthLimiter`.
|
|
46
|
+
*/
|
|
47
|
+
readonly authLimiter: AuthLimiterFactory;
|
|
48
|
+
/**
|
|
49
|
+
* Where `authorizationServer()` keeps clients, codes, grants and tokens when it names no `store`.
|
|
50
|
+
* Default `postgresAuthServerStore` over the app's pool.
|
|
51
|
+
*/
|
|
52
|
+
readonly authServerStore: AuthServerStore;
|
|
53
|
+
/**
|
|
54
|
+
* Rung implementations. `cache.tiers` still NAMES the ladder: a tier here replaces the rung of
|
|
55
|
+
* its own `name` (a `redis` tier needs no `REDIS_URL`), the boot builds every other named rung,
|
|
56
|
+
* and a tier whose name `cache.tiers` does not list is logged (`cache.tier.unnamed`) and unused.
|
|
57
|
+
*/
|
|
58
|
+
readonly cacheTiers: readonly CacheTier[];
|
|
59
|
+
/** The process's clock: every "now" and every wait not handed one. Default `systemClock`. */
|
|
60
|
+
readonly clock: SleepClock;
|
|
61
|
+
/**
|
|
62
|
+
* What the semantic cache keys on. Default `hashEmbedder`: offline and lexical — a near-exact
|
|
63
|
+
* match cache. `remoteEmbedder({ … })` for paraphrase hits.
|
|
64
|
+
*/
|
|
65
|
+
readonly embedder: Embedder;
|
|
66
|
+
/**
|
|
67
|
+
* Where every caught error is reported. `SENTRY_DSN` still adds the boot's transport BESIDE it
|
|
68
|
+
* when this is a local sink (`localErrorSink`), and none when it is the app's own Sentry
|
|
69
|
+
* transport (`sentryTransport`). Default: no reporter but the log line.
|
|
70
|
+
*/
|
|
71
|
+
readonly errorReporter: ErrorReporter;
|
|
72
|
+
/** The durable bus `step.waitForEvent` resumes from. Default `postgresEventBus`. */
|
|
73
|
+
readonly eventBus: EventBus;
|
|
74
|
+
/** Where `failureCapture` keeps a 5xx's bundle, while it is on. Default `postgresFailureStore`. */
|
|
75
|
+
readonly failureStore: FailureStore;
|
|
76
|
+
/**
|
|
77
|
+
* Where `idempotent: true` reservations live. Default `postgresIdempotencyStore`; one whose scope
|
|
78
|
+
* is `'process'` is legal and warned about — a retry on another replica runs twice.
|
|
79
|
+
*/
|
|
80
|
+
readonly idempotencyStore: IdempotencyStore;
|
|
81
|
+
/** The `/media/*` transform. Omitted, `builtinImageDriver` — core's PNG/JPEG/WebP pipeline. */
|
|
82
|
+
readonly images: ImageTransformDriver;
|
|
83
|
+
/**
|
|
84
|
+
* Where regenerated ISR pages live. Omitted, `isrController` keeps a per-process memory
|
|
85
|
+
* store — twelve replicas then hold twelve of them, and a purge tag reaches one twelfth of the
|
|
86
|
+
* fleet.
|
|
87
|
+
*/
|
|
88
|
+
readonly isrStore: IsrStore;
|
|
27
89
|
/**
|
|
28
90
|
* The queue every enqueue AND every claim uses. Installed as the ambient driver too, so
|
|
29
91
|
* `jobDriver()` and the worker cannot disagree — `startRoles` refuses to boot when they do.
|
|
30
92
|
*/
|
|
31
|
-
readonly jobs
|
|
32
|
-
/** Replaces the `S3_ENDPOINT`/embedded-disk decision whole: disks, default disk and all. */
|
|
33
|
-
readonly storage?: Storage;
|
|
93
|
+
readonly jobs: JobDriver;
|
|
34
94
|
/** Replaces the `SMTP_URL` / `RESEND_API_KEY` selection. */
|
|
35
|
-
readonly mail
|
|
95
|
+
readonly mail: MailDriver;
|
|
36
96
|
/**
|
|
37
|
-
*
|
|
38
|
-
* `
|
|
39
|
-
* `rateLimitStore` it was handed.
|
|
97
|
+
* Where `mcpConfirmations()` keeps pending rows when it names no `store`. Default
|
|
98
|
+
* `postgresConfirmationStore` over the app's pool.
|
|
40
99
|
*/
|
|
41
|
-
readonly
|
|
100
|
+
readonly mcpConfirmationStore: McpConfirmationStore;
|
|
101
|
+
/** `meter:` counters. Default `postgresMeterStore`, one row per tenant-day on every replica. */
|
|
102
|
+
readonly meterStore: MeterStore;
|
|
103
|
+
/**
|
|
104
|
+
* A notifier's ledger, preferences, inbox and digest. A missing `ledger` is the boot's
|
|
105
|
+
* `postgresDeliveryLedger` over its pool (`runtime-port-bindings.ts`); the rest default in notify.
|
|
106
|
+
*/
|
|
107
|
+
readonly notifyStores: NotifyStores;
|
|
108
|
+
/** The `x_outbox` store behind `handle.enqueue()`. Default `postgresOutboxStore`. */
|
|
109
|
+
readonly outboxStore: OutboxStore;
|
|
42
110
|
/** Replaces the `CLOUDFLARE_*` / `FASTLY_*` selection behind the `cdn` cache tier. */
|
|
43
|
-
readonly purge
|
|
111
|
+
readonly purge: PurgeDriver;
|
|
112
|
+
/** Where Web Push subscriptions live, while `pwa.vapid` is set. Default the Postgres store. */
|
|
113
|
+
readonly pushSubscriptionStore: PushSubscriptionStore;
|
|
44
114
|
/**
|
|
45
115
|
* Where the HTTP rate limiter keeps its counters. It also DECIDES `rateLimit.scope`: a store
|
|
46
116
|
* that says `'shared'` is a deployment declaring fleet-wide numbers, and `assertRateLimitScope`
|
|
@@ -51,13 +121,60 @@ export interface RuntimeOverrides {
|
|
|
51
121
|
* is `'process'` is legal and warned about: it is every declared limit enforced once per
|
|
52
122
|
* replica, and `docker/helm/values.yaml` runs three.
|
|
53
123
|
*/
|
|
54
|
-
readonly rateLimitStore
|
|
124
|
+
readonly rateLimitStore: RateLimitStore;
|
|
125
|
+
/** The browser a `scrape()` declaring no driver of its own runs on. No default: refused at run. */
|
|
126
|
+
readonly scrapeDriver: ScrapeDriver;
|
|
55
127
|
/**
|
|
56
|
-
* Where
|
|
57
|
-
*
|
|
58
|
-
|
|
128
|
+
* Where full-text search is answered (`searchIndex()`, `reindex`). Default `postgresSearchIndex`:
|
|
129
|
+
* `.searchable()`'s generated `tsvector` over the app's pool. Meilisearch or Typesense is an app's.
|
|
130
|
+
*/
|
|
131
|
+
readonly searchIndex: SearchIndex;
|
|
132
|
+
/**
|
|
133
|
+
* Where the secrets master key comes from. Installed before `app.config.ts` evaluates, so its
|
|
134
|
+
* `installSecrets()` asks this. Default `ULTIMATE_SECRETS_KEY`, then `.secrets.key`.
|
|
135
|
+
*/
|
|
136
|
+
readonly secretSource: SecretSource;
|
|
137
|
+
/**
|
|
138
|
+
* One semantic cache per scope (`llm({ cache: { semantic } })`). Default a `memorySemanticCache`
|
|
139
|
+
* per scope, per process; a pgvector-backed factory in production.
|
|
140
|
+
*/
|
|
141
|
+
readonly semanticCache: SemanticCacheFactory;
|
|
142
|
+
/**
|
|
143
|
+
* The provider `smsChannel()` sends through — Twilio, Vonage, SNS: the app's adapter, proved by
|
|
144
|
+
* `smsTransportConformance`. Default memory in development/test, refused elsewhere.
|
|
145
|
+
*/
|
|
146
|
+
readonly smsTransport: SmsTransport;
|
|
147
|
+
/**
|
|
148
|
+
* The boot's default disk, registered under the driver's own `name`: replaces the
|
|
149
|
+
* `S3_ENDPOINT`/embedded-disk decision. Several disks are the app's `defineStorage()`, which wins.
|
|
150
|
+
*/
|
|
151
|
+
readonly storage: StorageDriver;
|
|
152
|
+
/** Where spent TOTP steps are kept, fleet-wide. Default `postgresTotpReplayGuard`. */
|
|
153
|
+
readonly totpReplay: TotpReplayGuard;
|
|
154
|
+
/**
|
|
155
|
+
* Replaces the `NATS_URL` selection — any `Transport`. Already connected when it arrives, and
|
|
156
|
+
* NOT closed by `stop()`: whoever built it owns its socket.
|
|
157
|
+
*/
|
|
158
|
+
readonly transport: Transport;
|
|
159
|
+
/**
|
|
160
|
+
* Asked by `promoteAttachment` about every attached upload: infected is refused and deleted, no
|
|
161
|
+
* verdict fails closed unless `uploadPolicy({ onScanUnavailable: 'accept' })`. Default: no scan.
|
|
59
162
|
*/
|
|
60
|
-
readonly
|
|
163
|
+
readonly uploadScanner: UploadScanner;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* What a deployment may substitute for a boot decision the environment would otherwise make —
|
|
168
|
+
* the `runtime` export of `apps/<app>/runtime.ts`, the ONE place an app swaps a backend.
|
|
169
|
+
*
|
|
170
|
+
* Every field is OPTIONAL and every field REPLACES the default rather than sitting beside it: the
|
|
171
|
+
* env switch each one used to be is now the `??` arm of one expression, so there is exactly one
|
|
172
|
+
* answer to "which driver is this process running" (axiom 1). A field nothing consumes is not
|
|
173
|
+
* here — the entity `Driver` in particular, because `@ultimat3/entity` exposes no installer for
|
|
174
|
+
* one (`database(entities, { driver })` is the app's own call), and a slot the boot cannot honour
|
|
175
|
+
* is the class of defect this seam exists to end.
|
|
176
|
+
*/
|
|
177
|
+
export interface RuntimeOverrides extends Partial<PortValues> {
|
|
61
178
|
/** Prepended to the pipeline by `httpServer`, which `startRoles` never passed one. */
|
|
62
179
|
readonly middleware?: readonly Middleware[];
|
|
63
180
|
/**
|
|
@@ -69,15 +186,4 @@ export interface RuntimeOverrides {
|
|
|
69
186
|
* answers a document, and a protocol that fixes its own error shape is neither.
|
|
70
187
|
*/
|
|
71
188
|
readonly routes?: readonly Route[];
|
|
72
|
-
/** The `/media/*` transform. Omitted, `builtinImageDriver` — core's PNG/JPEG/WebP pipeline. */
|
|
73
|
-
readonly images?: ImageTransformDriver;
|
|
74
|
-
/**
|
|
75
|
-
* Who is dialling the `sync` node. Omitted, the app's own `configureAuthenticator()` is adapted
|
|
76
|
-
* — and that adapter now carries `expiresAt` and `refresh` of its own (`SYNC_GRANT_TTL_MS`),
|
|
77
|
-
* re-asking the app's resolver with the upgrade's own `cookie`/`authorization`. So this field is
|
|
78
|
-
* no longer the only way to get re-authorization; it is how a deployment states a window the
|
|
79
|
-
* credential itself declares (a token's `exp`), or resolves identity from a header the adapter
|
|
80
|
-
* deliberately does not retain per socket.
|
|
81
|
-
*/
|
|
82
|
-
readonly syncAuthenticate?: SyncAuthenticator;
|
|
83
189
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// The `boot` and `queue` phases' rows of `PORT_BINDINGS`, alone: `startQueue` and the boot helper
|
|
2
|
+
// install exactly these, and they are on `ROLE=migrate`'s and `x jobs`' path — which must not load the AI, auth, mail, notify or scraping
|
|
3
|
+
// adapters the `services` rows import (`serve-graph.test.ts`'s `MIGRATE_CEILING`).
|
|
4
|
+
|
|
5
|
+
import { installIdempotencyStore, installMeterStore } from '@ultimat3/action/adapter';
|
|
6
|
+
import { installClock, installSecretSource } from '@ultimat3/core/adapter';
|
|
7
|
+
import { installEventBus, installJobDriver } from '@ultimat3/jobs/adapter';
|
|
8
|
+
import type { InstalledBinding } from './runtime-ports';
|
|
9
|
+
|
|
10
|
+
export interface QueuePortBindings {
|
|
11
|
+
readonly eventBus: InstalledBinding<'eventBus'>;
|
|
12
|
+
readonly idempotencyStore: InstalledBinding<'idempotencyStore'>;
|
|
13
|
+
readonly jobs: InstalledBinding<'jobs'>;
|
|
14
|
+
readonly meterStore: InstalledBinding<'meterStore'>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const QUEUE_PORT_BINDINGS: QueuePortBindings = {
|
|
18
|
+
eventBus: { phase: 'queue', install: (bus) => installEventBus(bus) },
|
|
19
|
+
idempotencyStore: { phase: 'queue', install: (store) => installIdempotencyStore(store) },
|
|
20
|
+
jobs: { phase: 'queue', install: (driver) => installJobDriver(driver) },
|
|
21
|
+
meterStore: { phase: 'queue', install: (store) => installMeterStore(store) },
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export interface BootPortBindings {
|
|
25
|
+
readonly clock: InstalledBinding<'clock'>;
|
|
26
|
+
readonly secretSource: InstalledBinding<'secretSource'>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The `boot` phase's rows: installed before `app.config.ts` evaluates (its `installSecrets()` asks
|
|
31
|
+
* the secret source), and by every command that opens the queue alone (`runtime-boot-ports.ts`).
|
|
32
|
+
*/
|
|
33
|
+
export const BOOT_PORT_BINDINGS: BootPortBindings = {
|
|
34
|
+
clock: { phase: 'boot', install: (clock) => installClock(clock) },
|
|
35
|
+
secretSource: { phase: 'boot', install: (source) => installSecretSource(source) },
|
|
36
|
+
};
|