Repository navigation
test(session-usage): 多帧反证改数帧头,不再依赖 Node 的 zstd 整块解语义 - #490
Merged
Merged
Conversation
原反证断言 zstdDecompressSync(buf) 只能拿到第一帧,依赖的是「整块解只吐第一帧」这一 Node 旧行为。24.22.0 起解码跨 chunk 边界也能解出所有帧(nodejs/node#65865),断言在 legacy 腿(装 latest 24.x)上过期,main 下次 runner 升到 24.22.0 就会红。 改成数 zstd magic 帧头:既与产品代码 orEachFrame 的切帧判据同源,又不绑定解码器语义。 第二行断言用 stat.frames + stat.failed——帧头数 = 成功数 + 失败数 是实现契约,而 「帧头数 = 成功数」只在 failed 恒为 0 时成立,是巧合不是规矩。 已知局限写进注释:这条锁的是「切帧判据仍是 magic」,不是碰撞免疫。payload 里撞上 magic 时计数器与解码器会一起错(半片也解得出来),实测 frames 同样变成 4,这条测不出来。
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Merged
andimial
pushed a commit
to andimial/mneme
that referenced
this pull request
Oct 20, 2026
- CHANGELOG 0.9.3:把 [Unreleased] 攒的 7 条搬入新版本节,并补 slow-stack#487 / slow-stack#489 评审 / slow-stack#490 三条此前未登记的修复 - 双 README 版本表填 v0.9.3 主题描述;根 README 中英 News 表各加 v0.9.3 头条 - 根 README 路线图状态格跟到 v0.9.3 - 版本号 0.9.2 -> 0.9.3(package.json + package-lock.json) - 测试徽章 2230 -> 2257(本地全量 npm test:tests 2257 / pass 2256 / fail 0 / skip 1)
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.
背景
test/session-usage.test.js:68的反证断言zlib.zstdDecompressSync(buf)只能拿到第一帧,依赖的是 Node 的「整块解只吐第一帧」旧行为。Node 24.22.0 起解码跨 chunk 边界也能解出所有帧(nodejs/node#65865),这条断言随之过期。CI 的 legacy 腿装 latest 24.x,所以
main下次 runner 升到 24.22.0 就会红。产品代码
src/session-usage.js的forEachFrame自己逐帧解,不受影响。改动
改成数 zstd magic 帧头,不绑定解码器语义:
forEachFrame的切帧判据同源(它也是用indexOf(ZSTD_MAGIC)找帧界),把「夹具形状 = 代码假设」一并锁住;stat.frames + stat.failed:帧头数 = 成功数 + 失败数 是实现契约,而「帧头数 = 成功数」只在failed恒为 0 时成立,是巧合不是规矩。已知局限(写进注释,不谎报覆盖)
这条锁的是「切帧判据仍是 magic」,不是碰撞免疫。payload 里撞上
28 b5 2f fd时,计数器与解码器会一起错(半片也解得出来),实测frames同样变成 4,这条测不出来。真要堵得在 magic 后再验帧头描述符,另属一条车道。验证
npm run sync:74 文件,无额外 diffnpm test:2257 tests / 2256 pass / 0 fail / 1 skipmodusensus <guanqishi26@gmail.com>,无 AI 署名