feat(core): initialize hyperstitionstudio-core (hyperstitionstud_io.* / urn:io:hyperstitionstud:*) shared library, 4897-entry offline CMUdict fallback, local-config citation resolver, CLI entrypoints, and test suite (v1.2.0)

This commit is contained in:
Hermes Agent committed 2026-11-29 21:06:48 +00:00
commit f8235a2037
32 files changed
+6646

No files matched your search

+83
View File
@@ -0,0 +1,83 @@
#!/usr/bin/env python3
"""
hyperstitionstud_io.ci.doctor — Single-Command Offline Readiness, Font, Schema & SHA-256 Diagnostic (`hs-doctor`).
"""
from __future__ import annotations
import importlib.metadata
import json
from pathlib import Path
from typing import Any
from hyperstitionstud_io.config import load_workspace_config
from hyperstitionstud_io.glossary import sha256_file
EXPECTED_SHA256 = {
"/workspace/technocapital-singularity-zoology/taxonomy/glossary-registry.json": "7564ef40fb3e0e18d1d8547522db431b6a369c40139713b573df6e58b972d43d",
"/workspace/technocapital-singularity-zoology/encyclopedia/encyclopedia-manifest.json": "0d7ce833bb0aa0eea069bf764b2e3b0b36ac2631821c42f3d6bcb897335f8a7d",
}
REQUIRED_FONTS = [
"/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf",
"/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf",
"/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf",
"/usr/share/fonts/truetype/dejavu/DejaVuSansMono-Bold.ttf",
]
def run_diagnostics() -> dict[str, Any]:
cfg = load_workspace_config()
pkgs = {}
for p in ("Pillow", "reportlab", "pypdf", "pdfplumber"):
try:
pkgs[p] = importlib.metadata.version(p)
except importlib.metadata.PackageNotFoundError:
pkgs[p] = None
fonts_ok = {f: Path(f).is_file() for f in REQUIRED_FONTS}
dirs_ok = {k: v.is_dir() for k, v in cfg.paths.items()}
isolation_checks = {}
for p in cfg.read_only_files:
p_str = str(p)
actual = sha256_file(p) if p.is_file() else None
expected = EXPECTED_SHA256.get(p_str)
isolation_checks[p_str] = {
"exists": p.is_file(),
"sha256": actual,
"matches_baseline": (actual == expected) if expected else (actual is not None),
}
fb_path = Path(__file__).resolve().parent.parent / "phonetics" / "cmudict_fallback.json"
fb_count = len(json.loads(fb_path.read_text(encoding="utf-8"))) if fb_path.is_file() else 0
all_ok = (
all(v is not None for v in pkgs.values())
and all(fonts_ok.values())
and all(v["matches_baseline"] for v in isolation_checks.values())
and fb_count >= 190
)
return {
"namespace_urn": cfg.namespace_urn,
"schema_version": cfg.schema_version,
"workspace_config_file": str(cfg.source_file) if cfg.source_file else None,
"all_checks_passed": all_ok,
"python_packages": pkgs,
"truetype_fonts": fonts_ok,
"workspace_directories": dirs_ok,
"offline_cmudict_fallback_entries": fb_count,
"citation_path_mounts": cfg.citation_path_mounts,
"isolation_locks": isolation_checks,
}
def main() -> int:
res = run_diagnostics()
print(json.dumps(res, indent=2))
return 0 if res["all_checks_passed"] else 1
if __name__ == "__main__":
raise SystemExit(main())