Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions openverifiablellm/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ def verify_preprocessing(
actual=reproduced_manifest.get("preprocessing_version"),
detail="Preprocessing version tag",
)

if "chunk_size_bytes" in manifest:
_check_field(
report,
Expand All @@ -601,6 +602,14 @@ def verify_preprocessing(
actual=reproduced_manifest.get("chunk_size_bytes"),
detail="Merkle chunk size used during preprocessing",
)
else:
report.add(
CheckResult(
name="manifest_chunk_size_bytes",
status=CheckStatus.SKIP,
detail="Field absent from manifest (older version)",
)
)
else:
report.add(
CheckResult(
Expand Down
24 changes: 24 additions & 0 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,3 +316,27 @@ def test_export_and_load_merkle_proof(tmp_path):
chunk_data=chunk,
expected_root=root,
)


def test_extract_text_from_xml_malformed_xml(tmp_path, monkeypatch):
import defusedxml.ElementTree as ET

malformed_xml_content = """<?xml version="1.0"?>
<mediawiki>
<page>
<revision>
<text>Hello [[Malformed]]
</revision>
</page>
</mediawiki>
"""

input_file = tmp_path / "simplewiki-20260201-pages-malformed.xml"

with open(input_file, "w", encoding="utf-8") as f:
f.write(malformed_xml_content)

monkeypatch.chdir(tmp_path)

with pytest.raises(ET.ParseError):
utils.extract_text_from_xml(input_file)
3 changes: 2 additions & 1 deletion tests/test_verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,10 +367,11 @@ def setUp(self):

def test_merkle_checks_are_skipped(self):
r = verify_preprocessing(self.dump, project_root=self.tmp)
for name in ("raw_merkle_root", "processed_merkle_root"):
for name in ("raw_merkle_root", "processed_merkle_root", "manifest_chunk_size_bytes"):
c = next((x for x in r.checks if x.name == name), None)
self.assertIsNotNone(c, f"check '{name}' not found")
self.assertEqual(c.status, CheckStatus.SKIP)
self.assertIn("Field absent from manifest (older version)", c.detail)

def test_other_checks_still_pass(self):
r = verify_preprocessing(self.dump, project_root=self.tmp)
Expand Down
Loading