1
0

feat: 重构配置布局,server.listen/storage/logging + probes.execution 分组

- 新增 server.listen (host/port)、server.storage (dataDir/retention)、
  server.logging 分组
- 新增 probes.execution (maxConcurrentChecks) 分组,替代顶层 runtime
- 旧配置入口 (runtime/logging/server.host/server.port/server.dataDir)
  启动期拒绝
- 更新 types.ts、builder.ts、config-loader.ts 适配新路径
- 更新 probe-config.schema.json、probes.example.yaml、README.md、
  DEVELOPMENT.md
- 补充 config-loader 和 variables 测试覆盖新路径和旧入口拒绝
- 同步 5 个 delta specs 到主规范 (probe-config, config-variables,
  data-retention, probe-engine, runtime-logging)
- 归档 openspec change reorganize-config-layout
This commit is contained in:
2026-05-21 13:54:41 +08:00
parent 5238dbe77d
commit e448cb4654
14 changed files with 614 additions and 376 deletions

View File

@@ -220,9 +220,9 @@ describe("config variables", () => {
expect(typeof http2["ignoreSSL"]).toBe("boolean");
});
test("runtime 段不替换", () => {
test("server.storage 段不替换", () => {
const result = resolveVariables({
runtime: { maxConcurrentChecks: 10, retention: "${retention}" },
server: { storage: { retention: "${retention}" } },
targets: [
{
http: { url: "${host}" },
@@ -234,8 +234,44 @@ describe("config variables", () => {
});
expect(result.issues).toHaveLength(0);
const config = result.config as { runtime: { retention: string } };
expect(config.runtime.retention).toBe("${retention}");
const config = result.config as { server: { storage: { retention: string } } };
expect(config.server.storage.retention).toBe("${retention}");
});
test("probes 段不替换", () => {
const result = resolveVariables({
probes: { execution: { maxConcurrentChecks: "${maxConcurrentChecks}" } },
targets: [
{
http: { url: "${host}" },
id: "probes-no-replace",
type: "http",
},
],
variables: { host: "https://example.com", maxConcurrentChecks: "20" },
});
expect(result.issues).toHaveLength(0);
const config = result.config as { probes: { execution: { maxConcurrentChecks: string } } };
expect(config.probes.execution.maxConcurrentChecks).toBe("${maxConcurrentChecks}");
});
test("server.logging 段不替换", () => {
const result = resolveVariables({
server: { logging: { level: "${logLevel}" } },
targets: [
{
http: { url: "${host}" },
id: "logging-no-replace",
type: "http",
},
],
variables: { host: "https://example.com", logLevel: "debug" },
});
expect(result.issues).toHaveLength(0);
const config = result.config as { server: { logging: { level: string } } };
expect(config.server.logging.level).toBe("${logLevel}");
});
test("variables 段为非对象时报错", () => {