#!/usr/bin/env python3 """Check an implementation against its exact organization design release binding.""" import argparse import hashlib import os import re import sys import yaml HERE = os.path.dirname(os.path.abspath(__file__)) ROOT = os.environ.get("CLAUDE_PROJECT_DIR") or os.path.dirname(os.path.dirname(HERE)) RAW_COLOR = re.compile(r"(? 1: rels = [os.path.relpath(path, target) for path in paths] errors.append(f"local duplicate component id={cid}: {rels}") delta = binding.get("delta") or {} declared_delta = {_component_id(value) for value in delta.get("components") or []} delta_reasons = { _component_id(value): str(value.get("reason") or "").strip() for value in delta.get("components") or [] if isinstance(value, dict) } bound = {_component_id(value) for value in binding.get("component-ids") or []} for cid in sorted((set(local) & bound) - declared_delta): rels = [os.path.relpath(path, target) for path in local[cid]] errors.append( f"organization component local duplicate id={cid}: {rels}; " "재사용하거나 delta.components에 예외를 명시해야 함") for cid in sorted(set(local) & bound & declared_delta): if not delta_reasons.get(cid): errors.append(f"organization component delta id={cid}: reason 필수") if errors: for error in errors: print(f"[design-adherence] ERROR: {error}", file=sys.stderr) return 2 print(f"[design-adherence] OK: release={binding.get('release-id')}") return 0 if __name__ == "__main__": raise SystemExit(main())