project-cloud-ide-docs-v4-imports-and-integration-analysis
title: V4 Imports and Integration Analysis type: reference component_type: reference version: 1.0.0 created: '2025-12-27' updated: '2025-12-27' status: active tags:
- ai-ml
- authentication
- deployment
- security
- testing
- api
- architecture
- automation summary: 'V4 Imports and Integration Analysis Date: 2025-10-06 Purpose: Analyze v4 dependencies and plan v4βv5 consolidation for MVP/beta Critical Components for V5 MVP Status Integration Path --------------------- β Built & functional Compile locally, deploy...' moe_confidence: 0.950 moe_classified: 2025-12-31
V4 Imports and Integration Analysis
Date: 2025-10-06 Purpose: Analyze v4 dependencies and plan v4βv5 consolidation for MVP/beta
π― Executive Summaryβ
Critical Components for V5 MVPβ
| Component | Status | Priority | Integration Path |
|---|---|---|---|
| CODI2 Binary | β Built & functional | CRITICAL | Compile locally, deploy to GKE pods |
| API v2 (Rust/Axum) | β Production ready | HIGH | Auth/user management integration |
| workspace Pods | β GKE deployed | HIGH | Session management per user |
| Frontend (React) | β Running | HIGH | Merge with theia IDE UI |
| FoundationDB | β GKE cluster | CRITICAL | Multi-tenant data layer |
| WebSocket Gateway | β Implemented | HIGH | Real-time IDE communication |
π¦ Rust Dependencies Analysisβ
1. CODI2 (File Monitor & Audit Logger)β
Location: coditect-v4/codi2/
Critical Dependencies:
[dependencies]
# Core
tokio = { version = "1.0", features = ["macros", "rt-multi-thread", "fs", "sync", "time", "signal", "io-util", "process"] }
foundationdb = { version = "0.9", features = ["fdb-7_1"] }
# File monitoring
notify = "6.1"
sha2 = "0.10"
blake3 = "1.5"
# WebSocket/HTTP (for syncing to central server)
axum = { version = "0.7", features = ["ws", "macros"] }
tokio-tungstenite = { version = "0.24", features = ["native-tls"] }
# Serialization
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
Build Requirements:
# System dependencies
apt-get install -y clang libclang-dev cmake wget ca-certificates
# FoundationDB client library
wget https://github.com/apple/foundationdb/releases/download/7.1.61/foundationdb-clients_7.1.61-1_amd64.deb
dpkg -i foundationdb-clients_7.1.61-1_amd64.deb
Binary Output:
- Compiled size: ~16MB
- Deployment target: GKE user pods (1 per user)
- Purpose: File system monitoring + audit logging to FDB
Integration Tasks:
- Set up local Rust build environment
- Compile CODI2 binary
- Test with t2 FoundationDB connection
- Create Dockerfile with CODI2
- Deploy to GKE test pod
2. API v2 (Authentication & User Management)β
Location: src/v4-api-v2/
Critical Dependencies:
[dependencies]
# Web framework
actix-web = "4.4"
actix-cors = "0.6"
actix-ws = "0.2"
# Auth
jsonwebtoken = "9.1"
argon2 = "0.5" # Password hashing
# Database
foundationdb = { version = "0.9", features = ["fdb-7_1"] }
# Kubernetes integration
k8s-openapi = { version = "0.20", features = ["v1_28"] }
kube = { version = "0.87", features = ["runtime", "derive"] }
Key Features:
- JWT-based authentication
- User/tenant management
- workspace provisioning
- Pod auto-deployment (GKE)
Integration Tasks:
- Extract auth module from v4
- Integrate with theia authentication
- Connect to t2 FoundationDB
- Test user registration flow
- Test JWT validation
3. workspace Pod (Per-User Container)β
Location: src/v4-workspace-pod/Dockerfile
Architecture:
# Multi-stage build
FROM rust:1.87-slim AS codi2-builder
# Build CODI2 binary
FROM ubuntu:22.04
# Install FoundationDB client
# Install core dev tools (git, vim, tmux)
# Copy CODI2 binary
# Create user workspace
Pod Features:
- Isolated per user
- CODI2 monitoring built-in
- FoundationDB client
- Persistent volume at
/workspace
Integration Tasks:
- Build workspace pod image
- Test with CODI2 monitoring
- Connect to t2 FDB cluster
- Create GKE deployment template
- Test session management integration
π Frontend Dependencies Analysisβ
Location: src/frontend-original/
Package.json (likely contains):
{
"dependencies": {
"react": "^18.x",
"react-router-dom": "^6.x",
"axios": "^1.x",
"@monaco-editor/react": "^4.x",
"xterm": "^5.x",
"socket.io-client": "^4.x"
}
}
Key Components to Merge:
- Authentication UI (Login/Register forms)
- User Management (Profile, settings)
- WebSocket Connection (Real-time updates)
- File Browser (If better than theia's)
Integration Tasks:
- Analyze v4 React components
- Extract reusable UI components
- Port auth forms to theia widgets
- Integrate WebSocket client
- Test with t2 theia IDE
ποΈ FoundationDB Schema Analysisβ
Current V4 Models (from ADRs):
Core Tablesβ
// User Management
tenant_id/user:{user_id} β User
tenant_id/license:{license_id} β License
tenant_id/workspace:{workspace_id} β workspace
// Session Management
tenant_id/session:{session_id} β Session
tenant_id/session_file:{session_id}:{file_path} β FileState
// Audit Logging
tenant_id/audit:{timestamp}:{event_id} β AuditEvent
tenant_id/file_change:{file_path}:{timestamp} β FileChange
Multi-Tenant Patternβ
Key Format: tenant_id/namespace/identifier
Example: abc123/user/usr-001
abc123/workspace/wks-xyz
abc123/audit/2025-10-06T12:00:00Z/evt-123
Integration Tasks:
- Study v4 FDB key schema (ADR-002, ADR-003)
- Create FDB service adapter for t2
- Implement tenant isolation
- Port session storage logic
- Port audit logging patterns
π Authentication & Authorization Flowβ
V4 Current Flow (from src/v4-api-v2):
1. User Registration
ββ> POST /api/v2/auth/register
ββ> Validate email/password
ββ> Hash password (Argon2)
ββ> Store in FDB: tenant_id/user:{user_id}
ββ> Create workspace pod (Kubernetes)
ββ> Return JWT token
2. User Login
ββ> POST /api/v2/auth/login
ββ> Verify password hash
ββ> Generate JWT (jsonwebtoken)
ββ> Store session in FDB
ββ> Return token + user data
3. WebSocket Auth
ββ> Client connects with JWT in query
ββ> Server validates JWT
ββ> Attach session to WebSocket
ββ> Enable real-time communication
4. Pod Provisioning (on registration)
ββ> Create Kubernetes namespace: user-{user_id}
ββ> Deploy workspace pod from template
ββ> Attach PersistentVolume (50GB)
ββ> Inject CODI2 config
ββ> Start CODI2 monitoring
ββ> Store pod info in FDB
Integration Tasks:
- Extract auth handlers from v4 API
- Integrate with theia backend
- Test JWT flow end-to-end
- Implement WebSocket auth
- Test pod auto-provisioning
βΈοΈ GKE E2 Pod Integrationβ
Current V4 Setup (from CLAUDE.md):
# GKE Cluster
Cluster: codi-poc-e2-cluster
Zone: us-central1-a
Namespace: coditect-app
# Services Running
- coditect-frontend (React app)
- coditect-api-v2 (Rust API)
- foundationdb (StatefulSet, 3 nodes)
- fdb-proxy (HAProxy for load balancing)
# User workspace Pods (per user)
- Namespace: user-{user_id}
- Image: gcr.io/.../workspace-pod:v1
- Volume: 50GB PersistentVolume
- Monitoring: CODI2 binary inside pod
Pod Auto-Provisioning Logic (Rust code):
// From src/v4-api-v2/src/main.rs
use kube::{Client, Api};
use k8s_openapi::api::core::v1::{Pod, Namespace, PersistentVolumeClaim};
async fn provision_user_pod(user_id: &str) -> Result<()> {
let client = Client::try_default().await?;
// 1. Create namespace
let ns_api: Api<Namespace> = Api::all(client.clone());
ns_api.create(&PostParams::default(), &namespace_spec).await?;
// 2. Create PVC
let pvc_api: Api<PersistentVolumeClaim> = Api::namespaced(client.clone(), ns_name);
pvc_api.create(&PostParams::default(), &pvc_spec).await?;
// 3. Deploy pod
let pod_api: Api<Pod> = Api::namespaced(client.clone(), ns_name);
pod_api.create(&PostParams::default(), &pod_spec).await?;
Ok(())
}
Integration Tasks:
- Extract pod provisioning code
- Test with t2 GKE cluster
- Update pod template for theia
- Integrate with session management
- Test full user registration β pod creation flow
π Session Management Integrationβ
V4 Session Architecture:
// Session stored in FDB
interface Session {
sessionId: string;
userId: string;
tenantId: string;
workspaceId: string;
podNamespace: string;
podName: string;
createdAt: string;
lastAccessAt: string;
status: 'active' | 'suspended' | 'terminated';
}
// Session-to-Pod mapping
tenant_id/session:{session_id} β {
userId: "usr-123",
podNamespace: "user-usr-123",
podName: "workspace",
websocketConnected: true,
files: ["file1.ts", "file2.rs"],
agents: ["code-gen", "code-review"]
}
Integration Tasks:
- Port session model to t2
- Connect sessions to theia tabs
- Map session to user pod
- Implement session lifecycle
- Test multi-session isolation
π V4 β V5 Migration Roadmapβ
Phase 1: Local CODI2 Build (Week 1)β
Goal: Compile CODI2 binary locally
-
Setup Rust Environment
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Install system deps
sudo apt-get install clang libclang-dev cmake
# Install FDB client
wget https://github.com/apple/foundationdb/releases/download/7.1.61/foundationdb-clients_7.1.61-1_amd64.deb
sudo dpkg -i foundationdb-clients_7.1.61-1_amd64.deb -
Build CODI2
cd coditect-v4/codi2
cargo build --release
# Test binary
./target/release/codi2 --version
./target/release/codi2 test -
Test with T2 FDB
export FDB_CLUSTER_FILE=/workspace/PROJECTS/t2/docs/v4-config/fdb.cluster
./target/release/codi2 test
Deliverables:
- CODI2 binary compiled
- Connected to t2 FDB
- Basic monitoring tested
Phase 2: Authentication Integration (Week 2)β
Goal: Merge v4 auth with theia
-
Extract Auth Code
# Copy auth handlers
cp -r src/v4-api-v2/src/handlers/auth src/services/auth
# Extract models
cp -r src/v4-api-v2/src/models/user src/types/ -
Create theia Auth Service
// src/services/auth-service.ts
@injectable()
export class AuthService {
constructor(
@inject(FDBService) private fdb: FDBService
) {}
async register(email: string, password: string): Promise<User> {
// Port v4 registration logic
}
async login(email: string, password: string): Promise<JWT> {
// Port v4 login logic
}
} -
Create Auth UI Widgets
// src/browser/auth-widget/login-widget.tsx
export class LoginWidget extends ReactWidget {
// Port v4 login form
}
Deliverables:
- Auth service in theia
- Login/Register UI
- JWT generation working
- FDB user storage tested
Phase 3: workspace Pod Deployment (Week 3)β
Goal: Auto-provision GKE pods for users
-
Build workspace Pod Image
cd src/v4-workspace-pod
docker build -t gcr.io/PROJECT_ID/t2-workspace-pod:v1 .
docker push gcr.io/PROJECT_ID/t2-workspace-pod:v1 -
Create Pod Provisioning Service
// src/services/pod-provisioning-service.ts
@injectable()
export class PodProvisioningService {
async createUserPod(userId: string): Promise<PodInfo> {
// Port v4 Kubernetes logic
const namespace = `user-${userId}`;
await this.createNamespace(namespace);
await this.createPVC(namespace, '50Gi');
await this.deployPod(namespace, userId);
return podInfo;
}
} -
Integrate with Registration
// On user registration
const user = await authService.register(email, password);
const pod = await podProvisioningService.createUserPod(user.id);
await sessionService.linkUserToPod(user.id, pod);
Deliverables:
- workspace pod image built
- Pod provisioning service
- User β Pod linking
- CODI2 monitoring in pod
Phase 4: Session Management (Week 4)β
Goal: Multi-session isolation per user
-
Port Session Model
// src/types/session.ts (from v4)
interface Session {
sessionId: string;
userId: string;
tenantId: string;
workspaceId: string;
podInfo: PodInfo;
files: FileState[];
agents: AgentState[];
} -
Create Session Service
// src/services/session-service.ts
@injectable()
export class SessionService {
async createSession(userId: string): Promise<Session> {
const sessionId = uuidv4();
const session = { sessionId, userId, ... };
await this.fdb.set(`${tenantId}/session/${sessionId}`, session);
return session;
}
async switchSession(sessionId: string): Promise<void> {
// Load session state from FDB
// Update theia UI
// Reconnect to user pod
}
} -
Integrate with theia Tabs
// Map theia tab β Session
const sessionTab = new SessionWidget(sessionId);
shell.addWidget(sessionTab, { area: 'main' });
Deliverables:
- Session service implemented
- Session β theia tab mapping
- Session persistence to FDB
- Multi-session switching
Phase 5: Frontend Consolidation (Week 5)β
Goal: Merge v4 React UI with theia
-
Analyze v4 Components
# Identify reusable components
cd src/frontend-original
ls -la src/components/ -
Port to theia Widgets
// Example: User profile widget
// src/browser/user-profile-widget/user-profile-widget.tsx
export class UserProfileWidget extends ReactWidget {
// Port v4 user profile UI
} -
WebSocket Integration
// Port v4 WebSocket client
// src/services/websocket-service.ts
@injectable()
export class WebSocketService {
connect(jwt: string): void {
this.socket = io('ws://api.t2.com', {
auth: { token: jwt }
});
}
}
Deliverables:
- Key v4 components ported
- WebSocket service integrated
- UI consistency with theia
- Real-time updates working
Phase 6: E2E Testing & Deployment (Week 6)β
Goal: Full user flow working
Test Scenarios:
-
User Registration Flow
Register β Create User in FDB β Provision Pod β Create Session β Login to IDE -
Multi-Session Flow
Login β Create Session 1 β Create Session 2 β Switch Sessions β Verify Isolation -
File Monitoring Flow
Edit File β CODI2 Detects β Log to FDB β Real-time Update to UI -
Agent Execution Flow
Run Agent β Execute in User Pod β Stream Output β Store Results in FDB
Deployment Tasks:
- Build all Docker images
- Deploy to GKE staging cluster
- Run E2E test suite
- Performance testing
- Production deployment
π Complete Task Checklistβ
Infrastructure Setupβ
- Install Rust toolchain locally
- Install FoundationDB client
- Set up GCP credentials
- Configure kubectl for GKE
- Verify Docker daemon
CODI2 Compilationβ
- Build CODI2 binary
- Test FDB connection
- Test file monitoring
- Test WebSocket sync
- Create Dockerfile with CODI2
Authenticationβ
- Extract v4 auth code
- Port to theia service
- Create login/register UI
- Implement JWT validation
- Test end-to-end auth flow
Pod Provisioningβ
- Build workspace pod image
- Extract Kubernetes code from v4
- Create pod provisioning service
- Test namespace creation
- Test PVC creation
- Test pod deployment
Session Managementβ
- Port session model from v4
- Create session service
- Integrate with theia tabs
- Test session persistence
- Test session switching
Frontend Integrationβ
- Analyze v4 React components
- Port key components to theia
- Integrate WebSocket client
- Test real-time updates
- UI consistency testing
Database Integrationβ
- Study v4 FDB schema (ADRs)
- Port to t2 FDB service
- Implement tenant isolation
- Test multi-tenant queries
- Verify data persistence
E2E Testingβ
- Registration β Pod creation
- Login β Session creation
- Multi-session isolation
- File monitoring β Audit logs
- Agent execution in pod
Deploymentβ
- Build production images
- Deploy to staging GKE
- Run test suite
- Performance tuning
- Production rollout
π Key V4 Files to Referenceβ
Documentationβ
coditect-v4/CLAUDE.md- V4 operational guidedocs/v4-reference/adrs/adr-002-v4-storage-architecture.md- FDB patternsdocs/v4-reference/adrs/ADR-003-v4-multi-tenant-architecture.md- Tenant isolationdocs/v4-reference/v4-readme.md- V4 project overview
Source Codeβ
coditect-v4/codi2/- File monitor sourcesrc/v4-api-v2/src/handlers/auth/- Auth implementationsrc/v4-api-v2/src/models/- Data modelssrc/v4-workspace-pod/Dockerfile- Pod definitionsrc/frontend-original/- React UI
Configurationβ
docs/v4-config/fdb.cluster- FDB connection stringsrc/v4-workspace-pod/codi2-config.toml- CODI2 config
π― Success Criteria for V5 MVPβ
MVP Complete When:
- β User can register and login
- β GKE pod auto-provisioned on registration
- β CODI2 monitoring active in user pod
- β Multi-session tabs working in theia
- β File changes logged to FDB audit trail
- β Agent execution in isolated user pod
- β Real-time WebSocket updates
- β All data persisted to FoundationDB
- β Secure JWT authentication throughout
- β Beta users can access via coditect.ai
Next Steps:
- Update
project-tasks/project-plan-with-checkboxes.mdwith Phase 3.11 tasks - Create
docs/v5-migration-plan.mdwith detailed timeline - Set up local Rust build environment
- Begin CODI2 compilation
Questions to Resolve:
- Which GCP project for v5 deployment? (serene-voltage-464305-n2 or new?)
- FDB cluster location? (Use v4 cluster or deploy new for t2?)
- Container registry? (gcr.io or Artifact Registry?)
- Domain? (coditect.ai or new subdomain?)