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 ¶
- Variables
- func CSVFromJSON(jsonPath, nodesPath, edgesPath string) error
- func CheckShrink(path string, g *model.Graph, skipped map[string]bool, root string, force bool) error
- func DOTFromJSON(jsonPath, outPath string) error
- func GraphMLFromJSON(jsonPath, outPath string) error
- func OKFFromJSON(jsonPath, outDir string) error
- func ToJSON(g *model.Graph, communities map[int][]string, path, builtAtCommit string, ...) error
Constants ¶
This section is empty.
Variables ¶
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.
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
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, root string, 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 that was rebuilt in place (its file is still in the new graph) or truly deleted (its file is gone from disk). Two cases are refused as silent loss: a lost node whose source FAILED to process this run (it is in skipped, #479), and a lost node whose source left the corpus yet still exists on disk — it was EXCLUDED (e.g. a new .gitignore/.graphifyignore rule), not deleted, so eviction would be data loss (fail-closed, #1795). 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 for a skipped or excluded-but-present source, or ErrGraphUnverifiable when a non-empty existing graph.json cannot be parsed to make the comparison. It never writes. root is the project root, used to resolve a lost node's (root-relative) source path for the on-disk existence check.
func DOTFromJSON ¶ added in v0.3.0
DOTFromJSON writes the graph at jsonPath to outPath as a Graphviz digraph.
func GraphMLFromJSON ¶ added in v0.3.0
GraphMLFromJSON writes the graph at jsonPath to outPath as GraphML.
func OKFFromJSON ¶ added in v0.6.0
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.