generated from coulomb/repo-seed
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>
127 lines
4.3 KiB
Python
127 lines
4.3 KiB
Python
"""Seed the 6 canonical domains and topics from canon/projects/."""
|
|
import asyncio
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
# Allow running from state-hub/ root
|
|
sys.path.insert(0, str(Path(__file__).parent.parent))
|
|
|
|
from sqlalchemy import select
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from api.database import async_session_factory, engine
|
|
from api.models.domain import Domain
|
|
from api.models.topic import Topic, TopicStatus
|
|
|
|
DOMAINS = [
|
|
{"slug": "custodian", "name": "The Custodian"},
|
|
{"slug": "railiance", "name": "Railiance"},
|
|
{"slug": "markitect", "name": "Markitect"},
|
|
{"slug": "coulomb_social", "name": "Coulomb.social"},
|
|
{"slug": "personhood", "name": "Personhood"},
|
|
{"slug": "foerster_capabilities", "name": "Foerster Capabilities"},
|
|
]
|
|
|
|
TOPICS = [
|
|
{
|
|
"slug": "custodian",
|
|
"title": "The Custodian",
|
|
"description": (
|
|
"Master agent system: transgenerational cognitive infrastructure for "
|
|
"co-creating and stewarding knowledge across all domains."
|
|
),
|
|
"domain_slug": "custodian",
|
|
},
|
|
{
|
|
"slug": "railiance",
|
|
"title": "Railiance",
|
|
"description": (
|
|
"DevOps & infrastructure reliability. Dependency for all other projects; "
|
|
"provides the deployment and operational backbone."
|
|
),
|
|
"domain_slug": "railiance",
|
|
},
|
|
{
|
|
"slug": "markitect",
|
|
"title": "Markitect",
|
|
"description": (
|
|
"Knowledge artifact management: structured authoring, versioning, and "
|
|
"retrieval of canonical documents."
|
|
),
|
|
"domain_slug": "markitect",
|
|
},
|
|
{
|
|
"slug": "coulomb-social",
|
|
"title": "Coulomb.social",
|
|
"description": (
|
|
"Co-creation marketplace experiment: connecting people around shared "
|
|
"projects and complementary capabilities."
|
|
),
|
|
"domain_slug": "coulomb_social",
|
|
},
|
|
{
|
|
"slug": "personhood",
|
|
"title": "Personhood",
|
|
"description": (
|
|
"Rights and obligations framework: defining digital personhood, consent "
|
|
"models, and data sovereignty."
|
|
),
|
|
"domain_slug": "personhood",
|
|
},
|
|
{
|
|
"slug": "foerster-capabilities",
|
|
"title": "Foerster Capabilities",
|
|
"description": (
|
|
"Agency capability taxonomy inspired by Heinz von Foerster: mapping the "
|
|
"space of possible cognitive and social actions."
|
|
),
|
|
"domain_slug": "foerster_capabilities",
|
|
},
|
|
]
|
|
|
|
|
|
async def seed() -> None:
|
|
async with async_session_factory() as session:
|
|
# ── Insert domains (idempotent) ───────────────────────────────────────
|
|
domain_by_slug: dict[str, Domain] = {}
|
|
for data in DOMAINS:
|
|
existing = await session.execute(
|
|
select(Domain).where(Domain.slug == data["slug"])
|
|
)
|
|
domain = existing.scalar_one_or_none()
|
|
if domain is not None:
|
|
print(f" skip domain (exists): {data['slug']}")
|
|
else:
|
|
domain = Domain(slug=data["slug"], name=data["name"])
|
|
session.add(domain)
|
|
await session.flush() # get the id
|
|
print(f" insert domain: {data['slug']}")
|
|
domain_by_slug[data["slug"]] = domain
|
|
|
|
# ── Insert topics (idempotent) ─────────────────────────────────────────
|
|
for data in TOPICS:
|
|
existing = await session.execute(
|
|
select(Topic).where(Topic.slug == data["slug"])
|
|
)
|
|
if existing.scalar_one_or_none() is not None:
|
|
print(f" skip topic (exists): {data['slug']}")
|
|
continue
|
|
domain = domain_by_slug[data["domain_slug"]]
|
|
topic = Topic(
|
|
slug=data["slug"],
|
|
title=data["title"],
|
|
description=data["description"],
|
|
domain_id=domain.id,
|
|
status=TopicStatus.active,
|
|
)
|
|
session.add(topic)
|
|
print(f" insert topic: {data['slug']}")
|
|
|
|
await session.commit()
|
|
await engine.dispose()
|
|
print("Seed complete.")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(seed())
|