Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.
Python agent-contextagent-memoryagent-pluginsagentic-ragcontext-databasedsh-pluginknowledge-basememorymemory-managementself-evolvingvector-database
fix(ci): 修正 API 契约断言和工作流配置 (#6062)
Qin Haojiea55e423b8bb9
diff --git a/.github/scripts/check-plugin-version-bumps.sh b/.github/scripts/check-plugin-version-bumps.shindex f2a62728b..b0b74d702 100755--- a/.github/scripts/check-plugin-version-bumps.sh+++ b/.github/scripts/check-plugin-version-bumps.sh@@ -82,7 +82,7 @@ for entry in "${PLUGINS[@]}"; do# Test-only edits do not change the distributed plugin runtime.changed="$(git diff --name-only "$BASE_REF...HEAD" -- "$dir" "$SHARED_LIB" \- ':(exclude)**/*.test.mjs' | grep -v '/node_modules/' || true)"+ ':(exclude)**/*.test.mjs' ':(exclude)**/tests/**' | grep -v '/node_modules/' || true)"[ -n "$changed" ] || continue# A plugin added in this branch has no baseline version to compare against.diff --git a/.github/workflows/_docs-deploy.yml b/.github/workflows/_docs-deploy.ymlindex 738c1e7c0..8ddf999f3 100644--- a/.github/workflows/_docs-deploy.yml+++ b/.github/workflows/_docs-deploy.yml@@ -6,6 +6,9 @@ on:jobs:deploy:name: Build and Deploy Docs+ concurrency:+ group: github-pages+ cancel-in-progress: falseruns-on: ubuntu-24.04permissions:contents: readdiff --git a/.github/workflows/host-compat.yml b/.github/workflows/host-compat.ymlindex 8d1517e95..2a1616922 100644--- a/.github/workflows/host-compat.yml+++ b/.github/workflows/host-compat.yml@@ -37,9 +37,8 @@ jobs:with:node-version: '24'- - uses: pnpm/action-setup@v6- with:- version: '12'+ - name: Install pnpm+ run: npm install --global pnpm@12- name: Generate the shared runtime copiesrun: node examples/memory-plugin-shared/sync.mjsdiff --git a/tests/api_test/common/slow/test_boundary_conditions.py b/tests/api_test/common/slow/test_boundary_conditions.pyindex 8ef8a0050..f57f73250 100644--- a/tests/api_test/common/slow/test_boundary_conditions.py+++ b/tests/api_test/common/slow/test_boundary_conditions.py@@ -142,9 +142,8 @@ class TestBoundaryConditions:def test_list_tasks_with_zero_limit(self, api_client):resp = api_client.list_tasks(limit=0)- assert resp.status_code == 200, (- f"list_tasks with limit=0 should return valid status, got {resp.status_code}"- )+ assert resp.status_code == 400, resp.text+ assert resp.json()["error"]["code"] == "INVALID_ARGUMENT"def test_list_tasks_with_large_limit(self, api_client):resp = api_client.list_tasks(limit=10000)diff --git a/tests/api_test/common/slow/test_error_format.py b/tests/api_test/common/slow/test_error_format.pyindex 286a56047..1f57ab310 100644--- a/tests/api_test/common/slow/test_error_format.py+++ b/tests/api_test/common/slow/test_error_format.py@@ -80,15 +80,13 @@ class TestErrorFormatConsistency:def test_find_with_negative_limit(self, api_client):find_resp = api_client.find(query="test", limit=-1)- assert find_resp.status_code == 200, (- f"negative limit should return error or be clamped, got {find_resp.status_code}"- )+ assert find_resp.status_code == 400, find_resp.text+ assert find_resp.json()["error"]["code"] == "INVALID_ARGUMENT"def test_find_with_zero_limit(self, api_client):find_resp = api_client.find(query="test", limit=0)- assert find_resp.status_code == 200, (- f"zero limit should return error or empty results, got {find_resp.status_code}"- )+ assert find_resp.status_code == 400, find_resp.text+ assert find_resp.json()["error"]["code"] == "INVALID_ARGUMENT"def test_content_write_without_uri(self, api_client):endpoint = "/api/v1/content/write"diff --git a/tests/api_test/conftest.py b/tests/api_test/conftest.pyindex 983d8c032..87fa4414f 100644--- a/tests/api_test/conftest.py+++ b/tests/api_test/conftest.py@@ -96,7 +96,6 @@ TEST_CASE_DESCRIPTIONS = {"test_build_error_handling_slow.py::TestBuildErrorHandlingSlow::test_error_duplicate_resource_no_to": "TC-E12 同名资源二次添加","test_build_error_handling_slow.py::TestBuildErrorHandlingSlow::test_error_incremental_update_with_to": "TC-E13 同to增量更新","test_build_error_handling_slow.py::TestBuildErrorHandlingSlow::test_error_unsupported_file_type": "TC-E15 不支持的文件类型",- "test_build_error_handling_slow.py::TestBuildErrorHandlingSlow::test_error_corrupted_zip": "TC-E16 损坏的ZIP文件","test_build_uri_params_slow.py::TestBuildUriParamsSlow::test_build_with_to_param": "TC-E17 to参数指定URI","test_build_uri_params_slow.py::TestBuildUriParamsSlow::test_build_with_parent_param": "TC-E18 parent参数指定父目录","test_build_uri_params_slow.py::TestBuildUriParamsSlow::test_build_non_resources_scope_rejected": "TC-E11 scope参数非resources拒绝",@@ -193,7 +192,6 @@ TEST_CASE_APIS = {"test_build_error_handling_slow.py::TestBuildErrorHandlingSlow::test_error_duplicate_resource_no_to": "/api/v1/resources","test_build_error_handling_slow.py::TestBuildErrorHandlingSlow::test_error_incremental_update_with_to": "/api/v1/resources","test_build_error_handling_slow.py::TestBuildErrorHandlingSlow::test_error_unsupported_file_type": "/api/v1/resources",- "test_build_error_handling_slow.py::TestBuildErrorHandlingSlow::test_error_corrupted_zip": "/api/v1/resources","test_build_uri_params_slow.py::TestBuildUriParamsSlow::test_build_with_to_param": "/api/v1/resources","test_build_uri_params_slow.py::TestBuildUriParamsSlow::test_build_with_parent_param": "/api/v1/resources","test_build_uri_params_slow.py::TestBuildUriParamsSlow::test_build_non_resources_scope_rejected": "/api/v1/resources",diff --git a/tests/api_test/content/slow/test_content_write_modes_deep.py b/tests/api_test/content/slow/test_content_write_modes_deep.pyindex ca64892f0..215a3663f 100644--- a/tests/api_test/content/slow/test_content_write_modes_deep.py+++ b/tests/api_test/content/slow/test_content_write_modes_deep.py@@ -121,11 +121,16 @@ class TestContentWriteModesDeep:if root_uri:api_client.fs_rm(root_uri, recursive=True)- def test_write_on_nonexistent_child_uri(self, api_client):- fake_uri = f"viking://resources/nonexist_{uuid.uuid4().hex[:8]}/file.md"- write_resp = api_client.fs_write(- fake_uri, "Content for nonexistent", mode="replace", wait=True- )- assert write_resp.status_code == 404, (- f"write on nonexistent URI should return 400/404/412, got {write_resp.status_code}"- )+ def test_replace_creates_missing_file_and_parent(self, api_client):+ parent_uri = f"viking://resources/nonexist_{uuid.uuid4().hex[:8]}"+ file_uri = f"{parent_uri}/file.md"+ content = "Content for a newly created file"+ try:+ write_resp = api_client.fs_write(file_uri, content, mode="replace", wait=True)+ assert write_resp.status_code == 200, write_resp.text++ read_resp = api_client.fs_read(file_uri)+ assert read_resp.status_code == 200, read_resp.text+ assert read_resp.json()["result"] == content+ finally:+ api_client.fs_rm(parent_uri, recursive=True)diff --git a/tests/api_test/scenarios/resources_retrieval/test_build_error_handling.py b/tests/api_test/scenarios/resources_retrieval/test_build_error_handling.pyindex d33157eca..0e622775f 100644--- a/tests/api_test/scenarios/resources_retrieval/test_build_error_handling.py+++ b/tests/api_test/scenarios/resources_retrieval/test_build_error_handling.py@@ -131,7 +131,7 @@ class TestBuildErrorHandling:cleanup_temp_dir(temp_dir)def test_error_corrupted_zip(self, api_client):- """TC-E16 损坏的ZIP文件:验证伪造 .zip 文件回退或报错且不崩溃"""+ """TC-E16 损坏的ZIP文件:返回明确的参数错误。"""random_id = str(uuid.uuid4())[:8]temp_dir = tempfile.mkdtemp()@@ -141,10 +141,11 @@ class TestBuildErrorHandling:try:response = api_client.add_resource(path=zip_path, wait=True)- assert response.status_code == 500, f"损坏ZIP应返回 500, 实际: {response.status_code}"+ assert response.status_code == 400, response.textdata = response.json()assert data.get("status") == "error", f"损坏ZIP应返回 error, 实际: {data.get('status')}"+ assert data["error"]["code"] == "INVALID_ARGUMENT"print("✓ TC-E16 损坏的ZIP文件处理通过")finally:diff --git a/tests/api_test/scenarios/resources_retrieval_slow/test_build_error_handling_slow.py b/tests/api_test/scenarios/resources_retrieval_slow/test_build_error_handling_slow.pyindex 8836fa5f1..3f2414a53 100644--- a/tests/api_test/scenarios/resources_retrieval_slow/test_build_error_handling_slow.py+++ b/tests/api_test/scenarios/resources_retrieval_slow/test_build_error_handling_slow.py@@ -367,65 +367,3 @@ class TestBuildErrorHandlingSlow:returnraise AssertionError(f"SSH URL格式错误应返回 error 或降级, 实际: {data.get('status')}")-- def test_error_corrupted_zip(self, api_client):- """TC-E16 损坏的ZIP文件:验证伪造 .zip 文件报错含 zip/corrupt 或回退处理,不产生有效子节点"""- random_id = str(uuid.uuid4())[:8]-- temp_dir = tempfile.mkdtemp()- zip_path = os.path.join(temp_dir, f"corrupted_{random_id}.zip")- with open(zip_path, "w", encoding="utf-8") as f:- f.write("这不是一个真正的ZIP文件内容")-- try:- response = api_client.add_resource(path=zip_path, wait=True)- assert response.status_code == 500-- data = response.json()- if data.get("status") == "error":- error_msg = _extract_error_message(data).lower()- assert (- "zip" in error_msg- or "corrupt" in error_msg- or "error" in error_msg- or "archive" in error_msg- ), f"损坏ZIP错误信息应包含 zip/corrupt/error/archive, 实际: {error_msg}"- print(f"✓ TC-E16 损坏的ZIP文件处理通过(返回error): {error_msg[:80]}")- return-- assert data.get("status") == "ok"-- result = data.get("result", {})- if isinstance(result, dict) and result.get("status") == "error":- inner_errors = result.get("errors", [])- inner_msg = " ".join(str(e) for e in inner_errors)- assert (- "zip" in inner_msg.lower()- or "corrupt" in inner_msg.lower()- or "error" in inner_msg.lower()- or "bad" in inner_msg.lower()- ), f"损坏ZIP内层错误应包含 zip/corrupt/error/bad, 实际: {inner_msg}"- print(f"✓ TC-E16 损坏的ZIP文件处理通过(内层错误): {inner_msg[:80]}")- return-- root_uri = result.get("root_uri")- if root_uri:- assert_root_uri_valid(root_uri)-- tree_resp = api_client.fs_tree(root_uri)- if tree_resp.status_code == 200:- tree_data = tree_resp.json()- tree_result = tree_data.get("result")- if isinstance(tree_result, list):- children = tree_result- elif isinstance(tree_result, dict):- children = tree_result.get("children", [])- else:- children = []- assert len(children) == 0, (- f"损坏ZIP不应产生有效子节点, 实际子节点数: {len(children)}"- )-- print(f"✓ TC-E16 损坏的ZIP文件处理通过, root_uri: {root_uri}")- finally:- shutil.rmtree(temp_dir, ignore_errors=True)diff --git a/tests/api_test/scenarios/resources_retrieval_slow/test_build_media_resources_slow.py b/tests/api_test/scenarios/resources_retrieval_slow/test_build_media_resources_slow.pyindex a695cfae1..85851b740 100644--- a/tests/api_test/scenarios/resources_retrieval_slow/test_build_media_resources_slow.py+++ b/tests/api_test/scenarios/resources_retrieval_slow/test_build_media_resources_slow.py@@ -15,7 +15,7 @@ class TestBuildMediaResourcesSlow:"""TC-B13~B15 媒体类资源构建测试"""def test_build_image_svg(self, api_client):- """TC-B13 图片构建(SVG):验证 .svg 文件解析失败时错误信息合理,成功时 source_format=image 且可检索"""+ """TC-B13 图片构建(SVG):验证受支持的 SVG 可成功导入并检索。"""random_id = str(uuid.uuid4())[:8]unique_keyword = f"svg_keyword_{random_id}"temp_dir = tempfile.mkdtemp()@@ -27,39 +27,12 @@ class TestBuildMediaResourcesSlow:try:response = api_client.add_resource(path=svg_path, wait=True)- assert response.status_code == 500+ assert response.status_code == 200, response.textdata = response.json()- assert data.get("status") in ("ok", "error"), (- f"SVG文件应返回 ok 或 error, 实际: {data.get('status')}"- )-- if data.get("status") == "error":- error_msg = str(data.get("error", "")).lower()- assert (- "image" in error_msg- or "svg" in error_msg- or "parse" in error_msg- or "error" in error_msg- ), f"SVG外层错误应包含 image/svg/parse/error, 实际: {error_msg}"- print("✓ TC-B13 图片构建(SVG)通过(服务端返回error,SVG格式不被支持)")- return+ assert data.get("status") == "ok"result = data.get("result", {})- if isinstance(result, dict) and result.get("status") == "error":- inner_errors = result.get("errors", [])- inner_msg = " ".join(str(e) for e in inner_errors)- assert (- "image" in inner_msg.lower()- or "parse" in inner_msg.lower()- or "identify" in inner_msg.lower()- or "svg" in inner_msg.lower()- ), f"SVG解析错误信息应包含 image/parse/identify/svg, 实际: {inner_msg}"- print(- f"✓ TC-B13 图片构建(SVG)通过(服务端内层解析错误,SVG格式不被支持): {inner_msg[:80]}"- )- return-root_uri = result.get("root_uri") if isinstance(result, dict) else Noneassert_root_uri_valid(root_uri)diff --git a/tests/api_test/scenarios/resources_retrieval_slow/test_build_platform_wikipedia.py b/tests/api_test/scenarios/resources_retrieval_slow/test_build_platform_wikipedia.pyindex 05315202d..072d225df 100644--- a/tests/api_test/scenarios/resources_retrieval_slow/test_build_platform_wikipedia.py+++ b/tests/api_test/scenarios/resources_retrieval_slow/test_build_platform_wikipedia.py@@ -1,5 +1,5 @@+import pytestfrom build_test_helpers import (- _extract_error_message,assert_resource_indexed,assert_root_uri_valid,assert_source_format,@@ -18,27 +18,24 @@ class TestBuildPlatformWikipedia:"""TC-P05 Wikipedia页面构建:验证 wikipedia.org URL 走 WEBPAGE 路由且内容可检索"""for wiki_url in self.WIKI_URLS:response = api_client.add_resource(path=wiki_url, wait=True)- assert response.status_code == 500-data = response.json()- if data.get("status") == "error":- error_msg = _extract_error_message(data).lower()- if "403" in error_msg or "forbidden" in error_msg or "blocked" in error_msg:- print(f" Wikipedia URL {wiki_url} 返回403, 尝试下一个URL...")- continue- raise AssertionError(f"Wikipedia页面构建失败: {error_msg}")-+ if response.status_code == 403:+ assert data["status"] == "error"+ error = data["error"]+ assert error["code"] == "PERMISSION_DENIED"+ assert error["details"]["upstream_status_code"] == 403+ assert error["details"]["source"] == wiki_url+ continue+ if response.status_code == 412:+ assert data["status"] == "error"+ assert data["error"]["code"] == "FAILED_PRECONDITION"+ assert "site disallows crawlers" in data["error"]["message"]+ continue++ assert response.status_code == 200, response.textassert data.get("status") == "ok"result = data.get("result", {})- if isinstance(result, dict) and result.get("status") == "error":- inner_errors = result.get("errors", [])- inner_msg = " ".join(str(e) for e in inner_errors).lower()- if "403" in inner_msg or "forbidden" in inner_msg:- print(f" Wikipedia URL {wiki_url} 内层403, 尝试下一个URL...")- continue- raise AssertionError(f"Wikipedia页面构建内层错误: {inner_msg}")-root_uri = result.get("root_uri")assert root_uri, "Wikipedia页面构建应返回root_uri, 实际为空"assert_root_uri_valid(root_uri)@@ -58,4 +55,4 @@ class TestBuildPlatformWikipedia:print(f"✓ TC-P05 Wikipedia页面构建通过, root_uri: {root_uri}")return- print("✓ TC-P05 Wikipedia页面构建跳过(所有Wikipedia URL均返回403, CI环境限制)")+ pytest.skip("所有 Wikipedia URL 均拒绝访问或禁止爬虫,未验证内容构建")diff --git a/tests/api_test/sessions/slow/test_session_concurrency.py b/tests/api_test/sessions/slow/test_session_concurrency.pyindex b7910c647..36d15c6e6 100644--- a/tests/api_test/sessions/slow/test_session_concurrency.py+++ b/tests/api_test/sessions/slow/test_session_concurrency.py@@ -94,9 +94,8 @@ class TestSessionConcurrency:def test_delete_nonexistent_session_returns_404(self, api_client):fake_id = f"nonexistent-{uuid.uuid4().hex[:12]}"del_resp = api_client.delete_session(fake_id)- assert del_resp.status_code == 200, (- f"deleting nonexistent session returns 200, got {del_resp.status_code}"- )+ assert del_resp.status_code == 404, del_resp.text+ assert del_resp.json()["error"]["code"] == "NOT_FOUND"def test_add_message_to_deleted_session_fails(self, api_client):session_id = None