@ultimat3/cli 31.1.0 → 31.2.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 +1 -1
- package/package.json +29 -29
- package/src/binding-names.ts +124 -0
- package/src/browser-transport.ts +28 -0
- package/src/cmd-doctor.ts +8 -0
- package/src/cmd-exercise.ts +13 -1
- package/src/cmd-upgrade.ts +28 -4
- package/src/doctor-typescript.ts +31 -0
- package/src/error-codes.ts +2 -0
- package/src/mcp-errors-shot.ts +49 -0
- package/src/mcp-errors.ts +5 -41
- package/src/measure-scope.ts +17 -4
- package/src/messages-upgrade.ts +2 -0
- package/src/offline-ports.ts +106 -0
- package/src/prerender.ts +2 -2
- package/src/runtime-storage-boot.ts +41 -7
- package/src/templates/scaffold-repo.ts +2 -1
- package/src/templates/sign-in-oidc.ts +24 -9
- package/src/transport-calls.ts +7 -3
- package/src/transport-values.ts +59 -0
- package/src/typescript-floor.ts +83 -0
- package/src/upgrade-report.ts +8 -1
- package/wiki/Upgrading.md +17 -4
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// `apps/<app>/runtime.ts` for the two paths that run the app's primitives with no server — `x build`'s
|
|
2
|
+
// renders and `x exercise`'s pass — read and installed by the boot's own reader and loop, with
|
|
3
|
+
// every port first decided by `OFFLINE_PORTS`: a memory double, or the package default.
|
|
4
|
+
|
|
5
|
+
// Why a table and not the app's values: neither path may reach a deployment's backend. A port with
|
|
6
|
+
// no row is a build error (TS2741 on `OfflinePortTable`).
|
|
7
|
+
|
|
8
|
+
import { memoryAuditSink } from '@ultimat3/action';
|
|
9
|
+
import { loadAppRuntime } from './app-runtime';
|
|
10
|
+
import type { PortValues, RuntimeOverrides } from './runtime-overrides';
|
|
11
|
+
import { PORT_BINDINGS } from './runtime-port-bindings';
|
|
12
|
+
import type { ChosenPorts, WiredPort } from './runtime-ports';
|
|
13
|
+
import { installPorts } from './runtime-ports';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* What an offline path does with a port `runtime.ts` supplied. `double`: install this stand-in in
|
|
17
|
+
* the app's place — the port's presence is what the primitive asks, and the app's own backend may
|
|
18
|
+
* be production's. `default`: install nothing, so the package's own default answers; `why` says so.
|
|
19
|
+
*/
|
|
20
|
+
export type OfflineChoice<P extends WiredPort> =
|
|
21
|
+
| { readonly use: 'double'; readonly double: () => PortValues[P] }
|
|
22
|
+
| { readonly use: 'default'; readonly why: string };
|
|
23
|
+
|
|
24
|
+
export type OfflinePortTable = { readonly [P in WiredPort]: OfflineChoice<P> };
|
|
25
|
+
|
|
26
|
+
const remote = (why: string) => ({ use: 'default', why }) as const;
|
|
27
|
+
const NETWORK = remote('a remote backend; the package default (memory or a refusal) answers');
|
|
28
|
+
const POOL = remote('Postgres over the ambient pool by default: the scratch or measure database');
|
|
29
|
+
const BOOT = remote('a boot-phase port; the offline paths keep the process their command set up');
|
|
30
|
+
const SERVED = remote('read by the serving boot only; no request is served offline');
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* One row per wired port. Only `services`-phase ports can be doubles: `installPorts` installs that
|
|
34
|
+
* phase alone (`offline-ports.test.ts` holds it).
|
|
35
|
+
*/
|
|
36
|
+
export const OFFLINE_PORTS: OfflinePortTable = {
|
|
37
|
+
aiGateway: NETWORK,
|
|
38
|
+
// Its presence is the contract: `audit: true` is refused without one (`X_AUDIT_SINK_MISSING`), so
|
|
39
|
+
// an app that declared one runs; where the records go is the deployment's, never a build's.
|
|
40
|
+
auditSink: { use: 'double', double: () => memoryAuditSink() },
|
|
41
|
+
authLimiter: POOL,
|
|
42
|
+
authServerStore: POOL,
|
|
43
|
+
cacheTiers: SERVED,
|
|
44
|
+
clock: BOOT,
|
|
45
|
+
embedder: NETWORK,
|
|
46
|
+
errorReporter: remote('an offline failure is the command`s finding, never a production report'),
|
|
47
|
+
eventBus: POOL,
|
|
48
|
+
failureStore: SERVED,
|
|
49
|
+
idempotencyStore: POOL,
|
|
50
|
+
images: SERVED,
|
|
51
|
+
isrStore: SERVED,
|
|
52
|
+
jobs: POOL,
|
|
53
|
+
mail: NETWORK,
|
|
54
|
+
mcpConfirmationStore: POOL,
|
|
55
|
+
meterStore: POOL,
|
|
56
|
+
notifyStores: POOL,
|
|
57
|
+
outboxStore: POOL,
|
|
58
|
+
purge: NETWORK,
|
|
59
|
+
pushSubscriptionStore: POOL,
|
|
60
|
+
rateLimitStore: POOL,
|
|
61
|
+
scrapeDriver: NETWORK,
|
|
62
|
+
searchIndex: POOL,
|
|
63
|
+
secretSource: BOOT,
|
|
64
|
+
semanticCache: NETWORK,
|
|
65
|
+
smsTransport: NETWORK,
|
|
66
|
+
storage: remote('`x exercise` stands in a memory disk (`exercise-services.ts`)'),
|
|
67
|
+
totpReplay: POOL,
|
|
68
|
+
transport: NETWORK,
|
|
69
|
+
uploadScanner: NETWORK,
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/** The doubles for the ports `runtime` supplied; an absent port stays absent, as at a real boot. */
|
|
73
|
+
export function offlineChosen(
|
|
74
|
+
runtime: RuntimeOverrides | undefined,
|
|
75
|
+
table: OfflinePortTable = OFFLINE_PORTS,
|
|
76
|
+
): ChosenPorts {
|
|
77
|
+
const chosen: { [P in WiredPort]?: PortValues[P] } = {};
|
|
78
|
+
const pick = <P extends WiredPort>(port: P): void => {
|
|
79
|
+
const choice: OfflineChoice<P> = table[port];
|
|
80
|
+
if (choice.use === 'double' && runtime?.[port] !== undefined) chosen[port] = choice.double();
|
|
81
|
+
};
|
|
82
|
+
for (const port of Object.keys(table) as WiredPort[]) pick(port);
|
|
83
|
+
return chosen;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Install the offline ports for the app at `root`; answers the release, newest first. */
|
|
87
|
+
export async function installOfflinePorts(root: string): Promise<() => Promise<void>> {
|
|
88
|
+
const releases = await installPorts(
|
|
89
|
+
PORT_BINDINGS,
|
|
90
|
+
'services',
|
|
91
|
+
offlineChosen(await loadAppRuntime(root)),
|
|
92
|
+
);
|
|
93
|
+
return async () => {
|
|
94
|
+
for (const release of releases.toReversed()) await release();
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** `work` with the offline ports installed, released however it ends. */
|
|
99
|
+
export async function withOfflinePorts<T>(root: string, work: () => Promise<T>): Promise<T> {
|
|
100
|
+
const release = await installOfflinePorts(root);
|
|
101
|
+
try {
|
|
102
|
+
return await work();
|
|
103
|
+
} finally {
|
|
104
|
+
await release();
|
|
105
|
+
}
|
|
106
|
+
}
|
package/src/prerender.ts
CHANGED
|
@@ -265,7 +265,7 @@ export async function prerenderSite(options: PrerenderOptions): Promise<Prerende
|
|
|
265
265
|
// and no server is listening during a build. `renderStatic` keeps `ctx`: its output is a
|
|
266
266
|
// published file, and a `site/` load a policy refuses must fail the build, never render another
|
|
267
267
|
// actor's rows into it. `published` authenticates nobody: sitemap and llms.txt reads run in it.
|
|
268
|
-
const measure = await measureScope({ origin, buildId });
|
|
268
|
+
const measure = await measureScope({ origin, buildId, root: options.root });
|
|
269
269
|
const published = publicScope({ origin, buildId });
|
|
270
270
|
// Started on the first route that needs weighing, and released however the loop ends.
|
|
271
271
|
const database = measureDatabase(options.root);
|
|
@@ -436,7 +436,7 @@ export async function prerenderSite(options: PrerenderOptions): Promise<Prerende
|
|
|
436
436
|
}));
|
|
437
437
|
} finally {
|
|
438
438
|
capture.close();
|
|
439
|
-
await database.close();
|
|
439
|
+
await Promise.all([database.close(), measure.close()]);
|
|
440
440
|
}
|
|
441
441
|
// The variants and cards the exported documents name, before the worker precaches them.
|
|
442
442
|
await capture.write(pages);
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
// Single responsibility: the storage disk a boot installs — s3 when `S3_ENDPOINT` names one, the
|
|
2
|
-
// embedded local disk otherwise
|
|
3
|
-
// rather than after it. Split from `runtime-services.ts
|
|
2
|
+
// embedded local disk otherwise, NONE when the app already declared its own — and the two refusals
|
|
3
|
+
// that must come before the first upload rather than after it. Split from `runtime-services.ts`.
|
|
4
4
|
|
|
5
5
|
// why: Bun has no `mkdir`; the embedded root must exist before the disk is handed out.
|
|
6
6
|
import { mkdirSync } from 'node:fs';
|
|
7
7
|
import { isLocal, renderThrowable, resolveEnvironment } from '@ultimat3/core';
|
|
8
8
|
import { configuredHttp, defineHttpConfig } from '@ultimat3/http';
|
|
9
|
-
import type { Storage } from '@ultimat3/storage';
|
|
10
|
-
import {
|
|
9
|
+
import type { Storage, StorageConfig } from '@ultimat3/storage';
|
|
10
|
+
import {
|
|
11
|
+
definedStorage,
|
|
12
|
+
defineStorage,
|
|
13
|
+
localDriver,
|
|
14
|
+
s3Driver,
|
|
15
|
+
usesDevStorageSecret,
|
|
16
|
+
} from '@ultimat3/storage';
|
|
11
17
|
import type { StorageDriver } from '@ultimat3/storage/adapter';
|
|
12
18
|
import { LocalDiskUnsafeError, StorageUnwritableError } from './errors';
|
|
13
19
|
import type { DevServices, Env } from './runtime-bindings';
|
|
@@ -15,6 +21,30 @@ import { s3PathStyleOf } from './runtime-s3-path-style';
|
|
|
15
21
|
|
|
16
22
|
const FILE_SCHEME = 'file://';
|
|
17
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Every registry a boot in this process installed. `definedStorage()` holding one of these is a
|
|
26
|
+
* previous boot's default (a second `startServices` in one process), replaced; holding anything
|
|
27
|
+
* else is the app's own `defineStorage()`, kept.
|
|
28
|
+
*/
|
|
29
|
+
const bootInstalled = new WeakSet<Storage>();
|
|
30
|
+
|
|
31
|
+
function bootDefine(config: StorageConfig): Storage {
|
|
32
|
+
const installed = defineStorage(config);
|
|
33
|
+
bootInstalled.add(installed);
|
|
34
|
+
return installed;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The registry an app module declared before this boot ran, or `undefined`. `runtime.ts` is
|
|
39
|
+
* imported before `startServices`, and an app module it reaches that calls
|
|
40
|
+
* `defineStorage({ disks: { uploads, evidence } })` has already run: the boot's one-disk
|
|
41
|
+
* `defineStorage` replaced it, and every disk but the boot's was `X_STORAGE_DISK_UNKNOWN`.
|
|
42
|
+
*/
|
|
43
|
+
function appDeclared(): Storage | undefined {
|
|
44
|
+
const current = definedStorage();
|
|
45
|
+
return current === undefined || bootInstalled.has(current) ? undefined : current;
|
|
46
|
+
}
|
|
47
|
+
|
|
18
48
|
/**
|
|
19
49
|
* The most one request to this server carries — `http.maxRequestBodyBytes` as the server resolves
|
|
20
50
|
* it, read at each signing because the boot builds its disk before the app's `configureHttp` runs.
|
|
@@ -39,11 +69,15 @@ export const servedRequestCeiling = (): number =>
|
|
|
39
69
|
* to run a container, so this reports what to do instead of what went wrong.
|
|
40
70
|
*/
|
|
41
71
|
export function startStorage(services: DevServices, env: Env, override?: StorageDriver): Storage {
|
|
72
|
+
// Before every arm, the override included: "several disks are the app's `defineStorage()`, which
|
|
73
|
+
// wins" (`PortValues.storage`). The app's disks carry their own refusals (`localDriver`'s).
|
|
74
|
+
const declared = appDeclared();
|
|
75
|
+
if (declared !== undefined) return declared;
|
|
42
76
|
// First arm, not a branch beside the two below: `runtime.ts` handing the boot a driver has
|
|
43
77
|
// already answered "which disk", and re-deriving one from `S3_ENDPOINT` would be a second answer.
|
|
44
78
|
// Registered under the driver's own name — its signed URLs hang off that key (`defineStorage`).
|
|
45
79
|
if (override !== undefined) {
|
|
46
|
-
return
|
|
80
|
+
return bootDefine({ disks: { [override.name]: override }, default: override.name });
|
|
47
81
|
}
|
|
48
82
|
const binding = services.storage;
|
|
49
83
|
|
|
@@ -55,7 +89,7 @@ export function startStorage(services: DevServices, env: Env, override?: Storage
|
|
|
55
89
|
'set S3_BUCKET to the bucket name, or unset S3_ENDPOINT to use the embedded disk',
|
|
56
90
|
);
|
|
57
91
|
}
|
|
58
|
-
return
|
|
92
|
+
return bootDefine({
|
|
59
93
|
disks: {
|
|
60
94
|
object: s3Driver({
|
|
61
95
|
bucket,
|
|
@@ -107,5 +141,5 @@ export function startStorage(services: DevServices, env: Env, override?: Storage
|
|
|
107
141
|
// `maxRequestBytes`: a signed PUT lands on THIS server, so a grant it could never accept in one
|
|
108
142
|
// request is refused at signing, naming the multipart grant.
|
|
109
143
|
const disk = localDriver({ root, env, maxRequestBytes: servedRequestCeiling });
|
|
110
|
-
return
|
|
144
|
+
return bootDefine({ disks: { local: disk }, default: 'local' });
|
|
111
145
|
}
|
|
@@ -38,8 +38,9 @@ const BIOME_VERSION = '2.6.3';
|
|
|
38
38
|
* constant and TypeScript's was a literal buried in a dependency block, so the framework moved to
|
|
39
39
|
* 7.x and every `x new` kept scaffolding `^6.0.3`. `scaffold-repo.test.ts` now pins this against
|
|
40
40
|
* the repo's own root `package.json`, so the next bump cannot leave the scaffold behind in silence.
|
|
41
|
+
* Exported for `typescript-floor.ts`: `x upgrade` and `x doctor` hold an EXISTING app to it.
|
|
41
42
|
*/
|
|
42
|
-
const TYPESCRIPT_VERSION = '^7.0.2';
|
|
43
|
+
export const TYPESCRIPT_VERSION = '^7.0.2';
|
|
43
44
|
|
|
44
45
|
/**
|
|
45
46
|
* The Solid runtime every island and `@ultimat3/ui` component renders with, exact for the reason
|
|
@@ -46,6 +46,7 @@ import {
|
|
|
46
46
|
defineAuth,
|
|
47
47
|
discoverOAuthProvider,
|
|
48
48
|
hasOAuthProvider,
|
|
49
|
+
OAUTH_CALLBACK_ROUTE_PATH,
|
|
49
50
|
type OAuthLoginRoutes,
|
|
50
51
|
oauthLogin,
|
|
51
52
|
oauthStartPath,
|
|
@@ -58,6 +59,13 @@ export const OIDC_PROVIDER = '${provider}';
|
|
|
58
59
|
export const OIDC_ISSUER_ENV = '${oidcEnvPrefix(provider)}_ISSUER';
|
|
59
60
|
/** Where the sign-in page sends a browser: the start leg, \`${oauthStartPath(provider)}\`. */
|
|
60
61
|
export const OIDC_START_PATH = oauthStartPath(OIDC_PROVIDER);
|
|
62
|
+
/**
|
|
63
|
+
* The callback leg's mount AND the \`redirect_uri\` the issuer must have registered: one value,
|
|
64
|
+
* handed to \`oauthLogin({ callbackPath })\` below and mounted by \`sign-in-routes.ts\`. The
|
|
65
|
+
* framework's default; set it (e.g. \`'/auth/oauth/:provider/callback'\`) to keep a URI an IdP
|
|
66
|
+
* already holds, and both move together.
|
|
67
|
+
*/
|
|
68
|
+
export const OIDC_CALLBACK_PATH: string = OAUTH_CALLBACK_ROUTE_PATH;
|
|
61
69
|
|
|
62
70
|
type Env = Readonly<Record<string, string | undefined>>;
|
|
63
71
|
|
|
@@ -77,7 +85,10 @@ export const oidcLegs = (env: Env = process.env): Promise<OAuthLoginRoutes> => {
|
|
|
77
85
|
if (!hasOAuthProvider(OIDC_PROVIDER)) {
|
|
78
86
|
registerOAuthProvider(await discoverOAuthProvider({ id: OIDC_PROVIDER, issuer }));
|
|
79
87
|
}
|
|
80
|
-
return oauthLogin(signInAuth(), {
|
|
88
|
+
return oauthLogin(signInAuth(), {
|
|
89
|
+
successPath: AFTER_SIGN_IN,
|
|
90
|
+
callbackPath: OIDC_CALLBACK_PATH,
|
|
91
|
+
});
|
|
81
92
|
})().catch((error: unknown) => {
|
|
82
93
|
legs = undefined;
|
|
83
94
|
throw error;
|
|
@@ -111,10 +122,12 @@ unitTest('a discovery that fails is refused, and the next sign-in tries again',
|
|
|
111
122
|
|
|
112
123
|
const routesSource =
|
|
113
124
|
(): string => `// The two OIDC legs as plain HTTP routes — \`runtime.ts\` hands them to both boots. Plain routes,
|
|
114
|
-
// not actions: the callback is a redirect protocol whose shape the provider fixes.
|
|
115
|
-
|
|
125
|
+
// not actions: the callback is a redirect protocol whose shape the provider fixes. The callback is
|
|
126
|
+
// mounted at \`OIDC_CALLBACK_PATH\` — the \`callbackPath\` \`oauthLogin\` was handed, so its
|
|
127
|
+
// \`callback.path\` — never at a constant of its own: the mount and the \`redirect_uri\` move together.
|
|
128
|
+
import { OAUTH_START_ROUTE_PATH } from '@ultimat3/auth';
|
|
116
129
|
import type { Route } from '@ultimat3/http';
|
|
117
|
-
import { oidcLegs } from './oidc';
|
|
130
|
+
import { OIDC_CALLBACK_PATH, oidcLegs } from './oidc';
|
|
118
131
|
|
|
119
132
|
const leg = (name: 'start' | 'callback', path: string): Route => ({
|
|
120
133
|
method: 'GET',
|
|
@@ -126,20 +139,22 @@ const leg = (name: 'start' | 'callback', path: string): Route => ({
|
|
|
126
139
|
|
|
127
140
|
export const signInRoutes: readonly Route[] = [
|
|
128
141
|
leg('start', OAUTH_START_ROUTE_PATH),
|
|
129
|
-
leg('callback',
|
|
142
|
+
leg('callback', OIDC_CALLBACK_PATH),
|
|
130
143
|
];
|
|
131
144
|
`;
|
|
132
145
|
|
|
133
146
|
const routesTest =
|
|
134
|
-
(): string => `// Both legs are mounted, public
|
|
135
|
-
|
|
147
|
+
(): string => `// Both legs are mounted, public: the start leg at the framework's path, the callback at the one
|
|
148
|
+
// \`oauthLogin\` is handed as \`callbackPath\` — so the mount is the \`redirect_uri\` the IdP holds.
|
|
149
|
+
import { OAUTH_START_ROUTE_PATH } from '@ultimat3/auth';
|
|
136
150
|
import { expect, unitTest } from '@ultimat3/testing';
|
|
151
|
+
import { OIDC_CALLBACK_PATH } from './oidc';
|
|
137
152
|
import { signInRoutes } from './sign-in-routes';
|
|
138
153
|
|
|
139
|
-
unitTest('the start and callback legs are public GET routes at the
|
|
154
|
+
unitTest('the start and callback legs are public GET routes at the paths oauthLogin serves', () => {
|
|
140
155
|
expect(signInRoutes.map((route) => [route.method, route.path, route.meta.auth])).toEqual([
|
|
141
156
|
['GET', OAUTH_START_ROUTE_PATH, 'public'],
|
|
142
|
-
['GET',
|
|
157
|
+
['GET', OIDC_CALLBACK_PATH, 'public'],
|
|
143
158
|
]);
|
|
144
159
|
});
|
|
145
160
|
`;
|
package/src/transport-calls.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// rule has to leave alone is a fixture string. Which file may hold which shape is the caller's.
|
|
4
4
|
|
|
5
5
|
import { maskLiterals } from '@ultimat3/core';
|
|
6
|
+
import { destructuredNames } from './binding-names';
|
|
6
7
|
import { lineIndex } from './ts-scan';
|
|
7
8
|
|
|
8
9
|
export type TransportShape = 'fetch' | 'websocket' | 'xhr' | 'eventsource';
|
|
@@ -30,7 +31,7 @@ const FETCH = new RegExp(String.raw`(?<![\w$.])(${GLOBAL}?)fetch\s*\(`, 'g');
|
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
33
|
* Whether the file binds `fetch` itself — a `const`/`let`/`var`/`function`, an import, a
|
|
33
|
-
*
|
|
34
|
+
* destructuring that binds that NAME (`binding-names.ts`) or a parameter — which makes a BARE `fetch(` its own function, not the
|
|
34
35
|
* page's. `packages/action/src/idempotency-postgres.ts` calls a local `fetch(key)`. Per file, not
|
|
35
36
|
* per scope: a floor, and the one direction it errs is silence on a file that shadows the global
|
|
36
37
|
* AND calls it bare. `globalThis.fetch(` is reported regardless.
|
|
@@ -38,8 +39,11 @@ const FETCH = new RegExp(String.raw`(?<![\w$.])(${GLOBAL}?)fetch\s*\(`, 'g');
|
|
|
38
39
|
export function bindsFetch(code: string): boolean {
|
|
39
40
|
return (
|
|
40
41
|
/\b(?:const|let|var|function)\s+fetch\b/.test(code) ||
|
|
41
|
-
|
|
42
|
-
/\
|
|
42
|
+
// `import { fetch }` and `import { f as fetch }` bind it; `import { fetch as f }` binds `f`.
|
|
43
|
+
/\bimport\s+[^;]*(?<!\bas\s+)\bfetch\b(?!\s+as\b)[^;]*\bfrom\b/.test(code) ||
|
|
44
|
+
/\bimport\s+[^;]*\bas\s+fetch\b[^;]*\bfrom\b/.test(code) ||
|
|
45
|
+
// By the NAME a pattern binds: `{ fetch: f }` reads the property and binds `f`.
|
|
46
|
+
destructuredNames(code).has('fetch') ||
|
|
43
47
|
/\(\s*(?:[\w$]+\s*(?::[^,()]+)?,\s*)*fetch\s*[?:,)=][^()]*\)\s*(?::[^={;]+)?(?:=>|\{)/.test(
|
|
44
48
|
code,
|
|
45
49
|
)
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// The global `fetch` handed on as a VALUE in one file's text — `rpc({ fetch })`, `fetch: fetch`,
|
|
2
|
+
// `const f = window.fetch`, `make(globalThis.fetch)` — the bypass `transportCalls` cannot see: the
|
|
3
|
+
// call happens in the module it was passed to, as `options.fetch(url)`, a property no rule reads.
|
|
4
|
+
// Pure, beside `transport-calls.ts`; the caller decides which file may hold it.
|
|
5
|
+
|
|
6
|
+
import { maskLiterals } from '@ultimat3/core';
|
|
7
|
+
import type { TransportCall } from './transport-calls';
|
|
8
|
+
import { bindsFetch } from './transport-calls';
|
|
9
|
+
import { lineIndex } from './ts-scan';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* `fetch` not after `.`/a word char (a property on another object, `prefetch`), optionally behind
|
|
13
|
+
* the global object, not followed by a word char (`fetchUser`) — and never a call, which is
|
|
14
|
+
* `transportCalls`' finding already.
|
|
15
|
+
*/
|
|
16
|
+
const VALUE =
|
|
17
|
+
/(?<![\w$.])((?:(?:globalThis|window|self)\s*\.\s*)?)fetch(?![\w$])(?!\s*(?:\?\.\s*)?\()/g;
|
|
18
|
+
|
|
19
|
+
/** Every blank from `lastIndex` on, sticky: the scan stops at the next token, never the file end. */
|
|
20
|
+
const BLANK = /\s*/y;
|
|
21
|
+
|
|
22
|
+
/** The last non-blank character before `index`, or `''`. */
|
|
23
|
+
function before(masked: string, index: number): string {
|
|
24
|
+
for (let at = index - 1; at >= 0; at -= 1) {
|
|
25
|
+
const char = masked[at] ?? '';
|
|
26
|
+
if (!/\s/.test(char)) return char;
|
|
27
|
+
}
|
|
28
|
+
return '';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Where the name sits is no value: a type, an object/interface key, an assignment target. */
|
|
32
|
+
function isNotAValue(masked: string, start: number, end: number): boolean {
|
|
33
|
+
// `typeof fetch`, `typeof globalThis.fetch` — a type position (or a feature probe, no request).
|
|
34
|
+
if (/\btypeof\s*$/.test(masked.slice(Math.max(0, start - 12), start))) return true;
|
|
35
|
+
// Through every blank: masking turned comments into spaces, so `fetch /* c */ :` is a key too.
|
|
36
|
+
BLANK.lastIndex = end;
|
|
37
|
+
BLANK.test(masked);
|
|
38
|
+
const after = masked.slice(BLANK.lastIndex, BLANK.lastIndex + 3);
|
|
39
|
+
// `{ fetch: impl }`, `fetch?: Fn` — a key; `a ? fetch : b` is the ternary's value.
|
|
40
|
+
if (/^\??\s*:(?!:)/.test(after) && before(masked, start) !== '?') return true;
|
|
41
|
+
// `window.fetch = wrapped`, `<C fetch={…}>` — the name is written to, not read.
|
|
42
|
+
return /^=(?![=>])/.test(after);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function fetchValues(source: string): readonly TransportCall[] {
|
|
46
|
+
if (!source.includes('fetch')) return [];
|
|
47
|
+
// Comments and strings blanked, offsets kept: `'fetch'` in a message is not the global.
|
|
48
|
+
const masked = maskLiterals(source);
|
|
49
|
+
const lineAt = lineIndex(masked);
|
|
50
|
+
const shadowed = bindsFetch(masked);
|
|
51
|
+
const values: TransportCall[] = [];
|
|
52
|
+
for (const found of masked.matchAll(VALUE)) {
|
|
53
|
+
const global = (found[1] ?? '').replace(/\s/g, '');
|
|
54
|
+
if (global === '' && shadowed) continue;
|
|
55
|
+
if (isNotAValue(masked, found.index, found.index + found[0].length)) continue;
|
|
56
|
+
values.push({ shape: 'fetch', line: lineAt(found.index), spelled: `${global}fetch` });
|
|
57
|
+
}
|
|
58
|
+
return values;
|
|
59
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// The TypeScript an EXISTING app declares, held to the one `x new` scaffolds (`TYPESCRIPT_VERSION`).
|
|
2
|
+
// `@ultimat3/*` ships source and `.d.ts` checked by that compiler: an app a major behind is red on
|
|
3
|
+
// the framework's own files (TS2769 in `cdp-shot-keys.ts` under 6.0.3), whatever its own code says.
|
|
4
|
+
// Pure over manifest text; `x upgrade` and `x doctor` each report what it returns.
|
|
5
|
+
|
|
6
|
+
import { quoteArg } from './shell-quote';
|
|
7
|
+
import { TYPESCRIPT_VERSION } from './templates/scaffold-repo';
|
|
8
|
+
|
|
9
|
+
export interface TypescriptLag {
|
|
10
|
+
/** The manifest declaring it, relative to the app root, POSIX. */
|
|
11
|
+
readonly file: string;
|
|
12
|
+
readonly field: 'dependencies' | 'devDependencies';
|
|
13
|
+
readonly from: string;
|
|
14
|
+
readonly to: string;
|
|
15
|
+
/** The one command that moves it, run from the app root. */
|
|
16
|
+
readonly fix: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** The floor a plain range admits: `^6.0.3`, `~6.0`, `>=5.4`, `6.0.3` → its numbers; else none. */
|
|
20
|
+
const PLAIN = /^\s*(?:\^|~|>=|=)?\s*v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:-[\w.]+)?\s*$/;
|
|
21
|
+
|
|
22
|
+
export function lowerBound(range: string): readonly number[] | undefined {
|
|
23
|
+
const match = PLAIN.exec(range);
|
|
24
|
+
if (match === null) return undefined;
|
|
25
|
+
return [match[1], match[2], match[3]].map((part) => Number(part ?? '0'));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Strictly below, part by part. A prerelease of the floor itself reads as the floor. */
|
|
29
|
+
export function isBelow(held: readonly number[], floor: readonly number[]): boolean {
|
|
30
|
+
for (let at = 0; at < floor.length; at += 1) {
|
|
31
|
+
const left = held[at] ?? 0;
|
|
32
|
+
const right = floor[at] ?? 0;
|
|
33
|
+
if (left !== right) return left < right;
|
|
34
|
+
}
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const FIELDS = ['devDependencies', 'dependencies'] as const;
|
|
39
|
+
|
|
40
|
+
const declared = (text: string, field: string): string | undefined => {
|
|
41
|
+
try {
|
|
42
|
+
const parsed: unknown = JSON.parse(text);
|
|
43
|
+
if (typeof parsed !== 'object' || parsed === null) return undefined;
|
|
44
|
+
const block: unknown = Reflect.get(parsed, field);
|
|
45
|
+
if (typeof block !== 'object' || block === null) return undefined;
|
|
46
|
+
const range: unknown = Reflect.get(block, 'typescript');
|
|
47
|
+
return typeof range === 'string' ? range : undefined;
|
|
48
|
+
} catch {
|
|
49
|
+
// An unreadable manifest is `bun install`'s finding, named with its line; here it says nothing.
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/** `bun add` from the app root, `--cwd` into a workspace, `-d` where it was a devDependency. */
|
|
55
|
+
const fixFor = (file: string, field: TypescriptLag['field'], to: string): string => {
|
|
56
|
+
const dir = file.includes('/') ? file.slice(0, file.lastIndexOf('/')) : '';
|
|
57
|
+
return [
|
|
58
|
+
'bun add',
|
|
59
|
+
...(field === 'devDependencies' ? ['-d'] : []),
|
|
60
|
+
quoteArg(`typescript@${to}`),
|
|
61
|
+
...(dir === '' ? [] : ['--cwd', quoteArg(dir)]),
|
|
62
|
+
].join(' ');
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Every manifest whose `typescript` range admits a compiler below the scaffold's. A range this
|
|
67
|
+
* cannot read (`latest`, `catalog:`, `workspace:*`, `5 || 6`) is not judged: no claim beats a
|
|
68
|
+
* wrong one, and `x verify`'s typecheck still answers for it.
|
|
69
|
+
*/
|
|
70
|
+
export function typescriptLags(
|
|
71
|
+
manifests: readonly { readonly file: string; readonly text: string }[],
|
|
72
|
+
to: string = TYPESCRIPT_VERSION,
|
|
73
|
+
): readonly TypescriptLag[] {
|
|
74
|
+
const floor = lowerBound(to) ?? [];
|
|
75
|
+
return manifests.flatMap(({ file, text }) =>
|
|
76
|
+
FIELDS.flatMap((field) => {
|
|
77
|
+
const from = declared(text, field);
|
|
78
|
+
const held = from === undefined ? undefined : lowerBound(from);
|
|
79
|
+
if (from === undefined || held === undefined || !isBelow(held, floor)) return [];
|
|
80
|
+
return [{ file, field, from, to, fix: fixFor(file, field, to) }];
|
|
81
|
+
}),
|
|
82
|
+
);
|
|
83
|
+
}
|
package/src/upgrade-report.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import { msg } from './messages';
|
|
5
5
|
import type { JsonValue } from './output';
|
|
6
|
+
import type { TypescriptLag } from './typescript-floor';
|
|
6
7
|
import type { AgentsLinkState } from './upgrade-agents-link';
|
|
7
8
|
import type { BunEdit, BunManual } from './upgrade-bun-floor';
|
|
8
9
|
import type { GateFinding, HopGate, RepoScript } from './upgrade-gate';
|
|
@@ -69,8 +70,10 @@ export const humanLines = (input: {
|
|
|
69
70
|
readonly scripts: readonly RepoScript[];
|
|
70
71
|
readonly then: string;
|
|
71
72
|
readonly agentsMd?: AgentsLinkState;
|
|
73
|
+
/** Manifests whose TypeScript lags the scaffold's: by hand, the hop never moves a compiler. */
|
|
74
|
+
readonly typescript: readonly TypescriptLag[];
|
|
72
75
|
}): readonly string[] => {
|
|
73
|
-
const { hop, writes, gate, scripts, then, agentsMd } = input;
|
|
76
|
+
const { hop, writes, gate, scripts, then, agentsMd, typescript } = input;
|
|
74
77
|
return [
|
|
75
78
|
...(hop.section === null
|
|
76
79
|
? []
|
|
@@ -81,6 +84,7 @@ export const humanLines = (input: {
|
|
|
81
84
|
...writes.manual.map((site) =>
|
|
82
85
|
msg('cli.upgrade.bunManual', { path: site.path, line: site.line, why: site.why }),
|
|
83
86
|
),
|
|
87
|
+
...typescript.map((lag) => msg('cli.upgrade.typescript', { ...lag })),
|
|
84
88
|
...(agentsMd === 'link' || agentsMd === 'differs'
|
|
85
89
|
? [msg(agentsMd === 'link' ? 'cli.upgrade.agentsMd.link' : 'cli.upgrade.agentsMd.differs')]
|
|
86
90
|
: []),
|
|
@@ -118,6 +122,8 @@ export const report = (input: {
|
|
|
118
122
|
readonly then: string;
|
|
119
123
|
/** What the hop does to `AGENTS.md` (`upgrade-agents-link.ts`); absent when no hop is planned. */
|
|
120
124
|
readonly agentsMd?: AgentsLinkState;
|
|
125
|
+
/** `typescript-floor.ts`'s lags — reported on every outcome, an at-target app's included. */
|
|
126
|
+
readonly typescript: readonly TypescriptLag[];
|
|
121
127
|
}): JsonValue => {
|
|
122
128
|
const { hop, done, dryRun, pins, bunFrom, bunTo, writes, app, gate, scripts, then } = input;
|
|
123
129
|
return asJson({
|
|
@@ -135,6 +141,7 @@ export const report = (input: {
|
|
|
135
141
|
.filter((pin) => pinMoves(pin.spec, hop.to))
|
|
136
142
|
.map((pin) => ({ file: pin.file, name: pin.name, from: pin.spec, to: hop.to })),
|
|
137
143
|
bun: { from: bunFrom, to: bunTo, edited: writes.edited, manual: writes.manual },
|
|
144
|
+
typescript: input.typescript,
|
|
138
145
|
agentsMd: input.agentsMd ?? null,
|
|
139
146
|
guards: gate?.guards ?? null,
|
|
140
147
|
manifest: gate?.manifest ?? null,
|
package/wiki/Upgrading.md
CHANGED
|
@@ -65,6 +65,8 @@ Each entry changes a surface the table below covers.
|
|
|
65
65
|
|
|
66
66
|
`As of 2026-11-10`, released: the 74 breaking entries of `CHANGELOG.md`'s `## 31.0.0` section, in their order. No legacy path, no codemod, no shim. v31 is the stable line — the next major waits for its window ([Stability](Stability)).
|
|
67
67
|
|
|
68
|
+
**Move TypeScript to `^7.0.2` first** — `bun add -d typescript@^7.0.2` in every workspace that declares it, then `bun install`. `@ultimat3/cli` ships its `.ts` source, and your typecheck reads it: under TypeScript 6 with `exactOptionalPropertyTypes` (on in every `x new` tsconfig), `node_modules/@ultimat3/cli/src/cdp-shot-keys.ts` fails TS2769 at 26:43, so the gate is red before any entry below applies. Since 22.0.0 ([the `22.0.0` section](#21x--2200-entry-by-entry)); `x upgrade` moves the `@ultimat3/*` pins, never `typescript`. From 31.2.0, `x doctor` raises `X_TYPESCRIPT_VERSION` per lagging manifest, its fix the exact `bun add`, and `x upgrade` reports the same lag in `data.typescript` — reported only, never written. `x new` scaffolds `TYPESCRIPT_VERSION` (`packages/cli/src/templates/scaffold-repo.ts`). `As of 2026-11`, measured: TypeScript 6.0.3 reports TS2769 on that file, 7.0.2 nothing.
|
|
69
|
+
|
|
68
70
|
### The upgrade, top to bottom
|
|
69
71
|
|
|
70
72
|
| # | Do | What you see until you do | Entries |
|
|
@@ -72,7 +74,7 @@ Each entry changes a surface the table below covers.
|
|
|
72
74
|
| 1 | commit, then `bunx @ultimat3/cli@latest upgrade --json`: it pins every `@ultimat3/*`, installs and runs the gate | `X_UPGRADE_DIRTY_TREE` on a dirty tree | — |
|
|
73
75
|
| 2 | `x verify --only typecheck` and close every error: a hand-written `AuthServerStore` or `PreferenceStore`, an import of a removed Redis script or of `MAX_WIRE_ISSUES`, a hand-built `ActionDeniedError`/`QueryDeniedError`, a `set*` job/event-bus/mail/idempotency/meter/notify setter (a `runtime.ts` field), a factory's `associate()` or `buildMany`, a `setAuditSink`/`configureKdfGate`/`configureErrorReporting({ reporter })` call, a `runtime.storage` built with `defineStorage`, a `PushSubscriptionRecord` with `actorId: null`, a `configureAi({ embedder, semanticCache })` or `configureMetrics({ exporter })` call, an import of a framework mail or `noopMetricExporter`, an exhaustive `switch` over `AuditPrimitive` or `ScanVerdict`, `grantUpload({ quarantine })` or `releaseQuarantine`, an import of a name that left a package's `.` (entry 74's list), a gateway `retry` or realtime `backoff` in the old field names, a boolean job `retry.jitter`, a `setLogSink` call, realtime's `Row`, `Surface` from seo or `SURFACES` from render, a hand-written `SearchIndex` without `list`, a `registerActions`/`registerQuery` call | TS2741, TS2554, TS2305, TS2322 | 1, 6, 10, 14, 18, 29, 36, 40, 43–45, 48, 50, 51, 54–65, 67, 71, 72, 74 |
|
|
74
76
|
| 3 | `x verify --only unit,contract`: shorten a name over 63 bytes, write each `cors.origins` entry as its own `URL.origin`, rename an unsafe storage key or header value, switch a `fromDecimal` branch to `X_MONEY_NOT_DECIMAL`, read a truncated validation through `issuesTruncated`, pass `expose: true` to an `mcpTools()` whose tools your `/mcp` serves, name `localhost` exactly in an `allowHosts` that reaches it through `'*'`, compare a resolved disk by `.name`, advance the version in a custom store's `upsert`, drop `target` from a grant while a scanner is installed | `X_SQL_UNSAFE`, `X_CORS_CONFIG_INVALID` at boot, `X_STORAGE_PATH_UNSAFE`, `X_INVARIANT`, `X_MONEY_NOT_DECIMAL`, a remote tool missing from your `tools/list`, `X_SCRAPE_HOST_BLOCKED` for a `localhost` URL, `X_STORAGE_TARGET_UNSCANNED` | 2, 4, 7, 9, 11, 12, 19, 22, 27, 69, 70 |
|
|
75
|
-
| 4 | **before the deploy:** list stored objects whose keys the new rule refuses and copy them; cache a projection where a value passes 1 MiB; keep `redisTier`'s default `buildId` or plan the one-time bust; on `docker/helm`, move a pod that reads the metadata endpoint to a workload identity; name a Postgres `notifyStores.ledger` in `runtime.ts` if a notifier runs; add
|
|
77
|
+
| 4 | **before the deploy:** list stored objects whose keys the new rule refuses and copy them; cache a projection where a value passes 1 MiB; keep `redisTier`'s default `buildId` or plan the one-time bust; on `docker/helm`, move a pod that reads the metadata endpoint to a workload identity; name a Postgres `notifyStores.ledger` in `runtime.ts` if a notifier runs; add `https://<origin>/auth/sso/<provider>/callback` as a redirect URI at every OAuth IdP **before the new image rolls**, keep `/auth/oauth/<provider>/callback` registered until the last old pod is gone, and point sign-in links at `/auth/sso/<provider>`; with objects still under `org/*/pending/quarantine/`, install an `uploadScanner` answering `hold` for them | a read of an old key refused; a cache miss logged `X_CACHE_TOO_LARGE`; stale tagged keys until their TTL; a metadata-endpoint timeout; `X_NOTIFY_STORE_MISSING` on the first notification | 5, 6, 11, 16, 49, 52, 57 |
|
|
76
78
|
| 5 | **after the deploy:** declare `maxPage` on a read a client pages past 500 rows (`X_INPUT_INVALID` until you do); treat exit `70` as "drained, work abandoned" in alerts; read rate-limit keys through `addressNetwork`; switch on `denial.surface === 'mcp'` for an MCP read; honour `{ etag }` in a hand-written storage driver; give the collector a logs pipeline or set `OTEL_LOGS_EXPORTER=none`; with an external search index, run each `reindex()` once with `x db backfill <name> --write --force --json` so its sweep drops what the table lost | nothing fails: an alert, a dashboard filter or an ETag answers differently | 3, 8, 13, 14, 17, 28, 30, 66, 73 |
|
|
77
79
|
| 6 | `x db gen "tenant indexes"`, commit `packages/db/migrations` and `packages/db/schema/`; the new index builds `concurrently`, so a hot table keeps taking writes | `X_DB_DRIFT` from `x verify --only drift` | 20 |
|
|
78
80
|
|
|
@@ -121,10 +123,10 @@ Tier 0 — `@ultimat3/core` (3), (23), (25), (31), (33–35), (43), (51), (55),
|
|
|
121
123
|
| 37 | `httpServer({ rateLimitStore })`, `installRateLimitStore`, `adoptRateLimitStore` (`@ultimat3/http`), `configureAuthLimiters`, `configureTotpReplay` (`@ultimat3/auth`), `setScrapeDriver` (`@ultimat3/scraping`), and their resets | you passed a store to `httpServer` or called an installer yourself: TS2353/TS2305 — set `rateLimitStore`, `authLimiter`, `totpReplay` or `scrapeDriver` in `export const runtime = { … }` (`apps/<app>/runtime.ts`); every server's limiter counts in that one store. A boot or test harness imports `installRateLimitStore` from `@ultimat3/http/adapter`, `installAuthLimiters`/`installTotpReplay` (renamed from `configure*`) from `@ultimat3/auth/adapter`, `installScrapeDriver` from `@ultimat3/scraping/adapter` — each answers its release — and `resetRateLimitStore`, `resetAuthLimiters`, `resetTotpReplay`, `resetScrapeDriver` from the same subpaths, never `.` |
|
|
122
124
|
| 38 | `ScrapeClock`, `TestScrapeClock`, `systemScrapeClock`, `noWaitClock`, `testScrapeClock`, `scrapeClock`, `setScrapeClock`, `resetScrapeClock` (`@ultimat3/scraping`), `configureFlags({ clock })` (`@ultimat3/flags`) | TS2305 / TS2353 — import `SleepClock`, `FrozenClock`, `systemClock`, `noWaitClock`, `frozenClock`, `ambientClock` from `@ultimat3/core`; replace `setScrapeClock(c)` … `resetScrapeClock()` with `const release = installClock(c)` (`@ultimat3/core/adapter`) … `release()`; drop `clock` from `configureFlags` and set `clock` in `apps/<app>/runtime.ts`. A test that asserted a frozen clock advanced on an already-aborted sleep now reads 0 |
|
|
123
125
|
| 39 | `AuditSink` (`@ultimat3/admin`) | TS2305 on the import — `import type { AuditSink } from '@ultimat3/core/adapter'` and type the sink `AuditSink<AuditEntry>` |
|
|
124
|
-
| 40 | `associate`, `associations`, `Association`, `AssociationMap`, `buildMany`, `createMany`, `Persister` (`@ultimat3/testing`) | TS2305/TS2353/TS2339 — `associations: { orgId: associate(orgs, (o) => o.id) }` becomes `belongsTo: { org: belongsTo(orgs, 'orgId') }` (keep `orgId` in `defaults`); rename `buildMany`/`createMany` to `buildList`/`createList`; a hand-written persister is `insert(entity, row)` answering the stored row — or delete it and `usePersister(entityPersister({ driver }))`. A test that asserted `create()` returned the BUILT row now sees the stored one (defaults filled); a test that expected `X_TEST_FACTORY_NOT_PERSISTED` for a real `entity()` now writes to `defaultDriver()` |
|
|
126
|
+
| 40 | `associate`, `associations`, `Association`, `AssociationMap`, `buildMany`, `createMany`, `Persister` (`@ultimat3/testing`) | TS2305/TS2353/TS2339 — `associations: { orgId: associate(orgs, (o) => o.id) }` becomes `belongsTo: { org: belongsTo(orgs, 'orgId') }` (keep `orgId` in `defaults`); rename `buildMany`/`createMany` to `buildList`/`createList`; a hand-written persister is `insert(entity, row)` answering the stored row — or delete it and `usePersister(entityPersister({ driver }))`. A test that asserted `create()` returned the BUILT row now sees the stored one (defaults filled); a test that expected `X_TEST_FACTORY_NOT_PERSISTED` for a real `entity()` now writes to `defaultDriver()`. 31.0.0–31.1.0 widened a string literal in `defaults` to `string` (TS2322 on an `enumerated` column); 31.2.0 keeps it, so an `as const` added for that can go |
|
|
125
127
|
| 41 | `configureAi({ gateway })` (`@ultimat3/ai`) | TS2353 on `gateway` — set `aiGateway` in `export const runtime = { … }` (`apps/<app>/runtime.ts`); keep `configureAi` for `embedder`, `semanticCache`, `redact` only. A test installs one with `const release = installAiGateway(gateway)` from `@ultimat3/ai/adapter` and calls `release()` after |
|
|
126
128
|
| 42 | `RuntimeOverrides.syncAuthenticate` (`@ultimat3/cli`) | TS2353 on `syncAuthenticate` in `runtime.ts` — delete it; state a token's lifetime as `configureAuthenticator(resolve, { credentialTtlMs })`. A `<app>/packages/db/factories.ts` exporting `factories` is now linted by `unit`: `X_TEST_FACTORY_INVALID` names the factory and trait to fix |
|
|
127
|
-
| 43 | `setAuditSink`, `resetAuditSink`, `configureErrorReporting({ reporter })` (`@ultimat3/core`) | TS2305 / TS2322 (`reporter` is `never`) — set `auditSink` / `errorReporter` in `export const runtime = { … }` (`apps/<app>/runtime.ts`), not at module scope. A test: `const release = installAuditSink(sink)` / `installErrorReporter(reporter)` from `@ultimat3/core/adapter`, `release()` after — or `swapAdapter('auditSink', sink)` from `@ultimat3/testing`. `configureErrorReporting` keeps `clock`, `release`, `environment`, `enabled` |
|
|
129
|
+
| 43 | `setAuditSink`, `resetAuditSink`, `configureErrorReporting({ reporter })` (`@ultimat3/core`) | TS2305 / TS2322 (`reporter` is `never`) — set `auditSink` / `errorReporter` in `export const runtime = { … }` (`apps/<app>/runtime.ts`), not at module scope. A test: `const release = installAuditSink(sink)` / `installErrorReporter(reporter)` from `@ultimat3/core/adapter`, `release()` after — or `swapAdapter('auditSink', sink)` from `@ultimat3/testing`. `configureErrorReporting` keeps `clock`, `release`, `environment`, `enabled`. Through 31.1.0, `x exercise` and `x build`'s measurement did not read `runtime.ts`, so the sink declared there was missing in both ("Not breaking, but you will see it", below); 31.2.0 reads it, and a memory sink installed in `apps/web/exercise.ts` or `prerender.ts` as the workaround can be deleted |
|
|
128
130
|
| 44 | `configureKdfGate`, `resetKdfGate` (`@ultimat3/auth`) | TS2305 — `const release = installKdfGate({ maxConcurrent, maxQueued })` from `@ultimat3/auth/adapter`, `release()` (or `resetKdfGate()`, same subpath) after |
|
|
129
131
|
| 45 | `RuntimeOverrides.storage` (`@ultimat3/cli`) | TS2322 when `runtime.ts` passes `defineStorage({ … })` — pass the driver (`storage: s3Driver({ … })`): it is the default disk under the driver's `name`. Several disks: `defineStorage()` in `app.config.ts`, which wins |
|
|
130
132
|
| 46 | `jobDriverConformance`, `budgetStoreConformance`, `BudgetStoreLike` (`@ultimat3/testing`) | TS2305 — import them from `@ultimat3/testing/conformance`, where every port's suite lives; `behavesLike` stays on `@ultimat3/testing` |
|
|
@@ -133,7 +135,7 @@ Tier 0 — `@ultimat3/core` (3), (23), (25), (31), (33–35), (43), (51), (55),
|
|
|
133
135
|
| 49 | the default delivery ledger (`@ultimat3/notify`) | you deploy (staging or production) with no `notifyStores.ledger` in `runtime.ts` and a notifier runs: its first claim is `X_NOTIFY_STORE_MISSING`, where a memory ledger answered — one per process, so a replay on another replica or after a restart sent twice. Set `notifyStores: { ledger: postgresDeliveryLedger({ executor: dbExecutor() }) }` in `export const runtime = { … }` (`apps/<app>/runtime.ts`); the boot already applies `x_notify_deliveries`. Name every store you keep in that one object — it replaces, never merges. Development and test keep the memory default |
|
|
134
136
|
| 50 | `configureAi({ embedder, semanticCache })` (`@ultimat3/ai`) | TS2353 on `embedder` / `semanticCache` — set them in `export const runtime = { embedder, semanticCache }` (`apps/<app>/runtime.ts`); `semanticCache` is the same `(scope) => SemanticCache` factory. `configureAi` keeps `redact` only. A test: `const release = installAiEmbedder(embedder)` / `installSemanticCache(factory)` from `@ultimat3/ai/adapter`, `release()` after — or `swapAdapter('embedder', …)` from `@ultimat3/testing`. Prove one with `embedderConformance` / `semanticCacheFactoryConformance` from `@ultimat3/testing/conformance` |
|
|
135
137
|
| 51 | `configureMetrics({ exporter })` (`@ultimat3/core`) | TS2353 on `exporter` — subscribe it: `const release = subscribe('metric.export', (event) => exporter.export(event.payload))`, `release()` to uninstall; `exportMetrics()` / `startMetricExport(ms)` publish the tick as before. `configureMetrics` keeps `clock` and `enabled`. With `OTEL_EXPORTER_OTLP_ENDPOINT` set the boot already subscribes `otlpMetricExporter()` |
|
|
136
|
-
| 52 | `oauthLogin` (`@ultimat3/auth`) — its paths, cookie and `restartAt` | the routes moved from `/auth/oauth/:provider[/callback]` to `/auth/sso/:provider[/callback]` (`oauthStartPath`/`oauthCallbackPath`/`OAUTH_*_ROUTE_PATH` answer the new values; the call and its options are unchanged). **Before deploying, add `https://<origin>/auth/sso/<provider>/callback` as an allowed redirect URI at each IdP** (GitHub, Google, your OP) — keep the old one until the deploy is out — and point every sign-in link at `/auth/sso/<provider>`. A login started before the deploy fails its callback once (`X_OAUTH_STATE_INVALID`: the state cookie is now `__Host-x_sso_<provider>`); the user starts again. `restartAt(provider)` and every OAuth `fix:` name `/auth/sso/<provider>`. `oauthDenied` and `OAUTH_ROUTE_STATUS` keep their names on `@ultimat3/auth`; a deep import from `./oauth-route` moves to the barrel |
|
|
138
|
+
| 52 | `oauthLogin` (`@ultimat3/auth`) — its paths, cookie and `restartAt` | the routes moved from `/auth/oauth/:provider[/callback]` to `/auth/sso/:provider[/callback]` (`oauthStartPath`/`oauthCallbackPath`/`OAUTH_*_ROUTE_PATH` answer the new values; the call and its options are unchanged). **Before deploying, add `https://<origin>/auth/sso/<provider>/callback` as an allowed redirect URI at each IdP** (GitHub, Google, your OP) — keep the old one until the deploy is out — and point every sign-in link at `/auth/sso/<provider>`. A login started before the deploy fails its callback once (`X_OAUTH_STATE_INVALID`: the state cookie is now `__Host-x_sso_<provider>`); the user starts again. `restartAt(provider)` and every OAuth `fix:` name `/auth/sso/<provider>`. `oauthDenied` and `OAUTH_ROUTE_STATUS` keep their names on `@ultimat3/auth`; a deep import from `./oauth-route` moves to the barrel. The base path is fixed (`OAUTH_BASE_PATH`, `packages/auth/src/oauth-paths.ts`): a mid-roll pod answers on one path only, so both URIs stay registered until the roll completes. **Can't re-register the redirect URI at your IdP?** Keep the old one: `oauthLogin(auth, { callbackPath: '/auth/oauth/:provider/callback' })`, then mount `callback.path` (not `OAUTH_CALLBACK_ROUTE_PATH`); the start link stays `/auth/sso/<provider>`. **Hand-built callback?** From 31.2.0, `readHandshakeCookie` opens the cookie `oauthLogin().start` sets, so a `beginOAuth` + `handshakeCookie` start leg written as a workaround can be deleted; its in-flight cookies (`__Host-x_oauth_<p>`) are still read until 32.0.0 |
|
|
137
139
|
| 53 | the raw-CDP launcher (`@ultimat3/testing` → `@ultimat3/scraping/cdp`) | an e2e suite imports `findChrome`, `launchChrome`, `CHROME_PATH_ENV`, a `Cdp*Error` or `E2E_BROWSER_CLOSE_MS` from `@ultimat3/testing` (TS2305, no exported member): `bun add -d @ultimat3/scraping`, then `import { findChrome, LAUNCHED_CLOSE_MS } from '@ultimat3/scraping/cdp';` — `E2E_BROWSER_CLOSE_MS` is `LAUNCHED_CLOSE_MS`, the same value. Everything e2e-shaped (`openE2eBrowser`, `E2E_BROWSER_OPEN_MS`, `installE2eDriver`, …) stays on `@ultimat3/testing` |
|
|
138
140
|
| 54 | `welcomeMail`, `verifyEmailMail`, `resetPasswordMail`, `inviteMail`, `mfaEnrolledMail`, `securityAlertMail`, their `*Input` schemas and types, `MFA_METHODS`, `FRAMEWORK_MAILS` (`@ultimat3/mail`) | you import one (TS2305), or send a mail by one of the ids `welcome`, `verify-email`, `reset-password`, `invite`, `mfa-enrolled`, `security-alert` without declaring it — importing the package no longer registers them. Declare your own: `export const welcomeMail = defineMail<{ name: string }>({ id: 'welcome', subject: 'mail.welcome.subject', input: t.object({ name: t.string }), template: ({ data }) => [blocks.heading('mail.welcome.heading', { name: data.name })] })`, and carry every `mail.<id>.*` key it renders in `packages/i18n/catalogs/<locale>.json` — the base catalog keeps `mail.footer.*` only. Email verification and password reset are untouched: `@ultimat3/auth` sends `auth.email-verify` / `auth.password-reset` from your catalog, as before |
|
|
139
141
|
| 55 | `noopMetricExporter` (`@ultimat3/core`) | you import it (TS2305): delete the import and what it was handed to — exporting nothing is subscribing nothing to `metric.export` (entry 51). A test that needs an exporter value uses `memoryMetricExporter()` |
|
|
@@ -190,6 +192,11 @@ A setter still on a package's `.` barrel is `X_ADAPTER_PORT_INCOMPLETE` on the `
|
|
|
190
192
|
| What moved | Do |
|
|
191
193
|
|---|---|
|
|
192
194
|
| `x verify`'s `manifest` step is red, `X_MCP_APP_UNMOUNTED`, when `ai.mcp.expose` is `true` — **the default**, so an `app.config.ts` that never names it counts — and no `apps/web/mcp.ts` exports `mcp` (`As of 30.4.0`; before, the boot only logged it while `POST /mcp` answered 404). An app scaffolded before `x new` wrote that file hits it on its first 31.0.0 gate | mount it as `x new` does: `apps/web/mcp.ts` exporting `export const mcp = appMcp({ resolveToken: resolveAgentToken })`, `appMcp` from your `@<app>/mcp` package and `resolveAgentToken` from `./app/auth/agent-token` — copy those files (and `packages/mcp/src/index.ts`, if you have no `@<app>/mcp`) from a fresh `bunx create-ultimate`. With no catalog package, the error's own fix is the whole file: `export const mcp = defineAppMcp({ include: 'exposed', resolveToken })` (`@ultimat3/mcp`), `resolveToken` answering an agent or `null`. No agent surface wanted: `ai: { mcp: { expose: false } }` in `app.config.ts` |
|
|
195
|
+
| `verifyApiKey` (`@ultimat3/auth`) refuses every key with `X_API_KEY_INVALID` when the stored `prefix` is not the one the bearer parses to: since 31.0.0 it compares `parseApiKey(bearer).prefix` — always `ult_<env>_<id>` — to `record.prefix` (`packages/auth/src/api-keys.ts`, `verifyApiKey`). An app that minted keys itself, or stores a display prefix of its own (`acme_<env>_<id>`, a truncated `ult_prod`), passed on 30.x and fails every key now. A bearer not shaped `ult_<env>_<id>_<secret>` was already refused by `parseApiKey` before 31 | list the rows that cannot match: `psql "$DATABASE_URL" -c "select id, prefix from x_api_keys where prefix !~ ('^ult_[a-z0-9-]+_' \|\| id \|\| '$')"`; for each, `update x_api_keys set prefix = 'ult_<env>_' \|\| id where id = '<id>'`, `<env>` the second segment of the bearer that key's holder sends. A custom `ApiKeyStore` answers `prefix` exactly as `issueApiKey` wrote it |
|
|
196
|
+
| a unique collision under the memory driver — what a factory's `create()` writes to in a test since entry 40 — is `X_DB_UNIQUE_VIOLATION` with no SQLSTATE: `sqlState(e)` (`@ultimat3/db`) answers `undefined`, where Postgres answers `23505`, so a race handler matching `sqlState(e) === '23505'` passes in production and fails its test (`packages/entity/src/driver-errors.ts`, `entityUniqueViolation`) | match the code, which both drivers raise: `isUltimateError(e) && e.code === 'X_DB_UNIQUE_VIOLATION'` (`isUltimateError` from `@ultimat3/core`); `meta.constraint` names the constraint on both. Through 31.1.0 only the code matches under memory; fixed in **31.2.0**, from which the memory driver and every `defineDriver` store carry `23505` too and `sqlState(e) === SQLSTATE.uniqueViolation` (`@ultimat3/db`) also matches |
|
|
197
|
+
| `x exercise` reports `X_AUDIT_SINK_MISSING` (`X_QUERY_AUDIT_SINK_MISSING` for a query) on every `audit: true` primitive, and `x build` lists each page whose render runs one under `unmeasured`: entry 43 moved `auditSink` into `runtime.ts`, and neither pass installs `runtime.ts` | fixed in **31.2.0**: both read `apps/<app>/runtime.ts` through the boot's own loader, a memory sink standing in for the declared one so neither writes to it. On 31.0.0–31.1.0, install a memory sink at the top of `apps/web/exercise.ts` and `apps/web/prerender.ts` — `installAuditSink(memoryAuditSink())`, `installAuditSink` from `@ultimat3/core/adapter`, `memoryAuditSink` from `@ultimat3/action`; on 31.2.0, delete it |
|
|
198
|
+
| `defineFactory` (`@ultimat3/testing`, entry 40) widens a string literal in `defaults` or a trait to `string`, so an `enumerated([…])` column is TS2322 — `Type 'string' is not assignable to type '"closed" \| "open"'` | `'open' as const` on the literal. Fixed in **31.2.0**: from it, an `as const` or per-literal annotation added for this TS2322 can be deleted — kept, it is harmless |
|
|
199
|
+
| `disk('<name>')` is `X_STORAGE_DISK_UNKNOWN` for a disk your own `defineStorage({ disks: { … } })` declares, when an app module reached from `runtime.ts` makes that call: the boot installed its one-disk registry over it | fixed in **31.2.0**: the boot keeps a registry the app declared, and the app's `defineStorage()` wins over `runtime.storage`. Upgrade to it; no workaround is verified for 31.0.0–31.1.0 |
|
|
193
200
|
|
|
194
201
|
## 29.x → 30.0.0, entry by entry
|
|
195
202
|
|
|
@@ -1786,6 +1793,12 @@ dependency you can drop, entry 22 is one `x db gen` if `drift` asks for it, and
|
|
|
1786
1793
|
edit. 22.0.0 is plan 101's deep sweep: every framework package, both tracked apps and the deploy
|
|
1787
1794
|
path.
|
|
1788
1795
|
|
|
1796
|
+
**TypeScript 7 from here on — move it before this hop.** 22.0.0 added
|
|
1797
|
+
`packages/cli/src/cdp-shot-keys.ts`, and `@ultimat3/cli` ships its `.ts` source: under TypeScript 6
|
|
1798
|
+
with `exactOptionalPropertyTypes` it fails TS2769 at 26:43, in your typecheck, on every release from
|
|
1799
|
+
22.0.0 through 31. `bun add -d typescript@^7.0.2` in every workspace that declares it — what `x new`
|
|
1800
|
+
has scaffolded since 20.0.0 (`TYPESCRIPT_VERSION`). Not a `CHANGELOG.md` entry, so not counted above.
|
|
1801
|
+
|
|
1789
1802
|
| # | Surface | Costs you an edit if |
|
|
1790
1803
|
|---|---|---|
|
|
1791
1804
|
| 1 | `t.date` | you send a date that is not ISO-8601 in shape (`'March 14, 2026'`, `'3/14/2026'`, `'12'`). It is refused at validation now (`coerceQuery` no longer rewrites it). `new Date` read it at the host's local midnight, so the stored day depended on `TZ`. Send `'2026-03-14'`. Epoch-ms numbers and `Date` objects are unchanged |
|