89 lines
3.0 KiB
Python
89 lines
3.0 KiB
Python
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" / "formulation-agent.toml"
|
|
FORMULATIONS_README = ROOT / "docs" / "formulations" / "README.md"
|
|
|
|
|
|
class FormulationAgentConfigTests(unittest.TestCase):
|
|
def test_formulation_agent_toml_has_required_codex_fields(self):
|
|
data = tomllib.loads(AGENT_PATH.read_text(encoding="utf-8"))
|
|
|
|
self.assertEqual(data["name"], "formulation-agent")
|
|
self.assertIn("FEM formulation", data["description"])
|
|
self.assertEqual(data["sandbox_mode"], "read-only")
|
|
self.assertEqual(data["model_reasoning_effort"], "extra high")
|
|
self.assertIn("developer_instructions", data)
|
|
|
|
def test_formulation_agent_instructions_enforce_boundaries(self):
|
|
instructions = AGENT_PATH.read_text(encoding="utf-8")
|
|
|
|
for required_text in (
|
|
"Do not implement code.",
|
|
"Do not design C++ APIs",
|
|
"Do not run Abaqus, Nastran, or any reference solver.",
|
|
"Do not generate reference CSVs.",
|
|
"Do not approve release readiness.",
|
|
"docs/SOLVER_AGENT_DESIGN.md",
|
|
"docs/requirements/<feature-id>.md",
|
|
"docs/research/<feature-id>-research.md",
|
|
):
|
|
self.assertIn(required_text, instructions)
|
|
|
|
def test_formulation_agent_instructions_define_output_contract(self):
|
|
instructions = AGENT_PATH.read_text(encoding="utf-8")
|
|
|
|
for required_text in (
|
|
"Strong Form and Boundary Conditions",
|
|
"Weak or Variational Form",
|
|
"Discretization",
|
|
"Kinematics",
|
|
"Constitutive Contract",
|
|
"Element Equations",
|
|
"Mapping and Numerical Integration",
|
|
"Output Recovery",
|
|
"Numerical Risks",
|
|
"Downstream Handoff",
|
|
):
|
|
self.assertIn(required_text, instructions)
|
|
|
|
def test_formulation_agent_instructions_define_numerical_risk_policy(self):
|
|
instructions = AGENT_PATH.read_text(encoding="utf-8")
|
|
|
|
for required_text in (
|
|
"rigid body modes",
|
|
"patch test",
|
|
"hourglass",
|
|
"locking",
|
|
"Jacobian",
|
|
):
|
|
self.assertIn(required_text, instructions)
|
|
|
|
def test_formulation_document_guide_defines_output_contract(self):
|
|
guide = FORMULATIONS_README.read_text(encoding="utf-8")
|
|
|
|
for required_text in (
|
|
"Strong Form and Boundary Conditions",
|
|
"Weak or Variational Form",
|
|
"Discretization",
|
|
"Kinematics",
|
|
"Constitutive Contract",
|
|
"Element Equations",
|
|
"Mapping and Numerical Integration",
|
|
"Output Recovery",
|
|
"Numerical Risks",
|
|
"Downstream Handoff",
|
|
):
|
|
self.assertIn(required_text, guide)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|