@ultimat3/cli 30.8.0 → 31.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +75 -64
- package/README.md +4 -1
- package/package.json +30 -29
- package/src/admin-registration.ts +1 -1
- package/src/affected.ts +5 -1
- package/src/app-boundaries.ts +88 -9
- package/src/app-load-async.ts +133 -0
- package/src/app-load-batch.ts +203 -0
- package/src/app-load-prebuilt.ts +147 -0
- package/src/app-load-register.ts +175 -0
- package/src/app-load.ts +143 -175
- package/src/app-loader-imports.ts +31 -0
- package/src/app-root.ts +13 -0
- package/src/app-runtime.ts +5 -1
- package/src/boundary-findings.ts +12 -0
- package/src/browser-launcher-port.ts +3 -7
- package/src/browser-launcher.ts +1 -1
- package/src/budgets-scan.ts +8 -0
- package/src/budgets.ts +10 -1
- package/src/build-registry-background.ts +59 -0
- package/src/build-registry.ts +207 -0
- package/src/cdp-shot-clock.ts +3 -11
- package/src/cdp-shot-driver.ts +3 -2
- package/src/cdp-shot-element.ts +3 -2
- package/src/cdp-shot-page.ts +2 -2
- package/src/cdp-shot-watch.ts +4 -3
- package/src/cmd-auth.ts +3 -3
- package/src/cmd-db-recount.ts +15 -0
- package/src/cmd-drill.ts +10 -6
- package/src/cmd-exercise.ts +2 -1
- package/src/cmd-generate-spec.ts +6 -0
- package/src/cmd-generate.ts +22 -4
- package/src/cmd-mail.ts +1 -1
- package/src/cmd-routes.ts +2 -2
- package/src/cmd-secrets-spec.ts +4 -1
- package/src/cmd-shot.ts +14 -4
- package/src/cmd-verify-spec.ts +21 -1
- package/src/cmd-verify.ts +16 -4
- package/src/coverage-source.ts +4 -1
- package/src/db-diagnostics.ts +8 -1
- package/src/dev-boot.ts +29 -15
- package/src/dev-dashboard-invalidations.ts +43 -0
- package/src/dev-dashboard.ts +13 -16
- package/src/dev-n-plus-one.ts +7 -3
- package/src/dev-rebuild.ts +2 -1
- package/src/dev-route-table.ts +1 -1
- package/src/dev-traces.ts +16 -15
- package/src/document-options.ts +12 -1
- package/src/drift-store.ts +55 -0
- package/src/error-catalog.ts +8 -3
- package/src/error-codes-boundary.ts +32 -0
- package/src/error-codes.ts +23 -19
- package/src/errors.ts +17 -7
- package/src/exercise-database.ts +13 -1
- package/src/exercise-findings.ts +36 -18
- package/src/exercise-services.ts +84 -0
- package/src/exercise-subject.ts +38 -13
- package/src/failure-capture-boot.ts +9 -5
- package/src/framework-schema.ts +5 -5
- package/src/generate-exercise.ts +1 -1
- package/src/generate-files.ts +27 -7
- package/src/generate-kinds.ts +5 -0
- package/src/generate-refresh.ts +53 -0
- package/src/generate-workspace.ts +169 -0
- package/src/generate-write.ts +8 -2
- package/src/hold.ts +19 -8
- package/src/image-prepare.ts +6 -2
- package/src/index.ts +5 -20
- package/src/island-bundle.ts +7 -3
- package/src/island-capture.ts +2 -2
- package/src/island-harness.ts +1 -1
- package/src/job-registration.ts +43 -6
- package/src/jobs-driver.ts +4 -5
- package/src/mcp-errors.ts +18 -4
- package/src/mcp-host.ts +5 -1
- package/src/mcp-ui-interact.ts +3 -0
- package/src/messages-gate.ts +4 -0
- package/src/new-shapes-generate.ts +1 -1
- package/src/otlp-export.ts +94 -29
- package/src/output.ts +3 -7
- package/src/page-sync.ts +3 -1
- package/src/role-load.ts +17 -11
- package/src/role-start.ts +5 -4
- package/src/role-sync.ts +7 -8
- package/src/route-islands-preload.ts +46 -0
- package/src/route-islands.ts +6 -2
- package/src/runtime-admin.ts +5 -1
- package/src/runtime-bindings.ts +25 -19
- package/src/runtime-boot-ports.ts +66 -0
- package/src/runtime-bus.ts +29 -5
- package/src/runtime-cache-bus.ts +53 -0
- package/src/runtime-cache.ts +43 -13
- package/src/runtime-isr-outcome.ts +5 -4
- package/src/runtime-jobs.ts +2 -2
- package/src/runtime-keys.ts +37 -0
- package/src/runtime-overrides.ts +148 -42
- package/src/runtime-port-bindings-queue.ts +36 -0
- package/src/runtime-port-bindings.ts +117 -0
- package/src/runtime-ports.ts +164 -0
- package/src/runtime-purge.ts +41 -28
- package/src/runtime-push.ts +7 -3
- package/src/runtime-queue.ts +70 -55
- package/src/runtime-realtime.ts +5 -5
- package/src/runtime-render-document.ts +4 -1
- package/src/runtime-services.ts +110 -158
- package/src/runtime-storage-boot.ts +111 -0
- package/src/runtime-storage-upload.ts +9 -7
- package/src/runtime-storage.ts +7 -1
- package/src/serve-boot.ts +8 -4
- package/src/serve-entry.ts +3 -0
- package/src/serve-env.ts +47 -14
- package/src/serve-prebuilt-paths.ts +3 -0
- package/src/serve-prebuilt.ts +15 -4
- package/src/serve.ts +2 -2
- package/src/static-cards.ts +3 -2
- package/src/static-report.ts +2 -2
- package/src/style-bundle.ts +1 -1
- package/src/sync-authenticator.ts +17 -18
- package/src/templates/action-tests.ts +4 -4
- package/src/templates/backfill.ts +5 -8
- package/src/templates/entity.ts +3 -0
- package/src/templates/github/ci.yml.ts +3 -1
- package/src/templates/github/dependabot.yml.ts +73 -0
- package/src/templates/job.ts +13 -22
- package/src/templates/naming.ts +20 -1
- package/src/templates/pinned/docker-compose.yml +1 -1
- package/src/templates/query.ts +7 -8
- package/src/templates/route.ts +5 -3
- package/src/templates/scaffold-api.ts +1 -1
- package/src/templates/scaffold-auth.ts +5 -3
- package/src/templates/scaffold-claude-commands.ts +6 -3
- package/src/templates/scaffold-claude.ts +4 -4
- package/src/templates/scaffold-container-compose.ts +2 -4
- package/src/templates/scaffold-domain-package.ts +1 -1
- package/src/templates/scaffold-entries.ts +6 -1
- package/src/templates/scaffold-helm-fences.ts +3 -2
- package/src/templates/scaffold-helm.ts +35 -6
- package/src/templates/scaffold-repo.ts +47 -135
- package/src/templates/scaffold-runtime-ports.ts +62 -0
- package/src/templates/scaffold-verify-floor.ts +97 -0
- package/src/templates/shapes/overlay.ts +1 -1
- package/src/templates/sign-in-oidc.ts +5 -3
- package/src/templates/sign-in-shared.ts +28 -10
- package/src/templates/workspace.ts +75 -0
- package/src/test-ignores.ts +5 -2
- package/src/test-select.ts +4 -1
- package/src/upgrade-gate.ts +30 -5
- package/src/upgrade-report.ts +7 -1
- package/src/verify-changed-facts.ts +53 -0
- package/src/verify-changed-scope.ts +161 -0
- package/src/verify-changed.ts +174 -0
- package/src/verify-checks.ts +31 -19
- package/src/verify-drift-owner.ts +30 -0
- package/src/verify-e2e.ts +2 -1
- package/src/verify-factories.ts +86 -0
- package/src/verify-run.ts +13 -11
- package/src/verify-step.ts +13 -0
- package/src/verify-tests.ts +58 -6
- package/src/write-line.ts +21 -6
- package/wiki/Actions.md +2 -2
- package/wiki/Adapters.md +400 -0
- package/wiki/Admin-Dashboard.md +2 -1
- package/wiki/Agents.md +9 -9
- package/wiki/Auth.md +78 -2
- package/wiki/Building-Your-Own-Base.md +1 -1
- package/wiki/CLI-Reference.md +34 -7
- package/wiki/Caching-And-Invalidation.md +17 -5
- package/wiki/Compared.md +8 -2
- package/wiki/Configuration.md +14 -14
- package/wiki/Deployment.md +28 -1
- package/wiki/Entities-And-Migrations.md +48 -2
- package/wiki/FAQ.md +8 -2
- package/wiki/Feature-Flags.md +1 -1
- package/wiki/Home.md +3 -2
- package/wiki/Jobs-And-Workflows.md +107 -6
- package/wiki/Known-Gaps.md +4 -3
- package/wiki/MCP-And-AI.md +18 -4
- package/wiki/Mail.md +14 -5
- package/wiki/Migrations-And-Backfills.md +31 -4
- package/wiki/Money.md +2 -0
- package/wiki/N-Plus-One-Detection.md +24 -22
- package/wiki/Notify.md +28 -4
- package/wiki/Observability.md +121 -15
- package/wiki/Queries-And-Live-Queries.md +2 -2
- package/wiki/Realtime.md +9 -4
- package/wiki/Routes-And-Render-Modes.md +5 -0
- package/wiki/Scraping.md +57 -11
- package/wiki/Shapes.md +2 -2
- package/wiki/Stability.md +7 -5
- package/wiki/Storage-And-Uploads.md +56 -4
- package/wiki/Testing.md +69 -56
- package/wiki/Troubleshooting.md +1 -1
- package/wiki/Tutorial-01-First-App.md +1 -1
- package/wiki/Tutorial-04-Jobs-And-Realtime.md +1 -1
- package/wiki/Tutorial-05-Deploy-Free.md +1 -1
- package/wiki/Tutorial-06-Growing-Up.md +8 -8
- package/wiki/Upgrading.md +129 -4
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
// The app's prebuilt module registry: every module the scan imports, in scan order, written by
|
|
2
|
+
// `x build --target prebuilt` as the scan's own batches (`batchSources`), and read by a serving
|
|
3
|
+
// role's boot instead of a scan (`app-load-prebuilt.ts`). A leaf of the boot graph: it writes and
|
|
4
|
+
// reads files and imports none of the app.
|
|
5
|
+
|
|
6
|
+
// why: Bun ships no recursive remove; a previous registry must not survive beside the new one.
|
|
7
|
+
import { rm } from 'node:fs/promises';
|
|
8
|
+
// why: Bun ships no path API; a chunk names each module relative to itself.
|
|
9
|
+
import { join, relative } from 'node:path';
|
|
10
|
+
import { isJsonObject } from '@ultimat3/core';
|
|
11
|
+
import type { AppScan } from './app-load';
|
|
12
|
+
import { scannedModulePaths } from './app-load';
|
|
13
|
+
import { asyncModules } from './app-load-async';
|
|
14
|
+
import { batchSources, planBatches, uniqueBatchName } from './app-load-batch';
|
|
15
|
+
import { backgroundModules } from './build-registry-background';
|
|
16
|
+
import { toPosix } from './posix-path';
|
|
17
|
+
import { PREBUILT_REGISTRY_DIR } from './serve-prebuilt-paths';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Bumped whenever the shape below changes: a registry of another format is not read. 2: a chunk
|
|
21
|
+
* imports a hook module per app module, which registers it before the next one evaluates. 3: a
|
|
22
|
+
* second chunk set, the background roles' (`background`), and the stamp it is trusted under.
|
|
23
|
+
*/
|
|
24
|
+
export const REGISTRY_FORMAT = 3;
|
|
25
|
+
|
|
26
|
+
const INDEX_FILE = 'registry.json';
|
|
27
|
+
|
|
28
|
+
/** The background chunks' directory, beside the full set's: their hook files share names. */
|
|
29
|
+
const BACKGROUND_DIR = 'background';
|
|
30
|
+
|
|
31
|
+
/** One ordered module list and the chunks that import it. */
|
|
32
|
+
export interface RegistryChunks {
|
|
33
|
+
/** App-root-relative POSIX paths, in scan order — the order the chunks import them in. */
|
|
34
|
+
readonly files: readonly string[];
|
|
35
|
+
/**
|
|
36
|
+
* Registry-dir-relative chunk files, in order, holding `files` in order between them: up to
|
|
37
|
+
* `BATCH_SIZE` each, and a module whose evaluation can suspend in a chunk of its own. Each
|
|
38
|
+
* imports the hook modules (`hookFile`) beside it, one per app module.
|
|
39
|
+
*/
|
|
40
|
+
readonly chunks: readonly string[];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** `registry.json`: what the chunks import, and what wrote them. */
|
|
44
|
+
export interface PrebuiltRegistry extends RegistryChunks {
|
|
45
|
+
readonly format: typeof REGISTRY_FORMAT;
|
|
46
|
+
/** The Bun that wrote it: a chunk is evaluated by the runtime that resolved its specifiers. */
|
|
47
|
+
readonly bun: string;
|
|
48
|
+
/**
|
|
49
|
+
* What `worker` and `scheduler` import (`build-registry-background.ts`), a subsequence of
|
|
50
|
+
* `files`. `stamp` is `moduleStamp` (the bytes) of every module at write time: which modules
|
|
51
|
+
* reach a document is a fact about their content, so a module edited since is answered by the
|
|
52
|
+
* scan.
|
|
53
|
+
*/
|
|
54
|
+
readonly background: RegistryChunks & { readonly stamp: string };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** The registry's directory under `root`. */
|
|
58
|
+
export const registryDir = (root: string): string => join(root, PREBUILT_REGISTRY_DIR);
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* A chunk's specifier for one module: relative to the chunk, so a registry written at one
|
|
62
|
+
* `WORKDIR` resolves at another — the image is the same tree wherever it is mounted.
|
|
63
|
+
*/
|
|
64
|
+
function specifierFor(dir: string, absolute: string): string {
|
|
65
|
+
const path = toPosix(relative(dir, absolute));
|
|
66
|
+
return path.startsWith('.') ? path : `./${path}`;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Reads at most this many modules at once: a 12k-module app opened 12k descriptors otherwise. */
|
|
70
|
+
const STAMP_BATCH = 64;
|
|
71
|
+
|
|
72
|
+
/** One module's bytes, hashed — or `absent` for a file that cannot be read. */
|
|
73
|
+
const contentHash = (path: string): Promise<string> =>
|
|
74
|
+
Bun.file(path)
|
|
75
|
+
.bytes()
|
|
76
|
+
.then(
|
|
77
|
+
(bytes) => Bun.hash(bytes).toString(16),
|
|
78
|
+
() => 'absent',
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* The bytes of every module of `files` (app-root-relative), hashed, path by path. Never a
|
|
83
|
+
* modification time: an image build that rewrites timestamps (BuildKit `rewrite-timestamp`, a
|
|
84
|
+
* stage that copies the app again) moves every one and changes no module, and a stamp built on
|
|
85
|
+
* them sent every worker boot to the scan. Measured on 5,101 modules (2026-11-10): 30–73 ms,
|
|
86
|
+
* median 51, against a 1.5 s boot.
|
|
87
|
+
*/
|
|
88
|
+
export async function moduleStamp(root: string, files: readonly string[]): Promise<string> {
|
|
89
|
+
const facts: string[] = [];
|
|
90
|
+
for (let start = 0; start < files.length; start += STAMP_BATCH) {
|
|
91
|
+
const batch = files.slice(start, start + STAMP_BATCH);
|
|
92
|
+
const hashes = await Promise.all(batch.map((file) => contentHash(join(root, file))));
|
|
93
|
+
for (const [index, file] of batch.entries()) facts.push(`${file}\0${hashes[index] ?? ''}`);
|
|
94
|
+
}
|
|
95
|
+
return Bun.hash(facts.join('\n')).toString(16);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Writes the chunks importing `modules` (absolute, scan order) under `registryDir/<prefix>`. */
|
|
99
|
+
async function writeChunks(
|
|
100
|
+
root: string,
|
|
101
|
+
prefix: string,
|
|
102
|
+
modules: readonly string[],
|
|
103
|
+
alone: ReadonlySet<string>,
|
|
104
|
+
): Promise<RegistryChunks> {
|
|
105
|
+
const dir = join(registryDir(root), prefix);
|
|
106
|
+
const chunks: string[] = [];
|
|
107
|
+
// Cut as the scan cuts: a module that awaits at its top level, or reaches one, is alone.
|
|
108
|
+
let first = 0;
|
|
109
|
+
for (const batch of planBatches(modules, alone)) {
|
|
110
|
+
const name = `chunk-${String(chunks.length)}.ts`;
|
|
111
|
+
const { entry, hooks } = batchSources(
|
|
112
|
+
batch.map((path) => specifierFor(dir, path)),
|
|
113
|
+
first,
|
|
114
|
+
);
|
|
115
|
+
await Promise.all(hooks.map(([hook, source]) => Bun.write(join(dir, hook), source)));
|
|
116
|
+
await Bun.write(join(dir, name), entry);
|
|
117
|
+
chunks.push(`${prefix}/${name}`);
|
|
118
|
+
first += batch.length;
|
|
119
|
+
}
|
|
120
|
+
return { files: modules.map((path) => toPosix(relative(root, path))), chunks };
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Writes the registry for `modules` (absolute paths, scan order) and answers it. Every earlier
|
|
125
|
+
* registry is removed first: a chunk left from a larger app would import a module that is gone.
|
|
126
|
+
*/
|
|
127
|
+
export async function writePrebuiltRegistry(
|
|
128
|
+
root: string,
|
|
129
|
+
modules: readonly string[],
|
|
130
|
+
): Promise<PrebuiltRegistry> {
|
|
131
|
+
await rm(registryDir(root), { recursive: true, force: true });
|
|
132
|
+
// Under a directory of this write's own: a process that writes a registry twice and boots from
|
|
133
|
+
// it (a test, `x build` beside `x serve`) would otherwise import the first write's cached hooks.
|
|
134
|
+
const own = uniqueBatchName();
|
|
135
|
+
const alone = await asyncModules(root, modules);
|
|
136
|
+
const everything = await writeChunks(root, own, modules, alone);
|
|
137
|
+
const background = await writeChunks(
|
|
138
|
+
root,
|
|
139
|
+
`${own}/${BACKGROUND_DIR}`,
|
|
140
|
+
await backgroundModules(root, modules),
|
|
141
|
+
alone,
|
|
142
|
+
);
|
|
143
|
+
const registry: PrebuiltRegistry = {
|
|
144
|
+
format: REGISTRY_FORMAT,
|
|
145
|
+
bun: Bun.version,
|
|
146
|
+
...everything,
|
|
147
|
+
background: { ...background, stamp: await moduleStamp(root, everything.files) },
|
|
148
|
+
};
|
|
149
|
+
await Bun.write(join(registryDir(root), INDEX_FILE), `${JSON.stringify(registry, null, 2)}\n`);
|
|
150
|
+
return registry;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const strings = (value: unknown): readonly string[] | undefined =>
|
|
154
|
+
Array.isArray(value) && value.every((one) => typeof one === 'string')
|
|
155
|
+
? (value as string[])
|
|
156
|
+
: undefined;
|
|
157
|
+
|
|
158
|
+
/** One chunk set as read, or `undefined` when it cannot hold its files in order. */
|
|
159
|
+
function chunksOf(value: unknown): RegistryChunks | undefined {
|
|
160
|
+
if (!isJsonObject(value)) return undefined;
|
|
161
|
+
const files = strings(value['files']);
|
|
162
|
+
const chunks = strings(value['chunks']);
|
|
163
|
+
if (files === undefined || chunks === undefined) return undefined;
|
|
164
|
+
// Every chunk holds one module at least; the boot checks the modules they hold add up to `files`.
|
|
165
|
+
if (chunks.length > files.length || (files.length > 0 && chunks.length === 0)) return undefined;
|
|
166
|
+
return { files, chunks };
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* The registry under `root`, or `undefined` when there is none this process can use: absent,
|
|
171
|
+
* unreadable, of another format, or written by another Bun.
|
|
172
|
+
*/
|
|
173
|
+
export async function readPrebuiltRegistry(root: string): Promise<PrebuiltRegistry | undefined> {
|
|
174
|
+
const parsed: unknown = await Bun.file(join(registryDir(root), INDEX_FILE))
|
|
175
|
+
.json()
|
|
176
|
+
.catch(() => undefined);
|
|
177
|
+
if (!isJsonObject(parsed)) return undefined;
|
|
178
|
+
if (parsed['format'] !== REGISTRY_FORMAT || parsed['bun'] !== Bun.version) return undefined;
|
|
179
|
+
const everything = chunksOf(parsed);
|
|
180
|
+
const background = chunksOf(parsed['background']);
|
|
181
|
+
const stamp = isJsonObject(parsed['background']) ? parsed['background']['stamp'] : undefined;
|
|
182
|
+
if (everything === undefined || background === undefined || typeof stamp !== 'string') {
|
|
183
|
+
return undefined;
|
|
184
|
+
}
|
|
185
|
+
return {
|
|
186
|
+
format: REGISTRY_FORMAT,
|
|
187
|
+
bun: Bun.version,
|
|
188
|
+
...everything,
|
|
189
|
+
background: { ...background, stamp },
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* The image build's half: after its own scan of the app, the registry of what that scan imported —
|
|
195
|
+
* or none, removing any earlier one, when a module would not import. A registry missing that
|
|
196
|
+
* module would boot without its routes and actions; with none, the boot scans and refuses to serve
|
|
197
|
+
* a half-loaded app (`X_APP_MODULE_LOAD_FAILED`), with the module's own cause.
|
|
198
|
+
*/
|
|
199
|
+
export async function prebuildRegistry(
|
|
200
|
+
root: string,
|
|
201
|
+
scan: AppScan,
|
|
202
|
+
): Promise<PrebuiltRegistry | undefined> {
|
|
203
|
+
if (scan.findings.length === 0)
|
|
204
|
+
return writePrebuiltRegistry(root, await scannedModulePaths(root));
|
|
205
|
+
await rm(registryDir(root), { recursive: true, force: true });
|
|
206
|
+
return undefined;
|
|
207
|
+
}
|
package/src/cdp-shot-clock.ts
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
// The
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
import { systemClock } from '@ultimat3/core';
|
|
5
|
-
import type { ShotClock } from './browser-launcher-port';
|
|
1
|
+
// The page deadline a shot run uses when it names none. The clock a session runs on is core's
|
|
2
|
+
// `SleepClock` — `systemClock` in a run, a `frozenClock` under test, where sleeping IS advancing,
|
|
3
|
+
// so a 30-second deadline finishes in microseconds (v31: `ShotClock` was that interface renamed).
|
|
6
4
|
|
|
7
5
|
/** A navigation or a wait with no `timeout` of its own gets this. */
|
|
8
6
|
export const DEFAULT_PAGE_TIMEOUT_MS = 30_000;
|
|
9
|
-
|
|
10
|
-
export const systemShotClock: ShotClock = Object.freeze({
|
|
11
|
-
now: () => systemClock.now(),
|
|
12
|
-
monotonic: () => systemClock.monotonic(),
|
|
13
|
-
sleep: (ms: number) => Bun.sleep(ms),
|
|
14
|
-
});
|
package/src/cdp-shot-driver.ts
CHANGED
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
// (`@ultimat3/testing`'s launcher, the one the e2e step already runs on) or ATTACH to one somebody
|
|
3
3
|
// else runs over `--cdp-url`. One `open()` is one browser and one page, so a picture's console and
|
|
4
4
|
// network are its own. The page is `cdp-shot-page.ts`; this file is the session around it.
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
import type { CdpConnection, LaunchedBrowser } from '@ultimat3/scraping/cdp';
|
|
6
7
|
import {
|
|
7
8
|
CdpBrowserMissingError,
|
|
8
9
|
CdpCallFailedError,
|
|
9
10
|
CHROME_CANDIDATES,
|
|
10
11
|
cdpConnect,
|
|
11
12
|
launchChrome,
|
|
12
|
-
} from '@ultimat3/
|
|
13
|
+
} from '@ultimat3/scraping/cdp';
|
|
13
14
|
import type { ShotDriver, ShotSession, ShotSessionInit } from './browser-launcher-port';
|
|
14
15
|
import { cdpShotPage } from './cdp-shot-page';
|
|
15
16
|
import { watchPage } from './cdp-shot-watch';
|
package/src/cdp-shot-element.ts
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// (layout box and hit-test included, which no DOM-only check can see), and the poll that waits for
|
|
3
3
|
// the first match to reach a state. Two refusals, because they are two questions: the page does
|
|
4
4
|
// not have the element, or it does and something keeps it from being acted on.
|
|
5
|
-
import type {
|
|
5
|
+
import type { SleepClock } from '@ultimat3/core';
|
|
6
|
+
import type { ActionabilityState, ElementSnapshot } from './browser-launcher-port';
|
|
6
7
|
import { ShotElementMissingError, ShotElementUnreadyError } from './cdp-shot-errors';
|
|
7
8
|
|
|
8
9
|
/** JSON text, so the answer has one deserialiser: `parseSnapshots` below. */
|
|
@@ -108,7 +109,7 @@ export interface ReadyWait {
|
|
|
108
109
|
readonly selector: string;
|
|
109
110
|
readonly state: ActionabilityState;
|
|
110
111
|
readonly timeoutMs: number;
|
|
111
|
-
readonly clock:
|
|
112
|
+
readonly clock: SleepClock;
|
|
112
113
|
/** Re-read on every poll: never a handle captured before the loop. */
|
|
113
114
|
readonly snapshot: () => Promise<ElementSnapshot | undefined>;
|
|
114
115
|
readonly url: () => string;
|
package/src/cdp-shot-page.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
// mouse press at the element's centre, a keystroke is a key event — because an in-page `.click()`
|
|
5
5
|
// skips `pointerdown`, which is what a dialog's backdrop listens to.
|
|
6
6
|
import { assert, finiteCount, hostDecision } from '@ultimat3/core';
|
|
7
|
-
import type { CdpConnection } from '@ultimat3/
|
|
8
|
-
import { CdpCallFailedError, CdpTimeoutError } from '@ultimat3/
|
|
7
|
+
import type { CdpConnection } from '@ultimat3/scraping/cdp';
|
|
8
|
+
import { CdpCallFailedError, CdpTimeoutError } from '@ultimat3/scraping/cdp';
|
|
9
9
|
import type {
|
|
10
10
|
ElementSnapshot,
|
|
11
11
|
ShotCapture,
|
package/src/cdp-shot-watch.ts
CHANGED
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
// every request is paused (`Fetch.requestPaused`) and refused unless its host is allowed, so an
|
|
4
4
|
// injected `<img src="http://169.254.169.254/…">` never leaves — it is recorded as `refused`.
|
|
5
5
|
// Paused at the BROWSER too, so a popup the page opens is decided by the same `hostDecision`.
|
|
6
|
+
|
|
7
|
+
import type { SleepClock } from '@ultimat3/core';
|
|
6
8
|
import { hostDecision } from '@ultimat3/core';
|
|
7
|
-
import type { CdpConnection } from '@ultimat3/
|
|
9
|
+
import type { CdpConnection } from '@ultimat3/scraping/cdp';
|
|
8
10
|
import type {
|
|
9
11
|
ConsoleLine,
|
|
10
12
|
NetworkEntry,
|
|
11
13
|
PageError,
|
|
12
|
-
ShotClock,
|
|
13
14
|
ShotResourceType,
|
|
14
15
|
} from './browser-launcher-port';
|
|
15
16
|
|
|
@@ -136,7 +137,7 @@ export function watchPage(input: {
|
|
|
136
137
|
readonly connection: CdpConnection;
|
|
137
138
|
readonly sessionId: string;
|
|
138
139
|
readonly browserSessionId?: string | undefined;
|
|
139
|
-
readonly clock:
|
|
140
|
+
readonly clock: SleepClock;
|
|
140
141
|
readonly allowHosts: readonly string[];
|
|
141
142
|
}): PageWatch {
|
|
142
143
|
const { connection, sessionId, browserSessionId } = input;
|
package/src/cmd-auth.ts
CHANGED
|
@@ -12,8 +12,7 @@ import type { CliCommand, CommandContext } from './command';
|
|
|
12
12
|
import { ok } from './command';
|
|
13
13
|
import { msg } from './messages';
|
|
14
14
|
import type { CommandResult } from './output';
|
|
15
|
-
import {
|
|
16
|
-
import { startQueue } from './runtime-queue';
|
|
15
|
+
import { openAppQueue } from './runtime-boot-ports';
|
|
17
16
|
|
|
18
17
|
export interface OpenAuthStore extends MfaSecretStore {
|
|
19
18
|
close(): Promise<void>;
|
|
@@ -25,7 +24,8 @@ export interface OpenAuthStore extends MfaSecretStore {
|
|
|
25
24
|
* exits holding the PGlite lock breaks the next command run against this app.
|
|
26
25
|
*/
|
|
27
26
|
async function openAppAuthStore(root: string, ctx: CommandContext): Promise<OpenAuthStore> {
|
|
28
|
-
|
|
27
|
+
// `runtime.ts` read: sealing asks the master key, and a KMS app's key is its `secretSource`'s.
|
|
28
|
+
const queue = await openAppQueue(root, ctx.env);
|
|
29
29
|
return { adapter: postgresAuthAdapter(queue.db), close: () => queue.stop() };
|
|
30
30
|
}
|
|
31
31
|
|
package/src/cmd-db-recount.ts
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
} from '@ultimat3/db';
|
|
13
13
|
import { countersOf, describeCounter, getEntity } from '@ultimat3/entity';
|
|
14
14
|
import { loadApp } from './app-load';
|
|
15
|
+
import { loadAppRuntime } from './app-runtime';
|
|
15
16
|
import type { CommandContext } from './command';
|
|
16
17
|
import { DevAlreadyRunningError, liveDevLock } from './dev-lock';
|
|
17
18
|
import { BadFlagError } from './errors';
|
|
@@ -19,6 +20,7 @@ import { msg } from './messages';
|
|
|
19
20
|
import type { CommandResult } from './output';
|
|
20
21
|
import { flagBool } from './parse';
|
|
21
22
|
import { resolveServices } from './runtime-bindings';
|
|
23
|
+
import { installBootPorts } from './runtime-boot-ports';
|
|
22
24
|
import { startDb } from './runtime-queue';
|
|
23
25
|
import { quoteArg } from './shell-quote';
|
|
24
26
|
|
|
@@ -54,7 +56,20 @@ function counterNamed(target: string) {
|
|
|
54
56
|
return { parent, counter: describeCounter(counter) };
|
|
55
57
|
}
|
|
56
58
|
|
|
59
|
+
/**
|
|
60
|
+
* `runtime.ts`'s boot ports first: `loadApp` evaluates the app's modules, and one that seals or
|
|
61
|
+
* reads a secret at module scope must see the app's own source and clock (`runtime-boot-ports.ts`).
|
|
62
|
+
*/
|
|
57
63
|
export async function runRecountCommand(ctx: CommandContext, root: string): Promise<CommandResult> {
|
|
64
|
+
const booted = await installBootPorts(await loadAppRuntime(root));
|
|
65
|
+
try {
|
|
66
|
+
return await recount(ctx, root);
|
|
67
|
+
} finally {
|
|
68
|
+
for (const release of booted.reverse()) await release();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async function recount(ctx: CommandContext, root: string): Promise<CommandResult> {
|
|
58
73
|
const target = ctx.args.positionals[0];
|
|
59
74
|
if (target === undefined) return refuse('', 'is missing: name the counter as <entity>.<column>');
|
|
60
75
|
const { findings } = await loadApp(root);
|
package/src/cmd-drill.ts
CHANGED
|
@@ -40,12 +40,16 @@ const READY_TIMEOUT_MS = 90_000;
|
|
|
40
40
|
/** `@ultimat3/http`'s own default — the app's `configureHttp` is runtime code, not config. */
|
|
41
41
|
const HTTP_DEFAULT_DEADLINE_MS = 30_000;
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
/**
|
|
44
|
+
* What the app runs on. NATS is the environment's (v31: `realtime.transport` is gone, and
|
|
45
|
+
* `NATS_URL` alone selects the bus), so an unset `NATS_URL` is an app with no bus to fault.
|
|
46
|
+
*/
|
|
47
|
+
const declarationsOf = (
|
|
48
|
+
config: AppConfig | undefined,
|
|
49
|
+
env: Readonly<Record<string, string | undefined>>,
|
|
50
|
+
): DrillDeclarations => ({
|
|
44
51
|
redis: config?.cache.tiers.includes('redis') ?? false,
|
|
45
|
-
nats:
|
|
46
|
-
config?.realtime.transport === 'nats'
|
|
47
|
-
? { env: config.realtime.urlEnv ?? 'NATS_URL' }
|
|
48
|
-
: undefined,
|
|
52
|
+
nats: (env['NATS_URL']?.trim() ?? '') === '' ? undefined : { env: 'NATS_URL' },
|
|
49
53
|
});
|
|
50
54
|
|
|
51
55
|
/** The facts the thresholds derive from; `drillBudgets` screens every number it is handed. */
|
|
@@ -116,7 +120,7 @@ export const drillCommand: CliCommand = {
|
|
|
116
120
|
});
|
|
117
121
|
}
|
|
118
122
|
const config = await loadAppConfig(root);
|
|
119
|
-
const declared = declarationsOf(config);
|
|
123
|
+
const declared = declarationsOf(config, ctx.env);
|
|
120
124
|
// Every drill's services, decided before any process starts. A named drill's gap is thrown; in
|
|
121
125
|
// a whole run an undeclared service is stated as not run — an unset URL still refuses it all.
|
|
122
126
|
const planned: { drill: Drill; services: ReturnType<typeof drillServices> }[] = [];
|
package/src/cmd-exercise.ts
CHANGED
|
@@ -117,7 +117,8 @@ async function exercise(
|
|
|
117
117
|
...(only === undefined ? entityTenantFindings(describeEntities()) : []),
|
|
118
118
|
...subjectStatic,
|
|
119
119
|
...subjectProofs,
|
|
120
|
-
|
|
120
|
+
// The fix pastes into the file the app has, or hands it the file it lacks.
|
|
121
|
+
...exerciseFindings(records, overrides === undefined ? 'absent' : 'present'),
|
|
121
122
|
];
|
|
122
123
|
return {
|
|
123
124
|
ok: findings.length === 0,
|
package/src/cmd-generate-spec.ts
CHANGED
|
@@ -25,6 +25,12 @@ export const generateSpec: CommandSpec = {
|
|
|
25
25
|
{ name: 'admin', type: 'boolean', summary: 'resource: also emit the admin override' },
|
|
26
26
|
{ name: 'locales', type: 'string', summary: 'comma-separated locales, default en' },
|
|
27
27
|
{ name: 'at', type: 'string', summary: 'island, admin:page: directory to write into' },
|
|
28
|
+
{
|
|
29
|
+
name: 'app',
|
|
30
|
+
type: 'string',
|
|
31
|
+
summary: 'route, island, query: app under apps/',
|
|
32
|
+
default: 'web',
|
|
33
|
+
},
|
|
28
34
|
{ name: 'permission', type: 'string', summary: 'admin:page: the permission it needs' },
|
|
29
35
|
{ name: 'oidc', type: 'string', summary: 'sign-in: an OpenID Connect provider id' },
|
|
30
36
|
{ name: 'password', type: 'boolean', summary: 'sign-in: an address and a password' },
|
package/src/cmd-generate.ts
CHANGED
|
@@ -17,17 +17,19 @@ import { appDisk, plannedDisk } from './generate-disk';
|
|
|
17
17
|
import { writtenExercises } from './generate-exercise';
|
|
18
18
|
import { assertFeatureExists } from './generate-feature';
|
|
19
19
|
import { assertSliceToRead } from './generate-feature-required';
|
|
20
|
-
import { generate, sliceDir } from './generate-files';
|
|
20
|
+
import { DEFAULT_APP, generate, sliceDir } from './generate-files';
|
|
21
21
|
import { followUpEdits } from './generate-follow-ups';
|
|
22
22
|
import { formatWritten } from './generate-format-written';
|
|
23
23
|
import type { Generator } from './generate-kinds';
|
|
24
24
|
import { readFeature, readKind, readName, readPermission, readSurface } from './generate-kinds';
|
|
25
25
|
import { refusePluralTable } from './generate-plural';
|
|
26
26
|
import { followReexports } from './generate-reexports';
|
|
27
|
+
import { manifestCanChange } from './generate-refresh';
|
|
27
28
|
import { refuseShadowedTypes, refuseShadowedValues } from './generate-shadow';
|
|
28
29
|
import { declaresOnlyOtherEntities } from './generate-sibling';
|
|
29
30
|
import { runSignIn } from './generate-sign-in';
|
|
30
31
|
import { refuseSignInFlags } from './generate-sign-in-mode';
|
|
32
|
+
import { isWorkspaceKind, readApp, runWorkspace } from './generate-workspace';
|
|
31
33
|
import { containedPath, planWrites, writeFiles } from './generate-write';
|
|
32
34
|
import { resolveDbModule } from './handle-registration';
|
|
33
35
|
import { resolveCatalogModule } from './i18n-audit';
|
|
@@ -79,6 +81,8 @@ export const generateCommand: CliCommand = {
|
|
|
79
81
|
if (kind === 'sign-in') return await runSignIn(ctx, root);
|
|
80
82
|
// One chart per app, named by its `Chart.yaml`: the same shape, for the same reason.
|
|
81
83
|
if (kind === 'chart-alerts') return await runChartAlerts(ctx, root);
|
|
84
|
+
// A workspace, not a slice: no feature, no surface, no follow-up edit (`generate-workspace.ts`).
|
|
85
|
+
if (isWorkspaceKind(kind)) return await runWorkspace(ctx, root, kind);
|
|
82
86
|
const name = readName(ctx.args.positionals[1], kind);
|
|
83
87
|
const featureFlag = readFeature(flagString(ctx.args, 'feature'), kind);
|
|
84
88
|
// Both flags are resolved before a single file is planned: a bad surface or a locale that is
|
|
@@ -86,6 +90,8 @@ export const generateCommand: CliCommand = {
|
|
|
86
90
|
const surface = readSurface(flagString(ctx.args, 'surface'), kind, name);
|
|
87
91
|
const locales = resolveLocales(await namedOrAppLocales(root, flagList(ctx.args, 'locales')));
|
|
88
92
|
const at = flagString(ctx.args, 'at');
|
|
93
|
+
// The app workspace the slice lands in; `web` unless an app-local generator names another.
|
|
94
|
+
const app = readApp(flagString(ctx.args, 'app'), root, kind, name);
|
|
89
95
|
// Read with the two above, and refused here for their reason: the value is spliced into the
|
|
90
96
|
// emitted source three times, and a value that is not a `<resource>:<verb>` is a page the app
|
|
91
97
|
// cannot compile — found after the files are on disk, which is the worst place to find it.
|
|
@@ -98,7 +104,7 @@ export const generateCommand: CliCommand = {
|
|
|
98
104
|
// And whether the app has the frame a resource's page sits in.
|
|
99
105
|
const shell = existsSync(containedPath(root, SHELL_MODULE));
|
|
100
106
|
// Read for the same reason: which errors the slice declares is written on THIS app's disk.
|
|
101
|
-
const slice = sliceDir(surface, kebab(featureFlag ?? name));
|
|
107
|
+
const slice = sliceDir(surface, kebab(featureFlag ?? name), app);
|
|
102
108
|
// A named slice that is not there is refused, never invented (X_FEATURE_UNKNOWN).
|
|
103
109
|
assertFeatureExists(root, kind, featureFlag, slice, name);
|
|
104
110
|
// And a read with no table to read, never handed one (X_FEATURE_REQUIRED).
|
|
@@ -135,6 +141,7 @@ export const generateCommand: CliCommand = {
|
|
|
135
141
|
...(sliceEntity === undefined ? {} : { sliceEntity }),
|
|
136
142
|
...(sliceRepo === undefined ? {} : { sliceRepo }),
|
|
137
143
|
...(at === undefined ? {} : { at }),
|
|
144
|
+
...(app === DEFAULT_APP ? {} : { app }),
|
|
138
145
|
...(permission === undefined ? {} : { permission }),
|
|
139
146
|
surface,
|
|
140
147
|
live: flagBool(ctx.args, 'live'),
|
|
@@ -207,8 +214,12 @@ export const generateCommand: CliCommand = {
|
|
|
207
214
|
const touched = refused.length === 0 ? [...plan.written, ...follow.edited] : [];
|
|
208
215
|
// Re-projected after a real write, from the loaded app: named, since their bytes are not
|
|
209
216
|
// knowable without the files on disk.
|
|
217
|
+
// By the rule the run follows (`generate-refresh.ts`): files that cannot move a manifest
|
|
218
|
+
// fact name no refresh, because the run will not load the app to make one.
|
|
210
219
|
const refreshes =
|
|
211
|
-
plan.written.length === 0 ||
|
|
220
|
+
plan.written.length === 0 ||
|
|
221
|
+
refused.length > 0 ||
|
|
222
|
+
!(await manifestCanChange(root, [...plan.written, ...follow.edited], planned))
|
|
212
223
|
? []
|
|
213
224
|
: [MANIFEST_FILENAME, 'openapi.json'].filter((file) =>
|
|
214
225
|
existsSync(containedPath(root, file)),
|
|
@@ -261,7 +272,14 @@ export const generateCommand: CliCommand = {
|
|
|
261
272
|
// `openapi.json` rides with it (`writeAppArtifacts`): refreshing one contract and not the other
|
|
262
273
|
// made this command's own output fail the `contract-diff` step.
|
|
263
274
|
const artifacts: string[] = [];
|
|
264
|
-
|
|
275
|
+
// And only when the run's files can move one of its facts: the load is the whole app, the one
|
|
276
|
+
// step of a scaffold that grows with it, and an island, a test or a stylesheet moves nothing
|
|
277
|
+
// it projects (`generate-refresh.ts`).
|
|
278
|
+
if (
|
|
279
|
+
report.written.length > 0 &&
|
|
280
|
+
existsSync(containedPath(root, MANIFEST_FILENAME)) &&
|
|
281
|
+
(await manifestCanChange(root, [...report.written, ...edited]))
|
|
282
|
+
) {
|
|
265
283
|
const { manifest, findings } = await appManifest(root);
|
|
266
284
|
if (findings.length === 0) {
|
|
267
285
|
artifacts.push(
|
package/src/cmd-mail.ts
CHANGED
|
@@ -28,7 +28,7 @@ export const mailCommand: CliCommand = {
|
|
|
28
28
|
throw new MissingPositionalError({
|
|
29
29
|
command: 'mail preview',
|
|
30
30
|
positional: 'id',
|
|
31
|
-
example: 'x mail preview
|
|
31
|
+
example: 'x mail preview <id> --locale es --json # the id given to defineMail({ id })',
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
await loadApp(root);
|
package/src/cmd-routes.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
// The rows are `route-table.ts`'s — the one builder the MCP dev tool `routes.list` reads too — so
|
|
5
5
|
// the CLI keeps no second table.
|
|
6
6
|
|
|
7
|
+
import { SURFACES } from '@ultimat3/core';
|
|
7
8
|
import type { Surface } from '@ultimat3/render';
|
|
8
|
-
import { SURFACES } from '@ultimat3/render';
|
|
9
9
|
import { loadApp } from './app-load';
|
|
10
10
|
import { requireAppRoot } from './app-root';
|
|
11
11
|
import { routesSpec } from './cmd-routes-spec';
|
|
@@ -20,7 +20,7 @@ import { plainAppRoutes, renderRouteRows, routeRows } from './route-table';
|
|
|
20
20
|
* A closed set, because the filter was a bare `===`: `x routes --surface App` and `--surface pages`
|
|
21
21
|
* matched no row and reported `0 routes` with exit 0, which is the same output an app with no
|
|
22
22
|
* routes gives — so a typo and an empty route table are indistinguishable, and only one of them is
|
|
23
|
-
* a bug the caller can see. `SURFACES` is `@ultimat3/
|
|
23
|
+
* a bug the caller can see. `SURFACES` is `@ultimat3/core`'s one declaration of what a surface
|
|
24
24
|
* is; a list restated here would be a second answer to it (`x g --surface` is `generate-kinds.ts`'s
|
|
25
25
|
* narrower question — which surface to SCAFFOLD onto — and takes site|app alone).
|
|
26
26
|
*/
|
package/src/cmd-secrets-spec.ts
CHANGED
|
@@ -8,7 +8,10 @@ export const SECRETS_SUBCOMMANDS = ['show', 'init', 'edit', 'set', 'rotate'] as
|
|
|
8
8
|
|
|
9
9
|
export const secretsSpec: CommandSpec = {
|
|
10
10
|
name: 'secrets',
|
|
11
|
-
|
|
11
|
+
// The key is read from the env and the file only, and the summary says so: importing
|
|
12
|
+
// `apps/<app>/runtime.ts` for its `secretSource` would run the app's boot guards, which may need
|
|
13
|
+
// the very secrets this command edits. A KMS/Vault source is the booted app's (`runtime.ts`).
|
|
14
|
+
summary: `the committed encrypted secrets, decrypted into the ${ENV_SCHEMA_EXPORT} variables of the same names; the master key is ULTIMATE_SECRETS_KEY or .secrets.key only — a runtime.ts secretSource is the booted app's`,
|
|
12
15
|
usage: 'x secrets [show|init|edit|set <NAME>|rotate [--drop <keyId>]] [--json]',
|
|
13
16
|
requiresApp: true,
|
|
14
17
|
subcommands: [...SECRETS_SUBCOMMANDS],
|
package/src/cmd-shot.ts
CHANGED
|
@@ -8,12 +8,13 @@
|
|
|
8
8
|
import { mkdirSync } from 'node:fs';
|
|
9
9
|
import { join, resolve } from 'node:path';
|
|
10
10
|
import { renderFixShellArg } from '@ultimat3/core';
|
|
11
|
+
import { systemClock } from '@ultimat3/core/adapter';
|
|
11
12
|
import { appLocaleSet } from '@ultimat3/i18n/app-catalogs';
|
|
12
13
|
import { IDLE_HYDRATE_TIMEOUT_MS } from '@ultimat3/render';
|
|
13
14
|
import { requireAppRoot } from './app-root';
|
|
14
15
|
import { appBrowser } from './browser-launcher';
|
|
15
16
|
import type { ShotColorScheme, ShotDriver, ShotPage, ShotSession } from './browser-launcher-port';
|
|
16
|
-
import { DEFAULT_PAGE_TIMEOUT_MS
|
|
17
|
+
import { DEFAULT_PAGE_TIMEOUT_MS } from './cdp-shot-clock';
|
|
17
18
|
import {
|
|
18
19
|
islandShot,
|
|
19
20
|
islandShotResult,
|
|
@@ -232,6 +233,14 @@ export interface ShotRun {
|
|
|
232
233
|
readonly act?:
|
|
233
234
|
| ((page: ShotPage, settle: () => Promise<IslandCount | null>) => Promise<void>)
|
|
234
235
|
| undefined;
|
|
236
|
+
/**
|
|
237
|
+
* The clock the settle window runs on — the same seam `SettleOptions.sleep` and
|
|
238
|
+
* `InteractDeps.sleep` take, and the reason they had none on this path: `settleMs` was a
|
|
239
|
+
* `Bun.sleep` here, so a caller that injected a sleep everywhere else still paid the real
|
|
240
|
+
* 2000 ms window in wall time once per `runShot`, and a test doing it twice raced its own
|
|
241
|
+
* per-test timeout on a slower box. Absent is `Bun.sleep`: production waits for real.
|
|
242
|
+
*/
|
|
243
|
+
readonly sleep?: ((ms: number) => Promise<void>) | undefined;
|
|
235
244
|
}
|
|
236
245
|
|
|
237
246
|
/** Nothing here may replace the failure that caused it, so a teardown throw is swallowed. */
|
|
@@ -247,6 +256,7 @@ const quietly = async (stop: () => Promise<void>): Promise<void> => {
|
|
|
247
256
|
*/
|
|
248
257
|
export async function runShot(options: ShotRun): Promise<ShotArtifacts> {
|
|
249
258
|
const server = await options.boot();
|
|
259
|
+
const sleep = options.sleep ?? ((ms: number): Promise<void> => Bun.sleep(ms));
|
|
250
260
|
let session: ShotSession | undefined;
|
|
251
261
|
try {
|
|
252
262
|
const requestedUrl = new URL(options.route, server.url).toString();
|
|
@@ -256,7 +266,7 @@ export async function runShot(options: ShotRun): Promise<ShotArtifacts> {
|
|
|
256
266
|
// inside your network is the widest SSRF surface an app can own, and a screenshot command is
|
|
257
267
|
// not the place to open it by default. Every refusal lands in the verdict's `refused` count.
|
|
258
268
|
rules: { allowHosts: allowHostsFrom(server.url, options.extraHosts) },
|
|
259
|
-
clock:
|
|
269
|
+
clock: systemClock,
|
|
260
270
|
timeoutMs: options.timeoutMs,
|
|
261
271
|
...(options.viewport === undefined ? {} : { viewport: options.viewport }),
|
|
262
272
|
...(options.acceptLanguage === undefined
|
|
@@ -276,7 +286,7 @@ export async function runShot(options: ShotRun): Promise<ShotArtifacts> {
|
|
|
276
286
|
// Read NOW as well as at capture: the network ring is bounded, and a page that fires a few
|
|
277
287
|
// hundred requests while it settles evicts the document entry the verdict needs.
|
|
278
288
|
const landedStatus = documentStatus(page.network(), page.url());
|
|
279
|
-
if (options.settleMs > 0) await
|
|
289
|
+
if (options.settleMs > 0) await sleep(options.settleMs);
|
|
280
290
|
// The probe may legitimately answer nothing — a page that refuses evaluation, a driver with no
|
|
281
291
|
// JS engine. `null` says so; a `0` would read as "the route renders no islands", which is a
|
|
282
292
|
// different and much more alarming claim.
|
|
@@ -289,7 +299,7 @@ export async function runShot(options: ShotRun): Promise<ShotArtifacts> {
|
|
|
289
299
|
// runtime CALLS `import()`, so a mount gets exactly as long to settle as the runtime got to
|
|
290
300
|
// start it — and `--settle 0`, which asks for no wait, still gets none.
|
|
291
301
|
const settle = (): Promise<IslandCount | null> =>
|
|
292
|
-
settleIslands(probe, { windowMs: options.settleMs, pollMs: SETTLE_POLL_MS });
|
|
302
|
+
settleIslands(probe, { windowMs: options.settleMs, pollMs: SETTLE_POLL_MS, sleep });
|
|
293
303
|
let islands = await settle();
|
|
294
304
|
if (options.act !== undefined) {
|
|
295
305
|
await options.act(page, async () => {
|
package/src/cmd-verify-spec.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// `x verify`'s declaration, apart from its body: the parser, `x help` and the `errors` step
|
|
2
2
|
// read it without loading `cmd-verify.ts`, which `registry.ts` imports only when the command runs.
|
|
3
3
|
|
|
4
|
+
import { DEFAULT_BASE } from './affected';
|
|
4
5
|
import type { CommandSpec } from './parse';
|
|
5
6
|
import { BUDGET_RULE, WORKER_BYTES, WORKER_CEILING, WORKER_FLOOR } from './test-workers';
|
|
6
7
|
|
|
@@ -11,7 +12,7 @@ export const verifySpec: CommandSpec = {
|
|
|
11
12
|
name: 'verify',
|
|
12
13
|
summary: 'the gate: typecheck, lint, boundaries, all tests, drift, contract, budgets',
|
|
13
14
|
usage:
|
|
14
|
-
'x verify [--only <step>[,<step>…] [--shard i/n [--timings file]]] [--workers N] [--isolate] [--json] · x verify merge <part.json…> [--json]',
|
|
15
|
+
'x verify [--only <step>[,<step>…] [--shard i/n [--timings file]] | --changed [--base <ref>] [--dirty]] [--workers N] [--isolate] [--json] · x verify merge <part.json…> [--json]',
|
|
15
16
|
requiresApp: true,
|
|
16
17
|
subcommands: VERIFY_SUBCOMMANDS,
|
|
17
18
|
defaultSubcommand: 'run',
|
|
@@ -33,6 +34,25 @@ export const verifySpec: CommandSpec = {
|
|
|
33
34
|
summary:
|
|
34
35
|
'run the named step(s), comma-separated, in one process — an iteration loop or one CI job, NOT A GATE RUN; the gate is this command with no flag, or `x verify merge` over every job',
|
|
35
36
|
},
|
|
37
|
+
{
|
|
38
|
+
name: 'changed',
|
|
39
|
+
type: 'boolean',
|
|
40
|
+
subcommands: ['run'],
|
|
41
|
+
summary:
|
|
42
|
+
'run only the steps whose inputs the diff touches, each named with the files that chose it (data.changed) — NOT A GATE RUN; never with --only',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: 'base',
|
|
46
|
+
type: 'string',
|
|
47
|
+
subcommands: ['run'],
|
|
48
|
+
summary: `with --changed: git ref to diff against, merge-base style, as x affected reads it (default: ${DEFAULT_BASE})`,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: 'dirty',
|
|
52
|
+
type: 'boolean',
|
|
53
|
+
subcommands: ['run'],
|
|
54
|
+
summary: 'with --changed: also count uncommitted and untracked work',
|
|
55
|
+
},
|
|
36
56
|
{
|
|
37
57
|
name: 'shard',
|
|
38
58
|
type: 'string',
|