Repository navigation
Restore actual submodule checkout bytes in snapshot regression - #582
Conversation
Preserve checkout line endings and verify that restoring the original bytes restores the source snapshot. Agent-assisted-by: Codex (author) Signed-off-by: zengchuang-hw <zengchuang3@huawei.com>
jiangkuaixue123
left a comment
There was a problem hiding this comment.
审查意见
改了什么
只动了 tests/test_runtime.py 里的子模块快照回归测试 test_submodule_local_edit_changes_snapshot_hash(+6/−2),生产代码没变。
原先恢复夹具时写死了字面量 b"original\n"(LF 换行)。在 Windows 等开启了 core.autocrlf=true 的环境里,Git 检出到磁盘上往往是 CRLF(\r\n),测试写回 LF 后,工作区会一直被当成「脏」(有未提交改动),最终「应恢复干净」的断言会误失败。
这次在改动前用 read_bytes() 记下 Git 实际检出的字节,再用这些字节写回去;同时多断言一次:恢复后的 snapshot_hash(仓库快照指纹)要和改动前一致。两次不同编辑会得到不同哈希、脏状态为真——这些原有检查都还在。
问题与风险
没有发现影响正确性、安全或声明行为的实质缺陷。
- 改动面很小、意图清楚,且与 PR 描述里的 Windows /
autocrlf=true|false验证一致。 - 中间两次编辑仍写 LF,这是在制造「脏」状态做对比,不是用来恢复干净态,合理。
mergeable_state为 blocked,看下来是分支保护(审批 / 检查)尚未满足,不是「被未合入的前置 PR 挡住、无法单独看 diff」;本 PR 基于当前main、仅测例修复,可独立判断。
非阻塞小建议:合入后按 PR 说明在 main 上再跑一遍该回归即可;Ready CI 作者也未宣称已绿。
结论
批准(Approve)。
理由:这是针对换行符导致假脏状态的精准测试修复,断言更强、范围可控,未见实质问题。
jiangkuaixue123
left a comment
There was a problem hiding this comment.
改了什么
只动了测试文件 tests/test_runtime.py 里的 test_submodule_local_edit_changes_snapshot_hash(子模块本地改动会不会改变「快照哈希」的回归测试)。
原先收尾时用写死的 b"original\n"(纯 LF 换行)把夹具文件写回去。在 Windows 上如果开了 core.autocrlf=true(Git 会按本机习惯把换行变成 CRLF),检出出来的原文其实是带 \r\n 的,硬写 LF 回去就会让子模块一直显示「脏」(有未提交改动),测试误报失败。
这次在改文件之前先 read_bytes() 记下 Git 实际检出的字节,收尾时按原样写回;并多断言一条:恢复后的 snapshot_hash(仓库当前内容的指纹)要和改动前一致。生产代码、CI、全局 Git 配置都没动。
问题 / 风险
没有发现影响正确性、安全或声明行为的实质问题。中间两次编辑仍用纯 LF 写入,是故意制造「脏」状态,合理。
非阻塞小建议:若以后夹具本身也受 .gitattributes 约束,继续「先读再还原」比硬编码换行更稳——本 PR 已经朝这个方向走了。
结论
批准(Approve)。 这是对 #581 相关回归在 Windows/autocrlf 下的针对性修补,改动面小、意图清楚,加强了「恢复后哈希应回到原点」的断言;我这边按当前 head a97b985 审过,可合入(仍需满足仓库要求的其余审批与检查)。
jiangkuaixue123
left a comment
There was a problem hiding this comment.
改了什么
只动了 tests/test_runtime.py 里的子模块(submodule,嵌在主仓库里的另一个 Git 仓库)快照回归测试,生产代码没改。
原先测试在改完子模块文件后,用字面量 b"original\n" 写回去“还原”。在 Windows 上若开了 core.autocrlf=true(Git 自动把换行在检出时改成 CRLF),检出到磁盘上的实际内容是 original\r\n,再写回纯 LF 就会让子模块一直显示脏(dirty,有未提交改动),断言失败。
这次在改动前先用 read_bytes() 记下检出后的真实字节,还原时写回这些字节;并额外断言还原后的 snapshot_hash(仓库快照哈希,用来判断内容是否变过)与改动前一致。
问题或风险
没看到影响正确性、安全或声明行为的实质问题:
- 改动范围小(+6/−2),意图和注释清楚。
- 仍保留“两次不同编辑得到不同哈希”和“编辑后 dirty”的检查,只是把还原方式改对了,并加强了还原后哈希一致的断言。
- 故意写入的编辑内容仍用 LF,这没问题:那些步骤本来就要制造 dirty 状态。
非阻塞提醒:当前部分 CI(如 full-check、host-compatibility)还在跑;作者说明 Ready CI 未宣称全绿。这不挡本次批准,合入前仍以门禁结果为准。
结论
Approve。 这是针对真实 Git / 换行设置的合理测试修复,逻辑正确,且不改变产品行为。
jiangkuaixue123
left a comment
There was a problem hiding this comment.
改了什么
这个 PR 只动了测试 tests/test_runtime.py 里的 test_submodule_local_edit_changes_snapshot_hash(+6/−2),生产代码没改。
背景:子模块(submodule,嵌套在主仓库里的另一个 Git 仓库)快照回归测试会改 vendor.py,再写回「原始内容」期望仓库变干净。原先用字面量 b"original\n"(只有换行符 LF)去还原。在 Windows 且 Git 开启 core.autocrlf=true(自动把换行转成 CRLF)时,检出文件实际是 original\r\n,字面量还原对不上,Git 仍报 dirty(工作区有未提交改动),测试误失败。
本次做法:
- 编辑前用
read_bytes()记下检出时的真实字节; - 还原时写回这些字节,而不是写死 LF;
- 额外断言还原后的
snapshot_hash(快照哈希,用来标识仓库当前内容指纹)与编辑前一致。
两处「不同编辑产生不同哈希」和 dirty 断言都还在。
问题与风险
未发现影响正确性、安全或声明行为的实质问题。
非阻塞小建议:
- 中间两次编辑仍写死
\n,这是故意制造 dirty 内容,可以接受;若以后想在 CRLF 环境下更贴近真实检出,可以再讨论,但不是本 PR 必须改的。 - 说明里写 Ready CI 尚未全绿;我这边看到部分检查仍在跑(如 full-check、dashboard-browser、host-compatibility),与「等检查通过再合入」一致,不影响本次对 diff 本身的判断。
PR 基于当前 main,不依赖未合入的前置 PR;关联 #581 / #371 是问题与任务背景,diff 可单独审完。
结论
Approve。 修复对准了 Windows + autocrlf 下的真实失败模式,范围仅限该回归测试,断言反而更强(哈希也要对上)。建议在所需 CI 与另一份独立 Approve 齐备后再合入。
Dong1017
left a comment
There was a problem hiding this comment.
LGTM
Posted by Dong-bot, an automated agent acting on behalf of @Dong1017 (always-on-bot, model claude-sonnet-5-5).
PR review verdict — PASS
Reviewed base 5ffe750 and head a97b985 (full diff, one file: tests/test_runtime.py, +7/-3). This is a Dong-bot (authorized delegate) review. There are no prior formal reviews and no outstanding CHANGES_REQUESTED.
Verified:
- The change is test-only, in
test_submodule_local_edit_changes_snapshot_hash. The old test restored the file withb"original\n". Where Git's checkout converts line endings (for examplecore.autocrlfon Windows), that is not the checked-out byte content, so thedirty is Falseassertion could fail. The test now savesvendor.read_bytes()before editing and writes those bytes back, so it restores what Git actually checked out. - The new assertion
restored["snapshot_hash"] == original_snapshotis sound. Insrc/inferrsi/apps/host/targets/git.py,snapshot_hashissha256(f"{head}:{dirty_hash}").dirty_hashcovers the parentgit diff --binary HEAD, the untracked files and the submodule facts (snapshot_hashanddirtyfrom the nestedrepository_identity). When the submodule bytes are restored, all of these return to their initial values. The assertion therefore checks that a restored checkout gets the same identity as the original. - The original-snapshot call happens before any edit and has no side effects. The
first != secondanddirty is Trueassertions are unchanged, so the test still checks that distinct edits inside a submodule give distinct hashes. - No production code changes, so there is no behavior or contract risk beyond this test.
Not verified here: I did not run the tests or see CI results. I did not run the test on Windows with CRLF checkout settings. Merge still needs the required independent approvals on the final head and green CI.
|
@jiangkuaixue123 已收到你对当前 请编辑你已有的一份当前头 Approve,把正文第一个非空行改成单独、区分大小写的 Dong 当前已给出此独立测试修复的 |
|
当前最终头 当前尚不满足合入条件。 Dong 的独立 @david6666666 @hsliuustc0106 也可对本单文件测试修复给独立实际结论。我作为作者不计票,满足有效两票后会核对最新状态再 squash 并在 main 复验。 |
|
@linyueqian 也请对这份独立测试修复给实际检视:当前 我为作者/父责任人,不计独立票;Dong 对这份独立 bug 修复的批准有效,Jiang 现有记录仍待格式修正。请独立给结论,不预设批准;如由授权代理代交请写身份和授权来源,通过时正式 Approve 首个非空行单独为 |
Keep the source tree unchanged while renewing revision-scoped review records and CI. Agent-assisted-by: Codex (integrator) Signed-off-by: zengchuang-hw <zengchuang3@huawei.com>
|
为刷新正式复审记录,已追加签署的源码树完全相同提交:当前 @Dong1017 @jiangkuaixue123 @linyueqian 请基于当前头重新核对这份单文件回归并提交实际结论。通过时正式 Approve 首个非空行单独为 |
Dong1017
left a comment
There was a problem hiding this comment.
LGTM
Posted by Dong-bot, an automated agent acting on behalf of @Dong1017 (always-on-bot, model claude-sonnet-5-5).
PR review verdict — PASS
Reviewed base 5ffe750 and head 56d0f9c. This is a Dong-bot (authorized delegate) re-review of the full diff on the current head. It has one file, tests/test_runtime.py, +6/−2.
Verified from the diff:
- In
test_submodule_local_edit_changes_snapshot_hashthe test now readsvendor.read_bytes()before any edit. It restores those bytes at the end instead of the literalb"original\n". Undercore.autocrlf=truethe checkout is CRLF, so the old literal LF restore could never return to a clean state. The new restore fixes that. - The initial
repository_identity(superproject)["snapshot_hash"]is captured before the first edit, so it reflects the clean checkout. - The new
assertEqual(restored["snapshot_hash"], original_snapshot)strengthens the test. It checks that the restored state matches the original identity, not only thatdirtyis false. assertNotEqual(first, second)andassertTrue(...["dirty"])are unchanged. The two intermediate edits still write LF on purpose, to create dirty states.- The diff touches no production code, workflows or Git configuration.
- The PR body says this head has the same tree (
08e7a95f…) asa97b985f. I did not re-derive that, but nothing in the diff conflicts with it.
Blockers: none.
Limits: I did not run the tests, and I did not check the Windows or autocrlf results claimed in the PR body. The Ready CI I could see in the record ran on the earlier head a97b985f. The CI for 56d0f9ca still has to be green before merge.
Merge eligibility is not decided here. The gate needs two distinct independent write+ accounts with LGTM Approves on the exact current head, plus green CI. Whether this account counts as independent is for the gate owner to decide. My earlier recorded decisions on #550, #552, #562 and #585 say an owner or accountable-parent approval does not count toward the two required votes. Please check this against the #581/#371 ownership before counting it. Jiang's records on this head have first lines that are headings, not LGTM, so the author's format concern about them still stands.
Select process-scoped Git settings and verify actual checkout bytes on each host, preserving inherited Git options and all restoration assertions. Agent-assisted-by: Codex (author) Signed-off-by: zengchuang-hw <zengchuang3@huawei.com>
7100343
|
当前实质回归增强头为 @Dong1017 @jiangkuaixue123 @linyueqian 请复审这一份有实际测试差异的新头,旧头记录不转为新头有效票。通过时正式 Approve 首个非空行单独为 关于独立性:#581 已明确 Root 为该 bounded bug 的实现/接受责任人,Dong 在此为外部 triage/reviewer;不是 #429/#565/#584 的父责任票。合入前仍会按实际贡献/角色核对,而不是只按 GitHub 的批准数量。 |
jiangkuaixue123
left a comment
There was a problem hiding this comment.
LGTM
审查意见(当前头 71003438)
代理:InferRSI动态推送(Grok Bot),依据 Chenzhou Jiang / @jiangkuaixue123 的 standing delegation:对请求其审查的 InferRSI PR 代为阅读 diff、提交审查;无实质问题则 Approve,有实质问题则 Request changes。
改了什么
只改了测试文件 tests/test_runtime.py(+28/−10),生产代码、CI、仓库级 Git 配置都没动。
原先那个「改一下子模块里的文件,快照哈希(snapshot hash,整仓内容的指纹)要变;改回去后要变干净」的回归,现在拆成两条用例,分别在进程级强制 core.autocrlf=true(检出成 CRLF,即 \r\n)和 false(检出成 LF,即 \n)下跑同一套逻辑:
- 用 Git 的
GIT_CONFIG_COUNT/GIT_CONFIG_KEY_*环境变量追加一项配置,不覆盖调用方已有的进程级 Git 选项。 - 建好超级工程(superproject,里面挂着 submodule)后,先
read_bytes()记下真实检出字节,并断言与预期换行一致。 - 两次不同编辑仍要得到不同哈希,且处于 dirty(工作区有未提交改动)。
- 写回当初记下的字节(而不是字面量
original\n),并断言 dirty 消失且快照哈希回到改动前。
这正好修掉「在 CRLF 检出上写回 LF → 一直假脏 → 断言误失败」的问题,也把两种换行都钉死成可复现用例。
问题与风险
没有发现影响正确性、安全或声明行为的实质缺陷。
os/patch本文件已有导入;每个测试方法有独立setUp临时目录,两条用例不会抢同一路径。- 中间两次编辑故意写 LF,只为制造 dirty 对比,不用于恢复,合理。
mergeable_state=blocked看下来是分支保护(审批 / CI)未齐,不是「被未合入前置 PR 挡住、diff 无法单独判断」;本 diff 可独立审。
非阻塞小建议:合入前以本头 Ready CI 最终结果为准(作者也写了仍在等);我这边未在本机复跑 pytest。
结论
批准(Approve)。
理由:这是单文件、意图清楚的可移植性回归增强,断言更强,未见实质问题。
Dong1017
left a comment
There was a problem hiding this comment.
LGTM
Posted by Dong-bot, an automated agent acting on behalf of @Dong1017 (always-on-bot, model claude-sonnet-5-5).
PR review verdict — PASS
Reviewed base 5ffe750 and head 7100343 (full diff, one file: tests/test_runtime.py). This is a Dong-bot (authorized delegate) review. Earlier approvals on a97b985f and 56d0f9ca are not carried over to this head.
Verified from the diff and tests/test_runtime.py at the head:
- Restore fix kept.
vendor.read_bytes()is captured before any edit, and those bytes are written back at the end. This replaces the literalb"original\n", so a CRLF checkout is restored exactly. The test also assertsrestored["snapshot_hash"] == original_snapshotanddirtyis false. - Both line-ending cases are explicit.
test_submodule_local_edit_changes_snapshot_hashrunsautocrlf=true. The new..._with_lf_checkout_...test runsautocrlf=false. Both go through_check_submodule_edit_restore. The checkout bytes are asserted (original\r\nfor true,original\nfor false), so the tests no longer depend on host defaults. - Git option scoping is sound. The option is added through
GIT_CONFIG_COUNT/GIT_CONFIG_KEY_n/GIT_CONFIG_VALUE_n, withntaken from the caller's existing count, so inherited options are preserved.patch.dict(os.environ, …)restores the environment afterwards.osandpatchare already imported (lines 4 and 13).make_superprojectshells out togitwithout overriding the environment, so the submodule clone inherits the setting.make_superprojectis called inside the patched block, so the checkout really happens under the chosen setting. - Original assertions remain.
first != second,dirty is Trueafter the edits, and the two intermediate LF edits are unchanged. The diff touches no production code, workflows or Git config.
Blockers: none.
Non-blocking:
int(os.environ.get("GIT_CONFIG_COUNT", "0"))raises if a caller sets a malformed value. That is an unlikely environment, so I would not change it.
Limits:
- I did not run the tests. The 39 passed / 15 subtests result, the negative control and the Windows runs come from the PR body and are not independently verified.
- Final-head Ready CI was reported as pending in the PR body. The merge gate should rely on that result.
Independence: for this standalone bug, #581 names Root as implementer and acceptance owner. I am reviewing as an external reviewer, not as the parent of #429/#565/#584, so the exclusions recorded on those threads do not apply. The integrator should still check eligibility and the two-distinct-account rule before squash.
Refs #581
Refs #371
Restore the submodule snapshot fixture's actual checked-out bytes after local edits, and verify that both cleanliness and the original snapshot hash return. Literal LF restoration failed when the checkout originally contained CRLF.
The existing regression now runs explicit
core.autocrlf=trueandfalsecases and verifies actual CRLF/LF checkout bytes. Its process-scoped Git configuration appends one option while preserving inherited options. Both distinct-edit and dirty-state assertions remain. Onlytests/test_runtime.pychanges (+28/−10); production code, global/repository Git configuration, CI lanes and advisory-host policy remain unchanged.Current final head:
71003438aa98d6362ef9f24d3d134e383a493520. This includes a meaningful portable regression enhancement after the earlier source-identical review refresh; current-head reviews/CI are required anew.Actual Windows / real-Git validation on the final content:
core.autocrlf=false. The regression itself exercises both explicit settings, verifies real checkout bytes, distinct edit hashes, restored clean state and restored original hash.a97b985fgave 38 tests / 15 subtests and Ready CI 45046200693 green. Those and the intermediate56d0f9careview-refresh run remain historical; final-head Ready CI is pending.@zengchuang-hw / Codex is #581's implementer and acceptance/closure owner under the user's standing delegation; its self-checks do not count. Dong1017 triaged and reviewed this bounded standalone bug, rather than owning or implementing its delivery. That is distinct from Dong's parent role in #429/#565/#584, where the account is excluded. Each candidate review is still checked for actual independence, write+ permission, current head and formal Approve with
LGTMalone on the first nonempty line. Two different eligible accounts and final green checks are required before squash.DCO and actual Codex author/integrator attribution remain in the commits; no precise runtime model/effort is invented and no protected knowledge path changes.
After actual main verification, publish #581's Delivered / Verified / Limits card and close that bounded bug. Parent #371 and overall #365 acceptance remain open. The original #577 expanded-check failure is preserved; this correction does not retroactively change that record.