"""Static documentation contracts; no dependency resolver or probe parser is executed.""" from pathlib import Path import unittest ROOT = Path(__file__).resolve().parents[3] SKILL = ROOT / 'harness/agents/review/skills/gitea-code-review/SKILL.md' class ReviewProbeDocumentationTests(unittest.TestCase): def test_documentation_contract_requires_dependency_provenance_and_failure_preservation(self): text = SKILL.read_text() heading = '### Dependency provenance와 probe JSON framing' self.assertIn(heading, text) section = text.split(heading, 1)[1].split('\n## ', 1)[0] for rule in ('별도로 승인된', '실제 interpreter', 'resolved dependency 버전', 'source revision', 'lockfile', '실패한 resolution·collection', 'baseline', '제품 회귀', '새 venv', '설치·pinning 권한', '기존 evidence'): with self.subTest(rule=rule): self.assertIn(rule, section) def test_documentation_contract_requires_exactly_one_framed_record_and_safe_errors(self): section = SKILL.read_text().split('### Dependency provenance와 probe JSON framing', 1)[1].split('\n## ', 1)[0] for rule in ('producer와 consumer', '고유 marker', '정확히 하나의 완전한 JSON record', '누락·중복·malformed·truncation', '전체 stdout', 'brace', 'warning', 'exit status', 'TDD RED', 'timeout', '출력 한도', 'redaction', 'generic parser'): with self.subTest(rule=rule): self.assertIn(rule, section) def test_documentation_contract_requires_bound_content_and_control_response_handling(self): text = SKILL.read_text() heading = '### Programmatic read control response와 script 준비' self.assertIn(heading, text) section = text.split(heading, 1)[1].split('\n## ', 1)[0] for rule in ('첫 content-bearing 응답', 'exact 경로', 'source revision', 'hash', '읽은 범위', '응답 shape', 'control response', 'unchanged/dedup', '보존된 내용', 'evidence_gap', 'force-read', '전역 dedup', 'stale cache'): with self.subTest(rule=rule): self.assertIn(rule, section) def test_documentation_contract_requires_compile_before_execution_and_preserves_authority(self): section = SKILL.read_text().split('### Programmatic read control response와 script 준비', 1)[1].split('\n## ', 1)[0] for rule in ('typed JSON', '다중 quoted', 'compile', '실행·로그 append·외부 action 전에', '문법 검사', '안전성·인증·실행 성공', 'credential', 'commit/push', 'review role', '권한을 확장하지 않는다', 'TDD RED'): with self.subTest(rule=rule): self.assertIn(rule, section) if __name__ == '__main__': unittest.main()