feat: agent coordination system (workflows, locks, components, messages)

Adds /api/coord/* endpoints for real-time cross-session coordination:
- coord_workflows: named units of work per project
- coord_work_items: tasks within workflows with dependency chains
- coord_session_locks: exclusive resource locks with auto-expiry (TTL)
- coord_component_states: live component state per project (upsert)
- coord_messages: cross-session messaging and broadcasts
- /api/coord/status: cross-project snapshot endpoint

Replaces PROJECT_STATE.md as the coordination layer for Claude sessions.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-12 08:25:33 -07:00
parent bd88398297
commit 63975284f4
24 changed files with 1565 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
"""Pydantic schemas for CoordSessionLock."""
from datetime import datetime
from typing import Optional
from uuid import UUID
from pydantic import BaseModel, Field
class CoordSessionLockCreate(BaseModel):
"""Input schema for claiming a lock."""
project_key: str = Field(..., description="Project namespace", max_length=200)
session_id: str = Field(..., description="Session claiming the lock", max_length=200)
resource: str = Field(..., description="Resource path being locked, e.g. 'server/src/'", max_length=500)
description: Optional[str] = Field(None, description="Why this lock is needed")
ttl_hours: float = Field(2.0, description="Lock lifetime in hours; 0 = no expiry", ge=0)
class CoordSessionLockUpdate(BaseModel):
"""Input schema for updating a lock (rarely needed directly)."""
description: Optional[str] = None
expires_at: Optional[datetime] = None
class CoordSessionLockResponse(BaseModel):
"""Output schema for a lock."""
id: UUID
project_key: str
session_id: str
resource: str
description: Optional[str]
acquired_at: datetime
expires_at: Optional[datetime]
released_at: Optional[datetime]
created_at: datetime
updated_at: datetime
model_config = {"from_attributes": True}