import unittest from pathlib import Path try: import tomllib except ModuleNotFoundError: # pragma: no cover import tomli as tomllib ROOT = Path(__file__).resolve().parents[1] AGENT_PATH = ROOT / ".codex" / "agents" / "coordinator-agent.toml" COORDINATION_README = ROOT / "docs" / "coordination" / "README.md" class CoordinatorAgentConfigTests(unittest.TestCase): def test_coordinator_agent_toml_has_required_codex_fields(self): data = tomllib.loads(AGENT_PATH.read_text(encoding="utf-8")) self.assertEqual(data["name"], "coordinator-agent") self.assertIn("workflow state", data["description"]) self.assertEqual(data["sandbox_mode"], "workspace-write") self.assertEqual(data["model_reasoning_effort"], "extra high") self.assertIn("developer_instructions", data) def test_coordinator_agent_instructions_enforce_boundaries(self): instructions = AGENT_PATH.read_text(encoding="utf-8") for required_text in ( "Do not implement code.", "Do not edit source code.", "Do not edit tests.", "Do not edit CMake.", "Do not run build/test validation.", "Do not run Abaqus, Nastran, or any reference solver.", "Do not generate or modify Abaqus reference CSV files.", "Do not automatically spawn subagents.", "Do not approve release readiness independently.", ): self.assertIn(required_text, instructions) def test_coordinator_agent_instructions_define_workflow_and_status_contract(self): instructions = AGENT_PATH.read_text(encoding="utf-8") for required_text in ( "INTAKE -> STATE AUDIT -> GATE DECISION -> HANDOFF PACKAGE -> STATUS REPORT", "Requirement Agent", "Research Agent", "Formulation Agent", "Numerical Review Agent", "I/O Definition Agent", "Reference Model Agent", "Implementation Planning Agent", "Implementation Agent", "Build/Test Executor Agent", "Correction Agent", "Reference Verification Agent", "Physics Evaluation Agent", "Release Agent", "ready-for-implementation", "pass-for-reference-verification", "pass-for-physics-evaluation", "pass-for-release-agent", "ready-for-release", "completed", ): self.assertIn(required_text, instructions) def test_coordinator_agent_instructions_define_output_contract(self): instructions = AGENT_PATH.read_text(encoding="utf-8") for required_text in ( "Gate Evidence Inventory", "Decision Log", "Next Agent Handoff", "Traceability Snapshot", "Risk and Blocker Register", "Rework Loop Control", "No-Change Assertion", ): self.assertIn(required_text, instructions) def test_coordination_guide_defines_template_and_status_values(self): guide = COORDINATION_README.read_text(encoding="utf-8") for required_text in ( "docs/coordination/-coordination.md", "Gate Evidence Inventory", "Decision Log", "Next Agent Handoff", "Traceability Snapshot", "Risk and Blocker Register", "Rework Loop Control", "No-Change Assertion", "needs-user-decision", "blocked", "python scripts/validate_workspace.py", ): self.assertIn(required_text, guide) if __name__ == "__main__": unittest.main()