Repository navigation
[PR] fix(stream): compress that folds nothing no longer sets the ledger alignment marker | fix(stream): 什么都没折叠的 compress 不再置上账本对齐标记 - #6331
Closed
BBleae wants to merge 1 commit into
Conversation
applyRanges set session.pendingLedgerAlign right after committing the kernel's returned state, before the blocksCreated === 0 returns. A refused compress (range too small, cannot anchor, already compressed) and the no-op class armed the one-time ranxianglei#4316 alignment too, so the next save ran it after a call that folded nothing. Set the marker past those returns. A compress that created a block arms it exactly as before (ranxianglei#5608-D).
There was a problem hiding this comment.
Copilot was unable to review this pull request due to rate limiting. Please try again later. See Usage limits for GitHub Copilot for details.
Owner
|
Landed via batch PR #6455 (merged) — closing as superseded. |
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.
Fixes #6330
接着 #5608-C/D(PR #5609)和 #5797 做的。只动宿主侧,一个提交:改
src/stream.ts,另加一个测试文件和一行 CHANGELOG。kernel/**下面什么都没动。master(c26c31ace)上发生了什么
applyRanges在提交 kernel 返回的状态之后马上置session.pendingLedgerAlign = true,这在后面的r.blocksCreated === 0分支之前。所以在那里被拒绝的 compress(gate:too-small、gate:cannot-anchor、gate:already-compressed、gate:none-resolved、gate:summary-length、gate:other)和 no-op(#4521)也会给一次性的 #4316 对齐置上标记。下一次存盘消费这个标记,跑
restampRefsToLedger。被拒绝时,这次存盘就是它自己的失败记账安排的那一次(recordCompressFailure→markDirty→scheduleSave),所以applyRanges返回时对齐已经跑过了。no-op 时是会话的下一次存盘。于是对齐跑在一次什么都没折叠的调用上:
kept=N restamped=0 rehomed=0),但仍然把时间属性水位线抬到最高的引用号,于是此前渲染过的每个<acp>标签在下一个请求里都丢掉time=;不管哪种,在一次回执报失败或 no-op 的调用之后,出站字节都从第一条带标签的消息起变了,这些消息的
time=属性也不会回来。用新测试的夹具测的(9 轮带标签、开着时间戳、行在统一存储里;调一次
applyRanges、存一次盘,再对同一段历史跑第二次processTurn)。「偏离」那几行是这个夹具的一个本地变体:第三条消息受保护,于是它占一个存储行、不占引用号;这个变体不在提交的测试里。time=的标签gate:too-small)kept=9 restamped=0 rehomed=0kept=9 restamped=0 rehomed=0gate:too-small)kept=2 restamped=6 rehomed=0 blocked=1在 master 上第一个标签从
<acp tokens="752" type="text" time="…">m00001</acp>变成<acp tokens="752" type="text">m00001</acp>。这和
src/persist.ts里consumePendingLedgerAlign的注释("No fold ⇒ marker never set ⇒ pure legacy no-op")相矛盾。已发布的 0.1.213 不受影响:它在冷加载时对齐,没有延后的标记。这个标记是 PR #5609 带进来的。
改动
src/stream.ts:标记改在r.blocksCreated === 0的那几处返回之后再置,和其他只在成功时做的记账(clearCompressFailures、clearCompressLoopStreak)放在一起。被拒绝或 no-op 的 compress 不再置这个标记。创建了块的 compress 照旧置上。在旧位置和新位置之间,这条路径上没有任何东西会安排存盘(
scrubTurnSeparatorIds、块内容缓存和 CCR adopt 都只设字段和脏标记),所以折叠后的第一次存盘仍然能看到标记。在提交之前就返回的拒绝(参数解析失败、
gate:no-visible-context、gate:coverage-regression、gate:no-net-shrink等)本来就不置标记,不变。只有
applyRanges置这个标记,所以代理模式和插件模式的变化一样。开着的 PR #6155 把它的折叠钩子插在状态提交和本 PR 挪走的那段标记代码之间。两边的 diff 在那里碰到相邻的行,所以后合的一方要解一处小的文本冲突(只是标记那段挪到了更下面)。
这个 PR 不改的
搭着真折叠跑的对齐不动,包括它抬高水位线的那一步。同一个夹具,把中间四轮真的折叠掉,在 master 上和本 PR 上表现一样:对齐跑一次(引用都在账本位置上的会话是
kept=9 restamped=0 rehomed=0),折叠范围外的那几轮丢掉time=,虽然没有任何引用被挪动。这次抬高发生在restampRefsToLedger(kernel/src/refs.ts)里,所以我把它另外提成一个 kernel 授权申请,这里不碰kernel/**。测试
tests/compress-refused-ledger-align.test.ts(新文件,3 个测试):gate:too-small):对齐不跑,下一次渲染逐字节相同;用 master 的
src/stream.ts时前两个失败、第三个通过;改后三个都通过。本地跑的(Windows、Node 22、断网、一次性的家目录)。每个文件单独跑,
--test-concurrency=1:issue2204-decompress-to-file-outcome里两个只在 Windows 跳过的路径用例,storage-unified里一个要可选依赖better-sqlite3的用例)。这一组是所有引用applyRanges的测试文件(58 个,含新文件)再加 18 个:其他会走到对齐的文件(seq-ledger-pr3、storage-orphan-recovery、storage-unified)、其余的compress-*和stream-*文件、其他时间戳相关文件(message-timestamps-default-on、resume-miss-timestamp-seed、issue404-restore-timestamps、attach-invalid-timestamps)、plugin-fork、side-request-isolation、issue4986-digest-drift-ref-order、golden-kernel-dist-guard、golden-storage-render和storage-engine-proofs。tsc --noEmit、check:unused-exports、check:test-import-graph:干净。本地没跑的:完整的主套件(
tests/*.test.ts)、kernel 和 pi-subagents 套件(它们的文件都没变)、e2e 车道。完整套件的结论请以 CI 各车道为准。