@substrat-run/kernel 0.147.0 → 0.149.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/dist/attachment-sweep.d.ts +208 -0
- package/dist/attachment-sweep.d.ts.map +1 -0
- package/dist/attachment-sweep.js +318 -0
- package/dist/attachment-sweep.js.map +1 -0
- package/dist/audit-outcome.d.ts +1 -1
- package/dist/audit-outcome.d.ts.map +1 -1
- package/dist/audit-outcome.js +4 -2
- package/dist/audit-outcome.js.map +1 -1
- package/dist/export-break.d.ts +137 -0
- package/dist/export-break.d.ts.map +1 -0
- package/dist/export-break.js +219 -0
- package/dist/export-break.js.map +1 -0
- package/dist/index.d.ts +24 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -7
- package/dist/index.js.map +1 -1
- package/dist/install-receipts.d.ts +116 -0
- package/dist/install-receipts.d.ts.map +1 -0
- package/dist/install-receipts.js +162 -0
- package/dist/install-receipts.js.map +1 -0
- package/dist/invocation-line.d.ts +85 -0
- package/dist/invocation-line.d.ts.map +1 -1
- package/dist/invocation-line.js +43 -0
- package/dist/invocation-line.js.map +1 -1
- package/dist/map-bounded.d.ts +8 -0
- package/dist/map-bounded.d.ts.map +1 -0
- package/dist/map-bounded.js +16 -0
- package/dist/map-bounded.js.map +1 -0
- package/dist/migration-digest.d.ts +56 -0
- package/dist/migration-digest.d.ts.map +1 -1
- package/dist/migration-digest.js +92 -0
- package/dist/migration-digest.js.map +1 -1
- package/dist/migration-fence.d.ts +14 -0
- package/dist/migration-fence.d.ts.map +1 -0
- package/dist/migration-fence.js +515 -0
- package/dist/migration-fence.js.map +1 -0
- package/dist/migration-replay.d.ts +52 -0
- package/dist/migration-replay.d.ts.map +1 -0
- package/dist/migration-replay.js +140 -0
- package/dist/migration-replay.js.map +1 -0
- package/dist/module-migrations.d.ts +3 -3
- package/dist/module-migrations.js +3 -3
- package/dist/peer.d.ts +32 -2
- package/dist/peer.d.ts.map +1 -1
- package/dist/peer.js +100 -4
- package/dist/peer.js.map +1 -1
- package/dist/permission-eval.d.ts +8 -0
- package/dist/permission-eval.d.ts.map +1 -1
- package/dist/permission-eval.js +14 -0
- package/dist/permission-eval.js.map +1 -1
- package/dist/platform-sweep.d.ts +114 -361
- package/dist/platform-sweep.d.ts.map +1 -1
- package/dist/platform-sweep.js +134 -561
- package/dist/platform-sweep.js.map +1 -1
- package/dist/promote-review.d.ts +125 -0
- package/dist/promote-review.d.ts.map +1 -0
- package/dist/promote-review.js +181 -0
- package/dist/promote-review.js.map +1 -0
- package/dist/schedule-state.d.ts +91 -0
- package/dist/schedule-state.d.ts.map +1 -0
- package/dist/schedule-state.js +118 -0
- package/dist/schedule-state.js.map +1 -0
- package/dist/scope-copy-ledger.d.ts +29 -0
- package/dist/scope-copy-ledger.d.ts.map +1 -1
- package/dist/scope-copy-ledger.js +23 -0
- package/dist/scope-copy-ledger.js.map +1 -1
- package/dist/scope-copy.d.ts.map +1 -1
- package/dist/scope-copy.js +3 -2
- package/dist/scope-copy.js.map +1 -1
- package/dist/scope-host.d.ts +303 -11
- package/dist/scope-host.d.ts.map +1 -1
- package/dist/scope-host.js.map +1 -1
- package/dist/scope-identity.d.ts +68 -0
- package/dist/scope-identity.d.ts.map +1 -0
- package/dist/scope-identity.js +75 -0
- package/dist/scope-identity.js.map +1 -0
- package/dist/scope-store.d.ts +9 -6
- package/dist/scope-store.d.ts.map +1 -1
- package/dist/scope-store.js.map +1 -1
- package/dist/spine-restore.d.ts +2 -0
- package/dist/spine-restore.d.ts.map +1 -1
- package/dist/spine-restore.js +6 -1
- package/dist/spine-restore.js.map +1 -1
- package/dist/store-driver-releases.d.ts +306 -0
- package/dist/store-driver-releases.d.ts.map +1 -0
- package/dist/store-driver-releases.js +581 -0
- package/dist/store-driver-releases.js.map +1 -0
- package/dist/table-ownership.d.ts +5 -2
- package/dist/table-ownership.d.ts.map +1 -1
- package/dist/table-ownership.js +19 -10
- package/dist/table-ownership.js.map +1 -1
- package/dist/testing.d.ts +2 -0
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +2 -0
- package/dist/testing.js.map +1 -1
- package/dist/upload-link.d.ts +142 -0
- package/dist/upload-link.d.ts.map +1 -0
- package/dist/upload-link.js +441 -0
- package/dist/upload-link.js.map +1 -0
- package/dist/version-migrations.d.ts +63 -1
- package/dist/version-migrations.d.ts.map +1 -1
- package/dist/version-migrations.js +174 -8
- package/dist/version-migrations.js.map +1 -1
- package/dist/vertical-scope-stores.d.ts +43 -0
- package/dist/vertical-scope-stores.d.ts.map +1 -0
- package/dist/vertical-scope-stores.js +195 -0
- package/dist/vertical-scope-stores.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,515 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The data-loss fence: an authored migration may not lose data a scope holds unless it says so (#115).
|
|
3
|
+
*
|
|
4
|
+
* The planner (`@substrat-run/model-emit`) refuses every destructive diff when it writes a
|
|
5
|
+
* migration, but nothing judged what an AUTHORED migration does to the rows already there: a
|
|
6
|
+
* hand-written `DROP TABLE`, a `DROP COLUMN`, a `DELETE`, or a create-copy-rename rebuild that
|
|
7
|
+
* forgot a column ran unchecked against a scope full of data. This is the check, and it reads
|
|
8
|
+
* what the SQL DID rather than what its text says, so there is no SQL grammar to get wrong.
|
|
9
|
+
*
|
|
10
|
+
* **Measured, not parsed.** Parsing decides only whether to measure: a migration made only of
|
|
11
|
+
* provably additive statements (`CREATE …`, `ALTER TABLE … ADD …`) cannot lose anything and is not
|
|
12
|
+
* measured. Any other statement (any DML, `DROP`, `ALTER … RENAME`/`DROP COLUMN`, `PRAGMA`, `WITH`,
|
|
13
|
+
* a shape nobody listed) measures EVERY module table, not just the ones it names, so a trigger or a
|
|
14
|
+
* foreign-key cascade that reaches another table is seen too. Measured, per table: the rows, and
|
|
15
|
+
* per column the values in each storage class (`typeof`). Once before the first statement and
|
|
16
|
+
* once after the last, inside the migration's transaction, so the intermediate states of a rebuild
|
|
17
|
+
* do not matter and a refusal rolls the whole migration back. Every measuring query stays inside a
|
|
18
|
+
* Durable Object's own limits (`DO_SQL_LIMITS`), or the fence would close a scope for a reason of
|
|
19
|
+
* its own.
|
|
20
|
+
*
|
|
21
|
+
* **Production data is rows that exist.** A table with no rows may be dropped or rebuilt freely,
|
|
22
|
+
* whatever else is true of the scope; the same migration is refused in a scope where it would
|
|
23
|
+
* lose something. There is no phase flag to forget to flip.
|
|
24
|
+
*
|
|
25
|
+
* **What counts as a loss**, for a table that held rows: it is gone (under the name `ALTER TABLE …
|
|
26
|
+
* RENAME TO` last gave it, or under its original name, so a rebuild back into place keeps it —
|
|
27
|
+
* each table after the migration is claimed by one table before it, a rename first, and a `DROP
|
|
28
|
+
* TABLE` releases the name it removed); it has fewer
|
|
29
|
+
* rows; one of its columns that held values is gone (`RENAME COLUMN` is followed) or holds fewer
|
|
30
|
+
* of them in some storage class — which is how a retype shows, `'1.50'` turning into `1`. Counts
|
|
31
|
+
* cannot tell a faithful widening (`5` → `5.0`) from a rewrite (`5` → `0.05`), so any change of
|
|
32
|
+
* storage class is reported, and one made on purpose is declared with `discards`. `NOT NULL`
|
|
33
|
+
* without a default needs no rule: SQLite refuses it itself.
|
|
34
|
+
*
|
|
35
|
+
* **What it does not see**, because it counts — the residual classes, each named in the property
|
|
36
|
+
* test (`migration-fence.property.test.ts`) that holds the rest to ground truth:
|
|
37
|
+
* - in-place replacement: values rewritten at the same count and class (`UPDATE`), rows replaced
|
|
38
|
+
* by as many other rows (`DELETE` + `INSERT`), or a column dropped, re-added and refilled;
|
|
39
|
+
* - a dropped table whose name is continued by a table the migration created, filled from
|
|
40
|
+
* somewhere else, holding at least as many rows, even renamed away again (`DROP TABLE a; CREATE
|
|
41
|
+
* TABLE a AS SELECT * FROM b`, or `…; CREATE TABLE n AS SELECT * FROM b; ALTER TABLE n RENAME TO
|
|
42
|
+
* a; ALTER TABLE a RENAME TO d`): counts cannot tell it from the create-copy-drop-rename
|
|
43
|
+
* rebuild, or a rename after it, which the fence must accept;
|
|
44
|
+
* - which source a move's target gained from: a target is credited with everything it gained.
|
|
45
|
+
* And one refusal by design: data copied under another table's name is refused until `moves`
|
|
46
|
+
* declares it.
|
|
47
|
+
*
|
|
48
|
+
* **Declared losses pass.** `SqlMigration.moves` names data that went elsewhere, and is verified:
|
|
49
|
+
* the target must GAIN at least what its sources held, per class — and for a table moved whole,
|
|
50
|
+
* every source column that held values must arrive in a target column of the same name, unless
|
|
51
|
+
* that column is moved or discarded by name itself. `SqlMigration.discards` names data
|
|
52
|
+
* deliberately given up, with the reason a reviewer reads. A declaration naming a table or column
|
|
53
|
+
* the scope does not hold before the migration (a move's target excepted, which the migration may
|
|
54
|
+
* create) is an authoring error and refuses the migration too.
|
|
55
|
+
*
|
|
56
|
+
* **TEMP objects are refused.** A Durable Object refuses them outright, so a migration making one
|
|
57
|
+
* could never run on the hosted adapter, and a TEMP table shadows the scope's own tables for every
|
|
58
|
+
* unqualified statement after it. An authored migration that makes one is refused before it runs,
|
|
59
|
+
* on both adapters, and every measuring read names `main` so nothing else can answer for a table.
|
|
60
|
+
*
|
|
61
|
+
* **ATTACH and DETACH are refused** for the same first reason (#2321): a Durable Object refuses
|
|
62
|
+
* them, so the migration could never run hosted. And an attached database is a FILE, which the
|
|
63
|
+
* fence does not measure and a replay outside a host (`substrat push`) would otherwise create on
|
|
64
|
+
* the machine running it. Refused before anything runs, on both adapters.
|
|
65
|
+
*
|
|
66
|
+
* Kernel-derived DDL is exempt: its tables are indexes, rebuilt from the data this protects.
|
|
67
|
+
*/
|
|
68
|
+
import { blankReason, namesSpineTable, substratError, tokenizeSql } from '@substrat-run/contracts';
|
|
69
|
+
import { DO_SQL_LIMITS } from './sql-limits.js';
|
|
70
|
+
import { executableSqlStatements } from './sql-statements.js';
|
|
71
|
+
/** The storage classes a value can have; NULL is not a value. */
|
|
72
|
+
const CLASSES = ['integer', 'real', 'text', 'blob'];
|
|
73
|
+
/**
|
|
74
|
+
* Columns measured per query: each one is a result column per storage class, and a Durable
|
|
75
|
+
* Object refuses a result set wider than `DO_SQL_LIMITS.columns`.
|
|
76
|
+
*/
|
|
77
|
+
const COLUMNS_PER_SCAN = Math.floor(DO_SQL_LIMITS.columns / CLASSES.length);
|
|
78
|
+
/** SQLite folds ASCII letters only: `"ä"` and `"Ä"` are two tables, and must stay two keys. */
|
|
79
|
+
const lower = (s) => s.replace(/[A-Z]+/g, (m) => m.toLowerCase());
|
|
80
|
+
const quote = (name) => `"${name.replace(/"/g, '""')}"`;
|
|
81
|
+
const total = (c) => CLASSES.reduce((n, k) => n + c[k], 0);
|
|
82
|
+
const NONE = { integer: 0, real: 0, text: 0, blob: 0 };
|
|
83
|
+
/** The words of one statement, keywords lowercased; quoted names are kept apart from keywords. */
|
|
84
|
+
function words(statement) {
|
|
85
|
+
return tokenizeSql(statement).map((t) => ({ text: t.quoted ? t.text : lower(t.text), quoted: t.quoted, parts: t.parts }));
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The schema a name token names, and the name in it, as SQLite reads them: `main.n` and
|
|
89
|
+
* `"main"."n"` are `main` and `n`; `"main.n"` is ONE identifier, a name with a dot in it and no
|
|
90
|
+
* schema. The one reading of a qualifier, for the `temp` check and for following `main` names.
|
|
91
|
+
*/
|
|
92
|
+
function schemaAndName(w) {
|
|
93
|
+
const parts = w.parts ?? [w.text];
|
|
94
|
+
return parts.length === 2 ? { schema: lower(parts[0]), name: parts[1] } : { name: parts.join('.') };
|
|
95
|
+
}
|
|
96
|
+
/** A table name as the main schema holds it, or a name no main table has if another schema is named. */
|
|
97
|
+
function mainName(w) {
|
|
98
|
+
const { schema, name } = schemaAndName(w);
|
|
99
|
+
return schema === undefined || schema === 'main' ? lower(name) : `\u0000${schema}.${lower(name)}`;
|
|
100
|
+
}
|
|
101
|
+
/** A statement that can only define something: it fires nothing and removes nothing. */
|
|
102
|
+
function additive(statement) {
|
|
103
|
+
const w = words(statement);
|
|
104
|
+
const kw = (i) => (w[i] && !w[i].quoted ? w[i].text : undefined);
|
|
105
|
+
if (kw(0) === 'create')
|
|
106
|
+
return true;
|
|
107
|
+
// `ALTER TABLE <name> ADD [COLUMN] …` — the name is one token, dotted or not.
|
|
108
|
+
return kw(0) === 'alter' && kw(1) === 'table' && kw(3) === 'add';
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* The tables a virtual-table module keeps behind each virtual table, by suffix. Only these exact
|
|
112
|
+
* names are left out: a real table that merely starts with a virtual table's name is measured. A
|
|
113
|
+
* module not listed here has its shadow tables measured too, which can refuse a migration that
|
|
114
|
+
* only reshaped an index — the conservative answer.
|
|
115
|
+
*/
|
|
116
|
+
const SHADOW_SUFFIXES = {
|
|
117
|
+
fts5: ['data', 'idx', 'content', 'docsize', 'config'],
|
|
118
|
+
fts4: ['content', 'segments', 'segdir', 'docsize', 'stat'],
|
|
119
|
+
fts3: ['content', 'segments', 'segdir', 'docsize', 'stat'],
|
|
120
|
+
rtree: ['node', 'parent', 'rowid'],
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* The tables the fence measures, as SQLite names them: the scope's own, without the spine,
|
|
124
|
+
* SQLite's and workerd's internals, virtual tables (an index over data held elsewhere, or a
|
|
125
|
+
* module's own store the fence cannot count without its content table) and their shadow tables.
|
|
126
|
+
* Exported so a replay outside a host (`lint:migration-fence`) populates exactly what is measured.
|
|
127
|
+
*/
|
|
128
|
+
export function fencedTables(sql) {
|
|
129
|
+
const rows = sql.query("SELECT name, sql FROM main.sqlite_master WHERE type = 'table'");
|
|
130
|
+
const own = rows.filter((r) => {
|
|
131
|
+
const n = lower(r.name);
|
|
132
|
+
return !namesSpineTable(n) && !n.startsWith('sqlite_') && !n.startsWith('_cf_');
|
|
133
|
+
});
|
|
134
|
+
const skip = new Set();
|
|
135
|
+
for (const r of own) {
|
|
136
|
+
const m = /^\s*create\s+virtual\s+table\s+.*?\busing\s+(\w+)/is.exec(r.sql ?? '');
|
|
137
|
+
if (!m)
|
|
138
|
+
continue;
|
|
139
|
+
const name = lower(r.name);
|
|
140
|
+
skip.add(name);
|
|
141
|
+
for (const suffix of SHADOW_SUFFIXES[lower(m[1])] ?? [])
|
|
142
|
+
skip.add(`${name}_${suffix}`);
|
|
143
|
+
}
|
|
144
|
+
return own.map((r) => r.name).filter((name) => !skip.has(lower(name)));
|
|
145
|
+
}
|
|
146
|
+
function measure(sql) {
|
|
147
|
+
const out = new Map();
|
|
148
|
+
for (const table of fencedTables(sql)) {
|
|
149
|
+
// Qualified: a TEMP object of the same name would otherwise answer for the scope's table.
|
|
150
|
+
const names = sql.query("SELECT name FROM pragma_table_info(?, 'main')", [table]).map((c) => c.name);
|
|
151
|
+
const rows = Number(sql.query(`SELECT COUNT(*) AS n FROM main.${quote(table)}`)[0].n);
|
|
152
|
+
const columns = new Map();
|
|
153
|
+
for (let at = 0; at < names.length && rows > 0; at += COLUMNS_PER_SCAN) {
|
|
154
|
+
const chunk = names.slice(at, at + COLUMNS_PER_SCAN);
|
|
155
|
+
const select = chunk.flatMap((c, i) => CLASSES.map((k) => `COALESCE(SUM(typeof(${quote(c)}) = '${k}'), 0) AS c${i}_${k}`));
|
|
156
|
+
const r = sql.query(`SELECT ${select.join(', ')} FROM main.${quote(table)}`)[0];
|
|
157
|
+
chunk.forEach((c, i) => {
|
|
158
|
+
columns.set(lower(c), Object.fromEntries(CLASSES.map((k) => [k, Number(r[`c${i}_${k}`])])));
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
if (rows === 0)
|
|
162
|
+
for (const c of names)
|
|
163
|
+
columns.set(lower(c), NONE);
|
|
164
|
+
out.set(lower(table), { rows, columns });
|
|
165
|
+
}
|
|
166
|
+
return out;
|
|
167
|
+
}
|
|
168
|
+
function targetOf(spec) {
|
|
169
|
+
const parts = spec.trim().split('.');
|
|
170
|
+
if (parts.length > 2 || parts.some((p) => p === ''))
|
|
171
|
+
return undefined;
|
|
172
|
+
return parts.length === 1 ? { table: lower(parts[0]) } : { table: lower(parts[0]), column: lower(parts[1]) };
|
|
173
|
+
}
|
|
174
|
+
const show = (t) => (t.column ? `${t.table}.${t.column}` : t.table);
|
|
175
|
+
/** What a column a `DROP COLUMN` removed maps to: a name no column after the migration has. */
|
|
176
|
+
const DROPPED = '\u0000dropped';
|
|
177
|
+
/**
|
|
178
|
+
* Statement by statement, which original table holds each name right now. A name is held by at
|
|
179
|
+
* most one table — SQLite refuses a rename onto a name that exists — so a `DROP TABLE` releases it
|
|
180
|
+
* and a later rename onto it is that table's alone, whatever order the scope created them in.
|
|
181
|
+
*
|
|
182
|
+
* A table this migration made, renamed onto a dropped table's ORIGINAL name, continues the dropped
|
|
183
|
+
* one: that is the create-copy-drop-rename rebuild, which the counts then judge, and its later
|
|
184
|
+
* renames, of the table or its columns, are followed. A bare `CREATE TABLE` at that name is not a
|
|
185
|
+
* continuation: renames after it are not followed, which can only refuse.
|
|
186
|
+
*/
|
|
187
|
+
function followRenames(statements, before) {
|
|
188
|
+
const tables = new Map([...before.keys()].map((t) => [t, [t]]));
|
|
189
|
+
const columns = new Map([...before].map(([t, c]) => [t, new Map([...c.columns.keys()].map((k) => [k, k]))]));
|
|
190
|
+
const holder = new Map([...before.keys()].map((t) => [t, t]));
|
|
191
|
+
const dropped = new Set();
|
|
192
|
+
const rebuilt = new Set();
|
|
193
|
+
const rebuiltAt = (name) => {
|
|
194
|
+
if (!dropped.has(name) || holder.has(name))
|
|
195
|
+
return;
|
|
196
|
+
dropped.delete(name);
|
|
197
|
+
rebuilt.add(name);
|
|
198
|
+
holder.set(name, name);
|
|
199
|
+
tables.get(name).push(name);
|
|
200
|
+
};
|
|
201
|
+
for (const statement of statements) {
|
|
202
|
+
const w = words(statement);
|
|
203
|
+
const kw = (i) => (w[i] && !w[i].quoted ? w[i].text : undefined);
|
|
204
|
+
if (kw(0) === 'drop' && kw(1) === 'table') {
|
|
205
|
+
const at = kw(2) === 'if' && kw(3) === 'exists' ? 4 : 2;
|
|
206
|
+
if (!w[at])
|
|
207
|
+
continue;
|
|
208
|
+
const name = mainName(w[at]);
|
|
209
|
+
const original = holder.get(name);
|
|
210
|
+
if (original === undefined)
|
|
211
|
+
continue;
|
|
212
|
+
holder.delete(name);
|
|
213
|
+
dropped.add(original);
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
if (kw(0) !== 'alter' || kw(1) !== 'table' || !w[2])
|
|
217
|
+
continue;
|
|
218
|
+
const table = mainName(w[2]);
|
|
219
|
+
const original = holder.get(table);
|
|
220
|
+
if (!original) {
|
|
221
|
+
// A table this migration made, renamed onto a dropped table's original name: the rebuild.
|
|
222
|
+
if (kw(3) === 'rename' && kw(4) === 'to' && w[5])
|
|
223
|
+
rebuiltAt(mainName(w[5]));
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
const renamed = columns.get(original);
|
|
227
|
+
if (kw(3) === 'drop') {
|
|
228
|
+
// DROP [COLUMN] c: the column is gone, and its name is free for a later rename.
|
|
229
|
+
const k = kw(4) === 'column' ? 5 : 4;
|
|
230
|
+
if (!w[k])
|
|
231
|
+
continue;
|
|
232
|
+
const name = lower(w[k].text);
|
|
233
|
+
for (const [orig, current] of renamed)
|
|
234
|
+
if (current === name)
|
|
235
|
+
renamed.set(orig, DROPPED);
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
if (kw(3) !== 'rename')
|
|
239
|
+
continue;
|
|
240
|
+
if (kw(4) === 'to' && w[5]) {
|
|
241
|
+
holder.delete(table);
|
|
242
|
+
holder.set(mainName(w[5]), original);
|
|
243
|
+
tables.get(original).push(mainName(w[5]));
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
// RENAME [COLUMN] a TO b
|
|
247
|
+
const k = kw(4) === 'column' ? 5 : 4;
|
|
248
|
+
if (!w[k] || kw(k + 1) !== 'to' || !w[k + 2])
|
|
249
|
+
continue;
|
|
250
|
+
const from = lower(w[k].text);
|
|
251
|
+
const to = lower(w[k + 2].text);
|
|
252
|
+
for (const [orig, current] of renamed)
|
|
253
|
+
if (current === from)
|
|
254
|
+
renamed.set(orig, to);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
return { tables, columns, dropped, rebuilt };
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Which table after the migration each table before it became, one to one. A table renamed onto a
|
|
261
|
+
* name that exists afterwards, and not dropped since, claims it first; every other table falls
|
|
262
|
+
* back to its original name, then (unless it was dropped) to an earlier name it carried — never
|
|
263
|
+
* to a name another table already claimed. So
|
|
264
|
+
* `DROP TABLE b; ALTER TABLE a RENAME TO b` leaves `b` to `a`, and the `b` that was dropped is
|
|
265
|
+
* gone. Undefined: the table is gone.
|
|
266
|
+
*/
|
|
267
|
+
function endsOf(before, after, renames) {
|
|
268
|
+
const ends = new Map();
|
|
269
|
+
const claimed = new Set();
|
|
270
|
+
for (const [table, names] of renames.tables) {
|
|
271
|
+
const last = names[names.length - 1];
|
|
272
|
+
// `holder` gave each name to one table at a time, so two undropped tables cannot end on one.
|
|
273
|
+
if (names.length > 1 && !renames.dropped.has(table) && after.has(last)) {
|
|
274
|
+
// A rebuilt table may carry a column under its original name, so it is not followed strictly.
|
|
275
|
+
ends.set(table, { end: last, followed: !renames.rebuilt.has(table) });
|
|
276
|
+
claimed.add(last);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
for (const [table, names] of renames.tables) {
|
|
280
|
+
if (ends.has(table) || !before.has(table))
|
|
281
|
+
continue;
|
|
282
|
+
// A dropped table may come back only under its original name — a rebuild back into place. A
|
|
283
|
+
// name it carried before the drop now belongs to whatever was created there afterwards.
|
|
284
|
+
const candidates = renames.dropped.has(table) ? [table] : [table, ...[...names].reverse()];
|
|
285
|
+
const end = candidates.find((n) => after.has(n) && !claimed.has(n));
|
|
286
|
+
if (end !== undefined)
|
|
287
|
+
claimed.add(end);
|
|
288
|
+
// Followed strictly only when the table never moved: a table rebuilt back into place (moved
|
|
289
|
+
// aside, or dropped and recreated) may carry a column under its original name.
|
|
290
|
+
const followed = names.length === 1 && !renames.dropped.has(table);
|
|
291
|
+
ends.set(table, end === undefined ? undefined : { end, followed });
|
|
292
|
+
}
|
|
293
|
+
return ends;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Compare the two measures: every table that held rows, and every column that held values, must
|
|
297
|
+
* still hold at least as much — following renames — unless it is moved or discarded.
|
|
298
|
+
*/
|
|
299
|
+
function lossesOf(before, after, renames) {
|
|
300
|
+
const losses = [];
|
|
301
|
+
const ends = endsOf(before, after, renames);
|
|
302
|
+
for (const [table, b] of before) {
|
|
303
|
+
if (b.rows === 0)
|
|
304
|
+
continue;
|
|
305
|
+
const resolved = ends.get(table);
|
|
306
|
+
if (resolved === undefined) {
|
|
307
|
+
losses.push({ target: { table }, what: `table ${table} held ${b.rows} row(s) and is gone` });
|
|
308
|
+
continue;
|
|
309
|
+
}
|
|
310
|
+
const a = after.get(resolved.end);
|
|
311
|
+
if (a.rows < b.rows)
|
|
312
|
+
losses.push({ target: { table }, what: `table ${table} held ${b.rows} row(s), now ${a.rows}` });
|
|
313
|
+
const renamed = renames.columns.get(table);
|
|
314
|
+
for (const [column, held] of b.columns) {
|
|
315
|
+
if (total(held) === 0)
|
|
316
|
+
continue;
|
|
317
|
+
// Followed through its renames; on a table rebuilt back into place, the rename the old table
|
|
318
|
+
// took before it moved aside still names the column, and its original name is the fallback.
|
|
319
|
+
const mapped = renamed.get(column);
|
|
320
|
+
// A column a `DROP COLUMN` removed is gone, whatever later takes its name.
|
|
321
|
+
const kept = mapped === DROPPED ? undefined : (a.columns.get(mapped) ?? (resolved.followed ? undefined : a.columns.get(column)));
|
|
322
|
+
// A kernel-derived column (`_substrat_archived_at`, …) leaving is the kernel's own check's to
|
|
323
|
+
// refuse, right after this one in the same transaction (#2090), with the remedy that fits:
|
|
324
|
+
// no declaration can excuse it. Its VALUES are still held here.
|
|
325
|
+
if (kept === undefined && namesSpineTable(column))
|
|
326
|
+
continue;
|
|
327
|
+
const target = { table, column };
|
|
328
|
+
if (kept === undefined) {
|
|
329
|
+
losses.push({ target, what: `column ${table}.${column} held ${total(held)} value(s) and is gone` });
|
|
330
|
+
continue;
|
|
331
|
+
}
|
|
332
|
+
const short = CLASSES.filter((k) => kept[k] < held[k]);
|
|
333
|
+
if (short.length > 0) {
|
|
334
|
+
losses.push({
|
|
335
|
+
target,
|
|
336
|
+
what: `column ${table}.${column} held ${total(held)} value(s), now ${total(kept)}` +
|
|
337
|
+
(total(kept) >= total(held) ? ` (${short.map((k) => `${k} ${held[k]} → ${kept[k]}`).join(', ')}: retyped)` : ''),
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
return losses;
|
|
343
|
+
}
|
|
344
|
+
const declarationError = (key, message, reason = 'migration_declaration') => substratError('validation_failed', `migration ${key}: ${message} (#115)`, { reason });
|
|
345
|
+
/**
|
|
346
|
+
* A statement that makes a TEMP object: `CREATE TEMP|TEMPORARY …`, or one named into the `temp`
|
|
347
|
+
* schema (`CREATE TABLE temp.x`, `"temp"."x"`), however the name is spelled.
|
|
348
|
+
*/
|
|
349
|
+
function createsTemp(statement) {
|
|
350
|
+
const w = words(statement);
|
|
351
|
+
const kw = (i) => (w[i] && !w[i].quoted ? w[i].text : undefined);
|
|
352
|
+
if (kw(0) !== 'create')
|
|
353
|
+
return false;
|
|
354
|
+
if (kw(1) === 'temp' || kw(1) === 'temporary')
|
|
355
|
+
return true;
|
|
356
|
+
let at = 1;
|
|
357
|
+
if (kw(at) === 'unique' || kw(at) === 'virtual')
|
|
358
|
+
at += 1;
|
|
359
|
+
if (!['table', 'view', 'index', 'trigger'].includes(kw(at) ?? ''))
|
|
360
|
+
return false;
|
|
361
|
+
at += 1;
|
|
362
|
+
if (kw(at) === 'if' && kw(at + 1) === 'not' && kw(at + 2) === 'exists')
|
|
363
|
+
at += 3;
|
|
364
|
+
// `"temp.x"` is one identifier, a main table whose name holds a dot; `temp.x` is the schema.
|
|
365
|
+
return w[at] !== undefined && schemaAndName(w[at]).schema === 'temp';
|
|
366
|
+
}
|
|
367
|
+
/** A statement that attaches or detaches a database: `ATTACH [DATABASE] …`, `DETACH [DATABASE] …`. */
|
|
368
|
+
function attaches(statement) {
|
|
369
|
+
const w = words(statement);
|
|
370
|
+
return w[0] !== undefined && !w[0].quoted && (w[0].text === 'attach' || w[0].text === 'detach');
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* What a declaration counts: a column's values per class, or a table's rows — carried in one
|
|
374
|
+
* class slot so a move compares tables and columns with the same loop.
|
|
375
|
+
*/
|
|
376
|
+
function countOf(m, t) {
|
|
377
|
+
const table = m.get(t.table);
|
|
378
|
+
if (!table)
|
|
379
|
+
return undefined;
|
|
380
|
+
if (!t.column)
|
|
381
|
+
return { ...NONE, integer: table.rows };
|
|
382
|
+
return table.columns.get(t.column);
|
|
383
|
+
}
|
|
384
|
+
const covers = (declared, lost) => declared.table === lost.table && (declared.column === undefined || declared.column === lost.column);
|
|
385
|
+
/** Each class `got` falls short of `need`, as `<class> <need> → <got>`. */
|
|
386
|
+
const shortfall = (need, got) => CLASSES.filter((k) => got[k] < need[k]).map((k) => `${k} ${need[k]} → ${got[k]}`);
|
|
387
|
+
const plus = (a, b) => Object.fromEntries(CLASSES.map((k) => [k, a[k] + b[k]]));
|
|
388
|
+
const gain = (before, after) => Object.fromEntries(CLASSES.map((k) => [k, (after?.[k] ?? 0) - (before?.[k] ?? 0)]));
|
|
389
|
+
/**
|
|
390
|
+
* Verify the declared moves: each target gained, per class, what its sources held; and a table
|
|
391
|
+
* moved whole brought every column that held values into a target column of the same name, unless
|
|
392
|
+
* that column is declared by name itself.
|
|
393
|
+
*/
|
|
394
|
+
function moveFailures(before, after, moves, discards) {
|
|
395
|
+
const failures = [];
|
|
396
|
+
const byTarget = new Map();
|
|
397
|
+
for (const m of moves) {
|
|
398
|
+
const entry = byTarget.get(show(m.target)) ?? { target: m.target, sources: [] };
|
|
399
|
+
entry.sources.push(m.source);
|
|
400
|
+
byTarget.set(show(m.target), entry);
|
|
401
|
+
}
|
|
402
|
+
for (const { target, sources } of byTarget.values()) {
|
|
403
|
+
if (!countOf(after, target)) {
|
|
404
|
+
failures.push(`moves names ${show(target)} as a target, which does not exist after the migration`);
|
|
405
|
+
continue;
|
|
406
|
+
}
|
|
407
|
+
const need = sources.reduce((n, s) => plus(n, countOf(before, s)), NONE);
|
|
408
|
+
const gained = gain(countOf(before, target), countOf(after, target));
|
|
409
|
+
const short = shortfall(need, gained);
|
|
410
|
+
if (short.length > 0) {
|
|
411
|
+
const from = `moves into ${show(target)} from ${sources.map(show).join(', ')}`;
|
|
412
|
+
failures.push(target.column
|
|
413
|
+
? `${from}: the sources' values did not all arrive (${short.join(', ')})`
|
|
414
|
+
: `${from}: the sources held ${need.integer} row(s), the target gained ${gained.integer}`);
|
|
415
|
+
}
|
|
416
|
+
if (target.column)
|
|
417
|
+
continue;
|
|
418
|
+
// A table moved whole: its columns arrive by name, unless declared by name.
|
|
419
|
+
const byColumn = new Map();
|
|
420
|
+
for (const source of sources) {
|
|
421
|
+
for (const [column, held] of before.get(source.table).columns) {
|
|
422
|
+
const named = { table: source.table, column };
|
|
423
|
+
if (total(held) === 0 || namesSpineTable(column))
|
|
424
|
+
continue;
|
|
425
|
+
if (moves.some((m) => m.source.column === column && m.source.table === source.table))
|
|
426
|
+
continue;
|
|
427
|
+
if (discards.some((d) => covers(d, named)))
|
|
428
|
+
continue;
|
|
429
|
+
const entry = byColumn.get(column) ?? { need: NONE, from: [] };
|
|
430
|
+
byColumn.set(column, { need: plus(entry.need, held), from: [...entry.from, show(named)] });
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
for (const [column, { need: held, from }] of byColumn) {
|
|
434
|
+
const into = { table: target.table, column };
|
|
435
|
+
const now = countOf(after, into);
|
|
436
|
+
const missing = now === undefined ? [] : shortfall(held, gain(countOf(before, into), now));
|
|
437
|
+
if (now === undefined || missing.length > 0) {
|
|
438
|
+
failures.push(`moves ${from.join(', ')} into ${target.table}, but ${now === undefined ? `${show(into)} does not exist` : `${show(into)} did not gain them (${missing.join(', ')})`} — ` +
|
|
439
|
+
`move the column by name (moves: { '${from[0]}': '<table.column>' }) or discard it`);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
return failures;
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Wrap one authored migration's execution in the fence. `run` executes every statement of it; it
|
|
447
|
+
* runs inside the caller's transaction, so a throw from here rolls all of it back.
|
|
448
|
+
*/
|
|
449
|
+
export function fenceMigration(sql, migration, key, run) {
|
|
450
|
+
const statements = executableSqlStatements(migration.sql);
|
|
451
|
+
const temp = statements.find(createsTemp);
|
|
452
|
+
if (temp !== undefined) {
|
|
453
|
+
throw declarationError(key, `it creates a TEMP object (\`${temp.slice(0, 80)}\`). A Durable Object refuses TEMP objects, so this migration ` +
|
|
454
|
+
'cannot run on the hosted adapter, and a TEMP table shadows the scope\'s own tables for every unqualified statement ' +
|
|
455
|
+
'after it. Use a regular table and DROP it before the migration ends', 'migration_temp');
|
|
456
|
+
}
|
|
457
|
+
const attach = statements.find(attaches);
|
|
458
|
+
if (attach !== undefined) {
|
|
459
|
+
throw declarationError(key, `it attaches or detaches a database (\`${attach.slice(0, 80)}\`). A Durable Object refuses ATTACH and DETACH, so this ` +
|
|
460
|
+
'migration cannot run on the hosted adapter, and an attached database is a file outside the scope the fence protects. ' +
|
|
461
|
+
"Keep the migration inside the scope's own database", 'migration_attach');
|
|
462
|
+
}
|
|
463
|
+
const moves = Object.entries(migration.moves ?? {});
|
|
464
|
+
const discards = Object.entries(migration.discards ?? {});
|
|
465
|
+
// The push boundary refuses a `__proto__` declaration key, which a record parsed from JSON would
|
|
466
|
+
// silently drop (#2322); refusing it here too means the author hears it at lint time, not when
|
|
467
|
+
// the push leaves the migrations off.
|
|
468
|
+
for (const [what, record] of [['moves', migration.moves], ['discards', migration.discards]]) {
|
|
469
|
+
if (record && Object.hasOwn(record, '__proto__'))
|
|
470
|
+
throw declarationError(key, `${what} names __proto__, which a declaration cannot carry`);
|
|
471
|
+
}
|
|
472
|
+
if (moves.length === 0 && discards.length === 0 && statements.every(additive)) {
|
|
473
|
+
run();
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
const before = measure(sql);
|
|
477
|
+
// Every declaration is read before anything runs, so a malformed one changes nothing.
|
|
478
|
+
const parsedMoves = moves.map(([from, to]) => {
|
|
479
|
+
const source = targetOf(from);
|
|
480
|
+
const target = targetOf(to);
|
|
481
|
+
if (!source || !target)
|
|
482
|
+
throw declarationError(key, `moves: { '${from}': '${to}' } is not 'table' → 'table' or 'table.column' → 'table.column'`);
|
|
483
|
+
if (!source.column !== !target.column)
|
|
484
|
+
throw declarationError(key, `moves: { '${from}': '${to}' } moves a table to a column or a column to a table`);
|
|
485
|
+
if (!countOf(before, source))
|
|
486
|
+
throw declarationError(key, `moves names ${show(source)}, which this scope does not hold before the migration`);
|
|
487
|
+
return { source, target };
|
|
488
|
+
});
|
|
489
|
+
const parsedDiscards = discards.map(([spec, why]) => {
|
|
490
|
+
const target = targetOf(spec);
|
|
491
|
+
if (!target)
|
|
492
|
+
throw declarationError(key, `discards: { '${spec}': … } is not 'table' or 'table.column'`);
|
|
493
|
+
// The push boundary's own rule (`blankReason`): a reason of only whitespace or invisible
|
|
494
|
+
// characters says nothing a reviewer can read, so neither side accepts it (#2322).
|
|
495
|
+
if (typeof why !== 'string' || blankReason(why))
|
|
496
|
+
throw declarationError(key, `discards: { '${spec}': … } gives no reason; the reason is what a reviewer reads`);
|
|
497
|
+
if (!countOf(before, target))
|
|
498
|
+
throw declarationError(key, `discards names ${show(target)}, which this scope does not hold before the migration`);
|
|
499
|
+
return target;
|
|
500
|
+
});
|
|
501
|
+
run();
|
|
502
|
+
const after = measure(sql);
|
|
503
|
+
const failures = moveFailures(before, after, parsedMoves, parsedDiscards);
|
|
504
|
+
const unexcused = lossesOf(before, after, followRenames(statements, before)).filter((l) => !parsedDiscards.some((d) => covers(d, l.target)) && !parsedMoves.some((m) => covers(m.source, l.target)));
|
|
505
|
+
if (failures.length === 0 && unexcused.length === 0)
|
|
506
|
+
return;
|
|
507
|
+
const lines = [...failures, ...unexcused.map((l) => l.what)];
|
|
508
|
+
const remedy = unexcused.length === 0
|
|
509
|
+
? ''
|
|
510
|
+
: ` If this is intended, declare it on the migration — discards: { ${unexcused
|
|
511
|
+
.map((l) => `'${show(l.target)}': '<why this data may go>'`)
|
|
512
|
+
.join(', ')} } — or, where the data moved, moves: { '<source>': '<where it went>' }.`;
|
|
513
|
+
throw substratError('forbidden', `migration ${key} would lose data this scope holds, so it was not applied (#115): ${lines.join('; ')}.${remedy}`, { reason: 'data_loss' });
|
|
514
|
+
}
|
|
515
|
+
//# sourceMappingURL=migration-fence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-fence.js","sourceRoot":"","sources":["../src/migration-fence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AACH,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEnG,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,iEAAiE;AACjE,MAAM,OAAO,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAU,CAAC;AAU7D;;;GAGG;AACH,MAAM,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAE5E,+FAA+F;AAC/F,MAAM,KAAK,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,C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C,EAAE;QACJ,CAAC,CAAC,mEAAmE,SAAS;aACzE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,6BAA6B,CAAC;aAC3D,IAAI,CAAC,IAAI,CAAC,0EAA0E,CAAC;IAC9F,MAAM,aAAa,CACjB,WAAW,EACX,aAAa,GAAG,oEAAoE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,MAAM,EAAE,EAChH,EAAE,MAAM,EAAE,WAAW,EAAE,CACxB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { moduleMigrations } from './module-migrations.js';
|
|
2
|
+
import type { SqlValue } from './scope-host.js';
|
|
3
|
+
/**
|
|
4
|
+
* The shape of {@link replayMigrations} and its outcome. A caller reaching a kernel it did not
|
|
5
|
+
* build against (`substrat push`, through the vertical's own) checks this before calling, and
|
|
6
|
+
* treats any other value as "this kernel's replay is not one I know how to call".
|
|
7
|
+
*/
|
|
8
|
+
export declare const MIGRATION_REPLAY_API = 1;
|
|
9
|
+
/** An empty database the replay may do anything to. SQLite: the fence measures with its SQL. */
|
|
10
|
+
export interface ReplayDatabase {
|
|
11
|
+
/** Run SQL text holding any number of statements, with no parameters. */
|
|
12
|
+
exec(sql: string): void;
|
|
13
|
+
query<T = Record<string, SqlValue>>(sql: string, params?: readonly SqlValue[]): T[];
|
|
14
|
+
run(sql: string, params?: readonly SqlValue[]): {
|
|
15
|
+
changes: number;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/** Structural, as `moduleMigrations` takes it: a `ModuleRegistration` fits, and so does one read as data. */
|
|
19
|
+
export type ReplayModule = Parameters<typeof moduleMigrations>[0];
|
|
20
|
+
export interface ReplayOutcome {
|
|
21
|
+
/** Authored migrations across the modules — the ones the fence judges. */
|
|
22
|
+
readonly authored: number;
|
|
23
|
+
/** Authored migrations that ran against a populated scope and passed the fence. */
|
|
24
|
+
readonly passed: number;
|
|
25
|
+
/** The fence refused this migration: it would lose data a scope holds. The replay stopped here. */
|
|
26
|
+
readonly refused?: {
|
|
27
|
+
readonly key: string;
|
|
28
|
+
readonly reason: string;
|
|
29
|
+
readonly message: string;
|
|
30
|
+
};
|
|
31
|
+
/** This migration could not be run on synthetic data at all. The replay stopped here. */
|
|
32
|
+
readonly failed?: {
|
|
33
|
+
readonly key: string;
|
|
34
|
+
readonly message: string;
|
|
35
|
+
};
|
|
36
|
+
/** Every declared move and discard that passed, with its reason — what a reviewer reads beside the SQL. */
|
|
37
|
+
readonly declared: readonly string[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Replay `modules`, in order, against a populated scope in `db`. `spineDdl` builds the platform's
|
|
41
|
+
* `_substrat_*` tables first, for an authored migration that reads them (adapter-sqlite's
|
|
42
|
+
* `SCOPE_SPINE_DDL`); without it such a migration is {@link ReplayOutcome.failed}, not refused.
|
|
43
|
+
*
|
|
44
|
+
* Stops at the first refusal or failure: the migrations after it would replay against a schema
|
|
45
|
+
* no scope ever had.
|
|
46
|
+
*/
|
|
47
|
+
export declare function replayMigrations(db: ReplayDatabase, modules: readonly ReplayModule[], opts?: {
|
|
48
|
+
readonly spineDdl?: string;
|
|
49
|
+
/** Called before each migration runs — a caller bounding the replay's time reads progress here. */
|
|
50
|
+
readonly onMigration?: (key: string, authored: boolean) => void;
|
|
51
|
+
}): ReplayOutcome;
|
|
52
|
+
//# sourceMappingURL=migration-replay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-replay.d.ts","sourceRoot":"","sources":["../src/migration-replay.ts"],"names":[],"mappings":"AA0BA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAA2B,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAIzE;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,IAAI,CAAC;AAEtC,gGAAgG;AAChG,MAAM,WAAW,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