@ultimat3/cli 30.9.0 → 31.1.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 +80 -64
- package/README.md +4 -1
- package/package.json +30 -29
- package/src/admin-registration.ts +1 -1
- package/src/affected-base.ts +51 -0
- package/src/affected.ts +34 -11
- 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/ci-log.ts +76 -13
- package/src/cmd-affected-spec.ts +7 -3
- package/src/cmd-affected.ts +91 -77
- package/src/cmd-auth.ts +3 -3
- package/src/cmd-ci.ts +6 -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-pr-spec.ts +1 -1
- package/src/cmd-pr.ts +72 -1
- package/src/cmd-routes.ts +2 -2
- package/src/cmd-secrets-spec.ts +4 -1
- package/src/cmd-shot.ts +14 -262
- package/src/cmd-test-spec.ts +2 -2
- 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-package.ts +38 -0
- package/src/error-codes.ts +28 -40
- 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 +20 -4
- package/src/mcp-host.ts +5 -1
- package/src/mcp-ui-interact.ts +3 -0
- package/src/messages-gate.ts +10 -0
- package/src/new-shapes-generate.ts +1 -1
- package/src/otlp-export.ts +94 -29
- package/src/output.ts +24 -10
- package/src/page-sync.ts +3 -1
- package/src/pr-activity.ts +150 -0
- package/src/pr-bots.ts +109 -0
- package/src/pr-threads.ts +7 -2
- 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/shot-gpu.ts +61 -0
- package/src/shot-route.ts +95 -0
- package/src/shot-run.ts +189 -0
- package/src/shot-verdict.ts +5 -0
- 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/tsconfig-aliases.ts +85 -0
- 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 +162 -0
- package/src/verify-changed.ts +174 -0
- package/src/verify-checks.ts +33 -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/workspace-external-deps.ts +164 -0
- package/src/write-line.ts +21 -6
- package/wiki/Actions.md +2 -2
- package/wiki/Adapters.md +400 -0
- package/wiki/Admin-Dashboard.md +1 -1
- package/wiki/Agents.md +9 -9
- package/wiki/Auth.md +78 -2
- package/wiki/Building-Your-Own-Base.md +1 -1
- package/wiki/CLI-Reference.md +45 -14
- package/wiki/Caching-And-Invalidation.md +17 -5
- package/wiki/Compared.md +8 -2
- package/wiki/Configuration.md +14 -14
- package/wiki/Deployment.md +28 -1
- package/wiki/Entities-And-Migrations.md +47 -1
- package/wiki/FAQ.md +8 -2
- package/wiki/Feature-Flags.md +1 -1
- package/wiki/Home.md +3 -2
- package/wiki/Jobs-And-Workflows.md +107 -6
- package/wiki/Known-Gaps.md +4 -3
- package/wiki/MCP-And-AI.md +18 -4
- package/wiki/Mail.md +14 -5
- package/wiki/Migrations-And-Backfills.md +29 -4
- package/wiki/Money.md +2 -0
- package/wiki/N-Plus-One-Detection.md +24 -22
- package/wiki/Notify.md +28 -4
- package/wiki/Observability.md +121 -15
- package/wiki/Queries-And-Live-Queries.md +2 -2
- package/wiki/Realtime.md +9 -4
- package/wiki/Routes-And-Render-Modes.md +5 -0
- package/wiki/Scraping.md +57 -11
- package/wiki/Shapes.md +2 -2
- package/wiki/Stability.md +7 -5
- package/wiki/Storage-And-Uploads.md +56 -4
- package/wiki/Testing.md +65 -52
- package/wiki/Troubleshooting.md +1 -1
- package/wiki/Tutorial-01-First-App.md +1 -1
- package/wiki/Tutorial-04-Jobs-And-Realtime.md +1 -1
- package/wiki/Tutorial-05-Deploy-Free.md +1 -1
- package/wiki/Tutorial-06-Growing-Up.md +8 -8
- package/wiki/Upgrading.md +136 -5
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// Where this boot honours each `ADAPTER_PORTS` row: its installer and its undo, or the module that
|
|
2
|
+
// reads it as a value. Typed `PortBindings`, so a row core adds is a build error HERE until it is
|
|
3
|
+
// bound.
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
installAuthLimiters,
|
|
7
|
+
installAuthServerStore,
|
|
8
|
+
installTotpReplay,
|
|
9
|
+
} from '@ultimat3/auth/adapter';
|
|
10
|
+
import type { PgExecutor } from '@ultimat3/core';
|
|
11
|
+
import { installAuditSink, installErrorReporter } from '@ultimat3/core/adapter';
|
|
12
|
+
import { installSearchIndex } from '@ultimat3/entity/adapter';
|
|
13
|
+
import { installRateLimitStore } from '@ultimat3/http/adapter';
|
|
14
|
+
import { installMailDriver } from '@ultimat3/mail/adapter';
|
|
15
|
+
import { postgresDeliveryLedger } from '@ultimat3/notify';
|
|
16
|
+
import type { NotifyStores } from '@ultimat3/notify/adapter';
|
|
17
|
+
import { installNotifyStores, installSmsTransport } from '@ultimat3/notify/adapter';
|
|
18
|
+
import { installUploadScanner } from '@ultimat3/storage/adapter';
|
|
19
|
+
import { BOOT_PORT_BINDINGS, QUEUE_PORT_BINDINGS } from './runtime-port-bindings-queue';
|
|
20
|
+
import type { PortBindings } from './runtime-ports';
|
|
21
|
+
|
|
22
|
+
/** Every row, bound. Pure data plus closures: installing happens only in `installPorts`. */
|
|
23
|
+
export const PORT_BINDINGS: PortBindings = {
|
|
24
|
+
aiGateway: {
|
|
25
|
+
phase: 'services',
|
|
26
|
+
// Imported only when supplied: most apps run no model, and no role should load `@ultimat3/ai`.
|
|
27
|
+
install: async (gateway) => (await import('@ultimat3/ai/adapter')).installAiGateway(gateway),
|
|
28
|
+
},
|
|
29
|
+
auditSink: { phase: 'services', install: (sink) => installAuditSink(sink) },
|
|
30
|
+
authLimiter: {
|
|
31
|
+
phase: 'services',
|
|
32
|
+
install: (factory) => installAuthLimiters(factory),
|
|
33
|
+
},
|
|
34
|
+
// Installed only when supplied: unset, auth's own slot answers its env default — Postgres over
|
|
35
|
+
// the ambient pool, the pool this boot installed (`runtime-queue.ts`'s `setDbClient`).
|
|
36
|
+
authServerStore: { phase: 'services', install: (store) => installAuthServerStore(store) },
|
|
37
|
+
cacheTiers: { phase: 'read', at: 'runtime-cache.ts, each replacing the rung of its own name' },
|
|
38
|
+
clock: BOOT_PORT_BINDINGS.clock,
|
|
39
|
+
// Imported only when supplied, for `aiGateway`'s reason.
|
|
40
|
+
embedder: {
|
|
41
|
+
phase: 'services',
|
|
42
|
+
install: async (embedder) => (await import('@ultimat3/ai/adapter')).installAiEmbedder(embedder),
|
|
43
|
+
},
|
|
44
|
+
// Before `loadApp`; `serve-env.ts`'s `configureReporting` later chains its `SENTRY_DSN`
|
|
45
|
+
// transport in a frame above it, so this counts as the app's reporter there.
|
|
46
|
+
errorReporter: { phase: 'services', install: (reporter) => installErrorReporter(reporter) },
|
|
47
|
+
eventBus: QUEUE_PORT_BINDINGS.eventBus,
|
|
48
|
+
failureStore: { phase: 'read', at: 'failure-capture-boot.ts, while failureCapture is on' },
|
|
49
|
+
idempotencyStore: QUEUE_PORT_BINDINGS.idempotencyStore,
|
|
50
|
+
images: { phase: 'read', at: 'serve-web.ts, the /media/* transform' },
|
|
51
|
+
isrStore: { phase: 'read', at: 'serve-web.ts, the ISR controller' },
|
|
52
|
+
jobs: QUEUE_PORT_BINDINGS.jobs,
|
|
53
|
+
mail: {
|
|
54
|
+
phase: 'services',
|
|
55
|
+
install: (driver) => installMailDriver(driver),
|
|
56
|
+
},
|
|
57
|
+
mcpConfirmationStore: {
|
|
58
|
+
phase: 'services',
|
|
59
|
+
// Imported only when supplied, for `aiGateway`'s reason: most roles load no MCP module, and
|
|
60
|
+
// unset, mcp's own slot answers its env default (Postgres over the ambient pool).
|
|
61
|
+
install: async (store) =>
|
|
62
|
+
(await import('@ultimat3/mcp/adapter')).installConfirmationStore(store),
|
|
63
|
+
},
|
|
64
|
+
meterStore: QUEUE_PORT_BINDINGS.meterStore,
|
|
65
|
+
notifyStores: {
|
|
66
|
+
phase: 'services',
|
|
67
|
+
// Always a value: `startServices` fills a missing ledger with Postgres over its pool.
|
|
68
|
+
install: (stores) => installNotifyStores(stores),
|
|
69
|
+
},
|
|
70
|
+
outboxStore: { phase: 'read', at: 'runtime-queue.ts, behind the jobs facade with the jobs port' },
|
|
71
|
+
purge: { phase: 'read', at: 'runtime-cache.ts, the cdn tier' },
|
|
72
|
+
pushSubscriptionStore: { phase: 'read', at: 'runtime-push.ts, while pwa.vapid is set' },
|
|
73
|
+
rateLimitStore: {
|
|
74
|
+
phase: 'services',
|
|
75
|
+
install: (store) => installRateLimitStore(store),
|
|
76
|
+
},
|
|
77
|
+
scrapeDriver: {
|
|
78
|
+
phase: 'services',
|
|
79
|
+
// Imported only when supplied, for `aiGateway`'s reason: a browser driver is a scraping app's.
|
|
80
|
+
install: async (driver) =>
|
|
81
|
+
(await import('@ultimat3/scraping/adapter')).installScrapeDriver(driver),
|
|
82
|
+
},
|
|
83
|
+
// Installed only when supplied: unset, entity's own slot answers `postgresSearchIndex()`.
|
|
84
|
+
searchIndex: { phase: 'services', install: (index) => installSearchIndex(index) },
|
|
85
|
+
secretSource: BOOT_PORT_BINDINGS.secretSource,
|
|
86
|
+
semanticCache: {
|
|
87
|
+
phase: 'services',
|
|
88
|
+
install: async (factory) =>
|
|
89
|
+
(await import('@ultimat3/ai/adapter')).installSemanticCache(factory),
|
|
90
|
+
},
|
|
91
|
+
// Installed only when supplied: unset, notify's own slot answers memory locally, a refusal elsewhere.
|
|
92
|
+
smsTransport: { phase: 'services', install: (transport) => installSmsTransport(transport) },
|
|
93
|
+
storage: { phase: 'read', at: 'runtime-storage-boot.ts, the default disk' },
|
|
94
|
+
totpReplay: {
|
|
95
|
+
phase: 'services',
|
|
96
|
+
install: (guard) => installTotpReplay(() => guard),
|
|
97
|
+
},
|
|
98
|
+
transport: { phase: 'read', at: 'runtime-bus.ts, which installs the channel transport it dials' },
|
|
99
|
+
// Installed only when supplied: unset, storage's slot answers no scanner and nothing is scanned.
|
|
100
|
+
uploadScanner: { phase: 'services', install: (scanner) => installUploadScanner(scanner) },
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* The `notifyStores` value with zero config: a booted app has a database, so a MISSING ledger is
|
|
105
|
+
* Postgres over the boot's pool — an app's own ledger, inbox, preferences and digest are never
|
|
106
|
+
* replaced. `x_notify_deliveries` is applied every boot (`framework-schema.ts`) and swept hourly
|
|
107
|
+
* (`runtime-purge.ts`). Notify's own default (memory in development/test, `X_NOTIFY_STORE_MISSING`
|
|
108
|
+
* elsewhere) stays the net for a process no boot installed into. Here, beside the binding, so the
|
|
109
|
+
* serving graph pays no module for it.
|
|
110
|
+
*/
|
|
111
|
+
export function notifyStoresWithLedger(
|
|
112
|
+
supplied: NotifyStores | undefined,
|
|
113
|
+
executor: PgExecutor,
|
|
114
|
+
): NotifyStores {
|
|
115
|
+
if (supplied?.ledger !== undefined) return supplied;
|
|
116
|
+
return { ...supplied, ledger: postgresDeliveryLedger({ executor }) };
|
|
117
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
// Every `ADAPTER_PORTS` row bound to where this boot honours it, and the ONE install loop over the
|
|
2
|
+
// rows (`installPorts`). `PortBindings` is keyed by `AdapterPortName`, so a row core adds without a
|
|
3
|
+
// binding is a build error (TS2741). Which value fills a slot — `runtime.ts`'s, else the env
|
|
4
|
+
// default — is the caller's one `suppliedOr`.
|
|
5
|
+
|
|
6
|
+
import { ADAPTER_PORT_NAMES, type AdapterPortName } from '@ultimat3/core';
|
|
7
|
+
import type { PortValues } from './runtime-overrides';
|
|
8
|
+
|
|
9
|
+
/** A port this boot fills: the subset of `ADAPTER_PORTS` that is a `RuntimeOverrides` field. */
|
|
10
|
+
export type WiredPort = keyof PortValues;
|
|
11
|
+
|
|
12
|
+
/** A row with no `RuntimeOverrides` field yet — see `PendingBinding`. */
|
|
13
|
+
export type PendingPort = Exclude<AdapterPortName, WiredPort>;
|
|
14
|
+
|
|
15
|
+
/** What an install answers: the undo, run newest first by the boot's own unwind. */
|
|
16
|
+
export type PortRelease = () => void | Promise<void>;
|
|
17
|
+
|
|
18
|
+
/** The values one phase chose — each one `runtime.ts`'s field or the env default, never both. */
|
|
19
|
+
export type ChosenPorts = { readonly [P in WiredPort]?: PortValues[P] | undefined };
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Installed by the loop, in the phase that owns its dependencies: `boot` ports first, before
|
|
23
|
+
* `app.config.ts` evaluates (its `installSecrets()` asks the secret source); `queue` ports by
|
|
24
|
+
* `startQueue` (`x jobs` boots exactly those); `services` ports by `startServices`, before `loadApp`.
|
|
25
|
+
*/
|
|
26
|
+
export interface InstalledBinding<P extends WiredPort> {
|
|
27
|
+
readonly phase: InstallPhase;
|
|
28
|
+
/**
|
|
29
|
+
* May be async: an adapter most apps never swap (`aiGateway`, `scrapeDriver`) is imported only
|
|
30
|
+
* when `runtime.ts` supplies one, so no serving role pays for a package it does not use.
|
|
31
|
+
*/
|
|
32
|
+
readonly install: (value: PortValues[P]) => PortRelease | Promise<PortRelease>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type InstallPhase = 'boot' | 'queue' | 'services';
|
|
36
|
+
|
|
37
|
+
/** Read as a value where it is used, never installed ambiently: `at` names that reader. */
|
|
38
|
+
export interface ReadBinding {
|
|
39
|
+
readonly phase: 'read';
|
|
40
|
+
readonly at: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* A row with no `RuntimeOverrides` field yet, because the package owning it exposes no installer
|
|
45
|
+
* this boot can call. Stated rather than faked: a field nothing reads is the defect this seam
|
|
46
|
+
* exists to end. `X_ADAPTER_PORT_INCOMPLETE` (slice 21 part B) reports it until `owner` ships one.
|
|
47
|
+
*/
|
|
48
|
+
export interface PendingBinding {
|
|
49
|
+
readonly phase: 'pending';
|
|
50
|
+
readonly owner: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export type WiredBindings = { readonly [P in WiredPort]: InstalledBinding<P> | ReadBinding };
|
|
54
|
+
export type PendingBindings = { readonly [P in PendingPort]: PendingBinding };
|
|
55
|
+
/** Complete over `AdapterPortName`: a new row is a missing key, a removed one an excess key. */
|
|
56
|
+
export type PortBindings = WiredBindings & PendingBindings;
|
|
57
|
+
|
|
58
|
+
/** Every `RuntimeOverrides` port names a real row — a stray key is a build error here. */
|
|
59
|
+
const noStrayPorts: [Exclude<WiredPort, AdapterPortName>] extends [never] ? true : never = true;
|
|
60
|
+
void noStrayPorts;
|
|
61
|
+
|
|
62
|
+
/** The wired keys as a value, so the loop can narrow a row's name. Complete by its type. */
|
|
63
|
+
const WIRED: { readonly [P in WiredPort]: true } = {
|
|
64
|
+
aiGateway: true,
|
|
65
|
+
auditSink: true,
|
|
66
|
+
authLimiter: true,
|
|
67
|
+
authServerStore: true,
|
|
68
|
+
cacheTiers: true,
|
|
69
|
+
clock: true,
|
|
70
|
+
embedder: true,
|
|
71
|
+
errorReporter: true,
|
|
72
|
+
eventBus: true,
|
|
73
|
+
failureStore: true,
|
|
74
|
+
idempotencyStore: true,
|
|
75
|
+
images: true,
|
|
76
|
+
isrStore: true,
|
|
77
|
+
jobs: true,
|
|
78
|
+
mail: true,
|
|
79
|
+
mcpConfirmationStore: true,
|
|
80
|
+
meterStore: true,
|
|
81
|
+
notifyStores: true,
|
|
82
|
+
outboxStore: true,
|
|
83
|
+
purge: true,
|
|
84
|
+
pushSubscriptionStore: true,
|
|
85
|
+
rateLimitStore: true,
|
|
86
|
+
scrapeDriver: true,
|
|
87
|
+
searchIndex: true,
|
|
88
|
+
secretSource: true,
|
|
89
|
+
semanticCache: true,
|
|
90
|
+
smsTransport: true,
|
|
91
|
+
storage: true,
|
|
92
|
+
totpReplay: true,
|
|
93
|
+
transport: true,
|
|
94
|
+
uploadScanner: true,
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/** Whether a row is a `RuntimeOverrides` field — the scaffold marks the rest as pending. */
|
|
98
|
+
export const isWired = (port: string): port is WiredPort => Object.hasOwn(WIRED, port);
|
|
99
|
+
|
|
100
|
+
/** Generic so the binding's parameter and the chosen value are the SAME port's type. */
|
|
101
|
+
function installOne<P extends WiredPort>(
|
|
102
|
+
binding: WiredBindings[P],
|
|
103
|
+
port: P,
|
|
104
|
+
phase: InstallPhase,
|
|
105
|
+
chosen: ChosenPorts,
|
|
106
|
+
): PortRelease | Promise<PortRelease> | undefined {
|
|
107
|
+
if (binding.phase !== phase) return undefined;
|
|
108
|
+
const value: PortValues[P] | undefined = chosen[port];
|
|
109
|
+
// Absent: a port this phase builds no default for (`notifyStores`, `auditSink`), so the
|
|
110
|
+
// package's own default stands — which is the env default its row documents.
|
|
111
|
+
return value === undefined ? undefined : binding.install(value);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Install every port `phase` owns, in `ADAPTER_PORTS` order, and answer the releases in that order
|
|
116
|
+
* — the caller's unwind runs them newest first. The ONE place a backend becomes ambient. `bindings`
|
|
117
|
+
* is the full `PORT_BINDINGS`, or one phase's slice where loading the rest would weigh down a light
|
|
118
|
+
* boot (`runtime-port-bindings-queue.ts`).
|
|
119
|
+
*/
|
|
120
|
+
export async function installPorts(
|
|
121
|
+
bindings: { readonly [P in WiredPort]?: WiredBindings[P] },
|
|
122
|
+
phase: InstallPhase,
|
|
123
|
+
chosen: ChosenPorts,
|
|
124
|
+
): Promise<PortRelease[]> {
|
|
125
|
+
const releases: PortRelease[] = [];
|
|
126
|
+
try {
|
|
127
|
+
for (const port of ADAPTER_PORT_NAMES) {
|
|
128
|
+
if (!isWired(port)) continue;
|
|
129
|
+
const binding = bindings[port];
|
|
130
|
+
if (binding === undefined) continue;
|
|
131
|
+
// In order, one at a time: a later port may read an earlier one (the clock before the rest).
|
|
132
|
+
const release = await installOne(binding, port, phase, chosen);
|
|
133
|
+
if (release !== undefined) releases.push(release);
|
|
134
|
+
}
|
|
135
|
+
} catch (error) {
|
|
136
|
+
// A port that would not install (an adapter module that failed to load) must not strand the
|
|
137
|
+
// ones before it: released newest first, each tried, and the install's rejection is the cause.
|
|
138
|
+
for (const release of releases.reverse()) {
|
|
139
|
+
try {
|
|
140
|
+
await release();
|
|
141
|
+
} catch {
|
|
142
|
+
// Cleanup noise never replaces the install failure.
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
throw error;
|
|
146
|
+
}
|
|
147
|
+
return releases;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** A port's value, and the default the boot BUILT for it — `undefined` when `runtime.ts` supplied it. */
|
|
151
|
+
export interface Chosen<T, O extends T> {
|
|
152
|
+
readonly value: T;
|
|
153
|
+
readonly own: O | undefined;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* `runtime.ts`'s value, else the env default — built only when needed, and kept apart so the
|
|
158
|
+
* retention sweep expires the boot's own tables and never a store the app handed over.
|
|
159
|
+
*/
|
|
160
|
+
export function suppliedOr<T, O extends T>(supplied: T | undefined, build: () => O): Chosen<T, O> {
|
|
161
|
+
if (supplied !== undefined) return { value: supplied, own: undefined };
|
|
162
|
+
const own = build();
|
|
163
|
+
return { value: own, own };
|
|
164
|
+
}
|