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.
- codegraph/__init__.py +37 -0
- codegraph/agent.py +26 -0
- codegraph/agent_brain.py +2212 -0
- codegraph/agent_capabilities.py +4058 -0
- codegraph/agent_rules.py +531 -0
- codegraph/api_drift.py +455 -0
- codegraph/architecture.py +371 -0
- codegraph/async_queue/__init__.py +50 -0
- codegraph/async_queue/detectors/__init__.py +48 -0
- codegraph/async_queue/detectors/celery.py +160 -0
- codegraph/async_queue/detectors/kafka.py +168 -0
- codegraph/async_queue/detectors/rabbitmq.py +116 -0
- codegraph/async_queue/detectors/redis.py +130 -0
- codegraph/async_queue/detectors/sqs.py +135 -0
- codegraph/async_queue/models.py +161 -0
- codegraph/async_queue/otel_models.py +74 -0
- codegraph/async_queue/otel_parser.py +337 -0
- codegraph/async_queue/reconciler.py +427 -0
- codegraph/async_queue/scanner.py +291 -0
- codegraph/async_queue/traversal.py +447 -0
- codegraph/audit.py +106 -0
- codegraph/binding_resolver.py +616 -0
- codegraph/branch_comparison.py +197 -0
- codegraph/cache.py +95 -0
- codegraph/change_impact.py +547 -0
- codegraph/cli.py +2436 -0
- codegraph/cli_output.py +205 -0
- codegraph/config.py +45 -0
- codegraph/constraints.py +238 -0
- codegraph/context.py +2182 -0
- codegraph/context_freshness.py +351 -0
- codegraph/database/__init__.py +72 -0
- codegraph/database/extractor.py +3651 -0
- codegraph/database/interrogation.py +1494 -0
- codegraph/database/models.py +310 -0
- codegraph/database/schema_drift.py +862 -0
- codegraph/epistemic.py +200 -0
- codegraph/errors.py +282 -0
- codegraph/evidence/__init__.py +15 -0
- codegraph/evidence/citations.py +418 -0
- codegraph/evidence_contract.py +486 -0
- codegraph/frameworks.py +960 -0
- codegraph/frameworks_nestjs.py +502 -0
- codegraph/frameworks_nextjs.py +337 -0
- codegraph/frameworks_react.py +457 -0
- codegraph/freshness.py +335 -0
- codegraph/frontend_html.py +109 -0
- codegraph/git.py +362 -0
- codegraph/git_state.py +545 -0
- codegraph/graph/__init__.py +46 -0
- codegraph/graph/models.py +56 -0
- codegraph/graph/traversal.py +1993 -0
- codegraph/indexing/__init__.py +24 -0
- codegraph/indexing/classifier.py +564 -0
- codegraph/indexing/indexer.py +2578 -0
- codegraph/indexing/models.py +427 -0
- codegraph/indexing/parser.py +3404 -0
- codegraph/indexing/pool.py +136 -0
- codegraph/indexing/scanner.py +211 -0
- codegraph/indexing/telemetry.py +326 -0
- codegraph/indexing/templates.py +418 -0
- codegraph/indexing/test_framework.py +116 -0
- codegraph/installer.py +1702 -0
- codegraph/interrogation.py +2355 -0
- codegraph/llm/__init__.py +3 -0
- codegraph/llm/base.py +15 -0
- codegraph/llm/context.py +20 -0
- codegraph/mcp/__init__.py +3 -0
- codegraph/mcp/server.py +1476 -0
- codegraph/mcp_diagnostics.py +882 -0
- codegraph/memory/__init__.py +3 -0
- codegraph/memory/store.py +46 -0
- codegraph/models.py +310 -0
- codegraph/monorepo.py +925 -0
- codegraph/observability.py +262 -0
- codegraph/optimizer.py +1014 -0
- codegraph/planner.py +417 -0
- codegraph/process_lifecycle.py +1153 -0
- codegraph/py.typed +1 -0
- codegraph/query_expansion.py +199 -0
- codegraph/ranking.py +408 -0
- codegraph/refactor/__init__.py +36 -0
- codegraph/refactor/models.py +114 -0
- codegraph/refactor/renamer.py +844 -0
- codegraph/refactor/transactions.py +414 -0
- codegraph/resolver.py +3968 -0
- codegraph/resources/__init__.py +46 -0
- codegraph/resources/cache.py +117 -0
- codegraph/resources/coalescer.py +83 -0
- codegraph/resources/debouncer.py +98 -0
- codegraph/resources/governor.py +219 -0
- codegraph/resources/monitor.py +102 -0
- codegraph/resources/policy.py +123 -0
- codegraph/retrieval_policy.py +320 -0
- codegraph/roblox.py +2174 -0
- codegraph/route_composer.py +363 -0
- codegraph/route_topology.py +172 -0
- codegraph/runtime/__init__.py +51 -0
- codegraph/runtime/collector.py +155 -0
- codegraph/runtime/db_watcher.py +191 -0
- codegraph/runtime/ingestor.py +692 -0
- codegraph/runtime/models.py +130 -0
- codegraph/runtime/port_inspector.py +304 -0
- codegraph/runtime/reconciliation.py +492 -0
- codegraph/runtime/runner.py +353 -0
- codegraph/runtime/trace_linker.py +175 -0
- codegraph/search/__init__.py +25 -0
- codegraph/search/hybrid.py +846 -0
- codegraph/search/semantic.py +28 -0
- codegraph/security/__init__.py +51 -0
- codegraph/security/paths.py +189 -0
- codegraph/security/redaction.py +633 -0
- codegraph/semantic_conflicts.py +270 -0
- codegraph/semantic_decorators.py +372 -0
- codegraph/structural_diff.py +542 -0
- codegraph/styles.py +144 -0
- codegraph/symbol_history.py +277 -0
- codegraph/target_resolver.py +348 -0
- codegraph/task.py +637 -0
- codegraph/tool_selection_eval.py +1158 -0
- codegraph/tsconfig.py +236 -0
- codegraph/ui/__init__.py +6 -0
- codegraph/ui/server.py +755 -0
- codegraph/watcher.py +323 -0
- codegraph_engine-3.0.0.dist-info/METADATA +859 -0
- codegraph_engine-3.0.0.dist-info/RECORD +130 -0
- codegraph_engine-3.0.0.dist-info/WHEEL +6 -0
- codegraph_engine-3.0.0.dist-info/entry_points.txt +2 -0
- codegraph_engine-3.0.0.dist-info/licenses/LICENSE +21 -0
- codegraph_engine-3.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"""Resource Policies, Profiles, Task Priorities, and State Models.
|
|
2
|
+
|
|
3
|
+
Defines bounded execution budgets, memory limits, concurrency profiles,
|
|
4
|
+
and cooperative pressure levels without platform-specific hardware assumptions.
|
|
5
|
+
"""
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from dataclasses import asdict, dataclass
|
|
9
|
+
from enum import StrEnum
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ResourceProfile(StrEnum):
|
|
13
|
+
LIGHT = "LIGHT"
|
|
14
|
+
BALANCED = "BALANCED"
|
|
15
|
+
PERFORMANCE = "PERFORMANCE"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class PressureLevel(StrEnum):
|
|
19
|
+
NORMAL = "NORMAL"
|
|
20
|
+
ELEVATED = "ELEVATED"
|
|
21
|
+
HIGH = "HIGH"
|
|
22
|
+
CRITICAL = "CRITICAL"
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class TaskPriority(StrEnum):
|
|
26
|
+
INTERACTIVE_HIGH = "INTERACTIVE_HIGH"
|
|
27
|
+
INTERACTIVE_NORMAL = "INTERACTIVE_NORMAL"
|
|
28
|
+
BACKGROUND = "BACKGROUND"
|
|
29
|
+
MAINTENANCE = "MAINTENANCE"
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class ActivityMode(StrEnum):
|
|
33
|
+
ACTIVE_CODING = "ACTIVE_CODING"
|
|
34
|
+
IDLE = "IDLE"
|
|
35
|
+
BACKGROUND = "BACKGROUND"
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@dataclass(frozen=True)
|
|
39
|
+
class ResourcePolicy:
|
|
40
|
+
profile: ResourceProfile = ResourceProfile.BALANCED
|
|
41
|
+
max_interactive_workers: int = 2
|
|
42
|
+
max_background_workers: int = 1
|
|
43
|
+
max_files_per_incremental_batch: int = 25
|
|
44
|
+
max_graph_nodes_per_query: int = 300
|
|
45
|
+
max_graph_edges_per_query: int = 1200
|
|
46
|
+
max_git_commits: int = 15
|
|
47
|
+
max_memory_mb: int = 1024
|
|
48
|
+
max_cpu_time_ms_per_request: int = 5000
|
|
49
|
+
background_enabled: bool = True
|
|
50
|
+
aggressive_throttling: bool = True
|
|
51
|
+
debounce_ms: int = 500
|
|
52
|
+
|
|
53
|
+
@classmethod
|
|
54
|
+
def for_profile(cls, profile: str | ResourceProfile) -> ResourcePolicy:
|
|
55
|
+
p = ResourceProfile(str(profile).upper()) if isinstance(profile, str) else profile
|
|
56
|
+
if p == ResourceProfile.LIGHT:
|
|
57
|
+
return cls(
|
|
58
|
+
profile=ResourceProfile.LIGHT,
|
|
59
|
+
max_interactive_workers=1,
|
|
60
|
+
max_background_workers=1,
|
|
61
|
+
max_files_per_incremental_batch=10,
|
|
62
|
+
max_graph_nodes_per_query=100,
|
|
63
|
+
max_graph_edges_per_query=400,
|
|
64
|
+
max_git_commits=5,
|
|
65
|
+
max_memory_mb=512,
|
|
66
|
+
max_cpu_time_ms_per_request=2000,
|
|
67
|
+
background_enabled=True,
|
|
68
|
+
aggressive_throttling=True,
|
|
69
|
+
debounce_ms=800,
|
|
70
|
+
)
|
|
71
|
+
elif p == ResourceProfile.PERFORMANCE:
|
|
72
|
+
return cls(
|
|
73
|
+
profile=ResourceProfile.PERFORMANCE,
|
|
74
|
+
max_interactive_workers=4,
|
|
75
|
+
max_background_workers=2,
|
|
76
|
+
max_files_per_incremental_batch=100,
|
|
77
|
+
max_graph_nodes_per_query=1000,
|
|
78
|
+
max_graph_edges_per_query=5000,
|
|
79
|
+
max_git_commits=50,
|
|
80
|
+
max_memory_mb=4096,
|
|
81
|
+
max_cpu_time_ms_per_request=15000,
|
|
82
|
+
background_enabled=True,
|
|
83
|
+
aggressive_throttling=False,
|
|
84
|
+
debounce_ms=250,
|
|
85
|
+
)
|
|
86
|
+
else:
|
|
87
|
+
return cls(
|
|
88
|
+
profile=ResourceProfile.BALANCED,
|
|
89
|
+
max_interactive_workers=2,
|
|
90
|
+
max_background_workers=1,
|
|
91
|
+
max_files_per_incremental_batch=25,
|
|
92
|
+
max_graph_nodes_per_query=300,
|
|
93
|
+
max_graph_edges_per_query=1200,
|
|
94
|
+
max_git_commits=15,
|
|
95
|
+
max_memory_mb=1024,
|
|
96
|
+
max_cpu_time_ms_per_request=5000,
|
|
97
|
+
background_enabled=True,
|
|
98
|
+
aggressive_throttling=True,
|
|
99
|
+
debounce_ms=500,
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
def as_dict(self) -> dict[str, object]:
|
|
103
|
+
d = asdict(self)
|
|
104
|
+
d["profile"] = self.profile.value
|
|
105
|
+
return d
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
@dataclass(frozen=True)
|
|
109
|
+
class ResourceState:
|
|
110
|
+
policy_profile: str = ResourceProfile.BALANCED.value
|
|
111
|
+
active_interactive_requests: int = 0
|
|
112
|
+
active_background_tasks: int = 0
|
|
113
|
+
queued_tasks: int = 0
|
|
114
|
+
recent_cpu_time_ms: float = 0.0
|
|
115
|
+
recent_wall_time_ms: float = 0.0
|
|
116
|
+
estimated_memory_mb: float | None = None
|
|
117
|
+
pressure_level: str = PressureLevel.NORMAL.value
|
|
118
|
+
activity_mode: str = ActivityMode.IDLE.value
|
|
119
|
+
indexing_active: bool = False
|
|
120
|
+
watcher_active: bool = False
|
|
121
|
+
|
|
122
|
+
def as_dict(self) -> dict[str, object]:
|
|
123
|
+
return asdict(self)
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
"""Intent-specific retrieval policies for CodeGraph MCP v2.1.
|
|
2
|
+
|
|
3
|
+
Each policy defines:
|
|
4
|
+
- Allowed relationship types (graph edges that may participate)
|
|
5
|
+
- Preferred coverage layers (ordered)
|
|
6
|
+
- Traversal flags (callers, callees, tests, git, framework, architecture)
|
|
7
|
+
- Maximum graph depth
|
|
8
|
+
|
|
9
|
+
Downstream retrieval MUST filter graph candidates to allowed_relationship_types.
|
|
10
|
+
This prevents unrelated relationships from polluting context merely because
|
|
11
|
+
they exist in the graph.
|
|
12
|
+
"""
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
from dataclasses import dataclass
|
|
16
|
+
|
|
17
|
+
_DB_RELATIONSHIP_TYPES: frozenset[str] = frozenset({
|
|
18
|
+
"MAPS_TO_TABLE",
|
|
19
|
+
"MAPS_TO_COLUMN",
|
|
20
|
+
"READS_TABLE",
|
|
21
|
+
"WRITES_TABLE",
|
|
22
|
+
"READS_COLUMN",
|
|
23
|
+
"WRITES_COLUMN",
|
|
24
|
+
"REFERENCES_TABLE",
|
|
25
|
+
"REFERENCES_COLUMN",
|
|
26
|
+
"FOREIGN_KEY_TO",
|
|
27
|
+
"HAS_PRIMARY_KEY",
|
|
28
|
+
"HAS_INDEX",
|
|
29
|
+
"HAS_UNIQUE_CONSTRAINT",
|
|
30
|
+
"HAS_CHECK_CONSTRAINT",
|
|
31
|
+
"MIGRATES_TABLE",
|
|
32
|
+
"QUERIES_DATABASE",
|
|
33
|
+
"ORM_RELATION",
|
|
34
|
+
"POSSIBLE_TABLE",
|
|
35
|
+
"UNKNOWN_TABLE",
|
|
36
|
+
"READS_ENV",
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
_ROBLOX_RELATIONSHIP_TYPES: frozenset[str] = frozenset({
|
|
40
|
+
"REQUIRES_MODULE",
|
|
41
|
+
"CLIENT_DISPATCHES_REMOTE",
|
|
42
|
+
"SERVER_HANDLES_REMOTE",
|
|
43
|
+
"GETS_SERVICE",
|
|
44
|
+
"PROVIDES_SERVICE",
|
|
45
|
+
"READS_PERSISTENCE",
|
|
46
|
+
"WRITES_PERSISTENCE",
|
|
47
|
+
"CONFIGURES_PERSISTENCE",
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
@dataclass(frozen=True)
|
|
52
|
+
class RetrievalPolicy:
|
|
53
|
+
intent: str
|
|
54
|
+
allowed_relationship_types: frozenset[str]
|
|
55
|
+
preferred_flow: tuple[str, ...]
|
|
56
|
+
include_callers: bool = True
|
|
57
|
+
include_callees: bool = True
|
|
58
|
+
include_tests: bool = True
|
|
59
|
+
include_git: bool = False
|
|
60
|
+
include_framework: bool = True
|
|
61
|
+
include_architecture: bool = False
|
|
62
|
+
max_graph_depth: int = 3
|
|
63
|
+
max_package_depth: int = 2
|
|
64
|
+
preferred_target_types: tuple[str, ...] = ()
|
|
65
|
+
required_dimensions: tuple[str, ...] = ("TARGET", "SERVICE", "TEST")
|
|
66
|
+
|
|
67
|
+
def allows(self, relationship: str) -> bool:
|
|
68
|
+
"""Return True if the relationship type is permitted for this policy."""
|
|
69
|
+
if not self.allowed_relationship_types:
|
|
70
|
+
return True
|
|
71
|
+
rel = relationship.upper()
|
|
72
|
+
if (
|
|
73
|
+
rel in self.allowed_relationship_types
|
|
74
|
+
or rel in _DB_RELATIONSHIP_TYPES
|
|
75
|
+
or rel in _ROBLOX_RELATIONSHIP_TYPES
|
|
76
|
+
):
|
|
77
|
+
return True
|
|
78
|
+
if rel.startswith("TESTS") and "TESTS" in self.allowed_relationship_types:
|
|
79
|
+
return True
|
|
80
|
+
return False
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
# ---------------------------------------------------------------------------
|
|
84
|
+
# Policy definitions
|
|
85
|
+
# ---------------------------------------------------------------------------
|
|
86
|
+
|
|
87
|
+
_POLICIES: dict[str, RetrievalPolicy] = {}
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def _register(policy: RetrievalPolicy) -> None:
|
|
91
|
+
_POLICIES[policy.intent.upper()] = policy
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
# TRACE — follow the full verified call/dispatch/DI/route chain
|
|
95
|
+
_register(RetrievalPolicy(
|
|
96
|
+
intent="TRACE",
|
|
97
|
+
allowed_relationship_types=frozenset({
|
|
98
|
+
"HANDLED_BY", "ROUTE_HANDLER", "ROUTES_TO", "MOUNTS",
|
|
99
|
+
"CALLS", "DISPATCHES_TO", "RESOLVES_DEPENDENCY", "INJECTS", "PROVIDES",
|
|
100
|
+
"DEPENDS_ON", "IMPORTS", "TESTS", "POSSIBLE_CALLS",
|
|
101
|
+
"DEFINES", "CONTAINS", "PARALLEL_IMPLEMENTATION",
|
|
102
|
+
"DISPATCHES_TASK", "TRIGGERS_SIGNAL", "HANDLES_SIGNAL", "RENDERS_TEMPLATE",
|
|
103
|
+
"DISPATCHES_FORWARD", "TOOL_HANDLER", "PIPELINE_STEP",
|
|
104
|
+
}),
|
|
105
|
+
preferred_flow=("ENTRYPOINT", "HANDLER", "SERVICE", "DATA", "TEST"),
|
|
106
|
+
include_callers=True,
|
|
107
|
+
include_callees=True,
|
|
108
|
+
include_tests=True,
|
|
109
|
+
include_framework=True,
|
|
110
|
+
max_graph_depth=4,
|
|
111
|
+
max_package_depth=2,
|
|
112
|
+
preferred_target_types=("API_ENDPOINT", "FUNCTION", "METHOD", "CLASS"),
|
|
113
|
+
required_dimensions=("TARGET", "ROUTE", "CALLER", "CALLEE", "PROVIDER", "TEST"),
|
|
114
|
+
))
|
|
115
|
+
|
|
116
|
+
# UNDERSTAND — explain structure, definitions, dependencies, package & route ownership
|
|
117
|
+
_register(RetrievalPolicy(
|
|
118
|
+
intent="UNDERSTAND",
|
|
119
|
+
allowed_relationship_types=frozenset({
|
|
120
|
+
"DEFINES", "CONTAINS", "CALLS", "IMPORTS", "DEPENDS_ON",
|
|
121
|
+
"POSSIBLE_CALLS", "EXTENDS", "IMPLEMENTS", "PARALLEL_IMPLEMENTATION",
|
|
122
|
+
"MOUNTS", "HANDLED_BY", "ROUTE_HANDLER",
|
|
123
|
+
"REGISTERS", "DISPATCHES_TO", "EVENT_LISTENER", "TASK_HANDLER", "COMMAND_HANDLER",
|
|
124
|
+
"DISPATCHES_TASK", "TRIGGERS_SIGNAL", "HANDLES_SIGNAL", "RENDERS_TEMPLATE",
|
|
125
|
+
"DISPATCHES_FORWARD", "TOOL_HANDLER", "PIPELINE_STEP",
|
|
126
|
+
"INJECTS", "PROVIDES", "RESOLVES_DEPENDENCY", "CONFIGURES",
|
|
127
|
+
"DEPENDS_ON_PACKAGE", "TESTS",
|
|
128
|
+
}),
|
|
129
|
+
preferred_flow=("TARGET", "DEFINITIONS", "DEPENDENCIES", "CALLERS_CALLEES"),
|
|
130
|
+
include_callers=True,
|
|
131
|
+
include_callees=True,
|
|
132
|
+
include_tests=True,
|
|
133
|
+
include_framework=True,
|
|
134
|
+
max_graph_depth=2,
|
|
135
|
+
max_package_depth=1,
|
|
136
|
+
preferred_target_types=("CLASS", "FUNCTION", "MODULE"),
|
|
137
|
+
required_dimensions=("TARGET", "CALLER", "CALLEE", "ROUTE", "PACKAGE", "TEST"),
|
|
138
|
+
))
|
|
139
|
+
|
|
140
|
+
# DEBUG — find callers, callees, error paths, registrations, DI, configuration, tests, unknowns
|
|
141
|
+
_register(RetrievalPolicy(
|
|
142
|
+
intent="DEBUG",
|
|
143
|
+
allowed_relationship_types=frozenset({
|
|
144
|
+
"CALLS", "CALLED_BY", "DEPENDS_ON", "TESTS", "IMPORTS",
|
|
145
|
+
"POSSIBLE_CALLS", "DEFINES", "PARALLEL_IMPLEMENTATION",
|
|
146
|
+
"HANDLED_BY", "MOUNTS", "ROUTE_HANDLER",
|
|
147
|
+
"REGISTERS", "DISPATCHES_TO", "EVENT_LISTENER", "TASK_HANDLER", "COMMAND_HANDLER",
|
|
148
|
+
"DISPATCHES_TASK", "TRIGGERS_SIGNAL", "HANDLES_SIGNAL", "RENDERS_TEMPLATE",
|
|
149
|
+
"DISPATCHES_FORWARD", "TOOL_HANDLER", "PIPELINE_STEP",
|
|
150
|
+
"INJECTS", "PROVIDES", "RESOLVES_DEPENDENCY", "CONFIGURES",
|
|
151
|
+
"DEPENDS_ON_PACKAGE",
|
|
152
|
+
}),
|
|
153
|
+
preferred_flow=("TARGET", "EXECUTION_PATH", "ERROR_PATH", "TEST"),
|
|
154
|
+
include_callers=True,
|
|
155
|
+
include_callees=True,
|
|
156
|
+
include_tests=True,
|
|
157
|
+
include_framework=True,
|
|
158
|
+
max_graph_depth=3,
|
|
159
|
+
max_package_depth=2,
|
|
160
|
+
preferred_target_types=("FUNCTION", "METHOD", "CLASS"),
|
|
161
|
+
required_dimensions=("TARGET", "CALLER", "CALLEE", "ROUTE", "REGISTRATION", "PROVIDER", "TEST"),
|
|
162
|
+
))
|
|
163
|
+
|
|
164
|
+
# IMPACT — what depends on, calls, or tests the target?
|
|
165
|
+
_register(RetrievalPolicy(
|
|
166
|
+
intent="IMPACT",
|
|
167
|
+
allowed_relationship_types=frozenset({
|
|
168
|
+
"CALLED_BY", "DEPENDS_ON", "IMPLEMENTED_BY", "TESTS", "CALLS",
|
|
169
|
+
"IMPORTS", "POSSIBLE_CALLS", "PROVIDES", "INJECTS",
|
|
170
|
+
"HANDLED_BY", "MOUNTS", "REGISTERS", "DISPATCHES_TO", "EVENT_LISTENER",
|
|
171
|
+
"TASK_HANDLER", "COMMAND_HANDLER", "DEPENDS_ON_PACKAGE",
|
|
172
|
+
}),
|
|
173
|
+
preferred_flow=("TARGET", "CALLERS", "DEPENDENTS", "TEST"),
|
|
174
|
+
include_callers=True,
|
|
175
|
+
include_callees=False,
|
|
176
|
+
include_tests=True,
|
|
177
|
+
include_framework=False,
|
|
178
|
+
max_graph_depth=3,
|
|
179
|
+
max_package_depth=2,
|
|
180
|
+
preferred_target_types=("CLASS", "FUNCTION", "METHOD", "MODULE"),
|
|
181
|
+
required_dimensions=("TARGET", "CALLER", "ROUTE", "PROVIDER", "TEST", "PACKAGE"),
|
|
182
|
+
))
|
|
183
|
+
|
|
184
|
+
# REVIEW — review changes; needs callers, callees, tests, and git context
|
|
185
|
+
_register(RetrievalPolicy(
|
|
186
|
+
intent="REVIEW",
|
|
187
|
+
allowed_relationship_types=frozenset({
|
|
188
|
+
"CALLS", "CALLED_BY", "DEPENDS_ON", "TESTS", "IMPORTS", "POSSIBLE_CALLS",
|
|
189
|
+
"HANDLED_BY", "INJECTS", "PROVIDES", "REGISTERS", "DEPENDS_ON_PACKAGE",
|
|
190
|
+
}),
|
|
191
|
+
preferred_flow=("TARGET", "HANDLER", "SERVICE", "TEST"),
|
|
192
|
+
include_callers=True,
|
|
193
|
+
include_callees=True,
|
|
194
|
+
include_tests=True,
|
|
195
|
+
include_git=True,
|
|
196
|
+
include_framework=True,
|
|
197
|
+
max_graph_depth=2,
|
|
198
|
+
max_package_depth=1,
|
|
199
|
+
preferred_target_types=("CLASS", "FUNCTION", "METHOD"),
|
|
200
|
+
required_dimensions=("TARGET", "CALLER", "CALLEE", "TEST", "GIT"),
|
|
201
|
+
))
|
|
202
|
+
|
|
203
|
+
# REFACTOR — similar to UNDERSTAND but emphasizes callers and tests
|
|
204
|
+
_register(RetrievalPolicy(
|
|
205
|
+
intent="REFACTOR",
|
|
206
|
+
allowed_relationship_types=frozenset({
|
|
207
|
+
"DEFINES", "CONTAINS", "CALLS", "IMPORTS", "DEPENDS_ON",
|
|
208
|
+
"POSSIBLE_CALLS", "EXTENDS", "IMPLEMENTS", "PARALLEL_IMPLEMENTATION",
|
|
209
|
+
"TESTS", "INJECTS", "PROVIDES", "DEPENDS_ON_PACKAGE",
|
|
210
|
+
}),
|
|
211
|
+
preferred_flow=("TARGET", "DEFINITIONS", "CALLERS_CALLEES", "TEST"),
|
|
212
|
+
include_callers=True,
|
|
213
|
+
include_callees=True,
|
|
214
|
+
include_tests=True,
|
|
215
|
+
include_framework=False,
|
|
216
|
+
max_graph_depth=2,
|
|
217
|
+
max_package_depth=1,
|
|
218
|
+
preferred_target_types=("CLASS", "FUNCTION", "METHOD"),
|
|
219
|
+
required_dimensions=("TARGET", "CALLER", "CALLEE", "TEST"),
|
|
220
|
+
))
|
|
221
|
+
|
|
222
|
+
# CHANGE — modify existing behavior; needs definition + callers + routes + providers + registrations + tests + packages
|
|
223
|
+
_register(RetrievalPolicy(
|
|
224
|
+
intent="CHANGE",
|
|
225
|
+
allowed_relationship_types=frozenset({
|
|
226
|
+
"DEFINES", "CALLS", "CALLED_BY", "IMPORTS", "DEPENDS_ON", "TESTS",
|
|
227
|
+
"POSSIBLE_CALLS", "PARALLEL_IMPLEMENTATION",
|
|
228
|
+
"HANDLED_BY", "MOUNTS", "ROUTES_TO", "ROUTE_HANDLER",
|
|
229
|
+
"REGISTERS", "DISPATCHES_TO", "EVENT_LISTENER", "TASK_HANDLER", "COMMAND_HANDLER",
|
|
230
|
+
"INJECTS", "PROVIDES", "RESOLVES_DEPENDENCY", "CONFIGURES",
|
|
231
|
+
"DEPENDS_ON_PACKAGE",
|
|
232
|
+
}),
|
|
233
|
+
preferred_flow=("TARGET", "HANDLER", "SERVICE", "DATA", "TEST"),
|
|
234
|
+
include_callers=True,
|
|
235
|
+
include_callees=True,
|
|
236
|
+
include_tests=True,
|
|
237
|
+
include_framework=True,
|
|
238
|
+
include_git=True,
|
|
239
|
+
max_graph_depth=3,
|
|
240
|
+
max_package_depth=2,
|
|
241
|
+
preferred_target_types=("FUNCTION", "METHOD", "CLASS", "API_ENDPOINT"),
|
|
242
|
+
required_dimensions=("TARGET", "CALLER", "ROUTE", "PROVIDER", "REGISTRATION", "TEST", "PACKAGE"),
|
|
243
|
+
))
|
|
244
|
+
|
|
245
|
+
# TEST — locate and contextualize test coverage, target implementation, provider/event/route relationships
|
|
246
|
+
_register(RetrievalPolicy(
|
|
247
|
+
intent="TEST",
|
|
248
|
+
allowed_relationship_types=frozenset({
|
|
249
|
+
"TESTS", "CALLS", "DEPENDS_ON", "DEFINES", "IMPORTS",
|
|
250
|
+
"HANDLED_BY", "MOUNTS", "ROUTE_HANDLER",
|
|
251
|
+
"INJECTS", "PROVIDES", "RESOLVES_DEPENDENCY",
|
|
252
|
+
"REGISTERS", "EVENT_LISTENER", "TASK_HANDLER", "COMMAND_HANDLER",
|
|
253
|
+
}),
|
|
254
|
+
preferred_flow=("TEST", "TARGET", "DEFINITIONS", "DEPENDENCIES"),
|
|
255
|
+
include_callers=False,
|
|
256
|
+
include_callees=True,
|
|
257
|
+
include_tests=True,
|
|
258
|
+
include_framework=True,
|
|
259
|
+
max_graph_depth=2,
|
|
260
|
+
max_package_depth=1,
|
|
261
|
+
preferred_target_types=("TEST", "FUNCTION", "METHOD"),
|
|
262
|
+
required_dimensions=("TEST", "TARGET", "PROVIDER", "ROUTE"),
|
|
263
|
+
))
|
|
264
|
+
|
|
265
|
+
# ARCHITECTURE — top-level module, package, route, and service relationships
|
|
266
|
+
_register(RetrievalPolicy(
|
|
267
|
+
intent="ARCHITECTURE",
|
|
268
|
+
allowed_relationship_types=frozenset({
|
|
269
|
+
"IMPORTS", "DEPENDS_ON", "DEPENDS_ON_PACKAGE", "EXTERNAL_SERVICE",
|
|
270
|
+
"ROUTES_TO", "HANDLED_BY", "MOUNTS",
|
|
271
|
+
"DEFINES", "CONTAINS", "REGISTERS", "TASK_HANDLER", "COMMAND_HANDLER",
|
|
272
|
+
"INJECTS", "PROVIDES", "CONFIGURES",
|
|
273
|
+
}),
|
|
274
|
+
preferred_flow=("ENTRYPOINT", "SERVICE", "DATA", "EXTERNAL"),
|
|
275
|
+
include_callers=False,
|
|
276
|
+
include_callees=False,
|
|
277
|
+
include_tests=False,
|
|
278
|
+
include_architecture=True,
|
|
279
|
+
include_framework=True,
|
|
280
|
+
max_graph_depth=1,
|
|
281
|
+
max_package_depth=3,
|
|
282
|
+
preferred_target_types=("MODULE", "API_ENDPOINT", "CLASS"),
|
|
283
|
+
required_dimensions=("PACKAGE", "ENTRYPOINT", "SERVICE", "DATA"),
|
|
284
|
+
))
|
|
285
|
+
|
|
286
|
+
# EXPLAIN — like UNDERSTAND with full framework/route/package facts
|
|
287
|
+
_register(RetrievalPolicy(
|
|
288
|
+
intent="EXPLAIN",
|
|
289
|
+
allowed_relationship_types=frozenset({
|
|
290
|
+
"DEFINES", "CONTAINS", "CALLS", "IMPORTS", "DEPENDS_ON",
|
|
291
|
+
"HANDLED_BY", "ROUTES_TO", "MOUNTS", "ROUTE_HANDLER",
|
|
292
|
+
"POSSIBLE_CALLS", "EXTENDS", "IMPLEMENTS",
|
|
293
|
+
"PARALLEL_IMPLEMENTATION", "REGISTERS", "DISPATCHES_TO", "EVENT_LISTENER",
|
|
294
|
+
"TASK_HANDLER", "COMMAND_HANDLER",
|
|
295
|
+
"INJECTS", "PROVIDES", "RESOLVES_DEPENDENCY", "CONFIGURES",
|
|
296
|
+
"DEPENDS_ON_PACKAGE", "TESTS",
|
|
297
|
+
}),
|
|
298
|
+
preferred_flow=("TARGET", "DEFINITIONS", "DEPENDENCIES", "CALLERS_CALLEES"),
|
|
299
|
+
include_callers=True,
|
|
300
|
+
include_callees=True,
|
|
301
|
+
include_tests=False,
|
|
302
|
+
include_framework=True,
|
|
303
|
+
max_graph_depth=2,
|
|
304
|
+
max_package_depth=1,
|
|
305
|
+
preferred_target_types=("CLASS", "FUNCTION", "METHOD"),
|
|
306
|
+
required_dimensions=("TARGET", "CALLER", "CALLEE", "ROUTE", "PACKAGE"),
|
|
307
|
+
))
|
|
308
|
+
|
|
309
|
+
# Default fallback (same as UNDERSTAND)
|
|
310
|
+
_DEFAULT_POLICY = _POLICIES["UNDERSTAND"]
|
|
311
|
+
RETRIEVAL_POLICIES: dict[str, RetrievalPolicy] = _POLICIES
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
def get_retrieval_policy(intent: str) -> RetrievalPolicy:
|
|
315
|
+
"""Return the RetrievalPolicy for the given intent string.
|
|
316
|
+
|
|
317
|
+
Falls back to UNDERSTAND if the intent is not recognized.
|
|
318
|
+
"""
|
|
319
|
+
return _POLICIES.get(intent.upper().strip(), _DEFAULT_POLICY)
|
|
320
|
+
|