cecc6c0b41
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
43 lines
1.7 KiB
Python
43 lines
1.7 KiB
Python
"""Project registry — the §22 multi-project layer.
|
|
|
|
A deployment hosts one or more projects (§22.1). The git registry mirror
|
|
that lets a deployment declare projects lands in M3 and drives this module.
|
|
`seed_default_project` (the §22.13 META_REPO backfill) is retired in M3;
|
|
the registry mirror (`registry.refresh_registry`) is authoritative.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from . import db
|
|
from .config import Config
|
|
|
|
DEFAULT_PROJECT_ID = "default"
|
|
|
|
|
|
def resolved_default_id(config: Config) -> str:
|
|
"""The id of the deployment's bootstrap/default project. Plan A: always
|
|
'default' (the re-stamp to a config slug rides Plan B). The config knob is
|
|
read here so Plan B can flip the resolution without touching call sites."""
|
|
return config.default_project_id.strip() or DEFAULT_PROJECT_ID
|
|
|
|
|
|
def default_content_repo(config: Config) -> str | None:
|
|
"""The content repo the single-corpus mirror reads, from the default
|
|
project's row (filled by the registry mirror). Replaces the retired
|
|
META_REPO. None until the registry mirror has run."""
|
|
row = db.conn().execute(
|
|
"SELECT content_repo FROM projects WHERE id = ?",
|
|
(resolved_default_id(config),),
|
|
).fetchone()
|
|
return row["content_repo"] if row and row["content_repo"] else None
|
|
|
|
|
|
def project_initial_state(project_id: str) -> str:
|
|
"""§22.4b landing state for new entries in a project. Defaults to
|
|
'super-draft' for an unknown/unset row (the safe, today's-flow default)."""
|
|
row = db.conn().execute(
|
|
"SELECT initial_state FROM projects WHERE id = ?", (project_id,)
|
|
).fetchone()
|
|
if row is None or not row["initial_state"]:
|
|
return "super-draft"
|
|
return row["initial_state"]
|