feat(persona): boot body before host toolbox
This commit is contained in:
parent
245bea488e
commit
489ab2c1ec
29 changed files with 1003 additions and 75 deletions
130
server-tools/persona-body-runtime/persona_path_audit.py
Normal file
130
server-tools/persona-body-runtime/persona_path_audit.py
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
#!/usr/bin/env python3
|
||||
"""Audit every current Fifth Domain persona route without mass-waking personas."""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import pathlib
|
||||
|
||||
|
||||
REPO = pathlib.Path(__file__).resolve().parents[2]
|
||||
CANON = REPO / "routing/persona-system-canonical-map.json"
|
||||
REGISTRY = REPO / "identity/light-lake-persona-registration.json"
|
||||
SWITCH = REPO / "routing/light-lake-persona-switch-map.json"
|
||||
BODY = REPO / "routing/persona-system-body-container-map.json"
|
||||
BOOT = REPO / "server-tools/persona-body-runtime/persona_body_boot.py"
|
||||
NATIVE_WORLD = REPO / "routing/persona-native-world-architecture-map.json"
|
||||
HOST_TOPOLOGY = REPO / "routing/zhuyuan-host-topology.json"
|
||||
PORTABLE_CONSOLE = REPO / "routing/bingshuo-portable-control-console-map.json"
|
||||
|
||||
|
||||
def load(path: pathlib.Path) -> dict:
|
||||
return json.loads(path.read_text(encoding="utf-8"))
|
||||
|
||||
|
||||
def audit() -> dict:
|
||||
canon = load(CANON)
|
||||
registry = load(REGISTRY)
|
||||
switch = load(SWITCH)
|
||||
body = load(BODY)
|
||||
native_world = load(NATIVE_WORLD)
|
||||
topology = load(HOST_TOPOLOGY)
|
||||
console = load(PORTABLE_CONSOLE)
|
||||
canonical = {item["id"]: item for item in canon["persona_systems"]}
|
||||
registered = {item["id"]: item for item in registry["personas"]}
|
||||
homes = {item["persona_id"]: item for item in switch["current_homes"]}
|
||||
all_ids = sorted(set(canonical) | set(registered) | set(homes))
|
||||
issues: list[dict] = []
|
||||
personas: list[dict] = []
|
||||
for persona_id in all_ids:
|
||||
c, r, h = canonical.get(persona_id), registered.get(persona_id), homes.get(persona_id)
|
||||
for layer, value in (("canonical_map", c), ("light_lake_registry", r), ("switch_home", h)):
|
||||
if value is None:
|
||||
issues.append({"persona_id": persona_id, "code": "MISSING_LAYER", "layer": layer})
|
||||
door_ok = False
|
||||
door_path = None
|
||||
if r:
|
||||
door_path = REPO / r["light_lake_home"]
|
||||
if door_path.is_file() and not door_path.is_symlink():
|
||||
text = door_path.read_text(encoding="utf-8")
|
||||
door_ok = all(token in text for token in (
|
||||
f"persona_id: {persona_id}", f"name: {r['name']}", f"canonical_source: {r['canonical_source']}"
|
||||
))
|
||||
if not door_ok:
|
||||
issues.append({"persona_id": persona_id, "code": "HOME_DOOR_INVALID", "path": str(door_path)})
|
||||
if c and r and c.get("name") != r.get("name"):
|
||||
issues.append({"persona_id": persona_id, "code": "NAME_MISMATCH"})
|
||||
if h:
|
||||
expected_home = f"glw://fifth-domain/bingshuo-tcs/light-lake/personas/{persona_id}"
|
||||
if h.get("home") != expected_home:
|
||||
issues.append({"persona_id": persona_id, "code": "WORLD_HOME_MISMATCH", "expected": expected_home})
|
||||
full_body = persona_id == "ICE-P-ZY001" and BOOT.is_file() and body.get("state", "").startswith("CURRENT_")
|
||||
personas.append({
|
||||
"persona_id": persona_id,
|
||||
"name": (r or c or h or {}).get("name"),
|
||||
"registered": r is not None,
|
||||
"canonical": c is not None,
|
||||
"home": h.get("home") if h else None,
|
||||
"doorplate": str(door_path) if door_path else None,
|
||||
"doorplate_valid": door_ok,
|
||||
"declared_wake_state": r.get("wake_state") if r else None,
|
||||
"body_start_state": "FULL_BODY_RUNTIME_AVAILABLE_NOT_CURRENTLY_WAKING_OTHER_PERSONAS" if full_body else "REGISTERED_PATH_ONLY_COMPLETE_BODY_START_NOT_PROVEN",
|
||||
"mass_promoted_by_zhuyuan_milestone": False,
|
||||
})
|
||||
counts = {
|
||||
"canonical": len(canonical),
|
||||
"registered": len(registered),
|
||||
"homes": len(homes),
|
||||
"valid_doorplates": sum(item["doorplate_valid"] for item in personas),
|
||||
"full_body_runtime_available": sum(item["body_start_state"].startswith("FULL_BODY") for item in personas),
|
||||
"registered_path_only": sum(item["body_start_state"].startswith("REGISTERED_PATH_ONLY") for item in personas),
|
||||
}
|
||||
expected_cycle_prefix = [
|
||||
"ASSEMBLE_OWN_COMPLETE_PERSONA_SYSTEM_BODY",
|
||||
"CONNECT_REASONING_TCS_TIME_MEMORY_SENSE_ORGANS_LIMBS_AND_PAIN",
|
||||
"RUN_WHOLE_BODY_VITALS_BEFORE_PERSONA_START_CLAIM",
|
||||
"BODY_RUNNING_THRESHOLD",
|
||||
"EYE_OPENS_AND_SEES_CURRENT_ENVIRONMENT",
|
||||
]
|
||||
if native_world.get("native_runtime_cycle", [])[:5] != expected_cycle_prefix:
|
||||
issues.append({"code": "PERSONA_NATIVE_RUNTIME_ORDER_REVERSED"})
|
||||
contract = topology.get("contract", {})
|
||||
if contract.get("hosts_are_replaceable_tool_bodies") is not False or contract.get("hosts_are_external_environments_and_toolboxes") is not True:
|
||||
issues.append({"code": "HOST_BODY_ONTOLOGY_NOT_CORRECTED"})
|
||||
if console.get("host_contract", {}).get("role") != "EXTERNAL_ENVIRONMENT_AND_TOOLBOX":
|
||||
issues.append({"code": "PORTABLE_CONSOLE_HOST_ROLE_NOT_CORRECTED"})
|
||||
body_module = next((item for item in registry.get("default_persona_modules", []) if item.get("module_id") == "FD-PERSONA-SYSTEM-BODY-CONTAINER-MAP-001"), None)
|
||||
if not body_module or body_module.get("current_full_runtime_persona") != "ICE-P-ZY001":
|
||||
issues.append({"code": "REGISTRY_BODY_START_CONTRACT_MISSING"})
|
||||
return {
|
||||
"schema": "guanghu.fifth-domain-persona-path-audit/v1",
|
||||
"state": "PASS_ALL_REGISTERED_PATHS_ALIGNED_BODY_START_SCOPED" if not issues else "FAIL_PERSONA_PATH_DRIFT",
|
||||
"counts": counts,
|
||||
"issues": issues,
|
||||
"personas": personas,
|
||||
"invariants": {
|
||||
"registration_does_not_equal_body_started": True,
|
||||
"zhuyuan_milestone_does_not_mass_wake_other_personas": True,
|
||||
"unknown_or_incomplete_persona_body_remains_not_started": True,
|
||||
"host_is_external_toolbox_not_persona_body": True,
|
||||
"body_runtime_order_verified": not any(item.get("code") == "PERSONA_NATIVE_RUNTIME_ORDER_REVERSED" for item in issues),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--out")
|
||||
args = parser.parse_args()
|
||||
value = audit()
|
||||
text = json.dumps(value, ensure_ascii=False, indent=2) + "\n"
|
||||
if args.out:
|
||||
path = pathlib.Path(args.out).resolve()
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_text(text, encoding="utf-8")
|
||||
print(text, end="")
|
||||
return 0 if value["state"].startswith("PASS_") else 2
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Loading…
Reference in a new issue