feat(portability): add __file__-anchored WORKSPACE_ROOT discovery, cross-OS font resolver, and public HTTP onboarding quickstart (v1.2.0)
This commit is contained in:
1 parent
f8235a2037
commit
4e38541fbf
7 files changed
+227
-103
No files matched your search
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
hyperstitionstud_io.ci.doctor — Single-Command Offline Readiness, Font, Schema & SHA-256 Diagnostic (`hs-doctor`).
|
||||
hyperstitionstud_io.ci.doctor — Location-Independent Environment, Font, Schema & SHA-256 Diagnostic (`hs-doctor`).
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -12,22 +12,23 @@ from typing import Any
|
||||
|
||||
from hyperstitionstud_io.config import load_workspace_config
|
||||
from hyperstitionstud_io.glossary import sha256_file
|
||||
from hyperstitionstud_io.publishing.fonts import resolve_font_path
|
||||
|
||||
EXPECTED_SHA256 = {
|
||||
"/workspace/technocapital-singularity-zoology/taxonomy/glossary-registry.json": "7564ef40fb3e0e18d1d8547522db431b6a369c40139713b573df6e58b972d43d",
|
||||
"/workspace/technocapital-singularity-zoology/encyclopedia/encyclopedia-manifest.json": "0d7ce833bb0aa0eea069bf764b2e3b0b36ac2631821c42f3d6bcb897335f8a7d",
|
||||
EXPECTED_SHA256_BY_SUFFIX = {
|
||||
"taxonomy/glossary-registry.json": "7564ef40fb3e0e18d1d8547522db431b6a369c40139713b573df6e58b972d43d",
|
||||
"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",
|
||||
REQUIRED_FONT_NAMES = [
|
||||
"DejaVuSans.ttf",
|
||||
"DejaVuSans-Bold.ttf",
|
||||
"DejaVuSansMono.ttf",
|
||||
"DejaVuSansMono-Bold.ttf",
|
||||
]
|
||||
|
||||
|
||||
def run_diagnostics() -> dict[str, Any]:
|
||||
cfg = load_workspace_config()
|
||||
def run_diagnostics(workspace_root: str | Path | None = None) -> dict[str, Any]:
|
||||
cfg = load_workspace_config(workspace_root=workspace_root)
|
||||
pkgs = {}
|
||||
for p in ("Pillow", "reportlab", "pypdf", "pdfplumber"):
|
||||
try:
|
||||
@@ -35,14 +36,18 @@ def run_diagnostics() -> dict[str, Any]:
|
||||
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()}
|
||||
fonts_resolved = {
|
||||
fname: str(resolve_font_path(fname)) if resolve_font_path(fname) else "builtin-fallback"
|
||||
for fname in REQUIRED_FONT_NAMES
|
||||
}
|
||||
required_dirs = ("core_dir", "archive_dir", "zoology_dir", "knowledge_graph_dir")
|
||||
dirs_ok = {k: cfg.paths[k].is_dir() for k in required_dirs if k in cfg.paths}
|
||||
|
||||
isolation_checks = {}
|
||||
for p in cfg.read_only_files:
|
||||
p_str = str(p)
|
||||
p_str = p.as_posix()
|
||||
actual = sha256_file(p) if p.is_file() else None
|
||||
expected = EXPECTED_SHA256.get(p_str)
|
||||
expected = next((sha for suf, sha in EXPECTED_SHA256_BY_SUFFIX.items() if p_str.endswith(suf)), None)
|
||||
isolation_checks[p_str] = {
|
||||
"exists": p.is_file(),
|
||||
"sha256": actual,
|
||||
@@ -53,8 +58,8 @@ def run_diagnostics() -> dict[str, Any]:
|
||||
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())
|
||||
pkgs.get("Pillow") is not None
|
||||
and all(dirs_ok.values())
|
||||
and all(v["matches_baseline"] for v in isolation_checks.values())
|
||||
and fb_count >= 190
|
||||
)
|
||||
@@ -62,10 +67,11 @@ def run_diagnostics() -> dict[str, Any]:
|
||||
return {
|
||||
"namespace_urn": cfg.namespace_urn,
|
||||
"schema_version": cfg.schema_version,
|
||||
"workspace_root": str(cfg.workspace_root),
|
||||
"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,
|
||||
"truetype_fonts": fonts_resolved,
|
||||
"workspace_directories": dirs_ok,
|
||||
"offline_cmudict_fallback_entries": fb_count,
|
||||
"citation_path_mounts": cfg.citation_path_mounts,
|
||||
|
||||
Reference in new issue
Block a user