深化20条目录资料并保留发现来源审计
This commit is contained in:
@@ -188,7 +188,7 @@ async function main() {
|
||||
assert.equal(research.companies.length, 1015);
|
||||
assert.equal(research.categories.length, 11);
|
||||
assert.equal(research.evidence.length, 1086);
|
||||
assert.equal(research.observations.length, 151);
|
||||
assert.equal(research.observations.length, 155);
|
||||
assert.equal((await request("/api/research/ai-companies", { method: "POST", headers })).status, 405);
|
||||
const researchPage = await request("/docs/other-research/ai-company-research/overview", { headers });
|
||||
assert.equal(researchPage.status, 200);
|
||||
|
||||
@@ -14,6 +14,7 @@ export type ResearchCompany = {
|
||||
extraUrl?: string; pricingEvidence?: string;
|
||||
businessModel?: string; entityBasis?: string;
|
||||
profileOnly?: boolean; classificationBasis?: string; directoryTags?: string[];
|
||||
directoryOrigin?: "yc-2025-2026";
|
||||
technicalReview?: {
|
||||
level: "description" | "public-artifact" | "independent-test";
|
||||
reviewedAt: string; summary: string; evidenceIds: string[]; testScope?: string;
|
||||
@@ -81,6 +82,8 @@ export function validateResearch(snapshot: ResearchSnapshot) {
|
||||
throw new Error(`Invalid technical review: ${c.id}`);
|
||||
if (c.profileOnly && (c.revenueStatus !== "unknown" || !c.classificationBasis))
|
||||
throw new Error(`Invalid profile-only research record: ${c.id}`);
|
||||
if (c.directoryOrigin && (c.directoryOrigin !== "yc-2025-2026" || !/^YC\d+$/.test(c.id)))
|
||||
throw new Error(`Invalid research directory origin: ${c.id}`);
|
||||
if (!categories.has(c.cat) || !evidenceUrl(c.url) ||
|
||||
c.evidenceIds.some((id) => !evidence.has(id)) ||
|
||||
(c.pricingEvidence && !evidence.has(c.pricingEvidence)))
|
||||
@@ -99,7 +102,7 @@ export function validateResearch(snapshot: ResearchSnapshot) {
|
||||
if (coverage && (coverage.profilesRead + coverage.failedProfiles !== coverage.candidateRecords ||
|
||||
coverage.matchingProfiles !== coverage.existingProfiles + coverage.newProfiles ||
|
||||
coverage.matchingProfiles + coverage.otherOrMissingYear + coverage.unclearAI + coverage.dateConflicts !== coverage.profilesRead ||
|
||||
snapshot.companies.filter((c) => c.profileOnly).length !== coverage.newProfiles || !evidenceUrl(coverage.source)))
|
||||
snapshot.companies.filter((c) => c.profileOnly || c.directoryOrigin === "yc-2025-2026").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)) ||
|
||||
|
||||
@@ -25,7 +25,7 @@ test("research revisions share the authentication database and preserve replay l
|
||||
const initial = readResearchSnapshot();
|
||||
assert.equal(initial.companies.length, 1015);
|
||||
assert.equal(initial.evidence.length, 1086);
|
||||
assert.equal(initial.observations.length, 151);
|
||||
assert.equal(initial.observations.length, 155);
|
||||
assert.deepEqual(readResearchSnapshot(), initial, "reopening does not duplicate records");
|
||||
const db = openSiteDatabase();
|
||||
const tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table'").all() as { name: string }[];
|
||||
@@ -62,7 +62,7 @@ test("research validation rejects broken evidence and unsafe source links", () =
|
||||
|
||||
test("reviews link explicit companies without turning global or excluded cases into companies", () => {
|
||||
const snapshot = structuredClone(seed) as ResearchSnapshot;
|
||||
assert.equal(snapshot.reviews.filter((r) => r.scope === "companies").length, 28);
|
||||
assert.equal(snapshot.reviews.filter((r) => r.scope === "companies").length, 29);
|
||||
assert.equal(snapshot.reviews.filter((r) => r.scope === "dataset").length, 3);
|
||||
assert.equal(snapshot.reviews.filter((r) => r.scope === "excluded-candidate").length, 8);
|
||||
const review = snapshot.reviews.find((r) => r.id === "R4")!;
|
||||
@@ -84,10 +84,10 @@ test("disclosure counts exclude client income, biographies, targets and duplicat
|
||||
const snapshot = seed as ResearchSnapshot;
|
||||
const summary = categorySummary(snapshot);
|
||||
assert.equal(summary.reduce((n, c) => n + c.count, 0), 1015);
|
||||
assert.equal(summary.reduce((n, c) => n + c.self, 0), 17);
|
||||
assert.equal(summary.reduce((n, c) => n + c.self, 0), 18);
|
||||
assert.equal(summary.reduce((n, c) => n + c.estimate, 0), 1);
|
||||
assert.equal(summary.reduce((n, c) => n + c.platform, 0), 16);
|
||||
assert.equal(summary.reduce((n, c) => n + c.unknown, 0), 981);
|
||||
assert.equal(summary.reduce((n, c) => n + c.unknown, 0), 980);
|
||||
assert.equal(snapshot.companies.find((c) => c.name === "Rork")?.revenueStatus, "unknown");
|
||||
assert.equal(snapshot.companies.find((c) => c.name === "Result")?.revenueStatus, "unknown");
|
||||
assert.ok(snapshot.observations.filter((o) => o.selection === "signal").every((o) => o.scope === "公司整体"));
|
||||
@@ -167,15 +167,22 @@ test("directory coverage reconciles every candidate and keeps profile-only incom
|
||||
assert.equal(count("ai-unclear"), coverage.unclearAI);
|
||||
for (const row of coverageAudit.records.filter((r) => r.status === "imported")) {
|
||||
const company = snapshot.companies.find((c) => c.id === `YC${row.ycId}`)!;
|
||||
assert.ok(company.profileOnly);
|
||||
assert.ok(company.profileOnly || company.directoryOrigin === "yc-2025-2026");
|
||||
assert.equal(company.url, row.source);
|
||||
assert.equal(company.revenueStatus, "unknown");
|
||||
if (company.profileOnly) assert.equal(company.revenueStatus, "unknown");
|
||||
assert.equal(company.year, row.foundedYear);
|
||||
assert.ok([2025, 2026].includes(company.year!));
|
||||
}
|
||||
const invalid = structuredClone(snapshot);
|
||||
invalid.coverage!.newProfiles += 1;
|
||||
assert.throws(() => validateResearch(invalid), /coverage accounting/);
|
||||
const promoted = snapshot.companies.find((c) => c.id === "YC30215")!;
|
||||
assert.equal(promoted.profileOnly, false);
|
||||
assert.equal(promoted.directoryOrigin, "yc-2025-2026");
|
||||
assert.equal(promoted.revenueStatus, "self");
|
||||
const lostOrigin = structuredClone(snapshot);
|
||||
delete lostOrigin.companies.find((c) => c.id === promoted.id)!.directoryOrigin;
|
||||
assert.throws(() => validateResearch(lostOrigin), /coverage accounting/);
|
||||
});
|
||||
|
||||
test("income descriptions report sample dispersion and maximum-value sensitivity", () => {
|
||||
|
||||
Reference in New Issue
Block a user