feat: delegate project register; registrar-only ID minting
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 1s
Build and Publish Multi-Context Image / build-and-push (push) Successful in 39s

STATE-WP-0080-T02: statehub register routes project-flavor scaffolding
through rmgr scaffold and keeps only repo + host-path registration.
T01 refuse remains when GOAL.md is missing and --wp-prefix is not set.

RMGR-WP-0005-T01: C-06/C-11/C-32 skip mint+writeback unless this
instance is the identifier registrar (STATEHUB_REGISTRAR or railiance
hostname).
This commit is contained in:
tegwick 2026-08-18 21:49:15 +02:00
parent 71ad6c5d17
commit d8e0eddb22
6 changed files with 419 additions and 25 deletions

View file

@ -11,6 +11,7 @@ Checks:
C-04 workstream-status-drift WARN Yes File status != DB status (file wins)
C-05 workstream-title-drift WARN Yes File title != DB title (file wins)
C-06 workstream-unlinked WARN Yes Workplan has no state_hub_workstream_id
Identifier minting (--fix create+writeback) is registrar-only (ADR-007)
C-07 orphan-db-active FAIL No Active DB workstream, no backing file
C-08 orphan-db-closed INFO No Finished/archived DB workstream, no file
C-09 workstream-repo-mismatch FAIL Yes DB workstream repo_id != file location
@ -44,6 +45,11 @@ Usage:
python scripts/consistency_check.py --all [--fix] [--no-writeback] [--json] [--api-base URL]
python scripts/consistency_check.py --here [PATH] [--fix] [--no-writeback] [--json] [--api-base URL]
Registrar (ADR-007 interim / RMGR-WP-0005-T01):
C-06 / C-11 / C-32 mint hub IDs into files only when this instance is the
identifier registrar. Default: hostname starts with ``railiance``.
Override with STATEHUB_REGISTRAR=1 or =0. Read/project checks are unchanged.
Exit codes (single-repo / local CLI):
0 clean (no FAILs or WARNs; INFOs are allowed)
1 one or more assessment FAILs or automation ERRORs (C-00) present
@ -2601,6 +2607,36 @@ def _write_custodian_brief(api_base: str, repo_slug: str, repo_path: str) -> boo
return True
# ---------------------------------------------------------------------------
# Identifier registrar (ADR-007 decision 2 / RMGR-WP-0005-T01)
# ---------------------------------------------------------------------------
def _is_identifier_registrar() -> bool:
"""True when this instance may mint hub IDs into repository files."""
try:
from repo_manager.registrar import is_identifier_registrar
return is_identifier_registrar()
except ImportError:
raw = os.environ.get("STATEHUB_REGISTRAR", "").strip().lower()
if raw in {"1", "true", "yes", "on"}:
return True
if raw in {"0", "false", "no", "off"}:
return False
return socket.gethostname().lower().startswith("railiance")
def _skip_non_registrar_mint(report: "ConsistencyReport", check_id: str, label: str) -> bool:
if _is_identifier_registrar():
return False
report.fixes_applied.append(
f"{check_id} skipped: this instance is not the identifier registrar "
f"({label}; set STATEHUB_REGISTRAR=1 on the production instance; "
"ADR-007 interim / RMGR-WP-0005-T01)"
)
return True
# ---------------------------------------------------------------------------
# Fix engine
# ---------------------------------------------------------------------------
@ -2748,6 +2784,8 @@ def fix_repo(
)
elif issue.check_id == "C-06":
if _skip_non_registrar_mint(report, "C-06", "workplan UUID"):
continue
wp_file = Path(ctx["wp_file"])
meta = ctx["meta"]
domain = ctx["domain"]
@ -2877,6 +2915,8 @@ def fix_repo(
)
elif issue.check_id == "C-32":
if _skip_non_registrar_mint(report, "C-32", "work-record UUID"):
continue
md_path = ctx["md_path"]
kind = ctx["kind"]
rid = ctx["rid"]
@ -2998,6 +3038,8 @@ def fix_repo(
)
elif issue.check_id == "C-11":
if _skip_non_registrar_mint(report, "C-11", "task UUID"):
continue
ws_id = ctx["ws_id"]
ws_status = ctx.get("ws_status", "")
task = ctx["task"]