Skip to content

World's first open-source enterprise world model.

Stop time-word scoring when its pipeline misses the readiness deadline (#1174)

Rudy Mizrahi Celekli8439f580f591
diff --git a/scripts/bench/timewords.mjs b/scripts/bench/timewords.mjs
index 11a8a77b..0a1109fa 100644
--- a/scripts/bench/timewords.mjs
+++ b/scripts/bench/timewords.mjs
@@ -37,16 +37,30 @@ async function run(n) {
const r = await fetch(`${BASE}/api/v1/kbs/${KB}/documents`, { method: "POST", headers: { cookie: cookieHeader() }, body: fd });
if (!r.ok) throw new Error(`upload ${d.filename} -> ${r.status} ${(await r.text()).slice(0, 200)}`);
}
- for (let i = 0; i < 60; i++) { await sleep(3000); if (q(`SELECT count(*) FROM documents WHERE kb_id='${KB}' AND status<>'ready'`) === "0") break; }
+ let documentsReady = false;
+ for (let i = 0; i < 60; i++) {
+ await sleep(3000);
+ if (q(`SELECT count(*) FROM documents WHERE kb_id='${KB}' AND status<>'ready'`) === "0") {
+ documentsReady = true;
+ break;
+ }
+ }
+ if (!documentsReady) throw new Error(`Documents for ${KB} did not finish processing before the benchmark timeout`);
// 管线解析完自己排抽取;手动抽取是强制全量,只补没排上的,否则每篇抽两遍
for (const d of (await api("GET", `/api/v1/kbs/${KB}/documents?limit=50`)).docs) {
if (!["queued", "extracting", "done"].includes(d.graph_status)) await api("POST", `/api/v1/documents/${d.id}/extract`, {});
}
+ let extractionReady = false;
for (let i = 0; i < 240; i++) {
await sleep(5000);
const pending = q(`SELECT count(*) FROM jobs WHERE status IN ('queued','running') AND kind IN ('extract_document','resolve_time','process_document') AND (payload->>'kb_id'='${KB}' OR payload->>'document_id' IN (SELECT id::text FROM documents WHERE kb_id='${KB}'))`);
- if (pending === "0" && i > 3) break;
+ if (pending === "0" && i > 3) {
+ extractionReady = true;
+ break;
+ }
}
+ // An unfinished pipeline is missing evidence, not a measured extraction miss.
+ if (!extractionReady) throw new Error(`Extraction for ${KB} did not finish before the benchmark timeout`);
// 每句话:这篇文档里出处引文含 key 的开放陈述
const rows = [];
for (const d of corpus.docs) for (const e of d.expect) {