/** * ConflictDetector — 两阶段冲突判定 * Phase 1: Embedding 余弦相似度粗筛(阈值 0.80) * Phase 2: LLM 精判(通过 SPI 调用,不绑定特定模型) * * 规则冲突补充:当知识类型为 intent 时,先走本地规则冲突检测路径, * 覆盖 FR-C01 AC1 要求的“同一场景的矛盾规则”。未命中规则冲突时,再走通用 LLM 精判。 */ import type { KnowledgeEntry } from '../types/index.js'; import type { EmbeddingProvider, LLMJudgeProvider } from './spi.js'; import type { ConflictRecord } from './conflict-record.js'; export interface ConflictDetectorOptions { similarityThreshold?: number; embeddingProvider?: EmbeddingProvider; llmJudgeProvider: LLMJudgeProvider; } export declare class ConflictDetector { private readonly threshold; private readonly embedding?; private readonly llm; constructor(options: ConflictDetectorOptions); /** * 检测新条目与已有条目集合的冲突 * 返回冲突记录列表(可能为空 = 无冲突) */ detect(incoming: KnowledgeEntry, existingEntries: KnowledgeEntry[], options?: { similarityThreshold?: number; }): Promise; /** * Phase 1: Embedding 余弦相似度粗筛 * 降级:无 Embedding 时用元数据匹配(同类型 + 标题关键词重叠 > 60%) * intent 类型额外比较规则场景文本,避免标题不同但规则对象相同的冲突漏检。 */ private phase1Screen; /** * Phase 2: LLM 语义对比精判 */ private phase2Judge; /** * 规则冲突:同一场景给出相反约束。 * 当前用 intent 类型承载规则条目,因此在 detector 内补一条专门路径。 */ private isRuleConflict; private ruleScenarioText; private rulePolarity; } /** 关键词重叠度(降级用) */ export declare function keywordOverlap(a: string, b: string): number; export { cosineSimilarity } from '../utils/math.js'; //# sourceMappingURL=conflict-detector.d.ts.map