Repository navigation
feat: add canonical deterministic directory-level hashing #7
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,125 @@ | ||||||||||||||||||||
| import pytest | ||||||||||||||||||||
| from pathlib import Path | ||||||||||||||||||||
| from openverifiablellm.utils import compute_directory_hash | ||||||||||||||||||||
|
||||||||||||||||||||
| import hashlib | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
||||||||||||||||||||
| def test_directory_hash_is_deterministic(tmp_path): | ||||||||||||||||||||
| # Create files | ||||||||||||||||||||
| file1 = tmp_path / "a.txt" | ||||||||||||||||||||
| file2 = tmp_path / "b.txt" | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
Comment on lines
+6
to
+10
|
||||||||||||||||||||
| def test_directory_hash_is_deterministic(tmp_path): | |
| # Create files | |
| file1 = tmp_path / "a.txt" | |
| file2 = tmp_path / "b.txt" | |
| # --------------- compute_directory_hash tests ------------------------------------ | |
| def test_directory_hash_is_deterministic(tmp_path): | |
| # Create files | |
| file1 = tmp_path / "a.txt" | |
| file2 = tmp_path / "b.txt" |
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.
🧩 Analysis chain
🏁 Script executed:
Repository: AOSSIE-Org/OpenVerifiableLLM
Length of output: 2693
🏁 Script executed:
rg -n 'compute_directory_hash|is_file|is_symlink|symlink' openverifiablellm/utils.py -A 2 -B 1Repository: AOSSIE-Org/OpenVerifiableLLM
Length of output: 325
🏁 Script executed:
Repository: AOSSIE-Org/OpenVerifiableLLM
Length of output: 100
🏁 Script executed:
rg -n 'symlink|test.*hash' tests/ -A 3 -B 1Repository: AOSSIE-Org/OpenVerifiableLLM
Length of output: 1843
🏁 Script executed:
Repository: AOSSIE-Org/OpenVerifiableLLM
Length of output: 3503
🏁 Script executed:
Repository: AOSSIE-Org/OpenVerifiableLLM
Length of output: 276
🏁 Script executed:
rg -n 'is_symlink|symlink' tests/test_directory_hash.pyRepository: AOSSIE-Org/OpenVerifiableLLM
Length of output: 54
Exclude symlinked files from directory hashing.
At line 151,
is_file()returnsTruefor symlinks to files, allowing content outside the target directory to be included in the hash. This breaks deterministic reproducibility across systems where symlinks may reference different paths or external content.The function currently provides no test coverage for symlink behavior.
♻️ Proposed fix
for f in directory.rglob("*"): + if f.is_symlink(): + continue if not f.is_file(): continue📝 Committable suggestion
🤖 Prompt for AI Agents