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
Deliberate shrink-guard (#479) in the graphify build export step. to_json(G, communities, 'graphify-out/graph.json') returns False without writing when the new graph has fewer nodes than the existing graph.json; the wrapper prints this ERROR, exits 1, and skips writing GRAPH_REPORT.md and .graphify_analysis.json so no artifact misdescribes the persisted graph (#1392).
Source
Thrown at tools/skillgen/expected/graphify__skill-droid.md:434
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
- Intentional shrink: re-run a full build with --force to overwrite graph.json.
- Verify INPUT_PATH matches the original build root.
- Compare new vs existing node counts to find which files dropped out of extraction.
- Remove graphify-out/ and rebuild from scratch if the state is stale.
Example fix
# before: shrink refused
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).')
raise SystemExit(1)
# after: intentional shrink -> full rebuild with --force 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(f'shrink {old}->{G.number_of_nodes()} refused; use --force full rebuild if intentional') Prevention
- Rebuild with --force after intentional source deletions.
- Use a stable INPUT_PATH across builds.
- Act on to_json() == False immediately; do not write derived artifacts.
- Clean stale graphify-out/ directories when switching branches or roots.
When it happens
Trigger: Exporting a graph smaller than the on-disk graph.json: rebuild after source deletion, INPUT_PATH pointing at a smaller tree than the original build, or extraction dropping files.
Common situations: Post-prune rebuilds; building a subdirectory against a repo-root graph.json; partial re-extracts; stale larger graph.json from earlier work.
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/b42f1653e4259c90.
Report an issue: GitHub.