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
@@ -133,4 +133,14 @@ func (s *Subscriber) FetchModelConfigWithRetry(ctx context.Context, apply func(*
s.inner.RequestConfigWithRetry(ctx, contract.ConfigKindChat, apply)
}
// FetchPromptsWithRetry 后台重试拉取初始激活 prompt 集(覆盖内置默认)。
func (s *Subscriber) FetchPromptsWithRetry(ctx context.Context, apply func(map[string]string)) {
s.inner.RequestPromptsWithRetry(ctx, apply)
}
// SubscribePromptsUpdated 订阅 prompt 激活集热更新。
func (s *Subscriber) SubscribePromptsUpdated(onUpdate func(map[string]string)) (func() error, error) {
return s.inner.SubscribePromptsUpdated(onUpdate)
}
func (s *Subscriber) Close() { s.inner.Close() }