Commit 8019c687 by 黄南光

wiki-ontology尝试

1 parent 914553c4
Showing 618 changed files with 612 additions and 0 deletions
"use client";
import { useEffect, useRef } from "react";
import type { OntologyNode, OntologyEdge } from "@/lib/ontology-api";
// 节点分组配色:页面类型一组暖/主色,维度节点一组辅助色
const GROUP_COLORS: Record<string, string> = {
// 页面类型
entities: "#6366f1",
products: "#10b981",
procedures: "#f59e0b",
scripts: "#ec4899",
policies: "#ef4444",
comparisons: "#8b5cf6",
sources: "#64748b",
concepts: "#14b8a6",
troubleshooting: "#f97316",
synthesis: "#06b6d4",
// 维度节点
brand: "#0ea5e9",
series: "#38bdf8",
category: "#a855f7",
subbiz: "#c084fc",
role: "#22c55e",
scenario: "#eab308",
objection: "#fb7185",
skill: "#2dd4bf",
tag: "#94a3b8",
policy_type: "#f87171",
script_type: "#f472b6",
system: "#60a5fa",
};
function colorOf(group: string): string {
return GROUP_COLORS[group] || "#94a3b8";
}
interface Props {
nodes: OntologyNode[];
edges: OntologyEdge[];
onSelect?: (node: OntologyNode | null) => void;
filterGroups?: Set<string>; // 若提供,仅显示这些 group 的节点
}
export default function GraphView({ nodes, edges, onSelect, filterGroups }: Props) {
const containerRef = useRef<HTMLDivElement>(null);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const cyRef = useRef<any>(null);
useEffect(() => {
let destroyed = false;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let cy: any = null;
(async () => {
const cytoscape = (await import("cytoscape")).default;
const fcose = (await import("cytoscape-fcose")).default;
try {
cytoscape.use(fcose);
} catch {
/* 重复注册忽略 */
}
if (destroyed || !containerRef.current) return;
const showNode = (n: OntologyNode) => !filterGroups || filterGroups.has(n.group);
const visibleIds = new Set(nodes.filter(showNode).map((n) => n.id));
const elements = [
...nodes.filter(showNode).map((n) => ({
data: {
id: n.id,
label: n.label,
group: n.group,
color: colorOf(n.group),
size: Math.min(70, 20 + (n.degree || 0) * 2.5),
isPage: n.is_page ? 1 : 0,
raw: n,
},
})),
...edges
.filter((e) => visibleIds.has(e.source) && visibleIds.has(e.target))
.map((e) => ({ data: { source: e.source, target: e.target, rel: e.rel } })),
];
cy = cytoscape({
container: containerRef.current,
elements,
style: [
{
selector: "node",
style: {
"background-color": "data(color)",
label: "data(label)",
width: "data(size)",
height: "data(size)",
"font-size": 9,
"font-family": "system-ui, sans-serif",
color: "#334155",
"text-valign": "bottom",
"text-halign": "center",
"text-margin-y": 3,
"text-max-width": "90px",
"text-wrap": "ellipsis",
"border-width": 1,
"border-color": "#ffffff",
"overlay-opacity": 0,
},
},
{
// 页面节点方形、维度节点圆形,视觉区分
selector: "node[isPage = 1]",
style: { shape: "round-rectangle" },
},
{
selector: "node[isPage = 0]",
style: { shape: "ellipse", "font-size": 8, color: "#64748b" },
},
{
selector: "edge",
style: {
width: 1,
"line-color": "#e2e8f0",
"curve-style": "bezier",
"target-arrow-shape": "triangle",
"target-arrow-color": "#e2e8f0",
"arrow-scale": 0.5,
opacity: 0.7,
},
},
{
selector: "node:selected",
style: { "border-width": 3, "border-color": "#0f172a" },
},
{
selector: ".faded",
style: { opacity: 0.12 },
},
{
selector: ".highlight",
style: { "line-color": "#f59e0b", "target-arrow-color": "#f59e0b", width: 2, opacity: 1 },
},
],
layout: {
name: "fcose",
quality: "default",
animate: false,
nodeRepulsion: 8000,
idealEdgeLength: 90,
nodeSeparation: 90,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any,
wheelSensitivity: 0.2,
minZoom: 0.1,
maxZoom: 3,
});
cyRef.current = cy;
// 点击节点:高亮邻域 + 回调详情
cy.on("tap", "node", (evt: { target: { data: () => { raw: OntologyNode; id: string } } } & Record<string, unknown>) => {
const node = evt.target as unknown as {
data: () => { raw: OntologyNode };
neighborhood: () => unknown;
closedNeighborhood: () => { addClass: (c: string) => void };
};
cy.elements().addClass("faded");
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const nb = (evt.target as any).closedNeighborhood();
nb.removeClass("faded");
nb.connectedEdges?.().addClass?.("highlight");
onSelect?.(node.data().raw);
});
// 点击空白:还原
cy.on("tap", (evt: { target: unknown }) => {
if (evt.target === cy) {
cy.elements().removeClass("faded").removeClass("highlight");
onSelect?.(null);
}
});
})();
return () => {
destroyed = true;
cy?.destroy();
};
}, [nodes, edges, filterGroups, onSelect]);
return <div ref={containerRef} className="w-full h-full bg-slate-50 rounded-lg" />;
}
export { GROUP_COLORS, colorOf };
"use client";
import { useRef, useState, useEffect } from "react";
import { Send, Loader2, Sparkles, FileText } from "lucide-react";
import ReactMarkdown from "react-markdown";
import remarkGfm from "remark-gfm";
import { streamOntologyQuery, type OntologySource } from "@/lib/ontology-api";
interface ChatMessage {
role: "user" | "assistant";
content: string;
sources?: OntologySource[];
streaming?: boolean;
}
const SUGGESTIONS = [
"公司整体有哪些业务板块,如何咬合?",
"零跑出行无忧涉及哪些岗位和流程?",
"延保和会员权益有什么区别?",
];
export default function OntologyChat() {
const [messages, setMessages] = useState<ChatMessage[]>([]);
const [input, setInput] = useState("");
const [busy, setBusy] = useState(false);
const scrollRef = useRef<HTMLDivElement>(null);
useEffect(() => {
scrollRef.current?.scrollTo({ top: scrollRef.current.scrollHeight, behavior: "smooth" });
}, [messages]);
const send = (q: string) => {
const query = q.trim();
if (!query || busy) return;
const history = messages.map((m) => ({ role: m.role, content: m.content }));
setMessages((prev) => [
...prev,
{ role: "user", content: query },
{ role: "assistant", content: "", streaming: true },
]);
setInput("");
setBusy(true);
streamOntologyQuery({ query, history }, (ev) => {
setMessages((prev) => {
const next = [...prev];
const last = next[next.length - 1];
if (!last || last.role !== "assistant") return prev;
if (ev.type === "sources") last.sources = ev.sources;
else if (ev.type === "answer_delta") last.content += ev.content || "";
else if (ev.type === "error") {
last.content += `\n\n> ⚠️ ${ev.message || "出错了"}`;
last.streaming = false;
setBusy(false);
}
return next;
});
});
// 简单收尾:轮询流结束由 [DONE] 触发,这里用兜底解除 busy
const iv = setInterval(() => {
setMessages((prev) => {
const last = prev[prev.length - 1];
if (last && last.role === "assistant" && !last.streaming) {
clearInterval(iv);
return prev;
}
return prev;
});
}, 500);
// 兜底:由 fetch 完成后无更多事件时结束(用 finally 模拟)
setTimeout(() => {
setMessages((prev) => {
const next = [...prev];
const last = next[next.length - 1];
if (last && last.role === "assistant") last.streaming = false;
return next;
});
setBusy(false);
clearInterval(iv);
}, 60000);
};
return (
<div className="flex flex-col h-full">
<div className="flex items-center gap-2 px-4 py-3 border-b border-slate-200">
<Sparkles className="w-4 h-4 text-amber-500" />
<span className="font-medium text-slate-700 text-sm">本体问答</span>
<span className="text-xs text-slate-400">基于公司业务本体</span>
</div>
<div ref={scrollRef} className="flex-1 overflow-y-auto px-4 py-4 space-y-4">
{messages.length === 0 && (
<div className="text-sm text-slate-500 space-y-3">
<p>向公司业务本体提问,它理解公司整体业务、组织与流程。试试:</p>
{SUGGESTIONS.map((s) => (
<button
key={s}
onClick={() => send(s)}
className="block w-full text-left px-3 py-2 rounded-lg bg-slate-50 hover:bg-amber-50 hover:text-amber-700 border border-slate-200 transition text-xs"
>
{s}
</button>
))}
</div>
)}
{messages.map((m, i) => (
<div key={i} className={m.role === "user" ? "flex justify-end" : ""}>
<div
className={
m.role === "user"
? "max-w-[85%] bg-slate-800 text-white rounded-2xl rounded-br-sm px-4 py-2 text-sm"
: "max-w-full w-full"
}
>
{m.role === "assistant" ? (
<div className="prose prose-sm max-w-none prose-slate">
{m.sources && m.sources.length > 0 && (
<div className="flex flex-wrap gap-1 mb-2 not-prose">
{m.sources.map((s) => (
<span
key={s.idx}
title={s.rel_path}
className="inline-flex items-center gap-1 text-[11px] px-2 py-0.5 rounded-full bg-slate-100 text-slate-600 border border-slate-200"
>
<FileText className="w-3 h-3" />[{s.idx}] {s.title}
</span>
))}
</div>
)}
{m.content ? (
<ReactMarkdown remarkPlugins={[remarkGfm]}>{m.content}</ReactMarkdown>
) : (
<div className="flex items-center gap-2 text-slate-400 text-sm">
<Loader2 className="w-4 h-4 animate-spin" /> 检索本体中…
</div>
)}
</div>
) : (
m.content
)}
</div>
</div>
))}
</div>
<div className="p-3 border-t border-slate-200">
<div className="flex items-end gap-2">
<textarea
value={input}
onChange={(e) => setInput(e.target.value)}
onKeyDown={(e) => {
if (e.key === "Enter" && !e.shiftKey) {
e.preventDefault();
send(input);
}
}}
rows={1}
placeholder="问点公司业务的问题…"
className="flex-1 resize-none rounded-xl border border-slate-200 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-amber-300 max-h-32"
/>
<button
onClick={() => send(input)}
disabled={busy || !input.trim()}
className="p-2 rounded-xl bg-amber-500 text-white disabled:opacity-40 hover:bg-amber-600 transition"
>
{busy ? <Loader2 className="w-5 h-5 animate-spin" /> : <Send className="w-5 h-5" />}
</button>
</div>
</div>
</div>
);
}
// 公司业务本体(Ontology)前端 API —— 只调 /ontology/**,独立于 wiki/rag。
const API_BASE = process.env.NEXT_PUBLIC_API_URL || "/api";
export interface OntologyNode {
id: string;
label: string;
group: string;
degree?: number;
is_page?: boolean;
kb?: string;
page_type?: string;
rel_path?: string;
}
export interface OntologyEdge {
source: string;
target: string;
rel: string;
}
export interface OntologyGraph {
nodes: OntologyNode[];
edges: OntologyEdge[];
stats: Record<string, unknown>;
dangling: { from: string; ref: string; kind: string }[];
}
export interface Glossary {
dimensions: Record<string, string[]>;
terms: {
term: string; type: string; kb: string; brand: string[];
category?: string; brief: string; related: string[]; rel_path: string;
}[];
stats: Record<string, unknown>;
}
export async function fetchGraph(): Promise<OntologyGraph> {
const res = await fetch(`${API_BASE}/ontology/graph`);
if (!res.ok) throw new Error("获取本体图失败");
return res.json();
}
export async function fetchGlossary(): Promise<Glossary> {
const res = await fetch(`${API_BASE}/ontology/glossary`);
if (!res.ok) throw new Error("获取术语表失败");
return res.json();
}
export async function fetchOverview(): Promise<{ overview: string; context: string; has_overview: boolean }> {
const res = await fetch(`${API_BASE}/ontology/overview`);
if (!res.ok) throw new Error("获取总纲失败");
return res.json();
}
export async function fetchOntologyStats(): Promise<Record<string, unknown>> {
const res = await fetch(`${API_BASE}/ontology/stats`);
if (!res.ok) throw new Error("获取统计失败");
return res.json();
}
export interface OntologySource {
idx: number; title: string; type: string; kb: string; rel_path: string; score: number;
}
// SSE 流式问答,复用与 rag-api 相同的解析范式
export function streamOntologyQuery(
payload: { query: string; history: { role: string; content: string }[] },
onEvent: (event: { type: string; content?: string; sources?: OntologySource[]; message?: string }) => void,
) {
const controller = new AbortController();
fetch(`${API_BASE}/ontology/query`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload),
signal: controller.signal,
})
.then(async (res) => {
if (!res.ok) throw new Error(await res.text());
if (!res.body) throw new Error("浏览器不支持流式响应");
const reader = res.body.getReader();
const decoder = new TextDecoder();
let buffer = "";
while (true) {
const { done, value } = await reader.read();
if (done) break;
buffer += decoder.decode(value, { stream: true });
const events = buffer.split("\n\n");
buffer = events.pop() || "";
for (const raw of events) {
const line = raw.split("\n").find((item) => item.startsWith("data: "));
if (!line) continue;
const data = line.slice(6);
if (data === "[DONE]") continue;
try {
onEvent(JSON.parse(data));
} catch {
/* 忽略非法分片 */
}
}
}
})
.catch((error) => {
if (error instanceof Error && error.name === "AbortError") return;
onEvent({ type: "error", message: error instanceof Error ? error.message : String(error) });
});
return controller;
}
export interface GapReport {
missing_pages: { missing: string; referenced_by_count: number; referenced_by: string[]; kinds: string[] }[];
stats: Record<string, number>;
}
export async function fetchGaps(): Promise<GapReport> {
const res = await fetch(`${API_BASE}/ontology/gaps`);
if (!res.ok) throw new Error("获取缺口报告失败");
return res.json();
}
export async function fetchInterviewQuestions(): Promise<{ questions: string[] }> {
const res = await fetch(`${API_BASE}/ontology/interview/questions`);
if (!res.ok) throw new Error("生成反问清单失败");
return res.json();
}
# Wiki + RAG 智能知识平台 · 版本迭代报告 v7
## 交付物
| 文件 | 说明 |
|---|---|
| `Wiki_RAG智能知识平台版本迭代报告.html` | **最终报告**(单文件自包含,1.07 MB)。19 章 / 46 张内联 SVG / 54 张表格 / 100 个小节。直接双击用浏览器打开即可 |
| `试用期述职汇报_Wiki与RAG智能知识平台.pptx` | **汇报用 PPTX**(16:9,59 页,17.3 MB)。全篇按 A–F 六部分搭好,其中 B3「Wiki / RAG 智能知识平台」为写实内容(36 页,含报告里的 36 张图),A / B1 / B2 / C / D / E / F 为待填写模板页 |
| `事实底稿.md` | 写报告前的源码与 git 核查底稿。每条结论标注可回查的源码路径或 commit,正文只使用这里已核实的事实 |
### 章节顺序
叙述顺序为:Wiki 主线(1–6)→ Skills 瘦身(7)→ RAG 主线(8–11)→ **Wiki × RAG 综合对比(12)**
→ 工程深化:长文档 MapReduce / 原子提交 / Context 编排(13–15)→ 平台治理(16–18)→ 总结(19)。
章号只在 `_build/build_report.py` 的 `SECTIONS` 列表里定义。调整顺序后必须跑一次
`python _build/renumber.py`,它会把各章片段里的小节号(`8.3 xxx`)、图题(`图 8-2`)
与交叉引用(`第 8 章`)同步过来,幂等可重复执行。
## 目录结构
```
├── Wiki_RAG智能知识平台版本迭代报告.html ← 最终报告
├── 事实底稿.md ← 事实核查底稿
├── assets/ ← 46 张 SVG(构建时内联进 HTML)
├── _build/ ← 报告与图的构建脚本
│ ├── svgkit.py ← SVG 版式工具箱(自动紧致画布 / 立体组件 / 图表)
│ ├── dia_core.py ← 第 1–2 章图
│ ├── dia_wiki.py ← 第 3–5 章图
│ ├── dia_wiki2.py ← 第 6–10 章图
│ ├── dia_rag.py ← 第 11–12 章图
│ ├── dia_rag2.py ← 第 13–14 章图
│ ├── dia_platform.py ← 第 15–16 章图
│ ├── dia_memory.py ← 第 17 章图
│ ├── dia_final.py ← 第 18–19 章图
│ ├── build_report.py ← 组装器(章节片段 + 内联 SVG → 单文件 HTML)
│ ├── renumber.py ← 章节顺序变更后同步小节号 / 图号 / 交叉引用
│ ├── shot.py ← SVG → PNG(headless Chrome);--hi 出 2× 高清图
│ ├── deck_kit.py ← PPTX 版式工具箱(配色字体与 HTML 报告同源)
│ ├── make_pptx.py ← 述职 PPTX 生成器(A–F 全篇结构 + B3 写实内容)
│ ├── _shots_hi/ ← 46 张 3200px 宽 SVG 截图,供 PPTX 内嵌
│ └── sections/c1.html … c19.html ← 19 章正文片段
├── scripts/ ← 量化脚本(均可复跑)
│ ├── bench_query_headtohead.py ← Wiki × RAG 同题同环境实测
│ ├── bench_answer_models.py ← 问答模型横评(走完整生产链路)
│ ├── analyze_headtohead.py ← 对比实测聚合
│ └── aggregate_ingest.py ← 摄入侧七版本矩阵聚合
└── verification/ ← 全部实测数据与日志
├── 对比实测摘要.md ← Wiki × RAG 49 题实测摘要(人读)
├── headtohead_summary.json ← 同上(机读)
├── ingest_runs/
│ ├── 量化聚合摘要.md ← 摄入侧 B01–B07 × 4 基准文件矩阵(人读)
│ ├── quant_ingest.json ← 同上(机读,供画图引用)
│ ├── archive_runs.csv ← 逐次冷启动运行的原始记录
│ └── raw_result_json/ ← 28 次运行的 result.json + raw.log
├── raw/
│ ├── headtohead.jsonl ← 49 题 × 2 系统的逐题原始记录
│ ├── answer_models.jsonl ← 8 题 × 3 模型的逐次原始记录
│ └── compare_dataset.json ← 从原始差异报告提取的 196 题数据集
└── logs/
├── headtohead_run.log ← 对比实测完整运行日志(1.2 MB)
└── answer_models_run.log ← 模型横评完整运行日志(540 KB)
```
## 本轮新跑的实测(不是引用历史数据)
### 1. Wiki × RAG 同题同环境对比(49 题)
- 从原始 196 题对比集分层随机抽样(种子固定 20260814)
- 两套系统在**同一进程、同一时段、同一份知识库快照**下依次执行,均为无登录态调用
- 逐题记录:耗时 / input·output·cached token / 模型调用次数 / 回答字符 / Wiki 工具轮次 / RAG 检索链路各阶段候选数与意图
- **关键结果**:耗时均值基本持平(15.0 vs 14.8 s),但 Wiki 中位更快(10.4 vs 14.5 s)、RAG 稳定性显著更好(σ 3.0 vs 11.5)、**Wiki Token 是 RAG 的 2.9 倍**(24,388 vs 8,401)
### 2. 问答模型横评(8 题 × 3 模型)
- **走完整生产链路**(含 index.md 前缀、文件工具、related 二跳),不是只换一次生成调用
- 新增两个可程序判定的质量代理指标:**零工具题数**(一次文件都没读就作答)与**引用有效率**(`[[slug]]` 是否指向真实存在的页面)
- **关键结果**:qwen-flash 快 4.5 倍、省 5 倍 token,但 **7/8 题零工具调用**、引用有效率仅 85%;deepseek-v4-flash 8/8 题都调用工具、引用有效率 100%
### 3. 摄入侧七版本矩阵(B01–B07 × 4 基准文件)
- 来自 2026-08-11 的逐次冷启动实测归档,本轮按「每格取最后一次成功运行」的确定性口径**重新聚合**
- 覆盖:耗时 / input·cached·output·VLM token / 生成页数与字符 / Map 块数 / Frontmatter 合规率 / VLM 页级耗时分布
## 复跑方式
```bash
PY="D:/software_install/anaconda_env/envs/wiki_knowledge/python.exe"
# 摄入侧矩阵重新聚合(纯离线,秒级)
cd scripts && $PY aggregate_ingest.py
# Wiki × RAG 对比实测(需 MySQL + Qdrant + DASHSCOPE_API_KEY,约 35 分钟)
cd scripts && $PY bench_query_headtohead.py --n 25 --out ../verification/raw/headtohead.jsonl
cd scripts && $PY analyze_headtohead.py
# 问答模型横评(约 15 分钟)
cd scripts && $PY bench_answer_models.py --models deepseek-v4-flash,qwen-flash,qwen3.7-plus --repeat 1
# 重画全部 SVG + 重新组装报告
cd _build && for f in dia_core dia_wiki dia_wiki2 dia_rag dia_rag2 dia_platform dia_memory dia_final; do $PY $f.py; done
$PY _build/renumber.py # 只在改过 SECTIONS 顺序后需要
$PY _build/build_report.py
# 重新生成汇报 PPTX(图从 SVG 重新截,所以改完图直接重跑即可)
$PY _build/shot.py --hi
$PY _build/make_pptx.py
```
### 版式自查
`shot.py`(不带 `--hi`)会把 46 张 SVG 渲染成 1280px 宽的 PNG 到 `_build/_shots/`,
用来逐张检查有没有文字出框、连线压字。PPTX 侧可以用 LibreOffice 转 PDF 后逐页导图核对:
```bash
soffice --headless --convert-to pdf --outdir _build/_pdf 试用期述职汇报_Wiki与RAG智能知识平台.pptx
```
## 报告口径
- 「实现了」用于当前代码、配置与数据库可验证的能力
- 「提升 X%」只用于有可比基线与明确公式的数据
- 历史非受控数据明确标注为观察性证据
- 没有实测的指标写「待测」,**不用配置值或代码规模代替质量**
本报告明确**不给出** RAG 检索的 Recall@K / MRR / nDCG、Wiki 页面事实准确率、记忆采纳准确率——这三项都需要人工标注集,而标注集尚未建立。它们在第 19 章列为下一阶段的 P0。
<meta charset="utf-8"><style>html,body{margin:0;padding:0;background:#fff}svg{display:block;width:1600px}</style><svg xmlns="http://www.w3.org/2000/svg" viewBox="14.0 -6.0 1428.0 480.6" width="100%" preserveAspectRatio="xMidYMid meet" role="img" aria-label="跨页表格拼接"><rect x="14.0" y="-6.0" width="1428.0" height="480.6" fill="#FCFAF6"/><defs><filter id="soft" x="-30%" y="-30%" width="170%" height="170%"><feDropShadow dx="0" dy="2.5" stdDeviation="4" flood-color="#8A7460" flood-opacity=".16"/></filter><marker id="ar_E0930F" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6.4" markerHeight="6.4" orient="auto-start-reverse"><path d="M0.6 1L9.4 5L0.6 9L2.6 5z" fill="#E0930F"/></marker></defs><rect x="40.0" y="22.0" width="6.0" height="30.0" rx="3" fill="#D9622B"/><text x="58.0" y="42.0" text-anchor="start" style="font:800 22px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#2F2A24">跨页表格:模型负责标注延续关系,程序负责确定性拼接</text><text x="58.0" y="66.0" text-anchor="start" style="font:400 13px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#655F57">跨页表格在每页重复表头,却不一定显式写「续表」;靠字符串相似度硬猜会错拼两张不相关的表</text><rect x="46.0" y="118.0" width="210.0" height="250.0" rx="10" fill="#E2D6C4" opacity="0.30"/><rect x="40.0" y="112.0" width="210.0" height="250.0" rx="10" fill="#FFFFFF" stroke="#E2D6C4" stroke-width="1.4" filter="url(#soft)"/><text x="54.0" y="138.0" text-anchor="start" style="font:800 13.4px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#655F57">第 3 页</text><text x="54.0" y="164.0" text-anchor="start" style="font:600 11.6px 'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;fill:#655F57">| 品牌 | 产品 | 价格 |</text><text x="54.0" y="186.0" text-anchor="start" style="font:600 11.6px 'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;fill:#655F57">| --- | --- | --- |</text><text x="54.0" y="208.0" text-anchor="start" style="font:600 11.6px 'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;fill:#655F57">| 问界 | 整车延保 | 6,800 |</text><text x="54.0" y="230.0" text-anchor="start" style="font:600 11.6px 'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;fill:#655F57">| 问界 | 电池延保 | 3,200 |</text><text x="54.0" y="252.0" text-anchor="start" style="font:600 11.6px 'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;fill:#655F57">…(表格未结束)</text><rect x="54.0" y="316.0" width="182.0" height="32.0" rx="7" fill="#E0930F" opacity="0.9"/><text x="145.0" y="337.0" text-anchor="middle" style="font:800 11.6px 'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;fill:#fff">&lt;!--table-continues--&gt;</text><rect x="326.0" y="118.0" width="210.0" height="250.0" rx="10" fill="#E2D6C4" opacity="0.30"/><rect x="320.0" y="112.0" width="210.0" height="250.0" rx="10" fill="#FFFFFF" stroke="#E2D6C4" stroke-width="1.4" filter="url(#soft)"/><text x="334.0" y="138.0" text-anchor="start" style="font:800 13.4px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#655F57">第 4 页</text><text x="334.0" y="164.0" text-anchor="start" style="font:600 11.6px 'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;fill:#655F57">| 品牌 | 产品 | 价格 |</text><text x="334.0" y="186.0" text-anchor="start" style="font:600 11.6px 'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;fill:#655F57">| --- | --- | --- |</text><text x="334.0" y="208.0" text-anchor="start" style="font:600 11.6px 'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;fill:#655F57">| 智界 | 整车延保 | 7,200 |</text><text x="334.0" y="230.0" text-anchor="start" style="font:600 11.6px 'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;fill:#655F57">| 智界 | 轮胎保障 | 1,800 |</text><path d="M256.0 237.0L308.0 237.0" fill="none" stroke="#E0930F" stroke-width="2.2" stroke-linejoin="round" marker-end="url(#ar_E0930F)"/><rect x="586.0" y="118.0" width="450.0" height="250.0" rx="12" fill="#2F8781" opacity="0.30"/><rect x="580.0" y="112.0" width="450.0" height="250.0" rx="12" fill="#FFFFFF" stroke="#2F8781" stroke-width="1.4" filter="url(#soft)"/><text x="598.0" y="142.0" text-anchor="start" style="font:800 14.4px 'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;fill:#1F625E">_stitch_continued_tables() 的判定</text><text x="598.0" y="170.0" text-anchor="start" style="font:600 11.6px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#655F57">1. 遍历全部块,遇到带 table_continues 标记的表格块</text><text x="598.0" y="194.0" text-anchor="start" style="font:600 11.6px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#655F57">2. 取紧邻的下一个 table 块作为续表候选</text><text x="598.0" y="218.0" text-anchor="start" style="font:600 11.6px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#655F57">3. _merge_table_markdown:比较两表首行</text><text x="598.0" y="242.0" text-anchor="start" style="font:500 11.6px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#655F57"> · 首行相同 → 判定续表重复了表头,跳过其前两行再拼</text><text x="598.0" y="266.0" text-anchor="start" style="font:500 11.6px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#655F57"> · 首行不同 → 判定续表没写表头,保留其首行数据后再拼</text><text x="598.0" y="290.0" text-anchor="start" style="font:600 11.6px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#655F57">4. 把 page_end 改写成续表所在页,标记 continued_table</text><text x="598.0" y="314.0" text-anchor="start" style="font:600 11.6px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#655F57">5. 若续表自身也带标记 → while 循环继续拼下一页</text><text x="598.0" y="340.0" text-anchor="start" style="font:700 11.6px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#1F625E">证据不足时保持分页 —— 误拼两张不相关的表比分开更难被发现</text><rect x="1056.0" y="118.0" width="360.0" height="250.0" rx="12" fill="#4F8A3D" opacity="0.30"/><rect x="1050.0" y="112.0" width="360.0" height="250.0" rx="12" fill="#FFFFFF" stroke="#4F8A3D" stroke-width="1.4" filter="url(#soft)"/><text x="1068.0" y="142.0" text-anchor="start" style="font:800 14.4px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#39662B">拼接结果(单个块)</text><text x="1068.0" y="170.0" text-anchor="start" style="font:600 11.6px 'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;fill:#655F57">| 品牌 | 产品 | 价格 |</text><text x="1068.0" y="194.0" text-anchor="start" style="font:600 11.6px 'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;fill:#655F57">| --- | --- | --- |</text><text x="1068.0" y="218.0" text-anchor="start" style="font:600 11.6px 'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;fill:#655F57">| 问界 | 整车延保 | 6,800 |</text><text x="1068.0" y="242.0" text-anchor="start" style="font:600 11.6px 'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;fill:#655F57">| 问界 | 电池延保 | 3,200 |</text><text x="1068.0" y="266.0" text-anchor="start" style="font:700 11.6px 'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;fill:#39662B">| 智界 | 整车延保 | 7,200 |</text><text x="1068.0" y="290.0" text-anchor="start" style="font:700 11.6px 'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;fill:#39662B">| 智界 | 轮胎保障 | 1,800 |</text><text x="1068.0" y="340.0" text-anchor="start" style="font:700 11.6px 'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;fill:#39662B">metadata: page_start=3, page_end=4, continued_table=true</text><rect x="40.0" y="388.0" width="1290.0" height="60.6" rx="9" fill="#FDF3DE" stroke="#E0930F" stroke-width="1.1" opacity="0.95"/><rect x="40.0" y="388.0" width="4" height="60.6" rx="2" fill="#E0930F"/><text x="55.0" y="406.0" text-anchor="start" style="font:800 12.7px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#E0930F">可靠性边界</text><text x="55.0" y="424.9" text-anchor="start" style="font:500 12.2px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#655F57">这个机制依赖模型在提示词约束下正确标注延续关系(提示词第 7 条)。它比纯启发式(列数相近 / 宽度相近 / 表头相似)更可靠,因为模型看得到「这张表在页面底部被截断了」这个视觉事实;但它同样会漏标——因此代码的兜底策</text><text x="55.0" y="443.2" text-anchor="start" style="font:500 12.2px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#655F57">略是「没有标记就不拼」,宁可保留分页也不误拼。另外 _is_table_row 特意不只判断行首竖线:VLM 对跨页续表常省略行首 `|`,只看 startswith(&#x27;|&#x27;) 会把整段续表数据当成普通段落。</text></svg>
\ No newline at end of file \ No newline at end of file
<meta charset="utf-8"><style>html,body{margin:0;padding:0;background:#fff}svg{display:block;width:1600px}</style><svg xmlns="http://www.w3.org/2000/svg" viewBox="14.0 -6.0 1389.0 646.0" width="100%" preserveAspectRatio="xMidYMid meet" role="img" aria-label="Wiki 的三个动作与共同契约"><rect x="14.0" y="-6.0" width="1389.0" height="646.0" fill="#FCFAF6"/><defs><filter id="soft" x="-30%" y="-30%" width="170%" height="170%"><feDropShadow dx="0" dy="2.5" stdDeviation="4" flood-color="#8A7460" flood-opacity=".16"/></filter><marker id="ar_7A5EA8" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6.4" markerHeight="6.4" orient="auto-start-reverse"><path d="M0.6 1L9.4 5L0.6 9L2.6 5z" fill="#7A5EA8"/></marker><marker id="ar_2F8781" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6.4" markerHeight="6.4" orient="auto-start-reverse"><path d="M0.6 1L9.4 5L0.6 9L2.6 5z" fill="#2F8781"/></marker><marker id="ar_E0930F" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6.4" markerHeight="6.4" orient="auto-start-reverse"><path d="M0.6 1L9.4 5L0.6 9L2.6 5z" fill="#E0930F"/></marker><marker id="ar_918878" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6.4" markerHeight="6.4" orient="auto-start-reverse"><path d="M0.6 1L9.4 5L0.6 9L2.6 5z" fill="#918878"/></marker></defs><rect x="40.0" y="22.0" width="6.0" height="30.0" rx="3" fill="#D9622B"/><text x="58.0" y="42.0" text-anchor="start" style="font:800 22px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#2F2A24">Wiki 的三个动作围绕同一份权威页面闭环</text><text x="58.0" y="66.0" text-anchor="start" style="font:400 13px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#655F57">摄入产生资产,查询消费资产,维护修正资产;三者共享同一套 slug / Frontmatter / 来源标记契约</text><rect x="117.0" y="167.0" width="380.0" height="150.0" rx="14" fill="#7A5EA8" opacity="0.30"/><rect x="110.0" y="160.0" width="380.0" height="150.0" rx="14" fill="#FFFFFF" stroke="#7A5EA8" stroke-width="1.4" filter="url(#soft)"/><rect x="110.0" y="160.0" width="380" height="5.5" rx="2.7" fill="#7A5EA8"/><text x="300.0" y="196.0" text-anchor="middle" style="font:800 18px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#7A5EA8">摄入 Ingest</text><text x="300.0" y="226.0" text-anchor="middle" style="font:500 12.5px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#655F57">md / txt / docx / xlsx / pptx / pdf</text><text x="300.0" y="250.0" text-anchor="middle" style="font:500 12.5px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#655F57">→ 页面拓扑 + 12 字段头 + 正文</text><text x="300.0" y="274.0" text-anchor="middle" style="font:700 12.5px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#7A5EA8">成功 = 契约通过且一次性提交</text><rect x="557.0" y="167.0" width="380.0" height="150.0" rx="14" fill="#2F8781" opacity="0.30"/><rect x="550.0" y="160.0" width="380.0" height="150.0" rx="14" fill="#FFFFFF" stroke="#2F8781" stroke-width="1.4" filter="url(#soft)"/><rect x="550.0" y="160.0" width="380" height="5.5" rx="2.7" fill="#2F8781"/><text x="740.0" y="196.0" text-anchor="middle" style="font:800 18px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#2F8781">查询 Query</text><text x="740.0" y="226.0" text-anchor="middle" style="font:500 12.5px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#655F57">问题 → index.md 地图定位 slug</text><text x="740.0" y="250.0" text-anchor="middle" style="font:500 12.5px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#655F57">→ 直读 ≤3 页 + related 二跳</text><text x="740.0" y="274.0" text-anchor="middle" style="font:700 12.5px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#2F8781">答案必须带可点击的页面引用</text><rect x="997.0" y="167.0" width="380.0" height="150.0" rx="14" fill="#E0930F" opacity="0.30"/><rect x="990.0" y="160.0" width="380.0" height="150.0" rx="14" fill="#FFFFFF" stroke="#E0930F" stroke-width="1.4" filter="url(#soft)"/><rect x="990.0" y="160.0" width="380" height="5.5" rx="2.7" fill="#E0930F"/><text x="1180.0" y="196.0" text-anchor="middle" style="font:800 18px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#E0930F">维护 Maintain</text><text x="1180.0" y="226.0" text-anchor="middle" style="font:500 12.5px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#655F57">编辑 / lint / 重新摄入</text><text x="1180.0" y="250.0" text-anchor="middle" style="font:500 12.5px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#655F57">按来源摄出 + 字段归属重算</text><text x="1180.0" y="274.0" text-anchor="middle" style="font:700 12.5px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#E0930F">删一个来源不能误伤其他来源</text><rect x="418.0" y="438.0" width="660.0" height="176.0" rx="16" fill="#D9622B" opacity="0.30"/><rect x="410.0" y="430.0" width="660.0" height="176.0" rx="16" fill="#F4EDE2" stroke="#D9622B" stroke-width="1.4" filter="url(#soft)"/><text x="740.0" y="464.0" text-anchor="middle" style="font:800 16.5px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#A8461A">五项共同契约(三个动作都必须遵守)</text><text x="434.0" y="486.0" text-anchor="start" style="font:800 12.8px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#2F2A24">▸ slug / WikiType</text><text x="624.0" y="486.0" text-anchor="start" style="font:500 12.3px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#655F57">摄入定路径 · 查询定位 · 维护同步重命名</text><text x="434.0" y="509.0" text-anchor="start" style="font:800 12.8px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#2F2A24">▸ 12 字段 Frontmatter</text><text x="624.0" y="509.0" text-anchor="start" style="font:500 12.3px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#655F57">摄入落盘前校验 · 查询按字段防串味 · lint 复检</text><text x="434.0" y="532.0" text-anchor="start" style="font:800 12.8px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#2F2A24">▸ sources + field_sources</text><text x="624.0" y="532.0" text-anchor="start" style="font:500 12.3px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#655F57">摄入写账本 · 查询告知依据 · 摄出只撤销对应贡献</text><text x="434.0" y="555.0" text-anchor="start" style="font:800 12.8px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#2F2A24">▸ SOURCE_START/END</text><text x="624.0" y="555.0" text-anchor="start" style="font:500 12.3px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#655F57">包围来源正文块,使按来源精确删除成为可能</text><text x="434.0" y="578.0" text-anchor="start" style="font:800 12.8px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#2F2A24">▸ index.md</text><text x="624.0" y="578.0" text-anchor="start" style="font:500 12.3px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#655F57">入库后确定性重建 · 查询侧稳定前缀 · 维护保证一致</text><path d="M300.0 310.0L300.0 372.7L555.2 372.7L555.2 424.0" fill="none" stroke="#7A5EA8" stroke-width="1.9" stroke-linejoin="round" marker-end="url(#ar_7A5EA8)"/><path d="M740.0 310.0L740.0 372.7L740.0 372.7L740.0 424.0" fill="none" stroke="#2F8781" stroke-width="1.9" stroke-linejoin="round" marker-end="url(#ar_2F8781)"/><path d="M1180.0 310.0L1180.0 372.7L924.8 372.7L924.8 424.0" fill="none" stroke="#E0930F" stroke-width="1.9" stroke-linejoin="round" marker-end="url(#ar_E0930F)"/><path d="M492.0 235.0L548.0 235.0" fill="none" stroke="#918878" stroke-width="2.0" stroke-linejoin="round" marker-end="url(#ar_918878)"/><rect x="482.0" y="223.0" width="76.0" height="23.0" rx="11.5" fill="#FCFAF6" stroke="#918878" stroke-width="1.0" opacity="0.98"/><text x="520.0" y="239.3" text-anchor="middle" style="font:700 12px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#918878">页面即接口</text><path d="M932.0 235.0L988.0 235.0" fill="none" stroke="#918878" stroke-width="2.0" stroke-linejoin="round" marker-end="url(#ar_918878)"/><rect x="916.0" y="223.0" width="88.0" height="23.0" rx="11.5" fill="#FCFAF6" stroke="#918878" stroke-width="1.0" opacity="0.98"/><text x="960.0" y="239.3" text-anchor="middle" style="font:700 12px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#918878">反馈驱动修正</text><path d="M1180.0 150.0L1180.0 114.0L300.0 114.0L300.0 150.0" fill="none" stroke="#918878" stroke-width="2.0" stroke-linejoin="round" marker-end="url(#ar_918878)" stroke-dasharray="7,5"/><text x="740.0" y="106.0" text-anchor="middle" style="font:700 12.5px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#655F57">维护结果重新进入摄入:知识只增不减是不可维护的</text></svg>
\ No newline at end of file \ No newline at end of file
<meta charset="utf-8"><style>html,body{margin:0;padding:0;background:#fff}svg{display:block;width:1600px}</style><svg xmlns="http://www.w3.org/2000/svg" viewBox="14.0 -6.0 1367.0 802.0" width="100%" preserveAspectRatio="xMidYMid meet" role="img" aria-label="三阶段摄入时序"><rect x="14.0" y="-6.0" width="1367.0" height="802.0" fill="#FCFAF6"/><defs><filter id="soft" x="-30%" y="-30%" width="170%" height="170%"><feDropShadow dx="0" dy="2.5" stdDeviation="4" flood-color="#8A7460" flood-opacity=".16"/></filter><marker id="ar_3B6FB5" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6.4" markerHeight="6.4" orient="auto-start-reverse"><path d="M0.6 1L9.4 5L0.6 9L2.6 5z" fill="#3B6FB5"/></marker><marker id="ar_7A5EA8" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6.4" markerHeight="6.4" orient="auto-start-reverse"><path d="M0.6 1L9.4 5L0.6 9L2.6 5z" fill="#7A5EA8"/></marker><marker id="ar_2F8781" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6.4" markerHeight="6.4" orient="auto-start-reverse"><path d="M0.6 1L9.4 5L0.6 9L2.6 5z" fill="#2F8781"/></marker><marker id="ar_E0930F" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6.4" markerHeight="6.4" orient="auto-start-reverse"><path d="M0.6 1L9.4 5L0.6 9L2.6 5z" fill="#E0930F"/></marker><marker id="ar_4F8A3D" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6.4" markerHeight="6.4" orient="auto-start-reverse"><path d="M0.6 1L9.4 5L0.6 9L2.6 5z" fill="#4F8A3D"/></marker></defs><rect x="40.0" y="22.0" width="6.0" height="30.0" rx="3" fill="#D9622B"/><text x="58.0" y="42.0" text-anchor="start" style="font:800 22px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#2F2A24">一次短文档摄入的完整时序</text><text x="58.0" y="66.0" text-anchor="start" style="font:400 13px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#655F57">重点看两处:共享前缀在每次调用中逐字节一致;所有磁盘副作用集中在最后一段临界区</text><rect x="55.0" y="110.0" width="190.0" height="46.0" rx="10" fill="#FFFFFF" stroke="#3B6FB5" stroke-width="1.6"/><text x="150.0" y="130.0" text-anchor="middle" style="font:800 13.2px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#3B6FB5">接口层</text><text x="150.0" y="147.0" text-anchor="middle" style="font:500 11.6px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#918878">run_ingest_agent</text><line x1="150.0" y1="156.0" x2="150.0" y2="770.0" stroke="#E2D6C4" stroke-width="1.6" stroke-linecap="round" stroke-dasharray="5,6"/><rect x="325.0" y="110.0" width="190.0" height="46.0" rx="10" fill="#FFFFFF" stroke="#7A5EA8" stroke-width="1.6"/><text x="420.0" y="130.0" text-anchor="middle" style="font:800 13.2px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#7A5EA8">Planner</text><text x="420.0" y="147.0" text-anchor="middle" style="font:500 11.6px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#918878">qwen3.7-plus</text><line x1="420.0" y1="156.0" x2="420.0" y2="770.0" stroke="#E2D6C4" stroke-width="1.6" stroke-linecap="round" stroke-dasharray="5,6"/><rect x="605.0" y="110.0" width="190.0" height="46.0" rx="10" fill="#FFFFFF" stroke="#2F8781" stroke-width="1.6"/><text x="700.0" y="130.0" text-anchor="middle" style="font:800 13.2px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#2F8781">Writers ×N</text><text x="700.0" y="147.0" text-anchor="middle" style="font:500 11.6px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#918878">信号量 ≤20</text><line x1="700.0" y1="156.0" x2="700.0" y2="770.0" stroke="#E2D6C4" stroke-width="1.6" stroke-linecap="round" stroke-dasharray="5,6"/><rect x="885.0" y="110.0" width="190.0" height="46.0" rx="10" fill="#FFFFFF" stroke="#E0930F" stroke-width="1.6"/><text x="980.0" y="130.0" text-anchor="middle" style="font:800 13.2px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#E0930F">契约校验器</text><text x="980.0" y="147.0" text-anchor="middle" style="font:500 11.6px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#918878">ingest_contract</text><line x1="980.0" y1="156.0" x2="980.0" y2="770.0" stroke="#E2D6C4" stroke-width="1.6" stroke-linecap="round" stroke-dasharray="5,6"/><rect x="1160.0" y="110.0" width="190.0" height="46.0" rx="10" fill="#FFFFFF" stroke="#4F8A3D" stroke-width="1.6"/><text x="1255.0" y="130.0" text-anchor="middle" style="font:800 13.2px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#4F8A3D">磁盘 / DB</text><text x="1255.0" y="147.0" text-anchor="middle" style="font:500 11.6px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#918878">staging→正式</text><line x1="1255.0" y1="156.0" x2="1255.0" y2="770.0" stroke="#E2D6C4" stroke-width="1.6" stroke-linecap="round" stroke-dasharray="5,6"/><path d="M150.0 192.0L420.0 192.0" fill="none" stroke="#3B6FB5" stroke-width="1.9" stroke-linejoin="round" marker-end="url(#ar_3B6FB5)"/><text x="285.0" y="184.0" text-anchor="middle" style="font:700 11.8px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#3B6FB5">① 组装共享前缀:Skill + Schema 契约 + 原文(逐字节固定)</text><path d="M420.0 238.0L150.0 238.0" fill="none" stroke="#7A5EA8" stroke-width="1.9" stroke-linejoin="round" marker-end="url(#ar_7A5EA8)"/><text x="285.0" y="230.0" text-anchor="middle" style="font:700 11.8px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#7A5EA8">② 返回页面计划 JSON:type / slug / 路径 / global_dims / pages[]</text><path d="M156.0 284.0L214.0 284.0L214.0 314.0L162.0 314.0" fill="none" stroke="#3B6FB5" stroke-width="1.9" stroke-linejoin="round" marker-end="url(#ar_3B6FB5)"/><text x="224.0" y="303.0" text-anchor="start" style="font:600 11.8px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#3B6FB5">③ 结构校验:字段齐全?slug 冲突?路径合法?失败回喂错误重规划(≤2 次)</text><path d="M150.0 340.0L700.0 340.0" fill="none" stroke="#3B6FB5" stroke-width="1.9" stroke-linejoin="round" marker-end="url(#ar_3B6FB5)"/><text x="425.0" y="332.0" text-anchor="middle" style="font:700 11.8px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#3B6FB5">④ 扇出:同一份共享前缀 + 各自的页面任务(前缀之后才分叉)</text><path d="M700.0 386.0L980.0 386.0" fill="none" stroke="#2F8781" stroke-width="1.9" stroke-linejoin="round" marker-end="url(#ar_2F8781)"/><text x="840.0" y="378.0" text-anchor="middle" style="font:700 11.8px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#2F8781">⑤ 每页产出 Frontmatter + 正文,逐页送校验</text><path d="M980.0 432.0L700.0 432.0" fill="none" stroke="#E0930F" stroke-width="1.9" stroke-linejoin="round" marker-end="url(#ar_E0930F)"/><text x="840.0" y="424.0" text-anchor="middle" style="font:700 11.8px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#E0930F">⑥ 缺 required_extra / 枚举越界 → 带具体错误重试该页(≤4 次)</text><path d="M700.0 478.0L150.0 478.0" fill="none" stroke="#2F8781" stroke-width="1.9" stroke-linejoin="round" marker-end="url(#ar_2F8781)"/><text x="425.0" y="470.0" text-anchor="middle" style="font:700 11.8px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#2F8781">⑦ 全部页面通过;fail-fast:任一页异常立即中止整批</text><path d="M150.0 524.0L1255.0 524.0" fill="none" stroke="#3B6FB5" stroke-width="1.9" stroke-linejoin="round" marker-end="url(#ar_3B6FB5)"/><text x="702.5" y="516.0" text-anchor="middle" style="font:700 11.8px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#3B6FB5">⑧ 写 staging 临时目录 + 备份已存在的同名页面</text><path d="M150.0 570.0L1255.0 570.0" fill="none" stroke="#4F8A3D" stroke-width="1.9" stroke-linejoin="round" marker-end="url(#ar_4F8A3D)"/><text x="702.5" y="562.0" text-anchor="middle" style="font:700 11.8px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#4F8A3D">⑨ 全部 staging 成功 → 逐个 shutil.move 到正式路径</text><path d="M150.0 616.0L1255.0 616.0" fill="none" stroke="#4F8A3D" stroke-width="1.9" stroke-linejoin="round" marker-end="url(#ar_4F8A3D)"/><text x="702.5" y="608.0" text-anchor="middle" style="font:700 11.8px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#4F8A3D">⑩ 重建 index.md(全量,非追加)+ 追加 log.md + 落库任务状态</text><rect x="50.0" y="668.0" width="1305.0" height="74.0" rx="11" fill="#FBEAED" stroke="#B54A5B" stroke-width="1.3" stroke-dasharray="7,5"/><text x="70.0" y="694.0" text-anchor="start" style="font:800 13.5px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#8A3444">异常分支(⑧⑨ 任一步失败)</text><text x="70.0" y="718.0" text-anchor="start" style="font:500 12.2px 'Noto Sans SC','PingFang SC','Microsoft YaHei',-apple-system,'Segoe UI',sans-serif;fill:#655F57">把备份 shutil.move 回原路径 → finally 清空 staging 目录 → 正式仓库观察到的仍是完整旧版本,绝不出现「一半新一半旧」</text></svg>
\ No newline at end of file \ No newline at end of file
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!