Skip to content

feat(miner-rag): issue-centric RAG query builder (issue title/body → embeddable query text) #2320

Description

@JSONbored

The existing codebase RAG engine (src/review/rag.ts, retrieveContext/retrieveContextWithMetrics) and its review-path wiring (src/review/rag-wire.ts) build the retrieval QUERY from a PR's changed files + diff (buildRagQuery at src/review/rag-wire.ts:144, prepending the PR title to the changed-paths list + a diff sample). For the miner's ANALYZE phase there is no diff yet — only an issue's title + body — so this issue adds the issue-centric analogue of buildRagQuery, reusing the SAME underlying retrieveContext/retrieveContextWithMetrics retrieval engine unchanged.

This is a pure query-composition function (mirrors buildRagQuery's existing pattern exactly, just swapping the input source), so it's foundation-tier and independent of anything else in this phase.

Deliverables

  • src/review/issue-rag-wire.ts (co-located with the existing rag-wire.ts since it composes over the SAME retrieveContextWithMetrics/createReviewAdapters plumbing) exporting buildIssueRagQuery(input: { title: string; body?: string; labels?: string[] }), returning { queryText: string }
  • Query composition mirrors buildRagQuery's style: prepend the issue title, then the body (bounded — reuse the same MAX_QUERY_DIFF_CHARS-style budget constant, renamed appropriately, at src/review/rag-wire.ts:34), then append labels as a short hint line
  • Respect the SAME MIN_QUERY_CHARS floor already enforced inside retrieveContextWithMetrics (src/review/rag.ts:358) — a one-line issue produces "" and the caller degrades to no-context, exactly like the PR path
  • Unit tests: empty body, very long body (truncation), labels present/absent, and the too-short-to-query floor
  • Do NOT modify retrieveContext/retrieveContextWithMetrics/upsertChunks in src/review/rag.ts — this issue only builds the query TEXT; retrieval itself is reused unchanged

References

  • src/review/rag-wire.ts:144 (buildRagQuery — the PR-centric analogue this issue mirrors)
  • src/review/rag-wire.ts:32 (MAX_QUERY_PATHS/MAX_QUERY_DIFF_CHARS budget constants to mirror)
  • src/review/rag.ts:358 (MIN_QUERY_CHARS — the existing floor this issue's output must still respect)
  • src/review/rag.ts:394 (retrieveContextWithMetrics signature — the function this issue's query text ultimately feeds, unchanged)

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:featureGittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.help wantedExtra attention is needed

    Projects

    Status
    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions