feat(state-hub): implement v0.5 — dynamic domains & multi-repo

Replaces the hardcoded 6-domain PostgreSQL ENUM with a first-class
`domains` DB table, and adds a `managed_repos` table for multi-repo
support per domain.

P1 — Domain as a DB entity:
- Migration b1c2d3e4f5a6: creates `domains` table, migrates topics.domain
  ENUM column to domain_id FK, drops the domain ENUM type
- Domain ORM model (api/models/domain.py) + Pydantic schemas
- Domain API router: GET/POST /domains/, GET/PATCH /domains/{slug}/,
  rename and archive endpoints with EP/TD cascade on rename
- Topic model updated: domain_id FK + @property domain_slug for
  backwards-compatible JSON serialization (field renamed domain → domain_slug)
- TopicCreate/TopicRead updated; seed.py rewritten to use FK lookup

P2 — Multi-repo support:
- ManagedRepo ORM model (api/models/managed_repo.py) + schemas
- Repo API router: GET/POST /repos/, GET/PATCH /repos/{slug}/, archive
- Makefile: add-domain, rename-domain, add-repo, list-repos targets
- register_project.sh: verify domain via /domains/ API + POST /repos/

P3 — MCP tools & live validation:
- 6 new MCP tools: list_domains, create_domain, rename_domain,
  archive_domain, list_domain_repos, register_repo
- EP/TD routers: replace hardcoded VALID_DOMAINS set with per-request
  DB lookup — returns 422 with list of valid slugs on unknown domain
- State summary: adds domains: list[DomainSummary] (slug, name,
  repo_count, active_workstream_count, ep_count, td_count)
- TOOLS.md updated with domain management section

P4 — Dashboard:
- New domains.md page with KPI row + domain cards + repo lists
- domains.json.py + repos.json.py data loaders
- Domains page added to observablehq.config.js nav
- workstreams.md, extensions.md, techdept.md: domain_slug fix +
  dynamic domain list loaded from /domains/ API (no longer hardcoded)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-28 15:20:15 +01:00
parent fec05dcb5d
commit 07a082b7b0
30 changed files with 1205 additions and 85 deletions

View File

@@ -3,12 +3,13 @@ id: CUST-WP-0005
type: workplan
title: "State Hub v0.5 — Dynamic Domains & Multi-Repo"
domain: custodian
status: active
status: completed
owner: custodian
topic_slug: custodian
state_hub_workstream_id: 2271eb55-62ca-4bcc-8d9f-f9aacd6922d6
created: "2026-02-28"
updated: "2026-02-28"
completed: "2026-02-28"
---
# State Hub v0.5 — Dynamic Domains & Multi-Repo
@@ -44,7 +45,7 @@ should be open.
```task
id: CUST-WP-0005-T01
state_hub_task_id: 456a0252-9a34-43a6-8244-c3a2caf95d51
status: todo
status: done
priority: high
```
@@ -71,7 +72,7 @@ Downgrade: reverse all steps (recreate enum, repopulate, drop domain_id).
```task
id: CUST-WP-0005-T02
state_hub_task_id: eddff1ae-b263-4d3e-af95-91b4c3c2ecea
status: todo
status: done
priority: high
```
@@ -95,7 +96,7 @@ New file: `state-hub/api/schemas/domain.py`
```task
id: CUST-WP-0005-T03
state_hub_task_id: b91cd0b5-c647-41e5-abf5-98f6f5eb3333
status: todo
status: done
priority: high
```
@@ -115,7 +116,7 @@ Register in `state-hub/api/main.py`.
```task
id: CUST-WP-0005-T04
state_hub_task_id: 0825fa45-ec3a-43b5-8482-4a819db75c6a
status: todo
status: done
priority: medium
```
@@ -139,7 +140,7 @@ Update state router: any `Domain.custodian` etc. references → slug string.
```task
id: CUST-WP-0005-T05
state_hub_task_id: 50dc7eec-2b45-4a0d-b99e-27aca8a55a67
status: todo
status: done
priority: high
```
@@ -161,7 +162,7 @@ Add to `models/__init__.py` and register router.
```task
id: CUST-WP-0005-T06
state_hub_task_id: daca1636-0187-4fb7-a515-8a2cf84f89d9
status: todo
status: done
priority: medium
```
@@ -183,7 +184,7 @@ Schemas: `RepoCreate`, `RepoRead`, `RepoUpdate`.
```task
id: CUST-WP-0005-T07
state_hub_task_id: 930fd3fa-2e1d-401c-9e33-0378f33cb14d
status: todo
status: done
priority: medium
```
@@ -211,7 +212,7 @@ Update `state-hub/scripts/project_claude_md.template`:
```task
id: CUST-WP-0005-T08
state_hub_task_id: e99e6bd7-f6f2-496f-acbf-d2b013f37c73
status: todo
status: done
priority: medium
```
@@ -231,7 +232,7 @@ Update `state-hub/mcp_server/TOOLS.md` to document all 6 new tools.
```task
id: CUST-WP-0005-T09
state_hub_task_id: f2b352b6-4b9e-47b3-b629-48485245390e
status: todo
status: done
priority: low
```
@@ -255,7 +256,7 @@ Update global CLAUDE.md and project CLAUDE.md template to note
```task
id: CUST-WP-0005-T10
state_hub_task_id: ddb91669-5297-45d9-8b5e-10213135a96d
status: todo
status: done
priority: low
```
@@ -279,7 +280,7 @@ Add to `observablehq.config.js` nav.
```task
id: CUST-WP-0005-T11
state_hub_task_id: 3fec152c-00e1-4cdb-b6e5-26136c8cb6c1
status: todo
status: done
priority: low
```