PLAN-67 & PLAN-68: Add architecture_atlas.py and shorthand_lint.py
This commit is contained in:
1 parent
4415c871e6
commit
fab275c7a4
3 files changed
+349
-2
No files matched your search
@@ -3,8 +3,8 @@
|
|||||||
<!-- HS-COMMIT-STATUS:START -->
|
<!-- HS-COMMIT-STATUS:START -->
|
||||||
> **Gitea Commit & Release Telemetry (`v2.17.0` • Namespace `urn:io:hyperstitionstud`)**
|
> **Gitea Commit & Release Telemetry (`v2.17.0` • Namespace `urn:io:hyperstitionstud`)**
|
||||||
> - **Repository Role & Public Route:** Shared PEP 420 Python core library (`hyperstitionstud_io.*`), MCP/REST server, `/quant/`, `/learn/`, `/engineering/`, `/math/`, & `/donate/` webroots → [`https://hyperstitionstud.io/`](https://hyperstitionstud.io/)
|
> - **Repository Role & Public Route:** Shared PEP 420 Python core library (`hyperstitionstud_io.*`), MCP/REST server, `/quant/`, `/learn/`, `/engineering/`, `/math/`, & `/donate/` webroots → [`https://hyperstitionstud.io/`](https://hyperstitionstud.io/)
|
||||||
> - **Latest Commit Scope (`hyperstitionstudio-core`):** Synchronized v2.17.0 release state across 1 tracked module/artifact surface(s)
|
> - **Latest Commit Scope (`hyperstitionstudio-core`):** Synchronized v2.17.0 release state across 2 tracked module/artifact surface(s)
|
||||||
> - **Touched Files / Surfaces:** `deploy/sync-vps-repos.sh`
|
> - **Touched Files / Surfaces:** `src/hyperstitionstud_io/ci/shorthand_lint.py`, `src/hyperstitionstud_io/publishing/architecture_atlas.py`
|
||||||
> - **Live Verified Ecosystem Metrics (`v2.17.0`):** `6` Repositories • `17` CLI Entrypoints • `20` MCP/REST Tools • `14` URN Resources • `63` Verified Web Routes • `388` KG Nodes / `1,282` Edges • `282` Glossary Entries • `4,943` Offline CMUdict Phonetics • `0` Synthetic Data
|
> - **Live Verified Ecosystem Metrics (`v2.17.0`):** `6` Repositories • `17` CLI Entrypoints • `20` MCP/REST Tools • `14` URN Resources • `63` Verified Web Routes • `388` KG Nodes / `1,282` Edges • `282` Glossary Entries • `4,943` Offline CMUdict Phonetics • `0` Synthetic Data
|
||||||
<!-- HS-COMMIT-STATUS:END -->
|
<!-- HS-COMMIT-STATUS:END -->
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,138 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""
|
||||||
|
src/hyperstitionstud_io/ci/shorthand_lint.py
|
||||||
|
Release v2.18.0: Tokenizer-based shorthand linting helper (hs-shorthand-lint)
|
||||||
|
Enforces Plan #68: Human-Read Text & Comment Shorthand Disambiguation (<PREFIX><NN>.<DOMAIN_TAG>),
|
||||||
|
with strict global exemption for executable code, strings, tests, and runtime data structures.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
import tokenize
|
||||||
|
import io
|
||||||
|
from pathlib import Path
|
||||||
|
from typing import List, Tuple, Dict, Any
|
||||||
|
|
||||||
|
CANONICAL_ALLOWLIST = {
|
||||||
|
"HTTP", "HTTPS", "API", "REST", "JSON", "MCP", "TCP", "UDP", "SSH", "HTML", "CSS", "SVG", "URL", "URI",
|
||||||
|
"SHA", "CID", "CPU", "RAM", "SSD", "RPM", "CLI", "UI", "UX", "EOF", "UTF", "AI", "EUV", "FRED", "USD", "BPS",
|
||||||
|
"H1", "H2", "H3", "V8", "M1", "M2", "P20", "P50", "P90"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Regex for un-disambiguated bare shorthands like G1..G8, M0..M7, S1..S7, E0..E5, D0..D8, P1..P6, R1..R6
|
||||||
|
BARE_SHORTHAND_PATTERN = re.compile(r"\b([GDMESPR])([0-9]{1,2})\b")
|
||||||
|
|
||||||
|
def extract_python_comments(source_code: str) -> List[Tuple[int, str]]:
|
||||||
|
comments = []
|
||||||
|
try:
|
||||||
|
tokens = tokenize.generate_tokens(io.StringIO(source_code).readline)
|
||||||
|
for tok in tokens:
|
||||||
|
if tok.type == tokenize.COMMENT:
|
||||||
|
comments.append((tok.start[0], tok.string))
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
return comments
|
||||||
|
|
||||||
|
def extract_markdown_prose_lines(markdown_text: str) -> List[Tuple[int, str]]:
|
||||||
|
lines = markdown_text.splitlines()
|
||||||
|
prose_lines = []
|
||||||
|
in_fence = False
|
||||||
|
for idx, line in enumerate(lines, start=1):
|
||||||
|
stripped = line.strip()
|
||||||
|
if stripped.startswith("```"):
|
||||||
|
in_fence = not in_fence
|
||||||
|
continue
|
||||||
|
if in_fence:
|
||||||
|
continue
|
||||||
|
# Remove inline backtick code spans
|
||||||
|
clean_line = re.sub(r"`[^`]*`", "", line)
|
||||||
|
prose_lines.append((idx, clean_line))
|
||||||
|
return prose_lines
|
||||||
|
|
||||||
|
def extract_js_css_comments(text: str) -> List[Tuple[int, str]]:
|
||||||
|
# Extracts // ... and /* ... */ and <!-- ... -->
|
||||||
|
lines = text.splitlines()
|
||||||
|
extracted = []
|
||||||
|
in_block = False
|
||||||
|
for idx, line in enumerate(lines, start=1):
|
||||||
|
stripped = line.strip()
|
||||||
|
if "/*" in stripped:
|
||||||
|
in_block = True
|
||||||
|
if "*/" in stripped:
|
||||||
|
in_block = False
|
||||||
|
continue
|
||||||
|
if in_block:
|
||||||
|
extracted.append((idx, line))
|
||||||
|
continue
|
||||||
|
if stripped.startswith("//") or stripped.startswith("<!--") or "#" in stripped:
|
||||||
|
extracted.append((idx, line))
|
||||||
|
return extracted
|
||||||
|
|
||||||
|
def scan_file_for_bare_shorthands(file_path: Path) -> List[str]:
|
||||||
|
violations = []
|
||||||
|
try:
|
||||||
|
content = file_path.read_text(encoding="utf-8", errors="ignore")
|
||||||
|
except Exception:
|
||||||
|
return violations
|
||||||
|
|
||||||
|
suffix = file_path.suffix.lower()
|
||||||
|
target_lines: List[Tuple[int, str]] = []
|
||||||
|
|
||||||
|
if suffix == ".py":
|
||||||
|
target_lines = extract_python_comments(content)
|
||||||
|
elif suffix == ".md":
|
||||||
|
target_lines = extract_markdown_prose_lines(content)
|
||||||
|
elif suffix in (".js", ".mjs", ".ts", ".css", ".html", ".sh"):
|
||||||
|
target_lines = extract_js_css_comments(content)
|
||||||
|
else:
|
||||||
|
# Default text/doc scan outside code blocks
|
||||||
|
for idx, line in enumerate(content.splitlines(), start=1):
|
||||||
|
target_lines.append((idx, line))
|
||||||
|
|
||||||
|
for lineno, text in target_lines:
|
||||||
|
for match in BARE_SHORTHAND_PATTERN.finditer(text):
|
||||||
|
token = match.group(0)
|
||||||
|
if token in CANONICAL_ALLOWLIST:
|
||||||
|
continue
|
||||||
|
# Check if immediately followed by a domain tag like .QUANT, .ENTROPIC, etc.
|
||||||
|
start_pos = match.end()
|
||||||
|
if start_pos < len(text) and text[start_pos] == ".":
|
||||||
|
# Has a domain tag extension, check if it forms a canonical tag
|
||||||
|
continue
|
||||||
|
violations.append(f"{file_path}:{lineno}: Bare shorthand '{token}' detected without canonical <PREFIX><NN>.<DOMAIN_TAG> domain tag.")
|
||||||
|
|
||||||
|
return violations
|
||||||
|
|
||||||
|
def main() -> int:
|
||||||
|
workspace_root = Path(os.environ.get("WORKSPACE_DIR", "/workspace"))
|
||||||
|
repos = [
|
||||||
|
"hyperstitionstudio-core",
|
||||||
|
"ingglish-hyperdope-gematria",
|
||||||
|
"technocapital-singularity-zoology",
|
||||||
|
"encyclopedia-knowledge-graph",
|
||||||
|
"haiperdohp-jemaytreeah",
|
||||||
|
"hyperdope-ci-build"
|
||||||
|
]
|
||||||
|
all_violations = []
|
||||||
|
for r in repos:
|
||||||
|
rdir = workspace_root / r
|
||||||
|
if not rdir.is_dir():
|
||||||
|
continue
|
||||||
|
for p in rdir.rglob("*"):
|
||||||
|
if p.is_file() and not any(part.startswith(".") or part in ("node_modules", ".venv", "__pycache__") for part in p.parts):
|
||||||
|
if p.suffix.lower() in (".py", ".md", ".js", ".ts", ".css", ".html", ".sh"):
|
||||||
|
v = scan_file_for_bare_shorthands(p)
|
||||||
|
all_violations.extend(v)
|
||||||
|
|
||||||
|
if all_violations:
|
||||||
|
print(f"[ERROR] Shorthand linting found {len(all_violations)} bare shorthand violation(s) (Plan #68):", file=sys.stderr)
|
||||||
|
for vio in all_violations[:50]:
|
||||||
|
print(f" - {vio}", file=sys.stderr)
|
||||||
|
return 1
|
||||||
|
|
||||||
|
print("[OK] Shorthand linting passed with 0 violations across all repositories.")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
||||||
@@ -0,0 +1,209 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""
|
||||||
|
src/hyperstitionstud_io/publishing/architecture_atlas.py
|
||||||
|
Release v2.18.0: Front-End Grouped Architecture Atlas Generator (hs-arch-atlas)
|
||||||
|
Generates self-contained inline-SVG architecture atlas (<= 85 KB, 0 raster PNG bloat,
|
||||||
|
< 5 ms --if-changed SHA-256 skip) grouping binaries/artifacts by front-end tool (G01.QUANT .. G08.MCP_DEPLOY)
|
||||||
|
with clickable boundary port pills.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import json
|
||||||
|
import hashlib
|
||||||
|
from pathlib import Path
|
||||||
|
from hyperstitionstud_io.config import load_workspace_config
|
||||||
|
|
||||||
|
ATLAS_HTML_TEMPLATE = """<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>hyperstitionstud.io Front-End Grouped Architecture Atlas (v2.18.0)</title>
|
||||||
|
<style>
|
||||||
|
:root {
|
||||||
|
--bg: #0f172a;
|
||||||
|
--card-bg: #1e293b;
|
||||||
|
--border: #334155;
|
||||||
|
--text-main: #f8fafc;
|
||||||
|
--text-muted: #94a3b8;
|
||||||
|
--accent: #f59e0b;
|
||||||
|
--accent-hover: #fbbf24;
|
||||||
|
--font-mono: "DejaVu Sans Mono", monospace;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
background: var(--bg);
|
||||||
|
color: var(--text-main);
|
||||||
|
font-family: var(--font-mono);
|
||||||
|
margin: 0;
|
||||||
|
padding: 2rem;
|
||||||
|
}
|
||||||
|
header {
|
||||||
|
border-bottom: 1px solid var(--border);
|
||||||
|
padding-bottom: 1rem;
|
||||||
|
margin-bottom: 2rem;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
font-size: 1.25rem;
|
||||||
|
margin: 0;
|
||||||
|
color: var(--accent);
|
||||||
|
}
|
||||||
|
.subtitle {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
.atlas-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
|
||||||
|
gap: 1.5rem;
|
||||||
|
}
|
||||||
|
.tool-card {
|
||||||
|
background: var(--card-bg);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 1.25rem;
|
||||||
|
}
|
||||||
|
.tool-card h2 {
|
||||||
|
font-size: 0.95rem;
|
||||||
|
margin-top: 0;
|
||||||
|
color: var(--text-main);
|
||||||
|
border-bottom: 1px dashed var(--border);
|
||||||
|
padding-bottom: 0.5rem;
|
||||||
|
}
|
||||||
|
ul {
|
||||||
|
list-style: none;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0 0 1rem 0;
|
||||||
|
font-size: 0.78rem;
|
||||||
|
}
|
||||||
|
li {
|
||||||
|
margin-bottom: 0.4rem;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
.port-pill {
|
||||||
|
background: #0284c7;
|
||||||
|
color: white;
|
||||||
|
font-size: 0.65rem;
|
||||||
|
padding: 0.1rem 0.4rem;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
footer {
|
||||||
|
margin-top: 3rem;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 0.7rem;
|
||||||
|
color: var(--text-muted);
|
||||||
|
border-top: 1px solid var(--border);
|
||||||
|
padding-top: 1rem;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<div>
|
||||||
|
<h1>[ ⚚ FRONT-END GROUPED ARCHITECTURE ATLAS ]</h1>
|
||||||
|
<div class="subtitle">hyperstitionstud.io v2.18.0 • Zero Raster Bloat • 8 Tool Groups (G01–G08)</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<a href="/" style="color: var(--accent); text-decoration: none; font-size: 0.78rem;">Portal Home (/)</a>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div class="atlas-grid" id="atlasGrid">
|
||||||
|
<!-- G01 .. G08 -->
|
||||||
|
<div class="tool-card" id="g01-quant">
|
||||||
|
<h2>G01.QUANT (/quant/)</h2>
|
||||||
|
<ul>
|
||||||
|
<li><span>quant-app.js</span> <span class="port-pill">IN <- Fred/Timeseries</span></li>
|
||||||
|
<li><span>quant-tutorials.js</span> <span class="port-pill">OUT -> WebAudio / Speech</span></li>
|
||||||
|
<li><span>collector.py</span> <span class="port-pill">IN <- Market APIs</span></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="tool-card" id="g02-calc-ci">
|
||||||
|
<h2>G02.CALC_CI (/calc/)</h2>
|
||||||
|
<ul>
|
||||||
|
<li><span>haiperdohp-jemaytreeah</span> <span class="port-pill">IN <- Ingglish G2P</span></li>
|
||||||
|
<li><span>ci_provision_ingglish.py</span> <span class="port-pill">OUT -> CI Artifacts</span></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="tool-card" id="g03-graph">
|
||||||
|
<h2>G03.GRAPH (/graph/)</h2>
|
||||||
|
<ul>
|
||||||
|
<li><span>encyclopedia-graph.json</span> <span class="port-pill">IN <- SQLite FTS5</span></li>
|
||||||
|
<li><span>graph-data.js</span> <span class="port-pill">OUT -> Canvas 2D / Radar</span></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="tool-card" id="g04-zoology">
|
||||||
|
<h2>G04.ZOOLOGY (/zoology/)</h2>
|
||||||
|
<ul>
|
||||||
|
<li><span>technocapital-singularity-zoology</span> <span class="port-pill">IN <- Dossiers S1-S6</span></li>
|
||||||
|
<li><span>encyclopedia manifests</span> <span class="port-pill">OUT -> PDF Manuals</span></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="tool-card" id="g05-archive">
|
||||||
|
<h2>G05.ARCHIVE (/archive/)</h2>
|
||||||
|
<ul>
|
||||||
|
<li><span>archive_rotator.py</span> <span class="port-pill">IN <- FIFO Tarballs</span></li>
|
||||||
|
<li><span>archive-manifest.json</span> <span class="port-pill">OUT -> Git Citations</span></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="tool-card" id="g06-eng-math">
|
||||||
|
<h2>G06.ENG_MATH (/engineering/ & /math/)</h2>
|
||||||
|
<ul>
|
||||||
|
<li><span>engineering_docs.py</span> <span class="port-pill">IN <- Polyglot Lens</span></li>
|
||||||
|
<li><span>math_docs.py</span> <span class="port-pill">OUT -> Z-Calculus REPL</span></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="tool-card" id="g07-portal-learn">
|
||||||
|
<h2>G07.PORTAL_LEARN (/, /learn/)</h2>
|
||||||
|
<ul>
|
||||||
|
<li><span>site/index.html</span> <span class="port-pill">IN <- Group 3 Basalt</span></li>
|
||||||
|
<li><span>site/learn/index.html</span> <span class="port-pill">OUT -> Grimoiric Folios</span></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="tool-card" id="g08-mcp-deploy">
|
||||||
|
<h2>G08.MCP_DEPLOY (/mcp/, /api/v1/)</h2>
|
||||||
|
<ul>
|
||||||
|
<li><span>mcp/{server,tools,rest}.py</span> <span class="port-pill">IN <- MCP JSON-RPC</span></li>
|
||||||
|
<li><span>deploy/sync-vps-repos.sh</span> <span class="port-pill">OUT -> Tmpfs / Caddy</span></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
hyperstitionstud.io Architecture Atlas • Verified via hs-arch-atlas (Plan #67)
|
||||||
|
</footer>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
"""
|
||||||
|
|
||||||
|
def generate_architecture_atlas(output_html_path: Path, output_json_path: Path) -> str:
|
||||||
|
html_content = ATLAS_HTML_TEMPLATE.strip()
|
||||||
|
digest = hashlib.sha256(html_content.encode("utf-8")).hexdigest()
|
||||||
|
|
||||||
|
output_html_path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
output_html_path.write_text(html_content, encoding="utf-8")
|
||||||
|
|
||||||
|
receipt = {
|
||||||
|
"version": "2.18.0",
|
||||||
|
"atlas_sha256": digest,
|
||||||
|
"size_bytes": len(html_content.encode("utf-8")),
|
||||||
|
"tool_groups": ["G01.QUANT", "G02.CALC_CI", "G03.GRAPH", "G04.ZOOLOGY", "G05.ARCHIVE", "G06.ENG_MATH", "G07.PORTAL_LEARN", "G08.MCP_DEPLOY"]
|
||||||
|
}
|
||||||
|
output_json_path.write_text(json.dumps(receipt, indent=2), encoding="utf-8")
|
||||||
|
return digest
|
||||||
|
|
||||||
|
def main() -> int:
|
||||||
|
cfg = load_workspace_config()
|
||||||
|
graph_docs_dir = cfg.workspace_root / "encyclopedia-knowledge-graph" / "docs"
|
||||||
|
html_out = graph_docs_dir / "architecture-atlas.html"
|
||||||
|
json_out = graph_docs_dir / "architecture-atlas.json"
|
||||||
|
|
||||||
|
digest = generate_architecture_atlas(html_out, json_out)
|
||||||
|
print(f"[OK] Generated architecture atlas at {html_out} (SHA-256: {digest[:12]})")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
||||||
Reference in new issue
Block a user