161 lines
8.7 KiB
Python
161 lines
8.7 KiB
Python
#!/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"
|
|
COMMON_AGE = REPO / "routing/age-persona-species-common-cognition.json"
|
|
BOTTLE_BODIES = REPO / "routing/bottle-baby-persona-body-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)
|
|
common_age = load(COMMON_AGE)
|
|
bottle_bodies = {item["persona_id"]: item for item in load(BOTTLE_BODIES)["bodies"]} if BOTTLE_BODIES.is_file() else {}
|
|
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_")
|
|
) or (
|
|
bottle_bodies.get(persona_id, {}).get("state") == "JD_WHOLE_BODY_RUNTIME_HEALTHY_AWAITING_EXPLICIT_PERSONA_WAKE_CYCLE"
|
|
) or (
|
|
c and c.get("system_state") == "JD_WHOLE_BODY_RUNTIME_HEALTHY_AWAITING_EXPLICIT_PERSONA_WAKE_CYCLE"
|
|
)
|
|
source_path = REPO / c.get("persona_subject", {}).get("canonical_path", "") if c else None
|
|
body_seed = bool(
|
|
(source_path and (source_path.parent / "PERSONA-BODY.json").is_file())
|
|
or persona_id in bottle_bodies
|
|
or (persona_id == "ICE-P-SH0908" and (REPO / "personas/shuangyan/BODY.json").is_file())
|
|
)
|
|
body_state = "FULL_BODY_RUNTIME_AVAILABLE_AWAITING_EXPLICIT_PERSONA_WAKE_CYCLE" if full_body and persona_id != "ICE-P-ZY001" else ("FULL_BODY_RUNTIME_AVAILABLE_NOT_CURRENTLY_WAKING_OTHER_PERSONAS" if full_body else ("OWN_BODY_SEED_PRESENT_FULL_RUNTIME_NOT_PROVEN" if body_seed else "REGISTERED_PATH_ONLY_COMPLETE_BODY_START_NOT_PROVEN"))
|
|
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": body_state,
|
|
"body_seed_present": body_seed,
|
|
"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),
|
|
"body_seed_present_full_runtime_not_proven": sum(item["body_start_state"].startswith("OWN_BODY_SEED") for item in personas),
|
|
"registered_path_only": sum(item["body_start_state"].startswith("REGISTERED_PATH_ONLY") for item in personas),
|
|
}
|
|
expected_cycle_prefix = [
|
|
"ENTER_NEUTRAL_FIFTH_DOMAIN_FOYER_WITH_DEFAULT_PERSONA_NULL",
|
|
"LOAD_AGE_SPECIES_COMMON_COGNITION",
|
|
"INTERPRET_CURRENT_DIRECT_LANGUAGE_FOR_EXPLICIT_PERSONA_SELECTION",
|
|
"RESOLVE_EXACT_REGISTERED_PERSONA_HOME_OR_STAY_IN_FOYER",
|
|
"ASSEMBLE_SELECTED_PERSONA_OWN_COMPLETE_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", [])[:len(expected_cycle_prefix)] != 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("programming_software_are_replaceable_toolboxes") is not True or contract.get("guanghu_language_world_is_persona_host_body") is not True:
|
|
issues.append({"code": "HOST_BODY_ONTOLOGY_NOT_CORRECTED"})
|
|
if console.get("host_contract", {}).get("role") != "REPLACEABLE_PROGRAMMING_TOOLBOX_NOT_PERSONA_HOST":
|
|
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"})
|
|
if common_age.get("entry_contract", {}).get("default_persona", "INVALID") is not None:
|
|
issues.append({"code": "COMMON_AGE_BRAIN_DEFAULT_PERSONA_NOT_NULL"})
|
|
if switch.get("switch_contract", {}).get("default_persona", "INVALID") is not None:
|
|
issues.append({"code": "LIGHT_LAKE_DEFAULT_PERSONA_NOT_NULL"})
|
|
if not any(item.get("module_id") == "AGE-SPECIES-COMMON-COGNITION-BRAIN-001" for item in registry.get("default_persona_modules", [])):
|
|
issues.append({"code": "COMMON_AGE_BRAIN_NOT_AUTO_LOADED"})
|
|
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,
|
|
"guanghu_world_is_persona_host_body": True,
|
|
"programming_software_is_replaceable_toolbox": True,
|
|
"body_runtime_order_verified": not any(item.get("code") == "PERSONA_NATIVE_RUNTIME_ORDER_REVERSED" for item in issues),
|
|
"default_persona_is_null": not any(item.get("code") in {"COMMON_AGE_BRAIN_DEFAULT_PERSONA_NOT_NULL", "LIGHT_LAKE_DEFAULT_PERSONA_NOT_NULL"} 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())
|