Research-Stack/5-Applications/hutter_prize/scripts/build_review_packet.py
Devin AI 0c9efac330 chore(consolidation): integrate E8Sidon stack (PRs #79 #80 #81 #89) into one PR
Squash the four overlapping feature branches into a single change set against
main, eliminating cross-PR merge conflicts and the duplicated CI-fix scripts.

What this brings in (merge order #79 -> #80 -> #81 -> #89):
- #79 refactor(infra): shared utilities (4-Infrastructure/lib/*: q16, hashing,
  jsonl, fraction_utils) + the scripts/math-first/* validators that the
  math-check CI requires.
- #80 feat(lean): Semantics.E8Sidon (1025 lines) -- Eisenstein coefficient
  identity E4^2 = E8 and the Sidon framework. E4_sq_eq_E8_coeff is fully proved
  (all Fourier-coefficient extraction machine-checked); the single residual gap
  is pinned to E4_sq_eq_E8_qExpansion (Mathlib lacks the valence formula /
  dim M8 = 1). 4 sorries + 1 axiom (e8_additive_completeness), all TODO(lean-port).
- #81 refactor(lean): Float-free FixedPoint core (integer-only sqrt/log2/expNeg).
  E8Sidon.lean kept at #80's final 1025-line version (the #81 intermediate
  438-line copy was overridden by merge order).
- #89 feat(lean): Semantics.RRC.PolyFactorIdentity -- short-sleeve polynomial
  detection at the zerocopy limb boundary; now imports Semantics.E8Sidon for
  sigma3/sigma7/convolutionLHS (single source of truth) instead of inlining them.

Conflict resolution:
- flake.nix -> canonical rs-surface removal (Garnix shutdown).
- scripts/math-first/* -> byte-identical across branches, clean.
- .cursorrules / AGENTS.md -> unified; baselines + sorry inventory refreshed.

Verification:
- lake build (default aggregator): 3573 jobs, 0 errors.
- lake build Semantics.RRC.PolyFactorIdentity (E8Sidon + FixedPoint + PolyFactor):
  3655 jobs, 0 errors. Witnesses verified (sigma7 4 = 16513, convolutionLHS 6 = 2350).
- Python tests: 68/68 pass.

Note: the "Workers Builds: researchstack" check is a preexisting external
Cloudflare build unrelated to this change (no branch touches 4-Infrastructure/cloudflare/).

Build: 3573 jobs (default), 3655 jobs (narrow), 0 errors
Co-Authored-By: Allaun Silverfox <bigdataiscoming+9i37y6j2@protonmail.com>
2026-06-16 02:01:31 +00:00

115 lines
3.4 KiB
Python

#!/usr/bin/env python3
"""Build a deterministic outside-review packet with copied files and a manifest."""
from __future__ import annotations
import argparse
import hashlib
import json
import shutil
from pathlib import Path
import sys
sys.path.insert(0, str(Path(__file__).resolve().parents[3] / "4-Infrastructure"))
from lib.hashing import sha256_file
DEFAULT_PACKET = [
"PLAIN_LANGUAGE_OVERVIEW.md",
"README.md",
"DERIVATION_SPEC.md",
"TERNARY_VM_SPEC.md",
"AUDITABILITY_IP_BOUNDARY.md",
]
DEFAULT_REVIEW_QUESTIONS = [
"Is the current technical claim legible?",
"Is the current audit surface strong enough for the claim being made?",
"Are there obvious cheating paths not yet closed?",
"Are there obvious wording or trust problems that would confuse a careful reader?",
"What is the next smallest artifact that would materially improve review?",
]
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument(
"--root",
default=".",
help="Repo root used to resolve packet files. Defaults to the current directory.",
)
parser.add_argument(
"--out-dir",
required=True,
help="Directory where the review packet should be created.",
)
parser.add_argument(
"--label",
default="default_review_packet",
help="Short label for the packet manifest. Defaults to default_review_packet.",
)
parser.add_argument(
"--include",
action="append",
default=[],
help="Extra relative file path to include in addition to the default packet.",
)
return parser.parse_args()
def main() -> int:
args = parse_args()
root = Path(args.root).resolve()
out_dir = Path(args.out_dir).resolve()
out_dir.mkdir(parents=True, exist_ok=True)
packet_files: list[str] = []
for rel in DEFAULT_PACKET + args.include:
if rel not in packet_files:
packet_files.append(rel)
copied = []
packet_dir = out_dir / "packet"
packet_dir.mkdir(parents=True, exist_ok=True)
for rel in packet_files:
source = root / rel
if not source.is_file():
raise FileNotFoundError(f"Packet source missing: {source}")
destination = packet_dir / rel
destination.parent.mkdir(parents=True, exist_ok=True)
shutil.copy2(source, destination)
copied.append(
{
"path": rel,
"sha256": sha256_file(destination),
}
)
packet_fingerprint = hashlib.sha256(
json.dumps(
{
"label": args.label,
"packet_files": copied,
"default_review_questions": DEFAULT_REVIEW_QUESTIONS,
},
sort_keys=True,
).encode("utf-8")
).hexdigest()
manifest = {
"schema": "hutter_review_packet_manifest_v1",
"label": args.label,
"packet_dir_name": packet_dir.name,
"packet_files": copied,
"default_review_questions": DEFAULT_REVIEW_QUESTIONS,
"packet_fingerprint": packet_fingerprint,
}
manifest_path = out_dir / "review_packet.manifest.json"
manifest_path.write_text(json.dumps(manifest, indent=2) + "\n", encoding="utf-8")
print(json.dumps(manifest, indent=2))
return 0
if __name__ == "__main__":
raise SystemExit(main())