import json import sys import os def check_system_tables(): file_path = 'backend/internal/bootstrap/system_tables.json' if not os.path.exists(file_path): print(f"Error: {file_path} not found.") sys.exit(1) with open(file_path, 'r') as f: try: data = json.load(f) except json.JSONDecodeError as e: print(f"Error decoding JSON: {e}") sys.exit(1) forbidden_tables = {'account', 'opportunity', 'contact', 'lead'} found_violations = [] for item in data: table_name = item.get('tableName', '').lower() if table_name in forbidden_tables: found_violations.append(table_name) # Also check 'category' - should be 'system' or 'platform', not 'standard' for core category = item.get('category', '').lower() if category == 'standard': # Maybe strict system tables shouldn't have 'standard' category? # Let's enforce specific table names for now. pass if found_violations: print("❌ ARCHITECTURE VIOLATION: Business objects found in system_tables.json") print(f"Violating tables: {', '.join(found_violations)}") print("Rule: Business objects must be defined in manifest.json and installed via cmd/installer.") sys.exit(1) print("✅ Constraint Check Passed: No business logic in system_tables.json") sys.exit(0) if __name__ == '__main__': check_system_tables()