明确核查范围并补齐公司明细关联
This commit is contained in:
@@ -34,6 +34,7 @@ export type ResearchEvidence = {
|
||||
export type ResearchReview = {
|
||||
id: string; type: string; company: string; summary: string;
|
||||
evidenceIds: string[]; handling: string;
|
||||
scope?: "companies" | "dataset" | "excluded-candidate"; companyIds?: string[];
|
||||
};
|
||||
export type ResearchCoverage = {
|
||||
source: string; accessedAt: string; candidateRecords: number; profilesRead: number;
|
||||
@@ -101,10 +102,23 @@ export function validateResearch(snapshot: ResearchSnapshot) {
|
||||
snapshot.companies.filter((c) => c.profileOnly).length !== coverage.newProfiles || !evidenceUrl(coverage.source)))
|
||||
throw new Error("Invalid research coverage accounting");
|
||||
for (const r of snapshot.reviews)
|
||||
if (r.evidenceIds.some((id) => !evidence.has(id)))
|
||||
if (r.evidenceIds.some((id) => !evidence.has(id)) ||
|
||||
(r.companyIds && (new Set(r.companyIds).size !== r.companyIds.length ||
|
||||
r.companyIds.some((id) => !companies.has(id)))) ||
|
||||
(r.scope && !["companies", "dataset", "excluded-candidate"].includes(r.scope)) ||
|
||||
(r.scope === "companies" && !r.companyIds?.length) ||
|
||||
(r.scope && r.scope !== "companies" && !!r.companyIds?.length))
|
||||
throw new Error(`Invalid research review: ${r.id}`);
|
||||
}
|
||||
|
||||
/** Explicit reviewed associations take priority; older revisions use evidence ownership. */
|
||||
export function reviewCompanyIds(snapshot: ResearchSnapshot, review: ResearchReview): string[] {
|
||||
if (review.companyIds) return review.companyIds;
|
||||
const evidenceIds = new Set(review.evidenceIds);
|
||||
return [...new Set(snapshot.evidence.flatMap((e) =>
|
||||
e.companyId && evidenceIds.has(e.id) ? [e.companyId] : []))];
|
||||
}
|
||||
|
||||
export function categorySummary(snapshot: ResearchSnapshot) {
|
||||
return snapshot.categories.map((category) => {
|
||||
const companies = snapshot.companies.filter((c) => c.cat === category.id);
|
||||
|
||||
Reference in New Issue
Block a user