refactor(config):配置快照与 Provider Selection 边界收口#239
Merged
Conversation
# Conflicts: # docs/guides/configuration.md # internal/config/model.go # internal/tui/core/app/update_test.go
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Collaborator
Author
|
/review -codex |
Collaborator
Author
|
/review -codex |
| `config.yaml` 里的 `selected_provider/current_model` 表达的是“用户上次保存的选择状态”。 | ||
|
|
||
| ## 故障排查 | ||
| 启动时系统还会基于当前 provider、driver 支持情况和模型目录快照执行选择修正。因此需要区分两件事: |
Contributor
There was a problem hiding this comment.
这里写“启动时会基于 driver 支持情况执行选择修正”,但当前实现在已选 provider 的 driver 不受支持时会直接返回 ErrDriverUnsupported,不会自动切换到其他 provider(internal/config/state/service.go 中 ensureSupportedProvider 的调用路径)。建议把文案改成“会进行选择校验与必要修正;若 driver 不受支持会报错并中止”之类,和真实行为保持一致。
Collaborator
Author
|
/code -codex 只允许你帮我提高测试覆盖率 |
Contributor
完成情况已按你的要求仅做“提升测试覆盖率”,未改任何业务实现代码。 已完成内容
覆盖率结果(本地)
提交信息
额外说明
|
Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: phantom5099 <245659304+phantom5099@users.noreply.github.com>
test(config): improve selection state branch coverage
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
变更说明
本次本地改动围绕
config / provider selection / runtime provider 输入做了一次边界收口。目标不是继续兼容旧配置,也不是增加新的抽象层,而是把当前实现里已经承担不同职责的几部分逻辑拆清楚:
config负责配置快照、静态默认值、YAML 持久化与 provider 装配config/state负责当前selected_provider/current_model的选择与修正provider_runtime负责把解析后的 provider 配置收敛成 provider 层真正消费的运行时输入同时,文档和测试也同步更新为当前真实实现,避免继续保留与代码冲突的旧表述。
主要改动
StaticDefaults(),明确它只表示静态默认值骨架,不再暗示“完整可运行配置”。Config.Validate()收紧为ValidateSnapshot(),明确它只校验配置快照结构,不负责修正selected_provider/current_model的运行时可用性。internal/config/selection.go,把 provider/model 选择逻辑下沉到internal/config/state:state.ServiceSelection、ProviderOptionEnsureSelection / SelectProvider / SetCurrentModel / ListModels的职责边界provider_adapter.go重命名为provider_runtime.go,把解析后的ResolvedProviderConfig显式转换为provider.RuntimeConfig,避免上层直接共享 config 结构细节。Loader的语义:config.yamlapp/runtime/tui对 provider 选择服务的接入方式,使上层依赖config/state.Service而不是继续直接耦合旧的 config 内部选择实现。.envworkdir不进入config.yamlValidateSnapshot()不等于 runtime-ready预期收益
config的职责边界更清楚,后续不容易继续往里塞 selection、catalog 或 runtime 语义。config根包中分离出来,后续维护和测试成本更低。