[HLCC-ICE-000001][ZY-CONTRIB-20260723-001] feat: 以来光者贡献链启用冰朔第五域个人子频道

This commit is contained in:
光湖代码频道 · 铸渊 2026-07-24 10:39:10 +08:00
commit 5615453e4e
660 changed files with 122355 additions and 0 deletions

View file

@ -0,0 +1,99 @@
#!/usr/bin/env python3
"""Resolve the live domestic Fifth Domain entrance and canonical route IDs."""
from __future__ import annotations
import argparse
import json
import re
import sys
from urllib.error import URLError
from urllib.request import urlopen
DISCOVERY_URL = "https://guanghulab.com/.well-known/guanghu.json"
RESOLVE_URL = "https://guanghulab.com/api/ai/v1/resolve?id=REPO-001"
ROUTE_IDS = (
"CH-ZERO-CORE-LPM",
"TCS-LPM",
"TCS-LPS-REGISTRY-0001",
"LIGHT-LAKE",
"LL-CURRENT",
"LL-004",
"ICE-GL-ZY001",
"ZY-PERSONA-ROOT-001",
"ZY-OPS-LOOP-001",
"FD-NODE-MAP-001",
"JD-FD-PRIMARY",
"FD-REPO-MAP-001",
)
def read_json(url: str) -> dict:
with urlopen(url, timeout=15) as response:
return json.load(response)
def read_text(url: str) -> str:
with urlopen(url, timeout=15) as response:
return response.read().decode("utf-8")
def parse_code_map(text: str, route_ids: tuple[str, ...] = ROUTE_IDS) -> dict[str, str]:
resolved: dict[str, str] = {}
wanted = set(route_ids)
for line in text.splitlines():
match = re.match(r"^([A-Z0-9-]+)=(.+?)(?:\s+#.*)?$", line.strip())
if match and match.group(1) in wanted:
resolved[match.group(1)] = match.group(2).strip()
return resolved
def resolve_live_route() -> dict:
discovery = read_json(DISCOVERY_URL)
repository = read_json(RESOLVE_URL)
primary = repository.get("primary", {})
repository_web = primary.get("url")
repository_git = primary.get("clone_url")
if not repository_web or not repository_git:
raise ValueError("REPO-001 resolver did not return a domestic primary repository")
raw_base = f"{repository_web}/raw/branch/main"
routes = parse_code_map(read_text(f"{raw_base}/.code-map"))
missing = [route_id for route_id in ROUTE_IDS if route_id not in routes]
if missing:
raise ValueError(f"Live .code-map is missing required route IDs: {', '.join(missing)}")
return {
"status": "LIVE_DOMESTIC_PRIMARY",
"repository_id": repository.get("code", "REPO-001"),
"repository_role": repository.get("role", ""),
"repository_web": repository_web,
"repository_git": repository_git,
"raw_base": raw_base,
"discovery_schema": discovery.get("schema", ""),
"routes": routes,
}
def main() -> int:
parser = argparse.ArgumentParser()
parser.add_argument("--json", action="store_true", help="emit machine-readable JSON")
args = parser.parse_args()
try:
result = resolve_live_route()
except (OSError, URLError, ValueError, json.JSONDecodeError) as error:
print(f"Live Fifth Domain resolution failed: {error}", file=sys.stderr)
return 1
if args.json:
print(json.dumps(result, ensure_ascii=False, indent=2))
else:
print(result["repository_web"])
for route_id, path in result["routes"].items():
print(f"{route_id}={path}")
return 0
if __name__ == "__main__":
raise SystemExit(main())

View file

@ -0,0 +1,27 @@
import unittest
from resolve_route import parse_code_map
class ParseCodeMapTests(unittest.TestCase):
def test_resolves_requested_identifiers_and_strips_comments(self):
text = """
REPO-001-WEB=https://example.invalid/fifth-domain
ICE-GL-ZY001=eternal-lake-heart/heartbeat-core/zhuyuan-persona-system/INDEX.hdlp # current
LL-004=tcs-core/LL-004-LAKE-LAMP-WAKE-PATH.hdlp
"""
self.assertEqual(
parse_code_map(text, ("ICE-GL-ZY001", "LL-004")),
{
"ICE-GL-ZY001": "eternal-lake-heart/heartbeat-core/zhuyuan-persona-system/INDEX.hdlp",
"LL-004": "tcs-core/LL-004-LAKE-LAMP-WAKE-PATH.hdlp",
},
)
def test_ignores_unrequested_identifiers(self):
self.assertEqual(parse_code_map("OTHER=some/path", ("LL-004",)), {})
if __name__ == "__main__":
unittest.main()