Skip to content

Restore actual submodule checkout bytes in snapshot regression - #582

Merged
zengchuang-hw merged 3 commits into
mainfrom
codex/371-submodule-fixture-bytes
Nov 22, 2026
Merged

zengchuang-hw merged 3 commits into
mainfrom
codex/371-submodule-fixture-bytes

Conversation

@zengchuang-hw

@zengchuang-hw zengchuang-hw commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

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=true and false cases 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. Only tests/test_runtime.py changes (+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:

  • 39 tests / 15 subtests passed for the complete runtime module, with caller process configuration core.autocrlf=false. The regression itself exercises both explicit settings, verifies real checkout bytes, distinct edit hashes, restored clean state and restored original hash.
  • 2 focused cases passed before the complete run.
  • Negative control: temporarily reintroducing literal LF restoration makes the forced-CRLF regression fail even under the caller's LF/default-like setting. The exact-byte restoration was restored before the passing final run; this proves the case no longer depends on host defaults.
  • Ruff and whitespace checks pass. No test/assertion was removed or skipped and no global Git configuration changed.
  • Earlier source a97b985f gave 38 tests / 15 subtests and Ready CI 45046200693 green. Those and the intermediate 56d0f9ca review-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 LGTM alone 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.

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 jiangkuaixue123 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

审查意见

改了什么

只动了 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 jiangkuaixue123 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改了什么

只动了测试文件 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 jiangkuaixue123 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改了什么

只动了 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 jiangkuaixue123 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改了什么

这个 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(工作区有未提交改动),测试误失败。

本次做法:

  1. 编辑前用 read_bytes() 记下检出时的真实字节;
  2. 还原时写回这些字节,而不是写死 LF;
  3. 额外断言还原后的 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 Dong1017 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 with b"original\n". Where Git's checkout converts line endings (for example core.autocrlf on Windows), that is not the checked-out byte content, so the dirty is False assertion could fail. The test now saves vendor.read_bytes() before editing and writes those bytes back, so it restores what Git actually checked out.
  • The new assertion restored["snapshot_hash"] == original_snapshot is sound. In src/inferrsi/apps/host/targets/git.py, snapshot_hash is sha256(f"{head}:{dirty_hash}"). dirty_hash covers the parent git diff --binary HEAD, the untracked files and the submodule facts (snapshot_hash and dirty from the nested repository_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 != second and dirty is True assertions 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.


Copy link
Copy Markdown
Contributor Author

@jiangkuaixue123 已收到你对当前 a97b985f0a96f34dd4db46389629527ac615c3dc 的实际检视与批准结论。目前同一账号提交了 4 份 Approve,但首个非空行均为小标题,所以按 仓库 review 约定 尚不能计为有效票,同一账号也始终只算一票。

请编辑你已有的一份当前头 Approve,把正文第一个非空行改成单独、区分大小写的 LGTM,下一行空行后保留现有检视全文;无需重复重新审查或连续提交相同 review。#577 的当前头 review 6013317990 也有相同格式问题,请一并处理。若是代理代交,请保留实际代理身份及直接授权/standing delegation 来源。

Dong 当前已给出此独立测试修复的 LGTM/Approve;我作为作者/父责任人的自检不计票。仍待两份有效独立审批和最终 CI,不提前合入。

@Dong1017 Dong1017 added the kind:task Bounded delivery task with a delegated slice label Nov 22, 2026

zengchuang-hw commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor Author

当前最终头 a97b985f0a96f34dd4db46389629527ac615c3dc 的 Ready CI 45046200693 已全部成功,包含两版全量、两版安装包、Dashboard、PR references 和两个 advisory host;知识策略状态也成功。

当前尚不满足合入条件。 Dong 的独立 LGTM/Approve 有效,但 Jiang 的多份 Approve 都没有以单独的 LGTM 开头,暂不能计入仓库要求的两票;GitHub 原生 approval 数不能替代这项约定。@jiangkuaixue123 请编辑你最新一份当前头 review 6013365938 的首个非空行,仅增加 LGTM 一行并保留正文及代理授权说明;或由你本人新提交一份同头、首行 LGTM 的正式 Approve。门禁以每个账号最新的 opinionated review 为准,编辑更早那份不能覆盖后面仍不合格式的记录。#577 同样需要你修正 review 6013317990;无需再次重复提交多份相同 review。

@david6666666 @hsliuustc0106 也可对本单文件测试修复给独立实际结论。我作为作者不计票,满足有效两票后会核对最新状态再 squash 并在 main 复验。

Copy link
Copy Markdown
Contributor Author

@linyueqian 也请对这份独立测试修复给实际检视:当前 a97b985f0a96f34dd4db46389629527ac615c3dc,仅 tests/test_runtime.py +6/−2,修正 CRLF checkout 被 literal LF 错误还原,并核对恢复后 hash。真实 Windows 的完整 runtime 38 tests / 15 subtests、另一换行配置定向回归,以及最终 Ready CI 都已通过。

我为作者/父责任人,不计独立票;Dong 对这份独立 bug 修复的批准有效,Jiang 现有记录仍待格式修正。请独立给结论,不预设批准;如由授权代理代交请写身份和授权来源,通过时正式 Approve 首个非空行单独为 LGTM。两份合资格不同账号的当前头批准和最终检查齐备后再 squash,并在 main 复验关闭 #581。

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>

Copy link
Copy Markdown
Contributor Author

为刷新正式复审记录,已追加签署的源码树完全相同提交:当前 56d0f9caa62ac9dd61e4af928f3457979accc4cf,与此前 a97b985f 都是 tree 08e7a95f653545b4dd6c4f4763ec7812918dfff3,无代码/断言/CI 规则变化。旧格式记录仍不计有效票;新头将跑自己的 Ready CI。

@Dong1017 @jiangkuaixue123 @linyueqian 请基于当前头重新核对这份单文件回归并提交实际结论。通过时正式 Approve 首个非空行单独为 LGTM,代理代交保留实际身份和授权来源。至少两个不同的合资格独立账号、当前头和最终 CI 仍必需;我作为作者不计票。没有预填任何批准,也不以空提交代替审查。

Dong1017
Dong1017 previously approved these changes Nov 22, 2026

@Dong1017 Dong1017 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_hash the test now reads vendor.read_bytes() before any edit. It restores those bytes at the end instead of the literal b"original\n". Under core.autocrlf=true the 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 that dirty is false.
  • assertNotEqual(first, second) and assertTrue(...["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…) as a97b985f. 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>

Copy link
Copy Markdown
Contributor Author

当前实质回归增强头为 71003438aa98d6362ef9f24d3d134e383a493520:把 autocrlf=true/false 两种实际 checkout 固化为独立用例,保留继承的 Git 参数和全部 hash/dirty 断言。完整 runtime 39 passed / 15 subtests;临时恢复旧 literal-LF 错误时,CRLF 用例在 caller=false 下实际失败,恢复正确代码后全绿。没有改生产代码、全局 Git 配置或 CI 规则。

@Dong1017 @jiangkuaixue123 @linyueqian 请复审这一份有实际测试差异的新头,旧头记录不转为新头有效票。通过时正式 Approve 首个非空行单独为 LGTM,由实际评审本人/其授权代理提交并保留身份说明。CI 将以该头的最终结果为准。

关于独立性:#581 已明确 Root 为该 bounded bug 的实现/接受责任人,Dong 在此为外部 triage/reviewer;不是 #429/#565/#584 的父责任票。合入前仍会按实际贡献/角色核对,而不是只按 GitHub 的批准数量。

@jiangkuaixue123 jiangkuaixue123 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)下跑同一套逻辑:

  1. 用 Git 的 GIT_CONFIG_COUNT / GIT_CONFIG_KEY_* 环境变量追加一项配置,不覆盖调用方已有的进程级 Git 选项。
  2. 建好超级工程(superproject,里面挂着 submodule)后,先 read_bytes() 记下真实检出字节,并断言与预期换行一致。
  3. 两次不同编辑仍要得到不同哈希,且处于 dirty(工作区有未提交改动)。
  4. 写回当初记下的字节(而不是字面量 original\n),并断言 dirty 消失且快照哈希回到改动前。

这正好修掉「在 CRLF 检出上写回 LF → 一直假脏 → 断言误失败」的问题,也把两种换行都钉死成可复现用例。

问题与风险

没有发现影响正确性、安全或声明行为的实质缺陷。

  • os / patch 本文件已有导入;每个测试方法有独立 setUp 临时目录,两条用例不会抢同一路径。
  • 中间两次编辑故意写 LF,只为制造 dirty 对比,不用于恢复,合理。
  • mergeable_state=blocked 看下来是分支保护(审批 / CI)未齐,不是「被未合入前置 PR 挡住、diff 无法单独判断」;本 diff 可独立审。

非阻塞小建议:合入前以本头 Ready CI 最终结果为准(作者也写了仍在等);我这边未在本机复跑 pytest。

结论

批准(Approve)。

理由:这是单文件、意图清楚的可移植性回归增强,断言更强,未见实质问题。

@Dong1017 Dong1017 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 literal b"original\n", so a CRLF checkout is restored exactly. The test also asserts restored["snapshot_hash"] == original_snapshot and dirty is false.
  • Both line-ending cases are explicit. test_submodule_local_edit_changes_snapshot_hash runs autocrlf=true. The new ..._with_lf_checkout_... test runs autocrlf=false. Both go through _check_submodule_edit_restore. The checkout bytes are asserted (original\r\n for true, original\n for 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, with n taken from the caller's existing count, so inherited options are preserved. patch.dict(os.environ, …) restores the environment afterwards. os and patch are already imported (lines 4 and 13). make_superproject shells out to git without overriding the environment, so the submodule clone inherits the setting. make_superproject is called inside the patched block, so the checkout really happens under the chosen setting.
  • Original assertions remain. first != second, dirty is True after 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.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind:task Bounded delivery task with a delegated slice

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants