feat(core): implement Plan #62 efficiency, deduplication, caching & hook optimizations
This commit is contained in:
1 parent
d4b7502501
commit
9b587d6351
20 files changed
+176
-195
No files matched your search
@@ -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):
|
||||
|
||||
Reference in new issue
Block a user