Skip to content

fix(codex): -print-codex-config 读取未经 SQLite 覆盖的半成品配置——抽取 BootstrapPersistence 共享持久化引导#83

Open
KasumiNova wants to merge 1 commit into
mainfrom
fix/print-cmd-reads-sqlite-override
Open

fix(codex): -print-codex-config 读取未经 SQLite 覆盖的半成品配置——抽取 BootstrapPersistence 共享持久化引导#83
KasumiNova wants to merge 1 commit into
mainfrom
fix/print-cmd-reads-sqlite-override

Conversation

@KasumiNova

Copy link
Copy Markdown
Collaborator

根因:所有 -print-* 子命令在 SQLite 覆盖(cfg = *dbCfg)发生前就退出,而覆盖 逻辑只内联在 runTransform 内,导致 WebUI 编辑后的 provider/model/route 无法 被 -print-codex-config 读取,生成的 config.toml / models_catalog.json 是半成品。

方案:将 runTransform 内联的持久化引导(db.Registry 装配 + ConfigStore.LoadAll 覆盖 + 空库 seed)抽取为共享的 app.BootstrapPersistence,并新增轻量入口 app.TryLoadEffectiveConfig 供 print 路径使用。runTransform 与 main 的 print 路径 现在共享同一份覆盖语义,资源生命周期经 PersistenceResult.Shutdown 显式管理。

  • internal/service/app/persistence.go: 新增 PersistenceResult、BootstrapPersistence、TryLoadEffectiveConfig
  • internal/service/app/app.go: runTransform 改用 BootstrapPersistence,移除内联逻辑
  • cmd/moonbridge/main.go: print 分支前调用 TryLoadEffectiveConfig 覆盖 cfg
  • 新增 persistence_test.go(3 个单元测试)与 main_test.go 端到端回归测试

…sistence 共享持久化引导

根因:所有 -print-* 子命令在 SQLite 覆盖(cfg = *dbCfg)发生前就退出,而覆盖
逻辑只内联在 runTransform 内,导致 WebUI 编辑后的 provider/model/route 无法
被 -print-codex-config 读取,生成的 config.toml / models_catalog.json 是半成品。

方案:将 runTransform 内联的持久化引导(db.Registry 装配 + ConfigStore.LoadAll
覆盖 + 空库 seed)抽取为共享的 app.BootstrapPersistence,并新增轻量入口
app.TryLoadEffectiveConfig 供 print 路径使用。runTransform 与 main 的 print 路径
现在共享同一份覆盖语义,资源生命周期经 PersistenceResult.Shutdown 显式管理。

- internal/service/app/persistence.go: 新增 PersistenceResult、BootstrapPersistence、TryLoadEffectiveConfig
- internal/service/app/app.go: runTransform 改用 BootstrapPersistence,移除内联逻辑
- cmd/moonbridge/main.go: print 分支前调用 TryLoadEffectiveConfig 覆盖 cfg
- 新增 persistence_test.go(3 个单元测试)与 main_test.go 端到端回归测试
@KasumiNova KasumiNova requested a review from vfyjxf June 18, 2026 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant