Skip to content

fix(config): load provider shortcuts from cora yaml - #178

Merged
ajianaz merged 1 commit into
codecoradev:developfrom
sarvesh1327:fix/hook-load-yaml-model
Jun 6, 2026
Merged

ajianaz merged 1 commit into
codecoradev:developfrom
sarvesh1327:fix/hook-load-yaml-model

Conversation

@sarvesh1327

Copy link
Copy Markdown
Contributor

Summary

Test Plan

  • cargo test config::schema::tests::merge_top_level_provider_shortcuts --quiet
  • cargo test config::schema::tests --quiet
  • cargo test --test config_loading --quiet
  • cargo fmt --check
  • cargo test --quiet

Closes #176

@ajianaz ajianaz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: Approved ✅

What it does

Adds support for top-level model:, base_url:, and bare-string provider: in .cora.yaml, so users can write:

provider: openai
model: glm-5.1
base_url: https://api.z.ai/api/coding/paas/v4

instead of needing the nested format:

provider:
  provider: openai
  model: glm-5.1
  base_url: https://api.z.ai/api/coding/paas/v4

Code Quality

Aspect Verdict
Logic correctness ✅ deserialize_provider_section with untagged enum handles both bare string and section correctly
Merge precedence ✅ Top-level model/base_url applied first, then nested provider: section can override — more specific wins
Edge case: provider: null ✅ Returns Ok(None)
Edge case: bare provider: openai ✅ Wraps into ProviderSection { provider: Some("openai"), ..Default::default() }
Tests ✅ New test covers the exact scenario from issue #176
Format / Clippy ✅ Clean locally
Backward compat ✅ Nested format still works, nothing breaks

Minor observations (non-blocking)

  1. model + provider.model conflict: If user writes both top-level model: glm-5.1 AND nested provider: { model: gpt-4o }, the nested one wins (applied second). This is the correct behavior but not documented. Consider a note in docs.

  2. provider field has dual types now: The custom deserializer handles this cleanly, but it means .cora.yaml schema is no longer a simple struct — tooling (schema validators, IDE yaml completion) might not understand the polymorphic provider field. Low impact for now.

Test Results

cargo test merge_top_level_provider_shortcuts — PASS
cargo test config::schema::tests (51 tests) — ALL PASS
cargo fmt --check — PASS
cargo clippy — PASS

LGTM — ready to merge after maintainer approval. Fixes the real pain point from #176.

@ajianaz
ajianaz merged commit d83df0e into codecoradev:develop Jun 6, 2026
10 of 11 checks passed
ajianaz added a commit that referenced this pull request Jun 6, 2026
- Change trigger from pull_request to pull_request_target for write access
- Explicit checkout of PR head SHA for correct diff
- Bump version 0.4.1 → 0.4.2
- Includes provider shortcuts from PR #178

Co-authored-by: Zeko (Hermes) <[email protected]>
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.

Poor UX setting up pre-commit hook: model/provider/base_url not picked up from .cora.yaml

2 participants