@deepseek-ai/dsh-session-persistence-jsonl 0.2.2-rc.5 → 0.2.3-alpha.1

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 CHANGED
@@ -18,11 +18,11 @@
18
18
  en: d6112142a705ec43
19
19
  zh: f0914d9e37216f97
20
20
  /deepseek-ai-dsh-session-persistence-jsonl/use-this-package/when-to-choose-it:
21
- en: 37c10302bbbde268
22
- zh: 3d5c027bac868efd
21
+ en: 8fca7647035f8795
22
+ zh: 0bfb12da95611091
23
23
  /deepseek-ai-dsh-session-persistence-jsonl/use-this-package/minimal-configuration:
24
- en: b6c2f0f11f2fa9cf
25
- zh: 9fac03fcbe5bbad4
24
+ en: ee6b7741ed61f1d8
25
+ zh: e13b6554d1770f0f
26
26
  /deepseek-ai-dsh-session-persistence-jsonl/use-this-package/on-disk-layout:
27
27
  en: e20cf32540d7c785
28
28
  zh: 67e182529e9211ca
@@ -30,8 +30,8 @@
30
30
  en: 96498792672f6d50
31
31
  zh: d767a9c69dced889
32
32
  /deepseek-ai-dsh-session-persistence-jsonl/use-this-package/reading-the-logs:
33
- en: 4cec8a6c9f6e488b
34
- zh: 4757440a552db5e3
33
+ en: c9aff3ce6e32f790
34
+ zh: 1748bb565a366db6
35
35
  /deepseek-ai-dsh-session-persistence-jsonl/understand-the-implementation:
36
36
  en: a35407bb25671e7e
37
37
  zh: 6a00f9510c85adcb
package/README.md CHANGED
@@ -29,7 +29,7 @@ Mount this backend when a composition needs durable sessions backed by per-sessi
29
29
 
30
30
  ### When to choose it
31
31
 
32
- Choose this backend when consumers benefit from one artifact per session — navigation, external tooling, or a raw line-readable log. It is the sole first-party Session-persistence provider. The backend keeps sessions under a deployment-controlled root: project-local, shared, temporary, or centralized.
32
+ Choose this backend when consumers benefit from one artifact per session — navigation, external tooling, or a raw line-readable log. Shipped profiles use this provider by default. The [SQLite provider](../session-persistence-sqlite/README.md) is a separate plugin that imports existing JSONL history on first open. The backend keeps sessions under a deployment-controlled root: project-local, shared, temporary, or centralized.
33
33
 
34
34
  ### Minimal configuration
35
35
 
@@ -48,6 +48,8 @@ Choose this backend when consumers benefit from one artifact per session — nav
48
48
  | `compression` | `'zstd'` | Physical encoding: `'zstd'` checksummed frames, or `'none'` newline-delimited UTF-8 text |
49
49
  | `listConcurrency` | `3` | Maximum directory, header, and stat reads in flight, shared by every concurrent listing of this backend |
50
50
 
51
+ JSONL fork creation copies the supplied child history into the child's file before returning its writer; it does not read the parent artifact. Read opens wait for an in-progress local writer close to finish draining before reading that Session's history; a failed drain stops the open.
52
+
51
53
  Live-event write batching is not configuration: the batching window is the seam's internal scheduling policy inside each write handle.
52
54
 
53
55
  The generated [configuration catalog](../../../docs/config-catalog.md#deepseek-aidsh-session-persistence-jsonl) is the exhaustive source for every accepted field and its JSDoc.
@@ -84,9 +86,9 @@ Unloading the backend waits for the consumer unloads it triggers through `sessio
84
86
 
85
87
  Materialized `stat` and `list` snapshots include the format catalog's header classification as `formatStatus`, alongside the translated logical `header`. They also include `location: { kind: 'jsonl', path }` for the selected physical generation. A read-only preparation leaves the selected historical version unchanged; the status becomes `current` after publication of the successor. Unmaterialized pending Sessions omit `formatStatus` and `location`.
86
88
 
87
- `open(id, 'read'|'write')` selects the highest canonical generation. Current input follows the ordinary fast path. For historical input, a read open decodes and migrates the source once, validates the current logical result, and returns it without publishing a successor. A write open reuses that revision-keyed preparation when available, or performs the same preparation, then encodes a same-directory temporary file in bounded chunks, verifies it in a Worker Thread, rechecks the source revision, and publishes the current successor without overwrite before returning. The source remains byte-identical. Source drift after preparation rejects that write open without replacing the logical history already returned to readers; a later write open prepares the new revision. The backend marks decoded event graphs `shared-frozen` when it freezes them before memoization; every nested object and array is frozen, and handle reads and slices preserve that state, including empty slices. Only an unmaterialized pending log reports `detached`. `stat(id)` and `list()` select and translate only the highest generation header without reading event rows or starting migration; snapshots carry the selected file’s `sizeBytes` and a best-effort revision. Current revisions identify that file; historical revisions also fingerprint the selected files across the persistence root, so child changes invalidate cached logical events. Fingerprinting reads filesystem metadata only; unrelated changes conservatively invalidate historical revisions. One `list()` call shares a corpus fingerprint across its historical entries. With `compression: 'none'`, the log is newline-delimited text an external reader can consume directly; the compressed default must be read through the backend.
89
+ `open(id, 'read'|'write')` selects the highest canonical generation. Current input follows the ordinary fast path. For historical input, a read open decodes and migrates the source once, validates the current logical result, and returns it without publishing a successor. A write open reuses that revision-keyed preparation when available, or performs the same preparation, then encodes a same-directory temporary file in bounded chunks, verifies it in a Worker Thread, rechecks the source revision, and publishes the current successor without overwrite before returning. The source remains byte-identical. Source drift after preparation rejects that write open without replacing the logical history already returned to readers; a later write open prepares the new revision. The backend marks decoded event graphs `shared-frozen` when it freezes them before memoization; every nested object and array is frozen, and handle reads and slices preserve that state, including empty slices. Only an unmaterialized pending log reports `detached`. `stat(id)` and `list()` select and translate only the highest generation header without reading event rows or starting migration; snapshots carry the selected file’s `sizeBytes` and a best-effort revision. Current revisions identify that file; historical revisions also fingerprint the selected files across the persistence root, so child changes invalidate cached logical events. Fingerprinting reads filesystem metadata only; unrelated changes conservatively invalidate historical revisions. One `list()` call shares a corpus fingerprint across its historical entries and computes it from the same stat results. A later `list()` reuses a header from the previous complete listing while its file revision is unchanged, so it reads only the headers of changed logs. With `compression: 'none'`, the log is newline-delimited text an external reader can consume directly; the compressed default must be read through the backend.
88
90
 
89
- Verification accepts a successful Worker response only after the Worker exits naturally with code 0. Its concurrency slot remains held through that exit; cancellation and Worker errors terminate and join the Worker before rejecting.
91
+ The bundled verifier passes the Worker an absolute path string, which the single-file runtime resolves through its embedded filesystem. Verification accepts a successful Worker response only after the Worker exits naturally with code 0. Its concurrency slot remains held through that exit; cancellation and Worker errors terminate and join the Worker before rejecting.
90
92
 
91
93
  Historical body preparation completes the parent catalog through [V3→V4](../session-format-v3-to-v4/README.md). It finds candidate direct children from headers, reads each child's own descriptor through historical codecs, and retains compact evidence plus source revisions. It neither prepares child catalogs nor publishes child successors. Unreadable or unsupported headers, including corrupt Zstandard header frames, are omitted from discovery and `list()`. Direct access to a corrupt compressed header still rejects; header I/O and cancellation errors propagate. Child decoding and descriptor-field failures produce warnings naming the child path and retain header identity through `subagent/catalog` when the parent has no complete entry; healthy children and existing parent catalog entries remain available. Opening a damaged child still reports that child's error. Missing, unsupported, or multiple descriptors likewise produce unknown-mode membership without inventing a label. Published unknown entries remain browsable; child history reads retry the actual log and resolve its mode from a valid descriptor. Preparation rechecks membership and inspected source revisions before returning, reuse, and publication, including failed child reads so a repaired child invalidates stale preparation. Source drift retries a read open once and refuses a write open. Cancellation still aborts the operation. Current V4 opens bypass discovery and validate catalog fields, uniqueness, and current delivery ownership before exposing events.
92
94
 
package/README.zh.md CHANGED
@@ -29,7 +29,7 @@ kind: "package-reference"
29
29
 
30
30
  ### 何时选择
31
31
 
32
- 当消费方受益于每会话一份产物——导航、外部工具或可逐行读取的原始日志——时选择此后端。它是唯一的第一方会话持久化提供方。后端把会话保存在部署控制的根下:项目本地、共享、临时或集中式。
32
+ 当消费方受益于每会话一份产物——导航、外部工具或可逐行读取的原始日志——时选择此后端。内置 profile 默认使用此提供者。[SQLite 提供者](../session-persistence-sqlite/README.zh.md) 是独立插件,在首次打开时导入现有 JSONL 历史。后端把会话保存在部署控制的根下:项目本地、共享、临时或集中式。
33
33
 
34
34
  ### 最小配置
35
35
 
@@ -48,6 +48,8 @@ kind: "package-reference"
48
48
  | `compression` | `'zstd'` | 物理编码:`'zstd'` 带校验和帧,或 `'none'` 换行分隔 UTF-8 文本 |
49
49
  | `listConcurrency` | `3` | 同时进行的目录、header 与 stat 读取上限,由该后端所有并发的列举共用 |
50
50
 
51
+ JSONL fork 创建会把提供的子会话历史复制到子文件,再返回写句柄;它不读取父会话文件。读取打开会等待本进程中正在关闭的写者排空后,再读取该会话历史;排空失败会停止打开。
52
+
51
53
  实时事件的写入批处理不是配置:批处理窗口是该 seam 在每个写句柄内部的调度策略。
52
54
 
53
55
  生成的[配置目录](../../../docs/config-catalog.zh.md#deepseek-aidsh-session-persistence-jsonl)是每个受支持字段及其 JSDoc 的穷尽式真源。
@@ -84,9 +86,9 @@ kind: "package-reference"
84
86
 
85
87
  已实体化的 `stat` 与 `list` 快照在转换后的逻辑 `header` 之外,通过 `formatStatus` 保留格式 catalog 的头部分类。它们还包含选中物理 generation 的 `location: { kind: 'jsonl', path }`。只读准备不会改变所选历史版本;发布后继之后,状态才变为 `current`。尚未实体化的待定 Session 省略 `formatStatus` 与 `location`。
86
88
 
87
- `open(id, 'read'|'write')` 选择最高规范 generation。当前格式输入走普通快速路径。对于历史输入,只读 open 会单遍解码并迁移源、校验当前逻辑结果,然后在不发布后继的情况下返回。写 open 会在可用时复用按 revision 为键的 preparation,否则执行同一套 preparation,再按有界分片编码同目录临时文件、在 Worker Thread 中校验、复查源修订,并在返回前以不覆盖方式发布当前后继。源保持逐字节不变。如果源在 preparation 后发生变化,该次写 open 会失败,已经返回给读方的逻辑历史不会被替换;后续写 open 会针对新的 revision 重新执行 preparation。后端在 memo 化前冻结已解码的 event graph,并在此时将其标记为 `shared-frozen`;每个嵌套对象和数组都会冻结,句柄读取和 slice 即使为空也保留该状态。只有尚未实体化的 pending 空日志报告 `detached`。`stat(id)` 与 `list()` 只选择并转换最高 generation 的 header,不读取事件行,也不启动迁移;快照携带所选文件的 `sizeBytes` 与尽力而为的修订号。当前格式修订号标识该文件;历史格式修订号还包含持久化根目录中所选文件的指纹,因此子日志变化会使缓存的逻辑事件失效。指纹只读取文件系统元数据;无关变化也会保守地使历史修订号失效。一次 `list()` 为其历史条目共用一个全库指纹。选择 `compression: 'none'` 后,日志是外部读取方可直接消费的换行分隔文本;压缩默认值必须经后端读取。
89
+ `open(id, 'read'|'write')` 选择最高规范 generation。当前格式输入走普通快速路径。对于历史输入,只读 open 会单遍解码并迁移源、校验当前逻辑结果,然后在不发布后继的情况下返回。写 open 会在可用时复用按 revision 为键的 preparation,否则执行同一套 preparation,再按有界分片编码同目录临时文件、在 Worker Thread 中校验、复查源修订,并在返回前以不覆盖方式发布当前后继。源保持逐字节不变。如果源在 preparation 后发生变化,该次写 open 会失败,已经返回给读方的逻辑历史不会被替换;后续写 open 会针对新的 revision 重新执行 preparation。后端在 memo 化前冻结已解码的 event graph,并在此时将其标记为 `shared-frozen`;每个嵌套对象和数组都会冻结,句柄读取和 slice 即使为空也保留该状态。只有尚未实体化的 pending 空日志报告 `detached`。`stat(id)` 与 `list()` 只选择并转换最高 generation 的 header,不读取事件行,也不启动迁移;快照携带所选文件的 `sizeBytes` 与尽力而为的修订号。当前格式修订号标识该文件;历史格式修订号还包含持久化根目录中所选文件的指纹,因此子日志变化会使缓存的逻辑事件失效。指纹只读取文件系统元数据;无关变化也会保守地使历史修订号失效。一次 `list()` 为其历史条目共用一个全库指纹,并基于同一批 stat 结果计算该指纹。后续 `list()` 在文件修订号未变时复用上一次完整列举的 header,因此只读取已变化日志的 header。选择 `compression: 'none'` 后,日志是外部读取方可直接消费的换行分隔文本;压缩默认值必须经后端读取。
88
90
 
89
- 校验只有在 Worker 自然以退出码 0 结束后,才接受其成功响应。并发配额一直保留到该次退出;取消或 Worker 错误会先终止并等待 Worker 退出,再使校验失败。
91
+ 打包后的校验器向 Worker 传入绝对路径字符串,由单文件运行时通过内嵌文件系统解析。校验只有在 Worker 自然以退出码 0 结束后,才接受其成功响应。并发配额一直保留到该次退出;取消或 Worker 错误会先终止并等待 Worker 退出,再使校验失败。
90
92
 
91
93
  历史正文准备通过 [V3→V4](../session-format-v3-to-v4/README.zh.md) 补齐父目录:从 header 找到候选直属子 Session,通过历史编解码器逐个读取其自身 descriptor,保留紧凑证据与来源修订。此过程不准备子目录,也不发布子后继。不可读或不支持的 header(包括损坏的 Zstandard header 帧)不参与发现,也不出现在 `list()` 中。直接访问损坏的压缩 header 仍会失败;header 的 I/O 错误与取消错误继续传播。子日志解码或 descriptor 字段失败会产生带子路径的警告;父目录没有完整条目时,通过 `subagent/catalog` 保留 header 身份信息。健康子项和已有父目录项仍可使用。打开损坏子 Session 时仍报告该子会话的错误。缺失、不支持或多个 descriptor 同样生成模式未知的目录项,不编造标签。已发布的未知条目仍可浏览;读取子历史时会重试实际日志,并从有效 descriptor 确定模式。准备返回、复用与发布前会重新检查成员集合及已检查来源的修订,也包括读取失败的子日志,使修复后的子日志能够使旧准备缓存失效。来源变化时只读打开重试一次,写打开拒绝发布。取消仍会中止操作。当前 V4 打开跳过发现,并在暴露事件前校验目录字段、唯一性及当前投递归属。
92
94
 
package/lib/index.js CHANGED
@@ -7,15 +7,17 @@ import { performance } from "node:perf_hooks";
7
7
  import { scheduler } from "node:timers/promises";
8
8
  import { createHash, randomBytes } from "node:crypto";
9
9
  import pLimit from "p-limit";
10
- import { SessionAlreadyExistsError, SessionAlreadyOwnedError, SessionFormatUnsupportedError, SessionHandleClosedError, SessionPersistence, SessionPersistenceCorruptionError, SessionPersistenceNotFoundError, SessionPersistenceRevision, SessionReadOnlyError, assertContiguous, assertStoredId, materializeAppendBatch, materializeCreateHeader, sessionFormatVersionRefusal, validateStoredEvents } from "@deepseek-ai/dsh-session-persistence";
10
+ import { SessionAlreadyExistsError, SessionAlreadyOwnedError, SessionFormatUnsupportedError, SessionHandleClosedError, SessionPersistence, SessionPersistenceCorruptionError, SessionPersistenceNotFoundError, SessionReadOnlyError, assertContiguous, assertStoredId, materializeAppendBatch, materializeCreateHeader, sessionFormatVersionRefusal, validateStoredEvents } from "@deepseek-ai/dsh-session-persistence";
11
+ import { brandString } from "@deepseek-ai/dsh-brand";
11
12
  import { BlockAssembler, errorChain, expandAssistantStream } from "@deepseek-ai/dsh-llm";
12
13
  import { tryLockExclusive } from "@deepseek-ai/node-addon-system/flock";
13
- import { KNOWN_SESSION_EVENT_TYPES, SESSION_FORMAT_VERSION, Session, SessionId, SessionLogOffset } from "@deepseek-ai/dsh-session";
14
+ import { KNOWN_SESSION_EVENT_TYPES, SESSION_FORMAT_VERSION, SessionLogOffset, validateSessionLog } from "@deepseek-ai/dsh-session";
14
15
  import { SessionFormatError, SessionFormatUnsupportedMigrationError as SessionFormatUnsupportedMigrationError$1, parseSessionFormatLogFilename, sessionFormatLogFilename } from "@deepseek-ai/dsh-session-format";
15
16
  import { assertReleasedV4Relationships, assertV4RowAdmission, historicalChildCatalogSource } from "@deepseek-ai/dsh-session-format-v3-to-v4";
16
17
  import { constants, createZstdCompress, createZstdDecompress, zstdCompress, zstdDecompress, zstdDecompressSync } from "node:zlib";
17
18
  import { isDeepStrictEqual, promisify } from "node:util";
18
19
  import { constants as constants$1 } from "node:buffer";
20
+ import { fileURLToPath } from "node:url";
19
21
  import { Worker } from "node:worker_threads";
20
22
  import { currentSessionMessageProjections } from "@deepseek-ai/dsh-session-format-catalog/message-projections";
21
23
  import { Readable, pipeline } from "node:stream";
@@ -53,6 +55,10 @@ var JsonlSessionHandle = class {
53
55
  get inheritedEventCount() {
54
56
  return this.state.inheritedEventCount;
55
57
  }
58
+ /** Completion of an already-started close, including its final durability drain. */
59
+ get closeCompletion() {
60
+ return this.closing;
61
+ }
56
62
  /**
57
63
  * Read a slice of the valid contiguous logical log; see the seam contract.
58
64
  * @param offset - first logical seq to include (default 0).
@@ -302,7 +308,7 @@ var JsonlBackendTracker = class {
302
308
  this.writers.set(header.id, null);
303
309
  this.pending.set(header.id, {
304
310
  header,
305
- revision: SessionPersistenceRevision(`memory:${this.name}:${++this.counter}`),
311
+ revision: brandString(`memory:${this.name}:${++this.counter}`),
306
312
  inheritedEventCount
307
313
  });
308
314
  }
@@ -339,6 +345,14 @@ var JsonlBackendTracker = class {
339
345
  return this.pending.has(id);
340
346
  }
341
347
  /**
348
+ * Join an already-started writer close before reading its stored history.
349
+ * @param id - Session whose writer may still be draining.
350
+ * @returns completion of that writer's close, or undefined when no close is active.
351
+ */
352
+ closeCompletion(id) {
353
+ return this.writers.get(id)?.closeCompletion;
354
+ }
355
+ /**
342
356
  * Iterate the pending sessions for listing.
343
357
  * @returns the pending entries, keyed by session id.
344
358
  */
@@ -1451,7 +1465,7 @@ const verificationScheduler = new VerificationScheduler();
1451
1465
  function workerSpawn(request) {
1452
1466
  /* v8 ignore next 3 -- built-worker coverage owns the bundled path. */
1453
1467
  if (!import.meta.url.endsWith(".ts")) return {
1454
- entry: new URL("./worker.cjs", import.meta.url),
1468
+ entry: fileURLToPath(new URL("./worker.cjs", import.meta.url)),
1455
1469
  options: {
1456
1470
  workerData: request,
1457
1471
  execArgv: []
@@ -1826,7 +1840,7 @@ async function verifyCurrentGeneration(path, compression, expectedId, expectedEv
1826
1840
  });
1827
1841
  if (generation.meta.id !== expectedId) throw new Error(`current session generation contains id "${generation.meta.id}", expected "${expectedId}"`);
1828
1842
  if (generation.events.length !== expectedEventCount) throw new Error(`current session generation contains ${generation.events.length} events, expected ${expectedEventCount}`);
1829
- Session.fromRestore(generation.meta.id, generation.events, generation.meta, generation.inheritedEventCount, "detached", currentSessionMessageProjections);
1843
+ validateSessionLog(generation.meta, generation.events, generation.inheritedEventCount, "detached", currentSessionMessageProjections);
1830
1844
  assertCurrentAssistantStreams(generation.events);
1831
1845
  return {
1832
1846
  identity: snapshot.identity,
@@ -2023,7 +2037,7 @@ async function removeTemporary(path, primaryFailure, internals) {
2023
2037
  async function removeCommittedTemporary(path, internals) {
2024
2038
  try {
2025
2039
  await internals.fs.rm(path);
2026
- } catch {}
2040
+ } catch (_redundantStageRemoveFailed) {}
2027
2041
  }
2028
2042
  async function publishCurrentExclusive(staged, currentPath, internals) {
2029
2043
  if (internals.platform === "win32") try {
@@ -2329,7 +2343,7 @@ function freezeStoredEvents(events) {
2329
2343
  }
2330
2344
  /** Build the stat-derived best-effort change token shared by full and lightweight reads. */
2331
2345
  function fileRevision(identity) {
2332
- return SessionPersistenceRevision([
2346
+ return brandString([
2333
2347
  identity.dev,
2334
2348
  identity.ino,
2335
2349
  identity.size,
@@ -2337,6 +2351,17 @@ function fileRevision(identity) {
2337
2351
  identity.ctimeNs
2338
2352
  ].join(":"));
2339
2353
  }
2354
+ /**
2355
+ * Fingerprint a generation corpus independently of listing order.
2356
+ * @param revisions - each generation path with its file revision or `missing`.
2357
+ * @returns the hex digest.
2358
+ */
2359
+ function corpusDigest(revisions) {
2360
+ const hash = createHash("sha256");
2361
+ const byPath = new Map(revisions);
2362
+ for (const path of [...byPath.keys()].sort()) hash.update(JSON.stringify([path, byPath.get(path)]));
2363
+ return hash.digest("hex");
2364
+ }
2340
2365
  /** Whether a filesystem error means absence; every non-ENOENT failure must surface. */
2341
2366
  function isENOENT(error) {
2342
2367
  return error?.code === "ENOENT";
@@ -2395,7 +2420,7 @@ function waitWithAbort(operation, signal) {
2395
2420
  });
2396
2421
  }
2397
2422
  /**
2398
- * The JSONL backend registered as `ctx.sessionPersistence` by the plugin.
2423
+ * JSONL Session persistence with historical-format migration.
2399
2424
  * Sessions materialize lazily: a created session is
2400
2425
  * visible to this process immediately, reaches disk on its first append or
2401
2426
  * flush, and never existed if the process crashes before that.
@@ -2403,8 +2428,6 @@ function waitWithAbort(operation, signal) {
2403
2428
  var JsonlSessionPersistence = class extends SessionPersistence {
2404
2429
  config;
2405
2430
  tracker;
2406
- /** Backend label for diagnostics and effects; shadows `Service.name` without changing the service key. */
2407
- name = "session-persistence-jsonl";
2408
2431
  root;
2409
2432
  compression;
2410
2433
  /**
@@ -2423,9 +2446,27 @@ var JsonlSessionPersistence = class extends SessionPersistence {
2423
2446
  * revision guard.
2424
2447
  */
2425
2448
  coldLogMemo = /* @__PURE__ */ new Map();
2449
+ /**
2450
+ * Generation headers observed by the latest complete listing, keyed by
2451
+ * source path and guarded by the stat-derived revision, so a listing reads
2452
+ * only the first frame of logs whose file changed. Each complete listing
2453
+ * replaces the map, which drops deleted paths.
2454
+ *
2455
+ * Reuse relies on this backend never rewriting a generation's header line
2456
+ * in place: publication creates a new file, append grows it, and repair
2457
+ * truncates its tail, so every content change moves the revision. The
2458
+ * revision is file metadata, not a byte checksum. A reused entry also
2459
+ * reuses the path-identity check its first read passed.
2460
+ */
2461
+ listedHeaders = /* @__PURE__ */ new Map();
2426
2462
  /** One joinable decode/migration operation per selected historical Session file revision. */
2427
2463
  migrationPreparations = /* @__PURE__ */ new Map();
2428
- constructor(ctx, config, tracker) {
2464
+ /**
2465
+ * @param ctx - context used for scoped diagnostics and filesystem reads.
2466
+ * @param config - JSONL root, physical encoding, and listing concurrency.
2467
+ * @param tracker - handle bookkeeping; omitted creates bookkeeping for legacy reads.
2468
+ */
2469
+ constructor(ctx, config, tracker = new JsonlBackendTracker("session-persistence-jsonl")) {
2429
2470
  super(ctx);
2430
2471
  this.config = config;
2431
2472
  this.tracker = tracker;
@@ -2454,17 +2495,50 @@ var JsonlSessionPersistence = class extends SessionPersistence {
2454
2495
  };
2455
2496
  }
2456
2497
  /**
2498
+ * Prepare logical history while the caller retains Session write ownership.
2499
+ * @param id - stored Session identity.
2500
+ * @param signal - optional cancellation for decoding and destination publication.
2501
+ * @returns a commit operation that validates related sources before publishing the history.
2502
+ */
2503
+ async prepare(id, signal) {
2504
+ await this.ensureRootEncoding();
2505
+ signal?.throwIfAborted();
2506
+ const stored = await this.requireStoredLog(id, signal);
2507
+ const snapshot = {
2508
+ header: stored.meta,
2509
+ inheritedEventCount: stored.inheritedEventCount,
2510
+ events: stored.events
2511
+ };
2512
+ return { commit: async (publish) => {
2513
+ signal?.throwIfAborted();
2514
+ if (stored.status === "prepared") await stored.validateRelatedSources();
2515
+ signal?.throwIfAborted();
2516
+ await publish(snapshot);
2517
+ } };
2518
+ }
2519
+ /**
2520
+ * Check whether a JSONL artifact occupies the Session identity.
2521
+ * @param id - stored Session identity.
2522
+ * @returns whether the artifact exists.
2523
+ */
2524
+ async hasStoredJsonl(id) {
2525
+ await this.ensureRootEncoding();
2526
+ return await this.findLog(id) !== void 0;
2527
+ }
2528
+ /**
2457
2529
  * Create a new stored session and take its write ownership. The session is
2458
2530
  * visible to this process immediately; the physical artifact appears on the
2459
- * first append or flush.
2531
+ * first append or flush. A fork source copies its complete history into
2532
+ * the child artifact before creation resolves.
2460
2533
  * @param header - the immutable header to store; must be losslessly
2461
2534
  * JSON-serializable with a non-negative safe-integer `createdAt`.
2462
- * @param options - optional cancellation.
2535
+ * @param options - optional cancellation, inherited prefix length, and fork source.
2463
2536
  * @returns the owned write handle.
2464
2537
  */
2465
2538
  async create(header, options) {
2466
2539
  options?.signal?.throwIfAborted();
2467
2540
  const snapshot = materializeCreateHeader(header);
2541
+ const seed = options?.parentSource?.events;
2468
2542
  toHeaderLine(snapshot, options?.inheritedEventCount);
2469
2543
  const inheritedEventCount = SessionLogOffset(options?.inheritedEventCount ?? 0);
2470
2544
  await this.ensureRootEncoding();
@@ -2472,11 +2546,24 @@ var JsonlSessionPersistence = class extends SessionPersistence {
2472
2546
  if (this.tracker.hasPending(snapshot.id) || await this.findLog(snapshot.id, options?.signal) !== void 0) throw new SessionAlreadyExistsError(snapshot.id);
2473
2547
  options?.signal?.throwIfAborted();
2474
2548
  this.tracker.registerCreated(snapshot, inheritedEventCount);
2475
- return this.tracker.adopt(new JsonlSessionHandle(this, snapshot.id, snapshot, "write", {
2549
+ const handle = this.tracker.adopt(new JsonlSessionHandle(this, snapshot.id, snapshot, "write", {
2476
2550
  cursor: 0,
2477
2551
  materialized: false,
2478
2552
  inheritedEventCount
2479
2553
  }));
2554
+ if (seed === void 0) return handle;
2555
+ try {
2556
+ if (seed.length === 0) await handle.flush(options);
2557
+ else await handle.append(seed, options);
2558
+ return handle;
2559
+ } catch (error) {
2560
+ try {
2561
+ await handle.close();
2562
+ } catch (closeError) {
2563
+ throw new AggregateError([error, closeError], "Fork creation and handle cleanup failed");
2564
+ }
2565
+ throw error;
2566
+ }
2480
2567
  }
2481
2568
  /**
2482
2569
  * Open an existing stored session for `read` or single-writer `write`.
@@ -2489,6 +2576,8 @@ var JsonlSessionPersistence = class extends SessionPersistence {
2489
2576
  options?.signal?.throwIfAborted();
2490
2577
  await this.ensureRootEncoding();
2491
2578
  options?.signal?.throwIfAborted();
2579
+ if (access === "read") await this.tracker.closeCompletion(id);
2580
+ options?.signal?.throwIfAborted();
2492
2581
  const pending = this.tracker.pendingOf(id);
2493
2582
  if (access === "read") {
2494
2583
  if (pending !== void 0) return this.tracker.adopt(new JsonlSessionHandle(this, id, pending.header, "read", {
@@ -2585,7 +2674,7 @@ var JsonlSessionPersistence = class extends SessionPersistence {
2585
2674
  options?.signal?.throwIfAborted();
2586
2675
  return {
2587
2676
  ...metadata,
2588
- revision: selected.sourceVersion < SESSION_FORMAT_VERSION ? SessionPersistenceRevision(`${fileRevision(identity)}:${await this.historicalCorpusRevision(options?.signal)}`) : fileRevision(identity),
2677
+ revision: selected.sourceVersion < SESSION_FORMAT_VERSION ? brandString(`${fileRevision(identity)}:${await this.historicalCorpusRevision(options?.signal)}`) : fileRevision(identity),
2589
2678
  sizeBytes: Number(identity.size),
2590
2679
  location: {
2591
2680
  kind: "jsonl",
@@ -2609,31 +2698,15 @@ var JsonlSessionPersistence = class extends SessionPersistence {
2609
2698
  const snapshots = [];
2610
2699
  const listed = /* @__PURE__ */ new Set();
2611
2700
  const pending = [...this.tracker.pendingEntries()];
2612
- const artifacts = await this.listArtifacts(signal);
2613
- const corpusRevision = artifacts.some((artifact) => artifact.sourceVersion < SESSION_FORMAT_VERSION) ? await this.historicalCorpusRevision(signal) : void 0;
2614
- const statted = settledValues(await settleLimited(this.listLimit, artifacts, async (artifact) => {
2615
- signal?.throwIfAborted();
2616
- try {
2617
- const identity = await stat(artifact.path, { bigint: true });
2618
- signal?.throwIfAborted();
2619
- return {
2620
- artifact,
2621
- identity
2622
- };
2623
- } catch (error) {
2624
- signal?.throwIfAborted();
2625
- if (!isENOENT(error)) throw error;
2626
- return;
2627
- }
2628
- }));
2629
- for (const entry of statted) {
2630
- if (entry === void 0) continue;
2631
- const { artifact, identity } = entry;
2701
+ const { artifacts, revisions } = await this.listArtifacts(signal);
2702
+ const corpusRevision = artifacts.some((artifact) => artifact.sourceVersion < SESSION_FORMAT_VERSION) ? corpusDigest(revisions) : void 0;
2703
+ for (const artifact of artifacts) {
2704
+ const { identity } = artifact;
2632
2705
  listed.add(artifact.header.id);
2633
2706
  snapshots.push({
2634
- header: artifact.header,
2707
+ header: { ...artifact.header },
2635
2708
  formatStatus: artifact.formatStatus,
2636
- revision: artifact.sourceVersion < SESSION_FORMAT_VERSION ? SessionPersistenceRevision(`${fileRevision(identity)}:${corpusRevision}`) : fileRevision(identity),
2709
+ revision: artifact.sourceVersion < SESSION_FORMAT_VERSION ? brandString(`${fileRevision(identity)}:${corpusRevision}`) : fileRevision(identity),
2637
2710
  sizeBytes: Number(identity.size),
2638
2711
  location: {
2639
2712
  kind: "jsonl",
@@ -2650,6 +2723,8 @@ var JsonlSessionPersistence = class extends SessionPersistence {
2650
2723
  }
2651
2724
  /** Resolve and read one stored log, refusing loudly when the artifact is absent. */
2652
2725
  async requireStoredLog(id, signal) {
2726
+ await this.tracker.closeCompletion(id);
2727
+ signal?.throwIfAborted();
2653
2728
  const selected = await this.findLog(id, signal);
2654
2729
  if (selected === void 0) throw new SessionPersistenceNotFoundError(id);
2655
2730
  if (selected.sourceVersion < SESSION_FORMAT_VERSION) {
@@ -2733,10 +2808,10 @@ var JsonlSessionPersistence = class extends SessionPersistence {
2733
2808
  let prepared;
2734
2809
  let validateRelatedSources;
2735
2810
  try {
2736
- const children = async () => (await this.listArtifacts(signal)).filter((source) => source.header.origin === "subagent" && source.header.parentSession === id);
2811
+ const children = async () => (await this.listArtifacts(signal)).artifacts.filter((source) => source.header.origin === "subagent" && source.header.parentSession === id);
2737
2812
  const sources = await children();
2738
2813
  const related = await prepareCatalogFacts(id, sources, this.compression, signal);
2739
- for (const failure of related.failures) this.ctx.logger.warn(`${this.name}: session "${id}" catalog retained a child with unknown descriptor (raw log: ${failure.path}): ${String(failure.error)}`);
2814
+ for (const failure of related.failures) this.ctx.logger.warn(`${name}: session "${id}" catalog retained a child with unknown descriptor (raw log: ${failure.path}): ${String(failure.error)}`);
2740
2815
  const membership = sources.map((source) => source.path).sort();
2741
2816
  validateRelatedSources = async () => {
2742
2817
  const current = (await children()).map((source) => source.path).sort();
@@ -2946,7 +3021,7 @@ var JsonlSessionPersistence = class extends SessionPersistence {
2946
3021
  async truncateTornTail(header, truncateTo) {
2947
3022
  this.coldLogMemo.delete(header.id);
2948
3023
  await this.repair(header, truncateTo);
2949
- this.ctx.logger.warn(`${this.name}: session "${header.id}" recovered from a torn tail; incomplete tail bytes were discarded`);
3024
+ this.ctx.logger.warn(`${name}: session "${header.id}" recovered from a torn tail; incomplete tail bytes were discarded`);
2950
3025
  }
2951
3026
  /**
2952
3027
  * Whether this process still tracks a created-but-unmaterialized session.
@@ -3086,63 +3161,94 @@ var JsonlSessionPersistence = class extends SessionPersistence {
3086
3161
  }
3087
3162
  /** Historical logical events depend on the corpus, including members with unreadable headers. */
3088
3163
  async historicalCorpusRevision(signal) {
3089
- const paths = (await this.listGenerations(signal)).map((source) => source.sourcePath).sort();
3164
+ const paths = (await this.listGenerations(signal)).map((source) => source.sourcePath);
3090
3165
  const entries = settledValues(await settleLimited(this.listLimit, paths, async (path) => {
3091
3166
  signal?.throwIfAborted();
3092
3167
  try {
3093
- return {
3094
- path,
3095
- revision: fileRevision(await stat(path, { bigint: true }))
3096
- };
3168
+ return [path, fileRevision(await stat(path, { bigint: true }))];
3097
3169
  } catch (error) {
3098
3170
  if (!isENOENT(error)) throw error;
3099
- return {
3100
- path,
3101
- revision: "missing"
3102
- };
3171
+ return [path, "missing"];
3103
3172
  }
3104
3173
  }));
3105
- const hash = createHash("sha256");
3106
- for (const { path, revision } of entries) hash.update(JSON.stringify([path, revision]));
3107
3174
  signal?.throwIfAborted();
3108
- return hash.digest("hex");
3175
+ return corpusDigest(entries);
3109
3176
  }
3177
+ /**
3178
+ * Read every listed Session's generation header with one stat per generation.
3179
+ * @param signal - optional cancellation.
3180
+ * @returns the readable artifacts, and the revision of every generation
3181
+ * (`missing` when it vanished) for {@link corpusDigest}.
3182
+ */
3110
3183
  async listArtifacts(signal) {
3111
3184
  signal?.throwIfAborted();
3112
3185
  await this.ensureRootEncoding();
3113
3186
  signal?.throwIfAborted();
3114
3187
  const generations = await this.listGenerations(signal);
3188
+ const previous = this.listedHeaders;
3189
+ const listed = /* @__PURE__ */ new Map();
3115
3190
  const headers = await settleLimited(this.listLimit, generations, async (selected) => {
3116
3191
  signal?.throwIfAborted();
3192
+ let identity;
3117
3193
  try {
3118
- return {
3119
- selected,
3120
- metadata: await this.readGenerationHeader(selected, void 0, signal)
3121
- };
3194
+ identity = await stat(selected.sourcePath, { bigint: true });
3122
3195
  } catch (error) {
3123
- if (error instanceof SessionFormatUnsupportedError || error instanceof SessionPersistenceCorruptionError) return {
3196
+ signal?.throwIfAborted();
3197
+ if (!isENOENT(error)) throw error;
3198
+ return {
3124
3199
  selected,
3200
+ revision: "missing",
3201
+ identity: void 0,
3125
3202
  metadata: void 0
3126
3203
  };
3127
- throw error;
3128
3204
  }
3205
+ signal?.throwIfAborted();
3206
+ const revision = fileRevision(identity);
3207
+ const memo = previous.get(selected.sourcePath);
3208
+ const metadata = memo !== void 0 && memo.revision === revision ? memo.metadata : await this.readListedHeader(selected, signal);
3209
+ listed.set(selected.sourcePath, {
3210
+ revision,
3211
+ metadata
3212
+ });
3213
+ return {
3214
+ selected,
3215
+ revision,
3216
+ identity,
3217
+ metadata
3218
+ };
3129
3219
  });
3130
3220
  const artifacts = [];
3221
+ const revisions = [];
3131
3222
  const ids = /* @__PURE__ */ new Set();
3132
3223
  for (const outcome of headers) {
3133
3224
  if (outcome.status === "rejected") throw outcome.reason;
3134
- const { selected, metadata } = outcome.value;
3135
- if (metadata === void 0) continue;
3225
+ const { selected, revision, identity, metadata } = outcome.value;
3226
+ revisions.push([selected.sourcePath, revision]);
3227
+ if (identity === void 0 || metadata === void 0) continue;
3136
3228
  if (ids.has(metadata.header.id)) throw new Error(`duplicate JSONL session id "${metadata.header.id}" appears in multiple project directories`);
3137
3229
  ids.add(metadata.header.id);
3138
3230
  artifacts.push({
3139
3231
  ...metadata,
3140
3232
  path: selected.sourcePath,
3141
- sourceVersion: selected.sourceVersion
3233
+ sourceVersion: selected.sourceVersion,
3234
+ identity
3142
3235
  });
3143
3236
  }
3144
3237
  signal?.throwIfAborted();
3145
- return artifacts;
3238
+ this.listedHeaders = listed;
3239
+ return {
3240
+ artifacts,
3241
+ revisions
3242
+ };
3243
+ }
3244
+ /** Read one listed generation header; an unsupported or corrupt log is not a listed Session. */
3245
+ async readListedHeader(selected, signal) {
3246
+ try {
3247
+ return await this.readGenerationHeader(selected, void 0, signal);
3248
+ } catch (error) {
3249
+ if (error instanceof SessionFormatUnsupportedError || error instanceof SessionPersistenceCorruptionError) return;
3250
+ throw error;
3251
+ }
3146
3252
  }
3147
3253
  /** Read and translate one selected generation header without inspecting its body. */
3148
3254
  async readGenerationHeader(selected, expectedId, signal) {
@@ -3189,10 +3295,10 @@ var JsonlSessionPersistence = class extends SessionPersistence {
3189
3295
  if (header.version !== SESSION_FORMAT_VERSION) throw new Error(`format catalog returned non-current logical header v${header.version}`);
3190
3296
  return {
3191
3297
  version: SESSION_FORMAT_VERSION,
3192
- id: SessionId(header.id),
3298
+ id: brandString(header.id),
3193
3299
  createdAt: header.createdAt,
3194
3300
  ...header.cwd === void 0 ? {} : { cwd: header.cwd },
3195
- ...header.parentSession === void 0 ? {} : { parentSession: SessionId(header.parentSession) },
3301
+ ...header.parentSession === void 0 ? {} : { parentSession: brandString(header.parentSession) },
3196
3302
  isSeeded: header.isSeeded,
3197
3303
  ...header.origin === void 0 ? {} : { origin: header.origin },
3198
3304
  delegationDepth: header.delegationDepth,
@@ -3240,7 +3346,7 @@ var JsonlSessionPersistence = class extends SessionPersistence {
3240
3346
  await this.syncDirPosix(dir);
3241
3347
  try {
3242
3348
  await rm(tmp, { force: true });
3243
- } catch {}
3349
+ } catch (_redundantTempRemoveFailed) {}
3244
3350
  }
3245
3351
  /* v8 ignore stop */
3246
3352
  /* v8 ignore start -- native Windows coverage exercises this integration path */
@@ -3647,4 +3753,4 @@ async function apply(ctx, config) {
3647
3753
  await service.await();
3648
3754
  }
3649
3755
  //#endregion
3650
- export { Config, JsonlCompressionSchema, apply, name };
3756
+ export { Config, JsonlCompressionSchema, JsonlSessionPersistence, apply, name };
@@ -1 +1 @@
1
- {"version":3,"file":"generation.d.ts","sourceRoot":"","sources":["../../src/generation.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAQL,KAAK,UAAU,EAChB,MAAM,kBAAkB,CAAA;AAWzB,OAAO,KAAK,EACV,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,iCAAiC,CAAA;AAExC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAEnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAiBhD,+EAA+E;AAC/E,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;IAC/B,gFAAgF;IAChF,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,oBAAoB,CAAA;IACpE,wEAAwE;IACxE,YAAY,CAAC,MAAM,EAAE,qBAAqB,CAAC,QAAQ,CAAC,EAAE,mBAAmB,EAAE,MAAM,GAAG,sBAAsB,CAAA;IAC1G,uCAAuC;IACvC,WAAW,CAAC,KAAK,EAAE,qBAAqB,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GAAG,sBAAsB,CAAA;IACnF,4EAA4E;IAC5E,2BAA2B,CAAC,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,KAAK,CAAA;CAC7D;AAED,iGAAiG;AACjG,MAAM,WAAW,4BAA4B;IAC3C,qGAAqG;IACrG,QAAQ,CAAC,sBAAsB,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IACrD,6DAA6D;IAC7D,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,8FAA8F;IAC9F,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAC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