93 lines
3.0 KiB
Python
93 lines
3.0 KiB
Python
import unittest
|
|
from pathlib import Path
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
SKILL_PATH = ROOT / ".codex" / "skills" / "fesa-feature-definition" / "SKILL.md"
|
|
|
|
|
|
def read_skill():
|
|
return SKILL_PATH.read_text(encoding="utf-8")
|
|
|
|
|
|
def parse_frontmatter(text):
|
|
lines = text.splitlines()
|
|
if not lines or lines[0] != "---":
|
|
raise AssertionError("SKILL.md must start with YAML frontmatter")
|
|
|
|
fields = {}
|
|
for line in lines[1:]:
|
|
if line == "---":
|
|
return fields
|
|
key, sep, value = line.partition(":")
|
|
if not sep:
|
|
raise AssertionError(f"Invalid frontmatter line: {line}")
|
|
fields[key.strip()] = value.strip()
|
|
|
|
raise AssertionError("SKILL.md frontmatter must be closed")
|
|
|
|
|
|
class FesaFeatureDefinitionSkillTests(unittest.TestCase):
|
|
def test_skill_file_exists_with_required_frontmatter(self):
|
|
self.assertTrue(SKILL_PATH.exists(), "fesa-feature-definition SKILL.md is missing")
|
|
|
|
fields = parse_frontmatter(read_skill())
|
|
|
|
self.assertEqual(set(fields), {"name", "description"})
|
|
self.assertEqual(fields["name"], "fesa-feature-definition")
|
|
self.assertIn("Use when", fields["description"])
|
|
self.assertIn("FESA solver feature requests", fields["description"])
|
|
self.assertIn("requirements", fields["description"])
|
|
self.assertIn("research questions", fields["description"])
|
|
self.assertIn("acceptance criteria", fields["description"])
|
|
self.assertIn("verification matrices", fields["description"])
|
|
|
|
def test_skill_body_defines_core_workflow_and_inputs(self):
|
|
body = read_skill()
|
|
|
|
for required_text in (
|
|
"## Inputs",
|
|
"## Workflow",
|
|
"## Output Contract",
|
|
"## Boundaries",
|
|
"## Quality Gate",
|
|
"docs/SOLVER_SKILL_DESIGN.md",
|
|
"docs/SOLVER_AGENT_DESIGN.md",
|
|
"AGENTS.md",
|
|
"docs/requirements/<feature-id>.md",
|
|
"docs/research/<feature-id>-research.md",
|
|
):
|
|
self.assertIn(required_text, body)
|
|
|
|
def test_skill_body_defines_requirement_and_verification_contract(self):
|
|
body = read_skill()
|
|
|
|
for required_text in (
|
|
"Feature Definition Packet",
|
|
"shall",
|
|
"Requirement Verification Matrix",
|
|
"Research Questions",
|
|
"Reference Artifact Needs",
|
|
"Tolerance Decisions",
|
|
"Downstream Handoff",
|
|
"FESA-REQ-<FEATURE>-###",
|
|
"needs-user-decision",
|
|
):
|
|
self.assertIn(required_text, body)
|
|
|
|
def test_skill_body_enforces_scope_boundaries(self):
|
|
body = read_skill()
|
|
|
|
for required_text in (
|
|
"Do not finalize FEM formulations.",
|
|
"Do not implement C++ code.",
|
|
"Do not run Abaqus, Nastran, or any reference solver.",
|
|
"Do not generate reference CSVs.",
|
|
"Do not approve release readiness.",
|
|
):
|
|
self.assertIn(required_text, body)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|