fix(審查流程): 修正 bot 跳過、JSON 驗證與排除比對邊界
CI / 1. BUILD (pull_request) Successful in 3s
CI / 2. TEST (pull_request) Has been skipped
CI / 3. RESULT (pull_request) Has been skipped

This commit is contained in:
2026-07-11 12:18:24 +00:00
parent 268cd05211
commit 8f909e5397
10 changed files with 94 additions and 15 deletions
+20 -8
View File
@@ -78,16 +78,18 @@ export function groupConversations(comments) {
const lineNum = Number(c?.position) || Number(c?.new_position) || Number(c?.original_position) || 0;
const key = `${filePath}|${lineNum}`;
if (!groups.has(key)) {
groups.set(key, { key, path: filePath, line: lineNum, commentIds: [], bodies: [], resolved: false, botFinding: null });
groups.set(key, { key, path: filePath, line: lineNum, commentIds: [], bodies: [], resolved: false, botFinding: null, botFindings: [] });
}
const g = groups.get(key);
if (c?.id != null) g.commentIds.push(c.id);
const body = typeof c?.body === 'string' ? c.body : '';
if (body) g.bodies.push(body);
if (c?.resolver) g.resolved = true;
if (!g.botFinding) {
const finding = parseBotReviewComment(body);
if (finding) g.botFinding = { ...finding, location: lineNum ? `${filePath}:${lineNum}` : filePath };
const finding = parseBotReviewComment(body);
if (finding) {
const normalizedFinding = { ...finding, location: lineNum ? `${filePath}:${lineNum}` : filePath };
g.botFindings.push(normalizedFinding);
if (!g.botFinding) g.botFinding = normalizedFinding;
}
}
return [...groups.values()].map(g => ({ ...g, thread: g.bodies.join('\n---\n') }));
@@ -146,8 +148,12 @@ export async function judgeConversations(items, chatFn = chatJSON) {
* @returns {void}
*/
function pushCarried(target, conversation) {
if (!conversation.botFinding) return;
target.push({ ...conversation.botFinding, is_new: false });
const findings = conversation.botFindings?.length
? conversation.botFindings
: (conversation.botFinding ? [conversation.botFinding] : []);
for (const finding of findings) {
target.push({ ...finding, is_new: false });
}
}
/**
@@ -273,10 +279,16 @@ export async function reconcileConversations(deps = {}) {
const verdict = verdictByIdx.get(i) || 'open';
if (verdict === 'resolved') {
resolvedCount += 1;
if (c.botFinding) resolvedFindings.push({ ...c.botFinding, is_new: false });
const findings = c.botFindings?.length ? c.botFindings : (c.botFinding ? [c.botFinding] : []);
for (const finding of findings) {
resolvedFindings.push({ ...finding, is_new: false });
}
} else if (verdict === 'false_positive') {
falsePositiveCount += 1;
if (c.botFinding) excludedFindings.push(toExclusion(c.botFinding));
const findings = c.botFindings?.length ? c.botFindings : (c.botFinding ? [c.botFinding] : []);
for (const finding of findings) {
excludedFindings.push(toExclusion(finding));
}
} else {
openCount += 1;
pushCarried(carriedFindings, c);