import { computeRulesetHash, computeEngineRevision } from "../gate/ruleset_fingerprint.js"; import type { EvidenceView, DomainName } from "./types.js"; /** * 算产物当前 git hash + 是否存在。产物消失/无匹配返回 { hash: "", exists: false }。 * * 所有证据消费者共用以下 hash 计算: * - code 多端(src/)→ aggregateMultiSrcHash(消除 src/ 锁,多端聚合) * - 有 artifact 声明 → multi-src 用 aggregateMultiSrcHash,否则 getArtifactBundleHash(含 references/companion_files) * - 无 artifact 声明 → 单文件 getFileGitHash fallback(doctor 孤立产物场景) * * 产物消失(文件不存在/无匹配 glob)→ hash="" exists=false。调用方据此决定语义: * 调用方根据 exists 明确区分产物缺失与内容变化。 */ export declare function computeArtifactCurrentHash(artifactPath: string, domain: DomainName, projectRoot: string): Promise<{ hash: string; exists: boolean; }>; /** 三轴 stale 明细:内容(产物 git hash)/ 规则(ruleset_hash)/ 引擎(engine_revision)。 */ export interface StaleAxes { content: boolean; verificationInput: boolean; ruleset: boolean; engine: boolean; /** engine 轴是否经 scope revision 判定(record.engine_scope_revision 存在且调用方提供 currentScopeRevision)。 * true→scope 判定(SCOPE_REVISION_STALE);false/undefined→全局判定(ENGINE_REVISION_STALE)。供 staleReasons 区分。 */ engineViaScope?: boolean; /** 语义输入轴(双轨):有 ImpactEngine 结果时精化 input(affected→stale/skipped→fresh);undefined=fallback verificationInput。不替换 verificationInput。 */ semanticInput?: boolean; } /** Stale 原因分类:每条 stale 输出携带 reason,供诊断/审计/可观测统一识别 stale 来源。 */ export type StaleReason = "CONTENT_HASH_STALE" | "VERIFICATION_INPUT_STALE" | "RULESET_STALE" | "ENGINE_REVISION_STALE" | "SCOPE_REVISION_STALE" | "ARTIFACT_CHANGED_STALE" | "UNKNOWN_STALE"; /** * 从 StaleAxes 派生 stale reason 列表。每 stale 轴对应一个 reason;空数组 = fresh。 * reason 分类与 anyAxisStale 同源(semanticInput 优先于 verificationInput),供所有 stale 输出统一携带 reason。 */ export declare function staleReasons(axes: StaleAxes): StaleReason[]; /** * 判三轴 stale。纯逻辑(无 IO)——调用方预算 currentHash(computeArtifactCurrentHash)与 * currentRulesetHash/currentEngineRevision(循环外算一次避免每产物重算,computeEngineRevision 读 ~25 文件)。 * * 返回明细供 doctor 分类统计和任务证据评估使用。 * * 注意:内容轴 .isStale 内部对 currentHash="" 返回 false(:192 * `if (!record.artifact_git_hash || !currentGitHash) return false`)。产物消失场景由调用方据 * computeArtifactCurrentHash.exists/hash==="" 单独判(不依赖此函数的内容轴)。 */ export declare function staleAxes(record: EvidenceView, currentHash: string, currentRulesetHash: string, currentEngineRevision: string, currentInputHash?: string, currentScopeRevision?: string, semanticImpact?: { affectedArtifacts: ReadonlyArray<{ kind: string; }>; skippedArtifacts: ReadonlyArray<{ kind: string; }>; }, originTaskStatus?: string): StaleAxes; /** * record 是否任一轴 stale。 * 调用方须先判产物消失(hash==="" → 直接 stale,此函数的内容轴对空 hash 返回 false 会漏判)。 * * artifact fingerprint 优先:content 轴(产物 git hash)是 per-artifact 精确轴(每产物独立 hash,改单产物只该产物 content stale), * 为 stale 判定主导轴;ruleset/engine(scope/global)是辅助轴,**不作唯一失效条件**(改单个产物不连带 scope 内其他产物 stale, * 除非它们的 verification_input 依赖闭包含该产物)。多轴 OR:content || input || ruleset || engine,任一即 stale。 */ export declare function anyAxisStale(axes: StaleAxes): boolean; export { computeRulesetHash, computeEngineRevision };