diff --git a/skills/seal-use/references/report-templates.md b/skills/seal-use/references/report-templates.md index e583ff8..34918e5 100644 --- a/skills/seal-use/references/report-templates.md +++ b/skills/seal-use/references/report-templates.md @@ -114,26 +114,28 @@ Seal AI 审核报告是向企业财务总监、风控负责人及 CIO 交付的 ```markdown | 列号 | 列名 | 字段含义与说明 | 数据来源 | | :--- | :--- | :--- | :--- | -| **A** | `单据编号 (SN)` | 单据业务自然键(如 `CL2608001`) | 业务单据主键 | -| **B** | `审核记录ID (recordId)` | 单次 AI 审核运行的唯一主键,用于版本精确锁定 | 审批运行记录主键 | -| **C** | `单据模板` | 单据所属表单类型(如 `差旅报销单`) | 业务单据属性 | -| **D** | `提交人` | 单据发起员工姓名或工号 | 业务单据属性 | -| **E** | `单据金额` | 单据报销或付款总金额(元) | 业务单据属性 | -| **F** | `单据创建时间` | 单据在源系统创建的北京时间 | 业务单据属性 | -| **G** | `AI审核时间` | AI 模型执行审核的北京时间 | 审批运行属性 | -| **H** | `AI审核结论` | AI 给出的审批决策:`通过` / `驳回` | 审批运行结果 | +| **A** | `审核ID(recordId)` | 单次 AI 审核运行的唯一主键,用于版本精确锁定 | 审批运行记录主键 | +| **B** | `单据编号(SN)` | 单据业务自然键(如 `CL2608001`) | 业务单据主键 | +| **C** | `单据模板` | 单据所属表单类型(如 `差旅报销单`) | 业务单据模板 | +| **D** | `单据标题/事由` | 单据报销或申请标题、事由摘要 | 业务单据属性 | +| **E** | `提交人` | 单据发起员工姓名或工号 | 业务单据属性 | +| **F** | `费用承担部门` | 单据所属费用发生或承担部门 | 业务单据属性 | +| **G** | `跑批时间` | AI 审核执行的北京时间 | 审批运行属性 | +| **H** | `AI审批决策` | AI 给出的审批决策:`同意` / `驳回` | 审批运行结果 | | **I** | `AI审核完整意见与违规详情` | **核心证据列**:包含 AI 综合评语、触发的具体规则编号及违规条款细则 | 聚合 summary + conditions | -| **J** | `人工审批操作` | 人工审批人实际操作:`同意` / `驳回` / `终止` | 人工操作记录 | +| **J** | `人工审批结论` | 人工审批人实际操作:`同意` / `驳回` / `终止` | 人工操作记录 | | **K** | `人工审批批注/驳回说明` | **核心证据列**:人工审批人在系统后台填写的真实审批意见与驳回理由 | 提取 manualComment / rejectComment | -| **L** | `结论是否同向` | `同向一致` 或 `存在分歧` | 逻辑比较 H 与 J | +| **L** | `人机一致性` | `一致`、`分歧` 或 `未完结/流转中` | 比较 H 与 J 决策极性 | | **M** | `复核定性裁决` | **自由裁量填报列**:Agent/用户填写的定性结论(支持中英文口语化识别) | 人工/Agent 填报 | -| **N** | `裁决依据说明` | 针对复核裁决填写的定性分析、归因说明与管理整改建议 | 人工/Agent 填报 | -| **O** | `AI审核详情直达链接` | 带免密凭证的 Seal AI 审核页直达 URL | 动态生成穿透链接 | -| **P** | `合思原单据直达链接` | 合思/易快报 Web 页面原单据直达 URL | 提取自 sourceExtendData | +| **N** | `复核人` | 执行该单裁决核查的业务人员或 Agent 署名 | 人工/Agent 填报 | +| **O** | `复核批注说明` | 针对复核裁决填写的定性分析、归因说明与管理整改建议 | 人工/Agent 填报 | +| **P** | `审批耗时(秒)` | AI 模型单据全生命周期审核耗时(秒) | 审批运行属性 | ``` > [!TIP] > **中文口语化智能解析**:在「复核定性裁决」列中,用户不仅可以填写规范枚举(`ai_correct`),也可以自由填写中文口语:“`AI判断正确 / 人工判断错误`”、“`AI正确`”、“`人工正确`”、“`AI误判`”、“`双方正确`”等,CLI 在加载时均能百分之百精准识别映射。 +> +> 若需核查单据更细维度的明细金额、发票结构化票面或附件凭证,Agent 可通过 `seal-use approval-runs get ` 或 `seal-use hose-ebot` 按需补充调阅。 --- diff --git a/src/domains/seal/reports/pipeline/data.ts b/src/domains/seal/reports/pipeline/data.ts index f50a5f9..d4e9014 100644 --- a/src/domains/seal/reports/pipeline/data.ts +++ b/src/domains/seal/reports/pipeline/data.ts @@ -1,5 +1,5 @@ import type { KyInstance } from "ky"; -import { collectReportData } from "./collect.js"; +import { collectReportData, polarityOf } from "./collect.js"; import { loadReportDataFromLedger } from "../export/ledger.js"; import { renderVennAccuracySvg } from "../charts/venn.js"; @@ -286,7 +286,15 @@ export async function getMonthlyReportData( accuracyFormula, automationRate: data.performance?.automationRate, avgDurationSeconds: data.performance?.avgDurationSeconds, - riskInterceptCount: data.performance?.riskCount ?? data.blocks.filter((b) => b.agreement === "diverged" && b.verdict === "ai_correct").length + riskInterceptCount: + data.performance?.riskCount ?? + data.blocks.filter( + (b) => + b.agreement === "diverged" && + b.verdict === "ai_correct" && + polarityOf(b.aiDecision) === "reject" && + polarityOf(b.humanResult) === "pass" + ).length }, reviews: { available: data.notes.humanAccuracyAvailable, diff --git a/src/domains/seal/reports/pipeline/reports.test.ts b/src/domains/seal/reports/pipeline/reports.test.ts index 326efa8..a21bef6 100644 --- a/src/domains/seal/reports/pipeline/reports.test.ts +++ b/src/domains/seal/reports/pipeline/reports.test.ts @@ -492,6 +492,43 @@ describe("getMonthlyReportData", () => { expect(data.nextActions.validate).toBe("seal-use report validate <报告文件.md>"); }); + test("riskInterceptCount fallback counts AI reject + human pass + ai_correct and excludes AI pass + human reject", async () => { + // 模拟离线台账场景(无 cloud performance.riskCount) + // DEMO-007: AI 驳回,人工同意,裁决 ai_correct → 真正的风险拦截! + // DEMO-008: AI 同意,人工驳回,裁决 ai_correct → 依规放行正确,非风险拦截! + writeReview("corp-test", { sn: "DEMO-007", month: "2026-08", verdict: "ai_correct" }); + writeReview("corp-test", { sn: "DEMO-008", month: "2026-08", verdict: "ai_correct" }); + + const runs = [ + { + id: "r1", + sourceDocumentSN: "DEMO-007", + result: { decision: "驳回", summary: "发票违规超标" }, + pipelineData: { humanResult: "同意" }, + document: { fields: [{ key: "specificationId", value: "一般费用报销" }] } + }, + { + id: "r2", + sourceDocumentSN: "DEMO-008", + result: { decision: "同意", summary: "合规放行" }, + pipelineData: { humanResult: "驳回" }, + document: { fields: [{ key: "specificationId", value: "一般费用报销" }] } + } + ]; + + const fakeClient = { + get: async () => ({ json: async () => ({ data: { records: runs, total: 2 } }) }) + } as never; + + const data = await getMonthlyReportData(fakeClient, { + month: "2026-08", + corp: { id: "corp-test", name: "测试企业" } + }); + + // 只有 DEMO-007 算入风险拦截,DEMO-008 属于依规放行不虚增风险拦截 + expect(data.metrics.riskInterceptCount).toBe(1); + }); + test("blocks buildMonthlyReport when unreviewed diverged runs exist", async () => { const runs = [ { id: "r1", sourceDocumentSN: "DIVERGED-01", result: { decision: "同意" }, pipelineData: { humanResult: "驳回" } }