File size: 2,643 Bytes
e610a2f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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