Compare commits

..

43 Commits

Author SHA1 Message Date
Zayden-Jung 543d6ed527 Merge pull request '补核18项AI公司缺年候选、主体沿革与收费边界' (#40) from codex/ai-research-consolidated into main
Verify and deploy Tabularium / verify-and-deploy (push) Failing after 4m1s
Reviewed-on: #40
2026-10-31 08:43:48 +00:00
codex-bot 445bfb37d0 补核6项缺年候选并区分旧业务与资金示例 2026-10-31 16:41:30 +08:00
codex-bot baaea4fc61 补核6项缺年候选并以登记证据纳入Zymbly 2026-10-31 16:38:01 +08:00
codex-bot ac04839571 补核6项缺年候选并保留旧品牌与服务收费边界 2026-10-31 16:34:12 +08:00
Zayden-Jung 7cecb9f753 Merge pull request '补核12项缺年AI候选,区分旧主体与成立缺项' (#39) from codex/ai-research-consolidated into main
Verify and deploy Tabularium / verify-and-deploy (push) Failing after 4m15s
Reviewed-on: #39
2026-10-31 08:33:16 +00:00
codex-bot a2a5958fc4 补核12项缺年候选并关联官方主体登记 2026-10-31 16:29:35 +08:00
Zayden-Jung 7cc2397103 Merge pull request '统一 AI 公司研究:504项主营、192项AI候选与6项成立冲突补核' (#38) from codex/ai-research-consolidated into main
Verify and deploy Tabularium / verify-and-deploy (push) Failing after 5m35s
Reviewed-on: #38
2026-10-31 08:27:07 +00:00
codex-bot feb4de220d 补核6项成立冲突并拆分旧年份与缺年候选 2026-10-31 04:48:47 +08:00
codex-bot 652b0fd539 完成192项AI不明名单补核并核对预订与交付口径 2026-10-31 04:37:52 +08:00
codex-bot 5ee04f26ae 补核24项AI候选并区分实体销售与预付收入 2026-10-31 04:26:29 +08:00
codex-bot 812749823b 补核24项AI不明候选并区分同名主体与流失收入 2026-10-31 04:16:25 +08:00
codex-bot 8a4df5c7ba Review fifth uncertain AI cohort and distinguish ARR from service and contract claims 2026-10-31 04:03:33 +08:00
codex-bot 8d886ad3cc Review fourth uncertain AI cohort and separate managed services from transaction flows 2026-10-31 03:51:44 +08:00
codex-bot 790dda09de Review third uncertain AI cohort and retain shutdown and mixed service evidence 2026-10-31 03:44:51 +08:00
codex-bot 5182eca961 Review second uncertain AI cohort and separate client and legacy financials 2026-10-31 03:38:16 +08:00
codex-bot 5cd8f831be Review uncertain AI candidates and preserve unresolved business scope 2026-10-31 03:31:34 +08:00
codex-bot a520694f9e Merge developer tag review into consolidated AI research 2026-10-31 03:17:15 +08:00
codex-bot dc373bad09 Merge model tag review into consolidated AI research 2026-10-31 03:17:08 +08:00
codex-bot dc2c3a22f3 Merge industry review into consolidated AI research 2026-10-31 03:17:02 +08:00
codex-bot fefa7c5ebd Merge enterprise review into consolidated AI research 2026-10-31 03:16:57 +08:00
codex-bot 5c2d9fd06c Complete remaining tag review and distinguish intent from revenue 2026-10-31 03:13:45 +08:00
codex-bot 85a0c534aa Review mixed directory tags and separate historical Mixy income 2026-10-31 03:06:48 +08:00
codex-bot d4736f7477 Complete enterprise-tag review and exclude prospective income claims 2026-10-31 02:59:56 +08:00
codex-bot f41d9e0d53 Review first enterprise-tag cohort and separate client metrics 2026-10-31 02:51:26 +08:00
codex-bot 1736912ecb Complete developer tag review and distinguish agent hosting cost models 2026-10-31 02:39:58 +08:00
codex-bot 45f1d1dba3 Review developer tag candidates and separate runtime and compute businesses 2026-10-31 02:32:24 +08:00
codex-bot 8d7b10df19 Review model tag candidates and separate licensing and revenue evidence 2026-10-31 02:24:38 +08:00
codex-bot d9d675ce56 Complete industry tag review and distinguish service revenue run rates 2026-10-31 02:17:19 +08:00
codex-bot b8a82359e3 Review 20 industry tag candidates and Litmus historical ARR 2026-10-31 02:05:45 +08:00
codex-bot 4682e3513e Review 20 tag-classified industry candidates and current AI relevance 2026-10-31 02:00:16 +08:00
codex-bot c0ff99e640 Complete remaining 39 industry classifications and revenue boundary checks 2026-10-31 01:53:42 +08:00
codex-bot b5e4f817fb Review 20 industry companies and separate services from model claims 2026-10-31 01:44:23 +08:00
codex-bot df227df18c Review 30 industry companies and distinguish revenue commitments 2026-10-31 01:37:48 +08:00
codex-bot 1e81887682 research: review regulated services and separate client assets from income 2026-10-31 01:23:41 +08:00
codex-bot c25fb79eee research: separate industry software from brokerage and operations services 2026-10-31 01:18:08 +08:00
codex-bot a8b054381f research: distinguish industry services and model training inputs 2026-10-31 01:12:51 +08:00
codex-bot 8e5df06fdd research: review industry workflows and historical ARR boundaries 2026-10-31 01:07:22 +08:00
codex-bot 4942b86a4a research: finish enterprise classification and separate Tasklet product history 2026-10-31 00:57:16 +08:00
codex-bot 7e4f4fe3e6 research: separate enterprise workflows and speech model evidence 2026-10-31 00:37:13 +08:00
codex-bot 1e716c36b2 research: review enterprise workflows and product pivots 2026-10-31 00:29:52 +08:00
Zayden-Jung ba042ed5ae Merge pull request '扩展 AI 公司研究并修复收入统计表布局' (#31) from codex/ai-research-cn-sme into main
Verify and deploy Tabularium / verify-and-deploy (push) Successful in 9m0s
Reviewed-on: #31
2026-10-30 16:11:48 +00:00
Zayden-Jung 87987f6cc6 Merge pull request '支持基于内部摘要的章节级文章编辑' (#30) from codex/document-sections into main
Verify and deploy Tabularium / verify-and-deploy (push) Successful in 8m39s
Reviewed-on: #30
2026-10-30 14:05:53 +00:00
codex-bot 9ee2bd219a Add chapter editing API with internal summaries and revision control 2026-10-30 19:58:40 +08:00
16 changed files with 38817 additions and 3942 deletions
+1
View File
@@ -4,6 +4,7 @@
- Web 技术栈为 TypeScript、React、Tailwind CSS、Next.js Pages Router;不要切换到 App Router。
- 使用 pnpm 管理 JavaScript workspace,使用 uv 管理 `tools/figures` 的 Python 项目,保留两套锁文件。
- 文档正文、目录元数据与修订记录以站点现有 SQLite 数据库为唯一权威源,使用文档 API 或 docs 管理工具直接更新;不得把新正文、目录 JSON、数据库文件或日常内容快照提交到仓库。历史 Git 文档只用于显式的一次性迁移,不作为运行时种子。Python 图形源码放在 `tools/figures/src/endor_figures`,可复现的 SVG 输出放在 `apps/docs/public/figures`。
- 编辑已有文章时优先使用章节 API:先读取章节目录与内部摘要,据此选择需要读取正文的章节,再提交单章或多章操作。摘要缺失时先读对应正文并补充;修改观点前必须核对该章原文,检查读取版本与提交 revision 一致。摘要只写入内部章节数据,不放入网页正文、目录摘要或 Git;改写正文时同步更新摘要。完整操作与 Python 客户端用法见 README 的「先读摘要,再按章节编辑」。
- 未确认的架构提议明确标注为草案,不能表述为现有实现。
- 本地开发与预览只监听 `127.0.0.1`。部署容器监听 `0.0.0.0:3000`,服务器入口默认 18135,可通过独立 production.env 配置。
- 对 gitea.entroia.com 仅使用 codex-bot,提交身份为 Codex Bot <codex-bot@gitea.entroia.local>。SSH 使用隔离配置:`ssh -F /dev/null -o IdentitiesOnly=yes -i /Users/zzyang/.codex/credentials/gitea-entroia/codex_entroia_ed25519 -p 22222`。
+50
View File
@@ -75,6 +75,10 @@ sudo /opt/endorphin-tabularium-docs/docs save < "$doc_work_dir/document.json"
| `GET /api/documents/item/<slug>?revision=1` | 读取指定修订的完整正文 |
| `POST /api/documents` | 保存一个完整文档 JSON;字段与 `docs save` 相同 |
| `POST /api/documents/batch` | 保存 `{ "documents": [...] }`,每个请求 1—100 篇 |
| `GET /api/documents/sections/<slug>` | 读取章节 ID、标题和内部摘要,不返回正文 |
| `GET /api/documents/sections/<slug>?section=<id>` | 读取选中章节正文;重复 `section` 可选多章 |
| `GET /api/documents/sections/<slug>?revision=2` | 读取对应修订的章节目录;也可搭配 `section` |
| `POST /api/documents/sections/<slug>` | 原子执行章节新增、更新、删除和移动 |
写入使用 `Authorization: Bearer <文档 API Key>`。新建传 `revision: 0`;更新先读取当前全文,再使用读到的 revision。每篇正文最多 2,000,000 个 JavaScript 字符单位;每次请求最多 8 MiB。目录和修订分页的 `limit` 范围为 1—100,响应包含 `total` 和 `nextOffset`。
@@ -82,6 +86,52 @@ sudo /opt/endorphin-tabularium-docs/docs save < "$doc_work_dir/document.json"
建议写入时提供 `Idempotency-Key`,由 1—128 个字母、数字或 `._:-` 组成。同一个 Key、相同请求 ID 和相同输入重试时,返回原回执并标记 `replayed: true`,不追加修订;相同 ID 改换输入会冲突。回执描述原请求,不代表之后没有其他修改;需要当前内容时重新读取文档。改过正文或 revision 后,应使用新的请求 ID。
### 先读摘要,再按章节编辑
章节接口使用相同的文档 Key 和读写权限。编辑流程为:先读章节目录及摘要,选择需要深入的章节,再读取这些章节的正文,最后提交一组操作。不要只凭摘要修改未读正文;目录与正文响应的 `revision` 应一致,否则重新读取。接口不调用模型生成摘要:由编辑 Agent 阅读正文、撰写摘要,并在编辑请求中保存。
章节按行首 Markdown ATX 二级标题(`##`)划分,三级至六级标题随所属章节一起编辑;代码围栏内的标题不会切章。二级标题之前的文档标题及导言属于固定 ID `preamble`,可以修改但不能删除或移动。Setext 标题、带缩进或引用、列表标记的标题不作为章节边界。正文无行首二级标题时,全文作为导言处理。拆分及组合保持换行和未编辑内容原样,不自动格式化 Markdown。
目录中的每章包含 `id`、`title`、`position`、`summary`、`summaryStatus` 和 `contentHash`。摘要为编辑内部数据,单独保存在 SQLite 的 `document_sections` 和 `document_section_revisions` 中,不加入普通文档响应、网页 props、搜索索引或页面正文。完整数据库备份包含这些表;`docs export` 仍只导出当前文档,不包含内部摘要和修订。
旧文章无需重写,首次读取即可按原文返回目录,初始摘要为空,`summaryStatus` 为 `missing`。Agent 应按需读取这些章节,生成摘要并通过 `update` 保存;保存后状态为 `current`。这里的 `current` 仅表示摘要与该版正文一起保存,不保证模型的总结正确。全文接口仍兼容;未变化章节保留摘要与 ID,正文变化的章节清空摘要,等待更新。全文改名且改写章节时可能产生新 ID,因此全文保存后应重新读取目录。
章节编辑请求示例(示例 ID 需要替换为目录实际返回的值):
```json
{
"revision": 3,
"operations": [
{
"op": "update",
"id": "s_existing",
"content": "## 原有章节\n\n修改后的正文。\n\n",
"summary": "本章说明修改后的核心观点与边界。"
},
{
"op": "insert",
"after": "s_existing",
"content": "## 新章节\n\n新增论证。\n\n",
"summary": "补充上一章尚未覆盖的论证。"
}
]
}
```
`update` 可只改 `summary`,也可改正文;正文改变时若不提供新摘要,旧摘要会清空。`insert` 必须提供正文和非空摘要;摘要最多 8000 个 JavaScript 字符单位。`delete` 使用 `{ "op": "delete", "id": "s_existing" }`;`move` 使用 `{ "op": "move", "id": "s_existing", "after": "preamble" }`。按数组顺序执行,最多 100 个操作;新章 ID 由服务器生成,在回执目录中返回。章正文应从自己的 `##` 标题开始,只包含一个二级标题,并保留与下一章之间的换行;跨章代码围栏或章节边界改变会被拒绝,拆章请使用多个操作。
章节变更、内部摘要、组合后的全文和历史快照在同一事务内提交。每批操作只增加一次文章 `revision`;摘要单独更新也增加版本号。后续操作失败或全文版本过期时全部回滚。写入沿用幂等规则,回执包含新版本、章节目录和 `replayed`;章节接口与全文接口的幂等记录分开。修改章节不会改变其 ID,移动亦保留 ID;删除后的正文和摘要仍可从对应的旧修订读取。启用前的历史修订只有原文,摘要显示缺失。
Python 客户端对应命令:
```sh
python3 scripts/documents-client.py outline endor/endor-purpose-draft
python3 scripts/documents-client.py sections endor/endor-purpose-draft preamble s_existing
python3 scripts/documents-client.py edit-sections endor/endor-purpose-draft /private/path/edit.json --request-id chapter-edit-1
```
`outline` 和 `sections` 支持 `--revision`;请求文件只包含 `revision` 和 `operations`,不要把内部摘要文件提交到 Git。
### 创建、查看与撤销 Key
管理员只需通过已验证的服务器连接进行 Key 管理:
+3 -3
View File
@@ -182,10 +182,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, 1051);
assert.equal(research.companies.length, 1155);
assert.equal(research.categories.length, 11);
assert.equal(research.evidence.length, 1858);
assert.equal(research.observations.length, 237);
assert.equal(research.evidence.length, 3426);
assert.equal(research.observations.length, 453);
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);
+3 -3
View File
@@ -48,7 +48,7 @@ export type ResearchCandidateBatch = {
records: {
id: string; name: string; url: string | null; categoryId: string;
kind: "product" | "company" | "promotion"; profileStatus: "readable" | "unavailable" | "archive-only";
status: "pending-year" | "linked" | "existing-outside-cohort" | "outside-cohort" | "promotion";
status: "pending-year" | "pending-ai" | "linked" | "existing-outside-cohort" | "outside-cohort" | "promotion";
companyId?: string; evidenceIds?: string[]; note: string;
}[];
};
@@ -125,13 +125,13 @@ export function validateResearch(snapshot: ResearchSnapshot) {
if (!row.name.trim() || !row.note.trim() || !categories.has(row.categoryId) ||
!["product", "company", "promotion"].includes(row.kind) ||
!["readable", "unavailable", "archive-only"].includes(row.profileStatus) ||
!["pending-year", "linked", "existing-outside-cohort", "outside-cohort", "promotion"].includes(row.status) ||
!["pending-year", "pending-ai", "linked", "existing-outside-cohort", "outside-cohort", "promotion"].includes(row.status) ||
(row.kind !== "promotion" && (!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") ||
(row.evidenceIds ?? []).some((id) => !evidence.has(id)) ||
(row.status === "outside-cohort" && !row.evidenceIds?.length))
(["outside-cohort", "pending-ai"].includes(row.status) && !row.evidenceIds?.length))
throw new Error(`Invalid research candidate: ${row.id}`);
}
}
+75 -5
View File
@@ -1,5 +1,9 @@
import { randomUUID, createHash } from "node:crypto";
import { openSiteDatabase } from "./site-database";
import { DocumentValidationError, DocumentConflictError } from "./document-errors";
import { sectionSchema, loadSections, reconcileSections, persistSections, splitSections, outline,
applySectionOperations, parseSectionEdit, type DocumentSection } from "./document-sections";
export { DocumentValidationError, DocumentConflictError } from "./document-errors";
export type DocLink = {
slug: string; sourceSlug: string; category: string; title: string; searchText?: string;
@@ -9,8 +13,6 @@ export type DocLink = {
export type Doc = DocLink & { content: string };
export type DocInput = Omit<Doc, "revision" | "searchText">;
export type DocumentExport = { format: "tabularium-documents-v1"; documents: Doc[] };
export class DocumentValidationError extends Error {}
export class DocumentConflictError extends Error {}
export type DocumentReceipt = Pick<Doc, "slug" | "sourceSlug" | "revision">;
export const validSlug = /^[a-z0-9]+(?:-[a-z0-9]+)*(?:\/[a-z0-9]+(?:-[a-z0-9]+)*)*$/;
@@ -36,6 +38,7 @@ function database() {
digest TEXT PRIMARY KEY, document_count INTEGER NOT NULL, created_at TEXT NOT NULL
);
`);
sectionSchema(db);
return db;
}
@@ -57,12 +60,13 @@ export function validateDocument(input: DocInput): void {
throw new DocumentValidationError("Use compressed WebP images instead of original rasters");
}
function write(db: ReturnType<typeof database>, input: DocInput, expectedRevision: number): Doc {
function write(db: ReturnType<typeof database>, input: DocInput, expectedRevision: number, editedSections?: DocumentSection[]): Doc {
validateDocument(input);
const existing = db.prepare("SELECT id, revision FROM documents WHERE source_slug=?")
.get(input.sourceSlug) as { id: string; revision: number } | undefined;
const existing = db.prepare("SELECT id, revision, payload FROM documents WHERE source_slug=?")
.get(input.sourceSlug) as { id: string; revision: number; payload: string } | undefined;
if ((existing?.revision ?? 0) !== expectedRevision) throw new DocumentConflictError("Document revision conflict");
const id = existing?.id ?? randomUUID();
const previous = existing ? loadSections(db, id, (JSON.parse(existing.payload) as Doc).content) : [];
const doc: Doc = { slug: input.slug, sourceSlug: input.sourceSlug, category: input.category,
title: input.title, group: input.group, collection: input.collection, description: input.description,
draft: input.draft, featured: input.featured, content: input.content, revision: expectedRevision + 1 };
@@ -80,9 +84,75 @@ function write(db: ReturnType<typeof database>, input: DocInput, expectedRevisio
db.prepare("INSERT OR IGNORE INTO document_aliases VALUES (?,?)").run(alias, id);
db.prepare("INSERT INTO document_revisions VALUES (?,?,?,?)")
.run(id, doc.revision, payload, new Date().toISOString());
persistSections(db, id, doc.revision, editedSections ?? reconcileSections(doc.content, previous));
return doc;
}
// Internal summaries never enter Doc, catalog, search or browser page props.
export function readDocumentSections(slug: string, revision?: number) {
if (!validSlug.test(slug)) throw new DocumentValidationError("Invalid document slug");
if (revision !== undefined && (!Number.isSafeInteger(revision) || revision < 1)) throw new DocumentValidationError("Invalid revision");
const db = database();
try {
db.exec("BEGIN");
const row = db.prepare(`SELECT d.id,d.payload FROM documents d JOIN document_aliases a
ON a.document_id=d.id WHERE a.alias=?`).get(slug) as { id: string; payload: string } | undefined;
if (!row) { db.exec("COMMIT"); return null; }
let doc = JSON.parse(row.payload) as Doc;
let sections: DocumentSection[];
if (revision === undefined || revision === doc.revision) sections = loadSections(db, row.id, doc.content);
else {
const prior = db.prepare("SELECT payload FROM document_revisions WHERE document_id=? AND revision=?")
.get(row.id, revision) as { payload: string } | undefined;
if (!prior) { db.exec("COMMIT"); return null; }
doc = JSON.parse(prior.payload) as Doc;
const snapshot = db.prepare("SELECT payload FROM document_section_revisions WHERE document_id=? AND revision=?")
.get(row.id, revision) as { payload: string } | undefined;
sections = snapshot ? JSON.parse(snapshot.payload) as DocumentSection[] : splitSections(doc.content);
}
db.exec("COMMIT");
return { slug: doc.slug, sourceSlug: doc.sourceSlug, title: doc.title, revision: doc.revision, sections };
} finally { db.close(); }
}
export function editDocumentSections(slug: string, value: unknown, request?: { namespace: string; id: string }) {
if (!validSlug.test(slug)) throw new DocumentValidationError("Invalid document slug");
const edit = parseSectionEdit(value);
if (request && (!request.namespace || !/^[A-Za-z0-9._:-]{1,128}$/.test(request.id))) throw new DocumentValidationError("Invalid Idempotency-Key");
const digest = createHash("sha256").update(JSON.stringify({ slug, edit })).digest("hex");
const namespace = request ? request.namespace + ":sections" : undefined;
const db = database();
try {
db.exec("BEGIN IMMEDIATE");
try {
if (request) {
const prior = db.prepare("SELECT digest,response FROM document_write_requests WHERE namespace=? AND request_id=?")
.get(namespace!, request.id) as { digest: string; response: string } | undefined;
if (prior) {
if (prior.digest !== digest) throw new DocumentConflictError("Idempotency-Key was used with different content");
db.exec("COMMIT");
return { ...JSON.parse(prior.response) as { slug: string; sourceSlug: string; revision: number; sections: ReturnType<typeof outline> }, replayed: true };
}
}
const row = db.prepare(`SELECT d.id,d.payload FROM documents d JOIN document_aliases a
ON a.document_id=d.id WHERE a.alias=?`).get(slug) as { id: string; payload: string } | undefined;
if (!row) { db.exec("COMMIT"); return null; }
const doc = JSON.parse(row.payload) as Doc;
if (doc.revision !== edit.revision) throw new DocumentConflictError("Document revision conflict");
const previous = loadSections(db, row.id, doc.content);
const sections = applySectionOperations(previous, edit.operations);
// Preserve the initial outline when upgrading an existing document for the first time.
db.prepare("INSERT OR IGNORE INTO document_section_revisions VALUES (?,?,?)").run(row.id, doc.revision, JSON.stringify(previous));
const saved = write(db, { ...doc, content: sections.map((s) => s.content).join("") }, doc.revision, sections);
const receipt = { slug: saved.slug, sourceSlug: saved.sourceSlug, revision: saved.revision, sections: outline(sections) };
if (request) db.prepare("INSERT INTO document_write_requests VALUES (?,?,?,?)")
.run(namespace!, request.id, digest, JSON.stringify(receipt));
db.exec("COMMIT");
return { ...receipt, replayed: false };
} catch (error) { db.exec("ROLLBACK"); throw error; }
} finally { db.close(); }
}
export function saveDocument(input: DocInput, expectedRevision: number): Doc {
if (!Number.isSafeInteger(expectedRevision) || expectedRevision < 0) throw new DocumentValidationError("Provide expected revision");
const db = database();
+2
View File
@@ -0,0 +1,2 @@
export class DocumentValidationError extends Error {}
export class DocumentConflictError extends Error {}
+144
View File
@@ -0,0 +1,144 @@
import { createHash, randomUUID } from "node:crypto";
import type { DatabaseSync } from "node:sqlite";
import { DocumentValidationError } from "./document-errors";
export type DocumentSection = {
id: string; title: string; content: string; summary: string;
};
export type SectionOperation =
| { op: "update"; id: string; content?: string; summary?: string }
| { op: "insert"; after: string; content: string; summary: string }
| { op: "delete"; id: string }
| { op: "move"; id: string; after: string };
export type SectionEdit = { revision: number; operations: SectionOperation[] };
const hash = (text: string) => createHash("sha256").update(text).digest("hex");
// Preserve every byte, including CRLF and separators. H3-H6 belong to their H2 chapter.
export function splitSections(content: string): DocumentSection[] {
const starts: { offset: number; title: string }[] = [{ offset: 0, title: "导言" }];
let offset = 0;
let fence: { marker: string; length: number } | undefined;
for (const line of content.match(/[^\n]*\n|[^\n]+$/g) ?? []) {
const opening = line.match(/^ {0,3}(`{3,}|~{3,})(.*?)(?:\r?\n)?$/);
if (fence) {
if (new RegExp(`^ {0,3}${fence.marker}{${fence.length},}[ \\t]*\\r?\\n?$`).test(line)) fence = undefined;
} else if (opening && !(opening[1][0] === "`" && opening[2].includes("`"))) {
fence = { marker: opening[1][0], length: opening[1].length };
} else {
const heading = line.match(/^##(?:[ \t]+(.*?))?[ \t]*\r?\n?$/);
if (heading) starts.push({ offset, title: (heading[1] ?? "").replace(/[ \t]+#+[ \t]*$/, "").trim() });
}
offset += line.length;
}
const seen = new Map<string, number>();
return starts.map((start, index) => {
const occurrence = seen.get(start.title) ?? 0;
seen.set(start.title, occurrence + 1);
return { id: index === 0 ? "preamble" : "s_" + hash(`${start.title}\0${occurrence}`).slice(0, 24),
title: start.title, content: content.slice(start.offset, starts[index + 1]?.offset), summary: "" };
});
}
export function sectionSchema(db: DatabaseSync) {
db.exec(`CREATE TABLE IF NOT EXISTS document_sections (
document_id TEXT PRIMARY KEY REFERENCES documents(id), payload TEXT NOT NULL
);
CREATE TABLE IF NOT EXISTS document_section_revisions (
document_id TEXT NOT NULL REFERENCES documents(id), revision INTEGER NOT NULL,
payload TEXT NOT NULL, PRIMARY KEY(document_id, revision)
);`);
}
export function loadSections(db: DatabaseSync, documentId: string, content: string): DocumentSection[] {
const row = db.prepare("SELECT payload FROM document_sections WHERE document_id=?")
.get(documentId) as { payload: string } | undefined;
if (!row) return splitSections(content);
const sections = JSON.parse(row.payload) as DocumentSection[];
// A legacy writer must not leave an apparently current outline over different Markdown.
return sections.map((s) => s.content).join("") === content ? sections : reconcileSections(content, sections);
}
export function reconcileSections(content: string, previous: DocumentSection[]): DocumentSection[] {
const unused = new Set(previous);
return splitSections(content).map((section) => {
const prior = section.id === "preamble" ? previous.find((p) => p.id === "preamble") :
previous.find((p) => p.id !== "preamble" && unused.has(p) && p.content === section.content) ??
previous.find((p) => p.id !== "preamble" && unused.has(p) && p.title === section.title);
if (prior) unused.delete(prior);
return { ...section, id: prior?.id ?? (section.id === "preamble" ? "preamble" : "s_" + randomUUID()),
summary: prior?.content === section.content ? prior.summary : "" };
});
}
export function persistSections(db: DatabaseSync, documentId: string, revision: number, sections: DocumentSection[]) {
const payload = JSON.stringify(sections);
db.prepare(`INSERT INTO document_sections VALUES (?,?) ON CONFLICT(document_id)
DO UPDATE SET payload=excluded.payload`).run(documentId, payload);
db.prepare("INSERT INTO document_section_revisions VALUES (?,?,?)").run(documentId, revision, payload);
}
export function outline(sections: DocumentSection[]) {
return sections.map(({ content, ...section }, position) => ({ ...section, position,
contentHash: hash(content), summaryStatus: section.summary.trim() ? "current" : "missing" }));
}
export function parseSectionEdit(value: unknown): SectionEdit {
if (!value || typeof value !== "object" || Array.isArray(value)) throw new DocumentValidationError("Expected section edit object");
const row = value as Record<string, unknown>;
if (Object.keys(row).some((key) => !["revision", "operations"].includes(key)) ||
!Number.isSafeInteger(row.revision) || (row.revision as number) < 1 || !Array.isArray(row.operations) ||
!row.operations.length || row.operations.length > 100) throw new DocumentValidationError("Provide revision and 1 to 100 operations");
for (const raw of row.operations) {
if (!raw || typeof raw !== "object" || Array.isArray(raw)) throw new DocumentValidationError("Invalid operation");
const op = raw as Record<string, unknown>;
const fields: Record<string, string[]> = { update: ["op", "id", "content", "summary"],
insert: ["op", "after", "content", "summary"], delete: ["op", "id"], move: ["op", "id", "after"] };
if (typeof op.op !== "string" || !Object.hasOwn(fields, op.op) || Object.keys(op).some((key) => !fields[op.op as string].includes(key)))
throw new DocumentValidationError("Unknown operation or field");
for (const key of fields[op.op].filter((key) => !["content", "summary", "op"].includes(key)))
if (typeof op[key] !== "string" || !(op[key] as string).length) throw new DocumentValidationError("Missing section identifier");
for (const key of ["content", "summary"])
if (op[key] !== undefined && typeof op[key] !== "string") throw new DocumentValidationError(`Invalid ${key}`);
if (op.op === "update" && op.content === undefined && op.summary === undefined) throw new DocumentValidationError("Empty update");
if (op.op === "insert" && (typeof op.content !== "string" || typeof op.summary !== "string" || !op.summary.trim()))
throw new DocumentValidationError("Insert requires content and summary");
if (typeof op.summary === "string" && (!op.summary.trim() || op.summary.length > 8000))
throw new DocumentValidationError("Summary must contain 1 to 8000 characters");
}
return { revision: row.revision as number, operations: row.operations as SectionOperation[] };
}
export function applySectionOperations(previous: DocumentSection[], operations: SectionOperation[]) {
const sections = previous.map((section) => ({ ...section }));
function index(id: string) {
const result = sections.findIndex((s) => s.id === id);
if (result < 0) throw new DocumentValidationError("Unknown section id");
return result;
}
for (const op of operations) {
if (op.op === "insert") {
sections.splice(index(op.after) + 1, 0, { id: "s_" + randomUUID(), title: "", content: op.content, summary: op.summary });
} else {
const at = index(op.id);
if (op.op === "update") {
if (op.content !== undefined && op.content !== sections[at].content) sections[at].summary = "";
if (op.content !== undefined) sections[at].content = op.content;
if (op.summary !== undefined) sections[at].summary = op.summary;
} else {
if (op.id === "preamble") throw new DocumentValidationError("Cannot delete or move the preamble");
if (op.op === "delete") sections.splice(at, 1);
else {
if (op.id === op.after) throw new DocumentValidationError("Cannot move section after itself");
index(op.after);
const [section] = sections.splice(at, 1);
sections.splice(index(op.after) + 1, 0, section);
}
}
}
}
const content = sections.map((s) => s.content).join("");
const parsed = splitSections(content);
if (parsed.length !== sections.length || parsed.some((s, i) => s.content !== sections[i].content))
throw new DocumentValidationError("Each chapter must start with one H2 heading; preserve newline boundaries and balanced fences");
return sections.map((s, i) => ({ ...s, title: parsed[i].title }));
}
@@ -0,0 +1,37 @@
import type { NextApiRequest, NextApiResponse } from "next";
import { DocumentValidationError, readDocumentSections, editDocumentSections } from "@/lib/docs";
import { outline } from "@/lib/document-sections";
import { authorizeDocuments, documentApiError, idempotency } from "@/lib/documents-api";
export const config = { api: { bodyParser: { sizeLimit: "8mb" } } };
export default function handler(request: NextApiRequest, response: NextApiResponse) {
try {
const key = authorizeDocuments(request, response, request.method === "POST");
if (!key) return;
if (request.method !== "GET" && request.method !== "POST") {
response.setHeader("Allow", "GET, POST");
return response.status(405).end();
}
if (!Array.isArray(request.query.slug)) throw new DocumentValidationError("Invalid document slug");
const slug = request.query.slug.join("/");
if (Object.keys(request.query).some((k) => !["slug", "section", "revision"].includes(k)))
throw new DocumentValidationError("Unknown section query");
if (request.method === "POST") {
if (request.query.section !== undefined || request.query.revision !== undefined)
throw new DocumentValidationError("POST uses revision and operations in the body");
const saved = editDocumentSections(slug, request.body, idempotency(request, key.id));
return saved ? response.status(200).json(saved) : response.status(404).json({ code: "not_found" });
}
const revision = request.query.revision;
if (revision !== undefined && (typeof revision !== "string" || !/^[1-9]\d*$/.test(revision)))
throw new DocumentValidationError("Invalid revision");
const doc = readDocumentSections(slug, revision === undefined ? undefined : Number(revision));
if (!doc) return response.status(404).json({ code: "not_found" });
const selected = request.query.section;
if (selected === undefined) return response.status(200).json({ ...doc, sections: outline(doc.sections) });
const ids = typeof selected === "string" ? [selected] : selected;
if (!ids.length || ids.length > 100 || ids.some((id) => !id)) throw new DocumentValidationError("Select 1 to 100 sections");
if (ids.some((id) => !doc.sections.some((s) => s.id === id))) return response.status(404).json({ code: "not_found" });
return response.status(200).json({ ...doc, sections: doc.sections.filter((s) => ids.includes(s.id)) });
} catch (error) { return documentApiError(response, error); }
}
+123 -1
View File
@@ -7,8 +7,11 @@ import type { NextApiRequest, NextApiResponse } from "next";
import documents from "../src/pages/api/documents/index";
import batch from "../src/pages/api/documents/batch";
import item from "../src/pages/api/documents/item/[...slug]";
import sections from "../src/pages/api/documents/sections/[...slug]";
import { splitSections } from "../src/lib/document-sections";
import { openSiteDatabase } from "../src/lib/site-database";
import { createDocumentKey, authenticateDocumentKey, revokeDocumentKey, listDocumentKeys } from "../src/lib/document-keys";
import { allDocuments, documentHistory, readDocument, saveDocument, type Doc } from "../src/lib/docs";
import { allDocuments, documentHistory, readDocument, saveDocument, readDocumentSections, type Doc } from "../src/lib/docs";
import { newAuthConfig, signSession } from "../src/lib/auth";
const input: Doc = { slug: "endor/example", sourceSlug: "00-example", title: "Example", category: "Endor",
@@ -134,3 +137,122 @@ test("invalid batch members, duplicate identifiers, raw images and malformed fie
assert.equal(call(documents, { method: "DELETE", headers }).status, 405);
assert.equal(call(item, { headers, query: { slug: ["missing"] } }).status, 404);
}));
const chapterContent = "# Example\n\nIntroduction.\n\n## First\n\nFirst body.\n\n### Detail\n\nChild stays in chapter.\n\n## Second\n\nSecond body.\n";
type SectionResponse = { revision: number; replayed?: boolean;
sections: { id: string; title: string; summary: string; summaryStatus?: string; content?: string }[] };
const chapterQuery = { slug: input.slug.split("/") };
test("chapter parser preserves bytes, fences, duplicate headings and CRLF", () => {
const content = "# Title\r\n\r\n## Repeated\r\n~~~text\r\n## Inside fence\r\n~~~\r\n### Nested\r\n```js\r\n## Also inside\r\n````\r\n\r\n## Repeated\r\nTail";
const parts = splitSections(content);
assert.equal(parts.length, 3);
assert.notEqual(parts[1].id, parts[2].id);
assert.equal(parts.map((p) => p.content).join(""), content);
assert.equal(parts[1].title, "Repeated");
assert.ok(parts[1].content.includes("### Nested"));
assert.equal(splitSections("").length, 1);
assert.equal(splitSections("# Title\n\n- Item\n ## List detail\n\n> ## Quoted\n").length, 1);
});
test("outline reads existing Markdown without changing it and returns only selected bodies", () => isolated(({ headers }) => {
saveDocument({ ...input, content: chapterContent }, 0);
const db = openSiteDatabase();
db.exec("DELETE FROM document_sections; DELETE FROM document_section_revisions;"); db.close();
const result = call(sections, { headers, query: chapterQuery });
assert.equal(result.status, 200);
const outline = result.body as SectionResponse;
assert.equal(outline.revision, 1); assert.equal(outline.sections.length, 3);
assert.deepEqual(outline.sections.map((s) => s.title), ["导言", "First", "Second"]);
assert.ok(outline.sections.every((s) => s.content === undefined && s.summaryStatus === "missing"));
const selected = call(sections, { headers, query: { ...chapterQuery, section: outline.sections[1].id } }).body as SectionResponse;
assert.equal(selected.sections.length, 1);
assert.ok(selected.sections[0].content!.includes("### Detail"));
assert.equal(readDocument(input.slug)!.content, chapterContent);
assert.equal(call(sections, { headers, query: { ...chapterQuery, section: "missing" } }).status, 404);
assert.equal(call(sections, { headers, query: { ...chapterQuery, revision: "0" } }).status, 400);
}));
test("internal summaries persist separately and chapter updates leave other bytes untouched", () => isolated(({ headers }) => {
saveDocument({ ...input, content: chapterContent }, 0);
const before = readDocumentSections(input.slug)!;
const first = before.sections[1]; const second = before.sections[2];
const changed = first.content.replace("First body.", "Revised body.");
const edited = call(sections, { method: "POST", headers, query: chapterQuery, body: { revision: 1, operations: [
{ op: "update", id: first.id, content: changed, summary: "INTERNAL_SUMMARY_FIRST" },
{ op: "update", id: second.id, summary: "INTERNAL_SUMMARY_SECOND" },
] } });
assert.equal(edited.status, 200);
const after = readDocumentSections(input.slug)!;
assert.equal(after.revision, 2); assert.equal(after.sections[1].id, first.id);
assert.equal(after.sections[0].content, before.sections[0].content);
assert.equal(after.sections[2].content, before.sections[2].content);
assert.equal(after.sections[1].summary, "INTERNAL_SUMMARY_FIRST");
assert.equal(readDocument(input.slug)!.content, chapterContent.replace("First body.", "Revised body."));
assert.ok(!JSON.stringify(allDocuments()).includes("INTERNAL_SUMMARY"));
assert.ok(!JSON.stringify(call(item, { headers, query: chapterQuery }).body).includes("INTERNAL_SUMMARY"));
assert.ok(!JSON.stringify(call(documents, { headers }).body).includes("INTERNAL_SUMMARY"));
const history = readDocumentSections(input.slug, 1)!;
assert.equal(history.sections[1].content, first.content); assert.equal(history.sections[1].summary, "");
assert.equal(readDocumentSections(input.slug, 2)!.sections[1].summary, "INTERNAL_SUMMARY_FIRST");
}));
test("insert, move and delete chapters commit together with replay and conflict protection", () => isolated(({ headers }) => {
saveDocument({ ...input, content: chapterContent }, 0);
const before = readDocumentSections(input.slug)!;
const first = before.sections[1]; const second = before.sections[2];
const body = { revision: 1, operations: [
{ op: "move", id: second.id, after: "preamble" },
{ op: "delete", id: first.id },
{ op: "insert", after: second.id, content: "## New chapter\n\nNew body.\n", summary: "New material" },
] };
const options = { method: "POST", headers: { ...headers, "idempotency-key": "chapters-1" }, query: chapterQuery, body };
assert.equal(call(sections, options).status, 200);
const repeated = call(sections, options);
assert.equal(repeated.status, 200); assert.equal((repeated.body as SectionResponse).replayed, true);
const after = readDocumentSections(input.slug)!;
assert.deepEqual(after.sections.map((s) => s.title), ["导言", "Second", "New chapter"]);
assert.equal(after.sections[1].content, second.content);
assert.equal(after.revision, 2); assert.equal(documentHistory(input.sourceSlug).length, 2);
assert.equal(call(sections, { ...options, body: { ...body, revision: 2 } }).status, 409);
assert.equal(call(sections, { ...options, headers }).status, 409);
assert.equal(saveDocument({ ...readDocument(input.slug)!, description: "Changed metadata" }, 2).revision, 3);
assert.equal(readDocumentSections(input.slug)!.sections[2].summary, "New material");
}));
test("invalid late operation rolls back content, summary and history; read-only keys cannot edit", () => isolated(({ headers }) => {
saveDocument({ ...input, content: chapterContent }, 0);
const before = readDocumentSections(input.slug)!;
const invalid = [
[{ op: "update", id: before.sections[1].id, summary: "Should roll back" }, { op: "delete", id: "missing" }],
[{ op: "delete", id: "preamble" }],
[{ op: "move", id: before.sections[1].id, after: before.sections[1].id }],
[{ op: "update", id: before.sections[1].id, content: "## First\n\n## Extra\n" }],
[{ op: "update", id: before.sections[1].id, content: "## First\n![raw](/figures/raw.png)\n" }],
[{ op: "insert", after: "preamble", content: "## Missing summary\n" }],
[{ op: "delete", id: before.sections[1].id, unexpected: true }],
];
for (const operations of invalid) {
assert.equal(call(sections, { method: "POST", headers, query: chapterQuery, body: { revision: 1, operations } }).status, 400);
assert.deepEqual(readDocumentSections(input.slug), before);
assert.equal(documentHistory(input.sourceSlug).length, 1);
}
assert.equal(call(sections, { query: chapterQuery }).status, 401);
const reader = createDocumentKey("chapter reader", "read");
const readHeaders = { authorization: "Bearer " + reader.token };
assert.equal(call(sections, { headers: readHeaders, query: chapterQuery }).status, 200);
assert.equal(call(sections, { method: "POST", headers: readHeaders, query: chapterQuery, body: { revision: 1, operations: [] } }).status, 403);
}));
test("full-document saves invalidate changed chapter summaries and preserve unaffected summaries and ids", () => isolated(({ headers }) => {
saveDocument({ ...input, content: chapterContent }, 0);
const before = readDocumentSections(input.slug)!;
assert.equal(call(sections, { method: "POST", headers, query: chapterQuery, body: { revision: 1, operations:
before.sections.map((s) => ({ op: "update", id: s.id, summary: "Summary of " + s.title })) } }).status, 200);
saveDocument({ ...readDocument(input.slug)!, content: chapterContent.replace("First body.", "Changed externally.") }, 2);
const after = readDocumentSections(input.slug)!;
assert.equal(after.sections[1].id, before.sections[1].id);
assert.equal(after.sections[1].summary, "");
assert.equal(after.sections[2].summary, "Summary of Second");
assert.equal(readDocumentSections(input.slug, 2)!.sections[1].summary, "Summary of First");
}));
+368 -11
View File
@@ -23,9 +23,9 @@ 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, 1051);
assert.equal(initial.evidence.length, 1858);
assert.equal(initial.observations.length, 237);
assert.equal(initial.companies.length, 1155);
assert.equal(initial.evidence.length, 3426);
assert.equal(initial.observations.length, 453);
assert.deepEqual(initial.candidateBatches, seed.candidateBatches, "candidate gaps persist in the same database metadata");
assert.deepEqual(initial.directoryRechecks, seed.directoryRechecks, "follow-up classifications persist without rewriting the discovery audit");
assert.deepEqual(readResearchSnapshot(), initial, "reopening does not duplicate records");
@@ -64,8 +64,8 @@ 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, 115);
assert.equal(snapshot.reviews.filter((r) => r.scope === "dataset").length, 12);
assert.equal(snapshot.reviews.filter((r) => r.scope === "companies").length, 198);
assert.equal(snapshot.reviews.filter((r) => r.scope === "dataset").length, 21);
assert.equal(snapshot.reviews.filter((r) => r.scope === "excluded-candidate").length, 44);
const review = snapshot.reviews.find((r) => r.id === "R4")!;
assert.deepEqual(reviewCompanyIds(snapshot, review), ["AI007", "AI013", "AI021", "AI034"]);
@@ -85,11 +85,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), 1051);
assert.equal(summary.reduce((n, c) => n + c.self, 0), 43);
assert.equal(summary.reduce((n, c) => n + c.count, 0), 1155);
assert.equal(summary.reduce((n, c) => n + c.self, 0), 58);
assert.equal(summary.reduce((n, c) => n + c.estimate, 0), 2);
assert.equal(summary.reduce((n, c) => n + c.platform, 0), 19);
assert.equal(summary.reduce((n, c) => n + c.unknown, 0), 987);
assert.equal(summary.reduce((n, c) => n + c.unknown, 0), 1075);
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 === "公司整体"));
@@ -99,10 +99,33 @@ test("disclosure counts exclude client income, biographies, targets and duplicat
assert.ok(arena.metric !== "mrr" && arena.metric !== "arr", "a two-week cumulative figure cannot become MRR or ARR");
});
test("service run rates, legacy freight revenue and paid adoption do not become platform ARR", () => {
const snapshot = seed as ResearchSnapshot;
const runRate = snapshot.observations.find((o) => o.id === "INDUSTRY11-O-LOCKE-RUNRATE")!;
assert.equal(runRate.metric, "annualized-revenue");
assert.equal(runRate.selection, "historical");
assert.equal(runRate.observedAt, undefined);
assert.equal(runRate.comparisonGroup, null);
assert.equal(snapshot.companies.find((c) => c.id === "YC33283")?.revenueStatus, "self");
for (const id of ["TRUEMILE-OLD-REV", "VELTHA-DEMO", "LANTERN-OLD-REV"]) {
const observation = snapshot.observations.find((o) => o.id === `INDUSTRY11-O-${id}`)!;
assert.equal(observation.selection, "excluded");
assert.equal(observation.metric, undefined);
assert.equal(observation.comparisonGroup, null);
}
for (const [id, company] of [["VERDANT-DEPLOY", "YC32189"], ["SUTRIX-PAID", "YC36576"]]) {
const observation = snapshot.observations.find((o) => o.id === `INDUSTRY11-O-${id}`)!;
assert.equal(observation.selection, "adoption");
assert.equal(observation.metric, undefined);
assert.equal(snapshot.companies.find((c) => c.id === company)?.revenueStatus, "unknown");
}
assert.ok(platformIncomeSample(snapshot, { windowDays: 90 }).points.every((point) => !point.observation.id.startsWith("INDUSTRY11-")));
});
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, 59);
assert.equal(snapshot.companies.filter((c) => c.technicalReview?.level === "public-artifact").length, 9);
assert.equal(snapshot.companies.filter((c) => c.technicalReview).length, 138);
assert.equal(snapshot.companies.filter((c) => c.technicalReview?.level === "public-artifact").length, 23);
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/);
@@ -228,6 +251,10 @@ test("directory coverage reconciles every candidate and keeps profile-only incom
assert.equal(row.foundedYear, 2026, "original Native discovery remains unchanged");
assert.equal(company.year, null, "a model launch and YC date cannot settle the older business founding year");
assert.ok(snapshot.reviews.some((review) => review.id === "NATIVE-R-COHORT" && review.companyIds?.includes(company.id)));
} else if (company.id === "YC31470") {
assert.equal(row.foundedYear, 2025, "original Tasklet discovery remains unchanged");
assert.equal(company.year, null, "a new product cannot establish a new company founding year");
assert.ok(snapshot.reviews.some((review) => review.id === "ENTERPRISE3-R-TASKLET" && review.companyIds?.includes(company.id)));
} else {
assert.equal(company.year, row.foundedYear);
assert.ok([2025, 2026].includes(company.year!));
@@ -379,7 +406,7 @@ test("unreconciled directory financials remain source reviews instead of income
assert.ok(review.evidenceIds.includes("PH-TANA-DR"));
assert.equal(reviewCompanyIds(snapshot, review).length, 0);
assert.ok(!snapshot.observations.some((o) => o.evidence === "PH-TANA-DR"));
assert.equal(snapshot.candidateBatches!.flatMap((b) => b.records).filter((r) => r.status === "pending-year").length, 18);
assert.equal(snapshot.candidateBatches!.flatMap((b) => b.records).filter((r) => r.status === "pending-year").length, 43);
});
test("product pivots and founder histories do not become new company years or current revenue", () => {
@@ -416,6 +443,336 @@ test("follow-up evidence can admit an uncertain directory candidate without rewr
assert.throws(() => validateResearch(snapshot), /directory recheck/);
});
test("AI relevance follow-ups retain unresolved businesses and reuse existing company identities", () => {
const snapshot = structuredClone(seed) as ResearchSnapshot;
const batch = snapshot.candidateBatches!.find((b) => b.id === "YC-AI-UNCLEAR-1")!;
assert.equal(batch.complete, false);
assert.equal(batch.records.length, 24);
const original = coverageAudit.records.filter((r) => r.status === "ai-unclear").slice(0, 24);
assert.deepEqual(batch.records.map((r) => r.url), original.map((r) => r.source));
const linked = batch.records.filter((r) => r.status === "linked");
assert.equal(linked.length, 17);
assert.equal(linked.filter((r) => r.companyId!.startsWith("YC")).length, 14);
for (const [name, id] of [["Bud", "AI070"], ["Prism", "AI030"], ["Parametric", "AI014"]]) {
assert.equal(linked.find((r) => r.name === name)?.companyId, id);
}
assert.equal(snapshot.companies.filter((c) => c.profileOnly || c.directoryOrigin === "yc-2025-2026").length, 928);
for (const row of linked) {
const ycId = Number(row.id.replace("YC-AI1-", ""));
assert.equal(snapshot.directoryRechecks!.find((r) => r.ycId === ycId)?.companyId, row.companyId);
}
const pending = batch.records.filter((r) => r.status === "pending-ai");
assert.equal(pending.length, 7);
assert.ok(pending.every((r) => !r.companyId && r.evidenceIds!.length && /2025/.test(r.note)));
assert.match(pending.find((r) => r.name === "Better Auth")!.note, /AI.*模块/);
validateResearch(snapshot);
pending[0].companyId = "AI014";
assert.throws(() => validateResearch(snapshot), /research candidate/);
delete pending[0].companyId;
pending[0].evidenceIds = [];
assert.throws(() => validateResearch(snapshot), /research candidate/);
});
test("historical monthly revenue and customer examples do not enter recurring platform comparisons", () => {
const snapshot = seed as ResearchSnapshot;
const monthly = snapshot.observations.find((o) => o.id === "UNCLEAR1-O-SCALAR-MONTHLY")!;
assert.equal(monthly.value, 74000);
assert.equal(monthly.selection, "historical");
assert.equal(monthly.metric, undefined, "monthly revenue alone does not establish MRR or ARR");
assert.equal(monthly.comparisonGroup, null);
assert.equal(snapshot.companies.find((c) => c.id === "YC30514")!.revenueStatus, "self");
for (const id of ["AMBY-CLIENT", "NIXO-EXAMPLE", "AUTOSTEP-WASTE"]) {
assert.equal(snapshot.observations.find((o) => o.id === `UNCLEAR1-O-${id}`)!.selection, "excluded");
}
assert.ok(!platformIncomeSample(snapshot, { windowDays: null }).points.some((p) => p.observation.id.startsWith("UNCLEAR1-")));
const cua = snapshot.companies.find((c) => c.id === "YC30420")!;
assert.equal(cua.cat, "C03");
assert.equal(cua.revenueStatus, "unknown");
assert.match(cua.businessModel!, /自备计算机/);
assert.equal(cua.technicalReview!.level, "public-artifact");
});
test("a second uncertain cohort admits evidenced AI tasks while preserving autonomy and finance gaps", () => {
const snapshot = seed as ResearchSnapshot;
const batch = snapshot.candidateBatches!.find((b) => b.id === "YC-AI-UNCLEAR-2")!;
const original = coverageAudit.records.filter((r) => r.status === "ai-unclear").slice(24, 48);
assert.equal(batch.complete, false);
assert.deepEqual(batch.records.map((r) => r.url), original.map((r) => r.source));
assert.equal(batch.records.filter((r) => r.status === "linked").length, 13);
assert.equal(batch.records.filter((r) => r.status === "pending-ai").length, 11);
for (const name of ["Albacore Inc.", "Perseus Defense", "Munify", "Ruvo", "DeepGrove"]) {
const row = batch.records.find((r) => r.name === name)!;
assert.equal(row.status, "pending-ai");
assert.equal(row.companyId, undefined, "autonomy, a domain or finance automation alone is insufficient");
assert.ok(row.evidenceIds!.length);
}
const signals = snapshot.companies.find((c) => c.id === "YC30639")!;
assert.equal(signals.year, 2026, "retain the company year instead of assigning the batch's majority year");
assert.equal(signals.cat, "C06");
assert.equal(snapshot.companies.find((c) => c.id === "YC30846")!.cat, "C03");
assert.match(snapshot.companies.find((c) => c.id === "YC30821")!.business, /远端推理/);
assert.equal(snapshot.companies.find((c) => c.id === "YC30933")!.technicalReview!.level, "description",
"vendor clinical agreement is not an independent validation");
const amounts = snapshot.observations.filter((o) => o.id.startsWith("UNCLEAR2-"));
assert.equal(amounts.length, 8);
assert.ok(amounts.every((o) => ["excluded", "adoption"].includes(o.selection) && !o.metric && o.comparisonGroup === null));
assert.equal(amounts.find((o) => o.id.endsWith("WARDSTONE-GRANT"))!.selection, "excluded");
assert.equal(amounts.find((o) => o.id.endsWith("SOLVA-OLD-PREMIUM"))!.selection, "excluded");
assert.ok(batch.records.filter((r) => r.companyId).every((r) => snapshot.companies.find((c) => c.id === r.companyId)!.revenueStatus === "unknown"));
assert.ok(!platformIncomeSample(snapshot, { windowDays: null }).points.some((p) => p.observation.id.startsWith("UNCLEAR2-")));
});
test("the third uncertain cohort retains shutdowns, unknown scale and mixed data-service economics", () => {
const snapshot = seed as ResearchSnapshot;
const batch = snapshot.candidateBatches!.find((b) => b.id === "YC-AI-UNCLEAR-3")!;
const original = coverageAudit.records.filter((r) => r.status === "ai-unclear").slice(48, 72);
assert.equal(batch.complete, false);
assert.deepEqual(batch.records.map((r) => r.url), original.map((r) => r.source));
assert.equal(batch.records.filter((r) => r.status === "linked").length, 12);
assert.equal(batch.records.filter((r) => r.status === "pending-ai").length, 12);
for (const name of ["Voltair", "Mirabelle", "ZeroSettle", "Kyten Technologies"]) {
assert.equal(batch.records.find((r) => r.name === name)!.companyId, undefined);
}
const klaus = snapshot.companies.find((c) => c.id === "YC31084")!;
assert.equal(klaus.revenueStatus, "unknown", "a shutdown must not manufacture a zero revenue report");
assert.match(klaus.stage, /2026-09-01停服/);
assert.ok(!snapshot.observations.some((o) => o.company === klaus.id));
const openspec = snapshot.companies.find((c) => c.id === "YC31116")!;
assert.equal(openspec.team, null, "missing staff count stays unknown");
assert.equal(openspec.year, 2025, "a license copyright line alone is not a company founding date");
assert.equal(openspec.technicalReview!.level, "public-artifact");
assert.match(snapshot.companies.find((c) => c.id === "YC31095")!.businessModel!, /清洁/);
const figures = snapshot.observations.filter((o) => o.id.startsWith("UNCLEAR3-"));
assert.equal(figures.length, 8);
assert.ok(figures.every((o) => ["excluded", "adoption"].includes(o.selection) && !o.metric && o.comparisonGroup === null));
assert.equal(figures.find((o) => o.id.endsWith("SHORTKIT-OLD-ARR"))!.selection, "excluded");
assert.equal(figures.find((o) => o.id.endsWith("KALPA-TRAIN-COST"))!.selection, "excluded");
assert.ok(!platformIncomeSample(snapshot, { windowDays: null }).points.some((p) => p.observation.id.startsWith("UNCLEAR3-")));
});
test("the fourth uncertain cohort distinguishes product pivots, managed labor and pass-through money", () => {
const snapshot = seed as ResearchSnapshot;
const batch = snapshot.candidateBatches!.find((b) => b.id === "YC-AI-UNCLEAR-4")!;
const original = coverageAudit.records.filter((r) => r.status === "ai-unclear").slice(72, 96);
assert.equal(batch.complete, false);
assert.deepEqual(batch.records.map((r) => r.url), original.map((r) => r.source));
assert.equal(batch.records.filter((r) => r.status === "linked").length, 13);
assert.equal(batch.records.filter((r) => r.status === "pending-ai").length, 11);
assert.equal(batch.records.find((r) => r.name === "Orthogonal")!.companyId, "AI036");
assert.equal(snapshot.companies.filter((c) => c.url.endsWith("/companies/orthogonal")).length, 1);
const fern = snapshot.companies.find((c) => c.id === "YC31152")!;
assert.equal(fern.cat, "C02");
assert.match(fern.notes, /会议/);
const mocha = snapshot.companies.find((c) => c.id === "YC31269")!;
assert.equal(mocha.year, 2026);
assert.match(mocha.businessModel!, /人工/);
assert.match(mocha.price, /Platform.*Managed/);
assert.match(mocha.notes, /Coming soon/);
const figures = snapshot.observations.filter((o) => o.id.startsWith("UNCLEAR4-"));
assert.equal(figures.length, 7);
assert.ok(figures.every((o) => ["excluded", "adoption"].includes(o.selection) && !o.metric && o.comparisonGroup === null));
for (const suffix of ["LAURENCE-ADSPEND", "EKPA-CONNECTED-ASSETS", "REGBASE-CLIENT-GRANTS", "MOCHA-FUNDING"]) {
assert.equal(figures.find((o) => o.id.endsWith(suffix))!.selection, "excluded");
}
assert.equal(snapshot.companies.find((c) => c.id === "YC31199")!.technicalReview!.level, "public-artifact");
assert.ok(!platformIncomeSample(snapshot, { windowDays: null }).points.some((p) => p.observation.id.startsWith("UNCLEAR4-")));
});
test("the fifth uncertain cohort separates dated ARR, service run rates, bookings and previous ventures", () => {
const snapshot = seed as ResearchSnapshot;
const batch = snapshot.candidateBatches!.find((b) => b.id === "YC-AI-UNCLEAR-5")!;
const original = coverageAudit.records.filter((r) => r.status === "ai-unclear").slice(96, 120);
assert.equal(batch.complete, false);
assert.deepEqual(batch.records.map((r) => r.url), original.map((r) => r.source));
assert.equal(batch.records.filter((r) => r.status === "linked").length, 15);
assert.equal(batch.records.filter((r) => r.status === "pending-ai").length, 9);
assert.equal(batch.records.find((r) => r.name === "primitive")!.companyId, "AI002");
assert.equal(batch.records.find((r) => r.name === "Result")!.companyId, "AI001");
const result = snapshot.companies.find((c) => c.id === "AI001")!;
assert.equal(result.cat, "C09");
assert.equal(result.revenueStatus, "unknown");
assert.match(result.notes, /280万美元ARR属于用户/);
assert.ok(result.evidenceIds.includes("UNCLEAR5-31438-TERMS"));
const andco = snapshot.companies.find((c) => c.id === "YC31411")!;
assert.equal(andco.year, 2026, "a founder's previous venture must not replace the new company's stated year");
assert.match(andco.notes, /Layup/);
assert.equal(snapshot.evidence.find((e) => e.id === "UNCLEAR5-31411-LAUNCH6")!.companyId, null);
const figures = snapshot.observations.filter((o) => o.id.startsWith("UNCLEAR5-"));
assert.equal(figures.length, 18);
const dated = figures.find((o) => o.id.endsWith("TRELLIS-ARR-AUG"))!;
assert.equal(dated.metric, "arr");
assert.equal(dated.observedAt, "2026-08-24");
assert.equal(dated.bound, "≥");
assert.equal(figures.find((o) => o.id.endsWith("INSTA-RUNRATE"))!.metric, "annualized-revenue");
assert.equal(figures.find((o) => o.id.endsWith("INSTA-LAUNCH-ARR"))!.metric, "arr");
for (const suffix of ["PARROT-CONTRACT", "KINRO-OLD-CONTRACT", "BENTO-OLD-EMPLOYER", "TRELLIS-OLD-MGMT"]) {
assert.equal(figures.find((o) => o.id.endsWith(suffix))!.selection, "excluded");
}
assert.equal(snapshot.companies.find((c) => c.id === "YC31423")!.technicalReview!.level, "description",
"an internal benchmark subset is not an independent leaderboard result");
assert.ok(figures.every((o) => o.comparisonGroup === null));
assert.ok(!platformIncomeSample(snapshot, { windowDays: null }).points.some((p) => p.observation.id.startsWith("UNCLEAR5-")));
});
test("the sixth uncertain cohort preserves namesakes, churn and historical robotics MRR", () => {
const snapshot = seed as ResearchSnapshot;
const batch = snapshot.candidateBatches!.find((b) => b.id === "YC-AI-UNCLEAR-6")!;
const original = coverageAudit.records.filter((r) => r.status === "ai-unclear").slice(120, 144);
assert.equal(batch.complete, false);
assert.deepEqual(batch.records.map((r) => r.url), original.map((r) => r.source));
assert.equal(batch.records.filter((r) => r.status === "linked").length, 13);
assert.equal(batch.records.filter((r) => r.status === "pending-ai").length, 11);
const hera = snapshot.companies.find((c) => c.id === "YC32123")!;
const videoHera = snapshot.companies.find((c) => c.id === "AI025")!;
assert.equal(hera.cat, "C07");
assert.equal(hera.year, 2026);
assert.equal(videoHera.cat, "C08");
assert.equal(videoHera.year, 2025);
assert.notEqual(hera.url, videoHera.url, "same-name products with different YC pages must not be merged");
for (const name of ["Aernata", "Maquoketa Research", "Fire Wallet", "Eden Robotics", "Edgerun"]) {
const row = batch.records.find((r) => r.name === name)!;
assert.equal(row.status, "pending-ai");
assert.equal(row.companyId, undefined, "historical AI products, agent features and autonomous hardware need current-core evidence");
}
const figures = snapshot.observations.filter((o) => o.id.startsWith("UNCLEAR6-"));
assert.equal(figures.length, 13);
const churn = figures.find((o) => o.id.endsWith("ARDENT-CHURN"))!;
assert.equal(churn.selection, "excluded");
assert.equal(churn.metric, undefined, "lost ARR is not a positive current ARR observation");
assert.equal(snapshot.companies.find((c) => c.id === "YC31475")!.revenueStatus, "unknown");
const mrr = figures.find((o) => o.id.endsWith("AVEA-MRR"))!;
assert.equal(mrr.value, 18000);
assert.equal(mrr.metric, "mrr");
assert.equal(mrr.selection, "historical");
assert.match(mrr.unit, /无币种/);
assert.match(snapshot.companies.find((c) => c.id === "YC31530")!.notes, /Acquired/);
for (const suffix of ["PLAN0-PROJECTS-YC", "PLAN0-PROJECTS-LAUNCH", "SILMARIL-DAMAGE-YC", "SILMARIL-DAMAGE-CASE1", "SILMARIL-DAMAGE-CASE2", "EXPANSE-WASTE"]) {
assert.equal(figures.find((o) => o.id.endsWith(suffix))!.selection, "excluded");
}
const openwork = snapshot.companies.find((c) => c.id === "YC31505")!;
assert.equal(openwork.technicalReview!.level, "public-artifact");
assert.ok(openwork.technicalReview!.evidenceIds.includes("UNCLEAR6-31505-EE-LICENSE"));
assert.match(openwork.notes, /桌面MIT与ee目录/);
assert.ok(figures.every((o) => o.comparisonGroup === null));
assert.ok(!platformIncomeSample(snapshot, { windowDays: null }).points.some((p) => p.observation.id.startsWith("UNCLEAR6-")));
});
test("the seventh uncertain cohort separates hardware sales, prepayments and bounded verification", () => {
const snapshot = seed as ResearchSnapshot;
const batch = snapshot.candidateBatches!.find((b) => b.id === "YC-AI-UNCLEAR-7")!;
const original = coverageAudit.records.filter((r) => r.status === "ai-unclear").slice(144, 168);
assert.equal(batch.complete, false);
assert.deepEqual(batch.records.map((r) => r.url), original.map((r) => r.source));
assert.equal(batch.records.filter((r) => r.status === "linked").length, 16);
assert.equal(batch.records.filter((r) => r.status === "pending-ai").length, 8);
const robotNori = snapshot.companies.find((c) => c.id === "YC32553")!;
const healthNori = snapshot.companies.find((c) => c.id === "YC30657")!;
assert.equal(robotNori.cat, "C10");
assert.equal(healthNori.cat, "C09");
assert.notEqual(robotNori.url, healthNori.url, "same-name hardware and health companies retain distinct identities");
assert.equal(batch.records.find((r) => r.name === "Nori")!.companyId, robotNori.id);
const figures = snapshot.observations.filter((o) => o.id.startsWith("UNCLEAR7-"));
assert.equal(figures.length, 18);
const sales = figures.find((o) => o.id.endsWith("NORI-SALES"))!;
assert.equal(sales.value, 440000);
assert.equal(sales.selection, "historical");
assert.equal(sales.metric, undefined, "hardware sales with unverified preorder/delivery mix must not become ARR");
assert.match(snapshot.companies.find((c) => c.id === "YC32164")!.price!, /额度/);
for (const suffix of ["GUT-PHARMACY", "MANIFOLD-PICKS", "ATC-CLIENT-FLEET", "OPERON-CLIENT-SAVE", "ANYALPHA-OLD-APPS", "LETTER-DEMO"]) {
assert.equal(figures.find((o) => o.id.endsWith(suffix))!.selection, "excluded");
}
assert.match(figures.find((o) => o.id.endsWith("LETTER-DEMO"))!.scope, /fictional/);
assert.equal(snapshot.companies.find((c) => c.id === "YC34899")!.cat, "C06");
const kailash = snapshot.companies.find((c) => c.id === "YC34828")!;
assert.equal(kailash.cat, "C10");
assert.equal(kailash.technicalReview!.level, "description", "an open-weights claim without readable weights or a model card is not a reviewed public artifact");
const graphify = snapshot.companies.find((c) => c.id === "YC32583")!;
assert.equal(graphify.technicalReview!.level, "public-artifact");
const proof = snapshot.evidence.find((e) => e.id === "UNCLEAR7-32583-PROOF")!;
assert.match(proof.summary, /unknown/);
assert.match(proof.summary, /函数/);
assert.match(proof.limitation, /整库正确/);
assert.match(snapshot.companies.find((c) => c.id === "YC32518")!.notes, /Build标Coming soon/);
for (const name of ["Kara", "Molagri", "TareBio", "Atomarine", "Vernius Systems, Inc."]) {
const row = batch.records.find((r) => r.name === name)!;
assert.equal(row.status, "pending-ai");
assert.equal(row.companyId, undefined);
}
assert.ok(figures.every((o) => o.comparisonGroup === null));
assert.ok(!platformIncomeSample(snapshot, { windowDays: null }).points.some((p) => p.observation.id.startsWith("UNCLEAR7-")));
});
test("all original AI-unclear candidates retain a unique follow-up without counting EveryApp twice", () => {
const snapshot = seed as ResearchSnapshot;
const rows = snapshot.candidateBatches!.filter((b) => b.id.startsWith("YC-AI-UNCLEAR-")).flatMap((b) => b.records);
const original = coverageAudit.records.filter((r) => r.status === "ai-unclear");
assert.equal(rows.length, 192);
assert.equal(new Set(rows.map((r) => r.url)).size, 192);
assert.deepEqual(rows.map((r) => r.url), original.map((r) => r.source));
assert.equal(rows.filter((r) => r.status === "linked").length, 110);
assert.equal(rows.filter((r) => r.status === "pending-ai").length, 82);
assert.equal(snapshot.directoryRechecks!.filter((r) => r.ycId === 36088).length, 1);
const everyapp = rows.find((r) => r.name === "EveryApp")!;
assert.equal(everyapp.companyId, "AI074");
assert.equal(snapshot.companies.filter((c) => c.id === "AI074").length, 1);
for (const row of rows.filter((r) => r.status === "pending-ai")) {
assert.equal(row.companyId, undefined);
assert.ok(row.evidenceIds!.length > 0, "unresolved AI relevance has explicit evidence and gaps");
}
assert.equal(snapshot.coverage!.newProfiles, 928, "later evidence does not rewrite the original discovery accounting");
});
test("the final uncertain cohort separates delivery-start rentals, reservations and upstream costs", () => {
const snapshot = seed as ResearchSnapshot;
const batch = snapshot.candidateBatches!.find((b) => b.id === "YC-AI-UNCLEAR-8")!;
assert.equal(batch.complete, false, "reading the full pool does not resolve all AI, year or financial gaps");
assert.equal(batch.records.filter((r) => r.status === "linked").length, 11);
assert.equal(batch.records.filter((r) => r.status === "pending-ai").length, 13);
const rhem = snapshot.companies.find((c) => c.id === "YC35127")!;
assert.match(rhem.price!, /确认交付后/);
assert.match(rhem.price!, /99 USD/);
assert.equal(rhem.revenueStatus, "unknown");
assert.match(snapshot.companies.find((c) => c.id === "YC37272")!.price!, /预约/);
assert.match(snapshot.companies.find((c) => c.id === "AI074")!.price!, /有效订阅/);
assert.match(snapshot.companies.find((c) => c.id === "YC35396")!.notes, /Coming next/);
assert.match(snapshot.companies.find((c) => c.id === "YC36774")!.notes, /Early access/);
const figures = snapshot.observations.filter((o) => o.id.startsWith("UNCLEAR8-"));
assert.equal(figures.length, 9);
assert.ok(figures.every((o) => ["excluded", "adoption"].includes(o.selection) && !o.metric && o.comparisonGroup === null));
for (const suffix of ["OASIVE-OLD-WELLS", "OASIVE-OLD-GOOGLE", "OBSESSION-CALCULATOR", "EVERYAPP-UPSTREAM"]) {
assert.equal(figures.find((o) => o.id.endsWith(suffix))!.selection, "excluded");
}
for (const name of ["Clean", "STASIS", "RATLOG", "Inflection Space Systems", "twentyfour26"]) {
assert.equal(batch.records.find((r) => r.name === name)!.status, "pending-ai");
}
assert.ok(!platformIncomeSample(snapshot, { windowDays: null }).points.some((p) => p.observation.id.startsWith("UNCLEAR8-")));
});
test("founding conflicts preserve old product history without creating new companies or revenue", () => {
const snapshot = seed as ResearchSnapshot;
const batch = snapshot.candidateBatches!.find((b) => b.id === "YC-DATE-CONFLICT-1")!;
const original = coverageAudit.records.filter((r) => r.status === "date-conflict");
assert.equal(batch.complete, false);
assert.equal(batch.records.length, 6);
assert.deepEqual(batch.records.map((r) => r.url), original.map((r) => r.source));
assert.equal(new Set(batch.records.map((r) => r.url)).size, original.length);
for (const row of batch.records) {
assert.equal(row.status, "pending-year");
assert.equal(row.companyId, undefined);
const evidence = snapshot.evidence.filter((e) => row.evidenceIds!.includes(e.id));
assert.equal(evidence.length, row.evidenceIds!.length);
assert.ok(evidence.every((e) => e.companyId === null));
assert.ok(evidence.some((e) => e.publishedAt?.startsWith("2025-")), "old product launch remains explicit");
assert.ok(!snapshot.companies.some((c) => c.evidenceIds.some((eid) => row.evidenceIds!.includes(eid))));
}
assert.match(batch.records.find((r) => r.name === "Layers")!.note, /未确认当前AI核心/);
assert.ok(!snapshot.observations.some((o) => o.evidence.startsWith("YEARCONFLICT1-")));
const excluded = coverageAudit.records.filter((r) => r.status === "year-outside-or-missing");
assert.equal(excluded.filter((r) => r.foundedYear === null).length, 54);
assert.equal(excluded.filter((r) => r.foundedYear !== null).length, 214);
assert.ok(excluded.filter((r) => r.foundedYear !== null).every((r) => ![2025, 2026].includes(r.foundedYear!)));
});
test("Chinese discovery entries preserve unread articles and use separate primary evidence", () => {
const snapshot = structuredClone(seed) as ResearchSnapshot;
const batch = snapshot.candidateBatches!.find((b) => b.id === "JQ-2026-targeted-1")!;
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -1,5 +1,5 @@
{
"version": "2026-10-31-1",
"version": "2026-10-31-missing-year-4",
"scopeConfirmedAt": "2026-10-30",
"acceptance": "以确认的公开来源清单为边界,逐条核对并标明缺项。",
"provenance": "S01—S12恢复自已提交用户的《AI公司研究_来源与分类模板》来源清单;S13—S16单列后续已使用的补充证据渠道,不将使用次数当作全量覆盖。",
@@ -15,8 +15,8 @@
],
"initialAccess": "官网目录可访问",
"boundary": "已读取八个2025—2026批次镜像候选池1428条,再核YC官方页面;不声称覆盖全部YC历年或未公开公司。",
"nextCheck": "原新增目录中31条深化为个案并保留来源;当前基础项393条主营分类人工复核。本轮23项C06规则初分已读,22项保留、Bluma转创意制作,8项官网资料与Native政府接口缺项分开。软件/人工托管/制作代理及广告预算拆分;Native官网旧经营与YC2026成立冲突,当前year=null,原发现审计保留;2M ARR仅交叉核对。继续核C05/C07及其他非人工资料、主体、技术和财务,不把主营复核当完整来源覆盖。",
"limitation": "批次不等于成立年;不代表全部公司"
"limitation": "批次不等于成立年;不代表全部公司",
"nextCheck": "已统一企业141、行业252、模型标签26、开发标签51、其余标签34项,共504项新增主营复核。当前928条原YC新增记录保留发现来源,其中基础项871条均已做主营人工复核(871条),57条深化个案。C05规则89保留27/移62,C05标签52保留10/移42;C07规则184保留135/移49,C07标签68保留39/移29;模型标签26保留17/移9,开发标签51保留16/移35,其余标签34保留16/移18。主营复核仍含C00/短简介/混合交付缺项,不等完整产品/技术/财务审计。Tasklet及Native新产品与旧业务链保留,发现审计不改;Freya、Epicenter、Stellon许可及公开材料/厂商基准范围分开。客户收入、估价、资产、节省、管线/意向、预订需求、旧公司收入与示例排除自身ARR;Locke服务run-rate不等ARR,Mixy历史MRR/捐赠、Isengard无期间收入分开。各批证据、观测、核查与主体/收费/人工成本缺项均保留;全部确认来源清单的候选范围、AI不明/成立冲突及公司财务技术缺项继续核,不能声称全来源研究完成。 原AI不明192项已按原顺序补核八批192项:103新增、7复用(含此前已核EveryApp)、82保留AI主营待核,共110关联;没有再把EveryApp额外加1,全池192项均有可回查后续记录。原发现审计/928初始新增不回写;已读全池不等82项均确认AI,更不等268年范围外/缺失、6日期冲突和其他来源全部完成。Rhem交付后租赁/旧买断、Subvocal预约、EveryApp托管计划/Cloudflare费/OpenSEO套餐、ObsessionDB资源估算与BYOC年度运维分开,不新增可比MRR;市政债未来模块、原型/健康/倍速演示及Clean模型实现缺项保留。 原268项年份范围外/缺失已按原快照拆为214项列2022—2024(4/30/180)和54项无年,不称214项本轮登记核验。另6项日期冲突全池已补现官网和2025旧发布,均成立年待核,未新增公司;运营者/条款日期不替注册证据,Layers现AI核心待核,客户销售/利润计算器和前事业收入排除。 原54缺年已复读YC字段均仍空;外部补核首12项:5旧业务范围外、6缺年、1转AI待核,42项外部核查待续。政府登记与公司年份自述分开,美国/集团沿革、Inactive及新旧交付限制保留,无公司/收入新增。 缺年第二批6项:Milliray/DroneTector与Jinba/Carnot旧业务排除,4继续缺年;累计18项外部补核(7范围外/10缺年/1 AI待核),36项待续。Maywood公司自报2025及登记缺项、Q2Q Inactive和客户金额/按成功电话计费边界保留。 缺年第三批6项:Zymbly经英国登记2025入表、5项继续缺年;累计24项外部补核(1关联/7范围外/15缺年/1 AI待核),余30项。前Newton Education/全球主体、Cardinal旧产品、GovGuard拨款/人审、Elyra代收与医疗研发边界保留。 缺年第四批6项:CONUS旧业务排除、4缺年、Apollo AI待核;累计30项(1关联/8范围外/19缺年/2 AI待核),余24项。Gravy当前只读与远程依赖、空条款、CONUS免费核心与收费智能许可和LOI/示例金额边界保留。"
},
{
"id": "S02",
+1 -1
View File
@@ -1,5 +1,5 @@
{
"sourceVersion": "2026-10-31-sales-models-1",
"sourceVersion": "2026-10-31-missing-year-4",
"asOf": "2026-10-31",
"metric": "platform-mrr-usd",
"sampleUnit": "product-or-business",
+81 -5
View File
@@ -85,7 +85,7 @@ def candidate_register():
all_ids = [r['id'] for b in batches for r in b['records']]
assert len(set(all_ids)) == len(all_ids)
lines = []
statuses = {'pending-year': '成立年待核', 'linked': '已关联公司',
statuses = {'pending-year': '成立年待核', 'pending-ai': 'AI主营待核', 'linked': '已关联公司',
'existing-outside-cohort': '已有关联,年份范围外',
'outside-cohort': '范围外或既有业务,不新增公司', 'promotion': '推广活动,非公司新增'}
for batch in batches:
@@ -97,13 +97,13 @@ def candidate_register():
assert sum(counts.values()) == len(rows)
lines += ['', f"## {batch['sourceId']} 候选核对({batch['id']})", '',
f"[发现页面]({batch['url']}),读取于{batch['accessedAt']}。{batch['scope']}", '',
f"本批{len(rows)}条:{counts['linked']}条关联公司、{counts['existing-outside-cohort']}条关联范围外对照、{counts['outside-cohort']}条范围外不新增公司、{counts['pending-year']}条成立年待核、{counts['promotion']}条推广活动。完整来源覆盖标记:{'已完成' if batch['complete'] else '未完成'}。主营或产品任务的初分类不计入主公司表数量,只有已关联的公司记录进入对应公司明细。候选与缺项随研究版本保存在文档站同一SQLite的研究元数据中。", '',
f"本批{len(rows)}条:{counts['linked']}条关联公司、{counts['existing-outside-cohort']}条关联范围外对照、{counts['outside-cohort']}条范围外不新增公司、{counts['pending-year']}条成立年待核、{counts['pending-ai']}条AI主营待核、{counts['promotion']}条推广活动。完整来源覆盖标记:{'已完成' if batch['complete'] else '未完成'}。主营或产品任务的初分类不计入主公司表数量,只有已关联的公司记录进入对应公司明细。候选与缺项随研究版本保存在文档站同一SQLite的研究元数据中。", '',
'| 发现条目 | 主营或产品任务初分 | 核对状态 | 关联公司 | 核对证据 | 限制 |', '| --- | --- | --- | --- | --- | --- |']
for row in rows:
assert row['categoryId'] in categories
assert row['status'] in statuses
assert all(eid in evidence for eid in row.get('evidenceIds', []))
if row['status'] == 'outside-cohort':
if row['status'] in {'outside-cohort', 'pending-ai'}:
assert row.get('evidenceIds') and not row.get('companyId')
name = f"[{row['name']}]({row['url']})" if row['url'] else row['name']
company = '—'
@@ -121,6 +121,73 @@ def candidate_register():
return lines
def uncertain_ai_followups():
original = {row['source']: row for row in AUDIT['records'] if row['status'] == 'ai-unclear'}
rows = [row for batch in DATA.get('candidateBatches', [])
if batch['id'].startswith('YC-AI-UNCLEAR-') for row in batch['records']]
if not rows:
return []
urls = [row['url'] for row in rows]
assert len(set(urls)) == len(urls), 'Duplicate AI-relevance follow-up URL'
rechecks = {row['ycId']: row for row in DATA.get('directoryRechecks', [])}
counts = Counter(row['status'] for row in rows)
assert set(counts) <= {'linked', 'pending-ai'}
for row in rows:
assert row['url'] in original and row.get('evidenceIds')
baseline = original[row['url']]
if row['status'] == 'linked':
assert rechecks[baseline['ycId']]['companyId'] == row['companyId']
else:
assert not row.get('companyId') and baseline['ycId'] not in rechecks
unread = len(original) - len(rows)
assert unread >= 0
return ['', '## 原AI主营不明名单的后续覆盖', '',
f"原名单{len(original)}项,已有后续记录{len(rows)}项:{counts['linked']}项关联公司、{counts['pending-ai']}项仍待核AI主营,{unread}项尚无本批系列的后续记录。计数按原始YC页面去重;EveryApp此前的独立复核与末批记录不重复相加。", '',
'读完名单只证明每项有可回查的处理记录,不证明待核项均为AI公司,也不证明法律主体、收入或技术效果已独立验证。原始发现审计保持不变,成立年范围外/缺失、成立冲突及其他来源的缺项仍单列。', '']
def founding_year_followups():
original = {row['source']: row for row in AUDIT['records'] if row['status'] == 'date-conflict'}
rows = [row for batch in DATA.get('candidateBatches', [])
if batch['id'].startswith('YC-DATE-CONFLICT-') for row in batch['records']]
urls = [row['url'] for row in rows]
assert len(set(urls)) == len(urls), 'Duplicate founding-conflict follow-up URL'
assert set(urls) <= set(original), 'Unknown founding-conflict follow-up URL'
evidence = {row['id']: row for row in DATA['evidence']}
for row in rows:
assert row['status'] == 'pending-year' and not row.get('companyId')
assert row.get('evidenceIds') and all(eid in evidence for eid in row['evidenceIds'])
assert all(evidence[eid]['companyId'] is None for eid in row['evidenceIds'])
unread = len(original) - len(rows)
return ['', '## 原成立年冲突名单的后续覆盖', '',
f"原名单{len(original)}项,已有后续记录{len(rows)}项,均保留成立年待核,{unread}项尚无本系列后续记录。当前业务初分类见候选表,不计入主公司表及收入统计。", '',
'2025旧品牌发布可证明当时已有产品材料;当前目录的2026字段、批次、条款日期和运营者名称不能单独证明法律主体成立或新旧主体连续。未据此强改成立年。Layers当前AI核心仍另待核。', '']
def missing_year_followups():
original = {row['source'] for row in AUDIT['records']
if row['status'] == 'year-outside-or-missing' and row['foundedYear'] is None}
rows = [row for batch in DATA.get('candidateBatches', [])
if batch['id'].startswith('YC-MISSING-YEAR-') for row in batch['records']]
urls = [row['url'] for row in rows]
assert len(set(urls)) == len(urls) and set(urls) <= original
evidence = {e['id']: e for e in DATA['evidence']}
for row in rows:
assert row['status'] in {'outside-cohort', 'pending-year', 'pending-ai', 'linked'}
assert row.get('evidenceIds')
if row['status'] == 'linked':
matches = [r for r in DATA.get('directoryRechecks', []) if r['companyId'] == row.get('companyId')]
assert len(matches) == 1 and matches[0]['originalStatus'] == 'year-outside-or-missing'
assert all(eid in evidence and evidence[eid]['companyId'] == row['companyId'] for eid in row['evidenceIds'])
else:
assert not row.get('companyId')
assert all(eid in evidence and evidence[eid]['companyId'] is None for eid in row['evidenceIds'])
counts = Counter(row['status'] for row in rows)
return ['', '## 原缺少成立年名单的后续覆盖', '',
f"原快照缺年{len(original)}项,外部补核已有{len(rows)}项:{counts['linked']}项关联公司、{counts['outside-cohort']}项既有主体/业务范围外、{counts['pending-year']}项成立年待核、{counts['pending-ai']}项AI主营待核,{len(original)-len(rows)}项尚无本系列外部补核记录。", '',
'当前YC缺年字段复读与外部主体核查分别统计。登记创建日、公司自述年、产品发布、条款更新和批次不相互替代;已查英国或法国主体不代表完整集团沿革已核。原54项发现计数不回写,也不以Inactive补零收入。', '']
def directory_rechecks():
rows = DATA.get('directoryRechecks', [])
if not rows:
@@ -167,6 +234,11 @@ def render():
'year-outside-or-missing': cov['otherOrMissingYear'],
'ai-unclear': cov['unclearAI'], 'date-conflict': cov['dateConflicts']}
assert len({x['ycId'] for x in AUDIT['records']}) == len(AUDIT['records'])
excluded_years = Counter(x['foundedYear'] for x in AUDIT['records'] if x['status'] == 'year-outside-or-missing')
outside_years = {year: count for year, count in excluded_years.items() if year is not None}
assert all(year not in (2025, 2026) for year in outside_years)
assert sum(outside_years.values()) + excluded_years[None] == cov['otherOrMissingYear']
year_detail = '、'.join(f'{year}年{count}项' for year, count in sorted(outside_years.items()))
lines = ['# AI 公司资料覆盖与缺项', '',
f"截至 {DATA['asOf']},研究表含{len(companies):,}条公司或产品记录。YC候选池有逐条读取审计;其他来源为定向补充。清单尚不能作为全球AI公司普查,也不能将收入未知解释为零。", '',
'验收范围已于2026-10-30确认为:以确认的公开来源清单为边界,逐条核对并标明缺项。下方区分已逐条审计的候选池与定向补充来源;已使用某来源不代表该来源已被完整覆盖。', '',
@@ -178,7 +250,8 @@ def render():
f"| 初筛匹配 | {cov['matchingProfiles']:,} | 成立年及AI相关描述通过初筛,尚非逐家商业验证 |",
f"| 与原表重合 | {cov['existingProfiles']} | URL匹配,未再次新增 |",
f"| 新增目录记录 | {cov['newProfiles']:,} | 原始入表来源,后续深化不改变发现计数 |",
f"| 年份不符或缺失 | {cov['otherOrMissingYear']} | 此轮不作为成立年匹配项 |",
f"| 原目录列为范围外年份 | {sum(outside_years.values())} | {year_detail};原快照自述,不是独立登记核验 |",
f"| 原目录未给成立年 | {excluded_years[None]} | 与已列范围外年份分开,仍待补证 |",
f"| AI业务待确认 | {cov['unclearAI']} | 不强行把背景关键词当主营 |",
f"| 成立年与批次冲突 | {cov['dateConflicts']} | 另保留核查记录 |", '',
f"全表由{depth}条目录基础项和{len(companies)-depth}条个案或平台记录组成。候选池已匹配项之外另有{len(companies)-cov['matchingProfiles']}条记录,包含其他来源及发布/转型对照;其中已有{promoted}条原目录记录深化为个案,仍保留目录来源。两种统计边界不同。候选池数字只是该镜像快照的覆盖,Bud等后续定向补充不回填为原候选池已覆盖。", '',
@@ -217,13 +290,16 @@ def render():
lines.append(f"| {name} | {len(entries)} | {len({e['url'] for e in entries})} | {note} |")
others = [e for e in DATA['evidence'] if urlsplit(e['url']).netloc not in included]
lines.append(f"| 其他官网、评测及公开资料 | {len(others)} | {len({e['url'] for e in others})} | 按每条来源限制理解,不能统一当作独立证据 |")
lines += uncertain_ai_followups()
lines += founding_year_followups()
lines += missing_year_followups()
lines += directory_rechecks()
lines += source_register()
lines += context_methods()
lines += candidate_register()
lines += ['', '## 尚未满足的研究条件', '',
'行业ARR比较仍缺统一业务截止日、币种、经常性定义和业务边界。现有平台MRR可描述已采集产品,不足以代表全部新公司。技术评测只覆盖所列版本与任务,不宜跨领域汇总为统一强弱分数。', '',
'下一轮优先补收入线索的日期及合同定义、非YC和非英文来源、规则初分的人工复核,以及停止服务或被收购案例。这样能减少“只见赢家”和“只见融资公司”的偏差。公开来源池之外的未披露公司仍无法证明已被穷尽。', '',
'下一轮优先补收入线索的日期及合同定义、成立年冲突、AI主营仍待核项、非YC和非英文来源,以及停止服务或被收购案例。这样能减少“只见赢家”和“只见融资公司”的偏差。公开来源池之外的未披露公司仍无法证明已被穷尽。', '',
]
return '\n'.join(lines)
+29
View File
@@ -116,6 +116,17 @@ def main():
mode.add_argument('--revision', type=int)
reading.add_argument('--limit', type=int, default=50)
reading.add_argument('--offset', type=int, default=0)
sections = sub.add_parser('outline', help='Read chapter titles and internal summaries without bodies')
sections.add_argument('slug')
sections.add_argument('--revision', type=int)
section = sub.add_parser('sections', help='Read selected chapter bodies')
section.add_argument('slug')
section.add_argument('ids', nargs='+')
section.add_argument('--revision', type=int)
editing = sub.add_parser('edit-sections', help='Atomically apply chapter operations from private JSON')
editing.add_argument('slug')
editing.add_argument('file')
editing.add_argument('--request-id')
saving = sub.add_parser('save')
saving.add_argument('file', help='Private JSON file or - for stdin; one document or {documents: [...]}')
saving.add_argument('--request-id', help='Reuse this id only with the same input when retrying')
@@ -135,6 +146,24 @@ def main():
elif args.revision is not None:
path += '?' + urllib.parse.urlencode({'revision': args.revision})
result = request(base, token, 'GET', path)
elif args.command in ('outline', 'sections', 'edit-sections'):
path = '/api/documents/sections/' + urllib.parse.quote(args.slug, safe='/')
if args.command == 'edit-sections':
payload = json.load(sys.stdin) if args.file == '-' else json.loads(Path(args.file).read_text())
request_id = args.request_id or str(uuid.uuid4())
if not request_id or len(request_id) > 100 or any(c not in 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789._:-' for c in request_id):
raise ValueError('Invalid request id')
print('Request id: ' + request_id, file=sys.stderr)
result = request(base, token, 'POST', path, payload, request_id)
else:
query = []
if args.revision is not None:
query.append(('revision', args.revision))
if args.command == 'sections':
query.extend(('section', section_id) for section_id in args.ids)
if query:
path += '?' + urllib.parse.urlencode(query)
result = request(base, token, 'GET', path)
else:
payload = json.load(sys.stdin) if args.file == '-' else json.loads(Path(args.file).read_text())
request_id = args.request_id or str(uuid.uuid4())
+25
View File
@@ -4,6 +4,7 @@ import io
import json
from pathlib import Path
import tempfile
import sys
import unittest
from unittest.mock import patch
import urllib.error
@@ -15,6 +16,30 @@ spec.loader.exec_module(client)
class ClientTests(unittest.TestCase):
def test_section_reads_select_bodies_and_revision_without_full_document_fetch(self):
argv = ['client', '--url', 'https://docs.example', '--key-file', '/private/key',
'sections', 'endor/example', 'preamble', 's_one', '--revision', '3']
with patch.object(sys, 'argv', argv), patch.object(client, 'read_token', return_value='test-token'), \
patch.object(client, 'request', return_value={'revision': 3, 'sections': []}) as request, \
patch.object(sys, 'stdout', io.StringIO()):
client.main()
request.assert_called_once_with('https://docs.example', 'test-token', 'GET',
'/api/documents/sections/endor/example?revision=3&section=preamble&section=s_one')
def test_section_edit_keeps_payload_and_retry_id(self):
payload = {'revision': 3, 'operations': [{'op': 'update', 'id': 's_one', 'summary': 'Internal summary'}]}
with tempfile.TemporaryDirectory() as directory:
path = Path(directory) / 'edit.json'
path.write_text(json.dumps(payload))
argv = ['client', '--url', 'https://docs.example', '--key-file', '/private/key',
'edit-sections', 'endor/example', str(path), '--request-id', 'edit-1']
with patch.object(sys, 'argv', argv), patch.object(client, 'read_token', return_value='test-token'), \
patch.object(client, 'request', return_value={'revision': 4}) as request, \
patch.object(sys, 'stdout', io.StringIO()), patch.object(sys, 'stderr', io.StringIO()):
client.main()
request.assert_called_once_with('https://docs.example', 'test-token', 'POST',
'/api/documents/sections/endor/example', payload, 'edit-1')
def test_only_tls_or_loopback_origins_are_accepted(self):
self.assertEqual(client.server_url('https://docs.example/'), 'https://docs.example')
self.assertEqual(client.server_url('http://127.0.0.1:18135'), 'http://127.0.0.1:18135')