This implementation plan provides a detailed roadmap for building env-doctor, a local-first runtime compatibility intelligence and VRAM analysis tool for the HuggingFace + Torch + CUDA ecosystem.
Project Duration: 16-20 weeks for MVP
Team Size: 2-4 developers
Critical Path: Database Schema → Metadata Collection → CLI Engine → Compatibility Analysis
env-doctor solves undocumented runtime incompatibilities, CUDA/toolchain mismatches, unstable package combinations, and VRAM estimation inaccuracies in the ML ecosystem.
- Community Database Repository - GitHub-hosted compatibility intelligence
- Local CLI Engine - Offline-capable analysis tool
- Automatic Metadata System - PyPI-based data collection
- Compatibility Engine - Rule-based analysis
- Recommendation System - Stable stack suggestions
- VRAM Estimator - Memory requirement calculator
- Reporting System - AI-powered incompatibility detection
- Local-first: All analysis runs locally
- Community-driven: Database maintained by users
- Intelligence over resolution: Focus on "will it work?" not "can pip install it?"
- Two-layer system: Automatic metadata + curated intelligence
Objectives: Establish infrastructure, tooling, and project structure
Key Deliverables:
- Main repository (
env-doctor) with CI/CD - Database repository (
env-doctor-db) with validation - Development environment with
uv,ruff,mypy,pytest - Project structure following specification
- GitHub Actions workflows
Critical Tasks:
- Initialize both repositories with proper governance
- Configure
pyproject.tomlwith dependencies (typer, rich, pydantic, httpx, packaging, sqlmodel) - Set up CI/CD for testing (Python 3.10, 3.11, 3.12)
- Create project directory structure
- Configure development tools (ruff, mypy, pre-commit)
Acceptance Criteria:
- Repositories accessible and configured
- CI/CD pipelines passing
- Development environment reproducible
- Team can start development
Objectives: Implement SQLite schema, UID system, YAML compiler, and validation
Key Deliverables:
- Complete SQLite schema with 8 tables
- Deterministic SHA-256 UID generation
- YAML-to-SQLite compiler
- Data validation framework
- Database manager with query API
Database Tables:
packages- Package registrypackage_versions- Version trackingpackage_dependencies- Auto-generated from PyPIcompatibility_rules- Curated intelligencestable_stacks- Recommended combinationsstable_stack_packages- Stack compositionwheel_availability- Platform wheelsruntime_profiles- Runtime overhead data
UID Generation Functions:
generate_package_uid(name)
generate_version_uid(name, version)
generate_dependency_uid(pkg, ver, dep)
generate_compatibility_uid(pkg, pkg_range, dep, dep_range, cuda_ver=None, env_sys=None)
generate_stack_uid(name, cuda_ver, env_sys=None)
generate_wheel_uid(pkg, ver, py_tag, platform_tag)
generate_runtime_uid(runtime)YAML Compiler Workflow:
- Fetch YAML files from GitHub
- Validate structure and content
- Generate deterministic UIDs
- Insert/update database records
- Update metadata
- Commit transaction
Acceptance Criteria:
- Schema creates all tables with proper constraints
- UIDs deterministic and collision-free
- Compiler processes YAML files correctly
- Validation prevents invalid data
- Performance acceptable (<30s for 50 packages)
Objectives: Implement PyPI integration and automatic database population
Key Deliverables:
- PyPI API client with caching
- Dependency parser using
packaginglibrary - Wheel metadata extractor
- Database bootstrap system
- Two-layer intelligence integration
PyPI Integration:
- Endpoint:
https://pypi.org/pypi/{package}/json - Cache location:
~/.cache/env-doctor/pypi/ - Cache TTL: 24 hours
- Rate limiting and retry logic
Data Extraction:
requires_dist→ package_dependencies tablerequires_python→ Python version constraintsreleases→ wheel_availability table- Version metadata → package_versions table
Bootstrap Process:
Package List (torch, transformers, etc.)
↓
Fetch PyPI Metadata (parallel)
↓
Parse Dependencies & Constraints
↓
Extract Wheel Metadata
↓
Populate Database (Layer 1)
↓
Apply Curated Rules (Layer 2)
Two-Layer System:
- Layer 1 (Automatic): PyPI metadata - declared compatibility
- Layer 2 (Curated): YAML rules - operational compatibility
Acceptance Criteria:
- PyPI client fetches metadata reliably
- Dependencies parsed correctly
- Wheel availability tracked
- Bootstrap populates all tables
- Two layers integrated properly
Objectives: Build CLI interface with all commands
Key Deliverables:
- Typer-based CLI framework
- 7 core commands implemented
- Rich terminal UI
- Configuration system
- Help documentation
Commands:
-
env-doctor update-db- Download YAML from GitHub
- Compile to SQLite
- Show progress and statistics
-
env-doctor inspect- Scan current environment
- Detect Python, CUDA, GPU
- List installed packages
-
env-doctor check <requirements.txt>- Parse requirements
- Check compatibility rules
- Show conflicts and warnings
-
env-doctor recommend- Analyze environment
- Find matching stable stacks
- Suggest best option
-
env-doctor vram --model <model> --runtime <runtime> --quant <quant>- Fetch model info
- Calculate VRAM requirements
- Show breakdown and warnings
-
env-doctor patch <pyproject.toml|requirements.txt>- Detect incompatibilities
- Suggest fixes
- Apply patches with confirmation
-
env-doctor report-incompatibility <script.py|notebook.ipynb>- Execute locally
- Capture output
- Submit for analysis
Rich UI Components:
- Progress bars
- Tables for data
- Panels for grouping
- Syntax highlighting
- Color-coded severity
- Interactive prompts
Configuration:
- Location:
~/.config/env-doctor/config.toml - Settings: auto_update, cache_dir, verbosity
- Environment variable overrides
Acceptance Criteria:
- All commands functional
- UI provides excellent UX
- Configuration works
- Help system comprehensive
- Error handling robust
Objectives: Implement compatibility checking and conflict detection
Key Deliverables:
- Version range matching engine
- Compatibility rule matcher
- Dependency graph analyzer
- Conflict detector
- Severity scoring system
- Report generator
Version Matching:
from packaging.specifiers import SpecifierSet
from packaging.version import Version
def version_matches(version: str, specifier: str) -> bool:
return Version(version) in SpecifierSet(specifier)Compatibility Types:
compatible- Explicitly compatibleincompatible- Known to breakpartial- Works with limitationsruntime-risk- May fail at runtimeuntested- No community data
Conflict Detection:
- Version conflicts (unsatisfiable constraints)
- Runtime conflicts (known broken combinations)
- ABI conflicts (CUDA version mismatches)
Severity Scoring:
- Critical: 100 (will definitely break)
- High: 75 (very likely to break)
- Medium: 50 (may break)
- Low: 25 (minor issues)
- Info: 0 (informational)
Confidence Weighting:
- Production-tested: 1.0x
- Stable: 0.9x
- Community-tested: 0.7x
- Experimental: 0.5x
Report Sections:
- Summary - Overall status
- Critical Issues - Must fix
- Warnings - Should fix
- Recommendations - Suggested actions
- Details - Full analysis
Acceptance Criteria:
- Version matching handles all cases
- Rules matched correctly
- Conflicts detected reliably
- Severity scoring reasonable
- Reports clear and actionable
Objectives: Implement stable stack matching and recommendations
Key Deliverables:
- Stack matching algorithm
- Recommendation scoring
- Migration path generator
- Ranking system
- Interactive selection UI
Matching Criteria:
- CUDA version compatibility
- Python version compatibility
- Package overlap with current environment
- Platform compatibility
Scoring Factors:
- Confidence level (40%)
- Package overlap (30%)
- Recency (20%)
- Community adoption (10%)
Migration Path:
- Identify packages to upgrade/downgrade
- Identify packages to add/remove
- Order by dependencies
- Generate installation commands
Example Output:
# Recommended: torch-2.1-transformers-4.38 (Score: 95)
# Step 1: Upgrade torch
pip install torch==2.1.0+cu118 --index-url https://...
# Step 2: Upgrade transformers
pip install transformers==4.38.0
# Step 3: Install flash-attn
pip install flash-attn==2.5.0Acceptance Criteria:
- Stack matching finds relevant stacks
- Scoring produces reasonable rankings
- Migration paths correct
- UI intuitive
- Recommendations actionable
Objectives: Implement VRAM estimation and OOM detection
Key Deliverables:
- Model info fetcher (HuggingFace Hub)
- Weight memory calculator
- KV cache estimator
- Runtime profile system
- OOM risk detector
Weight Memory Formula:
weight_memory = (embedding_params + total_attention_params + total_ffn_params) * bytes_per_param
- MoE Support:
total_ffn_params = num_layers * (num_experts * ffn_params_per_expert + shared_expert_params) - GQA Support:
attention_paramsadjusted for reduced KV heads.
KV Cache Formula:
kv_cache = 2 * batch * seq_len * num_layers * num_kv_heads * head_dim * bytes_per_element
head_dim = hidden_size / num_attention_headsnum_kv_heads=num_attention_heads(MHA) or reduced count (GQA/MQA)
Total VRAM Estimate:
total_vram = (weight_memory + kv_cache) * fragmentation_multiplier + activation_memory + framework_overhead
- Fragmentation: Typically 1.1x - 1.2x
- Framework Overhead: ~0.5GB - 1.5GB (PyTorch/CUDA context)
- Activation Memory:
batch * seq_len * hidden * num_layers * (approx_factor)
Runtime Profiles:
{
"transformers": {
"kv_overhead_multiplier": 1.0,
"fragmentation_multiplier": 1.2
},
"vllm": {
"kv_overhead_multiplier": 1.1,
"fragmentation_multiplier": 1.15
}
}OOM Risk Levels:
- Safe: <70% VRAM
- Warning: 70-85% VRAM
- Danger: 85-95% VRAM
- Critical: >95% VRAM
Acceptance Criteria:
- Model info fetched correctly
- Calculations accurate
- Runtime profiles applied
- OOM risks detected
- UI clear and helpful
Objectives: Implement error reporting and AI analysis via Watsonx Orchestrate
Key Deliverables:
- Script/notebook execution system (cell-by-cell for notebooks)
- Markdown report generator (Code + Output + Env Info)
- Watsonx Orchestrate submission placeholder
- Python MCP Server for GitHub database updates
- Strict verification logic in AI agent prompt
- Setup guide for Watsonx agent
Execution:
- Python scripts: Full source capture and execution via
subprocess.run(). - Jupyter notebooks: Programmatic execution via
nbclientto capture outputs cell-by-cell. - Capture: Source code, stdout, stderr, and full environment manifest.
Markdown Report Format:
## Python Codeor## Cell [X]sections for source.## Outputsections for execution results and tracebacks.## Environment Infosection with JSON snapshot of the system.
Watsonx Orchestrate Workflow:
- Execute script/notebook locally.
- Generate comprehensive Markdown report.
- Submit Markdown to Watsonx Orchestrate agent.
- AI Agent performs Strict Verification: Rejects any error not caused by environment/package incompatibility.
- If verified, AI Agent generates structured compatibility JSON.
- AI Agent calls MCP Server tool (
update_compatibility_database) to commit YAML to GitHub.
MCP Server:
- FastMCP-based Python server.
- Tool:
update_compatibility_database(updates GitHub repository). - Authentication:
GITHUB_API_KEYenvironment variable.
Acceptance Criteria:
- Notebooks executed cell-by-cell.
- Markdown reports generated correctly.
- MCP server functional and secure.
- Strict verification logic enforced.
- Documentation for setup complete.
Objectives: Comprehensive testing and quality assurance
Key Deliverables:
- Unit test suite (>80% coverage)
- Integration tests
- End-to-end tests
- Performance benchmarks
- Security audit
- User acceptance testing
Test Coverage:
- Database operations
- UID generation
- Version matching
- Dependency parsing
- VRAM calculations
- CLI commands
- Compatibility analysis
- Recommendations
- Reporting system
Performance Benchmarks:
- Database compilation: <30s for 50 packages
- Compatibility check: <2s for 20 packages
- Recommendation: <5s
- VRAM estimation: <1s
- PyPI fetch: <10s for 10 packages
Security Testing:
- SQL injection prevention
- Command injection prevention
- Path traversal prevention
- Dependency vulnerabilities
- Secrets exposure
Acceptance Criteria:
-
80% code coverage
- All tests passing
- Benchmarks met
- No critical security issues
- Positive user feedback
Objectives: Create documentation and community infrastructure
Key Deliverables:
- User documentation (MkDocs)
- Developer documentation (Sphinx)
- API reference
- Tutorials and examples
- Contribution guidelines
- Community channels
User Documentation:
- Getting Started
- Installation Guide
- CLI Reference (all commands)
- Configuration Guide
- Troubleshooting
- FAQ
Developer Documentation:
- Architecture Overview
- Database Schema
- API Reference
- Contributing Guide
- Development Setup
- Testing Guide
Community Setup:
- GitHub Discussions
- Issue templates
- PR templates
- Code of Conduct
- Contribution workflow
- Release process
Tutorials:
- Checking environment compatibility
- Using stable stacks
- Estimating VRAM requirements
- Contributing compatibility rules
- Reporting incompatibilities
Acceptance Criteria:
- Documentation complete and clear
- Examples work correctly
- Contribution process documented
- Community channels active
Objectives: Prepare and execute MVP release
Key Deliverables:
- Release candidate testing
- PyPI package publication
- Initial database population
- Release announcement
- Marketing materials
Pre-Release Checklist:
- All tests passing
- Documentation complete
- Security audit passed
- Performance benchmarks met
- User testing completed
- Release notes written
- Migration guide prepared
Release Process:
- Create release branch
- Final testing round
- Update version numbers
- Build distribution packages
- Publish to PyPI
- Tag release in Git
- Create GitHub release
- Announce on social media
Initial Database:
- Populate with 20-30 core packages
- Include 50+ compatibility rules
- Add 5-10 stable stacks
- Document contribution process
Marketing:
- Blog post announcement
- Twitter/X thread
- Reddit posts (r/MachineLearning, r/LocalLLaMA)
- HuggingFace community
- Discord/Slack communities
Acceptance Criteria:
- Package installable via pip
- Database accessible
- All features functional
- Documentation live
- Community engaged
Objectives: Iterate based on feedback and add features
Planned Enhancements:
Short-term (1-3 months):
- Windows support
- ROCm support
- Additional package ecosystem coverage
- Enhanced VRAM estimation
- GitHub authentication for reporting
- Improved recommendation algorithm
Medium-term (3-6 months):
- Web dashboard for database browsing
- API for programmatic access
- IDE integrations (VS Code extension)
- Automated testing of compatibility rules
- Community voting on rules
- Analytics and usage tracking
Long-term (6-12 months):
- Docker sandbox verification
- Distributed training support
- Kubernetes integration
- TensorFlow ecosystem support
- Apple Metal support
- Enterprise features
Community Growth:
- Regular database updates
- Community calls
- Contributor recognition
- Documentation improvements
- Tutorial videos
- Conference talks
Phase 1 (Foundation)
↓
Phase 2 (Database Schema) ← Critical
↓
Phase 3 (Metadata Collection) ← Critical
↓
Phase 4 (CLI Engine) ← Critical
↓
Phase 5 (Compatibility Analysis) ← Critical
↓
Phase 6 (Recommendations)
↓
Phase 7 (VRAM Estimation)
↓
Phase 8 (Reporting)
↓
Phase 9 (Testing) - Parallel
↓
Phase 10 (Documentation)
↓
Phase 11 (Release)
Team Structure:
- Lead Developer - Architecture, critical path
- Backend Developer - Database, metadata, analysis
- Full Stack Developer - CLI, UI, reporting
- ML Engineer - VRAM estimation, AI integration
- QA Engineer - Testing, quality assurance
- Technical Writer - Documentation
Time Allocation:
- Development: 70%
- Testing: 15%
- Documentation: 10%
- Project Management: 5%
High-Priority Risks:
-
Database Schema Changes
- Impact: Critical
- Mitigation: Thorough design review, migration system
-
PyPI API Changes
- Impact: High
- Mitigation: Version detection, fallback mechanisms
-
AI Analysis Accuracy
- Impact: High
- Mitigation: Human review, confidence thresholds
-
Community Adoption
- Impact: High
- Mitigation: Marketing, documentation, ease of use
-
Performance Issues
- Impact: Medium
- Mitigation: Benchmarking, optimization, caching
Technical Metrics:
- Database compilation time: <30s
- Compatibility check time: <2s
- Test coverage: >80%
- Bug count: <10 critical bugs at release
Adoption Metrics:
- PyPI downloads: 1000+ in first month
- GitHub stars: 500+ in first 3 months
- Database contributions: 50+ PRs in first 3 months
- Active users: 100+ weekly active users
Quality Metrics:
- User satisfaction: >4/5 rating
- Documentation completeness: 100%
- Issue resolution time: <7 days average
- Community engagement: Active discussions
Core:
- Python 3.10+
- SQLite (database)
- uv (package management)
- Typer (CLI framework)
- Rich (terminal UI)
Libraries:
- pydantic (validation)
- httpx (HTTP client)
- packaging (version parsing)
- sqlmodel (ORM)
- huggingface_hub (model info)
Development:
- pytest (testing)
- ruff (linting/formatting)
- mypy (type checking)
- pre-commit (git hooks)
Infrastructure:
- GitHub Actions (CI/CD)
- PyPI (distribution)
- AWS Lambda / Vercel (serverless)
- watsonx (AI analysis)
env-doctor/
├── pyproject.toml
├── README.md
├── src/env_doctor/
│ ├── __init__.py
│ ├── main.py
│ ├── cli/
│ │ ├── update.py
│ │ ├── inspect.py
│ │ ├── check.py
│ │ ├── recommend.py
│ │ ├── vram.py
│ │ ├── patch.py
│ │ └── report.py
│ ├── core/
│ │ ├── compatibility.py
│ │ ├── recommendations.py
│ │ └── analysis.py
│ ├── database/
│ │ ├── models.py
│ │ ├── compiler.py
│ │ ├── manager.py
│ │ ├── queries.py
│ │ └── uid_generator.py
│ ├── scanner/
│ │ ├── environment.py
│ │ ├── packages.py
│ │ └── system.py
│ ├── vram/
│ │ ├── estimator.py
│ │ ├── models.py
│ │ └── profiles.py
│ ├── reporting/
│ │ ├── capture.py
│ │ ├── submission.py
│ │ └── analysis.py
│ └── utils/
│ ├── config.py
│ ├── logging.py
│ └── helpers.py
├── tests/
└── docs/
8 Core Tables:
packages- Package registrypackage_versions- Version trackingpackage_dependencies- Dependency graphcompatibility_rules- Curated rulesstable_stacks- Recommended stacksstable_stack_packages- Stack compositionwheel_availability- Platform wheelsruntime_profiles- Runtime overhead
update-db- Update local databaseinspect- Scan environmentcheck- Check compatibilityrecommend- Suggest stable stackvram- Estimate VRAMpatch- Fix dependenciesreport-incompatibility- Report errors
This implementation plan provides a comprehensive roadmap for building env-doctor from foundation to MVP release. The phased approach ensures systematic progress while maintaining flexibility for iteration based on feedback.
Key Success Factors:
- Strong database design (Phase 2)
- Reliable metadata collection (Phase 3)
- Excellent user experience (Phase 4)
- Accurate compatibility analysis (Phase 5)
- Active community engagement (Phase 10-12)
Next Steps:
- Review and approve this plan
- Assemble development team
- Begin Phase 1 (Project Foundation)
- Establish weekly progress reviews
- Set up communication channels
The estimated 16-20 week timeline to MVP is achievable with a dedicated team of 2-4 developers following this structured approach.