feat: add BingShuo system body validation reflex

This commit is contained in:
冰朔 2026-08-10 19:40:23 +08:00
commit 893f8e6781
25 changed files with 488 additions and 34 deletions

View file

@ -7,7 +7,7 @@ const { execFileSync } = require("node:child_process");
const test = require("node:test");
const {
createServer, loadAnchor, loadMap, loadNodeMap, loadSubjectRegistry, loadSubjectAliasMap, loadNavigationMap,
loadLighthousePaths, loadHostSkills,
loadLighthousePaths, loadHostSkills, loadIdentityAuthority,
loadFileSnapshot, GitSnapshotStore, compileWarmEntry,
resolveSubjectId, compileNavigation, resolveLighthousePath, compileHostNavigation, search, searchAll,
} = require("./server");
@ -65,6 +65,7 @@ test("Git snapshot store follows main atomically and retains the last known-good
nodes: ["routing/server-node-map.json", "FD-NODE-MAP-001"],
subjects: ["identity/fifth-domain-subject-registry.json", "FD-SUBJECT-REGISTRY-001"],
aliases: ["identity/subject-id-alias-map.json", "FD-SUBJECT-ID-ALIAS-MAP-001"],
identity_authority: ["routing/guanghu-identity-authority-map.json", "GH-IDENTITY-AUTHORITY-MAP-001"],
navigation: ["routing/ai-machine-navigation-map.json", "AI-MACHINE-NAV-001"],
lighthouse_paths: ["routing/lighthouse-path-registry.json", "GLW-LIGHTHOUSE-PATH-REGISTRY-001"],
host_skills: ["routing/host-skill-navigation-map.json", "GLW-HOST-SKILL-NAV-001"],
@ -179,6 +180,13 @@ test("human ids remain human and conflicted persona ids fail closed", () => {
assert.equal(resolveSubjectId(aliases, "ICE-PCA-001").status, "CONFLICT_REJECTED");
});
test("identity authority is a first-class atomic public snapshot map", () => {
const snapshot = loadFileSnapshot();
assert.equal(snapshot.identity_authority.map_id, "GH-IDENTITY-AUTHORITY-MAP-001");
assert.equal(snapshot.identity_authority.version, loadIdentityAuthority().version);
assert.equal(snapshot.anchor.maps.identity_authority.version, snapshot.identity_authority.version);
});
test("searching the old id returns the canonical subject", () => {
const results = searchAll(loadMap(), loadNodeMap(), "ICE-GL-ZY001", loadSubjectRegistry());
const subject = results.find(item => item.kind === "subject");
@ -282,6 +290,10 @@ test("public endpoints are read-only and expose CORS", async () => {
assert.equal((await navigationResponse.json()).map_id, "AI-MACHINE-NAV-001");
const lighthouseResponse = await fetch(`${base}/v1/lighthouse`);
assert.equal((await lighthouseResponse.json()).registry_id, "GLW-LIGHTHOUSE-PATH-REGISTRY-001");
const authorityResponse = await fetch(`${base}/v1/identity-authority`);
assert.equal((await authorityResponse.json()).map_id, "GH-IDENTITY-AUTHORITY-MAP-001");
const authorityResolve = await fetch(`${base}/v1/resolve?id=GH-IDENTITY-AUTHORITY-MAP-001`);
assert.equal(authorityResolve.status, 200);
const hostNavigateResponse = await fetch(
`${base}/v1/host-navigate?host=codex&intent=${encodeURIComponent("推一下线上仓库")}`,
);
@ -310,6 +322,7 @@ test("public endpoints are read-only and expose CORS", async () => {
assert.equal((await fetch(`${base}/v1/resolve?id=ICE-PCA-001`)).status, 409);
const manifestResponse = await fetch(`${base}/well-known`);
const manifest = await manifestResponse.json();
assert.match(manifest.identity_authority_map, /\/v1\/identity-authority$/);
assert.equal(manifest.write_authorization.request_credential_required, false);
assert.match(manifest.write_authorization.create_workorder, /\/authz\/api\/public\/workorders$/);
assert.equal((await fetch(`${base}/v1/search`, { method: "POST" })).status, 405);