Add metadata validation script and module documentation

- Introduced a new Python script `check_agents_metadata.py` for validating agent metadata, including YAML parsing, rating ranges, and cross-references.
- Added usage instructions and exit codes for the script.
- Created a new markdown file `模块目录和功能说明.md` to outline the directory structure and functionality of the modules.
- Added a text file `说明此文件不可AI修改.txt` to specify that certain files should not be modified by AI, including important information about the `dstalk` framework and its modules.
This commit is contained in:
2026-05-31 00:00:58 +08:00
parent 3cc9ee95e4
commit f2da0f2ed4
43 changed files with 2467 additions and 800 deletions

View File

@@ -1,9 +1,10 @@
// ============================================================================
// service_registry_test.cpp — ServiceRegistry 单元测试(补充覆盖,不与 host_api_test 重叠)
// ============================================================================
// host_api_test 已覆盖: 重复注册(同名同版/同名异版)、查询不存在服务、版本不满足、
// shutdown 后查询。本测试补充边界与生命周期路径
// ============================================================================
/*
* @file service_registry_test.cpp
* @brief ServiceRegistry unit tests (supplement to host_api_test): register,
* query, version check, unregister, null-pointer safety, re-registration.
* ServiceRegistry 单元测试host_api_test 补充):注册、查询、版本检查、取消注册、空指针安全、重新注册
* Copyright (c) 2026 dstalk contributors. GPLv3.
*/
#include <cstring>
#include <iostream>
@@ -12,6 +13,7 @@
// ---- 轻量断言 ----
static int g_failures = 0;
// Lightweight assertion helper: increments g_failures counter on failure
#define TCHECK(cond, msg) do { \
if (cond) { \
std::cout << "[OK] " << (msg) << "\n"; \
@@ -21,7 +23,11 @@ static int g_failures = 0;
} \
} while (0)
// ============================================================
// ServiceRegistry 补充测试:空名称/虚表拒绝、完整生命周期(注册→查询→取消注册→查询为空)、
// 取消注册空指针安全、取消注册后重新注册、空名称查询。
// ServiceRegistry supplement tests: null-name/vtable rejection, full lifecycle
// (register->query->unregister->query nullptr), unregister nullptr safety,
// re-registration after unregister, and query with nullptr name.
int main()
{
std::cout << "=== dstalk service_registry unit tests (supplement) ===\n\n";
@@ -47,6 +53,7 @@ int main()
// ====================================================================
// Test 3: 完整生命周期 — register → query → unregister → query(nullptr)
// Test 3: full lifecycle — register → query → unregister → query(nullptr)
// ====================================================================
{
dstalk::ServiceRegistry reg;
@@ -66,6 +73,7 @@ int main()
// ====================================================================
// Test 4: unregister_service(nullptr name) 不崩溃(安全空操作)
// Test 4: unregister_service(nullptr name) does not crash (safe no-op)
// ====================================================================
{
dstalk::ServiceRegistry reg;
@@ -75,6 +83,7 @@ int main()
// ====================================================================
// Test 5: 注册后重新注册同名 → 先 unregister 再 register 成功
// Test 5: re-register same name after unregister → succeeds
// ====================================================================
{
dstalk::ServiceRegistry reg;
@@ -101,7 +110,7 @@ int main()
}
// ====================================================================
// 结果
// 结果 / Result
// ====================================================================
std::cout << "\n";
if (g_failures == 0) {