@ultimat3/cli 31.4.2 → 31.5.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 -0
- package/package.json +29 -29
- package/src/app-boundaries.ts +3 -2
- package/src/asset-route-meta.ts +29 -0
- package/src/cmd-drill.ts +39 -9
- package/src/favicon.ts +2 -1
- package/src/island-routes.ts +2 -1
- package/src/mcp-host.ts +70 -9
- package/src/pwa-artifacts.ts +3 -3
- package/src/runtime-assets.ts +4 -1
- package/src/site-asset-routes.ts +2 -1
- package/src/style-routes.ts +2 -1
- package/src/templates/guard-repo-raw-sql.ts +6 -3
- package/src/worker-bundle.ts +2 -1
- package/wiki/Entities-And-Migrations.md +3 -3
- package/wiki/Interface-Rules.md +2 -2
- package/wiki/Project-Layout.md +3 -3
- package/wiki/Upgrading.md +4 -0
package/CLAUDE.md
CHANGED
|
@@ -132,6 +132,7 @@ Commands: `bun test ./packages/cli/` (repo root: the preload),
|
|
|
132
132
|
| `role-wake.ts` | the worker's LISTEN session (`@ultimat3/jobs`' `startQueueWake`) — worker role only, only over a client that `canListen` — and `queue_wake_live` |
|
|
133
133
|
| `role-sync.ts` / `role-replicator.ts` / `runtime-live-feed.ts` | the sync node, the change feed |
|
|
134
134
|
| `runtime-render*.ts` / `runtime-{isr-outcome,assets,storage,hooks}.ts` / `route-islands.ts` / `api-routes.ts` | the HTTP surface both boots mount † |
|
|
135
|
+
| `asset-route-meta.ts` | the ONE writer of an asset route's `tags: ['assets']` + `rateLimit: 'assets'`; the test walks `examples/dummy`'s built table and refuses an `assets.*` route on `default` |
|
|
135
136
|
| `client-{errors,vitals}-*.ts` | `clientErrors` (and `.vitals`): the script on `app/` (vitals: listed) documents, its `POST` route, mounted by BOTH boots ‡ |
|
|
136
137
|
| `retained-assets.ts` / `-layout.ts` / `-sweep.ts` / `-read.ts` / `-boot.ts` | `assets.retain`: the web boot publishes this build's hashed files before `/readyz` † |
|
|
137
138
|
| `runtime-overrides.ts` / `runtime-ports.ts` / `runtime-port-bindings.ts` | `runtime.ts`: a field per `ADAPTER_PORTS` row, installed by ONE loop or read where used; unbound row = build error. Plus `routes`. `docs/history/cli-adapter-ports.md` |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultimat3/cli",
|
|
3
|
-
"version": "31.
|
|
3
|
+
"version": "31.5.0",
|
|
4
4
|
"description": "The `x` binary: new, dev, build, verify, generate, db, mcp, doctor, deploy",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ultimate",
|
|
@@ -53,34 +53,34 @@
|
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@babel/core": "^8.0.9",
|
|
56
|
-
"@ultimat3/action": "31.
|
|
57
|
-
"@ultimat3/admin": "31.
|
|
58
|
-
"@ultimat3/ai": "31.
|
|
59
|
-
"@ultimat3/auth": "31.
|
|
60
|
-
"@ultimat3/cache": "31.
|
|
61
|
-
"@ultimat3/core": "31.
|
|
62
|
-
"@ultimat3/db": "31.
|
|
63
|
-
"@ultimat3/entity": "31.
|
|
64
|
-
"@ultimat3/flags": "31.
|
|
65
|
-
"@ultimat3/http": "31.
|
|
66
|
-
"@ultimat3/i18n": "31.
|
|
67
|
-
"@ultimat3/jobs": "31.
|
|
68
|
-
"@ultimat3/mail": "31.
|
|
69
|
-
"@ultimat3/manifest": "31.
|
|
70
|
-
"@ultimat3/mcp": "31.
|
|
71
|
-
"@ultimat3/money": "31.
|
|
72
|
-
"@ultimat3/notify": "31.
|
|
73
|
-
"@ultimat3/policy": "31.
|
|
74
|
-
"@ultimat3/pwa": "31.
|
|
75
|
-
"@ultimat3/query": "31.
|
|
76
|
-
"@ultimat3/realtime": "31.
|
|
77
|
-
"@ultimat3/render": "31.
|
|
78
|
-
"@ultimat3/schema": "31.
|
|
79
|
-
"@ultimat3/scraping": "31.
|
|
80
|
-
"@ultimat3/seo": "31.
|
|
81
|
-
"@ultimat3/storage": "31.
|
|
82
|
-
"@ultimat3/testing": "31.
|
|
83
|
-
"@ultimat3/time": "31.
|
|
56
|
+
"@ultimat3/action": "31.5.0",
|
|
57
|
+
"@ultimat3/admin": "31.5.0",
|
|
58
|
+
"@ultimat3/ai": "31.5.0",
|
|
59
|
+
"@ultimat3/auth": "31.5.0",
|
|
60
|
+
"@ultimat3/cache": "31.5.0",
|
|
61
|
+
"@ultimat3/core": "31.5.0",
|
|
62
|
+
"@ultimat3/db": "31.5.0",
|
|
63
|
+
"@ultimat3/entity": "31.5.0",
|
|
64
|
+
"@ultimat3/flags": "31.5.0",
|
|
65
|
+
"@ultimat3/http": "31.5.0",
|
|
66
|
+
"@ultimat3/i18n": "31.5.0",
|
|
67
|
+
"@ultimat3/jobs": "31.5.0",
|
|
68
|
+
"@ultimat3/mail": "31.5.0",
|
|
69
|
+
"@ultimat3/manifest": "31.5.0",
|
|
70
|
+
"@ultimat3/mcp": "31.5.0",
|
|
71
|
+
"@ultimat3/money": "31.5.0",
|
|
72
|
+
"@ultimat3/notify": "31.5.0",
|
|
73
|
+
"@ultimat3/policy": "31.5.0",
|
|
74
|
+
"@ultimat3/pwa": "31.5.0",
|
|
75
|
+
"@ultimat3/query": "31.5.0",
|
|
76
|
+
"@ultimat3/realtime": "31.5.0",
|
|
77
|
+
"@ultimat3/render": "31.5.0",
|
|
78
|
+
"@ultimat3/schema": "31.5.0",
|
|
79
|
+
"@ultimat3/scraping": "31.5.0",
|
|
80
|
+
"@ultimat3/seo": "31.5.0",
|
|
81
|
+
"@ultimat3/storage": "31.5.0",
|
|
82
|
+
"@ultimat3/testing": "31.5.0",
|
|
83
|
+
"@ultimat3/time": "31.5.0",
|
|
84
84
|
"babel-preset-solid": "^1.9.16"
|
|
85
85
|
}
|
|
86
86
|
}
|
package/src/app-boundaries.ts
CHANGED
|
@@ -72,10 +72,11 @@ const isService = (path: string): boolean => /\/service\.[cm]?ts$/.test(path);
|
|
|
72
72
|
* query that carries the read's policy, bound and cache tag — the scaffold's own dashboard showed
|
|
73
73
|
* every post to a viewer holding `dashboard:read` alone. Matched as a whole module name, resolved
|
|
74
74
|
* (`…/repo.ts`), NodeNext-spelled (`./repo.js`, `.mjs`, `.cjs`) or bare (`../post/repo`), so
|
|
75
|
-
* `report` and `repository` are names, not repos.
|
|
75
|
+
* `report` and `repository` are names, not repos. A `repo-<part>` module is the same repo split at
|
|
76
|
+
* the file ceiling (`repo-window.ts`): without it the split was a door around this rule.
|
|
76
77
|
*/
|
|
77
78
|
const isRepoSpecifier = (specifier: string): boolean =>
|
|
78
|
-
/(^|\/)repo(\/index)?(\.[cm]?[jt]sx?)?$/.test(specifier);
|
|
79
|
+
/(^|\/)repo(-[a-z0-9]+)*(\/index)?(\.[cm]?[jt]sx?)?$/.test(specifier);
|
|
79
80
|
const isDbSpecifier = (specifier: string): boolean =>
|
|
80
81
|
/(^|\/)packages\/db($|\/)/.test(specifier) ||
|
|
81
82
|
specifier.endsWith('/db') ||
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// The one place an asset route's tag and rate-limit bucket are written. Every route serving built
|
|
2
|
+
// bytes (chunks, stylesheets, icons, site files, framework scripts) spends `assets`, not `default`:
|
|
3
|
+
// one page load is dozens of content-hashed GETs, and `default`'s 120 burst at 2/s answered 429 to
|
|
4
|
+
// an office behind one NAT from the fifth route on.
|
|
5
|
+
|
|
6
|
+
import type { RouteMeta } from '@ultimat3/http';
|
|
7
|
+
|
|
8
|
+
/** The tag `withRetainedAssets` and the manifest read to know a route serves built bytes. */
|
|
9
|
+
export const ASSET_ROUTE_TAG = 'assets';
|
|
10
|
+
|
|
11
|
+
/** The bucket in `@ultimat3/http`'s `DEFAULT_RATE_LIMIT` an asset route spends. */
|
|
12
|
+
export const ASSET_RATE_LIMIT_BUCKET = 'assets';
|
|
13
|
+
|
|
14
|
+
/** What an asset route declares itself; the tag and the bucket are this function's to write. */
|
|
15
|
+
export type AssetRouteDeclaration = Omit<
|
|
16
|
+
RouteMeta,
|
|
17
|
+
'tags' | 'rateLimit' | 'rateLimitBucket' | 'rateLimitedBy'
|
|
18
|
+
>;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A route meta with `tags: ['assets']` and `rateLimit: 'assets'` written for it. Not optional per
|
|
22
|
+
* route: `asset-route-meta.test.ts` walks the reference app's built table and refuses any
|
|
23
|
+
* `assets.*` route whose meta did not come through here.
|
|
24
|
+
*/
|
|
25
|
+
export const assetRouteMeta = (meta: AssetRouteDeclaration): RouteMeta => ({
|
|
26
|
+
...meta,
|
|
27
|
+
tags: [ASSET_ROUTE_TAG],
|
|
28
|
+
rateLimit: ASSET_RATE_LIMIT_BUCKET,
|
|
29
|
+
});
|
package/src/cmd-drill.ts
CHANGED
|
@@ -5,7 +5,13 @@
|
|
|
5
5
|
|
|
6
6
|
import type { AppConfig } from '@ultimat3/core';
|
|
7
7
|
import { DRAIN_DEADLINE_DEFAULT_MS, MAX_TIMER_MS } from '@ultimat3/core';
|
|
8
|
-
import type {
|
|
8
|
+
import type {
|
|
9
|
+
Drill,
|
|
10
|
+
DrillConfig,
|
|
11
|
+
DrillDeclarations,
|
|
12
|
+
DrillFleet,
|
|
13
|
+
DrillReport,
|
|
14
|
+
} from '@ultimat3/testing';
|
|
9
15
|
import {
|
|
10
16
|
bunDrillSql,
|
|
11
17
|
DRILL_NAMES,
|
|
@@ -90,6 +96,33 @@ const findingsOf = (report: DrillReport): readonly Finding[] =>
|
|
|
90
96
|
return { code: error.code, cause: error.cause, fix: error.fix };
|
|
91
97
|
});
|
|
92
98
|
|
|
99
|
+
/** The evidence connection: `bunDrillSql`'s shape, a seam so a test can make it throw. */
|
|
100
|
+
type DrillSqlConnection = ReturnType<typeof bunDrillSql>;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* One drill's body over a started fleet, which is ALWAYS stopped. The fleet is spawned role
|
|
104
|
+
* processes: the connection was opened before the `try`, so a constructor that threw (a malformed
|
|
105
|
+
* URL is a synchronous `Invalid URL`) left every role running, and a `close()` that threw skipped
|
|
106
|
+
* `stop()` the same way.
|
|
107
|
+
*/
|
|
108
|
+
export async function withDrillFleet<T>(
|
|
109
|
+
fleet: Pick<DrillFleet, 'databaseUrl' | 'stop'>,
|
|
110
|
+
open: (url: string) => DrillSqlConnection,
|
|
111
|
+
body: (sql: DrillSqlConnection) => Promise<T>,
|
|
112
|
+
): Promise<T> {
|
|
113
|
+
let sql: DrillSqlConnection | undefined;
|
|
114
|
+
try {
|
|
115
|
+
sql = open(fleet.databaseUrl);
|
|
116
|
+
return await body(sql);
|
|
117
|
+
} finally {
|
|
118
|
+
try {
|
|
119
|
+
await sql?.close();
|
|
120
|
+
} finally {
|
|
121
|
+
await fleet.stop();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
93
126
|
export const drillCommand: CliCommand = {
|
|
94
127
|
spec: drillSpec,
|
|
95
128
|
async run(ctx: CommandContext): Promise<CommandResult> {
|
|
@@ -147,14 +180,11 @@ export const drillCommand: CliCommand = {
|
|
|
147
180
|
roles: drillRoles(drill),
|
|
148
181
|
readyTimeoutMs: READY_TIMEOUT_MS,
|
|
149
182
|
});
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
await sql.close();
|
|
156
|
-
await fleet.stop();
|
|
157
|
-
}
|
|
183
|
+
reports.push(
|
|
184
|
+
await withDrillFleet(fleet, bunDrillSql, (sql) =>
|
|
185
|
+
runDrill({ drill, fleet, budgets, targets, sql, sync: drillSyncLane(fleet) }),
|
|
186
|
+
),
|
|
187
|
+
);
|
|
158
188
|
}
|
|
159
189
|
const held = reports.filter((report) => report.verdict.ok).length;
|
|
160
190
|
const findings = reports.flatMap(findingsOf);
|
package/src/favicon.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { join } from 'node:path';
|
|
|
10
10
|
import { blankRaster, encodeImage } from '@ultimat3/core';
|
|
11
11
|
import type { CacheHint, Route, UltimateRequest } from '@ultimat3/http';
|
|
12
12
|
import { applyCacheHeaders } from '@ultimat3/http';
|
|
13
|
+
import { assetRouteMeta } from './asset-route-meta';
|
|
13
14
|
|
|
14
15
|
/** What a browser asks for with no `<link rel="icon">` to tell it otherwise. */
|
|
15
16
|
export const FAVICON_PATH = '/favicon.ico';
|
|
@@ -108,6 +109,6 @@ export async function faviconResponse(root: string): Promise<Response> {
|
|
|
108
109
|
export const faviconRoute = (root: string): Route => ({
|
|
109
110
|
method: 'GET',
|
|
110
111
|
path: FAVICON_PATH,
|
|
111
|
-
meta: { name: 'assets.favicon', auth: 'public', cache: FAVICON_CACHE
|
|
112
|
+
meta: assetRouteMeta({ name: 'assets.favicon', auth: 'public', cache: FAVICON_CACHE }),
|
|
112
113
|
handler: async (_request: UltimateRequest): Promise<Response> => faviconResponse(root),
|
|
113
114
|
});
|
package/src/island-routes.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import type { Route, UltimateRequest } from '@ultimat3/http';
|
|
6
6
|
import { applyCacheHeaders, jsonResponse, NO_STORE, textResponse } from '@ultimat3/http';
|
|
7
|
+
import { assetRouteMeta } from './asset-route-meta';
|
|
7
8
|
import type { IslandBundle } from './island-bundle';
|
|
8
9
|
import { ISLAND_BASE_PATH } from './island-bundle';
|
|
9
10
|
|
|
@@ -24,7 +25,7 @@ export function islandRoutes(source: IslandSource): readonly Route[] {
|
|
|
24
25
|
{
|
|
25
26
|
method: 'GET',
|
|
26
27
|
path: `${ISLAND_BASE_PATH}/*file`,
|
|
27
|
-
meta: { name: 'assets.island', auth: 'public'
|
|
28
|
+
meta: assetRouteMeta({ name: 'assets.island', auth: 'public' }),
|
|
28
29
|
handler: (request: UltimateRequest): Response => {
|
|
29
30
|
// An entry or a shared chunk: an entry's bytes import its chunks by a relative name, so both
|
|
30
31
|
// have to answer at the one base path, under the one cache rule.
|
package/src/mcp-host.ts
CHANGED
|
@@ -9,8 +9,10 @@
|
|
|
9
9
|
import { join } from 'node:path';
|
|
10
10
|
import {
|
|
11
11
|
agentActor,
|
|
12
|
+
isRole,
|
|
12
13
|
isUltimateError,
|
|
13
14
|
NotImplementedError,
|
|
15
|
+
ROLES,
|
|
14
16
|
renderFixShellArg,
|
|
15
17
|
renderThrowable,
|
|
16
18
|
UltimateError,
|
|
@@ -213,6 +215,71 @@ export function testRunArgv(filter: string | undefined): readonly string[] {
|
|
|
213
215
|
return ['bun', 'test', filter];
|
|
214
216
|
}
|
|
215
217
|
|
|
218
|
+
/**
|
|
219
|
+
* `db.migrate`'s answer to a foreign throw. The fix is the REGISTERED one (`mcp-errors.ts`), never
|
|
220
|
+
* a literal here: this said `x db reset`, and an agent that followed it wiped the database the
|
|
221
|
+
* migration had failed against.
|
|
222
|
+
*/
|
|
223
|
+
export function migrateFailed(error: unknown): UltimateError {
|
|
224
|
+
return new UltimateError({
|
|
225
|
+
code: 'X_DB_MIGRATE_FAILED',
|
|
226
|
+
// The blessed total renderer: `String(error)` runs the value's own `toString`, and this is
|
|
227
|
+
// the last hop before an agent is handed the three-line result.
|
|
228
|
+
cause: renderThrowable(error),
|
|
229
|
+
fix:
|
|
230
|
+
explainErrorCode('X_DB_MIGRATE_FAILED')?.fix ?? 'x errors explain X_DB_MIGRATE_FAILED --json',
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* The log `logs.tail` reads. `role` is joined into a path, so it must BE a role: `'../x'` named a
|
|
236
|
+
* file outside the state directory. The tool's schema lists the roles, but a schema is advice to a
|
|
237
|
+
* client and this is the line that opens the file.
|
|
238
|
+
*/
|
|
239
|
+
export function logTailPath(dir: string, role: string | undefined): string {
|
|
240
|
+
if (role === undefined) return join(dir, 'dev.log');
|
|
241
|
+
if (!isRole(role)) {
|
|
242
|
+
throw new BadFlagError({
|
|
243
|
+
flag: 'role',
|
|
244
|
+
command: 'mcp serve',
|
|
245
|
+
reason: `logs.tail's role "${role}" is not a runtime role`,
|
|
246
|
+
fix: `logs.tail({ role: 'web' }) # role is one of ${ROLES.join(', ')}; none reads dev.log`,
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
return join(dir, 'logs', `${role}.log`);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/** The first window read from a log's end; each further one is four times wider. */
|
|
253
|
+
const TAIL_WINDOW_BYTES = 64 * 1024;
|
|
254
|
+
/** The most a tail ever reads: past this, lines that long are cut rather than the log loaded. */
|
|
255
|
+
const TAIL_MAX_BYTES = 1024 * 1024;
|
|
256
|
+
|
|
257
|
+
/** What `tailLines` reads of a file: its size and a byte range — `Bun.file`'s own shape. */
|
|
258
|
+
export interface TailSource {
|
|
259
|
+
readonly size: number;
|
|
260
|
+
slice(start: number, end: number): { text(): Promise<string> };
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* The last `lines` lines, read from the END in widening windows. `file.text()` loaded the whole
|
|
265
|
+
* `dev.log` per call, and an agent calls this in a loop against a log `x dev` never rotates. A
|
|
266
|
+
* window that does not start at byte 0 drops its first line: it may be partial, and may begin
|
|
267
|
+
* mid-character.
|
|
268
|
+
*/
|
|
269
|
+
export async function tailLines(file: TailSource, lines: number): Promise<readonly string[]> {
|
|
270
|
+
let window = TAIL_WINDOW_BYTES;
|
|
271
|
+
for (;;) {
|
|
272
|
+
const start = Math.max(0, file.size - Math.min(window, TAIL_MAX_BYTES));
|
|
273
|
+
const all = (await file.slice(start, file.size).text()).trimEnd().split('\n');
|
|
274
|
+
const whole = start === 0 ? all : all.slice(1);
|
|
275
|
+
if (whole.length >= lines || start === 0) return whole.slice(-lines);
|
|
276
|
+
// At the cap with no newline inside it, the one line there is longer than the cap: answered
|
|
277
|
+
// cut, never as `[]` — an empty tail reads as an empty log.
|
|
278
|
+
if (window >= TAIL_MAX_BYTES) return (whole.length === 0 ? all : whole).slice(-lines);
|
|
279
|
+
window *= 4;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
216
283
|
function capabilities(
|
|
217
284
|
input: DevHostInput,
|
|
218
285
|
lazy: LazyServices,
|
|
@@ -249,13 +316,7 @@ function capabilities(
|
|
|
249
316
|
// code/cause/fix result, which is what an agent needs to act without a round trip. The
|
|
250
317
|
// engine's own errors already carry that shape and pass through untouched.
|
|
251
318
|
if (isUltimateError(error)) throw error;
|
|
252
|
-
throw
|
|
253
|
-
code: 'X_DB_MIGRATE_FAILED',
|
|
254
|
-
// The blessed total renderer: `String(error)` runs the value's own `toString`, and
|
|
255
|
-
// this is the last hop before an agent is handed the three-line result.
|
|
256
|
-
cause: renderThrowable(error),
|
|
257
|
-
fix: 'x db reset',
|
|
258
|
-
});
|
|
319
|
+
throw migrateFailed(error);
|
|
259
320
|
}
|
|
260
321
|
// The ledger is the evidence for "applied" — never the migrator's own return value.
|
|
261
322
|
const pending = await pendingIds(root, lazy);
|
|
@@ -292,7 +353,7 @@ function capabilities(
|
|
|
292
353
|
|
|
293
354
|
async tailLogs(lines: number, role: string | undefined) {
|
|
294
355
|
const dir = lazy.services.stateDir;
|
|
295
|
-
const path =
|
|
356
|
+
const path = logTailPath(dir, role);
|
|
296
357
|
const file = Bun.file(path);
|
|
297
358
|
if (!(await file.exists())) {
|
|
298
359
|
// `@ultimat3/core`'s `logger` is a module const with no sink seam, so there is nothing to
|
|
@@ -305,7 +366,7 @@ function capabilities(
|
|
|
305
366
|
: `mkdir -p ${renderFixShellArg(join(dir, 'logs'), '<the logs dir of the path the cause names>')} && x dev --role ${role} > ${path} 2>&1`,
|
|
306
367
|
});
|
|
307
368
|
}
|
|
308
|
-
return (
|
|
369
|
+
return tailLines(file, lines);
|
|
309
370
|
},
|
|
310
371
|
|
|
311
372
|
async readManifest() {
|
package/src/pwa-artifacts.ts
CHANGED
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
import type { AssetPath } from '@ultimat3/render';
|
|
32
32
|
import { assetPathProblem } from '@ultimat3/render';
|
|
33
33
|
import { loadAppConfig } from './app-config-load';
|
|
34
|
+
import { assetRouteMeta } from './asset-route-meta';
|
|
34
35
|
import { hasSourceIcon, iconPlan, iconRenderer } from './icon-assets';
|
|
35
36
|
import type { AppLocales } from './pwa-manifest-locales';
|
|
36
37
|
import { appLocales, localeMembers, spellIn } from './pwa-manifest-locales';
|
|
@@ -253,13 +254,12 @@ export const pwaManifestRoute = (artifacts: PwaArtifacts): Route => ({
|
|
|
253
254
|
path: WEB_MANIFEST_PATH,
|
|
254
255
|
// `'path'`: `/en/manifest.webmanifest` reaches this route with its prefix split off and `en` as the
|
|
255
256
|
// locale, and the bare path is the default locale's — never negotiated, so a CDN may cache both.
|
|
256
|
-
meta: {
|
|
257
|
+
meta: assetRouteMeta({
|
|
257
258
|
name: 'assets.manifest',
|
|
258
259
|
auth: 'public',
|
|
259
260
|
cache: MANIFEST_CACHE,
|
|
260
|
-
tags: ['assets'],
|
|
261
261
|
localeSource: 'path',
|
|
262
|
-
},
|
|
262
|
+
}),
|
|
263
263
|
handler: async (_request: UltimateRequest, ctx: RequestContext): Promise<Response> =>
|
|
264
264
|
applyCacheHeaders(
|
|
265
265
|
// `textResponse` for the length it declares: `compress` reads nothing undeclared.
|
package/src/runtime-assets.ts
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
variantKey,
|
|
20
20
|
variantRevision,
|
|
21
21
|
} from '@ultimat3/storage';
|
|
22
|
+
import { assetRouteMeta } from './asset-route-meta';
|
|
22
23
|
import { faviconRoute } from './favicon';
|
|
23
24
|
// The icon matrix's source, its base path and its renderer live in their own module so that
|
|
24
25
|
// `pwa-artifacts.ts` — which this file imports for the manifest route — can reach them without
|
|
@@ -260,7 +261,7 @@ export function assetRoutes(options: AssetRoutesOptions): readonly Route[] {
|
|
|
260
261
|
const routes: Route[] = plan.entries.map((entry) => ({
|
|
261
262
|
method: 'GET',
|
|
262
263
|
path: entry.outputPath,
|
|
263
|
-
meta: { name: `assets.icon.${entry.spec.filename}`, auth: 'public'
|
|
264
|
+
meta: assetRouteMeta({ name: `assets.icon.${entry.spec.filename}`, auth: 'public' }),
|
|
264
265
|
// Revalidated, never `immutable` (22.3.2): the file name is the icon's SIZE, so a new
|
|
265
266
|
// `icon.png` shipped under the same URLs and every client that had seen the old one kept it for
|
|
266
267
|
// a year. The manifest and the apple-touch links name these paths, so a hashed URL would move
|
|
@@ -277,6 +278,8 @@ export function assetRoutes(options: AssetRoutesOptions): readonly Route[] {
|
|
|
277
278
|
routes.push({
|
|
278
279
|
method: 'GET',
|
|
279
280
|
path: `${MEDIA_BASE_PATH}/*key`,
|
|
281
|
+
// Tagged `assets` (the retained-build lookup reads the tag) but NOT on the `assets` bucket: an
|
|
282
|
+
// authenticated storage read per request is not a content-hashed chunk, so it stays `default`.
|
|
280
283
|
meta: {
|
|
281
284
|
name: 'assets.media',
|
|
282
285
|
auth: 'required',
|
package/src/site-asset-routes.ts
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
parseByteRange,
|
|
13
13
|
RANGE_UNSATISFIABLE,
|
|
14
14
|
} from '@ultimat3/http';
|
|
15
|
+
import { assetRouteMeta } from './asset-route-meta';
|
|
15
16
|
import type { SiteAsset, SiteAssetTable } from './site-assets';
|
|
16
17
|
import { parseHashedAssetUrl, SITE_ASSET_BASE_PATH } from './site-assets';
|
|
17
18
|
|
|
@@ -65,7 +66,7 @@ export function siteAssetRoutes(table: SiteAssetTable): readonly Route[] {
|
|
|
65
66
|
{
|
|
66
67
|
method: 'GET',
|
|
67
68
|
path: `${SITE_ASSET_BASE_PATH}/*file`,
|
|
68
|
-
meta: { name: 'assets.site', auth: 'public'
|
|
69
|
+
meta: assetRouteMeta({ name: 'assets.site', auth: 'public' }),
|
|
69
70
|
handler: (request: UltimateRequest): Response => {
|
|
70
71
|
const named = parseHashedAssetUrl(request.pathname);
|
|
71
72
|
if (named === undefined) {
|
package/src/style-routes.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import type { Route, UltimateRequest } from '@ultimat3/http';
|
|
7
7
|
import { applyCacheHeaders, jsonResponse, NO_STORE, textResponse } from '@ultimat3/http';
|
|
8
|
+
import { assetRouteMeta } from './asset-route-meta';
|
|
8
9
|
import type { StyleBundle } from './style-bundle';
|
|
9
10
|
import { STYLE_BASE_PATH } from './style-bundle';
|
|
10
11
|
|
|
@@ -28,7 +29,7 @@ export function styleRoutes(source: StyleSource): readonly Route[] {
|
|
|
28
29
|
{
|
|
29
30
|
method: 'GET',
|
|
30
31
|
path: `${STYLE_BASE_PATH}/*file`,
|
|
31
|
-
meta: { name: 'assets.style', auth: 'public'
|
|
32
|
+
meta: assetRouteMeta({ name: 'assets.style', auth: 'public' }),
|
|
32
33
|
handler: (request: UltimateRequest): Response => {
|
|
33
34
|
const chunk = source().chunkAt(request.pathname);
|
|
34
35
|
if (chunk === undefined) {
|
|
@@ -277,9 +277,12 @@ export function rawRepoSql(files: readonly RepoFile[]): readonly Finding[] {
|
|
|
277
277
|
export const guard: Guard = {
|
|
278
278
|
summary: 'a repo.ts reads through the typed handle, never a sql literal the handle can express',
|
|
279
279
|
async check(_root, sources) {
|
|
280
|
-
// The run's ONE read of these files: every guard asking for this glob shares the walk.
|
|
281
|
-
|
|
282
|
-
|
|
280
|
+
// The run's ONE read of these files: every guard asking for this glob shares the walk. A
|
|
281
|
+
// \`repo-<part>.ts\` is the same repo split at the file ceiling, so it is read too — but not a
|
|
282
|
+
// \`repo-<part>.test.ts\`, which the same glob reaches and whose fixture SQL is no repo's.
|
|
283
|
+
const repos = await sources.files('{apps,packages}/**/repo{,-*}.ts');
|
|
284
|
+
const read = repos.filter((file) => !file.path.endsWith('.test.ts'));
|
|
285
|
+
return rawRepoSql(read.map((file) => ({ path: file.path, source: file.text })));
|
|
283
286
|
},
|
|
284
287
|
};
|
|
285
288
|
`;
|
package/src/worker-bundle.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { dirname, join, relative } from 'node:path';
|
|
9
9
|
import type { Route, UltimateRequest } from '@ultimat3/http';
|
|
10
10
|
import { applyCacheHeaders, jsonResponse, NO_STORE, textResponse } from '@ultimat3/http';
|
|
11
|
+
import { assetRouteMeta } from './asset-route-meta';
|
|
11
12
|
import { FrameworkScriptBuildFailedError, type FrameworkScriptKind } from './errors';
|
|
12
13
|
import { describeBuildError, graphHash, stripDebugId } from './island-identity';
|
|
13
14
|
|
|
@@ -204,7 +205,7 @@ function scriptRoute(
|
|
|
204
205
|
return {
|
|
205
206
|
method: 'GET',
|
|
206
207
|
path: `${basePath}/:file`,
|
|
207
|
-
meta: { name, auth: 'public'
|
|
208
|
+
meta: assetRouteMeta({ name, auth: 'public' }),
|
|
208
209
|
handler: (request: UltimateRequest): Response => {
|
|
209
210
|
const script = source();
|
|
210
211
|
if (script === undefined || script.url !== request.pathname) {
|
|
@@ -315,14 +315,14 @@ export const db = database(entities, { driver });
|
|
|
315
315
|
| Raw `sql` | Where |
|
|
316
316
|
|---|---|
|
|
317
317
|
| belongs | a `query`'s source, built with `from()`; a migration |
|
|
318
|
-
| is the exception | a `repo.ts`, for what the handle cannot say: a join, an aggregate, a CTE, a window. Its unit test runs [the migrated-database recipe](Testing#database-state-and-what-a-run-leaves-behind): the handle's `testDriver()` follows the installed client, so the handle's writes and the join meet in one database |
|
|
319
|
-
| is refused | a `repo.ts`, for `select *` / `insert` / `update` / `delete` on one table, and `select * … where id = ? for update` (`db.<table>.lock(id, fn)`) |
|
|
318
|
+
| is the exception | a `repo.ts` or a `repo-<part>.ts`, for what the handle cannot say: a join, an aggregate, a CTE, a window. Its unit test runs [the migrated-database recipe](Testing#database-state-and-what-a-run-leaves-behind): the handle's `testDriver()` follows the installed client, so the handle's writes and the join meet in one database |
|
|
319
|
+
| is refused | a `repo.ts` or a `repo-<part>.ts`, for `select *` / `insert` / `update` / `delete` on one table, and `select * … where id = ? for update` (`db.<table>.lock(id, fn)`) |
|
|
320
320
|
| is refused, any statement | `order by date_trunc('milliseconds', …)`: the index cannot serve it. `keyset()` pages at the column's own precision |
|
|
321
321
|
|
|
322
322
|
| Enforced by | What fails |
|
|
323
323
|
|---|---|
|
|
324
324
|
| `tsc` | `db.widgets` exists only when `widget` is in the set; a renamed column is an error in the repo |
|
|
325
|
-
| `guards/repo-raw-sql.ts` — `X_REPO_RAW_SQL`, `boundaries` step | a `sql` literal in a `repo.ts` the handle can express; the `fix:` is the handle call |
|
|
325
|
+
| `guards/repo-raw-sql.ts` — `X_REPO_RAW_SQL`, `boundaries` step | a `sql` literal in a `repo.ts` or a `repo-<part>.ts` the handle can express; the `fix:` is the handle call |
|
|
326
326
|
| `X_DB_HANDLE_UNREGISTERED` — `x g entity`, `x g resource` | a `client.ts` with no `const <set> = { … }` passed to `database()`, or an `index.ts` that does not export the handle; the `fix:` is the lines to add |
|
|
327
327
|
|
|
328
328
|
### Paging a raw join
|
package/wiki/Interface-Rules.md
CHANGED
|
@@ -276,13 +276,13 @@ a `fix:` — documented where its subject is: [Entities and migrations](Entities
|
|
|
276
276
|
|
|
277
277
|
| Rule | Refused by | The `fix:` it names |
|
|
278
278
|
|---|---|---|
|
|
279
|
-
| A `repo.ts` reads through the typed handle | `guards/repo-raw-sql.ts` — a `sql` literal the handle can express: `select *`, `insert`, `update` or `delete` on one table, plain comparisons | the handle call: `db.posts.where({ orgId }).orderBy('createdAt', 'desc').limit(limit).all()` |
|
|
279
|
+
| A `repo.ts` or a `repo-<part>.ts` reads through the typed handle | `guards/repo-raw-sql.ts` — a `sql` literal the handle can express: `select *`, `insert`, `update` or `delete` on one table, plain comparisons | the handle call: `db.posts.where({ orgId }).orderBy('createdAt', 'desc').limit(limit).all()` |
|
|
280
280
|
|
|
281
281
|
| Not a finding | Why |
|
|
282
282
|
|---|---|
|
|
283
283
|
| a join, an aggregate, a CTE, a window, an `or`, a function call | the handle has no word for it; raw SQL in the repo is the answer |
|
|
284
284
|
| a statement composed from another `sql` fragment | composition, not one statement |
|
|
285
|
-
| `sql` in a `query`'s source, a migration, a comment or a string | only a tagged template in a `repo.ts` is read |
|
|
285
|
+
| `sql` in a `query`'s source, a migration, a comment or a string | only a tagged template in a `repo.ts` or a `repo-<part>.ts` is read |
|
|
286
286
|
|
|
287
287
|
A sheet that defines its own `@function rem` / `fluid` or `@mixin respond-*` is refused by
|
|
288
288
|
`raw-length` and `raw-breakpoint`: Sass lets a module that forwards the tokens redefine one with no
|
package/wiki/Project-Layout.md
CHANGED
|
@@ -64,7 +64,7 @@ Enforcement, not vigilance:
|
|
|
64
64
|
| A `shared/` module exceeding its own byte budget | build error, so `shared/ui` cannot silently fatten |
|
|
65
65
|
| `site/` route emitting >0kb JS without an explicit `hydrate` | build error |
|
|
66
66
|
| `app/` → `api/` | **types only** (`import type`); a runtime import is a build error, call the typed client instead |
|
|
67
|
-
| routes → DB | build error. Routes call actions/queries; only `repo.ts` touches the DB |
|
|
67
|
+
| routes → DB | build error. Routes call actions/queries; only `repo.ts` or a `repo-<part>.ts` touches the DB |
|
|
68
68
|
| components → business logic | build error via the feature-slice rule below |
|
|
69
69
|
| services → HTTP | build error. A service that knows about requests cannot be reused by a job |
|
|
70
70
|
|
|
@@ -99,7 +99,7 @@ apps/web/app/<feature>/ui/ # component
|
|
|
99
99
|
| File | Owns | Never — and the error |
|
|
100
100
|
|---|---|---|
|
|
101
101
|
| `entity.ts` | table + domain type + invariants | I/O, policy |
|
|
102
|
-
| `repo.ts` | the feature's reads and writes, through the typed handle | a raw SQL literal the handle can express — `guards/repo-raw-sql.ts` |
|
|
102
|
+
| `repo.ts` or a `repo-<part>.ts` | the feature's reads and writes, through the typed handle | a raw SQL literal the handle can express — `guards/repo-raw-sql.ts` |
|
|
103
103
|
| `service.ts` | business logic, composed from repos | an HTTP import — `X_BOUNDARY_SERVICE_TO_HTTP` |
|
|
104
104
|
| `page.tsx` · `layout.tsx` | a URL | a database import — `X_BOUNDARY_ROUTE_TO_DB` |
|
|
105
105
|
| `actions/` | `action` / `mutator` declarations, one per file | logic (delegate to `service.ts`) |
|
|
@@ -108,7 +108,7 @@ apps/web/app/<feature>/ui/ # component
|
|
|
108
108
|
| `policy.ts` | `policy` rules for this feature | data shaping |
|
|
109
109
|
| `ui/` | Solid components | fetching, business logic, its own authz |
|
|
110
110
|
|
|
111
|
-
A feature imports another feature through that feature's `service.ts` or its published types, never its `repo.ts` — a convention, **not a build error** (`As of 2026-10-06`: no boundary rule reads it from a `service.ts`). A **route** importing any `repo.ts` is a build error, `X_BOUNDARY_ROUTE_TO_DB`; `x new`'s own dashboard reads through the `postList` query (`../post/live/post-list`).
|
|
111
|
+
A feature imports another feature through that feature's `service.ts` or its published types, never its `repo.ts` — a convention, **not a build error** (`As of 2026-10-06`: no boundary rule reads it from a `service.ts`). A **route** importing any `repo.ts` or a `repo-<part>.ts` is a build error, `X_BOUNDARY_ROUTE_TO_DB`; `x new`'s own dashboard reads through the `postList` query (`../post/live/post-list`).
|
|
112
112
|
|
|
113
113
|
## App packages
|
|
114
114
|
|
package/wiki/Upgrading.md
CHANGED
|
@@ -203,7 +203,11 @@ A setter still on a package's `.` barrel is `X_ADAPTER_PORT_INCOMPLETE` on the `
|
|
|
203
203
|
| after that refresh, `x verify`'s `boundaries` step reports findings the old guards never saw — all of them already in your code: `X_IMAGE_DIMENSIONS`, `X_SEMANTIC_INTERACTIVE` or `X_UNTRANSLATED_STRING` in `apps/*/shared/**/*.tsx` (the three scanned only `site/` and `app/`); `X_RAW_MOTION` on a raw duration or `cubic-bezier()` assigned to a custom property (`--my-ease: cubic-bezier(0, 0, 1, 1)`); `X_UNDECLARED_CUSTOM_PROPERTY` at a stylesheet that does not compile, `X_UNDEFINED_STYLE_CLASS` at the `.tsx` line importing one — while any sheet fails, `undeclared-custom-property` reports only the broken sheets and checks no `var()` read | fix each where its `fix:` points: the `shared/` component as you would in `app/`; `--my-ease: #{tokens.easing(out)}` for a motion value; the Sass at the compiler error the cause quotes. Then re-run `x verify` — a repaired sheet can surface the `var()` reads it was hiding |
|
|
204
204
|
| the same refresh drops findings that were false: a file's own function named `confirm`, `fetch` or `setInterval` (a declaration, import, parameter or destructured name), `Intl.DateTimeFormat().resolvedOptions().timeZone`, and a `role="option"` with `tabIndex={-1}` | nothing — a rename made only to quiet one of them can be reverted |
|
|
205
205
|
| `x doctor` lists `native-confirm`, `raw-fetch` and `raw-interval` as differing from the shipped template after the **31.4.2** hop: their copy from 31.4.1 shows `\u2014` where two comments meant a dash. Comments only; the rule is the same | optional: `x g guard native-confirm --force`, `x g guard raw-fetch --force`, `x g guard raw-interval --force` |
|
|
206
|
+
| `x doctor` lists `repo-raw-sql` as differing from the shipped template after the **31.5.0** hop: the guard now also reads a `repo-<part>.ts` (a `repo.ts` split at the file ceiling, e.g. `repo-window.ts`) and skips `*.test.ts`; `x verify`'s `boundaries` step may report `X_REPO_RAW_SQL` in a split repo it never read before, and a route importing `repo-<part>` is now `X_BOUNDARY_ROUTE_TO_DB` like one importing `repo` | `x g guard repo-raw-sql --force` — it rewrites `guards/repo-raw-sql.ts` **and** its `.test.ts`, so review the diff and keep any rule you edited on purpose. Then `x verify` |
|
|
206
207
|
| `undeclared-custom-property` and `undefined-style-class` report `<sheet> does not compile: asset("assets/…") ran with no site asset table installed` on 31.4.1 for a sheet that calls Sass `asset()` and builds fine (on 31.4.0, `undeclared-custom-property` passed the whole app on nothing instead). From **31.4.2** a guard's compile resolves `asset()` through the site asset table the build uses, so the sheet compiles and an `asset()` naming a file missing from `apps/web/site/assets/` is still the finding. The fix is in `@ultimat3/cli`'s `GuardSources`, not in a template | nothing to refresh. Delete any placeholder asset table you installed around a guard to work around it, then `x verify` |
|
|
208
|
+
| built, content-hashed asset routes spend the new `assets` rate-limit bucket (**31.5.0**: 2,000 burst, 200/s), not `default`. An app that lowered `rateLimit.buckets.default` to throttle its static files no longer throttles them that way | to tighten static routes, set `rateLimit: { buckets: { assets: { capacity, refillPerSecond } } }` in `app.config.ts`. Nothing to do otherwise |
|
|
209
|
+
| `rateLimit.buckets` in `app.config.ts` merges over the shipped buckets key by key (**31.5.0**). Before, any `buckets` you declared replaced the whole table, so `auth`, `mutation` and `assets` were gone and routes naming them used `default` | nothing. A bucket you declared still wins under its own name; delete any copy of a shipped bucket you kept only so it would not disappear |
|
|
210
|
+
| a `from(entity, fn)` provider's function receives a `RowWindow` (**31.5.0**), `{ after, limit, order, filters }`, the page the read is after | nothing: a function that ignores the argument behaves as before. Optional: a repository that reads its own top N reads `after` and `limit` instead, so later pages are not empty or short |
|
|
207
211
|
|
|
208
212
|
## 29.x → 30.0.0, entry by entry
|
|
209
213
|
|