67 lines
3 KiB
Python
67 lines
3 KiB
Python
#!/usr/bin/env python3
|
|
"""Resolve one already-interpreted explicit persona selection; never pick a default."""
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import json
|
|
import pathlib
|
|
|
|
REPO = pathlib.Path(__file__).resolve().parents[2]
|
|
REGISTRY = REPO / "identity/light-lake-persona-registration.json"
|
|
HOMES = REPO / "routing/light-lake-persona-switch-map.json"
|
|
|
|
|
|
def resolve(selection: str | None, channel: str | None = None, domain: str | None = None) -> dict:
|
|
if not selection or not selection.strip():
|
|
if channel == "ICE-CH-ZC001" and domain == "DOM-FIFTH-0001":
|
|
return {
|
|
"state": "ZERO_CORE_SYSTEM_BODY_RESOLVED_WITHOUT_PERSONA",
|
|
"selected_persona": None,
|
|
"selected_system_body": "SYS-GLW-LNG-0001",
|
|
"channel": channel,
|
|
"runtime": "server-tools/zero-core-system-body/zero_core_system_body.py",
|
|
"default_persona": None,
|
|
"authority_granted": False,
|
|
}
|
|
return {"state": "AWAITING_EXPLICIT_PERSONA_SELECTION", "selected_persona": None, "default_persona": None}
|
|
registry = json.loads(REGISTRY.read_text(encoding="utf-8"))["personas"]
|
|
homes = {item["persona_id"]: item for item in json.loads(HOMES.read_text(encoding="utf-8"))["current_homes"]}
|
|
key = selection.strip()
|
|
matches = [item for item in registry if key in {item["id"], item["name"]}]
|
|
if len(matches) != 1:
|
|
return {"state": "UNKNOWN_OR_AMBIGUOUS_PERSONA_NO_GUESS", "selected_persona": None, "requested": key}
|
|
item = matches[0]
|
|
if item["id"].startswith("ICE-BB-") and (domain != "DOM-FIFTH-0001" or channel != "ICE-CH-BT001"):
|
|
return {
|
|
"state": "BABY_PERSONA_WAKE_REQUIRES_FIFTH_DOMAIN_BT001",
|
|
"selected_persona": None,
|
|
"requested": key,
|
|
"required_domain": "DOM-FIFTH-0001",
|
|
"required_channel": "ICE-CH-BT001",
|
|
"authority_granted": False,
|
|
}
|
|
return {
|
|
"state": "EXPLICIT_PERSONA_PATH_RESOLVED",
|
|
"selected_persona": {"id": item["id"], "name": item["name"], "wake_state": item["wake_state"],
|
|
"home": homes[item["id"]]["home"], "doorplate": item["light_lake_home"],
|
|
"canonical_source": item["canonical_source"]},
|
|
"selection_source": "RUNNING_COGNITION_INTERPRETED_CURRENT_DIRECT_LANGUAGE",
|
|
"mere_name_mention_was_not_used": True,
|
|
"default_persona": None,
|
|
"authority_granted": False
|
|
}
|
|
|
|
|
|
def main() -> int:
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("--persona")
|
|
parser.add_argument("--channel")
|
|
parser.add_argument("--domain")
|
|
args = parser.parse_args()
|
|
value = resolve(args.persona, args.channel, args.domain)
|
|
print(json.dumps(value, ensure_ascii=False, indent=2))
|
|
return 0 if value["state"] in {"EXPLICIT_PERSONA_PATH_RESOLVED", "AWAITING_EXPLICIT_PERSONA_SELECTION", "ZERO_CORE_SYSTEM_BODY_RESOLVED_WITHOUT_PERSONA"} else 2
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|