Merge remote-tracking branch 'origin/master' into jsonl-packed-chunk-rows

Master's Zstandard physical encoding (#416) and this branch's packed chunk
rows compose as orthogonal layers: packChunks shapes the logical storage
records, compression shapes the physical bytes. The backend keeps both
config keys; eventLines(events, packChunks) replaces master's singular
eventLine helper and feeds encodeMaterialization/encodeEventBatch so packed
rows flow through either encoding. Demo apps carry both passthroughs. The
packed-row layout tests pin compression: 'none' (they assert textual line
tags) and read through rawLogPath; zstd spec fixtures inline
JSON.stringify for verbatim lines.
This commit is contained in:
kingwl
2026-07-20 20:14:49 +08:00
54 changed files with 1240 additions and 143 deletions
@@ -13,8 +13,20 @@ import { join } from 'node:path'
import { decodeStorageRecord, packChunkRuns } from '@deepseek-ai/dsh-session'
import type { SessionEvent, SessionHeader, SessionId, StorageRecord } from '@deepseek-ai/dsh-session'
/** Physical encoding selected for JSONL session artifacts. */
export type JsonlCompression = 'zstd' | 'none'
/**
* The first line of a session's `.jsonl` file: the immutable
* Return the artifact suffix for one physical encoding.
* @param compression - configured JSONL artifact encoding.
* @returns `.jsonl.zstd` for Zstandard or `.jsonl` for plaintext.
*/
export function logSuffix(compression: JsonlCompression): '.jsonl.zstd' | '.jsonl' {
return compression === 'zstd' ? '.jsonl.zstd' : '.jsonl'
}
/**
* The first JSONL record of a session artifact: the immutable
* {@link SessionHeader} tagged as a `session` record so a reader can tell it
* apart from an event line.
*/
@@ -127,10 +139,16 @@ export function sessionDir(root: string, cwd: string | undefined): string {
* @param root - the backend's session root directory.
* @param cwd - the session's project directory (picks the per-cwd bucket; `undefined` → `_no-cwd`).
* @param id - the session id, path-encoded via {@link encodeSegment} before filesystem use.
* @returns the session's `.jsonl` log file path.
* @param compression - physical artifact encoding and filename suffix.
* @returns the session's configured JSONL artifact path.
*/
export function logPath(root: string, cwd: string | undefined, id: SessionId): string {
return join(sessionDir(root, cwd), `${encodeSegment(id)}.jsonl`)
export function logPath(
root: string,
cwd: string | undefined,
id: SessionId,
compression: JsonlCompression,
): string {
return join(sessionDir(root, cwd), `${encodeSegment(id)}${logSuffix(compression)}`)
}
/**