Skip to content

feat(review): infer a cached per-repo quality-culture profile as AI-review grounding context #2995

Description

@JSONbored

Context

src/services/ai-review.ts renders verdicts largely from the diff, the linked issue, and the resolved dual-AI plan (combine/onMerge/reviewers, see the CombineStrategy plumbing around resolveAiReviewPlan). It has no notion of a given repo's own observable conventions -- commit message discipline, PR size norms, how strict the repo already is about tests/docs, what its existing .gittensory.yml already encodes. On idiosyncratic repos this makes verdicts read as generic boilerplate rather than reasoning grounded in how that repo actually operates. src/review/rag.ts already assembles retrieval context for the review prompt, so there is a natural seam to attach a repo-level profile alongside the per-PR retrieval it does today.

Separately, the Autonomous Miner System has an analogous need: a miner inferring a target repo's merge-bar before generating a PR faces the same extraction problem (parse recent commit history, PR patterns, and existing config into a compact profile). Building this twice would mean two divergent heuristics drifting apart on what "quality culture" means for the same repo.

Goal

Extract a lightweight, cached, per-repo quality-culture profile from a repo's own history and existing config, and feed it into the AI review prompt as grounding context without introducing a new scored gate dimension.

Requirements

  • Implement the profile extraction as a single shared, reusable function/module (not duplicated between consumers) -- it must be callable both from the review path (src/services/ai-review.ts / src/review/rag.ts) and from the Autonomous Miner System's merge-bar inference, so the two consumers never drift on what signals constitute "quality culture" for a repo.
  • Derive the profile only from data already available to this engine: recent commit message patterns, merged-PR size/shape history, and existing repo config (.gittensory.yml, CODEOWNERS-style signals if already surfaced elsewhere). Do not add new external data sources.
  • Cache the profile per repo with an explicit invalidation/staleness policy (e.g., re-derive on a TTL or on detecting new config commits) -- this must not become a per-review-call cost.
  • The profile is grounding context only: it must not introduce a new scored gate dimension, must not affect merge/close disposition on its own, and must degrade silently (empty/default profile) when history is too sparse to infer anything meaningful.
  • Feed the profile into the existing review prompt construction path alongside whatever src/review/rag.ts already assembles, without changing the shape of the AI review's structured output contract.
  • Cover both branches of every conditional introduced (sparse-history fallback vs. populated profile; cache hit vs. miss) per the repo's patch-coverage bar.

Deliverables

  • Shared quality-culture-profile extraction function, placed so both the review path and the Autonomous Miner System can import it without duplication
  • Per-repo caching layer with explicit invalidation policy
  • Wiring into the AI review prompt as additive grounding context (no gate/scoring changes)
  • Tests covering sparse-history fallback, cache hit/miss, and prompt-assembly integration
  • Fixture-based test PR against a repo with idiosyncratic conventions showing the verdict cites repo-specific grounding language

Expected outcomes

  • AI review verdicts on idiosyncratic repos reference repo-specific conventions rather than generic boilerplate, verifiable via fixture-diff tests
  • Zero change to gate merge/close outcomes attributable to this feature alone (profile is additive context, not a scoring input)
  • No duplicated profile-extraction logic between the review path and the Autonomous Miner System

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:featureGittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.

    Projects

    Status
    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions