Files
encyclopedia-knowledge-graph/docs/PLAN-ARCHIVE-ROTATION-AND-COMPRESSION-ECONOMIZER.md
T

9.1 KiB
Raw Blame History

Plan: Rotating Completed Archives (docs/archive/) Into Compressed Cold-Storage Bundles (.tar.gz) to Economize Stylistic Refreshes, Revisions & Search Sweeps (v2.0.28)

  • Document ID: PLAN-ARCHIVE-ROTATION-AND-COMPRESSION-ECONOMIZER (v2.0.28)
  • Roadmap Status: ACTIVE / READY
  • Target Directories & Modules:
    • /workspace/encyclopedia-knowledge-graph/docs/archive/ (56 loose .md/.pdf files = 3,215,398 bytes -> compressed completed-plans-archive.tar.gz + archive-manifest.json + README.md)
    • /workspace/technocapital-singularity-zoology/docs/archive/ (6 completed loose .md/.pdf files -> compressed completed-plans-archive.tar.gz + archive-manifest.json; moving the deferred podcast-series-plan-encyclopedia-of-technocapital-singularity-zoology.{md,pdf} for Episodes 06–09 up to technocapital-singularity-zoology/docs/ so docs/archive/ holds strictly completed cold records)
    • /workspace/hyperstitionstudio-core/src/hyperstitionstud_io/publishing/archive_rotator.py (hs-archive-rotate CLI & deterministic .tar.gz rotator)
    • /workspace/hyperstitionstudio-core/src/hyperstitionstud_io/publishing/pdf_compiler.py (Excluding docs/archive/ from discover_web_and_repo_pdf_pairs())
    • /workspace/hyperstitionstudio-core/tests/test_core_suite.py

1. Problem Statement & Empirical Economy Analysis

Currently, completed planning documents and historical audits are stored as uncompressed loose .md and .pdf files inside /workspace/encyclopedia-knowledge-graph/docs/archive/ (28 .md + 28 .pdf = 56 files, 3.22 MB) and /workspace/technocapital-singularity-zoology/docs/archive/ (4 .md + 4 .pdf = 8 files, 351 KB):

Overhead Dimension Current Uncompressed Loose docs/archive/ State After Compressed .tar.gz Rotation & Archive Exclusion Measured Savings
1. Stylistic PDF Refreshes (hs-pdf-build --refresh-all-web-pdfs) 84 total .md -> .pdf compilations (32 of which are historical docs/archive/ files never linked from the web UI). 52 active/web-linked .md -> .pdf compilations (0 compilations inside docs/archive/). -38.1% fewer PDFs compiled (32 redundant PDF builds eliminated on every refresh)
2. Repository Content Search (search_files / rglob("*.md")) Every content search or glob sweep scans 31 historical .md files (~410,000 chars / ~128,000 BPE tokens of superseded specs), polluting search matches and context windows. Loose .md and .pdf files are packed inside completed-plans-archive.tar.gz; only docs/archive/README.md and archive-manifest.json remain unpacked. -100% (~128K BPE tokens) of stale plan prose excluded from search_files & glob sweeps
3. Disk & tmpfs Webroot Footprint (/var/www/hyperstitionstud.io/repos) 3,566,151 bytes (3.57 MB) across 64 loose files (128 files after .gz/.br pre-compression in sync-vps-repos.sh). Single deterministic completed-plans-archive.tar.gz per docs/archive/ directory + README.md + archive-manifest.json (and sync-vps-repos.sh --exclude='docs/archive/*.tar.gz'). 62 loose files consolidated into 2 cold .tar.gz bundles

2. Boundary Guardrail: What Gets Rotated vs. What Must Never Be Compressed

  1. Rotated Into Cold Storage (docs/archive/completed-plans-archive.tar.gz):
    • /workspace/encyclopedia-knowledge-graph/docs/archive/*.{md,pdf} (excluding README.md, which stays unpacked as the human-readable index).
    • /workspace/technocapital-singularity-zoology/docs/archive/*.{md,pdf} (after moving the still-deferred podcast-series-plan-encyclopedia-of-technocapital-singularity-zoology.{md,pdf} for Episodes 06–09 to /workspace/technocapital-singularity-zoology/docs/ so no deferred plan is buried in cold storage).
  2. Never Rotated / Always Kept Live & Uncompressed:
    • /workspace/ingglish-hyperdope-gematria/ingglish-aq-archive/dossiers/*.md (71 verified dossiers & 21 dated 00:00 UTC news-wire dossiers served live at /archive/* and /api/v1/dossiers/{number} and ingested by timeseries.py and sqlite_meta.py).
    • All 22 Encyclopedia PDF volumes (/workspace/technocapital-singularity-zoology/encyclopedia/00..08/*.{md,pdf}) and top-level /zoology/*.{md,pdf} manuals/proposals.
    • Active and long-term deferred plans in top-level /workspace/encyclopedia-knowledge-graph/docs/PLAN-*.{md,pdf}.

3. Architecture of hyperstitionstud_io.publishing.archive_rotator (hs-archive-rotate)

3.1 Deterministic .tar.gz Rotation & Manifest Schema (docs/archive/archive-manifest.json)

The new module /workspace/hyperstitionstudio-core/src/hyperstitionstud_io/publishing/archive_rotator.py (registered in pyproject.toml as hs-archive-rotate = "hyperstitionstud_io.publishing.archive_rotator:main") implements:

  1. rotate_docs_archive_directory(archive_dir: Path) -> dict[str, Any]:
    • If completed-plans-archive.tar.gz already exists in archive_dir, extracts its existing members into a temporary staging directory first so newly archived .md/.pdf files are merged into the bundle without losing any previously rotated files.
    • Collects all loose *.md (except README.md) and *.pdf files in archive_dir.
    • Writes a deterministic gzip-compressed tarball completed-plans-archive.tar.gz (gzip.GzipFile(mtime=0), sorted member names, normalized TarInfo permissions 0644 and mtime=0 so identical contents always produce the exact same SHA-256 digest).
    • Writes archive_dir / "archive-manifest.json" recording:
      • bundle_filename: "completed-plans-archive.tar.gz",
      • bundle_size_bytes and bundle_sha256,
      • member_count and total_uncompressed_bytes,
      • members: sorted array of {name, size_bytes, sha256} for every .md and .pdf stored inside the .tar.gz archive.
    • Unlinks the loose .md (except README.md) and .pdf files from archive_dir only after verifying that every member in archive-manifest.json can be read back from completed-plans-archive.tar.gz with matching SHA-256 digests.
  2. Inspection & On-Demand Extraction CLI (hs-archive-rotate):
    • hs-archive-rotate: Rotates any loose .md/.pdf files in encyclopedia-knowledge-graph/docs/archive/ and technocapital-singularity-zoology/docs/archive/ into their completed-plans-archive.tar.gz bundles.
    • hs-archive-rotate --list: Lists all members and SHA-256 hashes from archive-manifest.json.
    • hs-archive-rotate --extract <filename> --out-dir <dir>: Extracts a specific historical .md or .pdf on demand without unpacking the rest of the archive.

3.2 Hardening discover_web_and_repo_pdf_pairs() in src/hyperstitionstud_io/publishing/pdf_compiler.py

  • Update discover_web_and_repo_pdf_pairs() to explicitly skip any path whose parent directory is named archive (if "archive" in p.parts: continue), guaranteeing that even before hs-archive-rotate runs, hs-pdf-build --refresh-all-web-pdfs never wastes cycles recompiling archived documents.

4. Three-Phase Implementation Roadmap (Phases 1–3)

Phase 1: Build src/hyperstitionstud_io/publishing/archive_rotator.py & Update pdf_compiler.py

  1. Create /workspace/hyperstitionstudio-core/src/hyperstitionstud_io/publishing/archive_rotator.py implementing rotate_docs_archive_directory(), rotate_all_docs_archives(), list_archive_members(), and extract_archive_member().
  2. Register hs-archive-rotate = "hyperstitionstud_io.publishing.archive_rotator:main" in pyproject.toml.
  3. Update discover_web_and_repo_pdf_pairs() in src/hyperstitionstud_io/publishing/pdf_compiler.py to exclude /docs/archive/ paths.

Phase 2: Relocate Deferred Podcast Plan & Rotate Both docs/archive/ Directories

  1. Move /workspace/technocapital-singularity-zoology/docs/archive/podcast-series-plan-encyclopedia-of-technocapital-singularity-zoology.{md,pdf} (Episodes 06–09 deferred plan) up to /workspace/technocapital-singularity-zoology/docs/ so it remains an accessible deferred plan outside cold storage.
  2. Archive PLAN-ARCHIVE-ROTATION-AND-COMPRESSION-ECONOMIZER.{md,pdf} into /workspace/encyclopedia-knowledge-graph/docs/archive/, update docs/archive/README.md, and run hs-archive-rotate across both repositories so all loose historical .md and .pdf files in docs/archive/ are rotated into completed-plans-archive.tar.gz + archive-manifest.json.

Phase 3: Update Skill Procedure & Verify in tests/test_core_suite.py

  1. Update hyperstitionstudio-roadmap-and-release (SKILL.md Procedure 3: Archiving Completed Plans) so archiving a completed plan moves the .md/.pdf pair into docs/archive/, updates docs/archive/README.md, and runs hs-archive-rotate to fold the pair into completed-plans-archive.tar.gz.
  2. Add unit assertions in tests/test_core_suite.py verifying that docs/archive/completed-plans-archive.tar.gz and docs/archive/archive-manifest.json exist, contain 0 loose .pdf files in docs/archive/, and that discover_web_and_repo_pdf_pairs() returns 0 paths inside docs/archive/.