test(composition): 钉住 source_tree_digest 投影的单射性与其载荷约束 - #11
Merged
Conversation
canonical 同族自查(TD 指派)发现:composition 里唯一用字符串拼接构造摘要输入的 地方是 source_tree_digest,而它的单射性**不是格式自己保证的**,是载荷在 require_git_object_id 上的——拼接在 resolve(),约束在 inspect_one(),跨函数, 且没有任何测试钉住这条依赖。谁将来放宽约束、或另开路径构造 SourceLock, 拼接就静默变回可伪造,而所有现有测试保持绿。 补三条测试,两半各自独立可判: - object_id_constraint_excludes_the_projection_delimiter_and_labels(约束这一半) 含换行与含 component 标签的样本刻意取**恰好 40 字符**,必须被字母表挡住而不是 被长度挡住——否则「排除分隔符/标签」这两条性质其实没验证到。 - projection_is_injective_under_the_object_id_constraint(投影这一半) 4096 组合法输入:每份投影都能唯一还原出 (native_tree, voxel_tree),且互不相同。 - collision_ruled_out_by_the_object_id_constraint(两半的接合点) 值替换方向的显式碰撞对;同时钉住「碰撞确实存在」与「约束确实挡得住」。 只钉后者的话,将来有人删掉约束时没有任何东西提醒他删掉的是什么。 失败信息一律点名是哪一半塌了,不必重新推导。 为让测试绑定**真实**投影而不是复制一份格式字符串(那正是 encode.rs 注释里点名的 平行结构反模式),把拼接抽成 source_tree_projection()。纯抽取、零行为变更: 抽取前后 build_plan_digest 10b3ebf8… 与 source_tree_digest f3fa3403… 逐字节相同。 授权:TD 明确授权的范围外补强(非夹带),不改任何生产逻辑。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
来源
canonical 同族自查(TD 指派,起因是架构仓
canonical_object_pairs拼接式编码可构造指纹碰撞)。自查结论:本仓无可利用暴露面,但发现一处无测试钉住的载荷性前提。问题
composition里唯一用字符串拼接构造摘要输入的地方是source_tree_digest:这个格式自己不保证单射。值替换方向的显式碰撞(已实测):
挡住它的是
require_git_object_id(tree_id 恒为 40 位[0-9a-f],换行与标签字符都不在字母表内)。但拼接在resolve(),约束在inspect_one(),跨函数,且没有任何测试钉住这条依赖——谁放宽约束或另开路径构造SourceLock,拼接静默变回可伪造,所有现有测试保持绿。这正是本项目已入册那条 lesson 的形状:守护的 precondition 锚在别处,且没人盯着那个锚。
补的三条测试:两半各自独立可判
object_id_constraint_excludes_the_projection_delimiter_and_labelsprojection_is_injective_under_the_object_id_constraint(native_tree, voxel_tree)且互不相同collision_ruled_out_by_the_object_id_constraint失败信息一律点名是哪一半塌了。变异矩阵验证两半确实独立:
一处生产代码改动:纯抽取,零行为变更
把拼接抽成
source_tree_projection(),为的是让测试绑定真实投影。若测试里复制一份格式字符串,就成了encode.rs注释里点名的平行结构反模式——生产格式改了测试还绿。零行为变更已实测:抽取前后
build_plan_digest=10b3ebf8…、source_tree_digest=f3fa3403…逐字节相同。验证
just nextest113/113(原 110 + 本次 3);fmt-check / clippy / deny / about / tool-lock / runtime-deps / check-contracts / check-generated / spec-lint + 17 项自测全部 exit 0。授权
TD 明确授权的范围外补强,不属夹带;不改任何生产逻辑。
🤖 Generated with Claude Code