From e82235e1dfc29bc33a996e844fc0d99d3c9e84e6 Mon Sep 17 00:00:00 2001 From: Nikola Chetelyazov Date: Mon, 13 Apr 2026 09:49:47 +0300 Subject: [PATCH] refactor: return shallow copies of nodes and edges from build() build() was returning direct references to the builder's internal arrays, allowing callers to mutate graph.nodes or graph.edges and corrupt the builder's state. Spreading into new arrays at build time prevents this at negligible cost. --- .../packages/core/src/analyzer/graph-builder.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/understand-anything-plugin/packages/core/src/analyzer/graph-builder.ts b/understand-anything-plugin/packages/core/src/analyzer/graph-builder.ts index e2dd645..8aa73b1 100644 --- a/understand-anything-plugin/packages/core/src/analyzer/graph-builder.ts +++ b/understand-anything-plugin/packages/core/src/analyzer/graph-builder.ts @@ -412,8 +412,8 @@ export class GraphBuilder { analyzedAt: new Date().toISOString(), gitCommitHash: this.gitHash, }, - nodes: this.nodes, - edges: this.edges, + nodes: [...this.nodes], + edges: [...this.edges], layers: [], tour: [], };