codegraph-engine 3.0.0__1-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 (130) hide show
  1. codegraph/__init__.py +37 -0
  2. codegraph/agent.py +26 -0
  3. codegraph/agent_brain.py +2212 -0
  4. codegraph/agent_capabilities.py +4058 -0
  5. codegraph/agent_rules.py +531 -0
  6. codegraph/api_drift.py +455 -0
  7. codegraph/architecture.py +371 -0
  8. codegraph/async_queue/__init__.py +50 -0
  9. codegraph/async_queue/detectors/__init__.py +48 -0
  10. codegraph/async_queue/detectors/celery.py +160 -0
  11. codegraph/async_queue/detectors/kafka.py +168 -0
  12. codegraph/async_queue/detectors/rabbitmq.py +116 -0
  13. codegraph/async_queue/detectors/redis.py +130 -0
  14. codegraph/async_queue/detectors/sqs.py +135 -0
  15. codegraph/async_queue/models.py +161 -0
  16. codegraph/async_queue/otel_models.py +74 -0
  17. codegraph/async_queue/otel_parser.py +337 -0
  18. codegraph/async_queue/reconciler.py +427 -0
  19. codegraph/async_queue/scanner.py +291 -0
  20. codegraph/async_queue/traversal.py +447 -0
  21. codegraph/audit.py +106 -0
  22. codegraph/binding_resolver.py +616 -0
  23. codegraph/branch_comparison.py +197 -0
  24. codegraph/cache.py +95 -0
  25. codegraph/change_impact.py +547 -0
  26. codegraph/cli.py +2436 -0
  27. codegraph/cli_output.py +205 -0
  28. codegraph/config.py +45 -0
  29. codegraph/constraints.py +238 -0
  30. codegraph/context.py +2182 -0
  31. codegraph/context_freshness.py +351 -0
  32. codegraph/database/__init__.py +72 -0
  33. codegraph/database/extractor.py +3651 -0
  34. codegraph/database/interrogation.py +1494 -0
  35. codegraph/database/models.py +310 -0
  36. codegraph/database/schema_drift.py +862 -0
  37. codegraph/epistemic.py +200 -0
  38. codegraph/errors.py +282 -0
  39. codegraph/evidence/__init__.py +15 -0
  40. codegraph/evidence/citations.py +418 -0
  41. codegraph/evidence_contract.py +486 -0
  42. codegraph/frameworks.py +960 -0
  43. codegraph/frameworks_nestjs.py +502 -0
  44. codegraph/frameworks_nextjs.py +337 -0
  45. codegraph/frameworks_react.py +457 -0
  46. codegraph/freshness.py +335 -0
  47. codegraph/frontend_html.py +109 -0
  48. codegraph/git.py +362 -0
  49. codegraph/git_state.py +545 -0
  50. codegraph/graph/__init__.py +46 -0
  51. codegraph/graph/models.py +56 -0
  52. codegraph/graph/traversal.py +1993 -0
  53. codegraph/indexing/__init__.py +24 -0
  54. codegraph/indexing/classifier.py +564 -0
  55. codegraph/indexing/indexer.py +2578 -0
  56. codegraph/indexing/models.py +427 -0
  57. codegraph/indexing/parser.py +3404 -0
  58. codegraph/indexing/pool.py +136 -0
  59. codegraph/indexing/scanner.py +211 -0
  60. codegraph/indexing/telemetry.py +326 -0
  61. codegraph/indexing/templates.py +418 -0
  62. codegraph/indexing/test_framework.py +116 -0
  63. codegraph/installer.py +1702 -0
  64. codegraph/interrogation.py +2355 -0
  65. codegraph/llm/__init__.py +3 -0
  66. codegraph/llm/base.py +15 -0
  67. codegraph/llm/context.py +20 -0
  68. codegraph/mcp/__init__.py +3 -0
  69. codegraph/mcp/server.py +1476 -0
  70. codegraph/mcp_diagnostics.py +882 -0
  71. codegraph/memory/__init__.py +3 -0
  72. codegraph/memory/store.py +46 -0
  73. codegraph/models.py +310 -0
  74. codegraph/monorepo.py +925 -0
  75. codegraph/observability.py +262 -0
  76. codegraph/optimizer.py +1014 -0
  77. codegraph/planner.py +417 -0
  78. codegraph/process_lifecycle.py +1153 -0
  79. codegraph/py.typed +1 -0
  80. codegraph/query_expansion.py +199 -0
  81. codegraph/ranking.py +408 -0
  82. codegraph/refactor/__init__.py +36 -0
  83. codegraph/refactor/models.py +114 -0
  84. codegraph/refactor/renamer.py +844 -0
  85. codegraph/refactor/transactions.py +414 -0
  86. codegraph/resolver.py +3968 -0
  87. codegraph/resources/__init__.py +46 -0
  88. codegraph/resources/cache.py +117 -0
  89. codegraph/resources/coalescer.py +83 -0
  90. codegraph/resources/debouncer.py +98 -0
  91. codegraph/resources/governor.py +219 -0
  92. codegraph/resources/monitor.py +102 -0
  93. codegraph/resources/policy.py +123 -0
  94. codegraph/retrieval_policy.py +320 -0
  95. codegraph/roblox.py +2174 -0
  96. codegraph/route_composer.py +363 -0
  97. codegraph/route_topology.py +172 -0
  98. codegraph/runtime/__init__.py +51 -0
  99. codegraph/runtime/collector.py +155 -0
  100. codegraph/runtime/db_watcher.py +191 -0
  101. codegraph/runtime/ingestor.py +692 -0
  102. codegraph/runtime/models.py +130 -0
  103. codegraph/runtime/port_inspector.py +304 -0
  104. codegraph/runtime/reconciliation.py +492 -0
  105. codegraph/runtime/runner.py +353 -0
  106. codegraph/runtime/trace_linker.py +175 -0
  107. codegraph/search/__init__.py +25 -0
  108. codegraph/search/hybrid.py +846 -0
  109. codegraph/search/semantic.py +28 -0
  110. codegraph/security/__init__.py +51 -0
  111. codegraph/security/paths.py +189 -0
  112. codegraph/security/redaction.py +633 -0
  113. codegraph/semantic_conflicts.py +270 -0
  114. codegraph/semantic_decorators.py +372 -0
  115. codegraph/structural_diff.py +542 -0
  116. codegraph/styles.py +144 -0
  117. codegraph/symbol_history.py +277 -0
  118. codegraph/target_resolver.py +348 -0
  119. codegraph/task.py +637 -0
  120. codegraph/tool_selection_eval.py +1158 -0
  121. codegraph/tsconfig.py +236 -0
  122. codegraph/ui/__init__.py +6 -0
  123. codegraph/ui/server.py +755 -0
  124. codegraph/watcher.py +323 -0
  125. codegraph_engine-3.0.0.dist-info/METADATA +859 -0
  126. codegraph_engine-3.0.0.dist-info/RECORD +130 -0
  127. codegraph_engine-3.0.0.dist-info/WHEEL +6 -0
  128. codegraph_engine-3.0.0.dist-info/entry_points.txt +2 -0
  129. codegraph_engine-3.0.0.dist-info/licenses/LICENSE +21 -0
  130. codegraph_engine-3.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,114 @@
1
+ """Models and data structures for deterministic, syntax-validated, transaction-safe refactoring."""
2
+ from __future__ import annotations
3
+
4
+ from dataclasses import asdict, dataclass, field
5
+ from enum import StrEnum
6
+ from typing import Any
7
+
8
+
9
+ class RefactorStatus(StrEnum):
10
+ """Execution status of a refactoring plan or transaction."""
11
+
12
+ READY = "READY"
13
+ BLOCKED = "BLOCKED"
14
+ APPLIED = "APPLIED"
15
+ ROLLED_BACK = "ROLLED_BACK"
16
+ ERROR = "ERROR"
17
+
18
+
19
+ class RefactorRisk(StrEnum):
20
+ """Assessed risk of an AST refactoring operation."""
21
+
22
+ LOW = "LOW" # All affected relationships are FACT / deterministically verified.
23
+ MEDIUM = "MEDIUM" # POSSIBLE relationships exist but scope is bounded.
24
+ HIGH = "HIGH" # UNKNOWN / AMBIGUOUS / CONFLICT relationships could make rename incomplete.
25
+
26
+
27
+ @dataclass(frozen=True)
28
+ class TokenReplacementSpan:
29
+ """Exact byte/token coordinates for an AST-grounded replacement."""
30
+
31
+ path: str
32
+ start_line: int
33
+ start_col: int
34
+ end_line: int
35
+ end_col: int
36
+ old_token: str
37
+ new_token: str
38
+ evidence: str
39
+ symbol_id: str
40
+
41
+ def to_dict(self) -> dict[str, Any]:
42
+ return asdict(self)
43
+
44
+
45
+ @dataclass
46
+ class RefactorPlan:
47
+ """Deterministic refactoring plan before in-memory preview or commit."""
48
+
49
+ transaction_id: str
50
+ target_symbol: str
51
+ new_name: str
52
+ files: list[str] = field(default_factory=list)
53
+ spans: list[TokenReplacementSpan] = field(default_factory=list)
54
+ risk: RefactorRisk = RefactorRisk.LOW
55
+ uncertainty_reasons: list[str] = field(default_factory=list)
56
+ affected_tests: list[str] = field(default_factory=list)
57
+ affected_routes: list[str] = field(default_factory=list)
58
+ affected_db_relationships: list[str] = field(default_factory=list)
59
+ original_file_hashes: dict[str, str] = field(default_factory=dict)
60
+ original_file_sizes: dict[str, int] = field(default_factory=dict)
61
+ original_file_mtimes: dict[str, float] = field(default_factory=dict)
62
+
63
+ def to_dict(self) -> dict[str, Any]:
64
+ return {
65
+ "transaction_id": self.transaction_id,
66
+ "target_symbol": self.target_symbol,
67
+ "new_name": self.new_name,
68
+ "files": sorted(self.files),
69
+ "spans": [s.to_dict() for s in sorted(self.spans, key=lambda x: (x.path, x.start_line, x.start_col))],
70
+ "risk": str(self.risk),
71
+ "uncertainty_reasons": sorted(self.uncertainty_reasons),
72
+ "affected_tests": sorted(self.affected_tests),
73
+ "affected_routes": sorted(self.affected_routes),
74
+ "affected_db_relationships": sorted(self.affected_db_relationships),
75
+ "original_file_hashes": dict(sorted(self.original_file_hashes.items())),
76
+ }
77
+
78
+
79
+ @dataclass
80
+ class RefactorResult:
81
+ """Complete result of a refactor preview, apply, or rollback."""
82
+
83
+ status: RefactorStatus
84
+ target_symbol: str
85
+ new_name: str
86
+ risk: RefactorRisk
87
+ uncertainty_reasons: list[str] = field(default_factory=list)
88
+ files_changed: int = 0
89
+ symbols_changed: int = 0
90
+ spans_count: int = 0
91
+ tests_affected: list[str] = field(default_factory=list)
92
+ routes_affected: list[str] = field(default_factory=list)
93
+ db_affected: list[str] = field(default_factory=list)
94
+ rollback_id: str | None = None
95
+ diffs: dict[str, str] = field(default_factory=dict)
96
+ errors: list[str] = field(default_factory=list)
97
+
98
+ def to_dict(self) -> dict[str, Any]:
99
+ return {
100
+ "status": str(self.status),
101
+ "target_symbol": self.target_symbol,
102
+ "new_name": self.new_name,
103
+ "risk": str(self.risk),
104
+ "uncertainty_reasons": sorted(self.uncertainty_reasons),
105
+ "files_changed": self.files_changed,
106
+ "symbols_changed": self.symbols_changed,
107
+ "spans_count": self.spans_count,
108
+ "tests_affected": sorted(self.tests_affected),
109
+ "routes_affected": sorted(self.routes_affected),
110
+ "db_affected": sorted(self.db_affected),
111
+ "rollback_id": self.rollback_id,
112
+ "diffs": dict(sorted(self.diffs.items())),
113
+ "errors": sorted(self.errors),
114
+ }