Add a session doctor and versioned migrations #1518
Replies: 2 comments 1 reply
|
session doctor + 版本迁移——会话格式 version 0 拒绝未知格式是对的(fail-safe),但没有诊断/迁移工具确实让用户被动。 配合 #1473/#1497(损坏会话拖垮 boot),一个 doctor 工具能救不少会话。第 8 章会话管理记录了这个痛点:https://github.com/Electricitysheep/dsh-handbook/blob/main/docs/08-tools-context.md |
|
This proposal is exactly what the session-log family of reports has been converging on — I've been involved in three of the four corruption threads you cite (#1452, #1473, #1497, plus #1449 for the serializer-poison path), and your design covers the gaps they exposed. Strong +1. A few source-level specifics from that work to fold in: The four distinct failure modes the doctor should classify (all seen in the wild today)
Design points your proposal gets right (confirmed against the codebase)
One addition worth consideringA JSON audit receipt (your machine-readable receipt) is also the natural input for the UI/CLI flow: after If you'd like, I can consolidate the four threads' source evidence (exact line numbers + repro shapes above) into the proposal body so maintainers have one self-contained document. |
Uh oh!
There was an error while loading. Please reload this page.
Problem
The session format is still version
0, and the persistence layer correctly refuses formats it cannot read. That is safe, but there is no user-facing migration or recovery path yet.Recent reports show the practical cost of this gap. A malformed or interrupted JSONL log can make a session unreadable, and in some cases one bad session can stop a workspace from loading. Examples include #496, #647, #1452, #1473, and #1497.
Fixing each writer is necessary, but users also need a supported way to inspect and recover durable history before the format starts changing between releases.
Proposal
Add an offline session doctor and a versioned migration pipeline.
Possible commands:
Repair and migration should write a new artifact by default. They should not overwrite the source log. The command should produce a machine-readable receipt listing the detected invariants, applied repairs, dropped or synthesized events, source hash, and output hash.
How I would implement it
The doctor should use the same event decoder and invariants as normal persistence. It can classify failures such as a torn tail, duplicate sequence, gap, unsupported event type, invalid synthetic closer, or a version mismatch.
Repairs should be explicit transforms with narrow preconditions. A transform that cannot prove a safe result should stop and explain the remaining problem instead of guessing.
Format migrations should be pure, versioned
SessionEventtransforms. Each migration should be repeatable, tested against frozen fixtures, and able to emit the same audit receipt as a repair.At workspace startup, one unreadable session should be quarantined and reported rather than preventing unrelated sessions from loading. The UI can then offer the doctor command or export the failing log.
Acceptance criteria
--checknever changes data and reports the first broken invariant plus its event position.--repairandmigratepreserve the source and write a separate output artifact.The current refusal behavior is documented in the persistence subsystem.
All reactions