Skip to content

fix(review): refresh capped RAG files on full reindex - #4405

Merged
JSONbored merged 1 commit into
mainfrom
codex/fix-rag-file-reindexing-for-capped-repos
Jul 9, 2026
Merged

fix(review): refresh capped RAG files on full reindex#4405
JSONbored merged 1 commit into
mainfrom
codex/fix-rag-file-reindexing-for-capped-repos

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Motivation

  • A full-RAG reindex could treat a repository already at MAX_CHUNKS_PER_REPO as fully done before inspecting per-path metadata, which prevented changed files from being deleted/replaced and left stale chunks in capped repos.

Description

  • Change src/review/rag-index.ts so the per-repo cap is checked only after consulting the stored per-path metadata and the unchanged-blob (blobSha) shortcut; the loop now allows processing a path if it has known stored chunks to delete and replace while still stopping for unknown/new paths once the cap is reached.
  • The new logic checks if (stored >= MAX_CHUNKS_PER_REPO && (!known || known.count <= 0)) to preserve the cap for genuinely new content but permit refreshes of existing paths.
  • Add a regression unit test in test/unit/rag-index.test.ts that seeds a repo already at the cap, marks one path as changed (new blob_sha) and asserts that the changed file is re-embedded and the repo remains capped overall.

Testing

  • Ran the targeted test: npx vitest run test/unit/rag-index.test.ts -t "refreshes changed files", and it passed (regression reproduced and fixed).
  • Ran the full test/unit/rag-index.test.ts; the targeted regression and related index tests passed, but three existing cron fan-out tests in that file timed out (15s timeout) and are unrelated to the cap change.
  • Verified repository-style checks locally (format/linters for the edited files) and no changed-line/style errors were produced.

Codex Task

@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@JSONbored JSONbored self-assigned this Jul 9, 2026
@JSONbored JSONbored added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 9, 2026
@JSONbored
JSONbored merged commit 86508fa into main Jul 9, 2026
7 checks passed
@JSONbored
JSONbored deleted the codex/fix-rag-file-reindexing-for-capped-repos branch July 9, 2026 09:32
@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.96%. Comparing base (64fb1a3) to head (90fc490).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4405   +/-   ##
=======================================
  Coverage   93.96%   93.96%           
=======================================
  Files         401      401           
  Lines       36892    36892           
  Branches    13490    13490           
=======================================
  Hits        34667    34667           
  Misses       1569     1569           
  Partials      656      656           
Files with missing lines Coverage Δ
src/review/rag-index.ts 93.90% <100.00%> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Development

Successfully merging this pull request may close these issues.

1 participant