CU-86exuferc: AI Review Engine — LLM Integration#3
Merged
miqdadyyy merged 3 commits intoJun 4, 2026
Conversation
Add the core AI review engine that sends code diffs to configured LLM providers and returns structured review feedback. - Add ai/openai/anthropic/custom provider types reusing the encrypted provider domain so API keys are stored encrypted and never returned in full (masked in responses). - Add internal/services/llm: ILLMFactory + ILLMService with OpenAI-compatible (LiteLLM/vLLM/Ollama/Azure), Anthropic, and custom proxy clients, shared HTTP helper with exponential backoff retry. - Add ai_connector usecase: CRUD endpoints at /api/v1/connectors. - Add review usecase: orchestrates diff -> prompt -> LLM -> parsed ReviewComment list with prompt templates, token counting and cost estimation; POST /api/v1/reviews/diff. - Add aiprompttemplate repository domain (DB-stored, per-repo editable prompts) registered in AutoMigrate. - Wire new repos/usecases/services; add LLMConfig; table-driven tests.
✅ Coverage Report
|
miqdadyyy
commented
Jun 4, 2026
- Run AI review as a background NATS worker job: HTTP POST
/api/v1/reviews/diff now enqueues via IPubSub and returns 202
Accepted; new worker HandleReviewDiff consumes the job and runs the
LLM review. Adds review_diff topic/channel constants and subscription.
- Move provider request/response structs out of the implementation
package into internal/services/llm/models/{openai,anthropic}.go.
- Move shared helpers (firstNonEmptyStr, firstAnthropicText, emitStream)
into base.go; rename models/models.go to llm.go.
- Replace 'validation failed' literal with fiber.ErrUnprocessableEntity
.Error() across all HTTP handlers.
- Replace hand-rolled maskSecret with a reflection-based
internal/pkg/mask package driven by mask:"start=N"/mask:"end=N"
struct tags; ConnectorResponse.APIKey now masked declaratively.
- Expand test coverage: mask pkg, llm openai/anthropic via httptest,
llm factory, worker handler, aiconnector List/Update, review
Enqueue + prompt-template path (275 tests pass, lint clean).
Owner
Author
|
Thanks for the review — all points addressed in the latest commit ( Architecture: background worker
Inline comments
Coverage |
miqdadyyy
deleted the
feature/CU-86exuferc-ai-review-engine-llm-integration
branch
June 8, 2026 03:20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the core AI review engine that sends code diffs to configured LLM providers and returns structured review feedback. Reuses the existing encrypted
providerdomain for AI credentials and mirrors the establishedservices/vcsfactory pattern forservices/llm.ClickUp Ticket
Changes
LLM service layer (
internal/services/llm/)ILLMFactory+ILLMServiceinterfaces mirroringservices/vcs.base.goHTTP helper (Fiber client) with exponential-backoff retry and upstream status mapping.StreamComplete.AI provider integration (reuses
providerdomain)ProviderCategoryAI,ProviderTypeOpenAI/Anthropic/Custom,ProviderAuthModeAPIKey.ProviderAIMetadata(api key / base URL / model) stored via the existing AES-encryptedEncryptedField— keys never stored in plaintext.AI connector CRUD (
internal/usecase/aiconnector/)POST/GET/PUT/DELETE /api/v1/connectors.****<last4>).Review engine (
internal/usecase/review/)POST /api/v1/reviews/diff: orchestrates diff → prompt → LLM → parsedReviewCommentlist.aiprompttemplaterepo domain, AutoMigrate).Wiring & config
cmd/cli/wire.go(regeneratedwire_gen.go).LLMConfigadded to config entity andconfig/local.yaml.Testing
go build ./...— successgo test ./...— 245 passed (incl. new table-driven tests foraiconnectorandreviewusecases covering success, not-found, wrapped-error, and JSON-parse-failure paths)make lint— 0 issuesgofmtclean on all changed filesAcceptance Criteria
Note
This repo has no
developbranch; the branch was created fromfeat/ai-provider(not yet on remote) per request. PR is targeted atmain— retarget to the intended integration branch before merge if needed.