PLAN-68: Implement shorthand disambiguation standard, hs-shorthand-lint, pre-commit gate, and core comment/UI migration
This commit is contained in:
1 parent
32cd771707
commit
9378c594f9
15 files changed
+301
-94
No files matched your search
@@ -56,7 +56,7 @@ def prepare_and_verify_deploy_scripts(
|
||||
modified_files: list[str] = []
|
||||
errors: list[str] = []
|
||||
|
||||
# Gate D1: Version Header & Tracked Mirror Parity
|
||||
# Gate DEPLOY-GATE-D01.MIRROR_PARITY: Version Header & Tracked Mirror Parity
|
||||
# Note: On VPS (/srv/hyperstitionstud.io/repos), the tracked copy is `hyperstitionstudio-core/deploy/push-all-to-git-libre-audio.sh`
|
||||
# while the parent directory `ws_root/push-all-to-git-libre-audio.sh` may be absent until hydrated.
|
||||
if ws_push_sh.is_file():
|
||||
@@ -123,7 +123,7 @@ def prepare_and_verify_deploy_scripts(
|
||||
|
||||
gate_d1_ok = len(errors) == 0
|
||||
|
||||
# Gate D2 & D3: bash -n Syntax, Executable Permissions & Zero-/dev/null Redirections
|
||||
# Gate DEPLOY-GATE-D02.BASH_SYNTAX & DEPLOY-GATE-D03.ZERO_DEV_NULL: bash -n Syntax, Executable Permissions & Zero-/dev/null Redirections
|
||||
scripts_to_audit = [
|
||||
ws_push_sh,
|
||||
tracked_push_sh,
|
||||
@@ -149,7 +149,7 @@ def prepare_and_verify_deploy_scripts(
|
||||
gate_d3_ok = False
|
||||
errors.append(f"Gate D3: Forbidden /dev/null found in {sp}")
|
||||
|
||||
# Gate D4: Untracked Runtime Artifact Hydration Parity (.gitignore vs. sync-vps-repos.sh)
|
||||
# Gate DEPLOY-GATE-D04.HYDRATION_PARITY: Untracked Runtime Artifact Hydration Parity (.gitignore vs. sync-vps-repos.sh)
|
||||
sync_txt_cur = sync_vps_sh.read_text(encoding="utf-8") if sync_vps_sh.is_file() else ""
|
||||
core_gi = (core_dir / ".gitignore").read_text(encoding="utf-8") if (core_dir / ".gitignore").is_file() else ""
|
||||
gate_d4_ok = True
|
||||
@@ -161,7 +161,7 @@ def prepare_and_verify_deploy_scripts(
|
||||
gate_d4_ok = False
|
||||
errors.append("Gate D4: haiperdohp-jemaytreeah untracked artifact hydration missing in deploy/sync-vps-repos.sh")
|
||||
|
||||
# Gate D5: Cold *.tar.gz Archive Exclusion & Explicit rm -f Safety in sync-vps-repos.sh
|
||||
# Gate DEPLOY-GATE-D05.TAR_EXCLUSION: Cold *.tar.gz Archive Exclusion & Explicit rm -f Safety in sync-vps-repos.sh
|
||||
gate_d5_ok = (
|
||||
"--exclude='completed-plans-archive.tar.gz'" in sync_txt_cur
|
||||
and "--exclude='inactive-plans-archive.tar.gz'" in sync_txt_cur
|
||||
@@ -171,7 +171,7 @@ def prepare_and_verify_deploy_scripts(
|
||||
if not gate_d5_ok:
|
||||
errors.append("Gate D5: Cold plan .tar.gz exclusion or rm -f cleanup missing in deploy/sync-vps-repos.sh")
|
||||
|
||||
# Gate D6: Single-Layer 1x Compression & Caddyfile Media Extension Parity
|
||||
# Gate DEPLOY-GATE-D06.COMPRESSION_PARITY: Single-Layer 1x Compression & Caddyfile Media Extension Parity
|
||||
caddy_txt = caddyfile_p.read_text(encoding="utf-8") if caddyfile_p.is_file() else ""
|
||||
push_src = ws_push_sh if ws_push_sh.is_file() else tracked_push_sh
|
||||
push_txt_cur = push_src.read_text(encoding="utf-8") if push_src.is_file() else ""
|
||||
@@ -185,7 +185,7 @@ def prepare_and_verify_deploy_scripts(
|
||||
if not gate_d6_ok:
|
||||
errors.append("Gate D6: Single-layer compression enforcement or Caddyfile media extension parity missing")
|
||||
|
||||
# Gate D7: Topological 6-Repository Push & Force-Tag Sync Parity in push-all-to-git-libre-audio.sh
|
||||
# Gate DEPLOY-GATE-D07.TOPO_PUSH_PARITY: Topological 6-Repository Push & Force-Tag Sync Parity in push-all-to-git-libre-audio.sh
|
||||
required_push_markers = (
|
||||
"hyperstitionstudio-core",
|
||||
"ingglish-hyperdope-gematria",
|
||||
@@ -201,7 +201,7 @@ def prepare_and_verify_deploy_scripts(
|
||||
if not gate_d7_ok:
|
||||
errors.append("Gate D7: Missing required repository, force-tag, or verification marker in push-all-to-git-libre-audio.sh")
|
||||
|
||||
# Gate D8: Automatic Git Staging Prior to Commit (--stage)
|
||||
# Gate DEPLOY-GATE-D08.PRE_COMMIT_STAGE: Automatic Git Staging Prior to Commit (--stage)
|
||||
staged_files: list[str] = []
|
||||
if stage and not check_only and (core_dir / ".git").exists():
|
||||
for rel_s in ("deploy/push-all-to-git-libre-audio.sh", "deploy/sync-vps-repos.sh", "deploy/Caddyfile"):
|
||||
|
||||
@@ -213,7 +213,7 @@ def run_public_regression_suite(
|
||||
regressions: list[str] = []
|
||||
gate_results: dict[str, bool] = {}
|
||||
|
||||
# Gate P1: API & MCP Liveness (502 / 5xx Detector)
|
||||
# Gate SMOKE-GATE-P01.STATIC_ROUTES: API & MCP Liveness (502 / 5xx Detector)
|
||||
p1_ok = True
|
||||
api_probes = (
|
||||
"/status",
|
||||
@@ -252,7 +252,7 @@ def run_public_regression_suite(
|
||||
regressions.append(f"Gate P1: GET {mcp_ep} returned HTTP {mcp_code}")
|
||||
gate_results["P1_api_and_mcp_liveness_zero_502"] = p1_ok
|
||||
|
||||
# Gate P2: Internal-vs-External Version & CIDv1 Drift
|
||||
# Gate SMOKE-GATE-P02.VERSION_CID_DRIFT: Internal-vs-External Version & CIDv1 Drift
|
||||
p2_ok = True
|
||||
st_obj = (api_responses.get("/status") or {}).get("data") or {}
|
||||
live_ver = st_obj.get("version")
|
||||
@@ -277,7 +277,7 @@ def run_public_regression_suite(
|
||||
regressions.append(f"Gate P2: {art_route} CIDv1 {live_cid!r} != baseline {exp_cid!r}")
|
||||
gate_results["P2_version_and_cidv1_parity"] = p2_ok
|
||||
|
||||
# Gate P3: Zero-Synthetic-Data & Canary Invariant Audit
|
||||
# Gate SMOKE-GATE-P03.ZERO_SYNTHETIC: Zero-Synthetic-Data & Canary Invariant Audit
|
||||
p3_ok = True
|
||||
nvda_qts = ((api_responses.get("/quant/timeseries?symbol=NVDA") or {}).get("data") or {}).get("instruments") or []
|
||||
if nvda_qts:
|
||||
@@ -304,7 +304,7 @@ def run_public_regression_suite(
|
||||
regressions.append("Gate P3: hs_generate_ticker_stats_card did not return valid PNG magic bytes")
|
||||
gate_results["P3_zero_synthetic_and_canary_invariants"] = p3_ok
|
||||
|
||||
# Gate P4: Web-Linked PDF Stylistic Refresh & SHA-256 Parity
|
||||
# Gate SMOKE-GATE-P04.PDF_PARITY: Web-Linked PDF Stylistic Refresh & SHA-256 Parity
|
||||
p4_ok = True
|
||||
for pdf_route, pdf_meta in baseline["expected_web_pdfs"].items():
|
||||
p_code, p_bytes = _http_fetch(f"{base}{pdf_route}")
|
||||
@@ -319,7 +319,7 @@ def run_public_regression_suite(
|
||||
regressions.append(f"Gate P4: {pdf_route} SHA-256 {live_sha[:12]} != baseline {pdf_meta['sha256'][:12]} (un-refreshed PDF!)")
|
||||
gate_results["P4_web_pdf_dark_mode_and_sha256_parity"] = p4_ok
|
||||
|
||||
# Gate P5: Deep-Link & Citation Target Resolution
|
||||
# Gate SMOKE-GATE-P05.DEEP_LINKS: Deep-Link & Citation Target Resolution
|
||||
p5_ok = True
|
||||
if nvda_qts:
|
||||
drefs = nvda_qts[0].get("doc_references") or {}
|
||||
@@ -332,7 +332,7 @@ def run_public_regression_suite(
|
||||
regressions.append(f"Gate P5: Deep link {rlk} returned HTTP {rc}")
|
||||
gate_results["P5_deep_link_resolution"] = p5_ok
|
||||
|
||||
# Gate P6: HTML / CSS Visual & Content Regression
|
||||
# Gate SMOKE-GATE-P06.NAV_STYLE_PARITY: HTML / CSS Visual & Content Regression
|
||||
p6_ok = True
|
||||
for h_route, h_meta in baseline["expected_html_surfaces"].items():
|
||||
hc, h_bytes = _http_fetch(f"{base}{h_route}")
|
||||
@@ -384,7 +384,7 @@ def verify_ui_style_and_navigation_consistency(workspace_root: str | Path | None
|
||||
chamfer_css_p = core / "site" / "assets" / "hs-group3-basalt-chamfer.css"
|
||||
chamfer_css = chamfer_css_p.read_text(encoding="utf-8") if chamfer_css_p.is_file() else ""
|
||||
|
||||
# Gate S1: Zero Spurious rgb(30, 41, 59) / #1e293b Background Invariant on Subpages & Group 3 CSS
|
||||
# Gate STYLE-GATE-S01.NO_SLATE_BG: Zero Spurious rgb(30, 41, 59) / #1e293b Background Invariant on Subpages & Group 3 CSS
|
||||
if re.search(r"#1e293b|rgb\(\s*30\s*,\s*41\s*,\s*59\s*\)", chamfer_css, flags=re.I):
|
||||
errors.append("Gate S1: Forbidden #1e293b / rgb(30, 41, 59) found in hs-group3-basalt-chamfer.css")
|
||||
|
||||
@@ -422,7 +422,7 @@ def verify_ui_style_and_navigation_consistency(workspace_root: str | Path | None
|
||||
):
|
||||
errors.append("Gate S1/S3: .hs-nav-btn in calc/styles.css contains #1e293b or !important color/border overrides")
|
||||
|
||||
# Gate S2: Intra-Page Font-Family Uniformity Invariant
|
||||
# Gate STYLE-GATE-S02.DEJAVU_FONT: Intra-Page Font-Family Uniformity Invariant
|
||||
if "--font-mono:" not in chamfer_css or "button," not in chamfer_css or "select," not in chamfer_css:
|
||||
errors.append("Gate S2: hs-group3-basalt-chamfer.css missing --font-mono inheritance on button/input/select/textarea")
|
||||
for sname in ("graph", "quant", "learn", "engineering_hub", "engineering_e1", "math_hub", "math_m1", "donate", "gallery"):
|
||||
@@ -432,7 +432,7 @@ def verify_ui_style_and_navigation_consistency(workspace_root: str | Path | None
|
||||
if sname == "graph" and "font-family: monospace;" in stxt:
|
||||
errors.append(f"Gate S2: Bare 'font-family: monospace;' without --font-mono found in /graph/")
|
||||
|
||||
# Gate S3: Cross-Page Navigation UI & Header Style Parity Invariant
|
||||
# Gate STYLE-GATE-S03.HEADER_PARITY: Cross-Page Navigation UI & Header Style Parity Invariant
|
||||
home_txt = (core / "site" / "index.html").read_text(encoding="utf-8")
|
||||
if '<div class="meta-badges">' not in home_txt:
|
||||
errors.append("Gate S3: Homepage site/index.html <div class=\"meta-badges\"> was modified!")
|
||||
@@ -452,7 +452,7 @@ def verify_ui_style_and_navigation_consistency(workspace_root: str | Path | None
|
||||
if any(pos == -1 for pos in positions) or positions != sorted(positions):
|
||||
errors.append(f"Gate S3: Canonical navigation link order mismatch in {sname}: {positions}")
|
||||
|
||||
# Gate S4 (Plan #66): Adaptive Mobile Device Detection & Mobile UI Ergonomics (Strategies 1A, 2A, 3A, 4A)
|
||||
# Gate STYLE-GATE-S04.MOBILE_UI (Plan #66): Adaptive Mobile Device Detection & Mobile UI Ergonomics (Strategies 1A, 2A, 3A, 4A)
|
||||
mob_js_p = core / "site" / "assets" / "hs-mobile-ui.js"
|
||||
if not mob_js_p.is_file():
|
||||
errors.append("Gate S4: Missing site/assets/hs-mobile-ui.js")
|
||||
|
||||
@@ -6,25 +6,32 @@ Enforces Plan #68: Human-Read Text & Comment Shorthand Disambiguation (<PREFIX><
|
||||
with strict global exemption for executable code, strings, tests, and runtime data structures.
|
||||
"""
|
||||
|
||||
import sys
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import io
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import tokenize
|
||||
import io
|
||||
from pathlib import Path
|
||||
from typing import List, Tuple, Dict, Any
|
||||
from typing import List, Tuple
|
||||
|
||||
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"
|
||||
"H1", "H2", "H3", "V8", "M1", "M2", "P20", "P50", "P90",
|
||||
"H01", "H02", "H03", "H04", "H05", "H06", "H07", "H08", "H09",
|
||||
}
|
||||
|
||||
# Regex for un-disambiguated bare shorthands like G1..G8, M0..M7, S1..S7, E0..E5, D0..D8, P1..P6, R1..R6
|
||||
# Regex for un-disambiguated bare shorthands (bare [GDMESPR][0-9]{1,2} tokens without a <PREFIX><NN>.<DOMAIN_TAG> qualifier)
|
||||
BARE_SHORTHAND_PATTERN = re.compile(r"\b([GDMESPR])([0-9]{1,2})\b")
|
||||
DATA_URI_BASE64_RE = re.compile(r"data:image/[a-zA-Z0-9+.-]+;base64,[A-Za-z0-9+/=]+")
|
||||
MD_LINK_URL_RE = re.compile(r"\]\([^)]*\)")
|
||||
SUPPORTED_EXTS = {".py", ".md", ".js", ".mjs", ".ts", ".css", ".html", ".svg", ".sh", ".toml", ".yaml", ".yml"}
|
||||
|
||||
|
||||
def extract_python_comments(source_code: str) -> List[Tuple[int, str]]:
|
||||
comments = []
|
||||
comments: List[Tuple[int, str]] = []
|
||||
try:
|
||||
tokens = tokenize.generate_tokens(io.StringIO(source_code).readline)
|
||||
for tok in tokens:
|
||||
@@ -34,43 +41,139 @@ def extract_python_comments(source_code: str) -> List[Tuple[int, str]]:
|
||||
pass
|
||||
return comments
|
||||
|
||||
|
||||
def extract_markdown_prose_lines(markdown_text: str) -> List[Tuple[int, str]]:
|
||||
lines = markdown_text.splitlines()
|
||||
prose_lines = []
|
||||
prose_lines: List[Tuple[int, str]] = []
|
||||
in_fence = False
|
||||
for idx, line in enumerate(lines, start=1):
|
||||
stripped = line.strip()
|
||||
if stripped.startswith("```"):
|
||||
if stripped.startswith("```") or stripped.startswith("~~~"):
|
||||
in_fence = not in_fence
|
||||
continue
|
||||
if in_fence:
|
||||
continue
|
||||
# Remove inline backtick code spans
|
||||
# Remove inline backtick code spans and markdown link target URLs
|
||||
clean_line = re.sub(r"`[^`]*`", "", line)
|
||||
clean_line = MD_LINK_URL_RE.sub("]()", clean_line)
|
||||
prose_lines.append((idx, clean_line))
|
||||
return prose_lines
|
||||
|
||||
|
||||
def extract_sh_comments(text: str) -> List[Tuple[int, str]]:
|
||||
comments: List[Tuple[int, str]] = []
|
||||
for idx, line in enumerate(text.splitlines(), start=1):
|
||||
in_sq = False
|
||||
in_dq = False
|
||||
esc = False
|
||||
for i, ch in enumerate(line):
|
||||
if esc:
|
||||
esc = False
|
||||
continue
|
||||
if ch == "\\" and not in_sq:
|
||||
esc = True
|
||||
continue
|
||||
if ch == "'" and not in_dq:
|
||||
in_sq = not in_sq
|
||||
elif ch == '"' and not in_sq:
|
||||
in_dq = not in_dq
|
||||
elif ch == "#" and not in_sq and not in_dq:
|
||||
if i == 0 or line[i - 1].isspace():
|
||||
comments.append((idx, line[i:]))
|
||||
break
|
||||
return comments
|
||||
|
||||
|
||||
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
|
||||
"""Extract // and /* ... */ comments while skipping string/template literals."""
|
||||
comments: List[Tuple[int, str]] = []
|
||||
i = 0
|
||||
n = len(text)
|
||||
line = 1
|
||||
in_sq = False
|
||||
in_dq = False
|
||||
in_bt = False
|
||||
while i < n:
|
||||
ch = text[i]
|
||||
if ch == "\n":
|
||||
line += 1
|
||||
i += 1
|
||||
continue
|
||||
if in_block:
|
||||
extracted.append((idx, line))
|
||||
if in_sq:
|
||||
if ch == "\\" and i + 1 < n:
|
||||
i += 2
|
||||
continue
|
||||
if ch == "'":
|
||||
in_sq = False
|
||||
i += 1
|
||||
continue
|
||||
if stripped.startswith("//") or stripped.startswith("<!--") or "#" in stripped:
|
||||
extracted.append((idx, line))
|
||||
return extracted
|
||||
if in_dq:
|
||||
if ch == "\\" and i + 1 < n:
|
||||
i += 2
|
||||
continue
|
||||
if ch == '"':
|
||||
in_dq = False
|
||||
i += 1
|
||||
continue
|
||||
if in_bt:
|
||||
if ch == "\\" and i + 1 < n:
|
||||
i += 2
|
||||
continue
|
||||
if ch == "`":
|
||||
in_bt = False
|
||||
i += 1
|
||||
continue
|
||||
if text[i : i + 2] == "/*":
|
||||
start_line = line
|
||||
end = text.find("*/", i + 2)
|
||||
if end == -1:
|
||||
comments.append((start_line, text[i:]))
|
||||
break
|
||||
block = text[i : end + 2]
|
||||
comments.append((start_line, block))
|
||||
line += block.count("\n")
|
||||
i = end + 2
|
||||
continue
|
||||
if text[i : i + 2] == "//":
|
||||
end = text.find("\n", i)
|
||||
if end == -1:
|
||||
comments.append((line, text[i:]))
|
||||
break
|
||||
comments.append((line, text[i:end]))
|
||||
i = end
|
||||
continue
|
||||
if ch == "'":
|
||||
in_sq = True
|
||||
elif ch == '"':
|
||||
in_dq = True
|
||||
elif ch == "`":
|
||||
in_bt = True
|
||||
i += 1
|
||||
return comments
|
||||
|
||||
|
||||
def extract_html_comments(text: str) -> List[Tuple[int, str]]:
|
||||
comments: List[Tuple[int, str]] = []
|
||||
i = 0
|
||||
line = 1
|
||||
while True:
|
||||
idx = text.find("<!--", i)
|
||||
if idx == -1:
|
||||
break
|
||||
line += text[i:idx].count("\n")
|
||||
end = text.find("-->", idx + 4)
|
||||
if end == -1:
|
||||
comments.append((line, text[idx:]))
|
||||
break
|
||||
block = text[idx : end + 3]
|
||||
comments.append((line, block))
|
||||
line += block.count("\n")
|
||||
i = end + 3
|
||||
return comments
|
||||
|
||||
|
||||
def scan_file_for_bare_shorthands(file_path: Path) -> List[str]:
|
||||
violations = []
|
||||
violations: List[str] = []
|
||||
try:
|
||||
content = file_path.read_text(encoding="utf-8", errors="ignore")
|
||||
except Exception:
|
||||
@@ -83,56 +186,104 @@ def scan_file_for_bare_shorthands(file_path: Path) -> List[str]:
|
||||
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"):
|
||||
elif suffix in (".sh", ".toml", ".yaml", ".yml"):
|
||||
target_lines = extract_sh_comments(content)
|
||||
elif suffix in (".js", ".mjs", ".ts", ".css"):
|
||||
target_lines = extract_js_css_comments(content)
|
||||
elif suffix in (".html", ".svg"):
|
||||
target_lines = extract_html_comments(content)
|
||||
else:
|
||||
# Default text/doc scan outside code blocks
|
||||
for idx, line in enumerate(content.splitlines(), start=1):
|
||||
target_lines.append((idx, line))
|
||||
return violations
|
||||
|
||||
for lineno, text in target_lines:
|
||||
for match in BARE_SHORTHAND_PATTERN.finditer(text):
|
||||
clean_text = DATA_URI_BASE64_RE.sub("", text)
|
||||
for match in BARE_SHORTHAND_PATTERN.finditer(clean_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
|
||||
if start_pos < len(clean_text) and clean_text[start_pos] == ".":
|
||||
continue
|
||||
violations.append(f"{file_path}:{lineno}: Bare shorthand '{token}' detected without canonical <PREFIX><NN>.<DOMAIN_TAG> domain tag.")
|
||||
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():
|
||||
|
||||
def _staged_files_for_repo(repo_dir: Path) -> List[Path]:
|
||||
res = subprocess.run(
|
||||
["git", "-C", str(repo_dir), "diff", "--cached", "--name-only", "--diff-filter=ACM"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=False,
|
||||
)
|
||||
if res.returncode != 0:
|
||||
return []
|
||||
files: List[Path] = []
|
||||
for rel in res.stdout.splitlines():
|
||||
rel_s = rel.strip()
|
||||
if not rel_s:
|
||||
continue
|
||||
for p in rdir.rglob("*"):
|
||||
p = repo_dir / rel_s
|
||||
if p.is_file() and p.suffix.lower() in SUPPORTED_EXTS:
|
||||
files.append(p)
|
||||
return files
|
||||
|
||||
|
||||
def main(argv: list[str] | None = None) -> int:
|
||||
ap = argparse.ArgumentParser(
|
||||
prog="hs-shorthand-lint",
|
||||
description="Tokenizer-based shorthand disambiguation linter (Plan #68).",
|
||||
)
|
||||
ap.add_argument("--check-all", action="store_true", help="Scan all 6 repositories (default).")
|
||||
ap.add_argument("--staged-diff", action="store_true", help="Scan only git-staged files in --repo.")
|
||||
ap.add_argument("--repo", default=None, help="Repository path to scan.")
|
||||
args = ap.parse_args(argv)
|
||||
|
||||
workspace_root = Path(os.environ.get("WORKSPACE_DIR", "/workspace"))
|
||||
all_violations: List[str] = []
|
||||
|
||||
if args.staged_diff:
|
||||
repo_dir = Path(args.repo).resolve() if args.repo else Path.cwd()
|
||||
for p in _staged_files_for_repo(repo_dir):
|
||||
all_violations.extend(scan_file_for_bare_shorthands(p))
|
||||
elif args.repo:
|
||||
rdir = Path(args.repo).resolve()
|
||||
if not rdir.is_dir():
|
||||
rdir = workspace_root / args.repo
|
||||
for p in sorted(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 p.suffix.lower() in SUPPORTED_EXTS:
|
||||
all_violations.extend(scan_file_for_bare_shorthands(p))
|
||||
else:
|
||||
repos = [
|
||||
"hyperstitionstudio-core",
|
||||
"ingglish-hyperdope-gematria",
|
||||
"technocapital-singularity-zoology",
|
||||
"encyclopedia-knowledge-graph",
|
||||
"haiperdohp-jemaytreeah",
|
||||
"hyperdope-ci-build",
|
||||
]
|
||||
for r in repos:
|
||||
rdir = workspace_root / r
|
||||
if not rdir.is_dir():
|
||||
continue
|
||||
for p in sorted(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 SUPPORTED_EXTS:
|
||||
all_violations.extend(scan_file_for_bare_shorthands(p))
|
||||
|
||||
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())
|
||||
@@ -23,11 +23,11 @@ ENABLED_LENSES: tuple[str, ...] = (
|
||||
|
||||
# 12 Canonical Lens-Neutral Mathematical Keys:
|
||||
# Structural Combine (6):
|
||||
# 1. struct_isometric_armor (G4 Isometric Chokepoint Ratio, 0-100)
|
||||
# 2. struct_drift_velocity (G3 Inverse Phonemic Drift & Quantized Steps, 0-100)
|
||||
# 3. struct_variance_collapse (G1 Log Gen 0 -> Gen 1 Variance Collapse, 0-100)
|
||||
# 4. struct_trophic_capture (S[1-5]xS6 Double-Articulation & Cross-Guild Degree, 0-100)
|
||||
# 5. struct_prime_density (G5 Prime & Twin-Prime Mutation Density, 0-100)
|
||||
# 1. struct_isometric_armor (RULE-G04.ISOMETRIC Chokepoint Ratio, 0-100)
|
||||
# 2. struct_drift_velocity (RULE-G03.STRUCTURAL Inverse Phonemic Drift & Quantized Steps, 0-100)
|
||||
# 3. struct_variance_collapse (RULE-G01.COLLAPSE Log GEN-00.ENGLISH -> GEN-01.INGGLISH Variance Collapse, 0-100)
|
||||
# 4. struct_trophic_capture (CLASS-S01.SILICON..CLASS-S05.BWO x CLASS-S06.AGI Double-Articulation & Cross-Guild Degree, 0-100)
|
||||
# 5. struct_prime_density (RULE-G05.TWIN_PRIME Mutation Density, 0-100)
|
||||
# 6. struct_repricing_resilience (Tri-Modal Repricing & State-Gate Closure, 0-100)
|
||||
# Longitudinal Time-Series Moments (6):
|
||||
# 7. ts_duty_cycle_pct (Pr[X_t > 0] Active Lock/Wire Duty Cycle %)
|
||||
@@ -35,7 +35,7 @@ ENABLED_LENSES: tuple[str, ...] = (
|
||||
# 9. ts_excess_over_replacement (Value Over Baseline Tier D Replacement)
|
||||
# 10. ts_quantile_profile ({p20_floor, p90_ceiling, boom_pct, bust_pct, cv})
|
||||
# 11. ts_optimal_lag_days (Peak Cross-Correlation Lead-Lag tau* in [-5..+5] days)
|
||||
# 12. ts_regime_splits (Conditional Regime Delta {M1, M2, M3})
|
||||
# 12. ts_regime_splits (Conditional Regime Delta {CLASS-M01.ENTROPIC, CLASS-M02.KINETIC, CLASS-M03.LEVIATHAN})
|
||||
|
||||
LENS_REGISTRY: dict[str, dict[str, Any]] = {
|
||||
"neutral_math": {
|
||||
|
||||
@@ -112,7 +112,7 @@ ATLAS_HTML_TEMPLATE = """<!DOCTYPE html>
|
||||
</header>
|
||||
|
||||
<div class="atlas-grid" id="atlasGrid">
|
||||
<!-- G01 .. G08 -->
|
||||
<!-- G01.QUANT .. G08.MCP_DEPLOY -->
|
||||
<div class="tool-card" id="g01-quant">
|
||||
<h2>G01.QUANT (/quant/)</h2>
|
||||
<ul>
|
||||
|
||||
@@ -907,7 +907,7 @@ def render_all_quadrant_closeups(
|
||||
im.save(out_dir / "quadrant-4-operators-deployment-vps.png", "PNG")
|
||||
tracked_draws["quadrant-4-operators-deployment-vps.png"] = d
|
||||
|
||||
# 10. Quadrant 04 Tab 2: Unit E4 MCP, REST & ETag 304 Probe
|
||||
# 10. Quadrant 04 Tab 2: UNIT-E04.MCP_REST_IPLD MCP, REST & ETag 304 Probe
|
||||
im, d = _new_canvas()
|
||||
_draw_chamfer_box(d, (10, 10, 670, 250), PLATE, BORDER, chamfer=10, pip=ROSE)
|
||||
d.text((24, 18), "STATELESS MCP (/mcp), REST v1 (/api/v1/*) & LIVE ETAG 304 PROBE", font=f_hdr, fill=ROSE)
|
||||
@@ -950,7 +950,7 @@ def render_all_quadrant_closeups(
|
||||
im.save(out_dir / "quadrant-4-tab-2-mcp-etag.png", "PNG")
|
||||
tracked_draws["quadrant-4-tab-2-mcp-etag.png"] = d
|
||||
|
||||
# 11. Quadrant 04 Tab 3: /ci/ 4-Gate Pipeline & P1-P6 Smoke
|
||||
# 11. Quadrant 04 Tab 3: /ci/ 4-Gate Pipeline & SMOKE-GATE-P01.STATIC_ROUTES..SMOKE-GATE-P06.NAV_STYLE_PARITY Smoke
|
||||
im, d = _new_canvas()
|
||||
_draw_chamfer_box(d, (10, 10, 670, 250), PLATE, BORDER, chamfer=10, pip=ROSE)
|
||||
d.text((24, 18), "4-GATE INGGLISH CI PIPELINE (/ci/) & 6-GATE PUBLIC SMOKE SUITE", font=f_hdr, fill=ROSE)
|
||||
|
||||
@@ -514,6 +514,7 @@ if [[ -d "${CORE_SRC}" ]]; then
|
||||
git -C "${REPO_ROOT}" add site/assets/closeups/
|
||||
fi
|
||||
python3 -m hyperstitionstud_io.publishing.readme_sync --repo "${REPO_NAME}" --stage
|
||||
python3 -m hyperstitionstud_io.ci.shorthand_lint --staged-diff --repo "${REPO_ROOT}"
|
||||
fi
|
||||
"""
|
||||
|
||||
@@ -559,7 +560,7 @@ def install_git_pre_commit_hooks(ws_root: Path | None = None, check_only: bool =
|
||||
if not hooks_dir.is_dir():
|
||||
continue
|
||||
for h_name, h_script, markers in (
|
||||
("pre-commit", PRE_COMMIT_HOOK_SCRIPT, ("readme_sync", "closeups_sync", "deploy_scripts_sync")),
|
||||
("pre-commit", PRE_COMMIT_HOOK_SCRIPT, ("readme_sync", "closeups_sync", "deploy_scripts_sync", "shorthand_lint")),
|
||||
("commit-msg", COMMIT_MSG_HOOK_SCRIPT, ("COMMIT-MSG GATE",)),
|
||||
):
|
||||
hook_path = hooks_dir / h_name
|
||||
|
||||
Reference in new issue
Block a user