codegraph-engine 2.3.0__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 (80) hide show
  1. codegraph/__init__.py +1 -1
  2. codegraph/agent_brain.py +172 -2
  3. codegraph/agent_capabilities.py +320 -3
  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/change_impact.py +320 -110
  20. codegraph/cli.py +776 -25
  21. codegraph/cli_output.py +17 -2
  22. codegraph/context.py +38 -11
  23. codegraph/context_freshness.py +2 -0
  24. codegraph/database/__init__.py +14 -0
  25. codegraph/database/extractor.py +712 -17
  26. codegraph/database/interrogation.py +388 -2
  27. codegraph/database/schema_drift.py +862 -0
  28. codegraph/epistemic.py +7 -0
  29. codegraph/evidence_contract.py +21 -0
  30. codegraph/frameworks.py +171 -6
  31. codegraph/frameworks_nestjs.py +502 -0
  32. codegraph/frameworks_nextjs.py +337 -0
  33. codegraph/frameworks_react.py +457 -0
  34. codegraph/freshness.py +2 -0
  35. codegraph/frontend_html.py +109 -0
  36. codegraph/git.py +2 -0
  37. codegraph/git_state.py +2 -0
  38. codegraph/indexing/__init__.py +7 -1
  39. codegraph/indexing/indexer.py +291 -38
  40. codegraph/indexing/models.py +6 -0
  41. codegraph/indexing/parser.py +239 -0
  42. codegraph/indexing/pool.py +136 -0
  43. codegraph/indexing/scanner.py +6 -0
  44. codegraph/indexing/templates.py +418 -0
  45. codegraph/interrogation.py +128 -20
  46. codegraph/mcp/server.py +190 -28
  47. codegraph/models.py +7 -0
  48. codegraph/monorepo.py +3 -0
  49. codegraph/optimizer.py +42 -5
  50. codegraph/process_lifecycle.py +31 -13
  51. codegraph/refactor/__init__.py +36 -0
  52. codegraph/refactor/models.py +114 -0
  53. codegraph/refactor/renamer.py +844 -0
  54. codegraph/refactor/transactions.py +403 -0
  55. codegraph/resolver.py +1202 -159
  56. codegraph/retrieval_policy.py +6 -0
  57. codegraph/route_topology.py +172 -0
  58. codegraph/runtime/__init__.py +19 -0
  59. codegraph/runtime/collector.py +155 -0
  60. codegraph/runtime/db_watcher.py +191 -0
  61. codegraph/runtime/ingestor.py +30 -10
  62. codegraph/runtime/port_inspector.py +304 -0
  63. codegraph/runtime/runner.py +155 -6
  64. codegraph/runtime/trace_linker.py +175 -0
  65. codegraph/search/hybrid.py +26 -0
  66. codegraph/semantic_decorators.py +34 -3
  67. codegraph/structural_diff.py +2 -0
  68. codegraph/styles.py +144 -0
  69. codegraph/symbol_history.py +2 -0
  70. codegraph/tsconfig.py +236 -0
  71. codegraph/ui/__init__.py +6 -0
  72. codegraph/ui/server.py +715 -0
  73. codegraph/watcher.py +323 -0
  74. {codegraph_engine-2.3.0.dist-info → codegraph_engine-3.0.0.dist-info}/METADATA +150 -38
  75. codegraph_engine-3.0.0.dist-info/RECORD +129 -0
  76. codegraph_engine-2.3.0.dist-info/RECORD +0 -94
  77. {codegraph_engine-2.3.0.dist-info → codegraph_engine-3.0.0.dist-info}/WHEEL +0 -0
  78. {codegraph_engine-2.3.0.dist-info → codegraph_engine-3.0.0.dist-info}/entry_points.txt +0 -0
  79. {codegraph_engine-2.3.0.dist-info → codegraph_engine-3.0.0.dist-info}/licenses/LICENSE +0 -0
  80. {codegraph_engine-2.3.0.dist-info → codegraph_engine-3.0.0.dist-info}/top_level.txt +0 -0
codegraph/cli_output.py CHANGED
@@ -17,21 +17,36 @@ from typing import Any, TextIO
17
17
 
18
18
  import typer
19
19
 
20
- _PROBE_GLYPHS = "✓✗⚠↻•→↓─—–"
20
+ _PROBE_GLYPHS = "✓✗⚠↻•→↓─—–├──└──│📄📞🌐🧪💾⚠️✅❌"
21
21
 
22
22
  # Ordered replacements so multi-char patterns (e.g. "(•)") are replaced before single chars ("•")
23
23
  _UNICODE_TO_ASCII_MAP: tuple[tuple[str, str], ...] = (
24
24
  ("(•)", "(*)"),
25
+ ("├── ", "|-- "),
26
+ ("└── ", "\\-- "),
27
+ ("├──", "|--"),
28
+ ("└──", "\\--"),
29
+ ("├─", "|-"),
30
+ ("└─", "\\-"),
31
+ ("│", "|"),
32
+ ("─", "-"),
25
33
  ("✓", "[OK]"),
26
34
  ("✗", "[ERROR]"),
27
35
  ("⚠", "[WARN]"),
28
36
  ("↻", "[REPAIRED]"),
37
+ ("⚠️", "[WARN]"),
38
+ ("✅", "[OK]"),
39
+ ("❌", "[ERROR]"),
40
+ ("📄", "[FILE]"),
41
+ ("📞", "[CALLER]"),
42
+ ("🌐", "[ROUTE]"),
43
+ ("🧪", "[TEST]"),
44
+ ("💾", "[DB]"),
29
45
  ("•", "*"),
30
46
  ("→", "->"),
31
47
  ("↓", "v"),
32
48
  ("—", "--"),
33
49
  ("–", "-"),
34
- ("─", "-"),
35
50
  )
36
51
 
37
52
 
codegraph/context.py CHANGED
@@ -301,7 +301,7 @@ def get_context(
301
301
  task: str | TaskSpec | dict[str, Any] = "",
302
302
  intent: Intent | str | None = None,
303
303
  max_tokens: int = 20_000,
304
- top_k: int = 15,
304
+ top_k: int = 25,
305
305
  plan: RetrievalPlan | dict[str, Any] | None = None,
306
306
  mode: str = "BALANCED", # FAST | BALANCED | DEEP
307
307
  explain: bool = False,
@@ -311,7 +311,7 @@ def get_context(
311
311
  include_build_artifacts: bool = False,
312
312
  max_symbols: int = 25,
313
313
  max_relationships: int = 30,
314
- max_files: int = 15,
314
+ max_files: int = 25,
315
315
  max_lines: int = 500,
316
316
  max_depth: int | None = None,
317
317
  max_package_depth: int | None = None,
@@ -363,7 +363,7 @@ def _get_context_impl(
363
363
  task: str | TaskSpec | dict[str, Any],
364
364
  intent: Intent | str | None = None,
365
365
  max_tokens: int = 20_000,
366
- top_k: int = 15,
366
+ top_k: int = 25,
367
367
  plan: RetrievalPlan | dict[str, Any] | None = None,
368
368
  mode: str = "BALANCED", # FAST | BALANCED | DEEP
369
369
  explain: bool = False,
@@ -374,7 +374,7 @@ def _get_context_impl(
374
374
  include_build_artifacts: bool = False,
375
375
  max_symbols: int = 25,
376
376
  max_relationships: int = 30,
377
- max_files: int = 15,
377
+ max_files: int = 25,
378
378
  max_lines: int = 500,
379
379
  max_depth: int | None = None,
380
380
  max_package_depth: int | None = None,
@@ -936,6 +936,28 @@ def _get_context_impl(
936
936
  if res.qualified_name and _guard.allows_symbol(res.qualified_name) and res.qualified_name not in _seen_seeds:
937
937
  _seen_seeds.add(res.qualified_name)
938
938
  ordered_seeds.append(res.qualified_name)
939
+ if res.file_path:
940
+ try:
941
+ f_rows = con.execute(
942
+ "SELECT canonical_id FROM symbols WHERE path = ? LIMIT 5",
943
+ (res.file_path,),
944
+ ).fetchall()
945
+ for fr in f_rows:
946
+ fs_cid = str(fr["canonical_id"])
947
+ if fs_cid and _guard.allows_canonical_id(fs_cid) and fs_cid not in _seen_seeds:
948
+ _seen_seeds.add(fs_cid)
949
+ ordered_seeds.append(fs_cid)
950
+ e_rows = con.execute(
951
+ "SELECT DISTINCT target FROM graph_edges WHERE file = ? AND relationship IN ('CALLS', 'IMPORTS') LIMIT 5",
952
+ (res.file_path,),
953
+ ).fetchall()
954
+ for er in e_rows:
955
+ e_tgt = str(er["target"])
956
+ if e_tgt and _guard.allows_symbol(e_tgt) and e_tgt not in _seen_seeds:
957
+ _seen_seeds.add(e_tgt)
958
+ ordered_seeds.append(e_tgt)
959
+ except Exception:
960
+ pass
939
961
 
940
962
  for ep in entry_points_out:
941
963
  h = str(ep.get("handler", ""))
@@ -1430,10 +1452,15 @@ def _get_context_impl(
1430
1452
  "SELECT canonical_id FROM symbols WHERE (canonical_id=? OR qualified_name=? OR name=?) AND path=? LIMIT 1",
1431
1453
  (item.symbol, item.symbol, item.symbol, item.file),
1432
1454
  ).fetchone()
1433
- if not srow:
1455
+ if not srow and not item.file:
1456
+ srow = con.execute(
1457
+ "SELECT canonical_id FROM symbols WHERE canonical_id=? OR qualified_name=? LIMIT 1",
1458
+ (item.symbol, item.symbol),
1459
+ ).fetchone()
1460
+ elif not srow and item.symbol:
1434
1461
  srow = con.execute(
1435
- "SELECT canonical_id FROM symbols WHERE canonical_id=? OR qualified_name=? OR name=? LIMIT 1",
1436
- (item.symbol, item.symbol, item.symbol),
1462
+ "SELECT canonical_id FROM symbols WHERE canonical_id=? LIMIT 1",
1463
+ (item.symbol,),
1437
1464
  ).fetchone()
1438
1465
  if srow:
1439
1466
  canon = srow["canonical_id"]
@@ -1525,12 +1552,12 @@ def _get_context_impl(
1525
1552
  ).fetchone()
1526
1553
  else:
1527
1554
  row = con.execute(
1528
- "SELECT canonical_id, kind FROM symbols WHERE (qualified_name=? OR name=?) AND path=? LIMIT 1",
1529
- (sym_name, sym_name, it.file_path),
1555
+ "SELECT canonical_id, kind FROM symbols WHERE (canonical_id=? OR qualified_name=? OR name=?) AND path=? LIMIT 1",
1556
+ (sym_name, sym_name, sym_name, it.file_path),
1530
1557
  ).fetchone()
1531
- if not row:
1558
+ if not row and not it.file_path:
1532
1559
  row = con.execute(
1533
- "SELECT canonical_id, kind FROM symbols WHERE qualified_name=? OR name=? LIMIT 1",
1560
+ "SELECT canonical_id, kind FROM symbols WHERE canonical_id=? OR qualified_name=? LIMIT 1",
1534
1561
  (sym_name, sym_name),
1535
1562
  ).fetchone()
1536
1563
  cid = known_cid or (row["canonical_id"] if row and "canonical_id" in row.keys() else None)
@@ -69,6 +69,8 @@ def _run_git(repository: Path, *args: str, timeout: int = 10) -> str | None:
69
69
  cwd=str(repository),
70
70
  capture_output=True,
71
71
  text=True,
72
+ encoding="utf-8",
73
+ errors="replace",
72
74
  timeout=timeout,
73
75
  )
74
76
  return res.stdout if res.returncode == 0 else None
@@ -19,6 +19,7 @@ from .interrogation import (
19
19
  get_db_impact,
20
20
  get_db_schema,
21
21
  get_db_table,
22
+ get_route_db_lineage,
22
23
  )
23
24
  from .models import (
24
25
  DatabaseEntity,
@@ -29,15 +30,27 @@ from .models import (
29
30
  normalize_dialect,
30
31
  normalize_schema_name,
31
32
  )
33
+ from .schema_drift import (
34
+ DriftSeverity,
35
+ DriftType,
36
+ SchemaDriftIssue,
37
+ SchemaFieldSpec,
38
+ detect_schema_drift,
39
+ )
32
40
 
33
41
  __all__ = [
34
42
  "DatabaseEntity",
35
43
  "DatabaseEntityKind",
36
44
  "DatabaseExtractionResult",
37
45
  "DatabaseQueryFact",
46
+ "DriftSeverity",
47
+ "DriftType",
38
48
  "MigrationFact",
49
+ "SchemaDriftIssue",
50
+ "SchemaFieldSpec",
39
51
  "build_db_canonical_id",
40
52
  "detect_file_dialects",
53
+ "detect_schema_drift",
41
54
  "extract_database_from_file",
42
55
  "find_db_callers",
43
56
  "find_db_columns",
@@ -50,6 +63,7 @@ __all__ = [
50
63
  "get_db_impact",
51
64
  "get_db_schema",
52
65
  "get_db_table",
66
+ "get_route_db_lineage",
53
67
  "has_potential_database_activity",
54
68
  "has_potential_orm_models",
55
69
  "normalize_dialect",