Skip to content

refactor(config): replace stringly-typed fields with typed enums#4909

Merged
bug-ops merged 1 commit into
mainfrom
4899-4900-config-typed-fields
Jun 6, 2026
Merged

refactor(config): replace stringly-typed fields with typed enums#4909
bug-ops merged 1 commit into
mainfrom
4899-4900-config-typed-fields

Conversation

@bug-ops

@bug-ops bug-ops commented Jun 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • Replace SttConfig.provider: String with ProviderName newtype for consistency with all other provider-reference fields in providers.rs
  • Introduce CandleSource enum (Huggingface | Local) and CandleDevice enum (Cpu | Cuda | Metal | Auto) replacing bare String fields in CandleConfig and CandleInlineConfig
  • Remove default_stt_provider(), default_candle_source(), default_candle_device() helper functions replaced by #[serde(default)] on typed enums
  • select_device() in provider_factory.rs now takes CandleDevice; exhaustive match eliminates silent wildcard fallthrough

TOML backward compatibility preserved: #[serde(rename_all = "lowercase")] maps existing string values; device = "auto" continues to work via CandleDevice::Auto with identical Metal→CUDA→CPU fallback logic.

Closes #4899
Closes #4900

Test plan

  • cargo +nightly fmt --check — clean
  • cargo clippy --workspace -- -D warnings — clean
  • RUSTFLAGS="-D warnings" cargo check --workspace --all-targets --features desktop,ide,server,chat,pdf,scheduler --locked — clean
  • cargo nextest run --config-file .github/nextest.toml --workspace --lib --bins — 10519 passed, 21 skipped
  • cargo check -p zeph --features candle — clean (stale &str tests in bootstrap/tests.rs fixed)
  • Serde backward compat verified: existing TOML configs with provider = "...", source = "huggingface", device = "auto" parse correctly

@github-actions github-actions Bot added documentation Improvements or additions to documentation rust Rust code changes core zeph-core crate config Configuration file changes refactor Code refactoring without functional changes size/L Large PR (201-500 lines) labels Jun 6, 2026
…, #4900)

- SttConfig.provider: String → ProviderName for consistency with all
  other provider-reference fields in providers.rs
- CandleConfig/CandleInlineConfig: source: String → CandleSource enum
  (Huggingface | Local), device: String → CandleDevice enum
  (Cpu | Cuda | Metal | Auto); serde rename_all="lowercase" preserves
  TOML backward compatibility including device="auto"
- Remove default_stt_provider() and default_candle_{source,device}()
  helper functions; replaced by #[serde(default)] on enum types
- select_device() in provider_factory.rs takes CandleDevice; exhaustive
  match eliminates silent wildcard fallthrough
- Fix stale &str call sites in src/bootstrap/tests.rs

Closes #4899
Closes #4900
@bug-ops
bug-ops enabled auto-merge (squash) June 6, 2026 11:36
@bug-ops
bug-ops force-pushed the 4899-4900-config-typed-fields branch from 23f2d68 to 015aa4d Compare June 6, 2026 11:36
@bug-ops
bug-ops merged commit 32158cc into main Jun 6, 2026
32 checks passed
@bug-ops
bug-ops deleted the 4899-4900-config-typed-fields branch June 6, 2026 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

config Configuration file changes core zeph-core crate documentation Improvements or additions to documentation refactor Code refactoring without functional changes rust Rust code changes size/L Large PR (201-500 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

config: CandleConfig.source and .device are stringly-typed; should use enums config: SttConfig.provider should use ProviderName instead of String

1 participant