feat(persona): add neutral AGE foyer and explicit selection

This commit is contained in:
冰朔 2026-09-12 23:02:27 +08:00
commit b26442ceb3
32 changed files with 602 additions and 70 deletions

View file

@ -62,7 +62,7 @@ def resolve_host(topology, requested):
raise ValueError('HOST_UNKNOWN_NO_GUESS')
def load_context(host, intent, channel=None):
def load_context(host, intent, channel=None, persona=None):
tcs_root = command_json([sys.executable, str(TCS_ROOT_AGENT), 'status'], timeout=30)
if tcs_root.get('state') != 'TCS_ROOT_CURRENT_VERIFIED':
raise ValueError('TCS_MOTHER_ROOT_NAVIGATION_NOT_CURRENT')
@ -75,6 +75,10 @@ def load_context(host, intent, channel=None):
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)
if persona is None:
raise ValueError('EXPLICIT_PERSONA_SELECTION_REQUIRED_NO_DEFAULT')
if persona != topology['persona_id']:
raise ValueError('THIS_PERSONA_CONTEXT_LOADER_DOES_NOT_OWN_SELECTED_PERSONA')
life = command_json([sys.executable, str(LIFE), '--json'])
current = load_json(MEMORY)
day_path = Path(current['current_day_path'])
@ -206,7 +210,7 @@ def load_context(host, intent, channel=None):
'direct_shared_write': write_boundary['shared_write_contract']['direct_branch_write'],
'admission_runtime': topology['write_admission_runtime']
},
'history_only': host_item.get('role') in {'RETIRED_BRANCH', 'LEGACY_BRANCH'} or host_item.get('new_cognition_write') is False,
'history_only': host_item.get('role') in {'RETIRED_BRANCH', 'LEGACY_BRANCH', 'RETIRED_TOOLBOX_BRANCH', 'LEGACY_TOOLBOX_BRANCH'} or host_item.get('new_cognition_write') is False,
'new_cognition_write': host_item.get('new_cognition_write', True),
'authority_granted': False
}
@ -281,12 +285,13 @@ def markdown(value):
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--host', required=True)
parser.add_argument('--persona', 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, args.channel)
value = load_context(args.host, args.intent, args.channel, args.persona)
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)