Skip to content

fix(review): prioritize manifest/config files in RAG indexing before the chunk cap - #3438

Merged
loopover-orb[bot] merged 1 commit into
mainfrom
fix/rag-index-manifest-priority
Jul 5, 2026
Merged

fix(review): prioritize manifest/config files in RAG indexing before the chunk cap#3438
loopover-orb[bot] merged 1 commit into
mainfrom
fix/rag-index-manifest-priority

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

  • Found via direct production investigation: repoDocGeneration (a self-hosted repo-doc generation feature) reported "Package manager: not detected / Build: none detected / Test: none detected / Lint: none detected" for JSONbored/gittensory in its generated AGENTS.md, while a sibling repo with the same npm setup detected correctly. Root cause traced to a missing package.json row in repo_chunks (confirmed via direct DB query) — gittensory's RAG index hit the hard MAX_CHUNKS_PER_REPO = 1500 cap exactly, and package.json never made it in.
  • indexRepo's pre-cap sort (src/review/rag-index.ts) only used filePriority (code=0 vs doc=1) — every source file, including package.json, ties at priority 0 and falls to an alphabetical tiebreaker, so on a repo over the cap, alphabetically-late root manifests lose to the sheer volume of src/**/test/** files. This isn't just a repo-doc-generation bug — it means RAG-grounded AI review context for the same large repo is also missing its own manifest/config files.
  • Fix: added a manifestPriority sort key that puts small, high-value manifest/config files (package.json, tsconfig*.json, wrangler.*, pnpm-workspace.yaml, go.mod, Cargo.toml, pyproject.toml, requirements*.txt, etc.) ahead of the existing code/doc split — reusing the same isDependencyManifestFile/isConfigFile classifiers src/signals/path-matchers.ts already exports for slop classification, rather than inventing a second filename vocabulary. This only reorders indexing priority; it doesn't change what's eligible (these are already indexable — JSON/TOML/YAML match CODE_EXT_RE).
  • Also closed a related, compounding gap found while tracing this: go.mod/go.work (extensionless, like Dockerfile/Makefile) were missing from ALLOW_EXTLESS_RE and were unconditionally skipped regardless of repo size or cap — added them (their lockfile siblings go.sum/go.work.sum remain excluded via the existing lockfile skip rule, which runs first).
  • No issue filed — found via direct investigation of a live production symptom, not a report.

Scope

  • The PR title follows type(scope): short summary Conventional Commit format, for example fix(api): restore profile access checks.
  • This PR is focused and does not mix unrelated backend, UI, MCP, docs, dependency, and deploy changes.
  • This follows CONTRIBUTING.md and does not reintroduce GitHub Pages, VitePress, site/, or CNAME.
  • I linked an issue, or this is small enough that the summary explains why an issue is not needed.

Validation

  • git diff --check
  • npm run typecheck (clean)
  • npx vitest run test/unit/rag-index.test.ts test/unit/rag.test.ts test/unit/path-matchers.test.ts — 157/157 passing
  • npm run test:workers / npm run build:mcp / npm run test:mcp-pack / npm run ui:openapi:check / npm run ui:build — not run individually this PR; no worker/MCP/OpenAPI/UI surface touched.
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries — added: a repo whose file count exceeds MAX_CHUNKS_PER_REPO still gets every manifest file (8 distinct manifest/config filenames tested) indexed under the cap; an under-cap repo shows byte-identical existing behavior when the cap never matters; go.mod/go.work (including nested paths) classify as indexable code while go.sum still correctly skips (precedence check).

Safety

  • No secrets, wallet details, hotkeys, coldkeys, user PATs, private keys, raw trust scores, private rankings, or private maintainer evidence are exposed.
  • Public GitHub text stays sanitized, low-noise, and does not imply compensation guarantees or optimization tactics.
  • Auth, cookie, CORS, GitHub App, Cloudflare, or session changes include negative-path tests. — N/A.
  • API/OpenAPI/MCP behavior is updated and tested where needed. — N/A, no API/OpenAPI/MCP surface changed.
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks. — N/A, no UI change.
  • Visible UI changes include a UI Evidence section below. — N/A, no visible UI change.
  • Public docs/changelogs are updated where needed. — N/A, internal indexing-priority fix, no documented behavior change (indexing eligibility/output shape is unchanged, only order).

Notes

  • One of five fixes from a live stack-health pass (Sentry + Loki audit on the self-hosted deployment); see the sibling PRs for the PR-publish silent-drop retry, REES safeCodeSpan TypeError, codex hang-detection, and Sentry release-validation strict-mode fixes.

indexRepo sorted the tree by filePriority (code=0, doc=1) before applying
MAX_CHUNKS_PER_REPO, so on a large repo package.json/tsconfig.json/etc. tied
every other source file and lost the alphabetical tiebreaker, starving them
out of the index entirely once the cap hit. Add a manifestPriority sort key
that puts dependency-manifest and config files (reusing the existing
isDependencyManifestFile/isConfigFile classifiers) ahead of the code/doc
split, and recognize go.mod/go.work as indexable (they were previously
skipped as extensionless).
@superagent-security

Copy link
Copy Markdown
Contributor

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

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 5, 2026
@loopover-orb

loopover-orb Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Tip

🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩

✅ Gittensory review result - approve/merge recommended

Review updated: 2026-07-05 07:11:10 UTC

4 files · 1 AI reviewer · no blockers · readiness 93/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
The change prioritizes manifest/config files before the existing code/doc ordering and adds Go manifest extensionless files to the RAG allowlist. The main production path is coherent: `indexRepo` filters indexable paths first, then sorts root manifests/configs ahead of other code so they survive the chunk cap, and the tests exercise that cap behavior through the real `indexRepo` path. I do not see a reachable correctness defect in the visible diff.

Nits — 4 non-blocking
  • nit: `src/review/rag-index.ts:52` documents the new sort key as `manifestPriority`, but the comment says these files are prioritized ahead of filePriority's code/doc split even though non-manifest files now still call `filePriority`; consider tightening the wording so future readers do not mistake this for a separate full ordering layer.
  • nit: `test/unit/rag-index.test.ts:351` asserts the final stored path order, but the query helper may be an implementation detail rather than a stable ordering contract; prefer comparing as a set unless this test is intentionally covering query ordering.
  • At `src/review/rag-index.ts:67`, consider exporting `manifestPriority` only if later tests need to cover the classifier boundary directly; otherwise keeping it private and testing through `indexRepo` is the right shape.
  • At `test/unit/rag.test.ts:88`, add `go.work.sum` beside `go.sum` if you want direct coverage of the comment's second lockfile sibling.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ⚠️ Missing No linked issue or no-issue rationale found.
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (no linked issue context).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 56 registered-repo PR(s), 46 merged, 416 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 56 PR(s), 416 issue(s).
Gate result ✅ Passing No configured blocker found.
Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository registration is not available in the local Gittensory cache.
  • Public profile languages: Python, TypeScript, JavaScript, Ruby, Go, Kotlin, MDX, Shell
  • Official Gittensor activity: 56 PR(s), 416 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • Explain no-issue PR.
  • No action.
  • Link the issue being solved, or explicitly explain why this is a no-issue PR.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.

🟩 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.

  • Re-run Gittensory review

@codecov

codecov Bot commented Jul 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.47%. Comparing base (5bf0a77) to head (b0a9e2e).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3438   +/-   ##
=======================================
  Coverage   93.47%   93.47%           
=======================================
  Files         292      292           
  Lines       30797    30798    +1     
  Branches    11225    11226    +1     
=======================================
+ Hits        28786    28787    +1     
  Misses       1355     1355           
  Partials      656      656           
Files with missing lines Coverage Δ
src/review/rag-index.ts 90.72% <100.00%> (+0.06%) ⬆️
src/review/rag.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Gittensory approves — the gate is satisfied and CI is green.

@loopover-orb
loopover-orb Bot merged commit e9f6519 into main Jul 5, 2026
10 checks passed
@loopover-orb
loopover-orb Bot deleted the fix/rag-index-manifest-priority branch July 5, 2026 07:14
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant