fix(ai-review exclusions): 修正追加排除規則時讀寫目錄顛倒導致既有規則被覆蓋

appendExclusions 原以 WORKSPACE 為主、repoDir 為鏡像,與 loadExclusions 相反,
會讀到空的 WORKSPACE 後把僅含本次新增的結果鏡像覆蓋掉 repoDir 既有規則,
改為以 repoDir 為主、WORKSPACE 為鏡像,順序與 loadExclusions 一致。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jeffery
2026-06-23 17:32:49 +08:00
co-authored by Claude Opus 4.8
parent bd9a3111fa
commit fcde1b0bc9
+3 -1
View File
@@ -115,7 +115,9 @@ async function main() {
// Step7 過濾:套用排除規則 + 防守方 AI 誤報裁決 // Step7 過濾:套用排除規則 + 防守方 AI 誤報裁決
step('Step7', '排除規則與誤報過濾'); step('Step7', '排除規則與誤報過濾');
if (reconcile.excludedFindings.length > 0) { if (reconcile.excludedFindings.length > 0) {
appendExclusions(WORKSPACE, reconcile.excludedFindings, repoDir || WORKSPACE); // 以 repoDir 為主(即將提交回去的來源分支副本),WORKSPACE 為鏡像;
// 順序須與下方 loadExclusions 一致,否則會讀到空的 WORKSPACE 而把既有排除規則覆蓋掉。
appendExclusions(repoDir || WORKSPACE, reconcile.excludedFindings, WORKSPACE);
} }
const exclusions = loadExclusions(repoDir || WORKSPACE, repoState, WORKSPACE); const exclusions = loadExclusions(repoDir || WORKSPACE, repoState, WORKSPACE);
input(`待過濾 ${sorted.length} 筆;排除規則 ${exclusions.length}`); input(`待過濾 ${sorted.length} 筆;排除規則 ${exclusions.length}`);