From 412d3f7df6a6524d93165160674a66624ed30f33 Mon Sep 17 00:00:00 2001 From: sb-iam <59984144+sb-iam@users.noreply.github.com> Date: Sat, 27 Jun 2026 21:03:57 -0700 Subject: [PATCH] tune(graph): de-noise the live materializer Verified materializePodGraph against real demo-pod data (joins all connect: 21/21 interventions->collisions, learned_from produced). Tuning: - engineer nodes are case-insensitive (merges Shakthi/shakthi) - git (engineer_states) now only CONFIRMS editing on files vision/collisions already surfaced, instead of adding the whole repo diff (killed a 29-file node explosion from a watcher running against the full podman repo) Cut demo-pod from 110 -> 77 nodes; git file-edges 39 -> 6. Co-Authored-By: Claude Opus 4.8 --- backend/src/graph/live.ts | 41 ++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/backend/src/graph/live.ts b/backend/src/graph/live.ts index 377b1b3..e4cf481 100644 --- a/backend/src/graph/live.ts +++ b/backend/src/graph/live.ts @@ -60,7 +60,7 @@ function upsertNode( key: string, patch: Partial>, ): string { - const id = nodeKey(kind, key); + const id = nodeKey(kind, kind === 'engineer' ? key.toLowerCase() : key); const cur = b.nodes.get(id); if (!cur) { b.nodes.set(id, { @@ -158,24 +158,7 @@ export async function materializePodGraph(podId: string): Promise 0 ? 'risk' : 'active', - summary: files.length - ? `${files.length} changed file(s) on ${git.branch ?? 'detached'}` - : `on ${git.branch ?? 'detached'}`, - weight: 0.7, - }); - for (const file of files) { - const f = upsertNode(b, 'file', file, { label: file, status: 'risk' }); - upsertEdge(b, eng, f, 'editing', 'edits', 0.6); - } - } - - // 3. Vision (observations): who is active and on which file, with confidence. + // 2. Vision (observations): who is active and on which file, with confidence. for (const o of observations) { if (!o.engineerId) continue; const recent = o.observedAt && now - new Date(o.observedAt).getTime() < ACTIVE_WINDOW_MS; @@ -190,7 +173,7 @@ export async function materializePodGraph(podId: string): Promise(); for (const col of collisionDocs) { collisionById.set(col.id, col); @@ -211,6 +194,24 @@ export async function materializePodGraph(podId: string): Promise 0 ? 'risk' : 'active', + summary: files.length + ? `${files.length} changed file(s) on ${git.branch ?? 'detached'}` + : `on ${git.branch ?? 'detached'}`, + weight: 0.7, + }); + for (const file of files) { + const fid = nodeKey('file', file); + if (b.nodes.has(fid)) upsertEdge(b, eng, fid, 'editing', 'edits', 0.6); + } + } + // 5. Interventions: what PodMan offered for each collision. const interventionById = new Map(); for (const iv of interventionDocs) {