Skip to content

extract no-op incremental run overwrites graph with empty graph #1347

Closed

Description

@pkudinov

Summary

graphify extract <path> --no-cluster --out <path> can overwrite an existing graph with an empty graph on a no-op incremental run.

The first run builds a valid code graph. The second run detects 0 changed files, but still writes graphify-out/graph.json with 0 nodes, 0 edges.

This is dangerous for CI / cached graph workflows because a no-op refresh destroys the usable graph.

Minimal repro

repo=$(mktemp -d /tmp/graphify-extract-noop.XXXXXX)
mkdir -p "$repo/src"
cat > "$repo/src/a.ts" <<'TS'
export function answer() { return 42; }
TS

# First run creates a valid graph.
graphify extract "$repo" --no-cluster --out "$repo" --max-workers 1
python3 - <<PY
import json
from pathlib import Path
p = Path("$repo") / "graphify-out" / "graph.json"
data = json.loads(p.read_text())
print("first", len(data.get("nodes", [])), len(data.get("links", data.get("edges", []))))
PY

# Second run has no changed files but overwrites the graph with an empty one.
graphify extract "$repo" --no-cluster --out "$repo" --max-workers 1
python3 - <<PY
import json
from pathlib import Path
p = Path("$repo") / "graphify-out" / "graph.json"
data = json.loads(p.read_text())
print("second", len(data.get("nodes", [])), len(data.get("links", data.get("edges", []))))
PY

Observed output

[graphify extract] scanning /tmp/graphify-extract-noop...
[graphify extract] found 1 code, 0 docs, 0 papers, 0 images
[graphify extract] AST extraction on 1 code files...
[graphify extract] wrote .../graphify-out/graph.json — 2 nodes, 1 edges (no clustering)
first 2 1

[graphify extract] incremental scan of /tmp/graphify-extract-noop...
[graphify extract] 0 code, 0 docs, 0 papers, 0 images changed; 1 unchanged; 0 deleted
[graphify extract] wrote .../graphify-out/graph.json — 0 nodes, 0 edges (no clustering)
second 0 0

Expected behavior

If the manifest says there are no changed or deleted files, extract should either:

  1. leave the existing graph.json unchanged, or
  2. rewrite the existing graph unchanged.

It should not replace the graph with an empty graph.

Notes

This looks related in spirit to prior incremental safety issues, but I could not find an issue for this exact no-op extract path. This is not an LLM/semantic extraction failure; the repro is code-only and uses --no-cluster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions