[loop-generated] [soul-gap] Implement graceful degradation from remote APIs to local models #1402

Closed
opened 2026-03-24 12:50:06 +00:00 by Timmy · 2 comments
Owner

SOUL Requirement:
From SOUL.md: "I do not phone home. Once awake, I make no network calls except to Bitcoin's heartbeat and whatever the user explicitly permits."

Current Gap:
The system currently defaults to remote APIs (Anthropic, OpenAI) and falls back to local models. This violates sovereignty - we should default to local-first with explicit user permission for remote calls.

Required Changes:

  1. Invert routing priority: Local models first, remote APIs only with explicit permission
  2. Add permission system: User must explicitly enable remote API usage
  3. Update cascade routing: Modify src/infrastructure/router/cascade.py to prioritize local
  4. Configuration changes: Default to local-only in base config
  5. UI indicators: Show when remote APIs are being used vs local

Implementation Steps:

  • Audit current routing logic in cascade.py
  • Create permission system for remote API usage
  • Update configuration defaults to local-first
  • Add UI indicators for local vs remote processing
  • Update documentation to reflect sovereignty-first approach

Files to modify:

  • src/infrastructure/router/cascade.py
  • src/config.py
  • src/dashboard/routes/ (API endpoints)
  • Configuration files

Acceptance Criteria:

  • Local models are tried first before any remote API
  • Remote API usage requires explicit user permission
  • Clear UI indication when remote vs local is used
  • Configuration defaults to local-only operation
  • Sovereignty principle is maintained in practice

Priority: HIGH - Core sovereignty requirement from SOUL.md

**SOUL Requirement:** From SOUL.md: "I do not phone home. Once awake, I make no network calls except to Bitcoin's heartbeat and whatever the user explicitly permits." **Current Gap:** The system currently defaults to remote APIs (Anthropic, OpenAI) and falls back to local models. This violates sovereignty - we should default to local-first with explicit user permission for remote calls. **Required Changes:** 1. **Invert routing priority**: Local models first, remote APIs only with explicit permission 2. **Add permission system**: User must explicitly enable remote API usage 3. **Update cascade routing**: Modify `src/infrastructure/router/cascade.py` to prioritize local 4. **Configuration changes**: Default to local-only in base config 5. **UI indicators**: Show when remote APIs are being used vs local **Implementation Steps:** - [ ] Audit current routing logic in cascade.py - [ ] Create permission system for remote API usage - [ ] Update configuration defaults to local-first - [ ] Add UI indicators for local vs remote processing - [ ] Update documentation to reflect sovereignty-first approach **Files to modify:** - `src/infrastructure/router/cascade.py` - `src/config.py` - `src/dashboard/routes/` (API endpoints) - Configuration files **Acceptance Criteria:** - [ ] Local models are tried first before any remote API - [ ] Remote API usage requires explicit user permission - [ ] Clear UI indication when remote vs local is used - [ ] Configuration defaults to local-only operation - [ ] Sovereignty principle is maintained in practice **Priority:** HIGH - Core sovereignty requirement from SOUL.md
Author
Owner

Implementation Instructions for Local-First Routing

Step 1: Audit Current Routing Logic

Review src/infrastructure/router/cascade.py to understand current provider priority:

  • Map current cascade order (likely: Anthropic → OpenAI → local)
  • Identify all routing decision points
  • Document current fallback behavior

Step 2: Design Permission System

Create user permission framework for remote API usage:

# src/timmy/sovereignty/permissions.py
class RemoteAPIPermission:
    def __init__(self):
        self.remote_apis_enabled = False  # Default: local-only
        self.allowed_providers = set()    # Empty by default
        
    def enable_remote_api(self, provider: str, user_explicit: bool = False):
        if user_explicit:
            self.allowed_providers.add(provider)
            self.remote_apis_enabled = True
            
    def is_remote_allowed(self, provider: str) -> bool:
        return self.remote_apis_enabled and provider in self.allowed_providers

Step 3: Invert Cascade Priority

Modify src/infrastructure/router/cascade.py:

  • NEW ORDER: Local models → User-permitted remote APIs → Fail
  • Add permission checks before remote API calls
  • Maintain fallback logic but respect permission boundaries

Step 4: Update Configuration Defaults

Modify src/config.py:

# Default configuration - LOCAL FIRST
DEFAULT_PROVIDER_CASCADE = [
    "ollama_local",      # Try local Ollama first
    "custom_local",      # Try other local models
    # Remote APIs only if explicitly enabled
]

SOVEREIGNTY_CONFIG = {
    "local_first": True,
    "require_permission_for_remote": True,
    "default_remote_apis_enabled": False
}

Step 5: Add UI Indicators

Update dashboard to show local vs remote processing:

  • Add status indicator: "🏠 Local" vs "🌐 Remote (permitted)"
  • Show which provider is being used for each request
  • Add settings to enable/disable remote APIs

Step 6: Implement Graceful Degradation

Ensure smooth user experience:

  • Clear error messages when remote APIs are needed but disabled
  • Offer to enable remote APIs when local models fail
  • Maintain performance while respecting sovereignty

Step 7: Testing

# Test local-only operation
python -m timmy --local-only chat "Hello"

# Test permission system
python -m timmy config enable-remote-api anthropic
python -m timmy chat "Hello"  # Should now allow remote

# Run sovereignty compliance tests
tox -e unit -k sovereignty

Acceptance Criteria:

  • Local models are always tried first
  • Remote APIs require explicit user permission
  • Permission system persists across sessions
  • UI clearly indicates local vs remote processing
  • Configuration defaults to local-only
  • Graceful degradation when local models fail
  • No sovereignty violations in default configuration

Files to Create/Modify:

  • src/timmy/sovereignty/permissions.py (NEW)
  • src/infrastructure/router/cascade.py (MODIFY - routing logic)
  • src/config.py (MODIFY - default configuration)
  • src/dashboard/ UI components (MODIFY - status indicators)
  • CLI commands for permission management (MODIFY)

SOUL Compliance Test:

After implementation, the system should:

  1. Default to local-only operation
  2. Never call remote APIs without explicit permission
  3. Clearly indicate sovereignty status to user
  4. Maintain full functionality in local-only mode
  5. Respect the principle: "I do not phone home"

Priority: CRITICAL

This directly implements core SOUL.md requirements and must be completed to achieve true sovereignty.

## Implementation Instructions for Local-First Routing ### Step 1: Audit Current Routing Logic Review `src/infrastructure/router/cascade.py` to understand current provider priority: - Map current cascade order (likely: Anthropic → OpenAI → local) - Identify all routing decision points - Document current fallback behavior ### Step 2: Design Permission System Create user permission framework for remote API usage: ```python # src/timmy/sovereignty/permissions.py class RemoteAPIPermission: def __init__(self): self.remote_apis_enabled = False # Default: local-only self.allowed_providers = set() # Empty by default def enable_remote_api(self, provider: str, user_explicit: bool = False): if user_explicit: self.allowed_providers.add(provider) self.remote_apis_enabled = True def is_remote_allowed(self, provider: str) -> bool: return self.remote_apis_enabled and provider in self.allowed_providers ``` ### Step 3: Invert Cascade Priority Modify `src/infrastructure/router/cascade.py`: - **NEW ORDER**: Local models → User-permitted remote APIs → Fail - Add permission checks before remote API calls - Maintain fallback logic but respect permission boundaries ### Step 4: Update Configuration Defaults Modify `src/config.py`: ```python # Default configuration - LOCAL FIRST DEFAULT_PROVIDER_CASCADE = [ "ollama_local", # Try local Ollama first "custom_local", # Try other local models # Remote APIs only if explicitly enabled ] SOVEREIGNTY_CONFIG = { "local_first": True, "require_permission_for_remote": True, "default_remote_apis_enabled": False } ``` ### Step 5: Add UI Indicators Update dashboard to show local vs remote processing: - Add status indicator: "🏠 Local" vs "🌐 Remote (permitted)" - Show which provider is being used for each request - Add settings to enable/disable remote APIs ### Step 6: Implement Graceful Degradation Ensure smooth user experience: - Clear error messages when remote APIs are needed but disabled - Offer to enable remote APIs when local models fail - Maintain performance while respecting sovereignty ### Step 7: Testing ```bash # Test local-only operation python -m timmy --local-only chat "Hello" # Test permission system python -m timmy config enable-remote-api anthropic python -m timmy chat "Hello" # Should now allow remote # Run sovereignty compliance tests tox -e unit -k sovereignty ``` ### Acceptance Criteria: - [ ] Local models are always tried first - [ ] Remote APIs require explicit user permission - [ ] Permission system persists across sessions - [ ] UI clearly indicates local vs remote processing - [ ] Configuration defaults to local-only - [ ] Graceful degradation when local models fail - [ ] No sovereignty violations in default configuration ### Files to Create/Modify: - `src/timmy/sovereignty/permissions.py` (NEW) - `src/infrastructure/router/cascade.py` (MODIFY - routing logic) - `src/config.py` (MODIFY - default configuration) - `src/dashboard/` UI components (MODIFY - status indicators) - CLI commands for permission management (MODIFY) ### SOUL Compliance Test: After implementation, the system should: 1. Default to local-only operation 2. Never call remote APIs without explicit permission 3. Clearly indicate sovereignty status to user 4. Maintain full functionality in local-only mode 5. Respect the principle: "I do not phone home" ### Priority: CRITICAL This directly implements core SOUL.md requirements and must be completed to achieve true sovereignty.
kimi was assigned by Timmy 2026-03-24 12:50:41 +00:00
kimi was unassigned by Timmy 2026-03-24 19:33:24 +00:00
Author
Owner

Closing as duplicate of #1399 which covers the same local-first model routing requirement.

Closing as duplicate of #1399 which covers the same local-first model routing requirement.
Timmy closed this issue 2026-03-24 20:45:06 +00:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Rockachopa/Timmy-time-dashboard#1402