diff --git a/deploy/cron.d/hyperstition-archive-rotate b/deploy/cron.d/hyperstition-archive-rotate new file mode 100644 index 0000000..1cced72 --- /dev/null +++ b/deploy/cron.d/hyperstition-archive-rotate @@ -0,0 +1,9 @@ +# /etc/cron.d/hyperstition-archive-rotate +# Installed by /srv/hyperstitionstud.io/repos/hyperstitionstudio-core/deploy/sync-vps-repos.sh +# Runs daily at 00:20 UTC (19:20 EST — Window C, 20 minutes after 00:00 UTC rollover harvest). +# Rotates loose docs/archive/*.{md,pdf} pairs into completed-plans-archive.tar.gz and checks SQLite telemetry DB (100M). +SHELL=/bin/bash +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +TZ=UTC + +20 0 * * * root /srv/hyperstitionstud.io/repos/hyperstitionstudio-core/deploy/run-vps-archive-rotation.sh >> /var/log/hyperstition-archive-rotate.log 2>&1 diff --git a/deploy/hyperstition-archive-rotate.service b/deploy/hyperstition-archive-rotate.service new file mode 100644 index 0000000..864d2f6 --- /dev/null +++ b/deploy/hyperstition-archive-rotate.service @@ -0,0 +1,11 @@ +[Unit] +Description=Hyperstition Studio Daily Cold-Archive & SQLite Telemetry Rotation (00:20 UTC) +After=network-online.target hyperstition-utc-rollover-harvest.service + +[Service] +Type=oneshot +User=root +WorkingDirectory=/srv/hyperstitionstud.io/repos/hyperstitionstudio-core +Environment="TZ=UTC" +Environment="PYTHONPATH=/srv/hyperstitionstud.io/repos/hyperstitionstudio-core/src" +ExecStart=/srv/hyperstitionstud.io/repos/hyperstitionstudio-core/deploy/run-vps-archive-rotation.sh diff --git a/deploy/hyperstition-archive-rotate.timer b/deploy/hyperstition-archive-rotate.timer new file mode 100644 index 0000000..5e386e2 --- /dev/null +++ b/deploy/hyperstition-archive-rotate.timer @@ -0,0 +1,10 @@ +[Unit] +Description=Daily 00:20 UTC Timer for Hyperstition Studio Cold-Archive & SQLite Rotation + +[Timer] +OnCalendar=*-*-* 00:20:00 UTC +Persistent=true +Unit=hyperstition-archive-rotate.service + +[Install] +WantedBy=timers.target diff --git a/deploy/run-vps-archive-rotation.sh b/deploy/run-vps-archive-rotation.sh new file mode 100755 index 0000000..5bd7b9f --- /dev/null +++ b/deploy/run-vps-archive-rotation.sh @@ -0,0 +1,75 @@ +#!/usr/bin/env bash +# /workspace/hyperstitionstudio-core/deploy/run-vps-archive-rotation.sh +# Daily 00:20 UTC (19:20 EST) Cold-Archive Rotation & Quiescent SQLite Logrotate Runner for hyperstitionstud.io +# Enforces 0 LLM tokens, 0 API keys, full stdout/stderr visibility, flock concurrency protection, and Gematria-Pipeline Immunity. +set -euo pipefail + +REPOS_ROOT="/srv/hyperstitionstud.io/repos" +LIVE_REPOS="/var/www/hyperstitionstud.io/repos" +LOCK_FILE="/tmp/hyperstition-archive-rotation.lock" +DRY_RUN=0 + +while [[ $# -gt 0 ]]; do + case "$1" in + --repos-root=*) + REPOS_ROOT="${1#*=}" + shift + ;; + --repos-root) + REPOS_ROOT="${2:-}" + shift 2 + ;; + --live-repos=*) + LIVE_REPOS="${1#*=}" + shift + ;; + --live-repos) + LIVE_REPOS="${2:-}" + shift 2 + ;; + --dry-run) + DRY_RUN=1 + shift + ;; + *) + echo "[ERROR] Unknown argument: $1" >&2 + exit 2 + ;; + esac +done + +exec 9>"${LOCK_FILE}" +if ! flock -n 9; then + echo "[SKIP] Another hyperstition-archive-rotation run holds ${LOCK_FILE}; exiting cleanly." + exit 0 +fi + +export TZ="UTC" +export PYTHONPATH="${REPOS_ROOT}/hyperstitionstudio-core/src" +unset OPENROUTER_API_KEY OPENAI_API_KEY ANTHROPIC_API_KEY + +echo "[1/3] Running Cold-Storage Plan Archive Rotation (hs-archive-rotate) against ${REPOS_ROOT}..." +if [[ "${DRY_RUN}" -eq 1 ]]; then + ROTATE_JSON="$(python3 -m hyperstitionstud_io.publishing.archive_rotator --workspace-root "${REPOS_ROOT}" --dry-run)" +else + ROTATE_JSON="$(python3 -m hyperstitionstud_io.publishing.archive_rotator --workspace-root "${REPOS_ROOT}")" +fi +echo "${ROTATE_JSON}" + +echo "[2/3] Running Quiescent SQLite Telemetry Logrotate Check (100M threshold)..." +if [[ "${DRY_RUN}" -eq 0 ]]; then + python3 -m hyperstitionstud_io.db.sqlite_meta --compress-archive --truncate-quiescent --max-mb 100 +fi + +echo "[3/3] Checking whether rotated docs/archive/ bundles require tmpfs webroot hydration..." +ROTATED_COUNT="$(python3 -c 'import json,sys; d=json.loads(sys.argv[1]); print(int(d.get("rotated_loose_files", 0)))' "${ROTATE_JSON}")" +if [[ "${DRY_RUN}" -eq 0 ]] && [[ "${ROTATED_COUNT}" -gt 0 ]] && [[ -d "${LIVE_REPOS}" ]]; then + echo "[SYNC] Rotated ${ROTATED_COUNT} loose archive file(s); refreshing ${LIVE_REPOS}..." + "${REPOS_ROOT}/hyperstitionstudio-core/deploy/sync-vps-repos.sh" \ + --repos-root="${REPOS_ROOT}" \ + --live-repos="${LIVE_REPOS}" \ + --no-pull \ + --no-caddy +else + echo "[OK] No loose archive files required rotation (rotated_loose_files=${ROTATED_COUNT}); tmpfs hydration skipped." +fi diff --git a/deploy/sync-vps-repos.sh b/deploy/sync-vps-repos.sh index a607cb4..35ef078 100755 --- a/deploy/sync-vps-repos.sh +++ b/deploy/sync-vps-repos.sh @@ -122,18 +122,19 @@ if [[ -d "${REPOS_ROOT}/haiperdohp-jemaytreeah" ]]; then echo "[build] Copying haiperdohp-jemaytreeah/config.default.js -> config.js..." run_checked "copy haiperdohp-jemaytreeah config.js" cp "${REPOS_ROOT}/haiperdohp-jemaytreeah/config.default.js" "${REPOS_ROOT}/haiperdohp-jemaytreeah/config.js" fi - if [[ ! -f "${REPOS_ROOT}/haiperdohp-jemaytreeah/db_lite.json" || ! -f "${REPOS_ROOT}/haiperdohp-jemaytreeah/db.json" ]] && [[ -f "${REPOS_ROOT}/haiperdohp-jemaytreeah/tools/generate_db_json.py" ]]; then + if [[ ! -f "${REPOS_ROOT}/haiperdohp-jemaytreeah/db_lite.json" || ! -f "${REPOS_ROOT}/haiperdohp-jemaytreeah/db.json" || "${REPOS_ROOT}/haiperdohp-jemaytreeah/db.txt" -nt "${REPOS_ROOT}/haiperdohp-jemaytreeah/db.json" ]] && [[ -f "${REPOS_ROOT}/haiperdohp-jemaytreeah/tools/generate_db_json.py" ]]; then echo "[build] Generating haiperdohp-jemaytreeah/db.json and db_lite.json from db.txt..." (cd "${REPOS_ROOT}/haiperdohp-jemaytreeah" && run_checked "generate_db_json.py" "${PYTHON_BIN}" tools/generate_db_json.py db.txt db.json) fi fi -echo "[2/5] Synchronizing local workspace.toml version and running hs-doctor, version_sync --check, and 6-Gate Knowledge Graph Verification..." +echo "[2/5] Synchronizing local workspace.toml version, rebuilding SQLite FTS5 catalog, and running hs-doctor, version_sync --check, and 6-Gate Knowledge Graph Verification..." if [[ -f "${REPOS_ROOT}/workspace.toml" ]] && [[ -f "${REPOS_ROOT}/hyperstitionstudio-core/workspace.example.toml" ]]; then # Sync schema_version in untracked parent workspace.toml with hyperstitionstud_io.__version__ run_checked "version_sync (sync untracked workspace.toml)" "${PYTHON_BIN}" -m hyperstitionstud_io.version_sync fi run_checked "version_sync --check" "${PYTHON_BIN}" -m hyperstitionstud_io.version_sync --check +run_checked "hs-db-build (--build)" "${PYTHON_BIN}" -m hyperstitionstud_io.db.sqlite_meta --build run_checked "hs-doctor" "${PYTHON_BIN}" -m hyperstitionstud_io.ci.doctor run_checked "build_encyclopedia_knowledge_graph.py --verify-only" "${PYTHON_BIN}" "${REPOS_ROOT}/encyclopedia-knowledge-graph/scripts/build_encyclopedia_knowledge_graph.py" --verify-only @@ -208,6 +209,18 @@ if [[ "${DO_CADDY}" -eq 1 ]]; then fi fi + SRC_CRON_ROTATE="${DEPLOY_DIR}/cron.d/hyperstition-archive-rotate" + DST_CRON_ROTATE="/etc/cron.d/hyperstition-archive-rotate" + if [[ -f "${SRC_CRON_ROTATE}" ]] && [[ -d "/etc/cron.d" ]] && { [[ -w "/etc/cron.d" ]] || [[ -n "${SUDO}" ]]; }; then + if [[ -f "${DST_CRON_ROTATE}" ]] && cmp -s "${SRC_CRON_ROTATE}" "${DST_CRON_ROTATE}"; then + echo "[5/5] ${DST_CRON_ROTATE} is already identical to deploy/cron.d/hyperstition-archive-rotate." + else + echo "[5/5] Installing 00:20 UTC archive rotation cron rule to ${DST_CRON_ROTATE}..." + run_checked "copy hyperstition-archive-rotate cron rule" ${SUDO} cp "${SRC_CRON_ROTATE}" "${DST_CRON_ROTATE}" + run_checked "chmod 0644 ${DST_CRON_ROTATE}" ${SUDO} chmod 0644 "${DST_CRON_ROTATE}" + fi + fi + if [[ -n "$(type -P systemctl || true)" ]] && [[ -d "/run/systemd/system" ]]; then UNITS_CHANGED=0 for unit_name in \ @@ -216,7 +229,9 @@ if [[ "${DO_CADDY}" -eq 1 ]]; then "hyperstition-closing-bell-harvest.service" \ "hyperstition-closing-bell-harvest.timer" \ "hyperstition-utc-rollover-harvest.service" \ - "hyperstition-utc-rollover-harvest.timer"; do + "hyperstition-utc-rollover-harvest.timer" \ + "hyperstition-archive-rotate.service" \ + "hyperstition-archive-rotate.timer"; do src_u="${DEPLOY_DIR}/${unit_name}" dst_u="/etc/systemd/system/${unit_name}" if [[ -f "${src_u}" ]]; then @@ -234,6 +249,7 @@ if [[ "${DO_CADDY}" -eq 1 ]]; then run_checked "systemctl restart hyperstition-mcp.service" ${SUDO} systemctl restart hyperstition-mcp.service run_checked "systemctl enable --now hyperstition-closing-bell-harvest.timer" ${SUDO} systemctl enable --now hyperstition-closing-bell-harvest.timer run_checked "systemctl enable --now hyperstition-utc-rollover-harvest.timer" ${SUDO} systemctl enable --now hyperstition-utc-rollover-harvest.timer + run_checked "systemctl enable --now hyperstition-archive-rotate.timer" ${SUDO} systemctl enable --now hyperstition-archive-rotate.timer elif [[ -f "/etc/systemd/system/hyperstition-mcp.service" ]]; then echo "[5/5] Restarting hyperstition-mcp.service to load latest MCP & REST API v1 (/api/v1/*) modules..." run_checked "systemctl enable --now hyperstition-mcp.service" ${SUDO} systemctl enable --now hyperstition-mcp.service diff --git a/deploy/test-first-deployment.sh b/deploy/test-first-deployment.sh index 3ec6f95..0369aad 100755 --- a/deploy/test-first-deployment.sh +++ b/deploy/test-first-deployment.sh @@ -75,7 +75,6 @@ ROUTES=( "/graph/docs/periodic-harvest-cicd-to-vps-flow-diagram.png" "/graph/docs/VPS-AND-GIT-OPERATOR-DEPLOYMENT-GUIDE.pdf" "/graph/docs/OPERATORS-MANUAL-LLM-TOKEN-DEPENDENT-DATA-PIPELINES.pdf" - "/graph/docs/PLAN-CRONJOB-ARCHIVE-ROTATION-ON-HYPERSTITIONSTUD-IO.pdf" "/graph/docs/PLAN-LEXICAL-AND-ETYMOLOGICAL-SIMPLIFICATION.pdf" "/graph/docs/PLAN-LLM-TOKEN-ECONOMIZER-AND-VARIANCE-ROUTING.pdf" "/graph/docs/PLAN-LLM-TOKEN-ECONOMIZER-DATA-FIDELITY-AND-DEGRADATION-RISK-EVALUATION.pdf" diff --git a/package.json b/package.json index 0c06685..c6f38b2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hyperstitionstud.io/workspace-core", - "version": "2.0.30", + "version": "2.1.0", "private": true, "description": "Offline-first ESM & browser global (@hyperstitionstud.io/* / window.HyperstitionStudio.*) packages for Base-36 AQ ciphers and interactive knowledge graph workbenches.", "license": "MIT", diff --git a/packages-js/ciphers-aq/package.json b/packages-js/ciphers-aq/package.json index 93cecac..7cbea29 100644 --- a/packages-js/ciphers-aq/package.json +++ b/packages-js/ciphers-aq/package.json @@ -1,6 +1,6 @@ { "name": "@hyperstitionstud.io/ciphers-aq", - "version": "2.0.30", + "version": "2.1.0", "type": "module", "main": "index.js", "license": "MIT" diff --git a/pyproject.toml b/pyproject.toml index 0f2f45e..bb3a2c4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "hyperstitionstudio-core" -version = "2.0.30" +version = "2.1.0" description = "Shared PEP 420 common library (hyperstitionstud_io.*) for Base-36 AQ ciphers, offline CMUdict Ingglish phonetics, ReportLab/Pillow publishing, SHA-256 glossary isolation guards, local-config citation verification, and multi-format knowledge graphs." readme = "README.md" requires-python = ">=3.10" diff --git a/scripts/build_gallery_manifest.py b/scripts/build_gallery_manifest.py index 60e9b2d..7d647d7 100755 --- a/scripts/build_gallery_manifest.py +++ b/scripts/build_gallery_manifest.py @@ -144,8 +144,8 @@ def main() -> int: }) manifest = { - "version": "2.0.30", - "namespace_urn": "urn:io:hyperstitionstud:gallery:2.0.30", + "version": "2.1.0", + "namespace_urn": "urn:io:hyperstitionstud:gallery:2.1.0", "total_items": len(items), "items": items, } diff --git a/site/donate/index.html b/site/donate/index.html index f940086..c97fb04 100644 --- a/site/donate/index.html +++ b/site/donate/index.html @@ -4,7 +4,7 @@
Strictly Periodic Telemetry (21:30 UTC US Closing Bell × 00:00 UTC News-Wire Dossiers) • Lens-Neutral Schema (urn:io:hyperstitionstud:quant-timeseries:v2.0.30)
+Strictly Periodic Telemetry (21:30 UTC US Closing Bell × 00:00 UTC News-Wire Dossiers) • Lens-Neutral Schema (urn:io:hyperstitionstud:quant-timeseries:v2.1.0)