Release v2.17.0: Synchronize deploy scripts, mobile UI, architecture atlas, and regression test suite
This commit is contained in:
1 parent
d3240b3bd1
commit
352f54f30a
24 files changed
+2497
-731
No files matched your search
@@ -11,6 +11,7 @@ import copy
|
||||
import functools
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import tomllib
|
||||
from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
@@ -20,6 +21,138 @@ CORE_REPO_ROOT = Path(__file__).resolve().parents[3]
|
||||
WORKSPACE_ROOT = CORE_REPO_ROOT.parent
|
||||
USER_WORKSPACE_TOML = Path.home() / ".config" / "hyperstitionstud.io" / "workspace.toml"
|
||||
|
||||
CANONICAL_SIX_REPOS: tuple[dict[str, Any], ...] = (
|
||||
{
|
||||
"key": "hyperstitionstudio-core",
|
||||
"aliases": ("hyperstitionstudio-core",),
|
||||
"gitea_slug": "hyperstitionstudio-core",
|
||||
"default_branch": "main",
|
||||
"public_route": "https://hyperstitionstud.io/",
|
||||
},
|
||||
{
|
||||
"key": "ingglish-hyperdope-gematria",
|
||||
"aliases": ("ingglish-hyperdope-gematria",),
|
||||
"gitea_slug": "ingglish-hyperdope-gematria",
|
||||
"default_branch": "main",
|
||||
"public_route": "https://hyperstitionstud.io/archive/00-index-and-methodology.md",
|
||||
},
|
||||
{
|
||||
"key": "technocapital-singularity-zoology",
|
||||
"aliases": ("technocapital-singularity-zoology",),
|
||||
"gitea_slug": "technocapital-singularity-zoology",
|
||||
"default_branch": "main",
|
||||
"public_route": "https://hyperstitionstud.io/zoology/encyclopedia-of-technocapital-singularity-zoology-overview-and-manifest.pdf",
|
||||
},
|
||||
{
|
||||
"key": "encyclopedia-knowledge-graph",
|
||||
"aliases": ("encyclopedia-knowledge-graph",),
|
||||
"gitea_slug": "encyclopedia-knowledge-graph",
|
||||
"default_branch": "main",
|
||||
"public_route": "https://hyperstitionstud.io/graph/index.html",
|
||||
},
|
||||
{
|
||||
"key": "haiperdohp-jemaytreeah",
|
||||
"aliases": ("haiperdohp-jemaytreeah",),
|
||||
"gitea_slug": "haiperdohp-jemaytreeah",
|
||||
"default_branch": "main",
|
||||
"public_route": "https://hyperstitionstud.io/calc/index.html",
|
||||
},
|
||||
{
|
||||
"key": "hyperdope-ci-build",
|
||||
"aliases": ("hyperdope-ci-build", "ingglish-hyperdope-ci"),
|
||||
"gitea_slug": "ingglish-hyperdope-ci",
|
||||
"default_branch": "feat/ingglish-aq-corpus",
|
||||
"public_route": "https://hyperstitionstud.io/ci/ONBOARDING-INGGLISH-AQ.pdf",
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def resolve_workspace_repo_dir(ws_root: Path | str, repo_key: str) -> Path:
|
||||
"""
|
||||
Resolve a canonical repository directory under `ws_root`, transparently handling
|
||||
aliases (`hyperdope-ci-build` vs `ingglish-hyperdope-ci`) and Gitea slugs.
|
||||
"""
|
||||
root = Path(ws_root)
|
||||
cand = root / repo_key
|
||||
if cand.is_dir():
|
||||
return cand
|
||||
for spec in CANONICAL_SIX_REPOS:
|
||||
if repo_key == spec["key"] or repo_key == spec["gitea_slug"] or repo_key in spec["aliases"]:
|
||||
for name in (spec["key"], *spec["aliases"], spec["gitea_slug"]):
|
||||
alt = root / name
|
||||
if alt.is_dir():
|
||||
return alt
|
||||
return root / spec["key"]
|
||||
return cand
|
||||
|
||||
|
||||
def normalize_workspace_relpath(p: Path | str, workspace_root: str | Path | None = None) -> str:
|
||||
"""
|
||||
Normalize a workspace path so paths under `workspace_root` serialize deterministically
|
||||
as `/workspace/...` regardless of host checkout directory.
|
||||
"""
|
||||
if workspace_root is not None:
|
||||
ws_res = str(Path(workspace_root).resolve())
|
||||
else:
|
||||
cfg = load_workspace_config(workspace_root=None)
|
||||
ws_res = str(cfg.workspace_root.resolve())
|
||||
s = str(Path(p).resolve())
|
||||
if s == ws_res:
|
||||
return "/workspace"
|
||||
if s.startswith(ws_res + "/"):
|
||||
return "/workspace" + s[len(ws_res) :]
|
||||
return str(p)
|
||||
|
||||
|
||||
def run_git_stdout(
|
||||
repo_dir: Path,
|
||||
args: list[str],
|
||||
*,
|
||||
strip_leading: bool = True,
|
||||
timeout: float = 5.0,
|
||||
) -> str:
|
||||
"""
|
||||
Execute `git -C <repo_dir> ...` and return stdout cleanly (or `""` on non-repo/error).
|
||||
When `strip_leading=False`, preserves leading whitespace (e.g., for `git status --porcelain`).
|
||||
"""
|
||||
rdir = Path(repo_dir)
|
||||
if not (rdir / ".git").exists():
|
||||
return ""
|
||||
try:
|
||||
res = subprocess.run(
|
||||
["git", "-C", str(rdir), *args],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=timeout,
|
||||
check=False,
|
||||
)
|
||||
if res.returncode == 0:
|
||||
return res.stdout.strip() if strip_leading else res.stdout.rstrip("\r\n")
|
||||
except Exception:
|
||||
pass
|
||||
return ""
|
||||
|
||||
|
||||
@functools.lru_cache(maxsize=64)
|
||||
def _count_lines_by_stat(resolved_path_str: str, st_mtime_ns: int, st_size: int) -> int:
|
||||
_ = (st_mtime_ns, st_size)
|
||||
with Path(resolved_path_str).open("rb") as fh:
|
||||
data = fh.read()
|
||||
if not data:
|
||||
return 0
|
||||
nl_count = data.count(b"\n")
|
||||
return nl_count if data.endswith(b"\n") else nl_count + 1
|
||||
|
||||
|
||||
def count_file_lines_cached(path: str | Path) -> int:
|
||||
"""
|
||||
Count lines in a file cached by `(str(resolved_path), st_mtime_ns, st_size)`.
|
||||
Automatically invalidates when `st_mtime_ns` or `st_size` changes on disk.
|
||||
"""
|
||||
p = Path(path).resolve()
|
||||
st = p.stat()
|
||||
return _count_lines_by_stat(str(p), st.st_mtime_ns, st.st_size)
|
||||
|
||||
|
||||
@functools.lru_cache(maxsize=64)
|
||||
def _parse_json_by_stat(resolved_path_str: str, st_mtime_ns: int, st_size: int) -> Any:
|
||||
@@ -50,23 +183,26 @@ class WorkspaceConfig:
|
||||
|
||||
@property
|
||||
def core_dir(self) -> Path:
|
||||
return self.paths.get("core_dir", self.workspace_root / "hyperstitionstudio-core")
|
||||
return self.paths.get("core_dir", resolve_workspace_repo_dir(self.workspace_root, "hyperstitionstudio-core"))
|
||||
|
||||
@property
|
||||
def archive_dir(self) -> Path:
|
||||
return self.paths.get("archive_dir", self.workspace_root / "ingglish-hyperdope-gematria")
|
||||
return self.paths.get("archive_dir", resolve_workspace_repo_dir(self.workspace_root, "ingglish-hyperdope-gematria"))
|
||||
|
||||
@property
|
||||
def zoology_dir(self) -> Path:
|
||||
return self.paths.get("zoology_dir", self.workspace_root / "technocapital-singularity-zoology")
|
||||
return self.paths.get("zoology_dir", resolve_workspace_repo_dir(self.workspace_root, "technocapital-singularity-zoology"))
|
||||
|
||||
@property
|
||||
def knowledge_graph_dir(self) -> Path:
|
||||
return self.paths.get("knowledge_graph_dir", self.workspace_root / "encyclopedia-knowledge-graph")
|
||||
return self.paths.get("knowledge_graph_dir", resolve_workspace_repo_dir(self.workspace_root, "encyclopedia-knowledge-graph"))
|
||||
|
||||
@property
|
||||
def ci_build_dir(self) -> Path:
|
||||
return self.paths.get("ci_build_dir", self.workspace_root / "hyperstition-ci-build")
|
||||
cand = self.paths.get("ci_build_dir") or self.paths.get("ci_repo_dir")
|
||||
if cand is not None and cand.is_dir():
|
||||
return cand
|
||||
return resolve_workspace_repo_dir(self.workspace_root, "hyperdope-ci-build")
|
||||
|
||||
|
||||
def _rebase_path(raw_path: str | Path, ws_root: Path) -> Path:
|
||||
@@ -105,20 +241,23 @@ def load_workspace_config(
|
||||
|
||||
chosen: Path | None = None
|
||||
for c in candidates:
|
||||
if c.is_file():
|
||||
chosen = c
|
||||
break
|
||||
try:
|
||||
if c.is_file():
|
||||
chosen = c
|
||||
break
|
||||
except OSError:
|
||||
continue
|
||||
|
||||
if chosen is not None and workspace_root is None:
|
||||
ws_root = chosen.resolve().parent
|
||||
|
||||
default_paths = {
|
||||
"core_dir": ws_root / "hyperstitionstudio-core",
|
||||
"archive_dir": ws_root / "ingglish-hyperdope-gematria",
|
||||
"zoology_dir": ws_root / "technocapital-singularity-zoology",
|
||||
"knowledge_graph_dir": ws_root / "encyclopedia-knowledge-graph",
|
||||
"ci_build_dir": ws_root / "hyperdope-ci-build",
|
||||
"gematria_js_dir": ws_root / "haiperdohp-jemaytreeah",
|
||||
"core_dir": resolve_workspace_repo_dir(ws_root, "hyperstitionstudio-core"),
|
||||
"archive_dir": resolve_workspace_repo_dir(ws_root, "ingglish-hyperdope-gematria"),
|
||||
"zoology_dir": resolve_workspace_repo_dir(ws_root, "technocapital-singularity-zoology"),
|
||||
"knowledge_graph_dir": resolve_workspace_repo_dir(ws_root, "encyclopedia-knowledge-graph"),
|
||||
"ci_build_dir": resolve_workspace_repo_dir(ws_root, "hyperdope-ci-build"),
|
||||
"gematria_js_dir": resolve_workspace_repo_dir(ws_root, "haiperdohp-jemaytreeah"),
|
||||
"memes_dir": ws_root / "memes",
|
||||
}
|
||||
default_ro = [
|
||||
@@ -143,6 +282,8 @@ def load_workspace_config(
|
||||
raw_cit = raw.get("citations", {}).get("path_mounts", {})
|
||||
|
||||
resolved_paths = {k: _rebase_path(v, ws_root) for k, v in raw_paths.items()} if raw_paths else default_paths
|
||||
if "ci_build_dir" in resolved_paths and not resolved_paths["ci_build_dir"].is_dir():
|
||||
resolved_paths["ci_build_dir"] = resolve_workspace_repo_dir(ws_root, "hyperdope-ci-build")
|
||||
resolved_ro = [_rebase_path(p, ws_root) for p in raw_iso.get("read_only_files", [])] if raw_iso.get("read_only_files") else default_ro
|
||||
resolved_mounts = {str(_rebase_path(k, ws_root)): str(v) for k, v in raw_cit.items()}
|
||||
|
||||
|
||||
@@ -12,20 +12,28 @@ Provides:
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import re
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from hyperstitionstud_io import __version__ as CURRENT_VERSION
|
||||
from hyperstitionstud_io.config import load_workspace_config
|
||||
from hyperstitionstud_io.glossary import ReadOnlyIsolationGuard
|
||||
from hyperstitionstud_io.ipld import compute_dag_json_cidv1
|
||||
from hyperstitionstud_io.lenses import ENABLED_LENSES
|
||||
from hyperstitionstud_io.mcp.rest import REST_DOMAIN_ALIASES
|
||||
from hyperstitionstud_io.mcp.tools import MCP_TOOLS_SCHEMA
|
||||
from hyperstitionstud_io.publishing.explication_template import (
|
||||
_render_global_nav_html,
|
||||
_render_guile_repl_drawer_html,
|
||||
_render_polyglot_selector_html,
|
||||
_render_prereq_box_html,
|
||||
render_explication_cartridge_html,
|
||||
render_explication_hub_page_html,
|
||||
render_explication_nav_html,
|
||||
render_explication_subpage_html,
|
||||
render_polyglot_cartridge_html,
|
||||
run_explication_cli_main,
|
||||
write_explication_site_bundle,
|
||||
)
|
||||
from hyperstitionstud_io.quant.collector import CANONICAL_WATCHLIST_24
|
||||
from hyperstitionstud_io.quant.macro import FRED_SERIES_SPEC
|
||||
|
||||
@@ -98,104 +106,14 @@ ENGINEERING_GUILE_CARTRIDGES: dict[str, dict[str, str]] = {
|
||||
}
|
||||
|
||||
|
||||
def _render_polyglot_selector_html() -> str:
|
||||
return (
|
||||
'<div id="hsPolyglotModeSelector" class="hs-polyglot-segmented" role="radiogroup" aria-label="Pedagogical Programming Language Lens">'
|
||||
'<span class="hs-polyglot-prefix">LENS:</span>'
|
||||
'<button type="button" id="guileSchemeModeToggle" class="hs-polyglot-seg" role="radio" data-lens-mode="off" aria-checked="true" title="Hide programming language cartridges (Alt+0)">OFF</button>'
|
||||
'<button type="button" class="hs-polyglot-seg" role="radio" data-lens-mode="guile" aria-checked="false" title="GNU Guile Scheme — Z-Combinator & Exact Rationals (Alt+1)"><span class="hs-guile-lambda-badge">λ</span>GUILE</button>'
|
||||
'<button type="button" class="hs-polyglot-seg" role="radio" data-lens-mode="ts" aria-checked="false" title="TypeScript — Static Union Types & Functional Pipelines (Alt+2)"><span class="hs-guile-lambda-badge">TS</span>TYPESCRIPT</button>'
|
||||
'<button type="button" class="hs-polyglot-seg" role="radio" data-lens-mode="rust" aria-checked="false" title="Rust — Ownership, Option<T> & Zero-Cost Iterators (Alt+3)"><span class="hs-guile-lambda-badge">Rs</span>RUST</button>'
|
||||
'<button type="button" class="hs-polyglot-seg" role="radio" data-lens-mode="all" aria-checked="false" title="Side-by-side comparison of Guile Scheme, TypeScript, and Rust (Alt+4)">≡ ALL 3</button>'
|
||||
'<strong id="guileSchemeModeState" style="display:none;">OFF</strong>'
|
||||
'</div>'
|
||||
)
|
||||
|
||||
|
||||
def render_polyglot_cartridge_html(
|
||||
cartridge: dict[str, str],
|
||||
spec_label: str = "1. Formal Specification & Python:",
|
||||
) -> str:
|
||||
import html
|
||||
|
||||
esc_scm = html.escape(cartridge["scm_expr"], quote=True)
|
||||
esc_ts = html.escape(cartridge["ts_expr"], quote=True)
|
||||
esc_rs = html.escape(cartridge["rust_expr"], quote=True)
|
||||
esc_math = html.escape(cartridge["math_view"], quote=True)
|
||||
esc_py = html.escape(cartridge["py_view"], quote=True)
|
||||
esc_title = html.escape(cartridge["title"], quote=True)
|
||||
esc_chal = html.escape(cartridge["challenge"], quote=True)
|
||||
return (
|
||||
'<section class="panel hs-plate-g3 hs-guile-cartridge">'
|
||||
'<div style="display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:0.5rem;">'
|
||||
f'<div style="font-size:0.74rem;font-weight:700;color:var(--cyan);text-transform:uppercase;letter-spacing:0.05em;">λ {esc_title}</div>'
|
||||
'<div style="display:flex;gap:0.25rem;flex-wrap:wrap;align-items:center;">'
|
||||
'<button type="button" class="hs-polyglot-seg" data-lens-mode="guile">λ Guile</button>'
|
||||
'<button type="button" class="hs-polyglot-seg" data-lens-mode="ts">TS TypeScript</button>'
|
||||
'<button type="button" class="hs-polyglot-seg" data-lens-mode="rust">Rs Rust</button>'
|
||||
'<button type="button" class="hs-polyglot-seg" data-lens-mode="all">≡ All 3</button>'
|
||||
'<button type="button" class="hs-polyglot-seg" data-lens-mode="off">Hide</button>'
|
||||
'</div>'
|
||||
'</div>'
|
||||
'<div class="hs-guile-triview">'
|
||||
f'<div class="hs-guile-box"><strong style="color:var(--gold);display:block;margin-bottom:0.2rem;">{spec_label}</strong><code>{esc_math}</code><pre style="white-space:pre-wrap;margin-top:0.25rem;color:var(--text-secondary);">{esc_py}</pre></div>'
|
||||
f'<div class="hs-guile-box hs-lang-box-guile"><div style="display:flex;justify-content:space-between;align-items:center;"><strong style="color:var(--cyan);">λ Guile Scheme (Z-Combinator):</strong><button type="button" class="btn hs-load-in-repl-btn" data-polyglot-lang="guile" data-scheme-expr="{esc_scm}" style="padding:0.12rem 0.4rem;font-size:0.65rem;">REPL →</button></div><code class="hs-guile-code-expr">{esc_scm}</code><div class="hs-guile-eval-result" style="margin-top:0.3rem;font-weight:700;color:var(--emerald);">=> [Select Lens to evaluate]</div></div>'
|
||||
f'<div class="hs-guile-box hs-lang-box-ts"><div style="display:flex;justify-content:space-between;align-items:center;"><strong style="color:var(--gold);">TS TypeScript (Strict AST):</strong><button type="button" class="btn hs-load-in-repl-btn" data-polyglot-lang="ts" data-scheme-expr="{esc_ts}" style="padding:0.12rem 0.4rem;font-size:0.65rem;">REPL →</button></div><code class="hs-ts-code-expr">{esc_ts}</code><div class="hs-ts-eval-result" style="margin-top:0.3rem;font-weight:700;color:var(--emerald);">=> [Select Lens to evaluate]</div></div>'
|
||||
f'<div class="hs-guile-box hs-lang-box-rust"><div style="display:flex;justify-content:space-between;align-items:center;"><strong style="color:var(--emerald);">Rs Rust (Option/Iterator AST):</strong><button type="button" class="btn hs-load-in-repl-btn" data-polyglot-lang="rust" data-scheme-expr="{esc_rs}" style="padding:0.12rem 0.4rem;font-size:0.65rem;">REPL →</button></div><code class="hs-rust-code-expr">{esc_rs}</code><div class="hs-rust-eval-result" style="margin-top:0.3rem;font-weight:700;color:var(--emerald);">=> [Select Lens to evaluate]</div></div>'
|
||||
'</div>'
|
||||
f'<div style="font-size:0.71rem;color:var(--text-secondary);"><strong>Guided Micro-Challenge (4-Ring Zero-Escape Sandbox):</strong> {esc_chal}</div>'
|
||||
'</section>'
|
||||
)
|
||||
|
||||
|
||||
def _render_guile_cartridge_html(key: str) -> str:
|
||||
return render_polyglot_cartridge_html(
|
||||
ENGINEERING_GUILE_CARTRIDGES[key],
|
||||
return render_explication_cartridge_html(
|
||||
ENGINEERING_GUILE_CARTRIDGES,
|
||||
key,
|
||||
spec_label="1. Formal Specification & Python:",
|
||||
)
|
||||
|
||||
|
||||
def _render_guile_repl_drawer_html(rel_prefix: str) -> str:
|
||||
return f"""
|
||||
<aside id="hsGuileReplDrawer" class="hs-plate-g3" aria-label="In-Browser Polyglot Guile Scheme, TypeScript, and Rust Hardened REPL">
|
||||
<div style="display:flex;justify-content:space-between;align-items:center;gap:0.5rem;margin-bottom:0.45rem;">
|
||||
<div style="font-size:0.73rem;font-weight:700;color:var(--cyan);">λ 4-RING HARDENED POLYGLOT REPL (GUILE • TS • RUST • ZERO EVAL)</div>
|
||||
<div style="display:flex;gap:0.4rem;align-items:center;">
|
||||
<select id="hsPolyglotReplLang" style="background:var(--bg-void);color:var(--cyan);border:1px solid var(--cyan);padding:0.15rem 0.35rem;font-family:inherit;font-size:0.68rem;font-weight:700;">
|
||||
<option value="guile">λ Guile Scheme</option>
|
||||
<option value="ts">TS TypeScript</option>
|
||||
<option value="rust">Rs Rust</option>
|
||||
</select>
|
||||
<label style="font-size:0.68rem;color:var(--text-secondary);cursor:pointer;"><input type="checkbox" id="hsGuilePreferFloat" /> Float view</label>
|
||||
<button type="button" id="hsGuileReplCloseBtn" class="btn" style="padding:0.15rem 0.45rem;font-size:0.68rem;">Minimize / Expand</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="hs-repl-body">
|
||||
<div style="display:flex;gap:0.4rem;margin-bottom:0.4rem;flex-wrap:wrap;">
|
||||
<select id="hsGuileReplPreset" style="flex:1;background:var(--bg-void);color:var(--text-main);border:1px solid var(--border);padding:0.28rem;font-family:inherit;font-size:0.7rem;">
|
||||
<option value="">-- Load Preset Polyglot Expression (Guile / TS / Rust) --</option>
|
||||
<option value='guile::(aq-base36 "LEMUR")'>[λ Guile] Base-36 AQ: (aq-base36 "LEMUR") => 114</option>
|
||||
<option value='ts::aqBase36("LEMUR")'>[TS] Base-36 AQ: aqBase36("LEMUR") => 114</option>
|
||||
<option value='rust::aq_base36("LEMUR")'>[Rs Rust] Base-36 AQ: aq_base36("LEMUR") => 114</option>
|
||||
<option value="guile::(prime-factors 666)">[λ Guile] Prime Factors via Z: (prime-factors 666) => (2 3 3 37)</option>
|
||||
<option value="ts::primeFactors(666)">[TS] Prime Factors: primeFactors(666) => [2,3,3,37]</option>
|
||||
<option value="rust::prime_factors(666_u64)">[Rs Rust] Prime Factors: prime_factors(666_u64) => vec![2, 3, 3, 37]</option>
|
||||
<option value="guile::(variance-pop *cluster-292-gen0*)">[λ Guile] Exact Rational Variance (Cluster 292): 4634/9</option>
|
||||
<option value="ts::variancePop([264, 317, 276] as const)">[TS] Cluster 292 Variance: 514.8889</option>
|
||||
<option value="rust::variance_pop(&[264.0, 317.0, 276.0])">[Rs Rust] Cluster 292 Variance: 514.8889</option>
|
||||
<option value="guile::((derivative (lambda (x) (* x x x)) 1e-5) 2.0)">[λ Guile] Thomas' Calculus d/dx(x^3) at x=2 => 12.0</option>
|
||||
<option value="ts::derivative((x: number): number => x ** 3, 1e-5)(2.0)">[TS] Derivative d/dx(x^3) at x=2 => 12</option>
|
||||
<option value="rust::derivative(|x: f64| x * x * x, 1e-5, 2.0)">[Rs Rust] Derivative d/dx(x^3) at x=2 => 12</option>
|
||||
</select>
|
||||
<button type="button" id="hsGuileReplEvalBtn" class="btn" style="border-color:var(--emerald);color:var(--emerald);">Evaluate (λ)</button>
|
||||
<button type="button" id="hsGuileReplStepBtn" class="btn" style="border-color:var(--gold);color:var(--gold);">Step AST Trace</button>
|
||||
</div>
|
||||
<textarea id="hsGuileReplInput" rows="2" style="width:100%;background:var(--bg-void);color:var(--text-main);border:1px solid var(--border);padding:0.45rem;font-family:inherit;font-size:0.73rem;">(aq-base36 "LEMUR")</textarea>
|
||||
<pre id="hsGuileReplOutput" style="margin-top:0.4rem;background:var(--bg-void);border:1px solid var(--border);padding:0.5rem;font-size:0.71rem;color:var(--emerald);max-height:150px;overflow-y:auto;white-space:pre-wrap;">polyglot> Ready (4-Ring Zero-Eval AST Sandbox). Select [λ GUILE | TS | RS | ≡ ALL 3] or click Evaluate (λ).</pre>
|
||||
</div>
|
||||
</aside>
|
||||
<script src="{rel_prefix}../assets/hs-guile-scheme-repl.js?v={CURRENT_VERSION}"></script>"""
|
||||
|
||||
HUB_PREREQ_LADDER: dict[str, Any] = {
|
||||
"unit_id": "E0",
|
||||
"expertise_level": "Level 1-2 (Novice to Advanced Beginner • 4-8 hrs study)",
|
||||
@@ -324,8 +242,8 @@ ENGINEERING_SUBPAGE_SPECS: dict[str, dict[str, Any]] = {
|
||||
"body": "hs_generate_ticker_stats_card compiles a 5-zone 900x1260 Group 3 Stealth Basalt PNG card and companion JSON payload in one shot (with draw_fitted_text() width clamping and ink-bbox midpoint centering). ipld/__init__.py serializes canonical UTF-8 dag-json and prefixes SHA-256 digests with [0x01, 0xA9, 0x02, 0x12, 0x20] to form Base32 CIDv1 ('baguqeera...').",
|
||||
},
|
||||
{
|
||||
"heading": "3. Command-Line Usage Examples: CLI (hs-ticker-card), Chatbot REST Client (/api/v1/tools/*) & MCP Client (/mcp)",
|
||||
"body": "Command-line invocations across all three client interfaces: (1) CLI: hs-ticker-card --symbol NVDA --lens tierzoo_ecology --out-dir /tmp/hyperstition-cards; (2) Chatbot REST API Client: curl -sS 'https://hyperstitionstud.io/api/v1/tools/hs_generate_ticker_stats_card?symbol=NVDA&lens=tierzoo_ecology&include_base64_png=false' | jq . (or POST JSON '{\"symbol\":\"NVDA\",\"lens\":\"tierzoo_ecology\",\"include_base64_png\":true}' to /api/v1/tools/hs_generate_ticker_stats_card, or GET /api/v1/zoology/pokedex/NVDA?include_card=true); (3) MCP JSON-RPC 2.0 Client: curl -sS -X POST 'https://hyperstitionstud.io/mcp' -H 'Content-Type: application/json' -d '{\"jsonrpc\":\"2.0\",\"id\":1," + '"method":"tools/call","params":{"name":"hs_generate_ticker_stats_card","arguments":{"symbol":"NVDA","lens":"tierzoo_ecology","include_base64_png":false}}}\' | jq .',
|
||||
"heading": "3. Command-Line Usage Examples: cURL, CLI (hs-ticker-card), Chatbot REST Client (/api/v1/tools/*) & MCP Client (/mcp)",
|
||||
"body": "Command-line invocations across all four client interfaces: (1) cURL (zero local dependencies; works against https://hyperstitionstud.io or http://127.0.0.1:8095): curl -sS 'https://hyperstitionstud.io/api/v1/tools/hs_generate_ticker_stats_card?symbol=NVDA&lens=tierzoo_ecology&include_base64_png=false' -o /tmp/NVDA-stats-card.json (or include_base64_png=true piped through jq -r '.data.artifacts.png_base64' | base64 -d > /tmp/NVDA-stats-card.png); (2) CLI (hs-ticker-card): hs-ticker-card --symbol NVDA --lens tierzoo_ecology --out-dir /tmp/hyperstition-cards; (3) Chatbot REST API Client: curl -sS 'https://hyperstitionstud.io/api/v1/tools/hs_generate_ticker_stats_card?symbol=NVDA&lens=tierzoo_ecology&include_base64_png=false' | jq . (or POST JSON '{\"symbol\":\"NVDA\",\"lens\":\"tierzoo_ecology\",\"include_base64_png\":true}' to /api/v1/tools/hs_generate_ticker_stats_card, or GET /api/v1/zoology/pokedex/NVDA?include_card=true); (4) MCP JSON-RPC 2.0 Client: curl -sS -X POST 'https://hyperstitionstud.io/mcp' -H 'Content-Type: application/json' -d '{\"jsonrpc\":\"2.0\",\"id\":1," + '"method":"tools/call","params":{"name":"hs_generate_ticker_stats_card","arguments":{"symbol":"NVDA","lens":"tierzoo_ecology","include_base64_png":false}}}\' | jq .',
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -416,76 +334,13 @@ def introspect_engineering_manifest(
|
||||
return manifest
|
||||
|
||||
|
||||
def _render_global_nav_html(rel_prefix: str, active_surface: str = "engineering") -> str:
|
||||
eng_cls = 'btn primary' if active_surface == "engineering" else 'btn'
|
||||
eng_cur = ' aria-current="page"' if active_surface == "engineering" else ''
|
||||
math_cls = 'btn primary' if active_surface == "math" else 'btn'
|
||||
math_cur = ' aria-current="page"' if active_surface == "math" else ''
|
||||
links = [
|
||||
f'<a class="btn" href="{rel_prefix}../index.html">Portal Home (/)</a>',
|
||||
'<a class="btn" href="/calc/index.html">Calculator</a>',
|
||||
'<a class="btn" href="/quant/index.html" style="border-color:var(--gold);color:var(--gold);">Quant</a>',
|
||||
'<a class="btn" href="/graph/index.html" style="border-color:var(--cyan);color:var(--cyan);">Graph</a>',
|
||||
f'<a class="btn" href="{rel_prefix}../learn/index.html" style="border-color:var(--emerald);color:var(--emerald);">Learn</a>',
|
||||
f'<a class="{eng_cls}"{eng_cur} href="{rel_prefix}../engineering/index.html">Engineering</a>',
|
||||
f'<a class="{math_cls}"{math_cur} href="{rel_prefix}../math/index.html">Math</a>',
|
||||
'<span class="nav-donate-sep" aria-hidden="true"></span>',
|
||||
f'<a class="btn-donate-pill" href="{rel_prefix}../donate/index.html?from={active_surface}" title="Signal Patronage & Open-Instrument Notes (/donate/)">'
|
||||
'<span class="donate-pill-emblem" aria-hidden="true">♥</span><span>DONATE</span></a>',
|
||||
]
|
||||
return "\n ".join(links)
|
||||
|
||||
|
||||
def _render_nav_html(active_slug: str | None, enabled_subpages: list[str], rel_prefix: str) -> str:
|
||||
links = [
|
||||
f'<a class="btn" href="{rel_prefix}index.html" style="border-color:{"var(--gold)" if active_slug is None else "rgba(56,189,248,0.55)"};">Engineering Hub (E0)</a>',
|
||||
]
|
||||
direct_pages = enabled_subpages[:6]
|
||||
overflow_pages = enabled_subpages[6:]
|
||||
for s in direct_pages:
|
||||
spec = ENGINEERING_SUBPAGE_SPECS[s]
|
||||
is_act = (s == active_slug)
|
||||
href = f"{s}/index.html" if active_slug is None else (f"../{s}/index.html" if not is_act else "index.html")
|
||||
style = "border-color:var(--gold);color:var(--gold);" if is_act else ""
|
||||
links.append(f'<a class="btn" href="{href}" style="{style}">{spec["short_title"]}</a>')
|
||||
if overflow_pages:
|
||||
opts = ['<option value="">More Units ▾</option>']
|
||||
for s in overflow_pages:
|
||||
spec = ENGINEERING_SUBPAGE_SPECS[s]
|
||||
href = f"{s}/index.html" if active_slug is None else (f"../{s}/index.html" if s != active_slug else "index.html")
|
||||
opts.append(f'<option value="{href}">{spec["short_title"]}</option>')
|
||||
links.append(f'<select class="btn hs-nav-overflow-select" onchange="if(this.value)window.location.href=this.value">{"".join(opts)}</select>')
|
||||
unit_links_html = "\n ".join(links)
|
||||
return (
|
||||
f'<div class="hs-subnav-links">\n {unit_links_html}\n </div>\n'
|
||||
f' {_render_polyglot_selector_html()}'
|
||||
)
|
||||
|
||||
|
||||
def _render_prereq_box_html(
|
||||
level_str: str,
|
||||
prereqs: list[str],
|
||||
resources: list[dict[str, Any]],
|
||||
rel_prefix: str,
|
||||
intro_prompt: str = "If any concepts on this page are unfamiliar, occupy your study time with these free foundational resources first:",
|
||||
prereq_heading: str = "Core Concepts Required:",
|
||||
) -> str:
|
||||
p_items = "".join(f"<li>{p}</li>" for p in prereqs)
|
||||
r_items = []
|
||||
for r in resources:
|
||||
url = r["url"]
|
||||
if not r.get("external") and url.startswith("/"):
|
||||
url = f"{rel_prefix}..{url}"
|
||||
ext_attr = ' target="_blank" rel="noopener noreferrer"' if r.get("external") else ""
|
||||
r_items.append(f'<li><a href="{url}"{ext_attr} style="color:var(--cyan);">{r["label"]} ↗</a></li>')
|
||||
return (
|
||||
'<section class="panel hs-plate-g3 plate-lock-emerald hs-prereq-ladder" style="margin-bottom:0.9rem;padding:1rem 1.2rem;">'
|
||||
f'<div style="font-size:0.74rem;font-weight:700;color:var(--emerald);text-transform:uppercase;letter-spacing:0.06em;">Prerequisite Track for Novices • Required Expertise: {level_str}</div>'
|
||||
f'<p style="font-size:0.76rem;color:var(--text-secondary);margin:0.35rem 0;">{intro_prompt}</p>'
|
||||
'<div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));gap:0.8rem;margin-top:0.4rem;">'
|
||||
f'<div><strong style="font-size:0.73rem;color:var(--gold);">{prereq_heading}</strong><ul style="font-size:0.72rem;color:var(--text-main);margin:0.25rem 0 0 1.1rem;line-height:1.5;">{p_items}</ul></div>'
|
||||
f'<div><strong style="font-size:0.73rem;color:var(--cyan);">Curated Free Public Study Resources:</strong><ul style="font-size:0.72rem;color:var(--text-main);margin:0.25rem 0 0 1.1rem;line-height:1.5;">{"".join(r_items)}</ul></div>'
|
||||
'</div></section>'
|
||||
return render_explication_nav_html(
|
||||
hub_label="Engineering Hub (E0)",
|
||||
active_slug=active_slug,
|
||||
enabled_subpages=enabled_subpages,
|
||||
specs=ENGINEERING_SUBPAGE_SPECS,
|
||||
rel_prefix=rel_prefix,
|
||||
)
|
||||
|
||||
|
||||
@@ -507,91 +362,21 @@ def _render_hub_html(manifest: dict[str, Any], include_guile_lens: bool = True)
|
||||
guile_hub_html = _render_guile_cartridge_html("E0") if include_guile_lens else ""
|
||||
guile_drawer_html = _render_guile_repl_drawer_html("") if include_guile_lens else ""
|
||||
|
||||
cards_html = ""
|
||||
sigil_map = {
|
||||
"E1": "☿",
|
||||
"E2": "☉",
|
||||
"E3": "♄ ☍",
|
||||
"E4": "⚚",
|
||||
"E5": "⚛",
|
||||
}
|
||||
for s in enabled:
|
||||
sp = ENGINEERING_SUBPAGE_SPECS[s]
|
||||
sig = sigil_map.get(sp["unit_id"], "⚛")
|
||||
cards_html += (
|
||||
f'<article class="panel hs-plate-g3 {sp["pip_class"]}" style="padding:1rem 1.15rem;display:flex;flex-direction:column;justify-content:space-between;gap:0.6rem;">'
|
||||
f'<div><div style="font-size:0.7rem;color:var(--gold);font-weight:700;"><span class="hs-sigil" aria-hidden="true">{sig}</span>{sp["unit_id"]} // {sp["expertise_level"]}</div>'
|
||||
f'<h2 style="font-size:0.95rem;margin:0.25rem 0;color:var(--text-main);">{sp["title"]}</h2>'
|
||||
f'<p style="font-size:0.74rem;color:var(--text-secondary);line-height:1.5;">{sp["sections"][0]["body"]}</p></div>'
|
||||
f'<div><a class="btn" href="{s}/index.html">Open {sp["short_title"]} Subpage →</a></div></article>'
|
||||
)
|
||||
stat_tiles_html = (
|
||||
f' <div class="panel hs-plate-g3 stat-tile"><div style="font-size:0.68rem;color:var(--text-secondary);">Repositories</div><div style="font-size:1.35rem;font-weight:700;color:var(--gold);">{counts["repositories"]}</div></div>\n'
|
||||
f' <div class="panel hs-plate-g3 stat-tile"><div style="font-size:0.68rem;color:var(--text-secondary);">CLI Entrypoints</div><div style="font-size:1.35rem;font-weight:700;color:var(--cyan);">{counts["cli_entrypoints"]}</div></div>\n'
|
||||
f' <div class="panel hs-plate-g3 stat-tile"><div style="font-size:0.68rem;color:var(--text-secondary);">MCP & REST Tools</div><div style="font-size:1.35rem;font-weight:700;color:var(--emerald);">{counts["mcp_tools"]}</div></div>\n'
|
||||
f' <div class="panel hs-plate-g3 stat-tile"><div style="font-size:0.68rem;color:var(--text-secondary);">Pluggable Lenses</div><div style="font-size:1.35rem;font-weight:700;color:var(--gold);">{counts["enabled_lenses"]}</div></div>\n'
|
||||
f' <div class="panel hs-plate-g3 stat-tile"><div style="font-size:0.68rem;color:var(--text-secondary);">Watchlist / FRED</div><div style="font-size:1.35rem;font-weight:700;color:var(--cyan);">{counts["watchlist_instruments"]} / {counts["fred_macro_series"]}</div></div>\n'
|
||||
f' <div class="panel hs-plate-g3 stat-tile"><div style="font-size:0.68rem;color:var(--text-secondary);">Enabled Subpages</div><div style="font-size:1.35rem;font-weight:700;color:var(--emerald);">{len(enabled)} / {len(ALL_ENGINEERING_SUBPAGES)}</div></div>'
|
||||
)
|
||||
|
||||
cli_rows = "".join(
|
||||
f"<tr><td><code>{k}</code></td><td><code>{v}</code></td></tr>"
|
||||
for k, v in sorted(manifest["cli_scripts"].items())
|
||||
)
|
||||
|
||||
return f"""<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Software Engineering Explication Hub — hyperstitionstud.io/engineering (v{CURRENT_VERSION})</title>
|
||||
<link rel="stylesheet" href="../assets/hs-group3-basalt-chamfer.css?v={CURRENT_VERSION}" />
|
||||
<style>
|
||||
* {{ box-sizing: border-box; margin: 0; padding: 0; }}
|
||||
body {{ font-family: 'DejaVu Sans Mono', ui-monospace, monospace; padding: 1.25rem; line-height: 1.5; }}
|
||||
.container {{ max-width: 1360px; margin: 0 auto; }}
|
||||
header {{ padding: 1.1rem 1.35rem; margin-bottom: 0.75rem; display: flex; justify-content: space-between; align-items: center; flex-wrap: nowrap; gap: 0.85rem; }}
|
||||
@media (max-width: 1220px) {{ header {{ flex-wrap: wrap; }} }}
|
||||
h1 {{ font-size: 0.98rem; font-weight: 700; letter-spacing: -0.02em; color: var(--text-main); }}
|
||||
.subtitle {{ font-size: 0.71rem; color: var(--text-secondary); margin-top: 0.25rem; }}
|
||||
.top-nav {{ margin-left: auto; display: flex; gap: 0.38rem; flex-wrap: nowrap; align-items: center; }}
|
||||
.btn {{ padding: 0.34rem 0.62rem; font-size: 0.7rem; font-weight: 600; text-decoration: none; font-family: inherit; cursor: pointer; }}
|
||||
.grid-cards {{ display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 0.85rem; margin-bottom: 0.9rem; }}
|
||||
.stats-row {{ display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.6rem; margin-bottom: 0.9rem; }}
|
||||
.stat-tile {{ padding: 0.7rem 0.85rem; text-align: center; }}
|
||||
table {{ width: 100%; font-size: 0.73rem; margin-top: 0.4rem; }}
|
||||
th, td {{ padding: 0.4rem 0.6rem; text-align: left; border: 1px solid var(--border); }}
|
||||
footer {{ margin-top: 1rem; padding-top: 0.8rem; border-top: 1px solid var(--border); text-align: center; font-size: 0.72rem; color: var(--text-secondary); }}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<header>
|
||||
<div>
|
||||
<div class="title-row">
|
||||
<span class="dot" style="background:var(--gold);box-shadow:0 0 10px var(--gold);" aria-hidden="true"></span>
|
||||
<h1>HYPERSTITION STUDIO // SOFTWARE ENGINEERING EXPLICATION HUB (UNIT E0)</h1>
|
||||
</div>
|
||||
<p class="subtitle">Commutative Live-Introspected Architecture • Piecewise & Non-Sequentially Revertible Cartridges • urn:io:hyperstitionstud:engineering:v{CURRENT_VERSION} <span class="hs-sigil-seal" aria-hidden="true">[ ⚚ · ☿ · ☍ · ☉ ]</span></p>
|
||||
</div>
|
||||
<nav class="top-nav hs-global-nav" aria-label="Primary Ecosystem Navigation">
|
||||
{global_nav_html}
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<nav class="hs-subnav-bar panel hs-plate-g3" aria-label="Unit and Polyglot Sub-Navigation">
|
||||
{subnav_html}
|
||||
</nav>
|
||||
|
||||
{prereq_html}
|
||||
{guile_hub_html}
|
||||
|
||||
<section class="stats-row">
|
||||
<div class="panel hs-plate-g3 stat-tile"><div style="font-size:0.68rem;color:var(--text-secondary);">Repositories</div><div style="font-size:1.35rem;font-weight:700;color:var(--gold);">{counts["repositories"]}</div></div>
|
||||
<div class="panel hs-plate-g3 stat-tile"><div style="font-size:0.68rem;color:var(--text-secondary);">CLI Entrypoints</div><div style="font-size:1.35rem;font-weight:700;color:var(--cyan);">{counts["cli_entrypoints"]}</div></div>
|
||||
<div class="panel hs-plate-g3 stat-tile"><div style="font-size:0.68rem;color:var(--text-secondary);">MCP & REST Tools</div><div style="font-size:1.35rem;font-weight:700;color:var(--emerald);">{counts["mcp_tools"]}</div></div>
|
||||
<div class="panel hs-plate-g3 stat-tile"><div style="font-size:0.68rem;color:var(--text-secondary);">Pluggable Lenses</div><div style="font-size:1.35rem;font-weight:700;color:var(--gold);">{counts["enabled_lenses"]}</div></div>
|
||||
<div class="panel hs-plate-g3 stat-tile"><div style="font-size:0.68rem;color:var(--text-secondary);">Watchlist / FRED</div><div style="font-size:1.35rem;font-weight:700;color:var(--cyan);">{counts["watchlist_instruments"]} / {counts["fred_macro_series"]}</div></div>
|
||||
<div class="panel hs-plate-g3 stat-tile"><div style="font-size:0.68rem;color:var(--text-secondary);">Enabled Subpages</div><div style="font-size:1.35rem;font-weight:700;color:var(--emerald);">{len(enabled)} / {len(ALL_ENGINEERING_SUBPAGES)}</div></div>
|
||||
</section>
|
||||
|
||||
<section class="grid-cards">
|
||||
{cards_html}
|
||||
</section>
|
||||
|
||||
<section class="panel hs-plate-g3" style="padding:1rem 1.2rem;margin-bottom:0.9rem;">
|
||||
extra_panels_html = f""" <section class="panel hs-plate-g3" style="padding:1rem 1.2rem;margin-bottom:0.9rem;">
|
||||
<h2 style="font-size:0.92rem;color:var(--gold);margin-bottom:0.4rem;">End-to-End Periodic Data Harvest → CI/CD → Deployed VPS Infrastructure Flow Diagram</h2>
|
||||
<p style="font-size:0.74rem;color:var(--text-secondary);margin-bottom:0.5rem;">Generated & verified deterministically by <code>hyperstitionstud_io.publishing.flow_diagram</code> during <code>push-all-to-git-libre-audio.sh</code> and <code>tests/test_core_suite.py</code>:</p>
|
||||
<div style="overflow-x:auto;background:var(--bg-well);padding:0.5rem;border:1px solid var(--border);">
|
||||
@@ -620,19 +405,39 @@ def _render_hub_html(manifest: dict[str, Any], include_guile_lens: bool = True)
|
||||
}});
|
||||
}})();
|
||||
</script>
|
||||
</section>
|
||||
</section>"""
|
||||
|
||||
<footer>
|
||||
hyperstitionstud.io/engineering v{CURRENT_VERSION} • CIDv1: <code>{manifest["ipld_dag_json_cidv1"]["/"][:36]}...</code> • <span class="hs-sigil-colophon" aria-hidden="true">⚚ · ☿ · ☍ · ☉ · ♄</span> • Made with <span class="hs-heart" style="color:var(--rose);">♥</span> by Lemurs.
|
||||
</footer>
|
||||
</div>
|
||||
<script src="../assets/hs-matrix-coderain.js?v={CURRENT_VERSION}" defer></script>
|
||||
<script src="../assets/hs-mobile-ui.js?v={CURRENT_VERSION}" defer></script>
|
||||
<script src="engineering-manifest-data.js?v={CURRENT_VERSION}"></script>
|
||||
<script src="engineering-app.js?v={CURRENT_VERSION}"></script>{guile_drawer_html}
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
return render_explication_hub_page_html(
|
||||
surface_slug="engineering",
|
||||
page_title=f"Software Engineering Explication Hub — hyperstitionstud.io/engineering (v{CURRENT_VERSION})",
|
||||
header_h1="HYPERSTITION STUDIO // SOFTWARE ENGINEERING EXPLICATION HUB (UNIT E0)",
|
||||
header_subtitle_html=f'Commutative Live-Introspected Architecture • Piecewise & Non-Sequentially Revertible Cartridges • urn:io:hyperstitionstud:engineering:v{CURRENT_VERSION} <span class="hs-sigil-seal" aria-hidden="true">[ ⚚ · ☿ · ☍ · ☉ ]</span>',
|
||||
global_nav_html=global_nav_html,
|
||||
subnav_html=subnav_html,
|
||||
prereq_html=prereq_html,
|
||||
guile_hub_html=guile_hub_html,
|
||||
guile_drawer_html=guile_drawer_html,
|
||||
stat_tiles_html=stat_tiles_html,
|
||||
enabled_subpages=enabled,
|
||||
specs=ENGINEERING_SUBPAGE_SPECS,
|
||||
sigil_map={
|
||||
"E1": "☿",
|
||||
"E2": "☉",
|
||||
"E3": "♄ ☍",
|
||||
"E4": "⚚",
|
||||
"E5": "⚛",
|
||||
},
|
||||
default_sigil="⚛",
|
||||
cidv1_prefix=manifest["ipld_dag_json_cidv1"]["/"][:36],
|
||||
manifest_js_filename="engineering-manifest-data.js",
|
||||
app_js_filename="engineering-app.js",
|
||||
stats_min_col_px=150,
|
||||
extra_css_html=(
|
||||
"\n table { width: 100%; font-size: 0.73rem; margin-top: 0.4rem; }"
|
||||
"\n th, td { padding: 0.4rem 0.6rem; text-align: left; border: 1px solid var(--border); }"
|
||||
),
|
||||
extra_panels_html=extra_panels_html,
|
||||
)
|
||||
|
||||
|
||||
def _render_subpage_html(slug: str, manifest: dict[str, Any], include_guile_lens: bool = True) -> str:
|
||||
@@ -644,20 +449,9 @@ def _render_subpage_html(slug: str, manifest: dict[str, Any], include_guile_lens
|
||||
guile_sub_html = _render_guile_cartridge_html(slug) if include_guile_lens else ""
|
||||
guile_drawer_html = _render_guile_repl_drawer_html("../") if include_guile_lens else ""
|
||||
|
||||
idx = enabled.index(slug)
|
||||
prev_link = f'<a class="btn" href="../{enabled[idx - 1]}/index.html">← Prev: {ENGINEERING_SUBPAGE_SPECS[enabled[idx - 1]]["short_title"]}</a>' if idx > 0 else '<a class="btn" href="../index.html">← Back to Engineering Hub (E0)</a>'
|
||||
next_link = f'<a class="btn" href="../{enabled[idx + 1]}/index.html">Next: {ENGINEERING_SUBPAGE_SPECS[enabled[idx + 1]]["short_title"]} →</a>' if idx + 1 < len(enabled) else '<a class="btn" href="../index.html">Return to Engineering Hub (E0) ↑</a>'
|
||||
|
||||
secs_html = ""
|
||||
for sec in spec["sections"]:
|
||||
secs_html += (
|
||||
'<article class="panel hs-plate-g3" style="padding:1rem 1.2rem;margin-bottom:0.85rem;">'
|
||||
f'<h2 style="font-size:0.92rem;color:var(--gold);margin-bottom:0.4rem;">{sec["heading"]}</h2>'
|
||||
f'<p style="font-size:0.76rem;color:var(--text-main);line-height:1.6;">{sec["body"]}</p>'
|
||||
'</article>'
|
||||
)
|
||||
extra_after_sections_html = ""
|
||||
if slug == "mcp-chatbot-rest-and-ipld":
|
||||
secs_html += (
|
||||
extra_after_sections_html = (
|
||||
'<section id="live-smoke-probe" class="panel hs-plate-g3 plate-lock-emerald" style="padding:1rem 1.2rem;margin-bottom:0.85rem;">'
|
||||
'<div style="display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:0.6rem;margin-bottom:0.55rem;">'
|
||||
'<h2 style="font-size:0.92rem;color:var(--emerald);">⚛ Live API & IPLD CIDv1 ETag 304 Conditional Cache Probe (#live-smoke-probe)</h2>'
|
||||
@@ -692,65 +486,22 @@ def _render_subpage_html(slug: str, manifest: dict[str, Any], include_guile_lens
|
||||
'</section>'
|
||||
)
|
||||
|
||||
return f"""<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>{spec["title"]} — hyperstitionstud.io/engineering (v{CURRENT_VERSION})</title>
|
||||
<link rel="stylesheet" href="../../assets/hs-group3-basalt-chamfer.css?v={CURRENT_VERSION}" />
|
||||
<style>
|
||||
* {{ box-sizing: border-box; margin: 0; padding: 0; }}
|
||||
body {{ font-family: 'DejaVu Sans Mono', ui-monospace, monospace; padding: 1.25rem; line-height: 1.5; }}
|
||||
.container {{ max-width: 1360px; margin: 0 auto; }}
|
||||
header {{ padding: 1.1rem 1.35rem; margin-bottom: 0.75rem; display: flex; justify-content: space-between; align-items: center; flex-wrap: nowrap; gap: 0.85rem; }}
|
||||
@media (max-width: 1220px) {{ header {{ flex-wrap: wrap; }} }}
|
||||
h1 {{ font-size: 0.98rem; font-weight: 700; letter-spacing: -0.02em; color: var(--text-main); }}
|
||||
.subtitle {{ font-size: 0.71rem; color: var(--text-secondary); margin-top: 0.25rem; }}
|
||||
.top-nav {{ margin-left: auto; display: flex; gap: 0.38rem; flex-wrap: nowrap; align-items: center; }}
|
||||
.btn {{ padding: 0.34rem 0.62rem; font-size: 0.7rem; font-weight: 600; text-decoration: none; font-family: inherit; cursor: pointer; }}
|
||||
footer {{ margin-top: 1rem; padding-top: 0.8rem; border-top: 1px solid var(--border); text-align: center; font-size: 0.72rem; color: var(--text-secondary); }}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<header>
|
||||
<div>
|
||||
<div class="title-row">
|
||||
<span class="dot" style="background:var(--gold);box-shadow:0 0 10px var(--gold);" aria-hidden="true"></span>
|
||||
<h1>{spec["title"]}</h1>
|
||||
</div>
|
||||
<p class="subtitle">Cartridge {spec["unit_id"]} • Non-Sequentially Revertible via <code>hs-eng-docs --disable {slug}</code> • v{CURRENT_VERSION} <span class="hs-sigil-seal" aria-hidden="true">[ ⚚ · ☿ · ☍ · ☉ ]</span></p>
|
||||
</div>
|
||||
<nav class="top-nav hs-global-nav" aria-label="Primary Ecosystem Navigation">
|
||||
{global_nav_html}
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<nav class="hs-subnav-bar panel hs-plate-g3" aria-label="Unit and Polyglot Sub-Navigation">
|
||||
{subnav_html}
|
||||
</nav>
|
||||
|
||||
{prereq_html}
|
||||
{guile_sub_html}
|
||||
{secs_html}
|
||||
|
||||
<div style="display:flex;justify-content:space-between;align-items:center;margin-top:0.8rem;">
|
||||
{prev_link}
|
||||
{next_link}
|
||||
</div>
|
||||
|
||||
<footer>
|
||||
hyperstitionstud.io/engineering/{slug} v{CURRENT_VERSION} • <span class="hs-sigil-colophon" aria-hidden="true">⚚ · ☿ · ☍ · ☉ · ♄</span> • Made with <span class="hs-heart" style="color:var(--rose);">♥</span> by Lemurs.
|
||||
</footer>
|
||||
</div>
|
||||
<script src="../../assets/hs-matrix-coderain.js?v={CURRENT_VERSION}" defer></script>
|
||||
<script src="../../assets/hs-mobile-ui.js?v={CURRENT_VERSION}" defer></script>
|
||||
<script src="../engineering-manifest-data.js?v={CURRENT_VERSION}"></script>
|
||||
<script src="../engineering-app.js?v={CURRENT_VERSION}"></script>{guile_drawer_html}
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
return render_explication_subpage_html(
|
||||
slug=slug,
|
||||
surface_slug="engineering",
|
||||
hub_label="Engineering Hub (E0)",
|
||||
cli_prog="hs-eng-docs",
|
||||
manifest=manifest,
|
||||
specs=ENGINEERING_SUBPAGE_SPECS,
|
||||
global_nav_html=global_nav_html,
|
||||
subnav_html=subnav_html,
|
||||
prereq_html=prereq_html,
|
||||
guile_sub_html=guile_sub_html,
|
||||
guile_drawer_html=guile_drawer_html,
|
||||
manifest_js_filename="engineering-manifest-data.js",
|
||||
app_js_filename="engineering-app.js",
|
||||
extra_after_sections_html=extra_after_sections_html,
|
||||
)
|
||||
|
||||
|
||||
def build_engineering_site(
|
||||
@@ -760,81 +511,39 @@ def build_engineering_site(
|
||||
include_guile_lens: bool = ENABLE_GUILE_SCHEME_LENS,
|
||||
workspace_root: str | Path | None = None,
|
||||
) -> dict[str, Any]:
|
||||
cfg = load_workspace_config(workspace_root=workspace_root)
|
||||
target_dir = Path(out_dir).resolve() if out_dir else (cfg.core_dir / "site" / "engineering").resolve()
|
||||
|
||||
with ReadOnlyIsolationGuard(cfg.read_only_files) as guard:
|
||||
if disable_all:
|
||||
if target_dir.is_dir():
|
||||
shutil.rmtree(target_dir)
|
||||
return {"ok": True, "disabled_all": True, "enabled_routes": []}
|
||||
|
||||
target_dir.mkdir(parents=True, exist_ok=True)
|
||||
active_tuple = tuple(s for s in ALL_ENGINEERING_SUBPAGES if s in enabled_subpages)
|
||||
manifest = introspect_engineering_manifest(enabled_subpages=active_tuple, workspace_root=workspace_root)
|
||||
|
||||
# Write manifest JSON & JS
|
||||
(target_dir / "engineering-manifest.json").write_text(json.dumps(manifest, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
|
||||
(target_dir / "engineering-manifest-data.js").write_text(
|
||||
"window.HYPERSTITION_ENGINEERING_MANIFEST = " + json.dumps(manifest, ensure_ascii=False) + ";\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
(target_dir / "engineering-app.js").write_text(
|
||||
"(function(){ 'use strict'; if (window.location.protocol !== 'file:') { document.querySelectorAll('img[data-http-src]').forEach(function(im){ im.src = im.getAttribute('data-http-src'); }); } })();\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
# Write Hub E0
|
||||
(target_dir / "index.html").write_text(_render_hub_html(manifest, include_guile_lens=include_guile_lens), encoding="utf-8")
|
||||
|
||||
# Write enabled subpages and remove any disabled subpage directories
|
||||
for s in ALL_ENGINEERING_SUBPAGES:
|
||||
sub_d = target_dir / s
|
||||
if s in active_tuple:
|
||||
sub_d.mkdir(parents=True, exist_ok=True)
|
||||
(sub_d / "index.html").write_text(_render_subpage_html(s, manifest, include_guile_lens=include_guile_lens), encoding="utf-8")
|
||||
elif sub_d.is_dir():
|
||||
shutil.rmtree(sub_d)
|
||||
|
||||
return {
|
||||
"ok": True,
|
||||
"version": CURRENT_VERSION,
|
||||
"output_dir": str(target_dir),
|
||||
"guile_scheme_lens_enabled": include_guile_lens,
|
||||
"enabled_subpages": list(active_tuple),
|
||||
"enabled_routes": manifest["enabled_routes"],
|
||||
"cidv1": manifest["ipld_dag_json_cidv1"]["/"],
|
||||
"isolation_receipt": guard.audit_receipt(),
|
||||
}
|
||||
return write_explication_site_bundle(
|
||||
surface_slug="engineering",
|
||||
all_subpages=ALL_ENGINEERING_SUBPAGES,
|
||||
enabled_subpages=enabled_subpages,
|
||||
out_dir=out_dir,
|
||||
disable_all=disable_all,
|
||||
include_guile_lens=include_guile_lens,
|
||||
workspace_root=workspace_root,
|
||||
introspect_fn=introspect_engineering_manifest,
|
||||
render_hub_fn=_render_hub_html,
|
||||
render_subpage_fn=_render_subpage_html,
|
||||
manifest_json_filename="engineering-manifest.json",
|
||||
manifest_js_filename="engineering-manifest-data.js",
|
||||
manifest_window_var="HYPERSTITION_ENGINEERING_MANIFEST",
|
||||
app_js_filename="engineering-app.js",
|
||||
app_js_source="(function(){ 'use strict'; if (window.location.protocol !== 'file:') { document.querySelectorAll('img[data-http-src]').forEach(function(im){ im.src = im.getAttribute('data-http-src'); }); } })();\n",
|
||||
)
|
||||
|
||||
|
||||
def main(argv: list[str] | None = None) -> int:
|
||||
ap = argparse.ArgumentParser(prog="hs-eng-docs", description="Build or toggle the /engineering/ Hub & modular subpages (E0-E5).")
|
||||
ap.add_argument("--sync", action="store_true", help="Rebuild all enabled /engineering/ pages from live codebase introspection.")
|
||||
ap.add_argument("--disable", default="", help="Comma-separated subpage slugs or unit IDs (e.g. quant-macro-and-bayesian-brief or E3) to disable.")
|
||||
ap.add_argument("--only", default="", help="Comma-separated subpage slugs or unit IDs (e.g. E1,E4) to enable exclusively.")
|
||||
ap.add_argument("--disable-all", action="store_true", help="Unmount all /engineering/ pages.")
|
||||
ap.add_argument("--disable-guile-lens", action="store_true", help="Omit additive Guile Scheme cartridges without touching E0-E5 content.")
|
||||
ap.add_argument("--out-dir", default=None)
|
||||
args = ap.parse_args(argv)
|
||||
|
||||
unit_map = {spec["unit_id"].upper(): slug for slug, spec in ENGINEERING_SUBPAGE_SPECS.items()}
|
||||
enabled = list(ALL_ENGINEERING_SUBPAGES)
|
||||
if args.only:
|
||||
req = {unit_map.get(x.strip().upper(), x.strip()) for x in args.only.split(",") if x.strip()}
|
||||
enabled = [s for s in ALL_ENGINEERING_SUBPAGES if s in req]
|
||||
if args.disable:
|
||||
dis = {unit_map.get(x.strip().upper(), x.strip()) for x in args.disable.split(",") if x.strip()}
|
||||
enabled = [s for s in enabled if s not in dis]
|
||||
|
||||
res = build_engineering_site(
|
||||
out_dir=args.out_dir,
|
||||
enabled_subpages=tuple(enabled),
|
||||
disable_all=args.disable_all,
|
||||
include_guile_lens=not args.disable_guile_lens,
|
||||
return run_explication_cli_main(
|
||||
prog="hs-eng-docs",
|
||||
description="Build or toggle the /engineering/ Hub & modular subpages (E0-E5).",
|
||||
all_subpages=ALL_ENGINEERING_SUBPAGES,
|
||||
specs=ENGINEERING_SUBPAGE_SPECS,
|
||||
build_fn=build_engineering_site,
|
||||
argv=argv,
|
||||
sync_help="Rebuild all enabled /engineering/ pages from live codebase introspection.",
|
||||
disable_help="Comma-separated subpage slugs or unit IDs (e.g. quant-macro-and-bayesian-brief or E3) to disable.",
|
||||
only_help="Comma-separated subpage slugs or unit IDs (e.g. E1,E4) to enable exclusively.",
|
||||
disable_all_help="Unmount all /engineering/ pages.",
|
||||
disable_guile_help="Omit additive Guile Scheme cartridges without touching E0-E5 content.",
|
||||
)
|
||||
print(json.dumps(res, indent=2))
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -0,0 +1,514 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
hyperstitionstud_io.publishing.explication_template
|
||||
Shared Group 3 Stealth Basalt Explication Hub & Orthogonal Subpage Cartridge Template Engine
|
||||
for `/engineering/` (`Units E0-E5`, `hs-eng-docs`) and `/math/` (`Units M0-M5`, `hs-math-docs`).
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import html
|
||||
import json
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
from typing import Any, Callable
|
||||
|
||||
from hyperstitionstud_io import __version__ as CURRENT_VERSION
|
||||
from hyperstitionstud_io.config import load_workspace_config
|
||||
from hyperstitionstud_io.glossary import ReadOnlyIsolationGuard
|
||||
|
||||
|
||||
def _render_polyglot_selector_html() -> str:
|
||||
return (
|
||||
'<div id="hsPolyglotModeSelector" class="hs-polyglot-segmented" role="radiogroup" aria-label="Pedagogical Programming Language Lens">'
|
||||
'<span class="hs-polyglot-prefix">LENS:</span>'
|
||||
'<button type="button" id="guileSchemeModeToggle" class="hs-polyglot-seg" role="radio" data-lens-mode="off" aria-checked="true" title="Hide programming language cartridges (Alt+0)">OFF</button>'
|
||||
'<button type="button" class="hs-polyglot-seg" role="radio" data-lens-mode="guile" aria-checked="false" title="GNU Guile Scheme — Z-Combinator & Exact Rationals (Alt+1)"><span class="hs-guile-lambda-badge">λ</span>GUILE</button>'
|
||||
'<button type="button" class="hs-polyglot-seg" role="radio" data-lens-mode="ts" aria-checked="false" title="TypeScript — Static Union Types & Functional Pipelines (Alt+2)"><span class="hs-guile-lambda-badge">TS</span>TYPESCRIPT</button>'
|
||||
'<button type="button" class="hs-polyglot-seg" role="radio" data-lens-mode="rust" aria-checked="false" title="Rust — Ownership, Option<T> & Zero-Cost Iterators (Alt+3)"><span class="hs-guile-lambda-badge">Rs</span>RUST</button>'
|
||||
'<button type="button" class="hs-polyglot-seg" role="radio" data-lens-mode="all" aria-checked="false" title="Side-by-side comparison of Guile Scheme, TypeScript, and Rust (Alt+4)">≡ ALL 3</button>'
|
||||
'<strong id="guileSchemeModeState" style="display:none;">OFF</strong>'
|
||||
'</div>'
|
||||
)
|
||||
|
||||
|
||||
def render_polyglot_cartridge_html(
|
||||
cartridge: dict[str, str],
|
||||
spec_label: str = "1. Formal Specification & Python:",
|
||||
) -> str:
|
||||
esc_scm = html.escape(cartridge["scm_expr"], quote=True)
|
||||
esc_ts = html.escape(cartridge["ts_expr"], quote=True)
|
||||
esc_rs = html.escape(cartridge["rust_expr"], quote=True)
|
||||
esc_math = html.escape(cartridge["math_view"], quote=True)
|
||||
esc_py = html.escape(cartridge["py_view"], quote=True)
|
||||
esc_title = html.escape(cartridge["title"], quote=True)
|
||||
esc_chal = html.escape(cartridge["challenge"], quote=True)
|
||||
return (
|
||||
'<section class="panel hs-plate-g3 hs-guile-cartridge">'
|
||||
'<div style="display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:0.5rem;">'
|
||||
f'<div style="font-size:0.74rem;font-weight:700;color:var(--cyan);text-transform:uppercase;letter-spacing:0.05em;">λ {esc_title}</div>'
|
||||
'<div style="display:flex;gap:0.25rem;flex-wrap:wrap;align-items:center;">'
|
||||
'<button type="button" class="hs-polyglot-seg" data-lens-mode="guile">λ Guile</button>'
|
||||
'<button type="button" class="hs-polyglot-seg" data-lens-mode="ts">TS TypeScript</button>'
|
||||
'<button type="button" class="hs-polyglot-seg" data-lens-mode="rust">Rs Rust</button>'
|
||||
'<button type="button" class="hs-polyglot-seg" data-lens-mode="all">≡ All 3</button>'
|
||||
'<button type="button" class="hs-polyglot-seg" data-lens-mode="off">Hide</button>'
|
||||
'</div>'
|
||||
'</div>'
|
||||
'<div class="hs-guile-triview">'
|
||||
f'<div class="hs-guile-box"><strong style="color:var(--gold);display:block;margin-bottom:0.2rem;">{spec_label}</strong><code>{esc_math}</code><pre style="white-space:pre-wrap;margin-top:0.25rem;color:var(--text-secondary);">{esc_py}</pre></div>'
|
||||
f'<div class="hs-guile-box hs-lang-box-guile"><div style="display:flex;justify-content:space-between;align-items:center;"><strong style="color:var(--cyan);">λ Guile Scheme (Z-Combinator):</strong><button type="button" class="btn hs-load-in-repl-btn" data-polyglot-lang="guile" data-scheme-expr="{esc_scm}" style="padding:0.12rem 0.4rem;font-size:0.65rem;">REPL →</button></div><code class="hs-guile-code-expr">{esc_scm}</code><div class="hs-guile-eval-result" style="margin-top:0.3rem;font-weight:700;color:var(--emerald);">=> [Select Lens to evaluate]</div></div>'
|
||||
f'<div class="hs-guile-box hs-lang-box-ts"><div style="display:flex;justify-content:space-between;align-items:center;"><strong style="color:var(--gold);">TS TypeScript (Strict AST):</strong><button type="button" class="btn hs-load-in-repl-btn" data-polyglot-lang="ts" data-scheme-expr="{esc_ts}" style="padding:0.12rem 0.4rem;font-size:0.65rem;">REPL →</button></div><code class="hs-ts-code-expr">{esc_ts}</code><div class="hs-ts-eval-result" style="margin-top:0.3rem;font-weight:700;color:var(--emerald);">=> [Select Lens to evaluate]</div></div>'
|
||||
f'<div class="hs-guile-box hs-lang-box-rust"><div style="display:flex;justify-content:space-between;align-items:center;"><strong style="color:var(--emerald);">Rs Rust (Option/Iterator AST):</strong><button type="button" class="btn hs-load-in-repl-btn" data-polyglot-lang="rust" data-scheme-expr="{esc_rs}" style="padding:0.12rem 0.4rem;font-size:0.65rem;">REPL →</button></div><code class="hs-rust-code-expr">{esc_rs}</code><div class="hs-rust-eval-result" style="margin-top:0.3rem;font-weight:700;color:var(--emerald);">=> [Select Lens to evaluate]</div></div>'
|
||||
'</div>'
|
||||
f'<div style="font-size:0.71rem;color:var(--text-secondary);"><strong>Guided Micro-Challenge (4-Ring Zero-Escape Sandbox):</strong> {esc_chal}</div>'
|
||||
'</section>'
|
||||
)
|
||||
|
||||
|
||||
def render_explication_cartridge_html(
|
||||
cartridges: dict[str, dict[str, str]],
|
||||
key: str,
|
||||
spec_label: str = "1. Formal Specification & Python:",
|
||||
) -> str:
|
||||
return render_polyglot_cartridge_html(
|
||||
cartridges[key],
|
||||
spec_label=spec_label,
|
||||
)
|
||||
|
||||
|
||||
def _render_guile_repl_drawer_html(rel_prefix: str) -> str:
|
||||
return f"""
|
||||
<aside id="hsGuileReplDrawer" class="hs-plate-g3" aria-label="In-Browser Polyglot Guile Scheme, TypeScript, and Rust Hardened REPL">
|
||||
<div style="display:flex;justify-content:space-between;align-items:center;gap:0.5rem;margin-bottom:0.45rem;">
|
||||
<div style="font-size:0.73rem;font-weight:700;color:var(--cyan);">λ 4-RING HARDENED POLYGLOT REPL (GUILE • TS • RUST • ZERO EVAL)</div>
|
||||
<div style="display:flex;gap:0.4rem;align-items:center;">
|
||||
<select id="hsPolyglotReplLang" style="background:var(--bg-void);color:var(--cyan);border:1px solid var(--cyan);padding:0.15rem 0.35rem;font-family:inherit;font-size:0.68rem;font-weight:700;">
|
||||
<option value="guile">λ Guile Scheme</option>
|
||||
<option value="ts">TS TypeScript</option>
|
||||
<option value="rust">Rs Rust</option>
|
||||
</select>
|
||||
<label style="font-size:0.68rem;color:var(--text-secondary);cursor:pointer;"><input type="checkbox" id="hsGuilePreferFloat" /> Float view</label>
|
||||
<button type="button" id="hsGuileReplCloseBtn" class="btn" style="padding:0.15rem 0.45rem;font-size:0.68rem;">Minimize / Expand</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="hs-repl-body">
|
||||
<div style="display:flex;gap:0.4rem;margin-bottom:0.4rem;flex-wrap:wrap;">
|
||||
<select id="hsGuileReplPreset" style="flex:1;background:var(--bg-void);color:var(--text-main);border:1px solid var(--border);padding:0.28rem;font-family:inherit;font-size:0.7rem;">
|
||||
<option value="">-- Load Preset Polyglot Expression (Guile / TS / Rust) --</option>
|
||||
<option value='guile::(aq-base36 "LEMUR")'>[λ Guile] Base-36 AQ: (aq-base36 "LEMUR") => 114</option>
|
||||
<option value='ts::aqBase36("LEMUR")'>[TS] Base-36 AQ: aqBase36("LEMUR") => 114</option>
|
||||
<option value='rust::aq_base36("LEMUR")'>[Rs Rust] Base-36 AQ: aq_base36("LEMUR") => 114</option>
|
||||
<option value="guile::(prime-factors 666)">[λ Guile] Prime Factors via Z: (prime-factors 666) => (2 3 3 37)</option>
|
||||
<option value="ts::primeFactors(666)">[TS] Prime Factors: primeFactors(666) => [2,3,3,37]</option>
|
||||
<option value="rust::prime_factors(666_u64)">[Rs Rust] Prime Factors: prime_factors(666_u64) => vec![2, 3, 3, 37]</option>
|
||||
<option value="guile::(variance-pop *cluster-292-gen0*)">[λ Guile] Exact Rational Variance (Cluster 292): 4634/9</option>
|
||||
<option value="ts::variancePop([264, 317, 276] as const)">[TS] Cluster 292 Variance: 514.8889</option>
|
||||
<option value="rust::variance_pop(&[264.0, 317.0, 276.0])">[Rs Rust] Cluster 292 Variance: 514.8889</option>
|
||||
<option value="guile::((derivative (lambda (x) (* x x x)) 1e-5) 2.0)">[λ Guile] Thomas' Calculus d/dx(x^3) at x=2 => 12.0</option>
|
||||
<option value="ts::derivative((x: number): number => x ** 3, 1e-5)(2.0)">[TS] Derivative d/dx(x^3) at x=2 => 12</option>
|
||||
<option value="rust::derivative(|x: f64| x * x * x, 1e-5, 2.0)">[Rs Rust] Derivative d/dx(x^3) at x=2 => 12</option>
|
||||
</select>
|
||||
<button type="button" id="hsGuileReplEvalBtn" class="btn" style="border-color:var(--emerald);color:var(--emerald);">Evaluate (λ)</button>
|
||||
<button type="button" id="hsGuileReplStepBtn" class="btn" style="border-color:var(--gold);color:var(--gold);">Step AST Trace</button>
|
||||
</div>
|
||||
<textarea id="hsGuileReplInput" rows="2" style="width:100%;background:var(--bg-void);color:var(--text-main);border:1px solid var(--border);padding:0.45rem;font-family:inherit;font-size:0.73rem;">(aq-base36 "LEMUR")</textarea>
|
||||
<pre id="hsGuileReplOutput" style="margin-top:0.4rem;background:var(--bg-void);border:1px solid var(--border);padding:0.5rem;font-size:0.71rem;color:var(--emerald);max-height:150px;overflow-y:auto;white-space:pre-wrap;">polyglot> Ready (4-Ring Zero-Eval AST Sandbox). Select [λ GUILE | TS | RS | ≡ ALL 3] or click Evaluate (λ).</pre>
|
||||
</div>
|
||||
</aside>
|
||||
<script src="{rel_prefix}../assets/hs-guile-scheme-repl.js?v={CURRENT_VERSION}"></script>"""
|
||||
|
||||
|
||||
def _render_global_nav_html(rel_prefix: str, active_surface: str = "engineering") -> str:
|
||||
eng_cls = 'btn primary' if active_surface == "engineering" else 'btn'
|
||||
eng_cur = ' aria-current="page"' if active_surface == "engineering" else ''
|
||||
math_cls = 'btn primary' if active_surface == "math" else 'btn'
|
||||
math_cur = ' aria-current="page"' if active_surface == "math" else ''
|
||||
links = [
|
||||
f'<a class="btn" href="{rel_prefix}../index.html">Portal Home (/)</a>',
|
||||
'<a class="btn" href="/calc/index.html">Calculator</a>',
|
||||
'<a class="btn" href="/quant/index.html" style="border-color:var(--gold);color:var(--gold);">Quant</a>',
|
||||
'<a class="btn" href="/graph/index.html" style="border-color:var(--cyan);color:var(--cyan);">Graph</a>',
|
||||
f'<a class="btn" href="{rel_prefix}../learn/index.html" style="border-color:var(--emerald);color:var(--emerald);">Learn</a>',
|
||||
f'<a class="{eng_cls}"{eng_cur} href="{rel_prefix}../engineering/index.html">Engineering</a>',
|
||||
f'<a class="{math_cls}"{math_cur} href="{rel_prefix}../math/index.html">Math</a>',
|
||||
'<span class="nav-donate-sep" aria-hidden="true"></span>',
|
||||
f'<a class="btn-donate-pill" href="{rel_prefix}../donate/index.html?from={active_surface}" title="Signal Patronage & Open-Instrument Notes (/donate/)">'
|
||||
'<span class="donate-pill-emblem" aria-hidden="true">♥</span><span>DONATE</span></a>',
|
||||
]
|
||||
return "\n ".join(links)
|
||||
|
||||
|
||||
def render_explication_nav_html(
|
||||
hub_label: str,
|
||||
active_slug: str | None,
|
||||
enabled_subpages: list[str],
|
||||
specs: dict[str, dict[str, Any]],
|
||||
rel_prefix: str,
|
||||
) -> str:
|
||||
links = [
|
||||
f'<a class="btn" href="{rel_prefix}index.html" style="border-color:{"var(--gold)" if active_slug is None else "rgba(56,189,248,0.55)"};">{hub_label}</a>',
|
||||
]
|
||||
direct_pages = enabled_subpages[:6]
|
||||
overflow_pages = enabled_subpages[6:]
|
||||
for s in direct_pages:
|
||||
spec = specs[s]
|
||||
is_act = (s == active_slug)
|
||||
href = f"{s}/index.html" if active_slug is None else (f"../{s}/index.html" if not is_act else "index.html")
|
||||
style = "border-color:var(--gold);color:var(--gold);" if is_act else ""
|
||||
links.append(f'<a class="btn" href="{href}" style="{style}">{spec["short_title"]}</a>')
|
||||
if overflow_pages:
|
||||
opts = ['<option value="">More Units ▾</option>']
|
||||
for s in overflow_pages:
|
||||
spec = specs[s]
|
||||
href = f"{s}/index.html" if active_slug is None else (f"../{s}/index.html" if s != active_slug else "index.html")
|
||||
opts.append(f'<option value="{href}">{spec["short_title"]}</option>')
|
||||
links.append(f'<select class="btn hs-nav-overflow-select" onchange="if(this.value)window.location.href=this.value">{"".join(opts)}</select>')
|
||||
unit_links_html = "\n ".join(links)
|
||||
return (
|
||||
f'<div class="hs-subnav-links">\n {unit_links_html}\n </div>\n'
|
||||
f' {_render_polyglot_selector_html()}'
|
||||
)
|
||||
|
||||
|
||||
def _render_prereq_box_html(
|
||||
level_str: str,
|
||||
prereqs: list[str],
|
||||
resources: list[dict[str, Any]],
|
||||
rel_prefix: str,
|
||||
intro_prompt: str = "If any concepts on this page are unfamiliar, occupy your study time with these free foundational resources first:",
|
||||
prereq_heading: str = "Core Concepts Required:",
|
||||
) -> str:
|
||||
p_items = "".join(f"<li>{p}</li>" for p in prereqs)
|
||||
r_items = []
|
||||
for r in resources:
|
||||
url = r["url"]
|
||||
if not r.get("external") and url.startswith("/"):
|
||||
url = f"{rel_prefix}..{url}"
|
||||
ext_attr = ' target="_blank" rel="noopener noreferrer"' if r.get("external") else ""
|
||||
r_items.append(f'<li><a href="{url}"{ext_attr} style="color:var(--cyan);">{r["label"]} ↗</a></li>')
|
||||
return (
|
||||
'<section class="panel hs-plate-g3 plate-lock-emerald hs-prereq-ladder" style="margin-bottom:0.9rem;padding:1rem 1.2rem;">'
|
||||
f'<div style="font-size:0.74rem;font-weight:700;color:var(--emerald);text-transform:uppercase;letter-spacing:0.06em;">Prerequisite Track for Novices • Required Expertise: {level_str}</div>'
|
||||
f'<p style="font-size:0.76rem;color:var(--text-secondary);margin:0.35rem 0;">{intro_prompt}</p>'
|
||||
'<div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));gap:0.8rem;margin-top:0.4rem;">'
|
||||
f'<div><strong style="font-size:0.73rem;color:var(--gold);">{prereq_heading}</strong><ul style="font-size:0.72rem;color:var(--text-main);margin:0.25rem 0 0 1.1rem;line-height:1.5;">{p_items}</ul></div>'
|
||||
f'<div><strong style="font-size:0.73rem;color:var(--cyan);">Curated Free Public Study Resources:</strong><ul style="font-size:0.72rem;color:var(--text-main);margin:0.25rem 0 0 1.1rem;line-height:1.5;">{"".join(r_items)}</ul></div>'
|
||||
'</div></section>'
|
||||
)
|
||||
|
||||
|
||||
def render_explication_hub_page_html(
|
||||
*,
|
||||
surface_slug: str,
|
||||
page_title: str,
|
||||
header_h1: str,
|
||||
header_subtitle_html: str,
|
||||
global_nav_html: str,
|
||||
subnav_html: str,
|
||||
prereq_html: str,
|
||||
guile_hub_html: str,
|
||||
guile_drawer_html: str,
|
||||
stat_tiles_html: str,
|
||||
enabled_subpages: list[str],
|
||||
specs: dict[str, dict[str, Any]],
|
||||
sigil_map: dict[str, str],
|
||||
default_sigil: str,
|
||||
cidv1_prefix: str,
|
||||
manifest_js_filename: str,
|
||||
app_js_filename: str,
|
||||
stats_min_col_px: int = 150,
|
||||
extra_css_html: str = "",
|
||||
extra_panels_html: str = "",
|
||||
) -> str:
|
||||
cards_html = ""
|
||||
for s in enabled_subpages:
|
||||
sp = specs[s]
|
||||
sig = sigil_map.get(sp["unit_id"], default_sigil)
|
||||
cards_html += (
|
||||
f'<article class="panel hs-plate-g3 {sp["pip_class"]}" style="padding:1rem 1.15rem;display:flex;flex-direction:column;justify-content:space-between;gap:0.6rem;">'
|
||||
f'<div><div style="font-size:0.7rem;color:var(--gold);font-weight:700;"><span class="hs-sigil" aria-hidden="true">{sig}</span>{sp["unit_id"]} // {sp["expertise_level"]}</div>'
|
||||
f'<h2 style="font-size:0.95rem;margin:0.25rem 0;color:var(--text-main);">{sp["title"]}</h2>'
|
||||
f'<p style="font-size:0.74rem;color:var(--text-secondary);line-height:1.5;">{sp["sections"][0]["body"]}</p></div>'
|
||||
f'<div><a class="btn" href="{s}/index.html">Open {sp["short_title"]} Subpage →</a></div></article>'
|
||||
)
|
||||
|
||||
extra_panels_block = f"\n\n{extra_panels_html}\n" if extra_panels_html else "\n"
|
||||
|
||||
return f"""<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>{page_title}</title>
|
||||
<link rel="stylesheet" href="../assets/hs-group3-basalt-chamfer.css?v={CURRENT_VERSION}" />
|
||||
<style>
|
||||
* {{ box-sizing: border-box; margin: 0; padding: 0; }}
|
||||
body {{ font-family: 'DejaVu Sans Mono', ui-monospace, monospace; padding: 1.25rem; line-height: 1.5; }}
|
||||
.container {{ max-width: 1360px; margin: 0 auto; }}
|
||||
header {{ padding: 1.1rem 1.35rem; margin-bottom: 0.75rem; display: flex; justify-content: space-between; align-items: center; flex-wrap: nowrap; gap: 0.85rem; }}
|
||||
@media (max-width: 1220px) {{ header {{ flex-wrap: wrap; }} }}
|
||||
h1 {{ font-size: 0.98rem; font-weight: 700; letter-spacing: -0.02em; color: var(--text-main); }}
|
||||
.subtitle {{ font-size: 0.71rem; color: var(--text-secondary); margin-top: 0.25rem; }}
|
||||
.top-nav {{ margin-left: auto; display: flex; gap: 0.38rem; flex-wrap: nowrap; align-items: center; }}
|
||||
.btn {{ padding: 0.34rem 0.62rem; font-size: 0.7rem; font-weight: 600; text-decoration: none; font-family: inherit; cursor: pointer; }}
|
||||
.grid-cards {{ display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 0.85rem; margin-bottom: 0.9rem; }}
|
||||
.stats-row {{ display: grid; grid-template-columns: repeat(auto-fit, minmax({stats_min_col_px}px, 1fr)); gap: 0.6rem; margin-bottom: 0.9rem; }}
|
||||
.stat-tile {{ padding: 0.7rem 0.85rem; text-align: center; }}{extra_css_html}
|
||||
footer {{ margin-top: 1rem; padding-top: 0.8rem; border-top: 1px solid var(--border); text-align: center; font-size: 0.72rem; color: var(--text-secondary); }}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<header>
|
||||
<div>
|
||||
<div class="title-row">
|
||||
<span class="dot" style="background:var(--gold);box-shadow:0 0 10px var(--gold);" aria-hidden="true"></span>
|
||||
<h1>{header_h1}</h1>
|
||||
</div>
|
||||
<p class="subtitle">{header_subtitle_html}</p>
|
||||
</div>
|
||||
<nav class="top-nav hs-global-nav" aria-label="Primary Ecosystem Navigation">
|
||||
{global_nav_html}
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<nav class="hs-subnav-bar panel hs-plate-g3" aria-label="Unit and Polyglot Sub-Navigation">
|
||||
{subnav_html}
|
||||
</nav>
|
||||
|
||||
{prereq_html}
|
||||
{guile_hub_html}
|
||||
|
||||
<section class="stats-row">
|
||||
{stat_tiles_html}
|
||||
</section>
|
||||
|
||||
<section class="grid-cards">
|
||||
{cards_html}
|
||||
</section>{extra_panels_block}
|
||||
<footer>
|
||||
hyperstitionstud.io/{surface_slug} v{CURRENT_VERSION} • CIDv1: <code>{cidv1_prefix}...</code> • <span class="hs-sigil-colophon" aria-hidden="true">⚚ · ☿ · ☍ · ☉ · ♄</span> • Made with <span class="hs-heart" style="color:var(--rose);">♥</span> by Lemurs.
|
||||
</footer>
|
||||
</div>
|
||||
<script src="../assets/hs-matrix-coderain.js?v={CURRENT_VERSION}" defer></script>
|
||||
<script src="../assets/hs-mobile-ui.js?v={CURRENT_VERSION}" defer></script>
|
||||
<script src="{manifest_js_filename}?v={CURRENT_VERSION}"></script>
|
||||
<script src="{app_js_filename}?v={CURRENT_VERSION}"></script>{guile_drawer_html}
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
|
||||
|
||||
def render_explication_subpage_html(
|
||||
*,
|
||||
slug: str,
|
||||
surface_slug: str,
|
||||
hub_label: str,
|
||||
cli_prog: str,
|
||||
manifest: dict[str, Any],
|
||||
specs: dict[str, dict[str, Any]],
|
||||
global_nav_html: str,
|
||||
subnav_html: str,
|
||||
prereq_html: str,
|
||||
guile_sub_html: str,
|
||||
guile_drawer_html: str,
|
||||
manifest_js_filename: str,
|
||||
app_js_filename: str,
|
||||
extra_after_sections_html: str = "",
|
||||
) -> str:
|
||||
enabled = manifest["enabled_subpages"]
|
||||
spec = specs[slug]
|
||||
idx = enabled.index(slug)
|
||||
prev_link = (
|
||||
f'<a class="btn" href="../{enabled[idx - 1]}/index.html">← Prev: {specs[enabled[idx - 1]]["short_title"]}</a>'
|
||||
if idx > 0
|
||||
else f'<a class="btn" href="../index.html">← Back to {hub_label}</a>'
|
||||
)
|
||||
next_link = (
|
||||
f'<a class="btn" href="../{enabled[idx + 1]}/index.html">Next: {specs[enabled[idx + 1]]["short_title"]} →</a>'
|
||||
if idx + 1 < len(enabled)
|
||||
else f'<a class="btn" href="../index.html">Return to {hub_label} ↑</a>'
|
||||
)
|
||||
|
||||
secs_html = ""
|
||||
for sec in spec["sections"]:
|
||||
secs_html += (
|
||||
'<article class="panel hs-plate-g3" style="padding:1rem 1.2rem;margin-bottom:0.85rem;">'
|
||||
f'<h2 style="font-size:0.92rem;color:var(--gold);margin-bottom:0.4rem;">{sec["heading"]}</h2>'
|
||||
f'<p style="font-size:0.76rem;color:var(--text-main);line-height:1.6;">{sec["body"]}</p>'
|
||||
'</article>'
|
||||
)
|
||||
if extra_after_sections_html:
|
||||
secs_html += extra_after_sections_html
|
||||
|
||||
return f"""<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>{spec["title"]} — hyperstitionstud.io/{surface_slug} (v{CURRENT_VERSION})</title>
|
||||
<link rel="stylesheet" href="../../assets/hs-group3-basalt-chamfer.css?v={CURRENT_VERSION}" />
|
||||
<style>
|
||||
* {{ box-sizing: border-box; margin: 0; padding: 0; }}
|
||||
body {{ font-family: 'DejaVu Sans Mono', ui-monospace, monospace; padding: 1.25rem; line-height: 1.5; }}
|
||||
.container {{ max-width: 1360px; margin: 0 auto; }}
|
||||
header {{ padding: 1.1rem 1.35rem; margin-bottom: 0.75rem; display: flex; justify-content: space-between; align-items: center; flex-wrap: nowrap; gap: 0.85rem; }}
|
||||
@media (max-width: 1220px) {{ header {{ flex-wrap: wrap; }} }}
|
||||
h1 {{ font-size: 0.98rem; font-weight: 700; letter-spacing: -0.02em; color: var(--text-main); }}
|
||||
.subtitle {{ font-size: 0.71rem; color: var(--text-secondary); margin-top: 0.25rem; }}
|
||||
.top-nav {{ margin-left: auto; display: flex; gap: 0.38rem; flex-wrap: nowrap; align-items: center; }}
|
||||
.btn {{ padding: 0.34rem 0.62rem; font-size: 0.7rem; font-weight: 600; text-decoration: none; font-family: inherit; cursor: pointer; }}
|
||||
footer {{ margin-top: 1rem; padding-top: 0.8rem; border-top: 1px solid var(--border); text-align: center; font-size: 0.72rem; color: var(--text-secondary); }}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<header>
|
||||
<div>
|
||||
<div class="title-row">
|
||||
<span class="dot" style="background:var(--gold);box-shadow:0 0 10px var(--gold);" aria-hidden="true"></span>
|
||||
<h1>{spec["title"]}</h1>
|
||||
</div>
|
||||
<p class="subtitle">Cartridge {spec["unit_id"]} • Non-Sequentially Revertible via <code>{cli_prog} --disable {slug}</code> • v{CURRENT_VERSION} <span class="hs-sigil-seal" aria-hidden="true">[ ⚚ · ☿ · ☍ · ☉ ]</span></p>
|
||||
</div>
|
||||
<nav class="top-nav hs-global-nav" aria-label="Primary Ecosystem Navigation">
|
||||
{global_nav_html}
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<nav class="hs-subnav-bar panel hs-plate-g3" aria-label="Unit and Polyglot Sub-Navigation">
|
||||
{subnav_html}
|
||||
</nav>
|
||||
|
||||
{prereq_html}
|
||||
{guile_sub_html}
|
||||
{secs_html}
|
||||
|
||||
<div style="display:flex;justify-content:space-between;align-items:center;margin-top:0.8rem;">
|
||||
{prev_link}
|
||||
{next_link}
|
||||
</div>
|
||||
|
||||
<footer>
|
||||
hyperstitionstud.io/{surface_slug}/{slug} v{CURRENT_VERSION} • <span class="hs-sigil-colophon" aria-hidden="true">⚚ · ☿ · ☍ · ☉ · ♄</span> • Made with <span class="hs-heart" style="color:var(--rose);">♥</span> by Lemurs.
|
||||
</footer>
|
||||
</div>
|
||||
<script src="../../assets/hs-matrix-coderain.js?v={CURRENT_VERSION}" defer></script>
|
||||
<script src="../../assets/hs-mobile-ui.js?v={CURRENT_VERSION}" defer></script>
|
||||
<script src="../{manifest_js_filename}?v={CURRENT_VERSION}"></script>
|
||||
<script src="../{app_js_filename}?v={CURRENT_VERSION}"></script>{guile_drawer_html}
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
|
||||
|
||||
def write_explication_site_bundle(
|
||||
*,
|
||||
surface_slug: str,
|
||||
all_subpages: tuple[str, ...],
|
||||
enabled_subpages: tuple[str, ...] | list[str],
|
||||
out_dir: str | Path | None,
|
||||
disable_all: bool,
|
||||
include_guile_lens: bool,
|
||||
workspace_root: str | Path | None,
|
||||
introspect_fn: Callable[..., dict[str, Any]],
|
||||
render_hub_fn: Callable[..., str],
|
||||
render_subpage_fn: Callable[..., str],
|
||||
manifest_json_filename: str,
|
||||
manifest_js_filename: str,
|
||||
manifest_window_var: str,
|
||||
app_js_filename: str,
|
||||
app_js_source: str,
|
||||
) -> dict[str, Any]:
|
||||
cfg = load_workspace_config(workspace_root=workspace_root)
|
||||
target_dir = Path(out_dir).resolve() if out_dir else (cfg.core_dir / "site" / surface_slug).resolve()
|
||||
|
||||
with ReadOnlyIsolationGuard(cfg.read_only_files) as guard:
|
||||
if disable_all:
|
||||
if target_dir.is_dir():
|
||||
shutil.rmtree(target_dir)
|
||||
return {"ok": True, "disabled_all": True, "enabled_routes": []}
|
||||
|
||||
target_dir.mkdir(parents=True, exist_ok=True)
|
||||
active_tuple = tuple(s for s in all_subpages if s in enabled_subpages)
|
||||
manifest = introspect_fn(enabled_subpages=active_tuple, workspace_root=workspace_root)
|
||||
|
||||
(target_dir / manifest_json_filename).write_text(
|
||||
json.dumps(manifest, indent=2, ensure_ascii=False) + "\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
(target_dir / manifest_js_filename).write_text(
|
||||
f"window.{manifest_window_var} = " + json.dumps(manifest, ensure_ascii=False) + ";\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
(target_dir / app_js_filename).write_text(app_js_source, encoding="utf-8")
|
||||
(target_dir / "index.html").write_text(
|
||||
render_hub_fn(manifest, include_guile_lens=include_guile_lens),
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
for s in all_subpages:
|
||||
sub_d = target_dir / s
|
||||
if s in active_tuple:
|
||||
sub_d.mkdir(parents=True, exist_ok=True)
|
||||
(sub_d / "index.html").write_text(
|
||||
render_subpage_fn(s, manifest, include_guile_lens=include_guile_lens),
|
||||
encoding="utf-8",
|
||||
)
|
||||
elif sub_d.is_dir():
|
||||
shutil.rmtree(sub_d)
|
||||
|
||||
return {
|
||||
"ok": True,
|
||||
"version": CURRENT_VERSION,
|
||||
"output_dir": str(target_dir),
|
||||
"guile_scheme_lens_enabled": include_guile_lens,
|
||||
"enabled_subpages": list(active_tuple),
|
||||
"enabled_routes": manifest["enabled_routes"],
|
||||
"cidv1": manifest["ipld_dag_json_cidv1"]["/"],
|
||||
"isolation_receipt": guard.audit_receipt(),
|
||||
}
|
||||
|
||||
|
||||
def run_explication_cli_main(
|
||||
*,
|
||||
prog: str,
|
||||
description: str,
|
||||
all_subpages: tuple[str, ...],
|
||||
specs: dict[str, dict[str, Any]],
|
||||
build_fn: Callable[..., dict[str, Any]],
|
||||
argv: list[str] | None = None,
|
||||
sync_help: str | None = None,
|
||||
disable_help: str = "",
|
||||
only_help: str = "",
|
||||
disable_all_help: str | None = None,
|
||||
disable_guile_help: str = "",
|
||||
) -> int:
|
||||
ap = argparse.ArgumentParser(prog=prog, description=description)
|
||||
ap.add_argument("--sync", action="store_true", help=sync_help)
|
||||
ap.add_argument("--disable", default="", help=disable_help)
|
||||
ap.add_argument("--only", default="", help=only_help)
|
||||
ap.add_argument("--disable-all", action="store_true", help=disable_all_help)
|
||||
ap.add_argument("--disable-guile-lens", action="store_true", help=disable_guile_help)
|
||||
ap.add_argument("--out-dir", default=None)
|
||||
args = ap.parse_args(argv)
|
||||
|
||||
unit_map = {spec["unit_id"].upper(): slug for slug, spec in specs.items()}
|
||||
enabled = list(all_subpages)
|
||||
if args.only:
|
||||
req = {unit_map.get(x.strip().upper(), x.strip()) for x in args.only.split(",") if x.strip()}
|
||||
enabled = [s for s in all_subpages if s in req]
|
||||
if args.disable:
|
||||
dis = {unit_map.get(x.strip().upper(), x.strip()) for x in args.disable.split(",") if x.strip()}
|
||||
enabled = [s for s in enabled if s not in dis]
|
||||
|
||||
res = build_fn(
|
||||
out_dir=args.out_dir,
|
||||
enabled_subpages=tuple(enabled),
|
||||
disable_all=args.disable_all,
|
||||
include_guile_lens=not args.disable_guile_lens,
|
||||
)
|
||||
print(json.dumps(res, indent=2))
|
||||
return 0
|
||||
@@ -8,6 +8,7 @@ PNG rendering never crashes on OS-specific font paths.
|
||||
from __future__ import annotations
|
||||
|
||||
import functools
|
||||
import os
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
@@ -109,6 +110,28 @@ def _reportlab_vera_fallback(filename: str) -> Path | None:
|
||||
return None
|
||||
|
||||
|
||||
@functools.lru_cache(maxsize=1)
|
||||
def _system_font_index() -> dict[str, Path]:
|
||||
"""
|
||||
Walk `/usr/share/fonts` at most once per process and build a filename -> Path map.
|
||||
"""
|
||||
idx: dict[str, Path] = {}
|
||||
sys_fonts = Path("/usr/share/fonts")
|
||||
if not sys_fonts.is_dir():
|
||||
return idx
|
||||
try:
|
||||
for root, _, files in os.walk(sys_fonts):
|
||||
root_p = Path(root)
|
||||
for fn in files:
|
||||
if fn not in idx:
|
||||
cand = root_p / fn
|
||||
if cand.is_file():
|
||||
idx[fn] = cand
|
||||
except OSError:
|
||||
pass
|
||||
return idx
|
||||
|
||||
|
||||
@functools.lru_cache(maxsize=64)
|
||||
def resolve_font_path(filename: str, fallback_filename: str | None = None) -> Path | None:
|
||||
cand_direct = Path(filename)
|
||||
@@ -118,20 +141,16 @@ def resolve_font_path(filename: str, fallback_filename: str | None = None) -> Pa
|
||||
cand = d / filename
|
||||
if cand.is_file():
|
||||
return cand
|
||||
sys_fonts = Path("/usr/share/fonts")
|
||||
if sys_fonts.is_dir():
|
||||
for match in sys_fonts.rglob(filename):
|
||||
if match.is_file():
|
||||
return match
|
||||
sys_idx = _system_font_index()
|
||||
if filename in sys_idx:
|
||||
return sys_idx[filename]
|
||||
if fallback_filename:
|
||||
for d in FONT_SEARCH_DIRS:
|
||||
cand = d / fallback_filename
|
||||
if cand.is_file():
|
||||
return cand
|
||||
if sys_fonts.is_dir():
|
||||
for match in sys_fonts.rglob(fallback_filename):
|
||||
if match.is_file():
|
||||
return match
|
||||
if fallback_filename in sys_idx:
|
||||
return sys_idx[fallback_filename]
|
||||
return _reportlab_vera_fallback(filename)
|
||||
|
||||
|
||||
@@ -146,3 +165,129 @@ def load_pillow_font(filename: str, size: int) -> Any:
|
||||
return ImageFont.load_default(size=size)
|
||||
except TypeError:
|
||||
return ImageFont.load_default()
|
||||
|
||||
|
||||
def fit_pillow_text_to_width(
|
||||
draw: Any,
|
||||
text: str,
|
||||
max_width: int,
|
||||
*,
|
||||
preferred_size: int = 12,
|
||||
min_size: int = 8,
|
||||
bold: bool = False,
|
||||
font_filename: str | None = None,
|
||||
) -> tuple[Any, int, int]:
|
||||
"""
|
||||
Step down a monospace/TrueType font size ladder from `preferred_size` down to `min_size`
|
||||
until `text` fits within `max_width` pixels with zero mid-word `[:N]` string slicing.
|
||||
Returns `(font, text_width, text_height)`.
|
||||
"""
|
||||
font_file = font_filename or ("DejaVuSansMono-Bold.ttf" if bold else "DejaVuSansMono.ttf")
|
||||
for sz in range(preferred_size, min_size - 1, -1):
|
||||
f = load_pillow_font(font_file, sz)
|
||||
tb = draw.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 = load_pillow_font(font_file, min_size)
|
||||
tb = draw.textbbox((0, 0), text, font=f)
|
||||
return f, int(tb[2] - tb[0]), int(tb[3] - tb[1])
|
||||
|
||||
|
||||
def draw_bounded_box_text(
|
||||
draw: Any,
|
||||
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,
|
||||
font_filename: str | None = None,
|
||||
) -> tuple[int, int, int, int]:
|
||||
"""
|
||||
Render `text` strictly inside `box` (`(bx1, by1, bx2, by2)`) with horizontal padding `pad_x`,
|
||||
dynamic font-ladder fitting, and zero mid-word slicing. Returns the rendered `(tx1, ty1, tx2, ty2)` bbox.
|
||||
"""
|
||||
bx1, by1, bx2, by2 = box
|
||||
avail_w = max(16, (bx2 - bx1) - 2 * pad_x)
|
||||
f, tw, th = fit_pillow_text_to_width(
|
||||
draw,
|
||||
text,
|
||||
avail_w,
|
||||
preferred_size=preferred_size,
|
||||
min_size=min_size,
|
||||
bold=bold,
|
||||
font_filename=font_filename,
|
||||
)
|
||||
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))
|
||||
draw.text((tx, ty), text, font=f, fill=fill)
|
||||
if hasattr(draw, "texts") and draw.texts:
|
||||
return draw.texts[-1][2]
|
||||
tb = draw.textbbox((tx, ty), text, font=f)
|
||||
return (int(tb[0]), int(tb[1]), int(tb[2]), int(tb[3]))
|
||||
|
||||
|
||||
def draw_bounded_kv_row(
|
||||
draw: Any,
|
||||
box: tuple[int, int, int, int],
|
||||
key_text: str,
|
||||
val_text: str,
|
||||
*,
|
||||
fill_bg: tuple[int, int, int] = GROUP3_PALETTE["BG_ODD"],
|
||||
outline: tuple[int, int, int] = GROUP3_PALETTE["BORDER_MUTED"],
|
||||
key_fill: tuple[int, int, int] = (245, 198, 48),
|
||||
val_fill: tuple[int, int, int] = GROUP3_PALETTE["TXT_PRI"],
|
||||
key_size: int = 11,
|
||||
val_size: int = 11,
|
||||
val_bold: bool = False,
|
||||
min_val_x: int | None = None,
|
||||
) -> None:
|
||||
"""
|
||||
Render a bounded key-value row container inside `box` (`(bx1, by1, bx2, by2)`) with
|
||||
dynamic font-ladder fitting and guaranteed non-overlapping key and value bounding boxes.
|
||||
"""
|
||||
bx1, by1, bx2, by2 = box
|
||||
draw.rectangle([bx1, by1, bx2, by2], fill=fill_bg, outline=outline)
|
||||
total_inner = (bx2 - bx1) - 16
|
||||
kf, kw, kh = fit_pillow_text_to_width(
|
||||
draw,
|
||||
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
|
||||
draw.text((kx, ky), key_text, font=kf, fill=key_fill)
|
||||
if hasattr(draw, "texts") and draw.texts:
|
||||
key_tb = draw.texts[-1][2]
|
||||
else:
|
||||
tb = draw.textbbox((kx, ky), key_text, font=kf)
|
||||
key_tb = (int(tb[0]), int(tb[1]), int(tb[2]), int(tb[3]))
|
||||
|
||||
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_pillow_text_to_width(
|
||||
draw,
|
||||
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)
|
||||
draw.text((vx_start, vy), val_text, font=vf, fill=val_fill)
|
||||
@@ -3,7 +3,7 @@
|
||||
hyperstitionstud_io.publishing.math_docs
|
||||
Introspective Mathematical Foundations & Quantitative Semiotics Explication Hub (`/math/` Unit M0)
|
||||
& Orthogonal Subpage Cartridge Compiler (`Units M1-M5`, `hs-math-docs`).
|
||||
Reuses the Introspective Cartridge Architecture from `engineering_docs.py` with:
|
||||
Reuses the Introspective Cartridge Architecture from `explication_template.py` / `engineering_docs.py` with:
|
||||
- Zero external KaTeX/MathJax CDNs (`100%` native `<math>`/`<sub>`/`<sup>` + DejaVu Sans Mono Unicode glyphs),
|
||||
- Embedded Novice Prerequisite Ladders (`.hs-prereq-ladder`) with curated free public math courses/textbooks,
|
||||
- Time-invariant algebraic conservation-law verification + live empirical constant introspection (`math-manifest.json`),
|
||||
@@ -12,9 +12,6 @@ Reuses the Introspective Cartridge Architecture from `engineering_docs.py` with:
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
@@ -25,9 +22,19 @@ from hyperstitionstud_io.ciphers import (
|
||||
compute_aq,
|
||||
compute_variance,
|
||||
)
|
||||
from hyperstitionstud_io.config import load_workspace_config
|
||||
from hyperstitionstud_io.glossary import ReadOnlyIsolationGuard
|
||||
from hyperstitionstud_io.config import load_json_cached, load_workspace_config
|
||||
from hyperstitionstud_io.ipld import compute_dag_json_cidv1
|
||||
from hyperstitionstud_io.publishing.explication_template import (
|
||||
_render_global_nav_html,
|
||||
_render_guile_repl_drawer_html,
|
||||
_render_prereq_box_html,
|
||||
render_explication_cartridge_html,
|
||||
render_explication_hub_page_html,
|
||||
render_explication_nav_html,
|
||||
render_explication_subpage_html,
|
||||
run_explication_cli_main,
|
||||
write_explication_site_bundle,
|
||||
)
|
||||
|
||||
ALL_MATH_SUBPAGES: tuple[str, ...] = (
|
||||
"base36-algebra-and-primes",
|
||||
@@ -99,13 +106,13 @@ MATH_GUILE_CARTRIDGES: dict[str, dict[str, str]] = {
|
||||
|
||||
|
||||
def _render_math_guile_cartridge_html(key: str) -> str:
|
||||
from hyperstitionstud_io.publishing.engineering_docs import render_polyglot_cartridge_html
|
||||
|
||||
return render_polyglot_cartridge_html(
|
||||
MATH_GUILE_CARTRIDGES[key],
|
||||
return render_explication_cartridge_html(
|
||||
MATH_GUILE_CARTRIDGES,
|
||||
key,
|
||||
spec_label="1. Mathematical Identity & Python:",
|
||||
)
|
||||
|
||||
|
||||
MATH_HUB_PREREQ_LADDER: dict[str, Any] = {
|
||||
"unit_id": "M0",
|
||||
"expertise_level": "Level 1-2 (High-School Algebra & Sigma Notation • 3-6 hrs study)",
|
||||
@@ -268,11 +275,11 @@ def introspect_math_manifest(
|
||||
workspace_root: str | Path | None = None,
|
||||
) -> dict[str, Any]:
|
||||
cfg = load_workspace_config(workspace_root=workspace_root)
|
||||
gl_obj = json.loads((cfg.zoology_dir / "taxonomy" / "glossary-registry.json").read_text(encoding="utf-8"))
|
||||
kg_obj = json.loads((cfg.knowledge_graph_dir / "encyclopedia-graph.json").read_text(encoding="utf-8"))
|
||||
ts_obj = json.loads((cfg.core_dir / "site" / "quant" / "quant-timeseries.json").read_text(encoding="utf-8"))
|
||||
mac_obj = json.loads((cfg.core_dir / "site" / "quant" / "real-macro-indicators.json").read_text(encoding="utf-8"))
|
||||
brf_obj = json.loads((cfg.core_dir / "site" / "quant" / "daily-brief-latest.json").read_text(encoding="utf-8"))
|
||||
gl_obj = load_json_cached(cfg.zoology_dir / "taxonomy" / "glossary-registry.json", copy_result=False)
|
||||
kg_obj = load_json_cached(cfg.knowledge_graph_dir / "encyclopedia-graph.json", copy_result=False)
|
||||
ts_obj = load_json_cached(cfg.core_dir / "site" / "quant" / "quant-timeseries.json", copy_result=False)
|
||||
mac_obj = load_json_cached(cfg.core_dir / "site" / "quant" / "real-macro-indicators.json", copy_result=False)
|
||||
brf_obj = load_json_cached(cfg.core_dir / "site" / "quant" / "daily-brief-latest.json", copy_result=False)
|
||||
|
||||
# Verify algebraic invariants dynamically
|
||||
eti_weights = [0.20, 0.18, 0.18, 0.16, 0.14, 0.14]
|
||||
@@ -328,36 +335,16 @@ def introspect_math_manifest(
|
||||
|
||||
|
||||
def _render_math_nav_html(active_slug: str | None, enabled_subpages: list[str], rel_prefix: str) -> str:
|
||||
links = [
|
||||
f'<a class="btn" href="{rel_prefix}index.html" style="border-color:{"var(--gold)" if active_slug is None else "rgba(56,189,248,0.55)"};">Math Hub (M0)</a>',
|
||||
]
|
||||
direct_pages = enabled_subpages[:6]
|
||||
overflow_pages = enabled_subpages[6:]
|
||||
for s in direct_pages:
|
||||
spec = MATH_SUBPAGE_SPECS[s]
|
||||
is_act = (s == active_slug)
|
||||
href = f"{s}/index.html" if active_slug is None else (f"../{s}/index.html" if not is_act else "index.html")
|
||||
style = "border-color:var(--gold);color:var(--gold);" if is_act else ""
|
||||
links.append(f'<a class="btn" href="{href}" style="{style}">{spec["short_title"]}</a>')
|
||||
if overflow_pages:
|
||||
opts = ['<option value="">More Units ▾</option>']
|
||||
for s in overflow_pages:
|
||||
spec = MATH_SUBPAGE_SPECS[s]
|
||||
href = f"{s}/index.html" if active_slug is None else (f"../{s}/index.html" if s != active_slug else "index.html")
|
||||
opts.append(f'<option value="{href}">{spec["short_title"]}</option>')
|
||||
links.append(f'<select class="btn hs-nav-overflow-select" onchange="if(this.value)window.location.href=this.value">{"".join(opts)}</select>')
|
||||
from hyperstitionstud_io.publishing.engineering_docs import _render_polyglot_selector_html
|
||||
|
||||
unit_links_html = "\n ".join(links)
|
||||
return (
|
||||
f'<div class="hs-subnav-links">\n {unit_links_html}\n </div>\n'
|
||||
f' {_render_polyglot_selector_html()}'
|
||||
return render_explication_nav_html(
|
||||
hub_label="Math Hub (M0)",
|
||||
active_slug=active_slug,
|
||||
enabled_subpages=enabled_subpages,
|
||||
specs=MATH_SUBPAGE_SPECS,
|
||||
rel_prefix=rel_prefix,
|
||||
)
|
||||
|
||||
|
||||
def _render_math_prereq_html(level_str: str, prereqs: list[str], resources: list[dict[str, Any]], rel_prefix: str) -> str:
|
||||
from hyperstitionstud_io.publishing.engineering_docs import _render_prereq_box_html
|
||||
|
||||
return _render_prereq_box_html(
|
||||
level_str=level_str,
|
||||
prereqs=prereqs,
|
||||
@@ -369,11 +356,6 @@ def _render_math_prereq_html(level_str: str, prereqs: list[str], resources: list
|
||||
|
||||
|
||||
def _render_math_hub_html(manifest: dict[str, Any], include_guile_lens: bool = True) -> str:
|
||||
from hyperstitionstud_io.publishing.engineering_docs import (
|
||||
_render_global_nav_html,
|
||||
_render_guile_repl_drawer_html,
|
||||
)
|
||||
|
||||
enabled = manifest["enabled_subpages"]
|
||||
inv = manifest["algebraic_invariants"]
|
||||
emp = manifest["empirical_counts"]
|
||||
@@ -392,101 +374,43 @@ def _render_math_hub_html(manifest: dict[str, Any], include_guile_lens: bool = T
|
||||
guile_hub_html = _render_math_guile_cartridge_html("M0") if include_guile_lens else ""
|
||||
guile_drawer_html = _render_guile_repl_drawer_html("") if include_guile_lens else ""
|
||||
|
||||
cards_html = ""
|
||||
sigil_map = {
|
||||
"M1": "☿",
|
||||
"M2": "∆ ◈",
|
||||
"M3": "☉",
|
||||
"M4": "♄ ☍",
|
||||
"M5": "⊗ λ",
|
||||
}
|
||||
for s in enabled:
|
||||
sp = MATH_SUBPAGE_SPECS[s]
|
||||
sig = sigil_map.get(sp["unit_id"], "λ")
|
||||
cards_html += (
|
||||
f'<article class="panel hs-plate-g3 {sp["pip_class"]}" style="padding:1rem 1.15rem;display:flex;flex-direction:column;justify-content:space-between;gap:0.6rem;">'
|
||||
f'<div><div style="font-size:0.7rem;color:var(--gold);font-weight:700;"><span class="hs-sigil" aria-hidden="true">{sig}</span>{sp["unit_id"]} // {sp["expertise_level"]}</div>'
|
||||
f'<h2 style="font-size:0.95rem;margin:0.25rem 0;color:var(--text-main);">{sp["title"]}</h2>'
|
||||
f'<p style="font-size:0.74rem;color:var(--text-secondary);line-height:1.5;">{sp["sections"][0]["body"]}</p></div>'
|
||||
f'<div><a class="btn" href="{s}/index.html">Open {sp["short_title"]} Subpage →</a></div></article>'
|
||||
)
|
||||
stat_tiles_html = (
|
||||
f' <div class="panel hs-plate-g3 stat-tile"><div style="font-size:0.68rem;color:var(--text-secondary);">ETI Convex Sum (∑w_k)</div><div style="font-size:1.3rem;font-weight:700;color:var(--gold);">{inv["eti_weights_sum"]:.2f}</div></div>\n'
|
||||
f' <div class="panel hs-plate-g3 stat-tile"><div style="font-size:0.68rem;color:var(--text-secondary);">Bayesian Simplex (∑P_m)</div><div style="font-size:1.3rem;font-weight:700;color:var(--cyan);">{inv["bayesian_posterior_simplex_sum"]:.4f}</div></div>\n'
|
||||
f' <div class="panel hs-plate-g3 stat-tile"><div style="font-size:0.68rem;color:var(--text-secondary);">292 G1 Collapse (σ²_0 → σ²_1)</div><div style="font-size:1.2rem;font-weight:700;color:var(--emerald);">{inv["cluster_292_gen0_variance"]} → {inv["cluster_292_gen1_variance"]}</div></div>\n'
|
||||
f' <div class="panel hs-plate-g3 stat-tile"><div style="font-size:0.68rem;color:var(--text-secondary);">G4 Fixed Points (Δ=0)</div><div style="font-size:1.3rem;font-weight:700;color:var(--gold);">{inv["g4_isometric_fixed_point_count"]}</div></div>\n'
|
||||
f' <div class="panel hs-plate-g3 stat-tile"><div style="font-size:0.68rem;color:var(--text-secondary);">Real Bars / FRED Series</div><div style="font-size:1.3rem;font-weight:700;color:var(--cyan);">{emp["total_real_bars_n"]} / {emp["fred_macro_series_n"]}</div></div>'
|
||||
)
|
||||
|
||||
return f"""<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Mathematical Foundations & Quantitative Semiotics Hub — hyperstitionstud.io/math (v{CURRENT_VERSION})</title>
|
||||
<link rel="stylesheet" href="../assets/hs-group3-basalt-chamfer.css?v={CURRENT_VERSION}" />
|
||||
<style>
|
||||
* {{ box-sizing: border-box; margin: 0; padding: 0; }}
|
||||
body {{ font-family: 'DejaVu Sans Mono', ui-monospace, monospace; padding: 1.25rem; line-height: 1.5; }}
|
||||
.container {{ max-width: 1360px; margin: 0 auto; }}
|
||||
header {{ padding: 1.1rem 1.35rem; margin-bottom: 0.75rem; display: flex; justify-content: space-between; align-items: center; flex-wrap: nowrap; gap: 0.85rem; }}
|
||||
@media (max-width: 1220px) {{ header {{ flex-wrap: wrap; }} }}
|
||||
h1 {{ font-size: 0.98rem; font-weight: 700; letter-spacing: -0.02em; color: var(--text-main); }}
|
||||
.subtitle {{ font-size: 0.71rem; color: var(--text-secondary); margin-top: 0.25rem; }}
|
||||
.top-nav {{ margin-left: auto; display: flex; gap: 0.38rem; flex-wrap: nowrap; align-items: center; }}
|
||||
.btn {{ padding: 0.34rem 0.62rem; font-size: 0.7rem; font-weight: 600; text-decoration: none; font-family: inherit; cursor: pointer; }}
|
||||
.grid-cards {{ display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 0.85rem; margin-bottom: 0.9rem; }}
|
||||
.stats-row {{ display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 0.6rem; margin-bottom: 0.9rem; }}
|
||||
.stat-tile {{ padding: 0.7rem 0.85rem; text-align: center; }}
|
||||
footer {{ margin-top: 1rem; padding-top: 0.8rem; border-top: 1px solid var(--border); text-align: center; font-size: 0.72rem; color: var(--text-secondary); }}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<header>
|
||||
<div>
|
||||
<div class="title-row">
|
||||
<span class="dot" style="background:var(--gold);box-shadow:0 0 10px var(--gold);" aria-hidden="true"></span>
|
||||
<h1>HYPERSTITION STUDIO // MATHEMATICAL FOUNDATIONS & QUANTITATIVE SEMIOTICS HUB (UNIT M0)</h1>
|
||||
</div>
|
||||
<p class="subtitle">Zero-CDN Native Unicode Math • Commutative Empirical Introspection • Piecewise & Non-Sequentially Revertible • urn:io:hyperstitionstud:math:v{CURRENT_VERSION} <span class="hs-sigil-seal" aria-hidden="true">[ ⚚ · ☿ · ☍ · ☉ ]</span></p>
|
||||
</div>
|
||||
<nav class="top-nav hs-global-nav" aria-label="Primary Ecosystem Navigation">
|
||||
{global_nav_html}
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<nav class="hs-subnav-bar panel hs-plate-g3" aria-label="Unit and Polyglot Sub-Navigation">
|
||||
{subnav_html}
|
||||
</nav>
|
||||
|
||||
{prereq_html}
|
||||
{guile_hub_html}
|
||||
|
||||
<section class="stats-row">
|
||||
<div class="panel hs-plate-g3 stat-tile"><div style="font-size:0.68rem;color:var(--text-secondary);">ETI Convex Sum (∑w_k)</div><div style="font-size:1.3rem;font-weight:700;color:var(--gold);">{inv["eti_weights_sum"]:.2f}</div></div>
|
||||
<div class="panel hs-plate-g3 stat-tile"><div style="font-size:0.68rem;color:var(--text-secondary);">Bayesian Simplex (∑P_m)</div><div style="font-size:1.3rem;font-weight:700;color:var(--cyan);">{inv["bayesian_posterior_simplex_sum"]:.4f}</div></div>
|
||||
<div class="panel hs-plate-g3 stat-tile"><div style="font-size:0.68rem;color:var(--text-secondary);">292 G1 Collapse (σ²_0 → σ²_1)</div><div style="font-size:1.2rem;font-weight:700;color:var(--emerald);">{inv["cluster_292_gen0_variance"]} → {inv["cluster_292_gen1_variance"]}</div></div>
|
||||
<div class="panel hs-plate-g3 stat-tile"><div style="font-size:0.68rem;color:var(--text-secondary);">G4 Fixed Points (Δ=0)</div><div style="font-size:1.3rem;font-weight:700;color:var(--gold);">{inv["g4_isometric_fixed_point_count"]}</div></div>
|
||||
<div class="panel hs-plate-g3 stat-tile"><div style="font-size:0.68rem;color:var(--text-secondary);">Real Bars / FRED Series</div><div style="font-size:1.3rem;font-weight:700;color:var(--cyan);">{emp["total_real_bars_n"]} / {emp["fred_macro_series_n"]}</div></div>
|
||||
</section>
|
||||
|
||||
<section class="grid-cards">
|
||||
{cards_html}
|
||||
</section>
|
||||
|
||||
<footer>
|
||||
hyperstitionstud.io/math v{CURRENT_VERSION} • CIDv1: <code>{manifest["ipld_dag_json_cidv1"]["/"][:36]}...</code> • <span class="hs-sigil-colophon" aria-hidden="true">⚚ · ☿ · ☍ · ☉ · ♄</span> • Made with <span class="hs-heart" style="color:var(--rose);">♥</span> by Lemurs.
|
||||
</footer>
|
||||
</div>
|
||||
<script src="../assets/hs-matrix-coderain.js?v={CURRENT_VERSION}" defer></script>
|
||||
<script src="../assets/hs-mobile-ui.js?v={CURRENT_VERSION}" defer></script>
|
||||
<script src="math-manifest-data.js?v={CURRENT_VERSION}"></script>
|
||||
<script src="math-app.js?v={CURRENT_VERSION}"></script>{guile_drawer_html}
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
return render_explication_hub_page_html(
|
||||
surface_slug="math",
|
||||
page_title=f"Mathematical Foundations & Quantitative Semiotics Hub — hyperstitionstud.io/math (v{CURRENT_VERSION})",
|
||||
header_h1="HYPERSTITION STUDIO // MATHEMATICAL FOUNDATIONS & QUANTITATIVE SEMIOTICS HUB (UNIT M0)",
|
||||
header_subtitle_html=f'Zero-CDN Native Unicode Math • Commutative Empirical Introspection • Piecewise & Non-Sequentially Revertible • urn:io:hyperstitionstud:math:v{CURRENT_VERSION} <span class="hs-sigil-seal" aria-hidden="true">[ ⚚ · ☿ · ☍ · ☉ ]</span>',
|
||||
global_nav_html=global_nav_html,
|
||||
subnav_html=subnav_html,
|
||||
prereq_html=prereq_html,
|
||||
guile_hub_html=guile_hub_html,
|
||||
guile_drawer_html=guile_drawer_html,
|
||||
stat_tiles_html=stat_tiles_html,
|
||||
enabled_subpages=enabled,
|
||||
specs=MATH_SUBPAGE_SPECS,
|
||||
sigil_map={
|
||||
"M1": "☿",
|
||||
"M2": "∆ ◈",
|
||||
"M3": "☉",
|
||||
"M4": "♄ ☍",
|
||||
"M5": "⊗ λ",
|
||||
},
|
||||
default_sigil="λ",
|
||||
cidv1_prefix=manifest["ipld_dag_json_cidv1"]["/"][:36],
|
||||
manifest_js_filename="math-manifest-data.js",
|
||||
app_js_filename="math-app.js",
|
||||
stats_min_col_px=175,
|
||||
)
|
||||
|
||||
|
||||
def _render_math_subpage_html(slug: str, manifest: dict[str, Any], include_guile_lens: bool = True) -> str:
|
||||
from hyperstitionstud_io.publishing.engineering_docs import (
|
||||
_render_global_nav_html,
|
||||
_render_guile_repl_drawer_html,
|
||||
)
|
||||
|
||||
enabled = manifest["enabled_subpages"]
|
||||
spec = MATH_SUBPAGE_SPECS[slug]
|
||||
global_nav_html = _render_global_nav_html("../", "math")
|
||||
@@ -495,78 +419,21 @@ def _render_math_subpage_html(slug: str, manifest: dict[str, Any], include_guile
|
||||
guile_sub_html = _render_math_guile_cartridge_html(slug) if include_guile_lens else ""
|
||||
guile_drawer_html = _render_guile_repl_drawer_html("../") if include_guile_lens else ""
|
||||
|
||||
idx = enabled.index(slug)
|
||||
prev_link = f'<a class="btn" href="../{enabled[idx - 1]}/index.html">← Prev: {MATH_SUBPAGE_SPECS[enabled[idx - 1]]["short_title"]}</a>' if idx > 0 else '<a class="btn" href="../index.html">← Back to Math Hub (M0)</a>'
|
||||
next_link = f'<a class="btn" href="../{enabled[idx + 1]}/index.html">Next: {MATH_SUBPAGE_SPECS[enabled[idx + 1]]["short_title"]} →</a>' if idx + 1 < len(enabled) else '<a class="btn" href="../index.html">Return to Math Hub (M0) ↑</a>'
|
||||
|
||||
secs_html = ""
|
||||
for sec in spec["sections"]:
|
||||
secs_html += (
|
||||
'<article class="panel hs-plate-g3" style="padding:1rem 1.2rem;margin-bottom:0.85rem;">'
|
||||
f'<h2 style="font-size:0.92rem;color:var(--gold);margin-bottom:0.4rem;">{sec["heading"]}</h2>'
|
||||
f'<p style="font-size:0.76rem;color:var(--text-main);line-height:1.6;">{sec["body"]}</p>'
|
||||
'</article>'
|
||||
)
|
||||
|
||||
return f"""<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>{spec["title"]} — hyperstitionstud.io/math (v{CURRENT_VERSION})</title>
|
||||
<link rel="stylesheet" href="../../assets/hs-group3-basalt-chamfer.css?v={CURRENT_VERSION}" />
|
||||
<style>
|
||||
* {{ box-sizing: border-box; margin: 0; padding: 0; }}
|
||||
body {{ font-family: 'DejaVu Sans Mono', ui-monospace, monospace; padding: 1.25rem; line-height: 1.5; }}
|
||||
.container {{ max-width: 1360px; margin: 0 auto; }}
|
||||
header {{ padding: 1.1rem 1.35rem; margin-bottom: 0.75rem; display: flex; justify-content: space-between; align-items: center; flex-wrap: nowrap; gap: 0.85rem; }}
|
||||
@media (max-width: 1220px) {{ header {{ flex-wrap: wrap; }} }}
|
||||
h1 {{ font-size: 0.98rem; font-weight: 700; letter-spacing: -0.02em; color: var(--text-main); }}
|
||||
.subtitle {{ font-size: 0.71rem; color: var(--text-secondary); margin-top: 0.25rem; }}
|
||||
.top-nav {{ margin-left: auto; display: flex; gap: 0.38rem; flex-wrap: nowrap; align-items: center; }}
|
||||
.btn {{ padding: 0.34rem 0.62rem; font-size: 0.7rem; font-weight: 600; text-decoration: none; font-family: inherit; cursor: pointer; }}
|
||||
footer {{ margin-top: 1rem; padding-top: 0.8rem; border-top: 1px solid var(--border); text-align: center; font-size: 0.72rem; color: var(--text-secondary); }}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<header>
|
||||
<div>
|
||||
<div class="title-row">
|
||||
<span class="dot" style="background:var(--gold);box-shadow:0 0 10px var(--gold);" aria-hidden="true"></span>
|
||||
<h1>{spec["title"]}</h1>
|
||||
</div>
|
||||
<p class="subtitle">Cartridge {spec["unit_id"]} • Non-Sequentially Revertible via <code>hs-math-docs --disable {slug}</code> • v{CURRENT_VERSION} <span class="hs-sigil-seal" aria-hidden="true">[ ⚚ · ☿ · ☍ · ☉ ]</span></p>
|
||||
</div>
|
||||
<nav class="top-nav hs-global-nav" aria-label="Primary Ecosystem Navigation">
|
||||
{global_nav_html}
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<nav class="hs-subnav-bar panel hs-plate-g3" aria-label="Unit and Polyglot Sub-Navigation">
|
||||
{subnav_html}
|
||||
</nav>
|
||||
|
||||
{prereq_html}
|
||||
{guile_sub_html}
|
||||
{secs_html}
|
||||
|
||||
<div style="display:flex;justify-content:space-between;align-items:center;margin-top:0.8rem;">
|
||||
{prev_link}
|
||||
{next_link}
|
||||
</div>
|
||||
|
||||
<footer>
|
||||
hyperstitionstud.io/math/{slug} v{CURRENT_VERSION} • <span class="hs-sigil-colophon" aria-hidden="true">⚚ · ☿ · ☍ · ☉ · ♄</span> • Made with <span class="hs-heart" style="color:var(--rose);">♥</span> by Lemurs.
|
||||
</footer>
|
||||
</div>
|
||||
<script src="../../assets/hs-matrix-coderain.js?v={CURRENT_VERSION}" defer></script>
|
||||
<script src="../../assets/hs-mobile-ui.js?v={CURRENT_VERSION}" defer></script>
|
||||
<script src="../math-manifest-data.js?v={CURRENT_VERSION}"></script>
|
||||
<script src="../math-app.js?v={CURRENT_VERSION}"></script>{guile_drawer_html}
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
return render_explication_subpage_html(
|
||||
slug=slug,
|
||||
surface_slug="math",
|
||||
hub_label="Math Hub (M0)",
|
||||
cli_prog="hs-math-docs",
|
||||
manifest=manifest,
|
||||
specs=MATH_SUBPAGE_SPECS,
|
||||
global_nav_html=global_nav_html,
|
||||
subnav_html=subnav_html,
|
||||
prereq_html=prereq_html,
|
||||
guile_sub_html=guile_sub_html,
|
||||
guile_drawer_html=guile_drawer_html,
|
||||
manifest_js_filename="math-manifest-data.js",
|
||||
app_js_filename="math-app.js",
|
||||
)
|
||||
|
||||
|
||||
def build_math_site(
|
||||
@@ -576,74 +443,37 @@ def build_math_site(
|
||||
include_guile_lens: bool = ENABLE_GUILE_SCHEME_LENS,
|
||||
workspace_root: str | Path | None = None,
|
||||
) -> dict[str, Any]:
|
||||
cfg = load_workspace_config(workspace_root=workspace_root)
|
||||
target_dir = Path(out_dir).resolve() if out_dir else (cfg.core_dir / "site" / "math").resolve()
|
||||
|
||||
with ReadOnlyIsolationGuard(cfg.read_only_files) as guard:
|
||||
if disable_all:
|
||||
if target_dir.is_dir():
|
||||
shutil.rmtree(target_dir)
|
||||
return {"ok": True, "disabled_all": True, "enabled_routes": []}
|
||||
|
||||
target_dir.mkdir(parents=True, exist_ok=True)
|
||||
active_tuple = tuple(s for s in ALL_MATH_SUBPAGES if s in enabled_subpages)
|
||||
manifest = introspect_math_manifest(enabled_subpages=active_tuple, workspace_root=workspace_root)
|
||||
|
||||
(target_dir / "math-manifest.json").write_text(json.dumps(manifest, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
|
||||
(target_dir / "math-manifest-data.js").write_text(
|
||||
"window.HYPERSTITION_MATH_MANIFEST = " + json.dumps(manifest, ensure_ascii=False) + ";\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
(target_dir / "math-app.js").write_text("(function(){ 'use strict'; })();\n", encoding="utf-8")
|
||||
(target_dir / "index.html").write_text(_render_math_hub_html(manifest, include_guile_lens=include_guile_lens), encoding="utf-8")
|
||||
|
||||
for s in ALL_MATH_SUBPAGES:
|
||||
sub_d = target_dir / s
|
||||
if s in active_tuple:
|
||||
sub_d.mkdir(parents=True, exist_ok=True)
|
||||
(sub_d / "index.html").write_text(_render_math_subpage_html(s, manifest, include_guile_lens=include_guile_lens), encoding="utf-8")
|
||||
elif sub_d.is_dir():
|
||||
shutil.rmtree(sub_d)
|
||||
|
||||
return {
|
||||
"ok": True,
|
||||
"version": CURRENT_VERSION,
|
||||
"output_dir": str(target_dir),
|
||||
"guile_scheme_lens_enabled": include_guile_lens,
|
||||
"enabled_subpages": list(active_tuple),
|
||||
"enabled_routes": manifest["enabled_routes"],
|
||||
"cidv1": manifest["ipld_dag_json_cidv1"]["/"],
|
||||
"isolation_receipt": guard.audit_receipt(),
|
||||
}
|
||||
return write_explication_site_bundle(
|
||||
surface_slug="math",
|
||||
all_subpages=ALL_MATH_SUBPAGES,
|
||||
enabled_subpages=enabled_subpages,
|
||||
out_dir=out_dir,
|
||||
disable_all=disable_all,
|
||||
include_guile_lens=include_guile_lens,
|
||||
workspace_root=workspace_root,
|
||||
introspect_fn=introspect_math_manifest,
|
||||
render_hub_fn=_render_math_hub_html,
|
||||
render_subpage_fn=_render_math_subpage_html,
|
||||
manifest_json_filename="math-manifest.json",
|
||||
manifest_js_filename="math-manifest-data.js",
|
||||
manifest_window_var="HYPERSTITION_MATH_MANIFEST",
|
||||
app_js_filename="math-app.js",
|
||||
app_js_source="(function(){ 'use strict'; })();\n",
|
||||
)
|
||||
|
||||
|
||||
def main(argv: list[str] | None = None) -> int:
|
||||
ap = argparse.ArgumentParser(prog="hs-math-docs", description="Build or toggle the /math/ Hub & modular subpages (M0-M5).")
|
||||
ap.add_argument("--sync", action="store_true")
|
||||
ap.add_argument("--disable", default="", help="Comma-separated subpage slugs or unit IDs (e.g. M3) to disable.")
|
||||
ap.add_argument("--only", default="", help="Comma-separated subpage slugs or unit IDs (e.g. M1,M4) to enable exclusively.")
|
||||
ap.add_argument("--disable-all", action="store_true")
|
||||
ap.add_argument("--disable-guile-lens", action="store_true", help="Omit additive Guile Scheme cartridges without touching M0-M5 content.")
|
||||
ap.add_argument("--out-dir", default=None)
|
||||
args = ap.parse_args(argv)
|
||||
|
||||
unit_map = {spec["unit_id"].upper(): slug for slug, spec in MATH_SUBPAGE_SPECS.items()}
|
||||
enabled = list(ALL_MATH_SUBPAGES)
|
||||
if args.only:
|
||||
req = {unit_map.get(x.strip().upper(), x.strip()) for x in args.only.split(",") if x.strip()}
|
||||
enabled = [s for s in ALL_MATH_SUBPAGES if s in req]
|
||||
if args.disable:
|
||||
dis = {unit_map.get(x.strip().upper(), x.strip()) for x in args.disable.split(",") if x.strip()}
|
||||
enabled = [s for s in enabled if s not in dis]
|
||||
|
||||
res = build_math_site(
|
||||
out_dir=args.out_dir,
|
||||
enabled_subpages=tuple(enabled),
|
||||
disable_all=args.disable_all,
|
||||
include_guile_lens=not args.disable_guile_lens,
|
||||
return run_explication_cli_main(
|
||||
prog="hs-math-docs",
|
||||
description="Build or toggle the /math/ Hub & modular subpages (M0-M5).",
|
||||
all_subpages=ALL_MATH_SUBPAGES,
|
||||
specs=MATH_SUBPAGE_SPECS,
|
||||
build_fn=build_math_site,
|
||||
argv=argv,
|
||||
disable_help="Comma-separated subpage slugs or unit IDs (e.g. M3) to disable.",
|
||||
only_help="Comma-separated subpage slugs or unit IDs (e.g. M1,M4) to enable exclusively.",
|
||||
disable_guile_help="Omit additive Guile Scheme cartridges without touching M0-M5 content.",
|
||||
)
|
||||
print(json.dumps(res, indent=2))
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -222,16 +222,20 @@ python3 hyperstitionstudio-core/tests/test_core_suite.py
|
||||
- `/` (Portal Home), `/learn/` (6-Module Interactive Track), `/quant/` (3-Pane Closing-Bell & FRED Macro Time-Series + 25-Scene Guided Tour), `/engineering/` (`E0-E5` Software Engineering Hub), `/math/` (`M0-M5` Applied Mathematics Hub), and `/donate/` (Signal Patronage).
|
||||
4. **4,943-Entry Offline `CMUdict` Phonetics Lookup (`cmudict_fallback.json`):**
|
||||
- Translates `Gen 0` English tokens to `Gen 1` Ingglish 100% offline with zero network calls.
|
||||
5. **One-Shot `900×1260` Ticker Stats Cards (`.png` + `.json`) via CLI, Chatbot REST API & MCP:**
|
||||
5. **One-Shot `900×1260` Ticker Stats Cards (`.png` + `.json`) via cURL, CLI, Chatbot REST API & MCP:**
|
||||
```bash
|
||||
# (a) Direct CLI entrypoint (writes /tmp/hyperstition-cards/NVDA-stats-card.{{png,json}}):
|
||||
# (a) cURL quickstart (zero local dependencies; works against https://hyperstitionstud.io or http://127.0.0.1:8095):
|
||||
curl -sS "https://hyperstitionstud.io/api/v1/tools/hs_generate_ticker_stats_card?symbol=NVDA&lens=tierzoo_ecology&include_base64_png=false" -o /tmp/NVDA-stats-card.json
|
||||
curl -sS "https://hyperstitionstud.io/api/v1/tools/hs_generate_ticker_stats_card?symbol=NVDA&lens=tierzoo_ecology&include_base64_png=true" | jq -r '.data.artifacts.png_base64' | base64 -d > /tmp/NVDA-stats-card.png
|
||||
|
||||
# (b) Direct CLI entrypoint (writes /tmp/hyperstition-cards/NVDA-stats-card.{{png,json}}):
|
||||
hs-ticker-card --symbol NVDA --lens tierzoo_ecology --out-dir /tmp/hyperstition-cards
|
||||
|
||||
# (b) Chatbot OpenAPI 3.1 REST API client (GET or POST /api/v1/tools/hs_generate_ticker_stats_card):
|
||||
# (c) Chatbot OpenAPI 3.1 REST API client (GET or POST /api/v1/tools/hs_generate_ticker_stats_card):
|
||||
curl -sS "https://hyperstitionstud.io/api/v1/tools/hs_generate_ticker_stats_card?symbol=NVDA&lens=tierzoo_ecology&include_base64_png=false" | jq .
|
||||
curl -sS "https://hyperstitionstud.io/api/v1/zoology/pokedex/NVDA?include_card=true" | jq '.data.stats_card.card_identity'
|
||||
|
||||
# (c) MCP JSON-RPC 2.0 client (Streamable HTTP POST /mcp or hs-mcp --transport stdio):
|
||||
# (d) MCP JSON-RPC 2.0 client (Streamable HTTP POST /mcp or hs-mcp --transport stdio):
|
||||
curl -sS -X POST "https://hyperstitionstud.io/mcp" -H "Content-Type: application/json" \\
|
||||
-d '{{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{{"name":"hs_generate_ticker_stats_card","arguments":{{"symbol":"NVDA","lens":"tierzoo_ecology","include_base64_png":false}}}}}}' | jq .
|
||||
```
|
||||
@@ -589,9 +593,10 @@ def main(argv: list[str] | None = None) -> int:
|
||||
ap.add_argument("--install-hooks", action="store_true", help="Install idempotent .git/hooks/pre-commit and commit-msg hooks across all 6 repositories.")
|
||||
ap.add_argument("--hooks-only", action="store_true", help="Install git hooks without modifying tracked README.md files on disk.")
|
||||
ap.add_argument("--version", default=None, help="Override target semantic version.")
|
||||
ap.add_argument("--workspace-root", default=None, help="Optional workspace root directory.")
|
||||
args = ap.parse_args(argv)
|
||||
|
||||
cfg = load_workspace_config()
|
||||
cfg = load_workspace_config(workspace_root=args.workspace_root)
|
||||
root = cfg.workspace_root
|
||||
|
||||
if args.hooks_only:
|
||||
|
||||
@@ -815,13 +815,13 @@ def main(argv: list[str] | None = None) -> int:
|
||||
ap.add_argument("--append-history", action="store_true", help="Merge newly fetched real exchange bars into site/quant/real-market-history.json.")
|
||||
ap.add_argument("--join-news", default=None, help="Optional path to news-aq-harvest-latest.json.")
|
||||
ap.add_argument("--write-dossier", default=None, help="Optional path to emit Markdown quant report.")
|
||||
ap.add_argument("--out", default=None, help="Output JSON path (default: <archive_dir>/financial-aq-harvest-latest.json).")
|
||||
ap.add_argument("--out", default=None, help="Output JSON path (default: <core_dir>/site/quant/financial-aq-harvest-latest.json).")
|
||||
args = ap.parse_args(argv)
|
||||
|
||||
cfg = load_workspace_config()
|
||||
if args.append_history:
|
||||
update_real_market_history_cache(allow_live_network=args.live)
|
||||
out_path = Path(args.out) if args.out else (cfg.archive_dir / "financial-aq-harvest-latest.json")
|
||||
out_path = Path(args.out) if args.out else (cfg.core_dir / "site" / "quant" / "financial-aq-harvest-latest.json")
|
||||
join_news = args.join_news or str(cfg.archive_dir / "news-aq-harvest-latest.json")
|
||||
|
||||
payload = build_financial_quant_harvest(
|
||||
|
||||
@@ -148,16 +148,21 @@ def build_daily_portfolio_brief(
|
||||
ts_bundle = build_quant_timeseries_bundle(write_files=False)
|
||||
macro_bundle = build_macro_indicators_bundle(allow_live_network=allow_live_network, write_files=False)
|
||||
|
||||
state_path = cfg.archive_dir.parent / "daily-brief-state.json"
|
||||
state_path = cfg.core_dir / "site" / "quant" / "daily-brief-state.json"
|
||||
legacy_state_paths = (
|
||||
cfg.archive_dir / "daily-brief-state.json",
|
||||
cfg.archive_dir.parent / "daily-brief-state.json",
|
||||
)
|
||||
out_json_path = cfg.core_dir / "site" / "quant" / "daily-brief-latest.json"
|
||||
out_js_path = cfg.core_dir / "site" / "quant" / "daily-brief-data.js"
|
||||
|
||||
with ReadOnlyIsolationGuard(cfg.read_only_files) as guard:
|
||||
# Load extant prior state if present
|
||||
# Load extant prior state if present (falling back to legacy path if needed)
|
||||
prior_state: dict[str, Any] = {}
|
||||
if state_path.is_file():
|
||||
active_read_state_path = state_path if state_path.is_file() else next((p for p in legacy_state_paths if p.is_file()), state_path)
|
||||
if active_read_state_path.is_file():
|
||||
try:
|
||||
prior_state = json.loads(state_path.read_text(encoding="utf-8"))
|
||||
prior_state = json.loads(active_read_state_path.read_text(encoding="utf-8"))
|
||||
except Exception:
|
||||
prior_state = {}
|
||||
|
||||
|
||||
Reference in new issue
Block a user