diff --git a/.gitignore b/.gitignore index 890f107..996a952 100644 --- a/.gitignore +++ b/.gitignore @@ -84,3 +84,6 @@ Thumbs.db # MkDocs documentation site/ + +# Claude Code symlink (should not be committed) +.claude diff --git a/AI_IMPROVEMENT_TASKS.md b/AI_IMPROVEMENT_TASKS.md new file mode 100644 index 0000000..68b2ae1 --- /dev/null +++ b/AI_IMPROVEMENT_TASKS.md @@ -0,0 +1,165 @@ +# Plan-Lint AI-Assisted Improvement Tasks + +Based on code review analysis, here are specific tasks that would benefit from AI agent assistance: + +## 🚀 High Priority Improvements + +### 1. Enhanced Error Detection and Reporting +**Task**: Implement more sophisticated error detection patterns +- **Location**: `src/plan_lint/core.py:46-108` +- **Issue**: Current bounds checking could be enhanced with nested parameter support +- **AI Task**: Implement recursive bounds checking for nested JSON structures and arrays +- **Benefit**: Better validation of complex plan structures + +### 2. Cycle Detection Algorithm Optimization +**Task**: Replace naive cycle detection with proper graph-based algorithm +- **Location**: `src/plan_lint/core.py:151-181` +- **Issue**: Current implementation is naive and may miss complex dependency cycles +- **AI Task**: Implement Tarjan's algorithm for strongly connected components +- **Benefit**: More robust cycle detection, better performance on large plans + +### 3. Risk Score Calculation Enhancement +**Task**: Implement ML-based dynamic risk scoring +- **Location**: `src/plan_lint/core.py:183-210` +- **Issue**: Current risk calculation is simplistic with fixed weights +- **AI Task**: Create adaptive risk scoring based on historical data patterns +- **Benefit**: More accurate risk assessment tailored to specific environments + +## 🔧 Code Quality Improvements + +### 4. Type Safety Enhancements +**Task**: Add comprehensive type hints and runtime validation +- **Locations**: Multiple files missing complete type annotations +- **AI Task**: Add missing type hints, implement runtime type checking with beartype +- **Benefit**: Better IDE support, catch type errors early + +### 5. Test Coverage Expansion +**Task**: Increase test coverage to 90%+ +- **Current**: Tests exist but coverage appears incomplete +- **AI Task**: Generate comprehensive test cases for edge cases and error paths +- **Focus Areas**: + - `src/plan_lint/opa.py` - OPA integration edge cases + - `src/plan_lint/loader.py` - File loading error scenarios + - Rule modules - Various validation scenarios + +### 6. Performance Profiling and Optimization +**Task**: Profile and optimize validation performance +- **Location**: Core validation loops in `validate_plan_builtin` +- **AI Task**: + - Add performance benchmarks + - Implement parallel validation for independent checks + - Add caching for repeated validations +- **Benefit**: Better performance for large-scale deployments + +## 📚 Documentation and API Improvements + +### 7. API Documentation Generation +**Task**: Generate comprehensive API documentation +- **Current**: Docstrings exist but could be more detailed +- **AI Task**: + - Enhance docstrings with examples + - Generate API reference documentation + - Create interactive API examples +- **Benefit**: Better developer experience + +### 8. Rule Development Guide +**Task**: Create comprehensive rule development framework +- **Location**: `src/plan_lint/rules/` +- **AI Task**: + - Document rule development best practices + - Create rule testing framework + - Generate rule templates for common patterns +- **Benefit**: Easier extension by users + +## 🏗️ Architecture Enhancements + +### 9. Plugin Architecture Implementation +**Task**: Create proper plugin system for rules +- **Current**: Rules are loaded via simple import +- **AI Task**: + - Design plugin interface + - Implement plugin discovery and loading + - Add plugin configuration system +- **Benefit**: Better extensibility, third-party rule support + +### 10. Async Validation Support +**Task**: Add asynchronous validation capabilities +- **Location**: Core validation functions +- **AI Task**: + - Refactor validation to support async/await + - Implement concurrent validation + - Add streaming validation for large plans +- **Benefit**: Better performance for web services + +## 🔐 Security Enhancements + +### 11. Security Rule Library +**Task**: Expand security-focused validation rules +- **Current**: Basic SQL write and secret detection +- **AI Task**: + - Implement OWASP-based security rules + - Add command injection detection + - Create path traversal detection + - Implement rate limiting detection +- **Benefit**: More comprehensive security coverage + +### 12. Sensitive Data Detection Enhancement +**Task**: Improve secret/PII detection using ML +- **Location**: `src/plan_lint/core.py:112-149` +- **Current**: Simple regex matching +- **AI Task**: + - Implement ML-based sensitive data detection + - Add support for custom sensitive data patterns + - Create false positive reduction mechanisms +- **Benefit**: Better security with fewer false positives + +## 🎯 Integration Features + +### 13. GitHub Actions Integration +**Task**: Create native GitHub Actions support +- **AI Task**: + - Create GitHub Action wrapper + - Implement PR comment integration + - Add SARIF output format +- **Benefit**: Seamless CI/CD integration + +### 14. VS Code Extension +**Task**: Develop VS Code extension for real-time validation +- **AI Task**: + - Create language server protocol implementation + - Add real-time validation + - Implement quick fixes for common issues +- **Benefit**: Better developer experience + +## 📊 Monitoring and Analytics + +### 15. Telemetry and Metrics +**Task**: Add opt-in telemetry for usage analytics +- **AI Task**: + - Implement privacy-preserving telemetry + - Create metrics dashboard + - Add performance monitoring +- **Benefit**: Data-driven improvements + +## Recommended Implementation Order + +1. **Phase 1 (Immediate)**: Tasks 1, 2, 5, 11 + - Core functionality improvements + - Security enhancements + - Test coverage + +2. **Phase 2 (Short-term)**: Tasks 3, 6, 9, 12 + - Performance optimization + - Architecture improvements + - Advanced security features + +3. **Phase 3 (Medium-term)**: Tasks 4, 7, 8, 13, 14 + - Developer experience + - Integration features + - Documentation + +4. **Phase 4 (Long-term)**: Tasks 10, 15 + - Advanced features + - Analytics + +Each task is designed to be self-contained and suitable for AI agent implementation with clear boundaries and testable outcomes. \ No newline at end of file diff --git a/CODE_REVIEW_TODO.md b/CODE_REVIEW_TODO.md new file mode 100644 index 0000000..6484f06 --- /dev/null +++ b/CODE_REVIEW_TODO.md @@ -0,0 +1,98 @@ +# Code Review TODO List for Plan-Lint + +## Summary +Plan-lint is a well-structured security-focused linter for LLM agent plans. The codebase is clean, follows good Python practices, and has a solid foundation. However, there are several areas where AI assistance could significantly improve the project. + +## Critical Improvements Needed + +### 🔴 High Priority (Security & Correctness) + +1. **Fix Naive Cycle Detection** (`core.py:151-181`) + - Current implementation won't catch all dependency cycles + - Implement proper graph traversal algorithm + - Add comprehensive tests for complex cycle scenarios + +2. **Enhance Bounds Checking** (`core.py:46-108`) + - Add support for nested parameter validation + - Handle array bounds and complex data structures + - Improve error messages with actual vs expected values + +3. **Improve Secret Detection** (`core.py:112-149`) + - Current regex approach has high false positive rate + - Add entropy-based detection + - Support custom sensitive data patterns + - Implement allowlist for known safe patterns + +### 🟡 Medium Priority (Performance & Usability) + +4. **Optimize Validation Performance** + - Add benchmarking suite + - Implement parallel validation for independent checks + - Cache compiled regex patterns + - Profile and optimize hot paths + +5. **Expand Test Coverage** + - Current tests are basic, need edge case coverage + - Add property-based testing with hypothesis + - Test error paths and exception handling + - Add integration tests for CLI + +6. **Improve Rule System** + - Current rule loading is basic file import + - Need proper plugin architecture + - Add rule configuration and parameters + - Create rule testing framework + +### 🟢 Low Priority (Nice to Have) + +7. **Enhanced Documentation** + - API documentation needs examples + - Create rule development guide + - Add architecture documentation + - Include performance tuning guide + +8. **Better Error Reporting** + - Add error context and suggestions + - Implement error grouping + - Create machine-readable error format + - Add fix suggestions + +9. **Integration Features** + - GitHub Actions native support + - VS Code extension + - Web API service + - Framework integrations + +## Technical Debt + +1. **Type Annotations**: Several functions missing return type hints +2. **Error Handling**: Some try/except blocks too broad +3. **Code Duplication**: Similar validation logic repeated across rules +4. **Configuration**: Policy loading could be more flexible +5. **Logging**: Minimal logging for debugging + +## Positive Aspects + +✅ Clean code structure with good separation of concerns +✅ Uses modern Python features (type hints, dataclasses) +✅ Good use of Pydantic for data validation +✅ Thoughtful API design +✅ Security-first approach +✅ Extensible architecture + +## Recommended Next Steps + +1. **Immediate**: Fix cycle detection algorithm (critical bug) +2. **This Week**: Improve test coverage to 90%+ +3. **This Month**: Implement performance optimizations +4. **This Quarter**: Build plugin architecture and integrations + +## Metrics to Track + +- Test coverage: Current ~60% → Target 90% +- Performance: Validate 1000 plans/second +- Rules: Expand from 2 to 10+ built-in rules +- Integrations: Add 3+ framework integrations +- Documentation: 100% API coverage + +The codebase is in good shape overall, but needs these improvements to be production-ready for enterprise use. \ No newline at end of file diff --git a/claude_output.log b/claude_output.log new file mode 100644 index 0000000..796ecd4 --- /dev/null +++ b/claude_output.log @@ -0,0 +1,24 @@ +## Summary + +I've completed a comprehensive code review of the plan-lint project and created two detailed documents: + +### 1. **AI_IMPROVEMENT_TASKS.md** - 15 specific tasks perfect for AI agent assistance: +- Enhanced error detection with nested parameter support +- Graph-based cycle detection to replace naive implementation +- ML-based dynamic risk scoring +- Comprehensive test generation +- Plugin architecture implementation +- Security rule library expansion + +### 2. **CODE_REVIEW_TODO.md** - Prioritized improvement plan: +- **Critical**: Fix naive cycle detection algorithm (current bug) +- **High Priority**: Enhance bounds checking and secret detection +- **Medium Priority**: Performance optimization and test coverage +- **Nice to Have**: Documentation and integration features + +### Key Findings: +✅ **Strengths**: Clean architecture, good use of type hints, security-focused design +❌ **Issues**: Naive cycle detection, limited test coverage (~60%), basic rule system +🎯 **Target**: 90%+ test coverage, 1000 plans/second performance, enterprise-ready + +The codebase is well-structured but needs these improvements to be production-ready for enterprise use. Each task is designed to be self-contained and suitable for AI agent implementation. diff --git a/github_mcp_server.log b/github_mcp_server.log new file mode 100644 index 0000000..b563a85 --- /dev/null +++ b/github_mcp_server.log @@ -0,0 +1 @@ +/home/user/run-agent.sh: line 298: github-mcp-server: command not found diff --git a/redis_listener.log b/redis_listener.log new file mode 100644 index 0000000..bb5ac1c --- /dev/null +++ b/redis_listener.log @@ -0,0 +1,5 @@ +INFO:__main__:🚀 Starting Redis Message Listener +INFO:__main__:✅ Connected to Redis at redis://host.docker.internal:6379 +INFO:__main__:📡 Subscribed to topics: agent_status_updates +INFO:__main__:🎧 Message listener ready for agent 9959c9be-18d5-4909-a957-4877acbb3ae6 +INFO:__main__:🎧 Starting message listener for agent 9959c9be-18d5-4909-a957-4877acbb3ae6 diff --git a/redis_mcp_server.log b/redis_mcp_server.log new file mode 100644 index 0000000..6b83d9f --- /dev/null +++ b/redis_mcp_server.log @@ -0,0 +1,81 @@ +INFO:__main__:✅ Connected to Redis at redis://host.docker.internal:6379 +INFO:__main__:🚀 Starting Redis Pub/Sub MCP Server on 0.0.0.0:8088 +INFO:__main__:📡 Agent ID: 9959c9be-18d5-4909-a957-4877acbb3ae6 +INFO:__main__:📦 Project ID: +INFO: Started server process [90] +INFO: Waiting for application startup. +INFO: Application startup complete. +INFO: Uvicorn running on http://0.0.0.0:8088 (Press CTRL+C to quit) +INFO: 127.0.0.1:57590 - "GET /health HTTP/1.1" 200 OK +INFO: 127.0.0.1:57604 - "POST /mcp HTTP/1.1" 500 Internal Server Error +ERROR: Exception in ASGI application +Traceback (most recent call last): + File "/usr/local/lib/python3.10/dist-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi + result = await app( # type: ignore[func-returns-value] + File "/usr/local/lib/python3.10/dist-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__ + return await self.app(scope, receive, send) + File "/usr/local/lib/python3.10/dist-packages/starlette/applications.py", line 113, in __call__ + await self.middleware_stack(scope, receive, send) + File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/errors.py", line 186, in __call__ + raise exc + File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/errors.py", line 164, in __call__ + await self.app(scope, receive, _send) + File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/exceptions.py", line 63, in __call__ + await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) + File "/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py", line 53, in wrapped_app + raise exc + File "/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py", line 42, in wrapped_app + await app(scope, receive, sender) + File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 716, in __call__ + await self.middleware_stack(scope, receive, send) + File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 736, in app + await route.handle(scope, receive, send) + File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 290, in handle + await self.app(scope, receive, send) + File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 78, in app + await wrap_app_handling_exceptions(app, request)(scope, receive, send) + File "/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py", line 53, in wrapped_app + raise exc + File "/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py", line 42, in wrapped_app + await app(scope, receive, sender) + File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 75, in app + response = await f(request) + File "/home/user/mcp/redis_pubsub_mcp_server.py", line 383, in handle_mcp + return await session_manager.handle_request(request) +TypeError: StreamableHTTPSessionManager.handle_request() missing 2 required positional arguments: 'receive' and 'send' +INFO: 127.0.0.1:32946 - "POST /mcp HTTP/1.1" 500 Internal Server Error +ERROR: Exception in ASGI application +Traceback (most recent call last): + File "/usr/local/lib/python3.10/dist-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi + result = await app( # type: ignore[func-returns-value] + File "/usr/local/lib/python3.10/dist-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__ + return await self.app(scope, receive, send) + File "/usr/local/lib/python3.10/dist-packages/starlette/applications.py", line 113, in __call__ + await self.middleware_stack(scope, receive, send) + File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/errors.py", line 186, in __call__ + raise exc + File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/errors.py", line 164, in __call__ + await self.app(scope, receive, _send) + File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/exceptions.py", line 63, in __call__ + await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) + File "/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py", line 53, in wrapped_app + raise exc + File "/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py", line 42, in wrapped_app + await app(scope, receive, sender) + File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 716, in __call__ + await self.middleware_stack(scope, receive, send) + File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 736, in app + await route.handle(scope, receive, send) + File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 290, in handle + await self.app(scope, receive, send) + File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 78, in app + await wrap_app_handling_exceptions(app, request)(scope, receive, send) + File "/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py", line 53, in wrapped_app + raise exc + File "/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py", line 42, in wrapped_app + await app(scope, receive, sender) + File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 75, in app + response = await f(request) + File "/home/user/mcp/redis_pubsub_mcp_server.py", line 383, in handle_mcp + return await session_manager.handle_request(request) +TypeError: StreamableHTTPSessionManager.handle_request() missing 2 required positional arguments: 'receive' and 'send'