@x1a0f3n9/dsh-session-persistence-jsonl 0.1.5-rc.3 → 0.1.5-rc.4
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/lib/index.js +26 -3
- package/lib/types/index.d.ts +2 -1
- package/lib/types/storage.d.ts +8 -0
- package/package.json +10 -10
package/lib/index.js
CHANGED
|
@@ -122,6 +122,7 @@ var JsonlSessionHandle = class {
|
|
|
122
122
|
}
|
|
123
123
|
/**
|
|
124
124
|
* Replace the current generation with an earlier contiguous prefix.
|
|
125
|
+
* Routed live events at or past `length` are dropped after the rewrite.
|
|
125
126
|
* @param length - number of events to retain.
|
|
126
127
|
* @returns resolution after the rewritten prefix is durable.
|
|
127
128
|
*/
|
|
@@ -153,6 +154,7 @@ var JsonlSessionHandle = class {
|
|
|
153
154
|
this.state.tornTruncateTo = void 0;
|
|
154
155
|
this.state.recoveredTail = void 0;
|
|
155
156
|
this.observedLength = length;
|
|
157
|
+
this.discardLiveFrom(length);
|
|
156
158
|
});
|
|
157
159
|
}
|
|
158
160
|
/**
|
|
@@ -211,6 +213,21 @@ var JsonlSessionHandle = class {
|
|
|
211
213
|
return this.close();
|
|
212
214
|
}
|
|
213
215
|
/**
|
|
216
|
+
* Drop routed live events at or past `length`. They belong to a discarded
|
|
217
|
+
* tail after destructive truncation; keeping them poisons the next drain
|
|
218
|
+
* with an append seq mismatch.
|
|
219
|
+
* @param length - retained event-prefix length, matching the new cursor.
|
|
220
|
+
*/
|
|
221
|
+
discardLiveFrom(length) {
|
|
222
|
+
if (this.buffered.length === 0) return;
|
|
223
|
+
this.buffered = this.buffered.filter((event) => event.seq < length);
|
|
224
|
+
if (this.buffered.length > 0) return;
|
|
225
|
+
this.drainPaused = false;
|
|
226
|
+
if (this.batchTimer === void 0) return;
|
|
227
|
+
clearTimeout(this.batchTimer);
|
|
228
|
+
this.batchTimer = void 0;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
214
231
|
* Buffer one published live session event and arm the bounded batching
|
|
215
232
|
* window when it is idle. The routing installer is the only caller.
|
|
216
233
|
* @param event - the live event, retained as a persistence-owned copy.
|
|
@@ -246,8 +263,10 @@ var JsonlSessionHandle = class {
|
|
|
246
263
|
try {
|
|
247
264
|
await this.persistContiguous(materializeAppendBatch(batch));
|
|
248
265
|
} catch (error) {
|
|
249
|
-
|
|
250
|
-
|
|
266
|
+
const merged = batch.concat(this.buffered);
|
|
267
|
+
const start = merged.findIndex((event) => event.seq === this.state.cursor);
|
|
268
|
+
this.buffered = start === -1 ? merged.filter((event) => event.seq < this.state.cursor) : merged.slice(start);
|
|
269
|
+
this.drainPaused = this.buffered.length > 0;
|
|
251
270
|
throw error;
|
|
252
271
|
}
|
|
253
272
|
});
|
|
@@ -453,6 +472,9 @@ var JsonlBackendTracker = class {
|
|
|
453
472
|
ctx.logger.warn(`session-persistence: background write for session "${session.id}" failed (buffered events retained): ${String(error)}`);
|
|
454
473
|
});
|
|
455
474
|
});
|
|
475
|
+
ctx.on("session/truncated", (session) => {
|
|
476
|
+
this.writers.get(session.id)?.discardLiveFrom(session.seq);
|
|
477
|
+
});
|
|
456
478
|
ctx.on("session/flush", (session) => {
|
|
457
479
|
const writer = this.writers.get(session.id);
|
|
458
480
|
if (writer === null || writer === void 0) return void 0;
|
|
@@ -3031,7 +3053,8 @@ var JsonlSessionPersistence = class extends SessionPersistence {
|
|
|
3031
3053
|
}
|
|
3032
3054
|
/**
|
|
3033
3055
|
* Rewrite one active session's current generation with an earlier event prefix.
|
|
3034
|
-
* Historical format generations are left in place.
|
|
3056
|
+
* Historical format generations are left in place. Routed live events at or
|
|
3057
|
+
* past `length` are dropped so a later drain cannot replay the discarded tail.
|
|
3035
3058
|
* @param id - the session whose write handle is active in this backend.
|
|
3036
3059
|
* @param length - number of events to retain.
|
|
3037
3060
|
* @returns resolution after the durable rewrite completes.
|
package/lib/types/index.d.ts
CHANGED
|
@@ -163,7 +163,8 @@ declare class JsonlSessionPersistence extends SessionPersistence {
|
|
|
163
163
|
resolveCurrentLog(id: SessionId, signal?: AbortSignal): Promise<string | undefined>;
|
|
164
164
|
/**
|
|
165
165
|
* Rewrite one active session's current generation with an earlier event prefix.
|
|
166
|
-
* Historical format generations are left in place.
|
|
166
|
+
* Historical format generations are left in place. Routed live events at or
|
|
167
|
+
* past `length` are dropped so a later drain cannot replay the discarded tail.
|
|
167
168
|
* @param id - the session whose write handle is active in this backend.
|
|
168
169
|
* @param length - number of events to retain.
|
|
169
170
|
* @returns resolution after the durable rewrite completes.
|
package/lib/types/storage.d.ts
CHANGED
|
@@ -99,6 +99,7 @@ export declare class JsonlSessionHandle implements SessionHandle {
|
|
|
99
99
|
append(events: readonly SessionEvent[], options?: SessionHandleAppendOptions): Promise<void>;
|
|
100
100
|
/**
|
|
101
101
|
* Replace the current generation with an earlier contiguous prefix.
|
|
102
|
+
* Routed live events at or past `length` are dropped after the rewrite.
|
|
102
103
|
* @param length - number of events to retain.
|
|
103
104
|
* @returns resolution after the rewritten prefix is durable.
|
|
104
105
|
*/
|
|
@@ -121,6 +122,13 @@ export declare class JsonlSessionHandle implements SessionHandle {
|
|
|
121
122
|
close(): Promise<void>;
|
|
122
123
|
/** `await using` support: delegates to {@link close}. */
|
|
123
124
|
[Symbol.asyncDispose](): Promise<void>;
|
|
125
|
+
/**
|
|
126
|
+
* Drop routed live events at or past `length`. They belong to a discarded
|
|
127
|
+
* tail after destructive truncation; keeping them poisons the next drain
|
|
128
|
+
* with an append seq mismatch.
|
|
129
|
+
* @param length - retained event-prefix length, matching the new cursor.
|
|
130
|
+
*/
|
|
131
|
+
discardLiveFrom(length: number): void;
|
|
124
132
|
/**
|
|
125
133
|
* Buffer one published live session event and arm the bounded batching
|
|
126
134
|
* window when it is idle. The routing installer is the only caller.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@x1a0f3n9/dsh-session-persistence-jsonl",
|
|
3
3
|
"description": "JSONL durable session persistence backend for the DeepSeek Harness",
|
|
4
|
-
"version": "0.1.5-rc.
|
|
4
|
+
"version": "0.1.5-rc.4",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -28,23 +28,23 @@
|
|
|
28
28
|
],
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@x1a0f3n9/dsh-session": "^0.1.5-rc.
|
|
32
|
-
"@x1a0f3n9/dsh-session-persistence": "^0.1.5-rc.
|
|
31
|
+
"@x1a0f3n9/dsh-session": "^0.1.5-rc.4",
|
|
32
|
+
"@x1a0f3n9/dsh-session-persistence": "^0.1.5-rc.4",
|
|
33
33
|
"@deepseek-ai/cordis": "^4.0.2"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"koffi": "^3.1.0",
|
|
37
|
-
"@x1a0f3n9/dsh-llm": "^0.1.5-rc.
|
|
38
|
-
"@x1a0f3n9/dsh-session-format": "^0.1.5-rc.
|
|
39
|
-
"@x1a0f3n9/dsh-session-format-catalog": "^0.1.5-rc.
|
|
40
|
-
"@x1a0f3n9/dsh-session-format-v2-to-v3": "^0.1.5-rc.
|
|
37
|
+
"@x1a0f3n9/dsh-llm": "^0.1.5-rc.4",
|
|
38
|
+
"@x1a0f3n9/dsh-session-format": "^0.1.5-rc.4",
|
|
39
|
+
"@x1a0f3n9/dsh-session-format-catalog": "^0.1.5-rc.4",
|
|
40
|
+
"@x1a0f3n9/dsh-session-format-v2-to-v3": "^0.1.5-rc.4",
|
|
41
41
|
"@deepseek-ai/node-addon-system": "^0.1.2",
|
|
42
42
|
"@deepseek-ai/schemastery": "^3.18.2"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@x1a0f3n9/dsh-session": "^0.1.5-rc.
|
|
46
|
-
"@x1a0f3n9/dsh-session
|
|
47
|
-
"@x1a0f3n9/dsh-session-persistence": "^0.1.5-rc.
|
|
45
|
+
"@x1a0f3n9/dsh-session-format-v0-to-v1": "^0.1.5-rc.4",
|
|
46
|
+
"@x1a0f3n9/dsh-session": "^0.1.5-rc.4",
|
|
47
|
+
"@x1a0f3n9/dsh-session-persistence": "^0.1.5-rc.4",
|
|
48
48
|
"@deepseek-ai/cordis": "^4.0.2"
|
|
49
49
|
}
|
|
50
50
|
}
|