from pathlib import Path ROOT = Path(__file__).resolve().parents[1] AGENT_TEAM_DIR = ROOT / "docs" / "agent_team" KNOWLEDGE = ROOT / "docs" / "knowledge_architecture.md" def _read(path: Path) -> str: assert path.exists(), f"missing doc: {path}" return path.read_text(encoding="utf-8") def test_top_level_knowledge_architecture_indexes_core_layers(): text = _read(KNOWLEDGE) for required in [ "docs/hermes/", "docs/hotspot/", "docs/agent_team/", "README.md", "memory.md", "rules.md", "harness.md", "skill_handoff.md", "md_inventory.md", "no-lookahead historical validation", "explicit user approval", ]: assert required in text def test_agent_team_has_complete_layer_contract_and_role_files(): expected = { "README.md", "memory.md", "md_inventory.md", "rules.md", "harness.md", "skill_handoff.md", "agent_01_coordinator.md", "agent_02_survey_literature.md", "agent_03_survey_skills_data.md", "agent_04_implementation_factor.md", "agent_05_implementation_pair_validator.md", "agent_06_qa_test_designer.md", "agent_07_qa_history_validator.md", "agent_08_promotion_memory_guardian.md", } assert expected.issubset({path.name for path in AGENT_TEAM_DIR.iterdir()}) readme = _read(AGENT_TEAM_DIR / "README.md") for required in [ "docs/knowledge_architecture.md", "memory.md", "md_inventory.md", "skill_handoff.md", "rules.md", "harness.md", "agent_*.md", ]: assert required in readme def test_agent_team_rules_protect_production_files_and_precision_first_policy(): text = _read(AGENT_TEAM_DIR / "rules.md") for required in [ "models/predictor.py", "services/recommendation_service.py", "services/predictor_service.py", "scripts/precompute_hot20.py", "scripts/precompute_queried_stocks.py", "docs/validation_registry.json", "BUY precision drops", "Production safety overrides speed", ]: assert required in text def test_agent_team_skill_handoff_routes_tasks_to_skills_and_docs(): text = _read(AGENT_TEAM_DIR / "skill_handoff.md") for required in [ "personal-investment-remote", "stock-pattern-mining", "openai-docs", "docs/hermes/README.md", "docs/hotspot/README.md", "docs/closed_loop_validation_design.md", "Escalation Triggers", ]: assert required in text