Research-Stack/5-Applications/tools-scripts/utils/generate_qchem_metadata.py
Devin AI 0639eae30a 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

68 lines
2.6 KiB
Python

# ==============================================================================
# COPYRIGHT NO ONE EVERYWHERE LLC (WYOMING HOLDING COMPANY)
# PROJECT: SOVEREIGN STACK
# This artifact is entirely proprietary and cryptographically proven.
# Open-Source usage requires explicit permission from Brandon Scott Schneider.
# ==============================================================================
# [WARDEN BOUNDARY ENFORCEMENT INJECTED]
import sys
import os
try:
from io_harness_compat import spawn_isolated_process, fetch_network_resource
except ImportError:
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from io_harness_compat import spawn_isolated_process, fetch_network_resource
import json
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[3] / "4-Infrastructure"))
from lib.hashing import sha256_text
# import subprocess (REMOVED BY WARDEN)
BASE_DIR = Path(__file__).parent.parent.resolve()
DATA_FILE = BASE_DIR / "hqw_atomic_combinations.json"
MANIFEST_BIN = BASE_DIR / "scripts" / "file_manifest_builder.py"
MANIFEST_OUT = BASE_DIR / "hqw_atomic_combinations.manifest.json"
METADATA_OUT = BASE_DIR / "hqw_materials_metadata.jsonl"
CHUNK_STORE = BASE_DIR / "hqw_chunks"
def generate_metadata():
print(f"[*] Reading {DATA_FILE}...")
with open(DATA_FILE, 'r') as f:
combinations = json.load(f)
print(f"[*] Generating per-combination metadata...")
with open(METADATA_OUT, 'w') as f:
for comb in combinations:
# Hash the formula + register_bits as a unique key for the combination
# This follows the 'valence as register' metadata requirement
data_str = json.dumps(comb, sort_keys=True)
digest = sha256_text(data_str)
comb['sha256'] = digest
f.write(json.dumps(comb) + "\n")
print(f"[+] Metadata saved to {METADATA_OUT}")
def generate_manifest():
print(f"[*] Building file-level manifest using file_manifest_builder.py...")
cmd = [
"python3", str(MANIFEST_BIN), "build",
"--input", str(DATA_FILE),
"--manifest-out", str(MANIFEST_OUT),
"--chunk-store", str(CHUNK_STORE)
]
result = subprocess.run(cmd, capture_output=True, text=True)
if result.returncode == 0:
print(f"[+] Manifest saved to {MANIFEST_OUT}")
print(f"[*] Chunk store created in {CHUNK_STORE}")
else:
print(f"[!] Manifest build failed: {result.stderr}")
if __name__ == "__main__":
if not DATA_FILE.exists():
print(f"[!] Error: {DATA_FILE} not found. Run the HQW simulation first.")
else:
generate_metadata()
generate_manifest()