blastdiff 0.1.0__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.
@@ -0,0 +1,406 @@
1
+ """Tree-sitter based TypeScript and JavaScript AST analyzer."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import re
6
+ from pathlib import PurePosixPath
7
+
8
+ import tree_sitter
9
+ import tree_sitter_javascript
10
+ import tree_sitter_typescript
11
+
12
+ from blastdiff.core.languages.base import detect_language
13
+ from blastdiff.core.models import CallSite, FileSymbols, ImportRef, SymbolDef
14
+
15
+ _WS_RE = re.compile(r"\s+")
16
+ _MAX_SNIPPET_LEN = 160
17
+
18
+
19
+ def _collapse_ws(text: str) -> str:
20
+ collapsed = _WS_RE.sub(" ", text).strip()
21
+ collapsed = re.sub(r"\(\s+", "(", collapsed)
22
+ collapsed = re.sub(r"\s+\)", ")", collapsed)
23
+ collapsed = re.sub(r",\s*\)", ")", collapsed)
24
+ return collapsed
25
+
26
+
27
+ def _node_text(node: tree_sitter.Node | None, source_bytes: bytes) -> str:
28
+ if node is None:
29
+ return ""
30
+ return source_bytes[node.start_byte : node.end_byte].decode("utf-8", errors="replace")
31
+
32
+
33
+ def _strip_quotes(raw: str) -> str:
34
+ raw = raw.strip()
35
+ if len(raw) >= 2 and raw[0] == raw[-1] and raw[0] in ("'", '"', "`"):
36
+ return raw[1:-1]
37
+ return raw
38
+
39
+
40
+ class TypeScriptAnalyzer:
41
+ """Extracts TS/TSX/JS/JSX symbol definitions, imports, and call sites."""
42
+
43
+ language: str = "typescript"
44
+ extensions: tuple[str, ...] = (".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs")
45
+
46
+ def __init__(self) -> None:
47
+ self._ts_parser = tree_sitter.Parser(
48
+ tree_sitter.Language(tree_sitter_typescript.language_typescript())
49
+ )
50
+ self._tsx_parser = tree_sitter.Parser(
51
+ tree_sitter.Language(tree_sitter_typescript.language_tsx())
52
+ )
53
+ self._js_parser = tree_sitter.Parser(
54
+ tree_sitter.Language(tree_sitter_javascript.language())
55
+ )
56
+
57
+ def _select_parser(self, file_path: str) -> tree_sitter.Parser:
58
+ suffix = PurePosixPath(file_path.replace("\\", "/")).suffix.lower()
59
+ if suffix == ".tsx":
60
+ return self._tsx_parser
61
+ if suffix in (".ts", ".mts", ".cts"):
62
+ return self._ts_parser
63
+ return self._js_parser
64
+
65
+ def analyze_file(self, file_path: str, source: str) -> FileSymbols:
66
+ lang = detect_language(file_path)
67
+ if not source:
68
+ return FileSymbols(file_path=file_path, language=lang)
69
+
70
+ source_bytes = source.encode("utf-8", errors="replace")
71
+ source_lines = source.splitlines()
72
+ parser = self._select_parser(file_path)
73
+ tree = parser.parse(source_bytes)
74
+
75
+ definitions: list[SymbolDef] = []
76
+ imports: list[ImportRef] = []
77
+ calls: list[CallSite] = []
78
+ re_exported_names: set[str] = set()
79
+
80
+ def snippet_for_line(lineno: int) -> str:
81
+ if 1 <= lineno <= len(source_lines):
82
+ return source_lines[lineno - 1].strip()[:_MAX_SNIPPET_LEN]
83
+ return ""
84
+
85
+ def extract_import(node: tree_sitter.Node) -> None:
86
+ line = node.start_point.row + 1
87
+ src_node = node.child_by_field_name("source")
88
+ module_name = _strip_quotes(_node_text(src_node, source_bytes))
89
+ names: list[str] = []
90
+ for child in node.children:
91
+ if child.type == "import_clause":
92
+ for ic in child.children:
93
+ if ic.type == "identifier":
94
+ names.append(_node_text(ic, source_bytes).strip())
95
+ elif ic.type == "namespace_import":
96
+ names.append("*")
97
+ elif ic.type == "named_imports":
98
+ for spec in ic.children:
99
+ if spec.type == "import_specifier":
100
+ orig = spec.child_by_field_name("name")
101
+ orig_txt = _node_text(orig, source_bytes).strip()
102
+ if orig_txt:
103
+ names.append(orig_txt)
104
+ if module_name:
105
+ imports.append(
106
+ ImportRef(module=module_name, names=names, line=line, file_path=file_path)
107
+ )
108
+
109
+ def is_async_node(node: tree_sitter.Node) -> bool:
110
+ return any(c.type == "async" for c in node.children)
111
+
112
+ def is_private_member(node: tree_sitter.Node) -> bool:
113
+ for child in node.children:
114
+ if child.type == "accessibility_modifier":
115
+ if _node_text(child, source_bytes).strip() == "private":
116
+ return True
117
+ return False
118
+
119
+ def build_fn_signature(
120
+ name: str,
121
+ fn_node: tree_sitter.Node,
122
+ include_keyword: bool = True,
123
+ ) -> str:
124
+ prefix = "async " if is_async_node(fn_node) else ""
125
+ kw = "function " if include_keyword else ""
126
+ type_params = _node_text(fn_node.child_by_field_name("type_parameters"), source_bytes).strip()
127
+ params_node = fn_node.child_by_field_name("parameters")
128
+ if params_node is not None:
129
+ params_txt = _node_text(params_node, source_bytes).strip()
130
+ else:
131
+ single_param = fn_node.child_by_field_name("parameter")
132
+ if single_param is not None:
133
+ params_txt = f"({_node_text(single_param, source_bytes).strip()})"
134
+ else:
135
+ params_txt = "()"
136
+ ret_node = fn_node.child_by_field_name("return_type")
137
+ if ret_node is None:
138
+ ret_node = next(
139
+ (c for c in fn_node.children if c.type == "type_annotation"),
140
+ None,
141
+ )
142
+ ret_txt = _node_text(ret_node, source_bytes).strip()
143
+ return _collapse_ws(f"{prefix}{kw}{name}{type_params}{params_txt}{ret_txt}")
144
+
145
+ def visit(
146
+ node: tree_sitter.Node,
147
+ class_stack: list[str],
148
+ enclosing_symbol: str | None,
149
+ inside_function: bool,
150
+ parent_exported: bool,
151
+ ) -> None:
152
+ ntype = node.type
153
+
154
+ if ntype == "import_statement":
155
+ extract_import(node)
156
+ return
157
+
158
+ if ntype == "export_statement":
159
+ # Collect `export { foo, bar }` names
160
+ for child in node.children:
161
+ if child.type == "export_clause":
162
+ for spec in child.children:
163
+ if spec.type == "export_specifier":
164
+ name_n = spec.child_by_field_name("name")
165
+ nm = _node_text(name_n, source_bytes).strip()
166
+ if nm:
167
+ re_exported_names.add(nm)
168
+ for child in node.children:
169
+ visit(child, class_stack, enclosing_symbol, inside_function, True)
170
+ return
171
+
172
+ if ntype in ("function_declaration", "generator_function_declaration"):
173
+ name_node = node.child_by_field_name("name")
174
+ name = _node_text(name_node, source_bytes).strip()
175
+ if name:
176
+ qualified = (
177
+ f"{enclosing_symbol}.{name}"
178
+ if (enclosing_symbol and inside_function)
179
+ else name
180
+ )
181
+ sig = build_fn_signature(name, node, include_keyword=True)
182
+ definitions.append(
183
+ SymbolDef(
184
+ name=name,
185
+ qualified_name=qualified,
186
+ kind="function",
187
+ signature=sig,
188
+ start_line=node.start_point.row + 1,
189
+ end_line=node.end_point.row + 1,
190
+ exported=parent_exported and not inside_function,
191
+ file_path=file_path,
192
+ )
193
+ )
194
+ body = node.child_by_field_name("body")
195
+ if body is not None:
196
+ for child in body.children:
197
+ visit(child, class_stack, qualified, True, False)
198
+ return
199
+
200
+ if ntype == "class_declaration":
201
+ name_node = node.child_by_field_name("name")
202
+ name = _node_text(name_node, source_bytes).strip()
203
+ if name:
204
+ qualified = ".".join([*class_stack, name]) if class_stack else name
205
+ heritage_parts: list[str] = []
206
+ for child in node.children:
207
+ if child.type in ("type_parameters", "class_heritage"):
208
+ heritage_parts.append(_node_text(child, source_bytes).strip())
209
+ heritage = " ".join(p for p in heritage_parts if p)
210
+ sig = _collapse_ws(f"class {name} {heritage}" if heritage else f"class {name}")
211
+ definitions.append(
212
+ SymbolDef(
213
+ name=name,
214
+ qualified_name=qualified,
215
+ kind="class",
216
+ signature=sig,
217
+ start_line=node.start_point.row + 1,
218
+ end_line=node.end_point.row + 1,
219
+ exported=parent_exported and not inside_function,
220
+ file_path=file_path,
221
+ )
222
+ )
223
+ body = node.child_by_field_name("body")
224
+ if body is not None:
225
+ next_classes = [*class_stack, name]
226
+ for child in body.children:
227
+ visit(child, next_classes, qualified, inside_function, parent_exported)
228
+ return
229
+
230
+ if ntype == "method_definition":
231
+ name_node = node.child_by_field_name("name")
232
+ name = _node_text(name_node, source_bytes).strip()
233
+ if name:
234
+ qualified = f"{'.'.join(class_stack)}.{name}" if class_stack else name
235
+ sig = build_fn_signature(name, node, include_keyword=False)
236
+ exported = (
237
+ not inside_function
238
+ and not is_private_member(node)
239
+ and not name.startswith(("_", "#"))
240
+ )
241
+ definitions.append(
242
+ SymbolDef(
243
+ name=name,
244
+ qualified_name=qualified,
245
+ kind="method",
246
+ signature=sig,
247
+ start_line=node.start_point.row + 1,
248
+ end_line=node.end_point.row + 1,
249
+ exported=exported,
250
+ file_path=file_path,
251
+ )
252
+ )
253
+ body = node.child_by_field_name("body")
254
+ if body is not None:
255
+ for child in body.children:
256
+ visit(child, class_stack, qualified, True, False)
257
+ return
258
+
259
+ if ntype == "interface_declaration":
260
+ name_node = node.child_by_field_name("name")
261
+ name = _node_text(name_node, source_bytes).strip()
262
+ if name:
263
+ sig = _collapse_ws(_node_text(node, source_bytes))
264
+ definitions.append(
265
+ SymbolDef(
266
+ name=name,
267
+ qualified_name=name,
268
+ kind="interface",
269
+ signature=sig,
270
+ start_line=node.start_point.row + 1,
271
+ end_line=node.end_point.row + 1,
272
+ exported=parent_exported and not inside_function,
273
+ file_path=file_path,
274
+ )
275
+ )
276
+ return
277
+
278
+ if ntype == "type_alias_declaration":
279
+ name_node = node.child_by_field_name("name")
280
+ name = _node_text(name_node, source_bytes).strip()
281
+ if name:
282
+ raw = _node_text(node, source_bytes).strip().rstrip(";")
283
+ sig = _collapse_ws(raw)
284
+ definitions.append(
285
+ SymbolDef(
286
+ name=name,
287
+ qualified_name=name,
288
+ kind="type",
289
+ signature=sig,
290
+ start_line=node.start_point.row + 1,
291
+ end_line=node.end_point.row + 1,
292
+ exported=parent_exported and not inside_function,
293
+ file_path=file_path,
294
+ )
295
+ )
296
+ return
297
+
298
+ if ntype in ("lexical_declaration", "variable_declaration"):
299
+ for child in node.children:
300
+ if child.type == "variable_declarator":
301
+ var_name_node = child.child_by_field_name("name")
302
+ value_node = child.child_by_field_name("value")
303
+ if (
304
+ var_name_node is not None
305
+ and var_name_node.type == "identifier"
306
+ and value_node is not None
307
+ and value_node.type in ("arrow_function", "function_expression")
308
+ and not inside_function
309
+ ):
310
+ name = _node_text(var_name_node, source_bytes).strip()
311
+ if name:
312
+ sig = build_fn_signature(name, value_node, include_keyword=False)
313
+ definitions.append(
314
+ SymbolDef(
315
+ name=name,
316
+ qualified_name=name,
317
+ kind="function",
318
+ signature=sig,
319
+ start_line=child.start_point.row + 1,
320
+ end_line=child.end_point.row + 1,
321
+ exported=parent_exported,
322
+ file_path=file_path,
323
+ )
324
+ )
325
+ body = value_node.child_by_field_name("body")
326
+ if body is not None:
327
+ visit(body, class_stack, name, True, False)
328
+ continue
329
+ visit(child, class_stack, enclosing_symbol, inside_function, False)
330
+ return
331
+
332
+ if ntype == "call_expression":
333
+ func_node = node.child_by_field_name("function")
334
+ callee_name = ""
335
+ if func_node is not None:
336
+ if func_node.type == "identifier":
337
+ callee_name = _node_text(func_node, source_bytes).strip()
338
+ elif func_node.type == "member_expression":
339
+ prop_node = func_node.child_by_field_name("property")
340
+ callee_name = _node_text(prop_node, source_bytes).strip()
341
+ if callee_name == "require":
342
+ args_node = node.child_by_field_name("arguments")
343
+ if args_node is not None:
344
+ for arg in args_node.children:
345
+ if arg.type == "string":
346
+ mod = _strip_quotes(_node_text(arg, source_bytes))
347
+ if mod:
348
+ imports.append(
349
+ ImportRef(
350
+ module=mod,
351
+ names=[],
352
+ line=node.start_point.row + 1,
353
+ file_path=file_path,
354
+ )
355
+ )
356
+ break
357
+ if callee_name:
358
+ line = node.start_point.row + 1
359
+ calls.append(
360
+ CallSite(
361
+ callee_name=callee_name,
362
+ line=line,
363
+ enclosing_symbol=enclosing_symbol,
364
+ file_path=file_path,
365
+ snippet=snippet_for_line(line),
366
+ )
367
+ )
368
+
369
+ elif ntype == "new_expression":
370
+ ctor_node = node.child_by_field_name("constructor")
371
+ callee_name = ""
372
+ if ctor_node is not None:
373
+ if ctor_node.type == "identifier":
374
+ callee_name = _node_text(ctor_node, source_bytes).strip()
375
+ elif ctor_node.type == "member_expression":
376
+ prop_node = ctor_node.child_by_field_name("property")
377
+ callee_name = _node_text(prop_node, source_bytes).strip()
378
+ if callee_name:
379
+ line = node.start_point.row + 1
380
+ calls.append(
381
+ CallSite(
382
+ callee_name=callee_name,
383
+ line=line,
384
+ enclosing_symbol=enclosing_symbol,
385
+ file_path=file_path,
386
+ snippet=snippet_for_line(line),
387
+ )
388
+ )
389
+
390
+ for child in node.children:
391
+ visit(child, class_stack, enclosing_symbol, inside_function, False)
392
+
393
+ visit(tree.root_node, [], None, False, False)
394
+
395
+ if re_exported_names:
396
+ for sym in definitions:
397
+ if sym.name in re_exported_names and "." not in sym.qualified_name:
398
+ sym.exported = True
399
+
400
+ return FileSymbols(
401
+ file_path=file_path,
402
+ language=lang,
403
+ definitions=definitions,
404
+ imports=imports,
405
+ calls=calls,
406
+ )
@@ -0,0 +1,281 @@
1
+ """Core immutable domain schemas for BlastDiff."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from enum import Enum
6
+ from typing import Literal
7
+
8
+ from pydantic import BaseModel, Field
9
+
10
+
11
+ class StoryBucket(str, Enum):
12
+ CONTRACT = "contract"
13
+ CORE = "core"
14
+ TESTS = "tests"
15
+ CONFIG = "config"
16
+ DOCS = "docs"
17
+
18
+
19
+ STORY_ORDER: dict[StoryBucket, int] = {
20
+ StoryBucket.CONTRACT: 0,
21
+ StoryBucket.CORE: 1,
22
+ StoryBucket.TESTS: 2,
23
+ StoryBucket.CONFIG: 3,
24
+ StoryBucket.DOCS: 4,
25
+ }
26
+
27
+
28
+ class ProofStatus(str, Enum):
29
+ PROVEN_BY_COVERAGE = "proven_by_coverage"
30
+ REACHED_BY_TESTS = "reached_by_tests"
31
+ UNVERIFIED = "unverified"
32
+ NON_EXECUTABLE = "non_executable"
33
+
34
+
35
+ class HazardSeverity(str, Enum):
36
+ CRITICAL = "critical"
37
+ HIGH = "high"
38
+ MEDIUM = "medium"
39
+
40
+
41
+ class HazardKind(str, Enum):
42
+ SIGNATURE_BREAK = "signature_break"
43
+ REMOVED_SYMBOL = "removed_symbol"
44
+ LAYER_VIOLATION = "layer_violation"
45
+ SWALLOWED_EXCEPTION = "swallowed_exception"
46
+ DEBUG_LEFTOVER = "debug_leftover"
47
+ HARDCODED_SECRET = "hardcoded_secret"
48
+ UNVERIFIED_LOGIC = "unverified_logic"
49
+
50
+
51
+ class ArchRule(BaseModel):
52
+ name: str
53
+ source_glob: str
54
+ forbid_import: str
55
+ reason: str = ""
56
+
57
+
58
+ class DiffLine(BaseModel):
59
+ kind: Literal["add", "del", "ctx"]
60
+ old_lineno: int | None = None
61
+ new_lineno: int | None = None
62
+ content: str
63
+ coverage_hits: int | None = None
64
+
65
+
66
+ class Hunk(BaseModel):
67
+ id: str
68
+ file_path: str
69
+ old_start: int
70
+ old_count: int
71
+ new_start: int
72
+ new_count: int
73
+ header: str = ""
74
+ symbol_name: str | None = None
75
+ fingerprint: str
76
+ lines: list[DiffLine] = Field(default_factory=list)
77
+ proof_status: ProofStatus = ProofStatus.NON_EXECUTABLE
78
+ covered_lines: int = 0
79
+ uncovered_lines: int = 0
80
+
81
+
82
+ class SymbolDef(BaseModel):
83
+ name: str
84
+ qualified_name: str
85
+ kind: Literal["function", "method", "class", "interface", "type"]
86
+ signature: str
87
+ start_line: int
88
+ end_line: int
89
+ exported: bool = True
90
+ file_path: str = ""
91
+
92
+
93
+ class ImportRef(BaseModel):
94
+ module: str
95
+ names: list[str] = Field(default_factory=list)
96
+ line: int
97
+ file_path: str = ""
98
+
99
+
100
+ class CallSite(BaseModel):
101
+ callee_name: str
102
+ line: int
103
+ enclosing_symbol: str | None = None
104
+ file_path: str
105
+ snippet: str = ""
106
+
107
+
108
+ class FileSymbols(BaseModel):
109
+ file_path: str
110
+ language: str
111
+ definitions: list[SymbolDef] = Field(default_factory=list)
112
+ imports: list[ImportRef] = Field(default_factory=list)
113
+ calls: list[CallSite] = Field(default_factory=list)
114
+
115
+
116
+ class CallerImpact(BaseModel):
117
+ file_path: str
118
+ line: int
119
+ enclosing_symbol: str | None = None
120
+ snippet: str = ""
121
+ in_diff: bool = False
122
+ is_test: bool = False
123
+
124
+
125
+ class SymbolChange(BaseModel):
126
+ file_path: str
127
+ name: str
128
+ kind: str
129
+ change_type: Literal["signature_changed", "removed", "modified", "added"]
130
+ old_signature: str | None = None
131
+ new_signature: str | None = None
132
+ start_line: int = 1
133
+ callers: list[CallerImpact] = Field(default_factory=list)
134
+ unmodified_caller_count: int = 0
135
+ test_callers: list[CallerImpact] = Field(default_factory=list)
136
+
137
+
138
+ class Hazard(BaseModel):
139
+ id: str
140
+ kind: HazardKind
141
+ severity: HazardSeverity
142
+ file_path: str
143
+ line: int
144
+ symbol_name: str | None = None
145
+ title: str
146
+ evidence: str
147
+ suggestion: str = ""
148
+
149
+
150
+ class FileReview(BaseModel):
151
+ path: str
152
+ old_path: str | None = None
153
+ status: Literal["added", "modified", "deleted", "renamed"] = "modified"
154
+ language: str = "text"
155
+ story_bucket: StoryBucket = StoryBucket.CORE
156
+ risk_score: int = 0
157
+ additions: int = 0
158
+ deletions: int = 0
159
+ hunks: list[Hunk] = Field(default_factory=list)
160
+ symbol_changes: list[SymbolChange] = Field(default_factory=list)
161
+ hazards: list[Hazard] = Field(default_factory=list)
162
+ proof_status: ProofStatus = ProofStatus.NON_EXECUTABLE
163
+ covered_added_lines: int = 0
164
+ uncovered_added_lines: int = 0
165
+ reaching_tests: list[str] = Field(default_factory=list)
166
+
167
+
168
+ class BlastRadiusReport(BaseModel):
169
+ total_symbol_changes: int = 0
170
+ signature_breaks: int = 0
171
+ removed_symbols: int = 0
172
+ unmodified_callers_total: int = 0
173
+ changes: list[SymbolChange] = Field(default_factory=list)
174
+
175
+
176
+ class ProofSummary(BaseModel):
177
+ coverage_source: str | None = None
178
+ added_lines_total: int = 0
179
+ covered_added_lines: int = 0
180
+ uncovered_added_lines: int = 0
181
+ coverage_pct: float | None = None
182
+ statically_reached_symbols: int = 0
183
+ unreached_symbols: int = 0
184
+ last_verify_command: str | None = None
185
+ last_verify_passed: bool | None = None
186
+ last_verify_output: str = ""
187
+
188
+
189
+ class ReviewThread(BaseModel):
190
+ id: str
191
+ session_id: str
192
+ file_path: str
193
+ line: int
194
+ symbol_name: str | None = None
195
+ hunk_fingerprint: str = ""
196
+ severity: Literal["blocker", "suggestion", "question", "note"] = "blocker"
197
+ body: str
198
+ status: Literal["open", "resolved", "outdated"] = "open"
199
+ round_created: int = 1
200
+ round_resolved: int | None = None
201
+ created_at: str
202
+ updated_at: str
203
+
204
+
205
+ class ReviewRound(BaseModel):
206
+ round_number: int
207
+ created_at: str
208
+ head_sha: str
209
+ diff_fingerprint: str
210
+ file_hashes: dict[str, str] = Field(default_factory=dict)
211
+ summary: str = ""
212
+
213
+
214
+ class RoundDelta(BaseModel):
215
+ from_round: int
216
+ to_label: str = "current"
217
+ changed_files: list[str] = Field(default_factory=list)
218
+ added_files: list[str] = Field(default_factory=list)
219
+ removed_files: list[str] = Field(default_factory=list)
220
+ unchanged_files: list[str] = Field(default_factory=list)
221
+
222
+
223
+ class SymbolOccurrence(BaseModel):
224
+ file_path: str
225
+ line: int
226
+ column: int = 1
227
+ enclosing_symbol: str | None = None
228
+ role: Literal["definition", "call", "read", "write", "import"]
229
+ snippet: str = ""
230
+ in_diff: bool = False
231
+ is_test: bool = False
232
+ line_in_diff: bool = False
233
+
234
+
235
+ class UpstreamDependency(BaseModel):
236
+ name: str
237
+ kind: Literal["call", "import", "write", "definition"]
238
+ file_path: str
239
+ line: int
240
+ target_file: str | None = None
241
+ target_line: int | None = None
242
+ snippet: str = ""
243
+ changed_in_diff: bool = False
244
+
245
+
246
+ class SymbolImpactReport(BaseModel):
247
+ symbol: str
248
+ source_file: str
249
+ source_line: int
250
+ inferred_kind: Literal[
251
+ "function", "method", "class", "interface", "type", "variable", "attribute", "unknown"
252
+ ] = "unknown"
253
+ scope: Literal["local", "repository"] = "repository"
254
+ enclosing_symbol: str | None = None
255
+ definitions: list[SymbolOccurrence] = Field(default_factory=list)
256
+ downstream_untouched: list[SymbolOccurrence] = Field(default_factory=list)
257
+ downstream_in_diff: list[SymbolOccurrence] = Field(default_factory=list)
258
+ downstream_tests: list[SymbolOccurrence] = Field(default_factory=list)
259
+ upstream: list[UpstreamDependency] = Field(default_factory=list)
260
+ upstream_changed_in_diff_count: int = 0
261
+ analysis_ms: int = 0
262
+
263
+
264
+ class DiffAnalysis(BaseModel):
265
+ repo_name: str
266
+ repo_root: str
267
+ branch: str
268
+ base_ref: str
269
+ target_label: str
270
+ diff_fingerprint: str
271
+ analysis_ms: int = 0
272
+ files: list[FileReview] = Field(default_factory=list)
273
+ story_counts: dict[str, int] = Field(default_factory=dict)
274
+ hazards: list[Hazard] = Field(default_factory=list)
275
+ blast_radius: BlastRadiusReport = Field(default_factory=BlastRadiusReport)
276
+ proof: ProofSummary = Field(default_factory=ProofSummary)
277
+ arch_rules_loaded: int = 0
278
+ current_round: int = 1
279
+ rounds: list[ReviewRound] = Field(default_factory=list)
280
+ threads: list[ReviewThread] = Field(default_factory=list)
281
+ delta_since_last_round: RoundDelta | None = None