Skip to content

Conversation

@gitauto-ai
Copy link
Contributor

@gitauto-ai gitauto-ai bot commented Apr 27, 2025

Resolves #222

Test these changes locally

git fetch origin
git checkout gitauto/issue-222-20250427-035619
git pull origin gitauto/issue-222-20250427-035619

Summary by Sourcery

Add a caching layer for generated commit messages to avoid re-generating responses for identical inputs.

New Features:

  • Introduce a service to cache commit message generation results.
  • Implement file-based caching using the user's application data folder.
  • Cache entries are specific to the AI model used and expire after 30 days.
  • Validate cache integrity using checksums.

@korbit-ai
Copy link

korbit-ai bot commented Apr 27, 2025

By default, I don't review pull requests opened by bots. If you would like me to review this pull request anyway, you can request a review via the /korbit-review command in a comment.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Apr 27, 2025

Reviewer's Guide by Sourcery

This pull request introduces a model-aware response cache service for commit messages. It implements caching using a file-based provider that stores data in the user's application data directory with a 30-day time-to-live.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Introduce an interface for cache providers.
  • Define methods for generating a cache key hash, loading a cached entry, and saving a cache entry.
Src/AiCommitMessage/Services/Cache/ICacheProvider.cs
Implement a file-based cache provider.
  • Store cache files in the user's application data directory or a configurable path.
  • Generate cache keys using SHA256 hashing of model, branch, author message, and diff.
  • Load cached responses from JSON files, validating against model, timestamp (30-day TTL), and checksum.
  • Delete expired or invalid cache files upon load attempt.
  • Save responses as JSON files including model, response, checksum, and timestamp.
  • Compute checksums for cached content using SHA256.
Src/AiCommitMessage/Services/Cache/FileCacheProvider.cs
Create a service to manage commit message caching.
  • Depend on the ICacheProvider interface.
  • Generate a cache key based on input parameters.
  • Attempt to load the response from the cache.
  • If not found, generate the response using a provided function.
  • Save the generated response to the cache.
  • Print console messages indicating cache hit or miss.
Src/AiCommitMessage/Services/Cache/CommitMessageCacheService.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#222 Implement a reusable and testable caching layer for commit message generation results from the OpenAI API.
#222 Store cached responses in a platform-agnostic location under the user's AppData/config directory, with optional override via COMMIT_CACHE_PATH env var.
#222 Use a model-aware SHA256 hash for lookup, include a checksum for validation, and apply a 30-day TTL.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 27, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

@gstraccini gstraccini bot added enhancement New feature or request good first issue Good for newcomers hacktoberfest Participation in the Hacktoberfest event help wanted Extra attention is needed 👷🏼 infrastructure Infrastructure-related tasks or issues 📝 documentation Tasks related to writing or updating documentation 🕔 high effort A task that can be completed in a few days 🧪 tests Tasks related to testing labels Apr 27, 2025
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

We have skipped reviewing this pull request. It seems to have been created by a bot (hey, gitauto-ai[bot]!). We assume it knows what it's doing!

@deepsource-io
Copy link

deepsource-io bot commented Apr 27, 2025

Here's the code health analysis summary for commits e284767..9d240dc. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource Test coverage LogoTest coverage❌ Failure
❗ 2 occurences introduced
View Check ↗
DeepSource Secrets LogoSecrets✅ SuccessView Check ↗
DeepSource Docker LogoDocker✅ SuccessView Check ↗
DeepSource C# LogoC#❌ Failure
❗ 3 occurences introduced
View Check ↗

Code Coverage Report

MetricAggregateC#
Branch Coverage44.5% (down 7.1% from main)44.5% (down 7.1% from main)
Condition Coverage44.5% (down 7.1% from main)44.5% (down 7.1% from main)
Composite Coverage45.6% (down 7.3% from main)45.6% (down 7.3% from main)
Line Coverage45.9% (down 7.4% from main)45.9% (down 7.4% from main)
New Branch Coverage0%0%
New Condition Coverage0%0%
New Composite Coverage0%0%
New Line Coverage0%0%

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

@github-actions github-actions bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Apr 27, 2025
@gstraccini gstraccini bot added 🚦 awaiting triage Items that are awaiting triage or categorization 🤖 bot Automated processes or integrations labels Apr 27, 2025
@guibranco guibranco added the gitauto GitAuto label to trigger the app in a issue. label May 6, 2025
@github-actions
Copy link
Contributor

github-actions bot commented May 14, 2025

🔥 Formatting issues detected

File Line
./Src/AiCommitMessage/Services/Cache/FileCacheProvider.cs 27

⚡ Please run dotnet csharpier . locally to fix the formatting issues.

@guibranco
Copy link
Owner

@gstraccini csharpier

@gstraccini
Copy link
Contributor

gstraccini bot commented May 14, 2025

Running CSharpier on this branch! 🔧

@gstraccini
Copy link
Contributor

gstraccini bot commented May 14, 2025

CSharpier result:

Error ./Src/AiCommitMessage/Services/Cache/CommitMessageCacheService.cs - Was not formatted.
  ----------------------------- Expected: Around Line 20 -----------------------------
              string diff,
              Func<Task<string>> generateFunc
          )
  ----------------------------- Actual: Around Line 20 -----------------------------
              string diff,
              Func<Task<string>> generateFunc)
          {
  
Error ./Src/AiCommitMessage/Services/Cache/FileCacheProvider.cs - Was not formatted.
  ----------------------------- Expected: Around Line 9 -----------------------------
      {
          private record CachedResponse(
              string Model,
  ----------------------------- Actual: Around Line 9 -----------------------------
      {
          private record CachedResponse(string Model, string Response, string Checksum, DateTime Timestamp);
  
  
Formatted 23 files in 551ms.

@guibranco
Copy link
Owner

@gstraccini csharpier

@gstraccini
Copy link
Contributor

gstraccini bot commented Jul 15, 2025

Running CSharpier on this branch! 🔧

@gstraccini
Copy link
Contributor

gstraccini bot commented Jul 15, 2025

CSharpier result:

Error ./Src/AiCommitMessage/Services/Cache/FileCacheProvider.cs - Was not formatted.
  ----------------------------- Expected: Around Line 27 -----------------------------
              {
                  var baseDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                  if (string.IsNullOrWhiteSpace(baseDir))
  ----------------------------- Actual: Around Line 27 -----------------------------
              {
                  var baseDir = Environment.GetFolderPath(
                      Environment.SpecialFolder.ApplicationData
  
Formatted 23 files in 474ms.

@gstraccini
Copy link
Contributor

gstraccini bot commented Jul 15, 2025

ℹ️ Workflow Template updated!

A new workflow template has been added: .github/workflows/linter.yml

@guibranco
Copy link
Owner

@gstraccini review

@github-actions
Copy link
Contributor

github-actions bot commented Nov 3, 2025

Infisical secrets check: ✅ No secrets leaked!

💻 Scan logs
6:19AM INF scanning for exposed secrets...
6:19AM INF 240 commits scanned.
6:19AM INF scan completed in 69.2ms
6:19AM INF no leaks found

@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 3, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🚷 blocked Task or issue is currently blocked 🤖 bot Automated processes or integrations 📝 documentation Tasks related to writing or updating documentation enhancement New feature or request gitauto GitAuto label to trigger the app in a issue. good first issue Good for newcomers hacktoberfest Participation in the Hacktoberfest event help wanted Extra attention is needed 🕔 high effort A task that can be completed in a few days 👷🏼 infrastructure Infrastructure-related tasks or issues size/L Denotes a PR that changes 100-499 lines, ignoring generated files. 🧪 tests Tasks related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Add model-aware response cache service with AppData storage and 30-day TTL

2 participants