Skip to content

Latest commit

Β 

History

122 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Konveyor AI Evaluation Framework

A comprehensive framework for evaluating LLM performance on application modernization tasks. Automatically generates test cases from Konveyor rules, validates code migrations, and produces professional reports with migration complexity analysis.

✨ Key Features

  • πŸ€– Automatic test generation from 2,680+ Konveyor rules with LLM code generation
  • πŸ“Š Migration complexity classification (TRIVIAL β†’ EXPERT) with expected AI success rates
  • πŸ”„ Agentic workflows for self-correcting code generation and fixing
  • πŸ“ˆ Professional HTML reports with Grafana-style design and complexity breakdowns
  • 🎯 Multi-dimensional evaluation: Functional correctness, security, code quality, explainability
  • ⚑ Graceful interruption with progress saving and resume capability
  • πŸ” Real Java compilation with 200+ JARs from Maven Central
  • πŸ’Ύ Database storage (SQLite/PostgreSQL) for historical tracking and trend analysis

πŸš€ Quick Start

# 1. Install dependencies
pip install -r requirements.txt

# 2. Configure API keys
cp config.example.yaml config.yaml
# Edit config.yaml with your OpenAI/Anthropic API keys

# 3. Setup Java dependencies (one-time)
cd evaluators/stubs && mvn clean package && cd ../..

# 4. Generate test suite with auto-generated code
python scripts/generate_tests.py --all-rulesets --target quarkus \
  --auto-generate --validate --model gpt-4-turbo

# 5. Classify by complexity
python scripts/classify_rule_complexity.py benchmarks/test_cases/generated/quarkus.yaml

# 6. Run evaluation
python evaluate.py --benchmark benchmarks/test_cases/generated/quarkus.yaml

# 7. View results
open results/evaluation_report_*.html

See WORKFLOW.md for the complete recommended workflow.

πŸ“‹ Migration Complexity Classification

Automatically categorizes rules by difficulty to set appropriate AI expectations:

Complexity AI Success Example Automation Strategy
TRIVIAL 95%+ javax.* β†’ jakarta.* namespace changes βœ… Full automation
LOW 80%+ @Stateless β†’ @ApplicationScoped βœ… Automation with light review
MEDIUM 60%+ JMS β†’ Reactive Messaging patterns ⚑ AI acceleration + developer completion
HIGH 30-50% Spring Security β†’ Quarkus Security πŸ” AI scaffolding + expert review
EXPERT <30% Custom security realms, internal APIs πŸ“‹ AI checklist + human migration

Why it matters: Segmented analysis reveals AI value at each difficulty level, not just overall pass rate.

See docs/COMPLEXITY_CLASSIFICATION.md for details.

πŸ“¦ Test Generation

Generate test cases from Konveyor rulesets with automatic code generation:

# Generate from specific migration path (Java EE β†’ Quarkus)
python scripts/generate_tests.py --all-rulesets --source java-ee --target quarkus \
  --auto-generate --validate --model gpt-4-turbo

# With local rulesets (100x faster, no API rate limits)
git clone https://github.com/konveyor/rulesets.git ~/projects/rulesets
python scripts/generate_tests.py --all-rulesets --target quarkus \
  --local-rulesets ~/projects/rulesets \
  --auto-generate --validate --model gpt-4-turbo

# Process in batches for large test suites
python scripts/generate_tests.py --all-rulesets --target quarkus \
  --auto-generate --model gpt-4-turbo \
  --batch-size 20

Features:

  • βœ… Auto-generates code_snippet and expected_fix using LLM
  • βœ… --validate flag: Agentic workflow compiles and auto-fixes errors
  • βœ… Ctrl+C to pause and save progress - resume by re-running same command
  • βœ… Auto-detects language from rules (Java, XML, YAML, properties)
  • βœ… Includes Konveyor migration guidance in prompts

Output: benchmarks/test_cases/generated/quarkus.yaml

See docs/generating_tests.md for full documentation.

πŸ”§ Test Validation & Fixing

Validate Test Cases

# Check compilation status
python scripts/validate_expected_fixes.py benchmarks/test_cases/generated/quarkus.yaml

Auto-Fix Compilation Errors

# Fix by complexity level (recommended: start with TRIVIAL/LOW)
python scripts/fix_expected_fixes.py \
  --file benchmarks/test_cases/generated/quarkus.yaml \
  --complexity trivial,low

# Preview fixes without applying
python scripts/fix_expected_fixes.py \
  --file benchmarks/test_cases/generated/quarkus.yaml \
  --dry-run

Features:

  • βœ… Agentic workflow: Iterates with compilation error feedback (max 3 attempts)
  • βœ… Migration-specific guidance (Java EE β†’ Quarkus patterns)
  • βœ… Ctrl+C to pause - progress saved incrementally
  • βœ… Auto-skips non-compilable tests (marked with reasons)
  • βœ… Validates each fix before applying

See docs/automating_test_case_fixes.md for details.

πŸ“Š Evaluation & Reports

Run Evaluation

# Evaluate all complexity levels
python evaluate.py --benchmark benchmarks/test_cases/generated/quarkus.yaml

# Filter by complexity
python evaluate.py \
  --benchmark benchmarks/test_cases/generated/quarkus.yaml \
  --filter-complexity trivial,low

# Exclude EXPERT level
python evaluate.py \
  --benchmark benchmarks/test_cases/generated/quarkus.yaml \
  --exclude-complexity expert

# Parallel execution for multiple models
python evaluate.py \
  --benchmark benchmarks/test_cases/generated/quarkus.yaml \
  --parallel 4

HTML Reports

πŸ“Š View Live Sample Report - Interactive demo (no installation required)

Professional Grafana-style reports with:

  • 🎨 Dark theme with Konveyor branding
  • πŸ“Š Complexity breakdown table - Pass rates by difficulty level (TRIVIAL β†’ EXPERT)
  • πŸ† Model ranking with composite scoring across all dimensions
  • πŸ” Individual test cards with complexity badges
  • πŸ“ˆ Interactive charts - Response time, cost analysis, performance metrics
  • πŸ”’ Security analysis - Vulnerability detection with severity levels
  • πŸ’‘ Explainability metrics - Comment density, explanation quality scores
  • ⚠️ Detailed failure analysis - Diff highlighting, compilation errors

Output: results/evaluation_report_*.html

🎯 Evaluation Dimensions

Tests evaluate LLM performance across:

  1. Functional Correctness (40% weight)

    • Compiles successfully
    • Resolves original violation
    • No new violations introduced
  2. Compilation Rate (15% weight)

    • Valid Java syntax
    • Correct imports and dependencies
  3. Code Quality (15% weight)

    • Cyclomatic complexity
    • Maintainability index
    • Style adherence
  4. Security (15% weight)

    • No SQL injection vulnerabilities
    • No hardcoded credentials
    • Migration-specific checks (lost @RolesAllowed, etc.)
    • Optional Semgrep integration for comprehensive analysis
  5. Explainability (10% weight)

    • Explanation quality score (0-10)
    • Comment density (10-30% ideal)
  6. Performance Metrics (5% weight)

    • Response time
    • Cost efficiency

πŸ”’ Security Analysis

Hybrid approach for comprehensive security scanning:

# Install Semgrep (optional but recommended)
pip install semgrep

# Uncomment in config.yaml:
security:
  tools:
    - semgrep

Without Semgrep: Fast pattern-based checks for common vulnerabilities With Semgrep: Comprehensive taint analysis and framework-specific rules

πŸ“ Project Structure

konveyor-iq/
β”œβ”€β”€ benchmarks/              # Test datasets
β”‚   └── test_cases/
β”‚       └── generated/       # Auto-generated from Konveyor rules
β”œβ”€β”€ config/                  # Configuration files
β”‚   └── migration_guidance.yaml  # Migration-specific prompts
β”œβ”€β”€ docs/                    # Documentation
β”‚   β”œβ”€β”€ SETUP.md
β”‚   β”œβ”€β”€ COMPLEXITY_CLASSIFICATION.md
β”‚   β”œβ”€β”€ generating_tests.md
β”‚   └── automating_test_case_fixes.md
β”œβ”€β”€ evaluators/              # Metric implementations
β”‚   β”œβ”€β”€ functional.py        # Compilation & pattern validation
β”‚   β”œβ”€β”€ security.py          # Security analysis
β”‚   β”œβ”€β”€ quality.py           # Code quality metrics
β”‚   └── stubs/              # Java compilation dependencies
β”‚       β”œβ”€β”€ pom.xml         # Maven dependencies (200+ JARs)
β”‚       └── lib/            # Downloaded JARs
β”œβ”€β”€ models/                  # LLM adapters
β”‚   β”œβ”€β”€ openai_adapter.py
β”‚   β”œβ”€β”€ anthropic_adapter.py
β”‚   └── google_adapter.py
β”œβ”€β”€ reporters/               # Report generation
β”‚   └── html_reporter.py    # Grafana-style HTML reports
β”œβ”€β”€ scripts/                 # Utility scripts
β”‚   β”œβ”€β”€ generate_tests.py   # Generate from Konveyor rules
β”‚   β”œβ”€β”€ classify_rule_complexity.py  # Classify difficulty
β”‚   β”œβ”€β”€ validate_expected_fixes.py   # Validate compilation
β”‚   └── fix_expected_fixes.py       # Auto-fix errors
β”œβ”€β”€ config.yaml              # Main configuration
β”œβ”€β”€ evaluate.py              # Main evaluation script
β”œβ”€β”€ WORKFLOW.md              # Recommended workflow
└── requirements.txt         # Python dependencies

πŸ“š Documentation

πŸ› οΈ Advanced Features

Agentic Workflows

Both test generation and fixing use agentic workflows for self-correction:

  1. Generate code β†’ Compile β†’ Get errors
  2. Fix errors with LLM (passes error feedback)
  3. Validate fix β†’ Compile β†’ Repeat if needed (max 3 attempts)

This dramatically improves compilation success rates (50% β†’ 85%+).

Graceful Interruption

Press Ctrl+C (or Cmd+C) to pause long-running scripts:

  • Finishes current operation
  • Saves all progress to YAML
  • Shows summary
  • Resume by re-running same command

Supported in: generate_tests.py, fix_expected_fixes.py

Migration Guidance System

Centralized, technology-specific guidance in config/migration_guidance.yaml:

  • Java EE β†’ Quarkus patterns
  • Spring Boot β†’ Quarkus patterns
  • Messaging migrations
  • Security migrations

Automatically injected into prompts based on test suite metadata.

Konveyor Rule Integration

When test cases reference Konveyor rules via source URL:

  1. Framework fetches official rule from GitHub
  2. Extracts migration guidance (message field)
  3. Includes in LLM prompt under "Konveyor Migration Guidance"

Ensures LLM receives authoritative migration patterns.

πŸ”§ Configuration

Edit config.yaml to specify:

  • Models: OpenAI (GPT-4, GPT-3.5), Anthropic (Claude), Google (Gemini)
  • Evaluation dimensions: Enable/disable metrics
  • Security tools: Pattern-based or Semgrep
  • Report format: HTML, Markdown
  • Parallelization: Number of concurrent workers
  • Storage: File (JSON), SQLite, or PostgreSQL

πŸ’Ύ Database Storage (Optional)

Track model performance over time with relational database storage:

# Install dependencies
pip install sqlalchemy

# Enable in config.yaml
storage:
  type: "sqlite"
  path: "konveyor_iq.db"

reporting:
  write_to_database: true

# Initialize database
python db_cli.py init

# Run evaluations (results auto-saved to database)
python evaluate.py --benchmark benchmarks/test_cases/generated/quarkus.yaml

# Query historical data
python db_cli.py query runs              # Recent evaluations
python db_cli.py query models --days 30  # Model comparison
python db_cli.py query rules             # All rules by pass rate
python db_cli.py query complexity        # Pass rates by difficulty
python db_cli.py query regressions       # Detect performance drops

Features:

  • πŸ“Š Track model performance trends over time
  • πŸ” Identify rules needing prompt engineering
  • πŸ’° Cost analysis and forecasting
  • πŸ“ˆ Regression detection and alerting
  • πŸ‘₯ Team collaboration via PostgreSQL

Backends:

  • SQLite - Local database, zero setup (recommended)
  • PostgreSQL - Team/production use, multi-user support
  • File - Default JSON storage (no historical queries)

See docs/database_storage.md for complete guide.

πŸŽ“ Example Results

Pass Rate by Complexity (gpt-4-turbo):
- TRIVIAL: 96% (24/25 tests)
- LOW:     84% (21/25 tests)
- MEDIUM:  68% (17/25 tests)
- HIGH:    44% (11/25 tests)
- EXPERT:  20% (5/25 tests)

Overall: 78% (78/125 tests)

This segmentation demonstrates AI value at each difficulty level.

🀝 Contributing

Contributions welcome! Areas of interest:

  • New migration patterns for evaluators/functional.py
  • Additional migration guidance for config/migration_guidance.yaml
  • Enhanced security rules
  • New LLM adapters

πŸ“„ License

Apache 2.0


Quick Links:

About

LLM evaluation framework for application modernization. Assesses AI-generated code fixes for Konveyor rule violations across functional correctness, quality, security, and explainability. Features Grafana-style reporting for cost estimation and model selection for migrations.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages