Skip to content

Commit fe8c28b

Browse files
fix: log review analysis mode
Amp-Thread-ID: https://ampcode.com/threads/T-019ecb81-dc76-76cb-8bf3-22a366c9be41 Co-authored-by: Amp <amp@ampcode.com>
1 parent 8e48555 commit fe8c28b

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

scripts/engine_adapter.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,12 @@ def run_head(
327327
target_ref: str,
328328
source_sha: str,
329329
) -> None:
330-
"""Review PR head: incremental from the PR base, full on a cache miss."""
331-
_incremental_or_full(
330+
"""Review PR head: incremental from the PR base, full on a cache miss.
331+
332+
Print the selected mode explicitly so GitHub Action logs make it obvious
333+
whether review used the incremental path or fell back to a full analysis.
334+
"""
335+
mode = _incremental_or_full(
332336
repo_path=repo_path,
333337
output_dir=output_dir,
334338
repo_name=repo_name,
@@ -339,6 +343,7 @@ def run_head(
339343
source_sha=source_sha,
340344
log_name="cb-head.log",
341345
)
346+
print(f"head_analysis_mode={mode}")
342347

343348

344349
def run_analyze(

tests/test_engine_adapter.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import tempfile
99
import types
1010
import unittest
11-
from contextlib import redirect_stderr
11+
from contextlib import redirect_stderr, redirect_stdout
1212
from io import StringIO
1313
from pathlib import Path
1414
from unittest.mock import patch
@@ -159,11 +159,14 @@ def test_main_rejects_invalid_depth(self):
159159
def test_head_uses_incremental(self):
160160
ri, rf = _Rec(), _Rec()
161161
self._install(run_full=rf, run_incremental=ri)
162-
engine_adapter.run_head("/repo", "/out", "r", "rid", 1, "base", "head", "head")
162+
buf = StringIO()
163+
with redirect_stdout(buf):
164+
engine_adapter.run_head("/repo", "/out", "r", "rid", 1, "base", "head", "head")
163165
self.assertEqual(len(ri.calls), 1)
164166
self.assertEqual(len(rf.calls), 0) # no fallback
165167
self.assertEqual(ri.calls[0]["base_ref"], "base")
166168
self.assertEqual(ri.calls[0]["target_ref"], "head")
169+
self.assertIn("head_analysis_mode=incremental", buf.getvalue())
167170

168171
def test_head_falls_back_to_full_on_cache_miss(self):
169172
analysis, IncMiss, _ = self._install() # install once so the exception class identity matches
@@ -174,11 +177,14 @@ def test_head_falls_back_to_full_on_cache_miss(self):
174177
(Path(out) / "stale.json").write_text("{}") # must be wiped before the full run
175178
(Path(out) / "health").mkdir()
176179
(Path(out) / "health" / "stale.json").write_text("{}")
177-
engine_adapter.run_head("/repo", out, "r", "rid", 3, "base", "head", "head")
180+
buf = StringIO()
181+
with redirect_stdout(buf):
182+
engine_adapter.run_head("/repo", out, "r", "rid", 3, "base", "head", "head")
178183
self.assertEqual(len(rf.calls), 1) # fell back to full
179184
self.assertEqual(rf.calls[0]["depth_level"], 3)
180185
self.assertFalse((Path(out) / "stale.json").exists()) # head dir wiped before full
181186
self.assertFalse((Path(out) / "health").exists()) # nested stale artifacts wiped too
187+
self.assertIn("head_analysis_mode=full", buf.getvalue())
182188

183189
def test_head_falls_back_to_full_on_baseline_unavailable(self):
184190
analysis, _, BaseUnavail = self._install() # the other warm-start failure must also fall back

0 commit comments

Comments
 (0)