@ultimat3/cli 31.43.0 → 31.45.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/codemods/ci-artifact-retention.ts +63 -0
- package/src/codemods/ci-pinned-actions.ts +121 -40
- package/src/codemods/index.ts +2 -0
- 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/github/ci.yml.ts +3 -0
- package/src/templates/guard-released-forms.ts +3 -0
- package/src/templates/guard-undeclared-env.ts +47 -8
- package/src/templates/guard-untranslated-string.ts +2 -2
- package/src/templates/scaffold-repo.ts +1 -1
- 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 +9 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultimat3/cli",
|
|
3
|
-
"version": "31.
|
|
3
|
+
"version": "31.45.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.45.0",
|
|
57
|
+
"@ultimat3/admin": "31.45.0",
|
|
58
|
+
"@ultimat3/ai": "31.45.0",
|
|
59
|
+
"@ultimat3/auth": "31.45.0",
|
|
60
|
+
"@ultimat3/cache": "31.45.0",
|
|
61
|
+
"@ultimat3/core": "31.45.0",
|
|
62
|
+
"@ultimat3/db": "31.45.0",
|
|
63
|
+
"@ultimat3/entity": "31.45.0",
|
|
64
|
+
"@ultimat3/flags": "31.45.0",
|
|
65
|
+
"@ultimat3/http": "31.45.0",
|
|
66
|
+
"@ultimat3/i18n": "31.45.0",
|
|
67
|
+
"@ultimat3/jobs": "31.45.0",
|
|
68
|
+
"@ultimat3/mail": "31.45.0",
|
|
69
|
+
"@ultimat3/manifest": "31.45.0",
|
|
70
|
+
"@ultimat3/mcp": "31.45.0",
|
|
71
|
+
"@ultimat3/money": "31.45.0",
|
|
72
|
+
"@ultimat3/notify": "31.45.0",
|
|
73
|
+
"@ultimat3/policy": "31.45.0",
|
|
74
|
+
"@ultimat3/pwa": "31.45.0",
|
|
75
|
+
"@ultimat3/query": "31.45.0",
|
|
76
|
+
"@ultimat3/realtime": "31.45.0",
|
|
77
|
+
"@ultimat3/render": "31.45.0",
|
|
78
|
+
"@ultimat3/schema": "31.45.0",
|
|
79
|
+
"@ultimat3/scraping": "31.45.0",
|
|
80
|
+
"@ultimat3/seo": "31.45.0",
|
|
81
|
+
"@ultimat3/storage": "31.45.0",
|
|
82
|
+
"@ultimat3/testing": "31.45.0",
|
|
83
|
+
"@ultimat3/time": "31.45.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',
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// 31.45.0: ci.yml's `verify-part-*` upload keeps its document one day. The verdict job reads it in
|
|
2
|
+
// the same run, and GitHub's 90-day default let one adopter's parts fill the org's artifact quota
|
|
3
|
+
// until CI could not run. Keyed on the upload's `name:` line, not the template's exact bytes, so an
|
|
4
|
+
// upload the app reshaped still gets it; one already holding a `retention-days` is the app's.
|
|
5
|
+
|
|
6
|
+
import { CI_WORKFLOW_PATH } from '../templates/github/ci.yml';
|
|
7
|
+
import type { Codemod, CodemodResult } from './codemod';
|
|
8
|
+
import { readText } from './engine-edits';
|
|
9
|
+
|
|
10
|
+
/** What the template writes at the end of the upload's `with:`, at its 10-column indent. */
|
|
11
|
+
export const RETENTION_LINES = [
|
|
12
|
+
" # The verdict reads it in this run only: kept GitHub's 90 days, every push's parts",
|
|
13
|
+
" # pile up until the org's artifact storage quota stops CI from running at all.",
|
|
14
|
+
' retention-days: 1',
|
|
15
|
+
'',
|
|
16
|
+
].join('\n');
|
|
17
|
+
|
|
18
|
+
/** The stock upload's artifact name, at whatever indent the app's `with:` sits. */
|
|
19
|
+
const PART_NAME = /^( +)name: verify-part-\$\{\{ matrix\.part \}\}\s*$/;
|
|
20
|
+
|
|
21
|
+
const NOTHING: CodemodResult = { changed: [], skipped: [] };
|
|
22
|
+
|
|
23
|
+
const indentOf = (line: string): number => line.length - line.trimStart().length;
|
|
24
|
+
|
|
25
|
+
/** The `with:` block holding line `at`: the run of non-blank lines at its indent or deeper. */
|
|
26
|
+
const blockAround = (lines: readonly string[], at: number, indent: number): [number, number] => {
|
|
27
|
+
const inside = (line: string | undefined): boolean =>
|
|
28
|
+
line !== undefined && line.trim() !== '' && indentOf(line) >= indent;
|
|
29
|
+
let first = at;
|
|
30
|
+
while (inside(lines[first - 1])) first -= 1;
|
|
31
|
+
let last = at;
|
|
32
|
+
while (inside(lines[last + 1])) last += 1;
|
|
33
|
+
return [first, last];
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const reindent = (indent: number): string[] =>
|
|
37
|
+
RETENTION_LINES.trimEnd()
|
|
38
|
+
.split('\n')
|
|
39
|
+
.map((line) => `${' '.repeat(indent)}${line.trimStart()}`);
|
|
40
|
+
|
|
41
|
+
export const codemod: Codemod = {
|
|
42
|
+
id: 'ci-artifact-retention',
|
|
43
|
+
since: '31.45.0',
|
|
44
|
+
summary: `${CI_WORKFLOW_PATH}: the verify-part-* upload the verdict reads in the same run keeps its document one day, never GitHub's 90`,
|
|
45
|
+
run: async (app) => {
|
|
46
|
+
const file = await readText(app, CI_WORKFLOW_PATH);
|
|
47
|
+
if (file === undefined) return NOTHING;
|
|
48
|
+
const lines = file.text.split('\n');
|
|
49
|
+
// Bottom-up, so an insert never shifts a block still to be read.
|
|
50
|
+
for (let at = lines.length - 1; at >= 0; at -= 1) {
|
|
51
|
+
const indent = PART_NAME.exec(lines[at] ?? '')?.[1]?.length;
|
|
52
|
+
if (indent === undefined) continue;
|
|
53
|
+
const [first, last] = blockAround(lines, at, indent);
|
|
54
|
+
const block = lines.slice(first, last + 1);
|
|
55
|
+
if (block.some((line) => line.trimStart().startsWith('retention-days:'))) continue;
|
|
56
|
+
lines.splice(last + 1, 0, ...reindent(indent));
|
|
57
|
+
}
|
|
58
|
+
const next = lines.join('\n');
|
|
59
|
+
if (next === file.text) return NOTHING;
|
|
60
|
+
await app.write(CI_WORKFLOW_PATH, file.restore(next));
|
|
61
|
+
return { changed: [CI_WORKFLOW_PATH], skipped: [] };
|
|
62
|
+
},
|
|
63
|
+
};
|
|
@@ -1,59 +1,143 @@
|
|
|
1
|
-
// 31.43.0:
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
1
|
+
// 31.43.0: `x new`'s workflows run every action by commit SHA (`templates/github/actions.ts`) and
|
|
2
|
+
// a checkout drops the job token before `bun install`. Line by line, so any tagged major moves
|
|
3
|
+
// (`@v5` included); a SHA or an action with no pin is never touched, and a line no edit reads
|
|
4
|
+
// safely (quoted, an inline `with:`) leaves the file the author's, with the diff.
|
|
5
5
|
|
|
6
6
|
import { CACHE, CHECKOUT, DOWNLOAD_ARTIFACT, UPLOAD_ARTIFACT } from '../templates/github/actions';
|
|
7
7
|
import { CI_WORKFLOW_PATH } from '../templates/github/ci.yml';
|
|
8
8
|
import { IMAGE_WORKFLOW_PATH } from '../templates/github/image.yml';
|
|
9
9
|
import type { Codemod, CodemodApp, CodemodResult } from './codemod';
|
|
10
10
|
import { unifiedDiff } from './engine-diff';
|
|
11
|
-
import type { SnippetEdit } from './engine-edits';
|
|
12
11
|
import { mergeResults, readText } from './engine-edits';
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
/** Each action this codemod pins, to the pin the template writes today. */
|
|
14
|
+
const PINS: Readonly<Record<string, string>> = {
|
|
15
|
+
checkout: CHECKOUT,
|
|
16
|
+
cache: CACHE,
|
|
17
|
+
'upload-artifact': UPLOAD_ARTIFACT,
|
|
18
|
+
'download-artifact': DOWNLOAD_ARTIFACT,
|
|
19
|
+
};
|
|
15
20
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
{ from: ' - uses: actions/cache@v6\n', to: ` - uses: ${CACHE}\n` },
|
|
23
|
-
{ from: ' - uses: actions/upload-artifact@v7\n', to: ` - uses: ${UPLOAD_ARTIFACT}\n` },
|
|
24
|
-
{
|
|
25
|
-
from: ' - uses: actions/download-artifact@v8\n',
|
|
26
|
-
to: ` - uses: ${DOWNLOAD_ARTIFACT}\n`,
|
|
27
|
-
},
|
|
28
|
-
];
|
|
21
|
+
const NAMES = Object.keys(PINS).join('|');
|
|
22
|
+
/** A step's `uses:` on a tag — `- uses:` or a later key of the step — in the one shape edited. */
|
|
23
|
+
const TAGGED = new RegExp(`^( *)(- )?uses: actions/(${NAMES})@v\\d+(?:\\.\\d+){0,2}[ \\t]*$`);
|
|
24
|
+
/** Any mention of a pinned action that is not a SHA: what must have read as TAGGED, or be refused. */
|
|
25
|
+
const MENTION = new RegExp(`actions/(?:${NAMES})@(?![0-9a-f]{40}(?![\\w-]))`);
|
|
26
|
+
const WITH = /^with:(.*)$/;
|
|
29
27
|
|
|
30
|
-
|
|
31
|
-
export const IMAGE_PINNED_EDITS: readonly SnippetEdit[] = [
|
|
32
|
-
{ from: ' - uses: actions/checkout@v7\n', to: ` - uses: ${CHECKOUT}\n` },
|
|
33
|
-
];
|
|
28
|
+
const NOTHING: CodemodResult = { changed: [], skipped: [] };
|
|
34
29
|
|
|
35
|
-
/** A
|
|
36
|
-
|
|
30
|
+
/** A line this codemod cannot edit safely, as its 1-based number and text. */
|
|
31
|
+
class Unsafe {
|
|
32
|
+
constructor(
|
|
33
|
+
readonly line: number,
|
|
34
|
+
readonly text: string,
|
|
35
|
+
) {}
|
|
36
|
+
}
|
|
37
37
|
|
|
38
|
-
const
|
|
38
|
+
const indentOf = (line: string): number => line.length - line.trimStart().length;
|
|
39
|
+
const isBlank = (line: string): boolean => line.trim() === '';
|
|
40
|
+
|
|
41
|
+
/** The step's lines around its `uses:` at `at`, as [first, last], keys at `keys` columns. */
|
|
42
|
+
const stepRange = (lines: readonly string[], at: number, keys: number, dashed: boolean) => {
|
|
43
|
+
let first = at;
|
|
44
|
+
if (!dashed) {
|
|
45
|
+
while (first > 0) {
|
|
46
|
+
const line = lines[first - 1] ?? '';
|
|
47
|
+
first -= 1;
|
|
48
|
+
if (indentOf(line) === keys - 2 && line.trimStart().startsWith('- ')) break;
|
|
49
|
+
if (!isBlank(line) && indentOf(line) < keys) return undefined;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
let last = at;
|
|
53
|
+
for (let next = at + 1; next < lines.length; next += 1) {
|
|
54
|
+
const line = lines[next] ?? '';
|
|
55
|
+
if (isBlank(line)) continue;
|
|
56
|
+
if (indentOf(line) < keys) break;
|
|
57
|
+
last = next;
|
|
58
|
+
}
|
|
59
|
+
return [first, last] as const;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/** The lines a checkout's step needs inserted to drop the token, and where; Unsafe when unreadable. */
|
|
63
|
+
const persistInsert = (
|
|
64
|
+
lines: readonly string[],
|
|
65
|
+
at: number,
|
|
66
|
+
keys: number,
|
|
67
|
+
dashed: boolean,
|
|
68
|
+
): { readonly after: number; readonly lines: readonly string[] } | Unsafe | undefined => {
|
|
69
|
+
const range = stepRange(lines, at, keys, dashed);
|
|
70
|
+
if (range === undefined) return new Unsafe(at + 1, lines[at] ?? '');
|
|
71
|
+
const [first, last] = range;
|
|
72
|
+
const own = (index: number): string => {
|
|
73
|
+
const line = lines[index] ?? '';
|
|
74
|
+
return indentOf(line) === keys || (index === first && dashed) ? line.trimStart() : '';
|
|
75
|
+
};
|
|
76
|
+
for (let index = first; index <= last; index += 1) {
|
|
77
|
+
const key = own(index).replace(/^- /, '');
|
|
78
|
+
const opened = WITH.exec(key);
|
|
79
|
+
if (opened === null) continue;
|
|
80
|
+
if (!/^\s*(?:#.*)?$/.test(opened[1] ?? '')) return new Unsafe(index + 1, lines[index] ?? '');
|
|
81
|
+
const children = lines.slice(index + 1, last + 1).filter((line) => !isBlank(line));
|
|
82
|
+
if (children.some((line) => line.trimStart().startsWith('persist-credentials:'))) return;
|
|
83
|
+
const inner = children[0] === undefined ? keys + 2 : indentOf(children[0]);
|
|
84
|
+
return { after: index, lines: [`${' '.repeat(inner)}persist-credentials: false`] };
|
|
85
|
+
}
|
|
86
|
+
const pad = ' '.repeat(keys);
|
|
87
|
+
return { after: at, lines: [`${pad}with:`, `${pad} persist-credentials: false`] };
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/** `text` with every tagged pin moved and each moved checkout's token dropped, or the first Unsafe. */
|
|
91
|
+
function pinActions(text: string): string | Unsafe {
|
|
92
|
+
const lines = text.split('\n');
|
|
93
|
+
// Bottom-up, so an insert never shifts a line still to be read.
|
|
94
|
+
for (let at = lines.length - 1; at >= 0; at -= 1) {
|
|
95
|
+
const line = lines[at] ?? '';
|
|
96
|
+
const tagged = TAGGED.exec(line);
|
|
97
|
+
if (tagged === null) {
|
|
98
|
+
if (MENTION.test(line)) return new Unsafe(at + 1, line);
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
const [, lead = '', dash, name = ''] = tagged;
|
|
102
|
+
const keys = lead.length + (dash === undefined ? 0 : 2);
|
|
103
|
+
if (name === 'checkout') {
|
|
104
|
+
const insert = persistInsert(lines, at, keys, dash !== undefined);
|
|
105
|
+
if (insert instanceof Unsafe) return insert;
|
|
106
|
+
if (insert !== undefined) lines.splice(insert.after + 1, 0, ...insert.lines);
|
|
107
|
+
}
|
|
108
|
+
lines[at] = `${lead}${dash ?? ''}uses: ${PINS[name] ?? ''}`;
|
|
109
|
+
}
|
|
110
|
+
return lines.join('\n');
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** The template's own change, for a file it leaves to the author. */
|
|
114
|
+
const TEMPLATE_DIFF = (path: string): string =>
|
|
115
|
+
unifiedDiff(
|
|
116
|
+
path,
|
|
117
|
+
`${Object.keys(PINS)
|
|
118
|
+
.map((name) => ` - uses: actions/${name}@v<N>`)
|
|
119
|
+
.join('\n')}\n`,
|
|
120
|
+
`${Object.entries(PINS)
|
|
121
|
+
.map(([name, pin]) =>
|
|
122
|
+
name === 'checkout'
|
|
123
|
+
? ` - uses: ${pin}\n with:\n persist-credentials: false`
|
|
124
|
+
: ` - uses: ${pin}`,
|
|
125
|
+
)
|
|
126
|
+
.join('\n')}\n`,
|
|
127
|
+
);
|
|
39
128
|
|
|
40
|
-
async function pin(
|
|
41
|
-
app: CodemodApp,
|
|
42
|
-
path: string,
|
|
43
|
-
edits: readonly SnippetEdit[],
|
|
44
|
-
): Promise<CodemodResult> {
|
|
129
|
+
async function pin(app: CodemodApp, path: string): Promise<CodemodResult> {
|
|
45
130
|
const file = await readText(app, path);
|
|
46
131
|
if (file === undefined) return NOTHING;
|
|
47
|
-
const next =
|
|
48
|
-
if (
|
|
49
|
-
const side = (key: 'from' | 'to') => `${edits.map((edit) => edit[key]).join('\n')}\n`;
|
|
132
|
+
const next = pinActions(file.text);
|
|
133
|
+
if (next instanceof Unsafe) {
|
|
50
134
|
return {
|
|
51
135
|
changed: [],
|
|
52
136
|
skipped: [
|
|
53
137
|
{
|
|
54
138
|
path,
|
|
55
|
-
reason: `${path} runs
|
|
56
|
-
diff:
|
|
139
|
+
reason: `${path}:${String(next.line)} runs ${next.text.trim()} in a shape this codemod cannot edit safely (quoted, commented, an inline with:), so the diff below is the template's change, to make by hand`,
|
|
140
|
+
diff: TEMPLATE_DIFF(path),
|
|
57
141
|
},
|
|
58
142
|
],
|
|
59
143
|
};
|
|
@@ -68,8 +152,5 @@ export const codemod: Codemod = {
|
|
|
68
152
|
since: '31.43.0',
|
|
69
153
|
summary: `${CI_WORKFLOW_PATH}, ${IMAGE_WORKFLOW_PATH}: every actions/* step pinned by commit SHA, and ci.yml's checkouts keep no git credential`,
|
|
70
154
|
run: async (app) =>
|
|
71
|
-
mergeResults([
|
|
72
|
-
await pin(app, CI_WORKFLOW_PATH, CI_PINNED_EDITS),
|
|
73
|
-
await pin(app, IMAGE_WORKFLOW_PATH, IMAGE_PINNED_EDITS),
|
|
74
|
-
]),
|
|
155
|
+
mergeResults([await pin(app, CI_WORKFLOW_PATH), await pin(app, IMAGE_WORKFLOW_PATH)]),
|
|
75
156
|
};
|
package/src/codemods/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { codemod as authenticatorSessionRefusal } from './authenticator-session-
|
|
|
7
7
|
import { codemod as biomeNoDefaultExport } from './biome-no-default-export';
|
|
8
8
|
import { codemod as bunfigIslandCoverage } from './bunfig-island-coverage';
|
|
9
9
|
import { codemod as chartDashboard } from './chart-dashboard';
|
|
10
|
+
import { codemod as ciArtifactRetention } from './ci-artifact-retention';
|
|
10
11
|
import { codemod as ciE2eBrowser } from './ci-e2e-browser';
|
|
11
12
|
import { codemod as ciPinnedActions } from './ci-pinned-actions';
|
|
12
13
|
import { codemod as ciServicesEnv } from './ci-services-env';
|
|
@@ -65,4 +66,5 @@ export const CODEMODS: readonly Codemod[] = [
|
|
|
65
66
|
docsEnvGuard,
|
|
66
67
|
testServices,
|
|
67
68
|
ciPinnedActions,
|
|
69
|
+
ciArtifactRetention,
|
|
68
70
|
];
|
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
|
|
|
@@ -151,6 +151,9 @@ ${SETUP_STEPS}
|
|
|
151
151
|
path: \${{ runner.temp }}/parts/\${{ matrix.part }}.json
|
|
152
152
|
if-no-files-found: error
|
|
153
153
|
overwrite: true
|
|
154
|
+
# The verdict reads it in this run only: kept GitHub's 90 days, every push's parts
|
|
155
|
+
# pile up until the org's artifact storage quota stops CI from running at all.
|
|
156
|
+
retention-days: 1
|
|
154
157
|
|
|
155
158
|
# THE VERDICT: \`x verify merge\` is green only when the parts are provably the whole gate — every
|
|
156
159
|
# step from exactly one part, every shard of a split over one corpus, each part green. It runs
|
|
@@ -71,6 +71,8 @@ export const RELEASED_GUARD_FORMS: Readonly<
|
|
|
71
71
|
['3b0u9i8hze00x', 'error'],
|
|
72
72
|
],
|
|
73
73
|
'undeclared-env': [
|
|
74
|
+
['13k4amuxgsnla', 'error'],
|
|
75
|
+
['1xkusngzbabza', 'error'],
|
|
74
76
|
['2jbihvbp83mb4', 'error'],
|
|
75
77
|
['3gsy96z8bgrrl', 'error'],
|
|
76
78
|
['81vvl6xx5bb8', 'error'],
|
|
@@ -82,6 +84,7 @@ export const RELEASED_GUARD_FORMS: Readonly<
|
|
|
82
84
|
'untranslated-string': [
|
|
83
85
|
['2x85ib5eqdxzi', 'error'],
|
|
84
86
|
['3j5e8t1k120u3', 'error'],
|
|
87
|
+
['d6gyn0l6szj8', 'error'],
|
|
85
88
|
['h57qtdwn7inz', 'error'],
|
|
86
89
|
],
|
|
87
90
|
'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)) {
|
|
@@ -187,7 +225,8 @@ export function undeclaredEnv(files: readonly SourceFile[], config: string): rea
|
|
|
187
225
|
findings.push({
|
|
188
226
|
code: CODE,
|
|
189
227
|
cause: \`\${file.path}:\${lineOf(text, match.index)} reads \${match[0]}, which app.config.ts does not declare — x env check never asks for it, so a deploy without it boots and fails at the first read\`,
|
|
190
|
-
|
|
228
|
+
// Second branch: a value \`bun build --define\` bakes in is no runtime env, and no deploy sets it.
|
|
229
|
+
fix: \`\${name}: { type: 'string', description: '…' }, // into envSchema in app.config.ts, read it as env.\${name} in \${file.path}, then: x env example. A build-time constant, not runtime env: declare const \${name}: string in a .d.ts, read \${name} in place of \${match[0]}, and bun build --define \${name}='"…"'\`,
|
|
191
230
|
at: file.path,
|
|
192
231
|
});
|
|
193
232
|
}
|
|
@@ -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
|
}
|
|
@@ -29,7 +29,7 @@ import { verifyFloor } from './scaffold-verify-floor';
|
|
|
29
29
|
* config as out of date on every `bun run lint`. A formatter is a build input: a floating range
|
|
30
30
|
* is a `lint` step whose verdict depends on the day the app was installed.
|
|
31
31
|
*/
|
|
32
|
-
const BIOME_VERSION = '2.6.
|
|
32
|
+
const BIOME_VERSION = '2.6.4';
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* The checker a scaffolded app typechecks with, and it must not lag the one the FRAMEWORK is built
|
|
@@ -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,15 @@ 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` |
|
|
315
|
+
| `x new`'s `ci.yml` uploads each `verify-part-*` document with `retention-days: 1` (**31.45.0**): the verdict job reads it in the same run, and GitHub's 90-day default let one adopter's parts fill the org's artifact storage quota until CI could not run | nothing: `x upgrade` applies codemod `ci-artifact-retention`; an upload that already sets `retention-days` is left as it is. Artifacts already stored keep their 90 days: delete them from the repository's Actions storage settings if the quota is already full |
|
|
316
|
+
| codemod `ci-pinned-actions` pins any tagged major of `actions/checkout`, `cache`, `upload-artifact` and `download-artifact` (**31.45.0**), and adds `persist-credentials: false` to each checkout it pins, inside the step's own `with:` when it has one; 31.43–31.44 skipped a workflow on another major (`actions/checkout@v5`) | nothing: `x doctor` names it as `X_UPGRADE_CODEMODS_PENDING`, and `x upgrade --json` applies it. A SHA-pinned line and an action with no pin are never touched |
|
|
317
|
+
| the shipped `undeclared-env` guard's fix changes (**31.45.0**), built in; its findings do not: `X_UNDECLARED_ENV` still opens with the `envSchema` line to paste, and adds a second branch for a build-time constant injected by `bun build --define process.env.X=…` (declare a global, `--define NAME=…`), which no deploy sets. A copy still in `guards/` keeps the old text until `x upgrade` migrates it to the release after 31.44.0 | nothing; for a `--define` constant, follow the second branch rather than declaring an env var |
|
|
309
318
|
|
|
310
319
|
## 29.x → 30.0.0, entry by entry
|
|
311
320
|
|