@opendatalabs/personal-server-ts-core 1.31.0 → 1.33.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 (45) hide show
  1. package/dist/additions/first-added.d.ts +203 -0
  2. package/dist/additions/first-added.d.ts.map +1 -0
  3. package/dist/additions/first-added.js +647 -0
  4. package/dist/additions/first-added.js.map +1 -0
  5. package/dist/additions/index.d.ts +6 -0
  6. package/dist/additions/index.d.ts.map +1 -0
  7. package/dist/additions/index.js +6 -0
  8. package/dist/additions/index.js.map +1 -0
  9. package/dist/additions/ledger-store.d.ts +69 -0
  10. package/dist/additions/ledger-store.d.ts.map +1 -0
  11. package/dist/additions/ledger-store.js +343 -0
  12. package/dist/additions/ledger-store.js.map +1 -0
  13. package/dist/additions/record-rules.d.ts +54 -0
  14. package/dist/additions/record-rules.d.ts.map +1 -0
  15. package/dist/additions/record-rules.js +191 -0
  16. package/dist/additions/record-rules.js.map +1 -0
  17. package/dist/additions/scope-lock.d.ts +14 -0
  18. package/dist/additions/scope-lock.d.ts.map +1 -0
  19. package/dist/additions/scope-lock.js +32 -0
  20. package/dist/additions/scope-lock.js.map +1 -0
  21. package/dist/additions/summary.d.ts +48 -0
  22. package/dist/additions/summary.d.ts.map +1 -0
  23. package/dist/additions/summary.js +101 -0
  24. package/dist/additions/summary.js.map +1 -0
  25. package/dist/api/index.d.ts.map +1 -1
  26. package/dist/api/index.js +26 -0
  27. package/dist/api/index.js.map +1 -1
  28. package/dist/contracts/data.d.ts +19 -1
  29. package/dist/contracts/data.d.ts.map +1 -1
  30. package/dist/contracts/data.js +95 -23
  31. package/dist/contracts/data.js.map +1 -1
  32. package/dist/mcp/connection-api.d.ts +25 -0
  33. package/dist/mcp/connection-api.d.ts.map +1 -1
  34. package/dist/mcp/connection-api.js +43 -4
  35. package/dist/mcp/connection-api.js.map +1 -1
  36. package/dist/ports/index.d.ts +11 -0
  37. package/dist/ports/index.d.ts.map +1 -1
  38. package/dist/ports/index.js.map +1 -1
  39. package/dist/sync/workers/download.d.ts.map +1 -1
  40. package/dist/sync/workers/download.js +19 -0
  41. package/dist/sync/workers/download.js.map +1 -1
  42. package/dist/test-utils/memory-storage.d.ts.map +1 -1
  43. package/dist/test-utils/memory-storage.js +47 -9
  44. package/dist/test-utils/memory-storage.js.map +1 -1
  45. package/package.json +5 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"first-added.js","sourceRoot":"","sources":["../../src/additions/first-added.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,oBAAoB,EAAyB,MAAM,mBAAmB,CAAC;AAEhF;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAC;AACxC,wEAAwE;AACxE,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,CAAC;AAChC,gGAAgG;AAChG,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,CAAC;AACxC,kFAAkF;AAClF,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AACvD,8DAA8D;AAC9D,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAClD,sEAAsE;AACtE,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AACrC,4DAA4D;AAC5D,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,CAAC;AAEjC,uFAAuF;AACvF,MAAM,UAAU,gBAAgB;IAC9B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;AAC1D,CAAC;AAqED,2DAA2D;AAC3D,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAU,CAAC;AAEnE,kFAAkF;AAClF,MA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YAC9C,OAAO,EAAE,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC;SACpC,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,6 @@
1
+ export * from "./first-added.js";
2
+ export * from "./record-rules.js";
3
+ export * from "./summary.js";
4
+ export * from "./ledger-store.js";
5
+ export * from "./scope-lock.js";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/additions/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,6 @@
1
+ export * from "./first-added.js";
2
+ export * from "./record-rules.js";
3
+ export * from "./summary.js";
4
+ export * from "./ledger-store.js";
5
+ export * from "./scope-lock.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/additions/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Keeps a scope's first-seen sidecar current. See `first-added.ts` for the
3
+ * ledger itself; this module is the only code that reads and writes it.
4
+ *
5
+ * The sidecar is a cache derived from the scope's stored versions, so every
6
+ * failure here is survivable: a missing or unreadable sidecar is rebuilt from
7
+ * the retained versions the next time the owner asks for it.
8
+ *
9
+ * Cost rules:
10
+ * - The WRITE path (`recordStoredVersion`: JSON ingest, binary ingest, sync
11
+ * download) never reads a stored envelope. It folds ONLY the version
12
+ * already in memory: into an existing sidecar, or into a new one when it
13
+ * is the scope's only version; otherwise it leaves the sidecar absent.
14
+ * Whatever it did not cover stays visible to the owner's read: the
15
+ * ledger's `through` marker only advances over versions that were folded.
16
+ * - The owner's `/additions` read (`ensureScopeLedger`) does all the
17
+ * catching up and rebuilding. It folds ONE version at a time, at most the
18
+ * newest `REBUILD_VERSION_LIMIT` versions and `REBUILD_BYTE_BUDGET` bytes
19
+ * of envelopes (index `sizeBytes`), oldest folded first, yielding to the
20
+ * event loop between versions. A scope whose rules track nothing is not
21
+ * read at all.
22
+ * - Negative outcomes (too large, nothing readable) are persisted as a ledger
23
+ * with a `skipped` reason, so they are not retried on every request. A
24
+ * single unreadable version is remembered in the ledger's `retry` list and
25
+ * read again at most once per hour; in between nothing is read.
26
+ *
27
+ * Guarantee, in order of strength:
28
+ * 1. Updates and deletions of one scope are serialized inside this process
29
+ * (`withScopeLock`), and after a write the sidecar is removed again if the
30
+ * scope has no versions left, so a delete racing a rebuild leaves nothing.
31
+ * 2. Across processes sharing one data directory a fold can still be lost.
32
+ * A lost version newer than the sidecar's `through` marker is repaired by
33
+ * the next `/additions` read.
34
+ * 3. A lost version at or before `through` is repaired only by a rebuild
35
+ * (delete the sidecar, or reimport).
36
+ * 4. A sidecar whose `latest` version no longer exists (it was deleted) is
37
+ * discarded and rebuilt.
38
+ */
39
+ import type { DataStoragePort } from "../ports/index.js";
40
+ import { type ScopeFirstSeenLedger, type VersionToFold } from "./first-added.js";
41
+ /** Most recent retained versions considered when a sidecar is rebuilt or caught up. */
42
+ export declare const REBUILD_VERSION_LIMIT = 200;
43
+ /** Envelope bytes (from the index) read for one scope in one rebuild or catch-up. */
44
+ export declare const REBUILD_BYTE_BUDGET: number;
45
+ export interface LedgerStoreOptions {
46
+ /** Override `REBUILD_BYTE_BUDGET`. */
47
+ byteBudget?: number;
48
+ /**
49
+ * The caller's clock, used to space the retries of unreadable versions.
50
+ * Defaults to the current time.
51
+ */
52
+ now?: Date;
53
+ }
54
+ /**
55
+ * Fold a version that was just stored AND indexed into the scope's sidecar.
56
+ * Best-effort and cheap: any failure is swallowed (the write that triggered
57
+ * it stays successful), and it never rebuilds. `data` is the envelope data
58
+ * already in memory, so the previous version is never re-read.
59
+ */
60
+ export declare function recordStoredVersion(storage: DataStoragePort, version: VersionToFold): Promise<void>;
61
+ /**
62
+ * The scope's ledger for a read: the stored sidecar (caught up with any newer
63
+ * retained version it missed), or a bounded rebuild from the retained versions
64
+ * that is persisted when the storage can hold it. Null when the scope has no
65
+ * version. This is the one place a read path may parse stored envelopes, and
66
+ * only when the sidecar is absent, stale or behind.
67
+ */
68
+ export declare function ensureScopeLedger(storage: DataStoragePort, scope: string, options?: LedgerStoreOptions): Promise<ScopeFirstSeenLedger | null>;
69
+ //# sourceMappingURL=ledger-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ledger-store.d.ts","sourceRoot":"","sources":["../../src/additions/ledger-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,EAML,KAAK,oBAAoB,EACzB,KAAK,aAAa,EACnB,MAAM,kBAAkB,CAAC;AAI1B,uFAAuF;AACvF,eAAO,MAAM,qBAAqB,MAAM,CAAC;AACzC,qFAAqF;AACrF,eAAO,MAAM,mBAAmB,QAAoB,CAAC;AAErD,MAAM,WAAW,kBAAkB;IACjC,sCAAsC;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,GAAG,CAAC,EAAE,IAAI,CAAC;CACZ;AAoRD;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,IAAI,CAAC,CA0Cf;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,eAAe,EACxB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAkCtC"}
@@ -0,0 +1,343 @@
1
+ /**
2
+ * Keeps a scope's first-seen sidecar current. See `first-added.ts` for the
3
+ * ledger itself; this module is the only code that reads and writes it.
4
+ *
5
+ * The sidecar is a cache derived from the scope's stored versions, so every
6
+ * failure here is survivable: a missing or unreadable sidecar is rebuilt from
7
+ * the retained versions the next time the owner asks for it.
8
+ *
9
+ * Cost rules:
10
+ * - The WRITE path (`recordStoredVersion`: JSON ingest, binary ingest, sync
11
+ * download) never reads a stored envelope. It folds ONLY the version
12
+ * already in memory: into an existing sidecar, or into a new one when it
13
+ * is the scope's only version; otherwise it leaves the sidecar absent.
14
+ * Whatever it did not cover stays visible to the owner's read: the
15
+ * ledger's `through` marker only advances over versions that were folded.
16
+ * - The owner's `/additions` read (`ensureScopeLedger`) does all the
17
+ * catching up and rebuilding. It folds ONE version at a time, at most the
18
+ * newest `REBUILD_VERSION_LIMIT` versions and `REBUILD_BYTE_BUDGET` bytes
19
+ * of envelopes (index `sizeBytes`), oldest folded first, yielding to the
20
+ * event loop between versions. A scope whose rules track nothing is not
21
+ * read at all.
22
+ * - Negative outcomes (too large, nothing readable) are persisted as a ledger
23
+ * with a `skipped` reason, so they are not retried on every request. A
24
+ * single unreadable version is remembered in the ledger's `retry` list and
25
+ * read again at most once per hour; in between nothing is read.
26
+ *
27
+ * Guarantee, in order of strength:
28
+ * 1. Updates and deletions of one scope are serialized inside this process
29
+ * (`withScopeLock`), and after a write the sidecar is removed again if the
30
+ * scope has no versions left, so a delete racing a rebuild leaves nothing.
31
+ * 2. Across processes sharing one data directory a fold can still be lost.
32
+ * A lost version newer than the sidecar's `through` marker is repaired by
33
+ * the next `/additions` read.
34
+ * 3. A lost version at or before `through` is repaired only by a rebuild
35
+ * (delete the sidecar, or reimport).
36
+ * 4. A sidecar whose `latest` version no longer exists (it was deleted) is
37
+ * discarded and rebuilt.
38
+ */
39
+ import { LedgerFold, MAX_RETRY_VERSIONS, RETRY_UNREADABLE_MS, readScopeFirstSeenLedger, yieldToEventLoop, } from "./first-added.js";
40
+ import { memoryRecordRulesFor } from "./record-rules.js";
41
+ import { withScopeLock } from "./scope-lock.js";
42
+ /** Most recent retained versions considered when a sidecar is rebuilt or caught up. */
43
+ export const REBUILD_VERSION_LIMIT = 200;
44
+ /** Envelope bytes (from the index) read for one scope in one rebuild or catch-up. */
45
+ export const REBUILD_BYTE_BUDGET = 256 * 1024 * 1024;
46
+ function isRecord(value) {
47
+ return value !== null && typeof value === "object" && !Array.isArray(value);
48
+ }
49
+ /** A scope whose rules track nothing: no envelope has to be read to fold it. */
50
+ function readsNothing(scope) {
51
+ return memoryRecordRulesFor(scope)?.length === 0;
52
+ }
53
+ /** The envelope data as stored (never the read-time view), or null if unreadable. */
54
+ async function readVersionData(storage, scope, collectedAt) {
55
+ if (readsNothing(scope))
56
+ return { scope, collectedAt, data: {} };
57
+ try {
58
+ // Called as methods of `storage`, never detached, to keep `this` bound.
59
+ const envelope = storage.readStoredEnvelope
60
+ ? await storage.readStoredEnvelope(scope, collectedAt)
61
+ : await storage.readEnvelope(scope, collectedAt);
62
+ if (!isRecord(envelope.data))
63
+ return null;
64
+ return { scope, collectedAt, data: envelope.data };
65
+ }
66
+ catch {
67
+ return null;
68
+ }
69
+ }
70
+ /** Retained versions, newest first by instant. */
71
+ function retainedVersions(storage, scope) {
72
+ return storage
73
+ .listVersions(scope, { limit: REBUILD_VERSION_LIMIT })
74
+ .filter((entry) => !Number.isNaN(Date.parse(entry.collectedAt)))
75
+ .sort((a, b) => Date.parse(b.collectedAt) - Date.parse(a.collectedAt) ||
76
+ (a.collectedAt < b.collectedAt
77
+ ? 1
78
+ : a.collectedAt > b.collectedAt
79
+ ? -1
80
+ : 0));
81
+ }
82
+ /**
83
+ * The newest prefix of `entries` (newest first) whose index sizes fit the
84
+ * budget. A scope that reads nothing is never limited.
85
+ */
86
+ function withinBudget(scope, entries, budget) {
87
+ if (readsNothing(scope))
88
+ return [...entries];
89
+ const selected = [];
90
+ let used = 0;
91
+ for (const entry of entries) {
92
+ used += Math.max(0, entry.sizeBytes ?? 0);
93
+ if (used > budget)
94
+ break;
95
+ selected.push(entry);
96
+ }
97
+ return selected;
98
+ }
99
+ async function readStoredLedger(storage, scope) {
100
+ if (!storage.readFirstSeenLedger)
101
+ return null;
102
+ try {
103
+ const ledger = readScopeFirstSeenLedger(await storage.readFirstSeenLedger(scope));
104
+ return ledger !== null && ledger.scope === scope ? ledger : null;
105
+ }
106
+ catch {
107
+ // An unreadable sidecar is rebuilt, never trusted and never fatal.
108
+ return null;
109
+ }
110
+ }
111
+ /** Remove the sidecar of a scope that no longer has any version. */
112
+ async function dropIfScopeEmpty(storage, scope) {
113
+ if (storage.findEntry({ scope }))
114
+ return false;
115
+ await storage.deleteFirstSeenLedger?.(scope);
116
+ return true;
117
+ }
118
+ /** Whether the version the ledger calls its `latest` is still stored (a direct lookup, not a window). */
119
+ function latestStillStored(storage, ledger) {
120
+ return (storage.findEntry({ scope: ledger.scope, at: ledger.latest.collectedAt })
121
+ ?.collectedAt === ledger.latest.collectedAt);
122
+ }
123
+ function isMarker(ledger) {
124
+ return ledger.skipped === "too_large" || ledger.skipped === "unreadable";
125
+ }
126
+ function newerThan(retained, ledger) {
127
+ const throughMs = Date.parse(ledger.through);
128
+ return retained.filter((entry) => Date.parse(entry.collectedAt) > throughMs);
129
+ }
130
+ /**
131
+ * Fold `entries` (newest first) into `fold`, oldest first, one envelope at a
132
+ * time. Returns how many were folded and the entries that could not be read.
133
+ */
134
+ async function foldEntries(storage, scope, entries, fold) {
135
+ let folded = 0;
136
+ const failed = [];
137
+ for (const entry of [...entries].reverse()) {
138
+ const version = await readVersionData(storage, scope, entry.collectedAt);
139
+ if (version) {
140
+ await fold.add(version);
141
+ folded += 1;
142
+ }
143
+ else {
144
+ failed.push(entry);
145
+ }
146
+ await yieldToEventLoop();
147
+ }
148
+ return { folded, failed };
149
+ }
150
+ /** The retry record for versions that could not be read, or null when there are none. */
151
+ function retryOf(failed, now) {
152
+ if (failed.length === 0)
153
+ return null;
154
+ return {
155
+ versions: failed
156
+ .slice(0, MAX_RETRY_VERSIONS)
157
+ .map((entry) => entry.collectedAt),
158
+ attemptedAt: now.toISOString(),
159
+ };
160
+ }
161
+ /**
162
+ * Rebuild a ledger from the scope's retained versions (see the cost rules in
163
+ * the header). `partial` marks a ledger that covers only part of the
164
+ * history, so its baseline is the oldest version actually folded.
165
+ */
166
+ async function rebuild(storage, scope, retained, budget, now) {
167
+ if (retained.length === 0)
168
+ return null;
169
+ const selected = withinBudget(scope, retained, budget);
170
+ const fold = new LedgerFold(null, scope);
171
+ const { folded, failed } = await foldEntries(storage, scope, selected, fold);
172
+ if (folded === 0) {
173
+ // Persisted so the next request does not repeat the failed work.
174
+ return {
175
+ version: 3,
176
+ scope,
177
+ baseline: null,
178
+ current: null,
179
+ latest: { collectedAt: retained[0].collectedAt, total: 0 },
180
+ through: retained[0].collectedAt,
181
+ skipped: selected.length === 0 ? "too_large" : "unreadable",
182
+ records: {},
183
+ };
184
+ }
185
+ const total = storage.countVersions(scope);
186
+ return fold.finish({
187
+ partial: folded < total,
188
+ through: retained[0].collectedAt,
189
+ retry: retryOf(failed, now),
190
+ });
191
+ }
192
+ /**
193
+ * Catch a ledger up for the owner's read. New versions (newer than `through`)
194
+ * are folded; a version that cannot be read is remembered in `retry` and
195
+ * tried again at most once per `RETRY_UNREADABLE_MS`. When nothing is new and
196
+ * no retry is due, nothing is read at all.
197
+ */
198
+ async function catchUp(storage, ledger, retained, budget, now) {
199
+ const newer = newerThan(retained, ledger);
200
+ const selected = withinBudget(ledger.scope, newer, budget);
201
+ // Unreadable versions still stored; the deleted ones are forgotten.
202
+ const pending = (ledger.retry?.versions ?? []).filter((version) => retained.some((entry) => entry.collectedAt === version));
203
+ const due = ledger.retry !== undefined &&
204
+ pending.length > 0 &&
205
+ now.getTime() - Date.parse(ledger.retry.attemptedAt) >= RETRY_UNREADABLE_MS;
206
+ const retryEntries = due
207
+ ? withinBudget(ledger.scope, retained.filter((entry) => pending.includes(entry.collectedAt)), budget)
208
+ : [];
209
+ const forgotten = pending.length !== (ledger.retry?.versions.length ?? 0);
210
+ if (selected.length === 0 && retryEntries.length === 0 && !forgotten) {
211
+ return ledger;
212
+ }
213
+ const fold = new LedgerFold(ledger);
214
+ const failedNew = selected.length > 0
215
+ ? (await foldEntries(storage, ledger.scope, selected, fold)).failed
216
+ : [];
217
+ const failedRetry = retryEntries.length > 0
218
+ ? (await foldEntries(storage, ledger.scope, retryEntries, fold)).failed
219
+ : [];
220
+ const stillFailing = due
221
+ ? failedRetry.map((entry) => entry.collectedAt)
222
+ : pending;
223
+ const versions = [
224
+ ...stillFailing,
225
+ ...failedNew.map((entry) => entry.collectedAt),
226
+ ].slice(0, MAX_RETRY_VERSIONS);
227
+ const attempted = due || failedNew.length > 0;
228
+ const retry = versions.length === 0
229
+ ? null
230
+ : {
231
+ versions,
232
+ attemptedAt: attempted
233
+ ? now.toISOString()
234
+ : ledger.retry.attemptedAt,
235
+ };
236
+ // Only a window cut (more versions than the index window shows) or the
237
+ // byte budget leaves new versions unfolded.
238
+ const beyond = storage.listVersions(ledger.scope, {
239
+ limit: 1,
240
+ offset: retained.length,
241
+ })[0];
242
+ const windowCut = beyond !== undefined &&
243
+ Date.parse(beyond.collectedAt) > Date.parse(ledger.through);
244
+ return ((await fold.finish({
245
+ partial: windowCut || selected.length < newer.length,
246
+ through: selected.length > 0 ? retained[0].collectedAt : ledger.through,
247
+ retry,
248
+ })) ?? ledger);
249
+ }
250
+ /**
251
+ * Fold a version that was just stored AND indexed into the scope's sidecar.
252
+ * Best-effort and cheap: any failure is swallowed (the write that triggered
253
+ * it stays successful), and it never rebuilds. `data` is the envelope data
254
+ * already in memory, so the previous version is never re-read.
255
+ */
256
+ export async function recordStoredVersion(storage, version) {
257
+ if (!storage.readFirstSeenLedger || !storage.writeFirstSeenLedger)
258
+ return;
259
+ try {
260
+ await withScopeLock(version.scope, async () => {
261
+ const retained = retainedVersions(storage, version.scope);
262
+ let existing = await readStoredLedger(storage, version.scope);
263
+ if (existing && !latestStillStored(storage, existing)) {
264
+ // Its newest version is gone: what it reports is stale.
265
+ await storage.deleteFirstSeenLedger?.(version.scope);
266
+ existing = null;
267
+ }
268
+ const others = retained.filter((entry) => entry.collectedAt !== version.collectedAt);
269
+ let through = version.collectedAt;
270
+ if (existing) {
271
+ // A failed or oversized rebuild is retried by the owner's read.
272
+ if (isMarker(existing))
273
+ return;
274
+ const throughMs = Date.parse(existing.through);
275
+ const unfolded = others.some((entry) => Date.parse(entry.collectedAt) > throughMs);
276
+ // Versions this write did not fold keep the marker where it was.
277
+ through =
278
+ unfolded || Date.parse(version.collectedAt) < throughMs
279
+ ? existing.through
280
+ : version.collectedAt;
281
+ }
282
+ else if (others.length > 0) {
283
+ // Older versions exist but no sidecar: leave it for `/additions` to
284
+ // build, so a write never reads history.
285
+ return;
286
+ }
287
+ const fold = new LedgerFold(existing, version.scope);
288
+ await fold.add(version);
289
+ const next = await fold.finish({ through });
290
+ if (!next)
291
+ return;
292
+ await storage.writeFirstSeenLedger(version.scope, next);
293
+ await dropIfScopeEmpty(storage, version.scope);
294
+ });
295
+ }
296
+ catch {
297
+ // Derived data: rebuilt from the retained versions when next needed.
298
+ }
299
+ }
300
+ /**
301
+ * The scope's ledger for a read: the stored sidecar (caught up with any newer
302
+ * retained version it missed), or a bounded rebuild from the retained versions
303
+ * that is persisted when the storage can hold it. Null when the scope has no
304
+ * version. This is the one place a read path may parse stored envelopes, and
305
+ * only when the sidecar is absent, stale or behind.
306
+ */
307
+ export async function ensureScopeLedger(storage, scope, options = {}) {
308
+ const budget = options.byteBudget ?? REBUILD_BYTE_BUDGET;
309
+ const now = options.now ?? new Date();
310
+ return withScopeLock(scope, async () => {
311
+ try {
312
+ const retained = retainedVersions(storage, scope);
313
+ if (retained.length === 0) {
314
+ await storage.deleteFirstSeenLedger?.(scope);
315
+ return null;
316
+ }
317
+ let existing = await readStoredLedger(storage, scope);
318
+ if (existing &&
319
+ (!latestStillStored(storage, existing) ||
320
+ (isMarker(existing) && newerThan(retained, existing).length > 0))) {
321
+ existing = null;
322
+ }
323
+ const ledger = existing
324
+ ? await catchUp(storage, existing, retained, budget, now)
325
+ : await rebuild(storage, scope, retained, budget, now);
326
+ if (ledger && ledger !== existing && storage.writeFirstSeenLedger) {
327
+ try {
328
+ await storage.writeFirstSeenLedger(scope, ledger);
329
+ if (await dropIfScopeEmpty(storage, scope))
330
+ return null;
331
+ }
332
+ catch {
333
+ // Served from memory; the next read rebuilds it again.
334
+ }
335
+ }
336
+ return ledger;
337
+ }
338
+ catch {
339
+ return null;
340
+ }
341
+ });
342
+ }
343
+ //# sourceMappingURL=ledger-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ledger-store.js","sourceRoot":"","sources":["../../src/additions/ledger-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAIH,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACxB,gBAAgB,GAGjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,uFAAuF;AACvF,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AACzC,qFAAqF;AACrF,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;AAYrD,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,gFAAgF;AAChF,SAAS,YAAY,CAAC,KAAa;IACjC,OAAO,oBAAoB,CAAC,KAAK,CAAC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BACpC,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,EACnE,CAAC;gBACD,QAAQ,GAAG,IAAI,CAAC;YAClB,CAAC;YACD,MAAM,MAAM,GAAG,QAAQ;gBACrB,CAAC,CAAC,MAAM,OAAO,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,CAAC;gBACzD,CAAC,CAAC,MAAM,OAAO,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;YACzD,IAAI,MAAM,IAAI,MAAM,KAAK,QAAQ,IAAI,OAAO,CAAC,oBAAoB,EAAE,CAAC;gBAClE,IAAI,CAAC;oBACH,MAAM,OAAO,CAAC,oBAAoB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;oBAClD,IAAI,MAAM,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC;wBAAE,OAAO,IAAI,CAAC;gBAC1D,CAAC;gBAAC,MAAM,CAAC;oBACP,uDAAuD;gBACzD,CAAC;YACH,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,54 @@
1
+ /** One collection of a scope whose items are memory records. */
2
+ export interface MemoryRecordRule {
3
+ /** Canonical collection name; also the prefix of every record key. Top-level key in a legacy body. */
4
+ collection: string;
5
+ /**
6
+ * Other names the same collection is stored under: PDPP stream names or
7
+ * alternate legacy keys. In the stored PDPP rows form `{ records: [...] }`
8
+ * a scope's rows belong to the rule whose collection or alias is the
9
+ * scope's dataset name (the part after the first dot).
10
+ */
11
+ aliases?: readonly string[];
12
+ /**
13
+ * LEGACY keyed form: fields tried in order for the record's identity.
14
+ * Dotted paths allowed. Empty = the collection is counted but not tracked.
15
+ */
16
+ idFields: readonly string[];
17
+ /**
18
+ * ROWS form (stored PDPP `{ records: [...] }`): fields tried in order for
19
+ * the identity. Each is chosen so the legacy projection binding copies the
20
+ * value unchanged into the matching `idFields` field, so one record has
21
+ * the same key in both forms (proved per binding in
22
+ * `record-rules.parity.test.ts`). Empty = counted but not tracked.
23
+ */
24
+ rowIdFields: readonly string[];
25
+ /** Rows form: keep a row only when this field equals this value (a stream that feeds several collections). */
26
+ streamFilter?: {
27
+ field: string;
28
+ equals: string;
29
+ };
30
+ /**
31
+ * The scope is one record (a profile): counted as 1 when its body has any
32
+ * content (legacy form) or once per row (rows form), never tracked.
33
+ */
34
+ singleton?: true;
35
+ }
36
+ /**
37
+ * Scope -> its record collections. The server's `total` must agree with what
38
+ * the owner app counts, so a scope the app counts is never given an empty
39
+ * list; where identity is not provably stable it is counted but not tracked.
40
+ * An empty list means the owner app also counts 0 for the scope.
41
+ *
42
+ * Both stored forms of a scope must produce the same keys, so each rule names
43
+ * the id field per form. Where the projection binding keeps no field that is
44
+ * equal in both forms (linkedin.experience, linkedin.education: the legacy
45
+ * body drops the row id), the collection is untracked in both forms and only
46
+ * counts toward the total.
47
+ *
48
+ * Changing a rule's `collection` or id fields re-keys that scope's ledger, so
49
+ * its records would be dated as new until its sidecar is rebuilt.
50
+ */
51
+ export declare const MEMORY_RECORD_RULES: Readonly<Record<string, readonly MemoryRecordRule[]>>;
52
+ /** The rules for a scope, or null when the scope has no entry (generic default applies). */
53
+ export declare function memoryRecordRulesFor(scope: string): readonly MemoryRecordRule[] | null;
54
+ //# sourceMappingURL=record-rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record-rules.d.ts","sourceRoot":"","sources":["../../src/additions/record-rules.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,MAAM,WAAW,gBAAgB;IAC/B,sGAAsG;IACtG,UAAU,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B;;;OAGG;IACH,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B;;;;;;OAMG;IACH,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,8GAA8G;IAC9G,YAAY,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACjD;;;OAGG;IACH,SAAS,CAAC,EAAE,IAAI,CAAC;CAClB;AAiCD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CACxC,MAAM,CAAC,MAAM,EAAE,SAAS,gBAAgB,EAAE,CAAC,CAqJ5C,CAAC;AAEF,4FAA4F;AAC5F,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,GACZ,SAAS,gBAAgB,EAAE,GAAG,IAAI,CAKpC"}