from pathlib import Path ROOT = Path(__file__).resolve().parents[1] HERMES_DIR = ROOT / "docs" / "hermes" def _read(path: Path) -> str: assert path.exists(), f"missing doc: {path}" return path.read_text() def test_hermes_hierarchy_indexes_memory_rules_harness_and_skill_handoff(): expected = { "README.md", "memory.md", "md_inventory.md", "rules.md", "harness.md", "skill_handoff.md", } assert expected.issubset({path.name for path in HERMES_DIR.iterdir()}) readme = _read(HERMES_DIR / "README.md") for required in [ "docs/hermes/memory.md", "docs/hermes/md_inventory.md", "docs/hermes/skill_handoff.md", "docs/hermes/rules.md", "docs/hermes/harness.md", "docs/agent_team_with_antigravity.md", "docs/agent_team_integration_summary.md", "HANDOFF.md", "Hermes must not directly change model logic", ]: assert required in readme def test_hermes_rules_protect_production_logic_files(): text = _read(HERMES_DIR / "rules.md") for required in [ "models/predictor.py", "services/recommendation_service.py", "services/predictor_service.py", "routers/stock.py", "scripts/precompute_hot20.py", "scripts/precompute_queried_stocks.py", "docs/validation_registry.json", "Run no-lookahead backward validation", "Ask for explicit user approval", ".env.telegram", ".env.wandb", ]: assert required in text def test_hermes_harness_documents_smoke_and_no_regression_commands(): text = _read(HERMES_DIR / "harness.md") for required in [ "venv/bin/python -m py_compile", "scripts/telegram_bot_wrapper.py", "scripts/send_experiment_notification.py", "scripts/data_quality_validator.py", "scripts/test_agent_integration.py", "scripts/wandb_experiment_tracker.py", "venv/bin/python scripts/telegram_bot_wrapper.py --message", "venv/bin/python scripts/data_quality_validator.py --check features", "venv/bin/python scripts/test_agent_integration.py --quiet", "venv/bin/python -m pytest tests/test_hermes_harness_docs.py", "tests/test_recommendation_service.py", "git diff --check", "No model/recommendation/precompute logic file is changed", ]: assert required in text def test_hermes_memory_records_fixed_side_effects_and_runtime_gap(): text = _read(HERMES_DIR / "memory.md") for required in [ "hermes_tools is not importable", "fallback", ".env.telegram", ".env.wandb", "parses `.env.telegram` as a key/value", "mode-specific CLI validation", "checks Antigravity CLI/config", ]: assert required in text def test_hermes_skill_handoff_keeps_helper_work_separate_from_accuracy_work(): text = _read(HERMES_DIR / "skill_handoff.md") for required in [ "personal-investment-remote", "stock-pattern-mining", "Worker A: Hermes helper utilities ownership", "Worker B: validation and data-quality ownership", "Worker C: memory and handoff ownership", "production-logic-sensitive", "closed-loop validation harness", ]: assert required in text