@ultimat3/cli 31.4.2 → 31.6.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 +15 -7
- package/package.json +29 -29
- package/src/admin-catalog-keys.ts +17 -1
- package/src/app-boundaries.ts +3 -2
- package/src/app-transport.ts +7 -3
- package/src/asset-route-meta.ts +29 -0
- package/src/browser-barrel-cut.ts +109 -0
- package/src/browser-import-chain.ts +119 -0
- package/src/browser-transport.ts +85 -13
- package/src/cmd-dev.ts +15 -2
- package/src/cmd-drill.ts +39 -9
- package/src/cmd-fix.ts +14 -4
- package/src/cmd-i18n.ts +52 -10
- package/src/dev-boot.ts +6 -4
- package/src/dev-log.ts +95 -0
- package/src/dev-rebuild-remount.ts +152 -0
- package/src/dev-rebuild-schema.ts +30 -0
- package/src/dev-rebuild.ts +51 -14
- package/src/dev-supervisor.ts +5 -4
- package/src/error-codes.ts +2 -0
- package/src/error-contract.ts +29 -2
- package/src/favicon.ts +2 -1
- package/src/fix-sequence.ts +97 -0
- package/src/generate-grant-findings.ts +2 -2
- package/src/generate-grants.ts +50 -1
- package/src/generate-write.ts +16 -0
- package/src/i18n-registration.ts +8 -5
- package/src/island-routes.ts +2 -1
- package/src/load-findings.ts +29 -22
- package/src/mcp-errors.ts +11 -3
- package/src/mcp-host-shell.ts +128 -0
- package/src/mcp-host.ts +81 -55
- package/src/mcp-test-output.ts +5 -2
- package/src/messages-gate.ts +12 -0
- package/src/messages.ts +16 -0
- package/src/policy-append.ts +88 -0
- 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/entity.ts +18 -3
- package/src/templates/guard-repo-raw-sql.ts +6 -3
- package/src/templates/policy.ts +5 -1
- package/src/templates/query.ts +4 -2
- package/src/templates/resource-service.ts +5 -2
- package/src/templates/scaffold-repo.ts +8 -2
- package/src/ts-scan.ts +86 -1
- package/src/verify-checks.ts +23 -51
- package/src/verify-contract-diff.ts +143 -0
- package/src/verify-seeds.ts +132 -0
- package/src/verify-tests.ts +12 -6
- package/src/worker-bundle.ts +2 -1
- package/wiki/CLI-Reference.md +2 -2
- 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 +7 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
// The `contract-diff` gate step: the contract the code builds now against the one last committed.
|
|
2
|
+
// Split from `verify-checks.ts` (at its ceiling) so the baseline — which file counts as "published"
|
|
3
|
+
// — is decided in one place beside the step that reads it.
|
|
4
|
+
|
|
5
|
+
// why: Bun has no synchronous existence check for `applies`.
|
|
6
|
+
import { existsSync } from 'node:fs';
|
|
7
|
+
// why: Bun ships no path joiner.
|
|
8
|
+
import { join } from 'node:path';
|
|
9
|
+
import type { Manifest } from '@ultimat3/manifest';
|
|
10
|
+
import { isManifest, MANIFEST_FILENAME, verifyContract } from '@ultimat3/manifest';
|
|
11
|
+
import { DEFAULT_REMOTE, fetchFixFor } from './affected-base';
|
|
12
|
+
import { appManifest, readAppManifest } from './app-manifest';
|
|
13
|
+
import type { Runner } from './exec';
|
|
14
|
+
import { msg } from './messages';
|
|
15
|
+
import type { Finding } from './output';
|
|
16
|
+
import { findingFrom } from './output';
|
|
17
|
+
import type { StepOutcome, VerifyStep } from './verify-step';
|
|
18
|
+
|
|
19
|
+
type Env = Readonly<Record<string, string | undefined>>;
|
|
20
|
+
|
|
21
|
+
/** The published contract, and — whenever it is not HEAD's file — the line saying what it is. */
|
|
22
|
+
export interface CommittedManifest {
|
|
23
|
+
readonly manifest?: Manifest;
|
|
24
|
+
readonly notice?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const file = MANIFEST_FILENAME;
|
|
28
|
+
|
|
29
|
+
/** A git call that answers `undefined` for every way of not answering — no binary included. */
|
|
30
|
+
async function gitOut(root: string, runner: Runner, args: readonly string[]) {
|
|
31
|
+
const result = await runner(['git', ...args], { cwd: root }).catch(() => undefined);
|
|
32
|
+
return result?.ok === true ? result.stdout : undefined;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const parsedManifest = (text: string): Manifest | undefined => {
|
|
36
|
+
try {
|
|
37
|
+
const parsed: unknown = JSON.parse(text);
|
|
38
|
+
return isManifest(parsed) ? parsed : undefined;
|
|
39
|
+
} catch {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The commit whose manifest is published. A pull request in CI (`GITHUB_BASE_REF`) has the
|
|
46
|
+
* rebaselined manifest committed at HEAD, so its baseline is the merge base with the target
|
|
47
|
+
* branch. A shallow checkout (CI's: depth 1, the base fetched at depth 1) reaches no merge base, and
|
|
48
|
+
* the fetched base ref itself is then the baseline — on a PR merge commit, its first parent. Only a
|
|
49
|
+
* base that is not fetched at all falls back to HEAD and names the fetch. Everywhere else, HEAD.
|
|
50
|
+
*/
|
|
51
|
+
async function baselineRev(root: string, runner: Runner, env: Env) {
|
|
52
|
+
const base = env['GITHUB_BASE_REF'];
|
|
53
|
+
if (base === undefined || base === '') return { rev: 'HEAD' };
|
|
54
|
+
const ref = `${DEFAULT_REMOTE}/${base}`;
|
|
55
|
+
const notice = msg('cli.verify.contract.mergeBase', { file, ref });
|
|
56
|
+
const sha = (await gitOut(root, runner, ['merge-base', 'HEAD', ref]))?.trim();
|
|
57
|
+
if (sha !== undefined && sha !== '') return { rev: sha, notice };
|
|
58
|
+
const tip = await gitOut(root, runner, ['rev-parse', '--verify', '--quiet', `${ref}^{commit}`]);
|
|
59
|
+
if (tip !== undefined)
|
|
60
|
+
return { rev: ref, notice: msg('cli.verify.contract.baseTip', { file, ref }) };
|
|
61
|
+
return {
|
|
62
|
+
rev: 'HEAD',
|
|
63
|
+
notice: msg('cli.verify.contract.baseUnfetched', { ref, file, fix: fetchFixFor(ref) }),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The contract as last COMMITTED, never the working-tree file: `x manifest` and every `x g`
|
|
69
|
+
* rewrite that one, so a breaking change diffed against it was green with no decision made (plan
|
|
70
|
+
* 101 19a FX4). Inside a checkout with no file at the baseline (never committed, or no commit yet)
|
|
71
|
+
* nothing is published, so there is no baseline. Outside a checkout (an unpacked tarball, a
|
|
72
|
+
* container with no `.git`) the file on disk is the only contract there is.
|
|
73
|
+
*/
|
|
74
|
+
export async function committedAppManifest(
|
|
75
|
+
root: string,
|
|
76
|
+
runner: Runner,
|
|
77
|
+
env: Env = {},
|
|
78
|
+
): Promise<CommittedManifest> {
|
|
79
|
+
if ((await gitOut(root, runner, ['rev-parse', '--is-inside-work-tree'])) === undefined) {
|
|
80
|
+
const notice = msg('cli.verify.contract.noCheckout', { file });
|
|
81
|
+
const manifest = await readAppManifest(root);
|
|
82
|
+
return manifest === undefined ? { notice } : { manifest, notice };
|
|
83
|
+
}
|
|
84
|
+
const { rev, notice: base } = await baselineRev(root, runner, env);
|
|
85
|
+
const withBase = (notice: string): string => (base === undefined ? notice : `${base}\n${notice}`);
|
|
86
|
+
const text = await gitOut(root, runner, ['show', `${rev}:./${file}`]);
|
|
87
|
+
if (text !== undefined) {
|
|
88
|
+
const manifest = parsedManifest(text);
|
|
89
|
+
if (manifest === undefined)
|
|
90
|
+
return { notice: withBase(msg('cli.verify.contract.notManifest', { file, rev })) };
|
|
91
|
+
return base === undefined ? { manifest } : { manifest, notice: base };
|
|
92
|
+
}
|
|
93
|
+
const head = await gitOut(root, runner, ['rev-parse', '--verify', '--quiet', 'HEAD']);
|
|
94
|
+
return {
|
|
95
|
+
notice: withBase(
|
|
96
|
+
head === undefined
|
|
97
|
+
? msg('cli.verify.contract.noCommit', { file })
|
|
98
|
+
: msg('cli.verify.contract.uncommitted', { file, rev }),
|
|
99
|
+
),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** A breaking change is allowed — with a major bump. `verifyContract` is the one that decides. */
|
|
104
|
+
function contractFindings(before: Manifest, after: Manifest): readonly Finding[] {
|
|
105
|
+
try {
|
|
106
|
+
verifyContract({ before, after });
|
|
107
|
+
return [];
|
|
108
|
+
} catch (error) {
|
|
109
|
+
return [{ ...findingFrom(error), at: MANIFEST_FILENAME }];
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* `built` — the manifest the code describes now — against the committed contract
|
|
115
|
+
* (`committedAppManifest`). Whenever the baseline is not HEAD's file, `output` says which.
|
|
116
|
+
*/
|
|
117
|
+
export async function contractDiffOutcome(
|
|
118
|
+
root: string,
|
|
119
|
+
runner: Runner,
|
|
120
|
+
built: Manifest,
|
|
121
|
+
env: Env = {},
|
|
122
|
+
): Promise<StepOutcome> {
|
|
123
|
+
const { manifest, notice } = await committedAppManifest(root, runner, env);
|
|
124
|
+
const findings = manifest === undefined ? [] : contractFindings(manifest, built);
|
|
125
|
+
return {
|
|
126
|
+
ok: findings.length === 0,
|
|
127
|
+
findings,
|
|
128
|
+
...(notice === undefined ? {} : { output: notice }),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export const contractDiffStep: VerifyStep = {
|
|
133
|
+
name: 'contract-diff',
|
|
134
|
+
summary: 'the published contract vs the manifest committed at HEAD (in CI: at the merge base)',
|
|
135
|
+
// A BREAKING change against the committed manifest, and nothing else. Whether the committed
|
|
136
|
+
// files are stale — `openapi.json` included — is the `manifest` step's, through the one check
|
|
137
|
+
// `x manifest --check` runs (`manifest-staleness.ts`).
|
|
138
|
+
applies: async (ctx) => existsSync(join(ctx.root, MANIFEST_FILENAME)),
|
|
139
|
+
async run(ctx) {
|
|
140
|
+
const { manifest } = await appManifest(ctx.root);
|
|
141
|
+
return contractDiffOutcome(ctx.root, ctx.runner, manifest, ctx.env ?? Bun.env);
|
|
142
|
+
},
|
|
143
|
+
};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// The seed run on the `unit` step: every seed the app declares (`SEED_GLOBS`) runs once, in file
|
|
2
|
+
// order, on one in-memory driver. A row its entity refuses — `{ minor: 19.99 }` typechecks — is
|
|
3
|
+
// reported with the entity's OWN code and fix, here, instead of 13 s later inside the e2e step's
|
|
4
|
+
// X_E2E_APP_FAILED. No seed file is no seeds: nothing is spawned.
|
|
5
|
+
|
|
6
|
+
import { ERROR_DOCS_URL, UltimateError } from '@ultimat3/core';
|
|
7
|
+
import type { Infer } from '@ultimat3/schema';
|
|
8
|
+
import { parse, t } from '@ultimat3/schema';
|
|
9
|
+
import { SEED_GLOBS } from './db-seed';
|
|
10
|
+
import type { Runner } from './exec';
|
|
11
|
+
import type { Finding } from './output';
|
|
12
|
+
import { findingFrom } from './output';
|
|
13
|
+
import { hasPathSegment } from './path-segments';
|
|
14
|
+
import { posixRelative } from './posix-path';
|
|
15
|
+
import { quoteArg } from './shell-quote';
|
|
16
|
+
import { isTest, sortedPosix } from './source-files';
|
|
17
|
+
|
|
18
|
+
const reportSchema = t.array(
|
|
19
|
+
t.object({
|
|
20
|
+
file: t.string,
|
|
21
|
+
/** The export that declared the seed; `*` when the module would not import. */
|
|
22
|
+
export: t.string,
|
|
23
|
+
seed: t.string,
|
|
24
|
+
code: t.nullable(t.string),
|
|
25
|
+
cause: t.nullable(t.string),
|
|
26
|
+
fix: t.nullable(t.string),
|
|
27
|
+
message: t.string,
|
|
28
|
+
}),
|
|
29
|
+
);
|
|
30
|
+
type SeedFailure = Infer<typeof reportSchema>[number];
|
|
31
|
+
|
|
32
|
+
/** The seed files `x db seed` would import, app-root-relative and sorted: the run's order. */
|
|
33
|
+
async function seedFiles(root: string): Promise<readonly string[]> {
|
|
34
|
+
const files = new Set<string>();
|
|
35
|
+
for (const pattern of SEED_GLOBS) {
|
|
36
|
+
for await (const absolute of new Bun.Glob(pattern).scan({ cwd: root, absolute: true })) {
|
|
37
|
+
const file = posixRelative(root, absolute);
|
|
38
|
+
if (hasPathSegment(absolute, 'node_modules') || isTest(file)) continue;
|
|
39
|
+
files.add(file);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return sortedPosix([...files]);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Run in a CHILD, from the app's root, for `verify-factories.ts`'s reason: the seeds, `isSeed` and
|
|
47
|
+
* `memoryDriver` must be the app's own `@ultimat3/entity`, and the app's entities must not register
|
|
48
|
+
* into this process. One driver for the whole run, so a later seed reads what an earlier one wrote,
|
|
49
|
+
* as `x db seed` does. The last stdout line is the report: the failures only.
|
|
50
|
+
*/
|
|
51
|
+
const script = (files: readonly string[]): string => `const files = ${JSON.stringify(files)};
|
|
52
|
+
const { isSeed, memoryDriver } = await import('@ultimat3/entity');
|
|
53
|
+
const driver = memoryDriver();
|
|
54
|
+
const str = (value, key) => { try { const v = value?.[key]; return typeof v === 'string' ? v : null; } catch { return null; } };
|
|
55
|
+
const failure = (file, name, seed, error) => ({ file, export: name, seed,
|
|
56
|
+
code: str(error, 'code'), cause: str(error, 'cause'), fix: str(error, 'fix'),
|
|
57
|
+
message: str(error, 'message') ?? (() => { try { return String(error); } catch { return 'a value that will not render'; } })() });
|
|
58
|
+
const failures = [];
|
|
59
|
+
for (const file of files) {
|
|
60
|
+
let mod;
|
|
61
|
+
try { mod = await import(\`\${process.cwd()}/\${file}\`); }
|
|
62
|
+
catch (error) { failures.push(failure(file, '*', '*', error)); continue; }
|
|
63
|
+
for (const [name, value] of Object.entries(mod)) {
|
|
64
|
+
if (!isSeed(value)) continue;
|
|
65
|
+
try { await value.run({ driver }); } catch (error) { failures.push(failure(file, name, value.name, error)); }
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
console.log(JSON.stringify(failures));`;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* A seed threw something with no code of its own (a `TypeError` in its body, a module that would
|
|
72
|
+
* not import). The fix is the one line that reproduces it with a full stack, on the same in-memory
|
|
73
|
+
* driver the unit step used — the seed's own file, its own export.
|
|
74
|
+
*/
|
|
75
|
+
export class SeedFailedError extends UltimateError {
|
|
76
|
+
constructor(input: { failure: SeedFailure; where: string }) {
|
|
77
|
+
const { failure } = input;
|
|
78
|
+
const call =
|
|
79
|
+
failure.export === '*'
|
|
80
|
+
? `await import('./${failure.file}')`
|
|
81
|
+
: `await (await import('./${failure.file}'))[${JSON.stringify(failure.export)}].run()`;
|
|
82
|
+
super({
|
|
83
|
+
code: 'X_SEED_FAILED',
|
|
84
|
+
cause: `${input.where} threw an uncoded value on the in-memory driver: ${failure.message}`,
|
|
85
|
+
fix: `bun --eval ${quoteArg(call)}`,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* The inner error, at the top level: a coded refusal keeps its code and its fix verbatim — the
|
|
92
|
+
* entity's fix is the one that names the edit — and only the cause gains which seed and file.
|
|
93
|
+
* An uncoded throw has no fix of its own, so the fix is the line that reproduces it with a stack.
|
|
94
|
+
*/
|
|
95
|
+
export const seedFinding = (failure: SeedFailure): Finding => {
|
|
96
|
+
const where =
|
|
97
|
+
failure.export === '*'
|
|
98
|
+
? `${failure.file} did not import`
|
|
99
|
+
: `seed "${failure.seed}" (${failure.file})`;
|
|
100
|
+
if (failure.code?.startsWith('X_') === true && failure.cause !== null && failure.fix !== null) {
|
|
101
|
+
return {
|
|
102
|
+
code: failure.code,
|
|
103
|
+
cause: `${where} on the in-memory driver: ${failure.cause}`,
|
|
104
|
+
fix: failure.fix,
|
|
105
|
+
docs: ERROR_DOCS_URL,
|
|
106
|
+
at: failure.file,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
return { ...findingFrom(new SeedFailedError({ failure, where })), at: failure.file };
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/** The child's last stdout line, parsed — or one finding saying the run printed no report. */
|
|
113
|
+
function readReport(stdout: string, stderr: string, first: string): readonly SeedFailure[] {
|
|
114
|
+
const last = stdout.trim().split('\n').at(-1) ?? '';
|
|
115
|
+
try {
|
|
116
|
+
return parse(reportSchema, JSON.parse(last));
|
|
117
|
+
} catch {
|
|
118
|
+
const reason = stderr.trim().split('\n').slice(-3).join(' ') || 'no report was printed';
|
|
119
|
+
return [
|
|
120
|
+
{ file: first, export: '*', seed: '*', code: null, cause: null, fix: null, message: reason },
|
|
121
|
+
];
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** The seed run's findings for the app at `root`; none when it declares no seed file. */
|
|
126
|
+
export async function seedFindings(root: string, runner: Runner): Promise<readonly Finding[]> {
|
|
127
|
+
const files = await seedFiles(root);
|
|
128
|
+
const first = files[0];
|
|
129
|
+
if (first === undefined) return [];
|
|
130
|
+
const result = await runner(['bun', '--eval', script(files)], { cwd: root });
|
|
131
|
+
return readReport(result.stdout, result.stderr, first).map(seedFinding);
|
|
132
|
+
}
|
package/src/verify-tests.ts
CHANGED
|
@@ -32,6 +32,7 @@ import { factoryFindings } from './verify-factories';
|
|
|
32
32
|
import { readVerifyFloor } from './verify-floor';
|
|
33
33
|
import type { MachinePace } from './verify-pace';
|
|
34
34
|
import { DECLARED_PACE, defaultTimeoutArgs, pacedMs, paceEnv } from './verify-pace';
|
|
35
|
+
import { seedFindings } from './verify-seeds';
|
|
35
36
|
import { shardFiles } from './verify-shard';
|
|
36
37
|
import type { ChangedTestSelection, StepOutcome, VerifyContext, VerifyStep } from './verify-step';
|
|
37
38
|
import { fromExec, fromFindings } from './verify-step';
|
|
@@ -449,16 +450,21 @@ const summaryOf = (type: TypedTest): string =>
|
|
|
449
450
|
Object.hasOwn(SUMMARIES, type) ? SUMMARIES[type] : `${type} tests`;
|
|
450
451
|
|
|
451
452
|
/**
|
|
452
|
-
* The unit suite, and an app's factory lint
|
|
453
|
-
*
|
|
454
|
-
*
|
|
453
|
+
* The unit suite, and beside it an app's factory lint (`verify-factories.ts`) and seed run
|
|
454
|
+
* (`verify-seeds.ts`): a factory or a seed row its entity refuses is found here, with the entity's
|
|
455
|
+
* own code, not by every test that uses it or inside e2e's X_E2E_APP_FAILED. The two are separate
|
|
456
|
+
* children run at once, so the step pays the slower one. Under `--shard` only slice 1 runs them,
|
|
457
|
+
* so `x verify merge` reports each finding once.
|
|
455
458
|
*/
|
|
456
459
|
const unitStep = async (ctx: VerifyContext): Promise<StepOutcome> => {
|
|
457
460
|
const suite = await runType(ctx, 'unit');
|
|
458
461
|
if (!isApp(ctx.root) || (ctx.shard !== undefined && ctx.shard.index !== 1)) return suite;
|
|
459
|
-
const factories = await
|
|
460
|
-
|
|
461
|
-
|
|
462
|
+
const [factories, seeds] = await Promise.all([
|
|
463
|
+
factoryFindings(ctx.root, ctx.runner),
|
|
464
|
+
seedFindings(ctx.root, ctx.runner),
|
|
465
|
+
]);
|
|
466
|
+
if (factories.length === 0 && seeds.length === 0) return suite;
|
|
467
|
+
return { ...suite, ok: false, findings: [...factories, ...seeds, ...suite.findings] };
|
|
462
468
|
};
|
|
463
469
|
|
|
464
470
|
const stepFor = (type: TestType): VerifyStep => {
|
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) {
|
package/wiki/CLI-Reference.md
CHANGED
|
@@ -1167,8 +1167,8 @@ whatever its bearer token was issued.
|
|
|
1167
1167
|
| `errors.explain` | `X_*` → cause, fix, docs | `dev:read` |
|
|
1168
1168
|
| `db.query` | ONE read-only SQL statement; `limit` defaults to 100 rows, maximum 1000 | `db:read` |
|
|
1169
1169
|
| `db.migrate` | apply pending migrations to a **branch** database | `db:migrate` |
|
|
1170
|
-
| `tests.run` |
|
|
1171
|
-
| `verify.run` |
|
|
1170
|
+
| `tests.run` | `x test [--filter]` itself — the shell's files, batches and environment, so it agrees with `x test`; structured results — an error outside any test (`1 error` beside `0 fail`) or a non-zero exit is a failure, never `failed: 0` | `dev:test` |
|
|
1171
|
+
| `verify.run` | `x verify` itself, so it agrees with the shell; `only: [steps]` is `--only` (not a gate run); structured per-step result | `dev:test` |
|
|
1172
1172
|
| `logs.tail` | last N log lines, optionally for one role | `dev:logs` |
|
|
1173
1173
|
| `graph.query` | `{ node }`: what a change to a file or primitive reaches (`x impact`); `{ from, to }`: the edges linking two nodes (`x graph --from --to`) | `dev:read` |
|
|
1174
1174
|
| `ui.shot` | photograph one route at a named viewport, light or dark; PNG path plus verdict. Launches a browser | `dev:test` |
|
|
@@ -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,14 @@ 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 |
|
|
211
|
+
| `x verify`'s `contract-diff` step is red, `X_MANIFEST_BREAKING`, on a breaking change that `x manifest` or `x g` had already written into `x.manifest.json`: from **31.6.0** the baseline is the manifest as committed (at `HEAD`, or at the merge base with `origin/$GITHUB_BASE_REF` in a GitHub pull request), never the working-tree file | bump the major version, or restore the removed surface. Regenerating the manifest no longer clears it |
|
|
212
|
+
| `x verify`'s `unit` step runs the app's seeds on the memory driver (**31.6.0**): a seed row the entity refuses — float money, a value its schema rejects — turns `unit` red under the entity's own code, and a seed that throws with no code is `X_SEED_FAILED` | fix the seed row the finding names, as its `fix:` says. Then `x verify --only unit` |
|
|
213
|
+
| `x verify`'s `errors` step reports `X_ERROR_FIX_INVALID` on an app's own error whose `fix:` defers the edit (a whitespace-delimited `# after <verb>ing …` or `# once <…>ed`), only says re-run, or runs `x g … --force` (**31.6.0**) | rewrite that `fix:` as the edit itself (`edit <path>.<ext>:<line> — <instruction>`) or a command that works on its own, with no `--force` |
|
|
207
214
|
|
|
208
215
|
## 29.x → 30.0.0, entry by entry
|
|
209
216
|
|