Files
gitea-agent/harness/tests/impl/contracts/test_impl_architecture_wiring.py
T

41 lines
2.2 KiB
Python

"""Canonical impl contracts stay reachable without duplicated skill bodies."""
import re
import unittest
from pathlib import Path
from harness.tests._support.contracts import read_contract, REQUIRED
from harness.tests._support.paths import ROOT
class ImplArchitectureDocsTests(unittest.TestCase):
def test_skills_require_single_detailed_workflow_source(self):
for name in ('gitea-issue-implementation', 'gitea-issue-rework'):
path = ROOT / 'harness/agents/impl/skills' / name / 'SKILL.md'
text = path.read_text()
reference = path.parent / 'references/workflow.md'
with self.subTest(skill=name):
self.assertIn(REQUIRED, text)
self.assertLess(len(text.splitlines()), 100)
self.assertEqual(text.count('name: ' + name), 1)
self.assertNotIn('## Managed-lock broker gate', text)
self.assertFalse(reference.read_text().startswith('---'))
contract = read_contract(path)
self.assertEqual(contract.count('## Managed-lock broker gate'), 1)
for gate in ('## Delegation evidence acceptance gate', '## Test inventory source-binding gate', '## Canonical external verification evidence'):
self.assertEqual(contract.count(gate), 1)
def test_all_canonical_impl_markdown_links_resolve(self):
for name in ('gitea-issue-implementation', 'gitea-issue-rework'):
directory = ROOT / 'harness/agents/impl/skills' / name
for path in [directory / 'SKILL.md', directory / 'references/workflow.md']:
for link in re.findall('\\[[^\\]]+\\]\\(([^)]+)\\)', path.read_text()):
if link.startswith(('https://', 'http://', '#')):
continue
target = link.split('#', 1)[0]
with self.subTest(path=path.name, link=link):
self.assertTrue((path.parent / target).resolve().exists())
def test_correction_default_and_exception_remain_distinct(self):
text = (ROOT / 'harness/agents/impl/skills/gitea-issue-rework/references/readback.md').read_text()
for token in ('atomic_client_precondition=false',):
self.assertIn(token.lower(), text.lower())