@stalfh233/omc-cli 0.6.80 → 0.6.82

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.
@@ -8,6 +8,8 @@ import { applicationResolutionOf, applicationScopeHint, flattenTreeRows, resolve
8
8
  import { assertRuleNamePlatformAcceptable, executeRuleSaveWrite, lintRuleGraphForWrite, lintRuleSaveWrite, ruleNodeGraphArg } from "../rule-support.js";
9
9
  import { defineTool, isRequiredAlternativePlaceholder, ToolInputError, ToolRefusalError } from "../tool-types.js";
10
10
  import { resolveRuleRowId } from "../identity.js";
11
+ import { extractDataRuleEdges, extractReferenceEdges } from "../graph.js";
12
+ import { scanModelWorkflowBindings } from "./workflow.js";
11
13
  import { wireCall, wireCallWith404Fallback, wireRows } from "../wire.js";
12
14
  import { readModelRecord } from "../model-record.js";
13
15
  import { BUSINESSRULE_LANE_CONTRACT } from "./businessrule-contract.js";
@@ -193,6 +195,76 @@ function ruleSummaryRoundTrip(roundTrip) {
193
195
  gapsHint: "gap 的 message/fix 用 rule.get(不带 summary)取 roundTrip.gaps",
194
196
  };
195
197
  }
198
+ /**
199
+ * r85(retro 2026-11-19 issue 09/11):codeType:7 映射的公式口径注记。
200
+ *
201
+ * - `eqEqParams`:formula 含 `==` —— 服务端(Aviator)规范比较符就是 `==`,
202
+ * `=` 在 IF() 条件内被服务端归一为 `==`(CalculateRuleExecutor.java:704-706),
203
+ * 两种都可在服务端求值;设计器可能对 `==` 标红(已知口径不一致,平台侧)。
204
+ * 工具不改写用户公式,本注记非侵入。
205
+ * - `designerTextParams`:editorText/editorMark 有设计器痕迹(`<field-xxx>` 富
206
+ * 文本,xxx 是设计器随机 nonce)——运行时只读 formula;rule.save 默认保留
207
+ * 这些映射的设计器文本(preservedDesignerText)。
208
+ * - `bareFormulaParams`:只有 formula、无 editorText——设计器以纯文本呈现(可能
209
+ * 标红),运行不受影响。
210
+ */
211
+ const RULE_FORMULA_NOTES_TEXT = "公式口径:服务端(Aviator)规范比较符是 ==;= 在 IF() 条件内被服务端归一后同样可求值(CalculateRuleExecutor.java:704-706),设计器可能对 == 标红(已知不一致,平台侧,工具不改写公式)。editorText 是设计器富文本(<field-xxx>code</field-xxx>;xxx 为设计器随机 nonce,不是字段 id),运行时只读 formula;bareFormulaParams 的映射在设计器以纯文本/标红呈现但运行不受影响,改动它们时 rule.save 默认保留现存设计器文本(preservedDesignerText)";
212
+ function ruleFormulaNotes(nodes) {
213
+ if (!Array.isArray(nodes))
214
+ return undefined;
215
+ const eqEqParams = [];
216
+ const designerTextParams = [];
217
+ const bareFormulaParams = [];
218
+ for (const entry of nodes) {
219
+ if (!entry || typeof entry !== "object" || Array.isArray(entry))
220
+ continue;
221
+ const node = entry;
222
+ const mapping = node.methodMapping;
223
+ if (!mapping || typeof mapping !== "object" || Array.isArray(mapping))
224
+ continue;
225
+ const m = mapping;
226
+ for (const listKey of ["inputMappings", "outputMappings"]) {
227
+ if (!Array.isArray(m[listKey]))
228
+ continue;
229
+ for (const element of m[listKey]) {
230
+ if (!element || typeof element !== "object" || Array.isArray(element))
231
+ continue;
232
+ const row = element;
233
+ if (Number(row.codeType) !== 7 || typeof row.bizCode !== "string")
234
+ continue;
235
+ let expression = null;
236
+ try {
237
+ const parsed = JSON.parse(row.bizCode);
238
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed))
239
+ expression = parsed;
240
+ }
241
+ catch {
242
+ expression = null;
243
+ }
244
+ const formula = expression !== null && typeof expression.formula === "string" ? expression.formula : "";
245
+ if (!formula)
246
+ continue;
247
+ const where = `${String(node.nodeCode ?? "")}/${String(row.serviceMethodParameterCode ?? "")}`;
248
+ if (formula.includes("=="))
249
+ eqEqParams.push(where);
250
+ const editorText = expression !== null && typeof expression.editorText === "string" ? expression.editorText : "";
251
+ const editorMark = expression !== null && typeof expression.editorMark === "string" ? expression.editorMark : "";
252
+ if (editorText.includes("<field-") || editorMark !== "")
253
+ designerTextParams.push(where);
254
+ else
255
+ bareFormulaParams.push(where);
256
+ }
257
+ }
258
+ }
259
+ if (eqEqParams.length === 0 && designerTextParams.length === 0 && bareFormulaParams.length === 0)
260
+ return undefined;
261
+ return {
262
+ eqEqParams,
263
+ designerTextParams,
264
+ bareFormulaParams,
265
+ note: RULE_FORMULA_NOTES_TEXT,
266
+ };
267
+ }
196
268
  /** 摘要面公共体:身份 + 体量 + 节点摘要。正文仍在默认面(nodes/routes)。 */
197
269
  function ruleSummaryBody(record, graph, roundTrip) {
198
270
  const nodes = Array.isArray(graph.nodes) ? graph.nodes : [];
@@ -704,7 +776,7 @@ export function registerBusinessRuleLane(tools) {
704
776
  description: RULE_TOOLS["rule.references"].description,
705
777
  inputSchema: {
706
778
  environment: environmentArg,
707
- kind: z.enum(["service", "model", "field"]).describe("按什么找引用:service=BIZ_ACTION methodMapping.serviceCode;model=CREATE/UPDATE/DELETE targetObjectCode 与 methodMapping.schemaCode;field=dataActions.targetDataItem 与映射 bizCode"),
779
+ kind: z.enum(["service", "model", "field", "rule"]).describe("按什么找引用:service=BIZ_ACTION methodMapping.serviceCode;model=CREATE/UPDATE/DELETE targetObjectCode 与 methodMapping.schemaCode;field=dataActions.targetDataItem、映射 bizCode、规则条件叶子与 datarule;rule=流程事件绑定的规则码(flow 级 handler + 节点级 nodeEvent,扫应用内模型的流程面)"),
708
780
  code: z.string().min(1).describe("要查引用的编码(服务/模型/字段 code);kind=field 可用 schemaCode.field 消歧"),
709
781
  schemaCodes: z.union([z.array(z.string().min(1)), z.string()]).optional().describe("只扫这些模型(省 wire 读);省略=全平台模型"),
710
782
  capability: capabilityArg,
@@ -787,16 +859,82 @@ export function registerBusinessRuleLane(tools) {
787
859
  fieldScope = prefix;
788
860
  }
789
861
  }
862
+ // R79 三期 T-B:kind=rule——查一条规则被哪些流程事件绑定。绑定数据住流程
863
+ // 模板(flow 级四 handler + 节点级八事件的 bizActions),与 rule 图无关,
864
+ // 因此本 kind 不走 rule.list/rule.get 扫描,改扫与 workflow.list 同源的
865
+ // 模型→流程面(scanModelWorkflowBindings 复用 get_published 的
866
+ // ruleBindings/nodeRuleBindings 投影,读回面与检索面同一谓词)。模型没有
867
+ // 流程 = 该模型不可能绑定,如实跳过(scanned.withoutWorkflow 计数)。
868
+ if (args.kind === "rule") {
869
+ const wantedRule = String(args.code);
870
+ const ruleHits = [];
871
+ let scannedWorkflows = 0;
872
+ let withoutWorkflow = 0;
873
+ let readFailures = 0;
874
+ for (const schemaCode of scoped) {
875
+ let face;
876
+ try {
877
+ face = await scanModelWorkflowBindings(session, schemaCode);
878
+ }
879
+ catch {
880
+ readFailures += 1; // 单模型读失败不中断整轮扫描
881
+ continue;
882
+ }
883
+ if (face === null) {
884
+ withoutWorkflow += 1;
885
+ continue;
886
+ }
887
+ scannedWorkflows += 1;
888
+ for (const binding of face.ruleBindings)
889
+ if (binding.ruleCodes.includes(wantedRule))
890
+ ruleHits.push({ schemaCode, workflowCode: face.workflowCode, handler: binding.handler, ruleCodes: binding.ruleCodes, published: face.published, via: "workflow-bindRule" });
891
+ for (const binding of face.nodeRuleBindings)
892
+ if (binding.ruleCodes.includes(wantedRule))
893
+ ruleHits.push({ schemaCode, workflowCode: face.workflowCode, activityCode: binding.activityCode, nodeEvent: binding.nodeEvent, ruleCodes: binding.ruleCodes, published: face.published, via: "workflow-bindRule" });
894
+ }
895
+ return {
896
+ kind: "rule",
897
+ code: wantedRule,
898
+ scanned: { models: scoped.length, workflows: scannedWorkflows, withoutWorkflow, ...(readFailures > 0 ? { readFailures } : {}) },
899
+ matches: ruleHits,
900
+ wire: { plan: "1 模型清单 + 每模型 isworkflow(无流程即止)→ 有流程再 getWorkflow + get_published" },
901
+ coverage: {
902
+ scanned: ["workflow.get_published:ruleBindings+nodeRuleBindings"],
903
+ notScanned: [],
904
+ note: "matches:[] = 扫描范围内没有任何流程事件(flow 级四 handler + 节点级八事件)绑定该规则;流程面按 get_published 读回,未发布流程读回草稿形态(命中行的 published:false 标注,不是已发布证据)",
905
+ },
906
+ ...(args.schemaCodes === undefined && scope !== undefined
907
+ ? { applicationResolution: { ...applicationResolutionOf(scope), mode: scanMode, models: scoped.length } }
908
+ : {}),
909
+ ...(ruleHits.length === 0
910
+ ? {
911
+ note: "零命中(流程绑定面)= " +
912
+ (args.schemaCodes !== undefined
913
+ ? `仅扫描了 schemaCodes 收窄的 ${scoped.length} 个模型(${scoped.slice(0, 5).join(", ")}${scoped.length > 5 ? "…" : ""})——绑定常在**其他**模型的流程上;要全平台结论请去掉 schemaCodes`
914
+ : "扫描范围内没有流程事件绑定该规则") +
915
+ "。规则是否存在于规则面用 rule.list;绑定写法用 workflow.bindRule",
916
+ ...(args.schemaCodes === undefined && scope !== undefined ? { hint: applicationScopeHint(scope, "绑定") } : {}),
917
+ }
918
+ : {
919
+ hint: "在线扫描完成;命中行的流程细节(参与人/节点)用 workflow.get_published {workflowCode} 读回;改绑定走 workflow.bindRule(merge 语义,不会清掉其它绑定)",
920
+ }),
921
+ };
922
+ }
790
923
  const matches = [];
791
924
  let scannedRules = 0;
792
925
  let parseFailures = 0;
926
+ let scannedDataRules = 0;
927
+ let dataRuleReadFailures = 0;
928
+ let childRefsSkipped = 0;
793
929
  for (const schemaCode of scoped) {
794
930
  let rows = [];
795
931
  try {
796
932
  rows = wireRows((await wireCall(session, { path: ENDPOINTS.businessRuleListBySchemaCode, query: { schemaCode } })).data);
797
933
  }
798
934
  catch {
799
- continue; // 模型无规则面(读失败/空)按无规则处理,不让单个模型挡住全扫
935
+ // 模型无规则面(读失败/空)按无规则处理,不让单个模型挡住全扫。
936
+ // R79 三期:kind=field 时仍要扫该模型的 datarule 面——不再 continue,
937
+ // 落到循环尾部的 datarule 块。
800
938
  }
801
939
  for (const row of rows) {
802
940
  const ruleCode = String(row.code ?? "");
@@ -818,6 +956,27 @@ export function registerBusinessRuleLane(tools) {
818
956
  parseFailures += 1;
819
957
  continue;
820
958
  }
959
+ // R79 三期 T-C①:条件叶子(filterCondition/BRANCH 出口/route 兜底/定时
960
+ // filterConditionGroups 的 currentSchemaDataItem、targetSchemaDataItem 与
961
+ // value {字段} 模板)。复用 graph 索引的权威抽取器(含宿主归属与日期偏移
962
+ // 噪音过滤),在线/离线两面同一定义——只取 via==="rule.condition" 边,
963
+ // 动作/映射命中仍由下方在线匹配产出(via 不变)。第一版只认主模型字段:
964
+ // 点号引用(子表)不匹配、计入 childRefsSkipped(不静默)。
965
+ if (args.kind === "field") {
966
+ const routes = decodeJsonColumn(record.route, JSON_COLUMN_NULL_COALESCE);
967
+ const schedulerSetting = decodeJsonColumn(record.schedulerSetting, JSON_COLUMN_NULL_COALESCE);
968
+ for (const edge of extractReferenceEdges(schemaCode, ruleCode, nodes, Array.isArray(routes) ? routes : [], schedulerSetting)) {
969
+ if (edge.via !== "rule.condition" || edge.code !== wanted)
970
+ continue;
971
+ if (edge.code.includes(".")) {
972
+ childRefsSkipped += 1;
973
+ continue;
974
+ }
975
+ if (fieldScope !== undefined && edge.schemaCode !== fieldScope)
976
+ continue;
977
+ matches.push({ schemaCode, ruleCode, nodeCode: edge.nodeCode, nodeType: edge.nodeType, via: "condition-leaf", hostSchemaCode: edge.schemaCode });
978
+ }
979
+ }
821
980
  for (const rawNode of nodes) {
822
981
  const nodeCode = String(rawNode.nodeCode ?? "");
823
982
  const nodeType = String(rawNode.nodeType ?? "");
@@ -849,21 +1008,72 @@ export function registerBusinessRuleLane(tools) {
849
1008
  }
850
1009
  }
851
1010
  }
1011
+ // R79 三期 T-C②:datarule 面(每模型 +1 wire bizdatarule/list)。命中两源:
1012
+ // propertyCodes[](权威目标字段绑定)与 options 里的 {字段code} 文本(跨字段
1013
+ // 公式/条件引用;matchedBy 区分)。options 是自由文本协议——字面匹配可能漏
1014
+ // JSON 形引用({"valueType":"currentModel","value":…}),协议局限在 coverage
1015
+ // note 声明;单模型读失败不中断扫描。第一版只认主模型字段(点号引用跳过)。
1016
+ if (args.kind === "field") {
1017
+ try {
1018
+ const dataRuleRows = wireRows((await wireCall(session, { path: ENDPOINTS.dataRuleList, query: { schemaCode } })).data);
1019
+ scannedDataRules += dataRuleRows.length;
1020
+ for (const row of dataRuleRows) {
1021
+ const matched = extractDataRuleEdges(schemaCode, row).find((edge) => {
1022
+ if (edge.code !== wanted)
1023
+ return false;
1024
+ if (edge.code.includes(".")) {
1025
+ childRefsSkipped += 1;
1026
+ return false;
1027
+ }
1028
+ return true;
1029
+ });
1030
+ if (matched)
1031
+ matches.push({
1032
+ schemaCode,
1033
+ kind: "datarule",
1034
+ ref: String(row.id ?? row.name ?? ""),
1035
+ name: row.name ?? null,
1036
+ dataRuleType: row.dataRuleType ?? null,
1037
+ matchedBy: matched.via === "datarule.targets" ? "propertyCodes" : "options",
1038
+ via: "datarule",
1039
+ });
1040
+ }
1041
+ }
1042
+ catch {
1043
+ dataRuleReadFailures += 1;
1044
+ }
1045
+ }
852
1046
  }
853
1047
  return {
854
1048
  kind: args.kind,
855
1049
  code: wanted,
856
1050
  ...(fieldScope !== undefined ? { requestedCode: rawCode, resolvedScope: { schemaCode: fieldScope, code: wanted } } : {}),
857
- scanned: { models: scoped.length, rules: scannedRules, ...(parseFailures > 0 ? { parseFailures } : {}) },
1051
+ scanned: args.kind === "field"
1052
+ ? {
1053
+ models: scoped.length,
1054
+ rules: scannedRules,
1055
+ datarules: scannedDataRules,
1056
+ ...(parseFailures > 0 ? { parseFailures } : {}),
1057
+ ...(dataRuleReadFailures > 0 ? { dataRuleReadFailures } : {}),
1058
+ ...(childRefsSkipped > 0 ? { childRefsSkipped } : {}),
1059
+ }
1060
+ : { models: scoped.length, rules: scannedRules, ...(parseFailures > 0 ? { parseFailures } : {}) },
858
1061
  matches,
859
- // r35a-F4(真机 2026-11-06):matches:[] 曾被当成「可安全删除」的依据,
860
- // 而探针实测该字段**被表单引用**(form.get draftControlCodes)且出现在
861
- // 流程节点权限里——本面两者都没扫。散文字段不承担安全契约:结构化声明。
862
- coverage: {
863
- scanned: ["businessrule"],
864
- notScanned: ["datarule", "form", "workflow.permissions", "workflow.bindings", "onlinejs", "listview"],
865
- note: "matches:[] 只代表 businessrule 面零命中;datarule/form/流程权限/视图等未扫描(离线 graph references 覆盖更广,见其 coverage),不可据此判定可安全删除",
866
- },
1062
+ // r35a-F4:matches:[] 曾被当成「可安全删除」的依据,而该字段可能**被表单
1063
+ // 引用**(form.get draftControlCodes)且出现在流程节点权限里——散文字段
1064
+ // 不承担安全契约:结构化声明。R79 三期起 kind=field 的覆盖面扩为
1065
+ // 动作/映射 + 条件叶子 + datarule;form/listview/流程字段权限仍不在。
1066
+ coverage: args.kind === "field"
1067
+ ? {
1068
+ scanned: ["businessrule:actions+mappings", "businessrule:condition-leaf", "datarule"],
1069
+ notScanned: ["form", "listview", "onlinejs", "workflow.permissions", "子表字段(条件叶/datarule 的点号引用不匹配)"],
1070
+ note: "matches:[] 只代表上述三面零命中;form/listview/流程字段权限/子表字段未扫描(离线 graph references 覆盖更广,见其 coverage),不可据此判定可安全删除。datarule 的 options 是自由文本协议:matchedBy:options 按 {字段code} 字面匹配,可能漏掉 JSON 形引用(如 currentModel 值对象)——命中/零命中涉 datarule 时建议 datarule.list 复核",
1071
+ }
1072
+ : {
1073
+ scanned: ["businessrule"],
1074
+ notScanned: ["form", "workflow.permissions", "workflow.bindings", "onlinejs", "listview"],
1075
+ note: "matches:[] 只代表 businessrule 面零命中;form/流程权限/视图等未扫描(离线 graph references 覆盖更广,见其 coverage),不可据此判定可安全删除",
1076
+ },
867
1077
  // r73 #3:app-scope 路径回显 applicationResolution(含 mode/models:扫了
868
1078
  // 哪个应用、共几个模型)。显式 schemaCodes 路径维持原形状(无
869
1079
  // applicationResolution/hint——显式范围自带出处,provenance 契约不变)。
@@ -872,15 +1082,18 @@ export function registerBusinessRuleLane(tools) {
872
1082
  : {}),
873
1083
  ...(matches.length === 0
874
1084
  ? {
875
- // r73 探针01-P1(2026-11-17):旧首句「零命中=全平台没有规则引用它」与
876
- // 同一载荷的 notScanned(不含条件叶子/datarule/listview)自相矛盾——快读
877
- // 者会直接答「没有规则用它」,而 daily_expiry_scan 的条件正引用该字段。
878
- // 首句先声明「本面」盲区,再给范围与离线替代。
879
- note: "零命中(本在线面仅 businessrule 的 methodMapping/targetObjectCode/dataActions;**不含规则条件叶子/datarule/listview**——条件里的引用用 `graph references field <code>`)= " +
1085
+ // r73 探针01-P1:零命中首句必须先声明「本面」盲区再下结论——快读
1086
+ // 者会直接答「没有规则用它」。R79 三期起条件叶子与 datarule 已入
1087
+ // kind=field 扫描面,首句盲区随之收窄(form/listview/流程字段权限
1088
+ // /子表字段仍在盲区)。
1089
+ note: (args.kind === "field"
1090
+ ? "零命中(本面扫 businessrule 的动作/映射/条件叶子 + datarule 的 propertyCodes/options 文本;**不含 form/listview/流程字段权限/子表字段**)"
1091
+ : "零命中(本在线面仅 businessrule 的 methodMapping/targetObjectCode/dataActions;**不含 form/listview**)") +
1092
+ "= " +
880
1093
  (args.schemaCodes !== undefined
881
1094
  ? `仅扫描了 schemaCodes 收窄的 ${scoped.length} 个模型(${scoped.slice(0, 5).join(", ")}${scoped.length > 5 ? "…" : ""})——引用常发生在**其他**模型上;要全平台结论请去掉 schemaCodes`
882
- : "全平台没有规则引用它") +
883
- "。范围:service→methodMapping.serviceCode;model→targetObjectCode/methodMapping.schemaCode;field→dataActions.targetDataItem/映射 bizCode(不含条件叶子与 datarule——条件叶子已入 graph 索引 rule.condition 边,条件引用先 `omc graph pull` 后 `graph references field`)。本工具是在线单点扫描;要离线毫秒级复询、字段级影响面或两跳爆炸半径,先 `omc graph pull --env <env>` 再 `omc graph references|impact <kind> <code>`",
1095
+ : "扫描范围内没有匹配引用") +
1096
+ "。范围:service→methodMapping.serviceCode;model→targetObjectCode/methodMapping.schemaCode;field→dataActions.targetDataItem/映射 bizCode/条件叶子(filterCondition、BRANCH 出口等)/datarule(子表字段不扫)。本工具是在线单点扫描;要离线毫秒级复询、字段级影响面或两跳爆炸半径,先 `omc graph pull --env <env>` 再 `omc graph references|impact <kind> <code>`",
884
1097
  ...(args.schemaCodes === undefined && scope !== undefined ? { hint: applicationScopeHint(scope, "引用") } : {}),
885
1098
  }
886
1099
  : {
@@ -1058,6 +1271,9 @@ export function registerBusinessRuleLane(tools) {
1058
1271
  routes: projected.routes,
1059
1272
  schedulerSetting: parse(record.schedulerSetting),
1060
1273
  renderCompat,
1274
+ // r85(retro 2026-11-19 issue 09/11):codeType:7 公式口径注记(非侵入,
1275
+ // 不改写公式)。无表达式映射时不出现该键。
1276
+ ...((() => { const notes = ruleFormulaNotes(projected.nodes); return notes ? { formulaNotes: notes } : {}; })()),
1061
1277
  ...(semanticFindings ? { semanticFindings } : {}),
1062
1278
  // r73 #2:roundTrip 是显式判定键(safe:true 也在),不是缺键
1063
1279
  ...(roundTrip ? { roundTrip } : {}),
@@ -1134,6 +1350,8 @@ export function registerBusinessRuleLane(tools) {
1134
1350
  nodeGraph: ruleNodeGraphArg,
1135
1351
  publish: z.boolean().optional().describe("also publish the new version in this call (businessrule/publish) so the designer sees it; enabling stays with rule.enable — default false keeps the legacy draft-only save"),
1136
1352
  allowAdvisory: z.boolean().optional().describe("调查逃生口;默认 false"),
1353
+ allowAbsentMappingFields: z.boolean().optional().describe("逃生阀:codeType:1 映射 bizCode 不在来源模型已发布字段时仍保存(回执 absentMappingFieldsAllowed 点名);默认拒 rule-mapping-field-absent(平台侧不保证拦,运行时静默 null→10005)"),
1354
+ allowDesignerTextOverwrite: z.boolean().optional().describe("逃生阀:覆盖映射现存的设计器公式文本(editorText/editorMark);默认保留现存设计器文本只更新 formula(回执 preservedDesignerText 点名)"),
1137
1355
  customTrigger: z.boolean().optional().describe("默认开:自定义 ruleCode + bizRuleType 0(非平台触发码 Create/Update/Delete/GetList/Load/Available/Cancel)即按钮/流程规则,工具在 START 后合成平台标准 CUSTOM_NODE「自定义按钮/流程触发」系统触发节点(nodeCode=ruleCode,live 布局 x558/y233);调用方已写 CUSTOM_NODE 则原样保留;显式 false 退回"),
1138
1356
  },
1139
1357
  execute: async (session, args) => executeRuleSaveWrite(session, args),
@@ -1148,6 +1366,13 @@ export function registerBusinessRuleLane(tools) {
1148
1366
  mode: linted.existing?.id ? "update" : "create",
1149
1367
  nodeCount: linted.nodes.length,
1150
1368
  routeCount: linted.routes.length,
1369
+ // r85(retro 2026-11-19):dry-run 与真写同源注记。
1370
+ ...(linted.routesSource !== undefined ? { routesSource: linted.routesSource, routesNote: "本次未传 routes:将读现行连线沿用(businessrule/get +1 wire)" } : {}),
1371
+ ...(linted.emptyMappings.length > 0 ? { emptyMappings: linted.emptyMappings } : {}),
1372
+ ...(linted.preservedDesignerText.length > 0 ? { preservedDesignerText: linted.preservedDesignerText } : {}),
1373
+ ...(linted.designerTextOverwritten.length > 0 ? { designerTextOverwritten: linted.designerTextOverwritten } : {}),
1374
+ ...(linted.mappingFieldChecks > 0 ? { mappingFieldChecks: linted.mappingFieldChecks } : {}),
1375
+ ...(linted.absentMappingFields !== undefined ? { absentMappingFieldsAllowed: linted.absentMappingFields } : {}),
1151
1376
  publish: args.publish === true,
1152
1377
  customTrigger: linted.customTriggerApplied,
1153
1378
  ...(linted.bizMethodChecks > 0 ? { bizMethodChecks: linted.bizMethodChecks } : {}),
@@ -743,8 +743,16 @@ export function prepareRuleGraph(ruleCode, graph, customTrigger, schemaCode) {
743
743
  const literal = row.value !== undefined ? row.value : row.expressionValue;
744
744
  if (literal === undefined)
745
745
  return row;
746
+ const literalText = typeof literal === "string" ? literal : String(literal);
747
+ // r85(issue 04):显式空常量(value:"")归一为 bizCode:""——这是合法的
748
+ // "空映射"形状,不是"值搬移"事件,不告警。
749
+ if (literalText === "") {
750
+ const emptyNext = { ...row, bizCode: "" };
751
+ delete emptyNext.value;
752
+ return emptyNext;
753
+ }
746
754
  changed = true;
747
- const next = { ...row, bizCode: typeof literal === "string" ? literal : String(literal) };
755
+ const next = { ...row, bizCode: literalText };
748
756
  delete next.value;
749
757
  return next;
750
758
  });
@@ -1392,16 +1400,24 @@ export function validateMethodMapping(mapping, nodeCode) {
1392
1400
  blockers.push({ code: "rule-graph-bizaction-mapping-codetype", nodeCode, key: `methodMapping.${listKey}[${index}].codeType`, message: `${listKey}[${index}].codeType 必须是 0-${RULE_CODE_TYPES.length - 1} 的整数(CodeType int 序列化:${RULE_CODE_TYPES.map((t, i) => `${i}=${t}`).join("/")})` });
1393
1401
  if (typeof row.serviceMethodParameterCode !== "string" || !row.serviceMethodParameterCode.trim())
1394
1402
  blockers.push({ code: "rule-graph-bizaction-mapping-param", nodeCode, key: `methodMapping.${listKey}[${index}].serviceMethodParameterCode`, message: `${listKey}[${index}] 缺 serviceMethodParameterCode(集成方法参数 code;quote 以它对账方法参数表)` });
1395
- if (row.codeType === 1 && (typeof row.bizCode !== "string" || !row.bizCode.trim()))
1396
- blockers.push({ code: "rule-graph-bizaction-mapping-bizcode", nodeCode, key: `methodMapping.${listKey}[${index}].bizCode`, message: `${listKey}[${index}].codeType=1(PROPERTY) 必须带 bizCode(RuleBizActionQuoteImpl 只消费 PROPERTY 映射的 bizCode+propertyName)` });
1403
+ // r85(retro 2026-11-19 issue 04):显式留空是合法形状——`bizCode:""`(恰好
1404
+ // 空串)在平台侧是"空映射":保存/发布不校验(RuleQuoteImpl.java:193 跳过
1405
+ // 空白),运行时 MapOps 跳过该映射=参数不传(MapOps.java:490-496)。仍拒:
1406
+ // 键缺席(与显式空串语义可区分)、纯空白串(MapOps isEmpty 不跳过、会按
1407
+ // 字段码 " " 求值成 null)、非字符串。
1408
+ if (row.codeType === 1 && row.bizCode !== "" && (typeof row.bizCode !== "string" || !row.bizCode.trim()))
1409
+ blockers.push({ code: "rule-graph-bizaction-mapping-bizcode", nodeCode, key: `methodMapping.${listKey}[${index}].bizCode`, message: `${listKey}[${index}].codeType=1(PROPERTY) 必须带 bizCode(RuleBizActionQuoteImpl 只消费 PROPERTY 映射的 bizCode+propertyName);可选参数显式留空传 bizCode:""(空映射:运行时参数不传,回执 emptyMappings 点名)` });
1397
1410
  // CONST(0): the literal value must live in `bizCode` by the time it is
1398
1411
  // written (MapOps reads getBizCode for CONST; the designer writes
1399
1412
  // componentValue=bizCode). prepareRuleGraph moves a value found under
1400
1413
  // `value`/`expressionValue` into bizCode, so accept any of the three here
1401
1414
  // and only refuse when the element carries no value at all (which would
1402
1415
  // arrive as literal "null" at runtime).
1403
- if (row.codeType === 0 && !(typeof row.bizCode === "string" && row.bizCode.trim()) && row.value === undefined && row.expressionValue === undefined)
1404
- blockers.push({ code: "rule-graph-bizaction-mapping-const-value", nodeCode, key: `methodMapping.${listKey}[${index}].bizCode`, message: `${listKey}[${index}].codeType=0(CONST) 缺常量值——放 bizCode(或 value,工具会移入 bizCode);平台 CONST 只读 bizCode,缺值运行时会取到字面 null` });
1416
+ // r85(issue 04):显式空常量合法——bizCode:"" / value:"" 是"空映射"(运行时
1417
+ // MapOps 跳过、参数不传),与"忘了给值"区分开:后者仍拒。
1418
+ const explicitEmptyConst = row.bizCode === "" || row.value === "" || row.expressionValue === "";
1419
+ if (row.codeType === 0 && !explicitEmptyConst && !(typeof row.bizCode === "string" && row.bizCode.trim()) && row.value === undefined && row.expressionValue === undefined)
1420
+ blockers.push({ code: "rule-graph-bizaction-mapping-const-value", nodeCode, key: `methodMapping.${listKey}[${index}].bizCode`, message: `${listKey}[${index}].codeType=0(CONST) 缺常量值——放 bizCode(或 value,工具会移入 bizCode);平台 CONST 只读 bizCode,缺值运行时会取到字面 null。可选参数显式留空传 bizCode:""(空映射:运行时参数不传)` });
1405
1421
  // EXPRESSION(7) — 入参「计算规则」:MapOps INPUT 方向对 CodeType.CONST /
1406
1422
  // CodeType.EXPRESSION 都取 `getBizMethodValue`/`getExpressionValue`
1407
1423
  // (MapOps.java:510-541),Mapping.expressionValue 是 Object、平台原样透传。