"""Write and verify two staging batches from original synthetic fixtures.""" import argparse import hashlib import json from pathlib import Path import tempfile from quarantine import validate_batch, write_batch ROOT = Path(__file__).resolve().parent def record(): reports = {} with tempfile.TemporaryDirectory(prefix='mlops-validation-') as temporary: for name in ('events.jsonl', 'valid-events.jsonl'): raw = (ROOT / name).read_bytes() target = Path(temporary) / name manifest = write_batch(validate_batch(raw), target) assert (target / 'source.bin').read_bytes() == raw assert all(hashlib.sha256((target / file).read_bytes()).hexdigest() == digest for file,digest in manifest['files'].items()) reports[name] = manifest return {'mode': 'Local synthetic JSON Lines validation and real staging writes; no training or model', 'files': {name: hashlib.sha256((ROOT / name).read_bytes()).hexdigest() for name in ('quarantine.py', 'inspect_dataset.py', 'vendor/availability.py', 'events.jsonl', 'valid-events.jsonl')}, 'batches': reports} def main(): parser = argparse.ArgumentParser() parser.add_argument('--save', type=Path) parser.add_argument('--check', action='store_true') args = parser.parse_args() result = record() if args.check and result != json.loads((ROOT / 'result.json').read_text()): raise SystemExit('validation results or source bindings differ') if args.save: args.save.write_text(json.dumps(result, indent=2)+'\n') print('Synthetic event batches; original bytes retained, no automatic repair') for name, row in result['batches'].items(): print(f"{name}: {row['status']}; source={row['source_lines']}; accepted={row['accepted']}; " f"quarantined={row['quarantined']}; training_file={row['training_file']}") print('The valid fixture is a separate reference batch, not the dirty batch with bad rows silently removed.') if __name__ == '__main__': main()