Release v2.12.0: Implement single-layer compression enforcement, 256KB plan archive cap with git.libre.audio citations, cold-archived inactive plans, codebase modularity/security/economization (Strategies 1A/2B/3A/4A/5A/6A/7A), and /quant/ spoken voice narration & #lensSelect UI element indicators (Strategies 1B/2A/3A/4A)

This commit is contained in:
Hermes Agent committed 2026-12-01 10:29:05 +00:00
1 parent cc73a57bd8
commit a066a0d03d
69 files changed
+2334 -619

No files matched your search

+111 -2
View File
@@ -10,6 +10,7 @@ Tests:
from __future__ import annotations
import hashlib
import json
import re
import sys
@@ -125,6 +126,7 @@ def test_offline_urn_namespaces_and_no_external_https_fonts() -> None:
for tgz in (
cfg.knowledge_graph_dir / "docs" / "archive" / "completed-plans-archive.tar.gz",
cfg.zoology_dir / "docs" / "archive" / "completed-plans-archive.tar.gz",
cfg.knowledge_graph_dir / "docs" / "plans" / "inactive" / "inactive-plans-archive.tar.gz",
):
if tgz.is_file():
with tarfile.open(tgz, "r:gz") as tf:
@@ -667,6 +669,7 @@ def test_ipld_quant_and_mcp_server() -> None:
web_pdf_pairs = discover_web_and_repo_pdf_pairs()
assert len(web_pdf_pairs) >= 48
assert all("archive" not in pdf_p.parts for _, pdf_p in web_pdf_pairs)
assert all(not ("plans" in pdf_p.parts and "inactive" in pdf_p.parts) for _, pdf_p in web_pdf_pairs)
assert any("encyclopedia/" in str(pdf_p) for _, pdf_p in web_pdf_pairs[:25])
row_cells = _split_markdown_table_row(r"| **3** | Pipes `a|b` & \| | $\mathbb{E}[|\Delta\text{bps}_{i,t}|] \in \{0..4\}$<br/>Line 2 & ⓘ |")
@@ -771,9 +774,14 @@ def test_ipld_quant_and_mcp_server() -> None:
assert flow_png_p.is_file() and flow_png_p.read_bytes()[:8] == b"\x89PNG\r\n\x1a\n"
assert flow_res["dimensions"] == [1800, 1280] and flow_res["breach_count"] == 0
# Verify Archive Rotator (Gematria-Pipeline Immunity, Richness Parity & require_companion_md=True)
# Verify Archive Rotator (Gematria-Pipeline Immunity, Richness Parity, .md-only 1x bundle, require_companion_md=True, --archive-inactive & Git citation fallback)
from hyperstitionstud_io.publishing.archive_rotator import (
INACTIVE_BUNDLE_FILENAME,
INACTIVE_MANIFEST_FILENAME,
assert_not_gematria_pipeline_source,
audit_and_fix_multi_compressed_files,
extract_archive_member,
extract_inactive_plan_member,
rotate_docs_archive_directory,
snapshot_gematria_pipeline_richness,
verify_gematria_pipeline_richness_invariant,
@@ -790,6 +798,9 @@ def test_ipld_quant_and_mcp_server() -> None:
except ValueError:
pass
# Verify docs/plans/inactive/ is allowed by Gematria-Pipeline Immunity
assert_not_gematria_pipeline_source(cfg_test.knowledge_graph_dir / "docs" / "plans" / "inactive")
rich_snap = snapshot_gematria_pipeline_richness()
assert verify_gematria_pipeline_richness_invariant(rich_snap, rich_snap) is True
@@ -800,10 +811,52 @@ def test_ipld_quant_and_mcp_server() -> None:
(arc_test_dir / "PLAN-SAMPLE.pdf").write_bytes(b"%PDF-1.4 sample")
(arc_test_dir / "STANDALONE-NO-MD.pdf").write_bytes(b"%PDF-1.4 standalone")
rot_res = rotate_docs_archive_directory(arc_test_dir, require_companion_md=True, check_allowed_dir=False)
assert rot_res["member_count"] == 2
assert rot_res["member_count"] == 1
assert rot_res["preserved_standalone_pdfs"] == ["STANDALONE-NO-MD.pdf"]
assert (arc_test_dir / "STANDALONE-NO-MD.pdf").is_file()
assert not (arc_test_dir / "PLAN-SAMPLE.pdf").exists()
sample_man = json.loads((arc_test_dir / "archive-manifest.json").read_text(encoding="utf-8"))
assert sample_man["manifest_dag_json_cid"].startswith("baguqeera")
assert sample_man["members"][0]["name"] == "PLAN-SAMPLE.md"
assert sample_man["members"][0]["companion_pdf_sha256"] == hashlib.sha256(b"%PDF-1.4 sample").hexdigest()
# Verify live completed-plans-archive.tar.gz is <= 256 KB (262,144 bytes), .md-only, and long_term_git_storage_citations work
kg_arc_dir = cfg_test.knowledge_graph_dir / "docs" / "archive"
kg_tgz = kg_arc_dir / "completed-plans-archive.tar.gz"
kg_man = json.loads((kg_arc_dir / "archive-manifest.json").read_text(encoding="utf-8"))
assert kg_tgz.stat().st_size <= 262_144, f"Expected completed-plans-archive.tar.gz <= 256 KB, got {kg_tgz.stat().st_size}"
assert kg_man["manifest_dag_json_cid"].startswith("baguqeera")
assert kg_man["long_term_git_rotated_count"] >= 1
assert all(m["git_citation_url"].startswith("https://git.libre.audio/seasharp/") for m in kg_man["members"])
assert all(lt["git_citation_url"].startswith("https://git.libre.audio/seasharp/") for lt in kg_man["long_term_git_storage_citations"])
# Verify extract_archive_member works for both active bundle members and long-term Git-rotated members
ext_out = tmp_path / "ext_check"
active_m_name = kg_man["members"][0]["name"]
lt_m_name = kg_man["long_term_git_storage_citations"][0]["name"]
p_act = extract_archive_member(kg_arc_dir, active_m_name, ext_out)
p_lt = extract_archive_member(kg_arc_dir, lt_m_name, ext_out)
assert p_act.is_file() and hashlib.sha256(p_act.read_bytes()).hexdigest() == kg_man["members"][0]["sha256"]
assert p_lt.is_file() and hashlib.sha256(p_lt.read_bytes()).hexdigest() == kg_man["long_term_git_storage_citations"][0]["sha256"]
# Verify inactive-plans-archive.tar.gz & inactive-archive-manifest.json
inact_dir = cfg_test.knowledge_graph_dir / "docs" / "plans" / "inactive"
inact_tgz = inact_dir / INACTIVE_BUNDLE_FILENAME
inact_man = json.loads((inact_dir / INACTIVE_MANIFEST_FILENAME).read_text(encoding="utf-8"))
assert inact_tgz.is_file() and inact_tgz.stat().st_size <= 262_144
assert inact_man["manifest_dag_json_cid"].startswith("baguqeera")
assert inact_man["member_count"] >= 6
p_inact = extract_inactive_plan_member(inact_man["members"][0]["plan_id"], out_dir=ext_out)
assert p_inact.is_file() and hashlib.sha256(p_inact.read_bytes()).hexdigest() == inact_man["members"][0]["sha256"]
# Verify Single-Layer (1x) Compression Invariant across all 6 repositories
comp_check = audit_and_fix_multi_compressed_files(workspace_root=cfg_test.workspace_root, fix=False)
assert comp_check["ok"] is True, f"Multi-compression violation detected: {comp_check}"
assert not comp_check["nested_archive_violations"]
assert not comp_check["peeled_gzip_files"]
assert not comp_check["removed_double_sidecars"]
caddy_txt = (cfg_test.core_dir / "deploy" / "Caddyfile").read_text(encoding="utf-8")
assert "@compressible not path *.gz *.br *.tgz" in caddy_txt and "encode @compressible zstd gzip" in caddy_txt
# Verify VPS Data Production incremental cache merge & static script/timer invariants
from hyperstitionstud_io.quant.collector import update_real_market_history_cache
@@ -1157,6 +1210,62 @@ def test_ipld_quant_and_mcp_server() -> None:
assert 'uParams.get("repl") === "trace"' in (cfg.core_dir / "site" / "assets" / "hs-guile-scheme-repl.js").read_text(encoding="utf-8")
assert 'id="live-smoke-probe"' in (cfg.core_dir / "site" / "engineering" / "mcp-chatbot-rest-and-ipld" / "index.html").read_text(encoding="utf-8")
# Verify Plan #53 (Strategies 1A, 2B, 3A, 4A, 5A, 6A, 7A): security.py, load_json_cached(), font lru_cache
from hyperstitionstud_io.config import load_json_cached
from hyperstitionstud_io.publishing.closeups_sync import _extract_js_ui_signature
from hyperstitionstud_io.publishing.fonts import load_pillow_font
from hyperstitionstud_io.security import SecurityBoundaryError, validate_safe_url
assert load_pillow_font("DejaVuSansMono.ttf", 12) is load_pillow_font("DejaVuSansMono.ttf", 12)
assert validate_safe_url("https://fred.stlouisfed.org/graph/fredgraph.csv") == "https://fred.stlouisfed.org/graph/fredgraph.csv"
assert validate_safe_url("http://127.0.0.1:18090/status", allow_http_localhost=True) == "http://127.0.0.1:18090/status"
for bad_url in ("file:///etc/passwd", "http://169.254.169.254/latest/meta-data/", "http://example.com/test"):
blocked_u = False
try:
validate_safe_url(bad_url, allow_http_localhost=False)
except SecurityBoundaryError:
blocked_u = True
assert blocked_u, f"Expected SecurityBoundaryError for {bad_url}"
tmp_json_f = tmp_path / "cached-test.json"
tmp_json_f.write_text('{"k": 1}', encoding="utf-8")
assert load_json_cached(tmp_json_f)["k"] == 1
tmp_json_f.write_text('{"k": 22}', encoding="utf-8")
assert load_json_cached(tmp_json_f)["k"] == 22
# Verify Plan #51 (Strategies 1B, 2A, 3A, 4A): /quant/ guided tour voice narration, #lensSelect UI indicator & JS closeup introspection
assert 'id="tutUiElementIndicator"' in quant_html_txt
quant_tut_js_p = cfg.core_dir / "site" / "quant" / "quant-tutorials.js"
quant_tut_txt = quant_tut_js_p.read_text(encoding="utf-8")
js_sig_1 = _extract_js_ui_signature(quant_tut_txt)
js_sig_2 = _extract_js_ui_signature(quant_tut_txt + '\n// document.getElementById("syntheticTestMutatedId")')
assert js_sig_1["js_ui_sha256"] != js_sig_2["js_ui_sha256"], "Mutating JS DOM control must change js_ui_sha256 fingerprint"
assert js_sig_1["has_lens_select_highlight"] is True and js_sig_1["speech_text_count"] == 25
node_quant_tut_test = subprocess.run(
[
"node",
"-e",
f"const QT = require({json.dumps(str(quant_tut_js_p))});"
"if (QT.episodes.length !== 5) process.exit(1);"
"let totalScenes = 0;"
"QT.episodes.forEach((ep) => {"
" ep.keyframes.forEach((kf) => {"
" totalScenes++;"
" if (!Array.isArray(kf.uiTargets) || kf.uiTargets.length === 0) process.exit(2);"
" if (!kf.uiElementLabel || !kf.speechText) process.exit(3);"
" });"
"});"
"if (totalScenes !== 25) process.exit(4);"
"const ep04 = QT.episodes[3];"
"if (!ep04.keyframes.every((kf) => kf.uiTargets.includes('lensSelect') && kf.uiTargets.includes('lensProjectionCard'))) process.exit(5);",
],
capture_output=True,
text=True,
check=False,
)
assert node_quant_tut_test.returncode == 0, f"Node QuantTutorials check failed ({node_quant_tut_test.returncode}): {node_quant_tut_test.stderr}"
# Verify PLAN-INTROSPECTIVE-PROTECT-SYSTEM-STRICT-EROFS-TEST-HARNESS
from hyperstitionstud_io.ci.erofs_harness import run_introspective_erofs_suite