LexBench-Web-Fetch / tools /test_review_scope.py
msq6's picture
Finalize the 530-task contract and verify the original 64 case changes
7dfdbfb verified
Raw History Blame
2.97 kB
"""Guard the bounded PR scope and honest source-observation metadata."""
from pathlib import Path
from collections import Counter
import json
import unittest
ROOT = Path(__file__).resolve().parents[1]
REVISIONS = ROOT / 'definitions/annotation-revisions'
class ReviewScopeTests(unittest.TestCase):
def setUp(self):
self.rationale = json.loads((REVISIONS / 'primary-content-20261103-rationale.json').read_text())
self.provenance = json.loads((REVISIONS / 'primary-content-20261103-provenance.json').read_text())
self.keys = {(c['suite'], c['case_id']) for c in self.rationale['changes']}
def test_scope_and_population(self):
self.assertEqual(len(self.keys), 64)
self.assertEqual(Counter(s for s, _ in self.keys),
{'articles': 32, 'access-restrictions': 14, 'dynamic-content': 6, 'popular-sites': 12})
population = json.loads((ROOT / 'definitions/populations/primary-content-20261103.json').read_text())
self.assertLessEqual(self.keys, {(c['suite'], c['id']) for c in population['cases']})
def test_observations_cover_only_authorized_changes(self):
rows = self.provenance['current_source_observations']
self.assertEqual(len(rows), 64)
self.assertEqual({(c['suite'], c['case_id']) for c in rows}, self.keys)
for row in rows:
self.assertFalse(row['browser_visibility_verified'])
self.assertFalse(row['historical_capture'])
self.assertEqual(row['removed_anchor_count'],
len(row['removed_anchor_ids_found_in_response']) +
len(row['removed_anchor_ids_not_found_in_response']))
reviews = self.provenance['current_source_reviews']
self.assertEqual(len(reviews), 64)
self.assertEqual({(r['suite'], r['case_id']) for r in reviews}, self.keys)
for review in reviews:
self.assertIn((review['suite'], review['case_id']), self.keys)
self.assertFalse(review['raw_capture_published'])
self.assertTrue(review['limitations'])
def test_authored_content_counterexamples_remain_required(self):
expected = {
'dynamic-096-ar-real-cnn-world': ['phase1-stable-f25f4853e0d1'],
'article-025': ['stable-7'], 'article-095': ['stable-21'],
'article-027': ['stable-28'], 'article-028': ['stable-16'],
'article-066': ['stable-37'], 'article-067': ['stable-12'],
'article-076': ['stable-8'],
'article-093': ['stable-' + str(i) for i in range(20, 26)],
}
for case in self.rationale['changes']:
if case['case_id'] not in expected:
continue
diff = next(d for d in case['changes'] if d['path'] == '/acceptance_contract/stable_text_anchors')
retained = {a['id'] for a in diff['after']}
self.assertLessEqual(set(expected[case['case_id']]), retained)