Files
Mai/.planning/phases/03-resource-management/03-02-PLAN.md
Mai Development 1e071398ff
Some checks failed
Discord Webhook / git (push) Has been cancelled
docs(03): create phase plan
Phase 3: Resource Management
- 4 plan(s) in 2 wave(s)
- 2 parallel, 2 sequential
- Ready for execution
2026-01-27 17:58:09 -05:00

6.0 KiB

phase, plan, type, wave, depends_on, files_modified, autonomous, user_setup, must_haves
phase plan type wave depends_on files_modified autonomous user_setup must_haves
03-resource-management 02 execute 1
src/resource/__init__.py
src/resource/tiers.py
src/config/resource_tiers.yaml
true
truths artifacts key_links
Hardware tier system detects and classifies system capabilities
Tier definitions are configurable and maintainable
Model mapping uses tiers for intelligent selection
path provides min_lines
src/resource/tiers.py Hardware tier detection and management system 80
path provides min_lines
src/config/resource_tiers.yaml Configurable hardware tier definitions 30
path provides
src/resource/__init__.py Resource management module initialization
from to via pattern
src/resource/tiers.py src/config/resource_tiers.yaml YAML configuration loading yaml.safe_load|yaml.load
from to via pattern
src/resource/tiers.py src/models/resource_monitor.py Resource monitoring integration ResourceMonitor
Create a hardware tier detection and management system that classifies systems into performance tiers (low_end, mid_range, high_end) with configurable thresholds and intelligent model mapping.

Purpose: Enable Mai to adapt gracefully from low-end hardware to high-end systems by understanding hardware capabilities and selecting appropriate models. Output: Tier detection system with configurable definitions and model mapping capabilities.

<execution_context> @/.opencode/get-shit-done/workflows/execute-plan.md @/.opencode/get-shit-done/templates/summary.md </execution_context>

@.planning/PROJECT.md @.planning/ROADMAP.md @.planning/STATE.md

Research-based architecture

@.planning/phases/03-resource-management/03-RESEARCH.md

Create resource module structure src/resource/__init__.py Create the resource module directory and __init__.py file. The __init__.py should expose the main resource management classes that will be created in this phase: - HardwareTierDetector (from tiers.py) - ProactiveScaler (from scaling.py) - ResourcePersonality (from personality.py)

Include proper module docstring explaining the resource management system's purpose. ls -la src/resource/ shows the directory exists with init.py file Resource module structure is established for Phase 3 components

Create configurable hardware tier definitions src/config/resource_tiers.yaml Create a YAML configuration file defining hardware tiers based on the research patterns. Include:
  1. Three tiers: low_end, mid_range, high_end
  2. Resource thresholds for each tier:
    • RAM amounts (min/max in GB)
    • CPU core counts (min/max)
    • GPU requirements (required/optional)
    • GPU VRAM thresholds
  3. Preferred model categories for each tier
  4. Performance characteristics and expectations
  5. Scaling thresholds specific to each tier

Example structure:

tiers:
  low_end:
    ram_gb: {min: 2, max: 4}
    cpu_cores: {min: 2, max: 4}
    gpu_required: false
    preferred_models: ["small"]
    scaling_thresholds:
      memory_percent: 75
      cpu_percent: 80
  
  mid_range:
    ram_gb: {min: 4, max: 8}
    cpu_cores: {min: 4, max: 8}
    gpu_required: false
    preferred_models: ["small", "medium"]
    scaling_thresholds:
      memory_percent: 80
      cpu_percent: 85
  
  high_end:
    ram_gb: {min: 8, max: null}
    cpu_cores: {min: 6, max: null}
    gpu_required: true
    gpu_vram_gb: {min: 6}
    preferred_models: ["medium", "large"]
    scaling_thresholds:
      memory_percent: 85
      cpu_percent: 90

Include comments explaining each threshold's purpose. python -c "import yaml; print('YAML valid:', yaml.safe_load(open('src/config/resource_tiers.yaml')))" loads the file without errors Hardware tier definitions are configurable and well-documented

Implement HardwareTierDetector class src/resource/tiers.py Create the HardwareTierDetector class that: 1. Loads tier definitions from resource_tiers.yaml 2. Detects current system resources using ResourceMonitor 3. Determines hardware tier based on resource thresholds 4. Provides model recommendations for detected tier 5. Supports tier-specific scaling thresholds

Key methods:

  • load_tier_config(): Load YAML configuration
  • detect_current_tier(): Determine system tier from resources
  • get_preferred_models(): Return model preferences for tier
  • get_scaling_thresholds(): Return tier-specific thresholds
  • is_gpu_required(): Check if tier requires GPU
  • can_upgrade_model(): Check if system can handle larger models

Include proper error handling for configuration loading and resource detection. The detector should integrate with the enhanced ResourceMonitor from Plan 01. python -c "from src.resource.tiers import HardwareTierDetector; htd = HardwareTierDetector(); tier = htd.detect_current_tier(); print('Detected tier:', tier)" returns a valid tier name HardwareTierDetector accurately classifies system capabilities and provides tier-based recommendations

Test hardware tier detection across simulated system configurations: - Low-end systems (2-4GB RAM, 2-4 CPU cores, no GPU) - Mid-range systems (4-8GB RAM, 4-8 CPU cores, optional GPU) - High-end systems (8GB+ RAM, 6+ CPU cores, GPU required)

Verify tier recommendations align with research patterns and model mapping is logical.

<success_criteria> HardwareTierDetector successfully classifies systems into appropriate tiers, loads configuration correctly, integrates with ResourceMonitor, and provides accurate model recommendations based on detected capabilities. </success_criteria>

After completion, create `.planning/phases/03-resource-management/03-02-SUMMARY.md`