复核EveryApp入表并保留原候选初筛审计

This commit is contained in:
2026-10-30 16:09:43 +08:00
parent 62c015fa9b
commit 62d3d498bb
11 changed files with 430 additions and 45 deletions
+13
View File
@@ -57,6 +57,10 @@ export type ResearchSnapshot = {
categories: ResearchCategory[]; companies: ResearchCompany[];
observations: ResearchObservation[]; evidence: ResearchEvidence[];
reviews: ResearchReview[]; coverage?: ResearchCoverage; candidateBatches?: ResearchCandidateBatch[];
directoryRechecks?: {
ycId: number; originalStatus: "ai-unclear" | "year-outside-or-missing" | "date-conflict";
companyId: string; reviewedAt: string; evidenceIds: string[]; reason: string;
}[];
};
export function evidenceUrl(value: string): string | undefined {
@@ -132,6 +136,15 @@ export function validateResearch(snapshot: ResearchSnapshot) {
}
}
const coverage = snapshot.coverage;
unique((snapshot.directoryRechecks ?? []).map((row) => String(row.ycId)), "directory rechecks");
for (const row of snapshot.directoryRechecks ?? []) {
if (!Number.isSafeInteger(row.ycId) || row.ycId <= 0 || !companies.has(row.companyId) ||
!["ai-unclear", "year-outside-or-missing", "date-conflict"].includes(row.originalStatus) ||
!/^\d{4}-\d{2}-\d{2}$/.test(row.reviewedAt) || Number.isNaN(Date.parse(row.reviewedAt)) ||
new Date(row.reviewedAt).toISOString().slice(0, 10) !== row.reviewedAt || row.reviewedAt > snapshot.asOf ||
!row.reason.trim() || !row.evidenceIds.length || row.evidenceIds.some((id) => !evidence.has(id)))
throw new Error(`Invalid directory recheck: ${row.ycId}`);
}
if (coverage && (coverage.profilesRead + coverage.failedProfiles !== coverage.candidateRecords ||
coverage.matchingProfiles !== coverage.existingProfiles + coverage.newProfiles ||
coverage.matchingProfiles + coverage.otherOrMissingYear + coverage.unclearAI + coverage.dateConflicts !== coverage.profilesRead ||