W22: coverage metric + network tests + Tool stream feedback + stdin pipe + session path + dependency check (W22.1-W22.6)
Some checks failed
CI / Determine matrix (push) Has been cancelled
CI / ${{ matrix.os }} / ${{ matrix.build_type }} (push) Has been cancelled
CI / Sanitizer (ASan+UBSan) / ubuntu-24.04 (push) Has been cancelled
CI / Coverage (gcovr) / ubuntu-24.04 (push) Has been cancelled

- W22.1: gcovr 覆盖率度量 + CI coverage job(40% 阈值 warning)
- W22.2: network_plugin 单元测试(parse_headers_json/extract_host_port/SSE/异常保护)
- W22.3: Tool Calling 流式反馈(chat_stream + "[工具调用]/[工具结果]" 状态行)
- W22.4: --prompt stdin pipe(--prompt - 从 stdin 读取)
- W22.5: session 路径健壮化(static 缓存 + mkdir + fallback)
- W22.6: 插件依赖拓扑静态校验(validate_dependencies 循环/缺失检测)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-27 21:21:24 +08:00
parent b2b381b9b3
commit df3bf298ee
13 changed files with 753 additions and 23 deletions

View File

@@ -306,11 +306,55 @@ std::vector<int> PluginLoader::topological_sort() const
return sorted;
}
int PluginLoader::validate_dependencies() const
{
int error_count = 0;
// 构建名称到ID的映射
std::unordered_map<std::string, int> name_to_id;
for (const auto& [id, plugin] : plugins_) {
name_to_id[plugin.name] = id;
}
// 检查1缺失依赖deps 引用的插件未加载)
for (const auto& [id, plugin] : plugins_) {
for (const auto& dep_name : plugin.dependencies) {
if (name_to_id.find(dep_name) == name_to_id.end()) {
if (host_api_) {
host_api_->log(DSTALK_LOG_ERROR,
"[plugin_loader] Plugin '%s': dependency '%s' not found (plugin not loaded)",
plugin.name.c_str(), dep_name.c_str());
}
error_count++;
}
}
}
// 检查2循环依赖拓扑排序失败
try {
topological_sort();
} catch (const std::runtime_error&) {
if (host_api_) {
host_api_->log(DSTALK_LOG_ERROR,
"[plugin_loader] Circular dependency detected among loaded plugins");
}
error_count++;
}
return error_count > 0 ? -1 : 0;
}
int PluginLoader::initialize_all(const dstalk_host_api_t* host_api)
{
if (!host_api) return -1;
host_api_ = host_api;
// 依赖合法性校验log 错误但不 crash继续初始化流程
if (validate_dependencies() != 0) {
host_api->log(DSTALK_LOG_WARN,
"[plugin_loader] Dependency validation failed; initialization may be incomplete");
}
try {
std::vector<int> order = topological_sort();