repodna-engine 1.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 (173) hide show
  1. repodna/__init__.py +3 -0
  2. repodna/__main__.py +10 -0
  3. repodna/advisor/__init__.py +17 -0
  4. repodna/advisor/engine.py +502 -0
  5. repodna/advisor/models.py +101 -0
  6. repodna/agent/__init__.py +87 -0
  7. repodna/agent/context.py +558 -0
  8. repodna/agent/deltas.py +198 -0
  9. repodna/agent/evidence.py +134 -0
  10. repodna/agent/expansion.py +447 -0
  11. repodna/agent/localization.py +518 -0
  12. repodna/agent/models.py +695 -0
  13. repodna/agent/patch.py +378 -0
  14. repodna/agent/postflight.py +278 -0
  15. repodna/agent/preflight.py +336 -0
  16. repodna/agent/ranking.py +318 -0
  17. repodna/agent/repo_map.py +392 -0
  18. repodna/agent/safety.py +111 -0
  19. repodna/agent/service.py +574 -0
  20. repodna/agent/sessions.py +264 -0
  21. repodna/agent/task.py +660 -0
  22. repodna/agent/telemetry.py +101 -0
  23. repodna/agent/token_budget.py +231 -0
  24. repodna/api/__init__.py +1 -0
  25. repodna/api/agent_routes.py +248 -0
  26. repodna/api/app.py +2904 -0
  27. repodna/benchmarks/__init__.py +29 -0
  28. repodna/benchmarks/baselines.py +126 -0
  29. repodna/benchmarks/budget_bench.py +162 -0
  30. repodna/benchmarks/engine.py +418 -0
  31. repodna/benchmarks/evaluator.py +310 -0
  32. repodna/benchmarks/metrics.py +206 -0
  33. repodna/benchmarks/models.py +194 -0
  34. repodna/benchmarks/scalability.py +166 -0
  35. repodna/brain/__init__.py +46 -0
  36. repodna/brain/evidence.py +276 -0
  37. repodna/brain/extractor.py +1207 -0
  38. repodna/brain/indexer.py +766 -0
  39. repodna/brain/models.py +275 -0
  40. repodna/brain/multilang_extractors.py +889 -0
  41. repodna/brain/retrieval.py +469 -0
  42. repodna/brain/tracer.py +203 -0
  43. repodna/cli/__init__.py +1 -0
  44. repodna/cli/__main__.py +10 -0
  45. repodna/cli/agent_cmd.py +228 -0
  46. repodna/cli/installer.py +590 -0
  47. repodna/cli/main.py +2173 -0
  48. repodna/cli/plugin_cmd.py +130 -0
  49. repodna/cli/workspace_cmd.py +211 -0
  50. repodna/context/__init__.py +9 -0
  51. repodna/context/builder.py +379 -0
  52. repodna/context/models.py +133 -0
  53. repodna/contract/__init__.py +39 -0
  54. repodna/contract/evaluator.py +318 -0
  55. repodna/contract/loader.py +260 -0
  56. repodna/contract/models.py +185 -0
  57. repodna/core/__init__.py +1 -0
  58. repodna/core/analyzer.py +1424 -0
  59. repodna/diff/__init__.py +35 -0
  60. repodna/diff/engine.py +332 -0
  61. repodna/diff/models.py +117 -0
  62. repodna/diff/snapshot.py +248 -0
  63. repodna/ecosystem/__init__.py +27 -0
  64. repodna/ecosystem/contracts.py +129 -0
  65. repodna/ecosystem/doctor.py +253 -0
  66. repodna/git_insights/__init__.py +1 -0
  67. repodna/git_insights/analyzer.py +273 -0
  68. repodna/graph/__init__.py +1 -0
  69. repodna/graph/engine.py +562 -0
  70. repodna/guardian/__init__.py +17 -0
  71. repodna/guardian/engine.py +369 -0
  72. repodna/guardian/models.py +104 -0
  73. repodna/history/__init__.py +40 -0
  74. repodna/history/cache.py +240 -0
  75. repodna/history/diff.py +394 -0
  76. repodna/history/engine.py +557 -0
  77. repodna/history/evidence.py +160 -0
  78. repodna/history/models.py +258 -0
  79. repodna/history/timeline.py +164 -0
  80. repodna/intelligence/__init__.py +33 -0
  81. repodna/intelligence/models.py +165 -0
  82. repodna/intelligence/service.py +570 -0
  83. repodna/live/__init__.py +94 -0
  84. repodna/live/alerts.py +443 -0
  85. repodna/live/coordinator.py +351 -0
  86. repodna/live/diff.py +444 -0
  87. repodna/live/events.py +471 -0
  88. repodna/live/filtering.py +329 -0
  89. repodna/live/history.py +637 -0
  90. repodna/live/models.py +505 -0
  91. repodna/live/observer.py +653 -0
  92. repodna/live/reconciliation.py +253 -0
  93. repodna/live/session.py +1547 -0
  94. repodna/mcp/__init__.py +5 -0
  95. repodna/mcp/__main__.py +6 -0
  96. repodna/mcp/agent_tools.py +258 -0
  97. repodna/mcp/server.py +3283 -0
  98. repodna/mcp/workspace_tools.py +200 -0
  99. repodna/parsers/__init__.py +13 -0
  100. repodna/parsers/base.py +126 -0
  101. repodna/parsers/capabilities.py +361 -0
  102. repodna/parsers/project_metadata.py +232 -0
  103. repodna/parsers/resolver.py +621 -0
  104. repodna/parsers/treesitter_parser.py +830 -0
  105. repodna/passport/__init__.py +64 -0
  106. repodna/passport/generator.py +546 -0
  107. repodna/passport/migrator.py +139 -0
  108. repodna/passport/models.py +224 -0
  109. repodna/passport/validator.py +143 -0
  110. repodna/performance/__init__.py +89 -0
  111. repodna/performance/cache.py +1584 -0
  112. repodna/performance/identity.py +341 -0
  113. repodna/performance/incremental.py +317 -0
  114. repodna/performance/models.py +157 -0
  115. repodna/performance/parallel.py +291 -0
  116. repodna/plugins/__init__.py +47 -0
  117. repodna/plugins/evaluator.py +334 -0
  118. repodna/plugins/models.py +113 -0
  119. repodna/plugins/validator.py +256 -0
  120. repodna/quality/__init__.py +91 -0
  121. repodna/quality/complexity.py +352 -0
  122. repodna/quality/config.py +159 -0
  123. repodna/quality/debt.py +73 -0
  124. repodna/quality/duplicates.py +330 -0
  125. repodna/quality/engine.py +282 -0
  126. repodna/quality/impact.py +198 -0
  127. repodna/quality/models.py +427 -0
  128. repodna/quality/rules.py +364 -0
  129. repodna/quality/sarif.py +107 -0
  130. repodna/quality/security_signals.py +278 -0
  131. repodna/quality/test_mapping.py +271 -0
  132. repodna/quality/unused.py +201 -0
  133. repodna/reports/__init__.py +1 -0
  134. repodna/reports/exporter.py +374 -0
  135. repodna/rules/__init__.py +1 -0
  136. repodna/rules/health.py +436 -0
  137. repodna/schemas/__init__.py +1 -0
  138. repodna/schemas/models.py +348 -0
  139. repodna/security/__init__.py +1 -0
  140. repodna/security/safe_yaml.py +81 -0
  141. repodna/security/validators.py +583 -0
  142. repodna/skills/__init__.py +0 -0
  143. repodna/skills/repodna/SKILL.md +59 -0
  144. repodna/skills/repodna/__init__.py +0 -0
  145. repodna/skills/repodna/examples/workflows.md +85 -0
  146. repodna/skills/repodna/references/architecture-rules.md +26 -0
  147. repodna/storage/__init__.py +1 -0
  148. repodna/storage/workspace.py +199 -0
  149. repodna/webui/__init__.py +1 -0
  150. repodna/webui/assets/DependencyGraph-km_Qo-nG.js +43 -0
  151. repodna/webui/assets/HealthReportView-WVL39aNO.js +1 -0
  152. repodna/webui/assets/index-ByZ5e5pe.js +506 -0
  153. repodna/webui/assets/index-CDj3e8hw.css +1 -0
  154. repodna/webui/index.html +21 -0
  155. repodna/workspace/__init__.py +131 -0
  156. repodna/workspace/compatibility.py +317 -0
  157. repodna/workspace/context.py +175 -0
  158. repodna/workspace/contracts.py +369 -0
  159. repodna/workspace/federation.py +411 -0
  160. repodna/workspace/identity.py +202 -0
  161. repodna/workspace/impact.py +111 -0
  162. repodna/workspace/manifest.py +266 -0
  163. repodna/workspace/models.py +461 -0
  164. repodna/workspace/packages.py +494 -0
  165. repodna/workspace/policies.py +142 -0
  166. repodna/workspace/services.py +238 -0
  167. repodna/workspace/topology.py +316 -0
  168. repodna_engine-1.0.1.dist-info/METADATA +129 -0
  169. repodna_engine-1.0.1.dist-info/RECORD +173 -0
  170. repodna_engine-1.0.1.dist-info/WHEEL +5 -0
  171. repodna_engine-1.0.1.dist-info/entry_points.txt +2 -0
  172. repodna_engine-1.0.1.dist-info/licenses/LICENSE +21 -0
  173. repodna_engine-1.0.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,369 @@
1
+ """Bounded, zero-network OpenAPI 3.0/3.1 contract parser and static contract inventory.
2
+
3
+ Security guarantees:
4
+ - Remote $ref (http://, https://, ftp://) is strictly disabled by default (zero SSRF).
5
+ - Local $ref is strictly contained within authorized repository/workspace root.
6
+ - Recursive $ref cycles are bounded via visited-set cycle detection and MAX_OPENAPI_REF_DEPTH.
7
+ - Document size capped at MAX_OPENAPI_BYTES (2 MiB).
8
+ - Protobuf, AsyncAPI, and GraphQL files are inventoried honestly as PARTIAL/UNSUPPORTED
9
+ rather than fabricating full semantic compatibility.
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ import hashlib
15
+ import json
16
+ from pathlib import Path
17
+ from typing import Any
18
+
19
+ from repodna.workspace.identity import normalize_canonical_path
20
+ from repodna.workspace.models import (
21
+ MAX_OPENAPI_BYTES,
22
+ MAX_OPENAPI_REF_DEPTH,
23
+ ContractDefinition,
24
+ ContractOperation,
25
+ )
26
+
27
+ _HTTP_METHODS = ("get", "post", "put", "delete", "patch", "options", "head")
28
+ _SENSITIVE_KEY_MARKERS = ("token", "password", "secret", "api_key", "apikey", "authorization", "bearer")
29
+
30
+
31
+ def _resolve_json_pointer(doc: dict[str, Any], pointer: str) -> Any:
32
+ if not pointer.startswith("#/"):
33
+ return None
34
+ curr: Any = doc
35
+ for part in pointer[2:].split("/"):
36
+ unescaped = part.replace("~1", "/").replace("~0", "~")
37
+ if isinstance(curr, dict) and unescaped in curr:
38
+ curr = curr[unescaped]
39
+ else:
40
+ return None
41
+ return curr
42
+
43
+
44
+ def _resolve_schema(
45
+ schema: Any,
46
+ *,
47
+ root_doc: dict[str, Any],
48
+ base_dir: Path,
49
+ repo_root: Path,
50
+ limitations: list[str],
51
+ visited: frozenset[str] = frozenset(),
52
+ depth: int = 0,
53
+ ) -> dict[str, Any]:
54
+ if not isinstance(schema, dict):
55
+ return {}
56
+ if depth > MAX_OPENAPI_REF_DEPTH:
57
+ limitations.append(f"Schema recursion limit ({MAX_OPENAPI_REF_DEPTH}) reached; deeper properties omitted.")
58
+ return {}
59
+ ref = schema.get("$ref")
60
+ if isinstance(ref, str):
61
+ if ref.startswith(("http://", "https://", "ftp://", "//")):
62
+ limitations.append(f"Remote $ref '{ref}' blocked (remote resolution disabled for SSRF safety).")
63
+ return {}
64
+ if ref in visited:
65
+ limitations.append(f"Circular $ref cycle detected at '{ref}'; recursion halted safely.")
66
+ return {}
67
+ next_visited = visited | {ref}
68
+ if ref.startswith("#/"):
69
+ target = _resolve_json_pointer(root_doc, ref)
70
+ return _resolve_schema(
71
+ target,
72
+ root_doc=root_doc,
73
+ base_dir=base_dir,
74
+ repo_root=repo_root,
75
+ limitations=limitations,
76
+ visited=next_visited,
77
+ depth=depth + 1,
78
+ )
79
+ # External local $ref (strictly contained in repo_root)
80
+ file_part, _, ptr_part = ref.partition("#")
81
+ target_file = (base_dir / file_part).resolve()
82
+ root_norm = normalize_canonical_path(repo_root)
83
+ target_norm = normalize_canonical_path(target_file) if target_file.exists() else str(target_file)
84
+ if not (target_norm == root_norm or target_norm.startswith(root_norm.rstrip("\\/") + ("\\" if "\\" in root_norm else "/"))):
85
+ limitations.append(f"Local $ref '{ref}' escapes repository boundary and was blocked.")
86
+ return {}
87
+ if target_file.exists() and target_file.is_file() and target_file.stat().st_size <= MAX_OPENAPI_BYTES:
88
+ try:
89
+ from repodna.security.safe_yaml import safe_load_bounded_yaml
90
+
91
+ raw = target_file.read_text(encoding="utf-8", errors="replace")
92
+ ext_doc = (
93
+ json.loads(raw)
94
+ if target_file.suffix.lower() == ".json"
95
+ else safe_load_bounded_yaml(raw, max_bytes=MAX_OPENAPI_BYTES, max_aliases=0)
96
+ )
97
+ if isinstance(ext_doc, dict):
98
+ sub = _resolve_json_pointer(ext_doc, "#" + ptr_part) if ptr_part else ext_doc
99
+ return _resolve_schema(
100
+ sub,
101
+ root_doc=ext_doc,
102
+ base_dir=target_file.parent,
103
+ repo_root=repo_root,
104
+ limitations=limitations,
105
+ visited=next_visited,
106
+ depth=depth + 1,
107
+ )
108
+ except Exception:
109
+ limitations.append(f"Failed to load local $ref '{ref}'.")
110
+ return {}
111
+ return {}
112
+ return schema
113
+
114
+
115
+ def _normalize_schema_type(prop_schema: dict[str, Any]) -> str:
116
+ raw_type = prop_schema.get("type")
117
+ nullable = bool(prop_schema.get("nullable", False))
118
+ if isinstance(raw_type, list):
119
+ # OpenAPI 3.1 type array e.g. ["string", "null"]
120
+ cleaned = sorted(str(t) for t in raw_type)
121
+ return "|".join(cleaned)
122
+ t_str = str(raw_type) if raw_type else "object"
123
+ return f"{t_str}|null" if nullable else t_str
124
+
125
+
126
+ def _extract_object_props(
127
+ schema: dict[str, Any],
128
+ *,
129
+ root_doc: dict[str, Any],
130
+ base_dir: Path,
131
+ repo_root: Path,
132
+ limitations: list[str],
133
+ ) -> tuple[list[str], dict[str, str], dict[str, list[str]]]:
134
+ resolved = _resolve_schema(schema, root_doc=root_doc, base_dir=base_dir, repo_root=repo_root, limitations=limitations)
135
+ if any(k in resolved for k in ("oneOf", "anyOf", "allOf")):
136
+ limitations.append("Schema uses OpenAPI composition (oneOf/anyOf/allOf); flattened conservatively.")
137
+ required = [str(r) for r in resolved.get("required", []) if isinstance(r, str)]
138
+ props_raw = resolved.get("properties", {})
139
+ props: dict[str, str] = {}
140
+ enums: dict[str, list[str]] = {}
141
+ if isinstance(props_raw, dict):
142
+ for pname, pschema in props_raw.items():
143
+ p_res = _resolve_schema(
144
+ pschema, root_doc=root_doc, base_dir=base_dir, repo_root=repo_root, limitations=limitations
145
+ )
146
+ props[str(pname)] = _normalize_schema_type(p_res)
147
+ if isinstance(p_res.get("enum"), list):
148
+ # Never leak sensitive literal values into enum lists if property name looks like a secret
149
+ if any(m in str(pname).lower() for m in _SENSITIVE_KEY_MARKERS):
150
+ enums[str(pname)] = ["[REDACTED]"]
151
+ else:
152
+ enums[str(pname)] = [str(v) for v in p_res["enum"]]
153
+ return sorted(set(required)), props, enums
154
+
155
+
156
+ def parse_openapi_file(
157
+ contract_file: Path,
158
+ *,
159
+ repo_root: Path,
160
+ repository_id: str,
161
+ repository_alias: str,
162
+ ) -> ContractDefinition | None:
163
+ """Parses an OpenAPI 3.0/3.1 YAML or JSON document with strict security bounds."""
164
+ if not contract_file.exists() or not contract_file.is_file():
165
+ return None
166
+ if contract_file.stat().st_size > MAX_OPENAPI_BYTES:
167
+ rel = contract_file.relative_to(repo_root).as_posix()
168
+ return ContractDefinition(
169
+ contract_id=f"ctr_{hashlib.sha256(f'{repository_id}|{rel}'.encode()).hexdigest()[:12]}",
170
+ format="openapi_3_0",
171
+ support_status="PARTIAL",
172
+ title=contract_file.name,
173
+ repository_id=repository_id,
174
+ repository_alias=repository_alias,
175
+ file_path=rel,
176
+ fingerprint="oversized",
177
+ limitations=[f"OpenAPI file exceeds size limit ({MAX_OPENAPI_BYTES:,} bytes) and was not parsed."],
178
+ )
179
+
180
+ raw_text = contract_file.read_text(encoding="utf-8", errors="replace")
181
+ try:
182
+ if contract_file.suffix.lower() == ".json":
183
+ doc = json.loads(raw_text)
184
+ else:
185
+ from repodna.security.safe_yaml import safe_load_bounded_yaml
186
+
187
+ doc = safe_load_bounded_yaml(raw_text, max_bytes=MAX_OPENAPI_BYTES, max_aliases=0)
188
+ except Exception:
189
+ return None
190
+ if not isinstance(doc, dict) or not isinstance(doc.get("openapi"), str):
191
+ return None
192
+
193
+ oa_ver = doc["openapi"].strip()
194
+ fmt = "openapi_3_1" if oa_ver.startswith("3.1") else "openapi_3_0"
195
+ info = doc.get("info", {}) if isinstance(doc.get("info"), dict) else {}
196
+ title = str(info.get("title") or contract_file.stem)
197
+ version = str(info.get("version")) if info.get("version") is not None else None
198
+ rel = contract_file.relative_to(repo_root).as_posix()
199
+ fp = hashlib.sha256(raw_text.encode("utf-8")).hexdigest()[:16]
200
+ limitations: list[str] = []
201
+
202
+ top_security: list[str] = []
203
+ if isinstance(doc.get("security"), list):
204
+ for sitem in doc["security"]:
205
+ if isinstance(sitem, dict):
206
+ top_security.extend(str(k) for k in sitem)
207
+
208
+ operations: list[ContractOperation] = []
209
+ paths = doc.get("paths", {})
210
+ if isinstance(paths, dict):
211
+ for ptemplate, pitem in sorted(paths.items()):
212
+ if not isinstance(pitem, dict):
213
+ continue
214
+ for method in _HTTP_METHODS:
215
+ op = pitem.get(method)
216
+ if not isinstance(op, dict):
217
+ continue
218
+ req_params: list[str] = []
219
+ opt_params: list[str] = []
220
+ for param in op.get("parameters", []) if isinstance(op.get("parameters"), list) else []:
221
+ if not isinstance(param, dict):
222
+ continue
223
+ pname = str(param.get("name", ""))
224
+ if not pname:
225
+ continue
226
+ if param.get("required") or param.get("in") == "path":
227
+ req_params.append(pname)
228
+ else:
229
+ opt_params.append(pname)
230
+
231
+ req_required_props: list[str] = []
232
+ req_props: dict[str, str] = {}
233
+ req_enums: dict[str, list[str]] = {}
234
+ rbody = op.get("requestBody")
235
+ if isinstance(rbody, dict) and isinstance(rbody.get("content"), dict):
236
+ app_json = rbody["content"].get("application/json")
237
+ if isinstance(app_json, dict) and isinstance(app_json.get("schema"), dict):
238
+ req_required_props, req_props, req_enums = _extract_object_props(
239
+ app_json["schema"],
240
+ root_doc=doc,
241
+ base_dir=contract_file.parent,
242
+ repo_root=repo_root,
243
+ limitations=limitations,
244
+ )
245
+
246
+ resp_statuses: list[str] = []
247
+ resp_props: dict[str, dict[str, str]] = {}
248
+ resp_enums: dict[str, dict[str, list[str]]] = {}
249
+ responses = op.get("responses", {})
250
+ if isinstance(responses, dict):
251
+ for status_code, rspec in sorted(responses.items()):
252
+ sc = str(status_code)
253
+ resp_statuses.append(sc)
254
+ if isinstance(rspec, dict) and isinstance(rspec.get("content"), dict):
255
+ app_json = rspec["content"].get("application/json")
256
+ if isinstance(app_json, dict) and isinstance(app_json.get("schema"), dict):
257
+ _, r_p, r_e = _extract_object_props(
258
+ app_json["schema"],
259
+ root_doc=doc,
260
+ base_dir=contract_file.parent,
261
+ repo_root=repo_root,
262
+ limitations=limitations,
263
+ )
264
+ resp_props[sc] = r_p
265
+ resp_enums[sc] = r_e
266
+
267
+ op_sec = list(top_security)
268
+ if isinstance(op.get("security"), list):
269
+ op_sec = []
270
+ for sitem in op["security"]:
271
+ if isinstance(sitem, dict):
272
+ op_sec.extend(str(k) for k in sitem)
273
+
274
+ operations.append(
275
+ ContractOperation(
276
+ path=str(ptemplate),
277
+ method=method.upper(),
278
+ operation_id=str(op["operationId"]) if op.get("operationId") else None,
279
+ required_params=sorted(set(req_params)),
280
+ optional_params=sorted(set(opt_params)),
281
+ request_required_props=req_required_props,
282
+ request_props=req_props,
283
+ request_enums=req_enums,
284
+ response_statuses=resp_statuses,
285
+ response_props=resp_props,
286
+ response_enums=resp_enums,
287
+ security_schemes=sorted(set(op_sec)),
288
+ )
289
+ )
290
+
291
+ return ContractDefinition(
292
+ contract_id=f"ctr_{hashlib.sha256(f'{repository_id}|{rel}'.encode()).hexdigest()[:12]}",
293
+ format=fmt,
294
+ support_status="SUPPORTED",
295
+ title=title,
296
+ version=version,
297
+ repository_id=repository_id,
298
+ repository_alias=repository_alias,
299
+ file_path=rel,
300
+ fingerprint=fp,
301
+ operations=operations,
302
+ limitations=sorted(set(limitations)),
303
+ )
304
+
305
+
306
+ def discover_repository_contracts(
307
+ repo_root: Path,
308
+ *,
309
+ repository_id: str,
310
+ repository_alias: str,
311
+ explicit_paths: list[str] | None = None,
312
+ ) -> list[ContractDefinition]:
313
+ """Discovers OpenAPI 3.x contracts (and honestly flags Protobuf/AsyncAPI/GraphQL as PARTIAL/UNSUPPORTED)."""
314
+ from repodna.security.validators import is_safe_subpath
315
+
316
+ root_res = repo_root.resolve()
317
+ found: list[ContractDefinition] = []
318
+ seen_paths: set[Path] = set()
319
+
320
+ candidates: list[Path] = []
321
+ for ep in explicit_paths or []:
322
+ raw_p = repo_root / ep
323
+ if raw_p.is_symlink() or not is_safe_subpath(root_res, raw_p):
324
+ continue
325
+ p = raw_p.resolve()
326
+ if p.exists() and p.is_file():
327
+ candidates.append(p)
328
+
329
+ for pattern in ("**/openapi*.yml", "**/openapi*.yaml", "**/openapi*.json", "**/swagger*.yml", "**/swagger*.json"):
330
+ for p in sorted(repo_root.glob(pattern))[:15]:
331
+ if any(part in ("node_modules", ".venv", ".git", "dist") for part in p.parts):
332
+ continue
333
+ if p.is_symlink() or not is_safe_subpath(root_res, p):
334
+ continue
335
+ candidates.append(p.resolve())
336
+
337
+ for p in candidates:
338
+ if p in seen_paths:
339
+ continue
340
+ seen_paths.add(p)
341
+ parsed = parse_openapi_file(p, repo_root=root_res, repository_id=repository_id, repository_alias=repository_alias)
342
+ if parsed is not None:
343
+ found.append(parsed)
344
+
345
+ # Honest inventory of non-OpenAPI schema formats (never fabricate full compatibility)
346
+ for ext, fmt in ((".proto", "protobuf"), (".graphql", "graphql"), (".gql", "graphql")):
347
+ for p in sorted(repo_root.glob(f"**/*{ext}"))[:10]:
348
+ if any(part in ("node_modules", ".venv", ".git", "dist") for part in p.parts):
349
+ continue
350
+ if p.is_symlink() or not is_safe_subpath(root_res, p):
351
+ continue
352
+ rel = p.resolve().relative_to(root_res).as_posix()
353
+ found.append(
354
+ ContractDefinition(
355
+ contract_id=f"ctr_{hashlib.sha256(f'{repository_id}|{rel}'.encode()).hexdigest()[:12]}",
356
+ format=fmt,
357
+ support_status="UNSUPPORTED",
358
+ title=p.name,
359
+ repository_id=repository_id,
360
+ repository_alias=repository_alias,
361
+ file_path=rel,
362
+ fingerprint=hashlib.sha256(p.read_bytes()[:8192]).hexdigest()[:16],
363
+ limitations=[
364
+ f"{fmt} structural compatibility analysis is not implemented in v0.13.0; inventoried for visibility only."
365
+ ],
366
+ )
367
+ )
368
+
369
+ return found