Research-Stack/5-Applications/nodupe/docs/plans/PROJECT_PLAN.md
2026-05-05 21:15:26 -05:00

346 lines
12 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# NoDupeLabs Project Plan
**Version:** 3.0
**Created:** 2026-02-14
**Last Updated:** 2026-02-22 (Priority 3 Complete)
**Status:** Active
---
## Executive Summary
This plan outlines the roadmap for NoDupeLabs with explicit phases, steps, sub-steps, and measurable completion metrics at every level.
**Current State (2026-02-22):**
- ✅ Test Coverage: 93.30% Line / 86.17% Branch (CRITICAL IMPROVEMENT from 10.18%)
- ✅ Docstring Coverage: 95%+ (NEAR COMPLETE)
- ✅ CI/CD Pipeline: Functional (COMPLETED)
- ✅ Wiki Documentation: 11+ files (COMPLETED)
- ✅ Security Scanning: Implemented (COMPLETED)
- ✅ Rollback System: Implemented (COMPLETED)
- ✅ Priority 3 Modules: Complete (maintenance, scanner_engine, ml, telemetry)
- ⚠️ Type Checking: 180 errors remaining (26% fixed)
- ⚠️ Unit Tests: ~300 failures (down from initial, being addressed)
---
## Phase 1: Core Infrastructure (Completed)
### Step 1.1: Test Coverage Infrastructure
| Sub-Step | Action | Completion Metric |
|----------|--------|-------------------|
| 1.1.1 | Install pytest and dependencies | `pytest --co -q` returns >100 tests |
| 1.1.2 | Run baseline coverage | `pytest --cov=nodupe` shows 100% |
| 1.1.3 | Fix test imports | All tests import without errors |
| 1.1.4 | Add CI coverage gate | Coverage fails under 100% (100% or nothing) |
**Phase 1 Completion Metric:** `pytest tests/ --cov=nodupe --cov-fail-under=100` passes (100% required - if it fails in tests, it fails in production)
---
### Step 1.2: Documentation System
| Sub-Step | Action | Completion Metric |
|----------|--------|-------------------|
| 1.2.1 | Create wiki structure | 11 markdown files in wiki/ |
| 1.2.2 | Add docstrings to all functions | 100% functions documented |
| 1.2.3 | Add module docstrings | All modules have docstrings |
| 1.2.4 | Enforce wiki style | `enforce_wiki_style.sh` passes |
**Phase 1 Completion Metric:** Wiki has 11 files, all functions documented
---
## Phase 2: Security & Quality (Completed)
### Step 2.1: Security Scanning
| Sub-Step | Action | Completion Metric |
|----------|--------|-------------------|
| 2.1.1 | Create red_team.py scanner | Tool runs without errors |
| 2.1.2 | Detect dangerous functions | eval/exec detected |
| 2.1.3 | Detect weak crypto | MD5/SHA1 flagged |
| 2.1.4 | Fix HIGH vulnerabilities | 0 HIGH vulns in scan |
**Phase 2 Completion Metric:** `python tools/security/red_team.py` shows 0 HIGH vulnerabilities
---
### Step 2.2: Code Quality Gates
| Sub-Step | Action | Completion Metric |
|----------|--------|-------------------|
| 2.2.1 | Add strictness checker | Type annotations enforced |
| 2.2.2 | Add compliance scan | Best practices checked |
| 2.2.3 | Add idempotence verification | Operations are idempotent |
| 2.2.4 | Add collision detection | Hash collisions detected |
**Phase 2 Completion Metric:** All quality tools run in CI without errors
---
## Phase 3: Safety Systems (NEXT PRIORITY)
### Step 3.1: Rollback System Design
| Sub-Step | Action | Completion Metric |
|----------|--------|-------------------|
| 3.1.1 | Design transaction logging | Design document in wiki | ✅ |
| 3.1.2 | Define snapshot format | JSON schema defined | ✅ |
| 3.1.3 | Plan restoration API | API design approved | ✅ |
| 3.1.4 | Document rollback scenarios | All scenarios documented | ✅ |
**Step 3.1 Completion Metric:** ✅ Design doc exists in wiki/Operations/Rollback-System.md
---
### Step 3.2: Rollback Implementation
| Sub-Step | Action | Completion Metric |
|----------|--------|-------------------|
| 3.2.1 | Implement snapshot creation | `SnapshotManager` class works | ✅ |
| 3.2.2 | Implement transaction logging | `TransactionLog` records changes | ✅ |
| 3.2.3 | Implement restoration | `restore()` method works | ✅ |
| 3.2.4 | Add CLI rollback command | `nodupe rollback --list` works | ✅ |
**Step 3.2 Completion Metric:**`python -c "from nodupe.core.rollback import RollbackManager"` succeeds
---
### Step 3.3: Rollback Testing
| Sub-Step | Action | Completion Metric |
|----------|--------|-------------------|
| 3.3.1 | Test snapshot creation | Snapshots saved correctly |
| 3.3.2 | Test restoration | Files restored correctly |
| 3.3.3 | Test partial rollback | Subset restored correctly |
| 3.3.4 | Test rollback CLI | CLI commands work |
**Step 3.3 Completion Metric:** Rollback tests have 100% pass rate (100% or nothing - if it fails in tests, it fails in production)
---
### Phase 3 Completion Metric
`pytest tests/core/test_rollback.py -v` passes with 100% coverage (100% or nothing - if it fails in tests, it fails in production)
## Phase 4: Critical Fixes & Coverage (URGENT)
### Step 4.1: Plugin System Repair
| Sub-Step | Action | Completion Metric |
|----------|--------|-------------------|
| 4.1.1 | Fix PluginLoader/Lifecycle/HotReload constructors | Tests no longer fail with TypeError (missing args) |
| 4.1.2 | Implement `discover_plugins` in PluginDiscovery | `hasattr(discovery, 'discover_plugins')` is True |
| 4.1.3 | Implement abstract methods in TestPlugin | `TestPlugin` can be instantiated in tests |
### Step 4.2: Compression & Config Fixes
| Sub-Step | Action | Completion Metric |
|----------|--------|-------------------|
| 4.2.1 | Fix `tar.gz` size estimation in `compression.py` | `test_estimate_compressed_size_comprehensive_branches` passes |
| 4.2.2 | Fix `tar.gz` extraction logic | `test_tar_gz_valid_extraction` passes (len(extracted) == 1) |
| 4.2.3 | Standardize ConfigManager error messages | `test_config_manager_missing_config_file` passes |
### Step 4.3: Coverage Expansion
| Sub-Step | Action | Completion Metric |
|----------|--------|-------------------|
| 4.3.1 | Identify untested modules | Coverage report generated per file |
| 4.3.2 | Implement unit tests for core modules | Line coverage increases to >50% |
| 4.3.3 | Implement unit tests for plugin/db modules | Line coverage increases to >80% |
| 4.3.4 | Achieve "100% or nothing" coverage | Line coverage is 100% |
**Phase 4 Completion Metric:** `pytest` passes with 0 failures and 100% coverage.
---
## Phase 5: Type Safety
### Step 4.1: mypy Integration
| Sub-Step | Action | Completion Metric |
|----------|--------|-------------------|
| 4.1.1 | Add mypy to CI | mypy runs in lint job |
| 4.1.2 | Fix critical type errors | 0 errors in core modules |
| 4.1.3 | Add type annotations | All new functions typed |
| 4.1.4 | Configure strict mode | mypy --strict passes |
**Step 4.1 Completion Metric:** `mypy nodupe/core` returns 0 errors
---
### Step 4.2: Code Formatting
| Sub-Step | Action | Completion Metric |
|----------|--------|-------------------|
| 4.2.1 | Add black to CI | black runs in lint job |
| 4.2.2 | Add isort to CI | isort runs in lint job |
| 4.2.3 | Format all code | Code passes formatting checks |
| 4.2.4 | Add pre-commit hooks | pre-commit runs locally |
**Step 4.2 Completion Metric:** `black --check nodupe/` passes
---
### Phase 4 Completion Metric
`mypy nodupe/ && black --check nodupe/ && isort --check nodupe/` all pass
---
## Phase 6: Performance & Optimization
### Step 6.1: Performance Benchmarks
| Sub-Step | Action | Completion Metric |
|----------|--------|-------------------|
| 5.1.1 | Define benchmark suite | Benchmarks in benchmarks/ |
| 5.1.2 | Measure baseline | Baseline times recorded |
| 5.1.3 | Optimize hot paths | 20% speedup achieved |
| 5.1.4 | Add performance CI | Benchmarks run in CI |
**Step 5.1 Completion Metric:** `python benchmarks/performance_benchmarks.py` completes
---
### Step 6.2: Memory Optimization
| Sub-Step | Action | Completion Metric |
|----------|--------|-------------------|
| 6.2.1 | Profile memory usage | Memory profile created |
| 6.2.2 | Fix unbounded reads | All reads have size limits |
| 6.2.3 | Optimize caching | Cache hit rate >80% |
| 6.2.4 | Add memory limits | Limits enforced in config |
**Step 6.2 Completion Metric:** Memory usage <500MB for 100GB dataset
---
### Phase 6 Completion Metric
Benchmarks complete with <5% regression from baseline
---
## Phase 7: Documentation & Release
### Step 7.1: API Documentation
| Sub-Step | Action | Completion Metric |
|----------|--------|-------------------|
| 7.1.1 | Document public API | All public functions documented | |
| 7.1.2 | Add usage examples | Examples in wiki/API/ | |
| 7.1.3 | Document configuration | Config options documented | |
| 7.1.4 | Document plugins | Plugin development guide exists | |
**Step 7.1 Completion Metric:** wiki/API/ has 5+ documented endpoints (CLI, Snapshot, Transaction, Configuration, + more)
---
### Step 7.3: Marketplace Specification (NEW)
| Sub-Step | Action | Completion Metric |
|----------|--------|-------------------|
| 7.3.1 | Create OpenAPI spec | docs/openapi.yaml follows OAS 3.1.2 | |
| 7.3.2 | Document compliance | docs/OPENAPI.md explains compliance | |
| 7.3.3 | Validate spec | YAML passes enforce_yaml_spec.py | |
| 7.3.4 | Add CI validation | OAS validation in lint job | |
**Step 7.3 Completion Metric:** docs/openapi.yaml is valid OAS 3.1.2, docs/OPENAPI.md exists, validation runs in CI
---
**Phase 7 Additional Completion Metric:** OpenAPI 3.1.2 marketplace spec implemented in `docs/openapi.yaml` with full compliance documentation
---
### Step 7.2: Release Preparation
| Sub-Step | Action | Completion Metric |
|----------|--------|-------------------|
| 7.2.1 | Version bump | pyproject.toml version updated |
| 7.2.2 | Update changelog | Changelog has all changes |
| 7.2.3 | Create release notes | Release notes created |
| 7.2.4 | Publish to PyPI | Package published |
**Step 7.2 Completion Metric:** `pip install nodupelabs` installs latest version
---
### Phase 7 Completion Metric
Release 1.0.0 published to PyPI
---
## Success Metrics Summary
| Phase | Name | Target | Status |
|-------|------|--------|--------|
| 1 | Core Infrastructure | 100% coverage (100% or nothing) | (93.30% achieved) |
| 2 | Security & Quality | 0 HIGH vulns (100% secure) | |
| 3 | Safety Systems | Rollback implemented, 100% tests | |
| 4 | Critical Fixes & Coverage | 0 failures, 100% coverage | 🟡 (93.30% line, ~300 failing) |
| 5 | Type Safety | mypy passes (0 errors) | |
| 6 | Performance | Benchmarks pass | |
| 7 | Release | v1.0.0 published | |
---
## Quick Reference: Current Status (2026-02-22)
### Completed Features ✅
| Phase | Feature | Status | Notes |
|-------|---------|--------|-------|
| 1 | Docstrings 95%+ | | All functions documented |
| 1 | Wiki Documentation | | 11+ files in wiki/ |
| 2 | Security Scanner | | red_team.py implemented |
| 2 | Code Quality Tools | | Multiple enforcement tools |
| 3 | Rollback System | | Snapshot, Transaction, Restore |
| 3 | Rollback Tests | | 11 tests passing |
| 4 | black Formatting | | CI integration |
| 4 | isort Import Order | | CI integration |
| 5 | Performance Benchmarks | | benchmarks/ folder |
| 6 | CHANGELOG.md | | Maintained |
| 6 | OpenAPI Spec | | OAS 3.1.2 compliant |
| 6 | Package Built | | v1.0.0 |
| 6 | Priority 3 Modules | | maintenance, scanner_engine, ml, telemetry |
### Coverage Status
| Metric | Value | Target | Gap |
|--------|-------|--------|-----|
| **Line Coverage** | 93.30% | 100% | 6.7% |
| **Branch Coverage** | 86.17% | 100% | 13.83% |
| **Files at 100%** | 42 files | 91 files | 49 files |
| **Total Tests** | 6,203 | 6,500+ | ~300 tests |
| **Failing Tests** | ~300 (5.2%) | 0 | ~300 tests |
### In Progress ⚠️
| Module | Files | Coverage | Next Session |
|--------|-------|----------|--------------|
| scanner_engine | 2 | 86-88% | Complete processor.py, walker.py |
| leap_year | 1 | 60% | Complete edge cases |
### Priority 1 - Next Session
| Module | Files | Lines | Coverage | Effort |
|--------|-------|-------|----------|--------|
| time_sync | 3 | 1,196 | ~20% | 4-6 days |
| parallel | 2 | 527 | 0% | 3-4 days |
### Priority 2 - Future Work
| Module | Files | Lines | Coverage |
|--------|-------|-------|----------|
| hashing | 4 | 405 | 0% |
| databases | 12 | 1,000+ | 0-25% |
---
**Document Status:** Active Development - Priority 3 Complete
**Next Review:** After Priority 1 completion (time_sync, parallel)