[verified] Clarify changed readback helper invocation preflight
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
"""Static contract regressions; these do not prove LLM execution behavior."""
|
||||
"""Documentation contracts and local synthetic controls; not agent/live execution."""
|
||||
from pathlib import Path
|
||||
import re
|
||||
import unittest
|
||||
@@ -93,6 +93,23 @@ class PriorityReviewContracts(unittest.TestCase):
|
||||
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 이전',
|
||||
'정본 adapter를 변경 없이', '중복 signature 검사를 강제하지',
|
||||
'inspect.signature', '.bind(', '실행하지', 'partial',
|
||||
'인증', 'pagination completeness', 'read-only',
|
||||
'새 runtime gate', 'source revision'):
|
||||
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_local_links_resolve_and_procedures_reference_new_rules(self):
|
||||
for path in (DISCOVERY, IMPLEMENTATION, README):
|
||||
text = path.read_text()
|
||||
@@ -103,5 +120,45 @@ class PriorityReviewContracts(unittest.TestCase):
|
||||
self.assertIn('11. 문서 검토 입력과 구조·의미 분리 절차', IMPLEMENTATION.read_text())
|
||||
|
||||
|
||||
class SyntheticReadbackInvocationTests(unittest.TestCase):
|
||||
"""Local Python binding/collector controls, not a production pre-create gate."""
|
||||
|
||||
def test_synthetic_signature_binding_rejects_extra_argument_without_callback_execution(self):
|
||||
import inspect
|
||||
calls = []
|
||||
|
||||
def pages(page, *, endpoint='reviews'):
|
||||
calls.append((page, endpoint))
|
||||
|
||||
signature = inspect.signature(pages)
|
||||
bound = signature.bind(1, endpoint='reviews')
|
||||
self.assertEqual(bound.arguments, {'page': 1, 'endpoint': 'reviews'})
|
||||
self.assertEqual(calls, [])
|
||||
with self.assertRaises(TypeError):
|
||||
signature.bind(1, 50)
|
||||
with self.assertRaises(TypeError):
|
||||
signature.bind(1, page_size=50)
|
||||
self.assertEqual(calls, [])
|
||||
|
||||
def test_actual_collector_calls_synthetic_callback_with_one_page_argument(self):
|
||||
import importlib.util
|
||||
import inspect
|
||||
path = HARNESS / 'agents/spec/skills/gitea-implementation-spec-review/scripts/review_support.py'
|
||||
spec = importlib.util.spec_from_file_location('readback_invocation_support', path)
|
||||
assert spec is not None and spec.loader is not None
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(module)
|
||||
calls = []
|
||||
|
||||
def pages(page):
|
||||
calls.append(page)
|
||||
return {'items': [{'id': page}], 'total_count': 2, 'has_more': page < 2}
|
||||
|
||||
inspect.signature(pages).bind(1)
|
||||
self.assertEqual(calls, [])
|
||||
self.assertEqual(module.collect_pages(pages, 'id', page_size=1), [{'id': 1}, {'id': 2}])
|
||||
self.assertEqual(calls, [1, 2])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user