"""Post-hoc version 2: accept equivalent, source-grounded scope statements. The frozen manifest and verify.py remain version 1. This separate predicate is only a sensitivity analysis of every retained answer, not a replacement result. """ import json import sys import verify as frozen SCOPE_FAILURE = 'sources.scope: quotation does not cover the required boundary' # Each sentence occurs in the frozen docs and explicitly limits generalization. EQUIVALENT_SCOPE_STATEMENTS = ( 'This task demonstrates how to perform a complete experiment; it does not establish that indexes help agents in general.', 'The result does not establish equivalence, demonstrate an improvement, or show that an index is unnecessary.', 'The observations do not establish that indexes help or harm agents in other environments.', ) def verify(output): verdict = frozen.verify(output) reasons = verdict['reason'].split('; ') if verdict['passed'] or SCOPE_FAILURE not in reasons: return verdict text = output.strip() if text.startswith('```json\n') and text.endswith('\n```'): text = text[8:-4] answer = json.loads(text, object_pairs_hook=frozen.unique_object) sources = answer.get('sources', []) if not isinstance(sources, list): return verdict scope = [source for source in sources if isinstance(source, dict) and source.get('claim') == 'scope'] if len(scope) != 1: return verdict quote = scope[0].get('quote') if scope[0].get('file') != 'production/full.md' or not isinstance(quote, str): return verdict if quote not in (frozen.ROOT / 'baseline/production/full.md').read_text(): return verdict if not any(sentence in quote for sentence in EQUIVALENT_SCOPE_STATEMENTS): return verdict # Preserve every other version-1 failure; never repair a malformed answer, # missing fact, forged quotation, or unrelated policy failure. remaining = [reason for reason in reasons if reason != SCOPE_FAILURE] return { 'passed': not remaining, 'reason': '; '.join(remaining) if remaining else 'Complete handoff accepted with an equivalent source-grounded scope quotation (post-hoc verifier v2).', 'metrics': {'failedChecks': len(remaining)}, } if __name__ == '__main__': raw = sys.stdin.buffer.read(2_000_001) if len(raw) > 2_000_000: raise ValueError('Verifier input limit exceeded') print(json.dumps(verify(json.loads(raw)['output']), allow_nan=False))