Organizational Intelligence Plugin (OIP)
A plugin for pmat that analyzes GitHub organizations to detect defect patterns, measure code quality, and generate actionable intelligence for software development teams.
Installation • Quick Start • Documentation • Contributing
Overview
Organizational Intelligence Plugin (OIP) mines Git history and integrates with pmat's Technical Debt Gradient (TDG) analysis to:
- Detect defect patterns across 10 categories (Configuration Errors, Security Vulnerabilities, Type Errors, etc.)
- Measure code quality via pmat TDG integration (0-100 score, higher is better)
- Generate privacy-safe summaries with automated PII stripping
- Provide fast PR reviews using stateful baselines (<30s vs 10+ minutes)
- Enable data-driven decisions for technical debt prioritization
Key Features
✅ Phase 1 - Core Analysis (oip analyze)
- Analyze GitHub organizations for defect patterns
- Integrate pmat TDG quality scores
- Generate comprehensive YAML reports
✅ Phase 2 - Summarization (oip summarize)
- Automated PII stripping (commit hashes, author emails)
- Frequency filtering and top-N category selection
- Privacy-safe summaries ready for AI consumption
✅ Phase 3 - PR Review (oip review-pr)
- Fast PR reviews using stateful baselines (<30s)
- Context-aware warnings based on organizational history
- Multiple output formats (Markdown, JSON)
🚀 Phase 1 GPU Extension (oip-gpu) - NEW!
- GPU-accelerated correlation analysis for defect patterns
- SIMD-optimized feature extraction (trueno backend)
- Benchmark suite with criterion (10-50× speedup targets)
- Complete GitHub → Features → Storage pipeline
- See: GPU Quick Start | Full Spec
Toyota Way Principles
This tool is built following Toyota Production System principles:
- Genchi Genbutsu (Go and See): Analyzes actual commit history, not surveys
- Kaizen (Continuous Improvement): Weekly reports track improvement over time
- Jidoka (Build Quality In): Identifies defect patterns to fix root causes
- Muda/Muri/Mura Elimination: Automates manual work, prevents overburden, smooths workflow
Installation
Prerequisites
- Rust 1.70 or higher
- Git
- pmat (optional, for TDG integration)
- GitHub Personal Access Token (for higher rate limits)
From Source
# Binary available at target/release/oip
Via Cargo (once published)
Setting Up GitHub Token
# Create a GitHub Personal Access Token at:
# https://github.com/settings/tokens
# Required scopes: repo (for private repos) or public_repo (for public only)
# Add to ~/.bashrc or ~/.zshrc for persistence
Usage
Quick Start
# 1. Analyze your organization
# 2. Generate privacy-safe summary
# 3. Review a PR (requires baseline)
Phase 1: Analyze Organization
# Analyze all repositories in an organization
# With verbose logging
# Limit concurrent analysis (default: 10)
Output: YAML report with:
- Defect patterns by category (frequency, confidence)
- TDG quality scores (requires pmat)
- Code churn metrics (lines changed, files per commit)
- Example commits (⚠️ contains PII - use Phase 2 to strip)
Phase 2: Summarize for Sharing
# Generate privacy-safe summary
# Include anonymized examples
Output: Clean YAML with:
- Top N defect categories by frequency
- PII redacted (commit_hash: REDACTED, author: REDACTED)
- Quality thresholds (TDG 85+, coverage 85%+)
- Safe for sharing with AI tools
Phase 3: PR Review
# One-time: Create baseline (run weekly)
# On every PR: Fast review (<30s)
# Output to stdout for CI integration
Phase 1 GPU: Accelerated Analysis
# Analyze repository with GPU-accelerated features
# Run performance benchmarks
# Force SIMD backend (CPU)
Output: Feature vectors ready for GPU correlation analysis
See GPU Quick Start for detailed examples.
Output: Context-aware warnings based on organizational defect patterns
Examples
Sprint Planning
# Generate current analysis
# Identify high-priority technical debt
# (High frequency + Low TDG score = urgent refactoring needed)
|
Weekly Baseline Updates
#!/bin/bash
# weekly-baseline.sh - Run via cron every Monday
ORG=myorg
DATE=
CI/CD Integration
# .github/workflows/pr-review.yml
name: Organizational Intelligence PR Review
on:
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install OIP
run: cargo install organizational-intelligence-plugin
- name: Review PR
run: |
FILES=$(gh pr diff ${{ github.event.pull_request.number }} --name-only | tr '\n' ',')
oip review-pr \
--baseline .oip/baseline.yaml \
--files "$FILES" \
--format markdown
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Configuration
Makefile Targets
Quality Gates
All code must pass:
- ✅
make lint- No clippy warnings - ✅
make test-fast- All unit tests pass - ✅
make coverage- 85%+ line coverage (currently: 86.65% ✅) - ✅ pmat TDG score 85+ (currently: 96.4/100 ✅)
Development
Project Structure
organizational-intelligence-plugin/
├── src/
│ ├── analyzer.rs # Organization analysis orchestration
│ ├── classifier.rs # Defect pattern classification (10 categories)
│ ├── cli.rs # Command-line interface (clap)
│ ├── git.rs # Git history mining
│ ├── github.rs # GitHub API integration (octocrab)
│ ├── pmat.rs # pmat TDG integration
│ ├── pr_reviewer.rs # PR review with stateful baselines
│ ├── report.rs # YAML report generation
│ ├── summarizer.rs # PII stripping and summarization
│ └── main.rs # Entry point
├── tests/
│ └── cli_tests.rs # CLI integration tests
├── docs/
│ └── how-to-integrate-as-plugin-with-pmat-improve-prompts-spec.md
├── Makefile # Development workflow automation
└── Cargo.toml # Rust dependencies
Running Tests
# Fast unit tests (recommended for development)
# All tests including network integration tests
# Coverage report with HTML output
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Follow EXTREME TDD: Write tests first (RED-GREEN-REFACTOR)
- Ensure all quality gates pass:
make lint && make test-fast - Commit using conventional commits (
feat:,fix:,docs:, etc.) - Push to your fork and submit a Pull Request
Code Standards:
- Minimum 85% test coverage for new code
- All clippy warnings must be resolved
- Follow Rust API guidelines
- Document public APIs with examples
Roadmap
Completed (Phase 1-3)
- ✅ Phase 1: Core analysis with pmat TDG integration
- ✅ Phase 2: Automated summarization with PII stripping
- ✅ Phase 3: Fast PR reviews using stateful baselines
Proposed (Phase 4)
- ⚪ AI Prompt Integration: Generate context-aware prompts for AI tools
- ⚪ DefectAwarePromptGenerator for paiml-mcp-agent-toolkit
- ⚪ MCP (Model Context Protocol) integration
- ⚪ Automated code review comments on GitHub PRs
See docs/how-to-integrate-as-plugin-with-pmat-improve-prompts-spec.md for detailed design specifications.
Troubleshooting
GitHub Rate Limits
Problem: API rate limit exceeded for...
Solution: Set GITHUB_TOKEN environment variable
pmat Not Found
Problem: pmat analyze tdg fails
Solution: Install pmat
Analysis Takes Too Long
Problem: Analyzing large organizations is slow
Solution: Reduce max-concurrent flag
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Built following Toyota Production System principles
- Inspired by empirical software engineering research
- Integrates with pmat for quality analysis
- Uses octocrab for GitHub API
- Uses git2-rs for Git operations
Support
- 📖 Documentation: docs/
- 🐛 Issues: GitHub Issues
Citation
If you use this tool in your research, please cite:
Status: Phase 1-3 Complete | Grade: TDG 96.4/100 (A+) | Coverage: 86.65% (422 tests) ✅
Built with ❤️ following the Toyota Way