Fix: unify AST and semantic graphs with entity resolution and worked example - #213
Open
karthick1005 wants to merge 61 commits into
Open
Fix: unify AST and semantic graphs with entity resolution and worked example#213karthick1005 wants to merge 61 commits into
karthick1005 wants to merge 61 commits into
Conversation
* fix: git hooks fail when graphify is installed via pipx When installed via pipx, the graphify module is only available in pipx's isolated venv, not the system python3. The git hooks (post-commit, post-checkout) hardcoded `python3` which cannot import graphify in this case. Detect the correct Python interpreter from the graphify binary's shebang line, matching the approach already used in skill.md Step 1. Falls back to python3 for system installs. * fix: handle env-style shebangs and improve interpreter detection - Use POSIX `command -v` instead of non-standard `which` - Parse `#!/usr/bin/env python3` shebangs correctly (previous `tr -d ' '` would produce `/usr/bin/envpython3`) - Add import validation fallback to python3 if resolved interpreter cannot import graphify
… buffer * fix: suppress graspologic ANSI output that breaks PowerShell scrolling graspologic's leiden() emits ANSI escape sequences (progress bars, colored warnings) that corrupt PowerShell 5.1's scroll buffer on Windows, disabling vertical scrolling. Redirect stdout/stderr to StringIO during leiden() calls to prevent any escape codes from reaching the terminal. Add 2 tests verifying cluster() produces no stdout/stderr output. Fixes Graphify-Labs#19 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs: add PowerShell troubleshooting section to Windows skill Document the PowerShell 5.1 scrolling issue and provide 4 workarounds: upgrade graphify, use Windows Terminal, reset terminal, or uninstall graspologic to use Louvain fallback. Fixes Graphify-Labs#19 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
- Register 'trae' and 'trae-cn' in _PLATFORM_CONFIG (skill-trae.md, ~/.trae/skills/ and ~/.trae-cn/skills/, claude_md=False) - Add CLI subcommands: graphify trae install/uninstall, graphify trae-cn install/uninstall (routes to _agents_install/uninstall) - Update help text with new platform entries - Create skill-trae.md (Agent-tool based extraction, AGENTS.md integration, no PreToolUse hook support per Trae limitations) - Update README.md and README.zh-CN.md with Trae platform docs Co-authored-by: lijinshuan <lijinshuan@bytedance.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…utput Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ean README, save-result CLI
…y-Labs#109: extension drift, click detection, skill coverage, .graphify_python persistence Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…-Labs#93 Graphify-Labs#102 Graphify-Labs#109) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ify-Labs#126) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…Graphify-Labs#71) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…e relations in innerHTML (#sec) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…y-Labs#127) Tree-sitter resolves call targets directly from source — marking them INFERRED was incorrect. Cross-file class-level uses edges remain INFERRED. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…AST calls Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…Windows git hooks (Graphify-Labs#140) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…sh (Graphify-Labs#137, Graphify-Labs#148, Graphify-Labs#149) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…hify-Labs#105) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…he, graphifyignore parent discovery, MCP fixes Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…sor, Gemini in CLI section
…cription Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…port Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…nstall Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…attribute Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…r prompt itself Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ort.py, bound collision loop Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…aceholder Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Graphify-Labs#195: skill.md requires general-purpose subagent type for extraction dispatch Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tion, entity alignment, and fine-grained linking
…phify-Labs#222 and bump to 0.4.2 - extract.py: use str(path) for node IDs to prevent same-basename collision (Graphify-Labs#211) - build.py: normalize from/to edge keys before KeyError (Graphify-Labs#216) - export.py: guard ZeroDivisionError when graph has no edges (Graphify-Labs#217) - hooks.py: remove stale CODE_EXTS filter, rebuild on any changed file (Graphify-Labs#222) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…, Graphify-Labs#221 into 0.4.2 - build/validate: accept NetworkX <=3.1 "links" key alongside "edges" (Graphify-Labs#212) - __main__: skip version check during install/uninstall, deduplicate paths (Graphify-Labs#220) - all file IO: explicit encoding="utf-8" to prevent crashes on Windows CJK locales (Graphify-Labs#204) - hooks: add newline="\n" on write to prevent CRLF shebang breakage on Windows (Graphify-Labs#204) - export: strip trailing .md from safe_name so "CLAUDE.md" doesn't become "CLAUDE.md.md" (Graphify-Labs#221) - report: add Community Hubs navigation block so Obsidian vault stays connected (Graphify-Labs#221) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Graph Unification: AST + Semantic Alignment with Worked Example
Status: Ready for review
Target: safishamsi/graphify
Fork: karthick1005/graphify
Summary
This contribution fixes a structural issue where AST and semantic extraction produced largely disconnected subgraphs and relied on brittle exact ID matching.
It introduces canonical identity, entity resolution, and entity-level semantic ↔ code linking, along with a worked example to validate the changes on a real-world backend system.
Problem
Currently:
Result:
Solution
1. Canonical Identity
SentenceTransformervssentence transformer)2. Entity Resolution
Implemented post-build merging using:
3. Fine-Grained Code Extraction
4. Semantic ↔ Code Linking
Added:
link_code_to_concepts()link_semantic_to_code()link_concepts()Establishes connections between:
5. Alignment Pipeline
Introduced structured flow:
Worked Example
Added:
Includes:
graph.json— generated graphREADME.md— corpus + usagereview.md— evaluation of graph qualityThis example demonstrates:
Result
Files Changed
graphify/build.py— canonical ID + merge logicgraphify/align.py— entity resolution + linkinggraphify/extract.py— fine-grained extractionworked/leetcode-backend/*— validation exampleBackwards Compatibility
Motivation
The issue was observed while analyzing generated graphs, where semantic and AST layers remained disconnected.
This change ensures proper integration and improves the usefulness of the generated knowledge graph.
Closes
Fixes #198