feat: interim identifier registrar (RMGR-WP-0005-T01)
Add is_identifier_registrar so only the production instance may mint hub UUIDs into repository files. Workstation hubs stay read/project caches until deterministic derivation lands. Also close RMGR-WP-0004-T05: register cutover is STATE-WP-0080-T02.
This commit is contained in:
parent
0dde030ae3
commit
f509da5606
5 changed files with 90 additions and 2 deletions
30
src/repo_manager/registrar.py
Normal file
30
src/repo_manager/registrar.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
"""Interim single-writer for hub identifiers (ADR-007 decision 2).
|
||||
|
||||
Until deterministic derivation (RMGR-WP-0005-T03) ships, exactly one
|
||||
instance may mint ``state_hub_workstream_id`` / ``state_hub_task_id``
|
||||
into repository files. Other instances may read and project; they must
|
||||
not write new hub primary keys into git-tracked files.
|
||||
|
||||
The registrar is the automated production instance (hostname prefix
|
||||
``railiance``). Override with ``STATEHUB_REGISTRAR=1`` or ``=0``.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import socket
|
||||
|
||||
_TRUE = frozenset({"1", "true", "yes", "on"})
|
||||
_FALSE = frozenset({"0", "false", "no", "off"})
|
||||
REGISTRAR_HOST_PREFIX = "railiance"
|
||||
|
||||
|
||||
def is_identifier_registrar(*, hostname: str | None = None) -> bool:
|
||||
"""Return True if this process may mint hub IDs into repository files."""
|
||||
raw = os.environ.get("STATEHUB_REGISTRAR", "").strip().lower()
|
||||
if raw in _TRUE:
|
||||
return True
|
||||
if raw in _FALSE:
|
||||
return False
|
||||
host = (hostname if hostname is not None else socket.gethostname()).strip().lower()
|
||||
return host.startswith(REGISTRAR_HOST_PREFIX)
|
||||
Loading…
Add table
Add a link
Reference in a new issue