diffSnapshots (graph/diff.ts)

hivemind · src/graph/diff.ts · typescript · Apache-2.0
database

Computes differences between two graph snapshots, returning added/removed nodes and edges.

// Source: https://github.com/activeloopai/hivemind | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * Snapshot diff (Phase 1.5).
 *
 * Loads two snapshots by commit SHA from a per-repo storage directory and
 * computes set differences on nodes and edges:
 *   - Nodes by `id`
 *   - Edges by canonical key `(source, target, relation, ord ?? 0)`
 *
 * Pure: no I/O outside the explicit load functions; safe to call from tests
 * with snapshots passed in as plain objects.
 */

import { existsSync, readFileSync } from "node:fs";
import { join } from "node:path";

import type { GraphEdge, GraphNode, GraphSnapshot } from "./types.js";

/** A node present in both snapshots whose declar

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key