Repository navigation
fix(git): 禁用自动全量扫描并约束状态进程 / disable automatic scans and bound status processes - #76
schattgieselman-lgtm wants to merge 2 commits into
Conversation
…d status processes - 后台仅读取有界元数据,手动扫描才运行 Git / read bounded metadata in the background and run Git only for explicit scans - 合并重复请求并限制扫描时长与输出,超时清理本次进程树 / coalesce duplicate requests, bound time and output, and clean up owned process trees - 区分未扫描与失败状态,提交前失败关闭,并添加跨平台回归测试 / distinguish unknown and failed states, fail closed before committing, and add cross-platform regression tests
|
感谢这个 PR,不过目前有几处功能回归,需要先修再合。 建议的整体方向这里其实是两个独立的问题:
本 PR 对第 2 条的处理(去重、超时、只清理自己创建的进程树)我认为可以保留。对第 1 条,彻底取消自动扫描代价偏大,下面几处回归都由此而来。建议改成更轻的方案:
这样分支名、upstream、ahead/behind 始终是真实值,同时仍然去掉了最危险的那条路径。 需要修改1. 推送行为改变( 推送用 2. 工作区为仓库子目录时无法提交( 扫描前的 3. ahead/behind 指示失效,分支名会过期 挂载时不扫描,↑↓ 计数默认不显示;每次写操作后的 按上面的轻量方案处理后,第 1 条和本条都会一并解决。 希望讨论
其他问题
想请你补充的信息为了把归因再坐实一些,方便的话请提供:
另外说明一点: |
背景 / Context
在 Windows / Deva 0.1.16 / Git 2.49.0.windows.1 上排查到两个长期存活的孤儿进程,命令均为:
两者合计约 33 GiB 私有内存,系统分页文件曾增长至约 37.5 GiB。终止这两个具体进程后,系统提交量明显下降。
归因边界:历史父进程已退出,缺少启动链日志,因此不能证明这两个进程由 Deva 启动,也没有复现原始 OOM。 但当前 GitWidget 在挂载和每轮 AI 回复结束后执行完全相同的全量扫描;主进程没有跨请求去重,使用 execFile 的直接子进程超时,也没有显式进程树清理。本 PR 对这条风险路径做防御性修复。
Two orphan Git status processes were observed consuming ~33 GiB of private memory in total. Their original parents were gone, so attribution to Deva is not proven, and the original OOM was not reproduced. The matching automatic scan path currently lacks request coalescing and explicit descendant cleanup; this PR hardens that path without claiming to fix every memory-growth cause.
改动 / Changes
git.status(dir)只读取有界.git/HEAD/MERGE_HEAD元数据,支持 linked worktree;不读取 index,不递归枚举文件,也不在挂载时执行git --version。移除 AI 回复完成后的自动扫描。{ scan: true },保留-uall/ NUL 文件级语义。拒绝磁盘根、用户目录和 Windows 系统目录;不把受信子目录扩展成未授权父目录扫描。先核对 Git 实际 worktree,避免配置重定向。taskkill /T,POSIX 使用本次创建的进程组。不按进程名全局终止 Git。scanState区分未扫描、完成和失败;界面显示扫描失败/重试,提交前扫描失败时禁止使用旧快照继续暂存和提交。验证 / Validation
本机 Windows(Node 24.16.0 / pnpm 10.8.0):
pnpm --filter @deva/desktop test:git— 19 tests passedpnpm typecheckpnpm build(已有 Vite 分块大小和 npm 配置警告,不影响成功退出)git diff --check回归覆盖元数据/linked worktree/异常 gitfile、默认不启动 Git、严格 opt-in、信任边界、并发去重与失败释放、真实小仓库 Git 输出、Windows launcher 选择、输出上限、超时终止后代且不影响无关进程、退出应用取消。
Tests include a real disposable Git repository and a real owned descendant process tree; no large-disk or OOM stress scan is run. CI adds the focused suite on Windows and Ubuntu / Node 22. Linux CI and live Electron UI behavior are not claimed as locally verified.
未上传本机安装包、补丁产物、个人路径或诊断日志。
No installed application bundles, local patch artifacts, private paths or personal logs are included.