"""Safeguard validation with negative mutation controls; no live operations.""" from pathlib import Path import json,unittest ROOT=Path(__file__).resolve().parents[1] CLAUSES=json.loads((Path(__file__).parent/'contract.json').read_text()) def validate(text): missing=[s for s in CLAUSES if s.lower() not in text.lower()] if missing: raise ValueError(missing) class Contract(unittest.TestCase): def test_published_procedure_has_all_safeguards(self): validate((ROOT/'SKILL.md').read_text()) def test_each_removed_safeguard_is_rejected(self): text=(ROOT/'SKILL.md').read_text().lower() for s in CLAUSES: with self.subTest(s=s),self.assertRaises(ValueError):validate(text.replace(s.lower(),'')) def test_procedure_not_an_empty_router(self): text=(ROOT/'SKILL.md').read_text() self.assertIn('## Verification' if '## Verification' in text else 'verification',text) self.assertTrue('Stop' in text or 'stop' in text or 'status unverified' in text) self.assertTrue('## Procedure' in text or '## Failure-Repair Workflow' in text or '## Scope Status Vocabulary' in text) if __name__=='__main__':unittest.main()