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 at the graphify build export step. When to_json() would write a graph smaller than the existing graphify-out/graph.json, it returns False without writing; the wrapper prints this ERROR and exits 1 before the report and analysis sidecar are generated, keeping all artifacts consistent (#1392).

Source

Thrown at tools/skillgen/expected/graphify__skill-kilo.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

  1. If intentional, re-run a full build with --force.
  2. Align INPUT_PATH with the original build root.
  3. Identify dropped files by diffing extraction node counts against graph.json.
  4. Delete graphify-out/ and rebuild fresh if state is inconsistent.
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 required')

Prevention

When it happens

Trigger: to_json(G, communities, 'graphify-out/graph.json') returning False because the newly built graph has fewer nodes than the existing file — file deletions, smaller input root, or extraction losses.

Common situations: Rebuilding after code cleanup; subdirectory build vs repo-root graph.json; partial extraction; stale artifacts.

Related errors


AI-assisted analysis of Graphify-Labs/graphify@7fe58b0b0f (2026-08-14). Data as JSON: /api/errors/0ad930516c127734. Report an issue: GitHub.