Skip to content

marcbrooker/morris

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧬 Morris

AI-Powered Mutation Testing for Rust

Find the bugs hiding in your test suite

Rust AWS Bedrock Claude

    ╔═══════════════════════════════════════╗
    β•‘  Your Code  β†’  Morris  β†’  Better Tests β•‘
    β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

🎯 What is Morris?

Morris is a cargo subcommand that uses AWS Bedrock (Claude Sonnet 4.6) to perform intelligent mutation testing on Rust projects. Instead of exhaustively testing thousands of mutations, Morris uses AI to strategically select 5-8 high-value mutations that are most likely to reveal gaps in your test coverage.

Morris follows a fixed workflow β€” file discovery, test execution, and mutation application are all handled by deterministic code. The AI is used only for two targeted tasks: selecting which mutations to try, and analyzing the results.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Your Code  β”‚ ───> β”‚    Morris    β”‚ ───> β”‚  Test Gaps  β”‚
β”‚   + Tests   β”‚      β”‚ (Fixed Flow) β”‚      β”‚  + Fixes    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
                            β”œβ”€ Discovers files (deterministic)
                            β”œβ”€ Runs baseline tests (deterministic)
                            β”œβ”€ AI selects mutations (Bedrock)
                            β”œβ”€ Tests mutations (deterministic)
                            └─ AI analyzes results (Bedrock)

πŸš€ Quick Start

Installation

cargo install --path .

Prerequisites

  • AWS Bedrock access with Claude Sonnet 4.6 enabled
  • AWS credentials configured (via ~/.aws/credentials or environment variables)
  • A Rust project with tests

Basic Usage

cd your-rust-project
cargo morris

That's it! Morris will analyze your code and report surviving mutations.


πŸ“‹ How It Works

Morris uses a fixed, deterministic workflow. The AI (via AWS Bedrock Converse API) is called exactly twice: once to propose mutations, and once to analyze results.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     Morris Workflow                         β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                             β”‚
β”‚  1. πŸ“ Discovery (deterministic)                            β”‚
β”‚     └─ Recursively finds .rs files under src/              β”‚
β”‚                                                             β”‚
β”‚  2. πŸ“– Read Sources (deterministic)                         β”‚
β”‚     └─ Reads all source files into memory                  β”‚
β”‚                                                             β”‚
β”‚  3. ⏱️  Baseline (deterministic)                             β”‚
β”‚     └─ Runs `cargo test` to verify and measure timing      β”‚
β”‚                                                             β”‚
β”‚  4. 🧬 Mutation Plan (AI β€” Bedrock call #1)                 β”‚
β”‚     └─ Claude proposes 5-8 strategic mutations as JSON     β”‚
β”‚        β€’ Operators: > β†’ <, + β†’ -, == β†’ !=                  β”‚
β”‚        β€’ Boundaries: 0 β†’ 1, len() β†’ len()-1                β”‚
β”‚        β€’ Logic: && β†’ ||, true β†’ false                      β”‚
β”‚                                                             β”‚
β”‚  5. πŸ§ͺ Testing Loop (deterministic)                         β”‚
β”‚     For each mutation:                                      β”‚
β”‚     β”œβ”€ Backup original file                                β”‚
β”‚     β”œβ”€ Apply mutation to single line                       β”‚
β”‚     β”œβ”€ Run tests (with 3x baseline timeout)                β”‚
β”‚     └─ Restore original file                               β”‚
β”‚                                                             β”‚
β”‚  6. πŸ“Š Results Summary (deterministic)                      β”‚
β”‚     └─ Counts killed / survived / build errors             β”‚
β”‚                                                             β”‚
β”‚  7. πŸ’‘ Analysis (AI β€” Bedrock call #2)                      β”‚
β”‚     └─ Claude explains surviving mutations and             β”‚
β”‚        suggests specific tests to catch them               β”‚
β”‚                                                             β”‚
β”‚  8. ✨ Auto Mode (optional, deterministic)                  β”‚
β”‚     └─ Parses AI suggestions and writes improved tests     β”‚
β”‚                                                             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸŽ›οΈ Command Line Options

Flag Description Use Case
(none) Default mode with Claude Sonnet 4.6 Best quality analysis
--quick Use Claude Haiku 4.5 Faster, less thorough
--auto Automatically apply test improvements Hands-free mode
-v / --verbose Enable debug logging Troubleshooting

Examples

# Standard analysis (recommended)
cargo morris

# Quick analysis for rapid feedback
cargo morris --quick

# Auto-apply test improvements
cargo morris --auto

# Quick + auto for maximum speed
cargo morris --quick --auto

πŸ“Š Example Output

$ cargo morris

🧬 Morris v0.2.0 - AI-Powered Mutation Testing

πŸ“ Discovering source files...
   src/lib.rs

πŸ“– Reading source files...
⏱️  Running baseline tests...
   βœ… Baseline passed in 1.2s (mutation timeout: 30.0s)

🧬 Asking AI for mutation plan...
   Got 6 mutations

πŸ§ͺ Testing mutations...

   [1/1] src/lib.rs:42 - Change > to <... ❌ SURVIVED
   [2/2] src/lib.rs:67 - Change + to -... ❌ SURVIVED
   [3/3] src/lib.rs:89 - Change == to !=... βœ… KILLED
   [4/4] src/lib.rs:23 - Change >= to >... βœ… KILLED
   [5/5] src/lib.rs:51 - Change true to false... ❌ SURVIVED
   [6/6] src/lib.rs:15 - Remove bounds check... πŸ”§ BUILD ERROR

πŸ“Š Results: 2 killed, 3 survived out of 5 testable mutations

πŸ’‘ Analyzing surviving mutations...

[AI analysis with specific test suggestions]

πŸ†š Morris vs cargo-mutants

cargo-mutants is an excellent exhaustive mutation testing tool. Morris takes a different approach:

cargo-mutants β€” Exhaustive Approach

  • Systematically generates all possible mutations
  • Tests hundreds/thousands of mutations
  • AST-based pattern matching
  • Comprehensive coverage analysis
  • Best for: CI/CD pipelines, audits

Morris β€” AI-Guided Approach

  • Fixed workflow, AI used only for selection & analysis
  • Selects 5-8 strategic mutations
  • Contextual explanations of why mutations survive
  • Auto-applies improvements
  • Best for: Interactive development, learning

The biggest difference is that mutants is a lot more mature, and probably more useful in production code bases for now.


πŸ”§ Configuration

AWS Credentials

Morris requires AWS credentials with Bedrock access:

# Option 1: AWS CLI
aws configure

# Option 2: Environment variables
export AWS_ACCESS_KEY_ID=your_key
export AWS_SECRET_ACCESS_KEY=your_secret
export AWS_REGION=us-east-1

Verbose Output

# Enable debug logging
cargo morris -v

# Or via environment variable
RUST_LOG=debug cargo morris

πŸ—οΈ Architecture

Morris uses a fixed workflow with two targeted Bedrock Converse API calls. All file I/O, test execution, and mutation application is deterministic code β€” no agent loop or tool-use protocol.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     Morris Architecture                  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                          β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                         β”‚
β”‚  β”‚   CLI      β”‚  cargo morris [--quick] [--auto] [-v]   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜                                         β”‚
β”‚        β”‚                                                 β”‚
β”‚        v                                                 β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”             β”‚
β”‚  β”‚        Fixed Workflow Engine            β”‚             β”‚
β”‚  β”‚                                        β”‚             β”‚
β”‚  β”‚  1. Discover .rs files (fs)            β”‚             β”‚
β”‚  β”‚  2. Read source files (fs)             β”‚             β”‚
β”‚  β”‚  3. Run baseline tests (cargo test)    β”‚             β”‚
β”‚  β”‚  4. Get mutation plan ──────────────┐  β”‚             β”‚
β”‚  β”‚  5. Test each mutation (cargo test) β”‚  β”‚             β”‚
β”‚  β”‚  6. Summarize results               β”‚  β”‚             β”‚
β”‚  β”‚  7. Get analysis ────────────────────  β”‚             β”‚
β”‚  β”‚  8. Auto-apply (optional, fs)       β”‚  β”‚             β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚             β”‚
β”‚                                           β”‚             β”‚
β”‚                                           v             β”‚
β”‚                              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚                              β”‚  AWS Bedrock        β”‚    β”‚
β”‚                              β”‚  Converse API       β”‚    β”‚
β”‚                              β”‚  β€’ Sonnet 4.6       β”‚    β”‚
β”‚                              β”‚  β€’ Haiku 4.5        β”‚    β”‚
β”‚                              β”‚  (2 calls total)    β”‚    β”‚
β”‚                              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β”‚                                                          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

About

Morris is an experimental AI-powered mutation tester and test critic for Rust

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages