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

@@ -20,29 +20,34 @@ import re
from pathlib import Path
from typing import Any
from PIL import Image, ImageDraw, ImageFont
from PIL import Image, ImageDraw
from hyperstitionstud_io import __version__ as CURRENT_VERSION
from hyperstitionstud_io.config import load_workspace_config
from hyperstitionstud_io.config import load_json_cached, load_workspace_config
from hyperstitionstud_io.glossary import ReadOnlyIsolationGuard
from hyperstitionstud_io.ipld import compute_dag_json_cidv1
from hyperstitionstud_io.publishing.fonts import (
GROUP3_PALETTE,
draw_group3_chamfered_plate,
load_pillow_font,
)
FONT_SANS = "/usr/share/fonts/google-noto/NotoSans-Regular.ttf"
FONT_BOLD = "/usr/share/fonts/google-noto/NotoSans-Bold.ttf"
FONT_MONO = "/usr/share/fonts/dejavu-sans-mono-fonts/DejaVuSansMono.ttf"
FONT_MONO_B = "/usr/share/fonts/dejavu-sans-mono-fonts/DejaVuSansMono-Bold.ttf"
FONT_SANS = "DejaVuSans.ttf"
FONT_BOLD = "DejaVuSans-Bold.ttf"
FONT_MONO = "DejaVuSansMono.ttf"
FONT_MONO_B = "DejaVuSansMono-Bold.ttf"
VOID = (7, 9, 13)
PLATE = (12, 16, 23)
WELL = (18, 24, 34)
BORDER = (30, 41, 59)
TEXT = (241, 245, 249)
MUTED = (148, 163, 184)
CYAN = (56, 189, 248)
VOID = GROUP3_PALETTE["BG_VOID"]
PLATE = GROUP3_PALETTE["BG_ODD"]
WELL = GROUP3_PALETTE["BG_EVEN"]
BORDER = GROUP3_PALETTE["BORDER_MUTED"]
TEXT = GROUP3_PALETTE["TXT_PRI"]
MUTED = GROUP3_PALETTE["TXT_SEC"]
CYAN = GROUP3_PALETTE["CYAN"]
GOLD = (245, 198, 48)
EMERALD = (52, 211, 153)
ROSE = (251, 113, 133)
VIOLET = (167, 139, 250)
EMERALD = GROUP3_PALETTE["EMERALD"]
ROSE = GROUP3_PALETTE["ROSE"]
VIOLET = GROUP3_PALETTE["VIOLET"]
ALL_CLOSEUP_FILENAMES: tuple[str, ...] = (
"quadrant-1-cybermemetics-calc-graph.png",
@@ -60,10 +65,35 @@ ALL_CLOSEUP_FILENAMES: tuple[str, ...] = (
def _fnt(path: str, size: int) -> Any:
try:
return ImageFont.truetype(path, size)
except Exception:
return ImageFont.load_default()
return load_pillow_font(path, size)
def _extract_js_ui_signature(js_text: str) -> dict[str, Any]:
"""
Strategy 4A (Plan #51): Introspect companion `.js` files (`quant-app.js`, `quant-tutorials.js`,
`learn-app.js`, `hs-guile-scheme-repl.js`) for dynamic DOM IDs, episode/scene definitions,
highlightable UI targets, and control labels.
"""
clean = re.sub(r"\bv\d+\.\d+\.\d+\b", "vX.Y.Z", js_text)
dom_ids = sorted(set(re.findall(r'getElementById\(\s*["\']([^"\']+)["\']\s*\)', clean)))
ui_targets = sorted(set(re.findall(r'uiTargets:\s*\[([^\]]+)\]', clean)))
ep_codes = re.findall(r'code:\s*["\'](Ep\s*\d+)["\']', clean)
speech_texts = re.findall(r'speechText:\s*["\']([^"\']+)["\']', clean)
lens_keys = sorted(set(re.findall(r'selectedLens:\s*["\']([^"\']+)["\']', clean)))
payload = {
"dom_ids": dom_ids,
"ui_targets": ui_targets,
"ep_codes": ep_codes,
"speech_text_count": len(speech_texts),
"lens_keys": lens_keys,
"has_ui_indicator_badge": "tutUiElementIndicator" in clean,
"has_lens_select_highlight": '"lensSelect"' in clean,
}
digest = hashlib.sha256(json.dumps(payload, sort_keys=True, ensure_ascii=False).encode("utf-8")).hexdigest()
return {
"js_ui_sha256": digest,
**payload,
}
def _extract_dom_signature(html_text: str) -> dict[str, Any]:
@@ -127,22 +157,33 @@ def introspect_live_ui_elements(workspace_root: str | Path | None = None) -> dic
if p.is_file():
surface_sigs[k] = _extract_dom_signature(p.read_text(encoding="utf-8"))
js_surfaces: dict[str, Path] = {
"quant_app_js": core / "site" / "quant" / "quant-app.js",
"quant_tutorials_js": core / "site" / "quant" / "quant-tutorials.js",
"learn_app_js": core / "site" / "learn" / "learn-app.js",
"polyglot_repl_js": core / "site" / "assets" / "hs-guile-scheme-repl.js",
}
js_sigs: dict[str, Any] = {}
for jk, jp in js_surfaces.items():
if jp.is_file():
js_sigs[jk] = _extract_js_ui_signature(jp.read_text(encoding="utf-8"))
# Live data counts from registries
ts_p = core / "site" / "quant" / "quant-timeseries.json"
ts_obj = json.loads(ts_p.read_text(encoding="utf-8")) if ts_p.is_file() else {}
ts_obj = load_json_cached(ts_p, copy_result=False) if ts_p.is_file() else {}
total_bars = sum(
sum(1 for b in (inst.get("bars") or []) if b.get("data_available"))
for inst in (ts_obj.get("instruments") or [])
)
brf_p = core / "site" / "quant" / "daily-brief-latest.json"
brf_obj = json.loads(brf_p.read_text(encoding="utf-8")) if brf_p.is_file() else {}
brf_obj = load_json_cached(brf_p, copy_result=False) if brf_p.is_file() else {}
post_probs = (
((brf_obj.get("agenda_1_executive_summary") or {}).get("bayesian_regime_inference") or {}).get("posterior_probabilities")
or {"R1_BULL_EXPANSION": 0.24, "R2_PINNED_ISOMETRIC": 0.61, "R3_TAIL_DRAWDOWN_RISK_OFF": 0.15}
)
eng_p = core / "site" / "engineering" / "engineering-manifest.json"
eng_obj = json.loads(eng_p.read_text(encoding="utf-8")) if eng_p.is_file() else {}
eng_obj = load_json_cached(eng_p, copy_result=False) if eng_p.is_file() else {}
eng_counts = eng_obj.get("introspected_counts") or {
"repositories": 6,
"cli_entrypoints": 17,
@@ -161,12 +202,13 @@ def introspect_live_ui_elements(workspace_root: str | Path | None = None) -> dic
db_entries_count = sum(1 for _ in db_txt_p.open(encoding="utf-8")) if db_txt_p.is_file() else 231615
ci_rep_p = ci_dir / "ci-audit-report.json"
ci_obj = json.loads(ci_rep_p.read_text(encoding="utf-8")) if ci_rep_p.is_file() else {}
ci_obj = load_json_cached(ci_rep_p, copy_result=False) if ci_rep_p.is_file() else {}
combined_hash = hashlib.sha256(
json.dumps(
{
"surfaces": {k: v["ui_structure_sha256"] for k, v in sorted(surface_sigs.items())},
"js_surfaces": {k: v["js_ui_sha256"] for k, v in sorted(js_sigs.items())},
"total_bars": total_bars,
"db_entries_count": db_entries_count,
"mcp_tools": eng_counts.get("mcp_tools", 20),
@@ -188,6 +230,7 @@ def introspect_live_ui_elements(workspace_root: str | Path | None = None) -> dic
"ci_keep_rate_pct": ci_obj.get("keep_rate_pct", 100.0),
},
"surfaces": surface_sigs,
"js_surfaces": js_sigs,
}
manifest["ipld_dag_json_cidv1"] = {"/": compute_dag_json_cidv1(manifest)}
return manifest
@@ -211,11 +254,8 @@ def _draw_chamfer_box(
chamfer: int = 8,
pip: tuple[int, int, int] | None = None,
) -> None:
x0, y0, x1, y1 = box
pts = [(x0, y0), (x1 - chamfer, y0), (x1, y0 + chamfer), (x1, y1), (x0, y1)]
d.polygon(pts, fill=fill, outline=outline)
if pip:
d.rectangle([x0, y0, x0 + 3, y1], fill=pip)
_ = chamfer
draw_group3_chamfered_plate(d, box, fill=fill, attention_color=outline, pip_color=pip)
def render_all_quadrant_closeups(
@@ -277,10 +317,15 @@ def render_all_quadrant_closeups(
eng_c = metrics["engineering_counts"]
surfaces = live_manifest["surfaces"]
# Detect live controls on /graph/, /quant/, /learn/, /engineering/
# Detect live controls on /graph/, /quant/, /learn/, /engineering/ (HTML + JS)
quant_ids = set(surfaces.get("quant", {}).get("ids") or [])
quant_tut_js = (live_manifest.get("js_surfaces") or {}).get("quant_tutorials_js") or {}
graph_has_min_deg = "minDegreeFilter" in (surfaces.get("graph", {}).get("ids") or [])
quant_has_window = "timeWindowPills" in (surfaces.get("quant", {}).get("ids") or [])
quant_has_quick_filter = "tickerQuickFilter" in (surfaces.get("quant", {}).get("ids") or [])
quant_has_window = "timeWindowPills" in quant_ids
quant_has_quick_filter = "tickerQuickFilter" in quant_ids
quant_has_speech_btn = "tutSpeechBtn" in quant_ids
quant_has_lens_select = "lensSelect" in quant_ids
quant_has_ui_indicator = bool(quant_tut_js.get("has_ui_indicator_badge") or ("tutUiElementIndicator" in quant_ids))
learn_has_seal_ribbon = "grimoireSealRibbon" in (surfaces.get("learn", {}).get("ids") or [])
learn_has_sigil_svg = "grimoireSigilSvg" in (surfaces.get("learn", {}).get("ids") or [])
eng_has_cli_filter = "engCliFilterInput" in (surfaces.get("engineering_hub", {}).get("ids") or [])
@@ -369,14 +414,15 @@ def render_all_quadrant_closeups(
d.text((466, ly + 3), lv[:26], font=f_mono_xs, fill=TEXT)
im.save(out_dir / "quadrant-1-tab-2-graph.png", "PNG")
# 3. Quadrant 02 Tab 1: Panel 1 Trajectory & Dose
# 3. Quadrant 02 Tab 1: Panel 1 Trajectory & Dose (dynamically reflects #tutSpeechBtn, #timeWindowPills, #tickerQuickFilter)
im, d = _new_canvas()
_draw_chamfer_box(d, (10, 10, 670, 250), PLATE, BORDER, chamfer=10, pip=GOLD)
d.text((24, 18), "PANEL 1: Synchronized 2-Pane Trajectory & Dose D ∈ {0..4}", font=f_hdr, fill=GOLD)
win_badge = "[30D|90D|ALL] • " if quant_has_window else ""
flt_badge = "QuickFilter • " if quant_has_quick_filter else ""
d.rectangle([416, 16, 656, 36], fill=WELL, outline=GOLD)
d.text((424, 19), f"{win_badge}{flt_badge}NVDA (S3)", font=f_mono_xs, fill=GOLD)
win_badge = "[30D|90D|ALL]•" if quant_has_window else ""
flt_badge = "Filter•" if quant_has_quick_filter else ""
vox_badge = "🔊Voice:ON•" if quant_has_speech_btn else ""
d.rectangle([388, 16, 656, 36], fill=WELL, outline=GOLD)
d.text((394, 19), f"{vox_badge}{win_badge}{flt_badge}NVDA", font=f_mono_xs, fill=GOLD)
d.rectangle([24, 42, 656, 168], fill=WELL, outline=BORDER)
d.line([(36, 114), (644, 114)], fill=(180, 50, 70), width=1)
d.text((42, 96), "Entity Threshold: envideea = 137", font=f_mono_xs, fill=ROSE)
@@ -439,10 +485,14 @@ def render_all_quadrant_closeups(
d.text((568, fy + 5), fn[:11], font=f_mono_xs, fill=EMERALD)
im.save(out_dir / "quadrant-2-tab-2-bayesian-fred.png", "PNG")
# 5. Quadrant 02 Tab 3: Panel 2 6-Lens Leaderboard & TCG Card
# 5. Quadrant 02 Tab 3: Panel 2 6-Lens Leaderboard & TCG Card (dynamically reflects #lensSelect & UI indicator badge)
im, d = _new_canvas()
_draw_chamfer_box(d, (10, 10, 670, 250), PLATE, BORDER, chamfer=10, pip=GOLD)
d.text((24, 18), "PANEL 2 & 3: 6-Lens Assemblage Leaderboard & One-Shot TCG Stats Card", font=f_hdr, fill=GOLD)
hdr_q2_t3 = "PANEL 2 & 3: #lensSelect 6-Lens Leaderboard & TCG Card" if quant_has_lens_select else "PANEL 2 & 3: 6-Lens Assemblage Leaderboard & One-Shot TCG Stats Card"
d.text((24, 18), hdr_q2_t3, font=f_hdr, fill=GOLD)
if quant_has_ui_indicator:
d.rectangle([476, 15, 656, 35], fill=WELL, outline=GOLD)
d.text((482, 18), "▼ UI: #lensSelect", font=f_mono_xs, fill=GOLD)
_draw_chamfer_box(d, (24, 42, 416, 240), WELL, GOLD, chamfer=8, pip=GOLD)
lenses = ["[Fund Mgr]", "[TierZoo]", "[Board]", "[Sabermetric]"]
for li, ltxt in enumerate(lenses):
@@ -694,7 +744,7 @@ def render_all_quadrant_closeups(
"ui_elements_fingerprint_sha256": live_manifest["ui_elements_fingerprint_sha256"],
"cidv1": live_manifest["ipld_dag_json_cidv1"]["/"],
"closeup_count": len(ALL_CLOSEUP_FILENAMES),
"isolation_receipt": guard.verification_receipt(),
"isolation_receipt": guard.audit_receipt(),
}