fix: normalize Conda environment cache keys (Fixes #488) - #490
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Test Coverage Report (Linux)
Coverage increased! Great work! |
Performance Report (Linux) ➖
Legend
|
Test Coverage Report (Windows)
Coverage increased! Great work! |
Performance Report (macOS)
Legend
|
Performance Report (Windows) ➖
Legend
|
There was a problem hiding this comment.
Pull request overview
This PR updates PET’s Conda locator to normalize the keys used by the shared Conda environment metadata cache, improving cross-refresh reuse (especially on Windows where the same path can appear with different casing/separators) while keeping the fingerprint-based invalidation behavior introduced in #487.
Changes:
- Normalize Conda environment metadata cache keys (
norm_case) for cache lookup, insertion, and removal. - Use normalized prefixes when pruning stale cache entries after discovery refresh.
Show a summary per file
| File | Description |
|---|---|
| crates/pet-conda/src/lib.rs | Normalizes Conda environment-info cache keys and uses normalized active prefixes when pruning stale cache entries. |
Review details
Comments suppressed due to low confidence (1)
crates/pet-conda/src/lib.rs:185
- Because the cache key is now normalized, a lookup for the same on-disk env using a differently-cased / differently-formatted path can return cached details whose
environment.prefixreflects the first path that populated the cache, not thepathrequested in this call. Callers (e.g.try_from/find) assume the returned environment details correspond to the input prefix, and this mismatch can lead to inconsistent reported prefixes and duplicate internal entries keyed by one path while carrying another in the value.
Consider patching the cached result before returning so environment.prefix always matches the requested path.
.expect("conda environment info cache lock poisoned")
.get(&cache_key)
.filter(|cached| &cached.fingerprint == fingerprint)
{
return Some(cached.details.clone());
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Low
Add Windows regression coverage for equivalent separator styles while ensuring cache hits return the caller's requested prefix. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
## Summary - add a PET-wide Rust coding skill alongside locator-specific guidance - capture path identity/cache, Unicode-safe parsing, hot-path I/O/allocation, and cross-platform rules - require tests to prove claimed read-count, cache-hit, and event-count invariants - wire the recurring checks into the Reviewer agent for every Rust change ## Review retrospective Recent feedback clustered around: - normalized cache keys and caller-facing path preservation (#487, #490) - Unicode-safe byte indexing and ASCII format handling (#493) - proving optimization scope and read counts (#493) - duplicate side effects and precise pattern semantics (#495) - workflow assignment/merge postconditions, already addressed in #486 Fixes #496 --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Summary
Validation
cargo test -p pet-conda environment_info_cache_.\scripts\rust-precommit.ps1Fixes #488