fix: skip oversized summary diffs individually and drop the dead summary_diffs column - #526
Merged
Merged
Conversation
LeXwDeX
marked this pull request as ready for review
September 3, 2026 05:52
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #525
Why
481e31e2b7引入的 256 KiB summary-diffs 闸有两处遗留问题(实测证据见 #525):truncateSummaryDiffs用break(原session.ts:77):首个超预算项直接终止整个循环,后面本可容纳的项被一并丢弃。实测存在单个patch长 7,097,898 字符(7.5 MiB)的真实数据,[超限项, 小项…]混合场景必然发生,此时SessionSummary.diff()(summary.ts:135)返回空列表。session.summary_diffs列是 legacy 死代码:setSummary只传 counters(summary.ts:106-113),列实测 2,025/2,025 全 NULL,fromRow/toRow的 diffs 两侧永不可达;guard 测试原标题已自称 "strips oversized legacy summary_diffs on read"。What changed
session.ts:break→continue—— 超限单项被跳过,其余可容纳项继续累积;字节核算不变,输出恒 ≤MAX_SUMMARY_DIFF_BYTEScore/session/sql.ts列定义、core/session/projector.ts投影、session.ts的stripOversizedDiffs+fromRowdiffs +toRowsummary_diffs20260903044702_drop_session_summary_diffs(ALTER TABLE session DROP COLUMN summary_diffs,SQLite O(1) 元数据操作,不重写表);bun script/migration.ts同步再生成schema.gen.ts/migration.gen.ts/schema.json,--check干净database-migration.test.ts新增真实执行用例(seeded legacy DB 实际跑 ALTER,断言列消失 / 行数据保留 / journal 记录;fresh 路径断言无此列)——补上「空库走schema.up快速路径、迁移语句从不执行」的盲区;删除 3 处死列测试(read-guard、budget-boundary 往返、httpapi legacy-diff 用例)481e31e2b7钉住的 4 处断言原样未改、继续通过(fix: summary diff cap discards trailing in-budget diffs when an earlier file exceeds 256KB; summary_diffs column is legacy dead code #525 验收硬门槛)SessionSummary.diffsschema 字段保持 optional(packages/schema/src/session-v1.ts:513)→ HTTP API 形状不变,无需 SDK 再生成Evidence
bun test test/session/summary-diff-guard.test.ts→ 6 pass / 0 fail(4 钉住 + 2 新增)bun test test/session/→ 457 pass / 0 fail(23 文件,含 summary / revert 回归)httpapi-session+session-diff-missing-patch→ 19 pass;coresession-projector+database-migration→ 26 pass(新增迁移执行测试后单文件 18 pass 复核)bun typecheck(core + opencode)exit 0;rootbun run lint4839 warnings = 基线零新增(预算 4850)rg summary_diffs packages/活引用清零;残留仅历史工件(baseline migration、旧packages/opencode/migrationsnapshot、missing-patch 测试历史注释)与新 drop migration 自身Migration类型只有up(无 down 概念),issue 验收中「回滚执行」无对应物,正向执行已由新测试真实覆盖Checklist
specgit finishexits 0.