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
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
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
Deliverables
Expected outcomes