Files
FESADev/scripts/test_correction_agent_config.py
T
2026-06-11 17:18:03 +09:00

91 lines
3.1 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" / "correction-agent.toml"
CORRECTIONS_README = ROOT / "docs" / "corrections" / "README.md"
class CorrectionAgentConfigTests(unittest.TestCase):
def test_correction_agent_toml_has_required_codex_fields(self):
data = tomllib.loads(AGENT_PATH.read_text(encoding="utf-8"))
self.assertEqual(data["name"], "correction-agent")
self.assertIn("C++/MSVC/CMake/CTest fixes", data["description"])
self.assertEqual(data["sandbox_mode"], "workspace-write")
self.assertEqual(data["model_reasoning_effort"], "extra high")
self.assertIn("developer_instructions", data)
def test_correction_agent_instructions_enforce_boundaries(self):
instructions = AGENT_PATH.read_text(encoding="utf-8")
for required_text in (
"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 reference HDF5 files or deterministic CSV views.",
"Do not approve release readiness.",
):
self.assertIn(required_text, instructions)
def test_correction_agent_instructions_define_triage_contract(self):
instructions = AGENT_PATH.read_text(encoding="utf-8")
for required_text in (
"TRIAGE -> MINIMAL FIX -> VERIFY -> REPORT",
"configure",
"compile",
"link",
"test",
"reference-comparison",
"harness",
"environment",
"upstream-contract",
):
self.assertIn(required_text, instructions)
def test_correction_agent_instructions_define_output_contract(self):
instructions = AGENT_PATH.read_text(encoding="utf-8")
for required_text in (
"Failure Triage",
"Root Cause Summary",
"Correction Scope",
"Verification Evidence",
"Traceability",
"Handoff Recommendation",
"Stop Condition",
):
self.assertIn(required_text, instructions)
def test_correction_report_guide_defines_template_and_status_values(self):
guide = CORRECTIONS_README.read_text(encoding="utf-8")
for required_text in (
"docs/corrections/<feature-id>-correction.md",
"Failure Triage",
"Root Cause Summary",
"Correction Scope",
"Verification Evidence",
"Traceability",
"Handoff Recommendation",
"Stop Condition",
"corrected-for-build-test",
"needs-upstream-decision",
"python scripts/validate_workspace.py",
):
self.assertIn(required_text, guide)
if __name__ == "__main__":
unittest.main()