Skip to main content

CODITECT Development Studio - System Design Document (SDD) v2.0

Version: 2.0.0
Date: 2026-01-31
Status: Draft
Changes: Unified persistent workspace, GCS primary storage, SQLite cluster, in-workspace multi-LLM coordination


1. Executive Summary

1.1 Purpose

This document describes the system design for the CODITECT Development Studio v2.0 - a browser-based thin client with unified persistent workspaces. Unlike v1.0's ephemeral sandboxes, v2.0 uses single persistent containers where multiple LLM agents coordinate on shared codebases, with all state persisted in GCS and SQLite.

1.2 Key Changes from v1.0

Aspectv1.0v2.0
ComputeEphemeral sandboxes (30-min timeout)Persistent workspaces (8-hour renewable)
LLM ModelExternal routing, isolatedIn-workspace coordination, shared
Storage PrimaryR2GCS (with R2 mirror)
Session StateDurable Objects onlySQLite cluster + JSONL
Cold Start5-10 seconds0 seconds
Cost$4.20/user @ 1K$6.50/user @ 1K

2. System Overview

2.1 High-Level Architecture

┌─────────────────────────────────────────────────────────────────────────────────┐
│ CLIENT LAYER (Browser) │
│ ┌─────────────────────────────────────┐ │
│ │ CODITECT Development Studio │ │
│ │ ┌──────────┐ ┌────────────────┐ │ │
│ │ │ Multi- │ │ Workspace │ │ │
│ │ │ Agent │ │ Timeline + │ │ │
│ │ │ Chat │ │ File Explorer │ │ │
│ │ └──────────┘ └────────────────┘ │ │
│ └─────────────────────────────────────┘ │
└──────────────────────────┬──────────────────────────────────────────────────────┘
│ WebSocket / HTTPS
┌──────────────────────────▼──────────────────────────────────────────────────────┐
│ EDGE LAYER (Cloudflare) │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────────┐ │
│ │ CDN │ │ WAF │ │ Workers │ │ Durable Objects │ │
│ │ │ │ │ │ (API) │ │ (Workspace Registry) │ │
│ └─────────────┘ └─────────────┘ └──────┬──────┘ └─────────────────────────┘ │
└───────────────────────────────────────────┼──────────────────────────────────────┘

┌───────────────────────────────────────────┼──────────────────────────────────────┐
│ PERSISTENT COMPUTE LAYER │
│ ┌────────────────────────────────────────▼────────────────────────────────┐ │
│ │ UNIFIED PERSISTENT WORKSPACE │ │
│ │ │ │
│ │ ┌─────────────────────────────────────────────────────────────────────┐ │ │
│ │ │ AGENT ORCHESTRATOR (in-workspace) │ │ │
│ │ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ │ │
│ │ │ │ Claude │ │ Gemini │ │ Kimi │ │ Codex │ │ │ │
│ │ │ │ Agent │ │ Agent │ │ Agent │ │ Agent │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ State: │ │ State: │ │ State: │ │ State: │ │ │ │
│ │ │ │ editing │ │ waiting │ │ analyzing│ │ indexing │ │ │ │
│ │ │ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │ │ │
│ │ │ │ │ │
│ │ │ Shared: task queue, file locks, message bus, context │ │ │
│ │ └─────────────────────────────────────────────────────────────────────┘ │ │
│ │ │ │
│ │ ┌─────────────────────────────────────────────────────────────────────┐ │ │
│ │ │ SQLITE DATABASE CLUSTER │ │ │
│ │ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ │ │
│ │ │ │ sessions.db │ │ messages.db │ │ artifacts.db│ │ │ │
│ │ │ │ (500MB) │ │ (2GB) │ │ (1GB) │ │ │ │
│ │ │ ├──────────────┤ ├──────────────┤ ├──────────────┤ │ │ │
│ │ │ │ session_id │ │ message_id │ │ artifact_id │ │ │ │
│ │ │ │ agent_states│ │ agent_id │ │ file_path │ │ │ │
│ │ │ │ file_locks │ │ content │ │ vector_embed│ │ │ │
│ │ │ └──────────────┘ └──────────────┘ └──────────────┘ │ │ │
│ │ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ │ │
│ │ │ │parsed_session│ │agent_metrics │ │workspace_idx │ │ │ │
│ │ │ │ (5GB) │ │ (100MB) │ │ (200MB) │ │ │ │
│ │ │ └──────────────┘ └──────────────┘ └──────────────┘ │ │ │
│ │ └─────────────────────────────────────────────────────────────────────┘ │ │
│ │ │ │
│ │ ┌─────────────────────────────────────────────────────────────────────┐ │ │
│ │ │ PERSISTENT STORAGE │ │ │
│ │ │ /home/developer/ │ │ │
│ │ │ ├── projects/ ← GCS FUSE mount (persistent) │ │ │
│ │ │ │ └── .coditect/ │ │ │
│ │ │ │ ├── session.jsonl ← Append-only event log │ │ │
│ │ │ │ ├── databases/ ← SQLite files │ │ │
│ │ │ │ └── checkpoints/ ← Git commits │ │ │
│ │ │ └── .cache/ ← Tool caches │ │ │
│ │ └─────────────────────────────────────────────────────────────────────┘ │ │
│ │ │ │
│ └────────────────────────────────────────────────────────────────────────────┘ │
└───────────────────────────────────────────┬──────────────────────────────────────┘
│ gcsfuse (bidirectional sync)
┌───────────────────────────────────────────▼──────────────────────────────────────┐
│ GCS PRIMARY STORAGE │
│ Bucket: coditect-workspaces-{org-id} │
│ ├── organizations/{org-id}/teams/{team-id}/users/{user-id}/ │
│ │ └── workspaces/{workspace-id}/ │
│ │ ├── projects/ ← Code repositories │
│ │ ├── databases/ ← SQLite files (~9GB per 1K users) │
│ │ ├── sessions/ ← JSONL archives │
│ │ └── vector-store/ ← Embeddings │
│ └── [R2 MIRROR - Cross-region hot cache] │
└───────────────────────────────────────────────────────────────────────────────────┘

2.2 Core Design Principles

Principlev1.0 Implementationv2.0 Implementation
Thin ClientBrowser UI, server computeSame
Persistent StateR2 snapshotsGCS + SQLite real-time sync
Multi-AgentExternal routingIn-workspace coordination
Zero Cold StartN/A (5-10s start)Always-warm workspaces
Data DurabilityEventual consistencyStrong consistency (WAL)
Audit TrailGit checkpoints onlyJSONL + Git dual trail

3. System Components

3.1 Thin Client (Browser)

Changes from v1.0:

  • Added Agent Activity Panel showing real-time status of all 4 LLMs
  • Added Workspace Timeline for session replay
  • Enhanced File Explorer with agent lock indicators

Key Modules:

ModuleChanges
Chat InterfaceShows multi-agent conversations, agent attribution
Agent PanelReal-time status: Claude (editing), Gemini (waiting), etc.
File TreeLock indicators showing which agent has which file
TimelineReplay session history from SQLite + JSONL

3.2 CODITECT-CORE Orchestrator

New Responsibilities:

  1. Workspace Lifecycle Management - Provision, schedule, hibernate persistent workspaces
  2. GCS Integration - Mount coordination, sync monitoring
  3. SQLite Backup Orchestration - Automated WAL archiving

API Changes:

// New endpoints for v2.0
POST /api/v2/workspaces // Create persistent workspace
GET /api/v2/workspaces/:id/status // Get workspace + agent states
POST /api/v2/workspaces/:id/hibernate // Hibernate after 8h
POST /api/v2/workspaces/:id/resume // Resume from hibernation
POST /api/v2/workspaces/:id/agents/:agent/execute // Send task to specific agent
GET /api/v2/workspaces/:id/agents // Get all agent states
GET /api/v2/workspaces/:id/timeline // Get session timeline from SQLite

3.3 Persistent Workspace Pool

Workspace Configuration:

ResourceSpecification
Compute2 vCPU, 4GB RAM (sustained)
Lifetime8 hours (renewable), hibernate after idle
Storage20GB local SSD + GCS mount
Databases6 SQLite databases (~9GB @ 1K users)
AgentsClaude, Gemini, Kimi, Codex (all in-container)

Lifecycle States:

Creating → Active → [Renewable] → Hibernating → Hibernated → Resuming → Active

Terminated (user action or max 24h)

3.4 SQLite Database Cluster

Six Specialized Databases:

DatabasePurposeSize (@ 1K users)Schema
sessions.dbActive session state, file locks500 MBsession_id, agent_states JSON, file_locks JSON
messages.dbAll agent communications2 GBmessage_id, agent_id, content, tokens, cost
artifacts.dbGenerated files, embeddings1 GBartifact_id, file_path, vector_embedding
parsed_sessions.dbNLP-extracted insights5 GBentities, sentiment, topics, decisions
agent_metrics.dbPerformance tracking100 MBtask_type, success, latency, tokens
workspace_idx.dbFile search index200 MBfile_path, content_hash, vector_embedding, git_status

Synchronization Strategy:

  • WAL Mode: Write-Ahead Logging for durability
  • Sync to GCS: Every 30 seconds via FUSE
  • Backup: Hourly full snapshots, continuous WAL archiving

3.5 Session JSONL Archive

Format:

{"ts": "2026-01-31T14:23:01Z", "type": "session_start", "agent": "system", "payload": {"workspace_id": "ws_abc123"}}
{"ts": "2026-01-31T14:23:15Z", "type": "agent_init", "agent": "claude", "payload": {"model": "claude-3-opus-20240229"}}
{"ts": "2026-01-31T14:24:30Z", "type": "user_message", "agent": "user", "payload": {"content": "Refactor auth module"}}
{"ts": "2026-01-31T14:24:31Z", "type": "file_lock_acquire", "agent": "claude", "payload": {"file": "src/auth.ts", "type": "exclusive"}}
{"ts": "2026-01-31T14:25:02Z", "type": "llm_response", "agent": "claude", "payload": {"completion_tokens": 800, "cost": 0.024}}
{"ts": "2026-01-31T14:25:03Z", "type": "file_edit", "agent": "claude", "payload": {"file": "src/auth.ts", "lines_changed": 45}}

Usage:

  • Real-time append during session
  • Compressed and archived daily
  • Used for session replay and audit

3.6 Agent Coordination Protocol

In-Workspace Coordination:

interface AgentCoordinator {
// Task distribution
taskQueue: PriorityQueue<AgentTask>;

// File locking
lockManager: {
acquire(file: string, agent: AgentId, type: 'shared' | 'exclusive'): Promise<boolean>;
release(file: string, agent: AgentId): void;
query(file: string): { locked: boolean; by?: AgentId; type?: LockType };
};

// Cross-agent messaging
messageBus: EventEmitter<{
'file_modified': { file: string; agent: AgentId; diff: string };
'task_completed': { taskId: string; agent: AgentId; result: any };
'agent_state_change': { agent: AgentId; from: State; to: State };
}>;

// Shared context
sharedContext: Map<string, { value: any; updatedBy: AgentId; updatedAt: Date }>;
}

// Example: Collaborative refactoring
async function collaborativeRefactor(targetFiles: string[], requirements: string) {
// All agents plan simultaneously
const [claudePlan, geminiPlan] = await Promise.all([
agents.claude.plan(requirements, targetFiles),
agents.gemini.plan(requirements, targetFiles)
]);

// Merge plans
const mergedPlan = coordinator.mergePlans([claudePlan, geminiPlan]);

// Execute with locking
for (const task of mergedPlan.tasks) {
const lock = await coordinator.lockManager.acquire(
task.file, task.agent, 'exclusive'
);

if (lock) {
await agents[task.agent].execute(task);
await coordinator.lockManager.release(task.file, task.agent);

// Notify other agents
coordinator.messageBus.emit('file_modified', {
file: task.file,
agent: task.agent,
diff: task.result.diff
});
}
}
}

4. Data Flows

4.1 User Login & Workspace Initialization

4.2 Multi-Agent Task Execution

4.3 Session Persistence & Recovery


5. Security Architecture

5.1 GCS Security

LayerImplementation
Encryption at RestAES-256 (Google-managed)
Encryption in TransitTLS 1.3
Access ControlIAM + Service Accounts per org
Bucket PolicyOrg-scoped buckets, no cross-access
Audit LoggingCloud Audit Logs → SIEM

5.2 SQLite Security

MeasureImplementation
EncryptionSQLCipher (AES-256) for sensitive databases
AccessUnix permissions, container-only access
Backup EncryptionGCS customer-managed encryption keys (CMEK)
WAL SecurityWAL files encrypted before GCS sync

5.3 Agent Isolation

While agents share a workspace, they operate with:

  • Process isolation: Each agent in separate thread/process
  • File locking: Exclusive locks prevent concurrent edits
  • Resource quotas: Per-agent CPU/memory limits
  • Sandboxed execution: Tool calls run in isolated subprocesses

6. Storage Architecture

6.1 GCS Bucket Structure

coditect-workspaces-{org-id}

├── organizations/{org-id}/
│ └── teams/{team-id}/
│ └── users/{user-id}/
│ ├── workspaces/
│ │ └── {workspace-id}/
│ │ ├── projects/ # Code repositories
│ │ │ └── {project-name}/
│ │ │ ├── src/
│ │ │ ├── .git/ # Git repository
│ │ │ └── .coditect/
│ │ │ ├── session.jsonl
│ │ │ └── checkpoints/
│ │ │
│ │ ├── databases/ # SQLite files
│ │ │ ├── sessions.db # ~500MB per 1K users
│ │ │ ├── messages.db # ~2GB per 1K users
│ │ │ ├── artifacts.db # ~1GB per 1K users
│ │ │ ├── parsed_sessions.db # ~5GB per 1K users
│ │ │ ├── agent_metrics.db # ~100MB per 1K users
│ │ │ └── workspace_idx.db # ~200MB per 1K users
│ │ │
│ │ ├── sessions/ # JSONL archives
│ │ │ └── 2026/
│ │ │ └── 01/
│ │ │ └── 31/
│ │ │ └── session_*.jsonl.gz
│ │ │
│ │ ├── vector-store/ # Embeddings
│ │ │ └── embeddings.parquet
│ │ │
│ │ └── backups/ # Automated backups
│ │ ├── daily/
│ │ └── hourly/
│ │
│ └── shared/ # Team resources
│ └── templates/

└── system/ # Global resources
└── embeddings/ # Pre-computed embeddings

[R2 MIRROR]
coditect-mirror-{region}
└── hot-cache/ # Frequently accessed files
└── {workspace-id}/
└── [recent 20% of GCS files]

6.2 Storage Tiers

TierStorage ClassUse CaseRetention
HotGCS StandardActive workspaces, recent sessions30 days
WarmGCS NearlineOld sessions, archived data90 days
ColdGCS ColdlineHistorical JSONL, old backups1 year
CacheR2 StandardHot file cacheLRU eviction

7. Scalability & Performance

7.1 Scaling Strategy

ComponentScaling Approach
WorkspacesHorizontal pool, auto-hibernate idle
GCSAutomatic (serverless)
SQLiteVertical per-workspace, shard by user
R2 MirrorAutomatic (serverless)
Durable ObjectsSharding by workspaceId

7.2 Performance Targets

MetricTargetMeasurement
Workspace start< 30sFirst container boot
Workspace resume< 5sFrom hibernation
Agent coordination< 50msIn-workspace message
SQLite query< 10msLocal database
GCS sync latency< 1sWAL flush to GCS
Session restoration< 3sFull state restore

8. Cost Model (v2.0)

8.1 Monthly Cost @ 1,000 Users

CategoryCost% of Total
Persistent Compute$4,20065%
GCS Storage$1,46022%
Operations$1,10017%
R2 Mirror$3555%
LLM Providers$3235%
Edge Compute$2193%
TOTAL$6,500100%

8.2 Cost per User

UsersMonthly CostCost/User
100$650$6.50
500$2,800$5.60
1,000$6,500$6.50
5,000$28,000$5.60
10,000$72,000$7.20

9. Migration from v1.0

9.1 Data Migration

Source (v1.0)Destination (v2.0)Method
R2 project filesGCS projects/gsutil rsync
Durable Object stateSQLite sessions.dbExport → Import
Git backupsGCS + GitContinue using

9.2 API Compatibility

v1.0 Endpointv2.0 EndpointCompatibility
POST /sessionsPOST /workspacesBreaking change
GET /sessions/:idGET /workspaces/:idBreaking change
POST /chatPOST /workspaces/:id/agents/:agent/executeBreaking change

Migration Period: 30 days with dual-mode support


10. Appendix

10.1 Glossary Updates

TermDefinition
Persistent WorkspaceLong-running container with GCS-mounted storage
Agent CoordinatorIn-workspace service managing multi-LLM coordination
SQLite ClusterSix specialized SQLite databases per workspace
Session JSONLAppend-only log of all workspace events
gcsfuseFUSE filesystem for mounting GCS buckets
WALWrite-Ahead Logging for SQLite durability

10.2 References

  • ADR-XXX: Unified Persistent Workspace Architecture (pending)
  • MOE-Agents C4 Architecture v2.0
  • CODITECT Economic Model v2.0
  • Google Cloud Storage Best Practices
  • SQLite WAL Mode Documentation

Document Owner: Platform Engineering Team
Version: 2.0.0
Last Updated: 2026-01-31