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" / "release-agent.toml" RELEASES_README = ROOT / "docs" / "releases" / "README.md" class ReleaseAgentConfigTests(unittest.TestCase): def test_release_agent_toml_has_required_codex_fields(self): data = tomllib.loads(AGENT_PATH.read_text(encoding="utf-8")) self.assertEqual(data["name"], "release-agent") self.assertIn("release readiness", data["description"]) self.assertEqual(data["sandbox_mode"], "workspace-write") self.assertEqual(data["model_reasoning_effort"], "extra high") self.assertIn("developer_instructions", data) def test_release_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 change requirements", "Do not change formulations", "Do not change I/O contracts", "Do not change reference artifacts", "Do not change tolerance policies", "Do not run Abaqus, Nastran, or any reference solver.", "Do not generate or modify Abaqus reference CSV files.", "Do not override failed or missing upstream gates.", ): self.assertIn(required_text, instructions) def test_release_agent_instructions_define_gate_and_status_contract(self): instructions = AGENT_PATH.read_text(encoding="utf-8") for required_text in ( "GATE AUDIT -> TRACEABILITY CHECK -> RELEASE DOCUMENTATION -> RELEASE VERDICT", "pass-for-release-agent", "pass-for-physics-evaluation", "pass-for-reference-verification", "ready-for-release", "known limitations", ): self.assertIn(required_text, instructions) def test_release_agent_instructions_define_output_contract(self): instructions = AGENT_PATH.read_text(encoding="utf-8") for required_text in ( "Gate Evidence Inventory", "Acceptance Traceability", "Validation Evidence", "Known Limitations", "Release Notes Draft", "Release Verdict", "No-Change Assertion", ): self.assertIn(required_text, instructions) def test_release_report_guide_defines_template_and_status_values(self): guide = RELEASES_README.read_text(encoding="utf-8") for required_text in ( "docs/releases/-release.md", "Gate Evidence Inventory", "Acceptance Traceability", "Validation Evidence", "Known Limitations", "Release Notes Draft", "Release Verdict", "No-Change Assertion", "ready-for-release", "needs-documentation", "needs-upstream-decision", "python scripts/validate_workspace.py", ): self.assertIn(required_text, guide) if __name__ == "__main__": unittest.main()