-
Notifications
You must be signed in to change notification settings - Fork 0
fix(noema): review deleted files from base-side evidence #1564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e96583b
fix(noema): stop treating a deleted file's expected head-content 404 …
claude db106d5
test(ci): close main's post-#1546 scheduler coverage regression
claude 85c2469
docs(gap-baseline): record post-#1546 scheduler coverage regression
claude 6f40a06
test(ci): document nested REST fixture helpers
seonghobae 6948175
fix(tests): drain dispatch fixture stdin to break CI dependency cycle
seonghobae dda959d
Merge branch 'main' into fix/noema-deleted-file-context
seonghobae d4cea2f
docs(changelog): record base-side deleted file context for Noema reviews
seonghobae 400f2b5
fix(noema): remove dead CodeGraph context branch from Noema review ga…
seonghobae 53911d5
test(noema): isolate deleted-file base-context regression
seonghobae 1e54a79
fix(noema): reconcile deleted-file context with transport retry
seonghobae b75a7a0
fix(noema): reconcile deleted-file evidence onto current main
seonghobae 22fbbde
fix(noema): bind deleted-file evidence to merge base
seonghobae 142179b
fix(noema): absorb hollow CodeGraph cleanup tests
seonghobae File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| """Regression tests for Noema deleted-file review context.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import base64 | ||
|
|
||
| from scripts.ci import noema_review_gate as noema | ||
|
|
||
|
|
||
| def test_fetch_changed_files_preserves_path_and_status(monkeypatch): | ||
| """The paginated Files API adapter must retain each file status.""" | ||
| monkeypatch.setattr( | ||
| noema, | ||
| "run", | ||
| lambda args, stdin=None: "a.py\tmodified\n\nb.py\tremoved\nfuzz/x.py\tadded\n", | ||
| ) | ||
|
|
||
| assert noema.fetch_changed_files("owner/repo", 7) == [ | ||
| ("a.py", "modified"), | ||
| ("b.py", "removed"), | ||
| ("fuzz/x.py", "added"), | ||
| ] | ||
|
|
||
|
|
||
| def test_removed_file_context_uses_base_content(monkeypatch): | ||
| """A deleted file must be reviewed from immutable pre-deletion evidence.""" | ||
| encoded = base64.b64encode(b"def doomed():\n pass\n").decode("ascii") | ||
| calls: list[str] = [] | ||
|
|
||
| def fake_run(args, stdin=None): | ||
| target = args[2] | ||
| calls.append(target) | ||
| if target.endswith("/files"): | ||
| return "fuzz/fuzz_opencode_normalize_output.py\tremoved\n" | ||
| if "contents/fuzz/fuzz_opencode_normalize_output.py?ref=base-sha" in target: | ||
| return encoded | ||
| raise AssertionError(args) | ||
|
|
||
| monkeypatch.setattr(noema, "run", fake_run) | ||
|
|
||
| context = noema.changed_file_context( | ||
| "owner/repo", 1486, "head-sha", "base-sha" | ||
| ) | ||
|
|
||
| assert "File removed in this PR. Pre-deletion content at base ref" in context | ||
| assert "def doomed" in context | ||
| assert not any("ref=head-sha" in target for target in calls) | ||
|
|
||
|
|
||
| def test_removed_file_context_fails_closed_without_base_sha(monkeypatch): | ||
| """Missing base identity must be explicit and must not trigger a head fetch.""" | ||
| monkeypatch.setattr( | ||
| noema, | ||
| "fetch_changed_files", | ||
| lambda repo, number: [("gone.py", "removed")], | ||
| ) | ||
| monkeypatch.setattr( | ||
| noema, | ||
| "fetch_head_file_content", | ||
| lambda *args, **kwargs: (_ for _ in ()).throw(AssertionError("unexpected fetch")), | ||
| ) | ||
|
|
||
| context = noema.changed_file_context("owner/repo", 7, "head-sha", "") | ||
|
|
||
| assert "base SHA unavailable" in context | ||
|
|
||
|
|
||
| def test_removed_file_base_fetch_failure_is_distinct_from_head_failure(monkeypatch): | ||
| """A base-side API failure must remain typed as base evidence failure.""" | ||
| monkeypatch.setattr( | ||
| noema, | ||
| "fetch_changed_files", | ||
| lambda repo, number: [("gone.py", "removed")], | ||
| ) | ||
|
|
||
| def fail_fetch(repo, path, ref): | ||
| raise RuntimeError("HTTP 502: token ***") | ||
|
|
||
| monkeypatch.setattr(noema, "fetch_head_file_content", fail_fetch) | ||
|
|
||
| context = noema.changed_file_context( | ||
| "owner/repo", 7, "head-sha", "base-sha" | ||
| ) | ||
|
|
||
| assert "Unavailable from base content API" in context | ||
| assert "Unavailable from head content API" not in context | ||
|
|
||
|
|
||
| def test_build_review_context_passes_live_base_ref(monkeypatch): | ||
| """The GraphQL base identity must reach changed-file context construction.""" | ||
| observed: list[tuple[str, int, str, str]] = [] | ||
| monkeypatch.setattr(noema, "review_thread_context", lambda pr: "") | ||
| monkeypatch.setattr(noema, "load_codegraph_context", lambda: "") | ||
|
|
||
| def fake_context(repo, number, head_sha, base_sha=""): | ||
| observed.append((repo, number, head_sha, base_sha)) | ||
| return "files" | ||
|
|
||
| monkeypatch.setattr(noema, "changed_file_context", fake_context) | ||
|
|
||
| result = noema.build_review_context( | ||
| "owner/repo", | ||
| 7, | ||
| {"headRefOid": "head-sha", "baseRefOid": "base-sha"}, | ||
| ) | ||
|
|
||
| assert observed == [("owner/repo", 7, "head-sha", "base-sha")] | ||
| assert "## Changed file context\nfiles" in result | ||
|
devin-ai-integration[bot] marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.