17 KiB
17 KiB
Architecture & Migration Plan: Shared Common Library Across All /workspace Projects Under the hyperstitionstud.io Namespace (v1.0.0)
- Document ID:
PLAN-COMMON-LIBRARY-HYPERSTITIONSTUDIO(v1.0.0) - Canonical Domain & Authority:
hyperstitionstud.io - Python PEP 420 Reverse-DNS Namespace:
io.hyperstitionstud.*(installed from/workspace/hyperstitionstudio-core) - JavaScript / ESM Scope Namespace:
@hyperstitionstud.io/*(window.HyperstitionStudio.*in offline browser bundles) - Schema, XML & URN Authority:
https://hyperstitionstud.io/schemas/v1/*,https://hyperstitionstud.io/ns/*, andurn:io:hyperstitionstud:* - Glossary & Encyclopedia Isolation Invariant: Verified (
0changes totaxonomy/glossary-registry.jsonorencyclopedia/encyclopedia-manifest.json).
1. Executive Summary & Architectural Problem Statement
Across the peer repositories in /workspace (ingglish-hyperdope-gematria, technocapital-singularity-zoology, encyclopedia-knowledge-graph, hyperdope-ci-build, hyperdope-gematria, memes, and thomas-calculus-tutor), several foundational subsystems are currently either duplicated in-file or coupled via cross-repository hardcoded script paths:
- Cross-Repo Subprocess Handoffs for PDF & Tier-List Rendering:
Both
technocapital-singularity-zoologyandencyclopedia-knowledge-graphinvoke/workspace/ingglish-hyperdope-gematria/ingglish-aq-archive/scripts/build_wire_report_pdf.pyandgenerate_aq_tier_list.pyvia hardcoded sibling paths. - Cross-Repo Node.js
ingglish(CMUdict) Resolution:technocapital-singularity-zoology/scripts/classify_technocapital_singularity.pyspawnsnode --input-type=modulewith--workdir /workspace/ingglish-hyperdope-gematriato resolvenode_modules/ingglish. - Duplicated Base-36
AQ& Prime Arithmetic:compute_aq(), prime-sieve/rank lookup (is_prime,prime_rank), repdigit detection (37 * k), andG1–G6drift/variance-collapse equations are re-implemented separately inclassify_technocapital_singularity.py,build_encyclopedia_knowledge_graph.py,ci_provision_ingglish.py, andgenerate_aq_tier_list.py. - Ad-Hoc JSON Schema & Provenance Identifiers:
The 8 JSON registries in
technocapital-singularity-zoologyand the exported graph files inencyclopedia-knowledge-graphlack a unified$schemaURI and XML/URN namespace authority.
Solution Overview
Extract all shared computation, phonetic translation, PDF/PNG/Canvas rendering, cryptographic isolation guards, and CI validation into a single, zero-duplication sibling repository:
- Repository Path:
/workspace/hyperstitionstudio-core - Python Namespace Package (PEP 420):
io.hyperstitionstud.* - JS/Browser Namespace:
@hyperstitionstud.io/* - XML/JSON/URN Namespace:
https://hyperstitionstud.io/...&urn:io:hyperstitionstud:...
2. Canonical hyperstitionstud.io Namespace Hierarchy
| Layer / Ecosystem | Canonical Namespace Pattern | Concrete Examples |
|---|---|---|
| Python 3.10+ (PEP 420 Namespace Package) | io.hyperstitionstud.<module> |
io.hyperstitionstud.ciphersio.hyperstitionstud.phoneticsio.hyperstitionstud.publishingio.hyperstitionstud.glossaryio.hyperstitionstud.graphio.hyperstitionstud.ciio.hyperstitionstud.audio |
| Node.js / ESM Packages | @hyperstitionstud.io/<pkg> |
@hyperstitionstud.io/phonetics-g2p"@hyperstitionstud.io/ciphers-aq""@hyperstitionstud.io/graph-workbench" |
Offline Browser Global (file://) |
window.HyperstitionStudio.<Module> |
window.HyperstitionStudio.EncyclopediaGraphDatawindow.HyperstitionStudio.GraphWorkbenchwindow.HyperstitionStudio.Ciphers |
JSON Schema $schema & $id URIs |
https://hyperstitionstud.io/schemas/v1/<name>.schema.json |
https://hyperstitionstud.io/schemas/v1/glossary-registry.schema.jsonhttps://hyperstitionstud.io/schemas/v1/encyclopedia-manifest.schema.jsonhttps://hyperstitionstud.io/schemas/v1/encyclopedia-graph.schema.json |
| GraphML / GEXF XML Namespace | xmlns:hs="https://hyperstitionstud.io/ns/kg/1.0" |
<graphml xmlns:hs="https://hyperstitionstud.io/ns/kg/1.0"><data key="hs:g1_variance_collapsed">249.36</data> |
| Entity & Node URN Identifiers | urn:io:hyperstitionstud:<domain>:<type>:<id> |
urn:io:hyperstitionstud:zoology:build:S1urn:io:hyperstitionstud:aq:hub:125urn:io:hyperstitionstud:lexicon:spec:blackwell |
CLI Entry Points (pyproject.toml) |
hs-<tool> |
hs-pdf-build, hs-tier-list, hs-ci-provision, hs-kg-build, hs-isolation-check |
3. Repository Layout of /workspace/hyperstitionstudio-core
/workspace/hyperstitionstudio-core/
├── pyproject.toml # Editable install: pip install -e /workspace/hyperstitionstudio-core
├── package.json # Workspace root for @hyperstitionstud.io/* JS/ESM packages
├── requirements.txt # Pillow>=10.0, reportlab>=4.0, pypdf>=4.0, pdfplumber>=0.10
├── README.md
├── schemas/
│ └── v1/ # Canonical JSON Schemas (https://hyperstitionstud.io/schemas/v1/*)
│ ├── glossary-registry.schema.json
│ ├── encyclopedia-manifest.schema.json
│ ├── singularity-zoology-matrix.schema.json
│ ├── memetic-superclass-registry.schema.json
│ ├── assemblage-builds-tier-list.schema.json
│ ├── quantitative-economic-anchors.schema.json
│ ├── citations-ledger.schema.json
│ └── encyclopedia-graph.schema.json
├── src/
│ └── io/
│ └── hyperstitionstud/ # PEP 420 Namespace Root (no __init__.py at io/, explicit at leaf packages)
│ ├── ciphers/
│ │ ├── __init__.py
│ │ ├── base36_aq.py # compute_aq(), digit/spoken/dual quant modes, zero-d-filter guard
│ │ ├── primes.py # Prime sieve, prime_rank(), twin-prime & repdigit (37*k) predicates
│ │ └── vectors_g1_g6.py # G1 variance collapse, G2 cross-gen twins, G3 steps, G4 iso, G5 twin-prime
│ ├── phonetics/
│ │ ├── __init__.py
│ │ ├── ingglish_bridge.py # Self-contained Node G2P bridge + pure-Python CMUdict fallback cache
│ │ └── cmudict_fallback.json # Offline deterministic fallback so zero --workdir coupling is needed
│ ├── publishing/
│ │ ├── __init__.py
│ │ ├── fonts.py # DejaVu Sans / Mono TrueType resolver & ReportLab family registration
│ │ ├── pdf_compiler.py # Unified build_wire_report_pdf (atomic .tmp.pdf + pypdf verification)
│ │ ├── tier_list_renderer.py # Unified S+..F & ETI 0-100 .pdf/.png card renderer (Pillow + ReportLab)
│ │ ├── encyclopedia_pdf.py # Multi-division, alphabetized volume PDF compiler
│ │ └── pokedex_compositor.py # Gen IV INFO Pokedex & meme-card compositor with box collision audit
│ ├── glossary/
│ │ ├── __init__.py
│ │ ├── registry.py # GlossaryRegistry CRUD, provenance-keyed filtering (source_type)
│ │ └── isolation_guard.py # Pre/post SHA-256 context manager (`with ReadOnlyIsolationGuard(...):`)
│ ├── graph/
│ │ ├── __init__.py
│ │ ├── builder.py # Multi-partite property graph builder & seen_edges deduplicator
│ │ ├── layouts.py # Mode 1 Trophic, Mode 2 Concentric ETI Radar, Mode 3 Funnel, Mode 4 Grid
│ │ ├── exporters.py # JSON, GraphML (xmlns:hs), GEXF 1.3, Obsidian JSON Canvas 1.0
│ │ └── atlas_png.py # 1600x1060 high-res static board renderer with pill-masked arrows
│ ├── ci/
│ │ ├── __init__.py
│ │ ├── gates_hyperdope.py # 4-Gate CI validator (normalize_caps, classify_candidates, db.json)
│ │ └── citation_sources.py # 3-tier provenance verifier (git remote URL -> local full-path fallback)
│ └── audio/
│ ├── __init__.py
│ └── multi_voice_tts.py # 5-voice edge-tts synthesizer, ffmpeg concat, mutagen duration audit
├── packages-js/
│ ├── ciphers-aq/ # @hyperstitionstud.io/ciphers-aq (shared with hyperdope-gematria)
│ └── graph-workbench/ # @hyperstitionstud.io/graph-workbench (shared with index.html)
└── tests/
├── test_ciphers_and_vectors.py
├── test_phonetics_offline.py
├── test_publishing_pdf_and_png.py
├── test_glossary_isolation_guard.py
└── test_graph_exporters_and_urns.py
4. Detailed Module Specifications & How Each Eliminates Cross-Repo Coupling
4.1 io.hyperstitionstud.ciphers — Unified Base-36 AQ, Prime & G1–G6 Vector Engine
- Replaces duplicated code in:
technocapital-singularity-zoology/scripts/classify_technocapital_singularity.pyencyclopedia-knowledge-graph/scripts/build_encyclopedia_knowledge_graph.pyingglish-hyperdope-gematria/ingglish-aq-archive/scripts/ci_provision_ingglish.pyingglish-hyperdope-gematria/ingglish-aq-archive/scripts/generate_aq_tier_list.py
- Capabilities:
compute_aq(text: str, quant_mode: Literal["off", "spoken", "digit", "dual"] = "off") -> intprime_rank(n: int) -> int | None(1-indexed prime rank, e.g.,193 -> 44,137 -> 33,71 -> 20)evaluate_bidirectional_lock(eng: str, ing: str) -> BidirectionalLock(computes all 18 fields of theG1–G6schema:eng_aq,ing_aq,delta,isometric,twin_prime_mutation,g3_quantized_step, etc.)assert_zero_d_filter(text: str)(enforces the strict boundary that Zoology and Knowledge Graph artifacts contain0references to the 10-letterddecagram).
4.2 io.hyperstitionstud.phonetics — Self-Contained Ingglish (CMUdict) Translator
- Eliminates
--workdir /workspace/ingglish-hyperdope-gematriacoupling:- Currently,
classify_technocapital_singularity.pyrequires/workspace/ingglish-hyperdope-gematria/node_modules/ingglishon disk to translate new English tokens intoGen 1Ingglish. io.hyperstitionstud.phonetics.translate_batch(terms)embeds both:- A bundled deterministic
cmudict_fallback.json+ pure-Python ARPAbet-to-Ingglish grapheme mapper for100%offline zero-Node operation, and - An optional Node
@hyperstitionstud.io/phonetics-g2pbridge when Node.js is available.
- A bundled deterministic
- Result:
technocapital-singularity-zoologycan run--scan-harvest,--revise-anchor, and--termson any machine even ifingglish-hyperdope-gematriais not cloned alongside it.
- Currently,
4.3 io.hyperstitionstud.publishing — Unified ReportLab PDF & Pillow Visual Renderer
- Eliminates hardcoded cross-repo script calls (
build_wire_report_pdf.py&generate_aq_tier_list.py):compile_markdown_to_pdf(md_path, pdf_path, title, namespace_footer="hyperstitionstud.io"):- Performs atomic writes via
.tmp.pdf->os.replace(). - Automatically escapes inline code spans before bold/italic regexes so ReportLab's XML parser never fails on
<or>. - Automatically verifies page count and extracted character count via
pypdfandpdfplumber.
- Performs atomic writes via
render_tier_list_artifacts(rows, tier_defs, out_md, out_pdf, out_png):- Directly importable by both
ingglish-hyperdope-gematria(Option #4S+..Fevaluations) andtechnocapital-singularity-zoology(ETI 0–100Zoological Assemblage Builds) without spawning cross-repo subprocesses.
- Directly importable by both
4.4 io.hyperstitionstud.glossary — Provenance-Keyed Glossary & Cryptographic Isolation Guard
- Provides reusable glossary infrastructure for all
/workspaceprojects:ReadOnlyIsolationGuard(paths: list[Path]):from io.hyperstitionstud.glossary import ReadOnlyIsolationGuard with ReadOnlyIsolationGuard([glossary_path, encyclopedia_manifest_path]) as guard: graph = build_graph(upstream_repo) # Automatically asserts pre_sha256 == post_sha256 on exit and emits guard.audit_receipt()ProvenanceFilter: Filters entries by explicitsource_type("archive_dossier","news_wire_harvest","podcast_series","knowledge_graph_meta") rather than fragile substring matching, guaranteeing that excluding in-house media or graph terms never strips extrinsic news-wire or dossier vocabulary.
5. Project-by-Project Dependency & Migration Matrix
| Workspace Project | Components Replaced by io.hyperstitionstud.* |
Post-Migration Modularity Status |
|---|---|---|
/workspace/technocapital-singularity-zoology |
Replaces --workdir Node ingglish subprocess, subprocess calls to generate_aq_tier_list.py and build_wire_report_pdf.py, and in-file compute_aq/prime_rank with io.hyperstitionstud.{ciphers,phonetics,publishing,glossary,ci,audio}. |
100% Standalone (zero runtime or build-time dependency on ingglish-hyperdope-gematria). |
/workspace/encyclopedia-knowledge-graph |
Replaces in-file compute_aq, XML/Canvas serializers, SHA-256 check boilerplate, and build_wire_report_pdf.py calls with io.hyperstitionstud.{graph,glossary,publishing} + xmlns:hs="https://hyperstitionstud.io/ns/kg/1.0" and urn:io:hyperstitionstud:* node URNs. |
100% Standalone Compiler & Workbench (consumes upstream JSONs validated against https://hyperstitionstud.io/schemas/v1/*). |
/workspace/ingglish-hyperdope-gematria |
Delegates build_wire_report_pdf.py, generate_aq_tier_list.py, and ci_provision_ingglish.py core logic to io.hyperstitionstud.{publishing,ci,ciphers} while keeping thin CLI wrappers at existing script paths for backwards compatibility. |
100% Backwards-Compatible (zero broken CLI paths; zero duplicated rendering code). |
/workspace/hyperdope-ci-build |
Uses io.hyperstitionstud.ci.gates_hyperdope during provisioning while keeping feat/ingglish-aq-corpus free of third-party files so upstream PR diffs remain 100% clean. |
100% PR-Clean (zero extraneous files added to upstream PR branch). |
/workspace/hyperdope-gematria |
Consumes @hyperstitionstud.io/ciphers-aq in calc/ciphers.js on branch feat/ingglish-priority-toggle. |
Shared JS Cipher Parity with Python io.hyperstitionstud.ciphers. |
/workspace/memes |
Uses io.hyperstitionstud.publishing.pokedex_compositor for Gen IV INFO Pokedex cards and meme templates. |
Unified Card & Font Rendering with automatic box-collision verification. |
6. Phased Implementation & Rollout Roadmap (Phases 1–4, Non-Breaking)
Phase 1: Scaffold /workspace/hyperstitionstudio-core & Publish v1 JSON Schemas
- Initialize
/workspace/hyperstitionstudio-core(git init -b main) withpyproject.toml(name = "hyperstitionstudio-core",version = "1.0.0") andsrc/io/hyperstitionstud/. - Author the 8 canonical JSON Schema files under
schemas/v1/*.schema.jsonwith$id: "https://hyperstitionstud.io/schemas/v1/<name>.schema.json". - Install in editable mode across the workspace environment (
pip install --no-deps -e /workspace/hyperstitionstudio-core).
Phase 2: Extract ciphers, phonetics, glossary, and ci Modules + Unit Test Suite
- Implement
io.hyperstitionstud.ciphers,io.hyperstitionstud.phonetics(with offlinecmudict_fallback.json),io.hyperstitionstud.glossary.isolation_guard, andio.hyperstitionstud.ci. - Run
pytest /workspace/hyperstitionstudio-core/tests/to verify 100% numerical parity on all282glossary entries,190bilingual specimens, and189cross-scale333/666/777equations.
Phase 3: Extract publishing (pdf_compiler, tier_list_renderer, pokedex_compositor) & graph
- Move the core ReportLab and Pillow rendering engines into
io.hyperstitionstud.publishingandio.hyperstitionstud.graph. - Replace the bodies of
/workspace/ingglish-hyperdope-gematria/ingglish-aq-archive/scripts/build_wire_report_pdf.pyandgenerate_aq_tier_list.pywith thin, backwards-compatible CLI shims that import fromio.hyperstitionstud.publishing.
Phase 4: Cut Over technocapital-singularity-zoology & encyclopedia-knowledge-graph and Run 3-Stage Audit
- Update
classify_technocapital_singularity.pyandbuild_encyclopedia_knowledge_graph.pyto import fromio.hyperstitionstud.*. - Execute the full 3-Stage
BUILD -> TEST -> STAGE_COMMITpipeline (ci_provision_ingglish.py --tier 2,sources.py verify --evidence, andbuild_encyclopedia_knowledge_graph.py --verify-only), verifyingall_gates_passed == trueand0SHA-256 mutations onglossary-registry.jsonandencyclopedia-manifest.json.