Research-Stack/5-Applications/tools-scripts/utils/generate_monthly_prepost_attestation.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

104 lines
4.2 KiB
Python

#!/usr/bin/env python3
# ==============================================================================
# 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.
# ==============================================================================
import argparse
import json
import sys
from datetime import datetime, timezone
from pathlib import Path
from typing import Any, Dict
sys.path.insert(0, str(Path(__file__).parent))
from rfc3161_stamp import stamp as rfc3161_stamp
sys.path.insert(0, str(Path(__file__).resolve().parents[3] / "4-Infrastructure"))
from lib.hashing import sha256_file
from lib.jsonl import load_json
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(description="Generate monthly PRE/POST accountability attestation package.")
parser.add_argument("--pairing-report", required=True, help="Path to pairing report JSON")
parser.add_argument("--integrity-report", required=True, help="Path to monitor integrity report JSON")
parser.add_argument("--weekly-digest", required=True, help="Path to weekly digest markdown")
parser.add_argument("--pre", required=True, help="Path to pre_records.jsonl")
parser.add_argument("--post", required=True, help="Path to post_records.jsonl")
parser.add_argument("--chain", required=True, help="Path to chain_records.jsonl")
parser.add_argument("--out", required=True, help="Output JSON path")
return parser.parse_args()
def main() -> int:
args = parse_args()
pairing_path = Path(args.pairing_report)
integrity_path = Path(args.integrity_report)
weekly_digest_path = Path(args.weekly_digest)
pre_path = Path(args.pre)
post_path = Path(args.post)
chain_path = Path(args.chain)
out_path = Path(args.out)
pairing = load_json(pairing_path)
integrity = load_json(integrity_path)
attestation: Dict[str, Any] = {
"generated_at_utc": datetime.now(timezone.utc).replace(microsecond=0).isoformat(),
"scope": "monthly_prepost_accountability",
"status": "PASS" if pairing.get("ok") and integrity.get("ok") else "REVIEW_REQUIRED",
"inputs": {
"pairing_report": {
"path": str(pairing_path),
"sha256": sha256_file(pairing_path),
"ok": bool(pairing.get("ok")),
},
"integrity_report": {
"path": str(integrity_path),
"sha256": sha256_file(integrity_path),
"ok": bool(integrity.get("ok")),
},
"weekly_digest": {
"path": str(weekly_digest_path),
"sha256": sha256_file(weekly_digest_path),
},
"pre_records": {
"path": str(pre_path),
"sha256": sha256_file(pre_path),
},
"post_records": {
"path": str(post_path),
"sha256": sha256_file(post_path),
},
"chain_records": {
"path": str(chain_path),
"sha256": sha256_file(chain_path),
},
},
"controls": {
"pre_post_pairing_ratio": pairing.get("pairing_ratio"),
"missing_post_for_pre": pairing.get("missing_post_for_pre", []),
"orphan_post_refs": pairing.get("orphan_post_refs", []),
"coverage_ratio": integrity.get("coverage_ratio"),
"freshness_ratio": integrity.get("freshness_ratio"),
"missing_chains": integrity.get("missing_chains", []),
"stale_chains": integrity.get("stale_chains", []),
},
}
out_path.parent.mkdir(parents=True, exist_ok=True)
out_path.write_text(json.dumps(attestation, indent=2) + "\n", encoding="utf-8")
out_sha256 = sha256_file(out_path)
try:
ts_info = rfc3161_stamp(out_path)
except Exception as exc:
ts_info = {"error": str(exc)}
print(json.dumps({"wrote": str(out_path), "status": attestation["status"], "sha256": out_sha256, "rfc3161": ts_info}, indent=2))
return 0
if __name__ == "__main__":
raise SystemExit(main())