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.
- repodna/__init__.py +3 -0
- repodna/__main__.py +10 -0
- repodna/advisor/__init__.py +17 -0
- repodna/advisor/engine.py +502 -0
- repodna/advisor/models.py +101 -0
- repodna/agent/__init__.py +87 -0
- repodna/agent/context.py +558 -0
- repodna/agent/deltas.py +198 -0
- repodna/agent/evidence.py +134 -0
- repodna/agent/expansion.py +447 -0
- repodna/agent/localization.py +518 -0
- repodna/agent/models.py +695 -0
- repodna/agent/patch.py +378 -0
- repodna/agent/postflight.py +278 -0
- repodna/agent/preflight.py +336 -0
- repodna/agent/ranking.py +318 -0
- repodna/agent/repo_map.py +392 -0
- repodna/agent/safety.py +111 -0
- repodna/agent/service.py +574 -0
- repodna/agent/sessions.py +264 -0
- repodna/agent/task.py +660 -0
- repodna/agent/telemetry.py +101 -0
- repodna/agent/token_budget.py +231 -0
- repodna/api/__init__.py +1 -0
- repodna/api/agent_routes.py +248 -0
- repodna/api/app.py +2904 -0
- repodna/benchmarks/__init__.py +29 -0
- repodna/benchmarks/baselines.py +126 -0
- repodna/benchmarks/budget_bench.py +162 -0
- repodna/benchmarks/engine.py +418 -0
- repodna/benchmarks/evaluator.py +310 -0
- repodna/benchmarks/metrics.py +206 -0
- repodna/benchmarks/models.py +194 -0
- repodna/benchmarks/scalability.py +166 -0
- repodna/brain/__init__.py +46 -0
- repodna/brain/evidence.py +276 -0
- repodna/brain/extractor.py +1207 -0
- repodna/brain/indexer.py +766 -0
- repodna/brain/models.py +275 -0
- repodna/brain/multilang_extractors.py +889 -0
- repodna/brain/retrieval.py +469 -0
- repodna/brain/tracer.py +203 -0
- repodna/cli/__init__.py +1 -0
- repodna/cli/__main__.py +10 -0
- repodna/cli/agent_cmd.py +228 -0
- repodna/cli/installer.py +590 -0
- repodna/cli/main.py +2173 -0
- repodna/cli/plugin_cmd.py +130 -0
- repodna/cli/workspace_cmd.py +211 -0
- repodna/context/__init__.py +9 -0
- repodna/context/builder.py +379 -0
- repodna/context/models.py +133 -0
- repodna/contract/__init__.py +39 -0
- repodna/contract/evaluator.py +318 -0
- repodna/contract/loader.py +260 -0
- repodna/contract/models.py +185 -0
- repodna/core/__init__.py +1 -0
- repodna/core/analyzer.py +1424 -0
- repodna/diff/__init__.py +35 -0
- repodna/diff/engine.py +332 -0
- repodna/diff/models.py +117 -0
- repodna/diff/snapshot.py +248 -0
- repodna/ecosystem/__init__.py +27 -0
- repodna/ecosystem/contracts.py +129 -0
- repodna/ecosystem/doctor.py +253 -0
- repodna/git_insights/__init__.py +1 -0
- repodna/git_insights/analyzer.py +273 -0
- repodna/graph/__init__.py +1 -0
- repodna/graph/engine.py +562 -0
- repodna/guardian/__init__.py +17 -0
- repodna/guardian/engine.py +369 -0
- repodna/guardian/models.py +104 -0
- repodna/history/__init__.py +40 -0
- repodna/history/cache.py +240 -0
- repodna/history/diff.py +394 -0
- repodna/history/engine.py +557 -0
- repodna/history/evidence.py +160 -0
- repodna/history/models.py +258 -0
- repodna/history/timeline.py +164 -0
- repodna/intelligence/__init__.py +33 -0
- repodna/intelligence/models.py +165 -0
- repodna/intelligence/service.py +570 -0
- repodna/live/__init__.py +94 -0
- repodna/live/alerts.py +443 -0
- repodna/live/coordinator.py +351 -0
- repodna/live/diff.py +444 -0
- repodna/live/events.py +471 -0
- repodna/live/filtering.py +329 -0
- repodna/live/history.py +637 -0
- repodna/live/models.py +505 -0
- repodna/live/observer.py +653 -0
- repodna/live/reconciliation.py +253 -0
- repodna/live/session.py +1547 -0
- repodna/mcp/__init__.py +5 -0
- repodna/mcp/__main__.py +6 -0
- repodna/mcp/agent_tools.py +258 -0
- repodna/mcp/server.py +3283 -0
- repodna/mcp/workspace_tools.py +200 -0
- repodna/parsers/__init__.py +13 -0
- repodna/parsers/base.py +126 -0
- repodna/parsers/capabilities.py +361 -0
- repodna/parsers/project_metadata.py +232 -0
- repodna/parsers/resolver.py +621 -0
- repodna/parsers/treesitter_parser.py +830 -0
- repodna/passport/__init__.py +64 -0
- repodna/passport/generator.py +546 -0
- repodna/passport/migrator.py +139 -0
- repodna/passport/models.py +224 -0
- repodna/passport/validator.py +143 -0
- repodna/performance/__init__.py +89 -0
- repodna/performance/cache.py +1584 -0
- repodna/performance/identity.py +341 -0
- repodna/performance/incremental.py +317 -0
- repodna/performance/models.py +157 -0
- repodna/performance/parallel.py +291 -0
- repodna/plugins/__init__.py +47 -0
- repodna/plugins/evaluator.py +334 -0
- repodna/plugins/models.py +113 -0
- repodna/plugins/validator.py +256 -0
- repodna/quality/__init__.py +91 -0
- repodna/quality/complexity.py +352 -0
- repodna/quality/config.py +159 -0
- repodna/quality/debt.py +73 -0
- repodna/quality/duplicates.py +330 -0
- repodna/quality/engine.py +282 -0
- repodna/quality/impact.py +198 -0
- repodna/quality/models.py +427 -0
- repodna/quality/rules.py +364 -0
- repodna/quality/sarif.py +107 -0
- repodna/quality/security_signals.py +278 -0
- repodna/quality/test_mapping.py +271 -0
- repodna/quality/unused.py +201 -0
- repodna/reports/__init__.py +1 -0
- repodna/reports/exporter.py +374 -0
- repodna/rules/__init__.py +1 -0
- repodna/rules/health.py +436 -0
- repodna/schemas/__init__.py +1 -0
- repodna/schemas/models.py +348 -0
- repodna/security/__init__.py +1 -0
- repodna/security/safe_yaml.py +81 -0
- repodna/security/validators.py +583 -0
- repodna/skills/__init__.py +0 -0
- repodna/skills/repodna/SKILL.md +59 -0
- repodna/skills/repodna/__init__.py +0 -0
- repodna/skills/repodna/examples/workflows.md +85 -0
- repodna/skills/repodna/references/architecture-rules.md +26 -0
- repodna/storage/__init__.py +1 -0
- repodna/storage/workspace.py +199 -0
- repodna/webui/__init__.py +1 -0
- repodna/webui/assets/DependencyGraph-km_Qo-nG.js +43 -0
- repodna/webui/assets/HealthReportView-WVL39aNO.js +1 -0
- repodna/webui/assets/index-ByZ5e5pe.js +506 -0
- repodna/webui/assets/index-CDj3e8hw.css +1 -0
- repodna/webui/index.html +21 -0
- repodna/workspace/__init__.py +131 -0
- repodna/workspace/compatibility.py +317 -0
- repodna/workspace/context.py +175 -0
- repodna/workspace/contracts.py +369 -0
- repodna/workspace/federation.py +411 -0
- repodna/workspace/identity.py +202 -0
- repodna/workspace/impact.py +111 -0
- repodna/workspace/manifest.py +266 -0
- repodna/workspace/models.py +461 -0
- repodna/workspace/packages.py +494 -0
- repodna/workspace/policies.py +142 -0
- repodna/workspace/services.py +238 -0
- repodna/workspace/topology.py +316 -0
- repodna_engine-1.0.1.dist-info/METADATA +129 -0
- repodna_engine-1.0.1.dist-info/RECORD +173 -0
- repodna_engine-1.0.1.dist-info/WHEEL +5 -0
- repodna_engine-1.0.1.dist-info/entry_points.txt +2 -0
- repodna_engine-1.0.1.dist-info/licenses/LICENSE +21 -0
- 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)
|