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,459 @@
1
+ """Deep, production-grade Go (.go) language parser and framework resolver for CodeGraph.
2
+
3
+ Provides deep Python-level AST extraction for Go:
4
+ - Full scope tree: package -> struct / interface -> method / function -> local scope
5
+ - Exact parameters, type annotations, return types, and parameter counts
6
+ - Godoc docstrings attached to symbols
7
+ - Visibility & export detection (Go capitalization rule)
8
+ - Struct composition & interface implementation (InheritanceRef)
9
+ - Local variable bindings (BindingRef)
10
+ - Enclosing caller-to-callee linkage (CallRef with caller_canonical_id and receiver)
11
+ - Router groups & mounted prefix composition (Gin, Echo, Chi, net/http)
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, join_route_prefixes
20
+ from codegraph.indexing.models import (
21
+ BindingRef,
22
+ CallRef,
23
+ ImportRef,
24
+ InheritanceRef,
25
+ Symbol,
26
+ )
27
+
28
+
29
+ def parse_go(content: str, file_path: str) -> Any:
30
+ """Parse Go 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
+ # 1. Package Extraction
46
+ pkg_name = "main"
47
+ for line in lines[:30]:
48
+ m_pkg = re.match(r"^\s*package\s+([A-Za-z0-9_]+)", line)
49
+ if m_pkg:
50
+ pkg_name = m_pkg.group(1)
51
+ break
52
+
53
+ # 2. Imports Extraction (single and block)
54
+ in_import_block = False
55
+ for line_idx, line in enumerate(lines, start=1):
56
+ clean = line.strip()
57
+ if clean.startswith("//") or not clean:
58
+ continue
59
+
60
+ if clean == "import (" or clean.startswith("import ("):
61
+ in_import_block = True
62
+ continue
63
+ elif in_import_block:
64
+ if clean == ")":
65
+ in_import_block = False
66
+ continue
67
+ m_imp = re.match(r'^(?:([A-Za-z0-9_]+)\s+)?"([^"]+)"', clean)
68
+ if m_imp:
69
+ alias = m_imp.group(1)
70
+ mod_path = m_imp.group(2)
71
+ imported_name = alias or mod_path.split("/")[-1]
72
+ imports.append(
73
+ ImportRef(
74
+ module=mod_path,
75
+ source_file=file_path,
76
+ name=imported_name,
77
+ line=line_idx,
78
+ alias=alias,
79
+ )
80
+ )
81
+ else:
82
+ m_single = re.match(r'^import\s+(?:([A-Za-z0-9_]+)\s+)?"([^"]+)"', clean)
83
+ if m_single:
84
+ alias = m_single.group(1)
85
+ mod_path = m_single.group(2)
86
+ imported_name = alias or mod_path.split("/")[-1]
87
+ imports.append(
88
+ ImportRef(
89
+ module=mod_path,
90
+ source_file=file_path,
91
+ name=imported_name,
92
+ line=line_idx,
93
+ alias=alias,
94
+ )
95
+ )
96
+
97
+ # 3. Helper to calculate block end based on brace counting
98
+ def find_block_end(start_idx: int) -> int:
99
+ brace_count = 0
100
+ found_open = False
101
+ for cur_idx in range(start_idx, len(lines)):
102
+ cur_line = lines[cur_idx]
103
+ sanitized = re.sub(r'"[^"\\]*(?:\\.[^"\\]*)*"', '""', cur_line)
104
+ sanitized = re.sub(r"`[^`]*`", '""', sanitized)
105
+ sanitized = re.sub(r"//.*$", "", sanitized)
106
+
107
+ for char in sanitized:
108
+ if char == "{":
109
+ brace_count += 1
110
+ found_open = True
111
+ elif char == "}":
112
+ brace_count -= 1
113
+ if found_open and brace_count <= 0:
114
+ return cur_idx + 1
115
+ return len(lines)
116
+
117
+ # Helper to collect godoc comments immediately preceding a declaration
118
+ def collect_godoc(start_idx: int) -> str | None:
119
+ doc_lines: list[str] = []
120
+ cur_idx = start_idx - 1
121
+ while cur_idx >= 0:
122
+ ln = lines[cur_idx].strip()
123
+ if ln.startswith("//"):
124
+ doc_lines.insert(0, ln.lstrip("/ ").rstrip())
125
+ cur_idx -= 1
126
+ else:
127
+ break
128
+ return "\n".join(doc_lines) if doc_lines else None
129
+
130
+ # Helper to parse parameter count and return type
131
+ def parse_params_and_return(sig_str: str) -> tuple[int, str | None]:
132
+ m_ret = re.search(r"\)\s*(?:(?:\(([^)]+)\))|([A-Za-z0-9_*\[\]]+))(?:\s*\{|$)", sig_str)
133
+ ret_type = None
134
+ if m_ret:
135
+ ret_type = (m_ret.group(1) or m_ret.group(2) or "").strip()
136
+
137
+ # Count parameters
138
+ m_params = re.search(r"\((.*?)\)", sig_str)
139
+ param_count = 0
140
+ if m_params and m_params.group(1).strip():
141
+ params = [p.strip() for p in m_params.group(1).split(",") if p.strip()]
142
+ param_count = len(params)
143
+
144
+ return param_count, ret_type
145
+
146
+ # Router groups map: variable name -> mounted prefix (e.g. "v1" -> "/api/v1")
147
+ router_groups: dict[str, str] = {}
148
+
149
+ # Active function scope for call graph linking: (name, canon_id, end_line)
150
+ active_scope: tuple[str, str, int] | None = None
151
+
152
+ # Regex definitions
153
+ struct_re = re.compile(r"^\s*type\s+([A-Z][A-Za-z0-9_]*)\s+struct\b")
154
+ interface_re = re.compile(r"^\s*type\s+([A-Z][A-Za-z0-9_]*)\s+interface\b")
155
+ method_re = re.compile(r"^\s*func\s*\(\s*(?:[A-Za-z0-9_]+\s+)?\*?([A-Za-z0-9_]+)\s*\)\s*([A-Za-z0-9_]+)\s*\((.*?)\)(.*)")
156
+ func_re = re.compile(r"^\s*func\s+([A-Za-z0-9_]+)\s*\((.*?)\)(.*)")
157
+
158
+ # Router group definition: v1 := r.Group("/v1")
159
+ group_re = re.compile(r'([A-Za-z0-9_]+)\s*:=\s*([A-Za-z0-9_]+)\.Group\s*\(\s*"([^"]+)"\s*\)')
160
+
161
+ # Route registrations
162
+ gin_re = re.compile(r'([A-Za-z0-9_]+)\.(GET|POST|PUT|DELETE|PATCH|OPTIONS|HEAD)\s*\(\s*"([^"]+)"\s*,\s*([A-Za-z0-9_.]+)')
163
+ chi_re = re.compile(r'([A-Za-z0-9_]+)\.(Get|Post|Put|Delete|Patch)\s*\(\s*"([^"]+)"\s*,\s*([A-Za-z0-9_.]+)')
164
+ http_re = re.compile(r'http\.HandleFunc\s*\(\s*"([^"]+)"\s*,\s*([A-Za-z0-9_.]+)')
165
+
166
+ # Local binding: x := NewService(...) or var client = ...
167
+ binding_re = re.compile(r'^\s*(?:var\s+)?([A-Za-z0-9_]+)\s*(?::=|=)\s*([A-Za-z0-9_]+(?:\.[A-Za-z0-9_]+)*)\s*\(')
168
+
169
+ for idx, line in enumerate(lines):
170
+ lineno = idx + 1
171
+ clean = line.strip()
172
+
173
+ # Update active scope stack
174
+ if active_scope and lineno > active_scope[2]:
175
+ active_scope = None
176
+
177
+ # 4. Check Struct
178
+ m_struct = struct_re.match(clean)
179
+ if m_struct:
180
+ name = m_struct.group(1)
181
+ end_line = find_block_end(idx)
182
+ canon_id = f"go:{pkg_name}:{name}"
183
+ doc = collect_godoc(idx)
184
+ symbols.append(
185
+ Symbol(
186
+ name=name,
187
+ qualified_name=f"{pkg_name}.{name}",
188
+ kind="struct",
189
+ start_line=lineno,
190
+ end_line=end_line,
191
+ file_path=file_path,
192
+ canonical_id=canon_id,
193
+ language="go",
194
+ module=pkg_name,
195
+ scope=pkg_name,
196
+ visibility="public" if name[0].isupper() else "private",
197
+ documentation=doc,
198
+ )
199
+ )
200
+ if name[0].isupper():
201
+ exports.append(name)
202
+
203
+ # Check for embedded struct composition (InheritanceRef)
204
+ for inner_idx in range(idx + 1, min(end_line - 1, len(lines))):
205
+ inner_clean = lines[inner_idx].strip()
206
+ m_embed = re.match(r"^([A-Z][A-Za-z0-9_]*)(?:\s+`[^`]*`)?$", inner_clean)
207
+ if m_embed:
208
+ embedded_type = m_embed.group(1)
209
+ inheritance.append(
210
+ InheritanceRef(
211
+ source_symbol=name,
212
+ base_name=embedded_type,
213
+ relationship="EXTENDS",
214
+ source_file=file_path,
215
+ line=inner_idx + 1,
216
+ )
217
+ )
218
+ continue
219
+
220
+ # 5. Check Interface
221
+ m_iface = interface_re.match(clean)
222
+ if m_iface:
223
+ name = m_iface.group(1)
224
+ end_line = find_block_end(idx)
225
+ canon_id = f"go:{pkg_name}:{name}"
226
+ doc = collect_godoc(idx)
227
+ symbols.append(
228
+ Symbol(
229
+ name=name,
230
+ qualified_name=f"{pkg_name}.{name}",
231
+ kind="interface",
232
+ start_line=lineno,
233
+ end_line=end_line,
234
+ file_path=file_path,
235
+ canonical_id=canon_id,
236
+ language="go",
237
+ module=pkg_name,
238
+ scope=pkg_name,
239
+ visibility="public" if name[0].isupper() else "private",
240
+ documentation=doc,
241
+ )
242
+ )
243
+ if name[0].isupper():
244
+ exports.append(name)
245
+ continue
246
+
247
+ # 6. Check Method with Receiver
248
+ m_method = method_re.match(clean)
249
+ if m_method:
250
+ receiver_type = m_method.group(1)
251
+ method_name = m_method.group(2)
252
+ sig_params = m_method.group(3)
253
+ sig_ret = m_method.group(4)
254
+ end_line = find_block_end(idx)
255
+ canon_id = f"go:{pkg_name}:{receiver_type}.{method_name}"
256
+ doc = collect_godoc(idx)
257
+ p_cnt, r_type = parse_params_and_return(clean)
258
+
259
+ symbols.append(
260
+ Symbol(
261
+ name=method_name,
262
+ qualified_name=f"{pkg_name}.{receiver_type}.{method_name}",
263
+ kind="method",
264
+ start_line=lineno,
265
+ end_line=end_line,
266
+ file_path=file_path,
267
+ canonical_id=canon_id,
268
+ language="go",
269
+ module=pkg_name,
270
+ scope=f"{pkg_name}.{receiver_type}",
271
+ signature=f"func ({receiver_type}) {method_name}({sig_params}){sig_ret}".strip(),
272
+ visibility="public" if method_name[0].isupper() else "private",
273
+ return_type=r_type,
274
+ parameter_count=p_cnt,
275
+ documentation=doc,
276
+ )
277
+ )
278
+ if method_name[0].isupper():
279
+ exports.append(f"{receiver_type}.{method_name}")
280
+ active_scope = (method_name, canon_id, end_line)
281
+ continue
282
+
283
+ # 7. Check Standalone Function
284
+ m_func = func_re.match(clean)
285
+ if m_func:
286
+ func_name = m_func.group(1)
287
+ sig_params = m_func.group(2)
288
+ sig_ret = m_func.group(3)
289
+ end_line = find_block_end(idx)
290
+ canon_id = f"go:{pkg_name}:{func_name}"
291
+ doc = collect_godoc(idx)
292
+ p_cnt, r_type = parse_params_and_return(clean)
293
+
294
+ symbols.append(
295
+ Symbol(
296
+ name=func_name,
297
+ qualified_name=f"{pkg_name}.{func_name}",
298
+ kind="function",
299
+ start_line=lineno,
300
+ end_line=end_line,
301
+ file_path=file_path,
302
+ canonical_id=canon_id,
303
+ language="go",
304
+ module=pkg_name,
305
+ scope=pkg_name,
306
+ signature=f"func {func_name}({sig_params}){sig_ret}".strip(),
307
+ visibility="public" if func_name[0].isupper() else "private",
308
+ return_type=r_type,
309
+ parameter_count=p_cnt,
310
+ documentation=doc,
311
+ )
312
+ )
313
+ if func_name[0].isupper():
314
+ exports.append(func_name)
315
+ active_scope = (func_name, canon_id, end_line)
316
+ continue
317
+
318
+ # 8. Check Router Group Mounts: v1 := r.Group("/api/v1")
319
+ m_grp = group_re.search(clean)
320
+ if m_grp:
321
+ child_router = m_grp.group(1)
322
+ parent_router = m_grp.group(2)
323
+ prefix = m_grp.group(3)
324
+ parent_prefix = router_groups.get(parent_router, "")
325
+ composed_prefix = f"{parent_prefix.rstrip('/')}/{prefix.lstrip('/')}".rstrip("/")
326
+ router_groups[child_router] = composed_prefix
327
+ mounts.append(
328
+ RouterMountDetection(
329
+ framework="gin",
330
+ parent_router=parent_router,
331
+ child_router=child_router,
332
+ prefix=composed_prefix,
333
+ file_path=file_path,
334
+ line=lineno,
335
+ confidence="HIGH",
336
+ evidence=f"Go router group '{child_router}' mounted with prefix '{composed_prefix}'",
337
+ )
338
+ )
339
+
340
+ # 9. Check Route Registrations with Mounted Prefix Composition
341
+ m_gin = gin_re.search(clean)
342
+ if m_gin:
343
+ router_var = m_gin.group(1)
344
+ method = m_gin.group(2).upper()
345
+ sub_path = m_gin.group(3)
346
+ handler = m_gin.group(4).split(".")[-1]
347
+ mount_prefix = router_groups.get(router_var, "")
348
+ full_route_path = join_route_prefixes(mount_prefix, sub_path)
349
+
350
+ routes.append(
351
+ RouteDetection(
352
+ framework="gin",
353
+ http_method=method,
354
+ route_path=full_route_path,
355
+ normalized_route=re.sub(r":\w+", "*", full_route_path),
356
+ handler_name=handler,
357
+ handler_canonical_id=f"go:{pkg_name}:{handler}",
358
+ file_path=file_path,
359
+ line=lineno,
360
+ confidence="HIGH",
361
+ evidence=f"Gin/Echo {method} route '{full_route_path}' registered on line {lineno}",
362
+ )
363
+ )
364
+
365
+ # Chi
366
+ m_chi = chi_re.search(clean)
367
+ if m_chi:
368
+ router_var = m_chi.group(1)
369
+ method = m_chi.group(2).upper()
370
+ sub_path = m_chi.group(3)
371
+ handler = m_chi.group(4).split(".")[-1]
372
+ mount_prefix = router_groups.get(router_var, "")
373
+ full_route_path = join_route_prefixes(mount_prefix, sub_path)
374
+
375
+ routes.append(
376
+ RouteDetection(
377
+ framework="chi",
378
+ http_method=method,
379
+ route_path=full_route_path,
380
+ normalized_route=re.sub(r"\{[^}]+\}", "*", full_route_path),
381
+ handler_name=handler,
382
+ handler_canonical_id=f"go:{pkg_name}:{handler}",
383
+ file_path=file_path,
384
+ line=lineno,
385
+ confidence="HIGH",
386
+ evidence=f"Chi {method} route '{full_route_path}' registered on line {lineno}",
387
+ )
388
+ )
389
+
390
+ # net/http
391
+ m_http = http_re.search(clean)
392
+ if m_http:
393
+ route_path = m_http.group(1)
394
+ handler = m_http.group(2).split(".")[-1]
395
+ routes.append(
396
+ RouteDetection(
397
+ framework="net/http",
398
+ http_method="ANY",
399
+ route_path=route_path,
400
+ normalized_route=route_path,
401
+ handler_name=handler,
402
+ handler_canonical_id=f"go:{pkg_name}:{handler}",
403
+ file_path=file_path,
404
+ line=lineno,
405
+ confidence="HIGH",
406
+ evidence=f"net/http route '{route_path}' registered on line {lineno}",
407
+ )
408
+ )
409
+
410
+ # 10. Local Bindings (e.g. client := NewHttpClient())
411
+ m_bind = binding_re.match(clean)
412
+ if m_bind:
413
+ var_name = m_bind.group(1)
414
+ src_call = m_bind.group(2)
415
+ scope_str = active_scope[1] if active_scope else pkg_name
416
+ bindings.append(
417
+ BindingRef(
418
+ target_name=var_name,
419
+ file_path=file_path,
420
+ line=lineno,
421
+ scope=scope_str,
422
+ expr_kind="IDENTIFIER",
423
+ source_expr=src_call,
424
+ )
425
+ )
426
+
427
+ # 11. Enclosing Caller-Linked Method & Function Calls
428
+ call_matches = re.finditer(r"\b([A-Za-z0-9_]+)\.([A-Za-z0-9_]+)\s*\(", clean)
429
+ for cm in call_matches:
430
+ receiver = cm.group(1)
431
+ callee_name = cm.group(2)
432
+ if receiver not in ("fmt", "log", "strings", "errors", "sync", "time", "os"):
433
+ calls.append(
434
+ CallRef(
435
+ source_file=file_path,
436
+ callee=callee_name,
437
+ qualified_callee=f"{receiver}.{callee_name}",
438
+ line=lineno,
439
+ confidence="HIGH" if active_scope else "MEDIUM",
440
+ caller_symbol=active_scope[0] if active_scope else None,
441
+ caller_canonical_id=active_scope[1] if active_scope else f"go:{pkg_name}",
442
+ receiver=receiver,
443
+ )
444
+ )
445
+
446
+ return ParseResult(
447
+ path=file_path,
448
+ language="go",
449
+ source_hash=source_hash,
450
+ symbols=tuple(symbols),
451
+ imports=tuple(imports),
452
+ calls=tuple(calls),
453
+ inheritance=tuple(inheritance),
454
+ routes=tuple(routes),
455
+ mounts=tuple(mounts),
456
+ bindings=tuple(bindings),
457
+ exports=tuple(exports),
458
+ parse_failed=False,
459
+ )