Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions .coderabbit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# CodeRabbit Configuration for Auto-Improvements
language: "en-US"
early_access: true
enable_free_tier: true

reviews:
profile: "assertive" # More feedback and suggestions
request_changes_workflow: false
high_level_summary: true
auto_title_placeholder: "@coderabbitai"
review_status: true
commit_status: true
collapse_walkthrough: false
changed_files_summary: true
sequence_diagrams: true
assess_linked_issues: true
related_issues: true
related_prs: true
suggested_labels: true
auto_apply_labels: true # Auto-apply suggested labels
suggested_reviewers: true
auto_assign_reviewers: true # Auto-assign reviewers
poem: true

# Path-specific instructions for auto-improvements
path_instructions:
- path: "**/*.py"
instructions: "Apply black formatting, optimize imports with isort, fix flake8 issues, improve type hints, add docstrings to all public functions and classes, optimize performance, and ensure security best practices."
- path: "**/*.ts"
instructions: "Apply ESLint and Prettier formatting, optimize imports, add proper TypeScript types, improve error handling, and ensure modern JavaScript practices."
- path: "**/*.tsx"
instructions: "Optimize React components, improve prop types, enhance accessibility, apply React best practices, and ensure proper state management."
- path: "**/test_*.py"
instructions: "Improve test coverage, add missing assertions, optimize test performance, and ensure proper mocking."
- path: "**/*.md"
instructions: "Fix formatting, improve readability, add missing sections, and ensure proper markdown syntax."

# Enable auto-reviews for all changes
auto_review:
enabled: true
drafts: false

knowledge_base:
opt_out: false
web_search:
enabled: true
code_guidelines:
enabled: true
filePatterns:
- "**/.cursorrules"
- ".github/copilot-instructions.md"
- "**/CLAUDE.md"
- "**/.cursor/rules/*"
- "**/.windsurfrules"
- "**/.clinerules/*"
- "**/.rules/*"
- "PROJECT_STANDARDS.md"
- "CONTRIBUTING.md"
learnings:
scope: "auto"
issues:
scope: "auto"
pull_requests:
scope: "auto"

code_generation:
docstrings:
language: "en-US"
path_instructions:
- path: "**/*.py"
instructions: "Generate comprehensive docstrings with parameters, return values, examples, and type hints following Google style."
- path: "**/*.ts"
instructions: "Generate JSDoc comments with parameter types, return types, and usage examples."
unit_tests:
path_instructions:
- path: "**/*.py"
instructions: "Generate comprehensive pytest tests with fixtures, mocks, edge cases, and proper assertions."
- path: "**/*.ts"
instructions: "Generate Jest/Vitest tests with proper mocking, edge cases, and TypeScript types."
92 changes: 92 additions & 0 deletions .cursorrules
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Cursor Rules for Self-Correcting Executor
# CodeRabbit will read this file to understand our coding standards

## Python Standards
- Use black for formatting (line length 88)
- Use isort for import sorting
- Use flake8 for linting (ignore E501, W503)
- Add type hints to all function parameters and return types
- Add comprehensive docstrings to all public functions and classes
- Use pytest for testing with fixtures and mocks
- Follow PEP 8 naming conventions
- Use dataclasses for simple data structures
- Prefer async/await over callbacks
- Use pathlib instead of os.path
- Always handle exceptions appropriately
- Use f-strings for string formatting
- Remove unused imports and variables
- Add logging for important operations

## TypeScript/JavaScript Standards
- Use ESLint with strict rules
- Use Prettier for formatting
- Add proper TypeScript types for all variables and functions
- Use JSDoc comments for public APIs
- Prefer const over let, never use var
- Use modern ES6+ features (arrow functions, destructuring, async/await)
- Handle errors properly with try/catch
- Use strict null checks
- Prefer interfaces over type aliases for object shapes
- Use proper React hooks patterns
- Optimize component re-renders
- Use proper accessibility attributes

## React/TSX Standards
- Use functional components with hooks
- Proper prop types with TypeScript interfaces
- Use memo() for performance optimization
- Handle loading and error states
- Use proper event handlers
- Implement proper accessibility (a11y)
- Use semantic HTML elements
- Optimize bundle size

## General Standards
- No console.log in production code
- Remove TODO comments in main branch
- Add comprehensive error handling
- Use meaningful variable and function names
- Keep functions small and focused (max 20 lines)
- Add unit tests for all public functions
- Use dependency injection for better testing
- Follow SOLID principles
- Optimize for performance and memory usage
- Use proper security practices (no hardcoded secrets)
- Add proper documentation
- Use consistent indentation (2 spaces for JS/TS, 4 for Python)

## MCP Integration Standards
- All MCP connectors must implement proper error handling
- Use structured logging for MCP operations
- Add timeout handling for external calls
- Implement proper retry logic with exponential backoff
- Use async patterns for all I/O operations
- Add comprehensive type definitions for MCP schemas
- Implement proper connection pooling
- Add health check endpoints
- Use proper authentication and authorization
- Add rate limiting where appropriate

## Quantum Computing Standards
- Use proper error handling for quantum operations
- Add timeout handling for quantum circuits
- Implement proper noise mitigation
- Use efficient circuit compilation
- Add proper documentation for quantum algorithms
- Use consistent naming for qubits and classical registers
- Implement proper measurement strategies
- Add circuit optimization techniques
- Use proper error correction when available
- Add benchmarking for quantum algorithms

## Auto-Fix Priorities
1. Security vulnerabilities (highest priority)
2. Type errors and missing type hints
3. Linting errors (flake8, ESLint)
4. Formatting issues (black, prettier)
5. Import optimization
6. Missing docstrings/comments
7. Performance optimizations
8. Code style improvements
9. Test coverage improvements
10. Documentation updates
28 changes: 28 additions & 0 deletions .github/workflows/claude.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Claude Code Action

on:
pull_request:
types: [opened, synchronize, reopened]
issue_comment:
types: [created]

permissions:
contents: read
pull-requests: write
issues: write

jobs:
claude:
runs-on: ubuntu-latest
if: |
(github.event_name == 'pull_request') ||
(github.event_name == 'issue_comment' &&
github.event.issue.pull_request &&
contains(github.event.comment.body, '@claude'))

steps:
- name: Claude Code Action
uses: anthropics/claude-code-action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
2 changes: 1 addition & 1 deletion .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.10, 3.11]
python-version: ["3.10", "3.11"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand Down
144 changes: 144 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

The Self-Correcting Executor is a sophisticated multi-agent system that combines MCP (Model Context Protocol) integration, quantum computing capabilities, and intelligent orchestration. The system has evolved from a simple protocol runner to include autonomous agents, data-driven mutations, and distributed workflows.

## Architecture

The system is organized into 6 distinct component types:
- **Protocols**: Executable tasks (e.g., `file_validator`, `api_health_checker`)
- **Agents**: Autonomous decision-making entities with A2A communication
- **Connectors**: MCP-compliant interfaces to external systems
- **Analyzers**: Data processing and insight generation
- **Services**: Background infrastructure services
- **Workflows**: Multi-step orchestrated processes

Key directories:
- `agents/` - Autonomous agents with A2A framework
- `protocols/` - Executable protocol implementations
- `connectors/` - MCP connectors and integrations
- `analyzers/` - Pattern detection and analysis
- `frontend/` - React/TypeScript UI with quantum visualizations
- `docs/architecture/` - Comprehensive architecture documentation

## Development Commands

### Standard Development
```bash
make up # Start development stack
make down # Stop development stack
make logs # Follow container logs
make health # Check API health (localhost:8080/health)
make test # Run pytest tests
make build # Build Docker containers
```

### Quantum Development Stack
```bash
make quantum # Start quantum development environment
make quantum-down # Stop quantum stack
make quantum-logs # Follow quantum container logs
make quantum-test # Run quantum-specific tests
make setup-dwave # Configure D-Wave Leap authentication
make verify-quantum # Test quantum hardware connection
```

### Frontend Development
```bash
cd frontend/
npm run dev # Start Vite dev server (localhost:3000)
npm run build # Build production bundle
npm run lint # Run ESLint
```

### Testing
```bash
python test_mcp_debug_simple.py # Simple MCP debugging
python test_real_dwave_quantum.py # Real quantum hardware tests
python test_mcp_ecosystem_expansion.py # MCP ecosystem tests
make test-debug # Debug test runner
```

## Code Standards

The project follows comprehensive coding standards defined in `.cursorrules`:

### Python
- Use black formatting (88 character line length)
- Type hints required for all functions
- Comprehensive docstrings (Google style)
- pytest for testing with fixtures
- Async/await patterns preferred
- Proper error handling and logging

### TypeScript/React
- ESLint with strict rules + Prettier formatting
- Functional components with hooks
- Proper TypeScript types and interfaces
- React performance optimization (memo, proper state management)
- Accessibility compliance

### MCP Integration Standards
- Structured logging for MCP operations
- Timeout and retry logic with exponential backoff
- Proper connection pooling and health checks
- Comprehensive type definitions for MCP schemas

## Key Concepts

### A2A (Agent-to-Agent) Communication
Agents communicate autonomously using the A2A framework for resource negotiation and task coordination.

### MCP Integration
Universal context sharing through Model Context Protocol enables seamless integration with external systems (GitHub, Claude, etc.).

### Pattern-Driven Mutations
The system analyzes execution patterns and applies intelligent mutations to improve performance and reliability.

### Quantum Computing
Real quantum hardware integration via D-Wave Ocean SDK for optimization problems and quantum algorithms.

## API Endpoints

### V2 Architecture (Primary)
- `POST /api/v2/intent` - Execute natural language intents
- `POST /api/v2/a2a/send` - Agent communication
- `POST /api/v2/mcp/connect` - Connect external MCP services
- `GET /api/v2/patterns` - Analyze execution patterns

### Legacy V1
- `POST /api/v1/execute` - Run individual protocols
- `GET /api/v1/protocols` - List available protocols

## Database

Uses PostgreSQL with key tables:
- `protocol_executions` - Execution history and metrics
- `protocol_mutations` - Applied mutations and triggers
- `execution_insights` - Generated insights for decision making

## Environment Setup

The project uses Docker with devcontainer support. Two main environments:
1. **Standard**: `docker-compose.yml` - Core MCP and agent services
2. **Quantum**: `docker-compose.quantum.yml` - Includes quantum computing stack

## Security

- Token-based API authentication
- Role-based component access control
- Protocol execution sandboxing
- Comprehensive audit logging
- No hardcoded secrets (use environment variables)

## Important Files

- `main.py` - Primary application entry point
- `orchestrator.py` - Multi-agent workflow coordination
- `agents/executor.py` - Core execution agent
- `connectors/mcp_base.py` - MCP protocol implementation
- `analyzers/pattern_detector.py` - Execution pattern analysis
- `docs/architecture/ARCHITECTURE.md` - Detailed system architecture
Loading
Loading