bpmax-cli 0.2.1-beta.53 → 0.2.1-beta.55
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.
- package/dist/bin.js +6404 -1333
- package/dist/bin.js.map +1 -1
- package/package.json +1 -1
- package/scripts/install-skills.mjs +21 -57
- package/skills/bpmax-ai-taskbook/SKILL.md +10 -0
- package/skills/bpmax-ai-taskbook/references/blueprint-taskbook-gates.md +120 -0
- package/skills/bpmax-ai-taskbook/references/taskbook-template.md +41 -1
- package/skills/bpmax-blueprint-doc-workflow/SKILL.md +15 -2
- package/skills/bpmax-blueprint-doc-workflow/references/blueprint-structure.md +8 -0
- package/skills/bpmax-blueprint-doc-workflow/references/per-flow-required-structure.md +13 -0
- package/skills/bpmax-blueprint-doc-workflow/references/sample-missing-modeling-review.xml +23 -0
- package/skills/bpmax-blueprint-doc-workflow/references/sample-paragraph-flow-details.xml +27 -0
- package/skills/bpmax-blueprint-doc-workflow/references/sample-pass.xml +45 -28
- package/skills/bpmax-blueprint-doc-workflow/references/source-traceability-and-flow-modeling.md +115 -0
- package/skills/bpmax-blueprint-doc-workflow/scripts/lint_blueprint_doc.py +386 -5
- package/skills/bpmax-dataset-field-template-editor/SKILL.md +6 -2
- package/skills/bpmax-dataset-field-template-editor/references/nested-field-patterns.md +8 -8
- package/skills/bpmax-dataset-template-editor/SKILL.md +10 -4
- package/skills/bpmax-dataset-template-editor/references/dataset-script-runtime-matrix.md +11 -0
- package/skills/bpmax-dataset-template-editor/references/runtime-gotchas.md +12 -0
- package/skills/bpmax-e2e-flow-test-operator-v2/SKILL.md +61 -0
- package/skills/bpmax-e2e-flow-test-operator-v2/agents/openai.yaml +7 -0
- package/skills/bpmax-e2e-flow-test-operator-v2/references/automation-generation-pipeline.md +33 -0
- package/skills/bpmax-e2e-flow-test-operator-v2/references/batch-generation-and-execution.md +17 -0
- package/skills/bpmax-e2e-flow-test-operator-v2/references/browser-action-runner.md +19 -0
- package/skills/bpmax-e2e-flow-test-operator-v2/references/browser-recording-and-replay.md +95 -0
- package/skills/bpmax-e2e-flow-test-operator-v2/references/form-script-generation.md +41 -0
- package/skills/bpmax-e2e-flow-test-operator-v2/references/identity-and-failure-routing.md +80 -0
- package/skills/bpmax-e2e-flow-test-operator-v2/references/multi-request-mutation.md +9 -0
- package/skills/bpmax-e2e-flow-test-operator-v2/references/scenario-coverage-generation.md +17 -0
- package/skills/bpmax-e2e-flow-test-operator-v2/references/scoped-execution.md +13 -0
- package/skills/bpmax-e2e-flow-test-operator-v2/references/step-restartability-and-state.md +23 -0
- package/skills/bpmax-e2e-flow-test-operator-v2/references/test-assets-and-evidence.md +9 -0
- package/skills/bpmax-e2e-flow-test-operator-v2/references/test-data-and-selector-contract.md +51 -0
- package/skills/bpmax-e2e-flow-test-operator-v2/references/test-preflight-and-confirmation.md +32 -0
- package/skills/bpmax-flow-template-editor/SKILL.md +1 -0
- package/skills/bpmax-user-mock-operator/SKILL.md +33 -26
- package/skills/bpmax-user-mock-operator/scripts/chrome_identity_bridge.mjs +202 -86
|
@@ -52,6 +52,67 @@ AI_FORBIDDEN_PATTERNS = [
|
|
|
52
52
|
r"AI[^。;\n]{0,30}自动认证",
|
|
53
53
|
r"AI[^。;\n]{0,30}自动对账",
|
|
54
54
|
]
|
|
55
|
+
DOCUMENT_MODELING_TABLES = {
|
|
56
|
+
"源流程逻辑映射与完整性核对": ["源流程逻辑映射与完整性核对"],
|
|
57
|
+
"人工调整记录": ["人工调整记录"],
|
|
58
|
+
"主流程阶段划分": ["主流程阶段划分"],
|
|
59
|
+
"并行场景建模决策": ["并行场景建模决策"],
|
|
60
|
+
"审批/决策矩阵评估": ["审批/决策矩阵评估", "审批与决策矩阵评估"],
|
|
61
|
+
}
|
|
62
|
+
FLOW_DETAIL_TABLES = {
|
|
63
|
+
"开始节点与创建表单": ["开始节点与创建表单", "开始节点", "创建表单"],
|
|
64
|
+
"环节配置": ["环节配置", "节点配置"],
|
|
65
|
+
"表单模板": ["表单模板"],
|
|
66
|
+
"流程数据集": ["流程数据集", "数据集"],
|
|
67
|
+
"列表/筛选/详情/看板入口": ["列表/筛选/详情/看板入口", "列表", "视图入口"],
|
|
68
|
+
"自动化与 AI/agent": ["自动化与 AI/agent", "自动化与 AI", "自动化"],
|
|
69
|
+
"办结口径与下游联动": ["办结口径与下游联动", "办结口径", "下游联动"],
|
|
70
|
+
"BPMAX 实现边界": ["BPMAX 实现边界", "实现边界"],
|
|
71
|
+
}
|
|
72
|
+
MATRIX_ASSESSMENT_TERMS = ["蓝图规则矩阵", "正式 BPMAX 矩阵"]
|
|
73
|
+
MATRIX_HEADER_RULES = {
|
|
74
|
+
"决策范围": ["决策范围", "决策"],
|
|
75
|
+
"条件": ["条件", "判断条件"],
|
|
76
|
+
"处理人/审批人来源": ["处理人/审批人来源", "处理人来源", "审批人来源", "人员来源"],
|
|
77
|
+
"结果/下一步": ["结果/下一步", "结果", "下一步"],
|
|
78
|
+
"维护责任人": ["维护责任人", "维护角色", "维护人"],
|
|
79
|
+
"蓝图规则矩阵": ["蓝图规则矩阵"],
|
|
80
|
+
"正式 BPMAX 矩阵": ["正式 BPMAX 矩阵"],
|
|
81
|
+
"运行态验收": ["运行态验收", "验收"],
|
|
82
|
+
}
|
|
83
|
+
FORMAL_MATRIX_RUNTIME_TERMS = {
|
|
84
|
+
"矩阵应用": ["矩阵应用"],
|
|
85
|
+
"规则记录": ["规则记录", "矩阵规则"],
|
|
86
|
+
"真实用户": ["真实用户", "BPMAX 用户"],
|
|
87
|
+
"消费节点": ["消费节点", "使用节点", "引用节点"],
|
|
88
|
+
"缺失规则": ["缺失", "未命中"],
|
|
89
|
+
"重复规则": ["重复", "多条命中"],
|
|
90
|
+
"readback": ["readback", "回读"],
|
|
91
|
+
"owner resolve": ["owner resolve", "owner-resolve", "处理人解析", "owner 解析"],
|
|
92
|
+
}
|
|
93
|
+
NAVIGATION_SECTION_TITLES = ["PC/H5 导航设计", "多端导航设计", "导航设计"]
|
|
94
|
+
NAVIGATION_HEADER_RULES = {
|
|
95
|
+
"流程": ["流程"],
|
|
96
|
+
"终端": ["终端", "端"],
|
|
97
|
+
"目标用户": ["目标用户", "用户", "角色"],
|
|
98
|
+
"入口/菜单": ["入口/菜单", "入口", "菜单"],
|
|
99
|
+
"路由/页面": ["路由/页面", "路由", "页面"],
|
|
100
|
+
"可见权限": ["可见权限", "显示权限", "权限"],
|
|
101
|
+
"验收": ["验收", "验收方式"],
|
|
102
|
+
}
|
|
103
|
+
PERMISSION_SECTION_TITLES = ["权限设计", "权限模型", "权限与可见性设计"]
|
|
104
|
+
PERMISSION_HEADER_RULES = {
|
|
105
|
+
"流程": ["流程"],
|
|
106
|
+
"对象/字段": ["对象/字段", "对象", "字段"],
|
|
107
|
+
"环节": ["环节", "节点", "阶段"],
|
|
108
|
+
"用户/角色": ["用户/角色", "用户", "角色", "主体"],
|
|
109
|
+
"可见": ["可见", "可见性"],
|
|
110
|
+
"可编辑": ["可编辑", "编辑性"],
|
|
111
|
+
"操作权限": ["操作权限", "动作权限", "权限动作"],
|
|
112
|
+
"验收": ["验收", "验收方式"],
|
|
113
|
+
}
|
|
114
|
+
PERMISSION_ACTION_TERMS = ["创建", "查看", "编辑", "删除", "提交", "审批", "导航"]
|
|
115
|
+
PERMISSION_DENY_TERMS = ["禁止", "不可", "无权限", "隐藏", "只读", "不适用"]
|
|
55
116
|
|
|
56
117
|
|
|
57
118
|
@dataclass
|
|
@@ -71,6 +132,12 @@ class FlowSection:
|
|
|
71
132
|
missing: list[str] = field(default_factory=list)
|
|
72
133
|
|
|
73
134
|
|
|
135
|
+
@dataclass
|
|
136
|
+
class TableData:
|
|
137
|
+
headers: list[str]
|
|
138
|
+
rows: list[dict[str, str]]
|
|
139
|
+
|
|
140
|
+
|
|
74
141
|
def read_content(path: Path) -> str:
|
|
75
142
|
raw = path.read_text(encoding="utf-8")
|
|
76
143
|
stripped = raw.lstrip()
|
|
@@ -113,19 +180,122 @@ def extract_title(xml: str) -> str:
|
|
|
113
180
|
return plain_text(match.group(1)).strip() if match else ""
|
|
114
181
|
|
|
115
182
|
|
|
183
|
+
def extract_heading_sections(xml: str) -> list[tuple[int, str, str]]:
|
|
184
|
+
heading_re = re.compile(r"<h([1-3])[^>]*>(.*?)</h\1>", re.S)
|
|
185
|
+
matches = list(heading_re.finditer(xml))
|
|
186
|
+
sections: list[tuple[int, str, str]] = []
|
|
187
|
+
for index, match in enumerate(matches):
|
|
188
|
+
level = int(match.group(1))
|
|
189
|
+
title = plain_text(match.group(2)).strip()
|
|
190
|
+
end = len(xml)
|
|
191
|
+
for next_match in matches[index + 1 :]:
|
|
192
|
+
if int(next_match.group(1)) <= level:
|
|
193
|
+
end = next_match.start()
|
|
194
|
+
break
|
|
195
|
+
sections.append((level, title, xml[match.start() : end]))
|
|
196
|
+
return sections
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def matching_sections(xml: str, title_terms: Iterable[str]) -> list[str]:
|
|
200
|
+
return [
|
|
201
|
+
content
|
|
202
|
+
for _, title, content in extract_heading_sections(xml)
|
|
203
|
+
if any(term in title for term in title_terms)
|
|
204
|
+
]
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
def extract_tables(xml: str) -> list[TableData]:
|
|
208
|
+
tables: list[TableData] = []
|
|
209
|
+
for table_match in re.finditer(r"<table\b[^>]*>(.*?)</table>", xml, re.I | re.S):
|
|
210
|
+
parsed_rows: list[list[str]] = []
|
|
211
|
+
row_cell_tags: list[list[str]] = []
|
|
212
|
+
for row_match in re.finditer(r"<tr\b[^>]*>(.*?)</tr>", table_match.group(1), re.I | re.S):
|
|
213
|
+
cells: list[str] = []
|
|
214
|
+
tags: list[str] = []
|
|
215
|
+
for cell_match in re.finditer(r"<(th|td)\b[^>]*>(.*?)</\1>", row_match.group(1), re.I | re.S):
|
|
216
|
+
tags.append(cell_match.group(1).lower())
|
|
217
|
+
cells.append(plain_text(cell_match.group(2)).strip())
|
|
218
|
+
if cells:
|
|
219
|
+
parsed_rows.append(cells)
|
|
220
|
+
row_cell_tags.append(tags)
|
|
221
|
+
if not parsed_rows:
|
|
222
|
+
continue
|
|
223
|
+
header_index = 0
|
|
224
|
+
for index, tags in enumerate(row_cell_tags):
|
|
225
|
+
if tags and all(tag == "th" for tag in tags):
|
|
226
|
+
header_index = index
|
|
227
|
+
break
|
|
228
|
+
headers = parsed_rows[header_index]
|
|
229
|
+
rows: list[dict[str, str]] = []
|
|
230
|
+
for cells in parsed_rows[header_index + 1 :]:
|
|
231
|
+
rows.append({header: cells[index] if index < len(cells) else "" for index, header in enumerate(headers)})
|
|
232
|
+
tables.append(TableData(headers=headers, rows=rows))
|
|
233
|
+
return tables
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
def header_name(table: TableData, aliases: Iterable[str]) -> str | None:
|
|
237
|
+
for header in table.headers:
|
|
238
|
+
normalized = re.sub(r"\s+", "", header).lower()
|
|
239
|
+
for alias in aliases:
|
|
240
|
+
expected = re.sub(r"\s+", "", alias).lower()
|
|
241
|
+
if normalized == expected or expected in normalized:
|
|
242
|
+
return header
|
|
243
|
+
return None
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
def row_value(row: dict[str, str], table: TableData, aliases: Iterable[str]) -> str:
|
|
247
|
+
header = header_name(table, aliases)
|
|
248
|
+
return row.get(header, "").strip() if header else ""
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
def is_placeholder(value: str) -> bool:
|
|
252
|
+
normalized = value.strip().strip("<>")
|
|
253
|
+
return normalized in {"", "-", "待填写", "待确认", "待补充", "未知"}
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
def flow_business_name(title: str) -> str:
|
|
257
|
+
parts = re.split(r"[::]", title, maxsplit=1)
|
|
258
|
+
return parts[1].strip() if len(parts) > 1 else title.strip()
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
def row_mentions_flow(row: dict[str, str], table: TableData, flow: FlowSection) -> bool:
|
|
262
|
+
flow_value = row_value(row, table, ["流程"])
|
|
263
|
+
return flow.title in flow_value or flow_business_name(flow.title) in flow_value
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
def require_table_headers(
|
|
267
|
+
findings: list[Finding],
|
|
268
|
+
table: TableData,
|
|
269
|
+
rules: dict[str, list[str]],
|
|
270
|
+
code: str,
|
|
271
|
+
label: str,
|
|
272
|
+
) -> bool:
|
|
273
|
+
ok = True
|
|
274
|
+
for required, aliases in rules.items():
|
|
275
|
+
if header_name(table, aliases) is None:
|
|
276
|
+
add_error(findings, code, f"{label} table is missing required header: {required}")
|
|
277
|
+
ok = False
|
|
278
|
+
return ok
|
|
279
|
+
|
|
280
|
+
|
|
116
281
|
def extract_flows(xml: str) -> list[FlowSection]:
|
|
117
282
|
heading_re = re.compile(r"<h([1-3])[^>]*>(.*?)</h\1>", re.S)
|
|
118
283
|
matches = list(heading_re.finditer(xml))
|
|
119
|
-
flow_matches = []
|
|
120
|
-
for match in matches:
|
|
284
|
+
flow_matches: list[tuple[int, re.Match[str], str]] = []
|
|
285
|
+
for match_index, match in enumerate(matches):
|
|
121
286
|
title = plain_text(match.group(2)).strip()
|
|
122
287
|
if re.search(r"流程[一二三四五六七八九十\d]+[::]", title):
|
|
123
|
-
flow_matches.append((match, title))
|
|
288
|
+
flow_matches.append((match_index, match, title))
|
|
124
289
|
|
|
125
290
|
flows = []
|
|
126
|
-
for
|
|
291
|
+
for match_index, match, title in flow_matches:
|
|
127
292
|
start = match.start()
|
|
128
|
-
|
|
293
|
+
level = int(match.group(1))
|
|
294
|
+
end = len(xml)
|
|
295
|
+
for next_match in matches[match_index + 1 :]:
|
|
296
|
+
if int(next_match.group(1)) <= level:
|
|
297
|
+
end = next_match.start()
|
|
298
|
+
break
|
|
129
299
|
content = xml[start:end]
|
|
130
300
|
flows.append(
|
|
131
301
|
FlowSection(
|
|
@@ -142,6 +312,161 @@ def add_error(findings: list[Finding], code: str, message: str, flow: str | None
|
|
|
142
312
|
findings.append(Finding("error", code, message, flow))
|
|
143
313
|
|
|
144
314
|
|
|
315
|
+
def validate_matrix_design(findings: list[Finding], sections: list[str]) -> None:
|
|
316
|
+
if not sections:
|
|
317
|
+
return
|
|
318
|
+
tables = extract_tables(" ".join(sections))
|
|
319
|
+
if not tables:
|
|
320
|
+
return
|
|
321
|
+
table = tables[0]
|
|
322
|
+
if not require_table_headers(
|
|
323
|
+
findings,
|
|
324
|
+
table,
|
|
325
|
+
MATRIX_HEADER_RULES,
|
|
326
|
+
"DOC_MATRIX_HEADER_MISSING",
|
|
327
|
+
"Approval/decision matrix assessment",
|
|
328
|
+
):
|
|
329
|
+
return
|
|
330
|
+
if not table.rows:
|
|
331
|
+
add_error(findings, "DOC_MATRIX_ROW_MISSING", "Approval/decision matrix assessment requires at least one rule row.")
|
|
332
|
+
return
|
|
333
|
+
section_text = plain_text(" ".join(sections))
|
|
334
|
+
for row_index, row in enumerate(table.rows, start=1):
|
|
335
|
+
for required, aliases in MATRIX_HEADER_RULES.items():
|
|
336
|
+
if is_placeholder(row_value(row, table, aliases)):
|
|
337
|
+
add_error(
|
|
338
|
+
findings,
|
|
339
|
+
"DOC_MATRIX_VALUE_MISSING",
|
|
340
|
+
f"Approval/decision matrix row {row_index} has no concrete value for: {required}",
|
|
341
|
+
)
|
|
342
|
+
formal_value = row_value(row, table, MATRIX_HEADER_RULES["正式 BPMAX 矩阵"])
|
|
343
|
+
formal_selected = bool(formal_value) and not re.search(r"不采用|不使用|不需要|否|无|不适用", formal_value)
|
|
344
|
+
if formal_selected:
|
|
345
|
+
for label, terms in FORMAL_MATRIX_RUNTIME_TERMS.items():
|
|
346
|
+
if not has_any(section_text, terms):
|
|
347
|
+
add_error(
|
|
348
|
+
findings,
|
|
349
|
+
"DOC_FORMAL_MATRIX_LIFECYCLE_MISSING",
|
|
350
|
+
f"Formal BPMAX matrix design is missing runtime lifecycle detail: {label}",
|
|
351
|
+
)
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
def validate_navigation_design(findings: list[Finding], xml: str, flows: list[FlowSection]) -> None:
|
|
355
|
+
sections = matching_sections(xml, NAVIGATION_SECTION_TITLES)
|
|
356
|
+
if not sections:
|
|
357
|
+
add_error(findings, "DOC_NAVIGATION_DESIGN_MISSING", "Missing required PC/H5 navigation design section.")
|
|
358
|
+
return
|
|
359
|
+
tables = extract_tables(" ".join(sections))
|
|
360
|
+
if not tables:
|
|
361
|
+
add_error(findings, "DOC_NAVIGATION_TABLE_MISSING", "PC/H5 navigation design must be presented as a table.")
|
|
362
|
+
return
|
|
363
|
+
table = tables[0]
|
|
364
|
+
if not require_table_headers(
|
|
365
|
+
findings,
|
|
366
|
+
table,
|
|
367
|
+
NAVIGATION_HEADER_RULES,
|
|
368
|
+
"DOC_NAVIGATION_HEADER_MISSING",
|
|
369
|
+
"PC/H5 navigation design",
|
|
370
|
+
):
|
|
371
|
+
return
|
|
372
|
+
if not table.rows:
|
|
373
|
+
add_error(findings, "DOC_NAVIGATION_ROW_MISSING", "PC/H5 navigation design requires at least one row.")
|
|
374
|
+
return
|
|
375
|
+
for row_index, row in enumerate(table.rows, start=1):
|
|
376
|
+
terminal = row_value(row, table, NAVIGATION_HEADER_RULES["终端"])
|
|
377
|
+
if "PC" in terminal.upper() and "H5" in terminal.upper():
|
|
378
|
+
add_error(
|
|
379
|
+
findings,
|
|
380
|
+
"DOC_NAVIGATION_TERMINAL_COMBINED",
|
|
381
|
+
f"Navigation row {row_index} combines PC and H5; design them as separate rows.",
|
|
382
|
+
)
|
|
383
|
+
for required, aliases in NAVIGATION_HEADER_RULES.items():
|
|
384
|
+
if is_placeholder(row_value(row, table, aliases)):
|
|
385
|
+
add_error(
|
|
386
|
+
findings,
|
|
387
|
+
"DOC_NAVIGATION_VALUE_MISSING",
|
|
388
|
+
f"Navigation row {row_index} has no concrete value for: {required}",
|
|
389
|
+
)
|
|
390
|
+
for flow in flows:
|
|
391
|
+
rows = [row for row in table.rows if row_mentions_flow(row, table, flow)]
|
|
392
|
+
if not rows:
|
|
393
|
+
add_error(
|
|
394
|
+
findings,
|
|
395
|
+
"FLOW_NAVIGATION_COVERAGE_MISSING",
|
|
396
|
+
"Navigation design has no row for this flow.",
|
|
397
|
+
flow.title,
|
|
398
|
+
)
|
|
399
|
+
continue
|
|
400
|
+
terminals = [row_value(row, table, NAVIGATION_HEADER_RULES["终端"]).upper() for row in rows]
|
|
401
|
+
if not any("PC" in terminal and "H5" not in terminal for terminal in terminals):
|
|
402
|
+
add_error(findings, "FLOW_PC_NAVIGATION_MISSING", "Flow has no independent PC navigation design.", flow.title)
|
|
403
|
+
if not any("H5" in terminal and "PC" not in terminal for terminal in terminals):
|
|
404
|
+
add_error(findings, "FLOW_H5_NAVIGATION_MISSING", "Flow has no independent H5 navigation design or explicit H5 non-applicability row.", flow.title)
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
def validate_permission_design(findings: list[Finding], xml: str, flows: list[FlowSection]) -> None:
|
|
408
|
+
sections = matching_sections(xml, PERMISSION_SECTION_TITLES)
|
|
409
|
+
if not sections:
|
|
410
|
+
add_error(findings, "DOC_PERMISSION_DESIGN_MISSING", "Missing required permission design section.")
|
|
411
|
+
return
|
|
412
|
+
tables = extract_tables(" ".join(sections))
|
|
413
|
+
if not tables:
|
|
414
|
+
add_error(findings, "DOC_PERMISSION_TABLE_MISSING", "Permission design must be presented as a table.")
|
|
415
|
+
return
|
|
416
|
+
table = tables[0]
|
|
417
|
+
if not require_table_headers(
|
|
418
|
+
findings,
|
|
419
|
+
table,
|
|
420
|
+
PERMISSION_HEADER_RULES,
|
|
421
|
+
"DOC_PERMISSION_HEADER_MISSING",
|
|
422
|
+
"Permission design",
|
|
423
|
+
):
|
|
424
|
+
return
|
|
425
|
+
if not table.rows:
|
|
426
|
+
add_error(findings, "DOC_PERMISSION_ROW_MISSING", "Permission design requires at least one row.")
|
|
427
|
+
return
|
|
428
|
+
for row_index, row in enumerate(table.rows, start=1):
|
|
429
|
+
for required, aliases in PERMISSION_HEADER_RULES.items():
|
|
430
|
+
if is_placeholder(row_value(row, table, aliases)):
|
|
431
|
+
add_error(
|
|
432
|
+
findings,
|
|
433
|
+
"DOC_PERMISSION_VALUE_MISSING",
|
|
434
|
+
f"Permission row {row_index} has no concrete value for: {required}",
|
|
435
|
+
)
|
|
436
|
+
for flow in flows:
|
|
437
|
+
rows = [row for row in table.rows if row_mentions_flow(row, table, flow)]
|
|
438
|
+
if not rows:
|
|
439
|
+
add_error(findings, "FLOW_PERMISSION_COVERAGE_MISSING", "Permission design has no row for this flow.", flow.title)
|
|
440
|
+
continue
|
|
441
|
+
row_text = plain_text(" ".join(" ".join(row.values()) for row in rows))
|
|
442
|
+
action_text = " ".join(
|
|
443
|
+
row_value(row, table, PERMISSION_HEADER_RULES["操作权限"])
|
|
444
|
+
for row in rows
|
|
445
|
+
)
|
|
446
|
+
for action in PERMISSION_ACTION_TERMS:
|
|
447
|
+
if action not in action_text:
|
|
448
|
+
add_error(
|
|
449
|
+
findings,
|
|
450
|
+
"FLOW_PERMISSION_ACTION_MISSING",
|
|
451
|
+
f"Permission design does not explicitly cover action: {action}",
|
|
452
|
+
flow.title,
|
|
453
|
+
)
|
|
454
|
+
if "字段" not in row_text:
|
|
455
|
+
add_error(
|
|
456
|
+
findings,
|
|
457
|
+
"FLOW_FIELD_PERMISSION_MISSING",
|
|
458
|
+
"Permission design does not include field visibility/editability for this flow.",
|
|
459
|
+
flow.title,
|
|
460
|
+
)
|
|
461
|
+
if not has_any(row_text, PERMISSION_DENY_TERMS):
|
|
462
|
+
add_error(
|
|
463
|
+
findings,
|
|
464
|
+
"FLOW_PERMISSION_DENY_BOUNDARY_MISSING",
|
|
465
|
+
"Permission design does not state the denied or read-only behavior for unauthorized users.",
|
|
466
|
+
flow.title,
|
|
467
|
+
)
|
|
468
|
+
|
|
469
|
+
|
|
145
470
|
def lint(xml: str, require_terms: list[str], forbid_terms: list[str]) -> tuple[list[Finding], list[FlowSection]]:
|
|
146
471
|
findings: list[Finding] = []
|
|
147
472
|
text = plain_text(xml)
|
|
@@ -170,9 +495,45 @@ def lint(xml: str, require_terms: list[str], forbid_terms: list[str]) -> tuple[l
|
|
|
170
495
|
if re.search(r"<pre[^>]*lang=[\"']mermaid[\"']", xml, re.I):
|
|
171
496
|
add_error(findings, "MERMAID_CODE_BLOCK", "Final blueprint must use whiteboard blocks, not Mermaid code blocks.")
|
|
172
497
|
|
|
498
|
+
first_flow_start: int | None = None
|
|
499
|
+
for _, title, section in extract_heading_sections(xml):
|
|
500
|
+
if re.search(r"流程[一二三四五六七八九十\d]+[::]", title):
|
|
501
|
+
first_flow_start = xml.find(section)
|
|
502
|
+
break
|
|
503
|
+
document_design = xml[:first_flow_start] if first_flow_start is not None else xml
|
|
504
|
+
|
|
505
|
+
for label, title_terms in DOCUMENT_MODELING_TABLES.items():
|
|
506
|
+
sections = matching_sections(document_design, title_terms)
|
|
507
|
+
if not sections:
|
|
508
|
+
add_error(
|
|
509
|
+
findings,
|
|
510
|
+
"DOC_MODELING_REVIEW_MISSING",
|
|
511
|
+
f"Missing required blueprint modeling review section: {label}",
|
|
512
|
+
)
|
|
513
|
+
continue
|
|
514
|
+
if not any(re.search(r"<table\b", section, re.I) for section in sections):
|
|
515
|
+
add_error(
|
|
516
|
+
findings,
|
|
517
|
+
"DOC_MODELING_TABLE_MISSING",
|
|
518
|
+
f"Blueprint modeling review must be presented as a table: {label}",
|
|
519
|
+
)
|
|
520
|
+
|
|
521
|
+
matrix_sections = matching_sections(document_design, DOCUMENT_MODELING_TABLES["审批/决策矩阵评估"])
|
|
522
|
+
matrix_text = plain_text(" ".join(matrix_sections))
|
|
523
|
+
for term in MATRIX_ASSESSMENT_TERMS:
|
|
524
|
+
if matrix_sections and term not in matrix_text:
|
|
525
|
+
add_error(
|
|
526
|
+
findings,
|
|
527
|
+
"DOC_MATRIX_BOUNDARY_MISSING",
|
|
528
|
+
f"Approval/decision matrix assessment must distinguish: {term}",
|
|
529
|
+
)
|
|
530
|
+
validate_matrix_design(findings, matrix_sections)
|
|
531
|
+
|
|
173
532
|
flows = extract_flows(xml)
|
|
174
533
|
if not flows:
|
|
175
534
|
add_error(findings, "FLOW_SECTION_MISSING", "No flow sections matching 流程X: were found.")
|
|
535
|
+
validate_navigation_design(findings, xml, flows)
|
|
536
|
+
validate_permission_design(findings, xml, flows)
|
|
176
537
|
|
|
177
538
|
for flow in flows:
|
|
178
539
|
flow_text = plain_text(flow.content)
|
|
@@ -188,6 +549,26 @@ def lint(xml: str, require_terms: list[str], forbid_terms: list[str]) -> tuple[l
|
|
|
188
549
|
add_error(findings, "FLOW_REQUIRED_CONTENT_MISSING", f"Missing per-flow content: {label}", flow.title)
|
|
189
550
|
flow.missing.append(label)
|
|
190
551
|
|
|
552
|
+
for label, title_terms in FLOW_DETAIL_TABLES.items():
|
|
553
|
+
sections = matching_sections(flow.content, title_terms)
|
|
554
|
+
if not sections:
|
|
555
|
+
add_error(
|
|
556
|
+
findings,
|
|
557
|
+
"FLOW_DETAIL_SECTION_MISSING",
|
|
558
|
+
f"Missing per-flow detail section required for tabular implementation: {label}",
|
|
559
|
+
flow.title,
|
|
560
|
+
)
|
|
561
|
+
flow.missing.append(f"{label} section")
|
|
562
|
+
continue
|
|
563
|
+
if not any(re.search(r"<table\b", section, re.I) for section in sections):
|
|
564
|
+
add_error(
|
|
565
|
+
findings,
|
|
566
|
+
"FLOW_DETAIL_TABLE_MISSING",
|
|
567
|
+
f"Per-flow implementation detail must be presented as a table: {label}",
|
|
568
|
+
flow.title,
|
|
569
|
+
)
|
|
570
|
+
flow.missing.append(f"{label} table")
|
|
571
|
+
|
|
191
572
|
if "AI" in flow_text or "agent" in flow_text or "Agent" in flow_text:
|
|
192
573
|
for term in AI_REQUIRED_TERMS:
|
|
193
574
|
if term not in flow_text:
|
|
@@ -72,7 +72,11 @@ bpmax-cli config dataset-field delete --id <id> --profile <profile> --confirm "d
|
|
|
72
72
|
## 字段结构门禁
|
|
73
73
|
- 普通项目字段优先使用 `classify=project`,来源通常是 `think_form_field`、`source_field`、`source_fk` 和可选 `source_filter`。
|
|
74
74
|
- `virtual` 字段必须显式配置 SQL、输出字段、关联字段;`virtual.sql -> sourceTable`、`virtual.outputField -> sourceField`、`virtual.joinField -> sourceFk`。
|
|
75
|
-
- `nested`
|
|
75
|
+
- `nested` 仅用于对象数组中需要保持同一数组元素内字段关联查询的结构;附件、快照、汇总对象及单值人员/组织对象优先建模为 `object` mapping 或抽平基础字段,不要因为来源是 JSON 就默认选择 `nested`。
|
|
76
|
+
- 排序、聚合、身份匹配优先抽平为 `keyword/integer/float/date` 等稳定字段;转换既有 nested 前检查列表、筛选、详情和看板是否使用 nested query。
|
|
77
|
+
- dataset-field.type 只允许 `keyword/text/integer/float/date/dynamic/nested`;`object/long/double` 属于 Elasticsearch mapping 类型,只能在数据集级 `post_es_mapping` 中使用。
|
|
78
|
+
- JSON 字符串字段需要解析时必须配套空值保护和 `JSON.parse` 类 `postScript`,不要让空值直接抛错。
|
|
79
|
+
- `think_project`、`think_form_field` 来源字段和 filter key 必须通过 typed lint 的权威列清单;未知来源表只作为运行态验证警告,审计/回填元数据不得塞进 `source_filter`。
|
|
76
80
|
- 字段级 `post_script` 只处理当前字段值,返回值会替换该字段值;不要把它当成整个数据集后处理脚本。
|
|
77
81
|
- `advanced` 字段只在原始详情或用户要求存在时保留;不存在不发,空字符串表示用户明确清空。
|
|
78
82
|
- 遇到 `FF::S::...` / `FF::J::...` 占位符时,必须继续展开到同目录文件,不得把占位符当最终内容。
|
|
@@ -123,7 +127,7 @@ bpmax-cli config dataset-field delete --id <id> --profile <profile> --confirm "d
|
|
|
123
127
|
|
|
124
128
|
## 输出要求
|
|
125
129
|
- 输出必须包含:操作模式、目标字段、当前 `flow_type` / `flow_key` / `data_set_id`、work 文件、impact 报告、submit 文件、response 文件、verify 结果和只读展示验收结果。
|
|
126
|
-
- 变更说明按 `requested` / `required-collateral` / `out-of-scope`
|
|
130
|
+
- 变更说明按 `requested` / `required-collateral` / `out-of-scope` 分类;只有 submit diff 含未经授权的 `out-of-scope` 变化时才停止并待确认。
|
|
127
131
|
- 对非用户原始直述的联动改动,说明为什么是 `required-collateral`,不改会有什么风险,以及是否已逐项确认。
|
|
128
132
|
- 高风险点必须显式说明:`virtual` 关联字段、`nested` JSON 解析、`postScript` 查询方式、`flow_key` 省略、只读展示是否已验证。
|
|
129
133
|
- 必须列出数据集、列表、筛选、详情、看板、流程脚本中的引用检查结果和下一步建议;统一规则见 `../bpmax-builder-shared/configuration-impact-review.md`。
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
# Nested 字段模式
|
|
2
2
|
|
|
3
|
-
##
|
|
4
|
-
-
|
|
5
|
-
-
|
|
6
|
-
-
|
|
3
|
+
## 适用条件
|
|
4
|
+
- 原始值是对象数组。
|
|
5
|
+
- 查询必须保持同一数组元素内多个属性的关联语义,例如“同一个成员同时满足角色和组织条件”。
|
|
6
|
+
- 列表、筛选、详情或看板确实使用 Elasticsearch nested query。
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
- `store`
|
|
10
|
-
- `功能负责人`
|
|
11
|
-
- `HRBP`
|
|
8
|
+
附件、快照、汇总对象以及单值人员/组织对象不满足上述条件时,优先在数据集级 `post_es_mapping` 使用 `object`,或抽平为稳定基础字段。
|
|
12
9
|
|
|
13
10
|
## 默认脚本模板
|
|
14
11
|
```js
|
|
@@ -22,3 +19,6 @@ return JSON.parse(ctx.value);
|
|
|
22
19
|
- 原始值是 JSON 字符串时,默认补 `post_script`
|
|
23
20
|
- 空值时要先保护
|
|
24
21
|
- 如果真实值应为数组,可改为 `return JSON.parse(ctx.value || '[]')`
|
|
22
|
+
- 排序、聚合和身份匹配优先抽平为 `keyword/integer/float/date` 字段
|
|
23
|
+
- 从既有 `nested` 转为 `object` 前,检查所有 nested query 消费方
|
|
24
|
+
- 数据集有效 nested 数还要加平台固定的 3 个保留字段;接近 50 时查看 lint/build 的 `dataset_mapping`
|
|
@@ -26,7 +26,7 @@ description: "用于通过 bpmax-cli typed config 创建、编辑、发布、暂
|
|
|
26
26
|
|
|
27
27
|
## 标准闭环
|
|
28
28
|
1. 读取 `bpmax-memory-protocol` 和当前目录 `MEMORY.md` 中与 `flow_type`、`flow_key`、数据集名、`custom_key`、默认位、脚本和字段关联相关的上下文。
|
|
29
|
-
2. 确认需求范围,输出 `requested / required-collateral / out-of-scope
|
|
29
|
+
2. 确认需求范围,输出 `requested / required-collateral / out-of-scope`;submit diff 中不得包含未经授权的 `out-of-scope` 变化,所有 `required-collateral` 必须逐项解释并取得确认。
|
|
30
30
|
3. 从线上最新配置开始。若只有列表页、名称或 `custom_key`,先通过 typed readback/export 或只读列表解析唯一远端 ID;不要猜 ID。
|
|
31
31
|
4. 导出 structured work:
|
|
32
32
|
- `bpmax-cli config dataset export --id <id> --out .codex/tmp/dataset-editor --profile <profile> --format json`
|
|
@@ -48,8 +48,8 @@ description: "用于通过 bpmax-cli typed config 创建、编辑、发布、暂
|
|
|
48
48
|
12. 新建数据集时,`work.mode` 与 `meta.mode` 都必须是 `create`;提交后读取标准响应顶层 `id`、`key`、`readback_hint`,再执行 verify/readback。
|
|
49
49
|
- `bpmax-cli config dataset submit --id create --payload <submit-file> --profile <profile> --format json`
|
|
50
50
|
- `bpmax-cli config dataset submit --id create --payload <submit-file> --profile <profile> --confirm "submit dataset create" --response-out .codex/tmp/dataset-editor/result/<file>.response.json --format json`
|
|
51
|
-
13. 提交后必须运行 `bpmax-cli config dataset verify --id <id> --expect <work-file> --profile <profile> --format json
|
|
52
|
-
14. 若影响 ES 文档内容、字段、权限、可见范围、脚本、关系或 mapping
|
|
51
|
+
13. 提交后必须运行 `bpmax-cli config dataset verify --id <id> --expect <work-file> --profile <profile> --format json`,先确认最新 readback 中的 `post_es_mapping` 与 work 一致;mapping 回读不正确时禁止 refresh。
|
|
52
|
+
14. 若影响 ES 文档内容、字段、权限、可见范围、脚本、关系或 mapping,仅在 mapping 回读正确后优先执行 typed `dataset refresh`(命令会按状态编排 pause/publish)并回读状态;只有明确的首次发布、暂停或取消卡住刷新场景才单独使用对应生命周期命令。首次 refresh 失败时先读最早的索引创建错误和最新配置,只允许一次有证据的有界重试,不得盲目循环刷新。
|
|
53
53
|
|
|
54
54
|
## 必读 Reference 路由
|
|
55
55
|
| 场景 | 必读 reference |
|
|
@@ -69,6 +69,8 @@ description: "用于通过 bpmax-cli typed config 创建、编辑、发布、暂
|
|
|
69
69
|
- `relationFields` 回包不能直接当最终字段集合;更新字段关联后必须再次执行 readback/export,以详情里的 `dataSetFields` / `fields` 作为当前有效字段集合。
|
|
70
70
|
- export、lint、build、verify 使用同一份 canonical dataset schema;`dataSetFields`、`relationFields`、`fields` 只是在不同接口阶段的别名,比较时按字段 key 归一化,不能因返回字段名或持久化顺序不同误报 mismatch。
|
|
71
71
|
- 字段大改、创建新数据集或影响 ES mapping 时,保存成功不等于列表可用;必须检查发布状态、批次、ES 数据和页面读取。
|
|
72
|
+
- lint/build 输出的 `dataset_mapping` 是 nested 预算证据:平台固定占用 3 个 nested 字段;只有静态分析完整且 `effective_nested_count > 50` 才阻断,`>=40` 只预警,动态脚本只要求运行态验证。
|
|
73
|
+
- dataset-field 的 `nested` 与 Elasticsearch mapping 的 `object/long/double` 等类型属于不同层级;`post_es_mapping` 中合法 ES 类型不得按 dataset-field 类型表误判。
|
|
72
74
|
- 删除旧数据集或旧字段关联时,默认按软删除理解;验收时不要被 `is_del=1` 历史记录误导。
|
|
73
75
|
- 替换旧数据集或默认数据集时,必须额外检查列表模板、看板模板、筛选器、详情模板和其它页面模板是否写死旧 `data_set_id`。
|
|
74
76
|
|
|
@@ -85,7 +87,9 @@ description: "用于通过 bpmax-cli typed config 创建、编辑、发布、暂
|
|
|
85
87
|
- 字段关联必须确认 `source_table`、`source_field`、`source_fk`、字段类型、展示名和排序,不得只凭字段中文名猜测。
|
|
86
88
|
- 大批量新增字段时优先使用 batch manifest,并保留每行 response;不要因为一行失败丢掉整批上下文。
|
|
87
89
|
- 字段关联提交后必须回读详情集合;如果列表、筛选器或看板仍看不到字段,继续核对页面模板绑定,而不是重复提交 relationFields。
|
|
88
|
-
-
|
|
90
|
+
- `nested` 仅用于对象数组中需要保持“同一数组元素内字段关联”查询语义的字段;附件、快照、汇总对象及单值人员/组织对象优先使用 `object`。
|
|
91
|
+
- 排序、聚合、身份匹配优先把稳定值抽平为 `keyword/integer/float/date` 等基础字段;纯展示对象不要消耗 nested 预算。
|
|
92
|
+
- 把既有 `nested` 改为 `object` 或抽平前,必须检查列表、筛选、详情和看板脚本是否使用 nested query;存在依赖时先列为 `required-collateral`,不得只改 mapping。
|
|
89
93
|
- 如果字段用于权限、归属、经销商/门店/区域聚合,必须保留稳定身份键,不能只保留展示名。
|
|
90
94
|
|
|
91
95
|
## 脚本与查询门禁
|
|
@@ -97,6 +101,8 @@ description: "用于通过 bpmax-cli typed config 创建、编辑、发布、暂
|
|
|
97
101
|
- 禁止先拉取大批 ES 数据再在脚本里 `find/filter/some`;必须直接查询需要的数据并控制 `size`。
|
|
98
102
|
- 禁止把 `raw-es-search`、`ctx.$esQuery(...)` 或 `/bpmax/project/list` 放进逐条 SN / 项目 / 团队循环形成 N+1;必须批量 terms、aggregation 或预计算。
|
|
99
103
|
- date/number 等 ES 强类型字段必须清洗空字符串、非法值,避免整批索引失败。
|
|
104
|
+
- `post_es_mapping` 通过修改 `ctx.mapping` 生效,末尾 `return ctx.mapping` 可以保留但不是必需条件;lint 不应仅因缺少 return 阻断。
|
|
105
|
+
- 排障必须先找本批次最早的索引创建或 mapping 错误;`__id`、`__create_time` 缺失、写入失败和列表空白可能只是索引未成功创建后的次生症状。
|
|
100
106
|
|
|
101
107
|
## 状态、发布和刷新门禁
|
|
102
108
|
- 必须明确区分基础配置编辑、字段关联编辑、状态操作和默认位迁移。
|
|
@@ -50,6 +50,9 @@
|
|
|
50
50
|
- 注意:
|
|
51
51
|
- 先保证 mapping 和真实查询路径一致
|
|
52
52
|
- 不要在字段仍是普通对象或错误类型时,就假设筛选器一定能搜到
|
|
53
|
+
- 只有对象数组需要保持同一数组元素内字段关联查询时才使用 `nested`
|
|
54
|
+
- 附件、快照、汇总和单值人员/组织对象优先 `object`
|
|
55
|
+
- 从 `nested` 转换前检查列表、筛选、详情和看板是否使用 `nested` query
|
|
53
56
|
|
|
54
57
|
### 复杂对象抽平
|
|
55
58
|
- `post_script`
|
|
@@ -63,8 +66,16 @@
|
|
|
63
66
|
- 标识、枚举、编码类通常用 `keyword`
|
|
64
67
|
- 数值、序号、计数类通常用数值型
|
|
65
68
|
- 时间筛选字段通常用 `date`
|
|
69
|
+
- Elasticsearch mapping 类型与 dataset-field 类型不是同一套枚举;`object`、`long`、`double` 等可以合法出现在 `post_es_mapping`,但不能作为 dataset-field.type。
|
|
66
70
|
- 这是一条可选兼容路径,不是 `nested/object` 搜索的唯一方案
|
|
67
71
|
|
|
72
|
+
## Nested 预算与静态分析
|
|
73
|
+
- BPMAX 当前平台固定加入 `__step_owners`、`__project_owner`、`__pending_taskusers` 3 个 nested 字段,ES 上限为 50。
|
|
74
|
+
- lint/build 计算业务基础数量、脚本新增/降级覆盖和有效数量;只有脚本可完整静态分析且有效数量超过 50 才阻断。
|
|
75
|
+
- 直接属性赋值、常量 mapping 对象、常量字段数组 `forEach` 可静态识别。
|
|
76
|
+
- 动态属性、条件分支或运行时生成 mapping 只输出 `runtime_verification_required`;此时必须通过索引创建、写入、查询和页面显示验证。
|
|
77
|
+
- 服务端使用脚本直接修改 `ctx.mapping`;`return ctx.mapping` 可用于可读性和兼容既有写法,但缺少 return 本身不是错误。
|
|
78
|
+
|
|
68
79
|
## 常见误区
|
|
69
80
|
- 不要把字段级 `post_script` 当成数据集级 `post_script`
|
|
70
81
|
- 不要把搜索后处理写进数据同步后处理
|
|
@@ -26,3 +26,15 @@
|
|
|
26
26
|
1. 新建成功后先回读详情。
|
|
27
27
|
2. 如需做 `pause -> publish` 闭环,若 `pause` 首次失败,先重新读取详情和列表状态。
|
|
28
28
|
3. 只要详情和列表都能回读到新数据集,不要立刻重建第二个同名数据集。
|
|
29
|
+
|
|
30
|
+
## Nested 字段超限会让索引创建失败
|
|
31
|
+
|
|
32
|
+
### 已验证根因
|
|
33
|
+
- 数据集 944 曾有 82 个业务 `nested` 字段,平台又固定加入 3 个保留 nested 字段,超过 ES `nested_fields.limit=50`。
|
|
34
|
+
- 将其中 42 个仅展示或单值对象字段在 `post_es_mapping` 中改为 `object` 后,项目 3181 成功写入并在真实列表显示。
|
|
35
|
+
|
|
36
|
+
### 排障顺序
|
|
37
|
+
1. 先找本批次最早的索引创建或 mapping 错误,不要从最后一个字段写入异常倒推根因。
|
|
38
|
+
2. 核对 lint/build 的 `dataset_mapping`:基础数、平台 3 个、脚本覆盖、有效数、上限和是否可静态确定。
|
|
39
|
+
3. `__id`、`__create_time` 缺失或列表空白可能是索引未创建成功后的次生症状,不应单独补字段后反复 refresh。
|
|
40
|
+
4. submit 后先 readback 最新 `post_es_mapping`;只有回读正确才 refresh。失败后重新读取最早错误,只允许一次有依据的有界重试。
|