From 827647c2f410fb8e176894e902904b8624d68ef4 Mon Sep 17 00:00:00 2001 From: amosblomqvist Date: Tue, 8 Sep 2026 22:41:57 +0300 Subject: [PATCH 1/2] backfill script: optional single-chat arg (used to retry the Nietzsche extraction after an auditor non-submission) --- scripts/backfill-graph.ts | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 scripts/backfill-graph.ts diff --git a/scripts/backfill-graph.ts b/scripts/backfill-graph.ts new file mode 100644 index 0000000..194addc --- /dev/null +++ b/scripts/backfill-graph.ts @@ -0,0 +1,36 @@ +/** + * One-time backfill: wipe the legacy ledgers and re-extract every chat with + * the redesigned pipeline (vision §1, commit b07c907). Run from the master + * tree only — data never crosses trees: + * + * npx tsx --env-file=.env.local scripts/backfill-graph.ts + */ +import { chatStore } from "../src/store/chats.ts"; +import { graphStore } from "../src/store/graph.ts"; +import { createExtractionPipeline } from "../src/agent/subagents/extraction.ts"; +import { getGraph } from "../src/core/graph.ts"; + +async function main() { + const only = process.argv[2]; // optional: extract just one chat id + const chats = only ? chatStore.listChats().filter((c) => c.id === only) : chatStore.listChats(); + console.log(`[backfill] ${chats.length} chats to extract`); + const pipeline = createExtractionPipeline({ chatStore, graphStore }); + for (const chat of chats) { + const t0 = Date.now(); + try { + const stats = await pipeline.runExtraction(chat.id); + console.log( + `[backfill] ${chat.id} (${chat.title.slice(0, 40)}): ` + + `${stats.nodes} nodes, ${stats.edges} edges, ${stats.events} events in ${((Date.now() - t0) / 1000).toFixed(1)}s`, + ); + } catch (err) { + console.error(`[backfill] ${chat.id} FAILED:`, err); + } + } + const graph = getGraph(graphStore); + console.log( + `[backfill] done: ${graph.nodes.length} nodes, ${graph.edges.length} edges, ${graph.events.length} events`, + ); +} + +main(); From a4fb25cbcc16483b23d43aa1fa4e7513ab6d0d20 Mon Sep 17 00:00:00 2001 From: amosblomqvist Date: Tue, 8 Sep 2026 22:42:13 +0300 Subject: [PATCH 2/2] chore: next-env.d.ts churn --- next-env.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/next-env.d.ts b/next-env.d.ts index ce4e94a..a419cbe 100644 --- a/next-env.d.ts +++ b/next-env.d.ts @@ -1,7 +1,7 @@ /// /// -import "./.next/types/routes.d.ts"; -import "./.next/types/root-params.d.ts"; +import "./.next/dev/types/routes.d.ts"; +import "./.next/dev/types/root-params.d.ts"; // NOTE: This file should not be edited // see https://nextjs.org/docs/app/api-reference/config/typescript for more information.