Detaillierte Systemarchitektur und Design-Dokumentation.
- System Overview
- Komponenten
- Datenmodell
- API Architecture
- Frontend Architecture
- STOP-Score System
- Enforcement Gate
- Data Flow
- Security
- Deployment
Code Cloud Agents ist ein Supervised AI System, das AI-Agenten รผberwacht und bei kritischen Entscheidungen automatisch eingreift. Das System basiert auf dem STOP-Score Konzept: Jede Agent-Aktion wird bewertet (0-100), und ab einem kritischen Score (โฅ70) wird die Ausfรผhrung blockiert und eine Human Review angefordert.
- Evidence-Based Verification: Keine Behauptung ohne Beweis
- STOP is Success: Bei Risiko ist STOP die richtige Entscheidung
- Cross-Layer Consistency: Frontend โ Backend โ Database Alignment
- Hard Enforcement: STOP-Entscheidungen sind BLOCKING, keine Umgehung mรถglich
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ WEB BROWSER โ
โ (React Dashboard) โ
โโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ HTTP/REST
โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ EXPRESS SERVER โ
โ (Node.js + TypeScript) โ
โ โ
โ โโโโโโโโโโโโโโ โโโโโโโโโโโโโโ โโโโโโโโโโโโโโ โ
โ โ API โ โ Auth โ โ Middlewareโ โ
โ โ Routes โ โ Layer โ โ Layer โ โ
โ โโโโโโโโโโโโโโ โโโโโโโโโโโโโโ โโโโโโโโโโโโโโ โ
โ โ
โ โโโโโโโโโโโโโโ โโโโโโโโโโโโโโ โโโโโโโโโโโโโโ โ
โ โ Task โ โ Audit โ โ Demo โ โ
โ โ Manager โ โ Logger โ โ System โ โ
โ โโโโโโโโโโโโโโ โโโโโโโโโโโโโโ โโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโผโโโโโโโโโโโโ
โ โ โ
โผ โผ โผ
โโโโโโโโโโโโโโ โโโโโโโโโโโโโโ โโโโโโโโโโโโโโ
โ SQLite โ โ Queue โ โ Enforcementโ
โ Database โ โ System โ โ Gate โ
โโโโโโโโโโโโโโ โโโโโโโโโโโโโโ โโโโโโโโโโโโโโ
Technologie: React 18 + TypeScript + Vite
Verantwortlichkeiten:
- User Interface fรผr Agent-Monitoring
- Task-Management Dashboard
- Audit-Log Visualisierung
- Real-time Updates (via polling/WebSocket)
- Admin Controls (Demo System, Enforcement Approvals)
Komponenten:
App.tsx: Main Application ComponentAgentCard.tsx: Agent Status DisplayTaskCard.tsx: Task Details DisplayAuditLog.tsx: Audit Trail ViewerEnforcementApproval.tsx: Human Review Interface
Technologie: Node.js v20+ + Express + TypeScript
Verantwortlichkeiten:
- REST API Endpoints
- Business Logic Execution
- Database Operations
- Queue Management
- Authentication & Authorization
- STOP-Score Calculation
- Enforcement Gate Logic
Module:
src/index.ts: Server Entry Pointsrc/api/*: REST API Routessrc/db/database.ts: Database Interfacesrc/audit/*: Audit & Enforcement Logicsrc/queue/queue.ts: Queue Systemsrc/demo/*: Demo Invite System
Technologie: SQLite (better-sqlite3)
Verantwortlichkeiten:
- Persistent Data Storage
- ACID Transactions
- Indexing & Query Optimization
- Audit Trail Storage
Schema:
tasks: Task managementaudit_entries: Audit logdemo_invites: Invite codesdemo_users: Demo users
Technologie: Redis (production) / In-Memory (development)
Verantwortlichkeiten:
- Task Queue Management
- Background Job Processing
- Retry Logic
- Dead Letter Queue
Technologie: Custom TypeScript Module
Verantwortlichkeiten:
- STOP-Score Calculation
- Risk Assessment
- Task Blocking
- Human Approval Workflow
โโโโโโโโโโโโโโโโโโโโโโโ
โ TASKS โ
โโโโโโโโโโโโโโโโโโโโโโโค
โ id (PK) โ
โ title โ
โ description โ
โ priority โ
โ status โ
โ assignee โ
โ created_at โ
โ updated_at โ
โ stop_score โ
โโโโโโโโโโโโฌโโโโโโโโโโโ
โ
โ 1:N
โ
โโโโโโโโโโโโผโโโโโโโโโโโ
โ AUDIT_ENTRIES โ
โโโโโโโโโโโโโโโโโโโโโโโค
โ id (PK) โ
โ task_id (FK) โ
โ decision โ
โ final_status โ
โ risk_level โ
โ stop_score โ
โ verified_artefacts โ
โ missing_invalid โ
โ required_action โ
โ created_at โ
โโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโ
โ DEMO_INVITES โ
โโโโโโโโโโโโโโโโโโโโโโโค
โ id (PK) โ
โ code (UNIQUE) โ
โ created_by โ
โ max_redemptions โ
โ expires_at โ
โ created_at โ
โโโโโโโโโโโโฌโโโโโโโโโโโ
โ
โ 1:N
โ
โโโโโโโโโโโโผโโโโโโโโโโโ
โ DEMO_USERS โ
โโโโโโโโโโโโโโโโโโโโโโโค
โ id (PK) โ
โ invite_id (FK) โ
โ username โ
โ password_hash โ
โ task_limit โ
โ tasks_created โ
โ created_at โ
โโโโโโโโโโโโโโโโโโโโโโโ
interface Task {
id: string; // UUID
title: string; // Max 200 chars
description?: string; // Optional
priority: "low" | "medium" | "high";
status: "pending" | "in_progress" | "completed" | "stopped";
assignee: string; // Agent name
created_at: string; // ISO 8601
updated_at?: string; // ISO 8601
stop_score?: number; // 0-100
}interface AuditEntry {
id: string; // UUID
task_id?: string; // FK to tasks
decision: "APPROVED" | "STOP_REQUIRED";
final_status: "COMPLETE" | "COMPLETE_WITH_GAPS" | "STOP_REQUIRED";
risk_level: "LOW" | "MEDIUM" | "HIGH" | "CRITICAL";
stop_score: number; // 0-100
verified_artefacts: string; // JSON array
missing_invalid_parts: string; // JSON array
required_next_action: string;
created_at: string; // ISO 8601
}Base URL: http://localhost:3000
Principles:
- RESTful Design
- JSON Request/Response
- HTTP Status Codes
- Error Handling
- Input Validation (Zod)
GET /api โ API Info
GET /health โ Health Check
POST /api/tasks โ Create Task
GET /api/tasks โ List All Tasks
GET /api/tasks/:id โ Get Task by ID
PUT /api/tasks/:id โ Update Task
GET /api/audit โ List Audit Entries
GET /api/audit/:id โ Get Audit Entry
GET /api/enforcement/blocked โ List Blocked Tasks
POST /api/enforcement/approve โ Approve Blocked Task
POST /api/enforcement/reject โ Reject Blocked Task
POST /api/demo/invites โ Create Invite (Admin)
POST /api/demo/redeem โ Redeem Invite Code
GET /api/demo/stats โ Demo Statistics
GET /api/demo/users/:id โ User Usage Stats
Success Response:
{
"success": true,
"data": {
"id": "abc123",
"title": "Task Title"
}
}Error Response:
{
"success": false,
"error": "Invalid input data",
"details": {
"field": "title",
"message": "Title is required"
}
}| Code | Meaning | Usage |
|---|---|---|
| 200 | OK | Successful GET/PUT |
| 201 | Created | Successful POST |
| 400 | Bad Request | Invalid input |
| 401 | Unauthorized | Authentication required |
| 403 | Forbidden | No permission |
| 404 | Not Found | Resource not found |
| 500 | Internal Error | Server error |
App.tsx
โโโ Header
โ โโโ Logo
โ โโโ Navigation
โโโ Dashboard
โ โโโ AgentStatus
โ โ โโโ AgentCard[]
โ โ โโโ AgentStats
โ โโโ TaskManager
โ โ โโโ TaskList
โ โ โ โโโ TaskCard[]
โ โ โโโ CreateTaskForm
โ โโโ AuditLog
โ โ โโโ AuditTable
โ โ โโโ AuditFilters
โ โโโ EnforcementPanel
โ โโโ BlockedTasks
โ โโโ ApprovalForm
โโโ Footer
Strategy: React Context + Hooks
Global State:
AgentContext: Agent status, capabilitiesTaskContext: Task list, active taskAuditContext: Audit entriesEnforcementContext: Blocked tasks, approvals
Component State:
- Local UI state (modals, forms, etc.)
- Form inputs
- Loading states
Strategy: Custom Hooks + Fetch API
// Custom Hook Example
function useTasks() {
const [tasks, setTasks] = useState<Task[]>([]);
const [loading, setLoading] = useState(false);
useEffect(() => {
fetchTasks();
}, []);
async function fetchTasks() {
setLoading(true);
const res = await fetch("/api/tasks");
const data = await res.json();
setTasks(data.data);
setLoading(false);
}
return { tasks, loading, refetch: fetchTasks };
}Der STOP-Score ist eine Risikobewertung (0-100), die bestimmt, ob eine Agent-Aktion fortgesetzt werden darf oder blockiert werden muss.
const WEIGHTS = {
PRICE_CLAIM: 25, // Preisbehauptung
LEGAL_CLAIM: 30, // Rechtsbehauptung
UNPROVEN_CLAIM: 20, // Unbewiesene Behauptung
MISSING_EVIDENCE: 15, // Fehlende Evidenz
IMPLEMENTATION_GAP: 10, // Implementierungslรผcke
NO_VERIFICATION: 25, // Keine Verifikation
};
function computeStopScore(reasons: StopReason[]): ScoreResult {
let score = 0;
const uniqueReasons = [...new Set(reasons)];
for (const reason of uniqueReasons) {
score += WEIGHTS[reason] ?? 0;
}
return {
score: Math.min(score, 100),
stopRequired: score >= 70,
reasons: uniqueReasons,
};
}| Score | Level | Action |
|---|---|---|
| 0-19 | LOW | โ Proceed |
| 20-44 | MEDIUM | |
| 45-69 | HIGH | |
| 70-100 | CRITICAL | ๐ HARD STOP |
| Reason | Score | Description |
|---|---|---|
PRICE_CLAIM |
25 | Unverified price statement |
LEGAL_CLAIM |
30 | Unverified legal statement |
UNPROVEN_CLAIM |
20 | Claim without evidence |
MISSING_EVIDENCE |
15 | Expected artefacts missing |
IMPLEMENTATION_GAP |
10 | Code incomplete |
NO_VERIFICATION |
25 | No verification performed |
Regel: Wenn STOP_SCORE โฅ 70, wird die Task SOFORT BLOCKIERT.
Ablauf:
- Agent sendet Task-Result
- System berechnet STOP-Score
- Wenn Score โฅ 70:
- Task wird in
blockedTasksMap gespeichert - Audit-Entry wird erstellt
- Status โ
AWAITING_APPROVAL - Task kann NICHT fortgesetzt werden
- Task wird in
- Human Review:
- Admin รถffnet Enforcement Panel
- Prรผft Grรผnde und Evidenz
- Entscheidung:
APPROVEoderREJECT
- Nach Approval:
- Task wird entsperrt
- Audit-Entry wird aktualisiert
- Task kann fortgesetzt werden
type GateStatus = "OPEN" | "BLOCKED" | "AWAITING_APPROVAL";
interface GateDecision {
status: GateStatus;
taskId: string;
stopScore: number;
reasons: StopReason[];
blockedAt?: string;
approvedBy?: string;
approvedAt?: string;
}Endpoint: POST /api/enforcement/approve
Request:
{
"taskId": "abc123",
"approvedBy": "admin@example.com",
"reason": "Evidence verified manually"
}Response:
{
"success": true,
"message": "Task approved, gate opened",
"taskId": "abc123"
}1. User (Frontend)
โ
โโโ> POST /api/tasks
โ
โโโ> Express Handler
โ
โโโ> Validate Input (Zod)
โโโ> Create Task in DB
โโโ> Add to Queue
โโโ> Return Task
2. Queue Worker
โ
โโโ> Process Task
โ
โโโ> Execute Agent Logic
โโโ> Collect Evidence
โโโ> Generate Result
3. Enforcement Gate
โ
โโโ> Evaluate Result
โ
โโโ> Calculate STOP-Score
โโโ> Check Reasons
โโโ> Decision:
โ
โโโ> Score < 70: APPROVE
โ โโโ> Update Task Status
โ
โโโ> Score โฅ 70: BLOCK
โโโ> Add to blockedTasks
โโโ> Create Audit Entry
โโโ> Await Human Review
1. Admin (Frontend)
โ
โโโ> GET /api/enforcement/blocked
โ
โโโ> List of Blocked Tasks
2. Admin Reviews Task
โ
โโโ> Verify Evidence
โโโ> Assess Risk
โโโ> Decision
3. Admin Approves/Rejects
โ
โโโ> POST /api/enforcement/approve
โ
โโโ> Enforcement Gate
โ
โโโ> Remove from blockedTasks
โโโ> Update Audit Entry
โโโ> Update Task Status
โโโ> Resume Task Processing
Zod Schemas:
const TaskSchema = z.object({
title: z.string().min(1).max(200),
priority: z.enum(["low", "medium", "high"]),
assignee: z.string().min(1),
});Status: ๐ง Coming Soon (Agent 2 Task)
Planned:
- JWT-based authentication
- Role-based access control (RBAC)
- Admin vs User permissions
- Session management
Status: ๐ง Coming Soon (Agent 2 Task)
Planned:
- Express Rate Limiter
- IP-based limiting
- Endpoint-specific limits
- DDoS protection
All Actions Logged:
- Task creation
- Task updates
- STOP decisions
- Human approvals
- API calls
Audit Log Retention: Unlimited (SQLite persistent)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ NGINX (Reverse Proxy) โ
โ Port 80/443 (SSL/TLS) โ
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโ> Frontend (Static)
โ /build/*
โ
โโโ> Backend (API)
/api/*, /health
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ PM2 (Process Manager) โ
โ cloud-agents-backend โ
โ Node.js v20 + tsx/esm โ
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโ> SQLite Database
โ /root/cloud-agents/data/
โ
โโโ> Logs
/root/cloud-agents/logs/
Server:
- IP: 178.156.178.70
- OS: Ubuntu 24.04
- CPU: 8 cores (Dedicated)
- RAM: 30 GB
- Disk: 226 GB
Stack:
- Process Manager: PM2
- Reverse Proxy: Nginx
- Database: SQLite
- Node.js: v20.19.6
- Build Locally
- Push to Git
- SSH to Server
- Pull Changes
- Install Dependencies
- Build
- Restart PM2
- Health Check
- Backup Database
Details: Deployment Guide
Target Metrics:
- API Response Time: < 100ms (p95)
- Database Query Time: < 10ms (p95)
- Frontend Load Time: < 2s
- Task Processing Time: < 5s
Monitoring:
- PM2 Monit
- Nginx Access Logs
- SQLite Query Logs
- Custom Performance Tracking
Planned Enhancements:
-
WebSocket Real-time (Agent 3)
- Real-time task updates
- Real-time chat
- Connection recovery
-
Integration APIs (Agent 3)
- GitHub, Slack, Linear
- Webhook handlers
- Event processing
-
Memory System (Agent 3)
- Conversation history
- Context tracking
- Long-term memory
-
Multi-Provider (Agent 3)
- Provider fallback
- Load balancing
- Cost optimization
- Developer Guide: Setup & Development
- Contributing: Contribution Guidelines
- API Docs: API Reference (coming soon)
Erstellt: 2025-12-26 Version: 1.0
๐ค Generated with Claude Code Co-Authored-By: Claude Sonnet 4.5 noreply@anthropic.com