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
The #479 shrink-guard error in the claw render of the graphify skill: to_json() refuses to overwrite an existing graphify-out/graph.json with a smaller graph and returns False; the Step 4 block detects that and exits with this message (including the --force guidance) before writing GRAPH_REPORT.md or the analysis sidecar (#1392).
Source
Thrown at tools/skillgen/expected/graphify__skill-claw.md:437
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: full rebuild with --force, or delete graphify-out/graph.json and re-run Step 4
- Unintentional: audit .graphify_extract.json for missing sources and re-run extraction
- Review .graphifyignore and recent deletions for the cause of the node-count drop
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(encoding='utf-8'))['nodes']) if graph_path.exists() else -1
if existing >= 0 and G.number_of_nodes() < existing:
if not SHRINK_INTENTIONAL:
raise SystemExit('shrink detected — audit extraction first')
graph_path.unlink()
wrote = to_json(G, communities, 'graphify-out/graph.json') Prevention
- Run the full --force rebuild after intentional deletions
- Never point an incremental update at a different (smaller) path over an existing graphify-out/
- Correlate node-count drops with .graphifyignore edits or extraction errors before overriding the guard
When it happens
Trigger: Running the claw skill's Step 4 when the rebuilt graph has fewer nodes than the existing graph.json — file deletions, widened ignore patterns, partial extraction failures, or a smaller INPUT_PATH over stale outputs.
Common situations: Post-refactor incremental builds; changed input scope without cleaning graphify-out/; extraction dropping files.
Related errors
- ERROR: refused to shrink graphify-out/graph.json (fewer node
- 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
- cannot stat {p}: {exc}
AI-assisted analysis of Graphify-Labs/graphify@7fe58b0b0f (2026-08-14).
Data as JSON: /api/errors/61c478599ce37698.
Report an issue: GitHub.