feat(prompts): v2 DB 控制面热切换 —— 版本留存 + 不重启即生效

在 v1(注册表+文件覆盖)上加 DB 管理层与热切换,镜像 model-config 控制面:
- store: sundynix_prompt 表(key/version/content/active) + ActivePrompts/ListPrompts/
  CreateVersion/Activate/Deactivate
- 控制面: ServePrompts/RequestActivePrompts(+Retry)/PublishPromptsUpdated/SubscribePromptsUpdated;
  prompts.ApplyOverrides 整体替换覆盖集(DB 激活集为权威)
- gateway API: GET/POST /api/v1/prompts、version/activate/deactivate;激活/撤销即广播
- dispatcher/mcp-go: 启动拉激活集 + 订阅热更新(不重启)
- live: 建版本→激活→mcp-go 图谱抽取 2→0→回滚 2(全程不重启);deactivate 回退代码默认;版本可回溯

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Blizzard
2026-06-30 14:59:52 +08:00
parent aa61590b6c
commit 5736ad145e
12 changed files with 306 additions and 1 deletions
@@ -119,4 +119,16 @@ func (b *Bus) ConsumeIngestJobs(ctx context.Context, h sharedbus.IngestHandler)
return b.inner.ConsumeIngestJobs(ctx, h)
}
// ---- Prompt 控制面 ----
// ServePrompts 让网关响应「取全部激活 prompt」请求。
func (b *Bus) ServePrompts(provide func() map[string]string) (func() error, error) {
return b.inner.ServePrompts(provide)
}
// PublishPromptsUpdated 广播最新激活集 → 各服务热更新。
func (b *Bus) PublishPromptsUpdated(m map[string]string) error {
return b.inner.PublishPromptsUpdated(m)
}
func (b *Bus) Close() { b.inner.Close() }