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 <noreply@anthropic.com>
This commit is contained in:
+21
-20
@@ -60,7 +60,7 @@ function upsertNode(
|
|||||||
key: string,
|
key: string,
|
||||||
patch: Partial<Omit<PodGraphNode, 'id' | 'kind' | 'x' | 'y'>>,
|
patch: Partial<Omit<PodGraphNode, 'id' | 'kind' | 'x' | 'y'>>,
|
||||||
): string {
|
): string {
|
||||||
const id = nodeKey(kind, key);
|
const id = nodeKey(kind, kind === 'engineer' ? key.toLowerCase() : key);
|
||||||
const cur = b.nodes.get(id);
|
const cur = b.nodes.get(id);
|
||||||
if (!cur) {
|
if (!cur) {
|
||||||
b.nodes.set(id, {
|
b.nodes.set(id, {
|
||||||
@@ -158,24 +158,7 @@ export async function materializePodGraph(podId: string): Promise<PodGraph | nul
|
|||||||
upsertNode(b, 'engineer', name, { label: name });
|
upsertNode(b, 'engineer', name, { label: name });
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Git truth (engineer_states): unpushed work + edited files.
|
// 2. Vision (observations): who is active and on which file, with confidence.
|
||||||
for (const [name, git] of gitStates) {
|
|
||||||
const files = git.changedFiles.map(parseGitStatusPath).filter(Boolean);
|
|
||||||
const eng = upsertNode(b, 'engineer', name, {
|
|
||||||
label: name,
|
|
||||||
status: files.length > 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.
|
|
||||||
for (const o of observations) {
|
for (const o of observations) {
|
||||||
if (!o.engineerId) continue;
|
if (!o.engineerId) continue;
|
||||||
const recent = o.observedAt && now - new Date(o.observedAt).getTime() < ACTIVE_WINDOW_MS;
|
const recent = o.observedAt && now - new Date(o.observedAt).getTime() < ACTIVE_WINDOW_MS;
|
||||||
@@ -190,7 +173,7 @@ export async function materializePodGraph(podId: string): Promise<PodGraph | nul
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. Collisions: the detected overlaps (fused git + vision).
|
// 3. Collisions: the detected overlaps (fused git + vision).
|
||||||
const collisionById = new Map<string, (typeof collisionDocs)[number]>();
|
const collisionById = new Map<string, (typeof collisionDocs)[number]>();
|
||||||
for (const col of collisionDocs) {
|
for (const col of collisionDocs) {
|
||||||
collisionById.set(col.id, col);
|
collisionById.set(col.id, col);
|
||||||
@@ -211,6 +194,24 @@ export async function materializePodGraph(podId: string): Promise<PodGraph | nul
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 4. Git truth (engineer_states): mark unpushed work and confirm editing on
|
||||||
|
// files vision/collisions already surfaced — not the whole repo diff.
|
||||||
|
for (const [name, git] of gitStates) {
|
||||||
|
const files = git.changedFiles.map(parseGitStatusPath).filter(Boolean);
|
||||||
|
const eng = upsertNode(b, 'engineer', name, {
|
||||||
|
label: name,
|
||||||
|
status: files.length > 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.
|
// 5. Interventions: what PodMan offered for each collision.
|
||||||
const interventionById = new Map<string, (typeof interventionDocs)[number]>();
|
const interventionById = new Map<string, (typeof interventionDocs)[number]>();
|
||||||
for (const iv of interventionDocs) {
|
for (const iv of interventionDocs) {
|
||||||
|
|||||||
Reference in New Issue
Block a user