π Coditect Sandbox Platform β Full Technical Architecture (L1 β L7)
π§ Level 1 β Problem Statement & Contextβ
Coditect addresses the need for secure, autosaving, multi-runtime sandbox environments that support AI agents, ephemeral developer environments, and dynamic runtime workloads in a zero-trust cloud-native architecture.
Context:
- Demand for ephemeral compute across AI and software engineering
- Multi-tenant environments need strong isolation
- Git-centric workflows require automatic snapshotting and history
- Runtime targets include: containers (gVisor/Kata), microVMs, and WASM
π§ Level 2 β High-Level Architectureβ
πΉ Key Components:β
ui/: React β sandbox explorer and live logsapi/: FastAPI β secure JWT-authenticated backendcontroller/: Go β CRD lifecycle and reconciliationagent/: Python β container execution inside GCP Workstationsinfra/: OpenTofu β GCP, IAM, WIF, GKE, Workstationsmonitoring/: Prometheus + Grafana
π System Flow:β
π Level 3 β Security Architectureβ
- OAuth2 or Firebase-based OIDC login
- JWT Access Tokens (5m), Refresh Tokens (7d)
- mTLS between API and agent
- Agent identity via GCP WIF with workload identity federation
- GitHub tokens scoped and stored in GCP Secret Manager
π§© Level 4 β Sandbox CRD & Controllerβ
CRD:β
apiVersion: coditect.io/v1alpha1
kind: Sandbox
metadata:
name: sbx-abc123
spec:
tenantID: tenant-a
userID: user-x
runtime: gvisor
image: python:3.11
limits:
cpu: 1
memoryMiB: 512
timeoutSeconds: 600
networkPolicy:
blockNetwork: true
status:
phase: Running
logsURL: https://...
autosaveURL: https://github.com/org/repo/tree/autosave/...
Controller Logic:β
- Adds finalizers
- Applies RuntimeClass
- Cleans up autosave snapshot on deletion
βοΈ Level 5 β Runtime & Quota Enforcementβ
| Runtime | Isolation Layer |
|---|---|
gvisor | syscall filter |
kata-fc | microVM (KVM) |
wasmtime | Wasm runtime sandbox |
- Quota set in JWT (
sandbox_quota) - TTL set on CRD and enforced by agent/controller
- Redis backend for active usage metering
π Level 6 β Git Autosave Snapshot Engineβ
- Worktree used per sandbox branch
- Daemon auto-commits every 30s
- Pushes to
autosave/<ticket>/<user>/<date> - Snapshots persisted on timeout, failure, destroy
git add . && git commit -m "autosave" && git push origin autosave/user-abc
- Token TTL managed via Secret Manager and GitHub App
π Level 7 β Observability & Threat Modelingβ
Metrics:β
sandbox_active_totalcontainer_cpu_usage_seconds_totalquota_utilization_ratio
Logs:β
- API + Agent + Controller log
sandbox_id,trace_id,user_id - Cloud Logging to GCS bucket
coditect-audit-logs
Threats & Mitigations:β
| Threat | Mitigation |
|---|---|
| JWT Forgery | RS256 signed via KMS, short TTL |
| Sandbox breakout | gVisor/Kata + seccomp |
| Workstation impersonation | mTLS + pinned CA + WIF |
| Quota exhaustion abuse | API-side token gating + alerting |
β This version includes complete system coverage, corrected syntax, and exportable structure.