Repository navigation
Conversation
Refs #751 Co-Authored-By: Claude Code <noreply@anthropic.com>
Yanami-2K
approved these changes
Nov 14, 2026
Yanami-2K
left a comment
Collaborator
There was a problem hiding this comment.
对照 #751 核对了完整 diff:fdDirHoldsFile 逐字搬移了单进程 fd 扫描(跳过非 / 开头的链接、先比路径再比 inode),只把 ReadDir 错误返回给调用方,gitIndexLockHeldUnder 的 uncertain 判定和命中返回值均未变。TestFdDirHoldsFile 用伪造 fd 目录断言了 pipe/socket、其他文件、悬空链接、同路径、硬链接同 inode 和目录不存在返回 NotExist,CI 全部通过。
Collaborator
Author
|
复审结论:✅ 通过(head
没有发现问题。 |
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.
Closes #751
改了什么
internal/runtime/git_isolation.go:把gitIndexLockHeldUnder里最内层「扫描单个进程 fd 目录、判断是否有描述符指向锁文件」的循环拆为私有函数fdDirHoldsFile(dir, want string, lock os.FileInfo) (bool, error)。target == want)或 inode(os.SameFile)命中返回true;返回的 error 只表示 fd 目录本身读取失败。/开头)的规则、注释和判定顺序逐字不变。gitIndexLockHeldUnder只保留锁文件校验、/proc遍历和「读不到 fd 目录 → 是否记为不确定」的判定,嵌套从三层循环降为两层。internal/runtime/git_index_lock_fd_test.go:TestFdDirHoldsFile覆盖空目录、pipe/socket/anon_inode、指向其他文件、悬空链接、同路径命中、硬链接同 inode 命中、fd 目录不存在返回os.ErrNotExist。为什么
原函数把锁文件校验、进程遍历、fd 链接匹配和「不确定」判定写在同一个函数里,最内层逻辑只能借助真实
/proc或伪造整棵进程树间接测试。拆出后单进程扫描可以直接单测,主函数读起来就是「遍历进程 → 读不到如何处理 → 命中即返回」。不改导出接口,不改行为。怎么验证的
gofmt -l internal/runtime无输出;go vet ./internal/runtime/通过。go test ./internal/runtime/ -run 'FdDirHoldsFile|GitIndexLock|IndexLock':新增测试及现有TestGitIndexLock*、TestRestoreProjectAgentGitIndex*、TestProjectAgentGitIndexLockWaitStopsOnCancel全部通过(bind mount 用例本机按原逻辑 SKIP)。go test ./internal/runtime/全量:7 个失败(2 个需要 Chromium、5 个 Docker 相关用例在全量跑时失败),在未改动的origin/main上全量跑失败列表完全相同;这 5 个 Docker 用例在本分支单独跑全部通过,与本次改动无关。🤖 Generated with Claude Code