Skip to content

AI Detection & Architecture Analysis

Votrio uses advanced techniques to detect AI-generated code and analyze architectural patterns. This guide explains how the detection works under the hood.

AI Detection Overview

Votrio detects AI-generated code using a hybrid approach combining multiple analysis techniques. Instead of relying on a single method, it scores code across three independent detectors that each look for different patterns:

Pattern Analysis (40% weight)

Looks for common AI characteristics like generic comments, boilerplate code, and excessive documentation

AST Analysis (40% weight)

Examines code structure for AI preferences like uniform function lengths, arrow functions, and destructuring patterns

LLM Verification (20% weight)

Optional: sends code snippets to Claude for semantic verification (disabled by default)

Each file receives a probability score from 0-1, and scores above 0.5 are flagged as findings. The final report shows overall AI likelihood and confidence metrics.

Pattern Analysis Detector

This detector searches for comment patterns and coding conventions that AI models tend to produce:

What It Looks For

  • Generic comments: "TODO:", "FIXME:", "//" function descriptions
  • Overly documented code: Excessive JSDoc comments and verbose docstrings
  • Boilerplate sections: "// Import dependencies", "// Configuration", "// Initialize"
  • Generic adjectives: "simple", "basic", "standard", "common", "typical"
  • Generic action comments: "// Handle error", "// Check if", "// Make sure"
  • Excessive comments: More than 30% of lines are comments

Example: Pattern Scoring

Code sample
// Import dependencies
import { useState } from 'react';

// Define types
interface User {
  id: string;
  name: string;
}

// Handle user state
const handleUser = (user: User) => {
  // Check if user exists
  if (!user) {
    // Make sure we handle this case
    console.log('User not found');
  }
};

This code would score high on pattern detection because it contains multiple boilerplate comments ("Import dependencies", "Define types", "Handle user"), generic action comments ("Check if", "Make sure"), and has a comment-to-code ratio of ~40%.

AST Analysis Detector

Abstract Syntax Tree (AST) analysis examines the structure of code itself. AI models have preferred coding styles that differ from human developers.

JavaScript/TypeScript Patterns

  • Uniform function lengths: Low variance in function sizes (AI tends to generate similarly-sized functions)
  • Excessive default parameters: 5+ default parameter assignments
  • Arrow function dominance: Prefers => syntax over function declarations
  • Heavy destructuring: Frequent use of { property } = object patterns
  • Template strings: Prefers template syntax like string with variables over concatenation

Python Patterns

  • Type hints: Frequent use of typing annotations
  • Docstrings: Multiple documentation blocks
  • List comprehensions: Prefers [x for x in list] syntax
  • F-strings: Uses f-string formatting extensively

Generic Checks (All Languages)

  • Consistent indentation: Very few indentation variations (3 or fewer)
  • Line length consistency: Lines don't exceed average by more than 50%
Scoring & Severity

Each file is scored on a 0-1 probability scale. The final score combines all three detectors:

aiProbability = (patternScore × 0.4) + (astScore × 0.4) + (llmScore × 0.2)

80%+ Probability → CRITICAL

Very likely AI-generated

60-80% Probability → HIGH

Probably AI-generated

40-60% Probability → MEDIUM

Some AI characteristics detected

<40% Probability → LOW

Minimal AI indicators

Architecture Analysis

Beyond AI detection, Votrio analyzes your codebase architecture to identify structural issues that impact maintainability:

God File Detection

Identifies files that are too large and handle too many responsibilities:

  • > 500 lines of code
  • > 20 imports (high coupling)
  • > 15 functions (multiple responsibilities)
  • Handles 3+ different concerns (DB, HTTP, UI, etc)

Circular Dependency Detection

Uses depth-first search (DFS) to find dependency cycles. Example: Module A → Module B → Module C → Module A

// Circular dependency found:
src/services/user.ts → src/utils/auth.ts → src/services/user.ts

// Breaking the cycle requires introducing an abstraction layer
// or using dependency injection to decouple the modules

Coupling Analysis

Measures how tightly modules are coupled. High coupling means changing one module requires changes in many others.

Abstraction Layer Detection

Checks if proper abstraction layers exist between components to prevent direct dependencies.

How to Interpret Results

AI Likelihood Score

The overall score represents the average probability across all files in your project:

  • > 80% = Very likely AI-generated codebase
  • 50-80% = Moderate AI generation detected
  • 20-50% = Low AI generation indicators
  • < 20% = Primarily human-written code

Confidence Score

Shows what percentage of files had detectable AI patterns. A high confidence with low likelihood suggests inconsistent code quality across the project.

Individual Findings

Each flagged file shows detailed breakdown of pattern, AST, and LLM scores. Review high-confidence findings to understand what patterns were detected.

Limitations & False Positives

AI detection is probabilistic and not 100% accurate. Be aware of these limitations:

  • Generated tests: Test code often looks AI-generated because it's standardized and well-commented
  • Modern codebases: Projects using modern practices (TypeScript, destructuring, type hints) may score higher
  • Junior developers: New programmers may follow tutorials or style guides that resemble AI patterns
  • Linted code: Heavily formatted code by tools may appear structurally uniform
  • Template-heavy code: Boilerplate and scaffolded projects naturally have AI-like characteristics

💡 Tip: Use AI detection as a starting point for review, not as definitive proof. Combine with manual code review for best results.

Using AI Detection in Your Workflow
Run AI detection via scan
# Scan for AI-generated code
votrio scan

# Get detailed JSON output for programmatic processing
votrio scan --format json

# Fail CI if high AI likelihood detected
votrio scan --ci --fail-on high

# Watch mode for continuous monitoring
votrio scan --watch

Interpreting Output

Category: ai-detection
Score: 65% (moderate likelihood)
Confidence: 45% (45% of files flagged)

Finding: src/services/user.ts
- Pattern score: 72%
- AST score: 58%
- LLM score: 0% (verification disabled)
- Overall probability: 65%

This example shows moderate AI likelihood with moderate confidence. Review the flagged files and look at the pattern/AST breakdowns to understand what characteristics were detected.