codegraph-engine 2.2.1__py3-none-any.whl → 3.0.0__py3-none-any.whl

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 (82) hide show
  1. codegraph/__init__.py +1 -1
  2. codegraph/agent_brain.py +172 -2
  3. codegraph/agent_capabilities.py +564 -6
  4. codegraph/agent_rules.py +1 -1
  5. codegraph/api_drift.py +455 -0
  6. codegraph/async_queue/__init__.py +50 -0
  7. codegraph/async_queue/detectors/__init__.py +48 -0
  8. codegraph/async_queue/detectors/celery.py +160 -0
  9. codegraph/async_queue/detectors/kafka.py +168 -0
  10. codegraph/async_queue/detectors/rabbitmq.py +116 -0
  11. codegraph/async_queue/detectors/redis.py +130 -0
  12. codegraph/async_queue/detectors/sqs.py +135 -0
  13. codegraph/async_queue/models.py +161 -0
  14. codegraph/async_queue/otel_models.py +74 -0
  15. codegraph/async_queue/otel_parser.py +337 -0
  16. codegraph/async_queue/reconciler.py +427 -0
  17. codegraph/async_queue/scanner.py +291 -0
  18. codegraph/async_queue/traversal.py +447 -0
  19. codegraph/branch_comparison.py +197 -0
  20. codegraph/change_impact.py +547 -0
  21. codegraph/cli.py +992 -3
  22. codegraph/cli_output.py +17 -2
  23. codegraph/context.py +38 -11
  24. codegraph/context_freshness.py +351 -0
  25. codegraph/database/__init__.py +14 -0
  26. codegraph/database/extractor.py +712 -17
  27. codegraph/database/interrogation.py +388 -2
  28. codegraph/database/schema_drift.py +862 -0
  29. codegraph/epistemic.py +7 -0
  30. codegraph/evidence_contract.py +21 -0
  31. codegraph/frameworks.py +171 -6
  32. codegraph/frameworks_nestjs.py +502 -0
  33. codegraph/frameworks_nextjs.py +337 -0
  34. codegraph/frameworks_react.py +457 -0
  35. codegraph/freshness.py +2 -0
  36. codegraph/frontend_html.py +109 -0
  37. codegraph/git.py +2 -0
  38. codegraph/git_state.py +545 -0
  39. codegraph/indexing/__init__.py +7 -1
  40. codegraph/indexing/indexer.py +291 -38
  41. codegraph/indexing/models.py +6 -0
  42. codegraph/indexing/parser.py +239 -0
  43. codegraph/indexing/pool.py +136 -0
  44. codegraph/indexing/scanner.py +6 -0
  45. codegraph/indexing/templates.py +418 -0
  46. codegraph/interrogation.py +128 -20
  47. codegraph/mcp/server.py +258 -27
  48. codegraph/models.py +7 -0
  49. codegraph/monorepo.py +3 -0
  50. codegraph/optimizer.py +42 -5
  51. codegraph/process_lifecycle.py +31 -13
  52. codegraph/refactor/__init__.py +36 -0
  53. codegraph/refactor/models.py +114 -0
  54. codegraph/refactor/renamer.py +844 -0
  55. codegraph/refactor/transactions.py +403 -0
  56. codegraph/resolver.py +1202 -159
  57. codegraph/retrieval_policy.py +6 -0
  58. codegraph/route_topology.py +172 -0
  59. codegraph/runtime/__init__.py +19 -0
  60. codegraph/runtime/collector.py +155 -0
  61. codegraph/runtime/db_watcher.py +191 -0
  62. codegraph/runtime/ingestor.py +30 -10
  63. codegraph/runtime/port_inspector.py +304 -0
  64. codegraph/runtime/runner.py +155 -6
  65. codegraph/runtime/trace_linker.py +175 -0
  66. codegraph/search/hybrid.py +26 -0
  67. codegraph/semantic_conflicts.py +270 -0
  68. codegraph/semantic_decorators.py +34 -3
  69. codegraph/structural_diff.py +542 -0
  70. codegraph/styles.py +144 -0
  71. codegraph/symbol_history.py +277 -0
  72. codegraph/tsconfig.py +236 -0
  73. codegraph/ui/__init__.py +6 -0
  74. codegraph/ui/server.py +715 -0
  75. codegraph/watcher.py +323 -0
  76. {codegraph_engine-2.2.1.dist-info → codegraph_engine-3.0.0.dist-info}/METADATA +257 -39
  77. codegraph_engine-3.0.0.dist-info/RECORD +129 -0
  78. codegraph_engine-2.2.1.dist-info/RECORD +0 -87
  79. {codegraph_engine-2.2.1.dist-info → codegraph_engine-3.0.0.dist-info}/WHEEL +0 -0
  80. {codegraph_engine-2.2.1.dist-info → codegraph_engine-3.0.0.dist-info}/entry_points.txt +0 -0
  81. {codegraph_engine-2.2.1.dist-info → codegraph_engine-3.0.0.dist-info}/licenses/LICENSE +0 -0
  82. {codegraph_engine-2.2.1.dist-info → codegraph_engine-3.0.0.dist-info}/top_level.txt +0 -0
codegraph/__init__.py CHANGED
@@ -1,6 +1,6 @@
1
1
  """CodeGraph MCP: local, evidence-backed codebase intelligence."""
2
2
 
3
- __version__ = "2.2.1"
3
+ __version__ = "3.0.0"
4
4
  from codegraph.errors import (
5
5
  CodeGraphError,
6
6
  ErrorCode,
codegraph/agent_brain.py CHANGED
@@ -644,6 +644,176 @@ RELATIONSHIP_SEMANTICS_REGISTRY: dict[str, RelationshipSemanticsSpec] = {
644
644
  common_tool="get_db_schema / get_context",
645
645
  example="`src/config.py` -> `READS_ENV` (`AST_VERIFIED`) -> `env:DATABASE_URL`",
646
646
  ),
647
+ "RENDERS": RelationshipSemanticsSpec(
648
+ relationship="RENDERS",
649
+ meaning="React JSX component renders a child component element (`<ChildComponent ... />`).",
650
+ typical_source="Parent component symbol (`DashboardPage`, `InvoiceTable`)",
651
+ typical_target="Child component symbol (`InvoiceCard`, `Button`)",
652
+ proves="Static JSX component composition tree hierarchy.",
653
+ does_not_prove="Does not prove conditional branch execution at runtime unless inspected.",
654
+ common_tool="find_callers / find_callees / get_references",
655
+ example="`Dashboard` -> `RENDERS` (`AST_VERIFIED`) -> `InvoiceTable`",
656
+ ),
657
+ "USES_HOOK": RelationshipSemanticsSpec(
658
+ relationship="USES_HOOK",
659
+ meaning="React component or custom hook calls a state/lifecycle hook (`useAuth()`, `useInvoices()`).",
660
+ typical_source="Component or custom hook (`UserProfile`, `useOrderDetails`)",
661
+ typical_target="Hook function symbol (`useAuth`, `useQuery`)",
662
+ proves="Component or custom hook lifecycle dependency on target hook.",
663
+ does_not_prove="Does not prove hook return value shape without inspecting hook definition.",
664
+ common_tool="find_callers / get_references / trace_path",
665
+ example="`UserProfile` -> `USES_HOOK` (`FRAMEWORK_VERIFIED`) -> `useAuth`",
666
+ ),
667
+ "IMPORTS_STYLE": RelationshipSemanticsSpec(
668
+ relationship="IMPORTS_STYLE",
669
+ meaning="Component or module imports a CSS/SCSS stylesheet or CSS module (`import styles from './Button.module.css'`).",
670
+ typical_source="Component or page file (`Button.tsx`)",
671
+ typical_target="Stylesheet file (`Button.module.css`, `globals.css`)",
672
+ proves="Component imports style definitions from target stylesheet.",
673
+ does_not_prove="Does not prove all style classes in the file are actively applied.",
674
+ common_tool="find_references / get_file / get_context",
675
+ example="`Button.tsx` -> `IMPORTS_STYLE` (`AST_VERIFIED`) -> `Button.module.css`",
676
+ ),
677
+ "USES_STYLE_CLASS": RelationshipSemanticsSpec(
678
+ relationship="USES_STYLE_CLASS",
679
+ meaning="JSX element or component references a CSS class selector (`className={styles.header}` or `className='btn-primary'`).",
680
+ typical_source="Component or JSX element (`Header.tsx`)",
681
+ typical_target="CSS class symbol (`.header-title`, `.btn-primary`)",
682
+ proves="Component applies the named CSS style class.",
683
+ does_not_prove="Does not prove CSS specificity or cascade overrides.",
684
+ common_tool="find_references / search_code / get_context",
685
+ example="`Header.tsx` -> `USES_STYLE_CLASS` (`FRAMEWORK_VERIFIED`) -> `.header-title`",
686
+ ),
687
+ "FETCHES_ROUTE": RelationshipSemanticsSpec(
688
+ relationship="FETCHES_ROUTE",
689
+ meaning="Frontend component, hook, or API client invokes a backend HTTP route (`fetch('/api/v1/invoices')`, `axios.get(...)`).",
690
+ typical_source="Frontend component or data hook (`useInvoices`, `createInvoiceForm`)",
691
+ typical_target="Backend route endpoint (`POST /api/v1/invoices`, `GET /api/v1/users`)",
692
+ proves="Frontend client-side network request targeting a backend route.",
693
+ does_not_prove="Does not prove backend server availability at runtime.",
694
+ common_tool="find_callers / trace_path / list_routes",
695
+ example="`useInvoices` -> `FETCHES_ROUTE` (`FRAMEWORK_VERIFIED`) -> `GET /api/v1/invoices`",
696
+ ),
697
+ "LOADS_SCRIPT": RelationshipSemanticsSpec(
698
+ relationship="LOADS_SCRIPT",
699
+ meaning="HTML template or page loads a JavaScript/TypeScript script bundle (`<script src='...'>`).",
700
+ typical_source="HTML file (`index.html`)",
701
+ typical_target="Script file (`src/main.tsx`, `bundle.js`)",
702
+ proves="HTML document includes and executes target script.",
703
+ does_not_prove="Does not prove script execution order if async/defer are used.",
704
+ common_tool="find_references / get_file",
705
+ example="`index.html` -> `LOADS_SCRIPT` (`STATIC_VERIFIED`) -> `src/main.tsx`",
706
+ ),
707
+ "LOADS_STYLESHEET": RelationshipSemanticsSpec(
708
+ relationship="LOADS_STYLESHEET",
709
+ meaning="HTML template or page loads an external stylesheet (`<link rel='stylesheet' href='...'>`).",
710
+ typical_source="HTML file (`index.html`)",
711
+ typical_target="Stylesheet file (`src/index.css`, `theme.css`)",
712
+ proves="HTML document links target stylesheet for presentation.",
713
+ does_not_prove="Does not prove runtime CDN stylesheet availability.",
714
+ common_tool="find_references / get_file",
715
+ example="`index.html` -> `LOADS_STYLESHEET` (`STATIC_VERIFIED`) -> `src/index.css`",
716
+ ),
717
+ "MAPS_TO_COLLECTION": RelationshipSemanticsSpec(
718
+ relationship="MAPS_TO_COLLECTION",
719
+ meaning="NoSQL document model (Mongoose model) maps to an underlying MongoDB collection.",
720
+ typical_source="Mongoose model (`InvoiceModel`)",
721
+ typical_target="MongoDB collection (`invoices`)",
722
+ proves="Static mapping between document model and database collection.",
723
+ does_not_prove="Does not prove database schema strictness unless validation options are inspected.",
724
+ common_tool="find_db_tables / find_db_models / get_db_table",
725
+ example="`InvoiceModel` -> `MAPS_TO_COLLECTION` (`FRAMEWORK_VERIFIED`) -> `db.UNKNOWN.UNKNOWN.invoices`",
726
+ ),
727
+ "WRITES_COLLECTION": RelationshipSemanticsSpec(
728
+ relationship="WRITES_COLLECTION",
729
+ meaning="Function or route writes (insert, update, delete) documents to a MongoDB collection.",
730
+ typical_source="Caller symbol or API handler (`createInvoice`)",
731
+ typical_target="MongoDB collection (`invoices`)",
732
+ proves="Write operation (`Model.create`, `Model.updateOne`, `insertOne`) against target collection.",
733
+ does_not_prove="Does not prove transaction commit or replica-set write concern acknowledgment.",
734
+ common_tool="find_db_writers / get_context / trace_path",
735
+ example="`createInvoice` -> `WRITES_COLLECTION` (`AST_VERIFIED`) -> `db.UNKNOWN.UNKNOWN.invoices`",
736
+ ),
737
+ "READS_COLLECTION": RelationshipSemanticsSpec(
738
+ relationship="READS_COLLECTION",
739
+ meaning="Function or route reads (find, aggregate, count) documents from a MongoDB collection.",
740
+ typical_source="Caller symbol or API handler (`listInvoices`)",
741
+ typical_target="MongoDB collection (`invoices`)",
742
+ proves="Read query (`Model.find`, `Model.findOne`, `aggregate`) against target collection.",
743
+ does_not_prove="Does not prove document existence at runtime.",
744
+ common_tool="find_db_readers / get_context / trace_path",
745
+ example="`listInvoices` -> `READS_COLLECTION` (`AST_VERIFIED`) -> `db.UNKNOWN.UNKNOWN.invoices`",
746
+ ),
747
+ "DISPATCHES_TASK": RelationshipSemanticsSpec(
748
+ relationship="DISPATCHES_TASK",
749
+ meaning="Caller function or route dispatches a background task (.delay(), .apply_async(), .send_task()).",
750
+ typical_source="Caller symbol or API handler (`checkout_order`, `register_user`)",
751
+ typical_target="Task handler function (`process_order_payment`, `send_welcome_email`)",
752
+ proves="Background task invocation connects caller to the queued task handler.",
753
+ does_not_prove="Does not prove queue worker status or job execution timing.",
754
+ common_tool="trace_path / find_callees / get_context",
755
+ example="`checkout_order` -> `DISPATCHES_TASK` (`FRAMEWORK_VERIFIED`) -> `process_order_payment`",
756
+ ),
757
+ "TRIGGERS_SIGNAL": RelationshipSemanticsSpec(
758
+ relationship="TRIGGERS_SIGNAL",
759
+ meaning="Model lifecycle action (save, delete) or signal emission triggers a signal receiver.",
760
+ typical_source="Model or lifecycle method (`Customer.save`, `signal.send`)",
761
+ typical_target="Signal receiver function (`on_customer_created`)",
762
+ proves="Django signal linkage connects the model or trigger site to registered receivers.",
763
+ does_not_prove="Does not prove transaction commit before receiver execution.",
764
+ common_tool="trace_path / find_callees / get_context",
765
+ example="`Customer.save` -> `TRIGGERS_SIGNAL` (`FRAMEWORK_VERIFIED`) -> `on_customer_created`",
766
+ ),
767
+ "HANDLES_SIGNAL": RelationshipSemanticsSpec(
768
+ relationship="HANDLES_SIGNAL",
769
+ meaning="Signal receiver function handles lifecycle events or domain signals from a sender model.",
770
+ typical_source="Receiver function (`on_customer_created`)",
771
+ typical_target="Sender model symbol (`Customer`)",
772
+ proves="Receiver function is bound to the sender model via @receiver or signal.connect.",
773
+ does_not_prove="Does not prove receiver handles all signal kwargs.",
774
+ common_tool="find_callers / get_references / get_context",
775
+ example="`on_customer_created` -> `HANDLES_SIGNAL` (`FRAMEWORK_VERIFIED`) -> `Customer`",
776
+ ),
777
+ "RENDERS_TEMPLATE": RelationshipSemanticsSpec(
778
+ relationship="RENDERS_TEMPLATE",
779
+ meaning="View or controller renders an HTML or Jinja template (render_template, TemplateResponse, template_name).",
780
+ typical_source="View handler symbol (`dashboard_view`)",
781
+ typical_target="Template file path (`templates/dashboard.html`)",
782
+ proves="Deterministic linkage between backend view function and frontend HTML template.",
783
+ does_not_prove="Does not prove all template context variables are provided.",
784
+ common_tool="list_routes / get_context / find_callees",
785
+ example="`dashboard_view` -> `RENDERS_TEMPLATE` (`FRAMEWORK_VERIFIED`) -> `templates/dashboard.html`",
786
+ ),
787
+ "DISPATCHES_FORWARD": RelationshipSemanticsSpec(
788
+ relationship="DISPATCHES_FORWARD",
789
+ meaning="Neural network module invocation (model(inputs), self.submodule(x)) dispatches to nn.Module.forward().",
790
+ typical_source="Caller function or model forward pass (`predict`, `Classifier.forward`)",
791
+ typical_target="Submodule or model forward method (`Encoder.forward`, `Linear.forward`)",
792
+ proves="PyTorch __call__ dispatch to forward method on a concrete or resolved module instance.",
793
+ does_not_prove="Does not prove runtime execution if forward hooks or dynamic wrappers abort execution.",
794
+ common_tool="trace_path / find_callees / get_context",
795
+ example="`predict` -> `DISPATCHES_FORWARD` (`AST_VERIFIED`) -> `Classifier.forward`",
796
+ ),
797
+ "TOOL_HANDLER": RelationshipSemanticsSpec(
798
+ relationship="TOOL_HANDLER",
799
+ meaning="Function or method is decorated as an agentic AI tool (@tool, @function_tool, @agent).",
800
+ typical_source="Tool function (`search_web_tool`, `execute_sql`)",
801
+ typical_target="Agent framework registration decorator (`@tool`)",
802
+ proves="Function is registered as a callable tool in an agentic workflow.",
803
+ does_not_prove="Does not prove tool argument schema compatibility with LLM runtime.",
804
+ common_tool="find_references / get_symbol / get_context",
805
+ example="`search_web_tool` -> `TOOL_HANDLER` (`FRAMEWORK_VERIFIED`) -> `@tool`",
806
+ ),
807
+ "PIPELINE_STEP": RelationshipSemanticsSpec(
808
+ relationship="PIPELINE_STEP",
809
+ meaning="Sequential execution link in an AI/ML pipeline or LangChain LCEL chain (prompt | llm | parser).",
810
+ typical_source="Upstream pipeline component or prompt template (`prompt_template`)",
811
+ typical_target="Downstream pipeline component or model runner (`chat_model`)",
812
+ proves="Dataflow pipe composition between execution steps in an AI/ML workflow.",
813
+ does_not_prove="Does not prove runtime type convergence between pipe boundaries.",
814
+ common_tool="trace_path / find_callees / get_context",
815
+ example="`prompt_template` -> `PIPELINE_STEP` (`DATAFLOW_VERIFIED`) -> `chat_model`",
816
+ ),
647
817
  }
648
818
 
649
819
 
@@ -1248,7 +1418,7 @@ CodeGraph enforces nine canonical `evidence_class` values defined in `ALLOWED_EV
1248
1418
 
1249
1419
  ## 5. Relationship Model
1250
1420
 
1251
- CodeGraph enforces the 56 canonical relationship types in `ALLOWED_RELATIONSHIP_EVIDENCE_MATRIX`. It **never** collapses framework routing, database operations, registry registration, or dependency injection into generic `CALLS` or `DEPENDS_ON`.
1421
+ CodeGraph enforces the {len(ALLOWED_RELATIONSHIP_EVIDENCE_MATRIX)} canonical relationship types in `ALLOWED_RELATIONSHIP_EVIDENCE_MATRIX`. It **never** collapses framework routing, database operations, registry registration, or dependency injection into generic `CALLS` or `DEPENDS_ON`.
1252
1422
 
1253
1423
  {relationships_block}
1254
1424
 
@@ -1547,7 +1717,7 @@ Repository -> Candidate Facts -> Task-Aware Filtering (RetrievalPolicy)
1547
1717
 
1548
1718
  - **Hard Invariants & Output Boundaries of `get_context`**:
1549
1719
  - Primary input is `query` (`task` is also supported as a string or `TaskSpec` dict alias).
1550
- - Enforces strict output boundaries BEFORE MCP serialization: `max_tokens` (default `4000`, hard cap `20000`), `max_files` (default `15`, hard cap `30`), and `max_lines` (default `500`, hard cap `1500`).
1720
+ - Enforces strict output boundaries BEFORE MCP serialization: `max_tokens` (default `4000`, hard cap `20000`), `max_files` (default `25`, hard cap `40`), and `max_lines` (default `500`, hard cap `1500`).
1551
1721
  - Returns explicit budget metadata: `selected_tokens`, `candidate_tokens`, `selected_files`, `selected_lines`, `coverage_score`, and `truncated`.
1552
1722
  - Preserves `unknowns` and `ambiguities` explicitly—never drops uncertainty to save tokens.
1553
1723
  - Compresses duplicate `(source, target, relationship)` edges into a single record with `occurrence_count` and `supporting_locations`.