@substrat-run/control-plane-api 0.211.0 → 0.213.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/api.d.ts +13 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +40 -2
- package/dist/api.js.map +1 -1
- package/dist/directory-lake-backfill.d.ts +56 -0
- package/dist/directory-lake-backfill.d.ts.map +1 -0
- package/dist/directory-lake-backfill.js +71 -0
- package/dist/directory-lake-backfill.js.map +1 -0
- package/dist/directory-lake-reads.d.ts +110 -0
- package/dist/directory-lake-reads.d.ts.map +1 -0
- package/dist/directory-lake-reads.js +239 -0
- package/dist/directory-lake-reads.js.map +1 -0
- package/dist/directory-lake-sink.d.ts +3 -0
- package/dist/directory-lake-sink.d.ts.map +1 -0
- package/dist/directory-lake-sink.js +56 -0
- package/dist/directory-lake-sink.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/pipelines-sink.d.ts +22 -0
- package/dist/pipelines-sink.d.ts.map +1 -1
- package/dist/pipelines-sink.js +39 -33
- package/dist/pipelines-sink.js.map +1 -1
- package/package.json +9 -9
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { PlatformActorId } from '@substrat-run/contracts';
|
|
2
|
+
import type { DirectoryLakeDataset, DirectoryLakeSink, HostAdmin } from '@substrat-run/kernel';
|
|
3
|
+
/**
|
|
4
|
+
* K-70 (tenants × time data leaves the objects): the backfill of the rows a directory data set
|
|
5
|
+
* held before its capture was switched on. One page per call, read by rowid after `after`; the
|
|
6
|
+
* caller follows `next` until `done` (`scripts/directory-lake-backfill.mjs`).
|
|
7
|
+
*
|
|
8
|
+
* - **A dry run unless asked.** A dry run reads the page and reports what a real run would ship
|
|
9
|
+
* (count and time span) and whether the data set captures; it ships and marks nothing.
|
|
10
|
+
* - **Shipped straight to the sink, never queued.** Two directory writes a row for a table's
|
|
11
|
+
* whole history would buy nothing the page does not already have.
|
|
12
|
+
* - **Only for a capturing data set**, on a real run: a row written after the walk passes it
|
|
13
|
+
* reaches the lake only through the outbox, so a backfill of a data set not capturing would
|
|
14
|
+
* leave a hole while its mark said there was none.
|
|
15
|
+
* - **Recorded page by page, without a gap.** Each shipped page is recorded in the directory
|
|
16
|
+
* (`advanceDirectoryLakeBackfill`, one `backfillDirectoryLake` admin row), and a real page must
|
|
17
|
+
* start where the last recorded one ended, so the page that reaches the table's end records a
|
|
18
|
+
* `backfilledAt` a later prune may rely on. A dry run may start anywhere.
|
|
19
|
+
* - **Idempotent.** Re-running a page re-ships the same rows; the lake keeps a key's latest
|
|
20
|
+
* version, and a duplicate is the same version.
|
|
21
|
+
*/
|
|
22
|
+
export declare const DIRECTORY_LAKE_BACKFILL_PAGE_MAX = 1000;
|
|
23
|
+
export interface DirectoryLakeBackfillInput {
|
|
24
|
+
dataset: DirectoryLakeDataset;
|
|
25
|
+
dryRun: boolean;
|
|
26
|
+
after: number;
|
|
27
|
+
limit: number;
|
|
28
|
+
}
|
|
29
|
+
export interface DirectoryLakeBackfillAnswer {
|
|
30
|
+
dataset: DirectoryLakeDataset;
|
|
31
|
+
dryRun: boolean;
|
|
32
|
+
capturing: boolean;
|
|
33
|
+
rows: number;
|
|
34
|
+
/** The span of the rows' own times on this page, or null when it was empty. */
|
|
35
|
+
from: string | null;
|
|
36
|
+
to: string | null;
|
|
37
|
+
next: number | null;
|
|
38
|
+
done: boolean;
|
|
39
|
+
/** Where a real run's page landed; null on a dry run or an empty page. */
|
|
40
|
+
ref: string | null;
|
|
41
|
+
/** The source rowid the next real page must start after, as the directory records it. */
|
|
42
|
+
resumeAfter: number;
|
|
43
|
+
/** When the data set's backfill reached the end, as recorded; null until it has. */
|
|
44
|
+
backfilledAt: string | null;
|
|
45
|
+
}
|
|
46
|
+
/** Why a real run cannot proceed: the host or the deployment lacks a part, or capture is off. */
|
|
47
|
+
export declare class DirectoryLakeBackfillRefused extends Error {
|
|
48
|
+
readonly reason: 'unsupported' | 'no-sink' | 'not-capturing' | 'out-of-order';
|
|
49
|
+
constructor(reason: 'unsupported' | 'no-sink' | 'not-capturing' | 'out-of-order', message: string);
|
|
50
|
+
}
|
|
51
|
+
export declare function backfillDirectoryLake(deps: {
|
|
52
|
+
admin: HostAdmin;
|
|
53
|
+
actor: PlatformActorId;
|
|
54
|
+
sink: DirectoryLakeSink | undefined;
|
|
55
|
+
}, input: DirectoryLakeBackfillInput): Promise<DirectoryLakeBackfillAnswer>;
|
|
56
|
+
//# sourceMappingURL=directory-lake-backfill.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory-lake-backfill.d.ts","sourceRoot":"","sources":["../src/directory-lake-backfill.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAE/F;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,gCAAgC,OAAQ,CAAC;AAEtD,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,oBAAoB,CAAC;IAC9B,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,oBAAoB,CAAC;IAC9B,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,+EAA+E;IAC/E,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,IAAI,EAAE,OAAO,CAAC;IACd,0EAA0E;IAC1E,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,yFAAyF;IACzF,WAAW,EAAE,MAAM,CAAC;IACpB,oFAAoF;IACpF,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,iGAAiG;AACjG,qBAAa,4BAA6B,SAAQ,KAAK;IACzC,QAAQ,CAAC,MAAM,EAAE,aAAa,GAAG,SAAS,GAAG,eAAe,GAAG,cAAc;IAAzF,YAAqB,MAAM,EAAE,aAAa,GAAG,SAAS,GAAG,eAAe,GAAG,cAAc,EAAE,OAAO,EAAE,MAAM,EAGzG;CACF;AAED,wBAAsB,qBAAqB,CACzC,IAAI,EAAE;IAAE,KAAK,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,eAAe,CAAC;IAAC,IAAI,EAAE,iBAAiB,GAAG,SAAS,CAAA;CAAE,EACvF,KAAK,EAAE,0BAA0B,GAChC,OAAO,CAAC,2BAA2B,CAAC,CAqCtC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* K-70 (tenants × time data leaves the objects): the backfill of the rows a directory data set
|
|
3
|
+
* held before its capture was switched on. One page per call, read by rowid after `after`; the
|
|
4
|
+
* caller follows `next` until `done` (`scripts/directory-lake-backfill.mjs`).
|
|
5
|
+
*
|
|
6
|
+
* - **A dry run unless asked.** A dry run reads the page and reports what a real run would ship
|
|
7
|
+
* (count and time span) and whether the data set captures; it ships and marks nothing.
|
|
8
|
+
* - **Shipped straight to the sink, never queued.** Two directory writes a row for a table's
|
|
9
|
+
* whole history would buy nothing the page does not already have.
|
|
10
|
+
* - **Only for a capturing data set**, on a real run: a row written after the walk passes it
|
|
11
|
+
* reaches the lake only through the outbox, so a backfill of a data set not capturing would
|
|
12
|
+
* leave a hole while its mark said there was none.
|
|
13
|
+
* - **Recorded page by page, without a gap.** Each shipped page is recorded in the directory
|
|
14
|
+
* (`advanceDirectoryLakeBackfill`, one `backfillDirectoryLake` admin row), and a real page must
|
|
15
|
+
* start where the last recorded one ended, so the page that reaches the table's end records a
|
|
16
|
+
* `backfilledAt` a later prune may rely on. A dry run may start anywhere.
|
|
17
|
+
* - **Idempotent.** Re-running a page re-ships the same rows; the lake keeps a key's latest
|
|
18
|
+
* version, and a duplicate is the same version.
|
|
19
|
+
*/
|
|
20
|
+
export const DIRECTORY_LAKE_BACKFILL_PAGE_MAX = 1_000;
|
|
21
|
+
/** Why a real run cannot proceed: the host or the deployment lacks a part, or capture is off. */
|
|
22
|
+
export class DirectoryLakeBackfillRefused extends Error {
|
|
23
|
+
reason;
|
|
24
|
+
constructor(reason, message) {
|
|
25
|
+
super(message);
|
|
26
|
+
this.reason = reason;
|
|
27
|
+
this.name = 'DirectoryLakeBackfillRefused';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export async function backfillDirectoryLake(deps, input) {
|
|
31
|
+
const { admin, actor, sink } = deps;
|
|
32
|
+
if (!admin.directoryLakeBackfill || !admin.directoryLakeCapture || !admin.advanceDirectoryLakeBackfill) {
|
|
33
|
+
throw new DirectoryLakeBackfillRefused('unsupported', 'this host has no directory outbox to the lake');
|
|
34
|
+
}
|
|
35
|
+
const held = (await admin.directoryLakeCapture(actor)).find((c) => c.dataset === input.dataset);
|
|
36
|
+
if (!input.dryRun) {
|
|
37
|
+
if (!sink)
|
|
38
|
+
throw new DirectoryLakeBackfillRefused('no-sink', 'this deployment binds no directory lake stream');
|
|
39
|
+
if (!held) {
|
|
40
|
+
throw new DirectoryLakeBackfillRefused('not-capturing', `${input.dataset} is not capturing; switch its capture on before a real backfill`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const page = await admin.directoryLakeBackfill(actor, input.dataset, input.after, input.limit);
|
|
44
|
+
const answer = {
|
|
45
|
+
dataset: input.dataset,
|
|
46
|
+
dryRun: input.dryRun,
|
|
47
|
+
capturing: held !== undefined,
|
|
48
|
+
rows: page.rows.length,
|
|
49
|
+
from: page.rows[0]?.at ?? null,
|
|
50
|
+
to: page.rows[page.rows.length - 1]?.at ?? null,
|
|
51
|
+
next: page.next,
|
|
52
|
+
done: page.done,
|
|
53
|
+
ref: null,
|
|
54
|
+
resumeAfter: held?.backfillAfter ?? 0,
|
|
55
|
+
backfilledAt: held?.backfilledAt ?? null,
|
|
56
|
+
};
|
|
57
|
+
if (input.dryRun)
|
|
58
|
+
return answer;
|
|
59
|
+
if (held.backfilledAt === null && input.after !== held.backfillAfter) {
|
|
60
|
+
// Checked before shipping, so a page from the wrong place is not sent at all. The directory
|
|
61
|
+
// checks it again when it records the page, which is the check that counts.
|
|
62
|
+
throw new DirectoryLakeBackfillRefused('out-of-order', `the ${input.dataset} backfill resumes after rowid ${held.backfillAfter}, not ${input.after}`);
|
|
63
|
+
}
|
|
64
|
+
if (page.rows.length > 0)
|
|
65
|
+
answer.ref = (await sink.ship(page.rows)).ref;
|
|
66
|
+
const state = await admin.advanceDirectoryLakeBackfill(actor, input.dataset, { after: input.after, next: page.next, done: page.done });
|
|
67
|
+
answer.resumeAfter = state.backfillAfter;
|
|
68
|
+
answer.backfilledAt = state.backfilledAt;
|
|
69
|
+
return answer;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=directory-lake-backfill.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory-lake-backfill.js","sourceRoot":"","sources":["../src/directory-lake-backfill.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,KAAK,CAAC;AA2BtD,iGAAiG;AACjG,MAAM,OAAO,4BAA6B,SAAQ,KAAK;IAChC,MAAM;IAA3B,YAAqB,MAAoE,EAAE,OAAe;QACxG,KAAK,CAAC,OAAO,CAAC,CAAC;sBADI,MAAM;QAEzB,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAC;IAC7C,CAAC;CACF;AAED,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,IAAuF,EACvF,KAAiC;IAEjC,MAAM,EAAE,KAAK,EAAE,KAAK,E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,EAAE,IAAI,CAAC,IAAI;QACf,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,GAAG,EAAE,IAAI;QACT,WAAW,EAAE,IAAI,EAAE,aAAa,IAAI,CAAC;QACrC,YAAY,EAAE,IAAI,EAAE,YAAY,IAAI,IAAI;KACzC,CAAC;IACF,IAAI,KAAK,CAAC,MAAM;QAAE,OAAO,MAAM,CAAC;IAChC,IAAI,IAAK,CAAC,YAAY,KAAK,IAAI,IAAI,KAAK,CAAC,KAAK,KAAK,IAAK,CAAC,aAAa,EAAE,CAAC;QACvE,4FAA4F;QAC5F,4EAA4E;QAC5E,MAAM,IAAI,4BAA4B,CAAC,cAAc,EAAE,OAAO,KAAK,CAAC,OAAO,iCAAiC,IAAK,CAAC,aAAa,SAAS,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;IACzJ,CAAC;IACD,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC;QAAE,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,IAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;IACzE,MAAM,KAAK,GAAG,MAAM,KAAK,CAAC,4BAA4B,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IACvI,MAAM,CAAC,WAAW,GAAG,KAAK,CAAC,aAAa,CAAC;IACzC,MAAM,CAAC,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC;IACzC,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { type AdminLogEntry, type PlatformActorId } from '@substrat-run/contracts';
|
|
2
|
+
import { type AuditLogFilter, type DirectoryLakeDataset, type HostAdmin } from '@substrat-run/kernel';
|
|
3
|
+
import type { LakeQueryEngine } from './lake-gateway.js';
|
|
4
|
+
/**
|
|
5
|
+
* K-70 (tenants × time data leaves the objects), step 2 part 2: history beyond the directory's
|
|
6
|
+
* window, read from the lake's directory table (`kernel.directory`, fed by the directory outbox,
|
|
7
|
+
* `packages/kernel/src/directory-lake.ts`).
|
|
8
|
+
*
|
|
9
|
+
* **The split.** A read is cut at the window's start (`DIRECTORY_LAKE_WINDOW_DAYS` before now):
|
|
10
|
+
* rows from then on come from the directory, as today, and rows before it from the lake. The two
|
|
11
|
+
* halves are disjoint by the row's own time, and walked in the read's order, so one page may hold
|
|
12
|
+
* rows from both and its cursor (the last row's id) continues across the seam.
|
|
13
|
+
*
|
|
14
|
+
* **The switch** (`DirectoryLakeReads`), off by default, because the prune is what makes the lake
|
|
15
|
+
* the only copy and it is not on yet:
|
|
16
|
+
* - `off`: the directory answers everything, exactly as before.
|
|
17
|
+
* - `compare`: the directory still answers everything; the part before the window is also read
|
|
18
|
+
* from the lake and the two are compared, the difference logged. The verify phase.
|
|
19
|
+
* - `on`: the part before the window comes from the lake. Turned on before the prune, then the
|
|
20
|
+
* prune; switched back off, the directory answers again for what it still holds.
|
|
21
|
+
*
|
|
22
|
+
* **Isolation**, as `lake-gateway.ts` holds it for events: no caller supplies SQL; every value is a
|
|
23
|
+
* literal from `LAKE_LITERAL`'s alphabet or refused; the data set and, for a tenant's read, the
|
|
24
|
+
* tenant are the first conjuncts; and every row the engine answers is checked against both, a
|
|
25
|
+
* mismatch failing the whole read.
|
|
26
|
+
*
|
|
27
|
+
* **Versions.** The lake keeps every version of a row; a read keeps one per `row_key`, the latest
|
|
28
|
+
* by `captured_at` then `seq` (a backfilled row has no `seq`). The admin log never updates a row,
|
|
29
|
+
* so its versions are copies of one row, but the rule is the data set's, not the admin log's.
|
|
30
|
+
*/
|
|
31
|
+
export type DirectoryLakeReads = 'off' | 'compare' | 'on';
|
|
32
|
+
export declare function parseDirectoryLakeReads(value: string | undefined): DirectoryLakeReads;
|
|
33
|
+
/** The filters a directory lake read may carry; each maps to one envelope column. */
|
|
34
|
+
export interface DirectoryLakeFilter {
|
|
35
|
+
tenantId?: string;
|
|
36
|
+
scopeId?: string;
|
|
37
|
+
actor?: string;
|
|
38
|
+
/** One value, or any of several (`kind IN (…)`). */
|
|
39
|
+
kind?: string | readonly string[];
|
|
40
|
+
/** Inclusive lower and exclusive upper bound on the row's own time (ISO 8601). */
|
|
41
|
+
since?: string;
|
|
42
|
+
until?: string;
|
|
43
|
+
/** Keyset on `row_key`, exclusive, in the read's order. */
|
|
44
|
+
cursor?: string;
|
|
45
|
+
order: 'asc' | 'desc';
|
|
46
|
+
limit: number;
|
|
47
|
+
}
|
|
48
|
+
/** One page of one data set's rows as SQL. One row over the limit, so duplicates cannot end a walk early. */
|
|
49
|
+
export declare function compileDirectoryLakeQuery(dataset: DirectoryLakeDataset, filter: DirectoryLakeFilter): string;
|
|
50
|
+
/** A row the engine handed back outside the data set or tenant asked about. */
|
|
51
|
+
export declare class DirectoryLakeMismatchError extends Error {
|
|
52
|
+
constructor(what: string);
|
|
53
|
+
}
|
|
54
|
+
/** One lake row, reduced to what a reader needs: its key, and the source row as stored. */
|
|
55
|
+
export interface DirectoryLakeRecord {
|
|
56
|
+
rowKey: string;
|
|
57
|
+
row: Record<string, unknown>;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* One page of a data set's rows from the lake, one per key (its latest version), in the read's
|
|
61
|
+
* order, at most `limit`. Answers whether the lake held more past the page.
|
|
62
|
+
*/
|
|
63
|
+
export declare function queryDirectoryLake(engine: LakeQueryEngine, dataset: DirectoryLakeDataset, filter: DirectoryLakeFilter): Promise<{
|
|
64
|
+
records: DirectoryLakeRecord[];
|
|
65
|
+
more: boolean;
|
|
66
|
+
}>;
|
|
67
|
+
/** An admin-log row as the directory stores it (snake_case, JSON columns as text), as an entry. */
|
|
68
|
+
export declare function adminLogEntryOfLakeRow(row: Record<string, unknown>): AdminLogEntry;
|
|
69
|
+
/** The start of the directory's window: rows at or after it are the directory's to answer. */
|
|
70
|
+
export declare function directoryWindowStart(nowMs: number, windowDays?: number): string;
|
|
71
|
+
export interface AdminLogHistoryDeps {
|
|
72
|
+
admin: HostAdmin;
|
|
73
|
+
actor: PlatformActorId;
|
|
74
|
+
lake: LakeQueryEngine | undefined;
|
|
75
|
+
mode: DirectoryLakeReads;
|
|
76
|
+
nowMs: number;
|
|
77
|
+
/** Where a compare's difference is reported. `console.warn` in the worker. */
|
|
78
|
+
report?: (line: Record<string, unknown>) => void;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The admin log, read across the directory's window and the lake behind it. `filter.limit` is
|
|
82
|
+
* required here: a history read is a page, never the whole log.
|
|
83
|
+
*/
|
|
84
|
+
export declare function readAdminLogHistory(deps: AdminLogHistoryDeps, filter: AuditLogFilter & {
|
|
85
|
+
limit: number;
|
|
86
|
+
}): Promise<AdminLogEntry[]>;
|
|
87
|
+
/**
|
|
88
|
+
* A tenant's whole admin log (the export), across the window and the lake. Off, or with no lake,
|
|
89
|
+
* it is the one directory read it always was; otherwise it pages the history read to its end.
|
|
90
|
+
*/
|
|
91
|
+
export declare function readWholeAdminLog(deps: AdminLogHistoryDeps, filter: AuditLogFilter): Promise<AdminLogEntry[]>;
|
|
92
|
+
/**
|
|
93
|
+
* The data sets whose every history reader reads the lake before the window (this file), so the
|
|
94
|
+
* directory may prune them to it. Only the admin log so far; the readers of the others are listed
|
|
95
|
+
* in the PR that added this (#3405) and join here one by one as they move.
|
|
96
|
+
*/
|
|
97
|
+
export declare const DIRECTORY_LAKE_HISTORY_READ: readonly DirectoryLakeDataset[];
|
|
98
|
+
/**
|
|
99
|
+
* Of the data sets the prune switch lists, those that may be pruned now: their history is read
|
|
100
|
+
* from the lake (`DIRECTORY_LAKE_HISTORY_READ`) and reads are `on`. The rest are refused with the
|
|
101
|
+
* reason, so a switch set ahead of its reader prunes nothing a console still needs.
|
|
102
|
+
*/
|
|
103
|
+
export declare function prunableDirectoryDatasets(wanted: readonly DirectoryLakeDataset[], reads: DirectoryLakeReads): {
|
|
104
|
+
allowed: DirectoryLakeDataset[];
|
|
105
|
+
refused: {
|
|
106
|
+
dataset: DirectoryLakeDataset;
|
|
107
|
+
reason: string;
|
|
108
|
+
}[];
|
|
109
|
+
};
|
|
110
|
+
//# sourceMappingURL=directory-lake-reads.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory-lake-reads.d.ts","sourceRoot":"","sources":["../src/directory-lake-reads.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,aAAa,EAAE,KAAK,eAAe,EAAiB,MAAM,yBAAyB,CAAC;AAC/H,OAAO,EAA8B,KAAK,cAAc,EAAE,KAAK,oBAAoB,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAClI,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,SAAS,GAAG,IAAI,CAAC;AAE1D,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,kBAAkB,CAKrF;AAOD,qFAAqF;AACrF,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;IAClC,kFAAkF;IAClF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2DAA2D;IAC3D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,KAAK,GAAG,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;CACf;AAOD,6GAA6G;AAC7G,wBAAgB,yBAAyB,CAAC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sB,iBAAiB,CAAC,IAAI,EAAE,mBAAmB,EAAE,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAenH;AAED;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,EAAE,SAAS,oBAAoB,EAAkB,CAAC;AAE1F;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,SAAS,oBAAoB,EAAE,EACvC,KAAK,EAAE,kBAAkB,GACxB;IAAE,OAAO,EAAE,oBAAoB,EAAE,CAAC;IAAC,OAAO,EAAE;QAAE,OAAO,EAAE,oBAAoB,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CAAE,CASnG"}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { LAKE_LITERAL, adminLogEntry } from '@substrat-run/contracts';
|
|
2
|
+
import { DIRECTORY_LAKE_WINDOW_DAYS } from '@substrat-run/kernel';
|
|
3
|
+
export function parseDirectoryLakeReads(value) {
|
|
4
|
+
const v = (value ?? '').trim();
|
|
5
|
+
if (v === '' || v === 'off')
|
|
6
|
+
return 'off';
|
|
7
|
+
if (v === 'compare' || v === 'on')
|
|
8
|
+
return v;
|
|
9
|
+
throw new Error(`directory lake reads: expected off, compare or on, got ${v}`);
|
|
10
|
+
}
|
|
11
|
+
/** The lake's directory table — `LAKES.directory` in `scripts/lake-provision.mjs`. */
|
|
12
|
+
const DIRECTORY_LAKE_TABLE = 'kernel.directory';
|
|
13
|
+
const COLUMNS = ['seq', 'dataset', 'row_key', 'tenant_id', 'scope_id', 'at', 'kind', 'actor', 'captured_at', 'row'];
|
|
14
|
+
function literal(value) {
|
|
15
|
+
if (!LAKE_LITERAL.test(value))
|
|
16
|
+
throw new Error('directory lake: refusing a literal outside the lake alphabet');
|
|
17
|
+
return `'${value}'`;
|
|
18
|
+
}
|
|
19
|
+
/** One page of one data set's rows as SQL. One row over the limit, so duplicates cannot end a walk early. */
|
|
20
|
+
export function compileDirectoryLakeQuery(dataset, filter) {
|
|
21
|
+
if (!Number.isInteger(filter.limit) || filter.limit < 1)
|
|
22
|
+
throw new Error('directory lake: limit must be a positive integer');
|
|
23
|
+
const where = [`dataset = ${literal(dataset)}`];
|
|
24
|
+
if (filter.tenantId !== undefined)
|
|
25
|
+
where.push(`tenant_id = ${literal(filter.tenantId)}`);
|
|
26
|
+
if (filter.scopeId !== undefined)
|
|
27
|
+
where.push(`scope_id = ${literal(filter.scopeId)}`);
|
|
28
|
+
if (filter.actor !== undefined)
|
|
29
|
+
where.push(`actor = ${literal(filter.actor)}`);
|
|
30
|
+
if (filter.kind !== undefined) {
|
|
31
|
+
const kinds = typeof filter.kind === 'string' ? [filter.kind] : [...filter.kind];
|
|
32
|
+
if (kinds.length === 0)
|
|
33
|
+
throw new Error('directory lake: an empty kind list matches nothing; ask for no filter instead');
|
|
34
|
+
where.push(kinds.length === 1 ? `kind = ${literal(kinds[0])}` : `kind IN (${kinds.map(literal).join(', ')})`);
|
|
35
|
+
}
|
|
36
|
+
if (filter.since !== undefined)
|
|
37
|
+
where.push(`at >= ${literal(filter.since)}`);
|
|
38
|
+
if (filter.until !== undefined)
|
|
39
|
+
where.push(`at < ${literal(filter.until)}`);
|
|
40
|
+
if (filter.cursor !== undefined)
|
|
41
|
+
where.push(`row_key ${filter.order === 'desc' ? '<' : '>'} ${literal(filter.cursor)}`);
|
|
42
|
+
const order = filter.order === 'desc' ? 'DESC' : 'ASC';
|
|
43
|
+
// Twice the page, so a key's other versions (a retried batch, a backfill beside a capture) cannot
|
|
44
|
+
// shorten a page that has more rows behind it.
|
|
45
|
+
return (`SELECT ${COLUMNS.join(', ')} FROM ${DIRECTORY_LAKE_TABLE} WHERE ${where.join(' AND ')} ` +
|
|
46
|
+
`ORDER BY row_key ${order} LIMIT ${filter.limit * 2 + 1}`);
|
|
47
|
+
}
|
|
48
|
+
/** A row the engine handed back outside the data set or tenant asked about. */
|
|
49
|
+
export class DirectoryLakeMismatchError extends Error {
|
|
50
|
+
constructor(what) {
|
|
51
|
+
super(`directory lake: the engine returned a row outside ${what}; the read is refused whole`);
|
|
52
|
+
this.name = 'DirectoryLakeMismatchError';
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const num = (v) => (typeof v === 'number' ? v : typeof v === 'string' && v !== '' ? Number(v) : -1);
|
|
56
|
+
const capturedMs = (v) => (typeof v === 'number' ? v : typeof v === 'string' ? Date.parse(v) : Number.NaN);
|
|
57
|
+
/**
|
|
58
|
+
* One page of a data set's rows from the lake, one per key (its latest version), in the read's
|
|
59
|
+
* order, at most `limit`. Answers whether the lake held more past the page.
|
|
60
|
+
*/
|
|
61
|
+
export async function queryDirectoryLake(engine, dataset, filter) {
|
|
62
|
+
const answered = await engine.query(compileDirectoryLakeQuery(dataset, filter));
|
|
63
|
+
const latest = new Map();
|
|
64
|
+
const keys = [];
|
|
65
|
+
for (const raw of answered) {
|
|
66
|
+
if (raw['dataset'] !== dataset)
|
|
67
|
+
throw new DirectoryLakeMismatchError(`data set ${dataset}`);
|
|
68
|
+
if (filter.tenantId !== undefined && raw['tenant_id'] !== filter.tenantId)
|
|
69
|
+
throw new DirectoryLakeMismatchError(`tenant ${filter.tenantId}`);
|
|
70
|
+
const key = String(raw['row_key']);
|
|
71
|
+
const at = capturedMs(raw['captured_at']);
|
|
72
|
+
const seq = num(raw['seq']);
|
|
73
|
+
const held = latest.get(key);
|
|
74
|
+
if (!held)
|
|
75
|
+
keys.push(key);
|
|
76
|
+
if (!held || at > held.at || (at === held.at && seq > held.seq))
|
|
77
|
+
latest.set(key, { at, seq, raw });
|
|
78
|
+
}
|
|
79
|
+
// The engine's order is kept; the last key may have versions past the page, so it is dropped
|
|
80
|
+
// when the answer was full, and the page ends before it.
|
|
81
|
+
const full = answered.length > filter.limit * 2;
|
|
82
|
+
const usable = full ? keys.slice(0, -1) : keys;
|
|
83
|
+
const records = usable.slice(0, filter.limit).map((key) => {
|
|
84
|
+
const raw = latest.get(key).raw;
|
|
85
|
+
const row = typeof raw['row'] === 'string' ? JSON.parse(raw['row']) : raw['row'];
|
|
86
|
+
return { rowKey: key, row };
|
|
87
|
+
});
|
|
88
|
+
return { records, more: full || usable.length > filter.limit };
|
|
89
|
+
}
|
|
90
|
+
/** An admin-log row as the directory stores it (snake_case, JSON columns as text), as an entry. */
|
|
91
|
+
export function adminLogEntryOfLakeRow(row) {
|
|
92
|
+
const json = (v) => (v === null || v === undefined ? null : typeof v === 'string' ? JSON.parse(v) : v);
|
|
93
|
+
return adminLogEntry.parse({
|
|
94
|
+
id: row['id'],
|
|
95
|
+
actor: row['actor'],
|
|
96
|
+
action: row['action'],
|
|
97
|
+
tenantId: row['tenant_id'] ?? null,
|
|
98
|
+
scopeId: row['scope_id'] ?? null,
|
|
99
|
+
vertical: row['vertical'] ?? null,
|
|
100
|
+
before: json(row['before']),
|
|
101
|
+
after: json(row['after']),
|
|
102
|
+
causedBy: row['caused_by'] ?? null,
|
|
103
|
+
onBehalfOf: json(row['on_behalf_of']),
|
|
104
|
+
at: row['at'],
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/** The start of the directory's window: rows at or after it are the directory's to answer. */
|
|
108
|
+
export function directoryWindowStart(nowMs, windowDays = DIRECTORY_LAKE_WINDOW_DAYS) {
|
|
109
|
+
return new Date(nowMs - windowDays * 86_400_000).toISOString();
|
|
110
|
+
}
|
|
111
|
+
const later = (a, b) => (a !== undefined && a > b ? a : b);
|
|
112
|
+
const earlier = (a, b) => (a !== undefined && a < b ? a : b);
|
|
113
|
+
/**
|
|
114
|
+
* The admin log, read across the directory's window and the lake behind it. `filter.limit` is
|
|
115
|
+
* required here: a history read is a page, never the whole log.
|
|
116
|
+
*/
|
|
117
|
+
export async function readAdminLogHistory(deps, filter) {
|
|
118
|
+
const { admin, actor, lake, mode } = deps;
|
|
119
|
+
const read = (f) => admin.auditLog(actor, f);
|
|
120
|
+
if (mode === 'off' || !lake)
|
|
121
|
+
return read(filter);
|
|
122
|
+
const ws = directoryWindowStart(deps.nowMs);
|
|
123
|
+
const olderAsked = filter.since === undefined || filter.since < ws;
|
|
124
|
+
if (!olderAsked)
|
|
125
|
+
return read(filter);
|
|
126
|
+
const order = filter.order === 'desc' ? 'desc' : 'asc';
|
|
127
|
+
const lakeFilter = (limit, cursor) => ({
|
|
128
|
+
...(filter.tenantId !== undefined ? { tenantId: filter.tenantId } : {}),
|
|
129
|
+
...(filter.scopeId !== undefined ? { scopeId: filter.scopeId } : {}),
|
|
130
|
+
...(filter.actor !== undefined ? { actor: filter.actor } : {}),
|
|
131
|
+
...(filter.action !== undefined ? { kind: filter.action } : {}),
|
|
132
|
+
...(filter.since !== undefined ? { since: filter.since } : {}),
|
|
133
|
+
until: earlier(filter.until, ws),
|
|
134
|
+
...(cursor !== undefined ? { cursor } : {}),
|
|
135
|
+
order,
|
|
136
|
+
limit,
|
|
137
|
+
});
|
|
138
|
+
// K-70: a staff read of the lake is recorded like any staff read, after the engine answered.
|
|
139
|
+
const recordLakeRead = (resultCount, compare) => admin.recordDelegatedRead(actor, {
|
|
140
|
+
method: 'lakeDirectory',
|
|
141
|
+
tenantId: (filter.tenantId ?? null),
|
|
142
|
+
scopeId: filter.scopeId ?? null,
|
|
143
|
+
params: { dataset: 'admin_log', ...(compare ? { compare: true } : {}), ...filter, cursor: undefined, limit: undefined },
|
|
144
|
+
resultCount,
|
|
145
|
+
});
|
|
146
|
+
if (mode === 'compare') {
|
|
147
|
+
const answer = await read(filter);
|
|
148
|
+
// The directory's rows before the window, against the lake's for the same filter and page.
|
|
149
|
+
const old = answer.filter((e) => e.at < ws);
|
|
150
|
+
if (old.length > 0) {
|
|
151
|
+
const first = old[0].id;
|
|
152
|
+
try {
|
|
153
|
+
// The same filter, cursor and order: the lake's rows before the window are the same set
|
|
154
|
+
// as the directory's, whichever end of the page they sit at.
|
|
155
|
+
const { records } = await queryDirectoryLake(lake, 'admin_log', lakeFilter(old.length, filter.cursor));
|
|
156
|
+
await recordLakeRead(records.length, true);
|
|
157
|
+
const inLake = new Set(records.map((r) => r.rowKey));
|
|
158
|
+
const missing = old.filter((e) => !inLake.has(e.id)).map((e) => e.id);
|
|
159
|
+
if (missing.length > 0 || records.length !== old.length) {
|
|
160
|
+
deps.report?.({ compare: 'admin_log', directory: old.length, lake: records.length, missing: missing.slice(0, 10), first });
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
catch (err) {
|
|
164
|
+
deps.report?.({ compare: 'admin_log', error: err.message, first });
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return answer;
|
|
168
|
+
}
|
|
169
|
+
// `on`: the window from the directory, the rest from the lake, walked in the read's order.
|
|
170
|
+
const fromDirectory = (limit, cursor) => filter.until !== undefined && filter.until <= ws
|
|
171
|
+
? Promise.resolve([])
|
|
172
|
+
: read({ ...filter, since: later(filter.since, ws), limit, ...(cursor !== undefined ? { cursor } : {}) });
|
|
173
|
+
const fromLake = async (limit, cursor) => {
|
|
174
|
+
const { records } = await queryDirectoryLake(lake, 'admin_log', lakeFilter(limit, cursor));
|
|
175
|
+
await recordLakeRead(records.length, false);
|
|
176
|
+
return records.map((r) => adminLogEntryOfLakeRow(r.row));
|
|
177
|
+
};
|
|
178
|
+
const segments = order === 'asc' ? [fromLake, fromDirectory] : [fromDirectory, fromLake];
|
|
179
|
+
const out = [];
|
|
180
|
+
let cursor = filter.cursor;
|
|
181
|
+
for (const segment of segments) {
|
|
182
|
+
const rows = await segment(filter.limit - out.length, cursor);
|
|
183
|
+
out.push(...rows);
|
|
184
|
+
if (out.length >= filter.limit)
|
|
185
|
+
break;
|
|
186
|
+
if (out.length > 0)
|
|
187
|
+
cursor = out[out.length - 1].id;
|
|
188
|
+
}
|
|
189
|
+
return out;
|
|
190
|
+
}
|
|
191
|
+
/** How many rows one page of a whole-history walk asks for. */
|
|
192
|
+
const HISTORY_WALK_PAGE = 1_000;
|
|
193
|
+
/**
|
|
194
|
+
* A tenant's whole admin log (the export), across the window and the lake. Off, or with no lake,
|
|
195
|
+
* it is the one directory read it always was; otherwise it pages the history read to its end.
|
|
196
|
+
*/
|
|
197
|
+
export async function readWholeAdminLog(deps, filter) {
|
|
198
|
+
if (deps.mode === 'off' || !deps.lake)
|
|
199
|
+
return deps.admin.auditLog(deps.actor, filter);
|
|
200
|
+
const out = [];
|
|
201
|
+
let cursor;
|
|
202
|
+
for (;;) {
|
|
203
|
+
const page = await readAdminLogHistory(deps, {
|
|
204
|
+
...filter,
|
|
205
|
+
order: 'asc',
|
|
206
|
+
limit: HISTORY_WALK_PAGE,
|
|
207
|
+
...(cursor !== undefined ? { cursor } : {}),
|
|
208
|
+
});
|
|
209
|
+
out.push(...page);
|
|
210
|
+
if (page.length < HISTORY_WALK_PAGE)
|
|
211
|
+
return out;
|
|
212
|
+
cursor = page[page.length - 1].id;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* The data sets whose every history reader reads the lake before the window (this file), so the
|
|
217
|
+
* directory may prune them to it. Only the admin log so far; the readers of the others are listed
|
|
218
|
+
* in the PR that added this (#3405) and join here one by one as they move.
|
|
219
|
+
*/
|
|
220
|
+
export const DIRECTORY_LAKE_HISTORY_READ = ['admin_log'];
|
|
221
|
+
/**
|
|
222
|
+
* Of the data sets the prune switch lists, those that may be pruned now: their history is read
|
|
223
|
+
* from the lake (`DIRECTORY_LAKE_HISTORY_READ`) and reads are `on`. The rest are refused with the
|
|
224
|
+
* reason, so a switch set ahead of its reader prunes nothing a console still needs.
|
|
225
|
+
*/
|
|
226
|
+
export function prunableDirectoryDatasets(wanted, reads) {
|
|
227
|
+
const allowed = [];
|
|
228
|
+
const refused = [];
|
|
229
|
+
for (const dataset of wanted) {
|
|
230
|
+
if (!DIRECTORY_LAKE_HISTORY_READ.includes(dataset))
|
|
231
|
+
refused.push({ dataset, reason: 'its history readers do not read the lake yet' });
|
|
232
|
+
else if (reads !== 'on')
|
|
233
|
+
refused.push({ dataset, reason: `DIRECTORY_LAKE_READS is ${reads}, not on` });
|
|
234
|
+
else
|
|
235
|
+
allowed.push(dataset);
|
|
236
|
+
}
|
|
237
|
+
return { allowed, refused };
|
|
238
|
+
}
|
|
239
|
+
//# sourceMappingURL=directory-lake-reads.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory-lake-reads.js","sourceRoot":"","sources":["../src/directory-lake-reads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAA2D,MAAM,yBAAyB,CAAC;AAC/H,OAAO,EAAE,0BAA0B,EAAkE,MAAM,sBAAsB,CAAC;AAgClI,MAAM,UAAU,uBAAuB,CAAC,KAAyB;IAC/D,MAAM,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAC/B,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,KAAK;QAAE,OAAO,KAAK,CAAC;IAC1C,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,IAAI;QAAE,OAAO,CAAC,CAAC;IAC5C,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,EAAE,CAAC,CAAC;AACjF,CAAC;AAED,sFAAsF;AACtF,MAAM,oBAAoB,GAAG,kBAAkB,CAAC;AAEhD,MAAM,OAAO,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,KAAK,CAAU,CAAC;AAkB7H,SAAS,OAAO,CAAC,KAAa;IAC5B,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;IAC/G,OAAO,IAAI,KAAK,GAAG,CAAC;AACtB,CAAC;AAED,6GAA6G;AAC7G,MAAM,UAAU,yBAAyB,CAAC,OAA6B,EAAE,MAA2B;IAClG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CA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I,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAE,CAAC,EAAE,CAAC;IACrC,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAoC,CAAC,WAAW,CAAC,CAAC;AAE1F;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CACvC,MAAuC,EACvC,KAAyB;IAEzB,MAAM,OAAO,GAA2B,EAAE,CAAC;IAC3C,MAAM,OAAO,GAAwD,EAAE,CAAC;IACxE,KAAK,MAAM,OAAO,IAAI,MAAM,EAAE,CAAC;QAC7B,IAAI,CAAC,2BAA2B,CAAC,QAAQ,CAAC,OAAO,CAAC;YAAE,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,8CAA8C,EAAE,CAAC,CAAC;aACjI,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,2BAA2B,KAAK,UAAU,EAAE,CAAC,CAAC;;YAClG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory-lake-sink.d.ts","sourceRoot":"","sources":["../src/directory-lake-sink.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAoB,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AA0ChF,wBAAgB,gCAAgC,CAAC,MAAM,EAAE,OAAO,GAAG,iBAAiB,CAkBnF"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { byteLength, sendPacked } from './pipelines-sink.js';
|
|
2
|
+
/**
|
|
3
|
+
* K-70 (tenants × time data leaves the objects): the Pipelines implementation of the directory's
|
|
4
|
+
* `DirectoryLakeSink`, shipping its outbox to the lake's directory table. The stream's fields are
|
|
5
|
+
* `scripts/lake/directory-stream-schema.generated.json`, derived from `_substrat_directory_outbox`.
|
|
6
|
+
*
|
|
7
|
+
* The same delivery contract as the event sink (`pipelines-sink.ts`): rows are packed by bytes
|
|
8
|
+
* and sent one request after another, a resolved `send` is Cloudflare confirming the records are
|
|
9
|
+
* in the durable stream, and a failure part-way throws so nothing is acknowledged and the batch
|
|
10
|
+
* goes again (at least once). The lake keeps every version of a row, keyed by
|
|
11
|
+
* (`dataset`, `row_key`), ordered by `captured_at` and then `seq`; a duplicate is the same version.
|
|
12
|
+
*
|
|
13
|
+
* Two shape changes, forced by the stream schema as they are for events: `at` and `captured_at`
|
|
14
|
+
* become epoch milliseconds (a day's `at`, `2026-11-24`, is that day's UTC midnight), and `row`
|
|
15
|
+
* travels as the JSON object it is rather than as text.
|
|
16
|
+
*/
|
|
17
|
+
function toRow(r) {
|
|
18
|
+
const at = Date.parse(r.at);
|
|
19
|
+
const capturedAt = Date.parse(r.capturedAt);
|
|
20
|
+
if (Number.isNaN(at) || Number.isNaN(capturedAt)) {
|
|
21
|
+
// A row whose time is not a time would land as a null the schema refuses, or worse as a wrong
|
|
22
|
+
// instant; failing keeps it queued and visible in the pass's errors.
|
|
23
|
+
throw new Error(`directory lake sink: ${r.dataset} ${r.rowKey} has an unreadable time (at ${r.at}, captured ${r.capturedAt})`);
|
|
24
|
+
}
|
|
25
|
+
const row = {
|
|
26
|
+
seq: r.seq,
|
|
27
|
+
dataset: r.dataset,
|
|
28
|
+
row_key: r.rowKey,
|
|
29
|
+
tenant_id: r.tenantId,
|
|
30
|
+
scope_id: r.scopeId,
|
|
31
|
+
at,
|
|
32
|
+
kind: r.kind,
|
|
33
|
+
actor: r.actor,
|
|
34
|
+
captured_at: capturedAt,
|
|
35
|
+
row: JSON.parse(r.row),
|
|
36
|
+
};
|
|
37
|
+
// The row's own size, without this field, as the event sink measures it: per-tenant volume.
|
|
38
|
+
return { ...row, bytes: byteLength(row) };
|
|
39
|
+
}
|
|
40
|
+
export function createPipelinesDirectoryLakeSink(stream) {
|
|
41
|
+
return {
|
|
42
|
+
async ship(rows) {
|
|
43
|
+
const first = rows[0];
|
|
44
|
+
const last = rows[rows.length - 1];
|
|
45
|
+
if (!first || !last)
|
|
46
|
+
throw new Error('directory lake sink: refusing to ship an empty batch');
|
|
47
|
+
const requests = await sendPacked(stream, rows.map((r) => ({
|
|
48
|
+
row: toRow(r),
|
|
49
|
+
refuse: (bytes) => new Error(`directory lake sink: ${r.dataset} ${r.rowKey} serializes to ${bytes} bytes, over one request; it stays queued`),
|
|
50
|
+
})));
|
|
51
|
+
const span = first.seq !== null && last.seq !== null ? `${first.seq}..${last.seq}` : `${first.dataset}:${first.rowKey}..${last.rowKey}`;
|
|
52
|
+
return { ref: `pipelines:directory/${span}#${requests}` };
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=directory-lake-sink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory-lake-sink.js","sourceRoot":"","sources":["../src/directory-lake-sink.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAE7D;;;;;;;;;;;;;;GAcG;AACH,SAAS,KAAK,CAAC,CAAmB;IAChC,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC5B,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;IAC5C,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC;QACjD,8FAA8F;QAC9F,qEAAqE;QACrE,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,MAAM,+BAA+B,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC;IACjI,CAAC;IACD,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AC,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,KAAK,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,EAAE,CAAC;YACxI,OAAO,EAAE,GAAG,EAAE,uBAAuB,IAAI,IAAI,QAAQ,EAAE,EAAE,CAAC;QAC5D,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -77,6 +77,8 @@ export type { CfObservabilityOptions } from './cf-observability.js';
|
|
|
77
77
|
export type { ScopeBackup, ScopeBackupEntry, ScopeBackupStore, ScopeBackupWriter, ScopeDumpHeader, StoredScopeBackup, DirectoryBackup, DirectoryBackupStore, DirectoryBackupWriter, } from './backups.js';
|
|
78
78
|
export { createR2AccessLogSink, createR2BackupStore, createR2DirectoryBackupStore, createR2EventSink, pruneAccessLogBatches, pruneScopeBackups, } from './r2-backups.js';
|
|
79
79
|
export { createPipelinesEventSink } from './pipelines-sink.js';
|
|
80
|
+
export { createPipelinesDirectoryLakeSink } from './directory-lake-sink.js';
|
|
81
|
+
export { DIRECTORY_LAKE_HISTORY_READ, parseDirectoryLakeReads, prunableDirectoryDatasets, readAdminLogHistory, readWholeAdminLog, type DirectoryLakeReads, } from './directory-lake-reads.js';
|
|
80
82
|
export type { LakeQueryEngine } from './lake-gateway.js';
|
|
81
83
|
export { createR2SqlEngine } from './r2-sql-engine.js';
|
|
82
84
|
export type { R2SqlEngineOptions } from './r2-sql-engine.js';
|