Files
gitea-agent/harness/tests/review/contracts/test_review_document_contracts.py
T

44 lines
2.2 KiB
Python

from pathlib import Path
import unittest
from harness.tests._support.paths import ROOT
REFERENCE = ROOT / 'harness/agents/review/skills/gitea-code-review/references/native-review.md'
SKILL = ROOT / 'harness/agents/review/skills/gitea-code-review/SKILL.md'
CACHE = ROOT / 'harness/operations/repository-cache.md'
OBSERVABILITY_HEADING = '## 조건부 observability 정책 확인과 종료 기록'
TIMEOUT_HEADING = '### 장시간 suite의 timeout evidence recipe'
class NativeJournalDocumentationTests(unittest.TestCase):
def test_canonical_registry_and_legacy_policy_are_explicit(self):
for path in (REFERENCE, SKILL, CACHE):
text = path.read_text()
for token in ('harness/.runtime/native-review-journals', 'canonical_journal_path', 'register_legacy_journal'):
with self.subTest(path=str(path), token=token):
self.assertIn(token, text)
def test_journal_parent_preflight_precedes_expensive_execution(self):
text = SKILL.read_text()
entry = text.split('## 진입 조건', 1)[1].split('## 리뷰 관점', 1)[0]
for requirement in ('고비용 리뷰·테스트 실행 전에', '$HARNESS_ROOT/harness/.runtime', 'lstat', 'symlink', '정확한 mode `0700`'):
with self.subTest(requirement=requirement):
self.assertIn(requirement, entry)
def test_no_caller_selected_journal_in_live_example(self):
text = REFERENCE.read_text()
self.assertNotIn('result = native_review.publish(plan, baseline, api, lease, journal_directory)', text)
self.assertIn('result = native_review.publish(plan, baseline, api, lease)', text)
class ReviewProbeDocumentationTests(unittest.TestCase):
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]
# Retain the required preparation order, not general authority prose.
for rule in ('compile', '실행·로그 append·외부 action 전에'):
with self.subTest(rule=rule):
self.assertIn(rule, section)
if __name__ == '__main__':
unittest.main()