@ultimat3/cli 31.43.0 → 31.44.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/package.json +29 -29
- package/src/cmd-env.ts +10 -3
- package/src/config-redact.ts +4 -7
- package/src/framework-schema-wait.ts +41 -9
- package/src/repro-scrub.ts +5 -5
- package/src/templates/guard-released-forms.ts +2 -0
- package/src/templates/guard-undeclared-env.ts +45 -7
- package/src/templates/guard-untranslated-string.ts +2 -2
- package/src/templates/shapes/agent-prompt.ts +44 -14
- package/src/templates/shapes/offline.ts +5 -2
- package/wiki/Migrations-And-Backfills.md +7 -2
- package/wiki/Realtime.md +1 -1
- package/wiki/Scraping.md +4 -2
- package/wiki/Upgrading.md +6 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultimat3/cli",
|
|
3
|
-
"version": "31.
|
|
3
|
+
"version": "31.44.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.10",
|
|
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.44.0",
|
|
57
|
+
"@ultimat3/admin": "31.44.0",
|
|
58
|
+
"@ultimat3/ai": "31.44.0",
|
|
59
|
+
"@ultimat3/auth": "31.44.0",
|
|
60
|
+
"@ultimat3/cache": "31.44.0",
|
|
61
|
+
"@ultimat3/core": "31.44.0",
|
|
62
|
+
"@ultimat3/db": "31.44.0",
|
|
63
|
+
"@ultimat3/entity": "31.44.0",
|
|
64
|
+
"@ultimat3/flags": "31.44.0",
|
|
65
|
+
"@ultimat3/http": "31.44.0",
|
|
66
|
+
"@ultimat3/i18n": "31.44.0",
|
|
67
|
+
"@ultimat3/jobs": "31.44.0",
|
|
68
|
+
"@ultimat3/mail": "31.44.0",
|
|
69
|
+
"@ultimat3/manifest": "31.44.0",
|
|
70
|
+
"@ultimat3/mcp": "31.44.0",
|
|
71
|
+
"@ultimat3/money": "31.44.0",
|
|
72
|
+
"@ultimat3/notify": "31.44.0",
|
|
73
|
+
"@ultimat3/policy": "31.44.0",
|
|
74
|
+
"@ultimat3/pwa": "31.44.0",
|
|
75
|
+
"@ultimat3/query": "31.44.0",
|
|
76
|
+
"@ultimat3/realtime": "31.44.0",
|
|
77
|
+
"@ultimat3/render": "31.44.0",
|
|
78
|
+
"@ultimat3/schema": "31.44.0",
|
|
79
|
+
"@ultimat3/scraping": "31.44.0",
|
|
80
|
+
"@ultimat3/seo": "31.44.0",
|
|
81
|
+
"@ultimat3/storage": "31.44.0",
|
|
82
|
+
"@ultimat3/testing": "31.44.0",
|
|
83
|
+
"@ultimat3/time": "31.44.0",
|
|
84
84
|
"babel-preset-solid": "^1.9.16"
|
|
85
85
|
}
|
|
86
86
|
}
|
package/src/cmd-env.ts
CHANGED
|
@@ -97,9 +97,16 @@ async function checkProcessEnv(ctx: CommandContext): Promise<CommandResult> {
|
|
|
97
97
|
...framework,
|
|
98
98
|
];
|
|
99
99
|
const ok = findings.length === 0;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
// The count is of DECLARED variables: a framework secret is no key of `envSchema`, so it is
|
|
101
|
+
// named by its code beside the count rather than counted into it ("3 of 2 declared").
|
|
102
|
+
const declared =
|
|
103
|
+
report.issues.length === 0
|
|
104
|
+
? msg('cli.env.checked', { count: total })
|
|
105
|
+
: msg('cli.env.invalid', { count: report.issues.length, total });
|
|
106
|
+
const verdict =
|
|
107
|
+
framework.length === 0
|
|
108
|
+
? declared
|
|
109
|
+
: `${declared} — ${framework.map((finding) => finding.code).join(', ')}`;
|
|
103
110
|
return {
|
|
104
111
|
ok,
|
|
105
112
|
command: 'env',
|
package/src/config-redact.ts
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
// The resolved `AppConfig` as JSON an operator may paste into an issue: every credential-named key
|
|
2
|
-
// and every `secret()` value replaced, a URL's password cut out of its userinfo.
|
|
3
|
-
// core's `isRedactedKey`
|
|
2
|
+
// and every `secret()` value replaced, a URL's password cut out of its userinfo. Both rules are
|
|
3
|
+
// core's — `isRedactedKey` (the logger's) and `redactUrlPassword` — so a field hidden there is here.
|
|
4
4
|
|
|
5
|
-
import { isRedactedKey, isSecret, REDACTED } from '@ultimat3/core';
|
|
5
|
+
import { isRedactedKey, isSecret, REDACTED, redactUrlPassword } from '@ultimat3/core';
|
|
6
6
|
import type { JsonValue } from './output';
|
|
7
7
|
|
|
8
|
-
/** `scheme://user:password@host` → `scheme://user:[redacted]@host`. The user stays: it is no secret. */
|
|
9
|
-
const USERINFO_PASSWORD = /^([a-z][a-z0-9+.-]*:\/\/[^:/@\s]*):[^@/\s]*@/i;
|
|
10
|
-
|
|
11
8
|
/** Past this depth a config is not data an operator wrote; the walk stops rather than recurse. */
|
|
12
9
|
const MAX_DEPTH = 16;
|
|
13
10
|
|
|
14
11
|
export function redactConfigValue(value: unknown, depth = 0): JsonValue {
|
|
15
12
|
if (isSecret(value)) return REDACTED;
|
|
16
13
|
if (value === null || value === undefined) return null;
|
|
17
|
-
if (typeof value === 'string') return value
|
|
14
|
+
if (typeof value === 'string') return redactUrlPassword(value);
|
|
18
15
|
if (typeof value === 'number') return Number.isFinite(value) ? value : String(value);
|
|
19
16
|
if (typeof value === 'boolean') return value;
|
|
20
17
|
// A config may carry a callback (a `health` probe, a `resolve` hook): named, never its source.
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
onShutdown,
|
|
13
13
|
UltimateError,
|
|
14
14
|
} from '@ultimat3/core';
|
|
15
|
+
import { dbUnavailable } from '@ultimat3/db';
|
|
15
16
|
import { SCHEMA_WAIT_ENV } from './framework-schema-stamp';
|
|
16
17
|
|
|
17
18
|
export { SCHEMA_WAIT_ENV };
|
|
@@ -26,6 +27,14 @@ export const DEFAULT_SCHEMA_WAIT_MS = 300_000;
|
|
|
26
27
|
const WAIT_BASE_MS = 1_000;
|
|
27
28
|
const WAIT_MAX_MS = 15_000;
|
|
28
29
|
|
|
30
|
+
/**
|
|
31
|
+
* The least any one schema read is given, deadline or none. The deadline bounds a read too — a
|
|
32
|
+
* catalog read on a blackholed database hangs until the pool gives up, ~125 s on a worker — but a
|
|
33
|
+
* read must be ALLOWED to answer: `0` is "refuse at once if behind", and the last read lands on the
|
|
34
|
+
* deadline by design. A reachable database answers a catalog read well inside a second.
|
|
35
|
+
*/
|
|
36
|
+
export const SCHEMA_READ_FLOOR_MS = 1_000;
|
|
37
|
+
|
|
29
38
|
/** `X_CONFIG_INVALID`: a deadline that is not whole milliseconds is refused, never read as NaN. */
|
|
30
39
|
export class SchemaWaitInvalidError extends UltimateError {
|
|
31
40
|
constructor(value: string) {
|
|
@@ -100,8 +109,12 @@ export async function waitForSchema<T>(
|
|
|
100
109
|
if (isDraining()) throw drained();
|
|
101
110
|
for (let attempt = 1; ; attempt += 1) {
|
|
102
111
|
// Raced against the drain like the sleep below: a read on an unreachable database hangs
|
|
103
|
-
// until the pool gives up — ~125 s on a worker, past the pod's grace, so SIGKILL (137).
|
|
104
|
-
|
|
112
|
+
// until the pool gives up — ~125 s on a worker, past the pod's grace, so SIGKILL (137). And
|
|
113
|
+
// against the deadline, which the read would otherwise outlive by that same ~125 s.
|
|
114
|
+
const boundMs = Math.max(deadlineMs - (clock.monotonic() - startedAt), SCHEMA_READ_FLOOR_MS);
|
|
115
|
+
const unanswered = (): UltimateError =>
|
|
116
|
+
refuse?.(clock.monotonic() - startedAt) ?? readUnanswered(boundMs, deadlineMs);
|
|
117
|
+
const verdict = await bounded(check(), stop.signal, drained, boundMs, unanswered);
|
|
105
118
|
if (verdict.ready) {
|
|
106
119
|
streak.passed();
|
|
107
120
|
return verdict.value;
|
|
@@ -150,19 +163,38 @@ function waitDrained(waitedMs = 0): UltimateError {
|
|
|
150
163
|
}
|
|
151
164
|
|
|
152
165
|
/**
|
|
153
|
-
* `
|
|
154
|
-
*
|
|
166
|
+
* `X_DB_UNAVAILABLE`, `@ultimat3/db`'s own refusal: the FIRST read never answered inside its bound,
|
|
167
|
+
* so there is no verdict to refuse with — only a database that does not answer.
|
|
168
|
+
*/
|
|
169
|
+
function readUnanswered(boundMs: number, deadlineMs: number): UltimateError {
|
|
170
|
+
return dbUnavailable(
|
|
171
|
+
`this role's first schema read did not answer within ${String(Math.round(boundMs))} ms (${SCHEMA_WAIT_ENV} is ${String(deadlineMs)}; a read is given at least ${String(SCHEMA_READ_FLOOR_MS)} ms)`,
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* `work`, unless `signal` aborts first — then `drained()` — or `boundMs` of REAL time pass — then
|
|
177
|
+
* `unanswered()`. Real time, never the injected clock: a database hangs in real time, and a frozen
|
|
178
|
+
* clock's `sleep` returns at once, which would cut every read a test makes. The abandoned read is
|
|
179
|
+
* not cancelled (the pool's own bound retires it); `Promise.race` keeps its late rejection handled.
|
|
155
180
|
*/
|
|
156
|
-
function
|
|
181
|
+
function bounded<V>(
|
|
157
182
|
work: Promise<V>,
|
|
158
183
|
signal: AbortSignal,
|
|
159
|
-
|
|
184
|
+
drained: () => UltimateError,
|
|
185
|
+
boundMs: number,
|
|
186
|
+
unanswered: () => UltimateError,
|
|
160
187
|
): Promise<V> {
|
|
161
188
|
let onAbort: () => void = () => undefined;
|
|
162
|
-
|
|
163
|
-
|
|
189
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
190
|
+
const cut = new Promise<never>((_resolve, reject) => {
|
|
191
|
+
onAbort = () => reject(drained());
|
|
164
192
|
if (signal.aborted) onAbort();
|
|
165
193
|
else signal.addEventListener('abort', onAbort, { once: true });
|
|
194
|
+
timer = setTimeout(() => reject(unanswered()), boundMs);
|
|
195
|
+
});
|
|
196
|
+
return Promise.race([work, cut]).finally(() => {
|
|
197
|
+
clearTimeout(timer);
|
|
198
|
+
signal.removeEventListener('abort', onAbort);
|
|
166
199
|
});
|
|
167
|
-
return Promise.race([work, aborted]).finally(() => signal.removeEventListener('abort', onAbort));
|
|
168
200
|
}
|
package/src/repro-scrub.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// config hostnames, any URL's userinfo and query values, emails and IPs become tokens; a frame's
|
|
4
4
|
// absolute path is made relative. A value it was never told about is NOT found: say so to the user.
|
|
5
5
|
|
|
6
|
-
import { isRedactedKey } from '@ultimat3/core';
|
|
6
|
+
import { isRedactedKey, replaceUrlUserinfo } from '@ultimat3/core';
|
|
7
7
|
|
|
8
8
|
export interface ScrubEnv {
|
|
9
9
|
readonly name: string;
|
|
@@ -153,12 +153,12 @@ const literal = (text: string): string => text.replace(/[.*+?^${}()|[\]\\]/g, '\
|
|
|
153
153
|
|
|
154
154
|
/** A URL in prose: its scheme, then everything up to a space, a quote or a bracket. */
|
|
155
155
|
const URL_TEXT = /\b[a-z][a-z0-9+.-]*:\/\/[^\s'"`<>()]+/gi;
|
|
156
|
-
/** Any URL's userinfo and query VALUES: credentials and tokens ride in both. */
|
|
156
|
+
/** Any URL's userinfo (to its LAST `@`) and query VALUES: credentials and tokens ride in both. */
|
|
157
157
|
function withoutUrlSecrets(text: string): string {
|
|
158
158
|
return text.replace(URL_TEXT, (url) =>
|
|
159
|
-
url
|
|
160
|
-
.replace(
|
|
161
|
-
|
|
159
|
+
replaceUrlUserinfo(url, () => '[cred]').replace(/\?[^#]*/, (query) =>
|
|
160
|
+
query.replace(/=[^&]*/g, '=[redacted]'),
|
|
161
|
+
),
|
|
162
162
|
);
|
|
163
163
|
}
|
|
164
164
|
|
|
@@ -71,6 +71,7 @@ export const RELEASED_GUARD_FORMS: Readonly<
|
|
|
71
71
|
['3b0u9i8hze00x', 'error'],
|
|
72
72
|
],
|
|
73
73
|
'undeclared-env': [
|
|
74
|
+
['1xkusngzbabza', 'error'],
|
|
74
75
|
['2jbihvbp83mb4', 'error'],
|
|
75
76
|
['3gsy96z8bgrrl', 'error'],
|
|
76
77
|
['81vvl6xx5bb8', 'error'],
|
|
@@ -82,6 +83,7 @@ export const RELEASED_GUARD_FORMS: Readonly<
|
|
|
82
83
|
'untranslated-string': [
|
|
83
84
|
['2x85ib5eqdxzi', 'error'],
|
|
84
85
|
['3j5e8t1k120u3', 'error'],
|
|
86
|
+
['d6gyn0l6szj8', 'error'],
|
|
85
87
|
['h57qtdwn7inz', 'error'],
|
|
86
88
|
],
|
|
87
89
|
'unzoned-date': [
|
|
@@ -48,6 +48,8 @@ const source =
|
|
|
48
48
|
// (\`apps/**\`, \`packages/**\`; never a test). Declared: a key of the \`envSchema\` export of
|
|
49
49
|
// \`app.config.ts\` — the one declaration \`x env check\` reads. A \`defineEnv(\` handed anything
|
|
50
50
|
// else (an inline \`{ … }\`) is refused: its record is unreachable once \`defineEnv\` returns values.
|
|
51
|
+
// Elsewhere, a record handed to \`defineEnv(\` — inline or a same-file \`const\` — names only keys
|
|
52
|
+
// \`envSchema\` declares: one built from \`envSchema.X\` reads it twice, never a second declaration.
|
|
51
53
|
// Allowed: every name the framework reads itself, \`NODE_ENV\` among them, and the OS's own.
|
|
52
54
|
|
|
53
55
|
import type { Finding, Guard } from '@ultimat3/cli';
|
|
@@ -72,6 +74,8 @@ const READ =
|
|
|
72
74
|
const OPENS = /\\bexport\\s+const\\s+envSchema\\b[^=]*=\\s*\\{/g;
|
|
73
75
|
/** A \`defineEnv(\` handed anything but \`envSchema\`: a declaration no command can read back. */
|
|
74
76
|
const OTHER_FORM = /\\bdefineEnv\\(\\s*(?!envSchema\\s*[,)])/g;
|
|
77
|
+
/** A \`defineEnv(\` call in app source: its record inline (\`{\`) or a name to resolve in the file. */
|
|
78
|
+
const CALL = /\\bdefineEnv\\(\\s*(?:(\\{)|([A-Za-z_$][\\w$]*))/g;
|
|
75
79
|
/** A key at the declaration's top level, once every nested group is emptied. */
|
|
76
80
|
const KEY = /(?:^|[{,\\s])['"]?([A-Za-z_$][\\w$]*)['"]?\\s*:/g;
|
|
77
81
|
|
|
@@ -100,18 +104,23 @@ const groupAt = (text: string, open: number): string => {
|
|
|
100
104
|
return text.slice(open + 1);
|
|
101
105
|
};
|
|
102
106
|
|
|
107
|
+
/** The top-level keys of the record opening at \`open\`, every nested group emptied first. */
|
|
108
|
+
const topLevelKeys = (text: string, open: number): readonly string[] => {
|
|
109
|
+
let body = groupAt(text, open);
|
|
110
|
+
// Innermost first, until none is left: a declaration's own \`{ type: … }\` keys are not names.
|
|
111
|
+
for (let before = ''; before !== body; ) {
|
|
112
|
+
before = body;
|
|
113
|
+
body = body.replaceAll(/\\{[^{}]*\\}|\\[[^[\\]]*\\]/g, ' ');
|
|
114
|
+
}
|
|
115
|
+
return [...body.matchAll(KEY)].map((key) => key[1] ?? '');
|
|
116
|
+
};
|
|
117
|
+
|
|
103
118
|
/** Every name \`app.config.ts\` declares: the top-level keys of each declaration it opens. */
|
|
104
119
|
export function declaredNames(config: string): ReadonlySet<string> {
|
|
105
120
|
const names = new Set<string>();
|
|
106
121
|
const text = blank(config);
|
|
107
122
|
for (const open of text.matchAll(OPENS)) {
|
|
108
|
-
|
|
109
|
-
// Innermost first, until none is left: a declaration's own \`{ type: … }\` keys are not names.
|
|
110
|
-
for (let before = ''; before !== body; ) {
|
|
111
|
-
before = body;
|
|
112
|
-
body = body.replaceAll(/\\{[^{}]*\\}|\\[[^[\\]]*\\]/g, ' ');
|
|
113
|
-
}
|
|
114
|
-
for (const key of body.matchAll(KEY)) names.add(key[1] ?? '');
|
|
123
|
+
for (const key of topLevelKeys(text, open.index + open[0].length - 1)) names.add(key);
|
|
115
124
|
}
|
|
116
125
|
return names;
|
|
117
126
|
}
|
|
@@ -173,11 +182,40 @@ const formFindings = (config: string): readonly Finding[] => {
|
|
|
173
182
|
const isFramework = (name: string): boolean =>
|
|
174
183
|
FRAMEWORK.has(name) || FRAMEWORK_PREFIXES.some((head) => name.startsWith(head));
|
|
175
184
|
|
|
185
|
+
/** Where the record a \`defineEnv(\` call is handed opens: inline, or a same-file \`const\`. */
|
|
186
|
+
const recordOpen = (text: string, call: RegExpMatchArray): number | undefined => {
|
|
187
|
+
if (call[1] !== undefined) return (call.index ?? 0) + call[0].length - 1;
|
|
188
|
+
const named = new RegExp(\`\\\\bconst\\\\s+\${call[2] ?? ''}\\\\b[^=]*=\\\\s*\\\\{\`).exec(text);
|
|
189
|
+
return named === null ? undefined : named.index + named[0].length - 1;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
/** A \`defineEnv(\` record in app source naming a key \`envSchema\` does not: invisible to \`x env\`. */
|
|
193
|
+
const recordFindings = (file: SourceFile, declared: ReadonlySet<string>): readonly Finding[] => {
|
|
194
|
+
const text = blank(file.source);
|
|
195
|
+
const code = codeOnly(text);
|
|
196
|
+
const findings: Finding[] = [];
|
|
197
|
+
for (const call of text.matchAll(CALL)) {
|
|
198
|
+
const open = code.charAt(call.index) === ' ' ? undefined : recordOpen(code, call);
|
|
199
|
+
if (open === undefined) continue;
|
|
200
|
+
for (const name of topLevelKeys(code, open)) {
|
|
201
|
+
if (declared.has(name) || isFramework(name) || AMBIENT.has(name)) continue;
|
|
202
|
+
findings.push({
|
|
203
|
+
code: CODE,
|
|
204
|
+
cause: \`\${file.path}:\${lineOf(text, call.index)} hands defineEnv a record declaring \${name}, which envSchema in app.config.ts does not — x env check, x env example, x secrets and x deploy never ask for it\`,
|
|
205
|
+
fix: \`add \${name}: { type: 'string', description: '…' } to envSchema in app.config.ts, read it as envSchema.\${name} in \${file.path}, then: x env example\`,
|
|
206
|
+
at: file.path,
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return findings;
|
|
211
|
+
};
|
|
212
|
+
|
|
176
213
|
/** Pure — the caller does the I/O — so the rule is testable without a filesystem. */
|
|
177
214
|
export function undeclaredEnv(files: readonly SourceFile[], config: string): readonly Finding[] {
|
|
178
215
|
const declared = declaredNames(config);
|
|
179
216
|
const findings: Finding[] = [...formFindings(config)];
|
|
180
217
|
for (const file of files) {
|
|
218
|
+
findings.push(...recordFindings(file, declared));
|
|
181
219
|
const text = blank(file.source);
|
|
182
220
|
const code = codeOnly(text);
|
|
183
221
|
for (const match of text.matchAll(READ)) {
|
|
@@ -102,7 +102,7 @@ export function untranslatedStrings(files: readonly SourceFile[]): readonly Find
|
|
|
102
102
|
findings.push({
|
|
103
103
|
code: CODE,
|
|
104
104
|
cause: \`\${file.path}:\${lineOf(text, match.index)} renders the typed string "\${typed}" inside <\${match[1] ?? 'element'}> — it is in no catalog, so every locale but the one it was typed in reads it verbatim\`,
|
|
105
|
-
fix: \`add a key for "\${typed}" to packages/i18n/catalogs/en.json, render it as {t('…')} in \${file.path}, then: x
|
|
105
|
+
fix: \`add a key for "\${typed}" to packages/i18n/catalogs/en.json, render it as {t('…')} in \${file.path}, then: x verify --only boundaries\`,
|
|
106
106
|
at: file.path,
|
|
107
107
|
});
|
|
108
108
|
}
|
|
@@ -113,7 +113,7 @@ export function untranslatedStrings(files: readonly SourceFile[]): readonly Find
|
|
|
113
113
|
findings.push({
|
|
114
114
|
code: CODE,
|
|
115
115
|
cause: \`\${file.path}:\${lineOf(text, match.index)} renders the typed string "\${typed}" as its \${name} — it is in no catalog, so every locale but the one it was typed in reads it verbatim\`,
|
|
116
|
-
fix: \`add a key for "\${typed}" to packages/i18n/catalogs/en.json, write it as \${name}={t('…')} in \${file.path}, then: x
|
|
116
|
+
fix: \`add a key for "\${typed}" to packages/i18n/catalogs/en.json, write it as \${name}={t('…')} in \${file.path}, then: x verify --only boundaries\`,
|
|
117
117
|
at: file.path,
|
|
118
118
|
});
|
|
119
119
|
}
|
|
@@ -8,6 +8,7 @@ import { ASSISTANT_DIR } from './agent-model';
|
|
|
8
8
|
|
|
9
9
|
const DIR = `${ASSISTANT_DIR}/prompts`;
|
|
10
10
|
const EVAL = 'assistant.suggest-title';
|
|
11
|
+
const PROMPT_FILE = `${DIR}/suggest-title.ts`;
|
|
11
12
|
|
|
12
13
|
const TEMPLATE = `You title posts for a team. Someone wants a new post about the topic below.
|
|
13
14
|
|
|
@@ -64,7 +65,8 @@ const templateLiteral = (text: string): string =>
|
|
|
64
65
|
const prompt = (): string => `/**
|
|
65
66
|
* The prompt behind \`suggestTitle\` (\`../actions/suggest-title.ts\`). No \`model\`: the environment
|
|
66
67
|
* names it (\`../model.ts\`), so the gateway's \`defaultModel\` answers. Editing the template requires
|
|
67
|
-
* bumping \`version\` and re-recording the baseline — the hash keys the traces and the eval
|
|
68
|
+
* bumping \`version\` and re-recording the baseline — the hash keys the traces and the eval, and
|
|
69
|
+
* the eval test refuses a baseline re-recorded under the old version (\`X_EVAL_BASELINE_MISSING\`).
|
|
68
70
|
*/
|
|
69
71
|
|
|
70
72
|
import { definePrompt } from '@ultimat3/ai';
|
|
@@ -89,9 +91,15 @@ import type { Scorer } from '@ultimat3/ai';
|
|
|
89
91
|
import { calledTool, defineEval, jsonSchemaValid } from '@ultimat3/ai';
|
|
90
92
|
import { userActor } from '@ultimat3/core';
|
|
91
93
|
import { suggestTitle } from '../actions/suggest-title';
|
|
94
|
+
import { suggestTitlePrompt } from './suggest-title';
|
|
92
95
|
|
|
93
96
|
const ORG = '00000000-0000-4000-8000-0000000000a1';
|
|
94
97
|
|
|
98
|
+
/** One baseline per prompt version: an edited template is a new version, recorded afresh. */
|
|
99
|
+
export const BASELINE = import.meta.resolve(
|
|
100
|
+
\`./suggest-title.v\${suggestTitlePrompt.version}.baseline.json\`,
|
|
101
|
+
);
|
|
102
|
+
|
|
95
103
|
/** What \`postTitles\` answers in every case: the titles the team already has. */
|
|
96
104
|
export const EXISTING = ['Money is minor units and a currency', 'Every date names its time zone'];
|
|
97
105
|
|
|
@@ -136,7 +144,7 @@ export const suggestTitleEval = defineEval({
|
|
|
136
144
|
name: '${EVAL}',
|
|
137
145
|
agent: suggestTitle,
|
|
138
146
|
actor: writer,
|
|
139
|
-
baseline:
|
|
147
|
+
baseline: BASELINE,
|
|
140
148
|
tolerance: 0.05,
|
|
141
149
|
tools: { postTitles: () => ({ titles: EXISTING }) },
|
|
142
150
|
scorers: [jsonSchemaValid(['title']), notExisting, titleShaped, calledTool('postTitles')],
|
|
@@ -150,13 +158,18 @@ const evalTest =
|
|
|
150
158
|
// one regression that is caught.
|
|
151
159
|
|
|
152
160
|
import type { ScriptedTurn } from '@ultimat3/ai';
|
|
153
|
-
import {
|
|
161
|
+
import {
|
|
162
|
+
baselinePath,
|
|
163
|
+
EvalBaselineMissingError,
|
|
164
|
+
readBaseline,
|
|
165
|
+
recordingBaselines,
|
|
166
|
+
} from '@ultimat3/ai';
|
|
154
167
|
import { expect, test } from '@ultimat3/testing';
|
|
155
168
|
// The registration: the agent's tool is offered under the name \`defineApi\` gives it.
|
|
156
169
|
import '../../../api/index';
|
|
157
170
|
import { scriptedGateway } from '../scripted-model';
|
|
158
171
|
import { suggestTitlePrompt } from './suggest-title';
|
|
159
|
-
import { EXISTING, suggestTitleCases, suggestTitleEval } from './suggest-title.evals';
|
|
172
|
+
import { BASELINE, EXISTING, suggestTitleCases, suggestTitleEval } from './suggest-title.evals';
|
|
160
173
|
|
|
161
174
|
/** What the model answered when the baseline was recorded, keyed by case name. */
|
|
162
175
|
const RECORDED: Readonly<Record<string, string>> = {
|
|
@@ -171,7 +184,29 @@ const turns = (title: (name: string) => string, look: boolean): readonly Scripte
|
|
|
171
184
|
{ answer: { title: title(testCase.name) } },
|
|
172
185
|
]);
|
|
173
186
|
|
|
187
|
+
/**
|
|
188
|
+
* This version's baseline was recorded against THIS template. Called before \`assert\`, which
|
|
189
|
+
* re-records under ULTIMATE_EVAL_RECORD=1: an edit that kept \`version\` is refused there too.
|
|
190
|
+
*/
|
|
191
|
+
async function refuseAnEditUnderItsVersion(): Promise<void> {
|
|
192
|
+
const path = baselinePath(BASELINE, '${EVAL}');
|
|
193
|
+
const recorded = await readBaseline(path);
|
|
194
|
+
// A bumped version has no baseline yet: the record run writes it, the gate refuses its absence.
|
|
195
|
+
if (recorded === undefined && recordingBaselines()) return;
|
|
196
|
+
if (recorded?.promptHash === suggestTitlePrompt.hash) return;
|
|
197
|
+
throw new EvalBaselineMissingError({
|
|
198
|
+
eval: '${EVAL}',
|
|
199
|
+
path,
|
|
200
|
+
reason:
|
|
201
|
+
recorded === undefined
|
|
202
|
+
? 'has never been recorded'
|
|
203
|
+
: \`was recorded against another template of version \${suggestTitlePrompt.version}\`,
|
|
204
|
+
fix: 'ULTIMATE_EVAL_RECORD=1 x test eval # after bumping version in ${PROMPT_FILE}: an edited template is a new version',
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
|
|
174
208
|
test('suggest-title holds its recorded scores, reading the titles first', async () => {
|
|
209
|
+
await refuseAnEditUnderItsVersion();
|
|
175
210
|
const { gateway } = scriptedGateway(turns((name) => RECORDED[name] ?? '', true));
|
|
176
211
|
const run = await suggestTitleEval.assert(gateway);
|
|
177
212
|
expect(run.passed).toBe(true);
|
|
@@ -181,14 +216,6 @@ test('suggest-title holds its recorded scores, reading the titles first', async
|
|
|
181
216
|
);
|
|
182
217
|
});
|
|
183
218
|
|
|
184
|
-
test('the baseline was recorded against this template: an edit re-records it', async () => {
|
|
185
|
-
const path = baselinePath(
|
|
186
|
-
import.meta.resolve('./suggest-title.v1.baseline.json'),
|
|
187
|
-
'${EVAL}',
|
|
188
|
-
);
|
|
189
|
-
expect((await readBaseline(path))?.promptHash).toBe(suggestTitlePrompt.hash);
|
|
190
|
-
});
|
|
191
|
-
|
|
192
219
|
// Through \`run\`, never \`assert\`: \`assert\` re-records under ULTIMATE_EVAL_RECORD=1.
|
|
193
220
|
test('a model that repeats a taken title without looking is caught', async () => {
|
|
194
221
|
const { gateway } = scriptedGateway(turns(() => EXISTING[0] ?? '', false));
|
|
@@ -245,10 +272,13 @@ const baseline = (): string =>
|
|
|
245
272
|
|
|
246
273
|
export function promptFiles(): readonly GeneratedFile[] {
|
|
247
274
|
return [
|
|
248
|
-
{ path:
|
|
275
|
+
{ path: PROMPT_FILE, contents: prompt() },
|
|
249
276
|
{ path: `${DIR}/suggest-title.evals.ts`, contents: evals() },
|
|
250
277
|
{ path: `${DIR}/suggest-title.eval.test.ts`, contents: evalTest() },
|
|
251
278
|
{ path: `${DIR}/suggest-title.evals.test.ts`, contents: scorerTest() },
|
|
252
|
-
{
|
|
279
|
+
{
|
|
280
|
+
path: `${DIR}/suggest-title.v${SUGGEST_TITLE_PROMPT.version}.baseline.json`,
|
|
281
|
+
contents: baseline(),
|
|
282
|
+
},
|
|
253
283
|
];
|
|
254
284
|
}
|
|
@@ -27,7 +27,10 @@ const OFFLINE_BUDGET = ` // measured: 158,171 B (\`bunx x verify --only budgets
|
|
|
27
27
|
// IndexedDB outbox that replays a write made offline) beside the form; the default form's
|
|
28
28
|
// transport-only island was 64,167 B. A raise states its own measured bytes and why here, in the
|
|
29
29
|
// same diff (\`X_BUDGET_EXCEEDED\`).
|
|
30
|
-
|
|
30
|
+
// raised 155kb → 156kb, measured: 158,737 B (2026-11-17) — the page boot 84,889 + the island
|
|
31
|
+
// 72,576 + inline 1,272. why: +12 B in each chunk, \`uuidV7\` minting at timestamp 0 for a clock
|
|
32
|
+
// before 1970 (it used to throw), in core's ids, which both chunks carry.
|
|
33
|
+
budget: { js: '156kb' },`;
|
|
31
34
|
|
|
32
35
|
const lan = (): string => `## 📶 Offline, and on your LAN
|
|
33
36
|
|
|
@@ -74,7 +77,7 @@ const edits = (): readonly ShapeEdit[] => [
|
|
|
74
77
|
{
|
|
75
78
|
path: 'apps/web/app/posts/page.test.ts',
|
|
76
79
|
find: " expect(page.config.budget.js).toBe('66kb');",
|
|
77
|
-
replace: " expect(page.config.budget.js).toBe('
|
|
80
|
+
replace: " expect(page.config.budget.js).toBe('156kb');",
|
|
78
81
|
},
|
|
79
82
|
// A write replayed from the outbox may already have landed: the key answers it, never twice.
|
|
80
83
|
{
|
|
@@ -11,7 +11,7 @@ One engine per concern. A **migration** changes the shape of a table — schema,
|
|
|
11
11
|
| Add, rename, retype, drop a column or table; add an index or constraint | a **migration** — `x db gen "<name>"` |
|
|
12
12
|
| Add an index to a big, hot table, or drop one from it | a **migration** too — `indexes: [{ on }]`: on an existing table the build is concurrent by default, and every drop is concurrent already. [Indexes built concurrently](#indexes-built-concurrently--expand--contract) |
|
|
13
13
|
| Rewrite, normalize, re-derive or backfill values in rows that already exist | a **backfill** — `backfill({ … })` |
|
|
14
|
-
| Add a nullable column, then populate every existing row before making it required | both: the migration adds the column, the backfill sweeps the rows, a second migration adds the `not null` once the sweep is done (expand → migrate → contract) |
|
|
14
|
+
| Add a nullable column, then populate every existing row before making it required | both: the migration adds the column, the backfill sweeps the rows, a second migration adds the `not null` once the sweep is done (expand → migrate → contract). Declaring it required at once writes both halves in one `x db gen` — [Foreign keys and CHECKs on a live table](#foreign-keys-and-checks-on-a-live-table) |
|
|
15
15
|
|
|
16
16
|
## Migrations: one engine, one ledger
|
|
17
17
|
|
|
@@ -271,10 +271,15 @@ An embedded scratch boot restores a post-`initdb` snapshot instead of running `i
|
|
|
271
271
|
| A key on a table this migration creates | the plain `add constraint` in the transaction, byte-identical to before — unless the unique index it needs is built by the deferred step, which would otherwise be `42830`. Then it defers too |
|
|
272
272
|
| A key re-added after a retype | the transaction: the rewrite holds ACCESS EXCLUSIVE already |
|
|
273
273
|
| A CHECK on a live table | `add constraint … not valid` in the transaction (it needs no index), `validate constraint` in the deferred step. New writes are held to it at once. A new table's stays in `create table` |
|
|
274
|
-
| `
|
|
274
|
+
| A column becoming NOT NULL (`As of 2026-11-17`) | a new NOT NULL column with no default: `add column` NULLABLE in the transaction, whose snapshot records it nullable. Then — for it, or for an existing column turned NOT NULL — the `_concurrently` step: `add constraint "<t>_<c>_not_null_check" check ("c" is not null) not valid`, `validate constraint`, `set not null` (Postgres proves it from the validated check, no scan), the check dropped. A key column owes none: `add primary key` makes it NOT NULL |
|
|
275
|
+
| `down` | restore the old key, drop the new key, drop the index; a contracted column `drop not null` |
|
|
275
276
|
|
|
276
277
|
`x db migrate` re-runs a failed step from the top. `validate` finding a bad row is `X_DB_FOREIGN_KEY_VIOLATION` (or the CHECK's own failure) with the constraint in place holding new writes and the old release still serving: repair the row, re-run. A declared constraint left `NOT VALID` in a database whose ledger says the step ran is `X_DB_DRIFT`, kind `not-valid-constraint`, and its fix is the validate statement.
|
|
277
278
|
|
|
279
|
+
A NOT NULL contract is the same story. On an empty table — a fresh or `x db reset` database — both steps apply and drift is clean: one `x db gen`, one `x db migrate`. On a table holding NULL there, the validate fails (`X_DB_STATEMENT_FAILED`, the cause naming `<t>_<c>_not_null_check`), the expand step stays applied and recorded nullable, and the database is not drift: backfill the rows, then `x db migrate` finishes the step. On a populated production table that means two releases — declare the column `.nullable()` and ship it with its `backfill()`, then declare it required and `x db gen` writes the contract alone.
|
|
280
|
+
|
|
281
|
+
**Before 2026-11-17** `x db gen` left a comment, `-- backfill "c", then: alter table … set not null;`, and recorded the column NOT NULL in that file's snapshot. Every database that ran it — a fresh one included — failed `x db migrate` with `X_DB_DRIFT` (`changed-column`), and a second `x db gen` wrote nothing. An app holding such a file, with the comment never carried out: declare the column `.nullable()`, `x db gen "relax c"` (a `drop not null`, a no-op on a database already repaired, and a snapshot that tells the truth), then declare it required again and `x db gen "contract c"`.
|
|
282
|
+
|
|
278
283
|
## A column drop takes two releases
|
|
279
284
|
|
|
280
285
|
`As of 2026-11-02`. Old and new pods serve one schema during a roll, and the old release names every column it declares in every read and insert, so a drop in the release that stops declaring it answers `X_DB_SCHEMA_STALE` from every old pod.
|
package/wiki/Realtime.md
CHANGED
|
@@ -670,7 +670,7 @@ No channel kind carries an ordered, two-way byte stream to a browser — a termi
|
|
|
670
670
|
|
|
671
671
|
## Wire protocol version
|
|
672
672
|
|
|
673
|
-
`PROTOCOL_VERSION` is **3** `As of 2026-09-22` (21.0.0; it was 2 from 2026-08-24) ([`packages/realtime/src/sync-protocol.ts`](https://github.com/developerz-ai/ultimate/blob/main/packages/realtime/src/sync-protocol.ts)). A mismatch is `X_PROTOCOL_VERSION` on the frame, with one instruction, rather than a per-field decode error nobody can act on.
|
|
673
|
+
`PROTOCOL_VERSION` is **3** `As of 2026-09-22` (21.0.0; it was 2 from 2026-08-24) ([`packages/realtime/src/sync-protocol.ts`](https://github.com/developerz-ai/ultimate/blob/main/packages/realtime/src/sync-protocol.ts)). A mismatch is `X_PROTOCOL_VERSION` on the frame, with one instruction, rather than a per-field decode error nobody can act on. A throw with no code (a live query's `TypeError`) is `X_INTERNAL` on the ack, its cause withheld as HTTP withholds an unclassified 5xx's — never `X_PROTOCOL_VERSION`, whose rebuild cannot repair a server bug. `As of 2026-11`.
|
|
674
674
|
|
|
675
675
|
**Clients and `sync` nodes must be redeployed together across this bump.** A cursor rides in BOTH directions — the client's `subscribe` and the node's `snapshot` — so a skew breaks resume from either side.
|
|
676
676
|
|
package/wiki/Scraping.md
CHANGED
|
@@ -212,7 +212,8 @@ The `/robots.txt` read is deadlined (10s), capped (500 KiB) and dialled through
|
|
|
212
212
|
| The read | Means | The gate |
|
|
213
213
|
|---|---|---|
|
|
214
214
|
| `2xx` | the file | its rules, cached for the run |
|
|
215
|
-
| `
|
|
215
|
+
| `2xx` with a body past the cap (500 KiB) | the file's head | the whole lines inside the cap are parsed (RFC 9309 §2.5), cached for the run; a head with no line end is **unreachable** |
|
|
216
|
+
| `4xx` (not `429`), a redirect off the list or past the hop cap | **unavailable** | no restrictions, cached for the run |
|
|
216
217
|
| `5xx`, `429`, a refused connection, the deadline, the run cancelled, a `fetchText` that rejects | **unreachable** | complete disallow — every path on the origin is `X_SCRAPE_ROBOTS_DISALLOWED` — and **not** cached: the next navigation asks again, so the run recovers when the file answers |
|
|
217
218
|
|
|
218
219
|
`429` is the one row that is **our policy, not the RFC's**: RFC 9309 calls every `4xx` unavailable, `429` included. Ultimate refuses on it because a server rate-limiting the crawler has not said "no rules" — stricter than the RFC requires, never looser.
|
|
@@ -270,7 +271,8 @@ Reuse is both the fast path and the safe path — logging in on every run is slo
|
|
|
270
271
|
|---|---|
|
|
271
272
|
| this store's sealed record, saved under this key | the session |
|
|
272
273
|
| nothing | `undefined` — the run logs in |
|
|
273
|
-
| an unsealed object, a corrupt one, one
|
|
274
|
+
| an unsealed object, a corrupt one, one whose tag fails under a key this process holds, one copied from another key's path | **burned**, then `undefined` — a session is a cache, so nothing is migrated |
|
|
275
|
+
| one sealed under a key this process does not hold yet (`X_SEAL_KEY_UNKNOWN`, mid-rotation) | `undefined`, the object **kept**: a pod that already holds the new key still restores it |
|
|
274
276
|
| no master key at all | `X_SEAL_KEY_MISSING`, before the browser opens — run `x secrets init` |
|
|
275
277
|
|
|
276
278
|
**Upgrading into sealed sessions discards what was stored before**, refusal markers included. A
|
package/wiki/Upgrading.md
CHANGED
|
@@ -306,6 +306,12 @@ A setter still on a package's `.` barrel is `X_ADAPTER_PORT_INCOMPLETE` on the `
|
|
|
306
306
|
| `undeclared-env` refuses an inline `defineEnv({ … })` in `app.config.ts` (**31.43.0**): `defineEnv` returns values, so `x env check`, `x env example`, `x secrets` and `x deploy` read no declaration from it — `X_UNDECLARED_ENV` at `app.config.ts:<line>`. Built in; a copy still in `guards/` keeps the old rule until `x upgrade` migrates it to the release after 31.42.1 | `export const envSchema = { … } satisfies EnvSchema; export const env = defineEnv(envSchema);`, the record moved as is, then `x env example` |
|
|
307
307
|
| shapes that changed in **31.30–31.42** with no changelog line (found by the public API lock in **31.43.0**): `@ultimat3/cache` `assertFiniteDurationMs` lost its 4th parameter; `@ultimat3/core` `INSTRUMENT_EVENTS` changed and `mapBounded` is overloaded; `@ultimat3/entity` `ColumnMeta.countedIn` and `@ultimat3/realtime/server` `QueryEntry.shape` changed type; `@ultimat3/policy` `PolicyScope`/`policyScope` return `ScopeNode[]`; `@ultimat3/render/server` `IsrController` requires `forgetAll`; `@ultimat3/testing` `ExerciseEffect` changed and `TempTree` requires `spawn` | an `IsrController` or `TempTree` you implement adds the new member; the rest is a type error at the call site, if any |
|
|
308
308
|
| `x new`'s CI files pin every `actions/*` step by commit SHA and check out with `persist-credentials: false` (**31.43.0**) | nothing: `x upgrade` applies codemod `ci-pinned-actions`; a hand-edited workflow is listed with its diff to apply by hand |
|
|
309
|
+
| `adminActorFrom()` answers a `kind` key on every actor (**31.44.0**), and an admin decision sees the caller's real kind, scopes and `onBehalfOf`: an MCP caller is an agent, a queued batch chunk runs as the actor that queued it | a test asserting `adminActorFrom(...)` with `toEqual` adds `kind: 'user'` (or the actor's kind); a policy that treated every admin caller as a user now sees agents — check rules that read `actor.kind`. A chunk queued before the upgrade runs as a `user`, as it did |
|
|
310
|
+
| a `sensitive` admin field is no list filter and no sort key by default (**31.44.0**) | nothing; `filterable: true` / `sortable: true` on the field override, on purpose |
|
|
311
|
+
| a `robots.txt` over 500 KiB is obeyed by its first 500 KiB, or refuses the origin when no line ends inside the cap (**31.44.0**) | nothing, unless a scrape relied on an oversized file reading as "no rules": check the target's file, or declare `robots: { ignore: '<reason>' }` |
|
|
312
|
+
| a `timestamp()` filter given zoneless ISO text reads it as UTC in both drivers (**31.44.0**); a Postgres whose session `TimeZone` was not UTC read it in that zone | to mean another zone, pass a `Date` or ISO text with its offset (`'2026-01-01T00:00:00+02:00'`) |
|
|
313
|
+
| a required column with no default is added nullable and contracted to NOT NULL in the migration's non-transactional step (**31.44.0**), so a fresh or reset database migrates clean | a committed migration that still holds the old `-- backfill "c", then: … set not null;` comment: declare the column `.nullable()`, `x db gen "relax c"`, declare it required again, `x db gen "contract c"`, then `x db migrate`. A populated production table: ship `.nullable()` plus its `backfill()` first, then required |
|
|
314
|
+
| two shipped guards change (**31.44.0**), built in: `undeclared-env` (`X_UNDECLARED_ENV`) also refuses a `defineEnv(` record anywhere in app source whose keys `envSchema` in `app.config.ts` does not declare; `untranslated-string` (`X_UNTRANSLATED_STRING`) ends its fix with `x verify --only boundaries`. A copy still in `guards/` keeps the old rule until `x upgrade` migrates it to the release after 31.43.0 | each `undeclared-env` finding names the keys to move into `envSchema`; then `x env example` |
|
|
309
315
|
|
|
310
316
|
## 29.x → 30.0.0, entry by entry
|
|
311
317
|
|