Skip to content

fix(config-loader): cacheHitRate no longer exceeds 100%#500

Open
nikolasdehor wants to merge 1 commit intoSynkraAI:mainfrom
nikolasdehor:fix/config-loader-hit-rate-formula
Open

fix(config-loader): cacheHitRate no longer exceeds 100%#500
nikolasdehor wants to merge 1 commit intoSynkraAI:mainfrom
nikolasdehor:fix/config-loader-hit-rate-formula

Conversation

@nikolasdehor
Copy link
Contributor

@nikolasdehor nikolasdehor commented Feb 24, 2026

Resumo

  • Corrige fórmula cacheHitRate em getPerformanceMetrics() que podia ultrapassar 100%
  • Antes: hits / loads — como loads conta apenas leituras do disco e hits conta acessos ao cache, a taxa podia exceder 100%
  • Depois: hits / (hits + misses) — denominador correto que representa o total de consultas ao cache

Closes #499

Plano de teste

  • 25 testes unitários passam localmente
  • Inclui 2 testes de regressão para verificar que a taxa nunca excede 100%

Summary by CodeRabbit

  • Bug Fixes
    • Fixed cache hit rate metric calculation to ensure accurate percentage reporting bounded between 0-100%, improving reliability of performance metrics.

Copilot AI review requested due to automatic review settings February 24, 2026 20:45
Copy link

Copilot AI left a comment

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 fixes a bug where the cache hit rate calculation in config-loader.js could exceed 100%. The issue occurred because the denominator used only disk loads (cache misses) instead of total requests.

Changes:

  • Updated getPerformanceMetrics() to calculate cache hit rate as cacheHits / (cacheHits + cacheMisses) × 100
  • Added comprehensive unit tests (25 total) for the config-loader module
  • Included 2 regression tests specifically validating the fix for issue #499

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
tests/core/config/config-loader.test.js New test suite with 25 tests covering all config-loader functions and regression tests for bug #499
.aios-core/install-manifest.yaml Updated manifest with new file hashes, sizes, and generation timestamp
.aios-core/core/config/config-loader.js Fixed cache hit rate formula to use total requests as denominator

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@coderabbitai
Copy link

coderabbitai bot commented Feb 24, 2026

Walkthrough

This PR adds comprehensive unit tests for the config-loader module covering all exported functions, configuration validation, and caching behavior. It also fixes a calculation bug in getPerformanceMetrics where the cache hit rate denominator incorrectly used disk loads instead of total requests, which could cause the metric to exceed 100%.

Changes

Cohort / File(s) Summary
Test Suite Addition
tests/core/config/config-loader.test.js
Comprehensive unit test coverage for config-loader module including validation of constants, behavior of config loading functions (loadFullConfig, loadConfigSections, loadAgentConfig, loadMinimalConfig), cache behavior verification, performance metrics validation, and regression test for cacheHitRate calculation (issue #499).
Cache Metrics Bug Fix
.aiox-core/core/config/config-loader.js
Corrected cacheHitRate calculation in getPerformanceMetrics to use the sum of cacheHits and cacheMisses as the denominator instead of loads. This ensures the metric reflects total requests and remains bounded within [0, 100]%. Added explanatory comments with issue reference.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely summarizes the main fix: correcting the cacheHitRate formula to prevent it from exceeding 100%.
Linked Issues check ✅ Passed The changes fully implement the required fix from issue #499: cacheHitRate now uses (cacheHits + cacheMisses) as denominator with zero-request handling, plus comprehensive regression tests.
Out of Scope Changes check ✅ Passed All changes are directly related to the cacheHitRate fix objective; the test file addition and formula correction both support issue #499 requirements.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@vercel
Copy link

vercel bot commented Feb 24, 2026

@nikolasdehor is attempting to deploy a commit to the Pedro Valério Lopez's projects Team on Vercel.

A member of the Team first needs to authorize it.

coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 24, 2026
The old formula divided cacheHits by loads (disk reads only), which
could produce rates above 100% since most requests are cache hits that
never touch disk.

Use (cacheHits + cacheMisses) as the denominator for a correct
percentage.

25 unit tests including 2 regression tests for this fix.

Closes SynkraAI#499
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.aiox-core/core/config/config-loader.js (1)

1-1: ⚠️ Potential issue | 🟡 Minor

Pipeline failure: Manifest needs regeneration.

The CI indicates the manifest is outdated due to a hash mismatch for this file. Run the following to fix:

npm run generate:manifest

Then commit the updated manifest file.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.aiox-core/core/config/config-loader.js at line 1, The CI failure shows the
manifest hash for config-loader.js is out of date; regenerate the package
manifest and commit it by running the project script to rebuild manifests (npm
run generate:manifest), then add and commit the updated manifest file so the
hash for config-loader.js matches the repo.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In @.aiox-core/core/config/config-loader.js:
- Line 1: The CI failure shows the manifest hash for config-loader.js is out of
date; regenerate the package manifest and commit it by running the project
script to rebuild manifests (npm run generate:manifest), then add and commit the
updated manifest file so the hash for config-loader.js matches the repo.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f7dc480a-cebf-4784-a871-a79814d61bc2

📥 Commits

Reviewing files that changed from the base of the PR and between 020f272 and 60fb685.

📒 Files selected for processing (1)
  • .aiox-core/core/config/config-loader.js

@nikolasdehor
Copy link
Contributor Author

Oi @Pedrovaleriolopez @oalanicolas, esse fix é bem direto — corrige o cálculo de hit rate do cache que passava de 100%. Tem teste cobrindo o cenário. Podem dar uma olhada quando tiverem um momento?

@nikolasdehor
Copy link
Contributor Author

@Pedrovaleriolopez @oalanicolas, lembrando que esse fix está aberto desde 24/fev e agora surgiram PRs duplicados (#581, #582) com o mesmo fix. Nosso PR é o original — rebased, testado e pronto pra merge. Podem aprovar?

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.

bug: getPerformanceMetrics() cacheHitRate divides by disk loads instead of total requests

2 participants