Kairo-Jinkendo/backend/sync_prompt_feature_config.py
Lars 53047b6c16
All checks were successful
Deploy Development / deploy (push) Successful in 38s
Test Suite / pytest-backend (push) Successful in 18s
Test Suite / lint-backend (push) Successful in 1s
Test Suite / compose-smoke (push) Has been skipped
Test Suite / k6 /api/health Baseline (push) Successful in 18s
Test Suite / playwright-smoke (push) Successful in 24s
AP0.4: Feature-, Prompt- und Config-Registry mit Single-Render und Entitlements-Features.
Migration 005, Registry-Sync, Placeholder-Validation, capability-geschuetzte API, Tests und Abschlussbericht v0.1.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-04 23:29:02 +02:00

61 lines
1.6 KiB
Python

"""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())