codegraph-engine 2.1.3__tar.gz → 2.1.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/LICENSE +1 -1
  2. codegraph_engine-2.1.7/PKG-INFO +617 -0
  3. codegraph_engine-2.1.7/README.md +584 -0
  4. codegraph_engine-2.1.7/pyproject.toml +66 -0
  5. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/__init__.py +1 -1
  6. codegraph_engine-2.1.7/src/codegraph/agent_brain.py +1961 -0
  7. codegraph_engine-2.1.7/src/codegraph/agent_capabilities.py +3500 -0
  8. codegraph_engine-2.1.7/src/codegraph/agent_rules.py +530 -0
  9. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/architecture.py +48 -5
  10. codegraph_engine-2.1.7/src/codegraph/binding_resolver.py +616 -0
  11. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/cli.py +345 -5
  12. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/config.py +2 -0
  13. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/context.py +845 -93
  14. codegraph_engine-2.1.7/src/codegraph/database/__init__.py +58 -0
  15. codegraph_engine-2.1.7/src/codegraph/database/extractor.py +2956 -0
  16. codegraph_engine-2.1.7/src/codegraph/database/interrogation.py +1085 -0
  17. codegraph_engine-2.1.7/src/codegraph/database/models.py +310 -0
  18. codegraph_engine-2.1.7/src/codegraph/epistemic.py +185 -0
  19. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/errors.py +7 -0
  20. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/evidence/citations.py +22 -1
  21. codegraph_engine-2.1.7/src/codegraph/evidence_contract.py +455 -0
  22. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/frameworks.py +359 -4
  23. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/git.py +92 -10
  24. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/graph/models.py +15 -0
  25. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/graph/traversal.py +680 -121
  26. codegraph_engine-2.1.7/src/codegraph/indexing/__init__.py +18 -0
  27. codegraph_engine-2.1.7/src/codegraph/indexing/classifier.py +559 -0
  28. codegraph_engine-2.1.7/src/codegraph/indexing/indexer.py +2317 -0
  29. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/indexing/models.py +75 -0
  30. codegraph_engine-2.1.7/src/codegraph/indexing/parser.py +3013 -0
  31. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/indexing/scanner.py +4 -1
  32. codegraph_engine-2.1.7/src/codegraph/indexing/telemetry.py +326 -0
  33. codegraph_engine-2.1.7/src/codegraph/installer.py +1652 -0
  34. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/interrogation.py +708 -122
  35. codegraph_engine-2.1.7/src/codegraph/mcp/server.py +1154 -0
  36. codegraph_engine-2.1.7/src/codegraph/mcp_diagnostics.py +879 -0
  37. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/models.py +14 -0
  38. codegraph_engine-2.1.7/src/codegraph/monorepo.py +922 -0
  39. codegraph_engine-2.1.7/src/codegraph/observability.py +262 -0
  40. codegraph_engine-2.1.7/src/codegraph/optimizer.py +977 -0
  41. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/ranking.py +61 -16
  42. codegraph_engine-2.1.7/src/codegraph/resolver.py +2772 -0
  43. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/resources/monitor.py +1 -1
  44. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/retrieval_policy.py +96 -17
  45. codegraph_engine-2.1.7/src/codegraph/route_composer.py +363 -0
  46. codegraph_engine-2.1.7/src/codegraph/runtime/__init__.py +32 -0
  47. codegraph_engine-2.1.7/src/codegraph/runtime/ingestor.py +672 -0
  48. codegraph_engine-2.1.7/src/codegraph/runtime/models.py +130 -0
  49. codegraph_engine-2.1.7/src/codegraph/runtime/reconciliation.py +492 -0
  50. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/search/__init__.py +2 -0
  51. codegraph_engine-2.1.7/src/codegraph/search/hybrid.py +820 -0
  52. codegraph_engine-2.1.7/src/codegraph/security/__init__.py +51 -0
  53. codegraph_engine-2.1.7/src/codegraph/security/paths.py +189 -0
  54. codegraph_engine-2.1.7/src/codegraph/security/redaction.py +633 -0
  55. codegraph_engine-2.1.7/src/codegraph/semantic_decorators.py +341 -0
  56. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/target_resolver.py +6 -6
  57. codegraph_engine-2.1.7/src/codegraph/tool_selection_eval.py +1158 -0
  58. codegraph_engine-2.1.7/src/codegraph_engine.egg-info/PKG-INFO +617 -0
  59. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph_engine.egg-info/SOURCES.txt +42 -0
  60. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph_engine.egg-info/requires.txt +1 -0
  61. codegraph_engine-2.1.7/tests/test_agent_ux_text_search_file_inspection.py +425 -0
  62. codegraph_engine-2.1.7/tests/test_artifact_classification.py +229 -0
  63. codegraph_engine-2.1.7/tests/test_artifact_retrieval_policy.py +450 -0
  64. codegraph_engine-2.1.7/tests/test_change_impact.py +486 -0
  65. codegraph_engine-2.1.7/tests/test_conservative_binding.py +429 -0
  66. codegraph_engine-2.1.7/tests/test_database_runtime_intelligence_and_security.py +773 -0
  67. codegraph_engine-2.1.7/tests/test_dependency_injection.py +661 -0
  68. codegraph_engine-2.1.7/tests/test_epistemic_relationships.py +283 -0
  69. codegraph_engine-2.1.7/tests/test_monorepo_packages.py +501 -0
  70. codegraph_engine-2.1.7/tests/test_package_boundaries.py +376 -0
  71. codegraph_engine-2.1.7/tests/test_phase10_context_optimization.py +1095 -0
  72. codegraph_engine-2.1.7/tests/test_phase11_agent_integration.py +800 -0
  73. codegraph_engine-2.1.7/tests/test_phase12_hardening.py +1040 -0
  74. codegraph_engine-2.1.7/tests/test_phase13_agent_brain_and_rc.py +226 -0
  75. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_platform_resources.py +4 -2
  76. codegraph_engine-2.1.7/tests/test_registries_and_dispatch.py +533 -0
  77. codegraph_engine-2.1.7/tests/test_route_composition.py +435 -0
  78. codegraph_engine-2.1.7/tests/test_semantic_decorators.py +553 -0
  79. codegraph_engine-2.1.7/tests/test_test_intelligence.py +501 -0
  80. codegraph_engine-2.1.7/tests/test_v215_external_feedback.py +585 -0
  81. codegraph_engine-2.1.7/tests/test_v216_installer.py +622 -0
  82. codegraph_engine-2.1.7/tests/test_v217_large_repo_indexing.py +415 -0
  83. codegraph_engine-2.1.3/PKG-INFO +0 -336
  84. codegraph_engine-2.1.3/README.md +0 -314
  85. codegraph_engine-2.1.3/pyproject.toml +0 -46
  86. codegraph_engine-2.1.3/src/codegraph/epistemic.py +0 -90
  87. codegraph_engine-2.1.3/src/codegraph/indexing/__init__.py +0 -4
  88. codegraph_engine-2.1.3/src/codegraph/indexing/classifier.py +0 -274
  89. codegraph_engine-2.1.3/src/codegraph/indexing/indexer.py +0 -969
  90. codegraph_engine-2.1.3/src/codegraph/indexing/parser.py +0 -1240
  91. codegraph_engine-2.1.3/src/codegraph/mcp/server.py +0 -736
  92. codegraph_engine-2.1.3/src/codegraph/observability.py +0 -151
  93. codegraph_engine-2.1.3/src/codegraph/optimizer.py +0 -372
  94. codegraph_engine-2.1.3/src/codegraph/resolver.py +0 -843
  95. codegraph_engine-2.1.3/src/codegraph/search/hybrid.py +0 -301
  96. codegraph_engine-2.1.3/src/codegraph/security/__init__.py +0 -3
  97. codegraph_engine-2.1.3/src/codegraph/security/paths.py +0 -35
  98. codegraph_engine-2.1.3/src/codegraph_engine.egg-info/PKG-INFO +0 -336
  99. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/setup.cfg +0 -0
  100. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/agent.py +0 -0
  101. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/audit.py +0 -0
  102. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/cache.py +0 -0
  103. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/constraints.py +0 -0
  104. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/evidence/__init__.py +0 -0
  105. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/freshness.py +0 -0
  106. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/graph/__init__.py +0 -0
  107. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/indexing/test_framework.py +0 -0
  108. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/llm/__init__.py +0 -0
  109. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/llm/base.py +0 -0
  110. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/llm/context.py +0 -0
  111. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/mcp/__init__.py +0 -0
  112. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/memory/__init__.py +0 -0
  113. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/memory/store.py +0 -0
  114. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/planner.py +0 -0
  115. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/py.typed +0 -0
  116. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/query_expansion.py +0 -0
  117. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/resources/__init__.py +0 -0
  118. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/resources/cache.py +0 -0
  119. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/resources/coalescer.py +0 -0
  120. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/resources/debouncer.py +0 -0
  121. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/resources/governor.py +0 -0
  122. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/resources/policy.py +0 -0
  123. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/search/semantic.py +0 -0
  124. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph/task.py +0 -0
  125. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph_engine.egg-info/dependency_links.txt +0 -0
  126. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph_engine.egg-info/entry_points.txt +0 -0
  127. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/src/codegraph_engine.egg-info/top_level.txt +0 -0
  128. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_active_coding_protection.py +0 -0
  129. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_adaptive_planning.py +0 -0
  130. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_adversarial_edge_cases.py +0 -0
  131. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_agent_ux_hardening.py +0 -0
  132. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_benchmark_infra.py +0 -0
  133. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_bounded_caches.py +0 -0
  134. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_cli_doctor_privacy.py +0 -0
  135. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_context_budget.py +0 -0
  136. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_context_cache.py +0 -0
  137. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_context_compiler_v2.py +0 -0
  138. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_core.py +0 -0
  139. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_database_integrity.py +0 -0
  140. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_debouncer.py +0 -0
  141. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_determinism_and_soak.py +0 -0
  142. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_developer_audit.py +0 -0
  143. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_evaluation_framework.py +0 -0
  144. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_framework_analyzers.py +0 -0
  145. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_framework_routes_persistence.py +0 -0
  146. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_git_intelligence.py +0 -0
  147. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_hardening.py +0 -0
  148. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_interrogation_contracts.py +0 -0
  149. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_latency_modes_and_parallel.py +0 -0
  150. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_mcp_integration.py +0 -0
  151. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_phase2.py +0 -0
  152. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_ranking_engine.py +0 -0
  153. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_reference_resolution.py +0 -0
  154. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_request_coalescer.py +0 -0
  155. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_resource_governor.py +0 -0
  156. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_retrieval_planner.py +0 -0
  157. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_scanner_security.py +0 -0
  158. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_single_pass_parser.py +0 -0
  159. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_symbol_identity.py +0 -0
  160. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_task_ambiguity.py +0 -0
  161. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_task_mcp_tools.py +0 -0
  162. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_task_normalization.py +0 -0
  163. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_task_spec.py +0 -0
  164. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_v211_factory_resolution.py +0 -0
  165. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_v211_features.py +0 -0
  166. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_v211_imports_dependents_cli.py +0 -0
  167. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_v211_recursive_frameworks.py +0 -0
  168. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_v21_diagnostics.py +0 -0
  169. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_v21_hard_exclusions.py +0 -0
  170. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_v21_query_expansion.py +0 -0
  171. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_v21_retrieval_policy.py +0 -0
  172. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_v21_target_resolver.py +0 -0
  173. {codegraph_engine-2.1.3 → codegraph_engine-2.1.7}/tests/test_verify_evidence.py +0 -0
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026 CodeGraph contributors
3
+ Copyright (c) 2026 Sri Raghuram, CodeGraph contributors
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -0,0 +1,617 @@
1
+ Metadata-Version: 2.4
2
+ Name: codegraph-engine
3
+ Version: 2.1.7
4
+ Summary: Deep deterministic repository intelligence for AI coding agents (code, dependencies, databases, and runtime observations)
5
+ Author: CodeGraph contributors
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/raghurammrsd/CODE_GRAPH_MCP
8
+ Project-URL: Repository, https://github.com/raghurammrsd/CODE_GRAPH_MCP
9
+ Project-URL: Documentation, https://github.com/raghurammrsd/CODE_GRAPH_MCP/blob/main/docs/agent-brain.md
10
+ Project-URL: Changelog, https://github.com/raghurammrsd/CODE_GRAPH_MCP/blob/main/CHANGELOG.md
11
+ Project-URL: Issues, https://github.com/raghurammrsd/CODE_GRAPH_MCP/issues
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
+ Requires-Python: >=3.12
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: pydantic>=2.7
21
+ Requires-Dist: typer>=0.12
22
+ Requires-Dist: mcp<2,>=1.0
23
+ Provides-Extra: mcp
24
+ Requires-Dist: mcp<2,>=1.0; extra == "mcp"
25
+ Provides-Extra: system
26
+ Requires-Dist: psutil>=5.9; extra == "system"
27
+ Provides-Extra: dev
28
+ Requires-Dist: pytest>=8; extra == "dev"
29
+ Requires-Dist: pytest-cov>=5; extra == "dev"
30
+ Requires-Dist: ruff>=0.6; extra == "dev"
31
+ Requires-Dist: mypy>=1.10; extra == "dev"
32
+ Dynamic: license-file
33
+
34
+ <p align="center">
35
+ <img src="docs/assets/codegraph_logo.jpg" alt="CodeGraph MCP — Deep Deterministic Repository Intelligence for AI Coding Agents" width="500" />
36
+ </p>
37
+
38
+ <h1 align="center">CodeGraph Engine (v2.1.7)</h1>
39
+
40
+ <p align="center">
41
+ <strong>Deep deterministic repository intelligence for AI coding agents.</strong>
42
+ </p>
43
+
44
+ <p align="center">
45
+ <a href="https://github.com/raghurammrsd/CODE_GRAPH_MCP"><img src="https://img.shields.io/badge/package-codegraph--engine%20v2.1.7-blue.svg" alt="Package: codegraph-engine v2.1.7" /></a>
46
+ <a href="pyproject.toml"><img src="https://img.shields.io/badge/python-3.12%20%7C%203.13-3776AB.svg" alt="Python 3.12 | 3.13" /></a>
47
+ <a href="src/codegraph/mcp/server.py"><img src="https://img.shields.io/badge/MCP-14%20default%20%7C%2056%20full%20tools-2ea043.svg" alt="MCP Tools: 14 default | 56 full" /></a>
48
+ <a href="tests/"><img src="https://img.shields.io/badge/pytest-842%20passed-brightgreen.svg" alt="Tests: 842 passed" /></a>
49
+ <a href="pyproject.toml"><img src="https://img.shields.io/badge/ruff-0%20errors-success.svg" alt="Ruff: 0 errors" /></a>
50
+ <a href="src/codegraph/"><img src="https://img.shields.io/badge/mypy-0%20issues%20(77%20files)-blue.svg" alt="Mypy: strict" /></a>
51
+ <a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT" /></a>
52
+ </p>
53
+
54
+ <p align="center">
55
+ <a href="#2-quickstart-30-second-setup"><strong>Quickstart</strong></a> •
56
+ <a href="#1-built-for-aiml-and-backend-heavy-repositories"><strong>Built For</strong></a> •
57
+ <a href="#5-database-intelligence"><strong>Database Intelligence</strong></a> •
58
+ <a href="#6-runtime-intelligence--static-reconciliation"><strong>Runtime Evidence</strong></a> •
59
+ <a href="#8-measured-performance-v216--v217"><strong>Measured Performance</strong></a> •
60
+ <a href="docs/agent-brain.md"><strong>56-Tool Reference</strong></a> •
61
+ <a href="https://github.com/raghurammrsd/CODE_GRAPH_MCP"><strong>GitHub</strong></a>
62
+ </p>
63
+
64
+ ```text
65
+ The AI reasons.
66
+ CodeGraph interrogates the repository.
67
+ The evidence stays traceable.
68
+ ```
69
+
70
+ **CodeGraph MCP gives AI coding agents an evidence-backed understanding of code, dependencies, databases, and optional runtime observations.**
71
+ > **Supported Languages & Frameworks:** First-class **Python** (`FastAPI`, `Flask`, `Django`, `SQLAlchemy`, `Celery`, `pytest`) + **TypeScript / JavaScript** (`.ts`, `.tsx`, `.js`, `.jsx`) & **Express.js** support.
72
+
73
+ When an AI coding agent works inside a complex Python or full-stack codebase, raw text search forces it to open dozens of files and mentally reconstruct call chains, router prefixes, dependency injection providers, and ORM table mappings inside its context window.
74
+
75
+ ```text
76
+ Complex repository
77
+ ↓
78
+ AI agent needs architectural & dataflow understanding
79
+ ↓
80
+ CodeGraph interrogates the local repository index
81
+ ↓
82
+ Compact, cited evidence (symbols, edges, tables, bounded slices)
83
+ ↓
84
+ AI reasons and edits with traceable citations
85
+ ```
86
+
87
+ ### 30-Second Install
88
+
89
+ ```bash
90
+ pip install "codegraph-engine[mcp]"
91
+ codegraph install
92
+ cd your-project
93
+ codegraph init
94
+ codegraph doctor
95
+ ```
96
+
97
+ ---
98
+
99
+ ## 1. Built for AI/ML and Backend-Heavy Repositories
100
+
101
+ CodeGraph is engineered for **AI/ML engineers**, **LLM application developers**, **model/inference engineers**, **backend Python & TypeScript/JS developers**, and **maintainers of large multi-package repositories** where relationships cross module, framework, and database boundaries.
102
+
103
+ ### AI/ML & LLM Engineering Workloads
104
+ - **Inference & Model Serving Services**: Trace HTTP/RPC routes (`FastAPI`, `Flask`) into inference handlers, request validators, preprocessing pipelines, model forward calls, postprocessing, and database/cache persistence.
105
+ - **Training & Evaluation Pipelines**: Map training entrypoints (`CLI` commands, scripts) to dataset loaders, feature transforms, trainer loops, checkpoint writers, and evaluation metrics.
106
+ - **LLM Applications & Tool Registries**: Resolve decorator and call-based tool/agent registries (`@register`, `register_tool`, `ROUTING_MANIFEST`), prompt/context builders, retrieval pipelines, and model provider clients.
107
+ - **Experiment & Monorepo Codebases**: Distinguish active source code (`SOURCE`) from generated protobuf/OpenAPI stubs (`GENERATED`), build outputs (`BUILD_ARTIFACT`), and vendor directories (`VENDOR`).
108
+
109
+ ### Backend-Heavy Python, TypeScript/JS & Service Architectures
110
+ - **Web Frameworks**: **FastAPI**, **Flask**, **Django**, and **Express.js** route registration (`ROUTE_HANDLER`, `HANDLED_BY`, `ROUTES_TO`) and nested router prefix composition (`MOUNTS` via `include_router`, `register_blueprint`, `app.use`).
111
+ - **Multi-Language Full-Stack Indexing**: Deep **Python** AST & dataflow analysis alongside **TypeScript** (`.ts`, `.tsx`) and **JavaScript** (`.js`, `.jsx`) symbol, import, call, and **Express.js** route extraction.
112
+ - **Dependency Injection & Event Systems**: FastAPI `Depends(...)` (`INJECTS`, `PROVIDES`, `RESOLVES_DEPENDENCY`, `DI_CYCLE`), event buses (`EVENT_LISTENER`, `DISPATCHES_TO`), and **Celery** background task queues (`TASK_HANDLER`).
113
+ - **Persistence & ORM Layers**: **SQLAlchemy**, **Django ORM**, **SQLModel**, **Prisma**, **Alembic**, **Django Migrations**, and raw **SQL** (`PostgreSQL`, `MySQL`, `SQLite`) table/column read-write analysis.
114
+ - **Test Suites**: Link **pytest** and `unittest` test functions and fixtures directly to the symbols, routes, DI providers, and event handlers they verify (`TESTS_SYMBOL`, `TESTS_ROUTE`, `TESTS_PROVIDER`, `TESTS_EVENT_HANDLER`).
115
+
116
+ ---
117
+
118
+ ## 2. Quickstart (30-Second Setup)
119
+
120
+ ### Step 1: Install the Package
121
+
122
+ ```bash
123
+ pip install "codegraph-engine[mcp]"
124
+ ```
125
+
126
+ ### Step 2: Configure Your AI Coding Agents (`codegraph install`)
127
+
128
+ CodeGraph includes an interactive, idempotent onboarding installer ([`src/codegraph/installer.py`](src/codegraph/installer.py)) that detects installed AI coding agents (**Claude Code**, **Cursor**, **Antigravity**, **Codex CLI**, **Gemini CLI**, and **Cline**), configures `mcpServers.codegraph`, installs marker-bounded routing instructions (`<!-- CODEGRAPH:START -->` … `<!-- CODEGRAPH:END -->`), and verifies MCP server startup:
129
+
130
+ ```bash
131
+ # Interactive setup (detects installed agents, previews planned changes, asks confirmation)
132
+ codegraph install
133
+
134
+ # Non-interactive setup for all detected agents in the current project
135
+ codegraph install --yes --target auto --location local
136
+
137
+ # Preview exact file modifications without writing anything
138
+ codegraph install --dry-run
139
+ ```
140
+
141
+ ### Step 3: Initialize & Verify Your Project Index
142
+
143
+ ```bash
144
+ cd your-project
145
+ codegraph init
146
+ codegraph status
147
+ codegraph doctor
148
+ ```
149
+
150
+ ### Managing Installation & Project Index Lifecycle
151
+
152
+ CodeGraph cleanly separates agent configuration from project index files:
153
+
154
+ | Command | Scope | What It Does |
155
+ | :--- | :--- | :--- |
156
+ | `codegraph install` | Agent configuration | Configures MCP server + marker-managed rules/skills for selected AI agents. |
157
+ | `codegraph init` | Project repository | Initializes `.codegraph.sqlite3` and indexes the current repository. |
158
+ | `codegraph index` | Project repository | Incrementally indexes modified files (`--verbose`, `--quiet`, `--json`). |
159
+ | `codegraph uninstall` | Agent configuration | Removes only CodeGraph-managed MCP entries and instruction blocks (preserves user config and project index). |
160
+ | `codegraph uninit` | Project repository | Removes only `.codegraph.sqlite3` and `.codegraph/` in the project (never touches source code or Git history). |
161
+
162
+ ---
163
+
164
+ ## 3. Core Workflow & Architecture
165
+
166
+ ```mermaid
167
+ flowchart TD
168
+ A["AI Coding Agent"] --> B["CodeGraph MCP"]
169
+ B --> C["Repository Intelligence"]
170
+
171
+ C --> D["Semantic Graph"]
172
+ C --> E["Text Search (search_code)"]
173
+ C --> F["Source Inspection (get_file)"]
174
+ C --> G["Database Intelligence"]
175
+ C --> H["Runtime Observation"]
176
+
177
+ D --> I["Structured Evidence + Epistemic Labels"]
178
+ E --> I
179
+ F --> I
180
+ G --> I
181
+ H --> I
182
+
183
+ I --> J["Context Optimization + Secret Redaction"]
184
+ J --> A
185
+ ```
186
+
187
+ ### Routing Each Question to the Right Primitive
188
+
189
+ ```text
190
+ STRUCTURAL → Graph tools (find_symbol, find_callers, find_callees, find_references, find_routes)
191
+ TEXTUAL → search_code (literal/regex search across Python, HTML/Jinja, JS/TS, CSS, YAML/JSON, SQL)
192
+ SOURCE → get_file (bounded start_line..end_line source inspection with truncation metadata)
193
+ GRAPH → Trace tools (trace_path, trace_flow, analyze_impact, get_git_impact)
194
+ DATABASE → Database tools (get_db_schema, find_db_tables, find_db_readers, find_db_writers, get_db_impact)
195
+ RUNTIME → Runtime/reconciliation tools (ingest_runtime_traces, get_runtime_trace, reconcile_static_runtime)
196
+ EDITING → Native agent / IDE editing tools
197
+ ```
198
+
199
+ ---
200
+
201
+ ## 4. AI/ML & Backend Architecture Examples
202
+
203
+ ### Example 1: Model Inference Service Flow
204
+
205
+ ```text
206
+ POST /v1/predict (FastAPI Route)
207
+ ↓ HANDLED_BY (FRAMEWORK_VERIFIED)
208
+ predict_endpoint (Handler)
209
+ ↓ INJECTS (DATAFLOW_VERIFIED)
210
+ get_inference_service (DI Provider)
211
+ ↓ CALLS (AST_VERIFIED)
212
+ InferenceService.run_inference
213
+ ├──►CALLS (AST_VERIFIED) ──► FeaturePreprocessor.transform
214
+ ├──►CALLS (AST_VERIFIED) ──► FraudClassifier.forward
215
+ ├──►CALLS (AST_VERIFIED) ──► ScorePostprocessor.calibrate
216
+ └──►CALLS (AST_VERIFIED) ──► PredictionRepository.log_prediction
217
+ ↓ WRITES_TABLE (AST_VERIFIED)
218
+ db:table:postgresql.public.prediction_logs
219
+ ```
220
+
221
+ **What CodeGraph structurally proves**:
222
+ - `find_routes(path="/v1/predict")` resolves composed router prefixes (`MOUNTS`) to `predict_endpoint`.
223
+ - `trace_path(from_symbol="predict_endpoint", to_symbol="log_prediction")` proves the multi-hop execution chain across DI injection, preprocessing, model execution, and persistence.
224
+ - `get_db_impact(symbol="InferenceService.run_inference")` identifies downstream writes to `prediction_logs`.
225
+
226
+ ### Example 2: Training & Evaluation Pipeline
227
+
228
+ ```text
229
+ train_cli (CLI Command Handler)
230
+ ↓ COMMAND_HANDLER (FRAMEWORK_VERIFIED)
231
+ TrainingPipeline.run
232
+ ├──►CALLS (AST_VERIFIED) ──► DatasetBuilder.load_splits
233
+ ├──►CALLS (AST_VERIFIED) ──► TokenizerTransform.encode_batch
234
+ ├──►CALLS (AST_VERIFIED) ──► Trainer.fit_epoch
235
+ ├──►CALLS (AST_VERIFIED) ──► CheckpointManager.save_weights
236
+ └──►CALLS (AST_VERIFIED) ──► Evaluator.compute_metrics
237
+ ```
238
+
239
+ **What CodeGraph structurally proves**:
240
+ - `find_callees(symbol="TrainingPipeline.run")` enumerates every stage of the pipeline with exact file and line ranges.
241
+ - `find_tests(symbol="Evaluator.compute_metrics")` locates the unit and regression tests covering metric calculation.
242
+ - When a transform or model class is dynamically instantiated from a YAML string (`getattr(models, cfg.arch)`), CodeGraph explicitly records `POSSIBLE_CALLS` (`POSSIBLE`) or `UNRESOLVED_REFERENCE` (`UNKNOWN`) rather than fabricating a false static call edge.
243
+
244
+ ### Example 3: LLM Agent & Tool Registry
245
+
246
+ ```text
247
+ POST /api/chat (LLM Endpoint)
248
+ ↓ HANDLED_BY (FRAMEWORK_VERIFIED)
249
+ chat_handler
250
+ ↓ CALLS (AST_VERIFIED)
251
+ AgentRunner.execute_step
252
+ ├──►REGISTERS / REGISTERED_HANDLER ──► ToolRegistry ("search_orders", "refund_order")
253
+ ├──►CALLS (AST_VERIFIED) ──► ContextBuilder.compile
254
+ ├──►READS_TABLE (AST_VERIFIED) ──► db:table:postgresql.public.conversations
255
+ └──►CALLS (AST_VERIFIED) ──► ModelProviderClient.generate
256
+ ```
257
+
258
+ **What CodeGraph structurally proves**:
259
+ - Tracks decorator and call-based registrations (`@tool_registry.register("search_orders")`) via `REGISTERS` and `REGISTERED_HANDLER` edges.
260
+ - Tracks environment variable dependencies (`os.getenv("OPENAI_API_KEY")`) as `READS_ENV` edges with the variable name only—never indexing or exposing secret values.
261
+
262
+ ### Example 4: Full-Stack Feature Investigation (Dundoo Bill Scanner)
263
+
264
+ Validated end-to-end in [`src/codegraph/tool_selection_eval.py`](src/codegraph/tool_selection_eval.py) (`run_dundoo_bill_scanner_e2e_eval()`):
265
+
266
+ ```text
267
+ Developer Prompt: "Wire up AI bill scanning next to the Manual Entry button"
268
+ │
269
+ ├── 1. get_architecture() → Maps app/, templates/, static/js/, tests/
270
+ ├── 2. search_code(query="Add Manual Entry") → Matches templates/bills.html:6
271
+ ├── 3. get_file(path="templates/bills.html", 1..12) → Reads bounded 12-line HTML slice
272
+ ├── 4. find_routes(path="/api/scan-bill") → Resolves POST /api/scan-bill → scan_bill_endpoint
273
+ ├── 5. find_symbol(symbol="parse_bill") → Grounds app/bill_scanner.py::parse_bill
274
+ ├── 6. get_file(path="app/bill_scanner.py", 1..20) → Reads parse_bill() and normalize_line_items()
275
+ ├── 7. find_callers(symbol="parse_bill") → Confirms scan_bill_endpoint calls parse_bill
276
+ └── 8. find_tests(symbol="parse_bill") → Finds test_parse_bill_calculates_total
277
+ ```
278
+
279
+ ---
280
+
281
+ ## 5. Database Intelligence
282
+
283
+ [`src/codegraph/database/`](src/codegraph/database/) provides static schema, ORM model, migration, and query extraction across **SQLAlchemy**, **Django ORM**, **SQLModel**, **Prisma** (`.prisma`), **Alembic**, **Django Migrations**, and **Raw SQL** (`PostgreSQL`, `MySQL`, `SQLite`).
284
+
285
+ ```text
286
+ POST /orders
287
+ ↓ HANDLED_BY (FRAMEWORK_VERIFIED)
288
+ OrderService.create_order
289
+ ↓ CALLS (AST_VERIFIED)
290
+ OrderRepository.insert_order
291
+ ↓ WRITES_TABLE (AST_VERIFIED)
292
+ db:table:postgresql.public.orders
293
+ ↓ FOREIGN_KEY_TO (AST_VERIFIED)
294
+ orders.user_id ──► users.id
295
+ ```
296
+
297
+ ### Capabilities Exposed by the 11 Database MCP Tools
298
+ - **Table & Column Discovery** (`get_db_schema`, `get_db_table`, `find_db_tables`, `find_db_columns`): Extract tables, column types, nullability, defaults, primary keys (`HAS_PRIMARY_KEY`), indexes (`HAS_INDEX`), unique/check constraints, and foreign keys (`FOREIGN_KEY_TO`).
299
+ - **ORM Mapping** (`find_db_models`): Map SQLAlchemy `__tablename__`, Django `models.Model` (`Meta.db_table`), SQLModel `table=True`, and Prisma `model` blocks via `MAPS_TO_TABLE` and `MAPS_TO_COLUMN`.
300
+ - **Readers, Writers & Callers** (`find_db_readers`, `find_db_writers`, `find_db_callers`, `find_db_queries`): Identify every function or method that executes `SELECT` (`READS_TABLE`) or `INSERT` / `UPDATE` / `DELETE` / `.add()` / `.save()` (`WRITES_TABLE`) against a table.
301
+ - **Migration Lineage & Schema Blast Radius** (`find_db_relationships`, `get_db_impact`): Track Alembic (`op.create_table`, `op.add_column`) and Django (`migrations.CreateModel`, `migrations.AddField`) operations (`MIGRATES_TABLE`) and compute bidirectional code $\leftrightarrow$ database impact.
302
+
303
+ ---
304
+
305
+ ## 6. Runtime Intelligence & Static Reconciliation
306
+
307
+ Static analysis proves what **can** happen structurally; runtime telemetry records what **was observed** during a specific execution window. [`src/codegraph/runtime/`](src/codegraph/runtime/) combines both without conflating them:
308
+
309
+ ```text
310
+ STATIC GRAPH (AST + Framework + Dataflow + DB)
311
+ +
312
+ OPTIONAL RUNTIME OBSERVATION (OTel JSON / JSONL Events / SQL Logs)
313
+ ↓
314
+ reconcile_static_runtime()
315
+ ```
316
+
317
+ ### Reconciliation Outcomes ([`ReconciliationStatus`](src/codegraph/runtime/models.py))
318
+
319
+ | Reconciliation Status | Static Graph | Runtime Trace | Meaning |
320
+ | :--- | :---: | :---: | :--- |
321
+ | **`CONFIRMED_RUNTIME_PATH`** | Present | Observed | Static relationship is structurally proven **and** observed executing in ingested traces. |
322
+ | **`NOT_OBSERVED_AT_RUNTIME`** | Present | Not observed | Statically valid edge was not exercised in the ingested trace sample. |
323
+ | **`RUNTIME_ONLY_OBSERVED`** | Dynamic / `UNKNOWN` | Observed | Executed at runtime (e.g., plugin hook, `getattr`, dynamic SQL) where static analysis remained `UNKNOWN`. |
324
+ | **`STATIC_RUNTIME_CONFLICT`** | Target A | Target B | Runtime execution dispatched to a different target than static resolution (e.g., dependency override or subclass). |
325
+
326
+ ### Epistemic Rules for Runtime Evidence
327
+ 1. **Runtime Telemetry Is Opt-In & Observational**: CodeGraph never instruments or executes your code automatically. Traces are ingested only when you call `ingest_runtime_traces` on OpenTelemetry JSON, structured JSONL, or SQL log files.
328
+ 2. **`NOT_OBSERVED_AT_RUNTIME` Does Not Mean Dead Code**: It only means the code path was not triggered during the recorded trace window (for example, an error handler, admin route, or periodic job).
329
+ 3. **Runtime Observations Never Overwrite Static Proof**: Runtime spans are stored with `evidence_class="RUNTIME_OBSERVED"` and kept distinct from `AST_VERIFIED`, `FRAMEWORK_VERIFIED`, and `DATAFLOW_VERIFIED` static edges.
330
+
331
+ ---
332
+
333
+ ## 7. Epistemic Trust & Evidence Contract
334
+
335
+ CodeGraph enforces a fail-closed evidence contract ([`src/codegraph/evidence_contract.py`](src/codegraph/evidence_contract.py)) across all **51 canonical relationship types** and **9 evidence classes**. CodeGraph prefers **explicit uncertainty** over **fabricated certainty**:
336
+
337
+ ```text
338
+ Dynamically resolved target (getattr(handler, action_name)())
339
+ ↓
340
+ UNRESOLVED_REFERENCE / POSSIBLE_CALLS (status = "UNKNOWN" | "POSSIBLE")
341
+ (Never fabricated into a verified CALLS edge)
342
+ ```
343
+
344
+ ### Current Evidence Vocabulary (`src/codegraph/evidence_contract.py`)
345
+
346
+ | Epistemic Status | Allowed Evidence Classes | What It Means |
347
+ | :--- | :--- | :--- |
348
+ | **`FACT`** | `AST_VERIFIED`, `STATIC_VERIFIED`, `FRAMEWORK_VERIFIED`, `DATAFLOW_VERIFIED` | Proven directly from syntax tree, framework decorator/router semantics, or conservative local dataflow. |
349
+ | **`RUNTIME_OBSERVED`** | `RUNTIME_OBSERVED` | Observed in user-supplied OpenTelemetry, JSONL, or SQL query logs (`hit_count`, `p50_ms`, `p95_ms`). |
350
+ | **`POSSIBLE`** | `POSSIBLE` | Plausible candidate relationship (`POSSIBLE_CALLS`, `POSSIBLE_TABLE`) requiring source inspection before mutation. |
351
+ | **`AMBIGUOUS`** | `AMBIGUOUS` | Multiple symbols or database tables match the bare identifier across modules or dialects; returns sorted `candidates`. |
352
+ | **`UNKNOWN`** | `UNKNOWN`, `RUNTIME_UNOBSERVED` | Target cannot be statically proven (dynamic reflection, external unindexed dependency, or `reason="resolution_budget_exceeded"`). |
353
+ | **`CONFLICT`** | Static vs. Runtime / Multi-Source | Static analysis and runtime observation (or competing definitions) disagree. |
354
+
355
+ ---
356
+
357
+ ## 8. Measured Performance (`v2.1.6` → `v2.1.7`)
358
+
359
+ ### Methodology
360
+ All indexing measurements below were recorded using [`benchmarks/run_v217_indexing_benchmark.py`](benchmarks/run_v217_indexing_benchmark.py) on the **same machine** (macOS `arm64`, Python `3.13`), **same repository fixtures**, and **same 16-phase telemetry harness**, comparing `v2.1.6` ([`benchmarks/reports/v217_before_metrics.json`](benchmarks/reports/v217_before_metrics.json)) against `v2.1.7` ([`benchmarks/reports/v217_after_metrics.json`](benchmarks/reports/v217_after_metrics.json)).
361
+
362
+ ### 4-Tier Scaling Summary (`54` → `2,504` Files)
363
+
364
+ | Workload Tier | Files | Symbols | Graph Edges | `v2.1.6` Total | `v2.1.7` Total | Improvement | `v2.1.7` Peak RSS | Peak WAL (`v2.1.6` → `v2.1.7`) | Final WAL |
365
+ | :--- | ---: | ---: | ---: | ---: | ---: | :--- | ---: | ---: | ---: |
366
+ | **Small** | `54` | `115` | `398` | `0.527 s` | `0.325 s` | **38.3% faster (`1.62x`)** | `46.25 MB` | `0.990 MB → 1.544 MB` | `0.0 MB` |
367
+ | **Medium** | `304` | `615` | `2,248` | `2.564 s` | `1.613 s` | **37.1% faster (`1.59x`)** | `62.67 MB` | `5.610 MB → 4.098 MB` | `0.0 MB` |
368
+ | **Large** | `1,004` | `2,015` | `7,428` | `8.730 s` | `5.296 s` | **39.3% faster (`1.65x`)** | `103.44 MB` | `19.300 MB → 5.033 MB` | `0.0 MB` |
369
+ | **Stress** | `2,504` | `5,015` | `18,528` | `21.983 s` | `13.395 s` | **39.1% faster (`1.64x`)** | `180.89 MB` | `46.980 MB → 6.628 MB` | `0.0 MB` |
370
+
371
+ ### Stress Tier (`2,504` Files) Phase Breakdown
372
+
373
+ | Phase / Metric | `v2.1.6` Baseline | `v2.1.7` Release | Measured Improvement |
374
+ | :--- | ---: | ---: | :--- |
375
+ | **Total Indexing Time** | `21.983 s` | `13.395 s` | **39.1% faster (`1.64x`)** |
376
+ | **Database Intelligence Pass** | `4.818 s` | `0.832 s` | **82.7% faster (`5.79x`)** |
377
+ | **Post-Processing Phase** | `13.770 s` | `7.056 s` | **48.8% faster (`1.95x`)** |
378
+ | **Symbol Resolution Phase** | `3.133 s` | `1.107 s` | **64.7% faster (`2.83x`)** |
379
+ | **Single-File Incremental Update** | `4.408 s` | `2.063 s` | **53.2% faster (`2.14x`)** |
380
+ | **Throughput (`files/sec`)** | `113.9 files/s` | `186.9 files/s` | **`+64.1%` throughput** |
381
+ | **Peak SQLite WAL Size** | `46.980 MB` | `6.628 MB` | **85.9% reduction (`7.09x` smaller)** |
382
+ | **Final SQLite WAL Size** | `0.000 MB` | `0.000 MB` | **100% reclaimed (`TRUNCATE`)** |
383
+ | **Indexed Symbols / Graph Edges** | `5,015` / `18,528` | `5,015` / `18,528` | **100% exact parity** |
384
+
385
+ ![CodeGraph — Measured Large-Repository Scaling](docs/assets/large_repo_scaling.svg)
386
+
387
+ ---
388
+
389
+ ## 9. Large-Repository Stress Testing: Home Assistant Core
390
+
391
+ Home Assistant Core is a large, complex public Python repository used as a real-world stress case for CodeGraph's indexing and post-processing pipeline.
392
+
393
+ ### 1. External Large-Repository Stress Observation (Pre-`v2.1.7`)
394
+ During external stress testing on a Home Assistant Core checkout (`~28,573` files), pre-`v2.1.7` indexing exhibited:
395
+ - Sustained single-core CPU usage (`~99%`) dominated by late post-processing
396
+ - Process memory peaking around `~1.1 GB` RSS before dropping
397
+ - Uncheckpointed `.codegraph/index.db-wal` growth reaching `~922 MB` because indexing held a single uncommitted transaction across all files and post-processing edges
398
+
399
+ ### 2. Reproducible Benchmark Fixture & Root-Cause Fixes (`v2.1.7`)
400
+ To profile and verify fixes deterministically in CI, [`benchmarks/run_v217_indexing_benchmark.py`](benchmarks/run_v217_indexing_benchmark.py) provisions a 4-tier Home Assistant-architecture fixture (`homeassistant/core`, `homeassistant/helpers`, `homeassistant/components/recorder` SQLAlchemy models/queries, `500` component domains, and `pytest` fixture suites; `2,504` files, `5,015` symbols, `18,528` edges):
401
+ - **Streaming & Token-Gated Database Pass**: Replaced the in-memory `file_contents` map and 8-per-file AST parses with streaming reads, fast token pre-filters (`has_potential_database_activity`, `has_potential_orm_models`), and a single shared `ast.AST` parse per candidate file (`4.818s → 0.832s`).
402
+ - **Pre-Indexed Binding & Symbol Resolution**: Replaced four $O(N_{\text{bindings}} \times N_{\text{symbols}})$ linear scans in [`src/codegraph/resolver.py`](src/codegraph/resolver.py) with pre-indexed maps and `@lru_cache(maxsize=65536)` on `normalize_module` (`3.133s → 1.107s`).
403
+ - **Chunked SQLite Commits & `TRUNCATE` Checkpoints**: Added composite indexes (`idx_imports_source_line`, `idx_calls_source_line`), bounded commit batches (`500` files / `10,000` edges), and `PRAGMA wal_checkpoint(TRUNCATE)` (`46.980 MB → 6.628 MB` peak WAL; `0.0 MB` final WAL).
404
+ - **Safe `Ctrl+C` Cancellation & Resume**: Interrupting `codegraph index` rolls back only the active batch, preserves committed batches, marks `resolution_dirty="1"`, and resumes cleanly on the next run.
405
+
406
+ ---
407
+
408
+ ## 10. Context Efficiency & Internal Agent Evaluation
409
+
410
+ ### 50-Task Context Compilation Benchmark ([`benchmarks/baselines/v2_0_verified.json`](benchmarks/baselines/v2_0_verified.json))
411
+
412
+ Rather than claiming a single universal token reduction percentage across all possible prompts, CodeGraph records candidate-vs-selected token metrics on every `get_context` call:
413
+
414
+ | Benchmark Metric | Measured Value | Source Artifact |
415
+ | :--- | ---: | :--- |
416
+ | **Evaluated Tasks** | `50 tasks` across `10 categories` | [`benchmarks/baselines/v2_0_verified.json`](benchmarks/baselines/v2_0_verified.json) |
417
+ | **Average Selected Tokens** | `542.0 tokens` | [`benchmarks/baselines/v2_0_verified.json`](benchmarks/baselines/v2_0_verified.json) |
418
+ | **Average Candidate-to-Selected Reduction Ratio** | `65.0%` (`0.65`) | [`benchmarks/baselines/v2_0_verified.json`](benchmarks/baselines/v2_0_verified.json) |
419
+ | **Compression at `budget = 200 tokens`** | `85.6%` reduction | [`benchmarks/baselines/context_baseline.json`](benchmarks/baselines/context_baseline.json) |
420
+ | **Compression at `budget = 600 tokens`** | `56.3%` reduction | [`benchmarks/baselines/context_baseline.json`](benchmarks/baselines/context_baseline.json) |
421
+ | **Cold vs. Warm `get_context` Latency (`p50`)** | `20.0 ms` cold → `0.67 ms` warm (`30.0x`) | [`benchmarks/baselines/context_baseline.json`](benchmarks/baselines/context_baseline.json) |
422
+ | **FACT / UNKNOWN / AMBIGUITY Correctness** | `100.0%` / `98.0%` / `100.0%` | [`benchmarks/baselines/v2_0_verified.json`](benchmarks/baselines/v2_0_verified.json) |
423
+
424
+ ### Results from the 32-Task Internal Evaluation ([`src/codegraph/tool_selection_eval.py`](src/codegraph/tool_selection_eval.py))
425
+
426
+ The table below reports results from the **32-task internal evaluation harness** (`run_tool_selection_ab_benchmark()`) comparing Mode A (unassisted exploration without CodeGraph routing rules) against Mode B (CodeGraph MCP + agent routing rules) on the same 32 tasks:
427
+
428
+ | Metric (32-Task Internal Evaluation) | Mode A (Baseline) | Mode B (CodeGraph MCP) | Delta |
429
+ | :--- | ---: | ---: | :--- |
430
+ | **Total Tool Calls** | `164` | `71` | `-93 calls (-56.7%)` |
431
+ | **Direct Full-File Reads** | `161` | `7` | `-154 file reads (-95.7%)` |
432
+ | **First-Tool Selection Accuracy** | `9.38%` | `100.0%` | `+90.62%` |
433
+ | **Unsupported Claims** | `11 (34.38%)` | `0 (0.00%)` | `-11 claims` |
434
+ | **Task Accuracy** | `59.84%` | `100.0%` | `+40.16%` |
435
+ | **12-Prompt Natural-Language Routing Eval** | — | `12 / 12 (100.0%)` | `12/12 on this evaluation set` |
436
+
437
+ ![CodeGraph — Measured Context & Exploration Efficiency](docs/assets/performance_comparison.svg)
438
+
439
+ ---
440
+
441
+ ## 11. Where CodeGraph Fits
442
+
443
+ CodeGraph is designed to work **alongside** your editor's language server (LSP), `ripgrep`, and structural AST tools.
444
+
445
+ Legend: `✓` supported • `◐` partial / workflow-dependent • `—` not established by cited documentation
446
+
447
+ | Capability | CodeGraph MCP (`v2.1.7`) | Editor LSP [1] | Structural AST (`ast-grep`) [2] | Lexical Search (`ripgrep`) [3] | Remote Code Search (`Sourcegraph MCP`) [4] |
448
+ | :--- | :---: | :---: | :---: | :---: | :---: |
449
+ | **Local-First & Offline Operation** | ✓ | ✓ | ✓ | ✓ | — |
450
+ | **Native MCP Server for AI Agents** | ✓ (14 default / 56 full) | — | ◐ | — | ✓ |
451
+ | **Semantic Symbol Graph (Callers / Callees)** | ✓ | ◐ (Position-based) | ◐ (Pattern-based) | — | ✓ (SCIP) |
452
+ | **Framework Route, Mount & DI Graph** | ✓ (`FastAPI`/`Flask`/`Django`/`Express`) | — | ◐ (Custom YAML rules) | — | — |
453
+ | **Database Schema, ORM, Migration & Table R/W** | ✓ (11 DB tools) | — | — | — | — |
454
+ | **Opt-In Runtime Trace Ingestion & Reconciliation** | ✓ (OTel / JSONL / SQL) | — | — | — | — |
455
+ | **Explicit Epistemic States (`FACT`/`POSSIBLE`/`UNKNOWN`)** | ✓ | — | — | — | — |
456
+ | **Literal Text Search Across HTML/JS/CSS/Config** | ✓ (`search_code`) | — | — | ✓ | ✓ |
457
+ | **Interactive Editor Hover, Completions & Diagnostics** | — | ✓ | ✓ (Lint/Rewrite) | — | — |
458
+ | **Multi-Repository Enterprise Cloud Search** | — | — | — | — | ✓ |
459
+
460
+ ![Repository Retrieval Approaches — Capability Comparison](docs/assets/capability_heatmap.svg)
461
+
462
+ For the complete multi-tool comparison and official references ([1] [LSP Specification](https://microsoft.github.io/language-server-protocol/specifications/lsp/current/), [2] [`ast-grep`](https://ast-grep.github.io/), [3] [`ripgrep`](https://github.com/BurntSushi/ripgrep), [4] [Sourcegraph MCP](https://sourcegraph.com/docs/api/mcp), [5] [Colby McHenry CodeGraph](https://github.com/colbymchenry/codegraph), [6] [GitHub Code Navigation](https://docs.github.com/en/repositories/working-with-files/using-files/navigating-code-on-github)), see [`docs/tool-comparison.md`](docs/tool-comparison.md).
463
+
464
+ ---
465
+
466
+ ## 12. Security, Privacy & Redaction Boundaries
467
+
468
+ CodeGraph runs **100% locally** (`stdio` MCP + local `.codegraph.sqlite3`), never executes repository code during indexing, and enforces strict file-access and redaction boundaries ([`src/codegraph/security/paths.py`](src/codegraph/security/paths.py), [`src/codegraph/security/redaction.py`](src/codegraph/security/redaction.py)).
469
+
470
+ ### `BLOCKED` vs. `REDACTED` Behavior
471
+
472
+ | Security Boundary | Enforcement Mode | Exact Behavior |
473
+ | :--- | :---: | :--- |
474
+ | **Sensitive Files** (`.env`, `.env.*`, `*.pem`, `*.key`, `*.crt`, `*.p12`, `*.pfx`, `id_rsa*`, `id_ed25519*`, `kubeconfig*`, `.npmrc`, `.pypirc`, `.netrc`, `.git/credentials`, `credentials*`, `secrets.*`, `*secret*.json/yaml`, `service-account*`, `.aws/*`, `.ssh/*`, `.gnupg/*`, `.kube/*`, `.docker/config.json`, `*.sqlite*`, `*.db`) | **`BLOCKED`** | Excluded from indexing and FTS; direct inspection via `get_file` or `read_file` is rejected with `SENSITIVE_FILE_ACCESS_DENIED`. |
475
+ | **Path Traversal & Symlink Escapes** (`../`, URL-encoded `%2e%2e`, null bytes, external symlinks) | **`BLOCKED`** | Canonical path check in `resolve_within_repo()` raises `SecurityError(ErrorCode.PATH_OUTSIDE_REPOSITORY)`. |
476
+ | **Binary Files** (`.pyc`, `.so`, `.dylib`, `.dll`, `.exe`, images, archives, PDFs, fonts, or NUL-byte files) | **`BLOCKED`** | Classified as `BINARY` and skipped during indexing and text search. |
477
+ | **Environment Variable Reads in Code** (`os.getenv("DATABASE_URL")`, `os.environ["OPENAI_API_KEY"]`) | **Metadata Only** | Records `READS_ENV` with the **variable name only**; never reads `.env` or runtime environment values. |
478
+ | **Database Connection Strings** (`postgresql://user:pass@host:5432/prod`) | **`REDACTED`** | Preserves dialect and database name while sanitizing credentials to `postgresql://[REDACTED]@[REDACTED]/prod`. |
479
+ | **API Keys, Bearer Tokens, JWTs & Private Keys** (`sk-...`, `ghp_...`, `AKIA...`, `AIza...`, `xoxb-...`, `eyJ...`, `-----BEGIN ... PRIVATE KEY-----`) | **`REDACTED`** | Replaced with `[REDACTED_SECRET]`, `Bearer [REDACTED]`, or `[REDACTED_PRIVATE_KEY]` before FTS indexing, `search_code`, `get_file`, `get_context`, or MCP responses. |
480
+ | **Runtime HTTP Headers & SQL Query Literals** (`authorization`, `cookie`, `set-cookie`, `x-api-key`, `WHERE password = '...'`) | **`REDACTED`** | Sensitive runtime keys and SQL literals are scrubbed (`[REDACTED]` / `?`) during `ingest_runtime_traces`. |
481
+
482
+ Run `codegraph privacy .` at any time to audit the local SQLite database and verify that no sensitive files or unredacted secrets are stored.
483
+
484
+ ---
485
+
486
+ ## 13. MCP Tooling & Profiles (14 Default / 56 Full)
487
+
488
+ By default, `create_server()` exposes the **14-tool `agent` profile** so AI coding agents receive a focused, non-overlapping tool surface. All 56 tools are available under `--profile full`.
489
+
490
+ ### Default `agent` Profile (14 High-Signal Tools)
491
+
492
+ | Category | Tool | Purpose |
493
+ | :--- | :--- | :--- |
494
+ | **Discovery (7)** | `find_symbol` | Locate a symbol definition by short, qualified, or canonical name (`symbol=...`). |
495
+ | | `search_code` | Literal or regex search across Python, JS/TS, HTML/Jinja, CSS, YAML/JSON, Markdown, and SQL. |
496
+ | | `find_references` | Find verified AST reference, import, and registration sites for a symbol. |
497
+ | | `find_callers` | Find functions, methods, or route handlers that call the target symbol (`CALLS`, `POSSIBLE_CALLS`). |
498
+ | | `find_callees` | Find functions, methods, or constructors called by the target symbol. |
499
+ | | `find_tests` | Find `pytest` / `unittest` test functions covering a symbol, route, DI provider, or event handler. |
500
+ | | `find_routes` | Discover FastAPI, Flask, Django, and Express HTTP routes with composed mount prefixes. |
501
+ | **Details & Context (5)** | `get_symbol` | Retrieve signature, decorators, docstring, line range, and methods for a symbol. |
502
+ | | `get_file` | Read bounded line ranges (`start_line`, `end_line`, `max_lines`) and AST symbol outline of a file. |
503
+ | | `get_context` | Compile a token-budgeted, task-aware context packet (`query`, `intent`, `max_tokens`). |
504
+ | | `get_architecture` | Summarize repository languages, layers, packages, entrypoints, routes, and database entities. |
505
+ | | `get_git_impact` | Compute blast-radius impact (`changed_files`, `affected_callers`, `affected_routes`, `tests`) for a Git diff. |
506
+ | **Graph Tracing (2)** | `trace_path` | Find the shortest verified execution path between `from_symbol` and `to_symbol`. |
507
+ | | `trace_flow` | Trace upstream callers and downstream callees around `symbol` up to `depth`. |
508
+
509
+ ### All 6 Implemented MCP Profiles ([`src/codegraph/agent_capabilities.py`](src/codegraph/agent_capabilities.py))
510
+
511
+ | Profile | Tool Count | Description |
512
+ | :--- | :---: | :--- |
513
+ | **`agent`** *(default in `create_server`)* | **14** | High-signal discovery, bounded file inspection, context synthesis, and path tracing. |
514
+ | **`core`** | **13** | Lightweight symbol lookup, callers/callees, imports/dependents, routes, and architecture. |
515
+ | **`graph`** | **17** | Call-graph traversal, blast-radius impact (`analyze_impact`), and test discovery. |
516
+ | **`minimal`** | **21** | Core interrogation plus `get_context`, `search_code`, `read_file`, and `verify_evidence`. |
517
+ | **`developer`** | **34** | Interactive development with Git history (`get_file_history`, `get_recent_changes`) and retrieval planning. |
518
+ | **`full`** | **56** | Complete capability surface including **11 Database tools** (`get_db_schema`, `get_db_table`, `find_db_tables`, `find_db_columns`, `find_db_models`, `find_db_queries`, `find_db_readers`, `find_db_writers`, `find_db_callers`, `find_db_relationships`, `get_db_impact`) and **3 Runtime tools** (`ingest_runtime_traces`, `get_runtime_trace`, `reconcile_static_runtime`). |
519
+
520
+ See [`docs/agent-brain.md`](docs/agent-brain.md) and [`agent-rules/tool-capabilities-summary.md`](agent-rules/tool-capabilities-summary.md) for the complete 56-tool reference.
521
+
522
+ ---
523
+
524
+ ## 14. CLI Reference
525
+
526
+ Every command below is verified against [`src/codegraph/cli.py`](src/codegraph/cli.py):
527
+
528
+ ```bash
529
+ # Agent Onboarding & Uninstall
530
+ codegraph install # Interactive agent detection & setup
531
+ codegraph install --yes --target auto --location local # Non-interactive local setup
532
+ codegraph install --print-config claude # Print MCP JSON + rules for an agent
533
+ codegraph install --dry-run # Preview planned file changes
534
+ codegraph uninstall --dry-run # Preview removal of CodeGraph agent blocks
535
+ codegraph uninstall --yes # Remove CodeGraph agent integrations
536
+
537
+ # Repository Initialization & Indexing
538
+ codegraph init . # Initialize and index repository
539
+ codegraph index . --verbose # Incremental index with 16-phase telemetry
540
+ codegraph index . --json # Output structured JSON phase telemetry
541
+ codegraph uninit --dry-run # Preview removal of .codegraph.sqlite3
542
+
543
+ # Health, Integrity & Privacy Diagnostics
544
+ codegraph status . # Show index freshness and graph counts
545
+ codegraph doctor . --database --resources # Verify SQLite integrity, FKs, FTS, and memory
546
+ codegraph privacy . # Verify zero sensitive files indexed
547
+ codegraph version # Print CodeGraph version (2.1.7)
548
+
549
+ # Code, Graph & Context Interrogation
550
+ codegraph search "authenticate" -r . # Search indexed symbols and chunks
551
+ codegraph symbols src/codegraph/cli.py -r . # List extracted symbols in a file
552
+ codegraph get-symbol Indexer -r . # Get AST details for a symbol
553
+ codegraph resolve-symbol resolve_Repository -r . # Ground symbol or return ambiguous candidates
554
+ codegraph resolve Indexer -r . # Resolve symbol with callers and callees
555
+ codegraph trace Indexer -d 2 -r . # Trace callers and callees up to depth 2
556
+ codegraph graph -r . # Summarize graph nodes and edges
557
+ codegraph routes -r . # List discovered HTTP routes
558
+ codegraph imports src/codegraph/cli.py -r . # List file/module imports
559
+ codegraph dependents src/codegraph/cli.py -r . # List reverse dependents
560
+ codegraph architecture -r . # Summarize repository architecture
561
+ codegraph debug "trace authentication flow" -r . # Return facts and debugging hypotheses
562
+ codegraph task "trace /api/v1/auth/login" # Normalize prompt into a TaskSpec
563
+ codegraph plan "trace /api/v1/auth/login" -r . # Build deterministic RetrievalPlan
564
+ codegraph context "trace /api/v1/auth/login" -r . # Compile token-budgeted ContextPacket
565
+ codegraph explain-context "trace /api/v1/auth/login" -r . # ContextPacket with budget rejection reasons
566
+ codegraph memory list -r . # Inspect repository-scoped notes
567
+ codegraph benchmark -r . # Run deterministic benchmark suite
568
+
569
+ # MCP Server Subcommands
570
+ codegraph mcp serve . # Start stdio MCP server
571
+ codegraph mcp serve . --profile full # Start stdio MCP server with all 56 tools
572
+ codegraph mcp doctor . # End-to-end MCP startup & query check
573
+ codegraph mcp config-check . # Read-only MCP config validation
574
+ codegraph mcp capabilities # Print machine-readable capability manifest
575
+ codegraph mcp rules --agent claude # Render agent rules for a specific agent
576
+ ```
577
+
578
+ ---
579
+
580
+ ## 15. Honest Limitations
581
+
582
+ 1. **Dynamic Metaprogramming & Reflection**: Calls constructed dynamically (`getattr(obj, dynamic_name)()`, `eval`, `exec`, `importlib.import_module(var)`, or runtime monkey-patching) cannot be proven statically. CodeGraph intentionally records these as `UNKNOWN` (`UNRESOLVED_REFERENCE` or `POSSIBLE_CALLS`) rather than inventing edges.
583
+ 2. **Bounded Wildcard & Re-Export Chains**: To guarantee termination on pathological repositories with circular `from x import *` chains, resolution halts at `max_reexport_depth=16` (`max_wildcard_expansions=64`) and emits `UNKNOWN` with `reason="resolution_budget_exceeded"`.
584
+ 3. **Python-First Depth vs. JS/TS Secondary Support**: Python receives deep AST, decorator, local dataflow (`LocalBindingResolver`), FastAPI/Flask/Django route, and SQLAlchemy/Django/SQLModel/Alembic analysis. JavaScript/TypeScript supports functions, classes, imports, calls, Express routes, and Prisma schemas, without full TypeScript compiler type evaluation.
585
+ 4. **Opt-In Runtime Telemetry Scope**: Runtime edges (`RUNTIME_OBSERVED`) reflect only the trace files you explicitly ingest. Unobserved paths (`NOT_OBSERVED_AT_RUNTIME`) are not dead code.
586
+ 5. **Very Large Pathological Repositories**: While `v2.1.7` reduces indexing time by `39.1%` and caps WAL size via chunked commits, initial cold indexing on repositories with tens of thousands of files still requires proportional CPU and disk I/O time (subsequent runs are incremental).
587
+
588
+ ---
589
+
590
+ ## 16. Documentation Map
591
+
592
+ - **Deep Agent Brain & 56-Tool Reference**: [`docs/agent-brain.md`](docs/agent-brain.md)
593
+ - **Compact Tool Capabilities Summary**: [`agent-rules/tool-capabilities-summary.md`](agent-rules/tool-capabilities-summary.md)
594
+ - **Detailed Multi-Tool Capability Comparison**: [`docs/tool-comparison.md`](docs/tool-comparison.md)
595
+ - **Antigravity Skill (`SKILL.md`)**: [`.agents/skills/codegraph/SKILL.md`](.agents/skills/codegraph/SKILL.md)
596
+ - **Agent Rule Packs (`Claude`, `Cursor`, `Antigravity`, `Codex`, `Gemini`, `Cline`)**: [`agent-rules/README.md`](agent-rules/README.md) & [`agent-rules/AGENTS.md`](agent-rules/AGENTS.md)
597
+ - **Engineering & Production Readiness**: [`docs/engineering/production-readiness.md`](docs/engineering/production-readiness.md)
598
+ - **Reproducible `v2.1.7` Benchmark Script & Artifacts**: [`benchmarks/run_v217_indexing_benchmark.py`](benchmarks/run_v217_indexing_benchmark.py), [`benchmarks/reports/v217_before_metrics.json`](benchmarks/reports/v217_before_metrics.json), [`benchmarks/reports/v217_after_metrics.json`](benchmarks/reports/v217_after_metrics.json)
599
+ - **Changelog**: [`CHANGELOG.md`](CHANGELOG.md)
600
+
601
+ ---
602
+
603
+ ## 17. Contributing & License
604
+
605
+ ```bash
606
+ git clone https://github.com/raghurammrsd/CODE_GRAPH_MCP.git
607
+ cd CODE_GRAPH_MCP
608
+ python3 -m venv .venv
609
+ source .venv/bin/activate
610
+ pip install -e ".[dev,mcp,system]"
611
+
612
+ python3 -m ruff check .
613
+ python3 -m mypy src/
614
+ python3 -m pytest -q
615
+ ```
616
+
617
+ Licensed under the [MIT License](LICENSE).