Skip to content

Code Knowledge Graph - #34

Merged
safiullah-24 merged 2 commits into
QuantumLogicsLabs:mainfrom
alisheikhy1158:feat/code-knowledge-graph
Aug 24, 2026
Merged

Code Knowledge Graph#34
safiullah-24 merged 2 commits into
QuantumLogicsLabs:mainfrom
alisheikhy1158:feat/code-knowledge-graph

Conversation

@alisheikhy1158

@alisheikhy1158 alisheikhy1158 commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR implements a structural code knowledge graph for the repository. It goes beyond file-level import tracking by extracting symbol-level entities (functions, classes, methods) and tracking relationships (calls, inherits, defines) across files, which enables advanced queries like "who calls this function." It also introduces incremental file updating to maintain the graph efficiently without full rebuilds.

Closes #


Type of Change

  • Bug fix
  • Agent improvement (planner, executor, memory)
  • New or updated tool (tools/)
  • Prompt update (prompts/)
  • API change (api/)
  • Configuration / settings
  • Refactor / code quality
  • Documentation
  • CI/CD
  • Other:

Changes

  • tools/
    • Added code_graph.py containing the core logic (GraphNode, GraphEdge, CodeGraph, build_code_graph, and update_file_in_graph) to extract and map Python AST entities.
    • Updated code_parser.py to include parse_repository_full, ensuring the graph builder bypasses token budget limits to get 100% repository coverage.
  • tests/ — Added test_code_graph.py to verify full graph construction, node/edge counts, symbol resolution, and incremental file updates (e.g., handling symbol renames and new cross-file calls).

Testing

pytest tests/ -v
x] All existing tests pass (68/68 passing)

[x] New tests added for new behaviour

[x] Linting passes: ruff check . && black --check .

[x] Type checks pass: mypy .

For Tool Changes
[x] tests/test_code_graph.py updated and passing

[x] Tool tested against a real or mock GitHub repo (Tested locally against the Repomind repository)

[ ] GitHub API calls are mocked in unit tests (no real commits in CI)

Security Checklist
[x] No API keys, tokens, or secrets introduced into tracked files

[x] .env values only reference variables defined in config/.env.example

[x] LLM-generated content is never passed to eval() or exec()

[ ] New API endpoints require appropriate auth (or explicitly document why not)

[ ] Docker image does not run as root (if Dockerfile modified)

[ ] No new dependency added without a pinned version in pyproject.toml

Breaking Changes
[ ] This PR introduces breaking changes to the API or agent behaviour

Screenshots / Output (if applicable)


##Reviewer Notes

Token budgeting in code_parser.py was originally skipping files like agent_runner.py during graph generation. This was resolved by implementing parse_repository_full to guarantee complete repository analysis for the graph without triggering the 50,000 max token limit.

@safiullah-24
safiullah-24 merged commit c70f856 into QuantumLogicsLabs:main Aug 24, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants