# Database Prompt Publication Center Plan **Goal:** Make Prompt releases editable and publishable without rebuilding the application while preserving immutable execution identities for queued tasks. **Architecture:** `factory_prompt_template` owns stable Prompt code/generation type and a current release pointer. `factory_prompt_version` stores immutable content versions; only publication status changes. `DatabasePromptRegistry` is the primary runtime registry when explicitly enabled and falls back to built-ins otherwise. Admin services lock templates during version creation and pointer changes. ## Task 1: Persistence - [x] Add Prompt template/version domain models, mapper contracts, and MyBatis mappings. - [x] Add base/upgrade SQL, built-in seeds, uniqueness constraints, and publication indexes. - [x] Keep Prompt version content immutable after insertion. ## Task 2: Publication Service - [x] Create templates and monotonically numbered versions with canonical fingerprints. - [x] Publish drafts and roll back to retired releases transactionally. - [x] Validate ownership, content hashes, provider availability, and publication state. ## Task 3: Runtime Registry - [x] Resolve current database publication by generation type. - [x] Resolve exact published/retired versions for queued task replay. - [x] Use an explicit database-enabled switch and retain built-in fallback. ## Task 4: Admin Experience - [x] Add permission-guarded Prompt list/detail/create/edit/version/publish/rollback APIs. - [x] Add RuoYi API client, Prompt management page, and menu SQL. - [x] Show current release, version history, fingerprints, and publication actions. ## Task 5: Verification - [x] Add mapper/schema, registry, service, controller, and frontend source-contract tests. - [x] Run targeted backend tests, frontend tests/build, and full generator baseline. - [x] Update the factory roadmap and migration order. ## Boundaries - P2-B2 versions the current system Prompt plus the existing user Prompt builder contract; parameterized user Prompt bodies migrate in later slices. - One-click multi-stage Prompt manifests remain P2-C pipeline work. - A/B experiments, approval workflows, provider secrets, and semantic model capability routing are not included.