@deepseek-ai/dsh-session-persistence-jsonl 0.1.5-alpha.1 → 0.1.5-alpha.2
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/README.i18n.yaml +2 -2
- package/README.md +4 -4
- package/README.zh.md +4 -4
- package/lib/index.js +2 -2
- package/lib/types/format.d.ts +3 -3
- package/lib/worker.cjs +10432 -20
- package/package.json +10 -10
package/README.i18n.yaml
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
|
3
3
|
# after editing either side, bring the other along and re-record with:
|
|
4
4
|
# pnpm run verify-translation-pairing --write packages/session/session-persistence-jsonl/README.md
|
|
5
|
-
README.md:
|
|
6
|
-
README.zh.md:
|
|
5
|
+
README.md: 194ea835f87e4c34e0821083246bcf89c0e0a684
|
|
6
|
+
README.zh.md: 4512d67e3439cbb4cf8642ca67be56bf0c7ac5b1
|
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ English | [中文](README.zh.md)
|
|
|
9
9
|
|
|
10
10
|
## Summary
|
|
11
11
|
|
|
12
|
-
`dsh-session-persistence-jsonl` stores each session in a current append-only JSONL log and retains immutable historical format generations — checksummed Zstandard frames by default, raw newline-delimited lines when compression is disabled. It serves the current logical `SessionEvent` stream through persistence handles, so format migration, compression, historical decoding, and crash recovery remain storage-internal details. Choose it when consumers need a per-session file on disk; the logs are readable as plain lines when `compression: 'none'` is selected. A root directory is the one required configuration; durability, lazy materialization,
|
|
12
|
+
`dsh-session-persistence-jsonl` stores each session in a current append-only JSONL log and retains immutable historical format generations — checksummed Zstandard frames by default, raw newline-delimited lines when compression is disabled. It serves the current logical `SessionEvent` stream through persistence handles, so format migration, compression, historical decoding, and crash recovery remain storage-internal details. Choose it when consumers need a per-session file on disk; the logs are readable as plain lines when `compression: 'none'` is selected. A root directory is the one required configuration; durability, lazy materialization, [supported historical-format migration](../session-format-catalog/README.md), and torn-tail crash recovery come with the backend.
|
|
13
13
|
|
|
14
14
|
## Table of Contents
|
|
15
15
|
|
|
@@ -53,7 +53,7 @@ The generated [configuration catalog](../../../docs/config-catalog.md#deepseek-a
|
|
|
53
53
|
|
|
54
54
|
### On-disk layout
|
|
55
55
|
|
|
56
|
-
Each session gets a session-owned directory under a readable project directory. Every canonical generation starts with a physical header whose version equals its filename.
|
|
56
|
+
Each session gets a session-owned directory under a readable project directory. Every canonical generation starts with a physical header whose version equals its filename. The current format stores one physical row per durable event; the frozen v0 and v1 readers also understand their historical packed Assistant-delta rows. The current format stores `isSeeded` in the header and derives the inherited cut from the last tagged `session/end-seed` marker, while historical codecs translate their numeric `seedLength`. The format catalog completes that translation before a handle exposes current logical values. Current storage records use the lossless provenance representation described below:
|
|
57
57
|
|
|
58
58
|
```text
|
|
59
59
|
<root>/
|
|
@@ -95,7 +95,7 @@ The backend owns its complete storage runtime (`src/storage.ts`): `JsonlSessionH
|
|
|
95
95
|
|
|
96
96
|
### Physical encoding
|
|
97
97
|
|
|
98
|
-
The default artifact is a standard concatenation of independent [Zstandard frames](../../../.agents/notes/implemented/architecture/2026-07-19-zstandard-jsonl-session-logs.md): one checksummed frame containing only the header line, then one checksummed frame per durable append batch, using Node's built-in Zstandard API at its default compression level (no level knob).
|
|
98
|
+
The default artifact is a standard concatenation of independent [Zstandard frames](../../../.agents/notes/implemented/architecture/2026-07-19-zstandard-jsonl-session-logs.md): one checksummed frame containing only the header line, then one checksummed frame per durable append batch, using Node's built-in Zstandard API at its default compression level (no level knob). The current format writes one event per row; `sourceEventSeqs` uses a lossless storage representation in which consecutive runs of at least three sequence numbers become `[start, end]` pairs, any other list stays verbatim, and reading expands the exact in-memory array. Historical migration reuses one Zstandard decoder, passes parsed rows through stateful format stages, and streams current records through one compression context in about 1 MiB main-thread slices while retaining only final current events, bounded decoder state, and the required sequence-remap table. Listing reads and validates only the header frame. `compression: 'none'` keeps the same storage-form logical lines without frame compression. A root belongs to one encoding: startup discovery and targeted lookup reject generations with the other suffix; format migration preserves the configured encoding, while compression conversion, mixed-root fallback, and dual write remain unsupported. Frozen v0 and v1 codecs retain their packed-row decoders solely for historical generations.
|
|
99
99
|
|
|
100
100
|
### Source map
|
|
101
101
|
|
|
@@ -151,7 +151,7 @@ JSONL storage does not mutate live request prefixes. A resumed loop can reuse pr
|
|
|
151
151
|
|
|
152
152
|
These limits define when this backend is a poor fit or needs special operational care. They are current package constraints, not a task backlog.
|
|
153
153
|
|
|
154
|
-
- **Format migration preserves the configured encoding and supports only the catalogued chain** — this build migrates
|
|
154
|
+
- **Format migration preserves the configured encoding and supports only the catalogued chain** — this build migrates supported historical generations to the current format; changing compression requires a separate root, and retained predecessors do not provide automatic fallback or downgrade support.
|
|
155
155
|
- **The flat-file storage layout does not load** — use a separate root or move pre-release artifacts into the project/session directory layout before loading.
|
|
156
156
|
- **Compressed files are not directly line-readable** — use the backend to load them, or select `compression: 'none'` before writing a fresh root when external line readers are required.
|
|
157
157
|
- **Nothing deletes session files** — logs accumulate under `root` until removed externally; the seam has no deletion API.
|
package/README.zh.md
CHANGED
|
@@ -9,7 +9,7 @@ kind: "package-reference"
|
|
|
9
9
|
|
|
10
10
|
## 概述
|
|
11
11
|
|
|
12
|
-
`dsh-session-persistence-jsonl` 把每个会话存为当前的仅追加 JSONL 日志,并保留不可变的历史格式 generation——默认以带校验和的 Zstandard 帧存储,禁用压缩时以换行分隔的原始文本行存储。它通过持久化句柄提供当前逻辑 `SessionEvent` 流,因此格式迁移、压缩、历史解码与崩溃恢复仍是存储内部细节。当消费方需要按会话的磁盘文件时选择它;选择 `compression: 'none'`
|
|
12
|
+
`dsh-session-persistence-jsonl` 把每个会话存为当前的仅追加 JSONL 日志,并保留不可变的历史格式 generation——默认以带校验和的 Zstandard 帧存储,禁用压缩时以换行分隔的原始文本行存储。它通过持久化句柄提供当前逻辑 `SessionEvent` 流,因此格式迁移、压缩、历史解码与崩溃恢复仍是存储内部细节。当消费方需要按会话的磁盘文件时选择它;选择 `compression: 'none'` 后日志可作为纯文本按行读取。根目录是唯一必填配置;持久性、延迟实体化、[受支持的历史格式迁移](../session-format-catalog/README.zh.md)与撕裂尾部崩溃恢复都随后端提供。
|
|
13
13
|
|
|
14
14
|
## 目录
|
|
15
15
|
|
|
@@ -53,7 +53,7 @@ kind: "package-reference"
|
|
|
53
53
|
|
|
54
54
|
### 磁盘布局
|
|
55
55
|
|
|
56
|
-
每个会话在可读项目目录下获得一个会话自有目录。每个规范 generation 都以版本与文件名一致的物理 header
|
|
56
|
+
每个会话在可读项目目录下获得一个会话自有目录。每个规范 generation 都以版本与文件名一致的物理 header 开始。当前格式为每个持久事件存储一行;冻结的 v0 与 v1 reader 也能理解其历史 packed Assistant delta 行。当前格式在 header 中存储 `isSeeded`,并从最后一个带标记的 `session/end-seed` 推导 inherited cut;历史 codec 则转换其数字 `seedLength`。格式 catalog 会在句柄暴露当前逻辑值之前完成该转换。当前存储记录使用下文所述的无损来源序列表示:
|
|
57
57
|
|
|
58
58
|
```text
|
|
59
59
|
<root>/
|
|
@@ -95,7 +95,7 @@ kind: "package-reference"
|
|
|
95
95
|
|
|
96
96
|
### 物理编码
|
|
97
97
|
|
|
98
|
-
默认产物是独立 [Zstandard 帧](../../../.agents/notes/implemented/architecture/2026-07-19-zstandard-jsonl-session-logs.zh.md) 的标准拼接:一个仅包含 header 行的带校验和帧,后跟每个持久 append 批次一个带校验和帧,使用 Node 内置 Zstandard API
|
|
98
|
+
默认产物是独立 [Zstandard 帧](../../../.agents/notes/implemented/architecture/2026-07-19-zstandard-jsonl-session-logs.zh.md) 的标准拼接:一个仅包含 header 行的带校验和帧,后跟每个持久 append 批次一个带校验和帧,使用 Node 内置 Zstandard API 的默认压缩级别(无级别开关)。当前格式为每个事件写一行;`sourceEventSeqs` 使用无损存储形式:至少包含三个序列号的连续段会变成 `[start, end]` 区间对,其他列表原样保留;读取时会展开回精确的内存数组。历史迁移会复用一个 Zstandard decoder,让已解析行流经有状态格式 Stage,并通过一个压缩 context 以约 1 MiB 主线程分片流式写入当前记录,同时只保留最终当前事件、有界 decoder 状态与必需的序号重映射表。列表只读取并验证 header 帧。`compression: 'none'` 保留相同的存储形式逻辑行,但不使用帧压缩。一个根只属于一种编码:启动发现与定向查找会拒绝使用另一后缀的 generation;格式迁移保留已配置编码,而压缩转换、混合根回退与双写仍不受支持。冻结的 v0 与 v1 codec 仅为历史 generation 保留 packed-row decoder。
|
|
99
99
|
|
|
100
100
|
### 源码地图
|
|
101
101
|
|
|
@@ -151,7 +151,7 @@ JSONL 存储不修改实时请求前缀。只有重建历史、当前 envelope
|
|
|
151
151
|
|
|
152
152
|
这些限制说明本后端何时不合适,或何时需要特别的运维注意。它们是当前包约束,不是任务积压。
|
|
153
153
|
|
|
154
|
-
- **格式迁移保留已配置编码,且只支持 catalog 中的链**——本 build
|
|
154
|
+
- **格式迁移保留已配置编码,且只支持 catalog 中的链**——本 build 把受支持的历史代迁移到当前格式;更改压缩需要独立根,保留的前任不提供自动 fallback 或 downgrade 支持。
|
|
155
155
|
- **平铺文件存储布局不加载**——加载前使用独立根,或将预发布产物移入项目/会话目录布局。
|
|
156
156
|
- **压缩文件不能直接按行读取**——使用后端加载;或在写入新根前选择 `compression: 'none'`,供外部行读取方使用。
|
|
157
157
|
- **不删除会话文件**——日志在 `root` 下累积,直到外部移除;seam 无删除接口。
|
package/lib/index.js
CHANGED
|
@@ -937,7 +937,7 @@ function logPath(root, cwd, id, compression) {
|
|
|
937
937
|
return generationLogPath(root, cwd, id, SESSION_FORMAT_VERSION, compression);
|
|
938
938
|
}
|
|
939
939
|
/**
|
|
940
|
-
* Serialize a
|
|
940
|
+
* Serialize a current event batch as JSONL lines (no trailing newline). Compact
|
|
941
941
|
* Assistant streams are nested event data; every event occupies one row.
|
|
942
942
|
* @param events - the batch to serialize, in log order.
|
|
943
943
|
* @returns the batch's JSONL text; the writer adds the final newline.
|
|
@@ -946,7 +946,7 @@ function eventLines(events) {
|
|
|
946
946
|
return events.map(eventLine).join("\n");
|
|
947
947
|
}
|
|
948
948
|
/**
|
|
949
|
-
* Serialize one
|
|
949
|
+
* Serialize one current event as one JSONL record without its trailing newline.
|
|
950
950
|
* @param event - current event to encode.
|
|
951
951
|
* @returns one physical JSON record.
|
|
952
952
|
*/
|
package/lib/types/format.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ export declare function generationLogFilename(version: number, compression: Json
|
|
|
36
36
|
*/
|
|
37
37
|
export declare function parseGenerationLogFilename(filename: string, compression: JsonlCompression): number | undefined;
|
|
38
38
|
/**
|
|
39
|
-
* The current
|
|
39
|
+
* The current physical header stored as the first JSONL record. The exact
|
|
40
40
|
* inherited cut lives on the last tagged `session/end-seed` event.
|
|
41
41
|
*/
|
|
42
42
|
interface HeaderLine {
|
|
@@ -124,14 +124,14 @@ export declare function generationLogPath(root: string, cwd: string | undefined,
|
|
|
124
124
|
*/
|
|
125
125
|
export declare function logPath(root: string, cwd: string | undefined, id: SessionId, compression: JsonlCompression): string;
|
|
126
126
|
/**
|
|
127
|
-
* Serialize a
|
|
127
|
+
* Serialize a current event batch as JSONL lines (no trailing newline). Compact
|
|
128
128
|
* Assistant streams are nested event data; every event occupies one row.
|
|
129
129
|
* @param events - the batch to serialize, in log order.
|
|
130
130
|
* @returns the batch's JSONL text; the writer adds the final newline.
|
|
131
131
|
*/
|
|
132
132
|
export declare function eventLines(events: readonly SessionEvent[]): string;
|
|
133
133
|
/**
|
|
134
|
-
* Serialize one
|
|
134
|
+
* Serialize one current event as one JSONL record without its trailing newline.
|
|
135
135
|
* @param event - current event to encode.
|
|
136
136
|
* @returns one physical JSON record.
|
|
137
137
|
*/
|