Add state-hub v0.1 — local-first state service for the Custodian
Implements the first live layer of the Custodian cognitive infrastructure:
PostgreSQL schema, FastAPI REST API, FastMCP stdio server, and Observable
Framework telemetry dashboard.
- state-hub/: full stack (docker-compose, FastAPI, Alembic, MCP server, dashboard)
- 5 DB tables: topics, workstreams, tasks, decisions, progress_events
- 11 MCP tools + 5 resources registered in .mcp.json
- Observable dashboard: Overview, Workstreams, Decisions, Progress pages
- CLAUDE.md: session protocol (get_state_summary / add_progress_event ritual)
- ~/.claude/CLAUDE.md: global cross-project reference to the hub
- scripts/pull_image.py: WSL2 TLS-resilient Docker image downloader
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-24 17:47:49 +01:00
|
|
|
import enum
|
|
|
|
|
import uuid
|
|
|
|
|
from datetime import date
|
|
|
|
|
|
|
|
|
|
from sqlalchemy import Date, Enum, ForeignKey, String, Text
|
|
|
|
|
from sqlalchemy.dialects.postgresql import UUID
|
|
|
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
|
|
|
|
|
|
|
|
from api.models.base import Base, TimestampMixin, new_uuid
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class WorkstreamStatus(str, enum.Enum):
|
|
|
|
|
active = "active"
|
|
|
|
|
blocked = "blocked"
|
|
|
|
|
completed = "completed"
|
|
|
|
|
archived = "archived"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Workstream(Base, TimestampMixin):
|
|
|
|
|
__tablename__ = "workstreams"
|
|
|
|
|
|
|
|
|
|
id: Mapped[uuid.UUID] = mapped_column(
|
|
|
|
|
UUID(as_uuid=True), primary_key=True, default=new_uuid
|
|
|
|
|
)
|
|
|
|
|
topic_id: Mapped[uuid.UUID] = mapped_column(
|
|
|
|
|
UUID(as_uuid=True), ForeignKey("topics.id", ondelete="RESTRICT"), nullable=False, index=True
|
|
|
|
|
)
|
|
|
|
|
slug: Mapped[str] = mapped_column(String(100), unique=True, nullable=False, index=True)
|
|
|
|
|
title: Mapped[str] = mapped_column(String(255), nullable=False)
|
|
|
|
|
description: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
|
|
|
status: Mapped[WorkstreamStatus] = mapped_column(
|
|
|
|
|
Enum(WorkstreamStatus), nullable=False, default=WorkstreamStatus.active
|
|
|
|
|
)
|
|
|
|
|
owner: Mapped[str | None] = mapped_column(String(100), nullable=True)
|
|
|
|
|
due_date: Mapped[date | None] = mapped_column(Date, nullable=True)
|
|
|
|
|
|
2026-03-02 23:39:17 +01:00
|
|
|
repo_id: Mapped[uuid.UUID | None] = mapped_column(
|
|
|
|
|
UUID(as_uuid=True),
|
|
|
|
|
ForeignKey("managed_repos.id", ondelete="SET NULL"),
|
|
|
|
|
nullable=True,
|
|
|
|
|
index=True,
|
|
|
|
|
)
|
|
|
|
|
|
Add state-hub v0.1 — local-first state service for the Custodian
Implements the first live layer of the Custodian cognitive infrastructure:
PostgreSQL schema, FastAPI REST API, FastMCP stdio server, and Observable
Framework telemetry dashboard.
- state-hub/: full stack (docker-compose, FastAPI, Alembic, MCP server, dashboard)
- 5 DB tables: topics, workstreams, tasks, decisions, progress_events
- 11 MCP tools + 5 resources registered in .mcp.json
- Observable dashboard: Overview, Workstreams, Decisions, Progress pages
- CLAUDE.md: session protocol (get_state_summary / add_progress_event ritual)
- ~/.claude/CLAUDE.md: global cross-project reference to the hub
- scripts/pull_image.py: WSL2 TLS-resilient Docker image downloader
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-24 17:47:49 +01:00
|
|
|
topic: Mapped["Topic"] = relationship("Topic", back_populates="workstreams") # noqa: F821
|
2026-03-02 23:39:17 +01:00
|
|
|
repo: Mapped["ManagedRepo"] = relationship("ManagedRepo", lazy="selectin") # noqa: F821
|
Add state-hub v0.1 — local-first state service for the Custodian
Implements the first live layer of the Custodian cognitive infrastructure:
PostgreSQL schema, FastAPI REST API, FastMCP stdio server, and Observable
Framework telemetry dashboard.
- state-hub/: full stack (docker-compose, FastAPI, Alembic, MCP server, dashboard)
- 5 DB tables: topics, workstreams, tasks, decisions, progress_events
- 11 MCP tools + 5 resources registered in .mcp.json
- Observable dashboard: Overview, Workstreams, Decisions, Progress pages
- CLAUDE.md: session protocol (get_state_summary / add_progress_event ritual)
- ~/.claude/CLAUDE.md: global cross-project reference to the hub
- scripts/pull_image.py: WSL2 TLS-resilient Docker image downloader
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-24 17:47:49 +01:00
|
|
|
tasks: Mapped[list["Task"]] = relationship( # noqa: F821
|
|
|
|
|
"Task", back_populates="workstream", lazy="selectin"
|
|
|
|
|
)
|
|
|
|
|
decisions: Mapped[list["Decision"]] = relationship( # noqa: F821
|
|
|
|
|
"Decision", back_populates="workstream", lazy="selectin"
|
|
|
|
|
)
|
|
|
|
|
progress_events: Mapped[list["ProgressEvent"]] = relationship( # noqa: F821
|
|
|
|
|
"ProgressEvent", back_populates="workstream", lazy="selectin"
|
|
|
|
|
)
|