-
-
Notifications
You must be signed in to change notification settings - Fork 28
Add experiments for preprocessing determinism and Merkle verification #66
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
base: main
Are you sure you want to change the base?
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,100 @@ | ||||||||||||||||||||||||||||||||||||||||||
| ## Experiments | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| This directory contains small reproducible experiments used to validate assumptions behind the **OpenVerifiableLLM deterministic training pipeline**. | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| The goal of these experiments is to verify that: | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| - preprocessing produces deterministic outputs | ||||||||||||||||||||||||||||||||||||||||||
| - dataset tampering can be detected using Merkle roots | ||||||||||||||||||||||||||||||||||||||||||
| - small reproducible datasets can be used for testing the pipeline | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| These experiments are **not part of the main pipeline**. They are intended for testing ideas and validating reproducibility guarantees. | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| --- | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| ## Directory Structure | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| experiments/ | ||||||||||||||||||||||||||||||||||||||||||
| │ | ||||||||||||||||||||||||||||||||||||||||||
| ├── data_subset/ | ||||||||||||||||||||||||||||||||||||||||||
| │ ├── sample_wiki_generate.py | ||||||||||||||||||||||||||||||||||||||||||
| │ ├── sample_wiki.xml.bz2 | ||||||||||||||||||||||||||||||||||||||||||
| │ └── tampered_sample_wiki.xml.bz2 | ||||||||||||||||||||||||||||||||||||||||||
| │ | ||||||||||||||||||||||||||||||||||||||||||
| ├── preprocessing_determinism/ | ||||||||||||||||||||||||||||||||||||||||||
| │ └── test_preprocessing.py | ||||||||||||||||||||||||||||||||||||||||||
| │ | ||||||||||||||||||||||||||||||||||||||||||
| ├── merkle_verification/ | ||||||||||||||||||||||||||||||||||||||||||
| │ └── test_merkle.py | ||||||||||||||||||||||||||||||||||||||||||
| │ | ||||||||||||||||||||||||||||||||||||||||||
| └── README.md | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| --- | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| ## Experiments includes | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| ### 1. Preprocessing Determinism | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| Verifies that running the preprocessing pipeline multiple times on the same dataset produces identical outputs. | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| The experiment compares: | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| - `processed_sha256` | ||||||||||||||||||||||||||||||||||||||||||
| - `processed_merkle_root` | ||||||||||||||||||||||||||||||||||||||||||
| - `environment_hash` | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| If these values match across runs, the preprocessing step is deterministic. | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| Run: | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||||||||||
| python -m experiments.preprocessing_determinism.test_preprocessing experiments/data_subset/sample_wiki.xml.bz2 | ||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| **Expected Results** - | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||||||||||
| Run 1 hash: ... | ||||||||||||||||||||||||||||||||||||||||||
| Run 2 hash: ... | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| Deterministic preprocessing confirmed 🎉 | ||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| ### 2. Merkle Root Tamper Detection | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| Tests whether dataset tampering is detected by comparing Merkle roots. | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| Two datasets are used: | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| sample_wiki.xml.bz2 (original) | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| tampered_sample_wiki.xml.bz2 (modified) | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| The experiment compares: | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| raw_merkle_root | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| processed_merkle_root | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+69
to
+78
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Format list items consistently using Markdown syntax. Lines 69-78 are missing Markdown list formatting. They should use 📝 Proposed fix Two datasets are used:
-sample_wiki.xml.bz2 (original)
+- `sample_wiki.xml.bz2` (original)
-tampered_sample_wiki.xml.bz2 (modified)
+- `tampered_sample_wiki.xml.bz2` (modified)
The experiment compares:
-raw_merkle_root
+- `raw_merkle_root`
-processed_merkle_root
+- `processed_merkle_root`📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||
| If either root differs, the tampering is successfully detected. | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| Run: | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||||||||||
| python -m experiments.merkle_verification.test_merkle --path1 experiments/data_subset/sample_wiki.xml.bz2 --path2 experiments/data_subset/tampered_sample_wiki.xml.bz2 | ||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| **Expected Results** - | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||||||||||
| Run 1 RAW Merkle root: ... | ||||||||||||||||||||||||||||||||||||||||||
| Run 2 RAW Merkle root: ... | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| Tampering detected 🎉 | ||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| ### 3. Dataset Subset | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| The data_subset directory contains a minimal Wikipedia XML example used for quick experimentation without downloading full dumps. | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| This allows experiments to run quickly while still exercising the preprocessing pipeline. | ||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,20 @@ | ||||||||||||
| import bz2 | ||||||||||||
|
|
||||||||||||
| # To make this tampered I deleted e of online | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor typo in comment. 📝 Proposed fix-# To make this tampered I deleted e of online
+# To make this tampered, I deleted 'e' from "online"📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||
|
|
||||||||||||
| xml_content = """<?xml version="1.0" encoding="UTF-8"?> | ||||||||||||
| <mediawiki> | ||||||||||||
| <page> | ||||||||||||
| <revision> | ||||||||||||
| <text> | ||||||||||||
| Hello <ref>citation</ref> world. | ||||||||||||
| This is [[Python|programming language]] | ||||||||||||
| {{Wikipedia }}is a free onlin encyclopedia. | ||||||||||||
| </text> | ||||||||||||
| </revision> | ||||||||||||
| </page> | ||||||||||||
| </mediawiki> | ||||||||||||
| """ | ||||||||||||
|
|
||||||||||||
| with bz2.open("experiments/data_subset/tampered_sample_wiki.xml.bz2", "wt", encoding="utf-8") as f: | ||||||||||||
| f.write(xml_content) | ||||||||||||
|
Comment on lines
+19
to
+20
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Wrap file-writing logic in an The script executes file I/O at module import time. This can cause unintended side effects if the module is imported elsewhere. Adding a main guard is a best practice for executable scripts. ♻️ Proposed fix-with bz2.open("experiments/data_subset/tampered_sample_wiki.xml.bz2", "wt", encoding="utf-8") as f:
- f.write(xml_content)
+if __name__ == "__main__":
+ with bz2.open("experiments/data_subset/tampered_sample_wiki.xml.bz2", "wt", encoding="utf-8") as f:
+ f.write(xml_content)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,63 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import argparse | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import json | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import logging | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from pathlib import Path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from openverifiablellm.utils import extract_text_from_xml | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| logger = logging.getLogger(__name__) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Experiment: Tamper Detection via Merkle Root Comparison | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Run with: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| python -m experiments.merkle_verification.test_merkle --path1 experiments/data_subset/sample_wiki.xml.bz2 --path2 experiments/data_subset/tampered_sample_wiki.xml.bz2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MANIFEST_PATH = Path("data/dataset_manifest.json") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def run(path1): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """Run preprocessing and return processed Merkle root.""" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| extract_text_from_xml(path1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #read genertaed manifest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix typo: "genertaed" → "generated". 📝 Proposed fix- `#read` genertaed manifest
+ # Read generated manifest📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| with MANIFEST_PATH.open() as f: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| manifest = json.load(f) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "raw_merkle_root": manifest["raw_merkle_root"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "processed_merkle_root": manifest["processed_merkle_root"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
tani-dubey marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if __name__ == "__main__": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| parser= argparse.ArgumentParser( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description= "Test tamper detection using Merkle root" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| parser.add_argument("--path1",required=True,help="Original dataset") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| parser.add_argument("--path2",required=True,help="Tampered dataset") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| args= parser.parse_args() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| logging.basicConfig( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| level= logging.INFO, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| format="%(levelname)s - %(message)s" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+34
to
+46
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Inconsistent spacing around Several lines have inconsistent spacing around ✏️ Proposed fix- parser= argparse.ArgumentParser(
- description= "Test tamper detection using Merkle root"
+ parser = argparse.ArgumentParser(
+ description="Test tamper detection using Merkle root"
)
- parser.add_argument("--path1",required=True,help="Original dataset")
- parser.add_argument("--path2",required=True,help="Tampered dataset")
+ parser.add_argument("--path1", required=True, help="Original dataset")
+ parser.add_argument("--path2", required=True, help="Tampered dataset")
- args= parser.parse_args()
+ args = parser.parse_args()
logging.basicConfig(
- level= logging.INFO,
+ level=logging.INFO,
format="%(levelname)s - %(message)s"
)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| root1 = run(args.path1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| root2 = run(args.path2) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| print(f"\nRun 1 RAW Merkle root: {root1['raw_merkle_root']}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| print(f"Run 2 RAW Merkle root: {root2['raw_merkle_root']}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| print(f"\nRun 1 processed Merkle root: {root1['processed_merkle_root']}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| print(f"Run 2 processed Merkle root: {root2['processed_merkle_root']}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| root1["raw_merkle_root"] != root2["raw_merkle_root"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| or root1["processed_merkle_root"] != root2["processed_merkle_root"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| print("\nTampering detected 🎉 (Merkle roots differ)") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| print("\nUnexpected result ❌ (Merkle roots identical)") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,57 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import json | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import logging | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import sys | ||||||||||||||||||||||||||||||||||||||||||||||||||
| from pathlib import Path | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| from openverifiablellm.utils import extract_text_from_xml | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| logger = logging.getLogger(__name__) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| Experiment to test Deterministic preprocessing, by compairing generated hash on 2 runs. | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix typo: "compairing" → "comparing". 📝 Proposed fix-Experiment to test Deterministic preprocessing, by compairing generated hash on 2 runs.
+Experiment to test deterministic preprocessing by comparing generated hash on 2 runs.📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| Run with: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| python -m experiments.preprocessing_determinism.test_preprocessing experiments/data_subset/sample_wiki.xml.bz2 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| MANIFEST_PATH = Path("data/dataset_manifest.json") | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| def run(input_path): | ||||||||||||||||||||||||||||||||||||||||||||||||||
| # Run preprocessing | ||||||||||||||||||||||||||||||||||||||||||||||||||
| extract_text_from_xml(input_path) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| #read genertaed manifest | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix typo: "genertaed" → "generated". 📝 Proposed fix- `#read` genertaed manifest
+ # Read generated manifest📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||
| with MANIFEST_PATH.open() as f: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| manifest = json.load(f) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| return { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "processed_sha256": manifest["processed_sha256"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "processed_merkle_root": manifest["processed_merkle_root"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "environment_hash": manifest["environment_hash"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+19
to
+30
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical: Manifest is never written—experiment will fail or use stale data.
🐛 Proposed fix def run(input_path):
# Run preprocessing
- extract_text_from_xml(input_path)
+ extract_text_from_xml(input_path, write_manifest=True)
- `#read` genertaed manifest
+ # Read generated manifest
with MANIFEST_PATH.open() as f:
manifest = json.load(f)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| if __name__ == "__main__": | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| if len(sys.argv) < 2: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| print("Usage: python -m experiments.preprocessing_determinism.test_preprocessing <input_dump>") | ||||||||||||||||||||||||||||||||||||||||||||||||||
| sys.exit(1) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| logging.basicConfig( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| level=logging.INFO, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| format="%(levelname)s - %(message)s" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+39
to
+42
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Fix inconsistent indentation. The arguments to 📝 Proposed fix logging.basicConfig(
- level=logging.INFO,
- format="%(levelname)s - %(message)s"
+ level=logging.INFO,
+ format="%(levelname)s - %(message)s"
)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| result1= run(sys.argv[1]) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| result2= run(sys.argv[1]) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+44
to
+45
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Add spaces around assignment operators for consistency. Minor style: PEP 8 recommends spaces around ✏️ Proposed fix- result1= run(sys.argv[1])
- result2= run(sys.argv[1])
+ result1 = run(sys.argv[1])
+ result2 = run(sys.argv[1])📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| print(f"\nRun 1 hash: {result1['processed_sha256']}") | ||||||||||||||||||||||||||||||||||||||||||||||||||
| print(f"Run 2 hash: {result2['processed_sha256']}") | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| result1["processed_sha256"] == result2["processed_sha256"] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| and result1["processed_merkle_root"] == result2["processed_merkle_root"] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| and result1["environment_hash"] == result2["environment_hash"] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ): | ||||||||||||||||||||||||||||||||||||||||||||||||||
| print("\nDeterministic preprocessing confirmed🎉") | ||||||||||||||||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| print("Hash didn't match❌") | ||||||||||||||||||||||||||||||||||||||||||||||||||
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.
Use a top-level heading (h1) as the first line.
The static analysis tool flagged that the first line should be a top-level heading. Change
## Experimentsto# Experiments.📝 Proposed fix
📝 Committable suggestion
🧰 Tools
🪛 markdownlint-cli2 (0.21.0)
[warning] 1-1: First line in a file should be a top-level heading
(MD041, first-line-heading, first-line-h1)
🤖 Prompt for AI Agents