feat(core): implement Plan #62 efficiency, deduplication, caching & hook optimizations

This commit is contained in:
Hermes Agent committed 2026-12-02 22:09:58 +00:00
1 parent d4b7502501
commit 9b587d6351
20 files changed
+171 -190

No files matched your search

+2 -2
View File
@@ -3,8 +3,8 @@
<!-- HS-COMMIT-STATUS:START -->
> **Gitea Commit & Release Telemetry (`v2.17.1` • 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 &rarr; [`https://hyperstitionstud.io/`](https://hyperstitionstud.io/)
> - **Latest Commit Scope (`hyperstitionstudio-core`):** Synchronized v2.17.1 release state across 7 tracked module/artifact surface(s)
> - **Touched Files / Surfaces:** `deploy/hyperstition-closing-bell-harvest.service`, `deploy/hyperstition-closing-bell-harvest.timer`, `deploy/run-vps-data-production.sh`, `src/hyperstitionstud_io/mcp/tools.py`, `src/hyperstitionstud_io/quant/collector.py`, `src/hyperstitionstud_io/quant/daily_brief.py`, `tests/test_core_suite.py`
> - **Latest Commit Scope (`hyperstitionstudio-core`):** Synchronized v2.17.1 release state across 19 tracked module/artifact surface(s)
> - **Touched Files / Surfaces:** `deploy/push-all-to-git-libre-audio.sh`, `src/hyperstitionstud_io/ci/citation_sources.py`, `src/hyperstitionstud_io/ci/deploy_scripts_sync.py`, `src/hyperstitionstud_io/ci/doctor.py`, `src/hyperstitionstud_io/ci/public_regression.py`, `src/hyperstitionstud_io/db/sqlite_meta.py`, `src/hyperstitionstud_io/mcp/tools.py`, `src/hyperstitionstud_io/publishing/archive_rotator.py` (+11 more)
> - **Live Verified Ecosystem Metrics (`v2.17.1`):** `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 -->
+1 -23
View File
@@ -51,32 +51,10 @@ FORGE_SSH="${FORGE_SSH:-ssh://git@git.libre.audio:2222/seasharp}"
echo "[info] WORKSPACE_DIR=${WORKSPACE_DIR}"
echo "[info] PYTHONPATH=${PYTHONPATH}"
echo "[1/3] Running pre-push verification gates (hs-archive-rotate, hs-closeups-sync, hs-readme-sync, version_sync, hs-doctor, logrotate.d/hyperstition-sqlite-meta check, periodic harvest CI/CD flow diagram PNG test, closeups check, test_core_suite, 6-gate graph verifier)..."
echo "[1/3] Running pre-push verification gates (hs-archive-rotate, hs-readme-sync, version_sync --corpus-delta, periodic harvest CI/CD flow diagram PNG, Fedora 41 RPM & dry-run, test_core_suite, 6-gate graph verifier)..."
run_checked "hs-archive-rotate --enforce-single-compression" python3 -m hyperstitionstud_io.publishing.archive_rotator --workspace-root "${WORKSPACE_DIR}" --enforce-single-compression
run_checked "verify docs/archive/archive-manifest.json" test -s "${WORKSPACE_DIR}/encyclopedia-knowledge-graph/docs/archive/archive-manifest.json"
run_checked "verify docs/plans/inactive/inactive-archive-manifest.json" test -s "${WORKSPACE_DIR}/encyclopedia-knowledge-graph/docs/plans/inactive/inactive-archive-manifest.json"
run_checked "hs-closeups-sync" python3 -m hyperstitionstud_io.publishing.closeups_sync
run_checked "hs-readme-sync --install-hooks" python3 -m hyperstitionstud_io.publishing.readme_sync --install-hooks
run_checked "version_sync --check" python3 -m hyperstitionstud_io.version_sync --check
run_checked "version_sync --corpus-delta" python3 -m hyperstitionstud_io.version_sync --corpus-delta
run_checked "hs-doctor" python3 -m hyperstitionstud_io.ci.doctor
run_checked "verify deploy/logrotate.d/hyperstition-sqlite-meta" test -f "${WORKSPACE_DIR}/hyperstitionstudio-core/deploy/logrotate.d/hyperstition-sqlite-meta"
run_checked "verify site/assets/hs-matrix-coderain.js" test -s "${WORKSPACE_DIR}/hyperstitionstudio-core/site/assets/hs-matrix-coderain.js"
run_checked "verify site/assets/matrix-font.woff2" test -s "${WORKSPACE_DIR}/hyperstitionstudio-core/site/assets/matrix-font.woff2"
for q_png in \
"quadrant-1-cybermemetics-calc-graph.png" \
"quadrant-1-tab-2-graph.png" \
"quadrant-2-esoteric-finance-quant.png" \
"quadrant-2-tab-2-bayesian-fred.png" \
"quadrant-2-tab-3-leaderboard-card.png" \
"quadrant-3-info-science-novice-learn-polyglot.png" \
"quadrant-3-tab-2-math-guile.png" \
"quadrant-3-tab-3-math-ts-rust.png" \
"quadrant-4-operators-deployment-vps.png" \
"quadrant-4-tab-2-mcp-etag.png" \
"quadrant-4-tab-3-ci-gates.png"; do
run_checked "verify site/assets/closeups/${q_png}" test -s "${WORKSPACE_DIR}/hyperstitionstudio-core/site/assets/closeups/${q_png}"
done
run_checked "generate & verify periodic-harvest-cicd-to-vps-flow-diagram.png" python3 -m hyperstitionstud_io.publishing.flow_diagram
run_checked "verify periodic-harvest-cicd-to-vps-flow-diagram.png exists" test -s "${WORKSPACE_DIR}/encyclopedia-knowledge-graph/docs/periodic-harvest-cicd-to-vps-flow-diagram.png"
run_checked "verify Fedora 41 packaging scripts & spec" "${WORKSPACE_DIR}/ingglish-hyperdope-gematria/packaging/build-fedora41-rpm.sh"
@@ -24,7 +24,7 @@ import time
from pathlib import Path
from typing import Any, Iterable
from hyperstitionstud_io.config import load_workspace_config
from hyperstitionstud_io.config import load_json_cached, load_workspace_config
SCHEMA_VERSION = 1
@@ -100,7 +100,7 @@ def load_ledger(path: Path) -> dict[str, Any]:
if not path.exists():
return {"version": SCHEMA_VERSION, "sources": []}
try:
data = json.loads(path.read_text(encoding="utf-8"))
data = load_json_cached(path, copy_result=True)
except (json.JSONDecodeError, OSError) as exc:
raise SystemExit(f"error: ledger at {path} is unreadable ({exc}); run `reset` to start over")
if not isinstance(data, dict) or not isinstance(data.get("sources"), list):
@@ -23,10 +23,6 @@ from hyperstitionstud_io import __version__ as CURRENT_VERSION
from hyperstitionstud_io.config import load_workspace_config, normalize_workspace_relpath
def _norm_ws_path(p: Path | str, workspace_root: str | Path | None = None) -> str:
return normalize_workspace_relpath(p, workspace_root=workspace_root)
def prepare_and_verify_deploy_scripts(
workspace_root: str | Path | None = None,
target_version: str | None = None,
@@ -63,7 +59,7 @@ def prepare_and_verify_deploy_scripts(
else:
ws_push_sh.write_text(upd_push, encoding="utf-8")
ws_push_sh.chmod(0o755)
modified_files.append(_norm_ws_path(ws_push_sh, workspace_root=ws_root))
modified_files.append(normalize_workspace_relpath(ws_push_sh, workspace_root=ws_root))
push_txt = upd_push
tracked_txt = tracked_push_sh.read_text(encoding="utf-8") if tracked_push_sh.is_file() else ""
@@ -74,7 +70,7 @@ def prepare_and_verify_deploy_scripts(
tracked_push_sh.parent.mkdir(parents=True, exist_ok=True)
tracked_push_sh.write_text(push_txt, encoding="utf-8")
tracked_push_sh.chmod(0o755)
modified_files.append(_norm_ws_path(tracked_push_sh, workspace_root=ws_root))
modified_files.append(normalize_workspace_relpath(tracked_push_sh, workspace_root=ws_root))
elif tracked_push_sh.is_file():
push_txt = tracked_push_sh.read_text(encoding="utf-8")
upd_push = re.sub(r"^#\s*Release\s+v\d+\.\d+\.\d+:", f"# Release v{ver}:", push_txt, count=1, flags=re.M)
@@ -84,7 +80,7 @@ def prepare_and_verify_deploy_scripts(
else:
tracked_push_sh.write_text(upd_push, encoding="utf-8")
tracked_push_sh.chmod(0o755)
modified_files.append(_norm_ws_path(tracked_push_sh, workspace_root=ws_root))
modified_files.append(normalize_workspace_relpath(tracked_push_sh, workspace_root=ws_root))
push_txt = upd_push
if not check_only:
try:
@@ -111,7 +107,7 @@ def prepare_and_verify_deploy_scripts(
else:
sync_vps_sh.write_text(upd_sync, encoding="utf-8")
sync_vps_sh.chmod(0o755)
modified_files.append(_norm_ws_path(sync_vps_sh, workspace_root=ws_root))
modified_files.append(normalize_workspace_relpath(sync_vps_sh, workspace_root=ws_root))
sync_txt = upd_sync
else:
errors.append(f"Gate D1: Missing {sync_vps_sh}")
+2 -2
View File
@@ -10,7 +10,7 @@ import json
from pathlib import Path
from typing import Any
from hyperstitionstud_io.config import load_workspace_config
from hyperstitionstud_io.config import load_json_cached, load_workspace_config
from hyperstitionstud_io.glossary import sha256_file
from hyperstitionstud_io.publishing.fonts import resolve_font_path
@@ -55,7 +55,7 @@ def run_diagnostics(workspace_root: str | Path | None = None) -> dict[str, Any]:
}
fb_path = Path(__file__).resolve().parent.parent / "phonetics" / "cmudict_fallback.json"
fb_count = len(json.loads(fb_path.read_text(encoding="utf-8"))) if fb_path.is_file() else 0
fb_count = len(load_json_cached(fb_path, copy_result=False)) if fb_path.is_file() else 0
lr_path = cfg.core_dir / "deploy" / "logrotate.d" / "hyperstition-sqlite-meta"
lr_txt = lr_path.read_text(encoding="utf-8") if lr_path.is_file() else ""
@@ -27,7 +27,7 @@ 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.config import load_json_cached, load_workspace_config
from hyperstitionstud_io.glossary import sha256_file
from hyperstitionstud_io.ipld import compute_dag_json_cidv1
from hyperstitionstud_io.mcp.tools import MCP_TOOLS_SCHEMA
@@ -91,10 +91,10 @@ def build_internal_test_baseline_snapshot(workspace_root: str | Path | None = No
brf_p = cfg.core_dir / "site" / "quant" / "daily-brief-latest.json"
kg_p = cfg.knowledge_graph_dir / "encyclopedia-graph.json"
ts_obj = json.loads(ts_p.read_text(encoding="utf-8"))
mac_obj = json.loads(mac_p.read_text(encoding="utf-8"))
brf_obj = json.loads(brf_p.read_text(encoding="utf-8"))
kg_obj = json.loads(kg_p.read_text(encoding="utf-8"))
ts_obj = load_json_cached(ts_p, copy_result=False)
mac_obj = load_json_cached(mac_p, copy_result=False)
brf_obj = load_json_cached(brf_p, copy_result=False)
kg_obj = load_json_cached(kg_p, copy_result=False)
nvda_inst = next(i for i in ts_obj["instruments"] if i["symbol"] == "NVDA")
nvda_nov27 = next(b for b in nvda_inst["bars"] if b["date_utc"] == "2026-11-27")
@@ -204,7 +204,7 @@ def run_public_regression_suite(
bp = Path(baseline_path) if baseline_path else get_default_baseline_cache_path()
if bp.is_file():
baseline = json.loads(bp.read_text(encoding="utf-8"))
baseline = load_json_cached(bp, copy_result=False)
else:
baseline = build_internal_test_baseline_snapshot()
+4 -4
View File
@@ -36,7 +36,7 @@ if _SRC_DIR.is_dir() and str(_SRC_DIR) not in sys.path:
sys.path.insert(0, str(_SRC_DIR))
from hyperstitionstud_io import __version__ as CURRENT_VERSION # noqa: E402
from hyperstitionstud_io.config import load_workspace_config # noqa: E402
from hyperstitionstud_io.config import load_json_cached, load_workspace_config # noqa: E402
from hyperstitionstud_io.glossary import ReadOnlyIsolationGuard # noqa: E402
from hyperstitionstud_io.ipld import compute_dag_json_cidv1 # noqa: E402
from hyperstitionstud_io.quant.timeseries import build_quant_timeseries_bundle # noqa: E402
@@ -403,7 +403,7 @@ def build_catalog_sqlite_db(db_path: Path | str | None = None) -> dict[str, Any]
# 2. Glossary Entries & Bilingual Specimens
gl_path = cfg.zoology_dir / "taxonomy" / "glossary-registry.json"
gl_data = json.loads(gl_path.read_text(encoding="utf-8"))
gl_data = load_json_cached(gl_path, copy_result=False)
seen_terms: set[str] = set()
glossary_rows = 0
@@ -500,7 +500,7 @@ def build_catalog_sqlite_db(db_path: Path | str | None = None) -> dict[str, Any]
# 3. Knowledge Graph Nodes & Edges
kg_path = cfg.knowledge_graph_dir / "encyclopedia-graph.json"
kg_data = json.loads(kg_path.read_text(encoding="utf-8"))
kg_data = load_json_cached(kg_path, copy_result=False)
deg_map: dict[str, int] = {}
edge_rows = 0
for e in kg_data.get("edges", []):
@@ -619,7 +619,7 @@ def build_catalog_sqlite_db(db_path: Path | str | None = None) -> dict[str, Any]
# 5. Periodic Quantitative Financial Time-Series Bars (24 Tickers x 30 UTC Days = 720 bars)
ts_path = cfg.core_dir / "site" / "quant" / "quant-timeseries.json"
if ts_path.is_file():
ts_bundle = json.loads(ts_path.read_text(encoding="utf-8"))
ts_bundle = load_json_cached(ts_path, copy_result=False)
else:
ts_bundle = build_quant_timeseries_bundle(write_files=False)
+2 -2
View File
@@ -683,7 +683,7 @@ def call_mcp_tool(name: str, arguments: dict[str, Any]) -> dict[str, Any]:
b_path = cfg.core_dir / "site" / "quant" / "daily-brief-latest.json"
if bool(arguments.get("refresh")) or not b_path.is_file():
return build_daily_portfolio_brief(allow_live_network=False, write_files=False)
return load_json_cached(b_path)
return load_json_cached(b_path, copy_result=False)
if name == "hs_inspect_engineering_and_math_docs":
from hyperstitionstud_io.publishing.engineering_docs import (
@@ -1036,7 +1036,7 @@ def call_mcp_tool(name: str, arguments: dict[str, Any]) -> dict[str, Any]:
if inc_base:
bp = get_default_baseline_cache_path()
if bp.is_file():
b_obj = json.loads(bp.read_text(encoding="utf-8"))
b_obj = load_json_cached(bp, copy_result=False)
out_cat["internal_test_baseline"] = {
"expected_version": b_obj.get("expected_version"),
"expected_mcp_tool_count": b_obj.get("expected_mcp_tool_count"),
@@ -32,7 +32,7 @@ from pathlib import Path
from typing import Any
from hyperstitionstud_io import __version__ as CURRENT_VERSION
from hyperstitionstud_io.config import load_json_cached, load_workspace_config
from hyperstitionstud_io.config import load_json_cached, load_workspace_config, normalize_workspace_relpath
from hyperstitionstud_io.db.sqlite_meta import ensure_single_layer_gzip_file, parse_size_spec_bytes
from hyperstitionstud_io.glossary import ReadOnlyIsolationGuard, sha256_file
from hyperstitionstud_io.ipld import compute_dag_json_cidv1
@@ -47,15 +47,6 @@ INACTIVE_MANIFEST_FILENAME = "inactive-archive-manifest.json"
DEFAULT_MAX_ARCHIVE_BUNDLE_BYTES = 256 * 1024 # 262,144 bytes (256 KB)
def _norm_ws_path(p: Path | str, workspace_root: str | Path | None = None) -> str:
cfg = load_workspace_config(workspace_root=workspace_root)
ws_res = str(cfg.workspace_root.resolve())
s = str(Path(p).resolve())
if s.startswith(ws_res):
return "/workspace" + s[len(ws_res):]
return str(p)
def assert_not_gematria_pipeline_source(target_path: str | Path, workspace_root: str | Path | None = None) -> Path:
"""
Hard programmatic block guaranteeing that NO file supplying any gematria, phonemic,
@@ -571,7 +562,7 @@ def _load_existing_manifest_maps(manifest_p: Path) -> tuple[dict[str, dict[str,
existing_manifest: dict[str, Any] = {}
if manifest_p.is_file():
try:
existing_manifest = load_json_cached(manifest_p)
existing_manifest = load_json_cached(manifest_p, copy_result=False)
except Exception:
existing_manifest = {}
@@ -690,8 +681,8 @@ def rotate_docs_archive_directory(
staged_files = sorted(p for p in stage_dir.iterdir() if p.is_file() and p.suffix == ".md")
if not staged_files and not long_term_by_name:
return {
"archive_dir": _norm_ws_path(arc_p),
"bundle_path": _norm_ws_path(bundle_p),
"archive_dir": normalize_workspace_relpath(arc_p),
"bundle_path": normalize_workspace_relpath(bundle_p),
"member_count": 0,
"rotated_loose_files": 0,
"preserved_standalone_pdfs": preserved_standalone_pdfs,
@@ -720,9 +711,9 @@ def rotate_docs_archive_directory(
lp.unlink()
return {
"archive_dir": _norm_ws_path(arc_p),
"bundle_path": _norm_ws_path(bundle_p),
"manifest_path": _norm_ws_path(manifest_p),
"archive_dir": normalize_workspace_relpath(arc_p),
"bundle_path": normalize_workspace_relpath(bundle_p),
"manifest_path": normalize_workspace_relpath(manifest_p),
"manifest_dag_json_cid": manifest_cid,
"max_bundle_bytes": eff_max_bytes,
"bundle_size_bytes": bundle_p.stat().st_size,
@@ -815,8 +806,8 @@ def rotate_inactive_plans_marked_for_archival(
if not staged_files and not long_term_by_name:
return {
"ok": True,
"inactive_dir": _norm_ws_path(inactive_dir, workspace_root=workspace_root),
"bundle_path": _norm_ws_path(bundle_p, workspace_root=workspace_root),
"inactive_dir": normalize_workspace_relpath(inactive_dir, workspace_root=workspace_root),
"bundle_path": normalize_workspace_relpath(bundle_p, workspace_root=workspace_root),
"member_count": 0,
"rotated_loose_files": 0,
"retained_inactive_plans": retained_inactive_plans,
@@ -843,9 +834,9 @@ def rotate_inactive_plans_marked_for_archival(
return {
"ok": True,
"version": CURRENT_VERSION,
"inactive_dir": _norm_ws_path(inactive_dir, workspace_root=workspace_root),
"bundle_path": _norm_ws_path(bundle_p, workspace_root=workspace_root),
"manifest_path": _norm_ws_path(manifest_p, workspace_root=workspace_root),
"inactive_dir": normalize_workspace_relpath(inactive_dir, workspace_root=workspace_root),
"bundle_path": normalize_workspace_relpath(bundle_p, workspace_root=workspace_root),
"manifest_path": normalize_workspace_relpath(manifest_p, workspace_root=workspace_root),
"manifest_dag_json_cid": manifest_cid,
"bundle_size_bytes": bundle_p.stat().st_size,
"bundle_sha256": bundle_sha,
@@ -981,10 +972,10 @@ def audit_and_fix_multi_compressed_files(
fp.unlink()
else:
fp.rename(base_p)
removed_double_sidecars.append(_norm_ws_path(fp, workspace_root=workspace_root))
removed_double_sidecars.append(normalize_workspace_relpath(fp, workspace_root=workspace_root))
continue
else:
removed_double_sidecars.append(_norm_ws_path(fp, workspace_root=workspace_root))
removed_double_sidecars.append(normalize_workspace_relpath(fp, workspace_root=workspace_root))
if fn.endswith((".gz", ".tgz")):
scanned_gz_count += 1
@@ -996,7 +987,7 @@ def audit_and_fix_multi_compressed_files(
if head.startswith((b"\x1f\x8b", b"\xfd7zXZ\x00")):
if fix:
ensure_single_layer_gzip_file(fp)
peeled_gzip_files.append(_norm_ws_path(fp, workspace_root=workspace_root))
peeled_gzip_files.append(normalize_workspace_relpath(fp, workspace_root=workspace_root))
if fn.endswith((".tar.gz", ".tgz", ".tar.xz")):
scanned_tar_count += 1
@@ -1025,12 +1016,12 @@ def audit_and_fix_multi_compressed_files(
elif bad_members and fix and fn.startswith("ingglish-isopsephic-exegesis-") and fn.endswith((".tar.gz", ".tar.xz")):
# Remove legacy 2x-compressed packaging wrapper if still present in an unpulled/live directory
fp.unlink()
removed_double_sidecars.append(_norm_ws_path(fp, workspace_root=workspace_root))
removed_double_sidecars.append(normalize_workspace_relpath(fp, workspace_root=workspace_root))
bad_members = []
if bad_members:
nested_archive_violations.append(
{
"archive": _norm_ws_path(fp, workspace_root=workspace_root),
"archive": normalize_workspace_relpath(fp, workspace_root=workspace_root),
"nested_compressed_members": bad_members,
}
)
@@ -1150,7 +1141,7 @@ def main(argv: list[str] | None = None) -> int:
):
mp = d / mf
if mp.is_file():
out[_norm_ws_path(d, workspace_root=args.workspace_root)] = load_json_cached(mp)
out[normalize_workspace_relpath(d, workspace_root=args.workspace_root)] = load_json_cached(mp, copy_result=False)
print(json.dumps(out, indent=2))
return 0
@@ -30,12 +30,15 @@ from typing import Any
from PIL import Image, ImageDraw
from hyperstitionstud_io import __version__ as CURRENT_VERSION
from hyperstitionstud_io.config import load_json_cached, load_workspace_config
from hyperstitionstud_io.config import count_file_lines_cached, load_json_cached, load_workspace_config
from hyperstitionstud_io.glossary import ReadOnlyIsolationGuard
from hyperstitionstud_io.ipld import compute_dag_json_cidv1
from hyperstitionstud_io.publishing.fonts import (
GROUP3_PALETTE,
draw_bounded_box_text,
draw_bounded_kv_row,
draw_group3_chamfered_plate,
fit_pillow_text_to_width,
load_pillow_font,
)
@@ -126,17 +129,15 @@ def _fit_font_for_width(
min_size: int = 8,
bold: bool = False,
) -> tuple[Any, int, int]:
font_file = FONT_MONO_B if bold else FONT_MONO
for sz in range(preferred_size, min_size - 1, -1):
f = _fnt(font_file, sz)
tb = d.textbbox((0, 0), text, font=f)
w = int(tb[2] - tb[0])
h = int(tb[3] - tb[1])
if w <= max_width:
return f, w, h
f = _fnt(font_file, min_size)
tb = d.textbbox((0, 0), text, font=f)
return f, int(tb[2] - tb[0]), int(tb[3] - tb[1])
return fit_pillow_text_to_width(
d,
text,
max_width,
preferred_size=preferred_size,
min_size=min_size,
bold=bold,
font_filename=FONT_MONO_B if bold else FONT_MONO,
)
def _draw_box_text(
@@ -152,18 +153,19 @@ def _draw_box_text(
bold: bool = False,
y_pos: int | None = None,
) -> tuple[int, int, int, int]:
bx1, by1, bx2, by2 = box
avail_w = max(16, (bx2 - bx1) - 2 * pad_x)
f, tw, th = _fit_font_for_width(d, text, avail_w, preferred_size=preferred_size, min_size=min_size, bold=bold)
if align == "center":
tx = bx1 + max(pad_x, ((bx2 - bx1) - tw) // 2)
elif align == "right":
tx = max(bx1 + pad_x, bx2 - pad_x - tw)
else:
tx = bx1 + pad_x
ty = y_pos if y_pos is not None else (by1 + max(2, ((by2 - by1) - th) // 2 - 1))
d.text((tx, ty), text, font=f, fill=fill)
return d.texts[-1][2]
return draw_bounded_box_text(
d,
box,
text,
fill,
pad_x=pad_x,
align=align,
preferred_size=preferred_size,
min_size=min_size,
bold=bold,
y_pos=y_pos,
font_filename=FONT_MONO_B if bold else FONT_MONO,
)
def _draw_kv_row(
@@ -181,22 +183,20 @@ def _draw_kv_row(
val_bold: bool = False,
min_val_x: int | None = None,
) -> None:
bx1, by1, bx2, by2 = box
d.rectangle([bx1, by1, bx2, by2], fill=fill_bg, outline=outline)
total_inner = (bx2 - bx1) - 16
kf, kw, kh = _fit_font_for_width(d, key_text, max(40, int(total_inner * 0.52)), preferred_size=key_size, min_size=8, bold=True)
ky = by1 + max(2, ((by2 - by1) - kh) // 2 - 1)
kx = bx1 + 8
d.text((kx, ky), key_text, font=kf, fill=key_fill)
key_tb = d.texts[-1][2]
vx_start = max(key_tb[2] + 8, min_val_x if min_val_x is not None else (key_tb[2] + 10))
avail_val_w = max(24, (bx2 - 6) - vx_start)
vf, vw, vh = _fit_font_for_width(d, val_text, avail_val_w, preferred_size=val_size, min_size=8, bold=val_bold)
if vx_start + vw > bx2 - 6:
vx_start = max(key_tb[2] + 6, (bx2 - 6) - vw)
vy = by1 + max(2, ((by2 - by1) - vh) // 2 - 1)
d.text((vx_start, vy), val_text, font=vf, fill=val_fill)
draw_bounded_kv_row(
d,
box,
key_text,
val_text,
fill_bg=fill_bg,
outline=outline,
key_fill=key_fill,
val_fill=val_fill,
key_size=key_size,
val_size=val_size,
val_bold=val_bold,
min_val_x=min_val_x,
)
def verify_closeup_geometry(tracked_by_filename: dict[str, _TrackedCanvasDraw]) -> dict[str, Any]:
@@ -408,7 +408,7 @@ def introspect_live_ui_elements(workspace_root: str | Path | None = None) -> dic
}
db_txt_p = calc_dir / "db.txt"
db_entries_count = sum(1 for _ in db_txt_p.open(encoding="utf-8")) if db_txt_p.is_file() else 231615
db_entries_count = count_file_lines_cached(db_txt_p) if db_txt_p.is_file() else 231615
ci_rep_p = ci_dir / "ci-audit-report.json"
ci_obj = load_json_cached(ci_rep_p, copy_result=False) if ci_rep_p.is_file() else {}
@@ -486,7 +486,7 @@ def render_all_quadrant_closeups(
prev_fp = ""
if manifest_path.is_file():
try:
prev_obj = json.loads(manifest_path.read_text(encoding="utf-8"))
prev_obj = load_json_cached(manifest_path, copy_result=False)
prev_fp = prev_obj.get("ui_elements_fingerprint_sha256", "")
except Exception:
prev_fp = ""
@@ -9,6 +9,7 @@ clamping (`breach_count == 0`).
from __future__ import annotations
import hashlib
import json
import os
from pathlib import Path
@@ -20,6 +21,7 @@ from hyperstitionstud_io.publishing.fonts import (
GROUP3_PALETTE,
chamfer_polygon_points as _chamfer_pts,
draw_group3_chamfered_plate as _draw_group3_plate,
fit_pillow_text_to_width,
load_pillow_font,
)
@@ -55,18 +57,48 @@ def _draw_arrow_right(draw: Any, x0: int, x1: int, y: int, color: tuple[int, int
draw.polygon([(x1 - 10, y - 5), (x1 - 10, y + 5), (x1, y)], fill=color)
def _compute_flow_diagram_sha256() -> str:
src_bytes = Path(__file__).resolve().read_bytes()
h = hashlib.sha256()
h.update(f"v{CURRENT_VERSION}:{DIAGRAM_WIDTH}x{DIAGRAM_HEIGHT}:".encode("utf-8"))
h.update(src_bytes)
return h.hexdigest()
def render_periodic_harvest_cicd_flow_diagram_png(
output_path: str | Path | None = None,
*,
if_changed: bool = True,
) -> dict[str, Any]:
"""
Render the 5-Stage End-to-End Periodic Data Harvest -> CI/CD -> Deployed VPS Infrastructure Flow Diagram
to `/workspace/encyclopedia-knowledge-graph/docs/periodic-harvest-cicd-to-vps-flow-diagram.png`.
When `if_changed=True` and the existing PNG embeds a matching `hs_diagram_sha256` tEXt chunk,
skips rewriting the file.
"""
from PIL import Image, ImageDraw
from PIL.PngImagePlugin import PngInfo
cfg = load_workspace_config()
out_p = Path(output_path) if output_path else (cfg.knowledge_graph_dir / "docs" / "periodic-harvest-cicd-to-vps-flow-diagram.png")
out_p = out_p.resolve()
diagram_sha256 = _compute_flow_diagram_sha256()
if if_changed and out_p.is_file():
try:
with Image.open(out_p) as existing_im:
if existing_im.info.get("hs_diagram_sha256") == diagram_sha256:
return {
"png_path": str(out_p),
"dimensions": [DIAGRAM_WIDTH, DIAGRAM_HEIGHT],
"size_bytes": out_p.stat().st_size,
"breach_count": 0,
"skipped_unchanged": True,
"hs_diagram_sha256": diagram_sha256,
}
except Exception:
pass
out_p.parent.mkdir(parents=True, exist_ok=True)
tmp_p = out_p.with_suffix(f".tmp.{os.getpid()}.png")
@@ -381,13 +413,17 @@ def render_periodic_harvest_cicd_flow_diagram_png(
fit_text(bbox[0] + 12, ly, ln, TXT_PRI, [f_m11, f_m10], max_x=bbox[2] - 10)
ly += 20
img.save(tmp_p, format="PNG")
pnginfo = PngInfo()
pnginfo.add_text("hs_diagram_sha256", diagram_sha256)
img.save(tmp_p, format="PNG", pnginfo=pnginfo)
os.replace(tmp_p, out_p)
return {
"png_path": str(out_p),
"dimensions": [DIAGRAM_WIDTH, DIAGRAM_HEIGHT],
"size_bytes": out_p.stat().st_size,
"breach_count": breach_count,
"skipped_unchanged": False,
"hs_diagram_sha256": diagram_sha256,
}
@@ -20,7 +20,7 @@ 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.config import load_json_cached, load_workspace_config
from hyperstitionstud_io.glossary import ReadOnlyIsolationGuard
from hyperstitionstud_io.ipld import compute_dag_json_cidv1
from hyperstitionstud_io.mcp.tools import MCP_TOOLS_SCHEMA
@@ -44,7 +44,7 @@ def compute_corpus_delta_report(workspace_root: str | Path | None = None) -> dic
prior_snap = cur_snap
if cache_p.is_file():
try:
prior_snap = json.loads(cache_p.read_text(encoding="utf-8"))
prior_snap = load_json_cached(cache_p, copy_result=False)
except Exception:
prior_snap = cur_snap
@@ -39,7 +39,7 @@ 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.config import load_json_cached, load_workspace_config
from hyperstitionstud_io.glossary import ReadOnlyIsolationGuard
from hyperstitionstud_io.phonetics import translate_batch
@@ -393,7 +393,7 @@ def build_quant_tour_voice_assets(
prev_clips_by_id: dict[str, dict[str, Any]] = {}
if not force and manifest_p.is_file():
try:
prev_man = json.loads(manifest_p.read_text(encoding="utf-8"))
prev_man = load_json_cached(manifest_p, copy_result=False)
for c_item in prev_man.get("clips") or []:
cid = str(c_item.get("clip_id") or "")
if cid and (target_dir / f"{cid}.wav").is_file():
@@ -34,7 +34,7 @@ if _SRC_DIR.is_dir() and str(_SRC_DIR) not in sys.path:
sys.path.insert(0, str(_SRC_DIR))
from hyperstitionstud_io import __version__ as CURRENT_VERSION # noqa: E402
from hyperstitionstud_io.config import load_workspace_config, resolve_workspace_repo_dir # noqa: E402
from hyperstitionstud_io.config import load_workspace_config, resolve_workspace_repo_dir, run_git_stdout # noqa: E402
STATUS_START = "<!-- HS-COMMIT-STATUS:START -->"
STATUS_END = "<!-- HS-COMMIT-STATUS:END -->"
@@ -73,22 +73,6 @@ REPO_SPECS: dict[str, dict[str, str]] = {
}
def _git_out(repo_dir: Path, args: list[str], strip_leading: bool = True) -> str:
try:
res = subprocess.run(
["git", "-C", str(repo_dir), *args],
capture_output=True,
text=True,
timeout=5,
check=False,
)
if res.returncode == 0:
return res.stdout.strip() if strip_leading else res.stdout.rstrip("\r\n")
except Exception:
pass
return ""
def _resolve_repo_dir(ws_root: Path, repo_key: str) -> Path:
return resolve_workspace_repo_dir(ws_root, repo_key)
@@ -106,11 +90,11 @@ def _introspect_repo_commit_context(repo_dir: Path, version: str) -> dict[str, A
}
# Check staged files first (for pre-commit hook)
staged_raw = _git_out(repo_dir, ["diff", "--cached", "--name-only"])
staged_raw = run_git_stdout(repo_dir, ["diff", "--cached", "--name-only"])
staged = [ln.strip() for ln in staged_raw.splitlines() if ln.strip() and ln.strip() != "README.md"]
# Check working-tree modified files next (preserve leading status column on line 1!)
status_raw = _git_out(repo_dir, ["status", "--porcelain"], strip_leading=False)
status_raw = run_git_stdout(repo_dir, ["status", "--porcelain"], strip_leading=False)
dirty: list[str] = []
for ln in status_raw.splitlines():
if not ln.strip():
@@ -119,7 +103,7 @@ def _introspect_repo_commit_context(repo_dir: Path, version: str) -> dict[str, A
if p and p != "README.md" and not p.startswith("untracked/"):
dirty.append(p)
head_files_raw = _git_out(repo_dir, ["diff-tree", "--no-commit-id", "--name-only", "-r", "HEAD"])
head_files_raw = run_git_stdout(repo_dir, ["diff-tree", "--no-commit-id", "--name-only", "-r", "HEAD"])
head_files = [ln.strip() for ln in head_files_raw.splitlines() if ln.strip() and ln.strip() != "README.md"]
active_files = staged if staged else (dirty if dirty else head_files)
@@ -488,8 +472,8 @@ def sync_all_repo_readmes(
PRE_COMMIT_HOOK_SCRIPT = """#!/usr/bin/env bash
# Auto-installed by hyperstitionstud_io.publishing.readme_sync (hs-readme-sync --install-hooks)
# Prepares & validates push-all-to-git-libre-audio.sh and deploy/sync-vps-repos.sh (Gates D1-D8),
# re-renders homepage UI closeups when page UI elements change, and synchronizes root README.md before every commit.
# Path-aware pre-commit hook: runs deploy_scripts_sync & closeups_sync only when staged files
# affect their respective surfaces, and synchronizes root README.md + shorthand_lint before every commit.
set -euo pipefail
REPO_ROOT="$(git rev-parse --show-toplevel)"
@@ -506,15 +490,20 @@ fi
if [[ -d "${CORE_SRC}" ]]; then
export PYTHONPATH="${CORE_SRC}${PYTHONPATH:+:${PYTHONPATH}}"
STAGED_FILES="$(git -C "${REPO_ROOT}" diff --cached --name-only || true)"
if [[ "${REPO_NAME}" == "hyperstitionstudio-core" ]]; then
if printf '%s\n' "${STAGED_FILES}" | grep -Eq '^(deploy/|pyproject\\.toml|src/hyperstitionstud_io/__init__\\.py)'; then
"${PYTHON_BIN}" -m hyperstitionstud_io.ci.deploy_scripts_sync --workspace-root "${WS_ROOT}" --stage
else
"${PYTHON_BIN}" -m hyperstitionstud_io.ci.deploy_scripts_sync --workspace-root "${WS_ROOT}"
"${PYTHON_BIN}" -m hyperstitionstud_io.ci.deploy_scripts_sync --workspace-root "${WS_ROOT}" --check
fi
fi
if printf '%s\n' "${STAGED_FILES}" | grep -Eq '(^site/|^index\\.html$|^config\\.default\\.js$|^ci-audit-report\\.json$|^src/hyperstitionstud_io/(publishing|quant)/)'; then
"${PYTHON_BIN}" -m hyperstitionstud_io.publishing.closeups_sync
if [[ -d "${WS_ROOT}/hyperstitionstudio-core/site/assets/closeups" ]] && [[ "${REPO_NAME}" == "hyperstitionstudio-core" ]]; then
git -C "${REPO_ROOT}" add site/assets/closeups/
fi
fi
"${PYTHON_BIN}" -m hyperstitionstud_io.publishing.readme_sync --repo "${REPO_NAME}" --stage
"${PYTHON_BIN}" -m hyperstitionstud_io.ci.shorthand_lint --staged-diff --repo "${REPO_ROOT}"
fi
+11 -11
View File
@@ -39,7 +39,7 @@ from hyperstitionstud_io.ciphers import ( # noqa: E402
is_repdigit_37,
prime_rank,
)
from hyperstitionstud_io.config import load_workspace_config # noqa: E402
from hyperstitionstud_io.config import load_json_cached, load_workspace_config # noqa: E402
from hyperstitionstud_io.glossary import ReadOnlyIsolationGuard # noqa: E402
from hyperstitionstud_io.ipld import ( # noqa: E402
compute_dag_json_cidv1,
@@ -377,7 +377,7 @@ def _load_real_history_latest_bars() -> dict[str, dict[str, Any]]:
if not hist_path.is_file():
return {}
try:
raw = json.loads(hist_path.read_text(encoding="utf-8"))
raw = load_json_cached(hist_path, copy_result=False)
out: dict[str, dict[str, Any]] = {}
for sym, sym_obj in (raw.get("instruments") or {}).items():
bars_by_date = sym_obj.get("bars_by_date") or {}
@@ -471,7 +471,7 @@ def build_financial_quant_harvest(
cfg = load_workspace_config()
with ReadOnlyIsolationGuard(cfg.read_only_files) as guard:
if snapshot_path and Path(snapshot_path).is_file():
raw_watchlist = json.loads(Path(snapshot_path).read_text(encoding="utf-8"))
raw_watchlist = load_json_cached(snapshot_path, copy_result=False)
else:
raw_watchlist = fetch_live_watchlist(
CANONICAL_WATCHLIST_24,
@@ -497,7 +497,7 @@ def build_financial_quant_harvest(
news_entities: dict[str, list[str]] = {}
if effective_news_path.is_file():
try:
news_obj = json.loads(effective_news_path.read_text(encoding="utf-8"))
news_obj = load_json_cached(effective_news_path, copy_result=False)
headline_records: list[str] = []
for st in news_obj.get("stories", news_obj.get("headlines", [])):
if isinstance(st, dict):
@@ -856,7 +856,7 @@ def update_real_market_history_cache(
cfg = load_workspace_config()
h_path = Path(history_path) if history_path else (cfg.core_dir / "site" / "quant" / "real-market-history.json")
if h_path.is_file():
doc = json.loads(h_path.read_text(encoding="utf-8"))
doc = load_json_cached(h_path, copy_result=True)
else:
doc = {"version": CURRENT_VERSION, "synthetic_data_eliminated": True, "instruments": {}}
@@ -1034,7 +1034,7 @@ def snapshot_local_telemetry(
src = q_dir / fname
if src.is_file():
try:
json.loads(src.read_text(encoding="utf-8"))
load_json_cached(src, copy_result=False)
shutil.copy2(src, s_dir / fname)
saved.append(fname)
except Exception:
@@ -1046,7 +1046,7 @@ def snapshot_local_telemetry(
snap_rmh_p = s_dir / "real-market-history.json"
if snap_rmh_p.is_file():
try:
base_rmh = json.loads(snap_rmh_p.read_text(encoding="utf-8"))
base_rmh = load_json_cached(snap_rmh_p, copy_result=True)
insts = base_rmh.setdefault("instruments", {})
for hist_doc in _excavate_git_json_versions(cfg.core_dir, "site/quant/real-market-history.json"):
for sym, s_obj in (hist_doc.get("instruments") or {}).items():
@@ -1102,8 +1102,8 @@ def reconcile_telemetry_snapshot(
cur_hist_p = q_dir / "real-market-history.json"
if snap_hist_p.is_file() and cur_hist_p.is_file():
try:
snap_hist = json.loads(snap_hist_p.read_text(encoding="utf-8"))
cur_hist = json.loads(cur_hist_p.read_text(encoding="utf-8"))
snap_hist = load_json_cached(snap_hist_p, copy_result=False)
cur_hist = load_json_cached(cur_hist_p, copy_result=True)
cur_insts = cur_hist.setdefault("instruments", {})
for sym, snap_obj in (snap_hist.get("instruments") or {}).items():
if sym == "ANTHR-PVT":
@@ -1139,8 +1139,8 @@ def reconcile_telemetry_snapshot(
cur_macro_p = q_dir / "real-macro-indicators.json"
if snap_macro_p.is_file() and cur_macro_p.is_file():
try:
snap_macro = json.loads(snap_macro_p.read_text(encoding="utf-8"))
cur_macro = json.loads(cur_macro_p.read_text(encoding="utf-8"))
snap_macro = load_json_cached(snap_macro_p, copy_result=False)
cur_macro = load_json_cached(cur_macro_p, copy_result=True)
cur_series = cur_macro.setdefault("series", {})
for s_key, snap_s in (snap_macro.get("series") or {}).items():
if s_key not in cur_series or not isinstance(snap_s, dict):
+2 -2
View File
@@ -19,7 +19,7 @@ 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.config import load_json_cached, load_workspace_config
from hyperstitionstud_io.glossary import ReadOnlyIsolationGuard
from hyperstitionstud_io.ipld import compute_dag_json_cidv1
from hyperstitionstud_io.quant.collector import NO_DATA_AVAILABLE
@@ -186,7 +186,7 @@ def build_daily_portfolio_brief(
active_read_state_path = state_path if state_path.is_file() else next((p for p in legacy_state_paths if p.is_file()), state_path)
if active_read_state_path.is_file():
try:
prior_state = json.loads(active_read_state_path.read_text(encoding="utf-8"))
prior_state = load_json_cached(active_read_state_path, copy_result=False)
except Exception:
prior_state = {}
+2 -2
View File
@@ -19,7 +19,7 @@ from typing import Any
from hyperstitionstud_io import __version__ as CURRENT_VERSION
from hyperstitionstud_io.ciphers import compute_aq, int_to_spoken_words, prime_rank
from hyperstitionstud_io.config import load_workspace_config
from hyperstitionstud_io.config import load_json_cached, load_workspace_config
from hyperstitionstud_io.glossary import ReadOnlyIsolationGuard
from hyperstitionstud_io.ipld import compute_dag_json_cidv1
from hyperstitionstud_io.phonetics import translate_batch
@@ -328,7 +328,7 @@ def build_macro_indicators_bundle(
cached_bundle: dict[str, Any] = {}
if cache_path.is_file():
try:
cached_bundle = json.loads(cache_path.read_text(encoding="utf-8"))
cached_bundle = load_json_cached(cache_path, copy_result=False)
except Exception:
cached_bundle = {}
+3 -3
View File
@@ -31,7 +31,7 @@ from hyperstitionstud_io.ciphers import (
is_repdigit_37,
prime_rank,
)
from hyperstitionstud_io.config import load_workspace_config
from hyperstitionstud_io.config import load_json_cached, load_workspace_config
from hyperstitionstud_io.glossary import ReadOnlyIsolationGuard
from hyperstitionstud_io.ipld import compute_dag_json_cidv1, write_pretty_and_dag_json
from hyperstitionstud_io.lenses import DEFAULT_LENS, ENABLED_LENSES, LENS_REGISTRY, apply_all_lenses
@@ -256,7 +256,7 @@ def _load_real_market_history_bars(cfg: Any) -> dict[str, dict[str, dict[str, An
if not hist_path.is_file():
return {}
try:
raw = json.loads(hist_path.read_text(encoding="utf-8"))
raw = load_json_cached(hist_path, copy_result=False)
out: dict[str, dict[str, dict[str, Any]]] = {}
for sym, sym_obj in (raw.get("instruments") or {}).items():
out[sym] = dict(sym_obj.get("bars_by_date") or {})
@@ -809,7 +809,7 @@ def build_quant_timeseries_bundle(
tl_path = cfg.zoology_dir / "taxonomy" / "assemblage-builds-tier-list.json"
builds_out: list[dict[str, Any]] = []
if tl_path.is_file():
tl_data = json.loads(tl_path.read_text(encoding="utf-8"))
tl_data = load_json_cached(tl_path, copy_result=False)
for row in tl_data.get("rows", []):
s6 = row.get("stats_6") or {}
b_struct = {
+13 -25
View File
@@ -22,7 +22,7 @@ if _SRC_DIR.is_dir() and str(_SRC_DIR) not in sys.path:
sys.path.insert(0, str(_SRC_DIR))
from hyperstitionstud_io import __version__ as CURRENT_VERSION # noqa: E402
from hyperstitionstud_io.config import load_workspace_config # noqa: E402
from hyperstitionstud_io.config import load_workspace_config, run_git_stdout # noqa: E402
SEMVER_RE = r"\d+\.\d+\.\d+"
@@ -122,18 +122,6 @@ def evaluate_change_scope_heuristics(signals: dict[str, Any]) -> dict[str, Any]:
}
def _git_run(repo_dir: Path, args: list[str]) -> str:
if not (repo_dir / ".git").exists():
return ""
proc = subprocess.run(
["git", "-C", str(repo_dir), *args],
capture_output=True,
text=True,
check=False,
)
return proc.stdout.strip() if proc.returncode == 0 else ""
def _extract_archived_plan_ids_from_text(text: str) -> set[str]:
return set(re.findall(r"\bPLAN-[A-Z0-9-]+\b", text))
@@ -165,7 +153,7 @@ def collect_workspace_change_signals(ws_root: Path | None = None) -> dict[str, A
if m_v:
current_v = m_v.group(1)
baseline_tag = _git_run(core, ["describe", "--tags", "--abbrev=0"]) or f"v{current_v}"
baseline_tag = run_git_stdout(core, ["describe", "--tags", "--abbrev=0"]) or f"v{current_v}"
repo_dirs = [
core,
@@ -181,12 +169,12 @@ def collect_workspace_change_signals(ws_root: Path | None = None) -> dict[str, A
for rdir in repo_dirs:
if not rdir.is_dir():
continue
porcelain = _git_run(rdir, ["status", "--porcelain"])
porcelain = run_git_stdout(rdir, ["status", "--porcelain"])
dirty_cnt = len([ln for ln in porcelain.splitlines() if ln.strip()]) if porcelain else 0
rtag = _git_run(rdir, ["describe", "--tags", "--abbrev=0"])
rtag = run_git_stdout(rdir, ["describe", "--tags", "--abbrev=0"])
ahead_cnt = 0
if rtag:
ahead_str = _git_run(rdir, ["rev-list", f"{rtag}..HEAD", "--count"])
ahead_str = run_git_stdout(rdir, ["rev-list", f"{rtag}..HEAD", "--count"])
ahead_cnt = int(ahead_str) if ahead_str.isdigit() else 0
repo_diff_summary[rdir.name] = {
"dirty_files": dirty_cnt,
@@ -209,15 +197,15 @@ def collect_workspace_change_signals(ws_root: Path | None = None) -> dict[str, A
current_archived_plans |= _extract_archived_plan_ids_from_text(p.name)
baseline_archived_plans: set[str] = set()
kg_tag = _git_run(kg, ["describe", "--tags", "--abbrev=0"]) or baseline_tag
kg_tag = run_git_stdout(kg, ["describe", "--tags", "--abbrev=0"]) or baseline_tag
if kg_tag:
old_manifest = _git_run(kg, ["show", f"{kg_tag}:docs/archive/archive-manifest.json"])
old_manifest = run_git_stdout(kg, ["show", f"{kg_tag}:docs/archive/archive-manifest.json"])
if old_manifest:
baseline_archived_plans |= _extract_archived_plan_ids_from_text(old_manifest)
old_readme = _git_run(kg, ["show", f"{kg_tag}:docs/archive/README.md"])
old_readme = run_git_stdout(kg, ["show", f"{kg_tag}:docs/archive/README.md"])
if old_readme:
baseline_archived_plans |= _extract_archived_plan_ids_from_text(old_readme)
old_ls = _git_run(kg, ["ls-tree", "--name-only", kg_tag, "docs/archive/"])
old_ls = run_git_stdout(kg, ["ls-tree", "--name-only", kg_tag, "docs/archive/"])
if old_ls:
baseline_archived_plans |= _extract_archived_plan_ids_from_text(old_ls)
@@ -239,22 +227,22 @@ def collect_workspace_change_signals(ws_root: Path | None = None) -> dict[str, A
# 3. CLI entrypoints (`pyproject.toml`), MCP tools (`mcp/tools.py`), JSON schemas (`schemas/v1/`), & subpages (`site/<slug>/index.html`)
pyproj_p = core / "pyproject.toml"
cur_scripts = _extract_cli_scripts_from_pyproject(pyproj_p.read_text(encoding="utf-8")) if pyproj_p.is_file() else set()
old_pyproj = _git_run(core, ["show", f"{baseline_tag}:pyproject.toml"])
old_pyproj = run_git_stdout(core, ["show", f"{baseline_tag}:pyproject.toml"])
old_scripts = _extract_cli_scripts_from_pyproject(old_pyproj) if old_pyproj else cur_scripts
tools_p = core / "src" / "hyperstitionstud_io" / "mcp" / "tools.py"
cur_tools = _extract_mcp_tool_names(tools_p.read_text(encoding="utf-8")) if tools_p.is_file() else set()
old_tools_txt = _git_run(core, ["show", f"{baseline_tag}:src/hyperstitionstud_io/mcp/tools.py"])
old_tools_txt = run_git_stdout(core, ["show", f"{baseline_tag}:src/hyperstitionstud_io/mcp/tools.py"])
old_tools = _extract_mcp_tool_names(old_tools_txt) if old_tools_txt else cur_tools
schemas_dir = core / "schemas" / "v1"
cur_schemas = {p.name for p in schemas_dir.glob("*.schema.json")} if schemas_dir.is_dir() else set()
old_schemas_ls = _git_run(core, ["ls-tree", "--name-only", baseline_tag, "schemas/v1/"])
old_schemas_ls = run_git_stdout(core, ["ls-tree", "--name-only", baseline_tag, "schemas/v1/"])
old_schemas = {Path(ln).name for ln in old_schemas_ls.splitlines() if ln.endswith(".schema.json")} if old_schemas_ls else cur_schemas
site_dir = core / "site"
cur_subpages = {p.parent.name for p in site_dir.glob("*/index.html")} if site_dir.is_dir() else set()
old_site_ls = _git_run(core, ["ls-tree", "-r", "--name-only", baseline_tag, "site/"])
old_site_ls = run_git_stdout(core, ["ls-tree", "-r", "--name-only", baseline_tag, "site/"])
old_subpages = {
Path(ln).parts[1]
for ln in old_site_ls.splitlines()
+4 -1
View File
@@ -1465,7 +1465,10 @@ def test_ipld_quant_and_mcp_server() -> None:
cfg.archive_dir / "packaging" / "bundle" / "scripts" / "ci_provision_ingglish.py",
cfg.archive_dir / "packaging" / "bundle" / "skills" / "hyperdope-ingglish-ci" / "scripts" / "ci_provision_ingglish.py",
):
assert ci_prov_mirror.read_text(encoding="utf-8") == ci_prov_txt, f"Out-of-sync ci_provision_ingglish.py mirror: {ci_prov_mirror}"
mirror_txt = ci_prov_mirror.read_text(encoding="utf-8")
assert len(mirror_txt.splitlines()) <= 40 and "runpy.run_path" in mirror_txt and "ci_provision_ingglish.py" in mirror_txt, (
f"Expected thin delegator wrapper for {ci_prov_mirror}"
)
# Verify Plan #58: Pre-Commit Preparation & Gates DEPLOY-GATE-D01.MIRROR_PARITY..DEPLOY-GATE-D08.PRE_COMMIT_STAGE for push-all-to-git-libre-audio.sh & deploy/sync-vps-repos.sh
from hyperstitionstud_io.ci.deploy_scripts_sync import prepare_and_verify_deploy_scripts