Skip to content
This repository was archived by the owner on May 12, 2026. It is now read-only.

Commit 703df69

Browse files
toraidlcodex
andcommitted
feat: surface diff-report summary and risk flags in workflow logs
Continue the diff-report optimization by exposing actionable summary signals directly in runtime logs, so operators can review high-level deltas without opening the JSON artifact first. What changed: - Add log_diff_report_summary() to emit compact file/prop/apk/risk counters. - Emit risk-flag codes as warning logs when present in diff-report highlights. - Wire summary logging into execute_porting() right after diff report persistence. - Extend workflow tests to assert summary and risk-flag logging behavior. Verification: - .venv/bin/python -m ruff check src/app/workflow.py tests/test_workflow.py - .venv/bin/python -m mypy --config-file mypy-curated.ini - .venv/bin/python -m pytest -q tests/test_workflow.py tests/test_diff_report.py - .venv/bin/python -m pytest -q Co-authored-by: OpenAI Codex <noreply@openai.com>
1 parent c66d495 commit 703df69

2 files changed

Lines changed: 63 additions & 1 deletion

File tree

src/app/workflow.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,40 @@ def run_repacking(
129129
packer.pack_ota_payload()
130130

131131

132+
def log_diff_report_summary(diff_report: dict[str, object], logger: logging.Logger) -> None:
133+
"""Log a compact summary for generated artifact diff reports."""
134+
summary = diff_report.get("summary", {})
135+
if not isinstance(summary, dict):
136+
summary = {}
137+
138+
logger.info(
139+
"Artifact diff summary: +%s -%s ~%s props=%s apks=%s risks=%s",
140+
summary.get("files_added", 0),
141+
summary.get("files_removed", 0),
142+
summary.get("files_modified", 0),
143+
summary.get("prop_changes", 0),
144+
summary.get("apk_changes", 0),
145+
summary.get("risk_flags", 0),
146+
)
147+
148+
highlights = diff_report.get("highlights", {})
149+
if not isinstance(highlights, dict):
150+
return
151+
risk_flags = highlights.get("risk_flags", [])
152+
if not isinstance(risk_flags, list) or not risk_flags:
153+
return
154+
155+
codes: list[str] = []
156+
for flag in risk_flags:
157+
if not isinstance(flag, dict):
158+
continue
159+
code = flag.get("code")
160+
if isinstance(code, str):
161+
codes.append(code)
162+
if codes:
163+
logger.warning("Artifact diff risk flags: %s", ", ".join(codes))
164+
165+
132166
def execute_porting(args, logger: logging.Logger) -> int:
133167
"""Execute the end-to-end porting workflow and return a process exit code."""
134168
is_official_modify = args.port is None
@@ -243,6 +277,7 @@ def execute_porting(args, logger: logging.Logger) -> int:
243277
diff_report = generate_diff_report(baseline_artifact_state, final_artifact_state)
244278
report_path = save_diff_report(diff_report, args.diff_report)
245279
logger.info(f"Artifact diff report saved to: {report_path}")
280+
log_diff_report_summary(diff_report, logger)
246281

247282
logger.info("=" * 70)
248283
logger.info("Porting completed successfully!")

tests/test_workflow.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,22 @@ def test_execute_porting_generates_diff_report_when_enabled():
272272
patch("src.app.workflow.run_modification_phases"),
273273
patch("src.app.workflow.run_repacking"),
274274
patch("src.app.workflow.collect_artifact_state") as collect_artifact_state_mock,
275-
patch("src.app.workflow.generate_diff_report", return_value={"summary": {}}) as generate_mock,
275+
patch(
276+
"src.app.workflow.generate_diff_report",
277+
return_value={
278+
"summary": {
279+
"files_added": 1,
280+
"files_removed": 0,
281+
"files_modified": 2,
282+
"prop_changes": 3,
283+
"apk_changes": 4,
284+
"risk_flags": 1,
285+
},
286+
"highlights": {
287+
"risk_flags": [{"code": "HIGH_IMPACT_PATH_CHANGED"}],
288+
},
289+
},
290+
) as generate_mock,
276291
patch("src.app.workflow.save_diff_report") as save_diff_report_mock,
277292
):
278293
bootstrap.return_value.exit_code = None
@@ -296,3 +311,15 @@ def test_execute_porting_generates_diff_report_when_enabled():
296311
assert collect_artifact_state_mock.call_count == 2
297312
generate_mock.assert_called_once()
298313
save_diff_report_mock.assert_called_once()
314+
logger.info.assert_any_call(
315+
"Artifact diff summary: +%s -%s ~%s props=%s apks=%s risks=%s",
316+
1,
317+
0,
318+
2,
319+
3,
320+
4,
321+
1,
322+
)
323+
logger.warning.assert_any_call(
324+
"Artifact diff risk flags: %s", "HIGH_IMPACT_PATH_CHANGED"
325+
)

0 commit comments

Comments
 (0)