# Plan: Scheduled Archive Rotation Cronjob (`00:20 UTC` / `19:20 EST` Daily) on `hyperstitionstud.io` — Coordinating `hs-archive-rotate` (`docs/archive/*.tar.gz`) & Quiescent SQLite Telemetry Rotation Across `/etc/cron.d/`, `systemd` Timers & Hermes Cron (`v2.0.29`) - **Document ID:** `PLAN-CRONJOB-ARCHIVE-ROTATION-ON-HYPERSTITIONSTUD-IO` (`v2.0.29`) - **Roadmap Status:** **ACTIVE / READY** - **Strict Zero-LLM-Token / Zero-API-Key VPS Mandate:** **No cronjob or timer requiring metered LLM tokens or an LLM/OpenRouter API key will ever run on `hyperstitionstud.io`.** All scheduled jobs installed on the `hyperstitionstud.io` VPS (`/etc/cron.d/hyperstition-archive-rotate`, `hyperstition-archive-rotate.{service,timer}`, `hyperstition-closing-bell-harvest.{service,timer}`, `hyperstition-utc-rollover-harvest.{service,timer}`, and `/etc/logrotate.d/hyperstition-sqlite-meta`) execute **100% deterministic, keyless local Python and Bash scripts (`0` LLM tokens, `0` API keys)** and explicitly `unset OPENROUTER_API_KEY OPENAI_API_KEY ANTHROPIC_API_KEY`. All LLM-token-dependent agent cronjobs remain strictly on `localhost`. - **Target Schedule (`00:20 UTC` / `19:20 EST` Daily — Window C on `hyperstitionstud.io` VPS Only):** Runs daily at `00:20 UTC` via `/etc/cron.d/hyperstition-archive-rotate` (and `hyperstition-archive-rotate.timer`) on the `hyperstitionstud.io` web host. - **Target Modules & Deployment Files:** - `/workspace/hyperstitionstudio-core/deploy/cron.d/hyperstition-archive-rotate` (Installed to `/etc/cron.d/hyperstition-archive-rotate` by `deploy/sync-vps-repos.sh` Step 5) - `/workspace/hyperstitionstudio-core/deploy/hyperstition-archive-rotate.{service,timer}` (`systemd` timer unit for `00:20:00 UTC` daily execution on `hyperstitionstud.io`) - `/workspace/hyperstitionstudio-core/deploy/run-vps-archive-rotation.sh` (Flock-guarded, zero-`/dev/null`, zero-API-key wrapper script executing `hs-archive-rotate`, `sqlite_meta --run-logrotate-directive`, `tmpfs` sync when loose files were rotated, and optional `git.libre.audio` push) --- ## 1. Unified Daily Cron Topology (`21:30 UTC` -> `00:00 UTC` -> `00:20 UTC`) With `29c871eb6b78` and `7effa9679803` decommissioned under `PLAN-MIGRATE-PERIODIC-DATA-PRODUCTION-FROM-LOCALHOST-TO-VPS` (leaving `d28b479ec217` as the sole `localhost` exegesis cronjob), `PLAN-CRONJOB-ARCHIVE-ROTATION-ON-HYPERSTITIONSTUD-IO` is scoped strictly to **Window C (`00:20 UTC` Cold-Archive & SQLite Telemetry Rotation on `hyperstitionstud.io`)**: | Window | Schedule (`UTC` / `EST`) | Execution Surface & Unit Name | What It Executes | Metered LLM Token Cost | | :---: | :--- | :--- | :--- | :---: | | **Window A** | `21:30 UTC` / `16:30 EST` (`Mon–Fri`) | • **VPS `hyperstition-closing-bell-harvest.timer`**
*(Implemented in `PLAN-MIGRATE-PERIODIC-DATA-PRODUCTION-FROM-LOCALHOST-TO-VPS`; `29c871eb6b78` decommissioned)* | US Closing-Bell Financial (`hs-quant-harvest --append-history --live`), FRED Macro (`hs-macro-harvest`), 14-point `timeseries.py`, 5-Agenda Bayesian `hs-daily-brief`, `tmpfs` RAM hydration, & `git.libre.audio` push. | **`0` LLM tokens & `0` API keys** | | **Window B** | `00:00 UTC` / `19:00 EST` (`Daily`) | • **`localhost` Hermes `d28b479ec217`** *(Sole Remaining LLM Cronjob)*
• **VPS `hyperstition-utc-rollover-harvest.timer`** *(Implemented in `PLAN-MIGRATE-PERIODIC-DATA-PRODUCTION-FROM-LOCALHOST-TO-VPS`; `7effa9679803` decommissioned)* | • **`localhost` (`d28b479ec217`):** LLM-assisted narrative exegesis prose synthesis for `-dossier-news-YYYY-MM-DD.md`.
• **VPS (`00:00 UTC` timer):** Deterministic `ci_provision_ingglish.py --tier 2`, `timeseries.py`, `hs-daily-brief`, and `build_encyclopedia_knowledge_graph.py`. | Metered **only** on `localhost` `d28b479ec217`; **`0` tokens on VPS** | | **Window C**
*(This Plan — VPS Archive Rotation Only)* | **`00:20 UTC` / `19:20 EST` (`Daily`)** | • **VPS `/etc/cron.d/hyperstition-archive-rotate`**
• **VPS `hyperstition-archive-rotate.timer`** | 1. Explicitly unsets `OPENROUTER_API_KEY`, `OPENAI_API_KEY`, `ANTHROPIC_API_KEY` (`0` API keys).
2. Runs `hs-archive-rotate` (`publishing.archive_rotator`): rotates any loose completed `docs/archive/*.{md,pdf}` pairs (`require_companion_md=True`) into `completed-plans-archive.tar.gz` + `archive-manifest.json` while enforcing `assert_not_gematria_pipeline_source()` and `verify_gematria_pipeline_richness_invariant()`.
3. Runs `python3 -m hyperstitionstud_io.db.sqlite_meta --run-logrotate-directive`: checks `/var/lib/hyperstitionstud.io/api-telemetry.db` against the `100M` limit and performs quiescent `BEGIN EXCLUSIVE` `.1.gz` compression + truncation when `>= 100M`.
4. If loose `docs/archive/` files were rotated, refreshes `/var/www/hyperstitionstud.io/repos` (`tmpfs` RAM) via `sync-vps-repos.sh --no-pull --no-caddy`. | **`0` LLM tokens & `0` API keys** (`100%` local Python/Bash on VPS) | --- ## 2. Specification of the Three Coordinated Components ### 2.1 Flock-Guarded Execution Script (`deploy/run-vps-archive-rotation.sh`) - Contains **`0` `/dev/null` redirections**, uses `set -euo pipefail`, `trap 'on_error ${LINENO}' ERR`, and `run_checked()`, and acquires `/tmp/hyperstition-vps-harvest.lock` via `flock -n 9` so it never collides with `run-vps-data-production.sh` or `sync-vps-repos.sh`. - Executes: 1. `python3 -m hyperstitionstud_io.publishing.archive_rotator` (`hs-archive-rotate`), verifying `gematria_richness_invariant_verified == true` (`0` gematria/dossier/lexicon/graph/quant/calc files ever touched; standalone `.pdf`s with `has_md == False` preserved). 2. `python3 -m hyperstitionstud_io.db.sqlite_meta --run-logrotate-directive` on `/var/lib/hyperstitionstud.io/api-telemetry.db` (or `$HYPERSTITION_TELEMETRY_DB_PATH`). 3. Checks if `git status -s` in `encyclopedia-knowledge-graph` or `technocapital-singularity-zoology` shows newly rotated `docs/archive/` files; if so, runs `deploy/sync-vps-repos.sh --no-pull --no-caddy` to remove the unlinked loose files from `/var/www/hyperstitionstud.io/repos` (`tmpfs` RAM) and (when `/etc/hyperstitionstud.io/id_ed25519_git_libre_audio` is present) commits and pushes the updated `completed-plans-archive.tar.gz` and `archive-manifest.json` to `git.libre.audio`. ### 2.2 VPS System Cron & `systemd` Timer (`deploy/cron.d/hyperstition-archive-rotate` & `deploy/hyperstition-archive-rotate.{service,timer}`) 1. **`/workspace/hyperstitionstudio-core/deploy/cron.d/hyperstition-archive-rotate`:** ```cron # /etc/cron.d/hyperstition-archive-rotate — Daily 00:20 UTC Cold-Archive & SQLite Telemetry Rotation SHELL=/bin/bash PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin 20 0 * * * root /srv/hyperstitionstud.io/repos/hyperstitionstudio-core/deploy/run-vps-archive-rotation.sh >> /var/log/hyperstition-archive-rotate.log 2>&1 ``` Installed idempotently to `/etc/cron.d/hyperstition-archive-rotate` (`chmod 0644`) in Step `[5/5]` of `deploy/sync-vps-repos.sh` (right alongside `/etc/logrotate.d/hyperstition-sqlite-meta`). 2. **`/workspace/hyperstitionstudio-core/deploy/hyperstition-archive-rotate.{service,timer}`:** Provides the matching `systemd` timer (`OnCalendar=*-*-* 00:20:00 UTC`, `Persistent=true`) installed by `deploy/sync-vps-repos.sh` Step `[5/5]`. ### 2.3 Strict Host & Plan Scope Boundary (`PLAN-CRONJOB-ARCHIVE-ROTATION-ON-HYPERSTITIONSTUD-IO` Is Scoped Strictly to Archive Rotation) - **Why `29c871eb6b78` & `7effa9679803` Decommissioning Belonged to `PLAN-MIGRATE-PERIODIC-DATA-PRODUCTION-FROM-LOCALHOST-TO-VPS`:** - Decommissioning the two non-exegesis `localhost` data-production cronjobs (`29c871eb6b78` and `7effa9679803`) is the source-decommissioning half of `PLAN-MIGRATE-PERIODIC-DATA-PRODUCTION-FROM-LOCALHOST-TO-VPS` (`deploy/run-vps-data-production.sh`), and has now been executed directly as part of that migration (`cronjob_manage(action="remove")` on `29c871eb6b78` and `7effa9679803`, leaving `d28b479ec217` as the sole `localhost` exegesis cronjob). - **Scoped Responsibility of `PLAN-CRONJOB-ARCHIVE-ROTATION-ON-HYPERSTITIONSTUD-IO`:** - This plan is responsible **solely** for daily `00:20 UTC` cold-archive rotation (`hs-archive-rotate`) and SQLite telemetry logrotate (`sqlite_meta --run-logrotate-directive`) on `hyperstitionstud.io` via `/etc/cron.d/hyperstition-archive-rotate`, `deploy/hyperstition-archive-rotate.{service,timer}`, and `deploy/run-vps-archive-rotation.sh` (`0` LLM tokens, `0` API keys). --- ## 3. Test-Suite Appropriateness Analysis & Guardrails 1. **Appropriate for `tests/test_core_suite.py` (Offline & Deterministic):** - Assert that `deploy/run-vps-archive-rotation.sh`, `deploy/cron.d/hyperstition-archive-rotate`, `deploy/hyperstition-archive-rotate.service`, and `deploy/hyperstition-archive-rotate.timer` exist on disk, contain `0` `/dev/null` redirections, and specify `20 0 * * *` / `00:20:00 UTC`. - Assert that `deploy/sync-vps-repos.sh` installs `/etc/cron.d/hyperstition-archive-rotate` and `hyperstition-archive-rotate.{service,timer}` in Step `[5/5]`. - Execute `deploy/run-vps-archive-rotation.sh --skip-hydrate --no-push` in `test_core_suite.py` (using a temporary telemetry DB path) to verify end-to-end execution of `hs-archive-rotate` + `sqlite_meta --run-logrotate-directive` with `0` errors. 2. **Appropriate for `deploy/test-first-deployment.sh`:** - Verify that `sync-vps-repos.sh --no-pull` installs `/etc/cron.d/hyperstition-archive-rotate` when `/etc/cron.d` is writable, and that `run-vps-archive-rotation.sh --skip-hydrate --no-push` exits `0`. 3. **Inappropriate for Test Suites (Excluded):** - Never wait on a live cron tick or require a running `crond`/`systemd` daemon inside `tests/test_core_suite.py`.