Graphify-Labs/graphify · error · SystemExit
ERROR: refused to shrink graphify-out/graph.json (existing g
Error message
ERROR: refused to shrink graphify-out/graph.json (existing graph has more nodes; #479).
What it means
Export-time shrink-guard (#479). graphify.export.to_json() returns False (no write) when the new graph is smaller than the existing graphify-out/graph.json; this wrapper prints the ERROR and exits 1, and only writes GRAPH_REPORT.md and .graphify_analysis.json when the graph was actually persisted (#1392).
Source
Thrown at tools/skillgen/expected/graphify__skill-opencode.md:429
raise SystemExit(1)
communities = cluster(G)
cohesion = score_all(G, communities)
tokens = {'input': extraction.get('input_tokens', 0), 'output': extraction.get('output_tokens', 0)}
gods = god_nodes(G)
surprises = surprising_connections(G, communities)
labels = {cid: 'Community ' + str(cid) for cid in communities}
# Placeholder questions - regenerated with real labels in Step 5
questions = suggest_questions(G, communities, labels)
# Export FIRST and honor the #479 shrink-guard: to_json returns False (writing
# nothing) when the new graph is smaller than the existing graph.json. Only write
# GRAPH_REPORT.md + the analysis sidecar when the graph was actually written, so
# they never describe a graph that graph.json doesn't contain (#1392).
wrote = to_json(G, communities, 'graphify-out/graph.json')
if not wrote:
print('ERROR: refused to shrink graphify-out/graph.json (existing graph has more nodes; #479).')
print('If this shrink is intentional (you deleted files), re-run a full build with --force.')
raise SystemExit(1)
report = generate(G, communities, cohesion, labels, gods, surprises, detection, tokens, 'INPUT_PATH', suggested_questions=questions)
Path('graphify-out/GRAPH_REPORT.md').write_text(report, encoding=\"utf-8\")
analysis = {
'communities': {str(k): v for k, v in communities.items()},
'cohesion': {str(k): v for k, v in cohesion.items()},
'gods': gods,
'surprises': surprises,
'questions': questions,
}
Path('graphify-out/.graphify_analysis.json').write_text(json.dumps(analysis, indent=2, ensure_ascii=False), encoding=\"utf-8\")
print(f'Graph: {G.number_of_nodes()} nodes, {G.number_of_edges()} edges, {len(communities)} communities')
"
```
If this step prints `ERROR: Graph is empty`, stop and tell the user what happened - do not proceed to labeling or visualization.
Replace INPUT_PATH with the actual path.
View on GitHub (pinned to 7fe58b0b0f)
Solutions
- If the shrink is intentional, re-run a full build with --force.
- Ensure INPUT_PATH equals the original build root.
- Locate dropped files by comparing extraction and graph.json node counts.
- Rebuild from a clean graphify-out/ if state is stale.
Defensive patterns
Strategy: validation
Validate before calling
import json
from pathlib import Path
existing = Path('graphify-out/graph.json')
if existing.exists():
old = len(json.loads(existing.read_text(encoding='utf-8')).get('nodes', []))
if G.number_of_nodes() < old:
raise SystemExit('shrink refused - full rebuild with --force needed') Prevention
- Force-rebuild after source deletions.
- Keep the build root identical across runs.
- Gate report/sidecar writes on to_json() returning True.
- Clean stale outputs when switching input sets.
When it happens
Trigger: to_json() called with a graph that has fewer nodes than the existing graph.json — source files deleted since last build, smaller input root, or extraction losses.
Common situations: Rebuild after cleanup; building a subset of the tree; partial extraction; stale larger graph.json.
Related errors
- ERROR: refused to shrink graphify-out/graph.json (existing g
- ERROR: refused to shrink graphify-out/graph.json (existing g
- ERROR: refused to shrink graphify-out/graph.json (fewer node
- ERROR: refused to shrink graphify-out/graph.json (existing g
- ERROR: refused to shrink graphify-out/graph.json (existing g
AI-assisted analysis of Graphify-Labs/graphify@7fe58b0b0f (2026-08-14).
Data as JSON: /api/errors/046e1f7f53cf8bc1.
Report an issue: GitHub.