Graphify-Labs/graphify · error · SystemExit
ERROR: refused to shrink graphify-out/graph.json (fewer node
Error message
ERROR: refused to shrink graphify-out/graph.json (fewer nodes than the existing graph). Run a full rebuild to be safe.
What it means
The shrink-guard error in the generated aider render of the graphify skill: to_json() returns False instead of writing when the new graph has fewer nodes than the existing graph.json (#479), and the Step 4 block exits with this message before writing GRAPH_REPORT.md or .graphify_analysis.json (#1392 — a report must never describe a graph that was not persisted). The expected-render wording differs slightly ('fewer nodes than the existing graph. Run a full rebuild to be safe.') and predates the --force hint.
Source
Thrown at tools/skillgen/expected/graphify__skill-aider.md:428
print('ERROR: Graph is empty - extraction produced no nodes.')
print('Possible causes: all files were skipped, binary-only corpus, or extraction failed.')
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)
# Persist the graph first and only write the report/analysis if it actually
# persisted - to_json refuses to shrink an existing graph.json (#479), and a
# report describing a graph we did not write would be a lie (#1392).
wrote = to_json(G, communities, 'graphify-out/graph.json')
if not wrote:
print('ERROR: refused to shrink graphify-out/graph.json (fewer nodes than the existing graph). Run a full rebuild to be safe.')
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)
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_analysis.json').write_text(json.dumps(analysis, indent=2))
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 intended, do a full rebuild: delete graphify-out/graph.json (or the whole graphify-out/) and re-run the build block
- If unintended, diff the node sources: check .graphify_extract.json for files that failed to extract and re-run extraction
- Review .graphifyignore changes that may have excluded previously indexed files
Example fix
# before
wrote = to_json(G, communities, 'graphify-out/graph.json')
# → ERROR: refused to shrink (fewer nodes than existing graph)
# after (intentional shrink)
Path('graphify-out/graph.json').unlink() # or full rebuild with --force in the current skill
wrote = to_json(G, communities, 'graphify-out/graph.json') Defensive patterns
Strategy: fallback
Validate before calling
from pathlib import Path
import json
graph_path = Path('graphify-out/graph.json')
existing = len(json.loads(graph_path.read_text())['nodes']) if graph_path.exists() else -1
if existing >= 0 and G.number_of_nodes() < existing:
if SHRINK_INTENTIONAL:
graph_path.unlink() # allow the smaller graph to be written
else:
raise SystemExit('node count dropped — investigate extraction before writing') Prevention
- Run a full rebuild (delete graphify-out/) whenever the source tree shrank on purpose
- Compare node counts before to_json() so shrink decisions are explicit, not discovered via the error
- Never mix graph.json from one run with sidecars from another — rebuild produces all three atomically
When it happens
Trigger: Running the aider skill's Step 4 build when the freshly built graph has fewer nodes than graphify-out/graph.json — deleted/renamed sources, expanded .graphifyignore, partially failed extraction, or building a smaller subpath over an existing graphify-out/.
Common situations: Post-cleanup incremental builds; switching input paths without clearing graphify-out/; extraction where some files errored; dedup collapsing node count.
Related errors
- ERROR: refused to shrink graphify-out/graph.json (existing g
- ERROR: refused to shrink graphify-out/graph.json (existing g
- module {__name__!r} has no attribute {name!r}
- Cannot read graph file {path}: {exc}. Re-run 'graphify extra
- ERROR: sections file must contain a JSON array: {path}
AI-assisted analysis of Graphify-Labs/graphify@7fe58b0b0f (2026-08-14).
Data as JSON: /api/errors/8283ead8d36badec.
Report an issue: GitHub.