711 lines
48 KiB
Python
711 lines
48 KiB
Python
#!/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
|
|
ENABLE_GUILE_SCHEME_LENS: bool = True
|
|
|
|
ENGINEERING_GUILE_CARTRIDGES: dict[str, dict[str, str]] = {
|
|
"E0": {
|
|
"title": "Polyglot Foil (E0): Homoiconic S-Expressions, Static Readonly<T> Types & Rust Option<T> 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<Record<string, number>>).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<bool, Error>.",
|
|
},
|
|
"quant-macro-and-bayesian-brief": {
|
|
"title": "Polyglot Foil (E3): Zero-Synthetic Missing-Data Semantics (#f / boolean / Option<f64>)",
|
|
"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_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_guile_cartridge_html(key: str) -> str:
|
|
c = ENGINEERING_GUILE_CARTRIDGES[key]
|
|
esc_scm = c["scm_expr"].replace('"', """)
|
|
esc_ts = c["ts_expr"].replace('"', """)
|
|
esc_rs = c["rust_expr"].replace('"', """)
|
|
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;">λ {c["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;">1. Formal Specification & Python:</strong><code>{c["math_view"]}</code><pre style="white-space:pre-wrap;margin-top:0.25rem;color:var(--text-secondary);">{c["py_view"]}</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">{c["scm_expr"]}</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">{c["ts_expr"]}</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">{c["rust_expr"]}</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> {c["challenge"]}</div>'
|
|
'</section>'
|
|
)
|
|
|
|
|
|
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)",
|
|
"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(_render_polyglot_selector_html())
|
|
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], include_guile_lens: bool = True) -> 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"],
|
|
"",
|
|
)
|
|
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 = ""
|
|
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}
|
|
{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;">
|
|
<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>{guile_drawer_html}
|
|
</body>
|
|
</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]
|
|
nav_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 ""
|
|
|
|
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}
|
|
{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} • 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>{guile_drawer_html}
|
|
</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,
|
|
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(),
|
|
}
|
|
|
|
|
|
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,
|
|
)
|
|
print(json.dumps(res, indent=2))
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|