"""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.15.0'], '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 ['complete successful job inventory including aggregates', '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, 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-home-gondor-v1]' PROTECTED = {'references/repository-entry-and-visibility.md': 'f040d6f57c4ec5faf4527296f7f71a751fab2153809e2dbe20c90cf2d582a77d', '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', '## Channel-owned workspace', '## Shared Corp'): '48d1e74b737db691ec31ac593400d59abc7d4eed4cd67b2f12f8a428a48034b5', ('SKILL.md', '## Authority and Escalation', '## Evidence Requirements'): 'e3c566055d9d04d3ab0286e6e5035a8c30f66a81b17b4d0379e8010dead3fa83'} BASELINE_BYTES = 84789