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,427 @@
1
+ """Unified typed Pydantic v2 domain models for RepoDNA v0.10.0 Deep Code Intelligence."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import hashlib
6
+ from datetime import UTC, datetime
7
+ from enum import StrEnum
8
+ from typing import Any
9
+
10
+ from pydantic import BaseModel, ConfigDict, Field
11
+
12
+ from repodna.parsers.capabilities import CapabilityLevel
13
+ from repodna.schemas.models import SeverityLevel
14
+
15
+ QUALITY_ENGINE_VERSION = "0.10.0"
16
+ QUALITY_SCHEMA_VERSION = 1
17
+
18
+
19
+ class QualityConfidence(StrEnum):
20
+ HIGH = "high"
21
+ MEDIUM = "medium"
22
+ LOW = "low"
23
+ UNKNOWN = "unknown"
24
+
25
+
26
+ class FindingStatus(StrEnum):
27
+ ACTIVE = "ACTIVE"
28
+ ACKNOWLEDGED = "ACKNOWLEDGED"
29
+ RESOLVED = "RESOLVED"
30
+ SUPPRESSED = "SUPPRESSED"
31
+ UNKNOWN = "UNKNOWN"
32
+
33
+
34
+ class FindingCategory(StrEnum):
35
+ COMPLEXITY = "complexity"
36
+ DUPLICATION = "duplication"
37
+ UNUSED_CODE = "unused_code"
38
+ TEST_GAP = "test_gap"
39
+ SECURITY_SIGNAL = "security_signal"
40
+ COUPLING = "coupling"
41
+ COVERAGE = "coverage"
42
+
43
+
44
+ class ComplexityContributor(BaseModel):
45
+ model_config = ConfigDict(extra="forbid")
46
+
47
+ construct_kind: str
48
+ line: int = Field(ge=1)
49
+ cyclomatic_delta: int = Field(ge=0, default=1)
50
+ nesting_depth: int = Field(ge=0, default=0)
51
+ nesting_weighted_delta: int = Field(ge=0, default=0)
52
+
53
+
54
+ class SymbolComplexityMetric(BaseModel):
55
+ """Explainable function/method complexity metric. Uses None (never fake 0) when unsupported."""
56
+
57
+ model_config = ConfigDict(extra="forbid")
58
+
59
+ symbol_id: str
60
+ symbol_name: str
61
+ qualified_name: str | None = None
62
+ file_path: str
63
+ language: str
64
+ line_start: int = Field(ge=1)
65
+ line_end: int = Field(ge=1)
66
+ cyclomatic_complexity: int | None = Field(default=None, ge=1)
67
+ nesting_weighted_complexity: int | None = Field(
68
+ default=None,
69
+ ge=0,
70
+ description="RepoDNA explainable nesting/branch metric (distinct from Sonar Cognitive Complexity).",
71
+ )
72
+ max_nesting_depth: int | None = Field(default=None, ge=0)
73
+ logical_sloc: int | None = Field(default=None, ge=0)
74
+ function_length: int = Field(ge=1)
75
+ parameter_count: int | None = Field(default=None, ge=0)
76
+ branch_count: int | None = Field(default=None, ge=0)
77
+ return_count: int | None = Field(default=None, ge=0)
78
+ methodology: str = "mccabe_cyclomatic_v1+repodna_nesting_weighted_v1"
79
+ capability: CapabilityLevel = CapabilityLevel.SUPPORTED
80
+ has_syntax_error: bool = False
81
+ contributors: list[ComplexityContributor] = Field(default_factory=list)
82
+ evidence_id: str | None = None
83
+
84
+
85
+ class CloneType(StrEnum):
86
+ TYPE_1 = "type_1_exact"
87
+ TYPE_2 = "type_2_normalized"
88
+
89
+
90
+ class CloneLocation(BaseModel):
91
+ model_config = ConfigDict(extra="forbid")
92
+
93
+ file_path: str
94
+ line_start: int = Field(ge=1)
95
+ line_end: int = Field(ge=1)
96
+ token_start: int = Field(ge=0)
97
+ token_count: int = Field(ge=1)
98
+ language: str
99
+ evidence_id: str | None = None
100
+
101
+
102
+ class CloneGroup(BaseModel):
103
+ model_config = ConfigDict(extra="forbid")
104
+
105
+ clone_group_id: str
106
+ clone_type: CloneType
107
+ language: str
108
+ occurrence_count: int = Field(ge=2)
109
+ token_count: int = Field(ge=1)
110
+ normalized_fingerprint: str
111
+ confidence: QualityConfidence = QualityConfidence.HIGH
112
+ locations: list[CloneLocation] = Field(default_factory=list)
113
+ exclusion_reason: str | None = None
114
+ explanation: str = ""
115
+
116
+
117
+ class DuplicateAnalysisSummary(BaseModel):
118
+ model_config = ConfigDict(extra="forbid")
119
+
120
+ total_clone_groups: int = 0
121
+ total_duplicated_locations: int = 0
122
+ total_duplicated_tokens: int = 0
123
+ min_tokens_threshold: int = 50
124
+ incomplete_coverage: bool = False
125
+ incomplete_reason: str | None = None
126
+ groups: list[CloneGroup] = Field(default_factory=list)
127
+
128
+
129
+ class UnusedCandidateCategory(StrEnum):
130
+ UNREFERENCED_PRIVATE_FUNCTION = "unreferenced_private_function"
131
+ UNREFERENCED_PRIVATE_METHOD = "unreferenced_private_method"
132
+ UNUSED_LOCAL_IMPORT = "unused_local_import"
133
+ UNREFERENCED_INTERNAL_SYMBOL = "unreferenced_internal_symbol"
134
+ UNREACHABLE_STATEMENT = "unreachable_statement"
135
+
136
+
137
+ class UnusedCodeCandidate(BaseModel):
138
+ model_config = ConfigDict(extra="forbid")
139
+
140
+ candidate_id: str
141
+ symbol_id: str | None = None
142
+ symbol_name: str
143
+ qualified_name: str | None = None
144
+ file_path: str
145
+ language: str
146
+ line_start: int = Field(ge=1)
147
+ line_end: int = Field(ge=1)
148
+ category: UnusedCandidateCategory
149
+ incoming_reference_count: int = Field(ge=0, default=0)
150
+ applicable_exclusions: list[str] = Field(default_factory=list)
151
+ analysis_scope: str = "repository_static_ast"
152
+ confidence: QualityConfidence = QualityConfidence.MEDIUM
153
+ evidence_id: str | None = None
154
+ explanation: str
155
+ known_limitations: list[str] = Field(default_factory=list)
156
+
157
+
158
+ class TestRelationshipKind(StrEnum):
159
+ __test__ = False
160
+
161
+ DIRECT_STATIC_REFERENCE = "direct_static_reference"
162
+ INDIRECT_STATIC_REFERENCE = "indirect_static_reference"
163
+ NAMING_CANDIDATE = "naming_candidate"
164
+ NO_OBSERVED_RELATIONSHIP = "no_observed_relationship"
165
+ UNKNOWN_UNSUPPORTED = "unknown_unsupported"
166
+
167
+
168
+ class TestMappingEntry(BaseModel):
169
+ __test__ = False
170
+
171
+ model_config = ConfigDict(extra="forbid")
172
+
173
+ production_file: str
174
+ production_symbol_id: str | None = None
175
+ production_symbol_name: str | None = None
176
+ language: str
177
+ relationship_kind: TestRelationshipKind
178
+ mapped_test_files: list[str] = Field(default_factory=list)
179
+ mapped_test_symbols: list[str] = Field(default_factory=list)
180
+ ecosystems_detected: list[str] = Field(default_factory=list)
181
+ confidence: QualityConfidence = QualityConfidence.MEDIUM
182
+ explanation: str = ""
183
+
184
+
185
+ class TestMappingSummary(BaseModel):
186
+ __test__ = False
187
+
188
+ model_config = ConfigDict(extra="forbid")
189
+
190
+ methodology: str = "static_test_relationship_mapping_v1"
191
+ disclosure: str = (
192
+ "Static test mapping identifies AST/naming relationships between test files and production code. "
193
+ "It does NOT measure runtime code coverage."
194
+ )
195
+ total_test_files: int = 0
196
+ total_production_files: int = 0
197
+ direct_mapped_count: int = 0
198
+ indirect_mapped_count: int = 0
199
+ naming_candidate_count: int = 0
200
+ no_observed_relationship_count: int = 0
201
+ unknown_unsupported_count: int = 0
202
+ ecosystems_detected: list[str] = Field(default_factory=list)
203
+ entries: list[TestMappingEntry] = Field(default_factory=list)
204
+
205
+
206
+ class SecuritySignalCategory(StrEnum):
207
+ DYNAMIC_EXECUTION = "risky_dynamic_execution"
208
+ UNSAFE_DESERIALIZATION = "unsafe_deserialization_candidate"
209
+ WEAK_CRYPTO = "weak_crypto_primitive_candidate"
210
+ UNSAFE_COMMAND_EXEC = "unsafe_command_execution_pattern"
211
+ HARDCODED_CREDENTIAL = "hardcoded_credential_indicator"
212
+
213
+
214
+ class SecuritySignal(BaseModel):
215
+ model_config = ConfigDict(extra="forbid")
216
+
217
+ signal_id: str
218
+ rule_id: str
219
+ category: SecuritySignalCategory
220
+ severity: SeverityLevel
221
+ confidence: QualityConfidence
222
+ language: str
223
+ file_path: str
224
+ line_start: int = Field(ge=1)
225
+ line_end: int = Field(ge=1)
226
+ symbol_name: str | None = None
227
+ cwe_id: str | None = None
228
+ evidence_id: str | None = None
229
+ redacted_snippet: str | None = None
230
+ explanation: str
231
+ limitations: str = (
232
+ "Structural AST signal only; no interprocedural dataflow or taint analysis was performed. "
233
+ "Presence of an API call does not prove exploitability."
234
+ )
235
+
236
+
237
+ class QualityFinding(BaseModel):
238
+ """Unified, evidence-backed finding across complexity, duplicates, unused code, tests, and security signals."""
239
+
240
+ model_config = ConfigDict(extra="forbid")
241
+
242
+ finding_id: str
243
+ rule_id: str
244
+ rule_version: str = "1.0.0"
245
+ category: FindingCategory
246
+ severity: SeverityLevel
247
+ confidence: QualityConfidence
248
+ language: str
249
+ symbol_id: str | None = None
250
+ symbol_name: str | None = None
251
+ file_path: str
252
+ line_start: int = Field(ge=1)
253
+ line_end: int = Field(ge=1)
254
+ evidence_ids: list[str] = Field(default_factory=list)
255
+ explanation: str
256
+ metric_values: dict[str, Any] = Field(default_factory=dict)
257
+ snapshot_identity: str | None = None
258
+ ruleset_fingerprint: str = ""
259
+ coverage_status: str = "supported"
260
+ suggested_action: str = ""
261
+ status: FindingStatus = FindingStatus.ACTIVE
262
+ suppression_reason: str | None = None
263
+
264
+ @classmethod
265
+ def compute_stable_id(
266
+ cls,
267
+ *,
268
+ rule_id: str,
269
+ file_path: str,
270
+ symbol_key: str,
271
+ discriminator: str = "",
272
+ ) -> str:
273
+ """
274
+ Compute a line-movement-resistant deterministic finding ID tied to rule, file, and symbol identity
275
+ (independent of timestamp, analysis_id, or shifted line numbers).
276
+ """
277
+ raw = f"{rule_id}|{file_path}|{symbol_key}|{discriminator}"
278
+ digest = hashlib.sha256(raw.encode("utf-8")).hexdigest()[:16]
279
+ return f"qf_{digest}"
280
+
281
+
282
+ class TechnicalDebtItem(BaseModel):
283
+ model_config = ConfigDict(extra="forbid")
284
+
285
+ file_path: str
286
+ symbol_name: str | None = None
287
+ language: str
288
+ debt_index: float = Field(ge=0.0)
289
+ contributing_signals: list[str] = Field(default_factory=list)
290
+ finding_ids: list[str] = Field(default_factory=list)
291
+ suggested_action: str = ""
292
+
293
+
294
+ class TechnicalDebtSummary(BaseModel):
295
+ model_config = ConfigDict(extra="forbid")
296
+
297
+ methodology: str = "repodna_explainable_debt_index_v1"
298
+ formula: str = (
299
+ "debt_index = 2.0*complexity_excess + 1.5*duplication_groups + 1.0*unused_candidates "
300
+ "+ 1.5*high_coupling + 1.0*test_gap + 2.5*security_signals + 2.0*contract_violations"
301
+ )
302
+ weights: dict[str, float] = Field(
303
+ default_factory=lambda: {
304
+ "complexity_excess": 2.0,
305
+ "duplication_groups": 1.5,
306
+ "unused_candidates": 1.0,
307
+ "high_coupling": 1.5,
308
+ "test_gap": 1.0,
309
+ "security_signals": 2.5,
310
+ "contract_violations": 2.0,
311
+ }
312
+ )
313
+ total_debt_index: float = 0.0
314
+ coverage_pct: float = 0.0
315
+ confidence: QualityConfidence = QualityConfidence.MEDIUM
316
+ limitations: list[str] = Field(
317
+ default_factory=lambda: [
318
+ "Debt index is an explainable weighted signal count, not a time-to-fix hour estimate.",
319
+ "Comparisons require identical ruleset fingerprints and comparable language coverage.",
320
+ "Missing/unsupported regions are excluded rather than counted as zero debt.",
321
+ ]
322
+ )
323
+ hotspots: list[TechnicalDebtItem] = Field(default_factory=list)
324
+
325
+
326
+ class SymbolImpactChangeKind(StrEnum):
327
+ ADDED = "added"
328
+ REMOVED = "removed"
329
+ RENAMED_CANDIDATE = "renamed_candidate"
330
+ SIGNATURE_CHANGED = "signature_changed"
331
+ VISIBILITY_CHANGED = "visibility_changed"
332
+ COMPLEXITY_CHANGED = "complexity_changed"
333
+ QUALITY_REGRESSION = "quality_regression"
334
+ QUALITY_RESOLVED = "quality_resolved"
335
+ UNKNOWN_COVERAGE_LOSS = "unknown_coverage_loss"
336
+
337
+
338
+ class SymbolImpactItem(BaseModel):
339
+ model_config = ConfigDict(extra="forbid")
340
+
341
+ symbol_name: str
342
+ qualified_name: str | None = None
343
+ file_path: str
344
+ language: str
345
+ change_kind: SymbolImpactChangeKind
346
+ is_potential_breaking: bool = False
347
+ breaking_reason: str | None = None
348
+ verified_impacted_files: list[str] = Field(default_factory=list)
349
+ candidate_impacted_files: list[str] = Field(default_factory=list)
350
+ complexity_before: int | None = None
351
+ complexity_after: int | None = None
352
+ before_evidence_id: str | None = None
353
+ after_evidence_id: str | None = None
354
+ explanation: str = ""
355
+
356
+
357
+ class SymbolImpactReport(BaseModel):
358
+ model_config = ConfigDict(extra="forbid")
359
+
360
+ before_snapshot_identity: str | None = None
361
+ after_snapshot_identity: str | None = None
362
+ total_changes: int = 0
363
+ potential_breaking_count: int = 0
364
+ coverage_loss_detected: bool = False
365
+ items: list[SymbolImpactItem] = Field(default_factory=list)
366
+ summary_text: str = ""
367
+
368
+
369
+ class QualityRuleThresholdConfig(BaseModel):
370
+ model_config = ConfigDict(extra="forbid")
371
+
372
+ enabled: bool = True
373
+ severity: SeverityLevel | None = None
374
+ max_cyclomatic: int | None = Field(default=None, ge=1, le=500)
375
+ max_nesting_depth: int | None = Field(default=None, ge=1, le=50)
376
+ max_function_length: int | None = Field(default=None, ge=5, le=5000)
377
+ max_parameters: int | None = Field(default=None, ge=1, le=50)
378
+ min_clone_tokens: int | None = Field(default=None, ge=15, le=1000)
379
+
380
+
381
+ class QualitySuppressionEntry(BaseModel):
382
+ model_config = ConfigDict(extra="forbid")
383
+
384
+ rule_id: str
385
+ file_path: str
386
+ symbol_name: str | None = None
387
+ reason: str = "Suppressed in .repodna/quality.yml"
388
+
389
+
390
+ class QualityConfig(BaseModel):
391
+ """Strict, declarative schema for `.repodna/quality.yml` (zero code execution)."""
392
+
393
+ model_config = ConfigDict(extra="forbid")
394
+
395
+ version: str = "1"
396
+ exclude_paths: list[str] = Field(default_factory=list)
397
+ rules: dict[str, QualityRuleThresholdConfig] = Field(default_factory=dict)
398
+ suppressions: list[QualitySuppressionEntry] = Field(default_factory=list)
399
+
400
+
401
+ class QualityReport(BaseModel):
402
+ """Top-level Deep Code Intelligence quality report for an analyzed repository snapshot."""
403
+
404
+ model_config = ConfigDict(extra="forbid")
405
+
406
+ schema_version: int = QUALITY_SCHEMA_VERSION
407
+ engine_version: str = QUALITY_ENGINE_VERSION
408
+ analysis_id: str
409
+ repo_name: str
410
+ snapshot_identity: str | None = None
411
+ ruleset_fingerprint: str
412
+ generated_at: datetime = Field(default_factory=lambda: datetime.now(UTC))
413
+ cache_hit: bool = False
414
+ duration_ms: int = 0
415
+ supported_files_count: int = 0
416
+ unsupported_files_count: int = 0
417
+ syntax_error_files_count: int = 0
418
+ language_capabilities: list[dict[str, Any]] = Field(default_factory=list)
419
+ findings: list[QualityFinding] = Field(default_factory=list)
420
+ complexity_metrics: list[SymbolComplexityMetric] = Field(default_factory=list)
421
+ duplicates: DuplicateAnalysisSummary = Field(default_factory=DuplicateAnalysisSummary)
422
+ unused_candidates: list[UnusedCodeCandidate] = Field(default_factory=list)
423
+ test_mapping: TestMappingSummary = Field(default_factory=TestMappingSummary)
424
+ security_signals: list[SecuritySignal] = Field(default_factory=list)
425
+ technical_debt: TechnicalDebtSummary = Field(default_factory=TechnicalDebtSummary)
426
+ phase_durations_ms: dict[str, float] = Field(default_factory=dict)
427
+ limitations: list[str] = Field(default_factory=list)