---
issue: 157
title: Python Environment Validation
analyzed: 2025-10-20T20:59:21Z
estimated_hours: 3
parallelization_factor: 1.5
---

# Parallel Work Analysis: Issue #157

## Overview

Deploy a minimal Python diagnostic script to Railway to validate that Python 3.11 + asyncio works correctly in an isolated environment BEFORE building the full bot-spawner service. This is critical Phase 0 validation to test if the asyncio hang issue is environment-specific or code-specific.

## Parallel Streams

### Stream A: Diagnostic Script & Dockerfile
**Scope**: Create minimal Python diagnostic script and Railway deployment configuration
**Files**:
- `.claude/epics/bot-spawner-extraction/diagnostic/diagnostic.py` (Python script)
- `.claude/epics/bot-spawner-extraction/diagnostic/Dockerfile` (deployment config)
- `.claude/epics/bot-spawner-extraction/diagnostic/README.md` (instructions)
**Agent Type**: backend-specialist (Python)
**Can Start**: immediately
**Estimated Hours**: 1.5 hours
**Dependencies**: none

**Deliverables**:
- Diagnostic Python script with heavy instrumentation:
  - Print Python version and platform info
  - Test asyncio import with error handling
  - Create and test event loop
  - Run basic async function
  - Clear success/failure logging
- Dockerfile using Ubuntu 24.04 + deadsnakes Python 3.11
- Deployment instructions

### Stream B: Railway Deployment & Analysis
**Scope**: Deploy to Railway, capture logs, analyze results, document findings
**Files**:
- `.claude/epics/bot-spawner-extraction/phase0-python-results.md` (findings)
**Agent Type**: general-purpose
**Can Start**: after Stream A completes
**Estimated Hours**: 1.5 hours
**Dependencies**: Stream A (needs diagnostic script and Dockerfile)

**Deliverables**:
- Deploy diagnostic container to Railway (buzztrail-voice-agent project)
- Capture and analyze execution logs
- Document findings with verdict:
  - ✅ PASS: Python 3.11 + asyncio works → Proceed with bot-spawner
  - ❌ FAIL: asyncio hangs → Try alternative approaches
- Recommendations for bot-spawner Dockerfile

## Coordination Points

### Shared Files
No files are shared between streams - clean separation.

### Sequential Requirements
1. **Stream A** (Diagnostic Script): Must complete first
   - Create diagnostic.py with instrumentation
   - Create Dockerfile with exact environment (Ubuntu 24.04 + Python 3.11)
   - Test locally if possible

2. **Stream B** (Deployment & Analysis): Depends on Stream A
   - Deploy diagnostic script to Railway
   - Monitor logs in real-time
   - Analyze results and make GO/NO-GO decision

### Integration Point
Stream B requires:
- Diagnostic script from Stream A (diagnostic.py)
- Dockerfile from Stream A
- Railway deployment knowledge (Railway CLI or similar)

## Conflict Risk Assessment

**Risk Level: LOW**

- Stream A works on `.claude/epics/bot-spawner-extraction/diagnostic/`
- Stream B works on `.claude/epics/bot-spawner-extraction/phase0-python-results.md`
- No file overlap, sequential execution required

## Parallelization Strategy

**Recommended Approach**: sequential (with some overlap possible)

**Why Sequential**:
- Stream B fundamentally depends on Stream A's output
- Deployment and analysis are tightly coupled
- Total work is only 3 hours, minimal overhead

**Possible Overlap**:
- Stream B agent can prepare deployment commands while Stream A works
- Stream B can monitor Railway project setup in parallel

**Execution Plan**:
1. **Phase 1** (1.5h): Stream A creates diagnostic script and Dockerfile
2. **Phase 2** (1.5h): Stream B deploys, monitors, and documents results

## Expected Timeline

**With sequential execution:**
- Stream A: 1.5 hours
- Stream B: 1.5 hours
- **Wall time: 3 hours**
- **Total work: 3 hours**

**With minor overlap** (prepared deployment):
- **Wall time: 2.5 hours** (Stream B can start prep early)
- **Total work: 3 hours**
- **Efficiency gain: ~17%**

**Parallelization factor: 1.5x** (modest improvement possible)

## Agent Assignments

**Stream A Agent**: Backend specialist (Python)
- Strong in Python, Docker, asyncio
- Creates minimal, well-instrumented diagnostic code
- Understands event loop mechanics

**Stream B Agent**: General-purpose (DevOps/documentation)
- Deploys to Railway using CLI
- Captures and analyzes logs
- Writes clear findings report
- Makes technical recommendations

## Notes

**Critical Success Factors**:
1. **Exact Environment Match**: Must use same base image and Python version planned for bot-spawner (Ubuntu 24.04 + Python 3.11 from deadsnakes)
2. **Heavy Instrumentation**: Logging must show exactly where failure occurs (if any)
3. **Compare to Working Example**: voice-agent works on Railway with Python 3.11, use as reference

**Testing Strategy**:
- Keep it minimal - no dependencies beyond Python stdlib
- Test locally first if possible (Docker on macOS/Linux)
- Deploy to Railway and monitor logs in real-time
- Compare behavior to voice-agent deployment

**Decision Tree**:
```
Diagnostic Script Result:
├─ ✅ SUCCESS (asyncio works)
│  └─ Recommendation: Proceed with bot-spawner
│     - Use Ubuntu 24.04 + Python 3.11
│     - asyncio is safe in isolated environment
│     - Issue likely in code interaction, not environment
│
└─ ❌ FAILURE (asyncio hangs)
   └─ Recommendation: Try alternatives
      - Test Python 3.12 (newer asyncio)
      - Test different base image (Alpine, Debian)
      - Compare with voice-agent Dockerfile
      - Consider uv for dependency management
```

**Follow-up Actions**:
- **If PASS**: Update Task #162 to use validated Dockerfile configuration
- **If FAIL**: Create new investigation tasks to isolate root cause

**Cleanup**: Diagnostic service should be removed from Railway after validation to avoid unnecessary costs.

**Railway Configuration**:
- Project: buzztrail-voice-agent (same as test services)
- Service name: python-diagnostic (temporary)
- No environment variables needed (standalone diagnostic)
- Expected runtime: <10 seconds (script exits after tests)
