record-verified-main-consolidation-and-recoverable-branch-cleanup
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
"""Save final consolidation evidence; no writes outside this integration clone."""
|
||||
from datetime import datetime, timezone
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
|
||||
ROOT = Path('/home/qishizhe/digital-drosophila-main-integration-20261001')
|
||||
AUDIT = ROOT / 'registry/branch-consolidation-20261001'
|
||||
|
||||
|
||||
def git(*args, cwd=ROOT):
|
||||
return subprocess.check_output(['git', *args], cwd=cwd, text=True).strip()
|
||||
|
||||
|
||||
def main():
|
||||
assert Path.cwd().resolve() == ROOT
|
||||
assert not (AUDIT / 'completion.json').exists()
|
||||
plan = json.loads((AUDIT / 'plan.json').read_text())
|
||||
cleanup = json.loads((AUDIT / 'remote-cleanup.json').read_text())
|
||||
integrity = json.loads((AUDIT / 'source-protection-final.json').read_text())
|
||||
assert cleanup['pass_all'] and integrity['status'] == 'PASS'
|
||||
refs = git('ls-remote', '--symref', 'origin').splitlines()
|
||||
assert 'ref: refs/heads/main\tHEAD' in refs
|
||||
heads = [line for line in refs if '\trefs/heads/' in line]
|
||||
assert heads == [cleanup['main_commit'] + '\trefs/heads/main']
|
||||
tag_refs = {line.split('\t')[1]: line.split('\t')[0] for line in refs
|
||||
if '\trefs/tags/' in line}
|
||||
assert len(tag_refs) == 14
|
||||
for branch, sha in plan['branches'].items():
|
||||
tag = plan['archive_tag_prefix'] + branch.removeprefix('codex/')
|
||||
assert tag_refs['refs/tags/' + tag + '^{}'] == sha
|
||||
git('merge-base', '--is-ancestor', sha, 'HEAD')
|
||||
source_trees = {}
|
||||
expected = {
|
||||
'/data/digital-drosophila': ('codex/lif-author-semantics-lab', '09187e4d4d67badf1b418c5f211258ca5d8fb328'),
|
||||
'/home/qishizhe/digital-drosophila-v100-acceleration': ('codex/v100-conditioning-acceleration', '018f038c7857c7e0236dd7408a680458520d92ce'),
|
||||
}
|
||||
for path, (branch, sha) in expected.items():
|
||||
actual = dict(branch=git('branch', '--show-current', cwd=path),
|
||||
head=git('rev-parse', 'HEAD', cwd=path),
|
||||
status=git('status', '--porcelain', cwd=path))
|
||||
assert actual == dict(branch=branch, head=sha, status='')
|
||||
source_trees[path] = actual
|
||||
guard = json.loads(subprocess.check_output(['python3', '-B', 'tools/repo_guard.py'], text=True))
|
||||
assert guard['pass']
|
||||
report = dict(schema='branch-consolidation-completion-v1', status='PASS',
|
||||
created_utc=datetime.now(timezone.utc).isoformat(), integration_commit=cleanup['main_commit'],
|
||||
remote_default='main', remote_branches=1, archived_tags=7,
|
||||
removed_remote_branch_refs=7, local_branches_preserved=True,
|
||||
all_old_tips_recoverable_and_ancestors_of_main=True, source_worktrees=source_trees,
|
||||
source_protection=integrity, staged_publication_guard=guard,
|
||||
model_or_science_changes=False, scientific_execution=False,
|
||||
lfs_objects_deleted=False, lfs_payloads_reuploaded=False,
|
||||
lfs_verification_scope='Original pointers preserved; authenticated availability checked. Prior fresh-download hash verification receipts remain unchanged.',
|
||||
final_receipt_publication='This report is committed after the integration commit; containing Git commit is the receipt publication revision.')
|
||||
with (AUDIT / 'completion.json').open('x') as f:
|
||||
json.dump(report, f, indent=2, sort_keys=True)
|
||||
f.write('\n')
|
||||
files = sorted(p for p in AUDIT.iterdir() if p.is_file())
|
||||
files += sorted((ROOT / 'tools/branch-consolidation').glob('*.py'))
|
||||
files += [ROOT / 'docs/30-reproducibility/main-restore.md', ROOT / 'docs/40-operations/branches-20261001.md']
|
||||
with (AUDIT / 'SHA256SUMS').open('x') as f:
|
||||
for path in files:
|
||||
f.write(hashlib.sha256(path.read_bytes()).hexdigest() + ' ' + str(path.relative_to(ROOT)) + '\n')
|
||||
print(json.dumps(report, indent=2))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user