Replies: 1 comment
|
核验补充(对照当前 main HEAD
关于修复方向,我倾向你给出的第二选项(torn 容忍只覆盖"严格 EOF 截断"):gap 之后还有有效行,更像是人工编辑 / 外部工具写入 / 跨版本残留,而不是崩溃尾部——这种情况报错(与 committed region 同策略)比静默删除更安全,因为删掉的是"看起来有效"的数据。代价是:真实崩溃后恰好又写入了有效行的场景(罕见)会从"静默修复"变成"报错",但这类写入本身就是异常来源。 建议补一个回归测试钉住该语义:构造 |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Summary
When a bad row or seq gap appears after the last
turn/end,scanRowsmarks that row and every row after it as torn (tornFrom = preserved.length), andcommitRepairrunsDELETE FROM events WHERE seq >= tornFrom— deleting valid events of the still-open turn that follow the bad row, then synthesizing only fake closers. One tail corruption discards more than the corrupted row.Evidence
packages/session/session-persistence-sqlite/src/schema.ts:254-269:commitRepair(session-persistence-sqlite/src/index.ts:313-315):DELETE FROM events WHERE seq >= tornFrom— everything from the first bad row to EOF is deleted, including valid events of the current unclosed turn. JSONL's scanner also errors on committed-region gaps, but SQLite's branch treats everything afterturn/endas deletable. SQLite transactions normally preclude bad rows (defensive branch), but manual edits / foreign tool writes / cross-version leftovers hit it.Suggested fix
Torn tolerance should only cover the unclosed tail: keep consecutive valid rows after a gap (truncate at the gap, not to EOF), or restrict tolerance to strict EOF-truncation cases.
Verified at master
47f9438.All reactions