@stigmer/server 3.25.0 → 3.26.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/boot/compose.d.ts.map +1 -1
- package/dist/boot/compose.js +11 -8
- package/dist/boot/compose.js.map +1 -1
- package/dist/boot/list-indexes.d.ts +3 -0
- package/dist/boot/list-indexes.d.ts.map +1 -0
- package/dist/boot/list-indexes.js +24 -0
- package/dist/boot/list-indexes.js.map +1 -0
- package/dist/domain/agentexecution/controller.d.ts.map +1 -1
- package/dist/domain/agentexecution/controller.js +6 -8
- package/dist/domain/agentexecution/controller.js.map +1 -1
- package/dist/domain/agentexecution/list-index.d.ts +2 -0
- package/dist/domain/agentexecution/list-index.d.ts.map +1 -0
- package/dist/domain/agentexecution/list-index.js +23 -0
- package/dist/domain/agentexecution/list-index.js.map +1 -0
- package/dist/domain/agentexecution/steps.d.ts +17 -33
- package/dist/domain/agentexecution/steps.d.ts.map +1 -1
- package/dist/domain/agentexecution/steps.js +94 -95
- package/dist/domain/agentexecution/steps.js.map +1 -1
- package/dist/domain/agentexecution/usage.d.ts.map +1 -1
- package/dist/domain/agentexecution/usage.js +37 -14
- package/dist/domain/agentexecution/usage.js.map +1 -1
- package/dist/domain/artifact/controller.d.ts.map +1 -1
- package/dist/domain/artifact/controller.js +27 -15
- package/dist/domain/artifact/controller.js.map +1 -1
- package/dist/domain/artifact/list-index.d.ts +2 -0
- package/dist/domain/artifact/list-index.d.ts.map +1 -0
- package/dist/domain/artifact/list-index.js +21 -0
- package/dist/domain/artifact/list-index.js.map +1 -0
- package/dist/domain/session/list-index.d.ts +4 -0
- package/dist/domain/session/list-index.d.ts.map +1 -0
- package/dist/domain/session/list-index.js +26 -0
- package/dist/domain/session/list-index.js.map +1 -0
- package/dist/domain/session/steps.d.ts +7 -8
- package/dist/domain/session/steps.d.ts.map +1 -1
- package/dist/domain/session/steps.js +76 -78
- package/dist/domain/session/steps.js.map +1 -1
- package/dist/domain/workflowexecution/controller.d.ts.map +1 -1
- package/dist/domain/workflowexecution/controller.js +53 -55
- package/dist/domain/workflowexecution/controller.js.map +1 -1
- package/dist/domain/workflowexecution/execution-filter.d.ts +4 -0
- package/dist/domain/workflowexecution/execution-filter.d.ts.map +1 -1
- package/dist/domain/workflowexecution/execution-filter.js +11 -5
- package/dist/domain/workflowexecution/execution-filter.js.map +1 -1
- package/dist/domain/workflowexecution/get-execution-summary.d.ts.map +1 -1
- package/dist/domain/workflowexecution/get-execution-summary.js +23 -17
- package/dist/domain/workflowexecution/get-execution-summary.js.map +1 -1
- package/dist/domain/workflowexecution/list-index.d.ts +2 -0
- package/dist/domain/workflowexecution/list-index.d.ts.map +1 -0
- package/dist/domain/workflowexecution/list-index.js +21 -0
- package/dist/domain/workflowexecution/list-index.js.map +1 -0
- package/dist/domain/workflowexecution/list-pending-approvals.d.ts.map +1 -1
- package/dist/domain/workflowexecution/list-pending-approvals.js +69 -32
- package/dist/domain/workflowexecution/list-pending-approvals.js.map +1 -1
- package/dist/domain/workflowexecution/queries.d.ts +30 -4
- package/dist/domain/workflowexecution/queries.d.ts.map +1 -1
- package/dist/domain/workflowexecution/queries.js +76 -22
- package/dist/domain/workflowexecution/queries.js.map +1 -1
- package/dist/extensions/list-read-scope.d.ts +9 -12
- package/dist/extensions/list-read-scope.d.ts.map +1 -1
- package/dist/extensions/list-read-scope.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/pipeline/steps/list-page.d.ts +63 -0
- package/dist/pipeline/steps/list-page.d.ts.map +1 -0
- package/dist/pipeline/steps/list-page.js +187 -0
- package/dist/pipeline/steps/list-page.js.map +1 -0
- package/dist/query/activity/handler.d.ts +6 -7
- package/dist/query/activity/handler.d.ts.map +1 -1
- package/dist/query/activity/handler.js +42 -59
- package/dist/query/activity/handler.js.map +1 -1
- package/dist/store/interface.d.ts +29 -0
- package/dist/store/interface.d.ts.map +1 -1
- package/dist/store/interface.js.map +1 -1
- package/dist/store/list-index.d.ts +123 -0
- package/dist/store/list-index.d.ts.map +1 -0
- package/dist/store/list-index.js +277 -0
- package/dist/store/list-index.js.map +1 -0
- package/dist/store/logger.d.ts +3 -0
- package/dist/store/logger.d.ts.map +1 -1
- package/dist/store/logger.js +5 -1
- package/dist/store/logger.js.map +1 -1
- package/dist/store/postgres/migrations.d.ts +10 -6
- package/dist/store/postgres/migrations.d.ts.map +1 -1
- package/dist/store/postgres/migrations.js +64 -6
- package/dist/store/postgres/migrations.js.map +1 -1
- package/dist/store/postgres/store.d.ts +26 -5
- package/dist/store/postgres/store.d.ts.map +1 -1
- package/dist/store/postgres/store.js +377 -22
- package/dist/store/postgres/store.js.map +1 -1
- package/dist/store/sqlite/migrations.d.ts +11 -5
- package/dist/store/sqlite/migrations.d.ts.map +1 -1
- package/dist/store/sqlite/migrations.js +50 -4
- package/dist/store/sqlite/migrations.js.map +1 -1
- package/dist/store/sqlite/store.d.ts +18 -3
- package/dist/store/sqlite/store.d.ts.map +1 -1
- package/dist/store/sqlite/store.js +321 -15
- package/dist/store/sqlite/store.js.map +1 -1
- package/package.json +6 -6
- package/src/authorization/__tests__/drivers.ts +6 -1
- package/src/boot/__tests__/list-indexes.test.ts +65 -0
- package/src/boot/compose.ts +23 -13
- package/src/boot/list-indexes.ts +25 -0
- package/src/domain/agentexecution/__tests__/agentexecution.test.ts +85 -3
- package/src/domain/agentexecution/controller.ts +8 -10
- package/src/domain/agentexecution/list-index.ts +24 -0
- package/src/domain/agentexecution/steps.ts +118 -115
- package/src/domain/agentexecution/usage.ts +38 -17
- package/src/domain/artifact/controller.ts +28 -18
- package/src/domain/artifact/list-index.ts +22 -0
- package/src/domain/session/list-index.ts +28 -0
- package/src/domain/session/steps.ts +108 -123
- package/src/domain/workflowexecution/__tests__/list-read-scope-summaries.test.ts +155 -99
- package/src/domain/workflowexecution/__tests__/workflowexecution.test.ts +193 -31
- package/src/domain/workflowexecution/controller.ts +54 -82
- package/src/domain/workflowexecution/execution-filter.ts +20 -7
- package/src/domain/workflowexecution/get-execution-summary.ts +31 -24
- package/src/domain/workflowexecution/list-index.ts +22 -0
- package/src/domain/workflowexecution/list-pending-approvals.ts +82 -25
- package/src/domain/workflowexecution/queries.ts +134 -23
- package/src/extensions/list-read-scope.ts +9 -12
- package/src/index.ts +10 -1
- package/src/pipeline/steps/__tests__/list-page.test.ts +186 -0
- package/src/pipeline/steps/list-page.ts +284 -0
- package/src/query/activity/handler.ts +57 -78
- package/src/store/README.md +51 -32
- package/src/store/__tests__/list-index.measure.test.ts +293 -0
- package/src/store/__tests__/list-index.test.ts +328 -0
- package/src/store/__tests__/store-contract.ts +346 -3
- package/src/store/interface.ts +39 -0
- package/src/store/list-index.ts +465 -0
- package/src/store/logger.ts +8 -1
- package/src/store/postgres/__tests__/list-index-repair.test.ts +133 -0
- package/src/store/postgres/__tests__/migrations.test.ts +27 -19
- package/src/store/postgres/__tests__/store-contract.test.ts +50 -3
- package/src/store/postgres/migrations.ts +69 -7
- package/src/store/postgres/store.ts +485 -29
- package/src/store/sqlite/__tests__/migrations.test.ts +51 -7
- package/src/store/sqlite/__tests__/store-contract.test.ts +70 -16
- package/src/store/sqlite/__tests__/support.ts +12 -3
- package/src/store/sqlite/migrations.ts +57 -6
- package/src/store/sqlite/store.ts +462 -21
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The list index: what a store keeps beside a row so a list lane can read
|
|
3
|
+
* one organization's or one parent's rows in creation order without
|
|
4
|
+
* decoding the whole kind. Every list lane used to call `listResources`
|
|
5
|
+
* and filter in memory, and the payload is opaque bytes by contract
|
|
6
|
+
* (postgres/migrations.ts: audit hashes are content-addressed over them),
|
|
7
|
+
* so an index is projected columns written beside the blob, never a path
|
|
8
|
+
* into it.
|
|
9
|
+
*
|
|
10
|
+
* A kind is list-indexed exactly when its declaration appears in the one
|
|
11
|
+
* explicit list the composition root hands to the store when it opens
|
|
12
|
+
* (boot/list-indexes.ts) — the search registry's idiom
|
|
13
|
+
* (query/search/registry.ts). A declaration lives beside the lanes that
|
|
14
|
+
* filter on its keys (`domain/<kind>/list-index.ts`) and states them as
|
|
15
|
+
* data, a field path or a label, so the store derives them without
|
|
16
|
+
* knowing any domain: this module is the one derivation every writer, the
|
|
17
|
+
* reconciliation at open and every read of an unproven row share.
|
|
18
|
+
*
|
|
19
|
+
* Facts are written atomically with the row, never best-effort (the one
|
|
20
|
+
* deliberate divergence from search, whose index only degrades search: a
|
|
21
|
+
* missing list row hides a row). A row's facts are PROVEN current when
|
|
22
|
+
* its stamp equals its `updated_at` and its revision is its declaration's;
|
|
23
|
+
* a row written by a binary that does not know the index (every production
|
|
24
|
+
* roll overlaps the old and the new pod for a minute), or by one with
|
|
25
|
+
* another revision of the declaration, is UNPROVEN, and a read evaluates
|
|
26
|
+
* it from its bytes with this module and repairs it (`queryResources` in
|
|
27
|
+
* interface.ts states the contract). Exactness is therefore the store's
|
|
28
|
+
* guarantee, independent of timing.
|
|
29
|
+
*
|
|
30
|
+
* The order is one for every indexed read: newest first on the audit's
|
|
31
|
+
* `spec_audit.created_at`, ties broken by id, both compared as bytes. The
|
|
32
|
+
* instant is fixed-width UTC text so the drivers sort it as text and this
|
|
33
|
+
* module compares it the same way; an absent stamp is the empty string,
|
|
34
|
+
* which sorts last newest-first — exactly `compareCreatedAtDesc`
|
|
35
|
+
* (pipeline/steps/helpers.ts), the order the session lists always had.
|
|
36
|
+
*
|
|
37
|
+
* Proven by __tests__/list-index.test.ts (declaration validation, the
|
|
38
|
+
* derivation, the instant, the merge) and, per driver, by the list-index
|
|
39
|
+
* arms of __tests__/store-contract.ts.
|
|
40
|
+
*/
|
|
41
|
+
import { ScalarType } from "@bufbuild/protobuf";
|
|
42
|
+
import { apiResourceKindName } from "./proto-fields.js";
|
|
43
|
+
/** A string field of the resource, by proto field names from the root ("spec.session_id"). */
|
|
44
|
+
export function field(path) {
|
|
45
|
+
return { from: "field", path };
|
|
46
|
+
}
|
|
47
|
+
/** A `metadata.labels` entry. */
|
|
48
|
+
export function label(key) {
|
|
49
|
+
return { from: "label", label: key };
|
|
50
|
+
}
|
|
51
|
+
const resolvedKeys = new WeakMap();
|
|
52
|
+
/**
|
|
53
|
+
* Declares a kind's list index, resolving every key against the schema so
|
|
54
|
+
* a misspelt path or a non-string field fails at module load, not as a
|
|
55
|
+
* silently empty list.
|
|
56
|
+
*/
|
|
57
|
+
export function declareListIndex(declaration) {
|
|
58
|
+
if (!Number.isInteger(declaration.revision) || declaration.revision < 1) {
|
|
59
|
+
throw new Error(`list index for ${apiResourceKindName(declaration.kind)}: revision must be a positive integer`);
|
|
60
|
+
}
|
|
61
|
+
const keys = [];
|
|
62
|
+
for (const [name, source] of Object.entries(declaration.keys)) {
|
|
63
|
+
keys.push({ name, read: resolveKeyReader(declaration, name, source) });
|
|
64
|
+
}
|
|
65
|
+
const frozen = Object.freeze({
|
|
66
|
+
...declaration,
|
|
67
|
+
keys: Object.freeze({ ...declaration.keys }),
|
|
68
|
+
});
|
|
69
|
+
resolvedKeys.set(frozen, keys);
|
|
70
|
+
return frozen;
|
|
71
|
+
}
|
|
72
|
+
function resolveKeyReader(declaration, name, source) {
|
|
73
|
+
switch (source.from) {
|
|
74
|
+
case "label":
|
|
75
|
+
return (resource) => resource.metadata?.labels?.[source.label] ?? "";
|
|
76
|
+
case "field": {
|
|
77
|
+
const localNames = resolveFieldPath(declaration, name, source.path);
|
|
78
|
+
return (resource) => {
|
|
79
|
+
let value = resource;
|
|
80
|
+
for (const localName of localNames) {
|
|
81
|
+
if (value === null || typeof value !== "object") {
|
|
82
|
+
return "";
|
|
83
|
+
}
|
|
84
|
+
value = value[localName];
|
|
85
|
+
}
|
|
86
|
+
return typeof value === "string" ? value : "";
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
default: {
|
|
90
|
+
const exhaustive = source;
|
|
91
|
+
throw new Error(`unknown list key source: ${String(exhaustive)}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function resolveFieldPath(declaration, name, path) {
|
|
96
|
+
const where = `list index for ${apiResourceKindName(declaration.kind)}, key '${name}'`;
|
|
97
|
+
const segments = path.split(".");
|
|
98
|
+
const localNames = [];
|
|
99
|
+
let message = declaration.schema;
|
|
100
|
+
segments.forEach((segment, index) => {
|
|
101
|
+
const found = message?.fields.find((f) => f.name === segment);
|
|
102
|
+
if (found === undefined) {
|
|
103
|
+
throw new Error(`${where}: '${path}' has no field '${segment}'`);
|
|
104
|
+
}
|
|
105
|
+
localNames.push(found.localName);
|
|
106
|
+
const last = index === segments.length - 1;
|
|
107
|
+
if (last) {
|
|
108
|
+
if (found.fieldKind !== "scalar" || found.scalar !== ScalarType.STRING) {
|
|
109
|
+
throw new Error(`${where}: '${path}' is not a string field`);
|
|
110
|
+
}
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (found.fieldKind !== "message") {
|
|
114
|
+
throw new Error(`${where}: '${segment}' in '${path}' is not a message`);
|
|
115
|
+
}
|
|
116
|
+
message = found.message;
|
|
117
|
+
});
|
|
118
|
+
return localNames;
|
|
119
|
+
}
|
|
120
|
+
/** The declaration's shape as text, for the revision pin. */
|
|
121
|
+
export function listIndexFingerprint(declaration) {
|
|
122
|
+
const keys = Object.entries(declaration.keys)
|
|
123
|
+
.map(([name, source]) => source.from === "field"
|
|
124
|
+
? `${name}=field:${source.path}`
|
|
125
|
+
: `${name}=label:${source.label}`)
|
|
126
|
+
.sort();
|
|
127
|
+
return `${apiResourceKindName(declaration.kind)}{${keys.join(",")}}`;
|
|
128
|
+
}
|
|
129
|
+
/** Derives a decoded row's facts; every absence is the empty value, never a throw. */
|
|
130
|
+
export function listIndexFactsOf(declaration, resource) {
|
|
131
|
+
const shaped = resource;
|
|
132
|
+
const keys = [];
|
|
133
|
+
for (const resolved of keysOf(declaration)) {
|
|
134
|
+
const value = resolved.read(resource);
|
|
135
|
+
if (value !== "") {
|
|
136
|
+
keys.push({ key: resolved.name, value });
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
org: shaped.metadata?.org ?? "",
|
|
141
|
+
createdAt: listIndexInstant(shaped.status?.audit?.specAudit?.createdAt),
|
|
142
|
+
revision: declaration.revision,
|
|
143
|
+
keys,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Whether two derivations would write the same key rows — the check that
|
|
148
|
+
* lets an update skip rewriting them, which a status write never needs.
|
|
149
|
+
*/
|
|
150
|
+
export function sameListKeyRows(a, b) {
|
|
151
|
+
return (a.createdAt === b.createdAt &&
|
|
152
|
+
a.keys.length === b.keys.length &&
|
|
153
|
+
a.keys.every((k, i) => k.key === b.keys[i]?.key && k.value === b.keys[i]?.value));
|
|
154
|
+
}
|
|
155
|
+
function keysOf(declaration) {
|
|
156
|
+
const keys = resolvedKeys.get(declaration);
|
|
157
|
+
if (keys === undefined) {
|
|
158
|
+
throw new Error(`list index for ${apiResourceKindName(declaration.kind)} was not made by declareListIndex`);
|
|
159
|
+
}
|
|
160
|
+
return keys;
|
|
161
|
+
}
|
|
162
|
+
// The instant is representable as four-digit-year ISO text in this range;
|
|
163
|
+
// outside it a stamp is treated as absent rather than mis-sorted.
|
|
164
|
+
const MIN_INSTANT_SECONDS = -62135596800n; // 0001-01-01T00:00:00Z
|
|
165
|
+
const MAX_INSTANT_SECONDS = 253402300799n; // 9999-12-31T23:59:59Z
|
|
166
|
+
/**
|
|
167
|
+
* A timestamp as the index's fixed-width UTC text
|
|
168
|
+
* (`YYYY-MM-DDTHH:MM:SS.nnnnnnnnnZ`), or "" when absent.
|
|
169
|
+
*/
|
|
170
|
+
export function listIndexInstant(timestamp) {
|
|
171
|
+
if (timestamp === undefined ||
|
|
172
|
+
timestamp.seconds < MIN_INSTANT_SECONDS ||
|
|
173
|
+
timestamp.seconds > MAX_INSTANT_SECONDS) {
|
|
174
|
+
return "";
|
|
175
|
+
}
|
|
176
|
+
const iso = new Date(Number(timestamp.seconds) * 1000).toISOString();
|
|
177
|
+
const nanos = String(Math.max(0, Math.min(999_999_999, timestamp.nanos))).padStart(9, "0");
|
|
178
|
+
return `${iso.slice(0, 19)}.${nanos}Z`;
|
|
179
|
+
}
|
|
180
|
+
/** Epoch milliseconds as the index's instant, for a `createdAtOrAfter` bound. */
|
|
181
|
+
export function listIndexInstantOfMillis(millis) {
|
|
182
|
+
const seconds = Math.floor(millis / 1000);
|
|
183
|
+
const nanos = (millis - seconds * 1000) * 1_000_000;
|
|
184
|
+
return listIndexInstant({ seconds: BigInt(seconds), nanos });
|
|
185
|
+
}
|
|
186
|
+
/** Byte order, the order both drivers sort text in (Postgres `COLLATE "C"`, sqlite BINARY). */
|
|
187
|
+
function compareBytes(a, b) {
|
|
188
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
189
|
+
}
|
|
190
|
+
/** Negative when `a` comes first in the index's newest-first order. */
|
|
191
|
+
export function compareListIndexOrder(a, b) {
|
|
192
|
+
const byCreated = compareBytes(b.createdAt, a.createdAt);
|
|
193
|
+
return byCreated !== 0 ? byCreated : compareBytes(b.id, a.id);
|
|
194
|
+
}
|
|
195
|
+
/** Whether a row's facts satisfy a query's predicates, the cursor included. */
|
|
196
|
+
export function matchesListIndexQuery(id, facts, query) {
|
|
197
|
+
if (query.org !== undefined && query.org !== "" && facts.org !== query.org) {
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
if (query.anyKey !== undefined) {
|
|
201
|
+
const wanted = query.anyKey;
|
|
202
|
+
if (!facts.keys.some((k) => wanted.some((w) => w.name === k.key && w.value === k.value))) {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
if (query.createdAtOrAfter !== undefined &&
|
|
207
|
+
facts.createdAt !== "" &&
|
|
208
|
+
compareBytes(facts.createdAt, query.createdAtOrAfter) < 0) {
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
if (query.after !== undefined &&
|
|
212
|
+
compareListIndexOrder({ createdAt: facts.createdAt, id }, query.after) <= 0) {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* The drivers' last step: the proven rows the index answered, merged with
|
|
219
|
+
* the unproven rows evaluated from their bytes, in order, without
|
|
220
|
+
* duplicates, cut to the limit. Both inputs already satisfy the query.
|
|
221
|
+
*/
|
|
222
|
+
export function mergeListIndexRows(proven, unproven, limit) {
|
|
223
|
+
const byId = new Map();
|
|
224
|
+
for (const row of [...proven, ...unproven]) {
|
|
225
|
+
byId.set(row.id, row);
|
|
226
|
+
}
|
|
227
|
+
const merged = [...byId.values()].sort((a, b) => compareListIndexOrder(a.cursor, b.cursor));
|
|
228
|
+
return limit === undefined ? merged : merged.slice(0, limit);
|
|
229
|
+
}
|
|
230
|
+
/** Refuses a limit a caller cannot mean: zero, negative or fractional. */
|
|
231
|
+
export function assertListIndexLimit(limit) {
|
|
232
|
+
if (limit !== undefined && (!Number.isInteger(limit) || limit < 1)) {
|
|
233
|
+
throw new Error(`list index limit must be a positive integer, got ${limit}`);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
// =============================================================================
|
|
237
|
+
// The registry a store opens with
|
|
238
|
+
// =============================================================================
|
|
239
|
+
/**
|
|
240
|
+
* The declarations one store was opened with, keyed by kind. A read names
|
|
241
|
+
* its declaration and the store refuses one it was not opened with, so a
|
|
242
|
+
* lane and the composition root cannot silently disagree about an index.
|
|
243
|
+
*/
|
|
244
|
+
export class ListIndexRegistry {
|
|
245
|
+
byKind = new Map();
|
|
246
|
+
constructor(declarations) {
|
|
247
|
+
for (const declaration of declarations) {
|
|
248
|
+
keysOf(declaration);
|
|
249
|
+
if (this.byKind.has(declaration.kind)) {
|
|
250
|
+
throw new Error(`list index for ${apiResourceKindName(declaration.kind)} is declared twice`);
|
|
251
|
+
}
|
|
252
|
+
this.byKind.set(declaration.kind, declaration);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
/** The declaration for a kind, or undefined when the kind is not list-indexed. */
|
|
256
|
+
declarationOf(kind) {
|
|
257
|
+
return this.byKind.get(kind);
|
|
258
|
+
}
|
|
259
|
+
/** Every declaration, in registration order. */
|
|
260
|
+
declarations() {
|
|
261
|
+
return [...this.byKind.values()];
|
|
262
|
+
}
|
|
263
|
+
/** A decoded row's facts when its kind is list-indexed; undefined otherwise. */
|
|
264
|
+
factsOf(kind, resource) {
|
|
265
|
+
const declaration = this.byKind.get(kind);
|
|
266
|
+
return declaration === undefined
|
|
267
|
+
? undefined
|
|
268
|
+
: listIndexFactsOf(declaration, resource);
|
|
269
|
+
}
|
|
270
|
+
/** Throws unless this exact declaration was registered. */
|
|
271
|
+
require(declaration) {
|
|
272
|
+
if (this.byKind.get(declaration.kind) !== declaration) {
|
|
273
|
+
throw new Error(`list index for ${apiResourceKindName(declaration.kind)} is not registered with this store`);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
//# sourceMappingURL=list-index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-index.js","sourceRoot":"","sources":["../../src/store/list-index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAKhD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAWxD,8FAA8F;AAC9F,MAAM,UAAU,KAAK,CAAC,IAAY;IAChC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACjC,CAAC;AAED,iCAAiC;AACjC,MAAM,UAAU,KAAK,CAAC,GAAW;IAC/B,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;AACvC,CAAC;AAoBD,MAAM,YAAY,GAAG,IAAI,OAAO,EAG7B,CAAC;AAEJ;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,CAAC,IAAI,CAAC,oCAAoC,CAC5F,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
|
package/dist/store/logger.d.ts
CHANGED
|
@@ -3,9 +3,12 @@
|
|
|
3
3
|
* compatible with boot/logger.ts, declared here so the store layer never
|
|
4
4
|
* imports upward from boot/. Lived inline in sqlite/store.ts through
|
|
5
5
|
* Phase 1; promoted when the Postgres driver became the second consumer.
|
|
6
|
+
* `info` carries what an operator reads at boot (the list index's
|
|
7
|
+
* reconciliation count).
|
|
6
8
|
*/
|
|
7
9
|
export interface StoreLogger {
|
|
8
10
|
debug(message: string, fields?: Record<string, unknown>): void;
|
|
11
|
+
info(message: string, fields?: Record<string, unknown>): void;
|
|
9
12
|
warn(message: string, fields?: Record<string, unknown>): void;
|
|
10
13
|
}
|
|
11
14
|
/** Default for tests and tools that want a silent store. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/store/logger.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/store/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC/D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC9D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CAC/D;AAED,4DAA4D;AAC5D,eAAO,MAAM,iBAAiB,EAAE,WAI/B,CAAC"}
|
package/dist/store/logger.js
CHANGED
package/dist/store/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/store/logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/store/logger.ts"],"names":[],"mappings":"AAcA,4DAA4D;AAC5D,MAAM,CAAC,MAAM,iBAAiB,GAAgB;IAC5C,KAAK,KAAI,CAAC;IACV,IAAI,KAAI,CAAC;IACT,IAAI,KAAI,CAAC;CACV,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Versioned schema migrations for the Postgres driver — an INDEPENDENT
|
|
3
3
|
* chain starting at its own v1 (DD-010 §3). It deliberately does NOT
|
|
4
|
-
* mirror sqlite's
|
|
4
|
+
* mirror sqlite's chain: that chain's value is Go-DDL fidelity for adopted
|
|
5
5
|
* laptop databases, a concern Postgres cannot have (no Postgres database
|
|
6
6
|
* predates this driver). Same runner discipline as sqlite/migrations.ts —
|
|
7
7
|
* deliberate, versioned, each step in its own transaction, `schema_version`
|
|
@@ -44,8 +44,10 @@ export declare const SCHEMA_VERSION_3 = 3;
|
|
|
44
44
|
export declare const SCHEMA_VERSION_4 = 4;
|
|
45
45
|
/** v5: every row holding the retired public visibility level moved to org. */
|
|
46
46
|
export declare const SCHEMA_VERSION_5 = 5;
|
|
47
|
+
/** v6: the list index's columns, key table and indexes (DDL only). */
|
|
48
|
+
export declare const SCHEMA_VERSION_6 = 6;
|
|
47
49
|
/** Target version for new databases. */
|
|
48
|
-
export declare const CURRENT_SCHEMA_VERSION =
|
|
50
|
+
export declare const CURRENT_SCHEMA_VERSION = 6;
|
|
49
51
|
/**
|
|
50
52
|
* Advisory lock key for the migration chain. Arbitrary but stable 64-bit
|
|
51
53
|
* value, derived from ASCII "STGMR1" — collisions with other advisory-lock
|
|
@@ -54,11 +56,13 @@ export declare const CURRENT_SCHEMA_VERSION = 5;
|
|
|
54
56
|
*/
|
|
55
57
|
export declare const MIGRATION_LOCK_KEY = 91621438607921n;
|
|
56
58
|
/**
|
|
57
|
-
* Applies
|
|
58
|
-
*
|
|
59
|
-
*
|
|
59
|
+
* Applies every pending migration up to `targetVersion` in order — all of
|
|
60
|
+
* them unless a test builds the database a given step starts from —
|
|
61
|
+
* serialized across instances by the advisory lock. Runs on a dedicated
|
|
62
|
+
* client (locks are session-scoped; a pool query could release on a
|
|
63
|
+
* different session).
|
|
60
64
|
*/
|
|
61
|
-
export declare function runMigrations(client: PoolClient): Promise<void>;
|
|
65
|
+
export declare function runMigrations(client: PoolClient, targetVersion?: number): Promise<void>;
|
|
62
66
|
/** Current schema version; 0 when none has been recorded yet. */
|
|
63
67
|
export declare function getSchemaVersion(client: PoolClient): Promise<number>;
|
|
64
68
|
//# sourceMappingURL=migrations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../../src/store/postgres/migrations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAOrC,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAClC,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAClC,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAClC,wDAAwD;AACxD,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAClC,8EAA8E;AAC9E,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAElC,wCAAwC;AACxC,eAAO,MAAM,sBAAsB,IAAmB,CAAC;AAEvD;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,kBAAkB,CAAC;AAElD
|
|
1
|
+
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../../src/store/postgres/migrations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAOrC,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAClC,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAClC,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAClC,wDAAwD;AACxD,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAClC,8EAA8E;AAC9E,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAClC,sEAAsE;AACtE,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAElC,wCAAwC;AACxC,eAAO,MAAM,sBAAsB,IAAmB,CAAC;AAEvD;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,kBAAkB,CAAC;AAElD;;;;;;GAMG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,UAAU,EAClB,aAAa,GAAE,MAA+B,GAC7C,OAAO,CAAC,IAAI,CAAC,CA+Bf;AAED,iEAAiE;AACjE,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAK1E"}
|
|
@@ -6,8 +6,10 @@ export const SCHEMA_VERSION_3 = 3;
|
|
|
6
6
|
export const SCHEMA_VERSION_4 = 4;
|
|
7
7
|
/** v5: every row holding the retired public visibility level moved to org. */
|
|
8
8
|
export const SCHEMA_VERSION_5 = 5;
|
|
9
|
+
/** v6: the list index's columns, key table and indexes (DDL only). */
|
|
10
|
+
export const SCHEMA_VERSION_6 = 6;
|
|
9
11
|
/** Target version for new databases. */
|
|
10
|
-
export const CURRENT_SCHEMA_VERSION =
|
|
12
|
+
export const CURRENT_SCHEMA_VERSION = SCHEMA_VERSION_6;
|
|
11
13
|
/**
|
|
12
14
|
* Advisory lock key for the migration chain. Arbitrary but stable 64-bit
|
|
13
15
|
* value, derived from ASCII "STGMR1" — collisions with other advisory-lock
|
|
@@ -16,11 +18,13 @@ export const CURRENT_SCHEMA_VERSION = SCHEMA_VERSION_5;
|
|
|
16
18
|
*/
|
|
17
19
|
export const MIGRATION_LOCK_KEY = 0x5354474d5231n;
|
|
18
20
|
/**
|
|
19
|
-
* Applies
|
|
20
|
-
*
|
|
21
|
-
*
|
|
21
|
+
* Applies every pending migration up to `targetVersion` in order — all of
|
|
22
|
+
* them unless a test builds the database a given step starts from —
|
|
23
|
+
* serialized across instances by the advisory lock. Runs on a dedicated
|
|
24
|
+
* client (locks are session-scoped; a pool query could release on a
|
|
25
|
+
* different session).
|
|
22
26
|
*/
|
|
23
|
-
export async function runMigrations(client) {
|
|
27
|
+
export async function runMigrations(client, targetVersion = CURRENT_SCHEMA_VERSION) {
|
|
24
28
|
await client.query("SELECT pg_advisory_lock($1)", [MIGRATION_LOCK_KEY]);
|
|
25
29
|
try {
|
|
26
30
|
await client.query(`
|
|
@@ -36,9 +40,10 @@ export async function runMigrations(client) {
|
|
|
36
40
|
[SCHEMA_VERSION_3, migrateToV3],
|
|
37
41
|
[SCHEMA_VERSION_4, migrateToV4],
|
|
38
42
|
[SCHEMA_VERSION_5, migrateToV5],
|
|
43
|
+
[SCHEMA_VERSION_6, migrateToV6],
|
|
39
44
|
];
|
|
40
45
|
for (const [version, migrate] of chain) {
|
|
41
|
-
if (currentVersion < version) {
|
|
46
|
+
if (currentVersion < version && version <= targetVersion) {
|
|
42
47
|
await applyInTransaction(client, version, migrate);
|
|
43
48
|
}
|
|
44
49
|
}
|
|
@@ -291,4 +296,57 @@ async function migrateToV5(client) {
|
|
|
291
296
|
}
|
|
292
297
|
}
|
|
293
298
|
}
|
|
299
|
+
/**
|
|
300
|
+
* v6: the list index (../list-index.ts) — schema only. Every existing row
|
|
301
|
+
* arrives with its stamp NULL, which makes it unproven, so the store's
|
|
302
|
+
* reconciliation at open derives its facts with the code that runs and
|
|
303
|
+
* reads stay exact until it has; a migration that decoded rows here would
|
|
304
|
+
* freeze today's declarations into the chain (the v5 step freezes its
|
|
305
|
+
* kind table for the same reason, public-visibility-retired.ts).
|
|
306
|
+
*
|
|
307
|
+
* - `list_org` and `list_created_at` are the order's inputs, byte-collated
|
|
308
|
+
* (`COLLATE "C"`) so the database sorts them the way list-index.ts
|
|
309
|
+
* compares them when it merges unproven rows in; `id` is compared under
|
|
310
|
+
* the same collation in the index expressions and the queries.
|
|
311
|
+
* - `list_index_revision` is the declaration revision the facts were
|
|
312
|
+
* derived under; `list_indexed_at` is the `updated_at` they were derived
|
|
313
|
+
* from. A writer that does not know these columns leaves them behind as
|
|
314
|
+
* it bumps `updated_at`, which is exactly what marks its row unproven.
|
|
315
|
+
* - `resource_list_keys` holds one row per (resource, key) with the
|
|
316
|
+
* creation instant copied in, so a parent's rows are one range of one
|
|
317
|
+
* index. It carries no foreign key: every indexed read joins
|
|
318
|
+
* `resources`, so a key row whose resource is gone matches nothing.
|
|
319
|
+
* - The partial index holds only unproven rows (none in steady state), so
|
|
320
|
+
* finding them is never a scan of the kind.
|
|
321
|
+
*/
|
|
322
|
+
async function migrateToV6(client) {
|
|
323
|
+
await client.query(`
|
|
324
|
+
ALTER TABLE resources
|
|
325
|
+
ADD COLUMN list_org TEXT COLLATE "C",
|
|
326
|
+
ADD COLUMN list_created_at TEXT COLLATE "C",
|
|
327
|
+
ADD COLUMN list_index_revision INTEGER,
|
|
328
|
+
ADD COLUMN list_indexed_at timestamptz;
|
|
329
|
+
|
|
330
|
+
CREATE INDEX idx_resources_list_org
|
|
331
|
+
ON resources (kind, list_org, list_created_at, (id COLLATE "C"));
|
|
332
|
+
CREATE INDEX idx_resources_list_created
|
|
333
|
+
ON resources (kind, list_created_at, (id COLLATE "C"));
|
|
334
|
+
CREATE INDEX idx_resources_list_revision
|
|
335
|
+
ON resources (kind, list_index_revision);
|
|
336
|
+
CREATE INDEX idx_resources_list_unproven
|
|
337
|
+
ON resources (kind, id) WHERE list_indexed_at IS DISTINCT FROM updated_at;
|
|
338
|
+
|
|
339
|
+
CREATE TABLE resource_list_keys (
|
|
340
|
+
kind TEXT NOT NULL,
|
|
341
|
+
id TEXT NOT NULL,
|
|
342
|
+
key TEXT NOT NULL,
|
|
343
|
+
value TEXT NOT NULL,
|
|
344
|
+
created_at TEXT COLLATE "C" NOT NULL,
|
|
345
|
+
PRIMARY KEY (kind, id, key)
|
|
346
|
+
);
|
|
347
|
+
|
|
348
|
+
CREATE INDEX idx_resource_list_keys_lookup
|
|
349
|
+
ON resource_list_keys (kind, key, value, created_at, (id COLLATE "C"));
|
|
350
|
+
`);
|
|
351
|
+
}
|
|
294
352
|
//# sourceMappingURL=migrations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrations.js","sourceRoot":"","sources":["../../../src/store/postgres/migrations.ts"],"names":[],"mappings":"AAwCA,OAAO,EACL,8BAA8B,EAC9B,kBAAkB,GACnB,MAAM,iCAAiC,CAAC;AAEzC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAClC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAClC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAClC,wDAAwD;AACxD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAClC,8EAA8E;AAC9E,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAElC,wCAAwC;AACxC,MAAM,CAAC,MAAM,sBAAsB,GAAG,gBAAgB,CAAC;AAEvD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,eAAe,CAAC;AAElD
|
|
1
|
+
{"version":3,"file":"migrations.js","sourceRoot":"","sources":["../../../src/store/postgres/migrations.ts"],"names":[],"mappings":"AAwCA,OAAO,EACL,8BAA8B,EAC9B,kBAAkB,GACnB,MAAM,iCAAiC,CAAC;AAEzC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAClC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAClC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAClC,wDAAwD;AACxD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAClC,8EAA8E;AAC9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CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BlB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { DescMessage, MessageShape } from "@bufbuild/protobuf";
|
|
2
2
|
import type { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
|
|
3
|
-
import type { AuditRecord, BootstrapStateStore, OAuthGrantStore, PendingOAuthStateStore, RawResourceDocument, ScheduleRunRecord, SearchIndexEntry, SearchIndexQuery, SearchIndexQueryResult, SignalDedupeStore, Store, WorkflowExecutionEventRecord } from "../interface.js";
|
|
3
|
+
import type { AuditRecord, BootstrapStateStore, OAuthGrantStore, PendingOAuthStateStore, RawResourceDocument, ScheduleRunRecord, SearchIndexEntry, SearchIndexQuery, SearchIndexQueryResult, SignalDedupeStore, Store, StoreOpenOptions, WorkflowExecutionEventRecord } from "../interface.js";
|
|
4
|
+
import type { ListIndexDeclaration, ListIndexQuery, ListIndexRow } from "../list-index.js";
|
|
4
5
|
import type { StoreLogger } from "../logger.js";
|
|
5
6
|
export declare class PostgresStore implements Store {
|
|
6
7
|
readonly bootstrapState: BootstrapStateStore;
|
|
@@ -9,18 +10,23 @@ export declare class PostgresStore implements Store {
|
|
|
9
10
|
readonly pendingOAuthStates: PendingOAuthStateStore;
|
|
10
11
|
private pool;
|
|
11
12
|
private readonly logger;
|
|
13
|
+
private readonly listIndexes;
|
|
12
14
|
private constructor();
|
|
13
15
|
/**
|
|
14
16
|
* Connects to databaseUrl, runs migrations (advisory-locked, so
|
|
15
|
-
* concurrent boots serialize),
|
|
16
|
-
*
|
|
17
|
-
*
|
|
17
|
+
* concurrent boots serialize), reconciles the list index (derives the
|
|
18
|
+
* facts of every unproven row of a declared kind; compare-and-set, so
|
|
19
|
+
* replicas opening together cannot conflict), and returns the ready
|
|
20
|
+
* store. Any failure here is a loud boot throw — never a degraded server
|
|
21
|
+
* (the same posture as SqliteStore.open; the composition root does not
|
|
22
|
+
* catch it).
|
|
18
23
|
*/
|
|
19
|
-
static open(databaseUrl: string, logger?: StoreLogger): Promise<PostgresStore>;
|
|
24
|
+
static open(databaseUrl: string, logger?: StoreLogger, options?: StoreOpenOptions): Promise<PostgresStore>;
|
|
20
25
|
saveResource<Desc extends DescMessage>(kind: ApiResourceKind, id: string, schema: Desc, msg: MessageShape<Desc>): Promise<void>;
|
|
21
26
|
getResource<Desc extends DescMessage>(kind: ApiResourceKind, id: string, schema: Desc): Promise<MessageShape<Desc>>;
|
|
22
27
|
updateResource<Desc extends DescMessage>(kind: ApiResourceKind, id: string, schema: Desc, modify: (msg: MessageShape<Desc>) => void): Promise<MessageShape<Desc>>;
|
|
23
28
|
listResources(kind: ApiResourceKind): Promise<Uint8Array[]>;
|
|
29
|
+
queryResources<K extends string>(declaration: ListIndexDeclaration<K>, query: ListIndexQuery<K>): Promise<ListIndexRow[]>;
|
|
24
30
|
deleteResource(kind: ApiResourceKind, id: string): Promise<void>;
|
|
25
31
|
findByField<Desc extends DescMessage>(kind: ApiResourceKind, fieldPath: string, value: string, schema: Desc): Promise<MessageShape<Desc>>;
|
|
26
32
|
findAllByField(kind: ApiResourceKind, fieldPath: string, value: string): Promise<Uint8Array[]>;
|
|
@@ -29,6 +35,21 @@ export declare class PostgresStore implements Store {
|
|
|
29
35
|
replaceResourceDataIfUnchanged(kind: ApiResourceKind, id: string, expectedData: Uint8Array, newData: Uint8Array): Promise<boolean>;
|
|
30
36
|
deleteResourcesByKind(kind: ApiResourceKind): Promise<number>;
|
|
31
37
|
deleteResourcesByIdPrefix(kind: ApiResourceKind, idPrefix: string): Promise<number>;
|
|
38
|
+
/**
|
|
39
|
+
* An unproven row's facts, derived from its bytes, and the row repaired
|
|
40
|
+
* when those bytes are still the stored ones — the compare-and-set on
|
|
41
|
+
* `data` means a newer write is never overwritten, and two replicas
|
|
42
|
+
* repairing one row write the same facts. Undefined when the bytes do
|
|
43
|
+
* not decode; the row stays unproven and is skipped, as a lane skips it.
|
|
44
|
+
*/
|
|
45
|
+
private deriveAndRepair;
|
|
46
|
+
/**
|
|
47
|
+
* Derives every unproven row of each declared kind, in id-keyed batches,
|
|
48
|
+
* and stamps every other kind's unstamped rows (they carry no facts), so
|
|
49
|
+
* the unproven set is empty when the server starts serving. Reads stay
|
|
50
|
+
* exact without it; it keeps them cheap.
|
|
51
|
+
*/
|
|
52
|
+
private reconcileListIndexes;
|
|
32
53
|
saveAudit<Desc extends DescMessage>(kind: ApiResourceKind, resourceId: string, schema: Desc, msg: MessageShape<Desc>, versionHash: string, tag: string): Promise<void>;
|
|
33
54
|
getAuditByHash<Desc extends DescMessage>(kind: ApiResourceKind, resourceId: string, versionHash: string, schema: Desc): Promise<MessageShape<Desc>>;
|
|
34
55
|
getAuditByTag<Desc extends DescMessage>(kind: ApiResourceKind, resourceId: string, tag: string, schema: Desc): Promise<MessageShape<Desc>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../src/store/postgres/store.ts"],"names":[],"mappings":"AAoCA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qFAAqF,CAAC;AAQ3H,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EAGnB,eAAe,EAEf,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAEhB,gBAAgB,EAChB,sBAAsB,EAGtB,iBAAiB,EACjB,KAAK,EACL,4BAA4B,EAC7B,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../src/store/postgres/store.ts"],"names":[],"mappings":"AAoCA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qFAAqF,CAAC;AAQ3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