Files
gitea-agent/harness/tests/spec/contracts/test_priority_review_contracts.py
T

68 lines
3.4 KiB
Python

"""Documentation contracts only; runtime collector coverage is separate."""
from pathlib import Path
import re
import unittest
from harness.tests._support.paths import HARNESS
DISCOVERY = HARNESS / 'agents/spec/skills/gitea-discovery-review/SKILL.md'
IMPLEMENTATION = HARNESS / 'agents/spec/skills/gitea-implementation-spec-review/SKILL.md'
README = HARNESS / 'docs/discovery/README.md'
class PriorityReviewContracts(unittest.TestCase):
def test_issue_body_provider_revision_documentation_contract(self):
access = (HARNESS / 'operations/gitea-access.md').read_text()
contract = access.split('### Issue body update의 provider-derived readback', 1)[-1]
for required in ('content_version', 'updated_at'):
self.assertIn(required, contract)
authoring = (HARNESS / 'agents/spec/skills/gitea-discovery-authoring/SKILL.md').read_text()
for text in (DISCOVERY.read_text(), authoring):
self.assertIn('Issue body update의 provider-derived readback', text)
self.assertIn('content_version', text)
self.assertIn('post-comment snapshot을 body update 직전 baseline', authoring)
def test_rework_report_documentation_contract_requires_categories_and_counting_rules(self):
text = IMPLEMENTATION.read_text()
section = text.split('### Named test 근거와 재작업 보고', 1)[1].split('\n## ', 1)[0]
for rule in ('해소:', '잔여:', '신규:', '문서 보완:', '해당 없음'):
with self.subTest(rule=rule):
self.assertIn(rule, section)
def test_changed_readback_helper_documentation_contract_is_conditional_and_precreate(self):
text = IMPLEMENTATION.read_text()
heading = '### 비정본·변경된 readback helper 호출 계약'
self.assertIn(heading, text, 'conditional readback invocation guidance is missing')
section = text.split(heading, 1)[1].split('\n## ', 1)[0]
for rule in ('native create 이전', 'inspect.signature', '.bind('):
with self.subTest(rule=rule):
self.assertIn(rule, section)
step = text.split('17. 호출 전에', 1)[1].split('\n18.', 1)[0]
self.assertIn('비정본·변경된 readback helper 호출 계약', step)
self.assertLess(step.index('비정본·변경된 readback helper 호출 계약'), step.index('Native review create를'))
def test_discovery_checker_documentation_contract_preserves_bytes_and_bounded_transformations(self):
text = DISCOVERY.read_text()
heading = '### 임시·변경된 Discovery checker 준비'
self.assertIn(heading, text, 'bounded Discovery checker preparation guidance is missing')
section = text.split(heading, 1)[1].split('\n## ', 1)[0]
for rule in ('LF/CRLF', 'splitlines', 'flags='):
with self.subTest(rule=rule):
self.assertIn(rule, section)
step = text.split('11. trusted workflow directory', 1)[1].split('\n12.', 1)[0]
self.assertIn('임시·변경된 Discovery checker 준비', step)
def test_local_links_resolve_and_procedures_reference_new_rules(self):
for path in (DISCOVERY, IMPLEMENTATION, README):
text = path.read_text()
for link in re.findall('\\]\\(([^)]+)\\)', text):
if not link.startswith(('http:', 'https:', '#')):
self.assertTrue((path.parent / link.split('#')[0]).exists(), link)
if __name__ == "__main__":
unittest.main()