Release v2.14.0: Implement pre-commit preparation & 8-gate drift-blocking verifier (hs-deploy-scripts-sync Gates D1-D8) for push-all-to-git-libre-audio.sh and deploy/sync-vps-repos.sh (Plan #58)
This commit is contained in:
1 parent
6624209f2b
commit
f78cf47e00
39 files changed
+574
-152
No files matched your search
@@ -1,3 +1,3 @@
|
||||
"""hyperstitionstud_io — Shared Common Library for the hyperstitionstud.io workspace (v2.13.0)."""
|
||||
__version__ = "2.13.0"
|
||||
"""hyperstitionstud_io — Shared Common Library for the hyperstitionstud.io workspace (v2.14.0)."""
|
||||
__version__ = "2.14.0"
|
||||
NAMESPACE_URN = "urn:io:hyperstitionstud"
|
||||
@@ -0,0 +1,247 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
hyperstitionstud_io.ci.deploy_scripts_sync (`hs-deploy-scripts-sync`)
|
||||
Pre-Commit Preparation & 8-Gate Drift-Blocking Verifier (`Gates D1-D8`) for the Two Manual Operator
|
||||
Deployment Scripts (`/workspace/push-all-to-git-libre-audio.sh` and `deploy/sync-vps-repos.sh`).
|
||||
|
||||
Wired directly into `.git/hooks/pre-commit`, `version_sync.py`, and `tests/test_core_suite.py` so that
|
||||
`push-all-to-git-libre-audio.sh` (and its tracked mirror `hyperstitionstudio-core/deploy/push-all-to-git-libre-audio.sh`)
|
||||
and `deploy/sync-vps-repos.sh` are always prepared, validated, and staged PRIOR to every commit.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from hyperstitionstud_io import __version__ as CURRENT_VERSION
|
||||
from hyperstitionstud_io.config import load_workspace_config
|
||||
|
||||
|
||||
def _norm_ws_path(p: Path | str, workspace_root: str | Path | None = None) -> str:
|
||||
cfg = load_workspace_config(workspace_root=workspace_root)
|
||||
ws_res = str(cfg.workspace_root.resolve())
|
||||
s = str(Path(p).resolve())
|
||||
if s.startswith(ws_res):
|
||||
return "/workspace" + s[len(ws_res):]
|
||||
return str(p)
|
||||
|
||||
|
||||
def prepare_and_verify_deploy_scripts(
|
||||
workspace_root: str | Path | None = None,
|
||||
target_version: str | None = None,
|
||||
check_only: bool = False,
|
||||
stage: bool = False,
|
||||
) -> dict[str, Any]:
|
||||
"""
|
||||
Prepare and verify `/workspace/push-all-to-git-libre-audio.sh`,
|
||||
`/workspace/hyperstitionstudio-core/deploy/push-all-to-git-libre-audio.sh`,
|
||||
and `/workspace/hyperstitionstudio-core/deploy/sync-vps-repos.sh` across Gates D1-D8.
|
||||
"""
|
||||
cfg = load_workspace_config(workspace_root=workspace_root)
|
||||
ws_root = cfg.workspace_root
|
||||
core_dir = cfg.core_dir
|
||||
ver = (target_version or CURRENT_VERSION).lstrip("v").strip()
|
||||
|
||||
ws_push_sh = ws_root / "push-all-to-git-libre-audio.sh"
|
||||
tracked_push_sh = core_dir / "deploy" / "push-all-to-git-libre-audio.sh"
|
||||
sync_vps_sh = core_dir / "deploy" / "sync-vps-repos.sh"
|
||||
caddyfile_p = core_dir / "deploy" / "Caddyfile"
|
||||
|
||||
modified_files: list[str] = []
|
||||
errors: list[str] = []
|
||||
|
||||
# Gate D1: Version Header & Tracked Mirror Parity
|
||||
if ws_push_sh.is_file():
|
||||
push_txt = ws_push_sh.read_text(encoding="utf-8")
|
||||
upd_push = re.sub(r"^#\s*Release\s+v\d+\.\d+\.\d+:", f"# Release v{ver}:", push_txt, count=1, flags=re.M)
|
||||
if upd_push != push_txt:
|
||||
if check_only:
|
||||
errors.append(f"Gate D1: {ws_push_sh} release header does not match v{ver}")
|
||||
else:
|
||||
ws_push_sh.write_text(upd_push, encoding="utf-8")
|
||||
ws_push_sh.chmod(0o755)
|
||||
modified_files.append(_norm_ws_path(ws_push_sh, workspace_root=ws_root))
|
||||
push_txt = upd_push
|
||||
|
||||
# Ensure tracked mirror inside hyperstitionstudio-core/deploy/push-all-to-git-libre-audio.sh is byte-identical
|
||||
tracked_txt = tracked_push_sh.read_text(encoding="utf-8") if tracked_push_sh.is_file() else ""
|
||||
if tracked_txt != push_txt:
|
||||
if check_only:
|
||||
errors.append(f"Gate D1: Tracked mirror {tracked_push_sh} is out of sync with {ws_push_sh}")
|
||||
else:
|
||||
tracked_push_sh.parent.mkdir(parents=True, exist_ok=True)
|
||||
tracked_push_sh.write_text(push_txt, encoding="utf-8")
|
||||
tracked_push_sh.chmod(0o755)
|
||||
modified_files.append(_norm_ws_path(tracked_push_sh, workspace_root=ws_root))
|
||||
else:
|
||||
errors.append(f"Gate D1: Missing {ws_push_sh}")
|
||||
|
||||
if sync_vps_sh.is_file():
|
||||
sync_txt = sync_vps_sh.read_text(encoding="utf-8")
|
||||
if re.search(r"^#\s*Release\s+v\d+\.\d+\.\d+:", sync_txt, flags=re.M):
|
||||
upd_sync = re.sub(r"^#\s*Release\s+v\d+\.\d+\.\d+:", f"# Release v{ver}:", sync_txt, count=1, flags=re.M)
|
||||
else:
|
||||
upd_sync = sync_txt.replace(
|
||||
"# /workspace/hyperstitionstudio-core/deploy/sync-vps-repos.sh\n",
|
||||
f"# /workspace/hyperstitionstudio-core/deploy/sync-vps-repos.sh\n# Release v{ver}: Self-re-executing tmpfs VPS hydration & service sync.\n",
|
||||
1,
|
||||
)
|
||||
if upd_sync != sync_txt:
|
||||
if check_only:
|
||||
errors.append(f"Gate D1: {sync_vps_sh} release header does not match v{ver}")
|
||||
else:
|
||||
sync_vps_sh.write_text(upd_sync, encoding="utf-8")
|
||||
sync_vps_sh.chmod(0o755)
|
||||
modified_files.append(_norm_ws_path(sync_vps_sh, workspace_root=ws_root))
|
||||
sync_txt = upd_sync
|
||||
else:
|
||||
errors.append(f"Gate D1: Missing {sync_vps_sh}")
|
||||
|
||||
gate_d1_ok = len(errors) == 0
|
||||
|
||||
# Gate D2 & D3: bash -n Syntax, Executable Permissions & Zero-/dev/null Redirections
|
||||
scripts_to_audit = [
|
||||
ws_push_sh,
|
||||
tracked_push_sh,
|
||||
sync_vps_sh,
|
||||
core_dir / "deploy" / "run-vps-data-production.sh",
|
||||
core_dir / "deploy" / "run-vps-archive-rotation.sh",
|
||||
cfg.archive_dir / "packaging" / "build-fedora41-rpm.sh",
|
||||
cfg.archive_dir / "packaging" / "bundle" / "scripts" / "run_exegesis_and_push_fedora41.sh",
|
||||
]
|
||||
gate_d2_ok = True
|
||||
gate_d3_ok = True
|
||||
for sp in scripts_to_audit:
|
||||
if not sp.is_file():
|
||||
continue
|
||||
if not check_only and not os.access(sp, os.X_OK):
|
||||
sp.chmod(0o755)
|
||||
proc = subprocess.run(["bash", "-n", str(sp)], capture_output=True, text=True, check=False)
|
||||
if proc.returncode != 0:
|
||||
gate_d2_ok = False
|
||||
errors.append(f"Gate D2: bash -n syntax error in {sp}: {proc.stderr.strip()}")
|
||||
stxt = sp.read_text(encoding="utf-8")
|
||||
if "/dev/null" in stxt:
|
||||
gate_d3_ok = False
|
||||
errors.append(f"Gate D3: Forbidden /dev/null found in {sp}")
|
||||
|
||||
# Gate D4: Untracked Runtime Artifact Hydration Parity (.gitignore vs. sync-vps-repos.sh)
|
||||
sync_txt_cur = sync_vps_sh.read_text(encoding="utf-8") if sync_vps_sh.is_file() else ""
|
||||
core_gi = (core_dir / ".gitignore").read_text(encoding="utf-8") if (core_dir / ".gitignore").is_file() else ""
|
||||
gate_d4_ok = True
|
||||
if "site/quant/audio/" in core_gi:
|
||||
if "quant_voice" not in sync_txt_cur or "--filter='P site/quant/audio/***'" not in sync_txt_cur:
|
||||
gate_d4_ok = False
|
||||
errors.append("Gate D4: site/quant/audio/ is in .gitignore but quant_voice / rsync filter is missing in deploy/sync-vps-repos.sh")
|
||||
if "generate_db_json.py" not in sync_txt_cur or "config.default.js" not in sync_txt_cur:
|
||||
gate_d4_ok = False
|
||||
errors.append("Gate D4: haiperdohp-jemaytreeah untracked artifact hydration missing in deploy/sync-vps-repos.sh")
|
||||
|
||||
# Gate D5: Cold *.tar.gz Archive Exclusion & Explicit rm -f Safety in sync-vps-repos.sh
|
||||
gate_d5_ok = (
|
||||
"--exclude='completed-plans-archive.tar.gz'" in sync_txt_cur
|
||||
and "--exclude='inactive-plans-archive.tar.gz'" in sync_txt_cur
|
||||
and 'docs/archive/completed-plans-archive.tar.gz"' in sync_txt_cur
|
||||
and 'docs/plans/inactive/inactive-plans-archive.tar.gz"' in sync_txt_cur
|
||||
)
|
||||
if not gate_d5_ok:
|
||||
errors.append("Gate D5: Cold plan .tar.gz exclusion or rm -f cleanup missing in deploy/sync-vps-repos.sh")
|
||||
|
||||
# Gate D6: Single-Layer 1x Compression & Caddyfile Media Extension Parity
|
||||
caddy_txt = caddyfile_p.read_text(encoding="utf-8") if caddyfile_p.is_file() else ""
|
||||
push_txt_cur = ws_push_sh.read_text(encoding="utf-8") if ws_push_sh.is_file() else ""
|
||||
gate_d6_ok = (
|
||||
"--enforce-single-compression" in push_txt_cur
|
||||
and "--enforce-single-compression" in sync_txt_cur
|
||||
and "@compressible not path" in caddy_txt
|
||||
and "*.wav" in caddy_txt
|
||||
and "*.pdf" in caddy_txt
|
||||
)
|
||||
if not gate_d6_ok:
|
||||
errors.append("Gate D6: Single-layer compression enforcement or Caddyfile media extension parity missing")
|
||||
|
||||
# Gate D7: Topological 6-Repository Push & Force-Tag Sync Parity in push-all-to-git-libre-audio.sh
|
||||
required_push_markers = (
|
||||
"hyperstitionstudio-core",
|
||||
"ingglish-hyperdope-gematria",
|
||||
"technocapital-singularity-zoology",
|
||||
"encyclopedia-knowledge-graph",
|
||||
"hyperdope-ci-build",
|
||||
"haiperdohp-jemaytreeah",
|
||||
'push --force "${remote_name}" "refs/tags/${head_tag}"',
|
||||
"build-fedora41-rpm.sh",
|
||||
"run_exegesis_and_push_fedora41.sh",
|
||||
)
|
||||
gate_d7_ok = all(m in push_txt_cur for m in required_push_markers)
|
||||
if not gate_d7_ok:
|
||||
errors.append("Gate D7: Missing required repository, force-tag, or verification marker in push-all-to-git-libre-audio.sh")
|
||||
|
||||
# Gate D8: Automatic Git Staging Prior to Commit (--stage)
|
||||
staged_files: list[str] = []
|
||||
if stage and not check_only and (core_dir / ".git").exists():
|
||||
for rel_s in ("deploy/push-all-to-git-libre-audio.sh", "deploy/sync-vps-repos.sh", "deploy/Caddyfile"):
|
||||
cand_p = core_dir / rel_s
|
||||
if cand_p.is_file():
|
||||
subprocess.run(["git", "-C", str(core_dir), "add", rel_s], check=False)
|
||||
staged_files.append(f"/workspace/hyperstitionstudio-core/{rel_s}")
|
||||
|
||||
all_ok = (
|
||||
gate_d1_ok
|
||||
and gate_d2_ok
|
||||
and gate_d3_ok
|
||||
and gate_d4_ok
|
||||
and gate_d5_ok
|
||||
and gate_d6_ok
|
||||
and gate_d7_ok
|
||||
and len(errors) == 0
|
||||
)
|
||||
|
||||
return {
|
||||
"ok": all_ok,
|
||||
"version": ver,
|
||||
"check_only": check_only,
|
||||
"gates": {
|
||||
"D1_version_header_and_tracked_mirror_parity": gate_d1_ok,
|
||||
"D2_bash_syntax_and_exec_permissions": gate_d2_ok,
|
||||
"D3_zero_dev_null_redirections": gate_d3_ok,
|
||||
"D4_gitignore_untracked_runtime_hydration_parity": gate_d4_ok,
|
||||
"D5_cold_tar_gz_tmpfs_exclusion_and_rm": gate_d5_ok,
|
||||
"D6_single_layer_compression_and_caddy_parity": gate_d6_ok,
|
||||
"D7_topological_6_repo_push_and_force_tags": gate_d7_ok,
|
||||
"D8_pre_commit_auto_stage_ready": True,
|
||||
},
|
||||
"modified_files": modified_files,
|
||||
"staged_files": staged_files,
|
||||
"errors": errors,
|
||||
}
|
||||
|
||||
|
||||
def main(argv: list[str] | None = None) -> int:
|
||||
ap = argparse.ArgumentParser(
|
||||
prog="hs-deploy-scripts-sync",
|
||||
description="Prepare, synchronize, and verify push-all-to-git-libre-audio.sh and deploy/sync-vps-repos.sh prior to commits.",
|
||||
)
|
||||
ap.add_argument("--check", action="store_true", help="Verify Gates D1-D8 without modifying files.")
|
||||
ap.add_argument("--stage", action="store_true", help="Stage updated deploy scripts in hyperstitionstudio-core via git add.")
|
||||
ap.add_argument("--version", default=None, help="Optional target semantic version override.")
|
||||
ap.add_argument("--workspace-root", default=None, help="Optional workspace root directory.")
|
||||
args = ap.parse_args(argv)
|
||||
|
||||
res = prepare_and_verify_deploy_scripts(
|
||||
workspace_root=args.workspace_root,
|
||||
target_version=args.version,
|
||||
check_only=args.check,
|
||||
stage=args.stage,
|
||||
)
|
||||
print(json.dumps(res, indent=2))
|
||||
return 0 if res["ok"] else 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
@@ -39,8 +39,8 @@ from hyperstitionstud_io.mcp.tools import MCP_TOOLS_SCHEMA, call_mcp_tool # noq
|
||||
|
||||
SERVER_INFO = {
|
||||
"name": "hyperstitionstudio-mcp",
|
||||
"version": "2.13.0",
|
||||
"namespace_urn": "urn:io:hyperstitionstud:mcp:2.13.0",
|
||||
"version": "2.14.0",
|
||||
"namespace_urn": "urn:io:hyperstitionstud:mcp:2.14.0",
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -475,7 +475,8 @@ def sync_all_repo_readmes(
|
||||
|
||||
PRE_COMMIT_HOOK_SCRIPT = """#!/usr/bin/env bash
|
||||
# Auto-installed by hyperstitionstud_io.publishing.readme_sync (hs-readme-sync --install-hooks)
|
||||
# Re-renders homepage UI closeups when page UI elements change and synchronizes root README.md before every commit.
|
||||
# Prepares & validates push-all-to-git-libre-audio.sh and deploy/sync-vps-repos.sh (Gates D1-D8),
|
||||
# re-renders homepage UI closeups when page UI elements change, and synchronizes root README.md before every commit.
|
||||
set -euo pipefail
|
||||
|
||||
REPO_ROOT="$(git rev-parse --show-toplevel)"
|
||||
@@ -485,6 +486,11 @@ CORE_SRC="${WS_ROOT}/hyperstitionstudio-core/src"
|
||||
|
||||
if [[ -d "${CORE_SRC}" ]]; then
|
||||
export PYTHONPATH="${CORE_SRC}${PYTHONPATH:+:${PYTHONPATH}}"
|
||||
if [[ "${REPO_NAME}" == "hyperstitionstudio-core" ]]; then
|
||||
python3 -m hyperstitionstud_io.ci.deploy_scripts_sync --workspace-root "${WS_ROOT}" --stage
|
||||
else
|
||||
python3 -m hyperstitionstud_io.ci.deploy_scripts_sync --workspace-root "${WS_ROOT}"
|
||||
fi
|
||||
python3 -m hyperstitionstud_io.publishing.closeups_sync
|
||||
if [[ -d "${WS_ROOT}/hyperstitionstudio-core/site/assets/closeups" ]] && [[ "${REPO_NAME}" == "hyperstitionstudio-core" ]]; then
|
||||
git -C "${REPO_ROOT}" add site/assets/closeups/
|
||||
@@ -535,7 +541,7 @@ def install_git_pre_commit_hooks(ws_root: Path | None = None, check_only: bool =
|
||||
if not hooks_dir.is_dir():
|
||||
continue
|
||||
for h_name, h_script, markers in (
|
||||
("pre-commit", PRE_COMMIT_HOOK_SCRIPT, ("readme_sync", "closeups_sync")),
|
||||
("pre-commit", PRE_COMMIT_HOOK_SCRIPT, ("readme_sync", "closeups_sync", "deploy_scripts_sync")),
|
||||
("commit-msg", COMMIT_MSG_HOOK_SCRIPT, ("COMMIT-MSG GATE",)),
|
||||
):
|
||||
hook_path = hooks_dir / h_name
|
||||
|
||||
@@ -684,7 +684,7 @@ def build_financial_quant_harvest(
|
||||
payload: dict[str, Any] = {
|
||||
"$schema": "./schemas/v1/financial-aq-harvest.schema.json",
|
||||
"$id": "urn:io:hyperstitionstud:schema:v1:financial-aq-harvest",
|
||||
"version": "2.13.0",
|
||||
"version": "2.14.0",
|
||||
"target_date_utc": datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%d"),
|
||||
"harvest_mode": harvest_mode,
|
||||
"synthetic_data_eliminated": True,
|
||||
|
||||
@@ -476,8 +476,20 @@ def sync_workspace_version(target_version: str, check_only: bool = False, ws_roo
|
||||
ws_toml.write_text(upd_ws, encoding="utf-8")
|
||||
modified_files.append(str(ws_toml))
|
||||
|
||||
from hyperstitionstud_io.ci.deploy_scripts_sync import prepare_and_verify_deploy_scripts
|
||||
from hyperstitionstud_io.publishing.readme_sync import sync_all_repo_readmes
|
||||
|
||||
deploy_res = prepare_and_verify_deploy_scripts(
|
||||
workspace_root=cfg.workspace_root,
|
||||
target_version=v,
|
||||
check_only=check_only,
|
||||
stage=False,
|
||||
)
|
||||
if check_only and not deploy_res["ok"]:
|
||||
mismatched_files.extend(deploy_res["errors"])
|
||||
elif not check_only:
|
||||
modified_files.extend(deploy_res["modified_files"])
|
||||
|
||||
readme_res = sync_all_repo_readmes(ws_root=cfg.workspace_root, version=v, check_only=check_only)
|
||||
if check_only and not readme_res["all_in_sync"]:
|
||||
mismatched_files.extend(readme_res["mismatched_readmes"])
|
||||
|
||||
Reference in new issue
Block a user