import { type AuditHistoryEntry } from './audit-history'; import type { DecisionCategory, DecisionKind, DecisionLogEntry, LoopPhase } from './decision-schema'; /** 从决策日志加载全部条目(按写入顺序,时间升序)。 * * v1.3.6 交付⑮:导出供新增查询接口复用(同文件内共享,也供测试直接消费)。 */ export declare function loadDecisionLog(dataDir?: string): DecisionLogEntry[]; /** queryByKind 选项 */ export interface QueryOptions { /** 起始时间(ISO 8601,含) */ since?: string; /** 结束时间(ISO 8601,含) */ until?: string; /** 返回条数上限(默认 100) */ limit?: number; } /** * 按决策种类查询决策日志(时间升序)。 * @param kind 决策种类 * @param opts 查询选项 * @param dataDir 可选的数据目录覆盖(用于测试) */ export declare function queryByKind(kind: DecisionKind, opts?: QueryOptions, dataDir?: string): DecisionLogEntry[]; /** * 按决策发生时刻查询决策日志(v1.3.6 交付⑮ · 时间升序)。 * @param moment 决策时刻(LoopPhase 七阶段) * @param opts 查询选项 * @param dataDir 可选的数据目录覆盖(用于测试) */ export declare function queryByMoment(moment: LoopPhase, opts?: QueryOptions, dataDir?: string): DecisionLogEntry[]; /** * 按 Agent 标识查询决策日志(v1.3.6 交付⑮ · 时间升序)。 * @param agentId Agent 标识(精确匹配) * @param opts 查询选项 * @param dataDir 可选的数据目录覆盖(用于测试) */ export declare function queryByAgent(agentId: string, opts?: QueryOptions, dataDir?: string): DecisionLogEntry[]; /** * 按判断时刻分类查询决策日志(v1.3.6 交付⑮ · 时间升序)。 * * 只返回带 category 标注的条目(老日志无此字段不参与过滤)。 * @param category 判断时刻分类(route/select/skip/retry/escalate) * @param opts 查询选项 * @param dataDir 可选的数据目录覆盖(用于测试) */ export declare function queryByCategory(category: DecisionCategory, opts?: QueryOptions, dataDir?: string): DecisionLogEntry[]; /** 组合查询过滤器(v1.3.6 交付⑮——多维度交叉回溯) */ export interface DecisionFilter { /** 按决策种类过滤 */ kind?: DecisionKind; /** 按决策时刻过滤 */ moment?: LoopPhase; /** 按 Agent 标识过滤 */ agentId?: string; /** 按判断时刻分类过滤(只匹配带 category 标注的条目) */ category?: DecisionCategory; /** 按会话标识过滤 */ sessionId?: string; } /** * 组合查询决策日志(v1.3.6 交付⑮——kind/moment/agentId/category 任意交叉,时间升序)。 * * 验收标准「可按 kind / moment / agentId 查询」的统一入口: * 单维度用 queryByKind / queryByMoment / queryByAgent 更直白, * 多维度交叉(如「某 Agent 的所有路由决策」)用本接口。 * * @param filter 过滤器(全部可选,空对象 = 不过滤) * @param opts 查询选项 * @param dataDir 可选的数据目录覆盖(用于测试) */ export declare function queryDecisions(filter: DecisionFilter, opts?: QueryOptions, dataDir?: string): DecisionLogEntry[]; /** 按种类聚合摘要 */ export interface KindSummary { kind: DecisionKind; /** 该种类决策总数 */ count: number; /** 最近一条决策时间(无则缺省) */ latestTs?: string; /** 高频 tag 聚合(top 5,按出现次数降序) */ topTags: Array<{ tag: string; count: number; }>; } /** * 按决策种类聚合摘要(供 daemon @daily 回灌 / MA5 高频模式提取)。 * @param kind 决策种类 * @param dataDir 可选的数据目录覆盖(用于测试) */ export declare function getKindSummary(kind: DecisionKind, dataDir?: string): KindSummary; /** 高频决策模式条目(MA5 回灌用) */ export interface HighFrequencyPattern { kind: DecisionKind; /** 聚合 key(kind + tags 组合) */ key: string; /** 出现次数(≥3 才算高频) */ count: number; /** 代表条目(最近一条) */ sample: DecisionLogEntry; } /** * 提取高频决策模式(MA5 审查历史回灌)——kind+tags 组合出现 ≥3 次。 * * @param minCount 最低出现次数(默认 3) * @param dataDir 可选的数据目录覆盖(用于测试) */ export declare function getHighFrequencyPatterns(minCount?: number, dataDir?: string): HighFrequencyPattern[]; /** traceBack 结果 */ export interface TraceResult { /** 被追溯的决策条目 */ decision: DecisionLogEntry; /** specRef 解析结果(决策带 specRef 时) */ spec?: { ref: string; file?: string; ok: boolean; }; /** artifactRef 解析结果(决策带 artifactRef 时) */ artifact?: { ref: string; commitSha?: string; ok: boolean; }; /** 按 commitSha join history.jsonl 的行为记录(A1-A19 审计结果) */ behaviorRecords?: AuditHistoryEntry[]; } /** * 从决策条目反向追溯: * decision → specRef(→ spec 文件)→ artifactRef(→ git commit/diff) * → 按 commitSha join history.jsonl 取 A1-A19 行为记录 * * specRef 解析:若看起来是文件路径(含 / 或 .md 等扩展名),file 指向该路径; * artifactRef 解析:若为 7-40 位 hex,视为 commitSha,按它 join 行为记录。 * * @param entryId 决策条目标识——用 ts 定位(决策日志无独立 id,以 ts 为准) * @param dataDir 可选的数据目录覆盖(用于测试) */ export declare function traceBack(entryId: string, dataDir?: string): TraceResult | undefined; /** * 反向追溯:给定 commitSha(行为引用),扫描 decision-log 中 artifactRef * 含该 commitSha 的决策条目。 * @param ref commitSha / 引用文本 * @param dataDir 可选的数据目录覆盖(用于测试) */ export declare function traceFromBehavior(ref: string, dataDir?: string): DecisionLogEntry[]; //# sourceMappingURL=decision-query.d.ts.map