# Task Completion Workflow

## When a coding task is completed, follow these steps:

### 1. Code Quality Checks
```bash
# Format the code
cargo fmt

# Run linter
cargo clippy

# Check for compilation errors
cargo check
```

### 2. Build & Test
```bash
# Build the project
cargo build

# Run tests
cargo test

# Run specific tests if relevant
cargo test module_name -- --nocapture
```

### 3. Media System Testing (if relevant)
```bash
# Test media processing
./test_media_system.sh

# Test image processing (if modified)
./test_images.sh

# Run comprehensive tests
./comprehensive_test.sh
```

### 4. Service Integration Testing
```bash
# Restart the service
sudo systemctl restart church-api

# Check service status
sudo systemctl status church-api

# View logs for errors
journalctl -fu church-api --lines=50
```

### 5. API Testing (if relevant)
```bash
# Test authentication
curl -X POST https://api.rockvilletollandsda.church/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"username": "admin", "password": "..."}'

# Test relevant endpoints with JWT token
# (Check fix_routes.sh for examples)
```

### 6. Performance Validation (for media changes)
- Check hardware acceleration is working:
  ```bash
  vainfo
  intel_gpu_top  # During transcoding
  ```
- Monitor memory usage and CPU utilization
- Verify transcoding times are reasonable
- Check for memory leaks in long-running operations

### 7. Documentation Updates
- Update inline comments for complex changes
- Add tracing logs for new operations
- Update memory files if architecture changes

### 8. Final Checklist
- [ ] Code compiles without warnings
- [ ] Tests pass
- [ ] Service restarts successfully  
- [ ] No memory leaks or resource exhaustion
- [ ] Hardware acceleration functional (if applicable)
- [ ] Logging provides adequate debugging information
- [ ] Error handling is comprehensive

## Critical Notes

### For Media/Streaming Changes:
- Always test with actual video files
- Verify both AV1 and H.264 codecs work
- Check HLS playlist generation
- Test with different client user agents
- Monitor segment caching behavior

### For GStreamer Integration:
- Ensure GStreamer initialization succeeds
- Test pipeline cleanup (no resource leaks)
- Verify hardware acceleration paths
- Check error handling for missing plugins
- Test with various input formats

### Performance Requirements:
- Transcoding should complete faster than real-time
- Memory usage should remain stable
- No blocking of other requests during transcoding
- Proper cleanup of temporary files and resources