codegraph-engine 2.3.0__py3-none-any.whl → 3.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 (118) hide show
  1. codegraph/__init__.py +1 -1
  2. codegraph/__main__.py +7 -0
  3. codegraph/agent_brain.py +253 -2
  4. codegraph/agent_capabilities.py +1348 -67
  5. codegraph/agent_rules.py +2 -1
  6. codegraph/api_drift.py +455 -0
  7. codegraph/architecture_rules.py +123 -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/change_impact.py +320 -110
  22. codegraph/changelog.py +170 -0
  23. codegraph/cli.py +1605 -62
  24. codegraph/cli_output.py +17 -2
  25. codegraph/context.py +135 -24
  26. codegraph/context_freshness.py +2 -0
  27. codegraph/database/__init__.py +14 -0
  28. codegraph/database/extractor.py +712 -17
  29. codegraph/database/interrogation.py +388 -2
  30. codegraph/database/schema_drift.py +862 -0
  31. codegraph/dataflow_propagation.py +118 -0
  32. codegraph/dead_code.py +387 -0
  33. codegraph/epistemic.py +15 -0
  34. codegraph/evidence_contract.py +34 -3
  35. codegraph/federation.py +245 -0
  36. codegraph/frameworks.py +234 -12
  37. codegraph/frameworks_nestjs.py +502 -0
  38. codegraph/frameworks_nextjs.py +337 -0
  39. codegraph/frameworks_react.py +457 -0
  40. codegraph/freshness.py +2 -0
  41. codegraph/frontend_html.py +109 -0
  42. codegraph/git.py +2 -0
  43. codegraph/git_state.py +2 -0
  44. codegraph/graph/traversal.py +150 -7
  45. codegraph/graph_csr.py +218 -0
  46. codegraph/incremental.py +150 -0
  47. codegraph/indexing/__init__.py +7 -1
  48. codegraph/indexing/classifier.py +5 -0
  49. codegraph/indexing/indexer.py +292 -38
  50. codegraph/indexing/languages/__init__.py +1 -0
  51. codegraph/indexing/languages/cpp.py +457 -0
  52. codegraph/indexing/languages/go.py +459 -0
  53. codegraph/indexing/languages/jvm.py +583 -0
  54. codegraph/indexing/languages/rust.py +507 -0
  55. codegraph/indexing/models.py +15 -1
  56. codegraph/indexing/parser.py +385 -9
  57. codegraph/indexing/pool.py +136 -0
  58. codegraph/indexing/protocols.py +220 -0
  59. codegraph/indexing/scanner.py +23 -0
  60. codegraph/indexing/templates.py +418 -0
  61. codegraph/interrogation.py +207 -39
  62. codegraph/lsp.py +318 -0
  63. codegraph/lsp_bridge/__init__.py +16 -0
  64. codegraph/lsp_bridge/bridge.py +102 -0
  65. codegraph/lsp_bridge/client.py +207 -0
  66. codegraph/lsp_bridge/models.py +71 -0
  67. codegraph/mcp/server.py +502 -29
  68. codegraph/memory/trajectory.py +282 -0
  69. codegraph/models.py +7 -0
  70. codegraph/monorepo.py +3 -0
  71. codegraph/multi_agent/__init__.py +13 -0
  72. codegraph/multi_agent/coordinator.py +229 -0
  73. codegraph/multi_agent/models.py +76 -0
  74. codegraph/optimizer.py +42 -5
  75. codegraph/polymorphism.py +95 -0
  76. codegraph/pr_review.py +296 -0
  77. codegraph/process_lifecycle.py +50 -12
  78. codegraph/reachability.py +198 -0
  79. codegraph/reachability_index.py +74 -0
  80. codegraph/refactor/__init__.py +48 -0
  81. codegraph/refactor/models.py +114 -0
  82. codegraph/refactor/patcher.py +348 -0
  83. codegraph/refactor/renamer.py +844 -0
  84. codegraph/refactor/transactions.py +414 -0
  85. codegraph/repair.py +233 -0
  86. codegraph/resolver.py +1357 -161
  87. codegraph/retrieval_policy.py +22 -1
  88. codegraph/roblox.py +2174 -0
  89. codegraph/route_composer.py +7 -0
  90. codegraph/route_topology.py +172 -0
  91. codegraph/runtime/__init__.py +25 -0
  92. codegraph/runtime/collector.py +155 -0
  93. codegraph/runtime/db_watcher.py +191 -0
  94. codegraph/runtime/ingestor.py +30 -10
  95. codegraph/runtime/otel_receiver.py +208 -0
  96. codegraph/runtime/port_inspector.py +304 -0
  97. codegraph/runtime/runner.py +155 -6
  98. codegraph/runtime/trace_linker.py +175 -0
  99. codegraph/sandbox.py +215 -0
  100. codegraph/search/hybrid.py +26 -0
  101. codegraph/security/supply_chain.py +188 -0
  102. codegraph/security/taint.py +421 -0
  103. codegraph/semantic_decorators.py +34 -3
  104. codegraph/structural_diff.py +2 -0
  105. codegraph/styles.py +144 -0
  106. codegraph/symbol_history.py +2 -0
  107. codegraph/test_gen.py +437 -0
  108. codegraph/tsconfig.py +236 -0
  109. codegraph/ui/__init__.py +6 -0
  110. codegraph/ui/server.py +876 -0
  111. codegraph/watcher.py +323 -0
  112. {codegraph_engine-2.3.0.dist-info → codegraph_engine-3.0.1.dist-info}/METADATA +365 -67
  113. codegraph_engine-3.0.1.dist-info/RECORD +164 -0
  114. {codegraph_engine-2.3.0.dist-info → codegraph_engine-3.0.1.dist-info}/WHEEL +1 -1
  115. codegraph_engine-2.3.0.dist-info/RECORD +0 -94
  116. {codegraph_engine-2.3.0.dist-info → codegraph_engine-3.0.1.dist-info}/entry_points.txt +0 -0
  117. {codegraph_engine-2.3.0.dist-info → codegraph_engine-3.0.1.dist-info}/licenses/LICENSE +0 -0
  118. {codegraph_engine-2.3.0.dist-info → codegraph_engine-3.0.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,507 @@
1
+ """Deep, production-grade Rust (.rs) language parser and framework resolver for CodeGraph.
2
+
3
+ Provides deep Python-level AST extraction for Rust:
4
+ - Full scope tree: crate/module -> struct / enum / trait -> impl block -> method / function
5
+ - Exact parameters, type annotations, return types, and parameter counts
6
+ - Rustdoc comments (///) attached to symbols
7
+ - Visibility & export detection (pub, pub(crate), private)
8
+ - Trait implementations (InheritanceRef)
9
+ - Local variable bindings (BindingRef)
10
+ - Enclosing caller-to-callee linkage (CallRef with caller_canonical_id and receiver)
11
+ - Router scopes & nested route compositions (Actix-web, Axum, Rocket)
12
+ """
13
+ from __future__ import annotations
14
+
15
+ import hashlib
16
+ import re
17
+ from typing import Any
18
+
19
+ from codegraph.frameworks import RouteDetection, RouterMountDetection
20
+ from codegraph.indexing.models import (
21
+ BindingRef,
22
+ CallRef,
23
+ ImportRef,
24
+ InheritanceRef,
25
+ Symbol,
26
+ )
27
+
28
+
29
+ def parse_rust(content: str, file_path: str) -> Any:
30
+ """Parse Rust source code with deep scope tracking, caller linking, and route resolution."""
31
+ from codegraph.indexing.parser import ParseResult
32
+
33
+ source_hash = hashlib.sha256(content.encode("utf-8", errors="replace")).hexdigest()
34
+ lines = content.splitlines()
35
+
36
+ symbols: list[Symbol] = []
37
+ imports: list[ImportRef] = []
38
+ calls: list[CallRef] = []
39
+ inheritance: list[InheritanceRef] = []
40
+ routes: list[RouteDetection] = []
41
+ mounts: list[RouterMountDetection] = []
42
+ bindings: list[BindingRef] = []
43
+ exports: list[str] = []
44
+
45
+ # Infer crate/module name from path
46
+ crate_name = "crate"
47
+ norm_path = file_path.replace("\\", "/")
48
+ if "src/" in norm_path:
49
+ rel = norm_path.split("src/", 1)[1]
50
+ crate_name = rel.replace(".rs", "").replace("/", "::")
51
+ else:
52
+ crate_name = norm_path.split("/")[-1].replace(".rs", "")
53
+
54
+ # Helper to calculate block end based on brace counting
55
+ def find_block_end(start_idx: int) -> int:
56
+ brace_count = 0
57
+ found_open = False
58
+ for cur_idx in range(start_idx, len(lines)):
59
+ cur_line = lines[cur_idx]
60
+ sanitized = re.sub(r'"[^"\\]*(?:\\.[^"\\]*)*"', '""', cur_line)
61
+ sanitized = re.sub(r"//.*$", "", sanitized)
62
+
63
+ for char in sanitized:
64
+ if char == "{":
65
+ brace_count += 1
66
+ found_open = True
67
+ elif char == "}":
68
+ brace_count -= 1
69
+ if found_open and brace_count <= 0:
70
+ return cur_idx + 1
71
+ return len(lines)
72
+
73
+ # Helper to collect rustdoc comments immediately preceding declaration
74
+ def collect_rustdoc(start_idx: int) -> str | None:
75
+ doc_lines: list[str] = []
76
+ cur_idx = start_idx - 1
77
+ while cur_idx >= 0:
78
+ ln = lines[cur_idx].strip()
79
+ if ln.startswith("///"):
80
+ doc_lines.insert(0, ln.lstrip("/ ").rstrip())
81
+ cur_idx -= 1
82
+ else:
83
+ break
84
+ return "\n".join(doc_lines) if doc_lines else None
85
+
86
+ # Helper to parse parameter count and return type
87
+ def parse_params_and_return(clean_line: str) -> tuple[int, str | None]:
88
+ m_ret = re.search(r"\)\s*(?:->\s*([^{]+))?(?:\s*\{|$)", clean_line)
89
+ ret_type = None
90
+ if m_ret and m_ret.group(1):
91
+ ret_type = m_ret.group(1).strip()
92
+
93
+ m_params = re.search(r"\((.*?)\)", clean_line)
94
+ param_count = 0
95
+ if m_params and m_params.group(1).strip():
96
+ params = [p.strip() for p in m_params.group(1).split(",") if p.strip()]
97
+ param_count = len(params)
98
+
99
+ return param_count, ret_type
100
+
101
+ # Regex patterns
102
+ use_re = re.compile(r"^\s*(?:pub\s+)?use\s+([^;]+);")
103
+ struct_re = re.compile(r"^\s*(pub(?:\([A-Za-z0-9_]+\))?\s+)?struct\s+([A-Za-z0-9_]+)")
104
+ enum_re = re.compile(r"^\s*(pub(?:\([A-Za-z0-9_]+\))?\s+)?enum\s+([A-Za-z0-9_]+)")
105
+ trait_re = re.compile(r"^\s*(pub(?:\([A-Za-z0-9_]+\))?\s+)?trait\s+([A-Za-z0-9_]+)")
106
+ impl_re = re.compile(r"^\s*impl(?:\s*<[^>]+>)?\s+(?:([A-Za-z0-9_]+)\s+for\s+)?([A-Za-z0-9_]+)")
107
+
108
+ # Attributes
109
+ actix_attr_re = re.compile(r'^\s*#\[(get|post|put|delete|patch|head)\s*\(\s*"([^"]+)"\s*\)\]')
110
+
111
+ # Scope mount: web::scope("/api/v1") or .nest("/api/v1", ...)
112
+ scope_mount_re = re.compile(r'(?:web::scope|\.nest)\s*\(\s*"([^"]+)"')
113
+
114
+ # Local binding: let client = Client::new();
115
+ binding_re = re.compile(r'^\s*let\s+(?:mut\s+)?([A-Za-z0-9_]+)(?:\s*:\s*([A-Za-z0-9_&<>*]+))?\s*=\s*([A-Za-z0-9_:]+)')
116
+
117
+ active_impl_type: str | None = None
118
+ active_impl_end: int = 0
119
+ active_fn_scope: tuple[str, str, int] | None = None
120
+ pending_actix_route: tuple[str, str, int] | None = None
121
+ imported_symbols: dict[str, str] = {}
122
+
123
+ for idx, line in enumerate(lines):
124
+ lineno = idx + 1
125
+ clean = line.strip()
126
+
127
+ if lineno > active_impl_end:
128
+ active_impl_type = None
129
+
130
+ if active_fn_scope and lineno > active_fn_scope[2]:
131
+ active_fn_scope = None
132
+
133
+ # 1. Imports / Use declarations
134
+ m_use = use_re.match(clean)
135
+ if m_use:
136
+ use_path = m_use.group(1).strip()
137
+ if "::{" in use_path:
138
+ base_mod, items_str = use_path.split("::{", 1)
139
+ base_mod = base_mod.removeprefix("crate::")
140
+ for itm in items_str.rstrip("}").split(","):
141
+ itm_clean = itm.strip()
142
+ if itm_clean:
143
+ imported_symbols[itm_clean] = f"{base_mod}::{itm_clean}"
144
+ imports.append(
145
+ ImportRef(
146
+ module=base_mod,
147
+ source_file=file_path,
148
+ name=itm_clean,
149
+ line=lineno,
150
+ )
151
+ )
152
+ else:
153
+ clean_path = use_path.removeprefix("crate::")
154
+ imported_name = clean_path.split("::")[-1]
155
+ imported_symbols[imported_name] = clean_path
156
+ imports.append(
157
+ ImportRef(
158
+ module=clean_path,
159
+ source_file=file_path,
160
+ name=imported_name,
161
+ line=lineno,
162
+ )
163
+ )
164
+ continue
165
+
166
+ # 2. Check Route Attribute (Actix / Rocket)
167
+ m_actix = actix_attr_re.match(clean)
168
+ if m_actix:
169
+ http_method = m_actix.group(1).upper()
170
+ route_path = m_actix.group(2)
171
+ pending_actix_route = (http_method, route_path, lineno)
172
+ continue
173
+
174
+ # 3. Check Struct
175
+ m_struct = struct_re.match(clean)
176
+ if m_struct:
177
+ vis_raw = m_struct.group(1) or ""
178
+ name = m_struct.group(2)
179
+ end_line = find_block_end(idx) if "{" in line else lineno
180
+ canon_id = f"rust:{crate_name}::{name}"
181
+ doc = collect_rustdoc(idx)
182
+ is_pub = "pub" in vis_raw
183
+ vis = "public" if is_pub else "private"
184
+
185
+ symbols.append(
186
+ Symbol(
187
+ name=name,
188
+ qualified_name=f"{crate_name}::{name}",
189
+ kind="struct",
190
+ start_line=lineno,
191
+ end_line=end_line,
192
+ file_path=file_path,
193
+ canonical_id=canon_id,
194
+ language="rust",
195
+ module=crate_name,
196
+ scope=crate_name,
197
+ visibility=vis,
198
+ documentation=doc,
199
+ )
200
+ )
201
+ if is_pub:
202
+ exports.append(name)
203
+ continue
204
+
205
+ # 4. Check Enum
206
+ m_enum = enum_re.match(clean)
207
+ if m_enum:
208
+ vis_raw = m_enum.group(1) or ""
209
+ name = m_enum.group(2)
210
+ end_line = find_block_end(idx)
211
+ canon_id = f"rust:{crate_name}::{name}"
212
+ doc = collect_rustdoc(idx)
213
+ is_pub = "pub" in vis_raw
214
+ vis = "public" if is_pub else "private"
215
+
216
+ symbols.append(
217
+ Symbol(
218
+ name=name,
219
+ qualified_name=f"{crate_name}::{name}",
220
+ kind="enum",
221
+ start_line=lineno,
222
+ end_line=end_line,
223
+ file_path=file_path,
224
+ canonical_id=canon_id,
225
+ language="rust",
226
+ module=crate_name,
227
+ scope=crate_name,
228
+ visibility=vis,
229
+ documentation=doc,
230
+ )
231
+ )
232
+ if is_pub:
233
+ exports.append(name)
234
+ continue
235
+
236
+ # 5. Check Trait
237
+ m_trait = trait_re.match(clean)
238
+ if m_trait:
239
+ vis_raw = m_trait.group(1) or ""
240
+ name = m_trait.group(2)
241
+ end_line = find_block_end(idx)
242
+ canon_id = f"rust:{crate_name}::{name}"
243
+ doc = collect_rustdoc(idx)
244
+ is_pub = "pub" in vis_raw
245
+ vis = "public" if is_pub else "private"
246
+
247
+ symbols.append(
248
+ Symbol(
249
+ name=name,
250
+ qualified_name=f"{crate_name}::{name}",
251
+ kind="trait",
252
+ start_line=lineno,
253
+ end_line=end_line,
254
+ file_path=file_path,
255
+ canonical_id=canon_id,
256
+ language="rust",
257
+ module=crate_name,
258
+ scope=crate_name,
259
+ visibility=vis,
260
+ documentation=doc,
261
+ )
262
+ )
263
+ if is_pub:
264
+ exports.append(name)
265
+ continue
266
+
267
+ # 6. Check Impl Block & Trait Implementation (InheritanceRef)
268
+ m_impl = impl_re.match(clean)
269
+ if m_impl:
270
+ trait_name = m_impl.group(1)
271
+ target_type = m_impl.group(2)
272
+ active_impl_type = target_type
273
+ active_impl_end = find_block_end(idx)
274
+
275
+ if trait_name:
276
+ inheritance.append(
277
+ InheritanceRef(
278
+ source_symbol=target_type,
279
+ base_name=trait_name,
280
+ relationship="IMPLEMENTS",
281
+ source_file=file_path,
282
+ line=lineno,
283
+ )
284
+ )
285
+ continue
286
+
287
+ # 7. Check Function / Method (supporting multi-line parameter signatures)
288
+ m_fn_start = re.match(r"^\s*(pub(?:\([A-Za-z0-9_]+\))?\s+)?(?:async\s+)?fn\s+([A-Za-z0-9_]+)\s*\(", clean)
289
+ if m_fn_start:
290
+ vis_raw = m_fn_start.group(1) or ""
291
+ fn_name = m_fn_start.group(2)
292
+ start_p = clean.find("(", m_fn_start.end(2))
293
+ depth = 1
294
+ end_p = -1
295
+ clean_scan = clean
296
+ for idx_c in range(start_p + 1, len(clean)):
297
+ if clean[idx_c] == "(":
298
+ depth += 1
299
+ elif clean[idx_c] == ")":
300
+ depth -= 1
301
+ if depth == 0:
302
+ end_p = idx_c
303
+ break
304
+ if end_p == -1:
305
+ combined = clean
306
+ scan_idx = idx + 1
307
+ while end_p == -1 and scan_idx < len(lines) and scan_idx < idx + 20:
308
+ next_l = lines[scan_idx].strip()
309
+ if next_l.startswith("//") or next_l.startswith("/*"):
310
+ scan_idx += 1
311
+ continue
312
+ prev_len = len(combined)
313
+ combined += " " + next_l
314
+ for idx_c in range(prev_len + 1, len(combined)):
315
+ if combined[idx_c] == "(":
316
+ depth += 1
317
+ elif combined[idx_c] == ")":
318
+ depth -= 1
319
+ if depth == 0:
320
+ end_p = idx_c
321
+ break
322
+ scan_idx += 1
323
+ if end_p != -1:
324
+ clean_scan = combined
325
+
326
+ if end_p != -1:
327
+ sig_params = clean_scan[start_p + 1:end_p].strip()
328
+ remainder = clean_scan[end_p + 1:].strip()
329
+ m_ret = re.search(r"->\s*([^{;]+)", remainder)
330
+ sig_ret = f" -> {m_ret.group(1).strip()}" if m_ret else ""
331
+ r_type = m_ret.group(1).strip() if m_ret else "()"
332
+ p_cnt = len([p for p in sig_params.split(",") if p.strip()]) if sig_params else 0
333
+
334
+ end_line = find_block_end(idx)
335
+ doc = collect_rustdoc(idx)
336
+ is_pub = "pub" in vis_raw
337
+ vis = "public" if is_pub else "private"
338
+
339
+ if active_impl_type:
340
+ # Method inside impl block
341
+ canon_id = f"rust:{crate_name}::{active_impl_type}::{fn_name}"
342
+ symbols.append(
343
+ Symbol(
344
+ name=fn_name,
345
+ qualified_name=f"{crate_name}::{active_impl_type}::{fn_name}",
346
+ kind="method",
347
+ start_line=lineno,
348
+ end_line=end_line,
349
+ file_path=file_path,
350
+ canonical_id=canon_id,
351
+ language="rust",
352
+ module=crate_name,
353
+ scope=f"{crate_name}::{active_impl_type}",
354
+ signature=f"fn {fn_name}({sig_params}){sig_ret}".strip(),
355
+ visibility=vis,
356
+ return_type=r_type,
357
+ parameter_count=p_cnt,
358
+ documentation=doc,
359
+ )
360
+ )
361
+ if is_pub:
362
+ exports.append(f"{active_impl_type}::{fn_name}")
363
+ active_fn_scope = (fn_name, canon_id, end_line)
364
+ else:
365
+ # Standalone function
366
+ canon_id = f"rust:{crate_name}::{fn_name}"
367
+ symbols.append(
368
+ Symbol(
369
+ name=fn_name,
370
+ qualified_name=f"{crate_name}::{fn_name}",
371
+ kind="function",
372
+ start_line=lineno,
373
+ end_line=end_line,
374
+ file_path=file_path,
375
+ canonical_id=canon_id,
376
+ language="rust",
377
+ module=crate_name,
378
+ scope=crate_name,
379
+ signature=f"fn {fn_name}({sig_params}){sig_ret}".strip(),
380
+ visibility=vis,
381
+ return_type=r_type,
382
+ parameter_count=p_cnt,
383
+ documentation=doc,
384
+ )
385
+ )
386
+ if is_pub:
387
+ exports.append(fn_name)
388
+ active_fn_scope = (fn_name, canon_id, end_line)
389
+
390
+ # Associate preceding Actix/Rocket route attribute if present
391
+ if pending_actix_route:
392
+ m_method, r_path, r_line = pending_actix_route
393
+ routes.append(
394
+ RouteDetection(
395
+ framework="actix-web",
396
+ http_method=m_method,
397
+ route_path=r_path,
398
+ normalized_route=r_path,
399
+ handler_name=fn_name,
400
+ handler_canonical_id=canon_id,
401
+ file_path=file_path,
402
+ line=r_line,
403
+ confidence="HIGH",
404
+ evidence=f"Actix/Rocket #[{m_method.lower()}(\"{r_path}\")] attribute on line {r_line}",
405
+ )
406
+ )
407
+ pending_actix_route = None
408
+ continue
409
+
410
+ # 8. Check Router Scopes / Nesting
411
+ m_mount = scope_mount_re.search(clean)
412
+ if m_mount:
413
+ prefix = m_mount.group(1)
414
+ mounts.append(
415
+ RouterMountDetection(
416
+ framework="actix-web",
417
+ parent_router="App",
418
+ child_router="Scope",
419
+ prefix=prefix,
420
+ file_path=file_path,
421
+ line=lineno,
422
+ confidence="HIGH",
423
+ evidence=f"Actix/Axum router scope prefix '{prefix}'",
424
+ )
425
+ )
426
+
427
+ # 9. Check Axum Routes (supporting chained methods e.g. .route("/path", get(a).post(b)))
428
+ if ".route(" in clean:
429
+ m_route_path = re.search(r'\.route\s*\(\s*"([^"]+)"', clean)
430
+ if m_route_path:
431
+ r_path = m_route_path.group(1)
432
+ verbs: list[tuple[str, str]] = []
433
+ init_verb = re.search(r'\.route\s*\(\s*"[^"]+"\s*,\s*(get|post|put|delete|patch|options|head)\s*\(\s*([A-Za-z0-9_]+)\s*\)', clean)
434
+ if init_verb:
435
+ verbs.append((init_verb.group(1), init_verb.group(2)))
436
+ for chained_verb in re.finditer(r'\.(get|post|put|delete|patch|options|head)\s*\(\s*([A-Za-z0-9_]+)\s*\)', clean):
437
+ item = (chained_verb.group(1), chained_verb.group(2))
438
+ if item not in verbs:
439
+ verbs.append(item)
440
+
441
+ for v_method, h_name in verbs:
442
+ target_canon = f"rust:{imported_symbols.get(h_name, f'{crate_name}::{h_name}')}"
443
+ routes.append(
444
+ RouteDetection(
445
+ framework="axum",
446
+ http_method=v_method.upper(),
447
+ route_path=r_path,
448
+ normalized_route=r_path,
449
+ handler_name=h_name,
450
+ handler_canonical_id=target_canon,
451
+ file_path=file_path,
452
+ line=lineno,
453
+ confidence="HIGH",
454
+ evidence=f"Axum {v_method.upper()} route '{r_path}' bound to '{h_name}' on line {lineno}",
455
+ )
456
+ )
457
+
458
+ # 10. Check Local Variable Bindings
459
+ m_bind = binding_re.match(clean)
460
+ if m_bind:
461
+ var_name = m_bind.group(1)
462
+ source = m_bind.group(3)
463
+ scope_str = active_fn_scope[1] if active_fn_scope else crate_name
464
+ bindings.append(
465
+ BindingRef(
466
+ target_name=var_name,
467
+ file_path=file_path,
468
+ line=lineno,
469
+ scope=scope_str,
470
+ expr_kind="IDENTIFIER",
471
+ source_expr=source,
472
+ )
473
+ )
474
+
475
+ # 11. Enclosing Caller-Linked Method & Function Calls
476
+ call_matches = re.finditer(r"\b([A-Za-z0-9_]+)\.([A-Za-z0-9_]+)\s*\(", clean)
477
+ for cm in call_matches:
478
+ receiver = cm.group(1)
479
+ callee_name = cm.group(2)
480
+ if receiver not in ("self", "println", "eprintln", "format", "vec", "Ok", "Err", "Some"):
481
+ calls.append(
482
+ CallRef(
483
+ source_file=file_path,
484
+ callee=callee_name,
485
+ qualified_callee=f"{receiver}.{callee_name}",
486
+ line=lineno,
487
+ confidence="HIGH" if active_fn_scope else "MEDIUM",
488
+ caller_symbol=active_fn_scope[0] if active_fn_scope else None,
489
+ caller_canonical_id=active_fn_scope[1] if active_fn_scope else f"rust:{crate_name}",
490
+ receiver=receiver,
491
+ )
492
+ )
493
+
494
+ return ParseResult(
495
+ path=file_path,
496
+ language="rust",
497
+ source_hash=source_hash,
498
+ symbols=tuple(symbols),
499
+ imports=tuple(imports),
500
+ calls=tuple(calls),
501
+ inheritance=tuple(inheritance),
502
+ routes=tuple(routes),
503
+ mounts=tuple(mounts),
504
+ bindings=tuple(bindings),
505
+ exports=tuple(exports),
506
+ parse_failed=False,
507
+ )
@@ -21,22 +21,34 @@ from dataclasses import dataclass, field
21
21
  from functools import lru_cache
22
22
 
23
23
  _SOURCE_EXTENSIONS = (
24
+ ".server.luau",
25
+ ".client.luau",
26
+ ".server.lua",
27
+ ".client.lua",
24
28
  ".d.ts",
25
29
  ".pyi",
26
30
  ".tsx",
27
31
  ".jsx",
28
32
  ".mjs",
29
33
  ".cjs",
34
+ ".luau",
35
+ ".lua",
30
36
  ".py",
31
37
  ".ts",
32
38
  ".js",
39
+ ".html",
40
+ ".htm",
41
+ ".jinja",
42
+ ".jinja2",
43
+ ".njk",
44
+ ".ejs",
33
45
  )
34
46
 
35
47
 
36
48
  @lru_cache(maxsize=65536)
37
49
  def normalize_module(file_path: str, language: str = "") -> str:
38
50
  """Deterministically normalize a repository-relative file path into a dotted module ID."""
39
- del language # normalization is uniform across Python/JS/TS after extension/index rules
51
+ del language # normalization is uniform across Python/JS/TS/Luau after extension/index rules
40
52
  cleaned = file_path.replace("\\", "/").strip()
41
53
  while cleaned.startswith("./"):
42
54
  cleaned = cleaned[2:]
@@ -58,6 +70,8 @@ def normalize_module(file_path: str, language: str = "") -> str:
58
70
  cleaned = cleaned[: -len("/__init__")]
59
71
  elif cleaned.endswith("/index"):
60
72
  cleaned = cleaned[: -len("/index")]
73
+ elif cleaned.endswith("/init"):
74
+ cleaned = cleaned[: -len("/init")]
61
75
 
62
76
  parts = [p for p in cleaned.split("/") if p and p != "."]
63
77
  return ".".join(parts) if parts else "root"