mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-10-04 00:03:59 +00:00
Phase 0.1/1/3/6: 核心生产问题修复
Healthcheck 隔离 (Phase 0.1): - 新增 internal/sdk/selftest.go: VirtualInstance 完全隔离自检空间 - PluginSDK.Selftest()/SelftestReset() 暴露隔离实例 (含 mutex) - LLM 自检只读白名单 isSafeReadonlyTool 防写类工具污染生产 - 单测验证: healthcheck 后生产实例内容不变 + 无残留 - 存量清理: 删除 gotest/luatest 残留目录 GraphDB 去重 (Phase 1): - migrateRelationUnique: 启动自动重建 relations 表加 UNIQUE 约束并去重 - Commit 改为存在性检查, 重复三元组仅刷新 confidence 不重复插入 - 3 个 dedup 单测全绿 配置时长解析 (Phase 3): - parseDurationExtended 支持 2d/1w/3h 等人类可读单位 - GetDuration 全局生效, 防 2d 静默回退 30m Agentcli 通知风暴治理 (Phase 6): - 语义通知: 累积 notify_bytes(2KB) 或间隔 notify_interval(2s) 触发 - 生命周期即时通知: 启动/进程退出/EOF 立即通知 - 可配置 settings, 保留通知机制保证 agent 感知终端存在 - 运维止血: 已杀掉幽灵 PID 3716282 (bash git sparse clone 运行 16h) Plan.md: 新增设计意图备忘(插件即App/分层记忆), 更新各 Phase 进度
This commit is contained in:
@ -210,6 +210,14 @@ func TestGetHelpers(t *testing.T) {
|
||||
if got := r.GetDuration("dur_key", 0); got != 5*time.Minute {
|
||||
t.Fatalf("GetDuration: expected 5m, got %v", got)
|
||||
}
|
||||
r.Set("dur_key_days", "2d")
|
||||
if got := r.GetDuration("dur_key_days", 0); got != 48*time.Hour {
|
||||
t.Fatalf("GetDuration d-unit: expected 48h, got %v", got)
|
||||
}
|
||||
r.Set("dur_key_weeks", "1w")
|
||||
if got := r.GetDuration("dur_key_weeks", 0); got != 168*time.Hour {
|
||||
t.Fatalf("GetDuration w-unit: expected 168h, got %v", got)
|
||||
}
|
||||
if got := r.GetDuration("nonexistent", 30*time.Second); got != 30*time.Second {
|
||||
t.Fatalf("GetDuration fallback: expected 30s, got %v", got)
|
||||
}
|
||||
@ -221,6 +229,42 @@ func TestGetHelpers(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseDurationExtended(t *testing.T) {
|
||||
cases := []struct {
|
||||
in string
|
||||
want time.Duration
|
||||
wantErr bool
|
||||
}{
|
||||
{"2d", 48 * time.Hour, false},
|
||||
{"1w", 7 * 24 * time.Hour, false},
|
||||
{"1d", 24 * time.Hour, false},
|
||||
{"2d12h", 60 * time.Hour, false},
|
||||
{"30m", 30 * time.Minute, false},
|
||||
{"500ms", 500 * time.Millisecond, false},
|
||||
{"1h30m", 90 * time.Minute, false},
|
||||
{" 3d ", 72 * time.Hour, false},
|
||||
{"2w", 336 * time.Hour, false},
|
||||
{"", 0, true},
|
||||
{"abc", 0, true},
|
||||
}
|
||||
for _, c := range cases {
|
||||
got, err := parseDurationExtended(c.in)
|
||||
if c.wantErr {
|
||||
if err == nil {
|
||||
t.Errorf("%q: expected error, got %v", c.in, got)
|
||||
}
|
||||
continue
|
||||
}
|
||||
if err != nil {
|
||||
t.Errorf("%q: unexpected error: %v", c.in, err)
|
||||
continue
|
||||
}
|
||||
if got != c.want {
|
||||
t.Errorf("%q: expected %v, got %v", c.in, c.want, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSnapshotRestoreCoreLLM(t *testing.T) {
|
||||
r := NewConfigRegistry("")
|
||||
defer r.Close()
|
||||
|
||||
Reference in New Issue
Block a user