@@ -35,10 +35,38 @@ def _counts(items: list[str]) -> dict[str, int]:
3535 return dict (sorted (Counter (items ).items ()))
3636
3737
38- def build_report (* , diff_file : str , files : list [str ], findings : list [Finding ], dry_run : bool ) -> dict [str , Any ]:
38+ def build_report (
39+ * ,
40+ diff_file : str ,
41+ files : list [str ],
42+ findings : list [Finding ],
43+ dry_run : bool ,
44+ filter_summary : dict [str , Any ] | None = None ,
45+ sandbox_summary : dict [str , Any ] | None = None ,
46+ telemetry_summary : dict [str , Any ] | None = None ,
47+ ) -> dict [str , Any ]:
3948 finding_dicts = [_redact_value (finding .to_dict ()) for finding in findings ]
4049 severity_counts = _counts ([str (item ["severity" ]) for item in finding_dicts ])
4150 category_counts = _counts ([str (item ["category" ]) for item in finding_dicts ])
51+ filter_summary = filter_summary or {"decision" : "allow" , "reason" : "not evaluated" }
52+ sandbox_summary = sandbox_summary or {
53+ "runner_name" : "none" ,
54+ "timeout_seconds" : 0 ,
55+ "status" : "not_run" ,
56+ "started_at" : "" ,
57+ "finished_at" : "" ,
58+ "stdout_summary" : "" ,
59+ "stderr_summary" : "" ,
60+ }
61+ telemetry_summary = telemetry_summary or {
62+ "files_scanned" : files ,
63+ "total_findings" : len (finding_dicts ),
64+ "severity_counts" : severity_counts ,
65+ "category_counts" : category_counts ,
66+ "sandbox_status" : sandbox_summary ["status" ],
67+ "filter_decision" : filter_summary ["decision" ],
68+ "duration_ms" : 0 ,
69+ }
4270
4371 report = {
4472 "summary" : {
@@ -51,6 +79,9 @@ def build_report(*, diff_file: str, files: list[str], findings: list[Finding], d
5179 "severity_counts" : severity_counts ,
5280 "category_counts" : category_counts ,
5381 },
82+ "filter" : filter_summary ,
83+ "sandbox" : sandbox_summary ,
84+ "telemetry" : telemetry_summary ,
5485 "findings" : finding_dicts ,
5586 }
5687 return _redact_value (report )
@@ -68,6 +99,9 @@ def _markdown_table_row(finding: dict[str, Any]) -> str:
6899
69100def render_markdown (report : dict [str , Any ]) -> str :
70101 summary = report ["summary" ]
102+ filter_summary = report .get ("filter" , {})
103+ sandbox_summary = report .get ("sandbox" , {})
104+ telemetry_summary = report .get ("telemetry" , {})
71105 lines = [
72106 "# Code Review Report" ,
73107 "" ,
@@ -76,6 +110,8 @@ def render_markdown(report: dict[str, Any]) -> str:
76110 f"- Diff file: `{ summary ['diff_file' ]} `" ,
77111 f"- Files scanned: { len (summary ['files_scanned' ])} " ,
78112 f"- Total findings: { summary ['total_findings' ]} " ,
113+ f"- Filter decision: { filter_summary .get ('decision' , 'unknown' )} " ,
114+ f"- Sandbox status: { sandbox_summary .get ('status' , 'unknown' )} " ,
79115 "" ,
80116 "## Severity Counts" ,
81117 "" ,
@@ -86,6 +122,32 @@ def render_markdown(report: dict[str, Any]) -> str:
86122 else :
87123 lines .append ("- none: 0" )
88124
125+ lines .extend ([
126+ "" ,
127+ "## Filter Summary" ,
128+ "" ,
129+ f"- Decision: { filter_summary .get ('decision' , 'unknown' )} " ,
130+ f"- Reason: { filter_summary .get ('reason' , '' )} " ,
131+ "" ,
132+ "## Sandbox Summary" ,
133+ "" ,
134+ f"- Runner: { sandbox_summary .get ('runner_name' , 'unknown' )} " ,
135+ f"- Timeout seconds: { sandbox_summary .get ('timeout_seconds' , 0 )} " ,
136+ f"- Status: { sandbox_summary .get ('status' , 'unknown' )} " ,
137+ f"- Started: { sandbox_summary .get ('started_at' , '' )} " ,
138+ f"- Finished: { sandbox_summary .get ('finished_at' , '' )} " ,
139+ f"- Stdout summary: { sandbox_summary .get ('stdout_summary' , '' )} " ,
140+ f"- Stderr summary: { sandbox_summary .get ('stderr_summary' , '' )} " ,
141+ "" ,
142+ "## Telemetry Summary" ,
143+ "" ,
144+ f"- Files scanned: { len (telemetry_summary .get ('files_scanned' , []))} " ,
145+ f"- Total findings: { telemetry_summary .get ('total_findings' , 0 )} " ,
146+ f"- Sandbox status: { telemetry_summary .get ('sandbox_status' , 'unknown' )} " ,
147+ f"- Filter decision: { telemetry_summary .get ('filter_decision' , 'unknown' )} " ,
148+ f"- Duration ms: { telemetry_summary .get ('duration_ms' , 0 )} " ,
149+ ])
150+
89151 lines .extend (["" , "## Findings" , "" ])
90152 findings = report ["findings" ]
91153 if not findings :
0 commit comments