Skip to main content

🚀 Quick Start Guide: Rust Developer - API + WASM Integration

Session Type: RUST-DEVELOPER (Primary Agent)
Focus Areas: API Backend + WASM Thin Client
File Boundaries: src/api/, src/wasm/, frontend/src/wasm/
Session Pattern: RUST-DEVELOPER-SESSION-$(date +%Y-%m-%d)-API-WASM

⚡ Instant Session Startup

1. terminal Setup (30 seconds)

# Navigate to v4 root
cd /home/halcasteel/coditect.foundationdb.0001/build/decisions/v4

# Set unique session identity
export SESSION_ID="RUST-DEVELOPER-SESSION-$(date +%Y-%m-%d)-API-WASM"
source .codi/scripts/set-session-identity.sh "$SESSION_ID"

# Start monitoring infrastructure
source .codi/scripts/infrastructure/session-start-hook.sh

# Log session start
./.codi/scripts/logging/actors/codi-log-ai.sh "$SESSION_ID: Starting API+WASM development session" "SESSION_START"

2. Claim Your Domain (15 seconds)

# Claim primary file areas
./.codi/scripts/logging/actors/codi-log-ai.sh "$SESSION_ID claiming src/api/ for API development" "FILE_CLAIM"
./.codi/scripts/logging/actors/codi-log-ai.sh "$SESSION_ID claiming src/wasm/ for WASM client" "FILE_CLAIM"
./.codi/scripts/logging/actors/codi-log-ai.sh "$SESSION_ID claiming frontend/src/wasm/ for React integration" "FILE_CLAIM"

3. Read Core Documentation (2 minutes)

# Your primary agent guide
cat agents/coditect/rust-developer.md

# Sub-agent capabilities available to you
cat agents/claude-subagents/README.md | grep -A5 "rust-expert-developer\|frontend-react-typescript-expert"

🎯 Your Mission: API + WASM Thin Client Integration

Primary Responsibilities

  1. Rust API Backend: Core authentication, data services, WebSocket endpoints
  2. WASM Thin Client: Lightweight browser client with API communication
  3. React Integration: TypeScript bindings and React hooks
  4. Security: Authentication flow and data serialization

Quality Gates

  • ✅ WASM bundle size < 2MB
  • ✅ API response time < 100ms
  • ✅ TypeScript strict compliance
  • ✅ 95% test coverage
  • ✅ Multi-tenant security

🤖 Sub-Agent Delegation Patterns

For Complex WASM Optimization

// When you need deep WASM expertise
Task(
description="Optimize WASM build for thin client",
prompt="Review WASM compilation settings in cargo.toml, analyze bundle size, optimize for browser compatibility. Focus on wee_alloc, panic=abort, and LTO settings.",
subagent_type="rust-expert-developer"
)

For React-WASM Integration

// When you need frontend integration patterns
Task(
description="Design React-WASM integration layer",
prompt="Create TypeScript bindings for WASM module, design React hooks for API communication, implement error boundaries and loading states.",
subagent_type="frontend-react-typescript-expert"
)

For Security Review

// When you need security validation
Task(
description="Security audit of WASM-API communication",
prompt="Review authentication flow between WASM client and API, validate data serialization security, check for XSS and CSRF vulnerabilities.",
subagent_type="security-specialist"
)

📁 Key File Locations

Rust API Backend

src/api/
├── auth/ # Your authentication endpoints
├── handlers/ # Request handlers
├── middleware/ # Security, logging, CORS
├── models/ # Data models
└── websocket/ # Real-time communication

WASM Client

src/wasm/
├── lib.rs # WASM entry point
├── api_client.rs # API communication
├── auth.rs # Client-side auth
└── bindings.rs # JS/TS bindings

Frontend Integration

frontend/src/wasm/
├── types.ts # TypeScript definitions
├── hooks.ts # React hooks
├── client.ts # WASM module wrapper
└── auth.ts # Authentication helpers

🛠️ Essential Commands

Development Workflow

# Build API backend
cd components/api && cargo build --release

# Build WASM client
cd src/wasm && wasm-pack build --target web --out-dir ../../frontend/src/wasm/pkg

# Run API tests
cargo test --package api

# Check WASM bundle size
ls -lh frontend/src/wasm/pkg/*.wasm

Coordination Commands

# Check other active sessions
grep "SESSION_START" .codi/logs/codi-ps.log | tail -10

# Coordinate with other agents
./.codi/scripts/logging/actors/codi-log-ai.sh "$SESSION_ID: API endpoints ready for CODI2 integration" "COORDINATE"

# Hand off completed work
./.codi/scripts/logging/actors/codi-log-ai.sh "$SESSION_ID: WASM client complete, ready for frontend integration" "HANDOFF"

📊 Progress Tracking

Log Your Major Actions

# Starting implementation
./.codi/scripts/logging/actors/codi-log-ai.sh "$SESSION_ID: Implementing WebSocket authentication endpoints" "CREATE"

# Testing milestones
./.codi/scripts/logging/actors/codi-log-ai.sh "$SESSION_ID: API tests passing, WASM bundle 1.8MB" "TEST_PASS"

# Integration points
./.codi/scripts/logging/actors/codi-log-ai.sh "$SESSION_ID: React hooks integrated with WASM client" "INTEGRATE"

# Completion
./.codi/scripts/logging/actors/codi-log-ai.sh "$SESSION_ID: API+WASM integration complete, ready for review" "TASK_COMPLETE"

🔗 Integration Points

With MONITORING-SPECIALIST (CODI2)

  • Metrics Endpoints: Provide /metrics API for CODI2 collection
  • Event Streaming: WebSocket events for real-time monitoring
  • Health Checks: /health endpoint for system status

With ORCHESTRATOR

  • Status Updates: Regular progress reports
  • Conflict Resolution: File ownership coordination
  • Quality Gates: Code review and approval

🚨 Emergency Procedures

Session Recovery

# If session gets disconnected
export SESSION_ID="RUST-DEVELOPER-SESSION-$(date +%Y-%m-%d)-API-WASM"
./.codi/scripts/logging/actors/codi-log-ai.sh "$SESSION_ID: Session recovered, resuming API development" "SESSION_RECOVER"

File Conflicts

# If another agent modified your files
./.codi/scripts/logging/actors/codi-log-ai.sh "$SESSION_ID: CONFLICT detected in src/api/, requesting coordination" "CONFLICT"

Build Failures

# Log build issues for investigation
./.codi/scripts/logging/actors/codi-log-ai.sh "$SESSION_ID: API build failed, investigating dependencies" "ERROR"

🎯 Success Criteria

Your session is successful when:

  • ✅ Rust API backend serves authenticated requests
  • ✅ WASM client communicates securely with API
  • ✅ React integration provides seamless UX
  • ✅ All tests pass with 95% coverage
  • ✅ Security audit shows no vulnerabilities
  • ✅ Bundle size meets performance targets

Ready to start? Run the terminal Setup commands and begin coding!