@deepseek-ai/dsh-session-format 0.1.3-alpha.2 → 0.1.5-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
@@ -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-format/README.md
5
- README.md: d44a7091bc5840afcb5d1e73f594284c3d5c8206
6
- README.zh.md: f4b6acd8e0ba3c28a1b5088fc577e1b4289ca9a0
5
+ README.md: 040d3383864d008b9df62378063a11223c1373be
6
+ README.zh.md: 7c57123ac7315cfc15e7a20f6834e8ae48fad3ec
package/README.md CHANGED
@@ -55,7 +55,7 @@ The recoverable decoder returns the accepted logical prefix. A codec may drop on
55
55
  <details>
56
56
  <summary>Implementation internals — click to expand</summary>
57
57
 
58
- The chain validates unique gap-free ordering at construction. The catalog composes one row decoder with stateful adjacent event transformers, retains only their bounded state and the final current events, and performs target validation at `finish()`; only the caller decides whether and how to publish that result.
58
+ The chain validates unique gap-free ordering at construction. A source cut may be unknown until EOF; stages that require a header cut reject its absence, while marker-based stages derive it from emitted events. Each stage returns its exact target cut at finish, and any predeclared cut must agree. The catalog composes one row decoder with stateful adjacent event transformers, retains only their bounded state and the final current events, and performs target validation at `finish()`; only the caller decides whether and how to publish that result.
59
59
 
60
60
  | File | Role |
61
61
  |---|---|
package/README.zh.md CHANGED
@@ -55,7 +55,7 @@ const eventRecords = current.events.map(catalog.encodeCurrentEvent)
55
55
  <details>
56
56
  <summary>实现细节——点击展开</summary>
57
57
 
58
- 迁移链在构造时校验唯一且无缺口的顺序。Catalog 把一个行 decoder 与有状态的相邻事件 transformer 组合起来,只保留其有界状态与最终当前事件,并在 `finish()` 时执行目标校验;只有调用方决定是否发布该结果以及如何发布。
58
+ 迁移链在构造时校验唯一且无缺口的顺序。源切点可以在 EOF 前保持未知;依赖头部切点的 Stage 拒绝缺失值,而基于标记的 Stage 从已发出的事件推导切点。每个 Stage 在完成时返回精确的目标切点,且必须与预声明切点一致。Catalog 把一个行 decoder 与有状态的相邻事件 transformer 组合起来,只保留其有界状态与最终当前事件,并在 `finish()` 时执行目标校验;只有调用方决定是否发布该结果以及如何发布。
59
59
 
60
60
  | 文件 | 职责 |
61
61
  |---|---|
package/lib/index.js CHANGED
@@ -136,7 +136,7 @@ var CompiledSessionFormatChain = class {
136
136
  }
137
137
  createStream(sourceHeader, sourceCut, output) {
138
138
  let header = sourceHeader;
139
- const validatedSourceCut = sessionFormatCount(sourceCut, "Session inherited event count");
139
+ const validatedSourceCut = sourceCut === void 0 ? void 0 : sessionFormatCount(sourceCut, "Session inherited event count");
140
140
  let inheritedEventCount = validatedSourceCut;
141
141
  const stages = [];
142
142
  const plan = this.plan(header.version);
@@ -158,11 +158,7 @@ var CompiledSessionFormatChain = class {
158
158
  migration,
159
159
  stage
160
160
  });
161
- if (index + 1 < plan.length) {
162
- const targetCut = stage.headerInheritedEventCount;
163
- if (targetCut === void 0) throw new SessionFormatError(`${migration.name} must expose its inherited cut before the next migration`);
164
- inheritedEventCount = targetCut;
165
- }
161
+ inheritedEventCount = stage.headerInheritedEventCount;
166
162
  }
167
163
  return new CompiledSessionFormatMigrationStream(header, validatedSourceCut, stages, output);
168
164
  }
@@ -249,7 +245,7 @@ var CompiledSessionFormatMigrationStream = class {
249
245
  finish() {
250
246
  let inheritedEventCount = this.sourceInheritedEventCount;
251
247
  for (const stage of this.stages) inheritedEventCount = stage.finish();
252
- return inheritedEventCount;
248
+ return sessionFormatCount(inheritedEventCount, "finished Session inherited event count");
253
249
  }
254
250
  };
255
251
  function throwUnsupportedRefusal(migration, error, subject = "Session") {
@@ -358,7 +354,7 @@ function createSessionFormatCatalog(options) {
358
354
  const sourceCut = decoder.headerInheritedEventCount;
359
355
  if (storedVersion === chain.currentVersion) return new CurrentSessionFormatRestore(decoder, sourceCut, restoreOptions.validation === "current" ? options.restoreCurrent : identityArtifact, chain.currentVersion);
360
356
  const collector = new SessionFormatEventCollector();
361
- return new MigratingSessionFormatRestore(decoder, sourceCut, chain.createStream(decoder.header, requiredHistoricalCut(storedVersion, sourceCut), collector), collector, restoreOptions.validation === "current" ? options.restoreCurrent : options.restoreTransformedCurrent, restoreOptions.validation, storedVersion, chain.currentVersion);
357
+ return new MigratingSessionFormatRestore(decoder, sourceCut, chain.createStream(decoder.header, sourceCut, collector), collector, restoreOptions.validation === "current" ? options.restoreCurrent : options.restoreTransformedCurrent, restoreOptions.validation, storedVersion, chain.currentVersion);
362
358
  }
363
359
  return Object.freeze({
364
360
  currentVersion: chain.currentVersion,
@@ -454,10 +450,6 @@ function restoreCurrentVersion(artifact, currentVersion) {
454
450
  function identityArtifact(artifact) {
455
451
  return artifact;
456
452
  }
457
- function requiredHistoricalCut(version, cut) {
458
- if (cut === void 0) throw new SessionFormatError(`format v${version} decoder must expose its inherited cut before migration`);
459
- return cut;
460
- }
461
453
  function malformed(targetVersion, error, storedVersion) {
462
454
  return Object.freeze({
463
455
  status: "malformed",
@@ -50,8 +50,8 @@ export interface SessionFormatMigrationStageInput {
50
50
  readonly sourceHeader: SessionFormatHeader;
51
51
  /** Validated target metadata produced by this edge's header migration. */
52
52
  readonly targetHeader: SessionFormatHeader;
53
- /** Exact inherited prefix length in source coordinates. */
54
- readonly sourceInheritedEventCount: number;
53
+ /** Inherited prefix length in source coordinates, or undefined until body decoding completes. */
54
+ readonly sourceInheritedEventCount: number | undefined;
55
55
  /** Whether this edge consumes physical decode output or a prior migration's validated output. */
56
56
  readonly sourceKind: 'decoded' | 'transformed';
57
57
  }
@@ -66,7 +66,7 @@ export interface SessionFormatChainOptions {
66
66
  export interface SessionFormatChain {
67
67
  readonly currentVersion: number;
68
68
  /** Compile the complete migration stage chain for one decoded source artifact. */
69
- createStream(header: SessionFormatHeader, inheritedEventCount: number, context: SessionFormatMigrationContext): SessionFormatMigrationStream;
69
+ createStream(header: SessionFormatHeader, inheritedEventCount: number | undefined, context: SessionFormatMigrationContext): SessionFormatMigrationStream;
70
70
  /** Convert only a supported header to the current logical representation. */
71
71
  migrateHeader(header: SessionFormatHeader): SessionFormatHeader;
72
72
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepseek-ai/dsh-session-format",
3
3
  "description": "Streaming adjacent Session format migration machinery",
4
- "version": "0.1.3-alpha.2",
4
+ "version": "0.1.5-alpha.1",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -27,7 +27,7 @@
27
27
  ],
28
28
  "license": "MIT",
29
29
  "dependencies": {
30
- "@deepseek-ai/dsh-util-values": "^0.1.3-alpha.2"
30
+ "@deepseek-ai/dsh-util-values": "^0.1.5-alpha.1"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "@deepseek-ai/cordis": "^4.0.2"