refactor(config): dedup unit-interval validators and complete must_use sweep#4939
Merged
Conversation
…e sweep Replace 9 copy-pasted unit-interval serde deserializers with two shared generic helpers in de_helpers.rs: de_unit_open for the half-open (0.0, 1.0] interval and de_unit_closed for the closed [0.0, 1.0] interval, each generic over f32/f64 via a crate-private UnitFloat trait. Callers reference them via deserialize_with. Range and finiteness semantics are unchanged; the offending field stays pinpointed by the TOML parse span. Add #[must_use = "validation result must be checked"] to the remaining 7 validate(&self) -> Result<(), String> methods (GatewayConfig, TrajectorySentinelConfig, UtilityScoringConfig, LearningConfig, FidelityConfig, PlanCacheConfig, ExperimentConfig) so callers cannot silently discard the validation error. Closes #4935 Closes #4936
bug-ops
enabled auto-merge (squash)
June 6, 2026 16:13
This was referenced Jun 6, 2026
bug-ops
added a commit
that referenced
this pull request
Jun 7, 2026
…rkspace (#4974) Extends the #[must_use] sweep from PR #4939 to cover all remaining public validate-style functions that return non-() values. Annotated 15 functions across 9 crates: - zeph-config: VigilConfig::validate, Config::validate, two entry.rs validate() - zeph-skills: SkillRegistry::scan_loaded (body() skipped — Result already #[must_use]) - zeph-orchestration: DependencyGraph::validate, validate_verify_config - zeph-experiments: EvalCase::validate - zeph-common: MemoryConfig::validate - zeph-core: QualityConfig::validate - zeph-mcp: validate_command, validate_env - zeph-plugins: validate_url_scheme_ephemeral - zeph-tools: validate_sandbox_denied_domains, validate_domain_patterns Closes #4943, #4961, #4963
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.
Summary
Code-quality cleanup in
zeph-config, continuing the DRY/must_usesweep from #4928/#4930/#4934. Two related P3 refactors:#4935 — dedup unit-interval serde validators
Replaced 9 copy-pasted private deserializers with two shared generic helpers in the new
crates/zeph-config/src/de_helpers.rs:de_unit_open— half-open interval(0.0, 1.0]de_unit_closed— closed interval[0.0, 1.0]Both are generic over
f32/f64through a crate-privateUnitFloattrait, so the same two functions serve every caller via#[serde(deserialize_with = "crate::de_helpers::...")].Converted callers:
(0.0, 1.0]:embedding_guard.threshold,causal_ipi.threshold,shadow_memory.drift_threshold, the three classifier thresholds,decay_lambda,link_weight_decay_lambda[0.0, 1.0]:similarity_threshold(×6 acrossgraph.rs/hebbian.rs), admissionthreshold,fast_path_marginRange and finiteness semantics are unchanged. The only behavioral delta is the error text: the inline field-name prefix (e.g.
embedding_guard.threshold must be in ...) is dropped in favor of a generic message, because thetomlparser already pins the offending field and value via its parse span. Validators with non-unit ranges ([0.5, 1.0],[0.0, 10.0]) or distinct multi-bound messages (importance_weight) are intentionally left untouched.#4936 — complete the
#[must_use]sweepAdded
#[must_use = "validation result must be checked"]to the remaining 7validate(&self) -> Result<(), String>methods (GatewayConfig,TrajectorySentinelConfig,UtilityScoringConfig,LearningConfig,FidelityConfig,PlanCacheConfig,ExperimentConfig). PR #4934 already annotated the other 2; this covers the rest so a validation error can never be silently discarded.Notes
de_helpersitems arepub(crate);UnitFloatis crate-private.must_usevalidate()results.Verification
cargo +nightly fmt --check -p zeph-configcargo clippy -p zeph-config --all-targets --all-features -- -D warningscargo nextest run -p zeph-config --all-features— 525 passed (+4 newde_helperstests)RUSTFLAGS="-D warnings" cargo check --workspace --all-targets --features desktop,ide,server,chat,pdf,scheduler --locked— clean (confirms nounused_must_useregression)RUSTDOCFLAGS="--deny rustdoc::broken_intra_doc_links" cargo doc --no-deps --all-features -p zeph-config+cargo test --doc -p zeph-config— cleanCloses #4935
Closes #4936