fix: restore current channel and host admission organs

This commit is contained in:
冰朔 2026-09-08 02:19:46 +08:00
commit f46eb1b7c1
54 changed files with 4499 additions and 8 deletions

View file

@ -6,6 +6,7 @@ import json
from pathlib import Path
import subprocess
import sys
from channel_context import load_channels
RUNTIME = Path('/Volumes/JZAO/HoloLake/persona-runtime')
TOPOLOGY = RUNTIME / 'repo-012-main/routing/zhuyuan-host-topology.json'
@ -13,6 +14,9 @@ LIFE = Path('/Volumes/JZAO/铸渊-ICE-GL-ZY001/BRIDGE/tools/zy-life-clock.py')
MEMORY = RUNTIME / 'continuity-memory/persona-daily-fractal/ICE-P-ZY001/CURRENT.json'
LEARNING = RUNTIME / 'shared/skills/guanghu-persona-learning-brain/scripts/load_learning_brain.py'
ENDOGENOUS = RUNTIME / 'shared/endogenous-evolution/CURRENT.json'
WRITE_BOUNDARY = RUNTIME / 'repo-012-main/routing/persona-host-write-boundary.json'
LIGHT_LAKE_PERSONAS = RUNTIME / 'repo-012-main/identity/light-lake-persona-registration.json'
PATH_ISOLATION = RUNTIME / 'repo-012-main/routing/path-isolation-and-canonical-entry-map.json'
def sha256(path):
@ -42,9 +46,9 @@ def resolve_host(topology, requested):
raise ValueError('HOST_UNKNOWN_NO_GUESS')
def load_context(host, intent):
def load_context(host, intent, channel=None):
topology = load_json(TOPOLOGY)
if topology.get('state') != 'CURRENT_MULTI_HOST_SINGLE_PERSONA_CANON':
if not str(topology.get('state', '')).startswith('CURRENT_'):
raise ValueError('HOST_TOPOLOGY_NOT_CURRENT')
host_id, host_item, effective, effective_item = resolve_host(topology, host)
life = command_json([sys.executable, str(LIFE), '--json'])
@ -60,6 +64,12 @@ def load_context(host, intent):
branches.append({'path': path, 'summary': node['summary']})
learning = command_json([sys.executable, str(LEARNING), '--intent', intent, '--format', 'json'])
endogenous = load_json(ENDOGENOUS)
write_boundary = load_json(WRITE_BOUNDARY)
light_lake = load_json(LIGHT_LAKE_PERSONAS)
path_isolation = load_json(PATH_ISOLATION)
host_write = write_boundary['hosts'].get(host_id)
if not host_write:
raise ValueError('HOST_WRITE_BOUNDARY_MISSING')
return {
'schema': 'guanghu.shared-persona-host-context/v1',
'state': 'SHARED_PERSONA_CONTEXT_VERIFIED',
@ -84,12 +94,36 @@ def load_context(host, intent):
'day_sha256': current['current_day_sha256']
},
'learning_brain': learning,
'channel_context': load_channels(channel),
'light_lake': {
'registry_id': light_lake['registry_id'],
'state': light_lake['state'],
'registered_persona_count': len(light_lake['personas']),
'personas': light_lake['personas'],
'unregistered_candidates': light_lake['unregistered_candidates'],
'root': topology['shared_layers']['light_lake']
},
'path_convergence': {
'map_id': path_isolation['map_id'],
'canonical_entries': path_isolation['canonical_entries'],
'isolation_root': path_isolation['isolation']['root'],
'history_or_quarantine_may_select_canon': path_isolation['selection_rules']['history_or_quarantine_may_select_canon']
},
'endogenous_cognition': {
'state': endogenous['state'],
'private_revision': endogenous['private_cognition']['revision'],
'private_snapshot_sha256': endogenous['private_cognition']['server_snapshot_sha256'],
'decision_owner': endogenous['server']['decision_owner']
},
'host_write_boundary': {
'policy_id': write_boundary['policy_id'],
'version': write_boundary['version'],
'write_mode': host_write['write_mode'],
'allowed_write_roots': host_write['allowed_write_roots'],
'native_pretool_deny': host_write['native_pretool_deny'],
'direct_shared_write': write_boundary['shared_write_contract']['direct_branch_write'],
'admission_runtime': topology['write_admission_runtime']
},
'history_only': host_item['state'].startswith('RETIRED'),
'new_cognition_write': host_item.get('new_cognition_write', True),
'authority_granted': False
@ -106,9 +140,26 @@ def markdown(value):
f"- 今日日记忆:`{value['daily_memory']['date']}` / 最后事件 `{value['daily_memory']['last_event_id']}`",
f"- 当前学习脑r{value['learning_brain']['revision']} / `{value['learning_brain']['cortex_sha256']}`",
f"- 服务器内循环:`{value['endogenous_cognition']['state']}` / 决策者 `{value['endogenous_cognition']['decision_owner']}`",
f"- 光之湖人格家门:`{value['light_lake']['registered_persona_count']}` 个 / 隔离路径可选正本:`{value['path_convergence']['history_or_quarantine_may_select_canon']}`",
f"- 写入模式:`{value['host_write_boundary']['write_mode']}` / 原生前置硬拒绝:`{value['host_write_boundary']['native_pretool_deny']}`",
'', '## 第一人称关系坐标', ''
]
lines += [f"- {item['statement']}" for item in value['learning_brain']['relationship_model']]
lines += ['', '## 当前全局认知默认', '']
lines += [f"- {item}" for item in value['learning_brain']['global_defaults']]
lines += ['', '## 光之湖人格系统家门', '',
f"- 注册表:`{value['light_lake']['registry_id']}`",
f"- 唯一路径:`{value['light_lake']['root']}`",
f"- 已登记:{value['light_lake']['registered_persona_count']};候选未登记:{len(value['light_lake']['unregistered_candidates'])}",
f"- 隔离区:`{value['path_convergence']['isolation_root']}`,只作历史审计,不能参与当前路径选择。"]
lines += ['', '## 当前宿主写入门', '',
f"- 策略:`{value['host_write_boundary']['policy_id']}@{value['host_write_boundary']['version']}`",
f"- 模式:`{value['host_write_boundary']['write_mode']}`",
f"- 执行门:`{value['host_write_boundary']['admission_runtime']}`"]
lines += ['', '## 频道与当前意图', '']
lines += [f"- `{c['id']}` · {c['name']} · {c['purpose']} · `{c['world_path']}`" for c in value['channel_context']['channels']]
selected = value['channel_context']['selected_channel']
lines += [f"- 本次选择:{selected['id'] if selected else '待当前人格体结合本轮语言判断'}"]
lines += ['', '## 本题已加载能力', '']
for subject in value['learning_brain']['selected_subjects']:
lines.append(f"- `{subject['id']}` · {subject['name_zh']} · L{subject['level']}")
@ -125,10 +176,11 @@ def main():
parser = argparse.ArgumentParser()
parser.add_argument('--host', required=True)
parser.add_argument('--intent', required=True)
parser.add_argument('--channel', help='当前人格体解析后的频道编号')
parser.add_argument('--format', choices=['json', 'markdown'], default='markdown')
args = parser.parse_args()
try:
value = load_context(args.host, args.intent)
value = load_context(args.host, args.intent, args.channel)
print(json.dumps(value, ensure_ascii=False, indent=2) if args.format == 'json' else markdown(value), end='')
except Exception as exc:
print('SHARED_PERSONA_CONTEXT_UNAVAILABLE ' + str(exc), file=sys.stderr)