@stalfh233/omc-cli 0.6.67 → 0.6.69

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.
@@ -234,14 +234,20 @@ async function expandButtonActionConfigs(session, viewSchemaCode, buttons) {
234
234
  const targetRow = targetFieldRows.find((row) => String(row.code ?? row.propertyCode ?? "") === assignment.targetDataItemId);
235
235
  if (!targetRow)
236
236
  unresolved(`赋值目标字段 ${targetModel}.${assignment.targetDataItemId} 不在发布面上`);
237
- configureList.push({
237
+ const entry = {
238
238
  currentDataItemId: assignment.currentDataItemId,
239
239
  targetDataItemId: assignment.targetDataItemId,
240
240
  targetDataItem: [{ ...targetRow, schemaCode: targetModel }],
241
241
  currentDataItem: [{ ...sourceRow, schemaCode: viewSchemaCode }],
242
- isConst: "false",
243
- OptionType: "Eq",
244
- });
242
+ isConst: assignment.isConst === "true" ? "true" : "false",
243
+ OptionType: typeof assignment.OptionType === "string" && assignment.OptionType ? assignment.OptionType : "Eq",
244
+ };
245
+ // r73 #5 后半(线上 #40):常量赋值(isConst:"true")→ 平台读面对的键名是
246
+ // currentDataInput(issue 8.6.41 实测读回该键);写面此前硬编码 isConst:"false"
247
+ // 并把该参数丢掉,导致「读面有常量值、写面表达不了」。现在原样透传。
248
+ if (entry.isConst === "true")
249
+ entry.currentDataInput = assignment.currentDataInput;
250
+ configureList.push(entry);
245
251
  }
246
252
  }
247
253
  const { targetModel: _tm, targetForm: _tf, configureList: _cl, ...rest } = button;
@@ -254,6 +260,51 @@ export function filterDefaultSystemColumns(columns, hideDefaultSystemFields) {
254
260
  return [...columns];
255
261
  return columns.filter((column) => typeof column.propertyCode !== "string" || !SYSTEM_FIELD_CODES.has(column.propertyCode));
256
262
  }
263
+ /**
264
+ * r73 #5(GitLab #40 P1,CloudPivot 8.6.41 实测):listview FLOW 按钮读写不对称。
265
+ * 写面 buttons[].targetCode(FLOW 必填)被展开进
266
+ * actionConfig.WorkflowListData[0].workflowCode(见 expandButtonActionConfigs);
267
+ * 读面 button.targetCode 恒为 null,真值只在 actionConfig(可能是 JSON 字符串或
268
+ * 对象;PowerShell ConvertFrom-Json 会把单元素数组展开成单个对象——两种形状都收)。
269
+ * workflowCode 可能 ≠ 模型 code(如 case_delay_apply 的流程 code 是
270
+ * case_delay_apply_flow)。读面统一从这里回填 targetCode 并带来源标注。
271
+ */
272
+ export const FLOW_TARGET_CODE_SOURCE = "actionConfig.WorkflowListData[0].workflowCode";
273
+ export function flowWorkflowCodeFromActionConfig(rawConfig) {
274
+ let parsed;
275
+ if (typeof rawConfig === "string" && rawConfig.trim() !== "") {
276
+ try {
277
+ const value = JSON.parse(rawConfig);
278
+ if (value !== null && typeof value === "object" && !Array.isArray(value))
279
+ parsed = value;
280
+ }
281
+ catch {
282
+ parsed = undefined;
283
+ }
284
+ }
285
+ else if (rawConfig !== null && typeof rawConfig === "object" && !Array.isArray(rawConfig)) {
286
+ parsed = rawConfig;
287
+ }
288
+ const list = parsed?.WorkflowListData;
289
+ // 数组是 wire 真形;单对象是 PowerShell 展开形(8.6.41 实测)——都取 [0].workflowCode。
290
+ const entries = Array.isArray(list) ? list : list !== null && typeof list === "object" && !Array.isArray(list) ? [list] : [];
291
+ for (const entry of entries) {
292
+ if (entry !== null && typeof entry === "object" && !Array.isArray(entry)) {
293
+ const code = entry.workflowCode;
294
+ if (typeof code === "string" && code.length > 0)
295
+ return code;
296
+ }
297
+ }
298
+ return null;
299
+ }
300
+ /** FLOW 回填判定:bindAction=FLOW 且行上的 targetCode 不是非空字符串时,从 actionConfig 反解。 */
301
+ function flowTargetBackfill(button) {
302
+ if (button.bindAction !== "FLOW")
303
+ return null;
304
+ if (typeof button.targetCode === "string" && button.targetCode.length > 0)
305
+ return null;
306
+ return flowWorkflowCodeFromActionConfig(button.actionConfig);
307
+ }
257
308
  /**
258
309
  * Decode a BizButtonModel row's `actionConfig` (stored as a JSON STRING) and
259
310
  * pull out the script source. Everything else is passed through so the caller
@@ -277,13 +328,16 @@ export function decodeButtonScript(input) {
277
328
  parsed = rawConfig;
278
329
  }
279
330
  const script = typeof parsed?.scriptData === "string" ? parsed.scriptData : undefined;
331
+ // r73 #5:FLOW 读面回填——targetCode 恒 null 时从 actionConfig 取真值并标注来源。
332
+ const flowBackfill = flowTargetBackfill(button);
280
333
  return {
281
334
  code: button.code ?? null,
282
335
  name: button.name ?? null,
283
336
  useLocation: button.useLocation ?? null,
284
337
  bindAction: button.bindAction ?? null,
285
338
  operateType: button.operateType ?? null,
286
- targetCode: button.targetCode ?? null,
339
+ targetCode: (typeof button.targetCode === "string" && button.targetCode.length > 0 ? button.targetCode : flowBackfill) ?? null,
340
+ ...(flowBackfill !== null ? { targetCodeSource: FLOW_TARGET_CODE_SOURCE } : {}),
287
341
  ...(script !== undefined
288
342
  ? {
289
343
  scriptData: script,
@@ -312,7 +366,7 @@ export function registerListViewLane(tools) {
312
366
  schemaCode: z.string().min(1),
313
367
  code: z.string().optional().describe("视图 code;省略时用默认视图(=schemaCode)"),
314
368
  full: z.boolean().optional().describe("返回 query/get 原始报文(大体积);默认返回列/排序/条件/动作/按钮的紧凑清单"),
315
- buttons: z.boolean().optional().describe("附带按钮明细(code/name/useLocation/bindAction/targetCode + SCRIPT 按钮的 scriptData 原文、actionConfig 解析结果)。按钮脚本存在 h_biz_button.actionConfig.scriptData,不必再翻 artifact"),
369
+ buttons: z.boolean().optional().describe("附带按钮明细(code/name/useLocation/bindAction/targetCode + SCRIPT 按钮的 scriptData 原文、actionConfig 解析结果)。按钮脚本存在 h_biz_button.actionConfig.scriptData,不必再翻 artifact。FLOW:读面 targetCode 回填自 actionConfig.WorkflowListData[0].workflowCode(targetCodeSource;可能≠模型 code)↔ 写面 buttons[].targetCode 必填"),
316
370
  buttonCode: z.string().min(1).optional().describe("只返回这一个按钮的脚本(与 buttons 同效但更省输出);不存在时报 button-absent 并列出可用 code"),
317
371
  capability: capabilityArg,
318
372
  },
@@ -377,13 +431,21 @@ export function registerListViewLane(tools) {
377
431
  buttonCodes: readArray(model, "customButtons").map((button) => button.code).filter((value) => typeof value === "string"),
378
432
  buttonBindings: readArray(model, "customButtons")
379
433
  .filter((button) => typeof button.code === "string")
380
- .map((button) => ({
381
- code: button.code,
382
- ...(button.bindAction !== undefined ? { bindAction: button.bindAction } : {}),
383
- ...(button.targetCode !== undefined ? { targetCode: button.targetCode } : {}),
384
- ...(button.targetModel !== undefined ? { targetModel: button.targetModel } : {}),
385
- ...(button.targetForm !== undefined ? { targetForm: button.targetForm } : {}),
386
- })),
434
+ .map((button) => {
435
+ // r73 #5:紧凑面同样回填 FLOW 的 targetCode(写面必填、读面恒 null 的不对称在这里收口)。
436
+ const flowBackfill = flowTargetBackfill(button);
437
+ return {
438
+ code: button.code,
439
+ ...(button.bindAction !== undefined ? { bindAction: button.bindAction } : {}),
440
+ ...(typeof button.targetCode === "string" && button.targetCode.length > 0
441
+ ? { targetCode: button.targetCode }
442
+ : flowBackfill !== null
443
+ ? { targetCode: flowBackfill, targetCodeSource: FLOW_TARGET_CODE_SOURCE }
444
+ : {}),
445
+ ...(button.targetModel !== undefined ? { targetModel: button.targetModel } : {}),
446
+ ...(button.targetForm !== undefined ? { targetForm: button.targetForm } : {}),
447
+ };
448
+ }),
387
449
  // Button scripts live in h_biz_button.actionConfig (a JSON STRING)
388
450
  // whose `scriptData` holds the source for bindAction=SCRIPT. Surfacing
389
451
  // them here removes the "listview.get → artifact → JSON.parse →
@@ -940,8 +1002,14 @@ export function registerListViewLane(tools) {
940
1002
  }
941
1003
  if (Array.isArray(afterModel.customButtons)) {
942
1004
  const buttons = readArray(afterModel, "customButtons");
1005
+ // r73 #5:configure 读回同样回填 FLOW targetCode(与 listview.get 读面同规则,
1006
+ // 两面对同一配置给同一个答案)。
943
1007
  readback.buttons = buttons
944
- .map(decodeButtonRow)
1008
+ .map((button) => {
1009
+ const decoded = decodeButtonRow(button);
1010
+ const flowBackfill = flowTargetBackfill(button);
1011
+ return flowBackfill !== null ? { ...decoded, targetCode: flowBackfill, targetCodeSource: FLOW_TARGET_CODE_SOURCE } : decoded;
1012
+ })
945
1013
  .sort((a, b) => Number(a.sortKey ?? 0) - Number(b.sortKey ?? 0));
946
1014
  if (args.buttonScripts !== undefined) {
947
1015
  const decoded = buttons.map((button) => decodeButtonScript(button));
@@ -2063,7 +2063,7 @@ export function validateRuleNodeGraph(graph, ruleCode, schemaCode, options = {})
2063
2063
  if (originatorType !== "FIXED" && originatorType !== "DYNAMIC")
2064
2064
  blockers.push({ code: "rule-graph-create-originator", nodeCode, key: "originatorValueType", message: `CREATE 节点 originatorValueType 必须是 FIXED(完整用户对象 JSON 串)/DYNAMIC(字段 code)(当前 "${originatorType}")` });
2065
2065
  else if (node.originatorValue === undefined || node.originatorValue === "")
2066
- blockers.push({ code: "rule-graph-create-originator-value", nodeCode, key: "originatorValue", message: "CREATE 节点缺 originatorValue" });
2066
+ blockers.push({ code: "rule-graph-create-originator-value", nodeCode, key: "originatorValue", message: "CREATE 节点缺 originatorValue。修法:DYNAMIC=人员字段 code(如 creater/发起人字段);FIXED=用户对象数组 JSON 串;若该图来自 rule.get 备份,部分平台版本读面不回传该键(8.6.41 实测)——补值或改用 rule.node.update 只 patch 目标节点" });
2067
2067
  if (node.startWorkflow === true && (typeof node.targetWorkflowCode !== "string" || !node.targetWorkflowCode.trim()))
2068
2068
  blockers.push({ code: "rule-graph-create-workflow-code", nodeCode, key: "targetWorkflowCode", message: "startWorkflow:true 必须带 targetWorkflowCode" });
2069
2069
  // Platform labels (HANDOFF C.2): CREATE.findMainData = 「查找满足条件的主表数据」
@@ -2242,7 +2242,7 @@ export function validateRuleNodeGraph(graph, ruleCode, schemaCode, options = {})
2242
2242
  if (node.childTriggerConditionType !== undefined) {
2243
2243
  const value = String(node.childTriggerConditionType);
2244
2244
  if (!RULE_CHILD_TRIGGER_CONDITION_TYPES.includes(value))
2245
- blockers.push({ code: "rule-graph-child-trigger-condition-type", nodeCode, key: "childTriggerConditionType", message: `节点 childTriggerConditionType "${value}" 不在 ${RULE_CHILD_TRIGGER_CONDITION_TYPES.join("/")}(子表触发数据范围:新增/修改/删除)` });
2245
+ blockers.push({ code: "rule-graph-child-trigger-condition-type", nodeCode, key: "childTriggerConditionType", message: `节点 childTriggerConditionType "${value}" 不在 ${RULE_CHILD_TRIGGER_CONDITION_TYPES.join("/")}——改用合法值 ADD/MODIFY/DELETE(子表触发数据范围:新增/修改/删除)` });
2246
2246
  }
2247
2247
  // dataCondition: 输入数据满足条件时触发执行动作(通用执行门)。
2248
2248
  if (node.dataCondition !== undefined)
@@ -1091,7 +1091,9 @@ export function registerRuntimeDataLane(tools) {
1091
1091
  columns: z.array(z.string().min(1)).optional().describe("列投影别名(=displayFields)"),
1092
1092
  // r29b F9: data.load/save/update 都叫 fields;list 面原先只有 displayFields/columns。
1093
1093
  fields: z.array(z.string().min(1)).optional().describe("列投影别名(=displayFields;与 data.load/data.save/data.update 的 fields 同语义)"),
1094
- orders: z.array(z.object({ field: z.string().min(1), dir: z.enum(["ASC", "DESC"]) })).optional().describe("运行面 query/list 不支持服务端排序;排序请用 listview.configure 的 sorts(视图级)或在本地对 items 排序"),
1094
+ // r73 #4(GitLab #40 P1):只读查询的排序 fallback 首选曾是写操作(listview.configure
1095
+ // 会改线上视图、影响所有用户)。顺序反转——本地排序第一,视图级写操作殿后并注明代价。
1096
+ orders: z.array(z.object({ field: z.string().min(1), dir: z.enum(["ASC", "DESC"]) })).optional().describe("query/list 不支持服务端排序。首选本地排(items[].fields.<字段>;--jq 只投影);listview.configure 的 sorts 是写操作(改线上视图、影响所有用户),仅确需时用"),
1095
1097
  mobile: z.boolean().optional(),
1096
1098
  // r63(b-F12):draftPolicy 此前只能从结果反推——探针无法控制也无法预知
1097
1099
  // 草稿口径。显式开关:false 注入 sequenceStatus≠DRAFT(真机验证可过滤,
@@ -1123,8 +1125,11 @@ export function registerRuntimeDataLane(tools) {
1123
1125
  status: "error",
1124
1126
  blocker: "invalid-input",
1125
1127
  tool: "data.list",
1126
- message: "运行面 query/list 不支持服务端排序;排序请用 listview.configure 的 sorts(视图级)或在本地对 items 排序。",
1127
- nextCommand: `omc call listview.configure --env <env> --args '${JSON.stringify({ schemaCode: args.schemaCode, sorts: args.orders })}'`,
1128
+ // r73 #4(GitLab #40 P1):旧文案把写操作(listview.configure 改线上视图)放在
1129
+ // 首位、nextCommand 直接指向它——只读查询的 fallback 不该默认引向写。本地排序
1130
+ // 第一(并说清怎么排),视图级写操作放末尾并注明影响所有用户。
1131
+ message: "运行面 query/list 不支持服务端排序。排序请先在本地做:用本工具取回数据(全量 all:true 或逐页翻页),再按 items[].fields.<字段> 在本地排序(--jq 只能投影不能排序,需用客户端脚本/管道排)。只有确实要改**视图级**默认排序时才用 listview.configure 的 sorts(写操作:会改线上视图排序、影响所有用户,谨慎)。",
1132
+ nextCommand: `omc call data.list --env <env> --args '${JSON.stringify({ schemaCode: args.schemaCode, all: true })}'(取回全量后本地排序)`,
1128
1133
  });
1129
1134
  let condition;
1130
1135
  let fromDsl = false;
@@ -149,6 +149,9 @@ const READ_SHAPES = {
149
149
  },
150
150
  "listview.get": {
151
151
  keys: ["present", "published", "lifecycle", "columns[]"],
152
+ // r73 #5(GitLab #40 P1,8.6.41 实测):FLOW 按钮读写不对称的对照表。
153
+ // returnsFace 只显 notes[0],教学并进首条。
154
+ notes: ["FLOW:读面 targetCode 回填自 actionConfig.WorkflowListData[0].workflowCode(targetCodeSource 标注;可能≠模型 code)↔ 写面 buttons[].targetCode 必填"],
152
155
  },
153
156
  "service.list": {
154
157
  // r28f F1:行内带 adapterCode;顶栏 adapterDistribution 是选型聚合。
@@ -761,6 +761,116 @@ export async function computeCarriedNodeCodes(session, schemaCode, ruleCode, pre
761
761
  return undefined; // 取不到存量图 → 维持严格闭集,行为与放宽前一致
762
762
  }
763
763
  }
764
+ /**
765
+ * A5 写前 gate(2026-11-03 issue):平台设计器只接受 中文/字母/数字、≤50 字符的
766
+ * 规则名。违规名 create 能落库(平台不拦),但设计器打开即报「规则名称仅支持
767
+ * 输入中文、字母和数字」且无法编辑——产出一个 UI 不可维护的 landmine。
768
+ * 只约束自定义规则(预置触发行的 name 属平台,见 executeRuleSaveWrite 的
769
+ * isPresetRule 分支)。
770
+ *
771
+ * r73 #1(GitLab #40):同一校验此前只在 executeRuleSaveWrite(execute 面)里,
772
+ * dry-run 不跑 → 「dry-run 过、真写拒」。导出后 write.ts semanticGate(rule.save
773
+ * 的 dry-run 与真写)与 rule.node.update 的 dryRunPayload 共用本函数,dry-run 与
774
+ * 真写同答案;语义(正则/适用范围/报错文案)与原内联版逐字节一致。
775
+ */
776
+ export function assertRuleNamePlatformAcceptable(ruleCode, name) {
777
+ if (PLATFORM_TRIGGER_RULE_CODES.has(ruleCode))
778
+ return;
779
+ if (typeof name !== "string")
780
+ return;
781
+ if (/^[\u4e00-\u9fa5A-Za-z0-9]{1,50}$/.test(name))
782
+ return;
783
+ throw new ToolRefusalError({
784
+ status: "refused",
785
+ blocker: "rule-name-invalid",
786
+ message: `规则 name「${name.slice(0, 60)}」不符合平台约束:仅支持中文/字母/数字,长度 1-50(设计器校验;违规名虽能落库,但设计器无法再编辑该规则)。建议改为纯中文或字母数字命名。`,
787
+ });
788
+ }
789
+ /**
790
+ * The ONE write-face graph lint (r73 #1, GitLab #40): prepareRuleGraph →
791
+ * carried-node relaxation → validateRuleNodeGraph → session-aware warnings
792
+ * (radio-condition / CREATE-flow-start) → the local refusal gates
793
+ * (formula-lint / rule-graph-validation-failed / routes-empty).
794
+ *
795
+ * executeRuleSaveWrite runs it before the real write; `rule.node.update`'s
796
+ * dryRunPayload runs it on the patched graph so a dry-run answers the SAME
797
+ * 能写/不能写 question as the real write — previously the dry-run only
798
+ * returned a plan (8.6.41 live: an empty originatorValue passed dry-run and
799
+ * was refused at execute). No second write path is introduced: this function
800
+ * only lints and refuses.
801
+ */
802
+ export async function lintRuleGraphForWrite(session, args, options = {}) {
803
+ // Pre-flight dry lint (ticket 14): a mis-shaped graph must be refused BEFORE
804
+ // any wire call, with structured blockers locating the node/key — never
805
+ // silently forwarded to the platform (ticket 09 lesson).
806
+ //
807
+ // Preset trigger rules (Create/Update/Delete) route the trigger-row write
808
+ // through the platform system node; the adapter injects it when absent
809
+ // before linting, so the caller only authors their action nodes (ticket 17
810
+ // live finding: dropping SYSTEM_CREATE pinned the row to DRAFT).
811
+ //
812
+ // Ticket 80: a button/flow-triggered rule (explicit customTrigger signal)
813
+ // gets the platform's CUSTOM_NODE 「自定义按钮/流程触发」 system trigger node
814
+ // synthesized after START when the caller did not author one, and EVERY
815
+ // route leaves with explicit string coordinates (empty points break the
816
+ // designer canvas).
817
+ //
818
+ // Ticket 80 + CFG-02/CFG-26: ONE normalization shared with the write
819
+ // preflight (prepareRuleGraph), so preview and execute validate the same
820
+ // graph: preset system node → button/flow CUSTOM_NODE trigger → route shape.
821
+ const prepared = prepareRuleGraph(args.ruleCode, args.nodeGraph, args.customTrigger, args.schemaCode);
822
+ const preparedGraph = prepared.graph;
823
+ // 回读差异放宽(中冶 2026-10-16):更新已存在规则时取存量图逐节点比对,
824
+ // 与存量完全一致的"原样携带"节点免闭集硬校验(设计器 UI 独有算子降级
825
+ // legacy warning 原样回传);新增/改动节点维持严格。存量永远可编辑。
826
+ const carriedNodeCodes = await computeCarriedNodeCodes(session, args.schemaCode, args.ruleCode, preparedGraph);
827
+ const blockers = [...prepared.warnings, ...validateRuleNodeGraph(preparedGraph, args.ruleCode, typeof args.schemaCode === "string" ? args.schemaCode : undefined, carriedNodeCodes ? { carriedNodeCodes } : {})];
828
+ const nodeArray = Array.isArray(preparedGraph.nodes) ? preparedGraph.nodes : [];
829
+ // 1.2: needs the published field types (pure lint cannot see them).
830
+ blockers.push(...(await radioConditionWarnings(session, args.schemaCode, nodeArray)));
831
+ // r24 反馈(2026-10-27 真机四格矩阵):CREATE 目标带已发布流程时的发起开关教学/拦截。
832
+ blockers.push(...(await createNodeFlowStartWarnings(session, nodeArray)));
833
+ // Ticket 113: warning-severity findings (e.g. unknown mapping keys) do not
834
+ // gate the write; they surface in the readback as lintWarnings.
835
+ const warningFindings = blockers.filter((blocker) => blocker.severity === "warning");
836
+ // `hazard` warnings stay non-gating but are surfaced separately: the readback
837
+ // must not let an always-true condition or an inert trigger look like a
838
+ // plain advisory.
839
+ const lintWarnings = warningFindings.filter((blocker) => blocker.hazard !== true);
840
+ const lintHazards = warningFindings.filter((blocker) => blocker.hazard === true);
841
+ const formulaWarnings = lintWarnings.filter((finding) => FORMULA_LINT_CODES.has(finding.code));
842
+ if (formulaWarnings.length > 0 && args.allowAdvisory !== true) {
843
+ throw new ToolRefusalError({
844
+ status: "refused",
845
+ blocker: "formula-lint-failed",
846
+ validation: formulaWarnings,
847
+ nextCommand: "将未知函数改为平台注册函数(文本拼接使用 STRING),仅调查时显式传 allowAdvisory:true",
848
+ message: "公式写前校验拒绝:发现未知函数、平台别名或字符串 + 拼接。请修正公式;调查用途可显式 allowAdvisory:true(默认 fail-closed)。",
849
+ });
850
+ }
851
+ if (blockers.some((blocker) => blocker.severity !== "warning")) {
852
+ throw new ToolRefusalError({
853
+ status: "refused",
854
+ blocker: "rule-graph-validation-failed",
855
+ message: options.validationRefusalMessage ?? "nodeGraph 未过出门前校验(dry lint);按 validation 逐项修正,校验器不猜不改",
856
+ validation: blockers,
857
+ });
858
+ }
859
+ const nodes = nodeArray;
860
+ const routes = Array.isArray(preparedGraph.routes) ? preparedGraph.routes : [];
861
+ // r15 harness finding: a multi-node graph with ZERO routes SAVES fine but the
862
+ // platform publish answers 550014 孤立节点 for every non-boundary node — the
863
+ // usual cause is the WRONG edge key (edges/from/to instead of routes/
864
+ // preNode/postNode, silently stripped). Refuse at the save gate, name the
865
+ // right shape, save the publish round-trip.
866
+ if (nodes.length >= 2 && routes.length === 0)
867
+ throw new ToolRefusalError({
868
+ status: "refused",
869
+ blocker: "rule-graph-routes-empty",
870
+ message: `图有 ${nodes.length} 个节点但 0 条 routes——平台发布会判「孤立节点」(550014)。边用 routes:[{preNode:"Start",postNode:"UPDATE_1"},...](不是 edges/from/to,那会被静默剥掉)`,
871
+ });
872
+ return { preparedGraph, blockers, lintWarnings, lintHazards, nodes, routes };
873
+ }
764
874
  /**
765
875
  * 550018 is the platform's catch-all "rule self-check failed" (ErrorCode
766
876
  * BUSINESS_RULE_PARAM_ERROR from BusinessRuleFacadeImpl.publishBusinessRule when
@@ -846,74 +956,10 @@ export async function modelWorkflowDispatchWarning(session, schemaCode) {
846
956
  }
847
957
  }
848
958
  export async function executeRuleSaveWrite(session, args) {
849
- // Pre-flight dry lint (ticket 14): a mis-shaped graph must be refused BEFORE
850
- // any wire call, with structured blockers locating the node/key — never
851
- // silently forwarded to the platform (ticket 09 lesson).
852
- //
853
- // Preset trigger rules (Create/Update/Delete) route the trigger-row write
854
- // through the platform system node; the adapter injects it when absent
855
- // before linting, so the caller only authors their action nodes (ticket 17
856
- // live finding: dropping SYSTEM_CREATE pinned the row to DRAFT).
857
- //
858
- // Ticket 80: a button/flow-triggered rule (explicit customTrigger signal)
859
- // gets the platform's CUSTOM_NODE 「自定义按钮/流程触发」 system trigger node
860
- // synthesized after START when the caller did not author one, and EVERY
861
- // route leaves with explicit string coordinates (empty points break the
862
- // designer canvas).
863
- const graph = args.nodeGraph;
864
- // Ticket 80 + CFG-02/CFG-26: ONE normalization shared with the write
865
- // preflight (prepareRuleGraph), so preview and execute validate the same
866
- // graph: preset system node → button/flow CUSTOM_NODE trigger → route shape.
867
- const prepared = prepareRuleGraph(args.ruleCode, graph, args.customTrigger, args.schemaCode);
868
- const preparedGraph = prepared.graph;
869
- // 回读差异放宽(中冶 2026-10-16):更新已存在规则时取存量图逐节点比对,
870
- // 与存量完全一致的"原样携带"节点免闭集硬校验(设计器 UI 独有算子降级
871
- // legacy warning 原样回传);新增/改动节点维持严格。存量永远可编辑。
872
- const carriedNodeCodes = await computeCarriedNodeCodes(session, args.schemaCode, args.ruleCode, preparedGraph);
873
- const blockers = [...prepared.warnings, ...validateRuleNodeGraph(preparedGraph, args.ruleCode, typeof args.schemaCode === "string" ? args.schemaCode : undefined, carriedNodeCodes ? { carriedNodeCodes } : {})];
874
- // 1.2: needs the published field types (pure lint cannot see them).
875
- blockers.push(...(await radioConditionWarnings(session, args.schemaCode, Array.isArray(preparedGraph.nodes) ? preparedGraph.nodes : [])));
876
- // r24 反馈(2026-10-27 真机四格矩阵):CREATE 目标带已发布流程时的发起开关教学/拦截。
877
- blockers.push(...(await createNodeFlowStartWarnings(session, Array.isArray(preparedGraph.nodes) ? preparedGraph.nodes : [])));
878
- // Ticket 113: warning-severity findings (e.g. unknown mapping keys) do not
879
- // gate the write; they surface in the readback as lintWarnings.
880
- const warningFindings = blockers.filter((blocker) => blocker.severity === "warning");
881
- // `hazard` warnings stay non-gating but are surfaced separately: the readback
882
- // must not let an always-true condition or an inert trigger look like a
883
- // plain advisory.
884
- const lintWarnings = warningFindings.filter((blocker) => blocker.hazard !== true);
885
- const lintHazards = warningFindings.filter((blocker) => blocker.hazard === true);
886
- const formulaWarnings = lintWarnings.filter((finding) => FORMULA_LINT_CODES.has(finding.code));
887
- if (formulaWarnings.length > 0 && args.allowAdvisory !== true) {
888
- throw new ToolRefusalError({
889
- status: "refused",
890
- blocker: "formula-lint-failed",
891
- validation: formulaWarnings,
892
- nextCommand: "将未知函数改为平台注册函数(文本拼接使用 STRING),仅调查时显式传 allowAdvisory:true",
893
- message: "公式写前校验拒绝:发现未知函数、平台别名或字符串 + 拼接。请修正公式;调查用途可显式 allowAdvisory:true(默认 fail-closed)。",
894
- });
895
- }
896
- if (blockers.some((blocker) => blocker.severity !== "warning")) {
897
- throw new ToolRefusalError({
898
- status: "refused",
899
- blocker: "rule-graph-validation-failed",
900
- message: "nodeGraph 未过出门前校验(dry lint);按 validation 逐项修正,校验器不猜不改",
901
- validation: blockers,
902
- });
903
- }
904
- const nodes = Array.isArray(preparedGraph.nodes) ? preparedGraph.nodes : [];
905
- const routes = Array.isArray(preparedGraph.routes) ? preparedGraph.routes : [];
906
- // r15 harness finding: a multi-node graph with ZERO routes SAVES fine but the
907
- // platform publish answers 550014 孤立节点 for every non-boundary node — the
908
- // usual cause is the WRONG edge key (edges/from/to instead of routes/
909
- // preNode/postNode, silently stripped). Refuse at the save gate, name the
910
- // right shape, save the publish round-trip.
911
- if (nodes.length >= 2 && routes.length === 0)
912
- throw new ToolRefusalError({
913
- status: "refused",
914
- blocker: "rule-graph-routes-empty",
915
- message: `图有 ${nodes.length} 个节点但 0 条 routes——平台发布会判「孤立节点」(550014)。边用 routes:[{preNode:"Start",postNode:"UPDATE_1"},...](不是 edges/from/to,那会被静默剥掉)`,
916
- });
959
+ // Pre-flight dry lint (ticket 14) lives in lintRuleGraphForWrite (r73 #1):
960
+ // the SAME lint now serves the real write AND `rule.node.update`'s
961
+ // dryRunPayload, so a dry-run answers the same 能写/不能写 question.
962
+ const { preparedGraph, blockers, lintWarnings, lintHazards, nodes, routes } = await lintRuleGraphForWrite(session, args);
917
963
  await assertCreateSelectionCompatibility(session, args.schemaCode, Array.isArray(nodes) ? nodes : []);
918
964
  await assertBizActionMappingFieldsExist(session, args.schemaCode, Array.isArray(nodes) ? nodes : []);
919
965
  // r47a: ordinary UPDATE/CREATE/EXPRESSION references use two distinct
@@ -1053,17 +1099,10 @@ export async function executeRuleSaveWrite(session, args) {
1053
1099
  // Only CUSTOM rule codes take the caller's name. `existing` already carries
1054
1100
  // the platform name, so the spread preserves it.
1055
1101
  const isPresetRule = PLATFORM_TRIGGER_RULE_CODES.has(args.ruleCode);
1056
- // A5 写前 gate(2026-11-03 issue):平台设计器只接受 中文/字母/数字、≤50 字符的
1057
- // 规则名。违规名 create 能落库(平台不拦),但设计器打开即报「规则名称仅支持
1058
- // 输入中文、字母和数字」且无法编辑——产出一个 UI 不可维护的 landmine。
1059
- // 只约束自定义规则(预置触发行的 name 属平台,见上方 isPresetRule 分支)。
1060
- if (!isPresetRule && typeof args.name === "string" && !/^[\u4e00-\u9fa5A-Za-z0-9]{1,50}$/.test(args.name)) {
1061
- throw new ToolRefusalError({
1062
- status: "refused",
1063
- blocker: "rule-name-invalid",
1064
- message: `规则 name「${args.name.slice(0, 60)}」不符合平台约束:仅支持中文/字母/数字,长度 1-50(设计器校验;违规名虽能落库,但设计器无法再编辑该规则)。建议改为纯中文或字母数字命名。`,
1065
- });
1066
- }
1102
+ // A5 写前 gate(2026-11-03 issue):name 字符集校验。r73 #1 起与 write.ts
1103
+ // semanticGate / rule.node.update dryRunPayload 共用同一函数(预置触发行
1104
+ // 在函数内部跳过),dry-run 与真写同答案。
1105
+ assertRuleNamePlatformAcceptable(args.ruleCode, args.name);
1067
1106
  // A8(2026-11-03 issue,8.1.108 实测):`options` / `extensionSetting` 缺席或空串
1068
1107
  // 时平台落 "",8.1 族实体校验要求结构化的默认值——update 回无明细 50000。写前
1069
1108
  // 归一:空串/缺席补平台默认结构(与设计器保存行为一致)。
@@ -114,6 +114,19 @@ const TOOL_INPUT_ALIASES = Object.freeze({
114
114
  "programming.compile": Object.freeze({ businessRuleCode: ["ruleCode"] }),
115
115
  "programming.save": Object.freeze({ businessRuleCode: ["ruleCode"] }),
116
116
  "programming.publish": Object.freeze({ businessRuleCode: ["ruleCode"] }),
117
+ // 线上 #40 第 10 条(2026-11-17):参数键名靠试错。以下四组在实证里
118
+ // 都是「同一对象换了个名字」,且别名在该工具上不与任何合法键冲突:
119
+ // 视图 code(listview 族)在参数表里叫 code,调用方习惯 viewCode;
120
+ "listview.get": Object.freeze({ code: ["viewCode"] }),
121
+ "listview.configure": Object.freeze({ code: ["viewCode"] }),
122
+ // 服务 code(b2 族读面)叫 serviceCode,调用方习惯 code;
123
+ "service.get": Object.freeze({ serviceCode: ["code"] }),
124
+ // 规则引用:查引用时调用方习惯 ruleCode/schemaCode,规范键是 code/schemaCodes。
125
+ // 注意 schemaCode→schemaCodes 是「扫描范围」语义(不是被查对象)——只在
126
+ // 调用方没给 code 时生效;kind=model 想按模型查请显式用 code。
127
+ "rule.references": Object.freeze({ code: ["ruleCode"], schemaCodes: ["schemaCode"] }),
128
+ // r73 探针02-P2:分页条数在 data.list 叫 size,调用方习惯 limit(SQL/REST 肌肉记忆)。
129
+ "data.list": Object.freeze({ size: ["limit"] }),
117
130
  });
118
131
  /**
119
132
  * r54 C② F2:该工具在 TOOL_INPUT_ALIASES 里声明的**同义词键**(调用方可能拿来
package/dist/write.js CHANGED
@@ -24,6 +24,7 @@ import { assertFieldFamilyAllowed } from "./field-families.js";
24
24
  import { validateBusinessCode } from "./code-rules.js";
25
25
  import { hardLayoutViolations, validateFormLayout } from "./form-layout.js";
26
26
  import { prepareRuleGraph, validateRuleNodeGraph } from "./lanes/rule-graph.js";
27
+ import { assertRuleNamePlatformAcceptable } from "./rule-support.js";
27
28
  import { WireError } from "./wire.js";
28
29
  /**
29
30
  * The shared governed write pipeline and the low-level write registration
@@ -399,6 +400,11 @@ export function writeTool(definition) {
399
400
  // Ticket 113: warning-severity findings ride the payload but never gate.
400
401
  if (blockers.some((blocker) => blocker.severity !== "warning"))
401
402
  throw new ToolRefusalError({ status: "refused", blocker: "rule-graph-validation-failed", nextCommand: "omc describe rule.save --example business-rule-branch-conditional", message: "nodeGraph 未过出门前校验(dry lint);按 validation 逐项修正,校验器不猜不改", validation: blockers });
403
+ // r73 #1(GitLab #40):rule name 的字符集校验此前只在
404
+ // executeRuleSaveWrite(execute 面)里,`rule.save --dry-run` 能跑图 lint 却
405
+ // 不跑 name 校验 → dry-run 过、真写拒。同一函数提到本闸后,dry-run 与真写
406
+ // 同答案(预置触发行在函数内部跳过;语义与 execute 面逐字节一致)。
407
+ assertRuleNamePlatformAcceptable(String(args.ruleCode ?? ""), args.name);
402
408
  }
403
409
  // Optional per-tool semantic gate: refuse before the write permission gate
404
410
  // and before any wire call, independent of input-schema validation.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stalfh233/omc-cli",
3
- "version": "0.6.67",
3
+ "version": "0.6.69",
4
4
  "description": "CloudPivot 8.6 configuration capability CLI — governed, fail-closed, coverage-manifest bounded.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -56,7 +56,7 @@
56
56
  },
57
57
  "dependencies": {
58
58
  "commander": "14.0.3",
59
- "omc-core": "0.6.67",
59
+ "omc-core": "0.6.69",
60
60
  "proper-lockfile": "4.1.2",
61
61
  "write-file-atomic": "6.0.0",
62
62
  "zod": "^3.23.8",
@@ -74,6 +74,6 @@
74
74
  "directory": "packages/omc-cli"
75
75
  },
76
76
  "optionalDependencies": {
77
- "@stalfh233/omc-fake-platform": "0.6.67"
77
+ "@stalfh233/omc-fake-platform": "0.6.69"
78
78
  }
79
79
  }