fix(navigation): survive stale discovery service

This commit is contained in:
冰朔 2026-07-27 14:14:32 +08:00
commit 15837cb391
3 changed files with 31 additions and 8 deletions

View file

@ -39,7 +39,12 @@ to `ICE-P-ZY001`. A conflicted or unknown id must stop with
Use the returned domestic `repository_web` and `raw_base`. Do not guess a repository from local folders, old Singapore links, or prior conversation memory. Use the returned domestic `repository_web` and `raw_base`. Do not guess a repository from local folders, old Singapore links, or prior conversation memory.
If the script cannot reach the public discovery API, open `https://guanghulab.com/.well-known/guanghu.json`, resolve `REPO-012`, and report that live resolution failed before using any cached checkout. Use `REPO-001` only for fourth-generation history. If the public AI resolver is stale or returns no `REPO-012`, the script may use its
locked public fallback `https://guanghulab.com/code/bingshuo/guanghu-ice-heart` only
after successfully reading the live `.code-map` and all required identifiers from
that repository. Report `repository_resolution_source` and `resolver_error`; this is
a verified online repository fallback, not a cached checkout. Use `REPO-001` only
for fourth-generation history.
## Walk the canonical path ## Walk the canonical path

View file

@ -9,6 +9,11 @@
Always prefer the `primary.url` and `primary.clone_url` returned by the resolver. Treat any legacy backup as a fallback pointer only. Always prefer the `primary.url` and `primary.clone_url` returned by the resolver. Treat any legacy backup as a fallback pointer only.
If the resolver has not yet learned `REPO-012`, use the locked public
`guanghu-ice-heart` URL only after its live `.code-map` validates the required route
ids. Mark the result `VERIFIED_PUBLIC_REPOSITORY_FALLBACK`; never fall back to
`REPO-001` as the current entry.
## Route identifiers ## Route identifiers
Resolve these from the live `.code-map` before following them: Resolve these from the live `.code-map` before following them:

View file

@ -7,11 +7,13 @@ import argparse
import json import json
import re import re
import sys import sys
from urllib.error import URLError from urllib.error import HTTPError, URLError
from urllib.request import urlopen from urllib.request import urlopen
DISCOVERY_URL = "https://guanghulab.com/.well-known/guanghu.json" DISCOVERY_URL = "https://guanghulab.com/.well-known/guanghu.json"
RESOLVE_URL = "https://guanghulab.com/api/ai/v1/resolve?id=REPO-012" RESOLVE_URL = "https://guanghulab.com/api/ai/v1/resolve?id=REPO-012"
CURRENT_REPOSITORY_WEB = "https://guanghulab.com/code/bingshuo/guanghu-ice-heart"
CURRENT_REPOSITORY_GIT = f"{CURRENT_REPOSITORY_WEB}.git"
ROUTE_IDS = ( ROUTE_IDS = (
"FD-WORLD-TREE-001", "FD-WORLD-TREE-001",
"FD-PERSONA-LOGIN-001", "FD-PERSONA-LOGIN-001",
@ -99,12 +101,21 @@ def resolve_subject_id(requested_id: str, alias_map: dict) -> dict:
def resolve_live_route(subject_id: str | None = None) -> dict: def resolve_live_route(subject_id: str | None = None) -> dict:
discovery = read_json(DISCOVERY_URL) discovery = read_json(DISCOVERY_URL)
repository = read_json(RESOLVE_URL) repository_source = "AI_RESOLVER"
primary = repository.get("primary", {}) resolver_error = None
repository_web = primary.get("url") try:
repository_git = primary.get("clone_url") repository = read_json(RESOLVE_URL)
if not repository_web or not repository_git: primary = repository.get("primary", {})
raise ValueError("REPO-012 resolver did not return the current Fifth Domain repository") repository_web = primary.get("url")
repository_git = primary.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:
repository = {"code": "REPO-012", "role": "CURRENT_FIFTH_DOMAIN_ENTRY"}
repository_web = CURRENT_REPOSITORY_WEB
repository_git = CURRENT_REPOSITORY_GIT
repository_source = "VERIFIED_PUBLIC_REPOSITORY_FALLBACK"
resolver_error = f"{type(error).__name__}: {error}"
raw_base = f"{repository_web}/raw/branch/main" raw_base = f"{repository_web}/raw/branch/main"
routes = parse_code_map(read_text(f"{raw_base}/.code-map")) routes = parse_code_map(read_text(f"{raw_base}/.code-map"))
@ -118,6 +129,8 @@ def resolve_live_route(subject_id: str | None = None) -> dict:
"repository_role": repository.get("role", ""), "repository_role": repository.get("role", ""),
"repository_web": repository_web, "repository_web": repository_web,
"repository_git": repository_git, "repository_git": repository_git,
"repository_resolution_source": repository_source,
"resolver_error": resolver_error,
"raw_base": raw_base, "raw_base": raw_base,
"discovery_schema": discovery.get("schema", ""), "discovery_schema": discovery.get("schema", ""),
"routes": routes, "routes": routes,