Skip to content

LLM Wiki is a cross-platform desktop application that turns your documents into an organized, interlinked knowledge base — automatically. Instead of traditional RAG (retrieve-and-answer from scratch every time), the LLM incrementally builds and maintains a persistent wiki from your sources。

TypeScript

fix: fail incomplete ingest output

nash_su07e0f36df2ba
diff --git a/src/lib/ingest-source-path-collision.test.ts b/src/lib/ingest-source-path-collision.test.ts
index a926ace1..d1987d59 100644
--- a/src/lib/ingest-source-path-collision.test.ts
+++ b/src/lib/ingest-source-path-collision.test.ts
@@ -690,6 +690,37 @@ describe("autoIngest source summary paths", () => {
).toBe(true)
})
+ it("rejects an ingest when a truncated FILE block cannot be repaired", async () => {
+ if (!tmp) throw new Error("missing temp project")
+ sourceMarkers = ["project-a config"]
+ generationSuffix = [
+ "",
+ "---FILE: wiki/concepts/incomplete.md---",
+ "---",
+ 'title: "Incomplete concept"',
+ 'sources: ["project-a/config.yaml"]',
+ "---",
+ "",
+ "# Incomplete concept",
+ "",
+ "This response was cut off",
+ ].join("\n")
+ truncatedRepairResponse = ""
+
+ await expect(autoIngest(
+ tmp.path,
+ `${tmp.path}/raw/sources/project-a/config.yaml`,
+ useWikiStore.getState().llmConfig,
+ undefined,
+ "project-a",
+ )).rejects.toThrow("Ingest incomplete")
+
+ const activity = useActivityStore.getState().items[0]
+ expect(activity.status).toBe("error")
+ expect(activity.detail).toContain("could not be repaired")
+ expect(activity.detail).toContain("wiki/concepts/incomplete.md")
+ })
+
it("propagates cancellation that happens during the dedicated review stage", async () => {
if (!tmp) throw new Error("missing temp project")
sourceMarkers = ["project-a config"]
diff --git a/src/lib/ingest.ts b/src/lib/ingest.ts
index a1a7f6ec..e6761d5d 100644
--- a/src/lib/ingest.ts
+++ b/src/lib/ingest.ts
@@ -1325,7 +1325,34 @@ async function autoIngestImpl(
}
}
+ // A partial write is not a successful ingest. Keep the generated files on
+ // disk so a retry can merge/repair them, but do not cache or embed the
+ // incomplete result. Throwing here keeps the queue task visible as
+ // pending/failed instead of removing it as "done" while Sources reports the
+ // same file as not ingested.
+ if (hardFailures.length > 0 || unrecoveredTruncatedPaths.length > 0) {
+ const reasons = [
+ hardFailures.length > 0
+ ? `${hardFailures.length} wiki file write failure(s)`
+ : "",
+ unrecoveredTruncatedPaths.length > 0
+ ? `${unrecoveredTruncatedPaths.length} truncated wiki file(s) could not be repaired: ${unrecoveredTruncatedPaths.join(", ")}`
+ : "",
+ ].filter(Boolean)
+ const message = `Ingest incomplete: ${reasons.join("; ")}`
+ activity.updateItem(activityId, {
+ status: "error",
+ detail: warningSummary
+ ? `${message} — ${warningSummary} (saved to .llm-wiki/ingest-warnings.log)`
+ : message,
+ filesWritten: writtenPaths,
+ })
+ throw new Error(message)
+ }
+
// ── Step 4: Parse review items ────────────────────────────────
+ // Do this only after the completeness gate above. Otherwise every queue
+ // retry could duplicate review items derived from the same partial output.
throwIfIngestAborted(signal, activityId)
const reviewItems = [
...parseReviewBlocks(generation, sp),