-
Notifications
You must be signed in to change notification settings - Fork 116
GSoC Module A: week 5 : feat(harvester): add git diff retrieval pipeline (stacked on top of #986) #987
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
Open
ParthAggarwal16
wants to merge
27
commits into
OWASP:main
Choose a base branch
from
ParthAggarwal16:week_5-clean
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
GSoC Module A: week 5 : feat(harvester): add git diff retrieval pipeline (stacked on top of #986) #987
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
5cab1cf
fix(harvester): address repository client review feedback
ParthAggarwal16 2f981e2
feat(harvester): implement incremental change detection
ParthAggarwal16 eb72939
fix(harvester): write checkpoints atomically
ParthAggarwal16 877bf7a
Use immutable commit ranges for change detection
ParthAggarwal16 967f146
test: replace mocked /tmp/repo path
ParthAggarwal16 bb90b14
feat(db): add artifact ingestion persistence models
ParthAggarwal16 ab615d5
Address CodeRabbit review feedback
ParthAggarwal16 a6929df
feat(harvester): replace filesystem checkpoint store with postgres
ParthAggarwal16 92f7f0d
test(harvester): match checkout invocation
ParthAggarwal16 189d84b
Address review feedback for Week 3
ParthAggarwal16 9819313
docs : fix Revision ID in the migration file
ParthAggarwal16 8763f21
fix(harvester): address repository client review feedback
ParthAggarwal16 1d5a9f0
feat(harvester): implement repository file filtering
ParthAggarwal16 a13641a
fix(harvester): improve filtering benchmark and sync behavior
ParthAggarwal16 81b757e
fix(harvester): isolate filter defaults and preserve empty overrides
ParthAggarwal16 105ac27
Use glob-based path filtering for harvester
ParthAggarwal16 e193949
feat(harvester): improve file filtering and exclusions
ParthAggarwal16 d5dde16
test: strengthen FileFilter validation
ParthAggarwal16 d8cafa9
fix(harvester): address repository client review feedback
ParthAggarwal16 f3c8eb1
fix(harvester): improve filtering benchmark and sync behavior
ParthAggarwal16 3221820
feat(harvester): add git diff retrieval pipeline
ParthAggarwal16 2d04894
feat(harvester): parse unified git diffs
ParthAggarwal16 67658da
feat(harvester): normalize extracted diff content
ParthAggarwal16 eaa6ae9
Enhance diff pipeline with metadata and normalization
ParthAggarwal16 79080d7
fix(harvester): address review feedback
ParthAggarwal16 4e6b8a5
Harden diff retrieval and isolate network benchmark tests
ParthAggarwal16 a1b2139
Addressing code rabbit comment
ParthAggarwal16 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -84,3 +84,5 @@ tmp/ | |
| cres/* | ||
| ### Local project management tooling | ||
| project management scripts/ | ||
|
|
||
| .harvester_cache/ | ||
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
168 changes: 168 additions & 0 deletions
168
application/tests/harvester_test/change_detector_test.py
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,168 @@ | ||
| import unittest | ||
| from unittest.mock import MagicMock | ||
| from unittest.mock import call | ||
| from unittest.mock import patch | ||
|
|
||
| from application.utils.harvester.change_detector import ( | ||
| ChangeDetector, | ||
| ) | ||
|
|
||
|
|
||
| class ChangeDetectorTests(unittest.TestCase): | ||
| @patch("application.utils.harvester.change_detector.subprocess.run") | ||
| def test_get_modified_files_since(self, mock_run): | ||
| client = MagicMock() | ||
| client.get_local_path.return_value = "repo-under-test" | ||
|
|
||
| mock_run.side_effect = [ | ||
| MagicMock(stdout="resolved_base\n"), | ||
| MagicMock(stdout="resolved_target\n"), | ||
| MagicMock(stdout="a.md\nb.md\na.md\n"), | ||
| ] | ||
|
|
||
| detector = ChangeDetector(client) | ||
|
|
||
| files = detector.get_modified_files_since( | ||
| "base", | ||
| "target", | ||
| ) | ||
|
|
||
| self.assertEqual( | ||
| files, | ||
| [ | ||
| "a.md", | ||
| "b.md", | ||
| ], | ||
| ) | ||
|
|
||
| mock_run.assert_has_calls( | ||
| [ | ||
| call( | ||
| [ | ||
| "git", | ||
| "-C", | ||
| "repo-under-test", | ||
| "rev-parse", | ||
| "--verify", | ||
| "--end-of-options", | ||
| "base^{commit}", | ||
| ], | ||
| capture_output=True, | ||
| text=True, | ||
| check=True, | ||
| timeout=60, | ||
| ), | ||
| call( | ||
| [ | ||
| "git", | ||
| "-C", | ||
| "repo-under-test", | ||
| "rev-parse", | ||
| "--verify", | ||
| "--end-of-options", | ||
| "target^{commit}", | ||
| ], | ||
| capture_output=True, | ||
| text=True, | ||
| check=True, | ||
| timeout=60, | ||
| ), | ||
| call( | ||
| [ | ||
| "git", | ||
| "-C", | ||
| "repo-under-test", | ||
| "diff", | ||
| "--name-only", | ||
| "resolved_base", | ||
| "resolved_target", | ||
| ], | ||
| capture_output=True, | ||
| text=True, | ||
| check=True, | ||
| timeout=60, | ||
| ), | ||
| ] | ||
| ) | ||
|
|
||
| @patch("application.utils.harvester.change_detector.subprocess.run") | ||
| def test_get_commits_since(self, mock_run): | ||
| client = MagicMock() | ||
| client.get_local_path.return_value = "repo-under-test" | ||
|
|
||
| mock_run.side_effect = [ | ||
| MagicMock(stdout="resolved_base\n"), | ||
| MagicMock(stdout="resolved_target\n"), | ||
| MagicMock(stdout="111\n222\n333\n"), | ||
| ] | ||
|
|
||
| detector = ChangeDetector(client) | ||
|
|
||
| commits = detector.get_commits_since( | ||
| "base", | ||
| "target", | ||
| ) | ||
|
|
||
| self.assertEqual( | ||
| commits, | ||
| [ | ||
| "111", | ||
| "222", | ||
| "333", | ||
| ], | ||
| ) | ||
|
|
||
| self.assertEqual( | ||
| mock_run.call_args_list, | ||
| [ | ||
| call( | ||
| [ | ||
| "git", | ||
| "-C", | ||
| "repo-under-test", | ||
| "rev-parse", | ||
| "--verify", | ||
| "--end-of-options", | ||
| "base^{commit}", | ||
| ], | ||
| capture_output=True, | ||
| text=True, | ||
| check=True, | ||
| timeout=60, | ||
| ), | ||
| call( | ||
| [ | ||
| "git", | ||
| "-C", | ||
| "repo-under-test", | ||
| "rev-parse", | ||
| "--verify", | ||
| "--end-of-options", | ||
| "target^{commit}", | ||
| ], | ||
| capture_output=True, | ||
| text=True, | ||
| check=True, | ||
| timeout=60, | ||
| ), | ||
| call( | ||
| [ | ||
| "git", | ||
| "-C", | ||
| "repo-under-test", | ||
| "log", | ||
| "--reverse", | ||
| "--format=%H", | ||
| "resolved_base..resolved_target", | ||
| ], | ||
| capture_output=True, | ||
| text=True, | ||
| check=True, | ||
| timeout=60, | ||
| ), | ||
| ], | ||
| ) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Unhandled
IntegrityErroron the new unique constraints.Neither
create_artifact_ingest_eventnorcreate_ingest_chunkcatchesIntegrityErrorfromuq_artifact_ingest_event_run_artifact/uq_ingest_chunk_artifact_chunk. A retried/duplicate ingest (samerun_id+artifact_id, or sameartifact_event_id+chunk_id) will raise uncaught, leaving the session in a state requiring rollback before further use.CheckpointStore.save()andadd_node/add_crein this same file already establish the pattern of catchingIntegrityError, rolling back, and re-raising a clear error.🐛 Proposed fix
(same pattern for
create_ingest_chunk)📝 Committable suggestion
🤖 Prompt for AI Agents