"""Startup sync for feature, prompt, placeholder and default config registries.""" from __future__ import annotations import sys import feature_registrations # noqa: F401 import placeholder_registrations # noqa: F401 import prompt_registrations # noqa: F401 from config_service import sync_default_configs from feature_registry import sync_features_to_db from placeholder_registry import sync_placeholders_to_db from prompt_registry import sync_prompts_to_db from services.audit import log_audit DEFAULT_CONFIGS = [ { "config_key": "prompt.default_execution_mode", "scope": "global", "value": "single", "value_type": "string", "description": "Default execution mode for prompt rendering", }, { "config_key": "prompt.render_logging_enabled", "scope": "global", "value": True, "value_type": "boolean", "description": "Write prompt_execution_logs on render", }, { "config_key": "features.registry_sync_enabled", "scope": "global", "value": True, "value_type": "boolean", "description": "Enable registry sync on startup", }, ] def main() -> int: results = [ sync_features_to_db(), sync_placeholders_to_db(), sync_prompts_to_db(), ] sync_default_configs(DEFAULT_CONFIGS) log_audit( "registry.sync.completed", details={ "features": results[0] == 0, "placeholders": results[1] == 0, "prompts": results[2] == 0, }, ) return 0 if all(code == 0 for code in results) else 1 if __name__ == "__main__": sys.exit(main())