feat(content-build): validation gate (rungs + resolve)
This commit is contained in:
23
tools/content_build/rungs.py
Normal file
23
tools/content_build/rungs.py
Normal file
@@ -0,0 +1,23 @@
|
||||
"""The rung vocabulary, sourced from the bible's disposition-ladder entry. The
|
||||
bible owns rung names/order; band NUMBERS live in client code and never here."""
|
||||
|
||||
from .errors import BuildError
|
||||
from .model import Entry
|
||||
|
||||
LADDER_ID = "rule.disposition-ladder"
|
||||
NEVER = "never"
|
||||
|
||||
|
||||
def ladder_rungs(entries: list[Entry]) -> list[str]:
|
||||
ladders = [e for e in entries if e.id == LADDER_ID]
|
||||
if len(ladders) != 1:
|
||||
raise BuildError(
|
||||
f"exactly one '{LADDER_ID}' entry required, found {len(ladders)}")
|
||||
if not ladders[0].rungs:
|
||||
raise BuildError("disposition-ladder needs a non-empty 'rungs:' list",
|
||||
source=ladders[0].source, entry_id=LADDER_ID)
|
||||
return list(ladders[0].rungs)
|
||||
|
||||
|
||||
def legal_gates(entries: list[Entry]) -> set[str]:
|
||||
return set(ladder_rungs(entries)) | {NEVER}
|
||||
Reference in New Issue
Block a user