@powerhousedao/reactor 4.1.0-dev.82 → 4.1.0-dev.83
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/src/cache/buffer/ring-buffer.d.ts +37 -0
- package/dist/src/cache/buffer/ring-buffer.d.ts.map +1 -0
- package/dist/src/cache/buffer/ring-buffer.js +69 -0
- package/dist/src/cache/buffer/ring-buffer.js.map +1 -0
- package/dist/src/cache/kysely-write-cache.d.ts +99 -0
- package/dist/src/cache/kysely-write-cache.d.ts.map +1 -0
- package/dist/src/cache/kysely-write-cache.js +309 -0
- package/dist/src/cache/kysely-write-cache.js.map +1 -0
- package/dist/src/cache/lru/lru-tracker.d.ts +15 -0
- package/dist/src/cache/lru/lru-tracker.d.ts.map +1 -0
- package/dist/src/cache/lru/lru-tracker.js +96 -0
- package/dist/src/cache/lru/lru-tracker.js.map +1 -0
- package/dist/src/cache/types.d.ts +42 -0
- package/dist/src/cache/types.d.ts.map +1 -0
- package/dist/src/cache/types.js +2 -0
- package/dist/src/cache/types.js.map +1 -0
- package/dist/src/cache/write/interfaces.d.ts +85 -0
- package/dist/src/cache/write/interfaces.d.ts.map +1 -0
- package/dist/src/cache/write/interfaces.js +2 -0
- package/dist/src/cache/write/interfaces.js.map +1 -0
- package/dist/src/executor/simple-job-executor.d.ts +0 -14
- package/dist/src/executor/simple-job-executor.d.ts.map +1 -1
- package/dist/src/executor/simple-job-executor.js +23 -43
- package/dist/src/executor/simple-job-executor.js.map +1 -1
- package/dist/src/executor/types.d.ts +6 -0
- package/dist/src/executor/types.d.ts.map +1 -1
- package/dist/src/executor/types.js.map +1 -1
- package/dist/src/executor/util.d.ts +16 -0
- package/dist/src/executor/util.d.ts.map +1 -0
- package/dist/src/executor/util.js +31 -0
- package/dist/src/executor/util.js.map +1 -0
- package/dist/src/index.d.ts +4 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/read-models/document-view.d.ts.map +1 -1
- package/dist/src/read-models/document-view.js +11 -9
- package/dist/src/read-models/document-view.js.map +1 -1
- package/dist/src/storage/interfaces.d.ts +13 -0
- package/dist/src/storage/interfaces.d.ts.map +1 -1
- package/dist/src/storage/interfaces.js.map +1 -1
- package/dist/src/storage/kysely/keyframe-store.d.ts +15 -0
- package/dist/src/storage/kysely/keyframe-store.d.ts.map +1 -0
- package/dist/src/storage/kysely/keyframe-store.js +71 -0
- package/dist/src/storage/kysely/keyframe-store.js.map +1 -0
- package/dist/src/storage/kysely/store.d.ts.map +1 -1
- package/dist/src/storage/kysely/store.js +0 -1
- package/dist/src/storage/kysely/store.js.map +1 -1
- package/dist/src/storage/kysely/types.d.ts +14 -1
- package/dist/src/storage/kysely/types.d.ts.map +1 -1
- package/dist/src/storage/txn.d.ts.map +1 -1
- package/dist/src/storage/txn.js +0 -1
- package/dist/src/storage/txn.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RingBuffer is a generic circular buffer implementation that stores a fixed number
|
|
3
|
+
* of items. When the buffer is full, new items overwrite the oldest items.
|
|
4
|
+
*
|
|
5
|
+
* This implementation maintains O(1) time complexity for push operations and provides
|
|
6
|
+
* items in chronological order (oldest to newest) via getAll().
|
|
7
|
+
*
|
|
8
|
+
* @template T - The type of items stored in the buffer
|
|
9
|
+
*/
|
|
10
|
+
export declare class RingBuffer<T> {
|
|
11
|
+
private buffer;
|
|
12
|
+
private head;
|
|
13
|
+
private size;
|
|
14
|
+
private capacity;
|
|
15
|
+
constructor(capacity: number);
|
|
16
|
+
/**
|
|
17
|
+
* Adds an item to the buffer. If the buffer is full, overwrites the oldest item.
|
|
18
|
+
*
|
|
19
|
+
* @param item - The item to add
|
|
20
|
+
*/
|
|
21
|
+
push(item: T): void;
|
|
22
|
+
/**
|
|
23
|
+
* Returns all items in the buffer in chronological order (oldest to newest).
|
|
24
|
+
*
|
|
25
|
+
* @returns Array of items in insertion order
|
|
26
|
+
*/
|
|
27
|
+
getAll(): T[];
|
|
28
|
+
/**
|
|
29
|
+
* Clears all items from the buffer.
|
|
30
|
+
*/
|
|
31
|
+
clear(): void;
|
|
32
|
+
/**
|
|
33
|
+
* Gets the current number of items in the buffer.
|
|
34
|
+
*/
|
|
35
|
+
get length(): number;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=ring-buffer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ring-buffer.d.ts","sourceRoot":"","sources":["../../../../src/cache/buffer/ring-buffer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,qBAAa,UAAU,CAAC,CAAC;IACvB,OAAO,CAAC,MAAM,CAAM;IACpB,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,QAAQ,CAAS;gBAEb,QAAQ,EAAE,MAAM;IAQ5B;;;;OAIG;IACH,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI;IAYnB;;;;OAIG;IACH,MAAM,IAAI,CAAC,EAAE;IAab;;OAEG;IACH,KAAK,IAAI,IAAI;IAMb;;OAEG;IACH,IAAI,MAAM,IAAI,MAAM,CAEnB;CACF"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RingBuffer is a generic circular buffer implementation that stores a fixed number
|
|
3
|
+
* of items. When the buffer is full, new items overwrite the oldest items.
|
|
4
|
+
*
|
|
5
|
+
* This implementation maintains O(1) time complexity for push operations and provides
|
|
6
|
+
* items in chronological order (oldest to newest) via getAll().
|
|
7
|
+
*
|
|
8
|
+
* @template T - The type of items stored in the buffer
|
|
9
|
+
*/
|
|
10
|
+
export class RingBuffer {
|
|
11
|
+
buffer;
|
|
12
|
+
head = 0;
|
|
13
|
+
size = 0;
|
|
14
|
+
capacity;
|
|
15
|
+
constructor(capacity) {
|
|
16
|
+
if (capacity <= 0) {
|
|
17
|
+
throw new Error("Ring buffer capacity must be greater than 0");
|
|
18
|
+
}
|
|
19
|
+
this.capacity = capacity;
|
|
20
|
+
this.buffer = new Array(capacity);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Adds an item to the buffer. If the buffer is full, overwrites the oldest item.
|
|
24
|
+
*
|
|
25
|
+
* @param item - The item to add
|
|
26
|
+
*/
|
|
27
|
+
push(item) {
|
|
28
|
+
const index = (this.head + this.size) % this.capacity;
|
|
29
|
+
if (this.size < this.capacity) {
|
|
30
|
+
this.buffer[index] = item;
|
|
31
|
+
this.size++;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
this.buffer[this.head] = item;
|
|
35
|
+
this.head = (this.head + 1) % this.capacity;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Returns all items in the buffer in chronological order (oldest to newest).
|
|
40
|
+
*
|
|
41
|
+
* @returns Array of items in insertion order
|
|
42
|
+
*/
|
|
43
|
+
getAll() {
|
|
44
|
+
if (this.size === 0) {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
const result = [];
|
|
48
|
+
for (let i = 0; i < this.size; i++) {
|
|
49
|
+
const index = (this.head + i) % this.capacity;
|
|
50
|
+
result.push(this.buffer[index]);
|
|
51
|
+
}
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Clears all items from the buffer.
|
|
56
|
+
*/
|
|
57
|
+
clear() {
|
|
58
|
+
this.buffer = new Array(this.capacity);
|
|
59
|
+
this.head = 0;
|
|
60
|
+
this.size = 0;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Gets the current number of items in the buffer.
|
|
64
|
+
*/
|
|
65
|
+
get length() {
|
|
66
|
+
return this.size;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=ring-buffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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,EAAE,EAAE,CAAC;YACnC,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC;YAC9C,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAClC,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,MAAM,GAAG,IAAI,KAAK,CAAI,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC1C,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;QACd,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { PHDocument } from "document-model";
|
|
2
|
+
import type { IDocumentModelRegistry } from "../registry/interfaces.js";
|
|
3
|
+
import type { IKeyframeStore, IOperationStore } from "../storage/interfaces.js";
|
|
4
|
+
import { RingBuffer } from "./buffer/ring-buffer.js";
|
|
5
|
+
import type { CachedSnapshot, WriteCacheConfig } from "./types.js";
|
|
6
|
+
import type { IWriteCache } from "./write/interfaces.js";
|
|
7
|
+
type DocumentStream = {
|
|
8
|
+
key: string;
|
|
9
|
+
ringBuffer: RingBuffer<CachedSnapshot>;
|
|
10
|
+
};
|
|
11
|
+
export declare class KyselyWriteCache implements IWriteCache {
|
|
12
|
+
private streams;
|
|
13
|
+
private lruTracker;
|
|
14
|
+
private keyframeStore;
|
|
15
|
+
private operationStore;
|
|
16
|
+
private registry;
|
|
17
|
+
private config;
|
|
18
|
+
constructor(keyframeStore: IKeyframeStore, operationStore: IOperationStore, registry: IDocumentModelRegistry, config: WriteCacheConfig);
|
|
19
|
+
/**
|
|
20
|
+
* Initializes the write cache.
|
|
21
|
+
* Currently a no-op as keyframe store lifecycle is managed externally.
|
|
22
|
+
*/
|
|
23
|
+
startup(): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Shuts down the write cache.
|
|
26
|
+
* Currently a no-op as keyframe store lifecycle is managed externally.
|
|
27
|
+
*/
|
|
28
|
+
shutdown(): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Retrieves document state at a specific revision from cache or rebuilds it.
|
|
31
|
+
*
|
|
32
|
+
* Cache hit path: Returns cached snapshot if available (O(1))
|
|
33
|
+
* Warm miss path: Rebuilds from cached base revision + incremental ops
|
|
34
|
+
* Cold miss path: Rebuilds from keyframe or from scratch using all operations
|
|
35
|
+
*
|
|
36
|
+
* @param documentId - The document identifier
|
|
37
|
+
* @param documentType - The document type for reducer lookup
|
|
38
|
+
* @param scope - The operation scope
|
|
39
|
+
* @param branch - The operation branch
|
|
40
|
+
* @param targetRevision - The target revision, or undefined for newest
|
|
41
|
+
* @param signal - Optional abort signal to cancel the operation
|
|
42
|
+
* @returns The document at the target revision
|
|
43
|
+
* @throws {Error} "Operation aborted" if signal is aborted
|
|
44
|
+
* @throws {ModuleNotFoundError} If document type not registered in registry
|
|
45
|
+
* @throws {Error} "Failed to rebuild document" if operation store fails
|
|
46
|
+
* @throws {Error} If reducer throws during operation application
|
|
47
|
+
* @throws {Error} If document serialization (structuredClone) fails
|
|
48
|
+
*/
|
|
49
|
+
getState(documentId: string, documentType: string, scope: string, branch: string, targetRevision?: number, signal?: AbortSignal): Promise<PHDocument>;
|
|
50
|
+
/**
|
|
51
|
+
* Stores a document snapshot in the cache at a specific revision.
|
|
52
|
+
*
|
|
53
|
+
* The document is deep-copied to prevent external mutations.
|
|
54
|
+
* Updates LRU tracker and may evict least recently used stream if at capacity.
|
|
55
|
+
* Asynchronously persists keyframes at configured intervals (fire-and-forget).
|
|
56
|
+
*
|
|
57
|
+
* @param documentId - The document identifier
|
|
58
|
+
* @param documentType - The document type
|
|
59
|
+
* @param scope - The operation scope
|
|
60
|
+
* @param branch - The operation branch
|
|
61
|
+
* @param revision - The revision number
|
|
62
|
+
* @param document - The document to cache
|
|
63
|
+
* @throws {Error} If document serialization (structuredClone) fails
|
|
64
|
+
*/
|
|
65
|
+
putState(documentId: string, documentType: string, scope: string, branch: string, revision: number, document: PHDocument): void;
|
|
66
|
+
/**
|
|
67
|
+
* Invalidates cached document streams.
|
|
68
|
+
*
|
|
69
|
+
* Supports three invalidation scopes:
|
|
70
|
+
* - Document-level: invalidate(documentId) - removes all streams for document
|
|
71
|
+
* - Scope-level: invalidate(documentId, scope) - removes all branches for scope
|
|
72
|
+
* - Stream-level: invalidate(documentId, scope, branch) - removes specific stream
|
|
73
|
+
*
|
|
74
|
+
* @param documentId - The document identifier
|
|
75
|
+
* @param scope - Optional scope to narrow invalidation
|
|
76
|
+
* @param branch - Optional branch to narrow invalidation (requires scope)
|
|
77
|
+
* @returns The number of streams evicted
|
|
78
|
+
*/
|
|
79
|
+
invalidate(documentId: string, scope?: string, branch?: string): number;
|
|
80
|
+
/**
|
|
81
|
+
* Clears the entire cache, removing all cached document streams.
|
|
82
|
+
* Resets LRU tracking state. This operation always succeeds.
|
|
83
|
+
*/
|
|
84
|
+
clear(): void;
|
|
85
|
+
/**
|
|
86
|
+
* Retrieves a specific stream for a document. Exposed on the implementation
|
|
87
|
+
* for testing, but not on the interface.
|
|
88
|
+
*/
|
|
89
|
+
getStream(documentId: string, scope: string, branch: string): DocumentStream | undefined;
|
|
90
|
+
private findNearestKeyframe;
|
|
91
|
+
private coldMissRebuild;
|
|
92
|
+
private warmMissRebuild;
|
|
93
|
+
private findNearestOlderSnapshot;
|
|
94
|
+
private makeStreamKey;
|
|
95
|
+
private getOrCreateStream;
|
|
96
|
+
private isKeyframeRevision;
|
|
97
|
+
}
|
|
98
|
+
export {};
|
|
99
|
+
//# sourceMappingURL=kysely-write-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kysely-write-cache.d.ts","sourceRoot":"","sources":["../../../src/cache/kysely-write-c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MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,UAAU,GACnB,IAAI;IAiCP;;;;;;;;;;;;OAYG;IACH,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM;IA+BvE;;;OAGG;IACH,KAAK,IAAI,IAAI;IAKb;;;OAGG;IACH,SAAS,CACP,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,cAAc,GAAG,SAAS;YAKf,mBAAmB;YAoBnB,eAAe;YA6Ff,eAAe;IAqD7B,OAAO,CAAC,wBAAwB;IAiBhC,OAAO,CAAC,aAAa;IAQrB,OAAO,CAAC,iBAAiB;IAsBzB,OAAO,CAAC,kBAAkB;CAG3B"}
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import { RingBuffer } from "./buffer/ring-buffer.js";
|
|
2
|
+
import { LRUTracker } from "./lru/lru-tracker.js";
|
|
3
|
+
export class KyselyWriteCache {
|
|
4
|
+
streams;
|
|
5
|
+
lruTracker;
|
|
6
|
+
keyframeStore;
|
|
7
|
+
operationStore;
|
|
8
|
+
registry;
|
|
9
|
+
config;
|
|
10
|
+
constructor(keyframeStore, operationStore, registry, config) {
|
|
11
|
+
this.keyframeStore = keyframeStore;
|
|
12
|
+
this.operationStore = operationStore;
|
|
13
|
+
this.registry = registry;
|
|
14
|
+
this.config = {
|
|
15
|
+
maxDocuments: config.maxDocuments,
|
|
16
|
+
ringBufferSize: config.ringBufferSize,
|
|
17
|
+
keyframeInterval: config.keyframeInterval,
|
|
18
|
+
};
|
|
19
|
+
this.streams = new Map();
|
|
20
|
+
this.lruTracker = new LRUTracker();
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Initializes the write cache.
|
|
24
|
+
* Currently a no-op as keyframe store lifecycle is managed externally.
|
|
25
|
+
*/
|
|
26
|
+
async startup() {
|
|
27
|
+
return Promise.resolve();
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Shuts down the write cache.
|
|
31
|
+
* Currently a no-op as keyframe store lifecycle is managed externally.
|
|
32
|
+
*/
|
|
33
|
+
async shutdown() {
|
|
34
|
+
return Promise.resolve();
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Retrieves document state at a specific revision from cache or rebuilds it.
|
|
38
|
+
*
|
|
39
|
+
* Cache hit path: Returns cached snapshot if available (O(1))
|
|
40
|
+
* Warm miss path: Rebuilds from cached base revision + incremental ops
|
|
41
|
+
* Cold miss path: Rebuilds from keyframe or from scratch using all operations
|
|
42
|
+
*
|
|
43
|
+
* @param documentId - The document identifier
|
|
44
|
+
* @param documentType - The document type for reducer lookup
|
|
45
|
+
* @param scope - The operation scope
|
|
46
|
+
* @param branch - The operation branch
|
|
47
|
+
* @param targetRevision - The target revision, or undefined for newest
|
|
48
|
+
* @param signal - Optional abort signal to cancel the operation
|
|
49
|
+
* @returns The document at the target revision
|
|
50
|
+
* @throws {Error} "Operation aborted" if signal is aborted
|
|
51
|
+
* @throws {ModuleNotFoundError} If document type not registered in registry
|
|
52
|
+
* @throws {Error} "Failed to rebuild document" if operation store fails
|
|
53
|
+
* @throws {Error} If reducer throws during operation application
|
|
54
|
+
* @throws {Error} If document serialization (structuredClone) fails
|
|
55
|
+
*/
|
|
56
|
+
async getState(documentId, documentType, scope, branch, targetRevision, signal) {
|
|
57
|
+
if (signal?.aborted) {
|
|
58
|
+
throw new Error("Operation aborted");
|
|
59
|
+
}
|
|
60
|
+
const streamKey = this.makeStreamKey(documentId, scope, branch);
|
|
61
|
+
const stream = this.streams.get(streamKey);
|
|
62
|
+
if (stream) {
|
|
63
|
+
const snapshots = stream.ringBuffer.getAll();
|
|
64
|
+
if (targetRevision === undefined) {
|
|
65
|
+
if (snapshots.length > 0) {
|
|
66
|
+
const newest = snapshots[snapshots.length - 1];
|
|
67
|
+
this.lruTracker.touch(streamKey);
|
|
68
|
+
return structuredClone(newest.document);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
const exactMatch = snapshots.find((s) => s.revision === targetRevision);
|
|
73
|
+
if (exactMatch) {
|
|
74
|
+
this.lruTracker.touch(streamKey);
|
|
75
|
+
return structuredClone(exactMatch.document);
|
|
76
|
+
}
|
|
77
|
+
const newestOlder = this.findNearestOlderSnapshot(snapshots, targetRevision);
|
|
78
|
+
if (newestOlder) {
|
|
79
|
+
const document = await this.warmMissRebuild(newestOlder.document, newestOlder.revision, documentId, documentType, scope, branch, targetRevision, signal);
|
|
80
|
+
this.putState(documentId, documentType, scope, branch, targetRevision, document);
|
|
81
|
+
this.lruTracker.touch(streamKey);
|
|
82
|
+
return structuredClone(document);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const document = await this.coldMissRebuild(documentId, documentType, scope, branch, targetRevision, signal);
|
|
87
|
+
let revision = targetRevision;
|
|
88
|
+
if (revision === undefined) {
|
|
89
|
+
revision = document.header.revision[scope] || 0;
|
|
90
|
+
}
|
|
91
|
+
this.putState(documentId, documentType, scope, branch, revision, document);
|
|
92
|
+
return structuredClone(document);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Stores a document snapshot in the cache at a specific revision.
|
|
96
|
+
*
|
|
97
|
+
* The document is deep-copied to prevent external mutations.
|
|
98
|
+
* Updates LRU tracker and may evict least recently used stream if at capacity.
|
|
99
|
+
* Asynchronously persists keyframes at configured intervals (fire-and-forget).
|
|
100
|
+
*
|
|
101
|
+
* @param documentId - The document identifier
|
|
102
|
+
* @param documentType - The document type
|
|
103
|
+
* @param scope - The operation scope
|
|
104
|
+
* @param branch - The operation branch
|
|
105
|
+
* @param revision - The revision number
|
|
106
|
+
* @param document - The document to cache
|
|
107
|
+
* @throws {Error} If document serialization (structuredClone) fails
|
|
108
|
+
*/
|
|
109
|
+
putState(documentId, documentType, scope, branch, revision, document) {
|
|
110
|
+
const safeCopy = structuredClone(document);
|
|
111
|
+
const streamKey = this.makeStreamKey(documentId, scope, branch);
|
|
112
|
+
const stream = this.getOrCreateStream(streamKey);
|
|
113
|
+
const snapshot = {
|
|
114
|
+
revision,
|
|
115
|
+
document: safeCopy,
|
|
116
|
+
};
|
|
117
|
+
stream.ringBuffer.push(snapshot);
|
|
118
|
+
if (this.isKeyframeRevision(revision)) {
|
|
119
|
+
// Fire-and-forget keyframe persistence: errors are logged but don't fail putState
|
|
120
|
+
// This allows in-memory cache to continue working even if keyframe storage fails
|
|
121
|
+
this.keyframeStore
|
|
122
|
+
.putKeyframe(documentId, documentType, scope, branch, revision, safeCopy)
|
|
123
|
+
.catch((err) => {
|
|
124
|
+
console.error(`Failed to persist keyframe ${documentId}@${revision}:`, err);
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Invalidates cached document streams.
|
|
130
|
+
*
|
|
131
|
+
* Supports three invalidation scopes:
|
|
132
|
+
* - Document-level: invalidate(documentId) - removes all streams for document
|
|
133
|
+
* - Scope-level: invalidate(documentId, scope) - removes all branches for scope
|
|
134
|
+
* - Stream-level: invalidate(documentId, scope, branch) - removes specific stream
|
|
135
|
+
*
|
|
136
|
+
* @param documentId - The document identifier
|
|
137
|
+
* @param scope - Optional scope to narrow invalidation
|
|
138
|
+
* @param branch - Optional branch to narrow invalidation (requires scope)
|
|
139
|
+
* @returns The number of streams evicted
|
|
140
|
+
*/
|
|
141
|
+
invalidate(documentId, scope, branch) {
|
|
142
|
+
let evicted = 0;
|
|
143
|
+
if (scope === undefined && branch === undefined) {
|
|
144
|
+
for (const [key] of this.streams.entries()) {
|
|
145
|
+
if (key.startsWith(`${documentId}:`)) {
|
|
146
|
+
this.streams.delete(key);
|
|
147
|
+
this.lruTracker.remove(key);
|
|
148
|
+
evicted++;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
else if (scope !== undefined && branch === undefined) {
|
|
153
|
+
for (const [key] of this.streams.entries()) {
|
|
154
|
+
if (key.startsWith(`${documentId}:${scope}:`)) {
|
|
155
|
+
this.streams.delete(key);
|
|
156
|
+
this.lruTracker.remove(key);
|
|
157
|
+
evicted++;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
else if (scope !== undefined && branch !== undefined) {
|
|
162
|
+
const key = this.makeStreamKey(documentId, scope, branch);
|
|
163
|
+
if (this.streams.has(key)) {
|
|
164
|
+
this.streams.delete(key);
|
|
165
|
+
this.lruTracker.remove(key);
|
|
166
|
+
evicted = 1;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return evicted;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Clears the entire cache, removing all cached document streams.
|
|
173
|
+
* Resets LRU tracking state. This operation always succeeds.
|
|
174
|
+
*/
|
|
175
|
+
clear() {
|
|
176
|
+
this.streams.clear();
|
|
177
|
+
this.lruTracker.clear();
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Retrieves a specific stream for a document. Exposed on the implementation
|
|
181
|
+
* for testing, but not on the interface.
|
|
182
|
+
*/
|
|
183
|
+
getStream(documentId, scope, branch) {
|
|
184
|
+
const key = this.makeStreamKey(documentId, scope, branch);
|
|
185
|
+
return this.streams.get(key);
|
|
186
|
+
}
|
|
187
|
+
async findNearestKeyframe(documentId, scope, branch, targetRevision, signal) {
|
|
188
|
+
if (targetRevision === Number.MAX_SAFE_INTEGER || targetRevision <= 0) {
|
|
189
|
+
return undefined;
|
|
190
|
+
}
|
|
191
|
+
return this.keyframeStore.findNearestKeyframe(documentId, scope, branch, targetRevision, signal);
|
|
192
|
+
}
|
|
193
|
+
async coldMissRebuild(documentId, documentType, scope, branch, targetRevision, signal) {
|
|
194
|
+
const effectiveTargetRevision = targetRevision || Number.MAX_SAFE_INTEGER;
|
|
195
|
+
const keyframe = await this.findNearestKeyframe(documentId, scope, branch, effectiveTargetRevision, signal);
|
|
196
|
+
let document;
|
|
197
|
+
let startRevision;
|
|
198
|
+
if (keyframe) {
|
|
199
|
+
document = structuredClone(keyframe.document);
|
|
200
|
+
startRevision = keyframe.revision;
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
document = undefined;
|
|
204
|
+
startRevision = 0;
|
|
205
|
+
}
|
|
206
|
+
// Throws ModuleNotFoundError if document type not registered
|
|
207
|
+
const module = this.registry.getModule(documentType);
|
|
208
|
+
let cursor = undefined;
|
|
209
|
+
const pageSize = 100;
|
|
210
|
+
let hasMorePages;
|
|
211
|
+
do {
|
|
212
|
+
if (signal?.aborted) {
|
|
213
|
+
throw new Error("Operation aborted");
|
|
214
|
+
}
|
|
215
|
+
const paging = cursor ? { cursor, pageSize } : { pageSize };
|
|
216
|
+
try {
|
|
217
|
+
const result = await this.operationStore.getSince(documentId, scope, branch, startRevision, paging, signal);
|
|
218
|
+
for (const operation of result.items) {
|
|
219
|
+
if (targetRevision !== undefined &&
|
|
220
|
+
operation.index > targetRevision) {
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
if (document === undefined) {
|
|
224
|
+
document = module.utils.createDocument();
|
|
225
|
+
}
|
|
226
|
+
// Fail-fast: if reducer throws, error propagates immediately without caching partial state
|
|
227
|
+
document = module.reducer(document, operation.action);
|
|
228
|
+
}
|
|
229
|
+
const reachedTarget = targetRevision !== undefined &&
|
|
230
|
+
result.items.some((op) => op.index >= targetRevision);
|
|
231
|
+
hasMorePages = Boolean(result.nextCursor) && !reachedTarget;
|
|
232
|
+
if (hasMorePages) {
|
|
233
|
+
cursor = result.nextCursor;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
catch (err) {
|
|
237
|
+
// Wrap errors with context to include document ID for debugging
|
|
238
|
+
throw new Error(`Failed to rebuild document ${documentId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
239
|
+
}
|
|
240
|
+
} while (hasMorePages);
|
|
241
|
+
if (!document) {
|
|
242
|
+
throw new Error(`Failed to rebuild document ${documentId}: no operations found`);
|
|
243
|
+
}
|
|
244
|
+
return document;
|
|
245
|
+
}
|
|
246
|
+
async warmMissRebuild(baseDocument, baseRevision, documentId, documentType, scope, branch, targetRevision, signal) {
|
|
247
|
+
// Throws ModuleNotFoundError if document type not registered
|
|
248
|
+
const module = this.registry.getModule(documentType);
|
|
249
|
+
let document = structuredClone(baseDocument);
|
|
250
|
+
try {
|
|
251
|
+
const pagedResults = await this.operationStore.getSince(documentId, scope, branch, baseRevision, undefined, signal);
|
|
252
|
+
for (const operation of pagedResults.items) {
|
|
253
|
+
if (signal?.aborted) {
|
|
254
|
+
throw new Error("Operation aborted");
|
|
255
|
+
}
|
|
256
|
+
if (targetRevision !== undefined && operation.index > targetRevision) {
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
// Fail-fast: if reducer throws, error propagates immediately without caching partial state
|
|
260
|
+
document = module.reducer(document, operation.action);
|
|
261
|
+
if (targetRevision !== undefined &&
|
|
262
|
+
operation.index === targetRevision) {
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
catch (err) {
|
|
268
|
+
// Wrap errors with context to include document ID for debugging
|
|
269
|
+
throw new Error(`Failed to rebuild document ${documentId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
270
|
+
}
|
|
271
|
+
return document;
|
|
272
|
+
}
|
|
273
|
+
findNearestOlderSnapshot(snapshots, targetRevision) {
|
|
274
|
+
let nearest = undefined;
|
|
275
|
+
for (const snapshot of snapshots) {
|
|
276
|
+
if (snapshot.revision < targetRevision) {
|
|
277
|
+
if (!nearest || snapshot.revision > nearest.revision) {
|
|
278
|
+
nearest = snapshot;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return nearest;
|
|
283
|
+
}
|
|
284
|
+
makeStreamKey(documentId, scope, branch) {
|
|
285
|
+
return `${documentId}:${scope}:${branch}`;
|
|
286
|
+
}
|
|
287
|
+
getOrCreateStream(key) {
|
|
288
|
+
let stream = this.streams.get(key);
|
|
289
|
+
if (!stream) {
|
|
290
|
+
if (this.streams.size >= this.config.maxDocuments) {
|
|
291
|
+
const evictKey = this.lruTracker.evict();
|
|
292
|
+
if (evictKey) {
|
|
293
|
+
this.streams.delete(evictKey);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
stream = {
|
|
297
|
+
key,
|
|
298
|
+
ringBuffer: new RingBuffer(this.config.ringBufferSize),
|
|
299
|
+
};
|
|
300
|
+
this.streams.set(key, stream);
|
|
301
|
+
}
|
|
302
|
+
this.lruTracker.touch(key);
|
|
303
|
+
return stream;
|
|
304
|
+
}
|
|
305
|
+
isKeyframeRevision(revision) {
|
|
306
|
+
return revision > 0 && revision % this.config.keyframeInterval === 0;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
//# sourceMappingURL=kysely-write-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kysely-write-cache.js","sourceRoot":"","sources":["../../../src/cache/kysely-write-cache.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AASlD,MAAM,OAAO,gBAAgB;IACnB,OAAO,CAA8B;IACrC,UAAU,CAAqB;IAC/B,aAAa,CAAiB;IAC9B,cAAc,CAAkB;IAChC,QAAQ,CAAyB;IACjC,MAAM,CAA6B;IAE3C,YACE,aAA6B,EAC7B,cAA+B,EAC/B,QAAgC,EAChC,MAAwB;QAExB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG;YACZ,YAAY,EAAE,MAAM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MAAM,CAAC,QAAQ,CAAC,CAAC;gBAChC,CAAC;YACH,CAAC;YAED,MAAM,GAAG;gBACP,GAAG;gBACH,UAAU,EAAE,IAAI,UAAU,CAAiB,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC;aACvE,CAAC;YACF,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QAChC,CAAC;QAED,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC3B,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,kBAAkB,CAAC,QAAgB;QACzC,OAAO,QAAQ,GAAG,CAAC,IAAI,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,gBAAgB,KAAK,CAAC,CAAC;IACvE,CAAC;CACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare class LRUTracker<K> {
|
|
2
|
+
private map;
|
|
3
|
+
private head;
|
|
4
|
+
private tail;
|
|
5
|
+
constructor();
|
|
6
|
+
get size(): number;
|
|
7
|
+
touch(key: K): void;
|
|
8
|
+
evict(): K | undefined;
|
|
9
|
+
remove(key: K): void;
|
|
10
|
+
clear(): void;
|
|
11
|
+
private addToFront;
|
|
12
|
+
private moveToFront;
|
|
13
|
+
private removeNode;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=lru-tracker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lru-tracker.d.ts","sourceRoot":"","sources":["../../../../src/cache/lru/lru-tracker.ts"],"names":[],"mappings":"AAYA,qBAAa,UAAU,CAAC,CAAC;IACvB,OAAO,CAAC,GAAG,CAAqB;IAChC,OAAO,CAAC,IAAI,CAAyB;IACrC,OAAO,CAAC,IAAI,CAAyB;;IAQrC,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,KAAK,CAAC,GAAG,EAAE,CAAC,GAAG,IAAI;IAUnB,KAAK,IAAI,CAAC,GAAG,SAAS;IAUtB,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,IAAI;IAUpB,KAAK,IAAI,IAAI;IAMb,OAAO,CAAC,UAAU;IAclB,OAAO,CAAC,WAAW;IAoBnB,OAAO,CAAC,UAAU;CAanB"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
class LRUNode {
|
|
2
|
+
key;
|
|
3
|
+
prev;
|
|
4
|
+
next;
|
|
5
|
+
constructor(key) {
|
|
6
|
+
this.key = key;
|
|
7
|
+
this.prev = undefined;
|
|
8
|
+
this.next = undefined;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export class LRUTracker {
|
|
12
|
+
map;
|
|
13
|
+
head;
|
|
14
|
+
tail;
|
|
15
|
+
constructor() {
|
|
16
|
+
this.map = new Map();
|
|
17
|
+
this.head = undefined;
|
|
18
|
+
this.tail = undefined;
|
|
19
|
+
}
|
|
20
|
+
get size() {
|
|
21
|
+
return this.map.size;
|
|
22
|
+
}
|
|
23
|
+
touch(key) {
|
|
24
|
+
const node = this.map.get(key);
|
|
25
|
+
if (node) {
|
|
26
|
+
this.moveToFront(node);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
this.addToFront(key);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
evict() {
|
|
33
|
+
if (!this.tail) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
const key = this.tail.key;
|
|
37
|
+
this.remove(key);
|
|
38
|
+
return key;
|
|
39
|
+
}
|
|
40
|
+
remove(key) {
|
|
41
|
+
const node = this.map.get(key);
|
|
42
|
+
if (!node) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
this.removeNode(node);
|
|
46
|
+
this.map.delete(key);
|
|
47
|
+
}
|
|
48
|
+
clear() {
|
|
49
|
+
this.map.clear();
|
|
50
|
+
this.head = undefined;
|
|
51
|
+
this.tail = undefined;
|
|
52
|
+
}
|
|
53
|
+
addToFront(key) {
|
|
54
|
+
const node = new LRUNode(key);
|
|
55
|
+
this.map.set(key, node);
|
|
56
|
+
if (!this.head) {
|
|
57
|
+
this.head = node;
|
|
58
|
+
this.tail = node;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
node.next = this.head;
|
|
62
|
+
this.head.prev = node;
|
|
63
|
+
this.head = node;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
moveToFront(node) {
|
|
67
|
+
if (node === this.head) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
this.removeNode(node);
|
|
71
|
+
node.prev = undefined;
|
|
72
|
+
node.next = this.head;
|
|
73
|
+
if (this.head) {
|
|
74
|
+
this.head.prev = node;
|
|
75
|
+
}
|
|
76
|
+
this.head = node;
|
|
77
|
+
if (!this.tail) {
|
|
78
|
+
this.tail = node;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
removeNode(node) {
|
|
82
|
+
if (node.prev) {
|
|
83
|
+
node.prev.next = node.next;
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
this.head = node.next;
|
|
87
|
+
}
|
|
88
|
+
if (node.next) {
|
|
89
|
+
node.next.prev = node.prev;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
this.tail = node.prev;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=lru-tracker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lru-tracker.js","sourceRoot":"","sources":["../../../../src/cache/lru/lru-tracker.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO;IACX,GAAG,CAAI;IACP,IAAI,CAAyB;IAC7B,IAAI,CAAyB;IAE7B,YAAY,GAAM;QAChB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;IACxB,CAAC;CACF;AAED,MAAM,OAAO,UAAU;IACb,GAAG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