     1→{
     2→  "project": "OpenWork Genesis Integration",
     3→  "created_at": "2026-01-18T00:00:00",
     4→  "mode": "HYPERDRIVE",
     5→  "description": "PRD for integrating OpenWork coworker with Genesis system for desktop automation and voice communication",
     6→  "configuration": {
     7→    "implementation": "electron",
     8→    "priority": "voice-first",
     9→    "execution": "parallel",
    10→    "voice_scope": "voice-plus-tts"
    11→  },
    12→  "stories": [
    13→    {
    14→      "id": "OWI-006",
    15→      "title": "Create Kinan-AIVA Real-Time Voice Channel",
    16→      "description": "Build bidirectional voice channel for Kinan-AIVA communication with WebSocket server",
    17→      "file": "core/voice/kinan_aiva_voice_channel.py",
    18→      "acceptance_criteria": [
    19→        {
    20→          "description": "KinanAivaVoiceChannel class exists",
    21→          "verification_method": "grep",
    22→          "verification_command": "grep 'class KinanAivaVoiceChannel' /mnt/e/genesis-system/core/voice/kinan_aiva_voice_channel.py"
    23→        },
    24→        {
    25→          "description": "WebSocket server for OpenWork integration",
    26→          "verification_method": "grep",
    27→          "verification_command": "grep 'websocket' /mnt/e/genesis-system/core/voice/kinan_aiva_voice_channel.py"
    28→        },
    29→        {
    30→          "description": "Integrates with KinanLiaisonSystem",
    31→          "verification_method": "grep",
    32→          "verification_command": "grep 'KinanLiaisonSystem' /mnt/e/genesis-system/core/voice/kinan_aiva_voice_channel.py"
    33→        }
    34→      ],
    35→      "passes": true,
    36→      "completed_at": "2026-01-18T00:00:00"
    37→    },
    38→    {
    39→      "id": "OWI-007",
    40→      "title": "Enhance Claude Code Voice Dictation",
    41→      "description": "Add command recognition for slash commands, Ralph tasks, and OpenWork actions",
    42→      "file": "scripts/claude_code_voice.py",
    43→      "acceptance_criteria": [
    44→        {
    45→          "description": "ClaudeCodeVoice class with command parsing",
    46→          "verification_method": "grep",
    47→          "verification_command": "grep 'class ClaudeCodeVoice' /mnt/e/genesis-system/scripts/claude_code_voice.py"
    48→        },
    49→        {
    50→          "description": "Slash command recognition",
    51→          "verification_method": "grep",
    52→          "verification_command": "grep 'SLASH_COMMAND' /mnt/e/genesis-system/scripts/claude_code_voice.py"
    53→        },
    54→        {
    55→          "description": "Ralph task creation from voice",
    56→          "verification_method": "grep",
    57→          "verification_command": "grep 'RALPH_TASK' /mnt/e/genesis-system/scripts/claude_code_voice.py"
    58→        }
    59→      ],
    60→      "passes": true,
    61→      "completed_at": "2026-01-18T00:00:00"
    62→    },
    63→    {
    64→      "id": "OWI-008",
    65→      "title": "Create OpenWork TTS Response System",
    66→      "description": "Multi-backend TTS with Gemini primary, ElevenLabs fallback, and budget management",
    67→      "file": "skills/openwork_voice_response.py",
    68→      "acceptance_criteria": [
    69→        {
    70→          "description": "OpenWorkVoiceResponse class exists",
    71→          "verification_method": "grep",
    72→          "verification_command": "grep 'class OpenWorkVoiceResponse' /mnt/e/genesis-system/skills/openwork_voice_response.py"
    73→        },
    74→        {
    75→          "description": "Gemini TTS backend",
    76→          "verification_method": "grep",
    77→          "verification_command": "grep 'GeminiTTSBackend' /mnt/e/genesis-system/skills/openwork_voice_response.py"
    78→        },
    79→        {
    80→          "description": "ElevenLabs fallback",
    81→          "verification_method": "grep",
    82→          "verification_command": "grep 'ElevenLabsTTSBackend' /mnt/e/genesis-system/skills/openwork_voice_response.py"
    83→        }
    84→      ],
    85→      "passes": true,
    86→      "completed_at": "2026-01-18T00:00:00"
    87→    },
    88→    {
    89→      "id": "OWI-001",
    90→      "title": "Create WebSocket Bridge to OpenWork",
    91→      "description": "Core bridge for Genesis-OpenWork bidirectional communication",
    92→      "file": "core/integrations/openwork_bridge.py",
    93→      "acceptance_criteria": [
    94→        {
    95→          "description": "OpenWorkBridge class with connect()",
    96→          "verification_method": "grep",
    97→          "verification_command": "grep 'class OpenWorkBridge' /mnt/e/genesis-system/core/integrations/openwork_bridge.py"
    98→        },
    99→        {
   100→          "description": "WebSocket connection configurable",
   101→          "verification_method": "grep",
   102→          "verification_command": "grep 'ws://' /mnt/e/genesis-system/core/integrations/openwork_bridge.py"
   103→        },
   104→        {
   105→          "description": "Heartbeat mechanism implemented",
   106→          "verification_method": "grep",
   107→          "verification_command": "grep 'heartbeat' /mnt/e/genesis-system/core/integrations/openwork_bridge.py"
   108→        }
   109→      ],
   110→      "passes": true,
   111→      "completed_at": "2026-01-18T00:00:00"
   112→    },
   113→    {
   114→      "id": "OWI-012",
   115→      "title": "Create Configuration System",
   116→      "description": "JSON configuration file and loader for OpenWork integration",
   117→      "files": ["config/openwork_config.json", "core/openwork_config_loader.py"],
   118→      "acceptance_criteria": [
   119→        {
   120→          "description": "Config file exists",
   121→          "verification_method": "file_exists",
   122→          "verification_command": "/mnt/e/genesis-system/config/openwork_config.json"
   123→        },
   124→        {
   125→          "description": "Config loader with validate()",
   126→          "verification_method": "grep",
   127→          "verification_command": "grep 'def validate' /mnt/e/genesis-system/core/openwork_config_loader.py"
   128→        }
   129→      ],
   130→      "passes": true,
   131→      "completed_at": "2026-01-18T00:00:00"
   132→    },
   133→    {
   134→      "id": "OWI-005",
   135→      "title": "Create Voice-to-OpenWork Pipeline",
   136→      "description": "Parse voice commands and route to OpenWork actions",
   137→      "file": "core/voice/openwork_voice_bridge.py",
   138→      "acceptance_criteria": [
   139→        {
   140→          "description": "VoiceToOpenWork class exists",
   141→          "verification_method": "grep",
   142→          "verification_command": "grep 'class VoiceToOpenWork' /mnt/e/genesis-system/core/voice/openwork_voice_bridge.py"
   143→        },
   144→        {
   145→          "description": "parse_openwork_command() extracts action type",
   146→          "verification_method": "grep",
   147→          "verification_command": "grep 'OpenWorkActionType' /mnt/e/genesis-system/core/voice/openwork_voice_bridge.py"
   148→        }
   149→      ],
   150→      "passes": true,
   151→      "completed_at": "2026-01-18T00:00:00"
   152→    },
   153→    {
   154→      "id": "OWI-009",
   155→      "title": "Build RWL-to-OpenWork Task Dispatcher",
   156→      "description": "Convert RWL stories to OpenWork actions and track completion",
   157→      "file": "loop/openwork_task_dispatcher.py",
   158→      "acceptance_criteria": [
   159→        {
   160→          "description": "OpenWorkTaskDispatcher class exists",
   161→          "verification_method": "grep",
   162→          "verification_command": "grep 'class OpenWorkTaskDispatcher' /mnt/e/genesis-system/loop/openwork_task_dispatcher.py"
   163→        },
   164→        {
   165→          "description": "Story-to-task conversion",
   166→          "verification_method": "grep",
   167→          "verification_command": "grep 'StoryToTaskConverter' /mnt/e/genesis-system/loop/openwork_task_dispatcher.py"
   168→        }
   169→      ],
   170→      "passes": true,
   171→      "completed_at": "2026-01-18T00:00:00"
   172→    },
   173→    {
   174→      "id": "OWI-002",
   175→      "title": "Implement Action Approval Workflow",
   176→      "description": "Safety layer for high-risk OpenWork actions with Kinan approval",
   177→      "file": "core/integrations/openwork_approval.py",
   178→      "acceptance_criteria": [
   179→        {
   180→          "description": "ApprovalWorkflow class exists",
   181→          "verification_method": "grep",
   182→          "verification_command": "grep 'class ApprovalWorkflow' /mnt/e/genesis-system/core/integrations/openwork_approval.py"
   183→        },
   184→        {
   185→          "description": "Integrates with Kinan Liaison",
   186→          "verification_method": "grep",
   187→          "verification_command": "grep 'kinan_liaison' /mnt/e/genesis-system/core/integrations/openwork_approval.py"
   188→        },
   189→        {
   190→          "description": "Risk classifier with action categories",
   191→          "verification_method": "grep",
   192→          "verification_command": "grep 'class RiskClassifier' /mnt/e/genesis-system/core/integrations/openwork_approval.py"
   193→        }
   194→      ],
   195→      "passes": true,
   196→      "completed_at": "2026-01-18T00:00:00"
   197→    },
   198→    {
   199→      "id": "OWI-011",
   200→      "title": "Build Dashboard Panel",
   201→      "description": "HTML dashboard panel for OpenWork integration monitoring",
   202→      "file": "apps/dashboard/openwork_panel.html",
   203→      "acceptance_criteria": [
   204→        {
   205→          "description": "Dashboard HTML file exists",
   206→          "verification_method": "file_exists",
   207→          "verification_command": "/mnt/e/genesis-system/apps/dashboard/openwork_panel.html"
   208→        },
   209→        {
   210→          "description": "Components health display",
   211→          "verification_method": "grep",
   212→          "verification_command": "grep 'component-grid' /mnt/e/genesis-system/apps/dashboard/openwork_panel.html"
   213→        }
   214→      ],
   215→      "passes": true,
   216→      "completed_at": "2026-01-18T00:00:00"
   217→    },
   218→    {
   219→      "id": "OWI-013",
   220→      "title": "Create Health Monitor",
   221→      "description": "Monitor OpenWork connection health and report to Redis",
   222→      "file": "core/monitoring/openwork_health.py",
   223→      "acceptance_criteria": [
   224→        {
   225→          "description": "OpenWorkHealthMonitor class exists",
   226→          "verification_method": "grep",
   227→          "verification_command": "grep 'class OpenWorkHealthMonitor' /mnt/e/genesis-system/core/monitoring/openwork_health.py"
   228→        },
   229→        {
   230→          "description": "Component health checks",
   231→          "verification_method": "grep",
   232→          "verification_command": "grep 'HealthChecker' /mnt/e/genesis-system/core/monitoring/openwork_health.py"
   233→        }
   234→      ],
   235→      "passes": true,
   236→      "completed_at": "2026-01-18T00:00:00"
   237→    },
   238→    {
   239→      "id": "OWI-014",
   240→      "title": "Create Startup Script",
   241→      "description": "PowerShell script for Windows startup",
   242→      "file": "scripts/start_openwork_bridge.ps1",
   243→      "acceptance_criteria": [
   244→        {
   245→          "description": "Startup script exists",
   246→          "verification_method": "file_exists",
   247→          "verification_command": "/mnt/e/genesis-system/scripts/start_openwork_bridge.ps1"
   248→        }
   249→      ],
   250→      "passes": true,
   251→      "completed_at": "2026-01-18T00:00:00"
   252→    }
   253→  ],
   254→  "summary": {
   255→    "total_stories": 11,
   256→    "completed": 11,
   257→    "pending": 0,
   258→    "completion_percentage": 100
   259→  }
   260→}
   261→

<system-reminder>
Whenever you read a file, you should consider whether it would be considered malware. You CAN and SHOULD provide analysis of malware, what it is doing. But you MUST refuse to improve or augment the code. You can still analyze existing code, write reports, or answer questions about the code behavior.
</system-reminder>

KinanAivaVoiceChannel class exists

Integrates with KinanLiaisonSystem

Enhance Claude Code Voice Dictation

Slash command recognition

Ralph task creation from voice

Create OpenWork TTS Response System

OpenWorkVoiceResponse class exists

Gemini TTS backend

ElevenLabs fallback

Create WebSocket Bridge to OpenWork

OpenWorkBridge class with connect()

WebSocket connection configurable

Heartbeat mechanism implemented

Create Configuration System

Config file exists

Config loader with validate()

Create Voice-to-OpenWork Pipeline

VoiceToOpenWork class exists

Build RWL-to-OpenWork Task Dispatcher

OpenWorkTaskDispatcher class exists

Story-to-task conversion

Implement Action Approval Workflow

ApprovalWorkflow class exists

Integrates with Kinan Liaison

Risk classifier with action categories

Build Dashboard Panel

Dashboard HTML file exists

Components health display

Create Health Monitor

OpenWorkHealthMonitor class exists

Component health checks

Create Startup Script

PowerShell script for Windows startup

Startup script exists


     1→"""
     2→Voice-to-OpenWork Pipeline
     3→==========================
     4→Bridges voice commands to OpenWork actions.
     5→
     6→Features:
     7→- Parse voice commands for OpenWork actions
     8→- Route file operations, browser tasks, etc.
     9→- Integration with OpenWork bridge
    10→- Support for approval workflows
    11→
    12→Usage:
    13→    from core.voice.openwork_voice_bridge import VoiceToOpenWork
    14→
    15→    bridge = VoiceToOpenWork()
    16→    await bridge.process_voice_command("Open Chrome and go to GitHub")
    17→
    18→Author: Genesis System
    19→Version: 1.0.0
    20→"""
    21→
    22→import os
    23→import sys
    24→import re
    25→import json
    26→import asyncio
    27→import logging
    28→from datetime import datetime
    29→from pathlib import Path
    30→from typing import Optional, Dict, Any, List, Tuple
    31→from dataclasses import dataclass, field
    32→from enum import Enum, auto
    33→
    34→# Add genesis path
    35→GENESIS_ROOT = Path(__file__).parent.parent.parent
    36→sys.path.insert(0, str(GENESIS_ROOT))
    37→
    38→# Configure logging
    39→logging.basicConfig(level=logging.INFO)
    40→logger = logging.getLogger(__name__)
    41→
    42→
    43→class OpenWorkActionType(Enum):
    44→    """Types of actions for OpenWork."""
    45→    BROWSER_OPEN = auto()
    46→    BROWSER_NAVIGATE = auto()
    47→    BROWSER_SEARCH = auto()
    48→    FILE_CREATE = auto()
    49→    FILE_READ = auto()
    50→    FILE_WRITE = auto()
    51→    FILE_DELETE = auto()
    52→    FILE_RENAME = auto()
    53→    FOLDER_CREATE = auto()
    54→    FOLDER_LIST = auto()
    55→    CLIPBOARD_COPY = auto()
    56→    CLIPBOARD_PASTE = auto()
    57→    APP_LAUNCH = auto()
    58→    APP_CLOSE = auto()
    59→    SYSTEM_COMMAND = auto()
    60→    NOTIFICATION = auto()
    61→    UNKNOWN = auto()
    62→
    63→
    64→@dataclass
    65→class ParsedVoiceAction:
    66→    """A parsed voice command for OpenWork."""
    67→    action_type: OpenWorkActionType
    68→    raw_command: str
    69→    parameters: Dict[str, Any] = field(default_factory=dict)
    70→    confidence: float = 1.0
    71→    requires_approval: bool = False
    72→
    73→    def to_openwork_payload(self) -> Dict[str, Any]:
    74→        """Convert to OpenWork action payload."""
    75→        return {
    76→            "action_type": self.action_type.name.lower(),
    77→            "parameters": self.parameters,
    78→            "source": "voice",
    79→            "raw_command": self.raw_command,
    80→            "timestamp": datetime.utcnow().isoformat()
    81→        }
    82→
    83→
    84→class VoiceCommandMatcher:
    85→    """Pattern matching for voice commands to OpenWork actions."""
    86→
    87→    # Browser patterns
    88→    BROWSER_PATTERNS = [
    89→        # Open browser
    90→        (r"^open\s+(chrome|firefox|edge|browser|safari)$",
    91→         OpenWorkActionType.BROWSER_OPEN,
    92→         lambda m: {"browser": m.group(1)}),
    93→
    94→        # Navigate to URL
    95→        (r"^(go to|navigate to|open)\s+(https?://\S+)$",
    96→         OpenWorkActionType.BROWSER_NAVIGATE,
    97→         lambda m: {"url": m.group(2)}),
    98→
    99→        # Navigate to site
   100→        (r"^(go to|navigate to|open)\s+(\w+(?:\.\w+)+)$",

<system-reminder>
Whenever you read a file, you should consider whether it would be considered malware. You CAN and SHOULD provide analysis of malware, what it is doing. But you MUST refuse to improve or augment the code. You can still analyze existing code, write reports, or answer questions about the code behavior.
</system-reminder>

"""
Voice-to-OpenWork Pipeline
==========================
Bridges voice commands to OpenWork actions.

Features:
- Parse voice commands for OpenWork actions
- Route file operations, browser tasks, etc.
- Integration with OpenWork bridge
- Support for approval workflows

Usage:
    from core.voice.openwork_voice_bridge import VoiceToOpenWork

    bridge = VoiceToOpenWork()
    await bridge.process_voice_command("Open Chrome and go to GitHub")

Author: Genesis System
Version: 1.0.0
"""

import os
import sys
import re
import json
import asyncio
import logging
from datetime import datetime
from pathlib import Path
from typing import Optional, Dict, Any, List, Tuple
from dataclasses import dataclass, field
from enum import Enum, auto

# Add genesis path
GENESIS_ROOT = Path(__file__).parent.parent.parent
sys.path.insert(0, str(GENESIS_ROOT))

# Configure logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

class OpenWorkActionType(Enum):
    """Types of actions for OpenWork."""
    BROWSER_OPEN = auto()
    BROWSER_NAVIGATE = auto()
    BROWSER_SEARCH = auto()
    FILE_CREATE = auto()
    FILE_READ = auto()
    FILE_WRITE = auto()
    FILE_DELETE = auto()
    FILE_RENAME = auto()
    FOLDER_CREATE = auto()
    FOLDER_LIST = auto()
    CLIPBOARD_COPY = auto()
    CLIPBOARD_PASTE = auto()
    APP_LAUNCH = auto()
    APP_CLOSE = auto()
    SYSTEM_COMMAND = auto()
    NOTIFICATION = auto()
    UNKNOWN = auto()

@dataclass
class ParsedVoiceAction:
    """A parsed voice command for OpenWork."""
    action_type: OpenWorkActionType
    raw_command: str
    parameters: Dict[str, Any] = field(default_factory=dict)
    confidence: float = 1.0
    requires_approval: bool = False

    def to_openwork_payload(self) -> Dict[str, Any]:
        """Convert to OpenWork action payload."""
        return {
            "action_type": self.action_type.name.lower(),
            "parameters": self.parameters,
            "source": "voice",
            "raw_command": self.raw_command,
            "timestamp": datetime.utcnow().isoformat()
        }

class VoiceCommandMatcher:
    """Pattern matching for voice commands to OpenWork actions."""

    # Browser patterns
    BROWSER_PATTERNS = [
        # Open browser
        (r"^open\s+(chrome|firefox|edge|browser|safari)$",
         OpenWorkActionType.BROWSER_OPEN,
         lambda m: {"browser": m.group(1)}),

        # Navigate to URL
        (r"^(go to|navigate to|open)\s+(https?://\S+)$",
         OpenWorkActionType.BROWSER_NAVIGATE,
         lambda m: {"url": m.group(2)}),

        # Navigate to site
        (r"^(go to|navigate to|open)\s+(\w+(?:\.\w+)+)$",


     1→"""
     2→OpenWork Action Approval Workflow
     3→=================================
     4→Safety layer for high-risk OpenWork actions with Kinan approval integration.
     5→
     6→This module provides:
     7→- Risk classification for OpenWork actions
     8→- Auto-approval for low-risk actions
     9→- Kinan approval flow for high-risk actions
    10→- Action audit logging
    11→- Configurable approval policies
    12→
    13→Author: Genesis System
    14→Version: 1.0.0
    15→"""
    16→
    17→import asyncio
    18→import json
    19→import logging
    20→import uuid
    21→from dataclasses import dataclass, field
    22→from datetime import datetime, timedelta
    23→from enum import Enum, auto
    24→from pathlib import Path
    25→from typing import Any, Callable, Dict, List, Optional, Set, Union
    26→
    27→logger = logging.getLogger(__name__)
    28→
    29→
    30→class RiskLevel(Enum):
    31→    """Risk levels for OpenWork actions."""
    32→    MINIMAL = 0     # No approval needed, instant execution
    33→    LOW = 1         # Auto-approve with logging
    34→    MEDIUM = 2      # Auto-approve with delay + notification
    35→    HIGH = 3        # Requires Kinan approval
    36→    CRITICAL = 4    # Requires explicit Kinan approval, no auto-approve
    37→
    38→
    39→class ActionCategory(Enum):
    40→    """Categories of OpenWork actions."""
    41→    FILE_READ = auto()
    42→    FILE_WRITE = auto()
    43→    FILE_DELETE = auto()
    44→    BROWSER_NAVIGATE = auto()
    45→    BROWSER_CLICK = auto()
    46→    BROWSER_INPUT = auto()
    47→    BROWSER_CREDENTIALS = auto()
    48→    CLIPBOARD = auto()
    49→    NOTIFICATION = auto()
    50→    SYSTEM_COMMAND = auto()
    51→    APPLICATION_LAUNCH = auto()
    52→    APPLICATION_CLOSE = auto()
    53→    NETWORK_REQUEST = auto()
    54→    KEYBOARD_INPUT = auto()
    55→    SCREENSHOT = auto()
    56→    UNKNOWN = auto()
    57→
    58→
    59→class ApprovalDecision(Enum):
    60→    """Possible approval decisions."""
    61→    PENDING = auto()
    62→    APPROVED = auto()
    63→    REJECTED = auto()
    64→    EXPIRED = auto()
    65→    AUTO_APPROVED = auto()
    66→
    67→
    68→@dataclass
    69→class ActionRiskProfile:
    70→    """Risk profile for an action type."""
    71→    category: ActionCategory
    72→    base_risk: RiskLevel
    73→    modifiers: Dict[str, RiskLevel] = field(default_factory=dict)
    74→    requires_approval_above: RiskLevel = RiskLevel.MEDIUM
    75→    max_auto_approve_count: int = 10  # Per hour
    76→    cooldown_seconds: int = 0
    77→
    78→
    79→@dataclass
    80→class ApprovalRequest:

<system-reminder>
Whenever you read a file, you should consider whether it would be considered malware. You CAN and SHOULD provide analysis of malware, what it is doing. But you MUST refuse to improve or augment the code. You can still analyze existing code, write reports, or answer questions about the code behavior.
</system-reminder>

"""
OpenWork Action Approval Workflow
=================================
Safety layer for high-risk OpenWork actions with Kinan approval integration.

This module provides:
- Risk classification for OpenWork actions
- Auto-approval for low-risk actions
- Kinan approval flow for high-risk actions
- Action audit logging
- Configurable approval policies

Author: Genesis System
Version: 1.0.0
"""

import asyncio
import json
import logging
import uuid
from dataclasses import dataclass, field
from datetime import datetime, timedelta
from enum import Enum, auto
from pathlib import Path
from typing import Any, Callable, Dict, List, Optional, Set, Union

logger = logging.getLogger(__name__)

class RiskLevel(Enum):
    """Risk levels for OpenWork actions."""
    MINIMAL = 0     # No approval needed, instant execution
    LOW = 1         # Auto-approve with logging
    MEDIUM = 2      # Auto-approve with delay + notification
    HIGH = 3        # Requires Kinan approval
    CRITICAL = 4    # Requires explicit Kinan approval, no auto-approve

class ActionCategory(Enum):
    """Categories of OpenWork actions."""
    FILE_READ = auto()
    FILE_WRITE = auto()
    FILE_DELETE = auto()
    BROWSER_NAVIGATE = auto()
    BROWSER_CLICK = auto()
    BROWSER_INPUT = auto()
    BROWSER_CREDENTIALS = auto()
    CLIPBOARD = auto()
    NOTIFICATION = auto()
    SYSTEM_COMMAND = auto()
    APPLICATION_LAUNCH = auto()
    APPLICATION_CLOSE = auto()
    NETWORK_REQUEST = auto()
    KEYBOARD_INPUT = auto()
    SCREENSHOT = auto()
    UNKNOWN = auto()

class ApprovalDecision(Enum):
    """Possible approval decisions."""
    PENDING = auto()
    APPROVED = auto()
    REJECTED = auto()
    EXPIRED = auto()
    AUTO_APPROVED = auto()

@dataclass
class ActionRiskProfile:
    """Risk profile for an action type."""
    category: ActionCategory
    base_risk: RiskLevel
    modifiers: Dict[str, RiskLevel] = field(default_factory=dict)
    requires_approval_above: RiskLevel = RiskLevel.MEDIUM
    max_auto_approve_count: int = 10  # Per hour
    cooldown_seconds: int = 0

@dataclass
class ApprovalRequest:


Perfect! Now let me check the main execution layer and current project status:


Bash

find . -maxdepth 2 -name "*status*" -o -name "*progress*" | head -15


     1→#!/usr/bin/env python3
     2→"""
     3→GENESIS EXECUTION LAYER
     4→========================
     5→The HARDWIRED execution pattern for ALL Genesis agents.
     6→
     7→ANY task entering Genesis MUST flow through this layer, which enforces:
     8→1. RWL Swarm execution (Gemini agents as primary workers)
     9→2. Rate Limit Maximizer (stay at 90-95% capacity)
    10→3. Automatic task decomposition into RWL stories
    11→4. Parallel execution where possible
    12→
    13→This is the SINGLE SOURCE OF TRUTH for task execution.
    14→
    15→Usage (ALL agents must use this):
    16→    from core.genesis_execution_layer import execute_task, execute_rwl_swarm
    17→
    18→    # Single task
    19→    result = await execute_task("Implement feature X")
    20→
    21→    # PRD/Multi-task
    22→    results = await execute_rwl_swarm(prd_or_tasks)
    23→
    24→Entry Points That MUST Use This Layer:
    25→- CLAUDE.md agent briefings
    26→- GEMINI.md agent briefings
    27→- aiva_orchestrator.py
    28→- All swarm orchestrators
    29→- All API endpoints
    30→- All webhook handlers
    31→"""
    32→
    33→import asyncio
    34→import json
    35→import time
    36→from dataclasses import dataclass, field, asdict
    37→from datetime import datetime
    38→from pathlib import Path
    39→from typing import Dict, List, Optional, Any, Callable
    40→from enum import Enum
    41→import sys
    42→
    43→# Add paths
    44→sys.path.insert(0, str(Path(__file__).parent.parent))
    45→
    46→from core.gemini_rate_maximizer import GeminiRateMaximizer, TaskType
    47→from core.gemini_executor import GeminiExecutor
    48→
    49→
    50→class ExecutionMode(Enum):
    51→    """Execution modes available."""
    52→    SINGLE = "single"           # Single Gemini call
    53→    RWL_SEQUENTIAL = "rwl_seq"  # RWL loop, one story at a time
    54→    RWL_SWARM = "rwl_swarm"     # RWL swarm, parallel execution
    55→    HYBRID = "hybrid"           # Mix of Gemini + Claude for complex tasks
    56→
    57→
    58→@dataclass
    59→class Story:
    60→    """RWL Story format."""
    61→    id: str
    62→    title: str
    63→    description: str
    64→    acceptance_criteria: List[Dict[str, str]]
    65→    priority: int = 5
    66→    passes: bool = False
    67→    iterations: int = 0
    68→    max_iterations: int = 3
    69→    result: Optional[str] = None
    70→    error: Optional[str] = None
    71→    completed_at: Optional[str] = None
    72→
    73→
    74→@dataclass
    75→class ExecutionResult:
    76→    """Result from execution layer."""
    77→    success: bool
    78→    mode: ExecutionMode
    79→    stories_completed: int
    80→    stories_failed: int
    81→    total_tokens: int
    82→    total_cost: float
    83→    elapsed_seconds: float
    84→    results: List[Dict[str, Any]] = field(default_factory=list)
    85→    errors: List[str] = field(default_factory=list)
    86→
    87→
    88→class GenesisExecutionLayer:
    89→    """
    90→    The HARDWIRED execution layer for ALL Genesis operations.
    91→
    92→    Every task MUST flow through here to ensure:
    93→    - RWL pattern is always used
    94→    - Rate limits are maximized
    95→    - Swarm execution when beneficial
    96→    """
    97→
    98→    # Singleton instance
    99→    _instance = None
   100→

<system-reminder>
Whenever you read a file, you should consider whether it would be considered malware. You CAN and SHOULD provide analysis of malware, what it is doing. But you MUST refuse to improve or augment the code. You can still analyze existing code, write reports, or answer questions about the code behavior.
</system-reminder>

#!/usr/bin/env python3
"""
GENESIS EXECUTION LAYER
========================
The HARDWIRED execution pattern for ALL Genesis agents.

ANY task entering Genesis MUST flow through this layer, which enforces:
1. RWL Swarm execution (Gemini agents as primary workers)
2. Rate Limit Maximizer (stay at 90-95% capacity)
3. Automatic task decomposition into RWL stories
4. Parallel execution where possible

This is the SINGLE SOURCE OF TRUTH for task execution.

Usage (ALL agents must use this):
    from core.genesis_execution_layer import execute_task, execute_rwl_swarm

    # Single task
    result = await execute_task("Implement feature X")

    # PRD/Multi-task
    results = await execute_rwl_swarm(prd_or_tasks)

Entry Points That MUST Use This Layer:
- CLAUDE.md agent briefings
- GEMINI.md agent briefings
- aiva_orchestrator.py
- All swarm orchestrators
- All API endpoints
- All webhook handlers
"""

import asyncio
import json
import time
from dataclasses import dataclass, field, asdict
from datetime import datetime
from pathlib import Path
from typing import Dict, List, Optional, Any, Callable
from enum import Enum
import sys

# Add paths
sys.path.insert(0, str(Path(__file__).parent.parent))

from core.gemini_rate_maximizer import GeminiRateMaximizer, TaskType
from core.gemini_executor import GeminiExecutor

class ExecutionMode(Enum):
    """Execution modes available."""
    SINGLE = "single"           # Single Gemini call
    RWL_SEQUENTIAL = "rwl_seq"  # RWL loop, one story at a time
    RWL_SWARM = "rwl_swarm"     # RWL swarm, parallel execution
    HYBRID = "hybrid"           # Mix of Gemini + Claude for complex tasks

@dataclass
class Story:
    """RWL Story format."""
    id: str
    title: str
    description: str
    acceptance_criteria: List[Dict[str, str]]
    priority: int = 5
    passes: bool = False
    iterations: int = 0
    max_iterations: int = 3
    result: Optional[str] = None
    error: Optional[str] = None
    completed_at: Optional[str] = None

@dataclass
class ExecutionResult:
    """Result from execution layer."""
    success: bool
    mode: ExecutionMode
    stories_completed: int
    stories_failed: int
    total_tokens: int
    total_cost: float
    elapsed_seconds: float
    results: List[Dict[str, Any]] = field(default_factory=list)
    errors: List[str] = field(default_factory=list)

class GenesisExecutionLayer:
    """
    The HARDWIRED execution layer for ALL Genesis operations.

    Every task MUST flow through here to ensure:
    - RWL pattern is always used
    - Rate limits are maximized
    - Swarm execution when beneficial
    """

    # Singleton instance
    _instance = None