-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathtest_coding_agent_skill_base.py
More file actions
170 lines (134 loc) · 7.58 KB
/
Copy pathtest_coding_agent_skill_base.py
File metadata and controls
170 lines (134 loc) · 7.58 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
from __future__ import annotations
import json
from pathlib import Path
from aureon.autonomous.aureon_coding_agent_skill_base import build_and_write_profile
from aureon.core.goal_execution_engine import GoalExecutionEngine
from aureon.inhouse_ai.tool_registry import ToolRegistry
def _fake_repo(root: Path) -> None:
(root / "aureon" / "demo").mkdir(parents=True)
(root / "scripts").mkdir()
(root / "tests").mkdir()
(root / "frontend" / "src").mkdir(parents=True)
(root / "aureon" / "demo" / "worker.py").write_text("def run_worker():\n return 'ok'\n", encoding="utf-8")
(root / "tests" / "test_worker.py").write_text("def test_ok():\n assert True\n", encoding="utf-8")
(root / "frontend" / "src" / "App.tsx").write_text(
'import { AureonWorkOrderExecutionConsole } from "@/components/generated/AureonWorkOrderExecutionConsole";\n'
"export default function App() {\n"
" return (\n"
" <main>\n"
" <AureonWorkOrderExecutionConsole />\n"
" </main>\n"
" );\n"
"}\n",
encoding="utf-8",
)
def test_tool_registry_exposes_coder_learning_tools(tmp_path: Path, monkeypatch) -> None:
_fake_repo(tmp_path)
monkeypatch.chdir(tmp_path)
registry = ToolRegistry(include_builtins=True)
assert {"web_search", "web_fetch", "repo_search", "skill_base_status"}.issubset(set(registry.names()))
result = json.loads(registry.execute("repo_search", {"pattern": "run_worker", "directory": "aureon"}))
assert result["hit_count"] == 1
def test_coding_agent_skill_base_writes_profile_and_mount(tmp_path: Path) -> None:
_fake_repo(tmp_path)
result = build_and_write_profile("Teach Aureon coder agents and skills", root=tmp_path, online=False)
app_text = (tmp_path / "frontend" / "src" / "App.tsx").read_text(encoding="utf-8")
assert result["schema_version"] == "aureon-coding-agent-skill-base-v2"
assert result["summary"]["coder_agent_count"] >= 5
assert result["summary"]["coding_logic_rule_count"] >= 6
assert result["summary"]["web_tools_ready"] is True
assert result["write_info"]["writer"] == "QueenCodeArchitect"
logic_map = result["coding_logic_map"]
assert logic_map["status"] == "who_what_where_when_how_ready"
assert {"who:", "what:", "where:", "when:", "how:"}.issubset(
{item.split()[0] for item in logic_map["decision_loop"]}
)
assert "frontend/src/App.tsx" in logic_map["file_area_index"]
assert (tmp_path / "frontend" / "public" / "aureon_coding_agent_skill_base.json").exists()
assert (tmp_path / "frontend" / "src" / "components" / "generated" / "AureonCodingAgentSkillBaseConsole.tsx").exists()
assert "AureonCodingAgentSkillBaseConsole" in app_text
assert "Who What Where When How" in (
tmp_path / "frontend" / "src" / "components" / "generated" / "AureonCodingAgentSkillBaseConsole.tsx"
).read_text(encoding="utf-8")
assert "logicMap.status" in (
tmp_path / "frontend" / "src" / "components" / "generated" / "AureonCodingAgentSkillBaseConsole.tsx"
).read_text(encoding="utf-8")
def test_goal_engine_routes_coder_skill_goal(tmp_path: Path, monkeypatch) -> None:
_fake_repo(tmp_path)
monkeypatch.chdir(tmp_path)
engine = GoalExecutionEngine()
plan = engine.submit_goal("Aureon must teach its coder agents the coding skill base and learning workflow.")
assert plan.status == "completed"
assert plan.steps[0].intent == "coding_agent_skill_base"
assert plan.steps[0].validation_result["valid"] is True
evidence = json.loads((tmp_path / "state" / "aureon_coding_agent_skill_base_last_run.json").read_text(encoding="utf-8"))
assert evidence["write_info"]["writer"] == "QueenCodeArchitect"
assert evidence["coding_logic_map"]["status"] == "who_what_where_when_how_ready"
def test_goal_engine_routes_coding_desktop_handoff_goal(tmp_path: Path, monkeypatch) -> None:
_fake_repo(tmp_path)
monkeypatch.chdir(tmp_path)
engine = GoalExecutionEngine()
plan = engine.submit_goal(
"Aureon must connect the remote desktop run handoff to the coding organism "
"so the user prompt becomes a finished product audit."
)
assert plan.status == "completed"
assert plan.steps[0].intent == "coding_agent_skill_base"
assert plan.steps[0].validation_result["valid"] is True
def test_goal_engine_routes_code_builder_terminal_goal(tmp_path: Path, monkeypatch) -> None:
_fake_repo(tmp_path)
monkeypatch.chdir(tmp_path)
engine = GoalExecutionEngine()
plan = engine.submit_goal(
"Connect Aureon coding systems, inspect the repo, propose the smallest safe patch, "
"and run focused tests so the code builder terminal works."
)
assert plan.status == "completed"
assert plan.steps[0].intent == "coding_agent_skill_base"
assert plan.steps[0].validation_result["valid"] is True
def test_goal_engine_routes_visual_asset_prompt_without_agentcore(tmp_path: Path, monkeypatch) -> None:
_fake_repo(tmp_path)
monkeypatch.chdir(tmp_path)
engine = GoalExecutionEngine()
plan = engine.submit_goal("drwaw me a image of a cat and open the file and show me it")
assert plan.status == "completed"
assert [step.intent for step in plan.steps] == ["visual_asset_request"]
assert plan.steps[0].validation_result["valid"] is True
payload = plan.steps[0].result["result"]
assert payload["status"] == "visual_asset_ready"
assert payload["public_url"].startswith("/aureon_visual_artifacts/")
assert Path(payload["asset_path"]).exists()
assert "cat" in payload["subject"]
def test_goal_engine_routes_video_artifact_prompt_without_agentcore(tmp_path: Path, monkeypatch) -> None:
# mp4 rendering runs through OpenCV's VideoWriter; without cv2 the plan
# honestly fails rather than fabricating a video file.
import pytest
pytest.importorskip("cv2")
_fake_repo(tmp_path)
monkeypatch.chdir(tmp_path)
engine = GoalExecutionEngine()
plan = engine.submit_goal("make a 1 second video of a dog and show me the finished file")
assert plan.status == "completed"
assert [step.intent for step in plan.steps] == ["visual_asset_request"]
assert plan.steps[0].validation_result["valid"] is True
payload = plan.steps[0].result["result"]
assert payload["status"] == "visual_asset_ready"
assert payload["asset_kind"] == "mp4"
assert payload["duration_seconds"] == 1
assert payload["public_url"].endswith(".webm")
assert payload["preview_url"].endswith("_preview.html")
assert Path(payload["asset_path"]).exists()
def test_goal_engine_routes_operational_ui_before_generic_coding_scope(tmp_path: Path, monkeypatch) -> None:
_fake_repo(tmp_path)
monkeypatch.chdir(tmp_path)
prompt = (
"Aureon must build a read-only operational UI status card for the last public artifact URL, "
"media kind, proof status, and snag count. Target the frontend generated operational console, "
"preserve all safety gates, run tests or build proof, and hand over only when ready.\n\n"
"Client-approved scope answers:\n"
"- deliverables: Repo changes or reports, code proposal, focused tests, proof checklist, snagging result, and client handover.\n"
"- target_system: Aureon repository, coding organism bridge, generated console evidence, and target files named by the prompt.\n"
"- acceptance: Goal route is clean, focused tests pass or are explicitly skipped, HNC/Auris proof is recorded, and blocking snags are zero."
)
plan = GoalExecutionEngine()._decompose_goal(prompt)
assert [step.intent for step in plan.steps] == ["self_author_operational_ui"]