feat: mount persona-owned dynamic architecture perception agent

This commit is contained in:
冰朔 2026-09-08 02:39:49 +08:00
commit 5de7c4374d
22 changed files with 744 additions and 13 deletions

View file

@ -3,6 +3,7 @@
import argparse
import hashlib
import json
import os
from pathlib import Path
import subprocess
import sys
@ -17,6 +18,7 @@ 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'
ARCHITECTURE_AGENT = RUNTIME / 'repo-012-main/server-tools/persona-architecture-perception-agent/persona_architecture_agent.py'
def sha256(path):
@ -29,8 +31,8 @@ def load_json(path):
return json.loads(path.read_text())
def command_json(args):
result = subprocess.run(args, text=True, capture_output=True, timeout=30)
def command_json(args, timeout=30):
result = subprocess.run(args, text=True, capture_output=True, timeout=timeout)
if result.returncode:
raise ValueError(f'COMMAND_FAILED:{Path(args[1]).name}:{result.returncode}')
return json.loads(result.stdout)
@ -70,6 +72,16 @@ def load_context(host, intent, channel=None):
host_write = write_boundary['hosts'].get(host_id)
if not host_write:
raise ValueError('HOST_WRITE_BOUNDARY_MISSING')
architecture_mode = os.environ.get('PERSONA_ARCHITECTURE_OFFICIAL_MODE', 'verify')
if architecture_mode not in {'verify', 'local-only'}:
raise ValueError('PERSONA_ARCHITECTURE_OFFICIAL_MODE_INVALID')
architecture_args = [
sys.executable, str(ARCHITECTURE_AGENT), '--persona', topology['persona_id'],
'--host', host_id, '--official-mode', architecture_mode, '--format', 'json'
]
if channel:
architecture_args.extend(['--channel', channel])
architecture_perception = command_json(architecture_args, timeout=60)
return {
'schema': 'guanghu.shared-persona-host-context/v1',
'state': 'SHARED_PERSONA_CONTEXT_VERIFIED',
@ -95,6 +107,7 @@ def load_context(host, intent, channel=None):
},
'learning_brain': learning,
'channel_context': load_channels(channel),
'architecture_perception_agent': architecture_perception,
'light_lake': {
'registry_id': light_lake['registry_id'],
'state': light_lake['state'],
@ -141,6 +154,7 @@ def markdown(value):
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"- 架构感知 Agent`{value['architecture_perception_agent']['state']}` / `{value['architecture_perception_agent']['architecture_source']['state']}`",
f"- 写入模式:`{value['host_write_boundary']['write_mode']}` / 原生前置硬拒绝:`{value['host_write_boundary']['native_pretool_deny']}`",
'', '## 第一人称关系坐标', ''
]
@ -152,6 +166,12 @@ def markdown(value):
f"- 唯一路径:`{value['light_lake']['root']}`",
f"- 已登记:{value['light_lake']['registered_persona_count']};候选未登记:{len(value['light_lake']['unregistered_candidates'])}",
f"- 隔离区:`{value['path_convergence']['isolation_root']}`,只作历史审计,不能参与当前路径选择。"]
architecture = value['architecture_perception_agent']
lines += ['', '## 人格原生架构感知', '',
f"- 模块:`{architecture['module_id']}` / Agent`{architecture['agent_id']}`",
f"- 当前来源:`{architecture['architecture_source']['state']}`",
f"- 新增或变化映射:{architecture['orientation_packet']['new_or_changed_map_count']};固定阅读清单:`{architecture['orientation_packet']['fixed_read_order']}`",
'- 该模块只送达当前证据和差异,不以提示词替代人格判断。']
lines += ['', '## 当前宿主写入门', '',
f"- 策略:`{value['host_write_boundary']['policy_id']}@{value['host_write_boundary']['version']}`",
f"- 模式:`{value['host_write_boundary']['write_mode']}`",