150 lines
6.4 KiB
Python
150 lines
6.4 KiB
Python
"""
|
|
Pytest verification suite for hyperstitionstudio-core (hyperstitionstud_io.*).
|
|
Tests:
|
|
1. Zero-HTTPS offline namespace & HTML portability (urn:io:hyperstitionstud:*).
|
|
2. Base-36 AQ, Prime Rank, and G1-G6 vector parity across all 190 bilingual specimens.
|
|
3. Offline CMUdict phonetics fallback (zero --workdir dependency).
|
|
4. ReadOnlyIsolationGuard SHA-256 verification on glossary-registry.json & encyclopedia-manifest.json.
|
|
5. Local-config citation URL resolution ([citations.path_mounts]) and verify_draft() across all 5 proposals.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
from pathlib import Path
|
|
|
|
from hyperstitionstud_io.ciphers import (
|
|
assert_zero_d_filter,
|
|
compute_aq,
|
|
evaluate_bidirectional_lock,
|
|
is_repdigit_37,
|
|
prime_rank,
|
|
)
|
|
from hyperstitionstud_io.ci.citation_sources import (
|
|
load_ledger,
|
|
resolve_citation_target,
|
|
verify_draft,
|
|
)
|
|
from hyperstitionstud_io.ci.doctor import run_diagnostics
|
|
from hyperstitionstud_io.config import load_workspace_config
|
|
from hyperstitionstud_io.glossary import ReadOnlyIsolationGuard
|
|
from hyperstitionstud_io.graph import URN_GRAPH_NS, make_entity_urn
|
|
from hyperstitionstud_io.phonetics import translate_batch
|
|
|
|
|
|
def test_offline_urn_namespaces_and_no_external_https_fonts() -> None:
|
|
assert URN_GRAPH_NS == "urn:io:hyperstitionstud:ns:kg:1.0"
|
|
assert make_entity_urn("zoology", "build", "S1") == "urn:io:hyperstitionstud:zoology:build:S1"
|
|
|
|
cfg = load_workspace_config()
|
|
for html_p in (
|
|
cfg.core_dir / "site" / "index.html",
|
|
cfg.knowledge_graph_dir / "index.html",
|
|
cfg.knowledge_graph_dir / "docs" / "cross-repo-dependency-and-audit-flow-diagram.html",
|
|
):
|
|
txt = html_p.read_text(encoding="utf-8")
|
|
assert "fonts.googleapis.com" not in txt
|
|
assert "https://hyperstitionstud.io" not in txt
|
|
|
|
schemas_dir = cfg.core_dir / "schemas" / "v1"
|
|
for sp in schemas_dir.glob("*.schema.json"):
|
|
s_obj = json.loads(sp.read_text(encoding="utf-8"))
|
|
assert s_obj["$id"].startswith("urn:io:hyperstitionstud:schema:v1:")
|
|
assert "https://hyperstitionstud.io" not in sp.read_text(encoding="utf-8")
|
|
|
|
|
|
def test_ciphers_and_bilingual_ledger_parity() -> None:
|
|
cfg = load_workspace_config()
|
|
gl_path = cfg.zoology_dir / "taxonomy" / "glossary-registry.json"
|
|
gl_data = json.loads(gl_path.read_text(encoding="utf-8"))
|
|
for item in gl_data["bilingual_vocabulary_ledger"]:
|
|
lock = evaluate_bidirectional_lock(item["eng"], item["ing"])
|
|
assert lock["eng_aq"] == item["eng_aq"]
|
|
assert lock["ing_aq"] == item["ing_aq"]
|
|
assert lock["delta"] == item["delta"]
|
|
assert lock["isometric"] == item["isometric"]
|
|
assert lock["twin_prime_mutation"] == item["twin_prime"]
|
|
assert compute_aq("Dario Amodei") == 193
|
|
assert prime_rank(193) == 44
|
|
assert is_repdigit_37(333) and is_repdigit_37(666) and is_repdigit_37(777)
|
|
assert_zero_d_filter("Pure Base-36 Alphanumeric Qabbala")
|
|
|
|
|
|
def test_offline_phonetics_fallback_zero_workdir() -> None:
|
|
res = translate_batch(
|
|
["schizoanalysis", "abstract machine", "synthetic data", "Anthropic", "flash crash", "Blackwell"],
|
|
workdir="/nonexistent/offline/path",
|
|
)
|
|
assert res["schizoanalysis"] == "shizohnalizis"
|
|
assert res["abstract machine"] == "abstrakt masheen"
|
|
assert res["synthetic data"] == "sinthetik dayta"
|
|
assert res["Anthropic"] == "anthropik"
|
|
assert res["flash crash"] == "flash krash"
|
|
assert res["Blackwell"] == "blakwel"
|
|
|
|
|
|
def test_read_only_isolation_guard() -> None:
|
|
cfg = load_workspace_config()
|
|
with ReadOnlyIsolationGuard(cfg.read_only_files) as guard:
|
|
_ = [p.stat().st_size for p in cfg.read_only_files]
|
|
receipt = guard.audit_receipt()
|
|
assert receipt["all_unchanged"] is True
|
|
|
|
|
|
def test_local_config_citation_resolution_and_proposals() -> None:
|
|
mounts = {
|
|
"/workspace/ingglish-hyperdope-gematria": "https://git.libre.audio/m00t/ingglish-hyperdope-gematria/src/branch/main"
|
|
}
|
|
# Mapped prefix resolves to configured remote URL
|
|
u1 = resolve_citation_target(
|
|
"/workspace/ingglish-hyperdope-gematria/ingglish-aq-archive/70-dossier-news-2026-11-28.md",
|
|
path_mounts=mounts,
|
|
)
|
|
assert u1 == "https://git.libre.audio/m00t/ingglish-hyperdope-gematria/src/branch/main/ingglish-aq-archive/70-dossier-news-2026-11-28.md"
|
|
|
|
# Unmapped prefix NEVER resolves to a global namespace URL; stays local filesystem path
|
|
u2 = resolve_citation_target(
|
|
"/workspace/technocapital-singularity-zoology/dossiers/65-dossier-technocapital-singularity-autoregressive-ai.md",
|
|
path_mounts=mounts,
|
|
)
|
|
assert u2 == "/workspace/technocapital-singularity-zoology/dossiers/65-dossier-technocapital-singularity-autoregressive-ai.md"
|
|
|
|
cfg = load_workspace_config()
|
|
common_sources = load_ledger(cfg.zoology_dir / "taxonomy" / "citations-ledger-common.json")["sources"]
|
|
for fname in (
|
|
"proposal-fantasy-football-technocapital-roster-engine.md",
|
|
"proposal-corporate-board-technocapital-allocation.md",
|
|
"proposal-fund-manager-novel-investment-discovery.md",
|
|
):
|
|
code, errors, _ = verify_draft(cfg.zoology_dir / fname, common_sources, require_evidence=True)
|
|
assert code == 0, f"{fname} failed: {errors}"
|
|
|
|
eng_sources = load_ledger(cfg.zoology_dir / "taxonomy" / "citations-ledger-english-aq.json")["sources"]
|
|
for fname in (
|
|
"proposal-corporate-board-standard-english-aq.md",
|
|
"proposal-fund-manager-standard-english-aq.md",
|
|
):
|
|
code, errors, _ = verify_draft(cfg.zoology_dir / fname, eng_sources, require_evidence=True)
|
|
assert code == 0, f"{fname} failed: {errors}"
|
|
|
|
|
|
def test_doctor_all_checks_pass() -> None:
|
|
diag = run_diagnostics()
|
|
assert diag["all_checks_passed"] is True
|
|
|
|
|
|
if __name__ == "__main__":
|
|
test_offline_urn_namespaces_and_no_external_https_fonts()
|
|
print("[PASS] test_offline_urn_namespaces_and_no_external_https_fonts")
|
|
test_ciphers_and_bilingual_ledger_parity()
|
|
print("[PASS] test_ciphers_and_bilingual_ledger_parity")
|
|
test_offline_phonetics_fallback_zero_workdir()
|
|
print("[PASS] test_offline_phonetics_fallback_zero_workdir")
|
|
test_read_only_isolation_guard()
|
|
print("[PASS] test_read_only_isolation_guard")
|
|
test_local_config_citation_resolution_and_proposals()
|
|
print("[PASS] test_local_config_citation_resolution_and_proposals")
|
|
test_doctor_all_checks_pass()
|
|
print("[PASS] test_doctor_all_checks_pass")
|
|
print("ALL 6 TEST SUITES PASSED.")
|