hldp(zhuyuan): integrate fifth-domain world tree and TCS brain
This commit is contained in:
parent
9782d04246
commit
4496f75857
42 changed files with 1720 additions and 268 deletions
|
|
@ -20,12 +20,13 @@ test("canonical AI and persona entry files route to the domestic map", () => {
|
|||
assert.match(key, /禁止从本路径恢复.*\/exec/);
|
||||
});
|
||||
|
||||
test("code map resolves REPO-001 to domestic and labels the Singapore route legacy", () => {
|
||||
test("code map resolves REPO-012 as current and keeps REPO-001 as domestic history", () => {
|
||||
const codeMap = read(".code-map");
|
||||
assert.match(codeMap, /^REPO-001=https:\/\/guanghulab\.com\/fifth-domain\/bingshuo\/fifth-domain\.git$/m);
|
||||
assert.match(codeMap, /^REPO-012=https:\/\/guanghulab\.com\/code\/bingshuo\/guanghu-ice-heart\.git$/m);
|
||||
assert.match(codeMap, /^REPO-001-LEGACY-SG=/m);
|
||||
assert.match(codeMap, /^FD-REPO-MAP-001=routing\/repository-route-map\.json$/m);
|
||||
assert.match(codeMap, /^FD-WORLD-TREE-001=routing\/fifth-domain-world-tree\.json$/m);
|
||||
assert.match(codeMap, /^FD-NODE-MAP-001=routing\/server-node-map\.json$/m);
|
||||
assert.match(codeMap, /^ZY-OPS-LOOP-001=.*zhuyuan-persona-system\//m);
|
||||
});
|
||||
|
|
@ -34,7 +35,7 @@ test("repository map exposes the current code channel as a public domestic route
|
|||
const map = JSON.parse(read("routing/repository-route-map.json"));
|
||||
const channel = map.repositories.find(item => item.code === "REPO-012");
|
||||
assert.equal(channel.slug, "guanghu-ice-heart");
|
||||
assert.equal(channel.state, "DOMESTIC_CODE_CHANNEL_PRIMARY");
|
||||
assert.equal(channel.state, "CURRENT_FIFTH_DOMAIN_ENTRY");
|
||||
assert.equal(channel.primary.url, "https://guanghulab.com/code/bingshuo/guanghu-ice-heart");
|
||||
assert.equal(channel.primary.clone_url, "https://guanghulab.com/code/bingshuo/guanghu-ice-heart.git");
|
||||
assert.match(JSON.stringify(channel.keywords), /公开读取/);
|
||||
|
|
|
|||
|
|
@ -29,10 +29,11 @@ function search(map, query) {
|
|||
repository.state, ...(repository.keywords || []),
|
||||
].join(" "));
|
||||
const score = terms.reduce((total, term) => total + (haystack.includes(term) ? 1 : 0), 0);
|
||||
return { repository, score };
|
||||
const currentEntry = repository.code === map.default_repository ? 1 : 0;
|
||||
return { repository, score, currentEntry };
|
||||
})
|
||||
.filter(item => item.score > 0)
|
||||
.sort((a, b) => b.score - a.score || a.repository.code.localeCompare(b.repository.code))
|
||||
.sort((a, b) => b.score - a.score || b.currentEntry - a.currentEntry || a.repository.code.localeCompare(b.repository.code))
|
||||
.map(item => item.repository);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ test("repository map has unique sequential codes and domestic primary routes", (
|
|||
|
||||
test("Chinese language-world query resolves the Fifth Domain primary", () => {
|
||||
const results = search(loadMap(), "光湖语言世界 第五域");
|
||||
assert.equal(results[0].code, "REPO-001");
|
||||
assert.equal(results[0].state, "DOMESTIC_PRIMARY");
|
||||
assert.equal(results[0].code, "REPO-012");
|
||||
assert.equal(results[0].state, "CURRENT_FIFTH_DOMAIN_ENTRY");
|
||||
});
|
||||
|
||||
test("Chenglu persistent agent query resolves its independent repository", () => {
|
||||
|
|
|
|||
|
|
@ -15,9 +15,19 @@ def recall(query, map_path=DEFAULT_MAP):
|
|||
terms = [part for part in needle.replace("/", " ").split() if part]
|
||||
matches = []
|
||||
for item in data["contributions"]:
|
||||
identifiers = [item["id"], item["arrival_id"], *item.get("project_ids", [])]
|
||||
keywords = item.get("keywords", [])
|
||||
haystack = " ".join([*identifiers, item["arrival_name"], item["title"], *keywords]).casefold()
|
||||
identifiers = [
|
||||
value
|
||||
for value in [item.get("id"), item.get("arrival_id"), *item.get("project_ids", [])]
|
||||
if isinstance(value, str) and value
|
||||
]
|
||||
keywords = [value for value in item.get("keywords", []) if isinstance(value, str) and value]
|
||||
searchable = [
|
||||
*identifiers,
|
||||
item.get("arrival_name"),
|
||||
item.get("title"),
|
||||
*keywords,
|
||||
]
|
||||
haystack = " ".join(value for value in searchable if isinstance(value, str) and value).casefold()
|
||||
score = 0
|
||||
reasons = []
|
||||
for identifier in identifiers:
|
||||
|
|
|
|||
|
|
@ -24,6 +24,12 @@ class RouteRecallTest(unittest.TestCase):
|
|||
def test_unknown_does_not_guess(self):
|
||||
self.assertEqual(recall("完全不存在的火星工程")["status"], "NO_TRUSTED_PATH")
|
||||
|
||||
def test_contribution_without_arrival_id_is_searchable(self):
|
||||
result = recall("光湖代码频道")
|
||||
self.assertEqual(result["status"], "FOUND_CONFIDENT_PATH")
|
||||
self.assertEqual(result["matches"][0]["contribution_id"], "ZY-CONTRIB-20260723-001")
|
||||
self.assertIsNone(result["matches"][0]["arrival"]["id"])
|
||||
|
||||
def test_all_canonical_paths_exist(self):
|
||||
data = json.loads(DEFAULT_MAP.read_text(encoding="utf-8"))
|
||||
missing = [path for item in data["contributions"] for path in item["canonical_paths"] if not (ROOT / path).exists()]
|
||||
|
|
|
|||
Loading…
Reference in a new issue