perf(review): skip duplicate full-file grounding fetch for added files#3918
Conversation
Every line of a newly added file is already a '+' line in the diff sent in the same prompt, so fetchFullFileContents re-fetching and re-inlining its full content duplicated that content byte-for-byte -- a wasted GitHub API round-trip and wasted prompt budget on every AI-reviewed PR under the recommended self-host grounding config. Closes #3897
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
|
Tip 🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 ✅ Gittensory review result - approve/merge recommendedReview updated: 2026-07-07 06:59:43 UTC
✅ Suggested Action - Approve/Merge
Review summary Nits — 4 non-blocking
Review context
Contributor next steps
Signal definitions
🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3918 +/- ##
=======================================
Coverage 93.58% 93.58%
=======================================
Files 358 358
Lines 34342 34342
Branches 12570 12570
=======================================
Hits 32138 32138
Misses 1580 1580
Partials 624 624
🚀 New features to boost your workflow:
|
Summary
fetchFullFileContents(grounding, on by default in the self-host starter env viaGITTENSORY_REVIEW_GROUNDING=true) fetched and inlined the full post-change content of every changed file whosestatus !== "removed", including newly ADDED files.+line in the diff, which is sent in the same prompt (up to 120,000 chars). So the full-file fetch for an added file was a byte-for-byte duplicate of content already present — a wasted GitHub Contents API round-trip and wasted prompt budget on every AI-reviewed PR under the recommended grounding config.status !== "added"to the existing candidate filter (same treatment as"removed"), and extended the existing "skips removed/binary" test to also assert an added file is excluded and never fetched.PullRequestFiledoesn't currently carry patch/line-count data, so a "skip when the diff already covers most of a modified file" refinement would need a bigger interface change; out of scope here.Found via a fresh performance/scalability/accuracy hardening audit of the self-host ORB stack. Tracked under #1667.
Scope
src/review/review-grounding.ts— excludestatus === "added"from the full-file-content candidate filtertest/unit/review-grounding.test.ts— cover the new exclusionValidation
npm run typechecknpx vitest run test/unit/review-grounding.test.ts --coverage— 20/20 passing; 100% line coverage, changed lines fully covered (remaining uncovered branches are pre-existing and untouched by this diff)git diff --checkcleanSafety
Closes #3897