feat(persona): unify system and code channel routes
This commit is contained in:
parent
53564e0fdf
commit
e80ee6d966
29 changed files with 825 additions and 242 deletions
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env python3
|
||||
"""Resolve the live domestic Fifth Domain entrance and canonical route IDs."""
|
||||
"""Resolve the live Guanghu code-channel entrance and canonical route IDs."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
|
|
@ -10,8 +10,9 @@ import sys
|
|||
from urllib.error import HTTPError, 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-012"
|
||||
FORGEJO_REPOSITORY_URL = (
|
||||
"https://guanghulab.com/code/api/v1/repos/bingshuo/guanghu-ice-heart"
|
||||
)
|
||||
CURRENT_REPOSITORY_WEB = "https://guanghulab.com/code/bingshuo/guanghu-ice-heart"
|
||||
CURRENT_REPOSITORY_GIT = f"{CURRENT_REPOSITORY_WEB}.git"
|
||||
ROUTE_IDS = (
|
||||
|
|
@ -30,6 +31,9 @@ ROUTE_IDS = (
|
|||
"FD-NODE-MAP-001",
|
||||
"JD-FD-PRIMARY",
|
||||
"FD-REPO-MAP-001",
|
||||
"CODE-CHANNEL-CANONICAL-MAP",
|
||||
"PERSONA-SYSTEM-ROOT",
|
||||
"PERSONA-SYSTEM-CANONICAL-MAP",
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -100,17 +104,16 @@ def resolve_subject_id(requested_id: str, alias_map: dict) -> dict:
|
|||
|
||||
|
||||
def resolve_live_route(subject_id: str | None = None) -> dict:
|
||||
discovery = read_json(DISCOVERY_URL)
|
||||
repository_source = "AI_RESOLVER"
|
||||
repository_source = "LIVE_FORGEJO_CODE_CHANNEL_API"
|
||||
resolver_error = None
|
||||
try:
|
||||
repository = read_json(RESOLVE_URL)
|
||||
primary = repository.get("primary", {})
|
||||
repository_web = primary.get("url")
|
||||
repository_git = primary.get("clone_url")
|
||||
live = read_json(FORGEJO_REPOSITORY_URL)
|
||||
repository_web = live.get("html_url")
|
||||
repository_git = live.get("clone_url")
|
||||
if not repository_web or not repository_git:
|
||||
raise ValueError("REPO-012 resolver did not return the current Fifth Domain repository")
|
||||
except (HTTPError, ValueError) as error:
|
||||
raise ValueError("Forgejo did not return the current REPO-012 route")
|
||||
repository = {"code": "REPO-012", "role": "CURRENT_FIFTH_DOMAIN_ENTRY"}
|
||||
except (HTTPError, URLError, ValueError) as error:
|
||||
repository = {"code": "REPO-012", "role": "CURRENT_FIFTH_DOMAIN_ENTRY"}
|
||||
repository_web = CURRENT_REPOSITORY_WEB
|
||||
repository_git = CURRENT_REPOSITORY_GIT
|
||||
|
|
@ -124,7 +127,7 @@ def resolve_live_route(subject_id: str | None = None) -> dict:
|
|||
raise ValueError(f"Live .code-map is missing required route IDs: {', '.join(missing)}")
|
||||
|
||||
result = {
|
||||
"status": "LIVE_DOMESTIC_PRIMARY",
|
||||
"status": "LIVE_CODE_CHANNEL_PRIMARY",
|
||||
"repository_id": repository.get("code", "REPO-012"),
|
||||
"repository_role": repository.get("role", ""),
|
||||
"repository_web": repository_web,
|
||||
|
|
@ -132,7 +135,7 @@ def resolve_live_route(subject_id: str | None = None) -> dict:
|
|||
"repository_resolution_source": repository_source,
|
||||
"resolver_error": resolver_error,
|
||||
"raw_base": raw_base,
|
||||
"discovery_schema": discovery.get("schema", ""),
|
||||
"code_channel_root": "https://guanghulab.com/code/",
|
||||
"routes": routes,
|
||||
}
|
||||
if subject_id:
|
||||
|
|
|
|||
Loading…
Reference in a new issue