diff --git a/deploy/profile-scripts/deploy_guard.py b/deploy/profile-scripts/deploy_guard.py index e11c5782..4b745a1b 100644 --- a/deploy/profile-scripts/deploy_guard.py +++ b/deploy/profile-scripts/deploy_guard.py @@ -79,6 +79,10 @@ def git(*args, check=True): # ── 1. 代码漂移检测与回滚 ── def check_code_drift(): + # 2026-08-25 假漂移过滤:git status 受 stat 缓存抖动误报 M(touch/mtime 变化即报), + # 导致 heavy_run.sh/regime_perf_daily.sh 反复被"假回滚"+告警噪音。 + # 先 refresh 索引 stat 缓存,再对报 M 的文件做内容级 diff 二次确认,无实质差异不回滚。 + git("update-index", "--refresh", check=False) out = git("status", "--porcelain", "--", *CODE_PATHS) if not out: return @@ -94,6 +98,16 @@ def check_code_drift(): untracked.append(path) else: modified.append(path) + if modified: + # 内容级二次确认:diff HEAD 为空的 = stat 抖动假漂移,不回滚 + real_modified = [f for f in modified + if git("diff", "--name-only", "HEAD", "--", f, check=False).strip()] + if not real_modified: + log(f"DRIFT假报(stat缓存抖动,内容无实质差异,不回滚): {modified}") + modified = [] + elif len(real_modified) < len(modified): + log(f"DRIFT部分假报: 真实修改={real_modified}, 假抖动={ [f for f in modified if f not in real_modified] }") + modified = real_modified if modified: diff_stat = git("diff", "--stat", "--", *modified, check=False) log(f"DRIFT: 检测到 {len(modified)} 个代码文件未入库改动: {modified}")