Skip to content
Merged
17 changes: 1 addition & 16 deletions scripts/ci/noema_review_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Comment on lines -477 to -486

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Info: Removed branch had no producer

load_codegraph_context had no production configuration or producer. Remaining CodeGraph setup belongs to OpenCode, so Noema loses no deployed review evidence.

Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.



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)
Expand Down Expand Up @@ -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(
{
Expand Down
15 changes: 2 additions & 13 deletions tests/test_noema_review_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, "")
Expand All @@ -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={
Expand All @@ -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
Expand All @@ -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")
Expand Down
7 changes: 7 additions & 0 deletions tests/test_pr_review_fix_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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) == (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion tests/test_repository_branch_coverage_reporting_edges.py
Original file line number Diff line number Diff line change
Expand Up @@ -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) == ""
Expand Down
Loading