@x1a0f3n9/dsh-session-persistence-jsonl 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/LICENSE +21 -0
- package/README.i18n.yaml +6 -0
- package/README.md +170 -0
- package/README.zh.md +170 -0
- package/lib/index.js +3726 -0
- package/lib/types/format.d.ts +209 -0
- package/lib/types/generation.d.ts +163 -0
- package/lib/types/history-suffix.d.ts +16 -0
- package/lib/types/index.d.ts +304 -0
- package/lib/types/lease.d.ts +57 -0
- package/lib/types/migration-verifier.d.ts +15 -0
- package/lib/types/storage.d.ts +263 -0
- package/lib/types/testing/generation.d.ts +8 -0
- package/lib/types/win32.d.ts +48 -0
- package/lib/types/worker.d.ts +3 -0
- package/lib/types/zstd-private-decoder.d.ts +33 -0
- package/lib/types/zstd-public-decoder.d.ts +15 -0
- package/lib/types/zstd.d.ts +68 -0
- package/lib/worker.cjs +1246 -0
- package/package.json +50 -0
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* On-disk format helpers for the JSONL session-persistence backend: path
|
|
3
|
+
* sanitization (a {@link SessionId} is an unvalidated branded string, so it
|
|
4
|
+
* MUST be encoded before use in a path — no traversal, no collision), the
|
|
5
|
+
* per-project/session directory layout, header-line (de)serialization, and the
|
|
6
|
+
* truncation-repair offset computation.
|
|
7
|
+
*
|
|
8
|
+
* @module dsh-session-persistence-jsonl/format
|
|
9
|
+
*/
|
|
10
|
+
import type { SessionEvent, SessionHeader, SessionId, SessionLogOffset as SessionLogOffsetType } from '@x1a0f3n9/dsh-session';
|
|
11
|
+
import type { SessionFormatRecovery, SessionFormatRestore } from '@x1a0f3n9/dsh-session-format';
|
|
12
|
+
/** Physical encoding selected for JSONL session artifacts. */
|
|
13
|
+
export type JsonlCompression = 'zstd' | 'none';
|
|
14
|
+
/**
|
|
15
|
+
* Return the artifact suffix for one physical encoding.
|
|
16
|
+
* @param compression - configured JSONL artifact encoding.
|
|
17
|
+
* @returns `.jsonl.zstd` for Zstandard or `.jsonl` for plaintext.
|
|
18
|
+
*/
|
|
19
|
+
export declare function logSuffix(compression: JsonlCompression): '.jsonl.zstd' | '.jsonl';
|
|
20
|
+
/**
|
|
21
|
+
* Return the canonical filename for one immutable Session format generation.
|
|
22
|
+
* Version zero retains the original suffix-only name; every later generation
|
|
23
|
+
* carries a lowercase numeric `vN` component.
|
|
24
|
+
* @param version - non-negative safe Session format version.
|
|
25
|
+
* @param compression - configured JSONL artifact encoding.
|
|
26
|
+
* @returns the generation filename inside one Session directory.
|
|
27
|
+
*/
|
|
28
|
+
export declare function generationLogFilename(version: number, compression: JsonlCompression): string;
|
|
29
|
+
/**
|
|
30
|
+
* Parse one canonical generation filename for the selected physical encoding.
|
|
31
|
+
* Noncanonical, temporary, uppercase, leading-zero, and version-zero-tagged names do
|
|
32
|
+
* not identify committed generations.
|
|
33
|
+
* @param filename - one entry from a Session directory.
|
|
34
|
+
* @param compression - configured JSONL artifact encoding.
|
|
35
|
+
* @returns its format version, or `undefined` when the name is not canonical.
|
|
36
|
+
*/
|
|
37
|
+
export declare function parseGenerationLogFilename(filename: string, compression: JsonlCompression): number | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* The current physical header stored as the first JSONL record. The exact
|
|
40
|
+
* inherited cut lives on the last tagged `session/end-seed` event.
|
|
41
|
+
*/
|
|
42
|
+
interface HeaderLine {
|
|
43
|
+
type: 'session';
|
|
44
|
+
version: number;
|
|
45
|
+
id: SessionId;
|
|
46
|
+
createdAt: number;
|
|
47
|
+
cwd?: string;
|
|
48
|
+
parentSession?: SessionId;
|
|
49
|
+
isSeeded: boolean;
|
|
50
|
+
origin?: 'subagent';
|
|
51
|
+
delegationDepth: number;
|
|
52
|
+
agentPreset?: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Refuse policy fields that never belong to a released Session header.
|
|
56
|
+
* @param value - parsed physical header candidate.
|
|
57
|
+
* @returns nothing after successful validation.
|
|
58
|
+
*/
|
|
59
|
+
export declare function assertNoRetiredHeaderFields(value: unknown): void;
|
|
60
|
+
/**
|
|
61
|
+
* Build the header line object from a {@link SessionHeader}.
|
|
62
|
+
* @param header - the immutable session metadata to serialize.
|
|
63
|
+
* @param inheritedEventCount - exact inherited prefix length; required for a
|
|
64
|
+
* seeded header and omitted only for an unseeded header.
|
|
65
|
+
* @returns the `type: 'session'`-tagged line object, absent optional fields omitted (never null).
|
|
66
|
+
*/
|
|
67
|
+
export declare function toHeaderLine(header: SessionHeader, inheritedEventCount?: SessionLogOffsetType): HeaderLine;
|
|
68
|
+
/**
|
|
69
|
+
* Encode an arbitrary string as a single safe path segment, injectively over ALL JS (UTF-16)
|
|
70
|
+
* strings — including lone surrogates. A {@link SessionId} is an unvalidated branded string,
|
|
71
|
+
* so this neutralizes `../`, absolute paths, NUL, and separators before any filesystem use.
|
|
72
|
+
* Safe code units remain literal; every other unit, including `~`, becomes
|
|
73
|
+
* `~XXXX`. Operating on code units preserves lone surrogates, while special-
|
|
74
|
+
* casing `.` and `..` prevents traversal by an otherwise safe whole segment.
|
|
75
|
+
*
|
|
76
|
+
* @param raw - the string to encode; must be non-empty (throws on `''`).
|
|
77
|
+
* @returns the escaped single path segment, decodable back to `raw`.
|
|
78
|
+
*/
|
|
79
|
+
export declare function encodeSegment(raw: string): string;
|
|
80
|
+
/**
|
|
81
|
+
* Build the readable directory key for a project path.
|
|
82
|
+
* Filesystem separators and drive separators become `-`; unsafe code units use
|
|
83
|
+
* the same `~XXXX` escape as session ids. The key is bounded for filesystem
|
|
84
|
+
* component limits. Separator replacement and truncation are intentionally
|
|
85
|
+
* lossy, following the common human-navigable project-directory convention.
|
|
86
|
+
* @param cwd - the session's project directory.
|
|
87
|
+
* @returns a single filesystem-safe project directory name.
|
|
88
|
+
*/
|
|
89
|
+
export declare function projectKey(cwd: string): string;
|
|
90
|
+
/**
|
|
91
|
+
* The configured root's human-navigable project directory. A configured root
|
|
92
|
+
* may be local or shared; this grouping does not prescribe its deployment.
|
|
93
|
+
* @param root - the backend's session root directory.
|
|
94
|
+
* @param cwd - the session's project directory; `undefined` selects `_no-cwd`.
|
|
95
|
+
* @returns the project directory path under `root`.
|
|
96
|
+
*/
|
|
97
|
+
export declare function projectDir(root: string, cwd: string | undefined): string;
|
|
98
|
+
/**
|
|
99
|
+
* The directory owned by one session and available for future session-local
|
|
100
|
+
* artifacts.
|
|
101
|
+
* @param root - the backend's session root directory.
|
|
102
|
+
* @param cwd - the session's project directory.
|
|
103
|
+
* @param id - the session id, encoded to one safe path segment.
|
|
104
|
+
* @returns the session directory beneath its project directory.
|
|
105
|
+
*/
|
|
106
|
+
export declare function sessionDir(root: string, cwd: string | undefined, id: SessionId): string;
|
|
107
|
+
/**
|
|
108
|
+
* Build one immutable Session format generation path.
|
|
109
|
+
* @param root - the backend's session root directory.
|
|
110
|
+
* @param cwd - the session's project directory (`undefined` → `_no-cwd`).
|
|
111
|
+
* @param id - the session id, path-encoded via {@link encodeSegment} before filesystem use.
|
|
112
|
+
* @param version - physical Session format generation.
|
|
113
|
+
* @param compression - physical artifact encoding and filename suffix.
|
|
114
|
+
* @returns the selected generation's configured JSONL artifact path.
|
|
115
|
+
*/
|
|
116
|
+
export declare function generationLogPath(root: string, cwd: string | undefined, id: SessionId, version: number, compression: JsonlCompression): string;
|
|
117
|
+
/**
|
|
118
|
+
* Build the current generation's append target path for a Session.
|
|
119
|
+
* @param root - the backend's session root directory.
|
|
120
|
+
* @param cwd - the session's project directory (`undefined` → `_no-cwd`).
|
|
121
|
+
* @param id - the session id, path-encoded via {@link encodeSegment} before filesystem use.
|
|
122
|
+
* @param compression - physical artifact encoding and filename suffix.
|
|
123
|
+
* @returns the current Session format generation path.
|
|
124
|
+
*/
|
|
125
|
+
export declare function logPath(root: string, cwd: string | undefined, id: SessionId, compression: JsonlCompression): string;
|
|
126
|
+
/**
|
|
127
|
+
* Serialize a current event batch as JSONL lines (no trailing newline). Compact
|
|
128
|
+
* Assistant streams are nested event data; every event occupies one row.
|
|
129
|
+
* @param events - the batch to serialize, in log order.
|
|
130
|
+
* @returns the batch's JSONL text; the writer adds the final newline.
|
|
131
|
+
*/
|
|
132
|
+
export declare function eventLines(events: readonly SessionEvent[]): string;
|
|
133
|
+
/**
|
|
134
|
+
* Serialize one current event as one JSONL record without its trailing newline.
|
|
135
|
+
* @param event - current event to encode.
|
|
136
|
+
* @returns one physical JSON record.
|
|
137
|
+
*/
|
|
138
|
+
export declare function eventLine(event: SessionEvent): string;
|
|
139
|
+
interface SessionLogScan {
|
|
140
|
+
meta: SessionHeader;
|
|
141
|
+
inheritedEventCount: SessionLogOffsetType;
|
|
142
|
+
events: SessionEvent[];
|
|
143
|
+
committedBytes: number;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Parse one complete header record supplied independently from event rows.
|
|
147
|
+
* @param record - the complete first JSONL record, including its newline.
|
|
148
|
+
* @returns logical metadata and a restore stream positioned after the header.
|
|
149
|
+
*/
|
|
150
|
+
export declare function parseHeaderRecord(record: Buffer): {
|
|
151
|
+
readonly meta: SessionHeader;
|
|
152
|
+
readonly restore: SessionFormatRestore;
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Incrementally scan complete JSONL event records after an independently
|
|
156
|
+
* supplied header record. Newline search and byte offsets stay on raw buffers;
|
|
157
|
+
* only complete records are decoded to UTF-8. A fragment crossing writes is
|
|
158
|
+
* copied because a decoder may reuse its output buffer after `write()` returns.
|
|
159
|
+
*/
|
|
160
|
+
export declare class SessionLogScanner {
|
|
161
|
+
private readonly recovery;
|
|
162
|
+
private readonly meta;
|
|
163
|
+
private readonly restore;
|
|
164
|
+
private eventCount;
|
|
165
|
+
private fragments;
|
|
166
|
+
private fragmentBytes;
|
|
167
|
+
private inputBytes;
|
|
168
|
+
private committedBytes;
|
|
169
|
+
private eventLine;
|
|
170
|
+
private issue;
|
|
171
|
+
private finished;
|
|
172
|
+
/**
|
|
173
|
+
* Create an event scanner from exactly one newline-terminated header record.
|
|
174
|
+
* @param headerRecord - the complete first JSONL record, including its newline.
|
|
175
|
+
*/
|
|
176
|
+
constructor(headerRecord: Buffer, recovery?: SessionFormatRecovery);
|
|
177
|
+
/**
|
|
178
|
+
* Consume the next raw plaintext chunk, retaining only an incomplete final record.
|
|
179
|
+
* @param chunk - bytes immediately following all previously supplied bytes.
|
|
180
|
+
*/
|
|
181
|
+
write(chunk: Buffer): void;
|
|
182
|
+
/**
|
|
183
|
+
* Snapshot progress before appending a recoverable torn-frame prefix.
|
|
184
|
+
* @returns byte, committed-prefix, and expanded-event cursors.
|
|
185
|
+
*/
|
|
186
|
+
checkpoint(): {
|
|
187
|
+
inputBytes: number;
|
|
188
|
+
committedBytes: number;
|
|
189
|
+
eventCount: SessionLogOffsetType;
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* Finish scanning, ignoring a final record without a newline as a torn tail.
|
|
193
|
+
* @returns the header, contiguous event prefix, and safe truncation offset.
|
|
194
|
+
*/
|
|
195
|
+
finish(): SessionLogScan;
|
|
196
|
+
/** Decode one complete event row and update the contiguous prefix. */
|
|
197
|
+
private consumeEventLine;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Parse a complete or torn JSONL buffer into its preserved event prefix. This
|
|
201
|
+
* compatibility wrapper supplies the first record separately, then delegates
|
|
202
|
+
* event rows to {@link SessionLogScanner}.
|
|
203
|
+
*
|
|
204
|
+
* @param buffer - the raw bytes of the log file (header line first).
|
|
205
|
+
* @returns the header, preserved event prefix, and byte offset safe to append at.
|
|
206
|
+
*/
|
|
207
|
+
export declare function scanLog(buffer: Buffer): SessionLogScan;
|
|
208
|
+
export {};
|
|
209
|
+
//# sourceMappingURL=format.d.ts.map
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Durable whole-generation publication for JSONL Session artifacts.
|
|
3
|
+
*
|
|
4
|
+
* Format packages transform parsed JSON values. This module owns the physical
|
|
5
|
+
* encoding, exact source identity, immutable generation files, and exclusive
|
|
6
|
+
* current-generation publication for both configured JSONL suffixes.
|
|
7
|
+
* @module @x1a0f3n9/dsh-session-persistence-jsonl/generation
|
|
8
|
+
*/
|
|
9
|
+
import { type FileHandle } from 'node:fs/promises';
|
|
10
|
+
import type { SessionFormatArtifact, SessionFormatJsonValue, SessionFormatRestore } from '@x1a0f3n9/dsh-session-format';
|
|
11
|
+
import type { JsonlCompression } from './format.ts';
|
|
12
|
+
import { publishNewFileWin32 } from './win32.ts';
|
|
13
|
+
/** Pure adapter between backend-owned JSONL framing and the format catalog. */
|
|
14
|
+
export interface JsonlGenerationFormatAdapter {
|
|
15
|
+
readonly currentVersion: number;
|
|
16
|
+
/** Create the single-pass codec and migration state for a historical header. */
|
|
17
|
+
createRestore(header: Record<string, unknown>): SessionFormatRestore;
|
|
18
|
+
/** Encode one current header record without materializing body rows. */
|
|
19
|
+
encodeHeader(header: SessionFormatArtifact['header'], inheritedEventCount: number): SessionFormatJsonValue;
|
|
20
|
+
/** Encode one current event record. */
|
|
21
|
+
encodeEvent(event: SessionFormatArtifact['events'][number]): SessionFormatJsonValue;
|
|
22
|
+
/** Classify a supported-version artifact that policy refuses to migrate. */
|
|
23
|
+
isUnsupportedMigrationError?(error: unknown): error is Error;
|
|
24
|
+
}
|
|
25
|
+
/** Inputs for preparing one historical generation and publishing its current successor later. */
|
|
26
|
+
export interface PrepareJsonlMigrationOptions {
|
|
27
|
+
/** Immutable generation selected by the backend resolver. */
|
|
28
|
+
readonly sourcePath: string;
|
|
29
|
+
/** Version selected from the source filename and independently checked against its header. */
|
|
30
|
+
readonly sourceVersion: number;
|
|
31
|
+
/** Canonical filename for `format.currentVersion` in the same Session directory. */
|
|
32
|
+
readonly currentPath: string;
|
|
33
|
+
readonly compression: JsonlCompression;
|
|
34
|
+
readonly format: JsonlGenerationFormatAdapter;
|
|
35
|
+
/** Validate one selected historical header's identity before any migration write. */
|
|
36
|
+
readonly validateHistoricalHeader?: (header: Readonly<Record<string, unknown>>) => void | Promise<void>;
|
|
37
|
+
/** Validate the staged file in an isolated worker before publication. */
|
|
38
|
+
readonly verifyCurrentFile: (path: string, compression: JsonlCompression, expectedId: string, expectedEventCount: number, expectedPrefix?: JsonlExpectedPrefix, signal?: AbortSignal) => Promise<JsonlVerifiedGeneration>;
|
|
39
|
+
readonly signal?: AbortSignal;
|
|
40
|
+
}
|
|
41
|
+
/** Small physical identity returned by an isolated generation verifier. */
|
|
42
|
+
export interface JsonlVerifiedGeneration {
|
|
43
|
+
readonly identity: JsonlPhysicalIdentity;
|
|
44
|
+
readonly bytes: number;
|
|
45
|
+
readonly digest: string;
|
|
46
|
+
}
|
|
47
|
+
/** Physical byte prefix already proven to be a valid complete generation. */
|
|
48
|
+
export interface JsonlExpectedPrefix {
|
|
49
|
+
readonly bytes: number;
|
|
50
|
+
readonly digest: string;
|
|
51
|
+
}
|
|
52
|
+
/** A historical source changed after its single decode and migration pass. */
|
|
53
|
+
export declare class JsonlGenerationSourceChangedError extends Error {
|
|
54
|
+
readonly path: string;
|
|
55
|
+
readonly name = "JsonlGenerationSourceChangedError";
|
|
56
|
+
/** @param path - historical generation whose revision changed. */
|
|
57
|
+
constructor(path: string);
|
|
58
|
+
}
|
|
59
|
+
/** Current logical state prepared independently from durable publication. */
|
|
60
|
+
export interface PreparedJsonlMigration {
|
|
61
|
+
readonly sourceIdentity: JsonlPhysicalIdentity;
|
|
62
|
+
readonly artifact: SessionFormatArtifact;
|
|
63
|
+
/** Encode, verify, and exclusively publish once; every call shares the same success or failure. */
|
|
64
|
+
publish(): Promise<JsonlPhysicalIdentity>;
|
|
65
|
+
}
|
|
66
|
+
/** A historical artifact is intact, but the format edge refuses its contents. */
|
|
67
|
+
export declare class JsonlGenerationUnsupportedMigrationError extends Error {
|
|
68
|
+
readonly fromVersion: number;
|
|
69
|
+
readonly reason: Error;
|
|
70
|
+
readonly name = "JsonlGenerationUnsupportedMigrationError";
|
|
71
|
+
/**
|
|
72
|
+
* @param fromVersion - unchanged source generation version.
|
|
73
|
+
* @param reason - format-edge refusal.
|
|
74
|
+
*/
|
|
75
|
+
constructor(fromVersion: number, reason: Error);
|
|
76
|
+
}
|
|
77
|
+
/** A current-generation filename already names different or invalid bytes. */
|
|
78
|
+
export declare class JsonlGenerationTargetConflictError extends Error {
|
|
79
|
+
readonly path: string;
|
|
80
|
+
readonly reason: Error;
|
|
81
|
+
readonly name = "JsonlGenerationTargetConflictError";
|
|
82
|
+
/**
|
|
83
|
+
* @param path - immutable target that prevented exclusive publication.
|
|
84
|
+
* @param reason - why the existing target cannot be accepted.
|
|
85
|
+
*/
|
|
86
|
+
constructor(path: string, reason: Error);
|
|
87
|
+
}
|
|
88
|
+
/** Stat identity captured together with exact generation bytes. */
|
|
89
|
+
export interface JsonlPhysicalIdentity {
|
|
90
|
+
readonly dev: bigint;
|
|
91
|
+
readonly ino: bigint;
|
|
92
|
+
readonly size: bigint;
|
|
93
|
+
readonly mtimeNs: bigint;
|
|
94
|
+
readonly ctimeNs: bigint;
|
|
95
|
+
}
|
|
96
|
+
/** Exact bytes of one stable file revision together with the stat identity that proved it stable. */
|
|
97
|
+
export interface StablePhysicalFile {
|
|
98
|
+
readonly bytes: Buffer;
|
|
99
|
+
readonly identity: JsonlPhysicalIdentity;
|
|
100
|
+
}
|
|
101
|
+
interface GenerationFileSystem {
|
|
102
|
+
open(path: string, flags: string, mode?: number): Promise<FileHandle>;
|
|
103
|
+
readFile(path: string, signal?: AbortSignal): Promise<Buffer>;
|
|
104
|
+
readdir(path: string): Promise<string[]>;
|
|
105
|
+
stat(path: string): Promise<JsonlPhysicalIdentity>;
|
|
106
|
+
lstat(path: string): Promise<{
|
|
107
|
+
isFile(): boolean;
|
|
108
|
+
isSymbolicLink(): boolean;
|
|
109
|
+
}>;
|
|
110
|
+
link(existingPath: string, newPath: string): Promise<void>;
|
|
111
|
+
rm(path: string): Promise<void>;
|
|
112
|
+
}
|
|
113
|
+
type GenerationBarrierPhase = 'before-source-check' | 'after-publication';
|
|
114
|
+
interface JsonlGenerationInternals {
|
|
115
|
+
readonly fs: GenerationFileSystem;
|
|
116
|
+
readonly randomToken: () => string;
|
|
117
|
+
readonly platform: NodeJS.Platform;
|
|
118
|
+
readonly publishNewWin32: typeof publishNewFileWin32;
|
|
119
|
+
readonly barrier: (phase: GenerationBarrierPhase, attempt: number) => void | Promise<void>;
|
|
120
|
+
}
|
|
121
|
+
/** Dependency overrides for an isolated generation runtime. */
|
|
122
|
+
export type JsonlGenerationRuntimeOverrides = Partial<Omit<JsonlGenerationInternals, 'fs'>> & {
|
|
123
|
+
readonly fs?: Partial<GenerationFileSystem>;
|
|
124
|
+
};
|
|
125
|
+
/** Bound generation operations used by production defaults and deterministic tests. */
|
|
126
|
+
export interface JsonlGenerationRuntime {
|
|
127
|
+
readStable(path: string, signal?: AbortSignal): Promise<StablePhysicalFile>;
|
|
128
|
+
prepare(options: PrepareJsonlMigrationOptions): Promise<PreparedJsonlMigration>;
|
|
129
|
+
verify(path: string, compression: JsonlCompression, expectedId: string, expectedEventCount: number, expectedPrefix?: JsonlExpectedPrefix): Promise<JsonlVerifiedGeneration>;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Read one stable revision of a JSONL file with a single retry. If an append
|
|
133
|
+
* overlaps both reads, return the second read's committed pre-read prefix
|
|
134
|
+
* instead of starving behind a continuous writer.
|
|
135
|
+
* @param path - the generation file to read.
|
|
136
|
+
* @param signal - optional cancellation for the stat/read work.
|
|
137
|
+
* @returns the stable bytes (or the committed prefix) and their stat identity.
|
|
138
|
+
*/
|
|
139
|
+
export declare function readStableJsonlFile(path: string, signal?: AbortSignal): Promise<StablePhysicalFile>;
|
|
140
|
+
/**
|
|
141
|
+
* Read and validate one complete current generation for an isolated verifier.
|
|
142
|
+
* @param path - staged or competing current-generation path.
|
|
143
|
+
* @param compression - configured physical encoding.
|
|
144
|
+
* @param expectedId - Session identity expected in the header.
|
|
145
|
+
* @param expectedEventCount - exact logical event count expected after decoding.
|
|
146
|
+
* @param expectedPrefix - verified migration prefix; an append tail may be present and is not validated.
|
|
147
|
+
* @returns stable physical identity and digest for publication comparison.
|
|
148
|
+
*/
|
|
149
|
+
export declare function verifyJsonlCurrentGeneration(path: string, compression: JsonlCompression, expectedId: string, expectedEventCount: number, expectedPrefix?: JsonlExpectedPrefix): Promise<JsonlVerifiedGeneration>;
|
|
150
|
+
/**
|
|
151
|
+
* Decode and migrate one historical generation without writing its successor.
|
|
152
|
+
* @param options - resolved source, current target, format adapter, and load cancellation.
|
|
153
|
+
* @returns the current artifact and an idempotent explicit publication operation.
|
|
154
|
+
*/
|
|
155
|
+
export declare function prepareJsonlMigration(options: PrepareJsonlMigrationOptions): Promise<PreparedJsonlMigration>;
|
|
156
|
+
/**
|
|
157
|
+
* Create one generation runtime with fixed filesystem and publication dependencies.
|
|
158
|
+
* @param overrides - deterministic filesystem, platform, and race dependencies.
|
|
159
|
+
* @returns bound generation operations.
|
|
160
|
+
*/
|
|
161
|
+
export declare function createJsonlGenerationRuntime(overrides?: JsonlGenerationRuntimeOverrides): JsonlGenerationRuntime;
|
|
162
|
+
export {};
|
|
163
|
+
//# sourceMappingURL=generation.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tail-page decoder for JSONL session logs. It scans cheap Zstandard frame
|
|
3
|
+
* boundaries and decompresses only the newest frames that cover one history
|
|
4
|
+
* page, without constructing a {@link SessionLogScanner} from seq 0.
|
|
5
|
+
*/
|
|
6
|
+
import type { SessionHistorySuffix, SessionHistorySuffixOptions } from '@x1a0f3n9/dsh-session-persistence';
|
|
7
|
+
import { type JsonlCompression } from './format.ts';
|
|
8
|
+
/**
|
|
9
|
+
* Decode one history-page suffix from a current-generation JSONL artifact.
|
|
10
|
+
* @param bytes - complete file bytes, possibly with a torn final Zstandard frame.
|
|
11
|
+
* @param compression - physical encoding of this generation.
|
|
12
|
+
* @param options - page bounds and cancellation.
|
|
13
|
+
* @returns header, covering events, and the logical cursor.
|
|
14
|
+
*/
|
|
15
|
+
export declare function readJsonlHistorySuffix(bytes: Buffer, compression: JsonlCompression, options: SessionHistorySuffixOptions): Promise<SessionHistorySuffix>;
|
|
16
|
+
//# sourceMappingURL=history-suffix.d.ts.map
|