Files
channel-delivery-skic/tests/test_simplification_contract.py
T

55 lines
4.3 KiB
Python

"""Offline bounded simplification contract; no dependency or network mutation."""
from pathlib import Path
import hashlib
import unittest
ROOT = Path(__file__).resolve().parents[1]
class SimplificationContract(unittest.TestCase):
def test_retained_safety_sections(self):
for (path, start, end), digest in SECTIONS.items():
text = (ROOT / path).read_text().split(start, 1)[1]
if end:
text = text.split(end, 1)[0]
self.assertEqual(hashlib.sha256(text.encode()).hexdigest(), digest, (path, start))
def test_dependencies_unchanged(self):
self.assertIn(DEPS, (ROOT / 'SKILL.md').read_text())
def test_unresolved_gates_and_safety_files_unchanged(self):
for name, digest in PROTECTED.items():
self.assertEqual(hashlib.sha256((ROOT / name).read_bytes()).hexdigest(), digest, name)
def test_decision_point_loads(self):
for name, markers in {
'SKILL.md': ['Before login, load', 'skic-skills/channel-board-skic', 'version: 1.14.2'],
'references/runtime-and-ci.md': ['Before login, load', 'Load `development-method-ttd`', 'Load `development-monorepo-pnpm`'],
'references/status-and-reporting.md': ['Before reporting, load', 'home-v1-skills-code-agent/development-integrity'],
'references/planning-artifact-reconciliation.md': ['corepack enable --install-directory', 'Before reporting, load'],
'references/failure-and-documentation.md': ['Before authoring or validating documentation, load', 'home-v1-skills-code-agent/corp-v1-glossary'],
}.items():
for marker in markers:
self.assertIn(marker, (ROOT / name).read_text(), (name, marker))
def test_no_helper_or_reference_removed(self):
self.assertEqual({p.name for p in (ROOT / 'references').glob('*.md')}, REFERENCES)
self.assertNotIn('SIMPLIFICATION.md', (ROOT / 'SKILL.md').read_text())
def test_retained_reporting_and_planning_guards(self):
status = (ROOT / 'references/status-and-reporting.md').read_text()
for marker in ['wave-previous:', 'List every Task', 'GATE_003_TASK_IMPLEMENTATION', 'status unverified', 'exact failed command']:
self.assertIn(marker, status)
planning = (ROOT / 'references/planning-artifact-reconciliation.md').read_text()
for marker in ['each matching task', 'run_number', 'semantics', 'If the PR merged or closed', 'no second Focus-admission', 'configured silent response']:
self.assertIn(marker, planning)
def test_operational_size_reduction(self):
paths = [ROOT / 'SKILL.md', *ROOT.glob('references/*.md')]
self.assertLess(sum(len(p.read_bytes()) for p in paths), BASELINE_BYTES)
DEPS = ' related_skills: [channel-board-skic, home-v1-discord, documentation-docusaurus, corp-v1-glossary, development-durable-wave-execution, development-gates, development-integrity, development-method-ttd, development-branching-strategy, development-monorepo-pnpm, development-scripts, development-gitops-argo-cd-gondor-v1]'
PROTECTED = {'references/task-delivery-gates.md': '9d803be17cf6254c7ea938e3899d58f25784c294f351d3485a20bdf4be18f597', 'references/repository-entry-and-visibility.md': 'f040d6f57c4ec5faf4527296f7f71a751fab2153809e2dbe20c90cf2d582a77d', 'references/common-pitfalls.md': '41c3b5cc88227b7402f52777f329c3fb9b891954dabee36dfd639f2bf27795a1', 'references/aerosim-lessons-review.md': '03873d038f146e28ea648c95f7c2e32d2648d1b5eaa963fb635980fe6e814514'}
REFERENCES = {'task-delivery-gates.md', 'common-pitfalls.md', 'failure-and-documentation.md', 'runtime-and-ci.md', 'repository-entry-and-visibility.md', 'aerosim-lessons-review.md', 'planning-artifact-reconciliation.md', 'status-and-reporting.md'}
SECTIONS = {('references/runtime-and-ci.md', '### Execution-context toolchain preflight', None): '87a1bdc8c00bdd9f4ad975703bec81f9c9affd26edcfc939f936a7556e7bfa39', ('references/runtime-and-ci.md', '## Channel-owned workspace', '## Shared Corp'): '48d1e74b737db691ec31ac593400d59abc7d4eed4cd67b2f12f8a428a48034b5', ('references/failure-and-documentation.md', '## Failure-Repair Workflow', '## Documentation Ownership'): 'fb6a08666ffcba086984d5437b2d89ce5c7961c007c50e59e1f07f41ea384db1', ('SKILL.md', '## Authority and Escalation', '## Evidence Requirements'): 'e3c566055d9d04d3ab0286e6e5035a8c30f66a81b17b4d0379e8010dead3fa83'}
BASELINE_BYTES = 84789