Skip to content

refactor(config): add validation for semantic_cache_threshold#2043

Merged
bug-ops merged 2 commits intomainfrom
feat-issue-2036
Mar 20, 2026
Merged

refactor(config): add validation for semantic_cache_threshold#2043
bug-ops merged 2 commits intomainfrom
feat-issue-2036

Conversation

@bug-ops
Copy link
Owner

@bug-ops bug-ops commented Mar 20, 2026

Summary

Add validation for llm.semantic_cache_threshold config parameter to ensure values are in the valid range [0.0, 1.0] and are finite (rejecting NaN/Inf).

Changes

  • crates/zeph-config/src/loader.rs: Added validation check in Config::validate() after env overrides are applied. Validation runs once at bootstrap and rejects invalid values with an actionable error message.
  • CHANGELOG.md: Added entry under [Unreleased] section
  • Test coverage: 8 new unit tests covering boundary cases (0.0, 0.5, 1.0), out-of-range (-0.1, 1.1), and IEEE 754 special values (NaN, +Inf, -Inf)

Validation Details

  • Range: [0.0, 1.0] inclusive (consistent with cosine similarity threshold domain)
  • Location: Config::validate() in loader.rs — catches all config load paths (TOML, env override, TUI, CLI)
  • Behavior: Rejects (ConfigError) invalid values, does not clamp
  • Error message: Includes field name and env var override hint for user guidance

Test Results

  • All 6022 tests passing (+8 new)
  • No regressions
  • Pre-commit checks: ✓ fmt ✓ clippy ✓ nextest

Fixes

Fixes #2036

Add Config::validate() check to ensure llm.semantic_cache_threshold is in [0.0, 1.0] and finite. Rejects NaN/Inf and out-of-range values at startup with actionable error message.

Fixes #2036
@github-actions github-actions bot added documentation Improvements or additions to documentation rust Rust code changes refactor Code refactoring without functional changes size/M Medium PR (51-200 lines) labels Mar 20, 2026
@bug-ops bug-ops enabled auto-merge (squash) March 20, 2026 13:59
@bug-ops bug-ops merged commit bbdbdb7 into main Mar 20, 2026
25 checks passed
@bug-ops bug-ops deleted the feat-issue-2036 branch March 20, 2026 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation refactor Code refactoring without functional changes rust Rust code changes size/M Medium PR (51-200 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: clamp semantic_cache_threshold to [0.0, 1.0]

1 participant