Skip to content

fix: normalize Conda environment cache keys (Fixes #488) - #490

Merged
Karthik Nadig (karthiknadig) merged 2 commits into
mainfrom
fix/issue-489
Jul 27, 2026
Merged

fix: normalize Conda environment cache keys (Fixes #488)#490
Karthik Nadig (karthiknadig) merged 2 commits into
mainfrom
fix/issue-489

Conversation

@karthiknadig

@karthiknadig Karthik Nadig (karthiknadig) commented Jul 27, 2026

Copy link
Copy Markdown
Member

Summary

  • normalize Conda environment metadata cache keys before lookup and insertion
  • use normalized keys when removing stale entries and pruning deleted prefixes
  • preserve caller-requested prefixes on cache hits
  • add Windows coverage for equivalent separator styles

Validation

  • cargo test -p pet-conda environment_info_cache_
  • .\scripts\rust-precommit.ps1

Fixes #488

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@karthiknadig
Karthik Nadig (karthiknadig) marked this pull request as ready for review July 27, 2026 02:45
@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown

Test Coverage Report (Linux)

Metric Value
Current Coverage 80.4%
Base Branch Coverage 80.3%
Delta .1% ✅

Coverage increased! Great work!

@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown

Performance Report (Linux) ➖

Metric PR (P50) PR (P95) Baseline (P50) Delta Change
Server Startup 1ms 1ms 1ms 0ms 0%
Full Refresh 70ms 365ms 58ms 12ms 20.0%

Results based on 10 iterations. P50 = median, P95 = 95th percentile.


Legend
  • 🚀 Significant speedup (>100ms faster)
  • ✅ Faster than baseline
  • ➖ No significant change
  • 🔺 Slower than baseline (>100ms)
  • ⚠️ Significant slowdown (>500ms)

@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown

Test Coverage Report (Windows)

Metric Value
Current Coverage 77.19%
Base Branch Coverage 77.17%
Delta 0.02% ✅

Coverage increased! Great work!

@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown

Performance Report (macOS)

Metric PR (P50) PR (P95) Baseline (P50) Delta
Server Startup 47ms 531ms 51ms -4ms
Full Refresh 85ms 30291ms 88ms -3ms

Results based on 10 iterations. P50 = median, P95 = 95th percentile.


Legend
  • 🚀 Significant speedup (>100ms faster)
  • ✅ Faster than baseline
  • ➖ No significant change
  • 🔺 Slower than baseline (>100ms)
  • ⚠️ Significant slowdown (>500ms)

@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown

Performance Report (Windows) ➖

Metric PR (P50) PR (P95) Baseline (P50) Delta Change
Server Startup 7ms 10ms 6ms 1ms 16.7%
Full Refresh 95ms 1030ms 90ms 5ms 5.6%

Results based on 10 iterations. P50 = median, P95 = 95th percentile.


Legend
  • 🚀 Significant speedup (>100ms faster)
  • ✅ Faster than baseline
  • ➖ No significant change
  • 🔺 Slower than baseline (>100ms)
  • ⚠️ Significant slowdown (>500ms)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.prefix reflects the first path that populated the cache, not the path requested 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

Comment thread crates/pet-conda/src/lib.rs
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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review details

  • Files reviewed: 1/1 changed files
  • Comments generated: 0 new
  • Review effort level: Low

@karthiknadig Karthik Nadig (karthiknadig) changed the title fix: normalize Conda environment cache keys (Fixes #489) fix: normalize Conda environment cache keys (Fixes #488) Jul 27, 2026
@karthiknadig
Karthik Nadig (karthiknadig) merged commit d13f6f4 into main Jul 27, 2026
38 checks passed
@karthiknadig
Karthik Nadig (karthiknadig) deleted the fix/issue-489 branch July 27, 2026 18:44
Karthik Nadig (karthiknadig) added a commit that referenced this pull request Aug 5, 2026
## 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>
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.

Path casing issue with environment_info_cache

3 participants