fix: restore current channel and host admission organs
This commit is contained in:
parent
88ffb1c97a
commit
f46eb1b7c1
54 changed files with 4499 additions and 8 deletions
28
server-tools/persona-host-alignment/channel_context.py
Normal file
28
server-tools/persona-host-alignment/channel_context.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
"""Read registered channel context. The persona selects; this module never guesses intent."""
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
|
||||
def load_channels(channel=None, root=ROOT):
|
||||
data = json.loads((root / 'routing/persona-channel-context-map.json').read_text())
|
||||
if data['map_id'] != 'ZY-PERSONA-CHANNEL-CONTEXT-001':
|
||||
raise ValueError('CHANNEL_CONTEXT_MAP_INVALID')
|
||||
rows = data['channels']
|
||||
if len({c['id'] for c in rows}) != len(rows):
|
||||
raise ValueError('CHANNEL_IDS_AMBIGUOUS')
|
||||
registry = json.loads((root / 'routing/fifth-domain-number-registry.json').read_text())
|
||||
numbers = {entry['id']: entry for entry in registry['registrations']}
|
||||
for item in rows:
|
||||
profile = json.loads((root / item['profile']).read_text())
|
||||
if item['id'] not in numbers or profile['channel_id'] != item['id']:
|
||||
raise ValueError('CHANNEL_NOT_REGISTERED')
|
||||
registered = numbers[item['id']]
|
||||
if profile['world_path'] != registered['world_path']:
|
||||
raise ValueError('CHANNEL_PATH_MISMATCH')
|
||||
item['world_path'] = profile['world_path']
|
||||
if channel is not None and channel not in {c['id'] for c in rows}:
|
||||
raise ValueError('UNKNOWN_PRIVATE_CHANNEL')
|
||||
return {**data, 'selected_channel': next((c for c in rows if c['id'] == channel), None),
|
||||
'selection_state': 'PERSONA_SELECTED' if channel else 'PERSONA_INTERPRETATION_REQUIRED',
|
||||
'authority_granted': False}
|
||||
Loading…
Reference in a new issue