Release v2.0.30: Cold-archive rotation (.tar.gz), 6-Gate public regression suite (hs-public-smoke), VPS-native periodic data production timers, /engineering/ (E0-E5) & /math/ (M0-M5) explication hubs, and LLM pipeline operator manual
This commit is contained in:
1 parent
64825ffd75
commit
54e7f8ff61
55 files changed
+4039
-62
No files matched your search
@@ -0,0 +1,553 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
hyperstitionstud_io.publishing.engineering_docs
|
||||
Introspective Software Engineering Explication Hub (`/engineering/` Unit E0) & Orthogonal Subpage Cartridge
|
||||
Compiler (`Units E1-E5`, `hs-eng-docs`).
|
||||
Provides:
|
||||
- Automatic fixed-point closure via live codebase introspection (`engineering-manifest.json`),
|
||||
- Embedded Novice Prerequisite Ladders (`.hs-prereq-ladder`) with curated free public resources,
|
||||
- Single-step, multi-sequential-step, and non-sequential (arbitrary-subset) revertability via `ENABLED_ENGINEERING_SUBPAGES`,
|
||||
- `< 55 KB` total uncompressed footprint (`< 14 KB` Brotli-11) sharing `/assets/hs-group3-basalt-chamfer.css`.
|
||||
"""
|
||||
|
||||
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.quant.collector import CANONICAL_WATCHLIST_24
|
||||
from hyperstitionstud_io.quant.macro import FRED_SERIES_SPEC
|
||||
|
||||
ALL_ENGINEERING_SUBPAGES: tuple[str, ...] = (
|
||||
"ciphers-and-phonetics",
|
||||
"knowledge-graph-and-sqlite",
|
||||
"quant-macro-and-bayesian-brief",
|
||||
"mcp-chatbot-rest-and-ipld",
|
||||
"cicd-vps-tmpfs-and-regression",
|
||||
)
|
||||
|
||||
ENABLED_ENGINEERING_SUBPAGES: tuple[str, ...] = ALL_ENGINEERING_SUBPAGES
|
||||
|
||||
HUB_PREREQ_LADDER: dict[str, Any] = {
|
||||
"unit_id": "E0",
|
||||
"expertise_level": "Level 1-2 (Novice to Advanced Beginner • 4-8 hrs study)",
|
||||
"summary": "New to command-line shells, Git repositories, or client-server web architecture? Start with these free foundational resources before diving into the engineering subpages:",
|
||||
"links": [
|
||||
{"label": "Internal: Self-Paced Learning Track (/learn/ Modules 1-6)", "url": "/learn/index.html", "external": False},
|
||||
{"label": "MIT Missing Semester of Your CS Education (Shell, Git, CLI)", "url": "https://missing.csail.mit.edu/", "external": True},
|
||||
{"label": "MDN Web Docs — How the Web Works (HTTP, HTML, Servers)", "url": "https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/How_the_Web_works", "external": True},
|
||||
],
|
||||
}
|
||||
|
||||
ENGINEERING_SUBPAGE_SPECS: dict[str, dict[str, Any]] = {
|
||||
"ciphers-and-phonetics": {
|
||||
"unit_id": "E1",
|
||||
"slug": "ciphers-and-phonetics",
|
||||
"title": "Unit E1: Base-36 AQ Ciphers, Offline CMUdict Phonetics & Zero-d-Filter Isolation",
|
||||
"short_title": "E1: Ciphers & Phonetics",
|
||||
"pip_class": "plate-lock-gold",
|
||||
"expertise_level": "Level 2: Introductory Python & Text Processing (10-15 hrs study)",
|
||||
"prerequisites": [
|
||||
"Python 3 functions, dictionaries (dict), frozenset, and regular expressions (re.sub)",
|
||||
"ASCII & Unicode character codepoints (ord(), UTF-8)",
|
||||
"Dictionary lookup vs. deterministic grapheme-to-phoneme fallback rules",
|
||||
],
|
||||
"public_resources": [
|
||||
{"label": "Internal: /learn/ Module 1 & 2 (Base-36 & Ingglish)", "url": "/learn/index.html", "external": False},
|
||||
{"label": "Official Python 3 Tutorial (Sections 3-5 & 7)", "url": "https://docs.python.org/3/tutorial/", "external": True},
|
||||
{"label": "Harvard CS50P (Intro to Programming with Python)", "url": "https://cs50.harvard.edu/python/", "external": True},
|
||||
{"label": "CMU Pronouncing Dictionary (CMUdict) Specification", "url": "http://www.speech.cs.cmu.edu/cgi-bin/cmudict", "external": True},
|
||||
{"label": "RegexOne Interactive Regular Expression Tutorial", "url": "https://regexone.com/", "external": True},
|
||||
],
|
||||
"sections": [
|
||||
{
|
||||
"heading": "1. PEP 420 Namespace & Zero-d-Filter Boundary (hyperstitionstud_io.ciphers)",
|
||||
"body": "The cipher engine maps digits 0-9 to 0..9 (ord(c)-48) and ASCII letters A-Z to 10..35 (ord(c)-87) across three quantization modes: digit (default), off (qualitative lexical only), and spoken (number-word expansion via int_to_spoken_words()). assert_zero_d_filter() enforces a hard boundary preventing legacy 10-letter decagram filters from ever entering Zoology or Knowledge Graph artifacts.",
|
||||
},
|
||||
{
|
||||
"heading": "2. Three-Tier Offline Phonemic Transducer (hyperstitionstud_io.phonetics)",
|
||||
"body": "translate_batch() resolves English phrases into Gen 1 Ingglish with zero external network calls and zero hardcoded /workspace dependencies: Tier 1 delegates to local Node/CLI translators when present; Tier 2 looks up the 4,943-entry bundled cmudict_fallback.json; Tier 3 applies deterministic English digraph-to-phoneme rules so arbitrary OOV strings always resolve.",
|
||||
},
|
||||
],
|
||||
},
|
||||
"knowledge-graph-and-sqlite": {
|
||||
"unit_id": "E2",
|
||||
"slug": "knowledge-graph-and-sqlite",
|
||||
"title": "Unit E2: 6-Gate 388-Node Knowledge Graph Compiler, ReadOnlyIsolationGuard & Quiescent SQLite + FTS5 Engine",
|
||||
"short_title": "E2: Knowledge Graph & SQLite",
|
||||
"pip_class": "plate-lock-emerald",
|
||||
"expertise_level": "Level 3-4: Databases, Cryptographic Hashing & OS Concurrency (15-25 hrs study)",
|
||||
"prerequisites": [
|
||||
"Cryptographic hash functions (SHA-256) and Python context managers (with / __exit__)",
|
||||
"Relational schemas, inverted full-text search indices (SQLite FTS5), and graph representations",
|
||||
"ACID transactions, Write-Ahead Logging (WAL), and BEGIN EXCLUSIVE file locking",
|
||||
],
|
||||
"public_resources": [
|
||||
{"label": "SQLite Write-Ahead Logging (WAL) Architecture", "url": "https://www.sqlite.org/wal.html", "external": True},
|
||||
{"label": "SQLite FTS5 Full-Text Search Extension Docs", "url": "https://www.sqlite.org/fts5.html", "external": True},
|
||||
{"label": "CMU 15-445/645 (Intro to Database Systems — Andy Pavlo)", "url": "https://15445.courses.cs.cmu.edu/", "external": True},
|
||||
{"label": "Python contextlib & Context Manager Documentation", "url": "https://docs.python.org/3/library/contextlib.html", "external": True},
|
||||
],
|
||||
"sections": [
|
||||
{
|
||||
"heading": "1. ReadOnlyIsolationGuard Context Manager (hyperstitionstud_io.glossary)",
|
||||
"body": "Every compiler, MCP tool, and REST v1 handler executes inside with ReadOnlyIsolationGuard(cfg.read_only_files) as guard:. Before and after the block runs, SHA-256 digests of taxonomy/glossary-registry.json and encyclopedia/encyclopedia-manifest.json are verified against baseline constants, raising RuntimeError immediately on any byte mutation.",
|
||||
},
|
||||
{
|
||||
"heading": "2. 6-Gate Multi-Format Graph Compiler & Quiescent 100M SQLite Logrotate (db/sqlite_meta.py)",
|
||||
"body": "build_encyclopedia_knowledge_graph.py compiles 388 nodes and 1,282 edges into JSON, JS, GraphML, GEXF, Obsidian Canvas, and 3 1600x1060 PNG atlases. sqlite_meta.py hydrates hyperstition-catalog.db (FTS5) and records /api/v1/* and /mcp telemetry in /var/lib/hyperstitionstud.io/api-telemetry.db, while deploy/logrotate.d/hyperstition-sqlite-meta acquires BEGIN EXCLUSIVE at 100M, snapshots .1.gz, and runs PRAGMA wal_checkpoint(TRUNCATE); VACUUM;.",
|
||||
},
|
||||
],
|
||||
},
|
||||
"quant-macro-and-bayesian-brief": {
|
||||
"unit_id": "E3",
|
||||
"slug": "quant-macro-and-bayesian-brief",
|
||||
"title": "Unit E3: Zero-Synthetic-Data Quant Engine, 14-Point Bidirectional Census, Dose 0..3+, FRED Macro & Bayesian Brief",
|
||||
"short_title": "E3: Quant, Macro & Bayesian",
|
||||
"pip_class": "plate-lock-gold",
|
||||
"expertise_level": "Level 3: Data Engineering, Time-Series Ingestion & Strategy Registries (10-15 hrs study)",
|
||||
"prerequisites": [
|
||||
"HTTP JSON/CSV client ingestion (urllib.request) and resilient fallback chains",
|
||||
"Missing-data domain representation (None / null vs. silent 0.0 corruption)",
|
||||
"Pluggable projection registries (LENS_REGISTRY) and state-machine persistence",
|
||||
],
|
||||
"public_resources": [
|
||||
{"label": "Internal: /quant/ Interactive Guided Canvas Tour (5 Episodes)", "url": "/quant/index.html", "external": False},
|
||||
{"label": "Python urllib.request & json Standard Library Documentation", "url": "https://docs.python.org/3/library/urllib.request.html", "external": True},
|
||||
{"label": "St. Louis Federal Reserve (FRED) Series & CSV Documentation", "url": "https://fredhelp.stlouisfed.org/", "external": True},
|
||||
{"label": "Refactoring.Guru — Strategy & Adapter Design Patterns in Python", "url": "https://refactoring.guru/design-patterns/python", "external": True},
|
||||
],
|
||||
"sections": [
|
||||
{
|
||||
"heading": "1. Strict Zero-Synthetic-Data Collector & Native-Cadence FRED Macro Engine (collector.py, macro.py)",
|
||||
"body": "collector.py and timeseries.py eliminate all synthetic bar interpolation: 23 public tickers load 440 verified daily exchange bars (site/quant/real-market-history.json), while private entity ANTHR-PVT and closed weekend/holiday sessions serialize strictly as null ('No data available'). macro.py ingests 14 keyless St. Louis Fed (FRED) CSV series at native 1d, 1mo, and 1q cadences without forward-fill.",
|
||||
},
|
||||
{
|
||||
"heading": "2. 14-Point Bidirectional Census, Confluence Dose (D in {0..4}) & 5-Agenda Bayesian Brief (daily_brief.py)",
|
||||
"body": "timeseries.py evaluates all 14 data points in Gen 0 (eng_aq) and Gen 1 (ing_aq) and classifies each bar by its 4-species Confluence Dose (Dose 2 isometric pinning vs. Dose 3+ breakout). daily_brief.py updates the append-only Bayesian state ledger (daily-brief-state.json) across R1 Bull, R2 Pinned Isometric, and R3 Tail Drawdown and grades each day's testable macro question Q_t.",
|
||||
},
|
||||
],
|
||||
},
|
||||
"mcp-chatbot-rest-and-ipld": {
|
||||
"unit_id": "E4",
|
||||
"slug": "mcp-chatbot-rest-and-ipld",
|
||||
"title": "Unit E4: Stateless MCP Server (:8095), Chatbot OpenAPI 3.1.0 REST Adapter, .png+.json Cards & IPLD CIDv1",
|
||||
"short_title": "E4: MCP, REST & IPLD CIDv1",
|
||||
"pip_class": "plate-lock-emerald",
|
||||
"expertise_level": "Level 4: Network Protocols, OpenAPI 3.1 & Content-Addressed Storage (15-20 hrs study)",
|
||||
"prerequisites": [
|
||||
"HTTP/1.1 request/response lifecycles, status codes (200, 404, 422, 500, 502), and reverse proxies",
|
||||
"JSON-RPC 2.0, OpenAPI 3.1.0 schema generation, and Model Context Protocol (MCP)",
|
||||
"Canonical JSON serialization, SHA-256 multihashes, and IPLD dag-json (0x0129) CIDv1",
|
||||
],
|
||||
"public_resources": [
|
||||
{"label": "MDN Web Docs — HTTP Protocol & Status Codes", "url": "https://developer.mozilla.org/en-US/docs/Web/HTTP", "external": True},
|
||||
{"label": "JSON-RPC 2.0 Official Specification", "url": "https://www.jsonrpc.org/specification", "external": True},
|
||||
{"label": "Model Context Protocol (MCP) Architecture Introduction", "url": "https://modelcontextprotocol.io/introduction", "external": True},
|
||||
{"label": "ProtoSchool — Content Identifiers (CIDs) & IPLD Merkle DAGs", "url": "https://proto.school/", "external": True},
|
||||
],
|
||||
"sections": [
|
||||
{
|
||||
"heading": "1. Unified Stateless MCP (/mcp) & Chatbot OpenAPI 3.1.0 REST Adapter (/api/v1/*)",
|
||||
"body": "mcp/server.py and mcp/rest.py expose all 15 tools in MCP_TOOLS_SCHEMA over stdio, Streamable HTTP POST/GET /mcp, and /api/v1/tools/{tool_name} on 127.0.0.1:8095. Top-level exception guards in _MCPHTTPHandler and record_api_telemetry() ensure sqlite3.OperationalError or read-only filesystem states never drop connections or trigger 502 Bad Gateway.",
|
||||
},
|
||||
{
|
||||
"heading": "2. One-Shot .png + .json Ticker Stats Cards (quant/cards.py) & Canonical IPLD dag-json (0x0129)",
|
||||
"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...').",
|
||||
},
|
||||
],
|
||||
},
|
||||
"cicd-vps-tmpfs-and-regression": {
|
||||
"unit_id": "E5",
|
||||
"slug": "cicd-vps-tmpfs-and-regression",
|
||||
"title": "Unit E5: Topological Git Push, Self-Re-Executing tmpfs VPS Hydration, Dark-Mode hs-pdf-build & hs-public-smoke",
|
||||
"short_title": "E5: CI/CD, VPS & Regression",
|
||||
"pip_class": "plate-lock-rose",
|
||||
"expertise_level": "Level 4: Linux Systems Administration, Bash Traps, systemd & DevOps (20-30 hrs study)",
|
||||
"prerequisites": [
|
||||
"POSIX Bash error handling (set -euo pipefail, trap ERR, run_checked(), exec, flock)",
|
||||
"Git fast-forward merges, annotated tags, and git pull --rebase --autostash",
|
||||
"Linux tmpfs RAM mounts, systemd services/timers, Caddy HTTP/3 QUIC, and TrueType cmap tables",
|
||||
],
|
||||
"public_resources": [
|
||||
{"label": "Pro Git Book (Chacon & Straub — Free Complete Online Text)", "url": "https://git-scm.com/book/en/v2", "external": True},
|
||||
{"label": "Wooledge BashGuide & BashFAQ (Error Handling & Process Exec)", "url": "https://mywiki.wooledge.org/BashGuide", "external": True},
|
||||
{"label": "freedesktop.org systemd.service & systemd.timer Manuals", "url": "https://www.freedesktop.org/software/systemd/man/systemd.service.html", "external": True},
|
||||
{"label": "Caddy Server Official Documentation (HTTP/3 & Reverse Proxy)", "url": "https://caddyserver.com/docs/", "external": True},
|
||||
],
|
||||
"sections": [
|
||||
{
|
||||
"heading": "1. Zero-/dev/null CI/CD Scripts, Self-Re-Exec & Autonomous VPS Harvest Timers",
|
||||
"body": "push-all-to-git-libre-audio.sh, deploy/sync-vps-repos.sh, and deploy/run-vps-data-production.sh contain 0 /dev/null redirections and capture exact exit codes via run_checked(). When sync-vps-repos.sh updates hyperstitionstudio-core on disk, HYPERSTITION_SYNC_REEXEC=1 immediately execs the new script image before hydrating /var/www/hyperstitionstud.io/repos (tmpfs RAM + Brotli-11/Gzip-9).",
|
||||
},
|
||||
{
|
||||
"heading": "2. Dark-Mode hs-pdf-build, Cold-Archive Rotator (hs-archive-rotate) & 6-Gate Public Regression (hs-public-smoke)",
|
||||
"body": "pdf_compiler.py transpiles LaTeX math, preserves <br/>, filters every character against DejaVu TrueType cmap tables, sets rl_config.defaultGraphicsFontName='DejaVu' (0 /Helvetica leaks), and prioritizes web-linked PDFs (--refresh-all-web-pdfs). archive_rotator.py rotates completed docs/archive/ pairs into completed-plans-archive.tar.gz, while public_regression.py audits live HTTP responses against .cache/internal-test-baseline-latest.json across Gates P1-P6.",
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def introspect_engineering_manifest(
|
||||
enabled_subpages: tuple[str, ...] = ENABLED_ENGINEERING_SUBPAGES,
|
||||
workspace_root: str | Path | None = None,
|
||||
) -> dict[str, Any]:
|
||||
cfg = load_workspace_config(workspace_root=workspace_root)
|
||||
pyproj_txt = (cfg.core_dir / "pyproject.toml").read_text(encoding="utf-8")
|
||||
cli_scripts: dict[str, str] = {}
|
||||
in_scripts = False
|
||||
for ln in pyproj_txt.splitlines():
|
||||
s = ln.strip()
|
||||
if s == "[project.scripts]":
|
||||
in_scripts = True
|
||||
continue
|
||||
if in_scripts:
|
||||
if s.startswith("["):
|
||||
break
|
||||
if "=" in s:
|
||||
k, v = s.split("=", 1)
|
||||
cli_scripts[k.strip()] = v.strip().strip('"')
|
||||
|
||||
schemas_list = sorted(p.name for p in (cfg.core_dir / "schemas" / "v1").glob("*.schema.json"))
|
||||
active_subpages = [s for s in ALL_ENGINEERING_SUBPAGES if s in enabled_subpages]
|
||||
enabled_routes = ["/engineering/index.html"] + [f"/engineering/{s}/index.html" for s in active_subpages]
|
||||
|
||||
manifest: dict[str, Any] = {
|
||||
"$id": "urn:io:hyperstitionstud:engineering-manifest",
|
||||
"version": CURRENT_VERSION,
|
||||
"enabled_subpages": active_subpages,
|
||||
"disabled_subpages": [s for s in ALL_ENGINEERING_SUBPAGES if s not in active_subpages],
|
||||
"enabled_routes": enabled_routes,
|
||||
"introspected_counts": {
|
||||
"repositories": 6,
|
||||
"cli_entrypoints": len(cli_scripts),
|
||||
"mcp_tools": len(MCP_TOOLS_SCHEMA),
|
||||
"rest_domain_aliases": len(REST_DOMAIN_ALIASES),
|
||||
"enabled_lenses": len(ENABLED_LENSES),
|
||||
"watchlist_instruments": len(CANONICAL_WATCHLIST_24),
|
||||
"fred_macro_series": len(FRED_SERIES_SPEC),
|
||||
"json_schemas_v1": len(schemas_list),
|
||||
},
|
||||
"cli_scripts": cli_scripts,
|
||||
"mcp_tool_names": [t["name"] for t in MCP_TOOLS_SCHEMA],
|
||||
"rest_domain_aliases": REST_DOMAIN_ALIASES,
|
||||
"schemas_v1": schemas_list,
|
||||
"flow_diagrams": {
|
||||
"cross_repo_dependency_png": "/graph/docs/cross-repo-dependency-and-audit-flow-diagram.png",
|
||||
"periodic_harvest_cicd_vps_png": "/graph/docs/periodic-harvest-cicd-to-vps-flow-diagram.png",
|
||||
},
|
||||
"hub_prereq_ladder": HUB_PREREQ_LADDER,
|
||||
"subpages": {s: ENGINEERING_SUBPAGE_SPECS[s] for s in active_subpages},
|
||||
}
|
||||
manifest["ipld_dag_json_cidv1"] = {"/": compute_dag_json_cidv1(manifest)}
|
||||
return manifest
|
||||
|
||||
|
||||
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">Portal Home (/)</a>',
|
||||
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>',
|
||||
]
|
||||
for s in enabled_subpages:
|
||||
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>')
|
||||
links.append(f'<a class="btn" href="{rel_prefix}../math/index.html">Math Hub (/math/)</a>')
|
||||
links.append('<span class="nav-donate-sep" aria-hidden="true"></span>')
|
||||
links.append(
|
||||
f'<a class="btn-donate-pill" href="{rel_prefix}../donate/index.html">'
|
||||
'<span class="donate-pill-emblem" aria-hidden="true">♥</span><span>DONATE</span></a>'
|
||||
)
|
||||
return "\n ".join(links)
|
||||
|
||||
|
||||
def _render_prereq_box_html(level_str: str, prereqs: list[str], resources: list[dict[str, Any]], rel_prefix: str) -> 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>'
|
||||
'<p style="font-size:0.76rem;color:var(--text-secondary);margin:0.35rem 0;">If any concepts on this page are unfamiliar, occupy your study time with these free foundational resources first:</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);">Core Concepts Required:</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_hub_html(manifest: dict[str, Any]) -> str:
|
||||
enabled = manifest["enabled_subpages"]
|
||||
counts = manifest["introspected_counts"]
|
||||
nav_html = _render_nav_html(None, enabled, "")
|
||||
prereq_html = _render_prereq_box_html(
|
||||
HUB_PREREQ_LADDER["expertise_level"],
|
||||
[
|
||||
"Command-line navigation, files, and Git version control",
|
||||
"How HTTP servers, JSON APIs, and static webroots operate",
|
||||
"Self-Paced Learning Track (/learn/ Modules 1-6)",
|
||||
],
|
||||
HUB_PREREQ_LADDER["links"],
|
||||
"",
|
||||
)
|
||||
|
||||
cards_html = ""
|
||||
for s in enabled:
|
||||
sp = ENGINEERING_SUBPAGE_SPECS[s]
|
||||
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;">{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>'
|
||||
)
|
||||
|
||||
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: 1rem 1.25rem; margin-bottom: 0.9rem; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.8rem; }}
|
||||
h1 {{ font-size: 1.12rem; color: var(--gold); }}
|
||||
.subtitle {{ font-size: 0.72rem; color: var(--text-secondary); margin-top: 0.2rem; }}
|
||||
.top-nav {{ margin-left: auto; display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }}
|
||||
.btn {{ padding: 0.35rem 0.7rem; font-size: 0.72rem; 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>
|
||||
<h1>HYPERSTITION STUDIO // SOFTWARE ENGINEERING EXPLICATION HUB (UNIT E0)</h1>
|
||||
<p class="subtitle">Commutative Live-Introspected Architecture • Piecewise & Non-Sequentially Revertible Cartridges • urn:io:hyperstitionstud:engineering:v{CURRENT_VERSION}</p>
|
||||
</div>
|
||||
<nav class="top-nav">
|
||||
{nav_html}
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
{prereq_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;">
|
||||
<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);">
|
||||
<img src="../../encyclopedia-knowledge-graph/docs/periodic-harvest-cicd-to-vps-flow-diagram.png" data-http-src="/graph/docs/periodic-harvest-cicd-to-vps-flow-diagram.png" alt="Periodic Data Harvest to CI/CD to VPS Flow Diagram" style="max-width:100%;height:auto;display:block;margin:0 auto;" />
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="panel hs-plate-g3" style="padding:1rem 1.2rem;">
|
||||
<h2 style="font-size:0.92rem;color:var(--cyan);margin-bottom:0.4rem;">Live Introspected CLI Entrypoints (pyproject.toml [project.scripts])</h2>
|
||||
<table>
|
||||
<thead><tr><th>CLI Command</th><th>Python Module:Function Target</th></tr></thead>
|
||||
<tbody>{cli_rows}</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<footer>
|
||||
hyperstitionstud.io/engineering v{CURRENT_VERSION} • CIDv1: <code>{manifest["ipld_dag_json_cidv1"]["/"][:36]}...</code> • Made with <span class="hs-heart" style="color:var(--rose);">♥</span> by Lemurs.
|
||||
</footer>
|
||||
</div>
|
||||
<script src="engineering-manifest-data.js?v={CURRENT_VERSION}"></script>
|
||||
<script src="engineering-app.js?v={CURRENT_VERSION}"></script>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
|
||||
|
||||
def _render_subpage_html(slug: str, manifest: dict[str, Any]) -> str:
|
||||
enabled = manifest["enabled_subpages"]
|
||||
spec = ENGINEERING_SUBPAGE_SPECS[slug]
|
||||
nav_html = _render_nav_html(slug, enabled, "../")
|
||||
prereq_html = _render_prereq_box_html(spec["expertise_level"], spec["prerequisites"], spec["public_resources"], "../")
|
||||
|
||||
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>'
|
||||
)
|
||||
|
||||
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: 1rem 1.25rem; margin-bottom: 0.9rem; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.8rem; }}
|
||||
h1 {{ font-size: 1.05rem; color: var(--gold); }}
|
||||
.subtitle {{ font-size: 0.72rem; color: var(--text-secondary); margin-top: 0.2rem; }}
|
||||
.top-nav {{ margin-left: auto; display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }}
|
||||
.btn {{ padding: 0.35rem 0.7rem; font-size: 0.72rem; 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>
|
||||
<h1>{spec["title"]}</h1>
|
||||
<p class="subtitle">Cartridge {spec["unit_id"]} • Non-Sequentially Revertible via <code>hs-eng-docs --disable {slug}</code> • v{CURRENT_VERSION}</p>
|
||||
</div>
|
||||
<nav class="top-nav">
|
||||
{nav_html}
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
{prereq_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} • Made with <span class="hs-heart" style="color:var(--rose);">♥</span> by Lemurs.
|
||||
</footer>
|
||||
</div>
|
||||
<script src="../engineering-manifest-data.js?v={CURRENT_VERSION}"></script>
|
||||
<script src="../engineering-app.js?v={CURRENT_VERSION}"></script>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
|
||||
|
||||
def build_engineering_site(
|
||||
out_dir: str | Path | None = None,
|
||||
enabled_subpages: tuple[str, ...] | list[str] = ENABLED_ENGINEERING_SUBPAGES,
|
||||
disable_all: bool = False,
|
||||
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), 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), encoding="utf-8")
|
||||
elif sub_d.is_dir():
|
||||
shutil.rmtree(sub_d)
|
||||
|
||||
return {
|
||||
"ok": True,
|
||||
"version": CURRENT_VERSION,
|
||||
"output_dir": str(target_dir),
|
||||
"enabled_subpages": list(active_tuple),
|
||||
"enabled_routes": manifest["enabled_routes"],
|
||||
"cidv1": manifest["ipld_dag_json_cidv1"]["/"],
|
||||
"isolation_receipt": guard.audit_receipt(),
|
||||
}
|
||||
|
||||
|
||||
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("--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)
|
||||
print(json.dumps(res, indent=2))
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in new issue
Block a user