export

package
v0.8.0-beta.22 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 10, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package export writes the assembled graph to disk. graph.json is the primary artifact (committed by CI, read by the query commands and the Claude skill); it uses the same NetworkX node-link shape as the Python original so existing tooling keeps working.

Index

Constants

This section is empty.

Variables

View Source
var ErrGraphShrink = errors.New("refusing to overwrite graph.json with a smaller graph")

ErrGraphShrink is returned by ToJSON when writing would replace an existing, larger graph.json with one that has fewer nodes and force is false. The guard exists to avoid silently losing nodes (#479) — e.g. missing chunk files from a prior session, or a dedup pass that collapsed same-named symbols on an --update.

View Source
var ErrGraphUnverifiable = errors.New("refusing to overwrite unparseable graph.json")

ErrGraphUnverifiable is returned by ToJSON when a non-empty existing graph.json cannot be parsed to verify the new graph is not a silent shrink. Fail SAFE: refuse rather than clobber a possibly-good graph over a transient read/parse failure. Pass force to override.

Functions

func CSVFromJSON added in v0.3.0

func CSVFromJSON(jsonPath, nodesPath, edgesPath string) error

CSVFromJSON writes the graph's nodes and edges to two CSV files.

func CheckShrink added in v0.8.1

func CheckShrink(path string, g *model.Graph, skipped map[string]bool, force bool) error

CheckShrink decides whether writing g over an existing graph.json at path would silently drop nodes, distinguishing a legitimate refactor/deletion shrink from a suspicious one. It mirrors upstream watch._check_shrink: the crude node-count guard in ToJSON cannot tell the two apart, so callers that know which sources were rebuilt this run call CheckShrink first and then ToJSON with force=true.

A net shrink is legitimate when every node that would be lost belongs to a source file that was (re)built or removed this run — none belong to skipped, the current source files that FAILED to process this run. A lost node from a skipped file is the silent loss (#479) worth refusing. CheckShrink returns nil when the write is safe (force set; no readable/non-empty graph on disk; the new graph is not smaller; or every lost node is accounted), ErrGraphShrink when a lost node's source file was skipped, or ErrGraphUnverifiable when a non-empty existing graph.json cannot be parsed to make the comparison. It never writes.

func DOTFromJSON added in v0.3.0

func DOTFromJSON(jsonPath, outPath string) error

DOTFromJSON writes the graph at jsonPath to outPath as a Graphviz digraph.

func GraphMLFromJSON added in v0.3.0

func GraphMLFromJSON(jsonPath, outPath string) error

GraphMLFromJSON writes the graph at jsonPath to outPath as GraphML.

func OKFFromJSON added in v0.6.0

func OKFFromJSON(jsonPath, outDir string) error

OKFFromJSON writes an OKF bundle for the graph at jsonPath into outDir.

func ToJSON

func ToJSON(g *model.Graph, communities map[int][]string, path, builtAtCommit string, force bool) error

ToJSON writes the graph to path in NetworkX node-link format with per-node community/norm_label and per-link confidence_score, plus the commit it was built from (for staleness checks).

Unless force is set, ToJSON refuses to overwrite an existing, non-empty graph.json when doing so would drop nodes: it returns ErrGraphShrink when the new graph has fewer nodes than the one on disk, or ErrGraphUnverifiable when the existing file cannot be parsed to make that comparison. In both cases the file on disk is left untouched. An absent or empty target is written normally.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL