1022 lines
50 KiB
Python
1022 lines
50 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
hyperstitionstud_io.publishing.closeups_sync
|
|
Deterministic Live-DOM-Introspected Homepage UI Closeup Compiler (`hs-closeups-sync`).
|
|
Automatically inspects the actual live HTML/JS/JSON surfaces across the workspace
|
|
(`/calc/`, `/graph/`, `/quant/`, `/learn/`, `/math/`, `/engineering/`, `/ci/`),
|
|
computes a structural UI element fingerprint (`ui-elements-manifest.json`), and
|
|
re-renders all 11 full-width `680x260` Group 3 UI closeups (`site/assets/closeups/*.png`)
|
|
whenever any page's UI elements (`id=...`, `<select><option>`, `.pill`, `<button>`,
|
|
`<section>`, `<table...>`, or corpus counts) are added, modified, or removed.
|
|
|
|
Enforces `PLAN-HOMEPAGE-QUADRANT-CLOSEUPS-TEXT-BOUNDING-BOX-FIT-AND-AUDIT` (Plan #61):
|
|
- Zero mid-word `[:N]` string slicing across all 11 closeups.
|
|
- Dynamic font-ladder fitting (`_fit_font_for_width`, `_draw_box_text`, `_draw_kv_row`).
|
|
- Built-in `verify_closeup_geometry()` verifying Invariants B1 (Enclosing Box Containment),
|
|
B2 (Zero Border Crossings), and B3 (Zero Horizontal Sibling Text Collisions).
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import hashlib
|
|
import json
|
|
import math
|
|
import re
|
|
import shutil
|
|
from pathlib import Path
|
|
from typing import Any
|
|
|
|
from PIL import Image, ImageDraw
|
|
|
|
from hyperstitionstud_io import __version__ as CURRENT_VERSION
|
|
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 = "DejaVuSans.ttf"
|
|
FONT_BOLD = "DejaVuSans-Bold.ttf"
|
|
FONT_MONO = "DejaVuSansMono.ttf"
|
|
FONT_MONO_B = "DejaVuSansMono-Bold.ttf"
|
|
|
|
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 = GROUP3_PALETTE["EMERALD"]
|
|
ROSE = GROUP3_PALETTE["ROSE"]
|
|
VIOLET = GROUP3_PALETTE["VIOLET"]
|
|
|
|
ALL_CLOSEUP_FILENAMES: tuple[str, ...] = (
|
|
"quadrant-1-cybermemetics-calc-graph.png",
|
|
"quadrant-1-tab-2-graph.png",
|
|
"quadrant-2-esoteric-finance-quant.png",
|
|
"quadrant-2-tab-2-bayesian-fred.png",
|
|
"quadrant-2-tab-3-leaderboard-card.png",
|
|
"quadrant-3-info-science-novice-learn-polyglot.png",
|
|
"quadrant-3-tab-2-math-guile.png",
|
|
"quadrant-3-tab-3-math-ts-rust.png",
|
|
"quadrant-4-operators-deployment-vps.png",
|
|
"quadrant-4-tab-2-mcp-etag.png",
|
|
"quadrant-4-tab-3-ci-gates.png",
|
|
)
|
|
|
|
|
|
def _fnt(path: str, size: int) -> Any:
|
|
return load_pillow_font(path, size)
|
|
|
|
|
|
class _TrackedCanvasDraw:
|
|
"""
|
|
Wraps `ImageDraw.ImageDraw` to record every container box (`chamfer` or `rect`)
|
|
and every rendered text bounding box (`textbbox`) for `verify_closeup_geometry()`.
|
|
"""
|
|
|
|
def __init__(self, im: Image.Image) -> None:
|
|
self._d = ImageDraw.Draw(im)
|
|
self.boxes: list[tuple[str, tuple[int, int, int, int]]] = []
|
|
self.texts: list[tuple[tuple[float, float], str, tuple[int, int, int, int]]] = []
|
|
|
|
def __getattr__(self, name: str) -> Any:
|
|
return getattr(self._d, name)
|
|
|
|
def polygon(self, xy: Any, *args: Any, **kwargs: Any) -> Any:
|
|
if isinstance(xy, list) and len(xy) >= 4:
|
|
xs = [int(p[0]) for p in xy]
|
|
ys = [int(p[1]) for p in xy]
|
|
if max(xs) - min(xs) > 20 and max(ys) - min(ys) > 14:
|
|
box = (min(xs), min(ys), max(xs), max(ys))
|
|
if ("chamfer", box) not in self.boxes:
|
|
self.boxes.append(("chamfer", box))
|
|
return self._d.polygon(xy, *args, **kwargs)
|
|
|
|
def rectangle(self, xy: Any, *args: Any, **kwargs: Any) -> Any:
|
|
if isinstance(xy, (list, tuple)) and len(xy) == 4 and isinstance(xy[0], (int, float)):
|
|
bx1, by1, bx2, by2 = int(xy[0]), int(xy[1]), int(xy[2]), int(xy[3])
|
|
# Record UI container boxes (ignore narrow chart bars / progress fill bars without outlines)
|
|
has_outline = kwargs.get("outline") is not None or (len(args) >= 2 and args[1] is not None)
|
|
if has_outline and (bx2 - bx1 > 24) and (by2 - by1 >= 16):
|
|
box = (bx1, by1, bx2, by2)
|
|
if ("rect", box) not in self.boxes:
|
|
self.boxes.append(("rect", box))
|
|
return self._d.rectangle(xy, *args, **kwargs)
|
|
|
|
def text(self, xy: tuple[float, float], text: str, font: Any = None, fill: Any = None, **kwargs: Any) -> Any:
|
|
if text:
|
|
tb = self._d.textbbox(xy, text, font=font)
|
|
self.texts.append(((float(xy[0]), float(xy[1])), str(text), (int(tb[0]), int(tb[1]), int(tb[2]), int(tb[3]))))
|
|
return self._d.text(xy, text, font=font, fill=fill, **kwargs)
|
|
|
|
|
|
def _fit_font_for_width(
|
|
d: _TrackedCanvasDraw,
|
|
text: str,
|
|
max_width: int,
|
|
*,
|
|
preferred_size: int = 12,
|
|
min_size: int = 8,
|
|
bold: bool = False,
|
|
) -> tuple[Any, int, int]:
|
|
font_file = FONT_MONO_B if bold else FONT_MONO
|
|
for sz in range(preferred_size, min_size - 1, -1):
|
|
f = _fnt(font_file, sz)
|
|
tb = d.textbbox((0, 0), text, font=f)
|
|
w = int(tb[2] - tb[0])
|
|
h = int(tb[3] - tb[1])
|
|
if w <= max_width:
|
|
return f, w, h
|
|
f = _fnt(font_file, min_size)
|
|
tb = d.textbbox((0, 0), text, font=f)
|
|
return f, int(tb[2] - tb[0]), int(tb[3] - tb[1])
|
|
|
|
|
|
def _draw_box_text(
|
|
d: _TrackedCanvasDraw,
|
|
box: tuple[int, int, int, int],
|
|
text: str,
|
|
fill: tuple[int, int, int],
|
|
*,
|
|
pad_x: int = 6,
|
|
align: str = "left",
|
|
preferred_size: int = 12,
|
|
min_size: int = 8,
|
|
bold: bool = False,
|
|
y_pos: int | None = None,
|
|
) -> tuple[int, int, int, int]:
|
|
bx1, by1, bx2, by2 = box
|
|
avail_w = max(16, (bx2 - bx1) - 2 * pad_x)
|
|
f, tw, th = _fit_font_for_width(d, text, avail_w, preferred_size=preferred_size, min_size=min_size, bold=bold)
|
|
if align == "center":
|
|
tx = bx1 + max(pad_x, ((bx2 - bx1) - tw) // 2)
|
|
elif align == "right":
|
|
tx = max(bx1 + pad_x, bx2 - pad_x - tw)
|
|
else:
|
|
tx = bx1 + pad_x
|
|
ty = y_pos if y_pos is not None else (by1 + max(2, ((by2 - by1) - th) // 2 - 1))
|
|
d.text((tx, ty), text, font=f, fill=fill)
|
|
return d.texts[-1][2]
|
|
|
|
|
|
def _draw_kv_row(
|
|
d: _TrackedCanvasDraw,
|
|
box: tuple[int, int, int, int],
|
|
key_text: str,
|
|
val_text: str,
|
|
*,
|
|
fill_bg: tuple[int, int, int] = PLATE,
|
|
outline: tuple[int, int, int] = BORDER,
|
|
key_fill: tuple[int, int, int] = GOLD,
|
|
val_fill: tuple[int, int, int] = TEXT,
|
|
key_size: int = 11,
|
|
val_size: int = 11,
|
|
val_bold: bool = False,
|
|
min_val_x: int | None = None,
|
|
) -> None:
|
|
bx1, by1, bx2, by2 = box
|
|
d.rectangle([bx1, by1, bx2, by2], fill=fill_bg, outline=outline)
|
|
total_inner = (bx2 - bx1) - 16
|
|
kf, kw, kh = _fit_font_for_width(d, key_text, max(40, int(total_inner * 0.52)), preferred_size=key_size, min_size=8, bold=True)
|
|
ky = by1 + max(2, ((by2 - by1) - kh) // 2 - 1)
|
|
kx = bx1 + 8
|
|
d.text((kx, ky), key_text, font=kf, fill=key_fill)
|
|
key_tb = d.texts[-1][2]
|
|
|
|
vx_start = max(key_tb[2] + 8, min_val_x if min_val_x is not None else (key_tb[2] + 10))
|
|
avail_val_w = max(24, (bx2 - 6) - vx_start)
|
|
vf, vw, vh = _fit_font_for_width(d, val_text, avail_val_w, preferred_size=val_size, min_size=8, bold=val_bold)
|
|
if vx_start + vw > bx2 - 6:
|
|
vx_start = max(key_tb[2] + 6, (bx2 - 6) - vw)
|
|
vy = by1 + max(2, ((by2 - by1) - vh) // 2 - 1)
|
|
d.text((vx_start, vy), val_text, font=vf, fill=val_fill)
|
|
|
|
|
|
def verify_closeup_geometry(tracked_by_filename: dict[str, _TrackedCanvasDraw]) -> dict[str, Any]:
|
|
"""
|
|
Verify Invariants B1 (Enclosing Box Containment), B2 (Zero Border Crossings),
|
|
and B3 (Zero Horizontal Sibling Text Collisions) across all 11 closeups.
|
|
"""
|
|
breaches: list[dict[str, Any]] = []
|
|
border_crossings: list[dict[str, Any]] = []
|
|
text_overlaps: list[dict[str, Any]] = []
|
|
|
|
for fname, td in tracked_by_filename.items():
|
|
for idx, (xy, txt, tb) in enumerate(td.texts):
|
|
tx1, ty1, tx2, ty2 = tb
|
|
# B1: Smallest enclosing box that contains the text anchor point
|
|
enclosing: list[tuple[int, str, tuple[int, int, int, int]]] = []
|
|
for bkind, (bx1, by1, bx2, by2) in td.boxes:
|
|
if bx1 - 2 <= xy[0] <= bx2 and by1 - 2 <= xy[1] <= by2:
|
|
enclosing.append(((bx2 - bx1) * (by2 - by1), bkind, (bx1, by1, bx2, by2)))
|
|
enclosing.sort(key=lambda item: item[0])
|
|
if enclosing:
|
|
_, bkind, (bx1, by1, bx2, by2) = enclosing[0]
|
|
if tx1 < bx1 + 2 or tx2 > bx2 - 2 or ty1 < by1 + 1 or ty2 > by2 - 1:
|
|
breaches.append(
|
|
{
|
|
"file": fname,
|
|
"text": txt,
|
|
"textbbox": tb,
|
|
"container_kind": bkind,
|
|
"container_box": (bx1, by1, bx2, by2),
|
|
}
|
|
)
|
|
|
|
# B2: Check if text crosses any container border
|
|
for bkind, (bx1, by1, bx2, by2) in td.boxes:
|
|
if bx1 <= tx1 and tx2 <= bx2 and by1 <= ty1 and ty2 <= by2:
|
|
continue
|
|
ix1, iy1 = max(tx1, bx1), max(ty1, by1)
|
|
ix2, iy2 = min(tx2, bx2), min(ty2, by2)
|
|
if ix2 > ix1 and iy2 > iy1:
|
|
border_crossings.append(
|
|
{
|
|
"file": fname,
|
|
"text": txt,
|
|
"textbbox": tb,
|
|
"crossed_kind": bkind,
|
|
"crossed_box": (bx1, by1, bx2, by2),
|
|
}
|
|
)
|
|
|
|
# B3: Check horizontal overlap with sibling text on the same vertical line
|
|
for idx2, (xy2, txt2, tb2) in enumerate(td.texts):
|
|
if idx2 <= idx:
|
|
continue
|
|
if abs(xy[1] - xy2[1]) <= 6:
|
|
if not (tb[2] + 2 <= tb2[0] or tb2[2] + 2 <= tb[0]):
|
|
text_overlaps.append(
|
|
{
|
|
"file": fname,
|
|
"text_a": txt,
|
|
"bbox_a": tb,
|
|
"text_b": txt2,
|
|
"bbox_b": tb2,
|
|
}
|
|
)
|
|
|
|
all_clean = (len(breaches) == 0) and (len(border_crossings) == 0) and (len(text_overlaps) == 0)
|
|
if not all_clean:
|
|
raise AssertionError(
|
|
f"Closeup geometry audit failed: breaches={breaches}, "
|
|
f"border_crossings={border_crossings}, text_overlaps={text_overlaps}"
|
|
)
|
|
return {
|
|
"all_clean": True,
|
|
"checked_closeups": len(tracked_by_filename),
|
|
"breach_count": 0,
|
|
"border_crossing_count": 0,
|
|
"text_overlap_count": 0,
|
|
}
|
|
|
|
|
|
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]:
|
|
"""Extract structural UI element IDs, classes, buttons, inputs, selects, and headings from an HTML surface."""
|
|
clean = re.sub(r"\bv\d+\.\d+\.\d+\b", "vX.Y.Z", html_text)
|
|
ids = sorted(set(re.findall(r'\bid=["\']([^"\']+)["\']', clean)))
|
|
classes = sorted(set(re.findall(r'\bclass=["\']([^"\']+)["\']', clean)))
|
|
buttons = [re.sub(r"<[^>]+>", "", b).strip() for b in re.findall(r"<button[^>]*>(.*?)</button>", clean, flags=re.S)]
|
|
options = [re.sub(r"<[^>]+>", "", o).strip() for o in re.findall(r"<option[^>]*>(.*?)</option>", clean, flags=re.S)]
|
|
inputs = sorted(set(re.findall(r'<input[^>]+placeholder=["\']([^"\']+)["\']', clean)))
|
|
headings = [re.sub(r"<[^>]+>", "", h).strip() for h in re.findall(r"<h[123][^>]*>(.*?)</h[123]>", clean, flags=re.S)]
|
|
payload = {
|
|
"ids": ids,
|
|
"classes": classes,
|
|
"buttons": buttons[:40],
|
|
"options": options[:40],
|
|
"inputs": inputs,
|
|
"headings": headings[:25],
|
|
}
|
|
digest = hashlib.sha256(json.dumps(payload, sort_keys=True, ensure_ascii=False).encode("utf-8")).hexdigest()
|
|
return {
|
|
"ui_structure_sha256": digest,
|
|
"id_count": len(ids),
|
|
"button_count": len(buttons),
|
|
"option_count": len(options),
|
|
"input_count": len(inputs),
|
|
"heading_count": len(headings),
|
|
"ids": ids,
|
|
"inputs": inputs,
|
|
"sample_buttons": buttons[:12],
|
|
"sample_options": options[:12],
|
|
"sample_headings": headings[:8],
|
|
}
|
|
|
|
|
|
def introspect_live_ui_elements(workspace_root: str | Path | None = None) -> dict[str, Any]:
|
|
"""
|
|
Introspect all target web pages and data registries to detect any added/removed UI elements
|
|
and extract live labels/counts for rendering the 11 `680x260` quadrant closeups.
|
|
"""
|
|
cfg = load_workspace_config(workspace_root=workspace_root)
|
|
core = cfg.core_dir
|
|
kg = cfg.knowledge_graph_dir
|
|
calc_dir = cfg.paths["gematria_js_dir"]
|
|
ci_dir = cfg.paths.get("ci_repo_dir") or (cfg.workspace_root / "hyperdope-ci-build")
|
|
|
|
surfaces: dict[str, Path] = {
|
|
"home": core / "site" / "index.html",
|
|
"quant": core / "site" / "quant" / "index.html",
|
|
"learn": core / "site" / "learn" / "index.html",
|
|
"engineering_hub": core / "site" / "engineering" / "index.html",
|
|
"engineering_e4": core / "site" / "engineering" / "mcp-chatbot-rest-and-ipld" / "index.html",
|
|
"math_hub": core / "site" / "math" / "index.html",
|
|
"math_m1": core / "site" / "math" / "base36-algebra-and-primes" / "index.html",
|
|
"graph": kg / "index.html",
|
|
"calc": calc_dir / "index.html",
|
|
}
|
|
|
|
surface_sigs: dict[str, Any] = {}
|
|
for k, p in surfaces.items():
|
|
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"))
|
|
|
|
ts_p = core / "site" / "quant" / "quant-timeseries.json"
|
|
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 = 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 = 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,
|
|
"mcp_tools": 20,
|
|
"watchlist_instruments": 24,
|
|
"fred_macro_series": 14,
|
|
}
|
|
cli_scripts = eng_obj.get("cli_scripts") or {
|
|
"hs-doctor": "ci.doctor:main",
|
|
"hs-mcp": "mcp.server:main",
|
|
"hs-kg-build": "graph.compiler:main",
|
|
"hs-public-smoke": "ci.public_regression:main",
|
|
}
|
|
|
|
db_txt_p = calc_dir / "db.txt"
|
|
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 = load_json_cached(ci_rep_p, copy_result=False) if ci_rep_p.is_file() else {}
|
|
|
|
combined_hash = hashlib.sha256(
|
|
json.dumps(
|
|
{
|
|
"layout_engine": "bounded_box_v2_plan61",
|
|
"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),
|
|
},
|
|
sort_keys=True,
|
|
).encode("utf-8")
|
|
).hexdigest()
|
|
|
|
manifest = {
|
|
"$id": "urn:io:hyperstitionstud:closeups-ui-manifest",
|
|
"ui_elements_fingerprint_sha256": combined_hash,
|
|
"closeup_images": list(ALL_CLOSEUP_FILENAMES),
|
|
"live_metrics": {
|
|
"calc_db_entries": db_entries_count,
|
|
"quant_total_real_bars": total_bars,
|
|
"quant_bayesian_posteriors": post_probs,
|
|
"engineering_counts": eng_counts,
|
|
"cli_scripts_sample": dict(list(sorted(cli_scripts.items()))[:4]),
|
|
"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
|
|
|
|
|
|
def _new_canvas() -> tuple[Image.Image, _TrackedCanvasDraw]:
|
|
im = Image.new("RGB", (680, 260), VOID)
|
|
d = _TrackedCanvasDraw(im)
|
|
for gx in range(0, 680, 32):
|
|
d.line([(gx, 0), (gx, 260)], fill=(12, 18, 30), width=1)
|
|
for gy in range(0, 260, 32):
|
|
d.line([(0, gy), (680, gy)], fill=(12, 18, 30), width=1)
|
|
return im, d
|
|
|
|
|
|
def _draw_chamfer_box(
|
|
d: _TrackedCanvasDraw,
|
|
box: tuple[int, int, int, int],
|
|
fill: tuple[int, int, int],
|
|
outline: tuple[int, int, int],
|
|
chamfer: int = 8,
|
|
pip: tuple[int, int, int] | None = None,
|
|
) -> None:
|
|
_ = chamfer
|
|
draw_group3_chamfered_plate(d, box, fill=fill, attention_color=outline, pip_color=pip)
|
|
|
|
|
|
def render_all_quadrant_closeups(
|
|
workspace_root: str | Path | None = None,
|
|
force: bool = False,
|
|
check_only: bool = False,
|
|
) -> dict[str, Any]:
|
|
"""
|
|
Compare the live UI element fingerprint against `site/assets/closeups/ui-elements-manifest.json`
|
|
and re-render all 11 `680x260` quadrant closeups whenever any page's UI elements change (or when `force=True`).
|
|
Verifies 100% bounding-box containment (`verify_closeup_geometry()`) on every render.
|
|
"""
|
|
cfg = load_workspace_config(workspace_root=workspace_root)
|
|
out_dir = cfg.core_dir / "site" / "assets" / "closeups"
|
|
out_dir.mkdir(parents=True, exist_ok=True)
|
|
manifest_path = out_dir / "ui-elements-manifest.json"
|
|
|
|
with ReadOnlyIsolationGuard(cfg.read_only_files) as guard:
|
|
live_manifest = introspect_live_ui_elements(workspace_root=workspace_root)
|
|
prev_fp = ""
|
|
if manifest_path.is_file():
|
|
try:
|
|
prev_obj = json.loads(manifest_path.read_text(encoding="utf-8"))
|
|
prev_fp = prev_obj.get("ui_elements_fingerprint_sha256", "")
|
|
except Exception:
|
|
prev_fp = ""
|
|
|
|
missing_pngs = [fn for fn in ALL_CLOSEUP_FILENAMES if not (out_dir / fn).is_file()]
|
|
needs_render = force or (prev_fp != live_manifest["ui_elements_fingerprint_sha256"]) or bool(missing_pngs)
|
|
|
|
if check_only:
|
|
return {
|
|
"ok": not needs_render,
|
|
"check_only": True,
|
|
"needs_render": needs_render,
|
|
"missing_pngs": missing_pngs,
|
|
"ui_elements_fingerprint_sha256": live_manifest["ui_elements_fingerprint_sha256"],
|
|
}
|
|
|
|
if not needs_render:
|
|
return {
|
|
"ok": True,
|
|
"rerendered": False,
|
|
"reason": "ui_elements_unchanged",
|
|
"ui_elements_fingerprint_sha256": live_manifest["ui_elements_fingerprint_sha256"],
|
|
"closeup_count": len(ALL_CLOSEUP_FILENAMES),
|
|
}
|
|
|
|
f_hdr = _fnt(FONT_MONO_B, 13)
|
|
f_mono_xs = _fnt(FONT_MONO, 11)
|
|
f_mono = _fnt(FONT_MONO, 12)
|
|
f_mono_b = _fnt(FONT_MONO_B, 12)
|
|
f_mono_md = _fnt(FONT_MONO_B, 14)
|
|
f_mono_lg = _fnt(FONT_MONO_B, 22)
|
|
f_mono_xl = _fnt(FONT_MONO_B, 26)
|
|
|
|
metrics = live_manifest["live_metrics"]
|
|
db_cnt_str = f"{metrics['calc_db_entries']:,}"
|
|
bars_cnt = metrics["quant_total_real_bars"]
|
|
eng_c = metrics["engineering_counts"]
|
|
surfaces = live_manifest["surfaces"]
|
|
|
|
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 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 [])
|
|
|
|
tracked_draws: dict[str, _TrackedCanvasDraw] = {}
|
|
|
|
# 1. Quadrant 01 Tab 1: /calc/ Cipher Matrix (haiperdohpjematreeah)
|
|
im, d = _new_canvas()
|
|
_draw_chamfer_box(d, (10, 10, 670, 250), PLATE, BORDER, chamfer=10, pip=EMERALD)
|
|
d.text((24, 20), "haiperdohpjematreeah • Multi-Cipher Phonetic & Base-36 AQ Matrix", font=f_hdr, fill=EMERALD)
|
|
d.rectangle([24, 44, 656, 74], fill=WELL, outline=EMERALD)
|
|
d.text((34, 51), "Query: sinthetik dayta", font=f_mono_md, fill=TEXT)
|
|
d.text((480, 52), f"db.txt: {db_cnt_str} Entries", font=f_mono, fill=CYAN)
|
|
ciphers = [
|
|
("haiperdohpjematreeah", "292", EMERALD),
|
|
("Phonemic Ingglish AQ", "292", CYAN),
|
|
("Written English AQ", "250", GOLD),
|
|
("Simple Ordinal", "178", ROSE),
|
|
]
|
|
cw = (656 - 24 - 24) // 4
|
|
for i, (clab, cval, ccol) in enumerate(ciphers):
|
|
bx = 24 + i * (cw + 8)
|
|
tile_box = (bx, 84, bx + cw, 152)
|
|
_draw_chamfer_box(d, tile_box, WELL, ccol, chamfer=7, pip=ccol)
|
|
_draw_box_text(d, tile_box, clab, MUTED, pad_x=8, preferred_size=11, min_size=9, y_pos=90)
|
|
d.text((bx + 12, 110), cval, font=f_mono_xl, fill=ccol)
|
|
rows = [
|
|
("sinthetik dayta", "AQ = 292", "Cluster 292 • Gen 1 σ² = 0.00 • Syzygy 4::5"),
|
|
("abstrakt masheen", "AQ = 292", "Cluster 292 • Phonemic Convergence Partner"),
|
|
("shizohnalizis", "AQ = 292", "Cluster 292 • Landian-Deleuzean Attractor"),
|
|
]
|
|
for ri, (rw, raq, rmeta) in enumerate(rows):
|
|
ry = 162 + ri * 27
|
|
d.rectangle([24, ry, 656, ry + 23], fill=(14, 20, 31), outline=BORDER)
|
|
d.text((34, ry + 4), rw, font=f_mono_b, fill=TEXT)
|
|
d.text((230, ry + 4), raq, font=f_mono_b, fill=EMERALD)
|
|
d.text((335, ry + 4), rmeta, font=f_mono, fill=CYAN)
|
|
im.save(out_dir / "quadrant-1-cybermemetics-calc-graph.png", "PNG")
|
|
tracked_draws["quadrant-1-cybermemetics-calc-graph.png"] = d
|
|
|
|
# 2. Quadrant 01 Tab 2: /graph/ Mode 2 ETI Radar
|
|
im, d = _new_canvas()
|
|
_draw_chamfer_box(d, (10, 10, 670, 250), PLATE, BORDER, chamfer=10, pip=CYAN)
|
|
hdr_g = "Mode 2: Concentric ETI Radar & Syzygy Compass" + (" [MinDeg+LOD]" if graph_has_min_deg else "")
|
|
d.text((24, 18), hdr_g, font=f_hdr, fill=CYAN)
|
|
d.rectangle([24, 42, 346, 240], fill=WELL, outline=BORDER)
|
|
cx_r, cy_r = 185, 141
|
|
for r_rad, r_col in [(90, (38, 52, 77)), (64, (45, 65, 95)), (36, (120, 98, 35))]:
|
|
d.ellipse([cx_r - r_rad, cy_r - r_rad, cx_r + r_rad, cy_r + r_rad], outline=r_col, width=1)
|
|
for ang_deg in range(0, 360, 60):
|
|
ar = math.radians(ang_deg)
|
|
d.line([(cx_r, cy_r), (cx_r + int(90 * math.cos(ar)), cy_r + int(90 * math.sin(ar)))], fill=(26, 36, 54), width=1)
|
|
nodes = [
|
|
(cx_r, cy_r, GOLD, "S1 (93)"),
|
|
(cx_r - 48, cy_r - 22, GOLD, "S3 (83)"),
|
|
(cx_r, cy_r - 78, CYAN, "aq:777"),
|
|
(cx_r + 58, cy_r + 8, EMERALD, "sinthetik dayta"),
|
|
(cx_r + 36, cy_r + 58, CYAN, "aq:292"),
|
|
]
|
|
for nx, ny, _, _ in nodes[1:]:
|
|
d.line([(cx_r, cy_r), (nx, ny)], fill=(56, 189, 248), width=2)
|
|
for nx, ny, ncol, nlab in nodes:
|
|
d.ellipse([nx - 7, ny - 7, nx + 7, ny + 7], fill=ncol, outline=VOID)
|
|
tb_n = d.textbbox((0, 0), nlab, font=f_mono_b)
|
|
nw = int(tb_n[2] - tb_n[0])
|
|
lx = nx + 10 if nx >= cx_r else nx - nw - 10
|
|
ly = ny - 7
|
|
if nlab == "aq:777":
|
|
lx, ly = nx - nw // 2, ny - 20
|
|
elif nlab == "S1 (93)":
|
|
lx, ly = nx - nw // 2, ny + 10
|
|
elif lx + nw > 338:
|
|
# Keep label strictly inside radar well [24, 42, 346, 240]
|
|
lx = 338 - nw
|
|
ly = ny - 20
|
|
d.text((lx, ly), nlab, font=f_mono_b, fill=ncol)
|
|
_draw_chamfer_box(d, (358, 42, 656, 240), WELL, CYAN, chamfer=8, pip=CYAN)
|
|
d.text((372, 52), "SELECTED NODE INSPECTOR", font=f_mono_b, fill=GOLD)
|
|
d.text((372, 72), "aq:292 • Cluster 292 Hub", font=f_mono_md, fill=TEXT)
|
|
badges = [
|
|
("Class: AQHub", 88, CYAN),
|
|
("Deg: 38", 68, GOLD),
|
|
("dr_9: 4 (4::5)", 104, EMERALD),
|
|
]
|
|
bx_i = 372
|
|
for btxt, bw, bcol in badges:
|
|
bbox = (bx_i, 96, bx_i + bw, 116)
|
|
d.rectangle(list(bbox), fill=PLATE, outline=bcol)
|
|
_draw_box_text(d, bbox, btxt, bcol, pad_x=5, align="center", preferred_size=10, min_size=8)
|
|
bx_i += bw + 6
|
|
insp_lines = [
|
|
("Filter:", "9-Sum Syzygies • MinDeg ≥ 0"),
|
|
("Gen 1 Locks:", "sinthetik dayta • abstrakt"),
|
|
("Variance:", "σ²_0 = 310.22 -> σ²_1 = 0.00"),
|
|
("Neighbors:", "Top 40 Cap + [Show All]"),
|
|
]
|
|
for li, (lk, lv) in enumerate(insp_lines):
|
|
ly = 128 + li * 25
|
|
_draw_kv_row(d, (372, ly, 644, ly + 21), lk, lv, key_size=11, val_size=10, min_val_x=472)
|
|
im.save(out_dir / "quadrant-1-tab-2-graph.png", "PNG")
|
|
tracked_draws["quadrant-1-tab-2-graph.png"] = d
|
|
|
|
# 3. Quadrant 02 Tab 1: Panel 1 Trajectory & Dose
|
|
im, d = _new_canvas()
|
|
_draw_chamfer_box(d, (10, 10, 670, 250), PLATE, BORDER, chamfer=10, pip=GOLD)
|
|
d.text((24, 18), "PANEL 1: 2-Pane Trajectory & Dose D ∈ {0..4}", font=f_hdr, fill=GOLD)
|
|
win_badge = "[30D|90D|ALL]•" if quant_has_window else ""
|
|
flt_badge = "Filter•" if quant_has_quick_filter else ""
|
|
vox_badge = "Vox:ON•" if quant_has_speech_btn else ""
|
|
pill_box = (398, 16, 656, 36)
|
|
d.rectangle(list(pill_box), fill=WELL, outline=GOLD)
|
|
_draw_box_text(d, pill_box, f"{vox_badge}{win_badge}{flt_badge}NVDA", GOLD, pad_x=6, align="center", preferred_size=10, min_size=8)
|
|
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)
|
|
pts = [(48, 146), (130, 134), (215, 108), (305, 118), (395, 88), (490, 96), (575, 68), (632, 58)]
|
|
d.line(pts, fill=CYAN, width=3)
|
|
for px, py in pts:
|
|
d.ellipse([px - 4, py - 4, px + 4, py + 4], fill=GOLD, outline=VOID)
|
|
d.rectangle([180, 74, 290, 94], fill=PLATE, outline=GOLD)
|
|
_draw_box_text(d, (180, 74, 290, 94), "Scope 1 (137)", GOLD, pad_x=6, align="center", preferred_size=11, bold=True)
|
|
d.rectangle([355, 56, 462, 76], fill=PLATE, outline=EMERALD)
|
|
_draw_box_text(d, (355, 56, 462, 76), "Wire Eq (292)", EMERALD, pad_x=6, align="center", preferred_size=11, bold=True)
|
|
d.rectangle([530, 46, 638, 66], fill=PLATE, outline=CYAN)
|
|
_draw_box_text(d, (530, 46, 638, 66), "Dose D=3 Lock", CYAN, pad_x=6, align="center", preferred_size=11, bold=True)
|
|
d.rectangle([24, 176, 656, 240], fill=(11, 16, 24), outline=BORDER)
|
|
d.text((34, 181), f"Pane 2: 30D Window Confluence Dose Inspector (N = 19 Trading Days • {bars_cnt} Bars)", font=f_mono_xs, fill=MUTED)
|
|
for bi in range(19):
|
|
bx = 36 + bi * 31
|
|
dose = 3 if bi in (4, 11, 16) else (2 if bi % 2 == 0 else 1)
|
|
bh = 10 + dose * 8
|
|
bcol = CYAN if dose == 3 else (EMERALD if dose == 2 else (71, 85, 105))
|
|
d.rectangle([bx, 234 - bh, bx + 22, 234], fill=bcol)
|
|
im.save(out_dir / "quadrant-2-esoteric-finance-quant.png", "PNG")
|
|
tracked_draws["quadrant-2-esoteric-finance-quant.png"] = d
|
|
|
|
# 4. Quadrant 02 Tab 2: Panel 6 Bayesian & Panel 5 FRED
|
|
im, d = _new_canvas()
|
|
_draw_chamfer_box(d, (10, 10, 670, 250), PLATE, BORDER, chamfer=10, pip=GOLD)
|
|
d.text((24, 18), "PANEL 6 & PANEL 5: 3-State Bayesian Regime Posteriors & Real FRED Macro", font=f_hdr, fill=GOLD)
|
|
_draw_chamfer_box(d, (24, 42, 334, 240), WELL, GOLD, chamfer=8, pip=GOLD)
|
|
d.text((38, 52), "PANEL 6: 3-STATE BAYESIAN SIMPLEX", font=f_mono_b, fill=GOLD)
|
|
r1 = float(metrics["quant_bayesian_posteriors"].get("R1_BULL_EXPANSION", 0.24))
|
|
r2 = float(metrics["quant_bayesian_posteriors"].get("R2_PINNED_ISOMETRIC", 0.61))
|
|
r3 = float(metrics["quant_bayesian_posteriors"].get("R3_TAIL_DRAWDOWN_RISK_OFF", 0.15))
|
|
bars_b = [
|
|
("R1 Bull Expansion", r1, f"{r1 * 100:.1f}%", EMERALD),
|
|
("R2 Pinned Dose 2 (-58% P50)", r2, f"{r2 * 100:.1f}%", CYAN),
|
|
("R3 Tail Drawdown (D≥3)", r3, f"{r3 * 100:.1f}%", ROSE),
|
|
]
|
|
for bi, (blab, bval, bpct, bcol) in enumerate(bars_b):
|
|
by = 80 + bi * 44
|
|
d.text((38, by), blab, font=f_mono_xs, fill=TEXT)
|
|
d.text((272, by), bpct, font=f_mono_b, fill=bcol)
|
|
d.rectangle([38, by + 18, 318, by + 32], fill=PLATE, outline=BORDER)
|
|
d.rectangle([38, by + 18, 38 + int(280 * min(1.0, bval)), by + 32], fill=bcol)
|
|
d.rectangle([38, 212, 318, 232], fill=PLATE, outline=CYAN)
|
|
_draw_box_text(d, (38, 212, 318, 232), "Simplex Σ P(R_k|E_t) = 1.0000", CYAN, pad_x=8, preferred_size=11)
|
|
_draw_chamfer_box(d, (346, 42, 656, 240), WELL, CYAN, chamfer=8, pip=CYAN)
|
|
d.text((360, 52), "PANEL 5: 14 REAL FRED MACRO SERIES", font=f_mono_b, fill=CYAN)
|
|
fred_rows = [
|
|
("EFFR / SOFR", "4.58 / 4.68%", "+10 bps Spread"),
|
|
("M2 - M1 Spread", "$3,365.9B", "337 (68th Prime)"),
|
|
("M2 Velocity V", "1.405x", "GDP / M2 Ratio"),
|
|
("10Y - EFFR", "+97 bps", "AQ('97') = 237"),
|
|
("Closed Market", "null", "0 Forward-Fill"),
|
|
]
|
|
for fi, (fk, fv, fn) in enumerate(fred_rows):
|
|
fy = 78 + fi * 30
|
|
rbox = (360, fy, 642, fy + 25)
|
|
d.rectangle(list(rbox), fill=PLATE, outline=BORDER)
|
|
f_k = _fnt(FONT_MONO_B, 10)
|
|
f_v = _fnt(FONT_MONO_B, 10)
|
|
f_n = _fnt(FONT_MONO, 10)
|
|
d.text((366, fy + 6), fk, font=f_k, fill=GOLD)
|
|
d.text((466, fy + 6), fv, font=f_v, fill=TEXT)
|
|
d.text((544, fy + 6), fn, font=f_n, fill=EMERALD)
|
|
im.save(out_dir / "quadrant-2-tab-2-bayesian-fred.png", "PNG")
|
|
tracked_draws["quadrant-2-tab-2-bayesian-fred.png"] = d
|
|
|
|
# 5. Quadrant 02 Tab 3: Panel 2 6-Lens Leaderboard & TCG Card
|
|
im, d = _new_canvas()
|
|
_draw_chamfer_box(d, (10, 10, 670, 250), PLATE, BORDER, chamfer=10, pip=GOLD)
|
|
hdr_q2_t3 = "PANEL 2 & 3: #lensSelect 6-Lens Leaderboard & TCG Card" if quant_has_lens_select else "PANEL 2 & 3: 6-Lens Leaderboard & One-Shot TCG Card"
|
|
d.text((24, 18), hdr_q2_t3, font=f_hdr, fill=GOLD)
|
|
if quant_has_ui_indicator:
|
|
ind_box = (476, 15, 656, 35)
|
|
d.rectangle(list(ind_box), fill=WELL, outline=GOLD)
|
|
_draw_box_text(d, ind_box, "▼ UI: #lensSelect", GOLD, pad_x=8, align="center", preferred_size=11)
|
|
_draw_chamfer_box(d, (24, 42, 416, 240), WELL, GOLD, chamfer=8, pip=GOLD)
|
|
lenses = [("[Fund Mgr]", 84), ("[TierZoo]", 78), ("[Board]", 66), ("[Sabermetric]", 104)]
|
|
lx = 36
|
|
for li, (ltxt, lw) in enumerate(lenses):
|
|
lbox = (lx, 50, lx + lw, 70)
|
|
d.rectangle(list(lbox), fill=PLATE, outline=GOLD if li == 0 else BORDER)
|
|
_draw_box_text(d, lbox, ltxt, GOLD if li == 0 else MUTED, pad_x=5, align="center", preferred_size=10, min_size=8)
|
|
lx += lw + 8
|
|
t_rows = [
|
|
("#1 S1 Cybernetic", "ETI 93", "Tier S+", "NVDA/PLTR/MSFT", GOLD),
|
|
("#2 S2 High-Freq", "ETI 90", "Tier S", "COIN/CME/VIRT", CYAN),
|
|
("#3 S6 Sovereign", "ETI 87", "Tier S", "BLK/JPM/GS", EMERALD),
|
|
("#4 S3 Lithography", "ETI 83", "Tier A", "ASML/TSM/AVGO", ROSE),
|
|
("#5 M3 Convergence", "ETI 76", "Tier B", "AQ 292 / 333", VIOLET),
|
|
]
|
|
f_tr_b = _fnt(FONT_MONO_B, 10)
|
|
f_tr = _fnt(FONT_MONO, 10)
|
|
for ti, (tname, teti, ttier, tsyms, tcol) in enumerate(t_rows):
|
|
ty = 80 + ti * 30
|
|
d.rectangle([36, ty, 404, ty + 25], fill=PLATE, outline=BORDER)
|
|
d.text((42, ty + 6), tname, font=f_tr_b, fill=TEXT)
|
|
d.text((172, ty + 6), teti, font=f_tr_b, fill=tcol)
|
|
d.text((228, ty + 6), ttier, font=f_tr, fill=GOLD)
|
|
d.text((288, ty + 6), tsyms, font=f_tr, fill=MUTED)
|
|
_draw_chamfer_box(d, (428, 42, 656, 240), WELL, CYAN, chamfer=8, pip=CYAN)
|
|
d.text((440, 52), "NVDA • S3 / S1 APEX", font=f_mono_b, fill=CYAN)
|
|
_draw_box_text(d, (428, 42, 656, 240), "envideea • AQ = 137 (33rd Prime)", GOLD, pad_x=10, preferred_size=10, min_size=9, y_pos=70)
|
|
stats = [("CAP", 96, GOLD), ("VEL", 92, CYAN), ("COL", 88, EMERALD), ("ARM", 85, ROSE)]
|
|
for si, (slab, sval, scol) in enumerate(stats):
|
|
sy = 94 + si * 26
|
|
d.text((442, sy), slab, font=f_mono_b, fill=TEXT)
|
|
d.rectangle([484, sy + 2, 604, sy + 14], fill=PLATE, outline=BORDER)
|
|
d.rectangle([484, sy + 2, 484 + int(1.2 * sval), sy + 14], fill=scol)
|
|
d.text((612, sy), str(sval), font=f_mono_b, fill=scol)
|
|
d.rectangle([442, 204, 642, 228], fill=PLATE, outline=EMERALD)
|
|
_draw_box_text(d, (442, 204, 642, 228), "CIDv1: baguqeera... (35ms)", EMERALD, pad_x=8, preferred_size=10)
|
|
im.save(out_dir / "quadrant-2-tab-3-leaderboard-card.png", "PNG")
|
|
tracked_draws["quadrant-2-tab-3-leaderboard-card.png"] = d
|
|
|
|
# 6. Quadrant 03 Tab 1: /learn/ Prereq Track
|
|
im, d = _new_canvas()
|
|
_draw_chamfer_box(d, (10, 10, 670, 250), PLATE, BORDER, chamfer=10, pip=EMERALD)
|
|
learn_hdr = (
|
|
"GRIMOIRE CODEX OF THE 6 SEALS (/learn/) • First-Principles Math & Sigils"
|
|
if (learn_has_seal_ribbon or learn_has_sigil_svg)
|
|
else "NOVICE PREREQUISITE LADDER (/learn/) • High-School Math to Combinators"
|
|
)
|
|
d.text((24, 18), learn_hdr, font=f_hdr, fill=EMERALD)
|
|
_draw_chamfer_box(d, (24, 42, 344, 240), WELL, EMERALD, chamfer=8, pip=EMERALD)
|
|
d.text((38, 52), "STEP-BY-STEP PREREQUISITE TRACK", font=f_mono_b, fill=EMERALD)
|
|
levels = [
|
|
("Level 1", "Base-36 Place Value & Mod-9"),
|
|
("Level 2", "Set Maps & Pop Variance σ²"),
|
|
("Level 3", "Property Graphs & Dot Prod"),
|
|
("Level 4", "Bayes Simplex & Z-Calculus"),
|
|
]
|
|
for li, (llab, ldesc) in enumerate(levels):
|
|
ly = 76 + li * 30
|
|
_draw_kv_row(d, (38, ly, 330, ly + 25), llab, ldesc, key_size=11, val_size=10, min_val_x=108)
|
|
d.rectangle([38, 202, 330, 228], fill=PLATE, outline=CYAN)
|
|
_draw_box_text(d, (38, 202, 330, 228), "Free Links: MIT 6.042J • 3Blue1Brown", CYAN, pad_x=8, preferred_size=10)
|
|
_draw_chamfer_box(d, (356, 42, 656, 240), WELL, CYAN, chamfer=8, pip=CYAN)
|
|
d.text((370, 52), "MODULE M01: BASE-36 DECOMPOSITION", font=f_mono_b, fill=CYAN)
|
|
d.rectangle([370, 74, 642, 102], fill=PLATE, outline=EMERALD)
|
|
d.text((380, 81), "Input Specimen: LEMUR", font=f_mono_md, fill=TEXT)
|
|
letters = [("L", "21"), ("E", "14"), ("M", "22"), ("U", "30"), ("R", "27")]
|
|
for idx, (ch, val) in enumerate(letters):
|
|
lx = 370 + idx * 54
|
|
d.rectangle([lx, 112, lx + 48, 168], fill=PLATE, outline=GOLD)
|
|
d.text((lx + 16, 118), ch, font=f_mono_md, fill=TEXT)
|
|
d.text((lx + 12, 142), val, font=f_mono_b, fill=GOLD)
|
|
res_box = (370, 178, 642, 228)
|
|
d.rectangle(list(res_box), fill=PLATE, outline=EMERALD)
|
|
d.text((382, 185), "21 + 14 + 22 + 30 + 27 = 114", font=f_mono_md, fill=EMERALD)
|
|
_draw_box_text(d, res_box, "Mod-9 Digital Root dr_9(114) = 6 (3::6)", CYAN, pad_x=10, preferred_size=10, min_size=9, y_pos=206)
|
|
im.save(out_dir / "quadrant-3-info-science-novice-learn-polyglot.png", "PNG")
|
|
tracked_draws["quadrant-3-info-science-novice-learn-polyglot.png"] = d
|
|
|
|
# 7. Quadrant 03 Tab 2: /math/ 2-Col Guile & Z-REPL
|
|
im, d = _new_canvas()
|
|
_draw_chamfer_box(d, (10, 10, 670, 250), PLATE, BORDER, chamfer=10, pip=CYAN)
|
|
d.text((24, 18), "POLYGLOT LENS [λ GUILE ACTIVE] • 2-Column Spec & Step AST Trace", font=f_hdr, fill=CYAN)
|
|
pills = [("OFF", False), ("λ GUILE", True), ("TS TYPESCRIPT", False), ("Rs RUST", False), ("≡ ALL 3", False)]
|
|
px = 24
|
|
for ptxt, pact in pills:
|
|
pw = len(ptxt) * 8 + 20
|
|
pbox = (px, 40, px + pw, 62)
|
|
d.rectangle(list(pbox), fill=(18, 28, 46) if pact else WELL, outline=GOLD if pact else BORDER)
|
|
_draw_box_text(d, pbox, ptxt, GOLD if pact else MUTED, pad_x=6, align="center", preferred_size=10)
|
|
px += pw + 8
|
|
_draw_chamfer_box(d, (24, 70, 334, 182), WELL, CYAN, chamfer=7, pip=CYAN)
|
|
d.text((36, 78), "1. Formal Math & Python 3.12", font=f_mono_b, fill=CYAN)
|
|
d.text((36, 102), "AQ(w) = Σ val_36(c_i)", font=f_mono_b, fill=TEXT)
|
|
d.text((36, 126), "from hyperstitionstud_io.ciphers \\", font=f_mono_xs, fill=MUTED)
|
|
d.text((36, 144), " import compute_aq", font=f_mono_xs, fill=MUTED)
|
|
d.text((36, 162), "compute_aq('LEMUR') # => 114", font=f_mono_b, fill=EMERALD)
|
|
_draw_chamfer_box(d, (346, 70, 656, 182), WELL, GOLD, chamfer=7, pip=GOLD)
|
|
d.text((358, 78), "2. λ GNU Guile Scheme (Z-Calculus)", font=f_mono_b, fill=GOLD)
|
|
d.text((358, 102), "(define aq-base36 (Z (lambda (r) ...)))", font=f_mono_xs, fill=MUTED)
|
|
d.text((358, 126), "(aq-base36 \"LEMUR\") ; => 114", font=f_mono_b, fill=TEXT)
|
|
d.text((358, 148), "(prime-factors 666) ; => (2 3 3 37)", font=f_mono_b, fill=EMERALD)
|
|
d.rectangle([24, 190, 656, 240], fill=(10, 15, 24), outline=GOLD)
|
|
d.text((36, 196), "4-Ring Zero-Eval AST Trace (?repl=trace • Ring 2 Quota <= 2000 Steps):", font=f_mono_xs, fill=GOLD)
|
|
d.text((36, 215), "guile> (prime-factors 666) => Step 1: d=2 -> 333 => Normal Form: (2 3 3 37)", font=f_mono_b, fill=EMERALD)
|
|
im.save(out_dir / "quadrant-3-tab-2-math-guile.png", "PNG")
|
|
tracked_draws["quadrant-3-tab-2-math-guile.png"] = d
|
|
|
|
# 8. Quadrant 03 Tab 3: /math/ 2-Col TypeScript & Rust
|
|
im, d = _new_canvas()
|
|
_draw_chamfer_box(d, (10, 10, 670, 250), PLATE, BORDER, chamfer=10, pip=CYAN)
|
|
d.text((24, 18), "STATIC-TYPED AST PARITY • Spacious 2-Column TypeScript & Rust View", font=f_hdr, fill=CYAN)
|
|
_draw_chamfer_box(d, (24, 46, 334, 240), WELL, CYAN, chamfer=8, pip=CYAN)
|
|
d.text((38, 56), "TS TypeScript (Strict ESM AST)", font=f_mono_b, fill=CYAN)
|
|
ts_lines = [
|
|
"export const charAq = (c: string): number =>",
|
|
" /[0-9]/.test(c) ? c.charCodeAt(0) - 48",
|
|
" : c.charCodeAt(0) - 55;",
|
|
"",
|
|
"aqBase36(\"LEMUR\");",
|
|
"// => 114 (Exact Parity)",
|
|
"primeFactors(666);",
|
|
"// => [2, 3, 3, 37]",
|
|
]
|
|
for idx, ln in enumerate(ts_lines):
|
|
col = EMERALD if ln.startswith("//") else (TEXT if "=>" not in ln else GOLD)
|
|
d.text((38, 84 + idx * 18), ln, font=f_mono_xs, fill=col)
|
|
_draw_chamfer_box(d, (346, 46, 656, 240), WELL, ROSE, chamfer=8, pip=ROSE)
|
|
d.text((360, 56), "Rs Rust (Zero-Alloc Iterator AST)", font=f_mono_b, fill=ROSE)
|
|
rs_lines = [
|
|
"pub fn aq_base36(s: &str) -> u64 {",
|
|
" s.chars().map(char_aq).sum()",
|
|
"}",
|
|
"",
|
|
"aq_base36(\"LEMUR\");",
|
|
"// => 114_u64",
|
|
"prime_factors(666_u64);",
|
|
"// => vec![2, 3, 3, 37]",
|
|
]
|
|
for idx, ln in enumerate(rs_lines):
|
|
col = EMERALD if ln.startswith("//") else TEXT
|
|
d.text((360, 84 + idx * 18), ln, font=f_mono_xs, fill=col)
|
|
im.save(out_dir / "quadrant-3-tab-3-math-ts-rust.png", "PNG")
|
|
tracked_draws["quadrant-3-tab-3-math-ts-rust.png"] = d
|
|
|
|
# 9. Quadrant 04 Tab 1: /engineering/ DevOps & CLIs
|
|
im, d = _new_canvas()
|
|
_draw_chamfer_box(d, (10, 10, 670, 250), PLATE, BORDER, chamfer=10, pip=ROSE)
|
|
d.text((24, 18), "ENGINEERING ARCHITECTURE • 4 Core Counters, Two-Script DevOps & CLIs", font=f_hdr, fill=ROSE)
|
|
tiles = [
|
|
("Repositories", str(eng_c.get("repositories", 6)), CYAN),
|
|
("CLI Entrypoints", str(eng_c.get("cli_entrypoints", 17)), GOLD),
|
|
("MCP & REST Tools", str(eng_c.get("mcp_tools", 20)), EMERALD),
|
|
("Watchlist / FRED", f"{eng_c.get('watchlist_instruments', 24)} / {eng_c.get('fred_macro_series', 14)}", ROSE),
|
|
]
|
|
tw = (656 - 24 - 24) // 4
|
|
for idx, (tlab, tval, tcol) in enumerate(tiles):
|
|
tx = 24 + idx * (tw + 8)
|
|
_draw_chamfer_box(d, (tx, 42, tx + tw, 92), WELL, tcol, chamfer=6, pip=tcol)
|
|
d.text((tx + 10, 48), tlab, font=f_mono_xs, fill=MUTED)
|
|
d.text((tx + 12, 64), tval, font=f_mono_lg, fill=tcol)
|
|
_draw_chamfer_box(d, (24, 102, 334, 240), WELL, ROSE, chamfer=8, pip=ROSE)
|
|
d.text((36, 112), "TWO-SCRIPT OPERATOR INVARIANT", font=f_mono_b, fill=ROSE)
|
|
d.rectangle([36, 134, 322, 164], fill=PLATE, outline=BORDER)
|
|
_draw_box_text(d, (36, 134, 322, 164), "1. ./push-all-to-git-libre-audio.sh", EMERALD, pad_x=8, preferred_size=11)
|
|
d.rectangle([36, 170, 322, 200], fill=PLATE, outline=BORDER)
|
|
_draw_box_text(d, (36, 170, 322, 200), "2. sudo deploy/sync-vps-repos.sh", CYAN, pad_x=8, preferred_size=11)
|
|
d.text((36, 210), "tmpfs RAM • Brotli-11 • 0 /dev/null", font=f_mono_xs, fill=GOLD)
|
|
_draw_chamfer_box(d, (346, 102, 656, 240), WELL, CYAN, chamfer=8, pip=CYAN)
|
|
cli_hdr = "CLI ENTRYPOINTS [Filter]" if eng_has_cli_filter else "CLI ENTRYPOINTS (pyproject.toml)"
|
|
d.text((358, 112), cli_hdr, font=f_mono_b, fill=CYAN)
|
|
clis = [
|
|
("hs-doctor", "ci.doctor:main"),
|
|
("hs-mcp", "mcp.server:main"),
|
|
("hs-kg-build", "graph.compiler:main"),
|
|
("hs-public-smoke", "ci.public_regression:main"),
|
|
]
|
|
for ci_i, (cname, cmod) in enumerate(clis):
|
|
cy_c = 134 + ci_i * 25
|
|
_draw_kv_row(d, (358, cy_c, 644, cy_c + 21), cname, cmod, key_size=11, val_size=10, min_val_x=478)
|
|
im.save(out_dir / "quadrant-4-operators-deployment-vps.png", "PNG")
|
|
tracked_draws["quadrant-4-operators-deployment-vps.png"] = d
|
|
|
|
# 10. Quadrant 04 Tab 2: Unit E4 MCP, REST & ETag 304 Probe
|
|
im, d = _new_canvas()
|
|
_draw_chamfer_box(d, (10, 10, 670, 250), PLATE, BORDER, chamfer=10, pip=ROSE)
|
|
d.text((24, 18), "STATELESS MCP (/mcp), REST v1 (/api/v1/*) & LIVE ETAG 304 PROBE", font=f_hdr, fill=ROSE)
|
|
_draw_chamfer_box(d, (24, 42, 334, 240), WELL, CYAN, chamfer=8, pip=CYAN)
|
|
d.text((36, 52), f"{eng_c.get('mcp_tools', 20)} TOOLS • 14 RESOURCES • 4 PROMPTS", font=f_mono_b, fill=CYAN)
|
|
eps = [
|
|
("POST /mcp", "JSON-RPC Streamable"),
|
|
("GET /api/v1/status", "Health + CIDv1 ETag"),
|
|
("GET /api/v1/quant/*", "24 Tickers + 14 FRED"),
|
|
("GET /api/v1/ipld/cid", "RFC 8785 + SHA-256"),
|
|
("ProtectSystem=strict", "EROFS Verified 20/20"),
|
|
]
|
|
for ei, (ep, edesc) in enumerate(eps):
|
|
ey = 78 + ei * 30
|
|
_draw_kv_row(d, (36, ey, 322, ey + 25), ep, edesc, key_size=10, val_size=10, min_val_x=184)
|
|
right_e4_box = (346, 42, 656, 240)
|
|
_draw_chamfer_box(d, right_e4_box, WELL, EMERALD, chamfer=8, pip=EMERALD)
|
|
_draw_box_text(d, right_e4_box, "LIVE API & ETAG 304 PROBE (#live-smoke-probe)", EMERALD, pad_x=12, preferred_size=11, min_size=9, bold=True, y_pos=52)
|
|
btn_e4_box = (360, 76, 642, 104)
|
|
d.rectangle(list(btn_e4_box), fill=(18, 28, 46), outline=EMERALD)
|
|
_draw_box_text(d, btn_e4_box, "[ ⚛ Run /api/v1/status & ETag 304 Probe ]", TEXT, pad_x=8, align="center", preferred_size=11, min_size=9, bold=True)
|
|
probe_lines = [
|
|
("1st Fetch:", "HTTP 200 OK (4.2 ms)"),
|
|
("ETag:", "\"baguqeera7x9m...\""),
|
|
("2nd Fetch:", "If-None-Match -> HTTP 304 (0.8ms)"),
|
|
("Isolation:", "ReadOnlyIsolationGuard: PASS"),
|
|
]
|
|
for pi, (pk, pv) in enumerate(probe_lines):
|
|
py_p = 114 + pi * 28
|
|
_draw_kv_row(
|
|
d,
|
|
(360, py_p, 642, py_p + 23),
|
|
pk,
|
|
pv,
|
|
key_size=10,
|
|
val_size=10,
|
|
val_fill=EMERALD if "304" in pv or "PASS" in pv else TEXT,
|
|
min_val_x=444,
|
|
)
|
|
im.save(out_dir / "quadrant-4-tab-2-mcp-etag.png", "PNG")
|
|
tracked_draws["quadrant-4-tab-2-mcp-etag.png"] = d
|
|
|
|
# 11. Quadrant 04 Tab 3: /ci/ 4-Gate Pipeline & P1-P6 Smoke
|
|
im, d = _new_canvas()
|
|
_draw_chamfer_box(d, (10, 10, 670, 250), PLATE, BORDER, chamfer=10, pip=ROSE)
|
|
d.text((24, 18), "4-GATE INGGLISH CI PIPELINE (/ci/) & 6-GATE PUBLIC SMOKE SUITE", font=f_hdr, fill=ROSE)
|
|
_draw_chamfer_box(d, (24, 42, 334, 240), WELL, GOLD, chamfer=8, pip=GOLD)
|
|
d.text((36, 52), "4-GATE CI PROVISIONER (db.txt)", font=f_mono_b, fill=GOLD)
|
|
gates = [
|
|
("Gate A: Format", "ASCII Lowercase [PASS]"),
|
|
("Gate B: Phonemic", "CMUdict 126k [PASS]"),
|
|
("Gate C: AQ Parity", "Base-36 Sum Lock [PASS]"),
|
|
("Gate D: Dedup", f"{db_cnt_str} Rows [PASS]"),
|
|
]
|
|
for gi, (gn, gdesc) in enumerate(gates):
|
|
gy = 80 + gi * 36
|
|
_draw_kv_row(d, (36, gy, 322, gy + 30), gn, gdesc, key_size=10, val_size=10, val_fill=EMERALD, min_val_x=162)
|
|
_draw_chamfer_box(d, (346, 42, 656, 240), WELL, EMERALD, chamfer=8, pip=EMERALD)
|
|
d.text((360, 52), "6-GATE PUBLIC SMOKE (P1 - P6)", font=f_mono_b, fill=EMERALD)
|
|
p_gates = [
|
|
("P1: Static Routes", "83/83 HTTP 200 OK"),
|
|
("P2: JSON Registries", "SHA-256 + CIDv1 Lock"),
|
|
("P3: REST API v1", "4/4 Endpoints + ETag"),
|
|
("P4: MCP JSON-RPC", f"{eng_c.get('mcp_tools', 20)} Tools + 14 Res"),
|
|
("P5/P6: Assets & PDF", "0 /Helvetica • Brotli"),
|
|
]
|
|
for pi, (pn, pdesc) in enumerate(p_gates):
|
|
py_g = 78 + pi * 30
|
|
_draw_kv_row(d, (360, py_g, 642, py_g + 25), pn, pdesc, key_fill=CYAN, val_fill=EMERALD, key_size=10, val_size=10, min_val_x=496)
|
|
im.save(out_dir / "quadrant-4-tab-3-ci-gates.png", "PNG")
|
|
tracked_draws["quadrant-4-tab-3-ci-gates.png"] = d
|
|
|
|
geometry_audit = verify_closeup_geometry(tracked_draws)
|
|
live_manifest["geometry_audit"] = geometry_audit
|
|
live_manifest["ipld_dag_json_cidv1"] = {"/": compute_dag_json_cidv1({k: v for k, v in live_manifest.items() if k != "ipld_dag_json_cidv1"})}
|
|
manifest_path.write_text(json.dumps(live_manifest, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
|
|
|
|
# Synchronize untracked mockup directory if present
|
|
untracked_closeups = cfg.workspace_root / "untracked" / "homepage-layout-mockups" / "closeups"
|
|
if untracked_closeups.is_dir():
|
|
for fn in ALL_CLOSEUP_FILENAMES:
|
|
src_p = out_dir / fn
|
|
if src_p.is_file():
|
|
shutil.copy2(src_p, untracked_closeups / fn)
|
|
|
|
return {
|
|
"ok": True,
|
|
"rerendered": True,
|
|
"ui_elements_fingerprint_sha256": live_manifest["ui_elements_fingerprint_sha256"],
|
|
"cidv1": live_manifest["ipld_dag_json_cidv1"]["/"],
|
|
"closeup_count": len(ALL_CLOSEUP_FILENAMES),
|
|
"geometry_audit": geometry_audit,
|
|
"isolation_receipt": guard.audit_receipt(),
|
|
}
|
|
|
|
|
|
def main(argv: list[str] | None = None) -> int:
|
|
ap = argparse.ArgumentParser(
|
|
prog="hs-closeups-sync",
|
|
description="Inspect live DOM UI elements across all pages and re-render homepage 680x260 UI closeups whenever UI elements are added or removed.",
|
|
)
|
|
ap.add_argument("--force", action="store_true", help="Force re-rendering all 11 closeups even if UI element fingerprint is unchanged.")
|
|
ap.add_argument("--check", action="store_true", help="Verify closeups match the current live UI element fingerprint without modifying files.")
|
|
args = ap.parse_args(argv)
|
|
res = render_all_quadrant_closeups(force=args.force, check_only=args.check)
|
|
print(json.dumps(res, indent=2))
|
|
return 0 if res.get("ok") else 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|