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>
58 lines
1.5 KiB
Python
58 lines
1.5 KiB
Python
"""Coordination component state model."""
|
|
|
|
from typing import Optional
|
|
|
|
from sqlalchemy import PrimaryKeyConstraint, String, Text
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from .base import Base, TimestampMixin
|
|
|
|
|
|
class CoordComponentState(Base, TimestampMixin):
|
|
"""Current state of a named component within a project."""
|
|
|
|
__tablename__ = "coord_component_states"
|
|
|
|
project_key: Mapped[str] = mapped_column(
|
|
String(200),
|
|
nullable=False,
|
|
primary_key=True,
|
|
doc="Project namespace"
|
|
)
|
|
|
|
component: Mapped[str] = mapped_column(
|
|
String(200),
|
|
nullable=False,
|
|
primary_key=True,
|
|
doc="Component name, e.g. 'server', 'agent', 'dashboard', 'database'"
|
|
)
|
|
|
|
state: Mapped[str] = mapped_column(
|
|
String(50),
|
|
nullable=False,
|
|
doc="State: deployed, building, stable, broken, unknown"
|
|
)
|
|
|
|
version: Mapped[Optional[str]] = mapped_column(
|
|
String(100),
|
|
doc="Version string or git SHA"
|
|
)
|
|
|
|
notes: Mapped[Optional[str]] = mapped_column(
|
|
Text,
|
|
doc="Freeform notes about current state"
|
|
)
|
|
|
|
updated_by: Mapped[str] = mapped_column(
|
|
String(200),
|
|
nullable=False,
|
|
doc="Session that last updated this record"
|
|
)
|
|
|
|
__table_args__ = (
|
|
PrimaryKeyConstraint("project_key", "component", name="pk_coord_component_states"),
|
|
)
|
|
|
|
def __repr__(self) -> str:
|
|
return f"<CoordComponentState(project_key='{self.project_key}', component='{self.component}', state='{self.state}')>"
|