bpmax-cli 0.2.1-beta.1 → 0.2.1-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. package/README.md +28 -1
  2. package/dist/bin.js +1367 -255
  3. package/dist/bin.js.map +1 -1
  4. package/package.json +1 -1
  5. package/skills/bpmax-ai-taskbook/SKILL.md +5 -1
  6. package/skills/bpmax-approval-matrix/SKILL.md +4 -1
  7. package/skills/bpmax-blueprint-doc-workflow/SKILL.md +87 -0
  8. package/skills/bpmax-blueprint-doc-workflow/agents/openai.yaml +4 -0
  9. package/skills/bpmax-blueprint-doc-workflow/references/blueprint-structure.md +60 -0
  10. package/skills/bpmax-blueprint-doc-workflow/references/per-flow-required-structure.md +98 -0
  11. package/skills/bpmax-blueprint-doc-workflow/references/sample-forbidden-term.xml +12 -0
  12. package/skills/bpmax-blueprint-doc-workflow/references/sample-mermaid-codeblock.xml +12 -0
  13. package/skills/bpmax-blueprint-doc-workflow/references/sample-missing-boundary.xml +10 -0
  14. package/skills/bpmax-blueprint-doc-workflow/references/sample-missing-whiteboard.xml +10 -0
  15. package/skills/bpmax-blueprint-doc-workflow/references/sample-pass.xml +55 -0
  16. package/skills/bpmax-blueprint-doc-workflow/scripts/lint_blueprint_doc.py +257 -0
  17. package/skills/bpmax-dataset-field-template-editor/SKILL.md +6 -3
  18. package/skills/bpmax-dataset-template-editor/SKILL.md +12 -2
  19. package/skills/bpmax-e2e-flow-config-orchestrator/SKILL.md +25 -1
  20. package/skills/bpmax-e2e-flow-test-operator/SKILL.md +13 -0
  21. package/skills/bpmax-e2e-flow-test-operator/references/ai-test-suite.md +25 -3
  22. package/skills/bpmax-flow-template-editor/SKILL.md +67 -5
  23. package/skills/bpmax-form-template-editor/SKILL.md +47 -0
@@ -0,0 +1,257 @@
1
+ #!/usr/bin/env python3
2
+ """Lint BPMAX blueprint Feishu Docx fetch output or XML.
3
+
4
+ The checker is intentionally structural. It does not try to prove business
5
+ correctness; it blocks the recurring blueprint failures that make a document
6
+ unusable for BPMAX implementation.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import argparse
12
+ import json
13
+ import re
14
+ import sys
15
+ from dataclasses import dataclass, field
16
+ from pathlib import Path
17
+ from typing import Iterable
18
+
19
+
20
+ DEFAULT_FORBID_TERMS = ["TODO", "待补充", "略", "后续完善", "代码块流程图"]
21
+ DEFAULT_REQUIRED_TERMS = [
22
+ "BPMAX 配置可实现",
23
+ "配置 + 脚本/API/现有插件",
24
+ "需定制插件/外部服务",
25
+ ]
26
+ CORE_CHAPTER_TERMS = [
27
+ "蓝图定位与目标",
28
+ "BPMAX 实施总规则",
29
+ "总体业务架构",
30
+ "公共支撑配置",
31
+ "实现边界",
32
+ ]
33
+ ACCEPTANCE_TERMS = ["验收", "风险", "待确认"]
34
+ FLOW_REQUIRED_TERMS = {
35
+ "业务目标与适用场景": ["业务目标与适用场景"],
36
+ "流程模板": ["流程模板"],
37
+ "开始节点": ["开始节点", "开始:", "创建"],
38
+ "创建表单": ["创建表单", "创建环节", "创建申请", "创建或导入", "初始表单"],
39
+ "环节配置": ["环节配置", "环节", "节点配置"],
40
+ "表单模板": ["表单模板", "字段"],
41
+ "流程数据集": ["流程数据集", "数据集", "写回"],
42
+ "视图入口": ["列表", "筛选", "详情", "看板", "入口", "视图"],
43
+ "自动化与 AI/agent": ["自动化", "AI", "agent", "Agent"],
44
+ "办结口径与下游联动": ["办结", "下游联动", "归档", "完成条件"],
45
+ "BPMAX 实现边界": DEFAULT_REQUIRED_TERMS,
46
+ }
47
+ AI_REQUIRED_TERMS = ["触发", "输入", "输出", "人工确认", "异常兜底"]
48
+ AI_FORBIDDEN_PATTERNS = [
49
+ r"AI[^。;\n]{0,30}自动(?:最终)?确认",
50
+ r"AI[^。;\n]{0,30}自动通过",
51
+ r"AI[^。;\n]{0,30}自动结案",
52
+ r"AI[^。;\n]{0,30}自动认证",
53
+ r"AI[^。;\n]{0,30}自动对账",
54
+ ]
55
+
56
+
57
+ @dataclass
58
+ class Finding:
59
+ level: str
60
+ code: str
61
+ message: str
62
+ flow: str | None = None
63
+
64
+
65
+ @dataclass
66
+ class FlowSection:
67
+ title: str
68
+ content: str
69
+ whiteboards: int = 0
70
+ mermaid_code_blocks: int = 0
71
+ missing: list[str] = field(default_factory=list)
72
+
73
+
74
+ def read_content(path: Path) -> str:
75
+ raw = path.read_text(encoding="utf-8")
76
+ stripped = raw.lstrip()
77
+ if stripped.startswith("{"):
78
+ data = json.loads(raw)
79
+ try:
80
+ return data["data"]["document"]["content"]
81
+ except KeyError as exc:
82
+ raise SystemExit(f"JSON input does not look like lark-cli docs +fetch output: missing {exc}") from exc
83
+ return raw
84
+
85
+
86
+ def plain_text(xml: str) -> str:
87
+ text = re.sub(r"<[^>]+>", " ", xml)
88
+ text = text.replace("&lt;", "<").replace("&gt;", ">").replace("&amp;", "&")
89
+ return re.sub(r"\s+", " ", text)
90
+
91
+
92
+ def has_any(text: str, terms: Iterable[str]) -> bool:
93
+ return any(term in text for term in terms)
94
+
95
+
96
+ def contains_forbidden_term(text: str, term: str) -> bool:
97
+ if term == "略":
98
+ return bool(re.search(r"(?<![\u4e00-\u9fffA-Za-z0-9])略(?![\u4e00-\u9fffA-Za-z0-9])", text))
99
+ return term in text
100
+
101
+
102
+ def has_ai_final_decision_violation(text: str, pattern: str) -> bool:
103
+ for match in re.finditer(pattern, text):
104
+ snippet = match.group(0)
105
+ if any(negation in snippet for negation in ["不自动", "不能", "不得", "不会", "不可", "不直接"]):
106
+ continue
107
+ return True
108
+ return False
109
+
110
+
111
+ def extract_title(xml: str) -> str:
112
+ match = re.search(r"<title(?:\s[^>]*)?>(.*?)</title>", xml, re.S)
113
+ return plain_text(match.group(1)).strip() if match else ""
114
+
115
+
116
+ def extract_flows(xml: str) -> list[FlowSection]:
117
+ heading_re = re.compile(r"<h([1-3])[^>]*>(.*?)</h\1>", re.S)
118
+ matches = list(heading_re.finditer(xml))
119
+ flow_matches = []
120
+ for match in matches:
121
+ title = plain_text(match.group(2)).strip()
122
+ if re.search(r"流程[一二三四五六七八九十\d]+[::]", title):
123
+ flow_matches.append((match, title))
124
+
125
+ flows = []
126
+ for index, (match, title) in enumerate(flow_matches):
127
+ start = match.start()
128
+ end = flow_matches[index + 1][0].start() if index + 1 < len(flow_matches) else len(xml)
129
+ content = xml[start:end]
130
+ flows.append(
131
+ FlowSection(
132
+ title=title,
133
+ content=content,
134
+ whiteboards=len(re.findall(r"<whiteboard\b", content)),
135
+ mermaid_code_blocks=len(re.findall(r"<pre[^>]*lang=[\"']mermaid[\"']", content, re.I)),
136
+ )
137
+ )
138
+ return flows
139
+
140
+
141
+ def add_error(findings: list[Finding], code: str, message: str, flow: str | None = None) -> None:
142
+ findings.append(Finding("error", code, message, flow))
143
+
144
+
145
+ def lint(xml: str, require_terms: list[str], forbid_terms: list[str]) -> tuple[list[Finding], list[FlowSection]]:
146
+ findings: list[Finding] = []
147
+ text = plain_text(xml)
148
+
149
+ if not extract_title(xml):
150
+ add_error(findings, "DOC_TITLE_MISSING", "Document must contain a <title> block.")
151
+
152
+ for term in CORE_CHAPTER_TERMS:
153
+ if term not in text:
154
+ add_error(findings, "DOC_CORE_CHAPTER_MISSING", f"Missing core blueprint chapter term: {term}")
155
+ if not any(term in text for term in ACCEPTANCE_TERMS):
156
+ add_error(findings, "DOC_ACCEPTANCE_MISSING", "Missing acceptance/risk/confirmation chapter wording.")
157
+
158
+ for term in require_terms:
159
+ if term not in text:
160
+ add_error(findings, "REQUIRED_TERM_MISSING", f"Required term not found: {term}")
161
+
162
+ for term in forbid_terms:
163
+ if contains_forbidden_term(text, term):
164
+ add_error(findings, "FORBIDDEN_TERM_PRESENT", f"Forbidden term found: {term}")
165
+
166
+ for pattern in AI_FORBIDDEN_PATTERNS:
167
+ if has_ai_final_decision_violation(text, pattern):
168
+ add_error(findings, "AI_AUTO_FINAL_DECISION", f"AI final-decision wording matched pattern: {pattern}")
169
+
170
+ if re.search(r"<pre[^>]*lang=[\"']mermaid[\"']", xml, re.I):
171
+ add_error(findings, "MERMAID_CODE_BLOCK", "Final blueprint must use whiteboard blocks, not Mermaid code blocks.")
172
+
173
+ flows = extract_flows(xml)
174
+ if not flows:
175
+ add_error(findings, "FLOW_SECTION_MISSING", "No flow sections matching 流程X: were found.")
176
+
177
+ for flow in flows:
178
+ flow_text = plain_text(flow.content)
179
+ if flow.whiteboards < 1:
180
+ add_error(findings, "FLOW_WHITEBOARD_MISSING", "Flow section has no <whiteboard> diagram.", flow.title)
181
+ flow.missing.append("whiteboard")
182
+ if flow.mermaid_code_blocks:
183
+ add_error(findings, "FLOW_MERMAID_CODE_BLOCK", "Flow section contains Mermaid code block.", flow.title)
184
+ flow.missing.append("no mermaid code block")
185
+
186
+ for label, terms in FLOW_REQUIRED_TERMS.items():
187
+ if not has_any(flow_text, terms):
188
+ add_error(findings, "FLOW_REQUIRED_CONTENT_MISSING", f"Missing per-flow content: {label}", flow.title)
189
+ flow.missing.append(label)
190
+
191
+ if "AI" in flow_text or "agent" in flow_text or "Agent" in flow_text:
192
+ for term in AI_REQUIRED_TERMS:
193
+ if term not in flow_text:
194
+ add_error(findings, "FLOW_AI_DETAIL_MISSING", f"AI/agent section missing term: {term}", flow.title)
195
+ flow.missing.append(f"AI {term}")
196
+
197
+ return findings, flows
198
+
199
+
200
+ def build_report(findings: list[Finding], flows: list[FlowSection], source: Path) -> dict:
201
+ errors = [f for f in findings if f.level == "error"]
202
+ return {
203
+ "ok": not errors,
204
+ "source": str(source),
205
+ "error_count": len(errors),
206
+ "flow_count": len(flows),
207
+ "flows": [
208
+ {
209
+ "title": flow.title,
210
+ "whiteboards": flow.whiteboards,
211
+ "mermaid_code_blocks": flow.mermaid_code_blocks,
212
+ "missing": flow.missing,
213
+ }
214
+ for flow in flows
215
+ ],
216
+ "findings": [finding.__dict__ for finding in findings],
217
+ }
218
+
219
+
220
+ def main() -> int:
221
+ parser = argparse.ArgumentParser(description="Lint BPMAX blueprint Feishu Docx content.")
222
+ parser.add_argument("--source", required=True, help="Path to lark-cli fetch JSON output or XML content.")
223
+ parser.add_argument("--json-report", help="Optional path to write a JSON lint report.")
224
+ parser.add_argument("--require-term", action="append", default=[], help="Additional required term. Repeatable.")
225
+ parser.add_argument("--forbid-term", action="append", default=[], help="Additional forbidden term. Repeatable.")
226
+ args = parser.parse_args()
227
+
228
+ source = Path(args.source)
229
+ xml = read_content(source)
230
+ require_terms = DEFAULT_REQUIRED_TERMS + args.require_term
231
+ forbid_terms = DEFAULT_FORBID_TERMS + args.forbid_term
232
+ findings, flows = lint(xml, require_terms, forbid_terms)
233
+ report = build_report(findings, flows, source)
234
+
235
+ if args.json_report:
236
+ Path(args.json_report).write_text(json.dumps(report, ensure_ascii=False, indent=2), encoding="utf-8")
237
+
238
+ status = "PASS" if report["ok"] else "FAIL"
239
+ print(f"BPMAX blueprint lint: {status}")
240
+ print(f"Source: {source}")
241
+ print(f"Flows: {report['flow_count']}")
242
+ for flow in report["flows"]:
243
+ missing = ", ".join(flow["missing"]) if flow["missing"] else "none"
244
+ print(f"- {flow['title']}: whiteboards={flow['whiteboards']}, missing={missing}")
245
+ if report["findings"]:
246
+ print("Findings:")
247
+ for finding in report["findings"]:
248
+ prefix = f"[{finding['level']}] {finding['code']}"
249
+ if finding.get("flow"):
250
+ prefix += f" ({finding['flow']})"
251
+ print(f"- {prefix}: {finding['message']}")
252
+
253
+ return 0 if report["ok"] else 1
254
+
255
+
256
+ if __name__ == "__main__":
257
+ sys.exit(main())
@@ -404,6 +404,8 @@ return JSON.parse(ctx.value);
404
404
 
405
405
  ### 7. 提交与回读
406
406
  - 当前版本 `dataset-field` adapter 支持编辑、新建和删除单个字段。复制或批量生成字段必须拆分成可审查的单字段 work 文件、lint 结果和 submit payload,再通过 typed CLI 的 create/submit/delete 路径逐项执行;尚未提供批量快捷命令时,不得改用旧脚本直提。
407
+ - 新建字段提交前必须由 CLI 本地 preflight 阻断缺字段,不要把低质量 payload 打到服务端:`payload.flow_type`、`payload.data_set_id`、`payload.source_table`、`payload.source_field`、`payload.source_fk` 都必须非空。若报错出现这些 `payload.*` 路径,先修 work/meta,不要把服务端“流程类型不能为空/来源表不能为空”当成远端问题。
408
+ - 批量 runner 或脚本包装 typed create 时,必须按“逐条独立状态”执行:每个字段单独记录 `field_key`、`work_file`、`submit_file`、`response_file`、`status`、`error`、`created_id`;支持 `--continue-on-error` 或等价策略继续处理后续 ready 字段,最后统一返回失败并保留成功/失败清单。不得因为第一条失败就丢失当前批次上下文。
407
409
 
408
410
  - 旧 `submit_dataset_field.py` 只保留为结构参考,默认会硬失败;不得用它直写线上字段配置。
409
411
  - 只有满足以下条件才允许真正执行提交请求:
@@ -413,8 +415,8 @@ return JSON.parse(ctx.value);
413
415
  - `submitBuiltAt` 不早于最近一次 `workConfirmedAt`
414
416
  - 只要 `work/<id>.json` 或 `submit/<id>.json` 被改动,已有确认默认失效,需要重新确认。
415
417
  - 提交接口:
416
- - 新建:暂未开放 typed CLI
417
- - 编辑:`PUT /bpmax/data-set-field/:id`
418
+ - 新建:`bpmax-cli config dataset-field create --id create:dataset-field --payload <submit.json> --confirm "submit dataset-field create:dataset-field" --response-out <response.json>`
419
+ - 编辑:`bpmax-cli config dataset-field submit --id <id> --payload <submit.json> --confirm "submit dataset-field <id>" --response-out <response.json>`
418
420
  - 新建字段提交成功后,脚本必须先从响应里提取真实字段 `id`,回填到 `meta/<artifact-id>.json`,然后再执行 `GET /bpmax/data-set-field/:id` 做回读验证。
419
421
  - 提交脚本会输出:
420
422
  - `result/<id>.response.json`:提交响应
@@ -592,7 +594,8 @@ bpmax-cli config dataset-field export --id <id> --out .codex/tmp/dataset-field-e
592
594
  bpmax-cli config dataset-field lint --work .codex/tmp/dataset-field-editor/work/<file>.json
593
595
  bpmax-cli config dataset-field build --work .codex/tmp/dataset-field-editor/work/<file>.json --meta .codex/tmp/dataset-field-editor/meta/<file>.meta.json --out .codex/tmp/dataset-field-editor/submit/<file>.json
594
596
  bpmax-cli config dataset-field submit --id <id> --payload .codex/tmp/dataset-field-editor/submit/<file>.json
595
- bpmax-cli config dataset-field submit --id <id> --payload .codex/tmp/dataset-field-editor/submit/<file>.json --confirm "submit dataset-field <id>"
597
+ bpmax-cli config dataset-field submit --id <id> --payload .codex/tmp/dataset-field-editor/submit/<file>.json --confirm "submit dataset-field <id>" --response-out .codex/tmp/dataset-field-editor/result/<file>.response.json
598
+ bpmax-cli config dataset-field create --id create:dataset-field --payload .codex/tmp/dataset-field-editor/submit/<create-file>.json --confirm "submit dataset-field create:dataset-field" --response-out .codex/tmp/dataset-field-editor/result/<create-file>.response.json
596
599
  bpmax-cli config dataset-field verify --id <id> --expect .codex/tmp/dataset-field-editor/work/<file>.json
597
600
  ```
598
601
 
@@ -7,7 +7,7 @@ description: "用于在 BPMAX 的数据集页面中创建、编辑、发布、
7
7
 
8
8
  ## 写入路径硬约束
9
9
  - 执行前必须先运行 `bpmax-cli config adapters --format json` 核对 `dataset`;只有 `build_status` 和 `submit_status` 都是 `supported` 时才允许进入 build/submit。当前 typed CLI 通过 huanpingtong `/api/data_set*` 代理访问 bpmax-server `/data-set*` 运行态接口;若 adapter 显示 `blocked`,只能导出、编辑 work、lint 和形成变更建议,不得提交。
10
- - 当前 bpmax-cli typed adapter 支持数据集的 `dataset export/lint/build/submit/verify`,编辑提交路径为 huanpingtong `/api/data_set/relationFields/:id`,新建提交路径为 huanpingtong `/api/data_set`,均代理到 bpmax-server 运行态接口。发布、暂停、取消刷新和索引刷新仍未纳入 typed adapter,不得把旧脚本、raw API、页面 fetch 当作替代提交路径。
10
+ - 当前 bpmax-cli typed adapter 支持数据集的 `dataset export/lint/build/submit/verify`,编辑提交路径为 huanpingtong `/api/data_set/relationFields/:id`,新建提交路径为 huanpingtong `/api/data_set`,均代理到 bpmax-server 运行态接口。relationFields 也可以用显式子命令 `bpmax-cli config dataset relation-fields submit/readback`。发布、暂停、取消刷新和索引刷新必须使用 `bpmax-cli config dataset publish|pause|cancel-refresh|refresh|reindex`,不得把旧脚本、raw API、页面 fetch 当作替代提交路径。
11
11
  - 旧来源脚本 `scripts/submit*.py` 只保留为结构参考,默认会硬失败;不得用它们直调 BPMAX API。
12
12
  - 不得用 `bpmax-cli api POST/PUT/DELETE /data_set*` 或其它 raw API 绕过 typed config submit。
13
13
 
@@ -54,7 +54,17 @@ description: "用于在 BPMAX 的数据集页面中创建、编辑、发布、
54
54
  - 浏览器实时线上页面、实时接口返回、当前页面真实请求体优先级高于本地仓库里的 `think_data_set` / `think_data_set_field` 镜像;本地配置只作为候选、检索和回放参考,不能覆盖线上事实。
55
55
  - 优先从真实页面和真实接口返回抽取 payload 骨架,不从零臆造。
56
56
  - 优先检索现有数据集,再决定是否新建;优先判断当前流程下是否已有同语义可复用数据集。
57
- - 当前默认走“线上详情导出到本地临时文件 -> 修改 work 文件 -> lint -> build submit -> 二次确认 -> typed CLI submit -> verify”。只有 `bpmax-cli config adapters` 显示 `dataset` 的 `build_status/submit_status` 为 `supported` 时,才允许进入提交闭环。
57
+ - 当前默认走“线上详情导出到本地临时文件 -> 修改 work 文件 -> lint -> build submit -> 二次确认 -> typed CLI submit -> verify/readback”。只有 `bpmax-cli config adapters` 显示 `dataset` 的 `build_status/submit_status` 为 `supported` 时,才允许进入提交闭环。
58
+ - 数据集 relationFields 编辑优先使用:
59
+
60
+ ```bash
61
+ bpmax-cli config dataset relation-fields submit --id <dataset_id> --payload <submit.json> --confirm "submit dataset <dataset_id>" --response-out <response.json> --format json
62
+ bpmax-cli config dataset relation-fields readback --id <dataset_id> --format json
63
+ ```
64
+
65
+ - 批量迁移多个数据集或字段时,优先生成 batch manifest 并使用 `bpmax-cli config batch submit/readback`。manifest 每行必须写 `domain`、`id`、`payload`、`confirm`、`response_out`;不要为每个字段临时写 collector 解析不同 response shape。
66
+ - 直接执行 typed submit/create 时,要读取响应顶层标准字段 `id`、`key`、`readback_hint`;如果还需要兼容旧字段,只能作为 fallback,不能把旧 response shape 当主路径。
67
+ - 通过 `bpmax-cli config batch submit/readback` 执行时,`response_out` 是行级 envelope:顶层读取 `ok`、`domain`、`id`、`action`,真实 typed 响应在 `response` 下,创建 ID 和回读提示读取 `response.id`、`response.key`、`response.readback_hint`。若某行停在 dry-run,必须把 `response.required_confirm` 写回 manifest 的 `confirm` 后重跑。
58
68
  - 提交前硬门禁:必须先跑数据集 lint;`basicTableAudit` blocker 或脚本位点里把 ES dataset 查询入口写成 `data_set_id` 时,直接阻断提交。
59
69
  - 脚本类查询默认口径:
60
70
  - 前端验数或调试样例默认优先 `raw-es-search`
@@ -38,10 +38,31 @@ description: "用于按 BPMAX 完整流程配置需求先调研、再出计划
38
38
 
39
39
  ```bash
40
40
  bpmax-cli config flow-app create --workspace <workspace> --form-work <form-work-file> --flow-work <flow-work-file> --name <name>
41
- bpmax-cli config flow-app create --workspace <workspace> --form-work <form-work-file> --flow-work <flow-work-file> --name <name> --confirm "create flow-app <name> in <workspace>"
41
+ bpmax-cli config flow-app create --workspace <workspace> --form-work <form-work-file> --flow-work <flow-work-file> --name <name> --confirm "create flow-app <name> in <workspace>" --evidence-out .codex/tmp/target-context.csv --response-out .codex/tmp/flow-app-create.response.json
42
42
  ```
43
43
 
44
44
  - `flow-app create` 的 dry-run 必须展示完整 operation plan:创建表单、发布表单、创建流程壳、绑定 `data.meta.form_template=<published_id>`、保存/发布流程、绑定工作区、回读验证。缺任何关键步骤都不得确认执行。
45
+ - 确认文本不得猜:dry-run JSON 必须包含 `required_confirm`,真实执行时直接复制该值;若确认文本不匹配,必须视为失败,不得把 dry-run JSON 当成功结果。
46
+ - 确认执行必须同时保留 `--response-out` 和 `--evidence-out`:前者保存完整响应、created IDs 和恢复上下文,后者保存给后续配置面复用的 target context。不得只保留 shell 重定向输出。
47
+ - 新建或迁移流程进入 dataset/list/filter/nav 任一后续阶段前,必须先取得 target context evidence:
48
+
49
+ ```bash
50
+ bpmax-cli config flow-app context --workspace <workspace> --flow <flow_type_or_key_or_name> --evidence-out .codex/tmp/target-context.csv --format json
51
+ bpmax-cli config readback flow-template --id <flow_type> --format json
52
+ bpmax-cli config readback form-template --id <form_template_id> --format json
53
+ ```
54
+
55
+ - 迁移工具只读回收证据统一使用 `bpmax-cli config readback <domain> --id <id> --format json`,不要生成 `bpmax-cli api GET ...` 或按 domain 手写 export/readback 差异。
56
+ - 批量提交或批量回读必须优先使用 batch manifest:
57
+
58
+ ```bash
59
+ bpmax-cli config batch submit --manifest .codex/tmp/config-batch.json --continue-on-error --format json
60
+ bpmax-cli config batch readback --manifest .codex/tmp/config-readback-batch.json --continue-on-error --format json
61
+ ```
62
+
63
+ - batch manifest 每行必须保留 `domain`、`id`、`payload`(submit 时)、`confirm` 和 `response_out`;失败项要进入最终 summary,不能因为一条失败丢失前面成功项和剩余待处理项。
64
+ - `target_context.evidence_status` 必须是 `verified`,且 `missing_context` 必须为空;否则停止在 target context 修复阶段,不得继续生成 dataset、列表、导航或 E2E 任务。
65
+ - `target-context.csv/json` 是后续迁移 apply-ready evidence:至少包含 `flow_type`、`flow_template_id`、`form_template_id`、`form_template_draft_id`、`workspace_key`、`workspace_readback_hash`。不得让 subagent 重新猜这些 ID。
45
66
  - `flow-app create` 的 flow work 必须预置表单驱动发起默认基线:隐藏 `project.name` / `project.brief` / `project.plan_end_time`,启用 `meta.use_template_project_name = true`,并提供非空 `meta.project_name_template`。这是 typed CLI 写入前 gate,不是可选建议。
46
67
  - 工作区绑定必须走 `PUT /workspace/workspace_flow` typed adapter,并在 `/workspace/by_key?key=<workspace>` 回读中确认新 `(flow_type, flow_key)` 存在。回读失败时不能宣布创建成功。
47
68
  - 若用户选择“完整流程配置”,默认依次评估:
@@ -125,6 +146,8 @@ bpmax-cli taskbook lint-prompt --prompt-source .codex/tmp/TASK_PROMPT.md
125
146
  - 如果用户要求“没有就新建”,计划中必须显式写出:
126
147
  - 是否先检索并复用已有表单/流程
127
148
  - 若没有可复用对象,是否使用 `flow-app create`
149
+ - 是否会执行 `bpmax-cli config flow-app context --workspace <workspace> --flow <flow> --evidence-out ...`
150
+ - `evidence_status=verified` 后才允许进入 dataset/list/filter/nav 配置
128
151
  - 目标工作区绑定是否属于本次 `requested` 或 `required-collateral`
129
152
  - 是否需要导航入口;没有明确要求菜单入口时,不默认写 nav-config
130
153
 
@@ -170,6 +193,7 @@ bpmax-cli taskbook lint-prompt --prompt-source .codex/tmp/TASK_PROMPT.md
170
193
  - 若流程或表单需求依赖控件能力判断,先用 [$form-control-library](../form-control-library/SKILL.md)。
171
194
  - 若某一步要求浏览器已打开特定页面,而当前页面不对,必须先让用户打开到正确页面,不要盲目继续。
172
195
  - `flow-app create` 完成后,必须再执行工作区视角的只读验证:
196
+ - `bpmax-cli config flow-app context --workspace <workspace> --flow <flow_type> --evidence-out .codex/tmp/target-context.csv --format json`
173
197
  - `bpmax-cli flow list --workspace <workspace> --format json`
174
198
  - 结果中应能看到新建流程
175
199
  - 打开目标工作区创建页确认表单加载
@@ -161,12 +161,18 @@ bpmax-cli e2e cache refresh --flow-id <flow_id> --profile <profile> --format jso
161
161
  - `unresolved.P0` 和 `unresolved.P1` 必须都是 `0`。
162
162
  - `cases.csv` 字段必须固定为:`case_id,priority,type,title,preconditions,config_basis,prep_data,steps,expected_result,test_data,roles,evidence_required,tags,status,updated_at`。
163
163
  - `config_basis` 必须指向真实存在的配置或能力依据,并说明覆盖原因。配置仓库使用 `think_*`、`.ai_test/`、`.codex/skills/`;`bpmax-cli` 包内能力可引用 `skills/`。
164
+ - 每条正式 E2E 用例的 `prep_data` 必须包含执行前置证据:`precondition_check=`、`browser_tool=`、`live_draft=`、`state_file=` 或 `report_run=`。没有 `precondition_check` 记录时,只能进入准备阶段,不能写正式执行结论。
165
+ - 用例内容必须可读,`title`、`preconditions`、`config_basis`、`prep_data`、`steps`、`expected_result`、`test_data` 不得出现乱码、异常编码片段、`???`、`xxx`、`占位`、`待补`、`暂无`、`略` 这类空洞内容;`steps` 必须是可执行步骤,不得是一句泛泛备注。
166
+ - 负向、边界、异常、错误提示、扫码错误 SN 等用例必须在 `expected_result`、`steps` 或 `evidence_required` 中写明 `expected_error_text` 或 `error_capture_required`,并要求真实错误提示截图。没拿到提示文案时,结论写“提示文案未取到”,不要直接判业务失败。
167
+ - 涉及人工介入、手工补救、续跑、`dirty_resumed` 的用例,必须在 `prep_data` 或步骤中声明 `resume_policy=full_rerun|checkpoint|evidence_only`,并说明是从头重跑、检查点重跑还是仅补证据;局部续跑只能给局部结论。
168
+ - 多角色用例必须在 `prep_data`/`roles`/`evidence_required` 中记录 `login_profile`、`mock_user`、`unmock_done` 或 `bpmax-user-mock-operator`,并要求每个角色单独截图,不能复用一个角色的截图。
164
169
  - `test_data` 不是占位字段,必须说明客户真实业务场景和业务逻辑,且必须写成结构化 `key=value`:
165
170
  - `业务场景=`:说明客户实际会发生的业务动作或业务对象,例如客户换货、采购审批、库存调拨、费用报销。
166
171
  - `业务逻辑=`:说明这组数据为什么能验证流程逻辑,例如一退一发、金额分级审批、库存占用后释放、审批矩阵命中。
167
172
  - `样本数据=`:说明可复测样本的真实业务属性,不得写 `sample`、`test`、`mock`、`xxx`、`占位`、`待补`。
168
173
  - `合理性=`:说明这组样本为什么符合客户业务规则、权限边界、主数据关系或上下游约束。
169
174
  - `bpmax-cli test-suite lint` 会硬检查 `test_data` 是否包含 `业务场景=`、`业务逻辑=`、`样本数据=`、`合理性=`,且 `样本数据=` 不得是泛化占位值,不得包含 token、cookie、手机号、密码、Authorization 或完整 payload。
175
+ - `bpmax-cli test-suite lint` 还会硬检查前置证据、错误提示截图要求、人工介入续跑策略、多角色证据隔离和内容乱码/占位文本。新增 lint 文案使用中文说明,机器字段仍保持稳定英文 code/rule_id。
170
176
  - 如果 `test_data` 语义对齐失败,先运行 `bpmax-cli test-suite lint --explain ...`,再按 CLI 输出的 title/preconditions/steps/expected 关键词重写 `业务场景=`。不要为了过 lint 把无关业务词塞进 `test_data`。
171
177
  - 生成或更新用例必须先落到 `.ai_test/suite_draft/`,执行 lint 并向用户概要说明后,得到用户确认才允许 promote 到 `.ai_test/suite/`。
172
178
  - 从正式用例复制到草稿,或从草稿 promote 到正式用例时,如果目标场景目录已经存在,第一次 `--replace` 只生成 copy diff preview,不覆盖目标;必须审阅 diff 后第二次显式追加 `--diff-reviewed`。
@@ -187,6 +193,13 @@ bpmax-cli test-suite lint-report --root .ai_test/report
187
193
 
188
194
  `test-suite` 的 JSON 错误输出应使用稳定英文 `code/rule_id/path`,用户可见 `message/suggestion` 使用中文;普通文本输出也应可直接给实施人员阅读。
189
195
 
196
+ ### 报告完整性门禁
197
+ - 单次执行报告必须位于 `.ai_test/report/<YYYYMMDD-NNN>/`,截图必须位于同一 run 的 `screenshots/` 下;`.codex/docs/` 只放复盘、长周期总结或交付版文档,并引用 `run_id` 和原始报告路径。
198
+ - 场景报告必须写 `planned_cases:`、`executed_cases:`、`precondition_check:`、`state_file:`、`browser_tool:`。`planned_cases` 与 `executed_cases` 必须逐条对账;有未执行用例时只能写阶段/局部结论,不能写完整通过。
199
+ - 报告出现 `not run`、`未执行`、`跳过` 时,`result:` 必须降级为 `partial`、`stage`、`blocked` 或明确“阶段/局部/不完整”。没有用户确认缩小范围时,不得把跳过用例合并进完整结论。
200
+ - 没有合规浏览器工具或页面证据时,必须使用浏览器阻塞模板:`browser_status: blocked`,并写“页面结论停止”;不得用 API/readback 证据冒充页面验证。
201
+ - 报告里写“页面通过 / 浏览器回归完成 / 真实页面已验证 / 完整链路通过”时,必须同时有 `browser_tool:` 和本 run 的本地截图证据。
202
+
190
203
  ### 测试资产与真实页面回归边界
191
204
  - 更新 `.ai_test/suite_draft`、通过 lint、完成 review、promote 到 `.ai_test/suite`,只能证明“测试资产已更新”,不等于已经完成真实页面回归。
192
205
  - 真实页面回归必须另行记录:浏览器 URL、当前用户/模拟用户、关键操作、截图、项目 ID/step ID、接口或数据回读证据。
@@ -75,7 +75,7 @@ case_id,priority,type,title,preconditions,config_basis,prep_data,steps,expected_
75
75
  - `title`:短标题。
76
76
  - `preconditions`:前置数据和环境。
77
77
  - `config_basis`:每条用例依据的配置位置和覆盖原因,必须至少包含一个可定位位置,例如 `think_flow/...`、`think_form_template/...`、`think_data_set/...`、`think_data_set_field/...`、`think_flow_page_template/...`、`think_configuration/...`、`think_role/...`、`think_category/...`、`think_api_platform/...`、`think_api_proxy/...`、`think_workspace/...`、`.ai_test/...`、`skills/...` 或 `.codex/skills/...`,并说明为什么这条用例要覆盖该配置点。
78
- - `prep_data`:结构化前置数据准备,至少包含 `账号=`、`入口=`、`样本=`、`准备操作=`、`预期=`。
78
+ - `prep_data`:结构化前置数据准备,至少包含 `账号=`、`入口=`、`样本=`、`准备操作=`、`预期=`、`precondition_check=`、`browser_tool=`、`live_draft=`,并提供 `state_file=` 或 `report_run=`。
79
79
  - `steps`:可读步骤,用 ` > ` 分隔。
80
80
  - `expected_result`:明确可判定结果。
81
81
  - `test_data`:客户真实业务测试数据说明,不写 token、cookie、手机号、密码或完整 payload。必须使用英文分号分隔的 `key=value`,至少包含 `业务场景=`、`业务逻辑=`、`样本数据=`、`合理性=`。
@@ -89,7 +89,7 @@ case_id,priority,type,title,preconditions,config_basis,prep_data,steps,expected_
89
89
 
90
90
  ```csv
91
91
  case_id,priority,type,title,preconditions,config_basis,prep_data,steps,expected_result,test_data,roles,evidence_required,tags,status,updated_at
92
- C001,P0,positive,正常客户换货主链路,有可用旧机SN和新机库存,"think_flow/flow_type'flow451422190___key'___status'1___is_del'0/flow 校验主流程节点和审批链; think_data_set/.../data_set 覆盖库存联动落库依据","账号=store_staff,dealer_owner;入口=https://yaditest.yitaiyitai.com/w:store_mgr/project?flow_type=flow451422190;样本=新建换货样本;准备操作=确认旧机SN和新机库存可用并打开创建入口;预期=旧机SN和新机库存可被选择且审批人可达;主数据=旧机SN和新机库存",发起换货 > 填写旧机 > 填写新机 > 提交 > 审批通过,旧机入库,新机出库,项目终态正确,"业务场景=客户换货补录;业务逻辑=旧机SN应回收入库且新机库存应出库并进入审批链;样本数据=旧机SN为已售可回收库存,新机SN为当前门店可用库存;合理性=符合客户退换货业务中一退一发和经销商负责人审批逻辑",store_staff,dealer_owner,screenshot+project_detail,"core,inventory,approval",active,2026-06-18
92
+ C001,P0,positive,正常客户换货主链路,有可用旧机SN和新机库存,"think_flow/flow_type'flow451422190___key'___status'1___is_del'0/flow 校验主流程节点和审批链; think_data_set/.../data_set 覆盖库存联动落库依据","账号=store_staff,dealer_owner;入口=https://yaditest.yitaiyitai.com/w:store_mgr/project?flow_type=flow451422190;样本=新建换货样本;准备操作=确认旧机SN和新机库存可用并打开创建入口;预期=旧机SN和新机库存可被选择且审批人可达;主数据=旧机SN和新机库存;precondition_check=.codex/tmp/e2e_states/customer-exchange.json;browser_tool=Chrome DevTools;live_draft=live;state_file=.codex/tmp/e2e_states/customer-exchange.json;report_run=.ai_test/report/20260618-001;login_profile=store_staff,dealer_owner;mock_user=store_staff后切dealer_owner;unmock_done=测试结束恢复管理员",发起换货 > 填写旧机 > 填写新机 > 提交 > 审批通过,旧机入库,新机出库,项目终态正确,"业务场景=客户换货补录;业务逻辑=旧机SN应回收入库且新机库存应出库并进入审批链;样本数据=旧机SN为已售可回收库存,新机SN为当前门店可用库存;合理性=符合客户退换货业务中一退一发和经销商负责人审批逻辑",store_staff,dealer_owner,screenshot+project_detail+每个角色独立截图,"core,inventory,approval",active,2026-06-18
93
93
  ```
94
94
 
95
95
  ## latest gate
@@ -121,7 +121,11 @@ C001,P0,positive,正常客户换货主链路,有可用旧机SN和新机库存,"t
121
121
  ## 前置数据规则
122
122
 
123
123
  - `prep_data` 是执行前必须先完成的准备清单,不是备注。
124
- - 最少写明 `账号=`、`入口=`、`样本=`、`准备操作=`、`预期=`。
124
+ - 最少写明 `账号=`、`入口=`、`样本=`、`准备操作=`、`预期=`、`precondition_check=`、`browser_tool=`、`live_draft=`,并提供 `state_file=` 或 `report_run=`。
125
+ - `precondition_check=` 必须指向本轮执行前置检查记录;没有该记录时只能进入准备阶段,不能写正式执行结论。
126
+ - `browser_tool=` 必须写明真实页面通道,例如 `Chrome DevTools`、`Playwright` 或 `AppleScript fallback`;如果没有可用浏览器工具,报告必须走 browser blocked 模板。
127
+ - `live_draft=` 必须写清本轮测的是 `live` 发布态还是 `draft` 草稿态。
128
+ - `state_file=` 或 `report_run=` 必须能定位本轮状态/报告证据。
125
129
  - `准备操作=` 必须写正式执行步骤前要做的具体动作,例如打开入口、创建或搜索样本、确认主数据、确认权限、确认自动化发布状态。
126
130
  - `预期=` 必须写准备完成的可判定结果,例如样本可用、样本不存在、审批人可达、字段可选、自动生成的下游项目已存在。
127
131
  - 复杂业务应补 `主数据=`、`权限=`、`自动化=`、`依赖流程=`、`清理策略=`。
@@ -129,6 +133,10 @@ C001,P0,positive,正常客户换货主链路,有可用旧机SN和新机库存,"t
129
133
  - 当用例验证自动贯通、子流程或下游对象时,必须补 `定位规则=`,说明按列表 URL、`flow_type`、搜索字段、根项目关系或详情 URL 定位对象。
130
134
  - `prep_data` 用英文分号 `;` 分隔字段,每一段都必须是 `key=value`;同一字段内多个值用英文逗号 `,` 分隔。
131
135
  - 全流程自动贯通用例必须写清自动触发依据,不能用人工直接创建的下游项目冒充自动贯通。
136
+ - 负向、边界、异常、错误提示、扫码错误 SN 等用例必须写 `expected_error_text` 或 `error_capture_required`,并要求错误提示截图;没截到提示时写“提示文案未取到”,不要直接判业务失败。
137
+ - 人工介入、手工补救、续跑、`dirty_resumed` 用例必须写 `resume_policy=full_rerun|checkpoint|evidence_only`,并说明局部/完整结论边界。
138
+ - 多角色用例必须写 `login_profile`、`mock_user`、`unmock_done` 或 `bpmax-user-mock-operator`,并要求每个角色单独截图。
139
+ - 用例内容不得出现乱码、异常编码、`???`、`xxx`、`占位`、`待补`、`暂无`、`略` 等空洞文本;`steps` 必须是可执行步骤。
132
140
 
133
141
  ## 真实业务测试数据规则
134
142
 
@@ -300,6 +308,12 @@ source_suite: .ai_test/suite/customer-exchange-main-flow
300
308
  result: pass
301
309
  tested_at: 2026-06-18
302
310
 
311
+ planned_cases: C001,C002,C003
312
+ executed_cases: C001,C002,C003
313
+ precondition_check: .codex/tmp/e2e_states/customer-exchange.json
314
+ state_file: .codex/tmp/e2e_states/customer-exchange.json
315
+ browser_tool: Chrome DevTools
316
+
303
317
  ## 1. 测试范围
304
318
 
305
319
  ## 2. 执行环境
@@ -331,3 +345,11 @@ Codex 桌面本地预览优先使用截图的绝对本地路径,图片文件
331
345
  ```bash
332
346
  bpmax-cli test-suite lint-report --root .ai_test/report
333
347
  ```
348
+
349
+ 报告 lint 会硬检查:
350
+ - `planned_cases:` 和 `executed_cases:` 必须存在且逐条对账;planned 中未出现在 executed 的用例必须有 blocked/not run 原因,报告结论降级为阶段/局部。
351
+ - `precondition_check:`、`state_file:`、`browser_tool:` 必须存在。
352
+ - 页面/浏览器结论(页面通过、浏览器回归通过、完整链路通过)必须有 `browser_tool` 证据和截图;接口/回读证据不能冒充页面验证。
353
+ - 出现 `not run` 但 `result: pass` 的报告必须降级为 `partial` 或 `stage`。
354
+ - 浏览器 blocked 报告必须使用 `browser_status: blocked` 模板并停止页面结论。
355
+ - 报告中的乱码/空洞步骤会通过用例内容 lint 拦截。
@@ -61,6 +61,15 @@ export BPMAX_BASE_URL='https://<your-bpmax-host>'
61
61
  - 没有第二次确认,不得执行 `bpmax-cli config flow-template submit --confirm "submit flow-template <id>"`。
62
62
  - 最终配置只能通过 typed CLI submit 提交,不能在对话里手写最终请求体直接发接口;旧 `scripts/submit_flow_template.py` 只作结构参考,默认会硬失败。
63
63
  - 主流程 `flow_type` 必须来自平台 `POST /flow/flow_type` 返回值或已有远端对象回读,格式应为 `flow<number>`;不得把业务 key、测试 marker、语义名拼成 `flow_type`。语义标识只能放在 `data.meta.testMarker`、配置备注、测试 profile 或其它 metadata 中。
64
+ - 迁移、新建流程壳或需要把后续表单/数据集/列表绑定到同一目标流程时,必须先生成 target context evidence,不得让后续任务猜 ID:
65
+
66
+ ```bash
67
+ bpmax-cli config flow-app context --workspace <workspace> --flow <flow_type_or_key_or_name> --evidence-out .codex/tmp/target-context.csv --format json
68
+ bpmax-cli config readback flow-template --id <flow_type> --format json
69
+ bpmax-cli config readback form-template --id <form_template_id> --format json
70
+ ```
71
+
72
+ - `target_context.evidence_status` 必须为 `verified`,且 `missing_context` 为空,才允许继续修改节点表单引用、数据集、列表、详情模板或工作区绑定;上下文证据必须保留 `workspace_readback_hash`。若缺 `form_template_draft_id` 或 `workspace_binding`,先修上下文,不得把本地 UUID、发布态 ID 或旧 dry-run payload 带入后续提交。
64
73
  - 对 `beforeNextStepScript` / `step_transform` / `cc_user_by_script` / `meta.*` 脚本字段,禁止整段“重写生成”;必须先脚本抽取到独立 `.js` 文件后做局部修改。
65
74
  - 脚本抽取、单行化、回填都必须走脚本化步骤;禁止手工在 JSON 里做转义和拼接。
66
75
  - 脚本回填前,必须按统一可读模式处理:抽取到 `scripts/<stem>/`,局部修改,再去除换行和多余缩进(保留语义,不做不可读压缩 / 混淆),最后写回 `work/<stem>.json` 对应字段。
@@ -108,8 +117,38 @@ export BPMAX_BASE_URL='https://<your-bpmax-host>'
108
117
  - `meta.project_create_validator` 属于创建前后端校验脚本;创建成功后的自定义跳转必须配置 `meta.project_after_create_path`,它由前端创建页在创建成功后执行,返回 route path 后调用 `this.$router.push(path)`。这个脚本必须以 `return` 开头,例如 `return (function () { ... return path; })();`;不要把创建后跳转写到 `project_after_create_callback`。
109
118
  - 流程级或节点级的“附件要求”“超时催办”“公开触发”“回调跳转”“允许流转他人环节”等配置,即使这次需求没显式提到,也必须在差量编辑时保留,不允许因只关注节点拓扑而误清空。
110
119
  - “刷新”默认指流程编辑器页面内右上角的刷新按钮,不是浏览器整页刷新。
111
- - 若 `meta.condational_jump` 为空,开始节点默认流转到首个业务节点;不要为了普通单一路径起步去构造自定义跳转。
112
- - `meta.condational_jump` 只用于“根据表单内容或脚本条件决定起步去向”的场景,不用于普通开始到后续节点的直连。
120
+ - 若 `meta.condational_jump` 为空,开始节点按平台默认进入首个业务节点;普通单一路径不要构造自定义跳转。
121
+ - 一旦配置 `meta.condational_jump`,必须显式写出所有可能起步去向,不能依赖后端隐式 fallback 到 `data.nodes[0]`。CLI lint 会要求最后一条是显式兜底边,脚本写 `return true;`;兜底目标可以是任意合法 `data.nodes[].id` 或 `-1`。
122
+ - `meta.condational_jump` 只用于“根据表单内容或脚本条件决定起步去向”的场景,不用于普通开始到后续节点的直连;如果启用,就按有序分支表完整建模。
123
+ - 开始条件跳转源码依据:
124
+ - 后端 `huanpingtong-server/src/model/project.ts` 的 `ProjectModel.getStartNodeId()` 会按数组顺序执行,每条命中后取该条 `result` 作为起始节点。
125
+ - `condition_mode` 为空或 `code` 时执行 `condition`;`condition_mode === "standard"` 时只执行 `standard_condition`。
126
+ - 脚本入参为 `$CURRENTFORM, ctx`,返回 boolean / truthy 表示“当前这条边命中”;不要返回 result 下标,返回值不是目标下标。
127
+ - 后端源码在未命中时会 fallback 到 `data.nodes[0]`,但 BPMAX 配置规范禁止依赖这个隐式 fallback,必须用最后一条 `return true;` 显式兜底。
128
+ - 前端 `ConditionJump.vue` 新增项默认结构包含 `name`、`result`、`condition`、`condition_mode: "standard"`、`condition_rules`;标准条件生成器会写入 `standard_condition`。
129
+ - 每条开始条件跳转的推荐结构:
130
+
131
+ ```json
132
+ {
133
+ "name": "客户拖车先到安全员",
134
+ "result": "security",
135
+ "condition_mode": "standard",
136
+ "condition_rules": { "logic": "AND", "conditions": [] },
137
+ "standard_condition": "return ctx?.$META_FORM_FIELD?.[\"is_customer_trailer\"] === \"yes\";"
138
+ }
139
+ ```
140
+
141
+ - 显式兜底边必须放在最后;如果普通路径就是首个业务节点,就显式指向首个业务节点。若业务兜底应直接到其它节点或结束,也可以指向对应节点 `id` 或 `-1`:
142
+
143
+ ```json
144
+ {
145
+ "name": "其他情况到直接上级",
146
+ "result": "direct_manager",
147
+ "condition_mode": "code",
148
+ "condition": "return true;"
149
+ }
150
+ ```
151
+
113
152
  - 必须严格区分两类条件跳转:
114
153
  - `meta.condational_jump` 是流程级开始条件跳转,运行时脚本返回 `boolean`
115
154
  - `node.condational_nodes` 是节点级条件路由,运行时脚本返回当前 `result` 数组命中的下标,未命中返回 `-1`
@@ -117,10 +156,29 @@ export BPMAX_BASE_URL='https://<your-bpmax-host>'
117
156
  - 在 `approve_actions` 或 `approve_to_step` 中显式引用 `节点名[condition]i`
118
157
  - `condational_nodes[i].result` 维护多目标数组
119
158
  - `condational_nodes[i].condition` / `standard_condition` 返回命中的 `result` 下标
159
+ - 多动作审批字段必须符合平台解析契约:
160
+ - `approve_actions` / `approve_fail_actions` 的每一项必须是 `按钮文案|目标节点ID`,可带编辑器扩展段,例如 `通过|判定[condition]0|||0`
161
+ - 普通多动作必须写成 `通过|ceo_node_id`、`转物流|logistics_node_id`,不能写裸 `["ceo_node_id", "logistics_node_id"]`
162
+ - 条件分支优先配置 `condational_nodes`,再让 `approve_to_step` 或 `approve_actions` 指向 `条件名[condition]0`
163
+ - 动作目标只能是真实 `data.nodes[].id`、终点如 `-1`、平台特殊目标 `[source]` / `anyNode`,或当前节点已定义的 `condational_nodes[].name + "[condition]0"` 引用
164
+ - `approve_to_step` / `approve_fail` 直接跳转字段也必须指向同一组合法目标,不能写节点名称、失效 id、数组或对象
165
+ - `condational_nodes` 本身必须是数组;`condational_nodes[]` 每一项都必须是对象,包含非空 `name`、`result`、`condition_mode` 和返回 result 下标的条件脚本;不能写成对象、字符串、裸目标数组或空对象
166
+ - `condition_mode` 为空或 `code` 时必须写非空 `condition`;`condition_mode: "standard"` 时必须写非空 `standard_condition`;两种模式不能混填后指望后端自动兜底
167
+ - `condational_nodes[].result` 必须是非空目标数组,每一项都必须是真实节点 `id`、终点如 `-1` 或 `[source]`;不能把不存在的节点、二级 `[condition]` 引用或 `anyNode` 放进 result。`anyNode` 只能用于按钮目标触发前端选择节点弹窗,后端条件脚本命中 result 时不会打开选择器。
120
168
  - 节点级条件路由的反模式包括:
121
169
  - 把一个二选一或多选一路由拆成多个并列单目标 `condational_nodes`
170
+ - `condational_nodes` 写成对象,或 `condational_nodes[]` 里混入字符串、数组或空对象,导致平台无法解析条件名、目标数组或脚本
171
+ - `condational_nodes[]` 缺少 `name`、`condition` / `standard_condition`,或 `condition_mode` 写成平台不识别的值
122
172
  - 把流程级 `meta.condational_jump` 的 `boolean` 返回值写法直接套用到节点级 `condational_nodes`
123
173
  - 节点上配置了 `condational_nodes`,但 `approve_actions` / `approve_to_step` 没有任何 `[condition]` 引用
174
+ - `approve_actions` / `approve_fail_actions` 写成裸节点 id 数组,导致平台按 `label|targetStep` 解析后 target 为 `undefined`
175
+ - `condational_nodes[].result` 里出现不存在的节点 id,导致条件命中后图上断边或运行态跳转失败
176
+ - 开始条件跳转的反模式包括:
177
+ - 有 `meta.condational_jump` 但只写例外分支,缺少最后一条 `return true;` 显式兜底
178
+ - 在最后一条之前写 `return true;`,导致后续起步分支永远不可达
179
+ - 把 `node.condational_nodes` 的下标写法复制到开始跳转,例如 `return 0;`、`return 1;`、`return -1;`、`return result.indexOf(...)`
180
+ - `result` 写节点名称、数组或对象;它只能是目标 `data.nodes[].id`,或 `-1` 表示成功结束
181
+ - `condition_mode: "standard"` 却只写 `condition`,或 `condition_mode: "code"` 却只写 `standard_condition`
124
182
  - 流程审批语义必须通过 semantic lint 强制校验:
125
183
  - 非审批语义环节不得配置审批人数,`approve_count_required` 必须为 `0` 或空;评分、填写、初始化、归档、记录、通知等普通办理环节不要用审批人数模拟流转。
126
184
  - 有审批/审核/确认/验收/批准/复核/月审/对账/判定等审批语义的环节,如果 `approve_count_required > 0`,拒绝分支必须显式配置目标节点,不能依赖默认下一节点。
@@ -140,7 +198,7 @@ export BPMAX_BASE_URL='https://<your-bpmax-host>'
140
198
  - 当前页面已验证:`FlowEditorDark.getSubmitData()` 返回的是裸 `data` 骨架,不包含顶层 `name`;`name` / `updateTime` / `flowTypeKey` 需要从编辑器实例字段补齐。
141
199
  - 当前环境已验证:当 `draft=1` 接口空壳且退回 `runtime_fallback` 时,导出脚本应继续从已发布 live `/api/flow` 补齐 `name` 和 `updateTime`,否则后续提交会因为缺少顶层字段而失真。
142
200
  - 当前环境已验证:`document.cookie` 往往拿不到 httpOnly 登录态;脚本鉴权优先复用同域真实请求头里的完整 `cookie` header,而不是只靠页面脚本读 cookie。
143
- - 当前页面已验证:节点跳转字段 `approve_to_step` / `approve_fail` 默认使用节点 `id`;脚本校验应以节点 `id` 优先,节点名兼容。
201
+ - 当前页面已验证:节点跳转字段 `approve_to_step` / `approve_fail` 必须使用节点 `id`;节点名称只能作为人工核对线索,不能作为提交目标写入配置。
144
202
  - 当前环境已验证:本地 `think_flow_page_template` 里的 UUID 目录名只适合离线检索;真正提交到 `/api/flow` 的 `node.step_detail_id` / `meta.step_detail_id` 要使用线上远端数字 `id`。不要把任何 UUID 目录名、`uuid'...'` 路径片段或本地镜像 ID 写入提交 payload。
145
203
  - 当前页面已验证:`data.group` 在线上真实返回和运行时中观测为 `array`;编辑场景应保留真实形态,不做归一化。
146
204
  - `data.group` 现在视为硬门禁字段:`work`/`submit`/草稿回读里都必须是 `array`。不要再接受“后端能存、前端再说”的 `{}`
@@ -616,7 +674,10 @@ export BPMAX_BASE_URL='https://<your-bpmax-host>'
616
674
  - 修改节点时,尽量保留现有节点 `id`,避免把已有流程整体重建。
617
675
  - 不要因为用户说“发起时要填表单”就默认新增一个名为“发起”或“申请”的阶段。先看当前流程是否采用 Meta 作为发起入口。
618
676
  - 如果只是普通单一路径开始,不要构造 `meta.condational_jump`;保持它为空,让开始节点默认流转到首个业务节点。
619
- - 只有在“开始节点要按表单值、脚本或条件表达式分流”时,才去构造 `meta.condational_jump`。
677
+ - 只有在“开始节点要按表单值、脚本或条件表达式分流”时,才去构造 `meta.condational_jump`;一旦构造,就必须显式写出所有可能会跳的情况。
678
+ - 开始条件跳转必须按“有序分支 + 显式兜底”建模:每条 `meta.condational_jump` 表达一条可能起步边,数组顺序即匹配顺序,最后一条必须写 `return true;` 并指向合法节点 `id` 或 `-1`。不要依赖后端隐式 fallback,也不要把 WEWF 的“申请人/发起人”建成普通节点来承载默认路径。
679
+ - `meta.condational_jump[*].condition` / `standard_condition` 必须返回严格 boolean。若来源是 WEWF 或其它系统的多分支条件脚本,且脚本语义是“返回目标下标 / route index”,必须先按当前 jump 的目标边包成 `return routeIndex === <target_index>;` 这类 boolean 语义;普通首节点路径如果存在,也要用最后一条 `return true;` 明确兜底,不能把节点级 index 脚本原样写入开始跳转。
680
+ - 开始条件跳转的目标和脚本必须逐边核对:每条 jump 的 `result` 必须对应当前条件命中的目标节点;例如 WEWF 有“非客户拖车 -> 直接上级”和“客户拖车 -> 安全员”两条起步边时,BPMAX 应显式生成两条 `meta.condational_jump`,第一条“客户拖车 -> 安全员”返回条件 boolean,最后一条“其他情况 -> 直接上级”返回 `true`。
620
681
  - 如果用户需求涉及“流程页面怎么展示”“列表怎么查”“详情页挂什么组件”,不要只改 `flow.data`,还要同步评估 `think_flow_page_template`。
621
682
  - 如果是给节点挂表单模板,不要手填一个猜测的 `form_template` 值。优先复用当前已激活配置仓库或现有流程里已经落地的真实引用格式。
622
683
  - 如果是给节点挂环节表单,优先按下面顺序判定,不要混淆:
@@ -652,6 +713,7 @@ export BPMAX_BASE_URL='https://<your-bpmax-host>'
652
713
  - `submit` 没有比已确认的 `work` 多出新的节点、阶段、脚本位点、模板引用或流程级开关
653
714
  - 阶段数组与节点 `period` 引用一致
654
715
  - `approve_to_step` / `approve_fail` 仍指向存在的节点
716
+ - `approve_actions` / `approve_fail_actions` 每一项都是 `按钮文案|目标`,不能是裸节点 id;目标必须是节点 id、终点、`[source]` / `anyNode` 或条件节点引用
655
717
  - `condational_nodes.result` 目标节点存在
656
718
  - `auto_trigger_flows.flows[].flow` 目标流程合法
657
719
  - 已有 `plugin_*`、`hook`、`object_events` 未被误清空
@@ -772,7 +834,7 @@ export BPMAX_BASE_URL='https://<your-bpmax-host>'
772
834
  - 流程级页面已验证字段是否仍然存在且值合理,优先对照 `references/runtime-verified-meta-fields.md`
773
835
  - 开始节点是否走了正确模型:
774
836
  - 普通单一路径:`meta.condational_jump = []`
775
- - 按条件分流:`meta.condational_jump` 非空且条件/目标正确
837
+ - 按条件分流:`meta.condational_jump` 非空、每条 `result` 指向真实节点或 `-1`、脚本返回 boolean,且最后一条是 `return true;` 显式兜底
776
838
  - 审批节点的通过/驳回线是否符合需求:
777
839
  - 是否真的存在审批人数要求
778
840
  - 驳回线是否被编辑器正确渲染