feat: coord API — no-auth, DB softfail 503, agent tracking protocol

- coord routers: removed JWT auth requirement (internal-only endpoints)
- error_handler: SQLAlchemy OperationalError/DisconnectionError → 503
  with Retry-After: 30 header instead of 500
- /health: live DB probe (SELECT 1) instead of static response
- CLAUDE.md: "Live State Tracking" section with full agent protocol
  for all projects — session start, lock claim/release, component
  state updates, softfail + local queue catch-up
- COORDINATION_PROTOCOL.md: softfail/catch-up section + server-side
  503 behavior documented

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-12 08:45:33 -07:00
parent 9855c6bb0a
commit 73573800b0
10 changed files with 70 additions and 48 deletions

View File

@@ -6,7 +6,6 @@ from fastapi import APIRouter, Depends, Query, status
from sqlalchemy.orm import Session
from api.database import get_db
from api.middleware.auth import get_current_user
from api.schemas.coord_message import CoordMessageCreate, CoordMessageResponse
from api.services import coord_message_service
@@ -20,7 +19,6 @@ def list_messages(
skip: int = Query(default=0, ge=0),
limit: int = Query(default=100, ge=1, le=1000),
db: Session = Depends(get_db),
current_user: dict = Depends(get_current_user),
):
"""List messages with optional filters."""
messages, total = coord_message_service.get_messages(
@@ -38,7 +36,6 @@ def list_messages(
def get_unread_count(
session_id: str = Query(...),
db: Session = Depends(get_db),
current_user: dict = Depends(get_current_user),
):
"""Return the count of unread messages for a session."""
count = coord_message_service.get_unread_count(db, session_id)
@@ -49,7 +46,6 @@ def get_unread_count(
def send_message(
data: CoordMessageCreate,
db: Session = Depends(get_db),
current_user: dict = Depends(get_current_user),
):
"""Send a message to a session or broadcast."""
msg = coord_message_service.send_message(db, data)
@@ -60,7 +56,6 @@ def send_message(
def mark_message_read(
message_id: UUID,
db: Session = Depends(get_db),
current_user: dict = Depends(get_current_user),
):
"""Mark a message as read."""
msg = coord_message_service.mark_read(db, message_id)
@@ -71,7 +66,6 @@ def mark_message_read(
def delete_message(
message_id: UUID,
db: Session = Depends(get_db),
current_user: dict = Depends(get_current_user),
):
"""Delete a message."""
return coord_message_service.delete_message(db, message_id)