brainy/tests/IMPLEMENTATION_SCHEDULE.md
David Snelling 8ff382ca3b chore: recovery checkpoint - v3.0 API successfully recovered
CRITICAL CHECKPOINT - DO NOT PUSH TO GITHUB

Recovery Status:
- Successfully recovered brainy.ts from compiled JavaScript
- All core v3.0 API methods functional (add, get, update, delete, relate, find, etc.)
- Neural subsystem intact (562KB embedded patterns, NLP working)
- Augmentation pipeline operational (20+ augmentations)
- HNSW clustering system complete
- Triple Intelligence compiled (needs constructor fix)
- Test suite validates functionality

Changes preserved:
- 898 files with changes from last 3 days
- 144,475 insertions
- All augmentation improvements
- All test coverage enhancements
- Complete v3.0 feature set

This is a LOCAL checkpoint only - contains recovered work after corruption incident.
Created backup in .backups/brainy-full-20250910-151314.tar.gz

Branch: recovery-checkpoint-20250910-151433
Date: Wed Sep 10 03:18:04 PM PDT 2025
2025-09-10 15:18:04 -07:00

8.2 KiB

100% Test Coverage Implementation Schedule

Week 1: Critical Path Testing (Target: 25% → 40% coverage)

Day 1-2: Test Infrastructure

Create essential test utilities and fix existing test issues.

Files to create:

tests/helpers/
├── test-factory.ts           # Entity & relationship factories
├── test-assertions.ts        # Custom matchers
├── test-mocks.ts             # Mock implementations
└── coverage-reporter.ts      # Coverage tracking

Actions:

  1. Fix all TypeScript errors in existing tests
  2. Create factory functions for all entity types
  3. Create mock storage adapters
  4. Setup coverage reporting

Day 3-5: Core CRUD Operations

Complete test coverage for basic operations.

Test files to create/update:

tests/unit/brainy/
├── add.test.ts              # 100% coverage of add method
├── get.test.ts              # 100% coverage of get method
├── update.test.ts           # 100% coverage of update method
├── delete.test.ts           # 100% coverage of delete method
└── batch-operations.test.ts # addMany, updateMany, deleteMany

Specific scenarios to test:

// add.test.ts - Must cover:
- All 31 noun types
- Invalid data (null, undefined, empty)
- Metadata handling
- Service multi-tenancy
- Concurrent adds
- Memory limits
- ID generation

// update.test.ts - Must cover:
- Partial updates
- Full replacements
- Non-existent entities
- Concurrent updates
- Version conflicts
- Metadata merging

Week 2: Relationship & Search APIs (Target: 40% → 55% coverage)

Day 6-7: Relationship Operations

Test files:

tests/unit/brainy/
├── relate.test.ts           # relate() method
├── unrelate.test.ts        # unrelate() method
├── getRelations.test.ts    # getRelations() method
└── relateMany.test.ts      # relateMany() method

Must test:

  • All 40 verb types
  • Bidirectional relationships
  • Cascade deletions
  • Relationship weights
  • Confidence scores
  • Metadata on edges
  • Circular relationships
  • Self-relationships

Day 8-10: Search Operations

Test files:

tests/unit/brainy/
├── find.test.ts            # All search modes
├── similar.test.ts         # Similarity search
├── metadata-filters.test.ts # Where clause testing
└── graph-search.test.ts    # Connected searches

Week 3: Storage Adapters (Target: 55% → 70% coverage)

Day 11-12: Memory & FileSystem Storage

Test files:

tests/unit/storage/
├── memory-storage-complete.test.ts
├── filesystem-storage-complete.test.ts
├── storage-migration.test.ts
└── storage-errors.test.ts

Critical paths:

  • Concurrent access
  • File permissions
  • Disk full
  • Corruption recovery
  • Atomic writes
  • Directory traversal

Day 13-15: S3 & Database Storage

Test files:

tests/unit/storage/
├── s3-storage-complete.test.ts
├── postgres-storage.test.ts
├── opfs-storage.test.ts
└── redis-storage.test.ts

Week 4: Augmentations (Target: 70% → 85% coverage)

Day 16-18: Core Augmentations

Priority augmentations to test:

tests/unit/augmentations/
├── index-augmentation.test.ts
├── cache-augmentation.test.ts
├── wal-augmentation.test.ts
├── metrics-augmentation.test.ts
├── validation-augmentation.test.ts
└── security-augmentation.test.ts

Day 19-20: Advanced Augmentations

Test remaining 25+ augmentations:

tests/unit/augmentations/
├── api-server.test.ts
├── audit-log.test.ts
├── batch-processing.test.ts
├── rate-limit.test.ts
├── replication.test.ts
└── [... 20+ more files]

Week 5: Neural & AI (Target: 85% → 92% coverage)

Day 21-23: Neural API

Test files:

tests/unit/neural/
├── clustering.test.ts      # All clustering algorithms
├── outliers.test.ts        # Anomaly detection
├── hierarchy.test.ts       # Semantic hierarchy
├── visualization.test.ts   # Viz data generation
├── neighbors.test.ts       # kNN search
└── performance.test.ts     # Performance metrics

Day 24-25: Embeddings & Triple Intelligence

Test files:

tests/unit/embeddings/
├── embedding-manager.test.ts
├── cached-embeddings.test.ts
└── model-loading.test.ts

tests/unit/triple/
├── triple-intelligence.test.ts
├── query-planning.test.ts
└── fusion-strategies.test.ts

Week 6: Final Push (Target: 92% → 100% coverage)

Day 26-27: Error Paths & Edge Cases

Focus areas:

  • Every try-catch block
  • Every promise rejection
  • Every null check
  • Every boundary condition
  • Every timeout
  • Every cleanup path

Day 28-29: Utils & Helpers

Test all utility functions:

tests/unit/utils/
├── distance.test.ts
├── embedding.test.ts
├── logger.test.ts
├── metadata-filter.test.ts
├── search-cache.test.ts
└── [... 30+ utility files]

Day 30: Coverage Verification

Final steps:

  1. Run full coverage report
  2. Identify any remaining gaps
  3. Create targeted tests for gaps
  4. Verify 100% coverage achieved
  5. Setup CI/CD coverage gates

Daily Execution Plan

Daily Routine:

# Morning: Write tests
npm run test:watch -- path/to/current.test.ts

# Afternoon: Check coverage
npm run test:coverage -- path/to/module

# Evening: Verify progress
npm run test:coverage:report

Coverage Tracking:

// tests/helpers/coverage-tracker.ts
export class CoverageTracker {
  static async report() {
    const coverage = await getCoverage()
    console.log(`
      Current Coverage: ${coverage.statements}%
      Target Coverage: 100%
      Remaining Lines: ${coverage.uncoveredLines}
      Files Complete: ${coverage.filesAt100Percent}
      Files Remaining: ${coverage.filesBelow100Percent}
    `)
  }
}

Priority Order for Maximum Impact

Week 1 Priority:

  1. Fix existing tests (2 hours)
  2. Test infrastructure (4 hours)
  3. Core CRUD operations (16 hours)
  4. Relationship APIs (8 hours)
  5. Basic search (8 hours)

Files with Highest Impact:

  1. src/brainy.ts - Main API (2,000 lines)
  2. src/storage/adapters/*.ts - Storage (3,000 lines)
  3. src/augmentations/*.ts - Augmentations (5,000 lines)
  4. src/neural/*.ts - Neural API (2,500 lines)
  5. src/utils/*.ts - Utilities (3,000 lines)

Automation Scripts

Create test scaffolding:

#!/bin/bash
# scripts/generate-tests.sh

for file in src/**/*.ts; do
  test_file="tests/unit/${file#src/}"
  test_file="${test_file%.ts}.test.ts"
  
  if [ ! -f "$test_file" ]; then
    mkdir -p "$(dirname "$test_file")"
    echo "Creating test for $file -> $test_file"
    npm run generate:test -- "$file" > "$test_file"
  fi
done

Coverage monitoring:

#!/bin/bash
# scripts/monitor-coverage.sh

while true; do
  clear
  npm run test:coverage:summary
  echo "---"
  echo "Uncovered files:"
  npm run test:coverage:uncovered
  sleep 60
done

Success Metrics

Daily Targets:

  • Day 1-5: +5% coverage per day
  • Day 6-10: +3% coverage per day
  • Day 11-20: +2% coverage per day
  • Day 21-25: +1.5% coverage per day
  • Day 26-30: +1% coverage per day

Weekly Milestones:

  • Week 1: Core APIs tested (40% coverage)
  • Week 2: Relationships & Search (55% coverage)
  • Week 3: Storage complete (70% coverage)
  • Week 4: Augmentations done (85% coverage)
  • Week 5: Neural/AI tested (92% coverage)
  • Week 6: 100% coverage achieved

Immediate Next Steps

  1. Fix existing test compilation errors (2 hours)
  2. Create test factory utilities (2 hours)
  3. Test brain.add() completely (2 hours)
  4. Test brain.relate() completely (2 hours)
  5. Run coverage report and verify progress (30 min)

Commands to Run Now:

# Fix TypeScript errors in tests
npm run type-check

# Create test infrastructure
mkdir -p tests/helpers
touch tests/helpers/test-factory.ts
touch tests/helpers/test-assertions.ts

# Start with core CRUD tests
npm run test:watch -- tests/unit/brainy/add.test.ts

# Monitor coverage
npm run test:coverage:watch

This schedule provides a realistic, day-by-day plan to achieve 100% coverage in 6 weeks (30 working days). The key is systematic execution and daily progress tracking.