Files
deepseek-harness/packages/session/session-format-catalog
Tianyi Cui bf29247fad fix(session): namespace historical V3 extensions with plugin prefixes
V3 permits external event, source and content identities and additional
request-tool fields. Copying those values into V4 can give an old plugin
named tool a core source identity, turn old tool-addition content into a
registry instruction, or activate formerly ignored deferLoading and delivery
metadata. Rejecting such collisions would instead refuse valid source logs.

Keep historical extensions in the existing extensible JSON representation.
Prefix unknown content and ignorable event tags with plugin:, preserving
all other content fields and opaque event payloads. Prefix external source
identities with plugin:plugin: or plugin:source: so wrapper and direct kinds
cannot collide even when original names already contain a category prefix.
Known first-party mappings remain explicit and unchanged.

Prefix extra request-tool field names and block-start field names with
plugin:, retaining exact values and existing-prefix doubling. Core schema
parameters, arguments, replay state and nested plugin data are not traversed.
Keep future-generation delivery records inactive after header promotion.
Pin the V3 event vocabulary independently of the current writer and provide
an offline verifier against an explicitly selected historical source commit.

Attachment authorization and export inspect declared event content only.
Team checkpoints preserve all own keys of unknown JSON blocks while still
rejecting malformed known content and retired core tool-result blocks.
Exercise physical read/write/reopen, prefix injectivity, own __proto__ keys,
provider opacity and retained source-identity snapshots.

No generic extension block, metadata wrapper or new schema-tooling type is
introduced. V4 type declarations, persistence schema, checkpoint and frozen
V0-V3 codecs remain unchanged. Canonical tool-result lifting and incomplete
child-catalog policy remain separate concerns.

Adapted from the extension-preservation work in 7ba7e174dd1 by Tianyi Cui.
Co-authored-by: Tianyi Cui <[email protected]>
2026-09-19 15:43:09 +08:00
..

description, kind
description kind
Build-static first-party Session format codec and adjacent migration assembly for persistence readers. package-library

@deepseek-ai/dsh-session-format-catalog

English | 中文

Summary

dsh-session-format-catalog gives persistence one deterministic Session format reader without consulting mounted plugins. It assembles codecs and adjacent edges from the earliest supported format through the current writer format, checks the complete gap-free chain at module initialization, and exposes physical dispatch, header-only classification, single-pass row restoration, and current record encoding through sessionFormatCatalog.

Table of Contents


Use this package

When to use it

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 completed restore validates its result; mutable row-decoder state belongs to one caller-owned streaming restore.

Entry point

const descriptor = sessionFormatCatalog.readHeader(physicalHeader)
const catalog = createSessionFormatCatalogWithChildren(childFacts)
const restore = catalog.createRestore(physicalHeader, { recovery: 'recoverable', validation: 'transformed' })
for (const row of physicalRows) restore.decodeRow(row)
const current = restore.finish()
const headerRecord = sessionFormatCatalog.encodeCurrentHeader(current.header, current.inheritedEventCount)
const eventRecords = current.events.map(sessionFormatCatalog.encodeCurrentEvent)

Import sessionFormatCatalog from the package root. JSONL and fixture readers create one restore, push each parsed physical row through decodeRow(), and call finish() once. Writers serialize the returned current artifact through encodeCurrentHeader() and encodeCurrentEvent(). Listing calls readHeader() and never opens event bodies.

Production historical reads select { recovery: 'recoverable', validation: 'transformed' }. Worker and fixture verification select { recovery: 'strict', validation: 'current' }. Transformed validation runs the released-current rules after migration but deliberately skips installed semantic validation for input that is already current.

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. The browser-safe ./message-projections export assembles current plugin-owned interpreters for detached constructors and surface folds; it does not mount recovery listeners.

createSessionFormatCatalogWithChildren(childFacts) binds explicit child evidence to V3→V4 during assembly; see the catalog-completion specification. historicalSessionFormatCatalog restores V0–V3 using the fixed released-V3 event vocabulary to collect child prerequisites without recursively completing their catalogs. An ignorable V3 extension remains opaque even when the installed writer knows its name. Isolated transcript replay explicitly supplies an empty array; persistence must collect the complete available direct-child set. Keep the supplied evidence unchanged for the catalog’s lifetime. Each restore owns independent stage state. The static sessionFormatCatalog supports header and native current-format reads; historical body reads require the child-bound catalog.


Understand the implementation

Implementation internals — click to expand

src/generated.ts is the static owner of codec and edge ordering. 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.


Further Exploration


Model Experience

Catalog dispatch

What the model sees

Nothing directly. The catalog only restores the SessionEvent history consumed by request reconstruction.

Token effect

Zero direct tokens.

KV Cache effect

No direct effect; restored history determines cache identity in its consumer.

Known Limitations and Deferred Work

  • First-party build inventory only — external migration ownership and distribution are not supported.
  • Generated ordering is closed — runtime plugin registration cannot supply a missing historical edge.

Dev Note

Working context for maintainers — click to expand

None.