feat(quant): implement Plan #72 pre-market-open daily brief & dual-calendar VPS cadence

This commit is contained in:
Hermes Agent committed 2026-12-02 22:09:58 +00:00
1 parent 3945e3648a
commit d4b7502501
8 files changed
+165 -16

No files matched your search

+61
View File
@@ -950,6 +950,10 @@ def test_ipld_quant_and_mcp_server() -> None:
vps_prod_sh = cfg_test.core_dir / "deploy" / "run-vps-data-production.sh"
assert vps_prod_sh.is_file() and "/dev/null" not in vps_prod_sh.read_text(encoding="utf-8")
vps_prod_txt = vps_prod_sh.read_text(encoding="utf-8")
assert "--window=auto" in vps_prod_txt or '--window=*' in vps_prod_txt
assert "us-pre-market-open" in vps_prod_txt
assert '--window "${WINDOW_MODE}"' in vps_prod_txt
for u_name in (
"hyperstition-closing-bell-harvest.service",
"hyperstition-closing-bell-harvest.timer",
@@ -958,6 +962,63 @@ def test_ipld_quant_and_mcp_server() -> None:
):
assert (cfg_test.core_dir / "deploy" / u_name).is_file()
# Verify Plan #72: Dual-Calendar Pre-Market-Open Timer & Session-Window Brief Deduplication
cb_timer_txt = (cfg_test.core_dir / "deploy" / "hyperstition-closing-bell-harvest.timer").read_text(encoding="utf-8")
assert "OnCalendar=Mon..Fri *-*-* 14:00:00 UTC" in cb_timer_txt
assert "OnCalendar=Mon..Fri *-*-* 21:30:00 UTC" in cb_timer_txt
cb_svc_txt = (cfg_test.core_dir / "deploy" / "hyperstition-closing-bell-harvest.service").read_text(encoding="utf-8")
assert "--window=auto" in cb_svc_txt
import datetime as _dt
from types import SimpleNamespace
from unittest.mock import patch as _mock_patch
from hyperstitionstud_io.quant.collector import build_financial_quant_harvest as _bfqh
from hyperstitionstud_io.quant.daily_brief import (
_resolve_session_window,
build_daily_portfolio_brief,
)
assert _bfqh(harvest_mode="us-pre-market-open", live_fetch=False)["harvest_mode"] == "us-pre-market-open"
assert _resolve_session_window("auto", _dt.datetime(2026, 12, 2, 14, 0, tzinfo=_dt.timezone.utc)) == "us-pre-market-open"
assert _resolve_session_window("auto", _dt.datetime(2026, 12, 2, 21, 30, tzinfo=_dt.timezone.utc)) == "us-closing-bell"
assert _resolve_session_window("auto", _dt.datetime(2026, 12, 2, 0, 5, tzinfo=_dt.timezone.utc)) == "utc-rollover"
tmp_brief_core = tmp_path / "brief_core_tmp"
(tmp_brief_core / "site" / "quant").mkdir(parents=True, exist_ok=True)
seed_hist = [
{
"run_number": idx + 1,
"session_window": "us-closing-bell",
"generated_at_utc": "",
"posterior_probabilities": {"R1_BULL_RISK_ON": 0.25, "R2_PINNED_ISOMETRIC": 0.50, "R3_TAIL_DRAWDOWN_RISK_OFF": 0.25},
"question_id": f"Q-RUN-{idx + 1:04d}",
"cidv1": f"baguqeeraseed{idx:04d}",
}
for idx in range(62)
]
# Ensure unique dates in seed_hist so none collide with each other
base_seed_dt = _dt.date(2026, 9, 1)
for idx, item in enumerate(seed_hist):
item["generated_at_utc"] = (base_seed_dt + _dt.timedelta(days=idx)).strftime("%Y-%m-%dT21:30:00Z")
(tmp_brief_core / "site" / "quant" / "daily-brief-state.json").write_text(
json.dumps({"version": "2.18.0", "run_number": 62, "run_history": seed_hist}, indent=2),
encoding="utf-8",
)
fake_cfg = SimpleNamespace(core_dir=tmp_brief_core, archive_dir=cfg_test.archive_dir, read_only_files=())
with _mock_patch("hyperstitionstud_io.quant.daily_brief.load_workspace_config", return_value=fake_cfg):
b_am = build_daily_portfolio_brief(allow_live_network=False, write_files=True, session_window="us-pre-market-open")
assert b_am["session_window"] == "us-pre-market-open"
b_pm = build_daily_portfolio_brief(allow_live_network=False, write_files=True, session_window="us-closing-bell")
assert b_pm["session_window"] == "us-closing-bell"
b_am_dup = build_daily_portfolio_brief(allow_live_network=False, write_files=True, session_window="us-pre-market-open")
assert b_am_dup["session_window"] == "us-pre-market-open"
brief_state_out = json.loads((tmp_brief_core / "site" / "quant" / "daily-brief-state.json").read_text(encoding="utf-8"))
assert len(brief_state_out["run_history"]) == 60
today_10 = b_am["generated_at_utc"][:10]
today_entries = [x for x in brief_state_out["run_history"] if x["generated_at_utc"][:10] == today_10]
assert [x["session_window"] for x in today_entries] == ["us-pre-market-open", "us-closing-bell"]
# Verify /engineering/ (hs-eng-docs) & /math/ (hs-math-docs) Piecewise & Non-Sequential Revertability
from hyperstitionstud_io.publishing.engineering_docs import build_engineering_site
from hyperstitionstud_io.publishing.math_docs import build_math_site