#!/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 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.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 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 ENABLE_GUILE_SCHEME_LENS: bool = True ENGINEERING_GUILE_CARTRIDGES: dict[str, dict[str, str]] = { "E0": { "title": "Polyglot Foil (E0): Homoiconic S-Expressions, Static Readonly Types & Rust Option Manifest Closure", "math_view": "Manifest M = (version, repos=6, tools=15, cidv1=H(M))", "py_view": "manifest = introspect_engineering_manifest()\ncid = compute_dag_json_cidv1(manifest)", "scm_expr": "(assoc-ref '((repositories 6) (mcp-tools 15) (lenses 4)) 'mcp-tools)", "ts_expr": "({repositories: 6, mcpTools: 15} satisfies Readonly>).mcpTools", "rust_expr": 'manifest_lookup("mcp_tools")', "challenge": "Switch between [λ Guile], [TS TypeScript], [Rs Rust], and [≡ ALL 3] or send any expression to the 4-Ring Hardened REPL.", }, "ciphers-and-phonetics": { "title": "Polyglot Foil (E1): Base-36 Alphanumeric Homomorphism in Guile (Z), TypeScript & Rust", "math_view": "AQ(w) = ∑_{i=1}^k v(c_i), v('0'..'9')=0..9, v('a'..'z')=10..35", "py_view": "sum(char_value_aq(ch) for ch in text)", "scm_expr": '(aq-base36 "LEMUR")', "ts_expr": 'aqBase36("LEMUR")', "rust_expr": 'aq_base36("LEMUR")', "challenge": 'Verify AQ("LEMUR") = 114 across all 3 languages in the hardened AST sandbox.', }, "knowledge-graph-and-sqlite": { "title": "Polyglot Foil (E2): Pre/Post SHA-256 Read-Only Isolation Guard & Borrow Checking", "math_view": "Guard(f): H_pre == H_expected ∧ H_post == H_pre", "py_view": "with ReadOnlyIsolationGuard(cfg.read_only_files) as guard:\n run_pipeline()", "scm_expr": "((lambda (pre post) (and (= pre 282) (= pre post))) 282 282)", "ts_expr": "((pre: number, post: number): boolean => pre === 282 && pre === post)(282, 282)", "rust_expr": "isolation_guard_ok(282_u32, 282_u32)", "challenge": "Compare Scheme's predicate, TypeScript's typed arrow guard, and Rust's Result.", }, "quant-macro-and-bayesian-brief": { "title": "Polyglot Foil (E3): Zero-Synthetic Missing-Data Semantics (#f / boolean / Option)", "math_view": "D_{i,t} = ∑_{s=1}^4 I(Species_s) ∈ {0..4}, Closed/Private = null", "py_view": "dose = sum(1 for flag in (s1, s2, s3, s4) if flag)", "scm_expr": "(confluence-dose '(#t #t #t #f))", "ts_expr": "[true, true, true, false].filter(Boolean).length", "rust_expr": "[Some(135.4), None, Some(138.2)].iter().filter_map(|&x| x).count()", "challenge": "Observe how Scheme #f, TypeScript filter(Boolean), and Rust Option::filter_map eliminate synthetic 0.0 fabrication.", }, "mcp-chatbot-rest-and-ipld": { "title": "Polyglot Foil (E4): JSON-RPC 2.0 Tool Dispatch & 'envideea' = 137 (33rd Prime)", "math_view": "Dispatch(name, args) → ToolTable[name](args)", "py_view": "res = call_mcp_tool(target_tool, t_args)", "scm_expr": '(list \'jsonrpc-2.0 \'tool "hs_evaluate_aq_and_ingglish" (aq-base36 "envideea"))', "ts_expr": 'aqBase36("envideea")', "rust_expr": 'mcp_dispatch_aq("envideea")', "challenge": 'Evaluate "envideea" => 137 across Guile, TypeScript, and Rust.', }, "cicd-vps-tmpfs-and-regression": { "title": "Polyglot Foil (E5): 4-Tier Programmatic Semantic Version Bump Heuristic", "math_view": "Bump(dirty, ahead, plans, tools, brk) ∈ {noop, patch, minor, major}", "py_view": "evaluate_change_scope_heuristics(signals)['recommended_bump_level']", "scm_expr": "(evaluate-bump-scope 2 0 1 0 #f)", "ts_expr": "evaluateBumpScope({dirty: 2, ahead: 0, plans: 1, tools: 0, breaking: false})", "rust_expr": "evaluate_bump_scope(2, 0, 1, 0, false)", "challenge": "Test the 4-tier decision tree (noop, patch, minor, major) in all 3 languages.", }, } def _render_guile_cartridge_html(key: str) -> str: return render_explication_cartridge_html( ENGINEERING_GUILE_CARTRIDGES, key, spec_label="1. Formal Specification & Python:", ) 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 & Bidirectional Lock Evaluation", "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 & Quantization Modes (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()), evaluating prime index ranks, 37×3k repdigit attractors, and 12-field bidirectional locks.", }, { "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...').", }, { "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 .', }, ], }, "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
, 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: 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, ) def _render_hub_html(manifest: dict[str, Any], include_guile_lens: bool = True) -> str: enabled = manifest["enabled_subpages"] counts = manifest["introspected_counts"] global_nav_html = _render_global_nav_html("", "engineering") subnav_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"], "", ) 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 "" stat_tiles_html = ( f'
Repositories
{counts["repositories"]}
\n' f'
CLI Entrypoints
{counts["cli_entrypoints"]}
\n' f'
MCP & REST Tools
{counts["mcp_tools"]}
\n' f'
Pluggable Lenses
{counts["enabled_lenses"]}
\n' f'
Watchlist / FRED
{counts["watchlist_instruments"]} / {counts["fred_macro_series"]}
\n' f'
Enabled Subpages
{len(enabled)} / {len(ALL_ENGINEERING_SUBPAGES)}
' ) cli_rows = "".join( f"{k}{v}" for k, v in sorted(manifest["cli_scripts"].items()) ) extra_panels_html = f"""

End-to-End Periodic Data Harvest → CI/CD → Deployed VPS Infrastructure Flow Diagram

Generated & verified deterministically by hyperstitionstud_io.publishing.flow_diagram during push-all-to-git-libre-audio.sh and tests/test_core_suite.py:

Periodic Data Harvest to CI/CD to VPS Flow Diagram

Live Introspected CLI Entrypoints (pyproject.toml [project.scripts])

{cli_rows}
CLI CommandPython Module:Function Target
""" 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} ', 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: enabled = manifest["enabled_subpages"] spec = ENGINEERING_SUBPAGE_SPECS[slug] global_nav_html = _render_global_nav_html("../", "engineering") subnav_html = _render_nav_html(slug, enabled, "../") prereq_html = _render_prereq_box_html(spec["expertise_level"], spec["prerequisites"], spec["public_resources"], "../") 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 "" extra_after_sections_html = "" if slug == "mcp-chatbot-rest-and-ipld": extra_after_sections_html = ( '
' '
' '

⚛ Live API & IPLD CIDv1 ETag 304 Conditional Cache Probe (#live-smoke-probe)

' '' '
' '

Fetches /api/v1/status twice (sending If-None-Match: <ETag> on the second request) to verify deterministic RFC 8785 JCS + IPLD dag-json CIDv1 HTTP caching and ReadOnlyIsolationGuard status.

' '
Click "Run Live /api/v1/status & ETag 304 Probe" to inspect live HTTP ETag & ReadOnlyIsolationGuard headers.
' '' '
' ) 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( out_dir: str | Path | None = None, enabled_subpages: tuple[str, ...] | list[str] = ENABLED_ENGINEERING_SUBPAGES, disable_all: bool = False, include_guile_lens: bool = ENABLE_GUILE_SCHEME_LENS, workspace_root: str | Path | None = None, ) -> dict[str, Any]: 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: 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.", ) if __name__ == "__main__": raise SystemExit(main())