@xneog/dsh-session-format-catalog 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DeepSeek
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,6 @@
1
+ # Bilingual-pair consistency record (docs/i18n/README.md): the git blob hash of each
2
+ # side as of the last confirmed-consistent state. Both languages carry equal authority;
3
+ # after editing either side, bring the other along and re-record with:
4
+ # pnpm run verify-translation-pairing --write packages/session/session-format-catalog/README.md
5
+ README.md: 81f6345b4d2123ea1f5981e3921777cb0f14d550
6
+ README.zh.md: 141c3f9dd78038835b13f7badaa65d59a69f45b7
package/README.md ADDED
@@ -0,0 +1,99 @@
1
+ ---
2
+ description: "Build-static first-party Session format codec and adjacent migration assembly for persistence readers."
3
+ kind: "package-library"
4
+ ---
5
+
6
+ # @xneog/dsh-session-format-catalog
7
+
8
+ English | [中文](README.zh.md)
9
+
10
+ ## Summary
11
+
12
+ `dsh-session-format-catalog` gives persistence one deterministic Session format reader without consulting mounted plugins. It assembles the frozen v0, v1, and v2 codecs with the adjacent v0-to-v1 and v1-to-v2 edges, checks the complete gap-free chain at module initialization, and exposes physical dispatch, header-only classification, migration, and current encoding through `sessionFormatCatalog`.
13
+
14
+ ## Table of Contents
15
+
16
+ - [Use this package](#use-this-package)
17
+ - [Understand the implementation](#understand-the-implementation)
18
+ - [Further Exploration](#further-exploration)
19
+ - [Model Experience](#model-experience)
20
+ - [Known Limitations and Deferred Work](#known-limitations-and-deferred-work)
21
+ - [Dev Note](#dev-note)
22
+
23
+ -----
24
+
25
+ <a id="use-this-package"></a>
26
+ ## Use this package
27
+
28
+ ### When to use it
29
+
30
+ Import this library from persistence and test-support readers that need the complete first-party released-format inventory before any feature plugin mounts. Feature compositions do not register or reorder its entries. No runtime invariant companion is published because construction rejects an invalid static inventory and each read validates its complete result; the catalog retains no independently mutable runtime relationship.
31
+
32
+ ### Entry point
33
+
34
+ ```text
35
+ const descriptor = sessionFormatCatalog.readHeader(physicalHeader)
36
+ const current = sessionFormatCatalog.migrate(sessionFormatCatalog.decodeArtifact(physicalHeader, rows))
37
+ ```
38
+
39
+ Import `sessionFormatCatalog` from the package root. JSONL readers pass parsed header and row JSON values to `decodeArtifact()` or `decodeRecoverableArtifact()`, migrate the logical result with `migrate()`, and serialize only the validated current artifact with `encodeCurrent()`. Listing calls `readHeader()` and never opens event bodies. Header reads validate every adjacent target and then restore the final header through the installed current Session package.
40
+
41
+ The catalog contains all supported historical readers directly. A profile cannot add, remove, or reorder an edge by mounting a feature plugin. Its peer dependency on `dsh-session` supplies the installed current event vocabulary and current restoration rules, while historical edge validators remain frozen.
42
+
43
+ -----
44
+
45
+ <a id="understand-the-implementation"></a>
46
+ ## Understand the implementation
47
+
48
+ <details>
49
+ <summary>Implementation internals — click to expand</summary>
50
+
51
+ [`src/generated.ts`](src/generated.ts) is the static owner of codec and edge ordering. [`src/current.ts`](src/current.ts) delegates final header, envelope, message, surface, seed, and current request-header validation to the installed Session semantics. The low-level constructor rejects duplicate codecs, duplicate edges, gaps, and entries beyond the current version before any Session read can begin.
52
+
53
+ </details>
54
+
55
+ -----
56
+
57
+ <a id="further-exploration"></a>
58
+ ## Further Exploration
59
+
60
+ - [Migration machinery](../session-format/README.md) — catalog construction and dispatch behavior.
61
+ - [Released v0 to v1 edge](../session-format-v0-to-v1/README.md) — codec and validator ownership.
62
+ - [Released v1 to v2 edge](../session-format-v1-to-v2/README.md) — Assistant stream embedding and cardinality-changing reference remapping.
63
+ - [JSONL persistence](../session-persistence-jsonl/README.md) — immutable generation naming and exclusive publication.
64
+
65
+ -----
66
+
67
+ <a id="model-experience"></a>
68
+ ## Model Experience
69
+
70
+ ### Catalog dispatch
71
+
72
+ #### What the model sees
73
+
74
+ Nothing directly. The catalog only restores the `SessionEvent` history consumed by request reconstruction.
75
+
76
+ #### Token effect
77
+
78
+ Zero direct tokens.
79
+
80
+ #### KV Cache effect
81
+
82
+ No direct effect; restored history determines cache identity in its consumer.
83
+
84
+ ## Known Limitations and Deferred Work
85
+
86
+ <a id="known-limitations-and-deferred-work"></a>
87
+
88
+ - **First-party build inventory only** — external migration ownership and distribution are not supported.
89
+ - **Generated ordering is closed** — runtime plugin registration cannot supply a missing historical edge.
90
+
91
+ <a id="dev-note"></a>
92
+ ### Dev Note
93
+
94
+ <details>
95
+ <summary>Working context for maintainers — click to expand</summary>
96
+
97
+ None.
98
+
99
+ </details>
package/README.zh.md ADDED
@@ -0,0 +1,99 @@
1
+ ---
2
+ description: "供持久化读取方使用的构建期静态第一方 Session 格式编解码器与相邻迁移装配。"
3
+ kind: "package-library"
4
+ ---
5
+
6
+ # @xneog/dsh-session-format-catalog
7
+
8
+ [English](README.md) | 中文
9
+
10
+ ## 概述
11
+
12
+ `dsh-session-format-catalog` 为持久化提供一个确定性的 Session 格式读取器,且无需查询已挂载插件。它把冻结的 v0、v1 与 v2 编解码器和相邻的 v0 到 v1、v1 到 v2 迁移边装配起来,在模块初始化时校验完整且无缺口的迁移链,并通过 `sessionFormatCatalog` 暴露物理分派、仅标头分类、迁移和当前格式编码。
13
+
14
+ ## 目录
15
+
16
+ - [使用本包](#use-this-package)
17
+ - [理解实现](#understand-the-implementation)
18
+ - [进一步探索](#further-exploration)
19
+ - [模型体验](#model-experience)
20
+ - [已知限制与延期工作](#known-limitations-and-deferred-work)
21
+ - [开发备注](#dev-note)
22
+
23
+ -----
24
+
25
+ <a id="use-this-package"></a>
26
+ ## 使用本包
27
+
28
+ ### 何时使用
29
+
30
+ 当持久化与测试支持读取方需要在任何功能插件挂载前取得完整第一方已发布格式清单时,导入本库。功能组合不会注册或重排其条目。它不发布运行时不变式伴生入口,因为构造过程会拒绝无效静态清单,每次读取也会校验完整结果;目录不保留可独立分叉的运行时可变关系。
31
+
32
+ ### 入口
33
+
34
+ ```text
35
+ const descriptor = sessionFormatCatalog.readHeader(physicalHeader)
36
+ const current = sessionFormatCatalog.migrate(sessionFormatCatalog.decodeArtifact(physicalHeader, rows))
37
+ ```
38
+
39
+ 从包根导入 `sessionFormatCatalog`。JSONL 读取方把解析后的标头与行 JSON 值传给 `decodeArtifact()` 或 `decodeRecoverableArtifact()`,使用 `migrate()` 迁移逻辑结果,并且只使用 `encodeCurrent()` 序列化经过校验的当前产物。列表读取调用 `readHeader()`,绝不打开事件正文。标头读取会校验每个相邻目标,然后通过已安装的当前 Session 包还原最终标头。
40
+
41
+ 该目录直接包含所有受支持的历史读取器。Profile 无法通过挂载功能插件来添加、移除或重新排列迁移边。它通过对 `dsh-session` 的 peer 依赖获得已安装的当前事件词表与当前还原规则,而历史迁移边校验器保持冻结。
42
+
43
+ -----
44
+
45
+ <a id="understand-the-implementation"></a>
46
+ ## 理解实现
47
+
48
+ <details>
49
+ <summary>实现细节——点击展开</summary>
50
+
51
+ [`src/generated.ts`](src/generated.ts) 是编解码器与迁移边顺序的静态所有者。[`src/current.ts`](src/current.ts) 把最终标头、事件信封、消息、表面、种子和当前请求标头校验委托给已安装的 Session 语义。底层构造函数会在开始读取任何 Session 之前拒绝重复编解码器、重复迁移边、缺口,以及超过当前版本的条目。
52
+
53
+ </details>
54
+
55
+ -----
56
+
57
+ <a id="further-exploration"></a>
58
+ ## 进一步探索
59
+
60
+ - [迁移机制](../session-format/README.zh.md)——目录构造与分派行为。
61
+ - [已发布 v0 到 v1 迁移边](../session-format-v0-to-v1/README.zh.md)——编解码器与校验器所有权。
62
+ - [已发布 v1 到 v2 迁移边](../session-format-v1-to-v2/README.zh.md)——Assistant stream 嵌入与基数变化引用重映射。
63
+ - [JSONL 持久化](../session-persistence-jsonl/README.zh.md)——不可变 generation 命名与排他发布。
64
+
65
+ -----
66
+
67
+ <a id="model-experience"></a>
68
+ ## 模型体验
69
+
70
+ ### 目录分派
71
+
72
+ #### 模型看到什么
73
+
74
+ 没有直接内容。该目录只还原由请求重建逻辑消费的 `SessionEvent` 历史。
75
+
76
+ #### Token 影响
77
+
78
+ 不直接产生 token。
79
+
80
+ #### KV Cache 影响
81
+
82
+ 没有直接影响;还原后的历史在其消费者中决定缓存身份。
83
+
84
+ ## 已知限制与延期工作
85
+
86
+ <a id="known-limitations-and-deferred-work"></a>
87
+
88
+ - **仅包含第一方构建清单**——尚不支持外部迁移所有权与分发。
89
+ - **生成顺序封闭**——运行时插件注册无法补充缺失的历史迁移边。
90
+
91
+ <a id="dev-note"></a>
92
+ ### 开发备注
93
+
94
+ <details>
95
+ <summary>维护者的工作上下文——点击展开</summary>
96
+
97
+ 无。
98
+
99
+ </details>
package/lib/index.js ADDED
@@ -0,0 +1,53 @@
1
+ import { KNOWN_SESSION_EVENT_TYPES, SESSION_FORMAT_VERSION, Session, SessionId, SessionLogOffset } from "@xneog/dsh-session";
2
+ import { SessionFormatUnsupportedMigrationError, createSessionFormatCatalog } from "@xneog/dsh-session-format";
3
+ import { releasedV0SessionFormatCodec, releasedV1SessionFormatCodec, sessionFormatV0ToV1 } from "@xneog/dsh-session-format-v0-to-v1";
4
+ import { assertReleasedV2Header, releasedV2SessionFormatCodec, restoreReleasedV2Artifact, sessionFormatV1ToV2 } from "@xneog/dsh-session-format-v1-to-v2";
5
+ //#region lib/types/current.js
6
+ /** Current installed Session validation used after vocabulary-aware format restoration. */
7
+ /**
8
+ * Validate current logical metadata through the installed Session package.
9
+ * @param header - detached current logical header.
10
+ * @returns nothing after successful validation.
11
+ */
12
+ function validateInstalledCurrentSessionHeader(header) {
13
+ if (header.version !== SESSION_FORMAT_VERSION) throw new Error(`installed Session format is v${SESSION_FORMAT_VERSION}, got v${header.version}`);
14
+ Session.fromRestore(SessionId(header.id), [], header, SessionLogOffset(0));
15
+ }
16
+ /**
17
+ * Validate current header, event envelopes, messages, surface operations, and seed cut through the installed Session package.
18
+ * @param artifact - vocabulary-restored current logical artifact.
19
+ * @returns nothing after successful validation.
20
+ */
21
+ function validateInstalledCurrentSessionArtifact(artifact) {
22
+ if (artifact.header.version !== SESSION_FORMAT_VERSION) throw new Error(`installed Session format is v${SESSION_FORMAT_VERSION}, got v${artifact.header.version}`);
23
+ Session.fromRestore(SessionId(artifact.header.id), artifact.events, artifact.header, SessionLogOffset(artifact.inheritedEventCount));
24
+ }
25
+ //#endregion
26
+ //#region lib/types/generated.js
27
+ /**
28
+ * GENERATED by `scripts/gen-session-format-catalog.ts` — do not edit by hand.
29
+ * The direct imports make historical readability independent of mounted plugins.
30
+ */
31
+ /** Physical codec dispatch and complete adjacent chain, independent of mounted plugins. */
32
+ const sessionFormatCatalog = createSessionFormatCatalog({
33
+ currentVersion: 2,
34
+ codecs: [
35
+ releasedV0SessionFormatCodec,
36
+ releasedV1SessionFormatCodec,
37
+ releasedV2SessionFormatCodec
38
+ ],
39
+ encodeCurrentArtifact: (artifact) => releasedV2SessionFormatCodec.encodeArtifact(artifact),
40
+ migrations: [sessionFormatV0ToV1, sessionFormatV1ToV2],
41
+ restoreCurrent(artifact) {
42
+ const restored = restoreReleasedV2Artifact(artifact, KNOWN_SESSION_EVENT_TYPES);
43
+ validateInstalledCurrentSessionArtifact(restored);
44
+ return restored;
45
+ },
46
+ restoreCurrentHeader(header) {
47
+ assertReleasedV2Header(header);
48
+ validateInstalledCurrentSessionHeader(header);
49
+ return header;
50
+ }
51
+ });
52
+ //#endregion
53
+ export { SessionFormatUnsupportedMigrationError, sessionFormatCatalog };
@@ -0,0 +1,15 @@
1
+ /** Current installed Session validation used after vocabulary-aware format restoration. */
2
+ import type { SessionFormatArtifact, SessionFormatHeader } from '@xneog/dsh-session-format';
3
+ /**
4
+ * Validate current logical metadata through the installed Session package.
5
+ * @param header - detached current logical header.
6
+ * @returns nothing after successful validation.
7
+ */
8
+ export declare function validateInstalledCurrentSessionHeader(header: SessionFormatHeader): void;
9
+ /**
10
+ * Validate current header, event envelopes, messages, surface operations, and seed cut through the installed Session package.
11
+ * @param artifact - vocabulary-restored current logical artifact.
12
+ * @returns nothing after successful validation.
13
+ */
14
+ export declare function validateInstalledCurrentSessionArtifact(artifact: SessionFormatArtifact): void;
15
+ //# sourceMappingURL=current.d.ts.map
@@ -0,0 +1,7 @@
1
+ /**
2
+ * GENERATED by `scripts/gen-session-format-catalog.ts` — do not edit by hand.
3
+ * The direct imports make historical readability independent of mounted plugins.
4
+ */
5
+ /** Physical codec dispatch and complete adjacent chain, independent of mounted plugins. */
6
+ export declare const sessionFormatCatalog: import("@xneog/dsh-session-format").SessionFormatCatalog;
7
+ //# sourceMappingURL=generated.d.ts.map
@@ -0,0 +1,4 @@
1
+ /** Build-static first-party Session format migration catalog. */
2
+ export { sessionFormatCatalog } from './generated.ts';
3
+ export { SessionFormatUnsupportedMigrationError } from '@xneog/dsh-session-format';
4
+ //# sourceMappingURL=index.d.ts.map
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@xneog/dsh-session-format-catalog",
3
+ "description": "Build-static first-party Session format codec and migration catalog",
4
+ "version": "0.1.3-alpha.1",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/gomes007-alt/xneog-harness.git",
11
+ "directory": "packages/session/session-format-catalog"
12
+ },
13
+ "type": "module",
14
+ "main": "lib/index.js",
15
+ "types": "lib/types/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./lib/types/index.d.ts",
19
+ "default": "./lib/index.js"
20
+ },
21
+ "./src/*": "./src/*",
22
+ "./package.json": "./package.json"
23
+ },
24
+ "files": [
25
+ "lib/index.js",
26
+ "lib/types/**/*.d.ts"
27
+ ],
28
+ "license": "MIT",
29
+ "dependencies": {
30
+ "@xneog/dsh-session-format": "^0.1.3-alpha.1",
31
+ "@xneog/dsh-session-format-v0-to-v1": "^0.1.3-alpha.1",
32
+ "@xneog/dsh-session-format-v1-to-v2": "^0.1.3-alpha.1"
33
+ },
34
+ "peerDependencies": {
35
+ "@xneog/cordis": "^4.0.2",
36
+ "@xneog/dsh-session": "^0.1.3-alpha.1"
37
+ },
38
+ "devDependencies": {
39
+ "@xneog/cordis": "^4.0.2",
40
+ "@xneog/dsh-session": "^0.1.3-alpha.1"
41
+ }
42
+ }