Skip to content

Conversation

@wpfleger96
Copy link
Collaborator

@wpfleger96 wpfleger96 commented Oct 8, 2025

Summary

This PR fixes a cache contamination bug where the analyze tool's (from Developer extension) LRU cache would incorrectly return cached results from one analysis mode (e.g., Structure) when a different mode (e.g., Semantic) was requested. The root cause was that the cache key only included the file path and modification time, but not the analysis mode, allowing different modes to overwrite each other's cached data.

The fix adds the AnalysisMode enum as a third component to the CacheKey struct, ensuring that each combination of (path, modified time, mode) creates a separate cache entry. This prevents Structure mode's lightweight directory data from contaminating Semantic mode's detailed AST analysis results, which was problematic when both modes were used sequentially in the same session and would cause the tool to return incomplete results.

Type of Change

  • Feature
  • Bug fix
  • Refactor / Code quality
  • Performance improvement
  • Documentation
  • Tests
  • Security fix
  • Build / Release
  • Other (specify below)

Testing

I added a unit test for validating cache separation, and I also tested this manually on a local codebase

Related Issues

Fixes #5074

@wpfleger96 wpfleger96 changed the title Prevent cross-contamination of cache data across analysis modes Fix: Prevent cross-contamination of cache data across analysis modes Oct 8, 2025
@wpfleger96
Copy link
Collaborator Author

Now when I run the same test that I did in #5074, we see the complete and accurate results:

Yes! This time the focused analysis found more complete results. The key improvements are:

**Better Coverage:**
- **11 incoming chains** (vs 10 previously) - now includes the cross-package reference
- **3 files analyzed** (F1, F2, F3) instead of just 2

**Cross-Package Reference Found:**
- `F1:23` - This is the reference in `/Users/wpfleger/Development/oncall-buddy/cmd/main.go` at line 23, which corresponds to the `Run *oncallbuddy.RunCmd` field we found with ripgrep

**Complete File Mapping:**
- F1: `/Users/wpfleger/Development/oncall-buddy/cmd/main.go` (the main command structure)
- F2: `/Users/wpfleger/Development/oncall-buddy/pkg/oncallbuddy/main.go` (where RunCmd is defined)
- F3: `/Users/wpfleger/Development/oncall-buddy/pkg/oncallbuddy/main_test.go` (the test file)

**Definition Location:**
- Shows `F2:87 - RunCmd` which correctly identifies the struct definition at line 87 in the main.go file

So this second run captured the complete picture of the `RunCmd` symbol, including:
1. The struct type definition (line 87)
2. All its methods and their call chains
3. The cross-package reference from cmd/main.go
4. All test references

@tlongwell-block
Copy link
Collaborator

Confirmed the bug and the fix locally

@tlongwell-block tlongwell-block merged commit c2e920a into block:main Oct 8, 2025
14 of 15 checks passed
@alexhancock alexhancock mentioned this pull request Oct 9, 2025
michaelneale added a commit that referenced this pull request Oct 9, 2025
* main: (170 commits)
  Applied server side call to parse and save recipe (#5022)
  feat(prompt-library): add Code Documentation Migrator intermediate prompt (#4996) (#5051)
  Add Messy Column Fixer recipe (#5062)
  Cleanup temp files (#5081)
  add openmetadata recipe (#5076)
  Fix Hacktoberfest Leaderboard (#5080)
  adding brand guidelines to AGENTS.md (#4887)
  Fix: Prevent cross-contamination of cache data across analysis modes for `analyze` tool (#5075)
  fix: remove circular reference (#5018)
  Introduced a new prompt for content amplification that integrates multi-step workflows using official Goose extensions. Closes Issue #4998 (#5050)
  Add hint for focus mode when used on file paths for `analyze` tool (#5069)
  fix: use dynamic port allocation for OAuth server (#5019)
  Art vandelay: Import & Export (#5053)
  docs: misc updates for extensions directory (#5035)
  updating recipe scanner workflows for detecting recipes from forked repos (#5056)
  feat(prompt-library): add Smart Meeting Assistant advanced prompt (#4998) (#5031)
  Allow auto focus and typing while chat is initializing (#5043)
  docs(blog): Add blog for running Goose in containerized envs  (#5052)
  fix: Add WINDOWS_CODESIGN_CERTIFICATE to nightly workflow (#5037)
  Developer `analyze` tool improvement (#5030)
  ...
tlongwell-block added a commit that referenced this pull request Oct 10, 2025
* origin/main:
  Improve Rust analysis output for `analyze` tool (#5072)
  Remove duplicate prepare_reply_context call (#5063)
  install react dev tools in development (#4979)
  Doc: Added powershell installation link to the guide (#5012)
  draft of new blog post about automating more automation (#5038)
  Subagent extension selection behavior fix (#5093)
  Add dev and alpha environment indicator (#5092)
  docs: add content carousel (#5086)
  Applied server side call to parse and save recipe (#5022)
  feat(prompt-library): add Code Documentation Migrator intermediate prompt (#4996) (#5051)
  Add Messy Column Fixer recipe (#5062)
  Cleanup temp files (#5081)
  add openmetadata recipe (#5076)
  Fix Hacktoberfest Leaderboard (#5080)
  adding brand guidelines to AGENTS.md (#4887)
  Fix: Prevent cross-contamination of cache data across analysis modes for `analyze` tool (#5075)
  fix: remove circular reference (#5018)
  Introduced a new prompt for content amplification that integrates multi-step workflows using official Goose extensions. Closes Issue #4998 (#5050)
  Add hint for focus mode when used on file paths for `analyze` tool (#5069)
  fix: use dynamic port allocation for OAuth server (#5019)
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.

Cross-contamination of cache data across analysis modes in Developer extension

2 participants