graphify icon indicating copy to clipboard operation
graphify copied to clipboard

AST pass explodes data .json into orphan key-nodes (CODE_EXTENSIONS includes .json) — 561 isolated nodes on a real repo

Open dawtips opened this issue 5 months ago • 1 comments

Summary

detect.CODE_EXTENSIONS includes .json (detect.py, the big extension set), so the AST/structural pass treats every JSON file as code and emits every JSON key as its own node. On repos where .json is data — eval fixtures, config, datasets, manifests — this floods the graph with orphan key-nodes and near-duplicate communities that swamp the real structure.

Observed (graphifyy 0.8.36, Windows, real repo)

A Python CLI repo (~200 files) with ~40 data .json files (eval cases.json/eval.json pairs, two plugin manifests, one test fixture):

with .json as code .json excluded
nodes 1819 1170
communities 114 73
isolated nodes 561 2
  • One repeated key (prompt_inputs_spec) appeared as 214 occurrences in the AST extraction (0 in the LLM semantic pass).
  • ~30 near-identical communities formed, one per eval suite, each holding just that file's keys (generation, target, cases_file, num_cases, …).
  • The report's "Knowledge Gaps" then flags 561 isolated nodes / 735 weakly-connected — reads like a codebase problem but is purely extraction noise.

Workaround

.graphifyignore with *.json (works — both detect() and the post-commit hook honor it). But it costs the LLM pass's concept extraction from those files too, and .graphifyignore shadowing .gitignore per-directory means re-listing everything else.

Suggested fixes (any of)

  1. Treat data-shaped .json as document rather than code — or only AST-extract manifest-style json the resolver actually understands (package.json, tsconfig.json, lockfiles are already skipped).
  2. A config knob to reclassify extensions per-repo (e.g. json: document / json: skip).
  3. Cheapest guard: warn in the report when a single .json yields N+ key-nodes with no cross-file edges — silent flooding is the painful part.

Happy to provide the full before/after graph.json pair if useful.

dawtips avatar Jun 10 '26 00:06 dawtips

Fixed in HEAD (commit a37672f). Added _is_config_json() which identifies config/manifest JSON by filename (package.json, tsconfig.json, .eslintrc.json, deno.json, etc.), compound suffix (*.tsconfig.json, *.eslintrc.json), or top-level key probe (dependencies, extends, $ref, compilerOptions). Data JSON files (top-level arrays, generic key/value files) are now skipped by the AST pass and left for the LLM semantic pass instead. package.json dependency edges and tsconfig.json extends chains continue to work. Smoke tested on fresh install. Shipping in the next release.

safishamsi avatar Jun 10 '26 20:06 safishamsi