Compare commits

...
5 Commits
Author SHA1 Message Date
yunyingk cbc3b333ba Merge pull request #248 from yunyingk/codex/release-v0.11.11
🧪 CI / 🧪 Test, Type-Check & Build Validation (push) Has been cancelled
🚀 Release / 🚀 Build & Publish GitHub Release (push) Has been cancelled
Release v0.11.11: Automated release bump
2026-10-16 17:48:45 +08:00
gitea 059616ba22 Release v0.11.11: Automated release bump 2026-10-16 17:47:30 +08:00
yunyingk 11434f75f0 Merge pull request #247 from yunyingk/mac15/remove-500-runs-limit
Refine report data collection to support unlimited runs without 500 cap
2026-10-16 17:46:34 +08:00
gitea 91feec7b0b Refine risk intercept fallback calculation and sync ledger documentation 2026-10-16 17:44:58 +08:00
gitea 04915c6ad6 Refine report data collection to support unlimited runs without 500 cap 2026-10-16 17:36:36 +08:00
12 changed files with 179 additions and 41 deletions

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "seal-use",
"version": "0.11.10",
"version": "0.11.11",
"description": "Seal Use tenant operations: approval-run diagnosis, minimal rule remediation, delegation links, Hose/合思 authorization, users, rules, billing, and search.",
"author": {
"name": "yingqing"
+8
View File
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [0.11.11] - 2026-10-16
### Added
- Merge pull request #247 from yunyingk/mac15/remove-500-runs-limit
- Refine risk intercept fallback calculation and sync ledger documentation
- Refine report data collection to support unlimited runs without 500 cap
## [0.11.10] - 2026-10-16
### Added
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "seal-use",
"version": "0.11.10",
"version": "0.11.11",
"private": true,
"description": "Seal tenant operations toolkit: approval-run diagnosis, rule remediation, Hose/合思 auth, plus a CLI and an optional MCP server.",
"license": "MIT",
+3 -3
View File
@@ -1,9 +1,9 @@
---
name: seal-use
description: "v0.11.10: Use for Seal Use enterprise onboarding, Hose/合思 or Seal-native authentication, approval operations, diagnosis, simulation, rules, users, configuration, and search."
description: "v0.11.11: Use for Seal Use enterprise onboarding, Hose/合思 or Seal-native authentication, approval operations, diagnosis, simulation, rules, users, configuration, and search."
metadata:
version: 0.11.10
short-description: Seal tenant and Hose approval automation (v0.11.10)
version: 0.11.11
short-description: Seal tenant and Hose approval automation (v0.11.11)
---
# Seal Use
+18 -13
View File
@@ -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 <recordId>` 或 `seal-use hose-ebot` 按需补充调阅。
---
@@ -186,6 +188,9 @@ seal-use report validate reports/审核报告.md
seal-use report render reports/审核报告.md --out build/审核报告/
```
> [!TIP]
> **全量取数与分页控制**:`seal-use report ledger`、`report data` 与 `report generate` 默认自动分页拉取所选时间区间内的**全部审批单据**(内置 100,000 笔安全防死循环上限),无任何 500 条的人工截断限制。如需做小样本分析或限定抓取笔数,可传入 `--limit <n>`(别名 `--max-runs <n>` / `-n <n>`,例如 `--limit 2000`)。
---
### 模式 B:CLI 命令行实时研讨驱动
+16 -6
View File
@@ -95,6 +95,16 @@ export async function handleLocalReportCommand(action: string | undefined, args:
if (!result.validation.valid) throw new CliError("报告校验未通过,未生成渲染产物。请按 validation.issues 修正后重试。", 1);
}
function resolveMaxRuns(args: ParsedArgs): number | undefined {
return (
numberOption(args.options.limit) ??
numberOption(args.options.n) ??
numberOption(args.options.count) ??
numberOption(args.options["max-runs"]) ??
numberOption(args.options.maxRuns)
);
}
/** `seal-use report generate` / `ledger` / `data` — AI 审核报告。 */
export async function handleReportCommand(
action: string | undefined,
@@ -125,7 +135,7 @@ export async function handleReportCommand(
if ((!startDate || !endDate) && !month) {
throw usageError(
"Usage: seal-use report ledger --start-date <YYYY-MM-DD> --end-date <YYYY-MM-DD> [--templates <t1,t2...>] [--max-runs <n>] [--out <file.xlsx|csv>] [--corp <corpId>]"
"Usage: seal-use report ledger --start-date <YYYY-MM-DD> --end-date <YYYY-MM-DD> [--templates <t1,t2...>] [--limit <n>] [--out <file.xlsx|csv>] [--corp <corpId>]"
);
}
@@ -136,7 +146,7 @@ export async function handleReportCommand(
month,
corp: { id: corp.id, name: corp.name },
templates,
maxRuns: numberOption(args.options["max-runs"]) ?? numberOption(args.options.maxRuns)
maxRuns: resolveMaxRuns(args)
});
}
@@ -186,7 +196,7 @@ export async function handleReportCommand(
if (!ledgerPath && (!startDate || !endDate) && !month) {
throw usageError(
"Usage: seal-use report data (--ledger <台账.xlsx> | --start-date <YYYY-MM-DD> --end-date <YYYY-MM-DD>) [--templates <t1,t2...>] [--max-runs <n>] [--corp <corpId>]"
"Usage: seal-use report data (--ledger <台账.xlsx> | --start-date <YYYY-MM-DD> --end-date <YYYY-MM-DD>) [--templates <t1,t2...>] [--limit <n>] [--corp <corpId>]"
);
}
@@ -202,7 +212,7 @@ export async function handleReportCommand(
month,
templates,
ledgerPath,
maxRuns: numberOption(args.options["max-runs"]) ?? numberOption(args.options.maxRuns)
maxRuns: resolveMaxRuns(args)
}
);
printJson(result, outputOptions(args.options));
@@ -225,7 +235,7 @@ export async function handleReportCommand(
if (!ledgerPath && (!startDate || !endDate) && !month) {
throw usageError(
"Usage: seal-use report generate (--ledger <台账.xlsx> | --start-date <YYYY-MM-DD> --end-date <YYYY-MM-DD>) [--templates <t1,t2...>] [--template <file>] [--report-id <RPT-...>] [--corp <corpId>]"
"Usage: seal-use report generate (--ledger <台账.xlsx> | --start-date <YYYY-MM-DD> --end-date <YYYY-MM-DD>) [--templates <t1,t2...>] [--limit <n>] [--template <file>] [--report-id <RPT-...>] [--corp <corpId>]"
);
}
@@ -243,7 +253,7 @@ export async function handleReportCommand(
ledgerPath,
templatePath: stringOption(args.options.template),
reportId: stringOption(args.options["report-id"]) ?? stringOption(args.options.reportId),
maxRuns: numberOption(args.options["max-runs"]) ?? numberOption(args.options.maxRuns),
maxRuns: resolveMaxRuns(args),
allowUnreviewed: booleanOption(args.options["allow-unreviewed"]) ?? booleanOption(args.options.force)
}
) as MonthlyReportResult;
+6 -6
View File
@@ -625,7 +625,7 @@ export const HELP_REGISTRY: AreaHelp[] = [
{
name: "ledger",
summary: "Export standalone audit run ledger (.xlsx / .csv) with full AI & human opinions",
usage: ["seal-use report ledger --start-date <YYYY-MM-DD> --end-date <YYYY-MM-DD> [--templates <t1,t2...>] [--out <file.xlsx>] [--corp <corpId>]"],
usage: ["seal-use report ledger --start-date <YYYY-MM-DD> --end-date <YYYY-MM-DD> [--templates <t1,t2...>] [--limit <n>] [--out <file.xlsx>] [--corp <corpId>]"],
options: [
{ flag: "--start-date <YYYY-MM-DD>", description: "Statistics start date, YYYY-MM-DD (e.g. 2026-08-12)" },
{ flag: "--end-date <YYYY-MM-DD>", description: "Statistics end date, YYYY-MM-DD (e.g. 2026-09-18)" },
@@ -633,20 +633,20 @@ export const HELP_REGISTRY: AreaHelp[] = [
{ flag: "--ledger <file>", description: "Inspect or convert an existing ledger file" },
{ flag: "--out <file>", description: "Output path (.xlsx or .csv); defaults to 台账-<corpId>-<period>.xlsx" },
{ flag: "--format <xlsx|csv>", description: "Export format (default: xlsx, or inferred from --out)" },
{ flag: "--max-runs <n>", description: "Cap approval-run fetch, default 500" }
{ flag: "--limit <n>", description: "Cap approval-run fetch (alias: --max-runs, default: all records in period, max 100000)" }
],
description: "Exports full audit ledger containing recordId, SN, template, AI decisions, full AI opinions & conditions, human results & comments, agreement, and review verdict columns. Agents can freely trim rows/templates and fill verdicts."
},
{
name: "data",
summary: "Extract pure structured report data, metrics, diverged runs, and triggers without templates",
usage: ["seal-use report data (--ledger <台账.xlsx> | --start-date <YYYY-MM-DD> --end-date <YYYY-MM-DD>) [--templates <t1,t2...>] [--max-runs <n>] [--corp <corpId>]"],
usage: ["seal-use report data (--ledger <台账.xlsx> | --start-date <YYYY-MM-DD> --end-date <YYYY-MM-DD>) [--templates <t1,t2...>] [--limit <n>] [--corp <corpId>]"],
options: [
{ flag: "--start-date <YYYY-MM-DD>", description: "Statistics start date, YYYY-MM-DD" },
{ flag: "--end-date <YYYY-MM-DD>", description: "Statistics end date, YYYY-MM-DD" },
{ flag: "--ledger <file>", description: "Directly parse an edited Excel/CSV ledger file without remote requests" },
{ flag: "--templates <names>", description: "Comma-separated template whitelist" },
{ flag: "--max-runs <n>", description: "Cap approval-run detail fetch, default 500 (max 500)" }
{ flag: "--limit <n>", description: "Cap approval-run detail fetch (alias: --max-runs, default: all records in period, max 100000)" }
],
description: "Template-free data pack for Agent authoring: returns performance metrics, formula fractions, template groups, top risk tags, diverged runs with exact triggered conditions, and reviews."
},
@@ -675,7 +675,7 @@ export const HELP_REGISTRY: AreaHelp[] = [
name: "generate",
aliases: ["monthly", "month"],
summary: "Fill the audit report template with performance, risk, and approval-run data",
usage: ["seal-use report generate (--ledger <台账.xlsx> | --start-date <YYYY-MM-DD> --end-date <YYYY-MM-DD>) [--templates <t1,t2...>] [--out <报告.md>] [--template <file>] [--report-id <RPT-...>] [--max-runs <n>] [--allow-unreviewed] [--corp <corpId>]"],
usage: ["seal-use report generate (--ledger <台账.xlsx> | --start-date <YYYY-MM-DD> --end-date <YYYY-MM-DD>) [--templates <t1,t2...>] [--out <报告.md>] [--template <file>] [--report-id <RPT-...>] [--limit <n>] [--allow-unreviewed] [--corp <corpId>]"],
options: [
{ flag: "--start-date <YYYY-MM-DD>", description: "Statistics start date, YYYY-MM-DD (e.g. 2026-08-12)" },
{ flag: "--end-date <YYYY-MM-DD>", description: "Statistics end date, YYYY-MM-DD (e.g. 2026-09-18)" },
@@ -685,7 +685,7 @@ export const HELP_REGISTRY: AreaHelp[] = [
{ flag: "--out <file>", description: "Save Markdown plus local images and Excel/CSV ledgers beside the report; stdout stays JSON" },
{ flag: "--overwrite", description: "Explicitly permit replacing existing output files" },
{ flag: "--report-id <RPT-...>", description: "Custom report id; defaults to RPT-<dateTag>-<random>" },
{ flag: "--max-runs <n>", description: "Cap approval-run detail fetch, default 500 (max 500)" },
{ flag: "--limit <n>", description: "Cap approval-run detail fetch (alias: --max-runs, default: all records in period, max 100000)" },
{ flag: "--allow-unreviewed", description: "Bypass pre-flight adjudication gate to generate draft when unreviewed diverged runs exist" }
],
description: "The template is the mutable skin: section headings, tables, and order may change and data demands are inferred from headings. Supports direct ledger-driven generation where user/Agent modifications to templates and rows are strictly respected."
@@ -1275,6 +1275,12 @@ describe("sealCapabilities", () => {
expect(rangeRes.period.start).toBe("2026-08-12");
expect(rangeRes.period.end).toBe("2026-09-18");
expect(rangeRes.templateGroups[0]?.template).toBe("差旅报销");
// 验证 maxRuns 突破了原本的 500 限制,传入 2000 校验合法
expect(() => tool!.parameters.parse({ month: "2026-08", maxRuns: 2000 })).not.toThrow();
const monthlyTool = sealCapabilities.find((item) => item.name === "sealReportMonthlyGet");
expect(monthlyTool).toBeDefined();
expect(() => monthlyTool!.parameters.parse({ month: "2026-08", maxRuns: 2000 })).not.toThrow();
});
test("deploy hosecloud configure saves integration and rejects missing customApiUrl", async () => {
+4 -4
View File
@@ -36,9 +36,9 @@ export const reportCapabilities = [
.number()
.int()
.positive()
.max(500)
.max(100000)
.optional()
.describe("拉取审批运行明细分块的上限,默认 500"),
.describe("拉取审批运行明细分块的上限(可选,未指定时默认拉取指定时间区间内的全量单据,最大安全上限 100000)"),
allowUnreviewed: z
.boolean()
.optional()
@@ -102,9 +102,9 @@ export const reportCapabilities = [
.number()
.int()
.positive()
.max(500)
.max(100000)
.optional()
.describe("拉取审批运行明细分块的上限,默认 500")
.describe("拉取审批运行明细分块的上限(可选,未指定时默认拉取指定时间区间内的全量单据,最大安全上限 100000)")
}),
handler: async (
client: KyInstance,
+10 -5
View File
@@ -95,7 +95,7 @@ export type CollectOptions = {
corp: { id: string; name: string };
/** 单据模板白名单,未指定则拉取全量模板 */
templates?: string[];
/** 用于拉明细分块的上限,防御性封顶 */
/** 用于拉明细分块的上限(可选,未指定时默认拉取指定时间区间全量单据,最大安全上限 100000) */
maxRuns?: number;
/** 是否载入本地人工裁决(默认载入);关掉则 humanAccuracy 恒为不可得 */
loadReviews?: boolean;
@@ -165,6 +165,9 @@ export function resolveReportPeriod(options: {
throw validationError("缺少统计起止时间:请指定 startDate 和 endDate(如 2026-08-12 至 2026-09-18)");
}
/** 默认明细拉取安全兜底上限(100,000 笔),未指定限制时默认拉取全区间单据 */
export const DEFAULT_MAX_REPORT_RUNS = 100_000;
/** 拉取报告所需数据。只取 demand 需要的部分,模板没提到的章节不发请求。 */
export async function collectReportData(
client: KyInstance,
@@ -172,7 +175,7 @@ export async function collectReportData(
options: CollectOptions
): Promise<ReportData> {
const range = resolveReportPeriod(options);
const maxRuns = Math.min(options.maxRuns ?? 500, 500);
const maxRuns = options.maxRuns ?? DEFAULT_MAX_REPORT_RUNS;
const fetched: Record<ReportDemand, boolean> = {
performance: false,
riskStats: false,
@@ -254,17 +257,19 @@ export async function collectReportData(
let offset = 0;
try {
while (runs.length < maxRuns) {
const fetchLimit = Math.min(100, maxRuns - runs.length);
const page = await api.listApprovalRuns(client, {
offset,
limit: 100,
limit: fetchLimit,
startDate: range.startDate,
endDate: range.endDate
});
const records = page.records ?? [];
if (!records.length) break;
runs.push(...records);
const toTake = records.slice(0, maxRuns - runs.length);
runs.push(...toTake);
offset += records.length;
if (records.length < 100) break;
if (records.length < fetchLimit || runs.length >= maxRuns) break;
}
let blocks: ReportBlock[] = runs.map((record) => {
+10 -2
View File
@@ -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,
@@ -353,6 +353,65 @@ describe("review store + human accuracy join", () => {
const xlsx = await buildReportLedgerXlsx(data);
expect(xlsx.byteLength).toBeGreaterThan(1000);
});
test("fetches over 500 records across pages without being clamped when maxRuns is omitted", async () => {
// 模拟服务端有 650 条记录(7 页:6 页 100 条 + 1 页 50 条)
const totalRecords = 650;
const fakeClient = {
get: async (_url: string, opts?: { searchParams?: URLSearchParams }) => {
const offset = Number(opts?.searchParams?.get("offset") ?? 0);
const limit = Number(opts?.searchParams?.get("limit") ?? 100);
const count = Math.max(0, Math.min(limit, totalRecords - offset));
const records = Array.from({ length: count }, (_, i) => ({
id: `run-${offset + i}`,
sourceDocumentSN: `SN-${offset + i}`,
result: { decision: "同意" },
pipelineData: { humanResult: "同意" }
}));
return {
json: async () => ({ data: { records, total: totalRecords } })
};
}
} as never;
const data = await collectReportData(fakeClient, new Set(["blocks"]), {
month: "2026-08",
corp: { id: "corp-a", name: "A" }
});
// 验证突破了原本的 500 条限制,全部 650 条完整拉出
expect(data.blocks).toHaveLength(650);
});
test("respects explicit maxRuns limit and slices precisely across pages", async () => {
const totalRecords = 500;
const fakeClient = {
get: async (_url: string, opts?: { searchParams?: URLSearchParams }) => {
const offset = Number(opts?.searchParams?.get("offset") ?? 0);
const limit = Number(opts?.searchParams?.get("limit") ?? 100);
const count = Math.max(0, Math.min(limit, totalRecords - offset));
const records = Array.from({ length: count }, (_, i) => ({
id: `run-${offset + i}`,
sourceDocumentSN: `SN-${offset + i}`,
result: { decision: "同意" },
pipelineData: { humanResult: "同意" }
}));
return {
json: async () => ({ data: { records, total: totalRecords } })
};
}
} as never;
const data = await collectReportData(fakeClient, new Set(["blocks"]), {
month: "2026-08",
corp: { id: "corp-a", name: "A" },
maxRuns: 150
});
expect(data.blocks).toHaveLength(150);
expect(data.blocks[0]?.sn).toBe("SN-0");
expect(data.blocks[149]?.sn).toBe("SN-149");
});
});
describe("getMonthlyReportData", () => {
@@ -433,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: "驳回" } }