diff --git a/scripts/ci/noema_review_gate.py b/scripts/ci/noema_review_gate.py index 249f94f6b7..68adc75c77 100644 --- a/scripts/ci/noema_review_gate.py +++ b/scripts/ci/noema_review_gate.py @@ -474,24 +474,9 @@ def review_thread_context(pr: dict[str, Any]) -> str: return "\n".join(lines) -def load_codegraph_context() -> str: - """Load optional precomputed CodeGraph context for structural review evidence.""" - path = os.environ.get("NOEMA_CODEGRAPH_CONTEXT_PATH", "").strip() - if not path: - return "" - try: - with open(path, encoding="utf-8") as handle: - return truncate_text(handle.read(), MAX_REVIEW_CONTEXT_CHARS) - except OSError as exc: - return f"CodeGraph context unavailable: {exc}" - - def build_review_context(repo: str, number: int, pr: dict[str, Any]) -> str: """Build bounded non-diff context for the Noema reviewer.""" sections: list[str] = [] - codegraph = load_codegraph_context() - if codegraph: - sections.append("## CodeGraph context\n" + codegraph) threads = review_thread_context(pr) if threads: sections.append("## Prior review threads\n" + threads) @@ -958,7 +943,7 @@ def call_llm( "content": "\n".join( [ "You are Noema, an independent pull request reviewer for ContextualWisdomLab.", - "Review the PR diff plus the additional changed-file, review-thread, and CodeGraph context for correctness, security, maintainability, and behavioral regressions.", + "Review the PR diff plus the additional changed-file and review-thread context for correctness, security, maintainability, and behavioral regressions.", "Return only JSON with this shape:", json.dumps( { diff --git a/tests/test_noema_review_gate.py b/tests/test_noema_review_gate.py index 6272ff2b59..cc08797476 100644 --- a/tests/test_noema_review_gate.py +++ b/tests/test_noema_review_gate.py @@ -1378,7 +1378,7 @@ def test_current_actor_rejects_unbound_action_identity(monkeypatch, actor, insta noema.current_actor() -def test_review_context_builders_include_codegraph_threads_and_files(monkeypatch, tmp_path): +def test_review_context_builders_include_threads_and_files(monkeypatch): assert noema.truncate_text("abc", 10) == "abc" assert "truncated 2 characters" in noema.truncate_text("abcdef", 4) assert "missing PR head SHA" in noema.changed_file_context("owner/repo", 7, "") @@ -1405,9 +1405,6 @@ def fake_run(args, stdin=None): raise AssertionError(args) monkeypatch.setattr(noema, "run", fake_run) - codegraph_path = tmp_path / "codegraph.md" - codegraph_path.write_text("call graph: src/a.py -> tests", encoding="utf-8") - monkeypatch.setenv("NOEMA_CODEGRAPH_CONTEXT_PATH", str(codegraph_path)) pr = make_pr( headRefOid="head sha", reviewThreads={ @@ -1431,8 +1428,6 @@ def fake_run(args, stdin=None): context = noema.build_review_context("owner/repo", 7, pr) - assert "## CodeGraph context" in context - assert "call graph: src/a.py -> tests" in context assert "Thread open at src/a.py:3" in context assert "reviewer: check call site" in context assert "### src/a.py" in context @@ -1442,13 +1437,7 @@ def fake_run(args, stdin=None): assert any("/files" in call[2] for call in calls) -def test_review_context_reports_omitted_files_and_missing_codegraph(monkeypatch, tmp_path): - monkeypatch.delenv("NOEMA_CODEGRAPH_CONTEXT_PATH", raising=False) - assert noema.load_codegraph_context() == "" - - monkeypatch.setenv("NOEMA_CODEGRAPH_CONTEXT_PATH", str(tmp_path / "missing.md")) - assert "CodeGraph context unavailable" in noema.load_codegraph_context() - +def test_review_context_reports_omitted_files(monkeypatch): paths = [f"src/file_{index}.py" for index in range(noema.MAX_CONTEXT_FILES + 1)] monkeypatch.setattr(noema, "fetch_changed_file_paths", lambda repo, number: paths) monkeypatch.setattr(noema, "fetch_head_file_content", lambda repo, path, head_sha: "x") diff --git a/tests/test_pr_review_fix_scheduler.py b/tests/test_pr_review_fix_scheduler.py index f6abd64b0f..32c20738ea 100644 --- a/tests/test_pr_review_fix_scheduler.py +++ b/tests/test_pr_review_fix_scheduler.py @@ -1352,6 +1352,13 @@ def test_fix_inspect_skip_wait_and_error_paths(monkeypatch): assert fix.inspect_pr("owner/repo", make_pr(headRepository={"nameWithOwner": "fork/repo"}), args)[1] == ( "external PR head is not writable by repository workflow credentials", ) + assert fix.inspect_pr( + "owner/repo", make_pr(mergeStateStatus="DIRTY", isDraft=True), args + ) == ("skip", ("draft PR",)) + assert fix.inspect_pr("owner/repo", make_pr(mergeStateStatus="DIRTY"), args) == ( + "skip", + ("merge conflict is not authorized for repair",), + ) monkeypatch.setattr(fix, "needs_autofix", lambda pr: (False, ())) assert fix.inspect_pr("owner/repo", make_pr(), args) == ( diff --git a/tests/test_repository_branch_coverage_javascript_and_noema.py b/tests/test_repository_branch_coverage_javascript_and_noema.py index 99793a4dfa..caeca87236 100644 --- a/tests/test_repository_branch_coverage_javascript_and_noema.py +++ b/tests/test_repository_branch_coverage_javascript_and_noema.py @@ -176,9 +176,7 @@ def test_noema_review_context_includes_locations_bodies_and_all_sections( assert "src/runtime.py:7" in rendered assert "reviewer: Fix this" in rendered - monkeypatch.setattr(noema, "load_codegraph_context", lambda: "graph") monkeypatch.setattr(noema, "changed_file_context", lambda *_args: "files") context = noema.build_review_context("owner/repo", 1, pr) - assert "CodeGraph context" in context assert "Prior review threads" in context assert "Changed file context" in context diff --git a/tests/test_repository_branch_coverage_reporting_edges.py b/tests/test_repository_branch_coverage_reporting_edges.py index b4527147c8..f5dbf1dae0 100644 --- a/tests/test_repository_branch_coverage_reporting_edges.py +++ b/tests/test_repository_branch_coverage_reporting_edges.py @@ -129,7 +129,6 @@ def test_noema_small_diff_and_empty_context_branches( rendered_context = noema.review_thread_context(pr) assert rendered_context == "- Thread open at src/runtime.py:\n - reviewer: note" - monkeypatch.setattr(noema, "load_codegraph_context", lambda: "") monkeypatch.setattr(noema, "review_thread_context", lambda _pr: "") monkeypatch.setattr(noema, "changed_file_context", lambda *_args: "") assert noema.build_review_context("owner/repo", 1, pr) == ""