def _mf_no_dup(pairs): out = {} for k, v in pairs: if k in out: raise ValueError(f"Duplicate JSON key in manifest.json: {k!r}") out[k] = v return out def _mf_no_nan(tok): raise ValueError(f"Non-standard JSON constant in manifest.json: {tok!r}") def _mf_finite_float(tok): v = float(tok) if not _math.isfinite(v): raise ValueError(f"Non-finite JSON float overflow in manifest.json: {tok!r}") return v mf = json.loads(manifest_path.read_text(encoding="utf-8"), object_pairs_hook=_mf_no_dup, parse_constant=_mf_no_nan, parse_float=_mf_finite_float) is_pub = (root / ".openislet_public_bundle").exists() or "public_export_file_inventory" in mf errs = manifest_integrity_errors(root, mf, public=is_pub) if errs: raise ValueError(f"Manifest snapshot integrity failed ({len(errs)} error(s)): {errs[:5]}") n_verified = len(mf.get("public_export_file_inventory") or mf.get("artifacts") or {}) return {"passed": True, "verified_files": n_verified, "public_bundle_mode": is_pub} if __name__ == "__main__": import argparse parser = argparse.ArgumentParser(description="Generate release manifest and optional public bundle.") parser.add_argument("--export-public-bundle", type=str, default=None, help="Directory to export rights-aware public bundle") parser.add_argument( "--regenerate-repo-manifest", action="store_true", help="Also regenerate in-repo manifest.json and JSONL aliases when --export-public-bundle is specified", ) parser.add_argument( "--verify-public-bundle", action="store_true", help="Verify pinned public bundle file hashes and inventory against manifest.json without requiring private caches", ) args = parser.parse_args() if args.verify_public_bundle or ( not args.export_public_bundle and not args.regenerate_repo_manifest and ((ROOT / ".openislet_public_bundle").exists() or not (ROOT / "docs" / "PROJECT-DECISIONS-LOG.md").exists()) ): res = verify_public_bundle_snapshot(ROOT) print( f"Verified {res['verified_files']} pinned artifacts against manifest.json " f"(public_bundle_mode={res['public_bundle_mode']}). " "Note: Full manifest regeneration from raw dossiers requires the private audit cache " "(data/dossiers/*.json, docs/PROJECT-DECISIONS-LOG.md)." ) else: if not args.export_public_bundle or args.regenerate_repo_manifest or not (ROOT / "manifest.json").exists(): main() if args.export_public_bundle: exported_files = export_public_bundle(Path(args.export_public_bundle)) print(f"Exported {len(exported_files)} allowlisted files to {args.export_public_bundle}")