Files
MeanField/reports/verify_archive.py
Emily Boudreaux e7e53ce682 Consolidate numerical research and preserve a reproducible handoff
Document the baseline, hypotheses, measured results, failed approaches,
current policy defaults, and remaining rotating n=3 and virial limitations.
Include the authoritative LaTeX report, Pandoc-generated Markdown, compiled
PDF, source provenance, branch decisions, and consolidation validation.

Organize raw results and miscellaneous artifacts under working/ without
deleting them; version the directory guide, relocation hashes, archive
verifier, and report build/conversion checks. Keep build caches at their
original paths and clearly distinguish retained binaries from the validated
research build. Preserve experimental policies without promoting failed
trials to defaults.
2026-09-20 09:10:27 -04:00

46 lines
1.9 KiB
Python

#!/usr/bin/env python3
"""Verify preserved artifacts against the original relocation inventory."""
from pathlib import Path
import argparse
import hashlib
import json
import os
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--repository', type=Path,
default=Path(__file__).resolve().parents[1])
args = parser.parse_args()
records = json.loads((Path(__file__).resolve().parent /
'archive/move_manifest.json').read_text())
original = Path('/Users/tboudreaux/Programming/4DSTAR/MeanField')
failures, count, size = [], 0, 0
for move in records['moves']:
destination = args.repository / Path(move['destination']).relative_to(original)
for item in move['entries']:
path = destination if item['path'] == '.' else destination / item['path']
if item['kind'] == 'directory':
good = path.is_dir() and not path.is_symlink()
elif item['kind'] == 'symlink':
good = path.is_symlink() and os.readlink(path) == item['target']
else:
count += 1
size += item['bytes']
good = path.is_file() and not path.is_symlink()
if good:
digest = hashlib.sha256()
with path.open('rb') as stream:
for block in iter(lambda: stream.read(1024 * 1024), b''):
digest.update(block)
good = path.stat().st_size == item['bytes'] and digest.hexdigest() == item['sha256']
if not good:
failures.append(str(path))
print(json.dumps({'files': count, 'bytes': size, 'failed_paths': failures,
'all_preserved': not failures}, indent=2))
raise SystemExit(bool(failures))
if __name__ == '__main__':
main()