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 datetime
|
|
|
|
|
|
|
|
|
|
from sqlalchemy import CheckConstraint, DateTime, 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 DecisionType(str, enum.Enum):
|
|
|
|
|
made = "made"
|
|
|
|
|
pending = "pending"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DecisionStatus(str, enum.Enum):
|
|
|
|
|
open = "open"
|
|
|
|
|
resolved = "resolved"
|
|
|
|
|
escalated = "escalated"
|
|
|
|
|
superseded = "superseded"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Decision(Base, TimestampMixin):
|
|
|
|
|
__tablename__ = "decisions"
|
|
|
|
|
__table_args__ = (
|
|
|
|
|
CheckConstraint(
|
2026-06-22 13:52:13 +02:00
|
|
|
"topic_id IS NOT NULL OR workplan_id IS NOT NULL",
|
|
|
|
|
name="ck_decisions_topic_or_workplan",
|
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
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
id: Mapped[uuid.UUID] = mapped_column(
|
|
|
|
|
UUID(as_uuid=True), primary_key=True, default=new_uuid
|
|
|
|
|
)
|
|
|
|
|
topic_id: Mapped[uuid.UUID | None] = mapped_column(
|
|
|
|
|
UUID(as_uuid=True), ForeignKey("topics.id", ondelete="RESTRICT"), nullable=True, index=True
|
|
|
|
|
)
|
2026-06-22 13:52:13 +02:00
|
|
|
workplan_id: Mapped[uuid.UUID | None] = mapped_column(
|
2026-08-22 00:27:48 +02:00
|
|
|
UUID(as_uuid=True),
|
|
|
|
|
ForeignKey("workplans.id", ondelete="RESTRICT", onupdate="CASCADE"),
|
|
|
|
|
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
|
|
|
)
|
|
|
|
|
title: Mapped[str] = mapped_column(String(255), nullable=False)
|
|
|
|
|
description: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
|
|
|
decision_type: Mapped[DecisionType] = mapped_column(
|
|
|
|
|
Enum(DecisionType), nullable=False, default=DecisionType.pending
|
|
|
|
|
)
|
|
|
|
|
status: Mapped[DecisionStatus] = mapped_column(
|
|
|
|
|
Enum(DecisionStatus), nullable=False, default=DecisionStatus.open
|
|
|
|
|
)
|
|
|
|
|
rationale: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
|
|
|
decided_by: Mapped[str | None] = mapped_column(String(100), nullable=True)
|
|
|
|
|
decided_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)
|
|
|
|
|
deadline: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)
|
|
|
|
|
escalation_note: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
|
|
|
superseded_by: Mapped[uuid.UUID | None] = mapped_column(
|
|
|
|
|
UUID(as_uuid=True), ForeignKey("decisions.id", ondelete="SET NULL"), nullable=True
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
topic: Mapped["Topic | None"] = relationship("Topic", back_populates="decisions") # noqa: F821
|
2026-06-22 13:52:13 +02:00
|
|
|
workplan: Mapped["Workplan | None"] = relationship("Workplan", back_populates="decisions") # 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
|
|
|
progress_events: Mapped[list["ProgressEvent"]] = relationship( # noqa: F821
|
|
|
|
|
"ProgressEvent", back_populates="decision", lazy="selectin"
|
|
|
|
|
)
|