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.
This commit is contained in:
Nikola Chetelyazov
2026-04-13 09:49:47 +03:00
Unverified
parent ef0c65aa17
commit e82235e1df
@@ -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: [],
};