Git Code Review
nyxCore: Git Code Review Tool
Technical Documentation — Architecture, Algorithms, and Scientific Foundations
Version: 1.0 Date: 2026-03-10 Classification: Internal Technical Reference
Table of Contents
2. Git Code Review Tool
The Git Code Review Tool integrates AI-powered analysis directly into the pull request workflow. It fetches PR diffs from GitHub, runs multi-provider LLM review, extracts structured findings, and presents them alongside the diff with file-level navigation and scoring.
2.1 System Architecture
2.2 Security Model: BYOK Token Resolution
All GitHub API calls use the tenant's encrypted Personal Access Token retrieved via resolveGitHubToken(). The token is stored as AES-256-GCM ciphertext in the api_keys table and decrypted per-request. No GitHub credentials are ever stored in plaintext or cached in application memory.
Required PAT scopes for code review:
repo— read access to private repositories and pull requestsread:org— enumerate organization repositories (optional)
2.3 GitHub REST API Layer
The review tool uses three GitHub REST API endpoints:
| Endpoint | Purpose |
|---|---|
GET /repos/{owner}/{repo}/pulls |
List open pull requests |
GET /repos/{owner}/{repo}/pulls/{number} |
Get PR metadata (title, author, base/head SHA, stats) |
GET /repos/{owner}/{repo}/pulls/{number}/files |
Fetch unified diff per file |
Pagination is handled with up to 3 pages of results (100 PRs per page). File diffs include the patch field containing the unified diff text, which is parsed by the diff parser into structured hunks.
2.4 AI-Powered Code Review
The review engine sends the PR diff to the configured LLM provider with a structured prompt requesting JSON output. The prompt instructs the model to:
- Identify issues by category:
security,performance,correctness,style,documentation - Assign severity:
critical,high,medium,low - Locate findings to specific file paths and line numbers within the diff
- Provide actionable suggestions
Each finding is persisted as a ReviewFinding record and associated with the parent PullRequestReview.
Multi-Persona Analysis: When multiple personas are configured for the review workflow, each persona runs independently against the same diff, producing persona-specific findings. The findings are then merged and de-duplicated by a consensus scoring step that weights convergent findings (flagged by multiple personas) with higher severity.
Provider Fan-Out: The review can be configured to run across multiple LLM providers simultaneously (e.g., Anthropic + OpenAI). Each provider's findings are aggregated, with cross-provider consensus elevating finding confidence.
2.5 Unified Diff Parsing Algorithm
The diff parser transforms GitHub's unified diff text into a structured representation for display and line-number mapping.
Input format (GitHub unified diff):
@@ -10,7 +10,8 @@
context line
-removed line
+added line
+new added line
context line
Parsing steps:
- Split on
@@ -N,M +N,M @@hunk headers (regex:/^@@ -(\d+),(\d+) \+(\d+),(\d+) @@/) - For each hunk, track
oldLineandnewLinecounters starting from the hunk's base offsets - Classify each line:
context(space),deletion(-),addition(+) - Build a
lineMapfrom new-file line numbers to diff position for finding anchoring
The resulting structure enables the DiffViewer component to render syntax-highlighted diffs with inline finding annotations at precise line positions.
2.6 tRPC Procedure Architecture
The codeReview router exposes:
| Procedure | Type | Description |
|---|---|---|
listPRs |
query | Fetch open PRs for a repository |
getPR |
query | Get PR metadata with review status |
startReview |
mutation | Initiate AI review for a PR |
getReview |
query | Fetch review results with findings |
listFindings |
query | Paginated findings for a review |
updateFinding |
mutation | Mark finding as resolved/dismissed |
rerunReview |
mutation | Re-run review with different provider/persona |
The startReview mutation is rate-limited to the LLM tier (10 req/min) to prevent runaway API costs from rapid re-runs.
2.7 UI Component Hierarchy
CodeReviewView
├── PRSelector — repository + branch picker
├── PRList — paginated PR cards with status badges
├── DiffViewer — split/unified diff with syntax highlighting
│ ├── FileTree — collapsible file navigation sidebar
│ ├── HunkRenderer — individual diff hunk with line numbers
│ └── FindingAnnotation — inline finding marker with tooltip
└── ReviewPanel — findings summary, severity breakdown, actions
├── FindingCard — expandable finding with suggestion
└── ConsensusScore — multi-provider agreement indicator
2.8 Error Handling & Resilience
| Failure Mode | Handling |
|---|---|
| GitHub token missing | Surfaces "No GitHub token configured" with link to Admin > API Keys |
| PR not found (404) | Clears review state, shows inline error |
| LLM provider error | Retries with next available provider in fallback chain |
| Diff too large (>100KB) | Truncates to first 100KB with warning banner |
| Rate limit (HTTP 429) | Exponential backoff: 1s, 2s, 4s, max 3 retries |
References
- McInnes, L., Healy, J., & Melville, J. (2018). UMAP: Uniform Manifold Approximation and Projection for Dimension Reduction. arXiv:1802.03426.
- Bertin, J. (1983). Semiology of Graphics. University of Wisconsin Press.
- Ware, C. (2012). Information Visualization: Perception for Design (3rd ed.). Morgan Kaufmann.
- Stevens, S. S. (1957). On the psychophysical law. Psychological Review, 64(3), 153–181.
- Drcmda. (2021). React Three Fiber: A React renderer for Three.js. GitHub: pmndrs/react-three-fiber.
