@substrat-run/adapter-cloudflare 0.219.0 → 0.221.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.
Files changed (54) hide show
  1. package/dist/control-plane-do.d.ts +107 -5
  2. package/dist/control-plane-do.d.ts.map +1 -1
  3. package/dist/control-plane-do.js +207 -16
  4. package/dist/control-plane-do.js.map +1 -1
  5. package/dist/directory-mirror-backfill.d.ts +143 -0
  6. package/dist/directory-mirror-backfill.d.ts.map +1 -0
  7. package/dist/directory-mirror-backfill.js +467 -0
  8. package/dist/directory-mirror-backfill.js.map +1 -0
  9. package/dist/directory-mirror-verify.d.ts +166 -0
  10. package/dist/directory-mirror-verify.d.ts.map +1 -0
  11. package/dist/directory-mirror-verify.js +478 -0
  12. package/dist/directory-mirror-verify.js.map +1 -0
  13. package/dist/directory-mirror.d.ts +101 -3
  14. package/dist/directory-mirror.d.ts.map +1 -1
  15. package/dist/directory-mirror.js +143 -37
  16. package/dist/directory-mirror.js.map +1 -1
  17. package/dist/directory-objects.d.ts +14 -0
  18. package/dist/directory-objects.d.ts.map +1 -1
  19. package/dist/directory-objects.js +34 -0
  20. package/dist/directory-objects.js.map +1 -1
  21. package/dist/directory-placement.d.ts.map +1 -1
  22. package/dist/directory-placement.js +10 -2
  23. package/dist/directory-placement.js.map +1 -1
  24. package/dist/directory-split-inventory.d.ts +2 -1
  25. package/dist/directory-split-inventory.d.ts.map +1 -1
  26. package/dist/directory-split-inventory.js +4 -1
  27. package/dist/directory-split-inventory.js.map +1 -1
  28. package/dist/host.d.ts +71 -5
  29. package/dist/host.d.ts.map +1 -1
  30. package/dist/host.js +293 -37
  31. package/dist/host.js.map +1 -1
  32. package/dist/peer-call-target.d.ts.map +1 -1
  33. package/dist/peer-call-target.js +3 -2
  34. package/dist/peer-call-target.js.map +1 -1
  35. package/dist/route-read-model-publisher.d.ts +42 -1
  36. package/dist/route-read-model-publisher.d.ts.map +1 -1
  37. package/dist/route-read-model-publisher.js +176 -55
  38. package/dist/route-read-model-publisher.js.map +1 -1
  39. package/dist/route-read-model.d.ts +15 -0
  40. package/dist/route-read-model.d.ts.map +1 -1
  41. package/dist/route-read-model.js +21 -9
  42. package/dist/route-read-model.js.map +1 -1
  43. package/dist/scope-do.d.ts +48 -1
  44. package/dist/scope-do.d.ts.map +1 -1
  45. package/dist/scope-do.js +434 -29
  46. package/dist/scope-do.js.map +1 -1
  47. package/dist/scope-sweeper-do.d.ts +24 -0
  48. package/dist/scope-sweeper-do.d.ts.map +1 -1
  49. package/dist/scope-sweeper-do.js +90 -1
  50. package/dist/scope-sweeper-do.js.map +1 -1
  51. package/dist/scope-work.d.ts +2 -2
  52. package/dist/scope-work.js +2 -2
  53. package/dist/scope-work.js.map +1 -1
  54. package/package.json +18 -13
@@ -0,0 +1,166 @@
1
+ import { type DirectoryMirror, type MirrorBackfillPass, type MirrorBackfillRunner } from './directory-mirror.js';
2
+ /** One table's page of the directory's rows, as (key, digest), and the key range it covers. */
3
+ export interface MirrorCompareRequest {
4
+ table: string;
5
+ /** The range is `(after, upTo]` in key order; null `after` is from the start, null `upTo` to the end. */
6
+ after: string | null;
7
+ upTo: string | null;
8
+ rows: {
9
+ key: string;
10
+ digest: string;
11
+ }[];
12
+ }
13
+ export interface MirrorCompareResult {
14
+ /** Keys the directory holds that the object lacks, and that the object holds beyond the directory's. */
15
+ missing: string[];
16
+ extra: string[];
17
+ /** Keys both hold whose rows differ. */
18
+ differs: string[];
19
+ /** Of those, the keys the object holds parked (in flight, not a difference). */
20
+ parked: string[];
21
+ /** The object held more rows in the range than one answer carries. */
22
+ truncated: boolean;
23
+ }
24
+ /** Rows of a range the object reads at most, so a range a restore left full of extras stays bounded. */
25
+ export declare const MIRROR_COMPARE_MAX_ROWS = 1000;
26
+ /** The object's half: its rows of the request's range, digested and compared. */
27
+ export declare function compareMirrorRange(sql: SqlStorage, req: MirrorCompareRequest): Promise<MirrorCompareResult>;
28
+ export declare const VERIFY_DDL: string[];
29
+ export interface VerifyLimits {
30
+ pageRows: number;
31
+ pagesPerPass: number;
32
+ pauseMs: number;
33
+ /** From the end of one run to the start of the next. */
34
+ intervalMs: number;
35
+ /** Hostnames (a tenant) or verticals (the registry) whose read-model entries one owner compares. */
36
+ entriesPerOwner: number;
37
+ }
38
+ export declare const VERIFY_LIMITS: VerifyLimits;
39
+ /** The switch: unset, empty or `off` compares nothing; `on` compares every mirrored table. Anything else is refused. */
40
+ export declare function parseDirectoryVerify(value: unknown): boolean;
41
+ export type DifferenceKind = 'missing' | 'extra' | 'differs';
42
+ /** One owner's comparison: what was read, what differs, what was in flight. */
43
+ export interface VerifyTally {
44
+ rows: number;
45
+ missing: number;
46
+ extra: number;
47
+ differs: number;
48
+ inFlight: number;
49
+ /** A range on the object's side held more rows than one answer carries: the extras are a floor. */
50
+ truncated: number;
51
+ /** The first differences, for staff: which table, which key, which kind. */
52
+ sample: {
53
+ table: string;
54
+ key: string;
55
+ kind: DifferenceKind;
56
+ }[];
57
+ /** The read model fed from the objects: entries compared, how many differ, which. Null until the rows verify. */
58
+ entries: {
59
+ checked: number;
60
+ differ: number;
61
+ inFlight: boolean;
62
+ sample: string[];
63
+ truncated: boolean;
64
+ } | null;
65
+ /** The backfill had filled this owner when its comparison started (null: the backfill is not on). */
66
+ filled: boolean | null;
67
+ /** An object refused a page; the comparison stopped there. */
68
+ error: string | null;
69
+ }
70
+ export interface VerifyOwner {
71
+ owner: string;
72
+ /** The last finished comparison: when, and what it found. Null until one finished. */
73
+ checkedAt: string | null;
74
+ result: (VerifyTally & {
75
+ verified: boolean;
76
+ }) | null;
77
+ /** The comparison in progress in the current run, if this owner's is not finished. */
78
+ inProgress: VerifyTally | null;
79
+ }
80
+ export interface VerifyStatus {
81
+ enabled: true;
82
+ run: number | null;
83
+ phase: 'walk' | 'done' | null;
84
+ startedAt: string | null;
85
+ /** When the current run finished (null while it walks), and when the last finished run did. */
86
+ finishedAt: string | null;
87
+ lastFinishedAt: string | null;
88
+ tenants: number;
89
+ /** Owners whose last finished comparison found no difference, found some, or stopped on an error. */
90
+ verified: number;
91
+ differing: number;
92
+ errored: number;
93
+ /** The next run starts no earlier than this. */
94
+ nextRunAt: string | null;
95
+ }
96
+ /** How the directory reaches the objects for a comparison (`durableMirrorSender`). */
97
+ export interface MirrorVerifySender {
98
+ compare(owner: string, req: MirrorCompareRequest): Promise<MirrorCompareResult>;
99
+ /** A tenant object's route reads, one per hostname (`readRouteSourceOfTenant`). */
100
+ routeSources(owner: string, hostnames: readonly string[]): Promise<{
101
+ row: Record<string, unknown> | null;
102
+ refused: {
103
+ region: string | null;
104
+ jurisdiction: string | null;
105
+ } | null;
106
+ }[]>;
107
+ /** The registry's version fields by id (`VERSION_POLICY_SQL`). */
108
+ versionPolicies(ids: readonly string[]): Promise<Record<string, unknown>[]>;
109
+ /** The registry's serving-policy entries by slug, as the directory computes them. */
110
+ servingPolicies(slugs: readonly string[]): Promise<(Record<string, unknown> | null)[]>;
111
+ }
112
+ export interface DirectoryVerifyOptions {
113
+ sql: SqlStorage;
114
+ transaction: <T>(fn: () => T) => T;
115
+ sender: MirrorVerifySender;
116
+ quiet: () => boolean;
117
+ limits?: Partial<VerifyLimits>;
118
+ now?: () => number;
119
+ }
120
+ /** The directory's half of 3d, one per `ControlPlaneDO` instance while the switch is on beside the mirror. */
121
+ export declare class DirectoryVerify implements MirrorBackfillRunner {
122
+ private readonly options;
123
+ private readonly sql;
124
+ private readonly limits;
125
+ private readonly keys;
126
+ constructor(options: DirectoryVerifyOptions);
127
+ private now;
128
+ private iso;
129
+ private keyColumns;
130
+ /** Every table the mirror copies now, in placement order. */
131
+ private mirrored;
132
+ private runRow;
133
+ private nextRunAt;
134
+ wanted(): boolean;
135
+ /** The run in effect, a new one once the last finished and its interval passed. In the caller's transaction. */
136
+ private ensureRun;
137
+ private ownerRow;
138
+ /** Whether 3c's backfill has filled this owner in its current run (null when the backfill was never on). */
139
+ private filledByBackfill;
140
+ /** The owner the next page is for: the one in progress, else the registry, else the next tenant. Null: the run is done. */
141
+ private nextOwner;
142
+ private tablesOf;
143
+ /** The directory's row of a key as it stands now, digested; null when it is gone or no longer this owner's. */
144
+ private currentDigest;
145
+ private queued;
146
+ /** One page of one table: read and digest, ask the object, re-read what it named. */
147
+ private comparePage;
148
+ /** The owner's read-model entries, built from the objects and compared with the directory's. */
149
+ private compareEntries;
150
+ /** Record an owner's progress, or finish it: the tally becomes its result, and the walk moves on. */
151
+ private save;
152
+ pass(): Promise<MirrorBackfillPass>;
153
+ status(): VerifyStatus;
154
+ /** A page of owners' reports in owner order after `after`, or the one `owner` names. */
155
+ owners(query?: {
156
+ after?: string;
157
+ owner?: string;
158
+ limit?: number;
159
+ }): VerifyOwner[];
160
+ }
161
+ /**
162
+ * The directory's comparison as its environment sets it, attached to its mirror: null when
163
+ * `DIRECTORY_VERIFY` is off or refused, or there is no mirror. Its tables are created only when on.
164
+ */
165
+ export declare function directoryVerifyFor(env: unknown, mirror: DirectoryMirror | null, limits?: Partial<VerifyLimits>): DirectoryVerify | null;
166
+ //# sourceMappingURL=directory-mirror-verify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directory-mirror-verify.d.ts","sourceRoot":"","sources":["../src/directory-mirror-verify.ts"],"names":[],"mappings":"AAgCA,OAAO,EAUL,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EAG1B,MAAM,uBAAuB,CAAC;AAQ/B,+FAA+F;AAC/F,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,yGAAyG;IACzG,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CACzC;AAED,MAAM,WAAW,mBAAmB;IAClC,wGAAwG;IACxG,OAAO,EAAE,MAAM,EAAE,CAAC;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AU;IAMlB,6DAA6D;IAC7D,OAAO,CAAC,QAAQ;IAKhB,OAAO,CAAC,MAAM;IAId,OAAO,CAAC,SAAS;IAKjB,MAAM,IAAI,OAAO,CAKhB;IAED,gHAAgH;IAChH,OAAO,CAAC,SAAS;IAcjB,OAAO,CAAC,QAAQ;IAIhB,4GAA4G;IAC5G,OAAO,CAAC,gBAAgB;IAUxB,2HAA2H;IAC3H,OAAO,CAAC,SAAS;IA0BjB,OAAO,CAAC,QAAQ;IAKhB,+GAA+G;YACjG,aAAa;IAU3B,OAAO,CAAC,MAAM;IAMd,qFAAqF;YACvE,WAAW;IAoCzB,gGAAgG;YAClF,cAAc;IAiD5B,qGAAqG;IACrG,OAAO,CAAC,IAAI;IAcN,IAAI,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAqDxC;IAED,MAAM,IAAI,YAAY,CAwBrB;IAED,wFAAwF;IACxF,MAAM,CAAC,KAAK,GAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,WAAW,EAAE,CAapF;CACF;AAQD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,GAAG,IAAI,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,eAAe,GAAG,IAAI,CAyBvI"}
@@ -0,0 +1,478 @@
1
+ /**
2
+ * Step 3d of the directory split (K-68, directory split; rfc/tenant-scale.md §12): VERIFY. A comparison
3
+ * job reads both sides, owner by owner (the registry, then each tenant in id order), and reports per
4
+ * owner what differs. It decides nothing and moves no read: a report is all it writes.
5
+ *
6
+ * **Off by default, and only beside the mirror.** `DIRECTORY_VERIFY` unset (or `off`) attaches
7
+ * nothing; `on` compares every table the mirror copies, a run at a time, `intervalMs` (six hours)
8
+ * between the end of one run and the start of the next. Switching it off stops it after the page in
9
+ * flight and leaves the last report readable; nothing waits on it.
10
+ *
11
+ * **"Equal" means the same thing on both sides.** A side's rows are read with the capture's own
12
+ * statement (`SELECT t.*`, decoded by `decodeMirrorRow`; the directory's with the backfill's reader,
13
+ * `readOwnerRows`, so with the placement the triggers use) and each is digested by `mirrorRowDigest`.
14
+ * The directory sends one table's page of (key, digest) and the key range it covers; the object
15
+ * digests its own rows in that range and answers which keys it lacks, which it holds beyond the
16
+ * directory's, and which differ.
17
+ *
18
+ * **In flight is not a difference.** A key the answer names is re-read in the directory after the
19
+ * answer came back. It is in flight, and counted apart, when it is still in `directory_mirror_outbox`
20
+ * for that object, when the object holds it parked, or when the directory's row changed since the page
21
+ * was read (the flush may have carried the change to the object between the page and the answer). Only
22
+ * what is left is a difference.
23
+ *
24
+ * **The router's read model, fed from the objects and compared** (the rfc's step 3d). Once an owner's
25
+ * rows show no difference, its read-model entries are built from the objects and compared with the
26
+ * ones the directory publishes, by the same assembly (`routeEntryOfRead`, `servingPolicyEntryOf`):
27
+ * - a tenant: one route entry (`h:`) per hostname of its scopes, from the tenant object's own
28
+ * hostnames, scopes and tenants (`ROUTE_SOURCE_SQL`) and the registry's version fields;
29
+ * - the registry: one serving-policy entry (`v:`) per vertical, from the registry's own rows.
30
+ * Nothing is written to KV: the router keeps reading what the directory publishes.
31
+ */
32
+ import { REGISTRY_OWNER, tenantOwnerOf } from '@substrat-run/kernel';
33
+ import { MIRRORED_TABLES, mirrorKeyColumns, mirrorKeySql, mirrorOwnerRowsSql, mirrorRowDigest, mirrorTargetsSql, objectKindOfOwner, quoteIdent, decodeMirrorRow, } from './directory-mirror.js';
34
+ import { readOwnerRows } from './directory-mirror-backfill.js';
35
+ import { computeRouteReadModelEntry, routeEntryOfRead } from './route-read-model-publisher.js';
36
+ /** Rows of a range the object reads at most, so a range a restore left full of extras stays bounded. */
37
+ export const MIRROR_COMPARE_MAX_ROWS = 1_000;
38
+ /** The object's half: its rows of the request's range, digested and compared. */
39
+ export async function compareMirrorRange(sql, req) {
40
+ const keys = mirrorKeyColumns(sql, req.table);
41
+ const keyExprs = keys.map((k) => (k === 'rowid' ? 't.rowid' : `t.${quoteIdent(k)}`));
42
+ const tuple = `(${keyExprs.join(', ')})`;
43
+ const marks = `(${keyExprs.map(() => '?').join(', ')})`;
44
+ const after = req.after === null ? null : JSON.parse(req.after);
45
+ const upTo = req.upTo === null ? null : JSON.parse(req.upTo);
46
+ const where = [after ? `${tuple} > ${marks}` : null, upTo ? `${tuple} <= ${marks}` : null].filter((w) => w !== null);
47
+ const rowid = keys[0] === 'rowid' ? ', t.rowid AS "__mirror_rowid"' : '';
48
+ const found = sql
49
+ .exec(`SELECT t.*${rowid}, ${mirrorKeySql(keys, 't')} AS "__mirror_key" FROM ${quoteIdent(req.table)} t` +
50
+ (where.length > 0 ? ` WHERE ${where.join(' AND ')}` : '') +
51
+ ` ORDER BY ${keyExprs.join(', ')} LIMIT ?`, ...(after ?? []), ...(upTo ?? []), MIRROR_COMPARE_MAX_ROWS + 1)
52
+ .toArray();
53
+ const truncated = found.length > MIRROR_COMPARE_MAX_ROWS;
54
+ const held = new Map();
55
+ for (const r of found.slice(0, MIRROR_COMPARE_MAX_ROWS))
56
+ held.set(String(r['__mirror_key']), await mirrorRowDigest(decodeMirrorRow(req.table, r).row));
57
+ const wanted = new Map(req.rows.map((r) => [r.key, r.digest]));
58
+ const missing = [];
59
+ const differs = [];
60
+ for (const [key, digest] of wanted) {
61
+ const mine = held.get(key);
62
+ if (mine === undefined)
63
+ missing.push(key);
64
+ else if (mine !== digest)
65
+ differs.push(key);
66
+ }
67
+ const extra = [...held.keys()].filter((k) => !wanted.has(k));
68
+ const named = [...missing, ...differs, ...extra];
69
+ const parked = named.length === 0
70
+ ? []
71
+ : sql
72
+ .exec(`SELECT row_key FROM directory_mirror_parked WHERE tbl = ? AND row_key IN (SELECT value FROM json_each(?))`, req.table, JSON.stringify(named))
73
+ .toArray().map((r) => r.row_key);
74
+ return { missing, extra, differs, parked, truncated };
75
+ }
76
+ // ---------------------------------------------------------------------------
77
+ // The directory's half: the walk, the report.
78
+ // ---------------------------------------------------------------------------
79
+ const RUN = 'directory_mirror_verify_run';
80
+ const OWNERS = 'directory_mirror_verify';
81
+ export const VERIFY_DDL = [
82
+ `CREATE TABLE IF NOT EXISTS ${RUN} (
83
+ id INTEGER PRIMARY KEY CHECK (id = 1),
84
+ run INTEGER NOT NULL,
85
+ tables TEXT NOT NULL,
86
+ phase TEXT NOT NULL,
87
+ current TEXT,
88
+ after_tenant TEXT,
89
+ started_at TEXT NOT NULL,
90
+ finished_at TEXT
91
+ )`,
92
+ // One row per owner: the comparison in progress (`tally`) and the last one finished (`result`).
93
+ `CREATE TABLE IF NOT EXISTS ${OWNERS} (
94
+ owner TEXT PRIMARY KEY,
95
+ run INTEGER NOT NULL,
96
+ ord INTEGER NOT NULL,
97
+ after TEXT,
98
+ tally TEXT NOT NULL,
99
+ started_at TEXT NOT NULL,
100
+ checked_at TEXT,
101
+ result TEXT
102
+ )`,
103
+ ];
104
+ export const VERIFY_LIMITS = {
105
+ pageRows: 100,
106
+ pagesPerPass: 20,
107
+ pauseMs: 1_000,
108
+ intervalMs: 6 * 60 * 60 * 1000,
109
+ entriesPerOwner: 200,
110
+ };
111
+ /** The switch: unset, empty or `off` compares nothing; `on` compares every mirrored table. Anything else is refused. */
112
+ export function parseDirectoryVerify(value) {
113
+ const text = typeof value === 'string' ? value.trim() : '';
114
+ if (text === '' || text === 'off')
115
+ return false;
116
+ if (text === 'on')
117
+ return true;
118
+ throw new Error(`directory verify: ${text} is not on or off`);
119
+ }
120
+ const SAMPLE_MAX = 20;
121
+ /** The tenant id the walk stood at before `tenantId`, so the next page reaches `tenantId` again. */
122
+ const previousTenantOf = (sql, tenantId) => sql.exec(`SELECT tenant_id FROM tenants WHERE tenant_id < ? ORDER BY tenant_id DESC LIMIT 1`, tenantId).toArray()[0]?.tenant_id ?? '';
123
+ const tenantPrefix = tenantOwnerOf('');
124
+ const emptyTally = (filled) => ({
125
+ rows: 0, missing: 0, extra: 0, differs: 0, inFlight: 0, truncated: 0, sample: [], entries: null, filled, error: null,
126
+ });
127
+ const verified = (t) => t.error === null && t.missing + t.extra + t.differs === 0 && t.truncated === 0 && !!t.entries && t.entries.differ === 0;
128
+ /** The directory's half of 3d, one per `ControlPlaneDO` instance while the switch is on beside the mirror. */
129
+ export class DirectoryVerify {
130
+ options;
131
+ sql;
132
+ limits;
133
+ keys = new Map();
134
+ constructor(options) {
135
+ this.options = options;
136
+ this.sql = options.sql;
137
+ this.limits = { ...VERIFY_LIMITS, ...options.limits };
138
+ }
139
+ now() {
140
+ return (this.options.now ?? Date.now)();
141
+ }
142
+ iso(ms = this.now()) {
143
+ return new Date(ms).toISOString();
144
+ }
145
+ keyColumns(table) {
146
+ let keys = this.keys.get(table);
147
+ if (!keys)
148
+ this.keys.set(table, (keys = mirrorKeyColumns(this.sql, table)));
149
+ return keys;
150
+ }
151
+ /** Every table the mirror copies now, in placement order. */
152
+ mirrored() {
153
+ const on = new Set(this.sql.exec(`SELECT tbl FROM directory_mirror_tables`).toArray().map((r) => r.tbl));
154
+ return MIRRORED_TABLES.filter((t) => on.has(t));
155
+ }
156
+ runRow() {
157
+ return this.sql.exec(`SELECT run, tables, phase, current, after_tenant, started_at, finished_at FROM ${RUN} WHERE id = 1`).toArray()[0] ?? null;
158
+ }
159
+ nextRunAt(run) {
160
+ if (!run || run.phase !== 'done' || run.finished_at === null)
161
+ return null;
162
+ return Date.parse(run.finished_at) + this.limits.intervalMs;
163
+ }
164
+ wanted() {
165
+ if (this.mirrored().length === 0)
166
+ return false;
167
+ const run = this.runRow();
168
+ if (!run || run.phase === 'walk')
169
+ return true;
170
+ return this.now() >= this.nextRunAt(run);
171
+ }
172
+ /** The run in effect, a new one once the last finished and its interval passed. In the caller's transaction. */
173
+ ensureRun() {
174
+ const tables = this.mirrored();
175
+ if (tables.length === 0)
176
+ return null;
177
+ const held = this.runRow();
178
+ if (held && (held.phase === 'walk' || this.now() < this.nextRunAt(held)))
179
+ return held;
180
+ this.sql.exec(`INSERT INTO ${RUN} (id, run, tables, phase, current, after_tenant, started_at, finished_at) VALUES (1, ?, ?, 'walk', NULL, NULL, ?, NULL)
181
+ ON CONFLICT (id) DO UPDATE SET run = excluded.run, tables = excluded.tables, phase = 'walk', current = NULL, after_tenant = NULL,
182
+ started_at = excluded.started_at, finished_at = NULL`, (held?.run ?? 0) + 1, JSON.stringify(tables), this.iso());
183
+ return this.runRow();
184
+ }
185
+ ownerRow(owner) {
186
+ return this.sql.exec(`SELECT * FROM ${OWNERS} WHERE owner = ?`, owner).toArray()[0] ?? null;
187
+ }
188
+ /** Whether 3c's backfill has filled this owner in its current run (null when the backfill was never on). */
189
+ filledByBackfill(owner) {
190
+ const has = this.sql.exec(`SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'directory_mirror_fill'`).toArray().length > 0;
191
+ if (!has)
192
+ return null;
193
+ const row = this.sql.exec(`SELECT f.filled_at FROM directory_mirror_fill f JOIN directory_mirror_fill_run r ON r.id = 1 AND r.run = f.run WHERE f.owner = ?`, owner).toArray()[0];
194
+ return !!row && row.filled_at !== null;
195
+ }
196
+ /** The owner the next page is for: the one in progress, else the registry, else the next tenant. Null: the run is done. */
197
+ nextOwner(run) {
198
+ if (run.current)
199
+ return run.current;
200
+ let owner;
201
+ const registry = this.ownerRow(REGISTRY_OWNER);
202
+ if (!registry || registry.run !== run.run) {
203
+ owner = REGISTRY_OWNER;
204
+ }
205
+ else {
206
+ const next = this.sql.exec(`SELECT tenant_id FROM tenants WHERE tenant_id > ? ORDER BY tenant_id LIMIT 1`, run.after_tenant ?? '').toArray()[0];
207
+ if (!next) {
208
+ this.sql.exec(`UPDATE ${RUN} SET phase = 'done', finished_at = ? WHERE id = 1`, this.iso());
209
+ return null;
210
+ }
211
+ owner = tenantOwnerOf(next.tenant_id);
212
+ this.sql.exec(`UPDATE ${RUN} SET after_tenant = ? WHERE id = 1`, next.tenant_id);
213
+ }
214
+ this.sql.exec(`UPDATE ${RUN} SET current = ? WHERE id = 1`, owner);
215
+ this.sql.exec(`INSERT INTO ${OWNERS} (owner, run, ord, after, tally, started_at, checked_at, result) VALUES (?, ?, 0, NULL, ?, ?, NULL, NULL)
216
+ ON CONFLICT (owner) DO UPDATE SET run = excluded.run, ord = 0, after = NULL, tally = excluded.tally, started_at = excluded.started_at`, owner, run.run, JSON.stringify(emptyTally(this.filledByBackfill(owner))), this.iso());
217
+ return owner;
218
+ }
219
+ tablesOf(run, owner) {
220
+ const kind = objectKindOfOwner(owner);
221
+ return JSON.parse(run.tables).filter((t) => mirrorOwnerRowsSql(t, 't', kind) !== null);
222
+ }
223
+ /** The directory's row of a key as it stands now, digested; null when it is gone or no longer this owner's. */
224
+ async currentDigest(table, owner, key) {
225
+ const keys = this.keyColumns(table);
226
+ const where = keys.map((k) => (k === 'rowid' ? 't.rowid = ?' : `t.${quoteIdent(k)} IS ?`)).join(' AND ');
227
+ const rowid = keys[0] === 'rowid' ? ', t.rowid AS "__mirror_rowid"' : '';
228
+ const found = this.sql
229
+ .exec(`SELECT t.*${rowid} FROM ${quoteIdent(table)} t WHERE ${where} AND ? IN (${mirrorTargetsSql(table, 't').join(', ')})`, ...JSON.parse(key), owner)
230
+ .toArray()[0];
231
+ return found ? mirrorRowDigest(decodeMirrorRow(table, found).row) : null;
232
+ }
233
+ queued(owner, table) {
234
+ return new Set(this.sql.exec(`SELECT row_key FROM directory_mirror_outbox WHERE target = ? AND tbl = ?`, owner, table).toArray().map((r) => r.row_key));
235
+ }
236
+ /** One page of one table: read and digest, ask the object, re-read what it named. */
237
+ async comparePage(run, owner, row, tally) {
238
+ const tables = this.tablesOf(run, owner);
239
+ const page = this.options.transaction(() => readOwnerRows(this.sql, (t) => this.keyColumns(t), tables, owner, { ord: row.ord, after: row.after }, { rows: this.limits.pageRows, bytes: Number.MAX_SAFE_INTEGER, spanTables: false }));
240
+ const table = tables[row.ord];
241
+ if (table === undefined)
242
+ return { ord: row.ord, after: null, done: true };
243
+ const digests = new Map();
244
+ for (const c of page.changes)
245
+ digests.set(c.key, await mirrorRowDigest(c.row));
246
+ // The range this page covers: to its last key, or to the end of the table once the page reached it.
247
+ const tableDone = page.ord > row.ord;
248
+ const upTo = tableDone ? null : page.after;
249
+ const answer = await this.options.sender.compare(owner, { table, after: row.after, upTo, rows: [...digests].map(([key, digest]) => ({ key, digest })) });
250
+ tally.rows += page.changes.length;
251
+ if (answer.truncated)
252
+ tally.truncated += 1;
253
+ const queued = this.queued(owner, table);
254
+ const parked = new Set(answer.parked);
255
+ const named = [
256
+ ...answer.missing.map((key) => ({ key, kind: 'missing' })),
257
+ ...answer.differs.map((key) => ({ key, kind: 'differs' })),
258
+ ...answer.extra.map((key) => ({ key, kind: 'extra' })),
259
+ ];
260
+ for (const { key, kind } of named) {
261
+ const now = await this.currentDigest(table, owner, key);
262
+ // Changed since the page was read (or, for an extra, written since): the flush is carrying it.
263
+ const moved = kind === 'extra' ? now !== null : now !== digests.get(key);
264
+ if (queued.has(key) || parked.has(key) || moved) {
265
+ tally.inFlight += 1;
266
+ continue;
267
+ }
268
+ tally[kind] += 1;
269
+ if (tally.sample.length < SAMPLE_MAX)
270
+ tally.sample.push({ table, key, kind });
271
+ }
272
+ return { ord: page.ord, after: tableDone ? null : page.after, done: page.done };
273
+ }
274
+ /** The owner's read-model entries, built from the objects and compared with the directory's. */
275
+ async compareEntries(owner) {
276
+ const { sender } = this.options;
277
+ const limit = this.limits.entriesPerOwner;
278
+ const inFlight = this.sql.exec(`SELECT 1 FROM directory_mirror_outbox WHERE target = ? LIMIT 1`, owner).toArray().length > 0;
279
+ const out = { checked: 0, differ: 0, inFlight, sample: [], truncated: false };
280
+ if (inFlight)
281
+ return out;
282
+ if (owner === REGISTRY_OWNER) {
283
+ const slugs = this.sql.exec(`SELECT slug FROM verticals ORDER BY slug LIMIT ?`, limit + 1).toArray().map((r) => r.slug);
284
+ out.truncated = slugs.length > limit;
285
+ const mine = slugs.slice(0, limit);
286
+ const theirs = await sender.servingPolicies(mine);
287
+ mine.forEach((slug, i) => {
288
+ out.checked += 1;
289
+ if (JSON.stringify(computeRouteReadModelEntry(this.sql, `v:${slug}`)) !== JSON.stringify(theirs[i] ?? null)) {
290
+ out.differ += 1;
291
+ if (out.sample.length < SAMPLE_MAX)
292
+ out.sample.push(`v:${slug}`);
293
+ }
294
+ });
295
+ return out;
296
+ }
297
+ const tenantId = owner.slice(tenantPrefix.length);
298
+ const hostnames = this.sql.exec(`SELECT h.hostname FROM hostnames h WHERE h.scope_id IN (SELECT s.scope_id FROM scopes s WHERE s.tenant_id = ?) AND h.tenant_id = ? ORDER BY h.hostname LIMIT ?`, tenantId, tenantId, limit + 1).toArray().map((r) => r.hostname);
299
+ out.truncated = hostnames.length > limit;
300
+ const mine = hostnames.slice(0, limit);
301
+ if (mine.length === 0)
302
+ return out;
303
+ const expected = mine.map((h) => JSON.stringify(computeRouteReadModelEntry(this.sql, `h:${h}`)));
304
+ const reads = await sender.routeSources(owner, mine);
305
+ const ids = [...new Set(reads.map((r) => r.row?.['vertical_version_id']).filter((id) => typeof id === 'string'))];
306
+ const versions = new Map((ids.length > 0 ? await sender.versionPolicies(ids) : []).map((v) => [String(v['version_id']), v]));
307
+ mine.forEach((hostname, i) => {
308
+ out.checked += 1;
309
+ const read = reads[i] ?? { row: null, refused: null };
310
+ const id = read.row?.['vertical_version_id'];
311
+ const v = typeof id === 'string' ? versions.get(id) : undefined;
312
+ // A bound version the registry does not hold reads as the directory's LEFT JOIN does: none.
313
+ const version = v
314
+ ? { id: String(v['version_id']), deployment_ref: v['version_ref'], outbound_json: v['outbound_json'], calls_json: v['calls_json'], scope_stores_json: v['scope_stores_json'] }
315
+ : null;
316
+ if (JSON.stringify(routeEntryOfRead(read, version)) !== expected[i]) {
317
+ out.differ += 1;
318
+ if (out.sample.length < SAMPLE_MAX)
319
+ out.sample.push(`h:${hostname}`);
320
+ }
321
+ });
322
+ return out;
323
+ }
324
+ /** Record an owner's progress, or finish it: the tally becomes its result, and the walk moves on. */
325
+ save(run, owner, at, tally, finished) {
326
+ return this.options.transaction(() => {
327
+ const held = this.runRow();
328
+ if (!held || held.run !== run.run)
329
+ return 0;
330
+ let rows = this.sql.exec(`UPDATE ${OWNERS} SET ord = ?, after = ?, tally = ? WHERE owner = ? AND run = ?`, at.ord, at.after, JSON.stringify(tally), owner, run.run).rowsWritten;
331
+ if (finished) {
332
+ const result = { ...tally, verified: verified(tally) };
333
+ rows += this.sql.exec(`UPDATE ${OWNERS} SET checked_at = ?, result = ? WHERE owner = ?`, this.iso(), JSON.stringify(result), owner).rowsWritten;
334
+ rows += this.sql.exec(`UPDATE ${RUN} SET current = NULL WHERE id = 1`).rowsWritten;
335
+ }
336
+ return rows;
337
+ });
338
+ }
339
+ async pass() {
340
+ const out = {
341
+ pages: 0, rows: 0, filled: 0, failed: 0, claims: false, more: false, nextAt: null, deferred: false, rowsWrittenDirectory: 0, rowsWrittenObjects: 0,
342
+ };
343
+ for (let i = 0; i < this.limits.pagesPerPass; i++) {
344
+ if (!this.options.quiet()) {
345
+ out.deferred = true;
346
+ out.more = true;
347
+ return out;
348
+ }
349
+ const picked = this.options.transaction(() => {
350
+ const run = this.ensureRun();
351
+ if (!run || run.phase === 'done')
352
+ return null;
353
+ const owner = this.nextOwner(run);
354
+ if (!owner)
355
+ return null;
356
+ const row = this.ownerRow(owner);
357
+ // An owner in progress whose row is gone: start it again on the next page.
358
+ if (!row || row.run !== run.run) {
359
+ this.sql.exec(`UPDATE ${RUN} SET current = NULL WHERE id = 1`);
360
+ if (run.after_tenant !== null && owner !== REGISTRY_OWNER)
361
+ this.sql.exec(`UPDATE ${RUN} SET after_tenant = ? WHERE id = 1`, previousTenantOf(this.sql, owner.slice(tenantPrefix.length)));
362
+ return 'again';
363
+ }
364
+ return { run, owner, row };
365
+ });
366
+ if (picked === 'again')
367
+ continue;
368
+ if (!picked)
369
+ break;
370
+ const { run, owner, row } = picked;
371
+ const tally = JSON.parse(row.tally);
372
+ let at;
373
+ try {
374
+ at = await this.comparePage(run, owner, row, tally);
375
+ if (at.done)
376
+ tally.entries = tally.missing + tally.extra + tally.differs === 0 ? await this.compareEntries(owner) : null;
377
+ }
378
+ catch (err) {
379
+ console.error(`directory verify: ${owner} stopped on an error; the next run compares it again`, err);
380
+ tally.error = String(err?.message ?? err).slice(0, 500);
381
+ out.rowsWrittenDirectory += this.save(run, owner, { ord: row.ord, after: row.after }, tally, true);
382
+ out.failed += 1;
383
+ continue;
384
+ }
385
+ out.pages += 1;
386
+ out.rows += tally.rows - JSON.parse(row.tally).rows;
387
+ out.rowsWrittenDirectory += this.save(run, owner, at, tally, at.done);
388
+ if (at.done)
389
+ out.filled += 1;
390
+ }
391
+ const run = this.runRow();
392
+ if (run?.phase === 'done') {
393
+ out.more = true;
394
+ out.nextAt = this.nextRunAt(run);
395
+ }
396
+ else {
397
+ out.more = this.wanted();
398
+ if (out.more)
399
+ out.nextAt = this.now() + this.limits.pauseMs;
400
+ }
401
+ return out;
402
+ }
403
+ status() {
404
+ const run = this.runRow();
405
+ const tenants = Number(this.sql.exec(`SELECT COUNT(*) AS n FROM tenants`).one().n);
406
+ const counts = this.sql.exec(`SELECT SUM(CASE WHEN json_extract(result, '$.verified') = 1 THEN 1 ELSE 0 END) AS ok,
407
+ SUM(CASE WHEN result IS NOT NULL AND json_extract(result, '$.verified') = 0 AND json_extract(result, '$.error') IS NULL THEN 1 ELSE 0 END) AS differing,
408
+ SUM(CASE WHEN json_extract(result, '$.error') IS NOT NULL THEN 1 ELSE 0 END) AS errored,
409
+ MAX(checked_at) AS last
410
+ FROM ${OWNERS}`).one();
411
+ const next = this.nextRunAt(run);
412
+ return {
413
+ enabled: true,
414
+ run: run?.run ?? null,
415
+ phase: run?.phase ?? null,
416
+ startedAt: run?.started_at ?? null,
417
+ finishedAt: run?.finished_at ?? null,
418
+ lastFinishedAt: run?.phase === 'done' ? run.finished_at : counts.last,
419
+ tenants,
420
+ verified: Number(counts.ok ?? 0),
421
+ differing: Number(counts.differing ?? 0),
422
+ errored: Number(counts.errored ?? 0),
423
+ nextRunAt: next === null ? null : this.iso(next),
424
+ };
425
+ }
426
+ /** A page of owners' reports in owner order after `after`, or the one `owner` names. */
427
+ owners(query = {}) {
428
+ const limit = Math.max(1, Math.min(query.limit ?? 100, 500));
429
+ const run = this.runRow();
430
+ const rows = (query.owner
431
+ ? this.sql.exec(`SELECT * FROM ${OWNERS} WHERE owner = ?`, query.owner)
432
+ : this.sql.exec(`SELECT * FROM ${OWNERS} WHERE owner > ? ORDER BY owner LIMIT ?`, query.after ?? '', limit)).toArray();
433
+ return rows.map((r) => ({
434
+ owner: r.owner,
435
+ checkedAt: r.checked_at,
436
+ result: r.result === null ? null : JSON.parse(r.result),
437
+ inProgress: run && run.current === r.owner ? JSON.parse(r.tally) : null,
438
+ }));
439
+ }
440
+ }
441
+ /** The verify sender's half of a `MirrorSender`, or null when the sender cannot compare. */
442
+ const verifySenderOf = (sender) => sender.compare && sender.routeSources && sender.versionPolicies && sender.servingPolicies
443
+ ? { compare: sender.compare, routeSources: sender.routeSources, versionPolicies: sender.versionPolicies, servingPolicies: sender.servingPolicies }
444
+ : null;
445
+ /**
446
+ * The directory's comparison as its environment sets it, attached to its mirror: null when
447
+ * `DIRECTORY_VERIFY` is off or refused, or there is no mirror. Its tables are created only when on.
448
+ */
449
+ export function directoryVerifyFor(env, mirror, limits) {
450
+ let on;
451
+ try {
452
+ on = parseDirectoryVerify(Reflect.get(env, 'DIRECTORY_VERIFY'));
453
+ }
454
+ catch (err) {
455
+ console.error('directory verify: DIRECTORY_VERIFY refused, the comparison stays off:', err.message);
456
+ return null;
457
+ }
458
+ if (!on)
459
+ return null;
460
+ if (!mirror) {
461
+ console.error('directory verify: DIRECTORY_VERIFY is on but the mirror is off (DIRECTORY_MIRROR); nothing is compared');
462
+ return null;
463
+ }
464
+ const { sql, transaction, sender, quiet, now } = mirror.options;
465
+ const verifySender = verifySenderOf(sender);
466
+ if (!verifySender) {
467
+ console.error('directory verify: the mirror cannot reach the objects for a comparison; nothing is compared');
468
+ return null;
469
+ }
470
+ const verify = new DirectoryVerify({ sql, transaction, sender: verifySender, quiet, ...(limits ? { limits } : {}), ...(now ? { now } : {}) });
471
+ transaction(() => {
472
+ for (const stmt of VERIFY_DDL)
473
+ sql.exec(stmt);
474
+ });
475
+ mirror.attachBackfill(verify);
476
+ return verify;
477
+ }
478
+ //# sourceMappingURL=directory-mirror-verify.js.map