fix(knowledge): 修复循环依赖 + 归档 session-dedup-knowledge-map + 记录 ISS-002

- KnowledgeIndexService: 域级生成从 @PostConstruct 移到 @EventListener(ApplicationReadyEvent),解决 KnowledgeIndexService ↔ KnowledgeDomainService 循环依赖
- devflow 归档: evidence.md + acceptance.md(含运行验证结果)
- devflow/index.md: session-dedup-knowledge-map 状态改为 archived
- openspec .archive-ready 标记
- mvp/issues/ISS-002: Executor 无约束重复调用 lookup_knowledge
This commit is contained in:
zhuyongxin
2026-07-01 14:26:59 +08:00
parent 354ffc1947
commit e4f37cb9e6
7 changed files with 253 additions and 3 deletions
@@ -9,7 +9,9 @@ import com.superbiz.agent.repository.KnowledgeDomainRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Service;
import jakarta.annotation.PostConstruct;
@@ -69,7 +71,18 @@ public class KnowledgeIndexService {
log.info("知识库索引加载完成,共 {} 个文档", loaded);
// 检查各域是否有 knowledge_domain 记录,无则触发生成
} catch (Exception e) {
log.error("知识库索引加载失败", e);
}
}
/**
* 应用就绪后,检查各域是否有 knowledge_domain 记录,无则触发生成
* 使用 ApplicationReadyEvent 而非 PostConstruct,避免循环依赖
*/
@EventListener(ApplicationReadyEvent.class)
public void onApplicationReady() {
try {
knowledgeIndex.stream()
.map(KnowledgeEntry::getCategory)
.filter(c -> c != null && !c.isBlank())
@@ -80,9 +93,8 @@ public class KnowledgeIndexService {
knowledgeDomainService.onDocumentChange(category);
}
});
} catch (Exception e) {
log.error("知识库索引加载失败", e);
log.error("域级记录生成失败", e);
}
}