跪拜 Guibai
← All articles
Artificial Intelligence

Graphify Tested: 34 Seconds to a Semantic Code Graph, but the Docs Path Fails Quietly

By 李翌 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Knowing which edges come from the AST and which from a model makes an impact analysis tool safe to act on; that explicit provenance is the pattern other tools should copy. The silent partial-results failure on the docs path shows why you cannot trust exit codes when a step depends on an LLM key.

Summary

Graphify turns a codebase into a graph that answers "who calls this?" and "what does this function affect?" without shipping code to a server. It parses files with tree-sitter into an AST, extracts semantic edges for calls, imports, inheritance and references, and lets you query that graph from the CLI. Running `graphify extract . --code-only` on TradingAgents, a 165-file Python project, took 34 seconds with 12 workers and produced 2,589 nodes, 5,919 edges, and 105 communities. A second project with 516 Python files finished in 33 seconds, so the scaling is linear when the directory is clean. The tool also reports a 70.6x reduction in tokens per query for an AI context, because a graph query costs about 2,444 tokens versus 172,600 for the naive text corpus.

The strongest design choice is honesty about edge provenance. The path query labels each hop as `[EXTRACTED]` when the AST confirms it and `[INFERRED]` with a confidence score when a model guessed it, and it names the weakest hop. That matters because most similar tools mix the two and force you to trust everything equally. The `query` command is BFS traversal, not an answer engine: it returns a list of nodes, truncated at a token budget, so you still have to read the code. And the non-code path is fragile: adding docs and images caused all 7 semantic chunks to fail with 400 and 429 errors from the Gemini backend, and 16 files silently dropped out, because the tool returns partial results without a nonzero exit.

The practical takeaway is to treat Graphify as a retrieval index, not a replacement for reading code. Use the three-command workflow: `extract --code-only` to build, `god-nodes` to see architecture hubs, and `affected` to get exact caller lists. Compare grep's 71 text matches for a symbol against Graphify's 13 semantic relations with line numbers: the counts measure different dimensions. The tool is overkill for a few-hundred-line project, and it will not answer "how are errors handled" directly. But for a large unfamiliar codebase, it compresses the search from hours to seconds, as long as you check the logs for silent drops.

Takeaways
— On TradingAgents (165 Python files), `graphify extract . --code-only` took 34 seconds with 12 workers, producing 2,589 nodes, 5,919 edges, and 105 communities.
— A second project of 516 Python files (3.3 MB) took 33 seconds, producing 2,405 nodes, 6,340 edges, and 180 communities, showing roughly linear scaling.
— Code-only mode makes zero API calls and runs fully offline; generated graph.json is 2.5 MB and interactive HTML exports in 1 second at 2.7 MB.
— Graphify's own benchmark reports a 70.6x reduction in tokens per query (2,444 tokens per graph query vs ~172,600 for the naive corpus).
— Path queries label each hop as [EXTRACTED] or [INFERRED] with a confidence score, naming the weakest hop (e.g., indirect_call at 0.85).
— The `query` command performs BFS traversal, not Q&A: a real question about error handling returned 388 nodes, truncated to 73.
— When docs/images are included, semantic chunks failed 7/7 (5 with 400, 2 with 429) and 16 files disappeared from the graph, while the tool returned partial results without a nonzero exit.
— The PyPI package name is graphifyy (double y), not graphify; other graphify* packages are explicitly not affiliated.
— For a symbol, grep returned 71 text matches including comments and docs, while `graphify affected` returned 13 semantic relations with line numbers.
— God-nodes listed the top hub as TradingAgentsGraph with 74 edges, matching the actual core object of the project.
— The recommended workflow is three commands: extract --code-only, god-nodes, and affected; clean the directory or use .graphifyignore before indexing to avoid slowdowns from large binaries.
Conclusions

Separating extracted from inferred edges is the feature that actually makes a graph tool trustworthy, because it tells you where a model's guess is the only basis for a relationship.

A silent partial-results failure for the docs path means exit code alone cannot verify a run; anyone using the non-code features has to inspect logs for dropped files.

The grep-vs-graphify count difference shows that comparing raw numbers from different tools is meaningless; the unit of measurement changes from textual occurrence to semantic relationship.

Linear scaling on clean directories is a reminder that performance claims for indexing tools depend on what you feed them; measuring input size, especially binary blobs, explains most 'slow' reports.

Concepts & terms
AST (Abstract Syntax Tree)
A tree representation of source code structure that parsers like tree-sitter produce; Graphify uses it to extract semantic relationships without executing code.
Semantic edge
A relationship between code entities extracted from the AST, such as a function call, an import, inheritance, or a reference, as opposed to a textual occurrence.
God-nodes
The highest-degree nodes in the code graph, acting as architectural hubs; Graphify's god-nodes command lists them to expose the skeleton of a project.
BFS traversal
A graph search that visits all neighbors before going deeper; Graphify's query command uses it to return a set of related nodes, not a synthesized answer.
Partial results
When a tool returns output from a subset of input files while silently skipping failures; Graphify's docs path can produce graphs missing files without erroring.
From the discussion
Featured comments
去吧波波鸟

This trick hits me most — when taking over an unfamiliar project, seeing the skeleton in 30 seconds is far faster than flipping through files. Also keep in mind that the documentation leg can fail silently; without checking the logs you really can't tell something is missing.

See top comments, translated →
Source: juejin.cn ↗ Google Translate ↗ Backup ↗