登记Product Hunt候选并补充Kilo公司个案

This commit is contained in:
2026-10-30 15:11:59 +08:00
parent f27b82b6a5
commit dca7c81889
11 changed files with 616 additions and 35 deletions
+3 -3
View File
@@ -185,10 +185,10 @@ async function main() {
assert.equal(researchResponse.status, 200, "authenticated research API");
assert.ok(researchResponse.headers.get("cache-control")?.includes("no-store"));
const research = await researchResponse.json();
assert.equal(research.companies.length, 1015);
assert.equal(research.companies.length, 1016);
assert.equal(research.categories.length, 11);
assert.equal(research.evidence.length, 1091);
assert.equal(research.observations.length, 183);
assert.equal(research.evidence.length, 1101);
assert.equal(research.observations.length, 187);
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);
+32 -1
View File
@@ -43,11 +43,20 @@ export type ResearchCoverage = {
otherOrMissingYear: number; unclearAI: number; dateConflicts: number; failedProfiles: number;
discoverySha256: string;
};
export type ResearchCandidateBatch = {
id: string; sourceId: string; url: string; accessedAt: string; scope: string; complete: boolean;
records: {
id: string; name: string; url: string | null; categoryId: string;
kind: "product" | "promotion"; profileStatus: "readable" | "unavailable" | "archive-only";
status: "pending-year" | "linked" | "existing-outside-cohort" | "promotion";
companyId?: string; note: string;
}[];
};
export type ResearchSnapshot = {
version: string; asOf: string; scope: string; limitations: string[];
categories: ResearchCategory[]; companies: ResearchCompany[];
observations: ResearchObservation[]; evidence: ResearchEvidence[];
reviews: ResearchReview[]; coverage?: ResearchCoverage;
reviews: ResearchReview[]; coverage?: ResearchCoverage; candidateBatches?: ResearchCandidateBatch[];
};
export function evidenceUrl(value: string): string | undefined {
@@ -98,6 +107,28 @@ export function validateResearch(snapshot: ResearchSnapshot) {
!Number.isFinite(o.value))
throw new Error(`Invalid research observation: ${o.id}`);
}
unique((snapshot.candidateBatches ?? []).map((b) => b.id), "candidate batches");
unique((snapshot.candidateBatches ?? []).flatMap((b) => b.records.map((r) => r.id)), "candidates");
for (const batch of snapshot.candidateBatches ?? []) {
if (!/^S\d{2}$/.test(batch.sourceId) || !evidenceUrl(batch.url) || !batch.scope.trim() ||
typeof batch.complete !== "boolean" || !/^\d{4}-\d{2}-\d{2}$/.test(batch.accessedAt) ||
Number.isNaN(Date.parse(batch.accessedAt)) ||
new Date(batch.accessedAt).toISOString().slice(0, 10) !== batch.accessedAt ||
batch.accessedAt > snapshot.asOf)
throw new Error(`Invalid research candidate batch: ${batch.id}`);
for (const row of batch.records) {
const linked = ["linked", "existing-outside-cohort"].includes(row.status);
if (!row.name.trim() || !row.note.trim() || !categories.has(row.categoryId) ||
!["product", "promotion"].includes(row.kind) ||
!["readable", "unavailable", "archive-only"].includes(row.profileStatus) ||
!["pending-year", "linked", "existing-outside-cohort", "promotion"].includes(row.status) ||
(row.kind === "product" && (!row.url || !evidenceUrl(row.url))) ||
(row.url !== null && !evidenceUrl(row.url)) ||
linked !== !!row.companyId || (row.companyId && !companies.has(row.companyId)) ||
(row.kind === "promotion") !== (row.status === "promotion"))
throw new Error(`Invalid research candidate: ${row.id}`);
}
}
const coverage = snapshot.coverage;
if (coverage && (coverage.profilesRead + coverage.failedProfiles !== coverage.candidateRecords ||
coverage.matchingProfiles !== coverage.existingProfiles + coverage.newProfiles ||
+24 -8
View File
@@ -23,9 +23,10 @@ test("research revisions share the authentication database and preserve replay l
for (let i = 0; i < 20; i++) consumeCode(config, "invalid");
assert.equal(consumeCode(config, "invalid"), "limited");
const initial = readResearchSnapshot();
assert.equal(initial.companies.length, 1015);
assert.equal(initial.evidence.length, 1091);
assert.equal(initial.observations.length, 183);
assert.equal(initial.companies.length, 1016);
assert.equal(initial.evidence.length, 1101);
assert.equal(initial.observations.length, 187);
assert.deepEqual(initial.candidateBatches, seed.candidateBatches, "candidate gaps persist in the same database metadata");
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 +63,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, 43);
assert.equal(snapshot.reviews.filter((r) => r.scope === "companies").length, 46);
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")!;
@@ -83,11 +84,11 @@ test("reviews link explicit companies without turning global or excluded cases i
test("disclosure counts exclude client income, biographies, targets and duplicate milestones", () => {
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.count, 0), 1016);
assert.equal(summary.reduce((n, c) => n + c.self, 0), 26);
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), 972);
assert.equal(summary.reduce((n, c) => n + c.unknown, 0), 973);
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 === "公司整体"));
@@ -95,8 +96,8 @@ test("disclosure counts exclude client income, biographies, targets and duplicat
test("technical reviews keep accessible materials separate from tested capabilities", () => {
const snapshot = structuredClone(seed) as ResearchSnapshot;
assert.equal(snapshot.companies.filter((c) => c.technicalReview).length, 7);
assert.equal(snapshot.companies.filter((c) => c.technicalReview?.level === "public-artifact").length, 3);
assert.equal(snapshot.companies.filter((c) => c.technicalReview).length, 8);
assert.equal(snapshot.companies.filter((c) => c.technicalReview?.level === "public-artifact").length, 4);
assert.equal(snapshot.companies.filter((c) => c.technicalReview?.level === "independent-test").length, 1);
assert.equal(snapshot.companies.find((c) => c.id === "AI051")?.revenueStatus, "unknown");
assert.match(snapshot.companies.find((c) => c.id === "AI051")!.technicalReview!.testScope!, /Sep 2026/);
@@ -255,3 +256,18 @@ test("distribution statistics match independently calculated snapshot references
}
}
});
test("product launch candidates preserve unresolved years and many launches per company", () => {
const snapshot = structuredClone(seed) as ResearchSnapshot;
const batch = snapshot.candidateBatches![0];
assert.equal(batch.complete, false);
assert.equal(batch.records.length, 19);
const kilo = batch.records.filter((r) => r.companyId === "AI072");
assert.equal(kilo.length, 2, "IDE and hosted products resolve to one company");
assert.equal(snapshot.companies.filter((c) => c.id === "AI072").length, 1);
assert.ok(batch.records.some((r) => r.status === "pending-year" && !r.companyId));
assert.ok(batch.records.some((r) => r.status === "existing-outside-cohort" && r.companyId === "AI054"));
kilo[0].companyId = "missing-company";
assert.throws(() => validateResearch(snapshot), /research candidate/);
});