@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.
@@ -5,7 +5,7 @@ import { governedRead } from "../read.js";
5
5
  import { writeTool } from "../write.js";
6
6
  import { decodeJsonColumn, JSON_COLUMN_NULL_COALESCE } from "../json-column.js";
7
7
  import { applicationResolutionOf, applicationScopeHint, flattenTreeRows, resolveApplicationScope, suggestModelNames } from "../support.js";
8
- import { executeRuleSaveWrite, ruleNodeGraphArg } from "../rule-support.js";
8
+ import { assertRuleNamePlatformAcceptable, executeRuleSaveWrite, lintRuleGraphForWrite, ruleNodeGraphArg } from "../rule-support.js";
9
9
  import { defineTool, ToolInputError, ToolRefusalError } from "../tool-types.js";
10
10
  import { resolveRuleRowId } from "../identity.js";
11
11
  import { wireCall, wireCallWith404Fallback, wireRows } from "../wire.js";
@@ -48,6 +48,22 @@ function businessRuleRollbackSpec(toolName) {
48
48
  */
49
49
  const RULE_NODE_LAYOUT_KEYS = ["x", "y", "width", "height"];
50
50
  const RULE_ROUTE_LAYOUT_KEYS = ["points"];
51
+ /**
52
+ * r73 #2(GitLab #40,8.6.41 实测):`rule.get` 读面显式声明「整图原样回存是否
53
+ * 可行」(roundTrip)。平台版本形状有差异——8.6.41 设计器建的 CREATE 节点可能
54
+ * 只有 originatorValueType 没有 originatorValue,把 rule.get 的 nodes/routes 原样
55
+ * 喂 rule.save 会被 rule-graph-create-originator-value 拒。hazard → gap,每个
56
+ * gap 带一句可执行修法(不是泛泛的「请修正」);映射不全时回通用兜底。
57
+ */
58
+ const RULE_ROUND_TRIP_FIXES = Object.freeze({
59
+ "rule-graph-create-originator-value": 'CREATE 节点补 originatorValue(DYNAMIC=人员字段 code;FIXED=用户对象数组 JSON 串,如 [{"id":"<userId>","name":"<名>"}]),或不要整图回存:用 rule.node.update 只 patch 目标节点',
60
+ "rule-graph-create-originator": "CREATE 节点补 originatorValueType:FIXED(originatorValue=用户对象数组 JSON 串)或 DYNAMIC(originatorValue=人员字段 code)",
61
+ "rule-graph-create-workflow-code": "补 targetWorkflowCode=目标模型的已发布流程 code,或去掉 startWorkflow",
62
+ "rule-graph-child-trigger-condition-type": "补 childTriggerConditionType:ADD/MODIFY/DELETE 之一(子表触发数据范围:新增/修改/删除)",
63
+ "rule-graph-create-mapping-missing": "补 dataActions 字段映射(execFormMapping 只是展示开关不是映射来源),或不要整图回存:用 rule.node.update 只 patch 目标节点",
64
+ });
65
+ const roundTripFixOf = (code) => RULE_ROUND_TRIP_FIXES[code] ?? "按 message 修正该节点后重存;或不要整图回存:用 rule.node.update 只 patch 目标节点";
66
+ const RULE_ROUND_TRIP_HINT = "整图原样回存会被这些 hazard 拒(rule.save);备份/恢复请用 rule.node.update 单节点 patch,或先补 gaps。**平台版本差异**:部分版本的读面不回传 CREATE 节点的 originatorValue(8.6.41 实测),本工具不猜值。";
51
67
  function projectRuleGraph(nodes, routes, full) {
52
68
  if (full)
53
69
  return { nodes, routes };
@@ -219,7 +235,7 @@ export function registerBusinessRuleLane(tools) {
219
235
  inputSchema: {
220
236
  environment: environmentArg,
221
237
  kind: z.enum(["service", "model", "field"]).describe("按什么找引用:service=BIZ_ACTION methodMapping.serviceCode;model=CREATE/UPDATE/DELETE targetObjectCode 与 methodMapping.schemaCode;field=dataActions.targetDataItem 与映射 bizCode"),
222
- code: z.string().min(1).describe("要查引用的编码(服务 code / 模型 code / 字段 code)"),
238
+ code: z.string().min(1).describe("要查引用的编码(服务/模型/字段 code);kind=field 可用 schemaCode.field 消歧"),
223
239
  schemaCodes: z.union([z.array(z.string().min(1)), z.string()]).optional().describe("只扫这些模型(省 wire 读);省略=全平台模型"),
224
240
  capability: capabilityArg,
225
241
  },
@@ -233,13 +249,74 @@ export function registerBusinessRuleLane(tools) {
233
249
  // "found" 0 models → false zero-hit), so walk the application tree.
234
250
  // The implicit scope is echoed: a zero-hit scan over 1-of-N applications
235
251
  // must not read as "nothing references this" tenant-wide.
236
- const scope = args.schemaCodes === undefined ? await resolveApplicationScope(session, undefined) : undefined;
237
- const scoped = args.schemaCodes === undefined
238
- ? flattenTreeRows(wireRows((await wireCall(session, { path: ENDPOINTS.applicationTree, query: { appCode: scope.code } })).data))
239
- .filter((row) => row.type === "BizModel" && typeof row.code === "string" && row.code !== "")
240
- .map((row) => String(row.code))
241
- : (Array.isArray(args.schemaCodes) ? args.schemaCodes : [args.schemaCodes]);
242
- const wanted = args.code;
252
+ //
253
+ // r73 #3(GitLab #40,8.6.41 实测):`resolveApplicationScope` 在部分版本
254
+ // 解析到**空应用树** → scoped=[] → 扫描循环零次 → ok + matches:[]。空
255
+ // matches 会被读成「没有任何引用,可安全删除」。空扫描(scanned.models
256
+ // ===0)必须 fail closed:refused + applicationResolution(调用方要能一眼
257
+ // 看见「我扫了哪个应用」),而不是回一个危险的 ok 空集。
258
+ const treeOf = async (scope) => {
259
+ const tree = wireRows((await wireCall(session, { path: ENDPOINTS.applicationTree, query: { appCode: scope.code } })).data);
260
+ return flattenTreeRows(tree).filter((row) => row.type === "BizModel" && typeof row.code === "string" && row.code !== "");
261
+ };
262
+ const scanMode = args.schemaCodes === undefined ? "application" : "schemaCodes";
263
+ let scope;
264
+ let scoped = [];
265
+ // 应用树模型全集——显式 schemaCodes 的交叉核对用(树读不到 → 无法核对 → 跳过)
266
+ let treeModelCodes;
267
+ if (args.schemaCodes === undefined) {
268
+ scope = await resolveApplicationScope(session, undefined);
269
+ scoped = (await treeOf(scope)).map((row) => String(row.code));
270
+ }
271
+ else {
272
+ scoped = Array.isArray(args.schemaCodes) ? args.schemaCodes : [args.schemaCodes];
273
+ try {
274
+ scope = await resolveApplicationScope(session, undefined);
275
+ treeModelCodes = new Set((await treeOf(scope)).map((row) => String(row.code)));
276
+ }
277
+ catch {
278
+ scope = undefined; // 应用面读失败:交叉核对不可用,按原行为扫描
279
+ }
280
+ if (treeModelCodes !== undefined && treeModelCodes.size > 0 && !scoped.some((code) => treeModelCodes.has(code))) {
281
+ // 显式 schemaCodes 全部不存在(应用树交叉核对)——空集拒绝而不是空 ok。
282
+ throw new ToolRefusalError({
283
+ status: "refused",
284
+ blocker: "references-scan-empty",
285
+ message: `扫描范围为 0 个模型——本次没有扫描任何东西,空 matches 不代表「无引用」;通常是 app scope 解析为空(8.6.41 已知)或 schemaCodes 传了不存在的模型。本次 schemaCodes 传入 ${scoped.length} 个模型,应用 ${scope?.code ?? "?"} 的模型树(${treeModelCodes.size} 个模型)里一个都不存在`,
286
+ applicationResolution: scope !== undefined
287
+ ? { ...applicationResolutionOf(scope), mode: scanMode, models: 0, schemaCodesGiven: scoped.length, treeModels: treeModelCodes.size }
288
+ : { code: null, source: "unresolved", mode: scanMode, models: 0, schemaCodesGiven: scoped.length },
289
+ nextCommand: `omc call rule.references --args '{"kind":"${args.kind}","code":"${args.code}","schemaCodes":["<模型code>",...]}'(显式指定扫描范围)`,
290
+ });
291
+ }
292
+ }
293
+ if (scoped.length === 0) {
294
+ throw new ToolRefusalError({
295
+ status: "refused",
296
+ blocker: "references-scan-empty",
297
+ message: "扫描范围为 0 个模型——本次没有扫描任何东西,空 matches 不代表「无引用」;通常是 app scope 解析为空(8.6.41 已知)或 schemaCodes 传了不存在的模型",
298
+ applicationResolution: scope !== undefined
299
+ ? { ...applicationResolutionOf(scope), mode: scanMode, models: 0 }
300
+ : { code: null, source: "unresolved", mode: scanMode, models: 0 },
301
+ nextCommand: `omc call rule.references --args '{"kind":"${args.kind}","code":"${args.code}","schemaCodes":["<模型code>",...]}'(显式指定扫描范围)`,
302
+ });
303
+ }
304
+ // r73 探针02-P1(2026-11-17):kind=field 支持 `schemaCode.field` 限定写法
305
+ // (与 graph references 一致)。裸 code 会把别的模型的同名字段并进来(实证:
306
+ // 查 crm_contract.amount 命中 crm_receipt.Create 的自身 amount)——消歧此前
307
+ // 只能靠逐条 rule.get 人工核对。前缀不在本次扫描范围时按原样查(code 可能真含点)。
308
+ const rawCode = args.code;
309
+ let wanted = rawCode;
310
+ let fieldScope;
311
+ if (args.kind === "field" && rawCode.includes(".")) {
312
+ const cut = rawCode.lastIndexOf(".");
313
+ const prefix = rawCode.slice(0, cut);
314
+ const bare = rawCode.slice(cut + 1);
315
+ if (bare !== "" && scoped.includes(prefix)) {
316
+ wanted = bare;
317
+ fieldScope = prefix;
318
+ }
319
+ }
243
320
  const matches = [];
244
321
  let scannedRules = 0;
245
322
  let parseFailures = 0;
@@ -286,13 +363,17 @@ export function registerBusinessRuleLane(tools) {
286
363
  matches.push({ schemaCode, ruleCode, nodeCode, nodeType, via: "methodMapping.schemaCode" });
287
364
  }
288
365
  else {
366
+ // dataActions 的 targetDataItem 宿主是 targetObjectCode(跨模型写回),
367
+ // mapping.bizCode 宿主是承载模型——dot 限定按宿主过滤,与 graph 边归属一致。
368
+ const actionHost = String(rawNode.targetObjectCode ?? "") || schemaCode;
289
369
  if (["CREATE", "UPDATE", "DELETE"].includes(nodeType) && Array.isArray(rawNode.dataActions)
370
+ && (fieldScope === undefined || actionHost === fieldScope)
290
371
  && rawNode.dataActions.some((action) => String(action.targetDataItem ?? "") === wanted))
291
- matches.push({ schemaCode, ruleCode, nodeCode, nodeType, via: "dataActions.targetDataItem", ...(String(rawNode.targetObjectCode ?? "") !== "" ? { targetObjectCode: String(rawNode.targetObjectCode) } : {}) });
292
- if (mapping) {
372
+ matches.push({ schemaCode, ruleCode, nodeCode, nodeType, via: "dataActions.targetDataItem", hostSchemaCode: actionHost, ...(String(rawNode.targetObjectCode ?? "") !== "" ? { targetObjectCode: String(rawNode.targetObjectCode) } : {}) });
373
+ if (mapping && (fieldScope === undefined || schemaCode === fieldScope)) {
293
374
  for (const [key, label] of [["inputMappings", "inputMappings.bizCode"], ["outputMappings", "outputMappings.bizCode"]]) {
294
375
  if (Array.isArray(mapping[key]) && mapping[key].some((row2) => String(row2.bizCode ?? "") === wanted && (row2.codeType === undefined || row2.codeType === 1)))
295
- matches.push({ schemaCode, ruleCode, nodeCode, nodeType, via: label });
376
+ matches.push({ schemaCode, ruleCode, nodeCode, nodeType, via: label, hostSchemaCode: schemaCode });
296
377
  }
297
378
  }
298
379
  }
@@ -302,6 +383,7 @@ export function registerBusinessRuleLane(tools) {
302
383
  return {
303
384
  kind: args.kind,
304
385
  code: wanted,
386
+ ...(fieldScope !== undefined ? { requestedCode: rawCode, resolvedScope: { schemaCode: fieldScope, code: wanted } } : {}),
305
387
  scanned: { models: scoped.length, rules: scannedRules, ...(parseFailures > 0 ? { parseFailures } : {}) },
306
388
  matches,
307
389
  // r35a-F4(真机 2026-11-06):matches:[] 曾被当成「可安全删除」的依据,
@@ -312,15 +394,24 @@ export function registerBusinessRuleLane(tools) {
312
394
  notScanned: ["datarule", "form", "workflow.permissions", "workflow.bindings", "onlinejs", "listview"],
313
395
  note: "matches:[] 只代表 businessrule 面零命中;datarule/form/流程权限/视图等未扫描(离线 graph references 覆盖更广,见其 coverage),不可据此判定可安全删除",
314
396
  },
315
- ...(scope !== undefined ? { applicationResolution: applicationResolutionOf(scope) } : {}),
397
+ // r73 #3:app-scope 路径回显 applicationResolution(含 mode/models:扫了
398
+ // 哪个应用、共几个模型)。显式 schemaCodes 路径维持原形状(无
399
+ // applicationResolution/hint——显式范围自带出处,provenance 契约不变)。
400
+ ...(args.schemaCodes === undefined && scope !== undefined
401
+ ? { applicationResolution: { ...applicationResolutionOf(scope), mode: scanMode, models: scoped.length } }
402
+ : {}),
316
403
  ...(matches.length === 0
317
404
  ? {
318
- note: "零命中=" +
405
+ // r73 探针01-P1(2026-11-17):旧首句「零命中=全平台没有规则引用它」与
406
+ // 同一载荷的 notScanned(不含条件叶子/datarule/listview)自相矛盾——快读
407
+ // 者会直接答「没有规则用它」,而 daily_expiry_scan 的条件正引用该字段。
408
+ // 首句先声明「本面」盲区,再给范围与离线替代。
409
+ note: "零命中(本在线面仅 businessrule 的 methodMapping/targetObjectCode/dataActions;**不含规则条件叶子/datarule/listview**——条件里的引用用 `graph references field <code>`)= " +
319
410
  (args.schemaCodes !== undefined
320
411
  ? `仅扫描了 schemaCodes 收窄的 ${scoped.length} 个模型(${scoped.slice(0, 5).join(", ")}${scoped.length > 5 ? "…" : ""})——引用常发生在**其他**模型上;要全平台结论请去掉 schemaCodes`
321
412
  : "全平台没有规则引用它") +
322
413
  "。范围: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>`",
323
- ...(scope !== undefined ? { hint: applicationScopeHint(scope, "引用") } : {}),
414
+ ...(args.schemaCodes === undefined && scope !== undefined ? { hint: applicationScopeHint(scope, "引用") } : {}),
324
415
  }
325
416
  : {
326
417
  // r31(2026-10-31):影响评估场景 agent 已路由到本工具——在必经之路
@@ -419,6 +510,7 @@ export function registerBusinessRuleLane(tools) {
419
510
  // dry-lint,把"已启用但运行时会被静默跳过/UI 独有算子/选项 key 撞车"
420
511
  // 等语义隐患以 semanticFindings 暴露——"可读不可验"到此为止。
421
512
  let semanticFindings;
513
+ let roundTrip;
422
514
  try {
423
515
  const { validateRuleNodeGraph } = await import("./rule-graph.js");
424
516
  // r45 I5 误报根因:体检重建图只带 nodes/routes,把行级 schedulerSetting
@@ -437,6 +529,23 @@ export function registerBusinessRuleLane(tools) {
437
529
  message: finding.message,
438
530
  }));
439
531
  }
532
+ // r73 #2(GitLab #40,8.6.41 实测):roundTrip = 整图原样回存的显式判定。
533
+ // safe:true 也是显式键(不是缺键)——agent 要能区分「判定过、可回存」与
534
+ // 「没判定」。与 full/keys 选择器无关:它是回执顶层键,与 nodes 并列。
535
+ const hazards = findings.filter((finding) => finding.severity !== "warning");
536
+ roundTrip = hazards.length === 0
537
+ ? { safe: true }
538
+ : {
539
+ safe: false,
540
+ gaps: hazards.map((finding) => ({
541
+ code: finding.code,
542
+ ...(finding.nodeCode !== undefined ? { nodeCode: finding.nodeCode } : {}),
543
+ ...(finding.key !== undefined ? { key: finding.key } : {}),
544
+ message: finding.message,
545
+ fix: roundTripFixOf(finding.code),
546
+ })),
547
+ hint: RULE_ROUND_TRIP_HINT,
548
+ };
440
549
  }
441
550
  catch {
442
551
  // 体检失败不破坏读回本身
@@ -468,6 +577,8 @@ export function registerBusinessRuleLane(tools) {
468
577
  schedulerSetting: parse(record.schedulerSetting),
469
578
  renderCompat,
470
579
  ...(semanticFindings ? { semanticFindings } : {}),
580
+ // r73 #2:roundTrip 是显式判定键(safe:true 也在),不是缺键
581
+ ...(roundTrip ? { roundTrip } : {}),
471
582
  ...(staleRow ? { staleRow, effectiveId, staleRowMessage, staleId: true, latestId: effectiveId, note: staleNote } : {}),
472
583
  };
473
584
  if (args.withRuntime === true) {
@@ -521,6 +632,9 @@ export function registerBusinessRuleLane(tools) {
521
632
  ? payload.schedulerSetting.dataSourceType
522
633
  : undefined,
523
634
  ...(payload.statusLag ? { statusLag: payload.statusLag, statusNote: payload.statusNote } : {}),
635
+ // r73 #2:summary 面同样带 roundTrip 显式判定(不内联正文也要能回答
636
+ // 「这张图能不能原样回存」)。
637
+ ...(roundTrip ? { roundTrip } : {}),
524
638
  // #39 摩擦 E:summary 面也要带 stale 提示——持旧 id 的调用方常只看
525
639
  // summary,漏掉 stale 会把旧图当成「改了没生效」。
526
640
  ...(staleRow ? { staleId: true, latestId: effectiveId, note: staleNote } : {}),
@@ -559,6 +673,33 @@ export function registerBusinessRuleLane(tools) {
559
673
  // (so every graph gate + readback is identical). Platform constraints honoured:
560
674
  // `nodeCode`/`nodeType` are immutable (routes reference nodeCode; the platform
561
675
  // cannot retype a node), so the patch may not change them.
676
+ //
677
+ // r73 #1(GitLab #40,8.6.41 实测):execute 与 dryRunPayload 共用同一个
678
+ // 读法/合并法(loadRuleNodePatchGraph)——dry-run 读存量行 → 浅合并 patch →
679
+ // 全图 lint(lintRuleGraphForWrite,与真写同门)。读失败(规则/节点不存在、
680
+ // 不可变键)按 execute 同款 refusal 抛出,绝不静默放行。
681
+ const loadRuleNodePatchGraph = async (session, args) => {
682
+ const id = await resolveRuleRowId(session, args.schemaCode, args.ruleCode);
683
+ if (!id)
684
+ throw new ToolRefusalError({ status: "refused", blocker: "rule-absent", message: `规则 ${args.schemaCode}.${args.ruleCode} 不存在;拒绝 node patch` });
685
+ const record = (await wireCall(session, { path: ENDPOINTS.businessRuleGet, query: { id } })).data;
686
+ if (!record)
687
+ throw new ToolRefusalError({ status: "refused", blocker: "rule-absent", message: `规则 ${args.schemaCode}.${args.ruleCode}(id ${id})读回为空` });
688
+ for (const key of ["nodeCode", "nodeType"])
689
+ if (key in args.patch)
690
+ throw new ToolRefusalError({ status: "refused", blocker: "rule-node-immutable-key", message: `node patch 不允许改 ${key}(平台按 nodeCode 连接路由、节点类型不可变);要改名/改型请整图 rule.save` });
691
+ // node/route are SEPARATE JSON-string columns (see rule.get): `node` is the
692
+ // nodes array, `route` the routes array — not one {nodes,routes} object.
693
+ const nodes = decodeJsonColumn(record.node, JSON_COLUMN_NULL_COALESCE);
694
+ const routes = decodeJsonColumn(record.route, JSON_COLUMN_NULL_COALESCE);
695
+ const nodeList = Array.isArray(nodes) ? nodes : [];
696
+ const target = nodeList.find((node) => node.nodeCode === args.nodeCode);
697
+ if (!target)
698
+ throw new ToolRefusalError({ status: "refused", blocker: "rule-node-absent", message: `现有图中没有 nodeCode=${args.nodeCode};用 rule.get schemaCode+ruleCode 查看 nodeCode` });
699
+ const mergedNode = { ...target, ...args.patch };
700
+ const mergedGraph = { nodes: nodeList.map((node) => (node.nodeCode === args.nodeCode ? mergedNode : node)), ...(Array.isArray(routes) ? { routes } : {}) };
701
+ return { id, record, mergedGraph, ruleName: String(record.name ?? args.ruleCode) };
702
+ };
562
703
  writeTool({
563
704
  tools,
564
705
  name: "rule.node.update",
@@ -575,26 +716,27 @@ export function registerBusinessRuleLane(tools) {
575
716
  customTrigger: z.boolean().optional(),
576
717
  },
577
718
  execute: async (session, args) => {
578
- const id = await resolveRuleRowId(session, args.schemaCode, args.ruleCode);
579
- if (!id)
580
- throw new ToolRefusalError({ status: "refused", blocker: "rule-absent", message: `规则 ${args.schemaCode}.${args.ruleCode} 不存在;拒绝 node patch` });
581
- const record = (await wireCall(session, { path: ENDPOINTS.businessRuleGet, query: { id } })).data;
582
- if (!record)
583
- throw new ToolRefusalError({ status: "refused", blocker: "rule-absent", message: `规则 ${args.schemaCode}.${args.ruleCode}(id ${id})读回为空` });
584
- for (const key of ["nodeCode", "nodeType"])
585
- if (key in args.patch)
586
- throw new ToolRefusalError({ status: "refused", blocker: "rule-node-immutable-key", message: `node patch 不允许改 ${key}(平台按 nodeCode 连接路由、节点类型不可变);要改名/改型请整图 rule.save` });
587
- // node/route are SEPARATE JSON-string columns (see rule.get): `node` is the
588
- // nodes array, `route` the routes array — not one {nodes,routes} object.
589
- const nodes = decodeJsonColumn(record.node, JSON_COLUMN_NULL_COALESCE);
590
- const routes = decodeJsonColumn(record.route, JSON_COLUMN_NULL_COALESCE);
591
- const nodeList = Array.isArray(nodes) ? nodes : [];
592
- const target = nodeList.find((node) => node.nodeCode === args.nodeCode);
593
- if (!target)
594
- throw new ToolRefusalError({ status: "refused", blocker: "rule-node-absent", message: `现有图中没有 nodeCode=${args.nodeCode};用 rule.get schemaCode+ruleCode 查看 nodeCode` });
595
- const mergedNode = { ...target, ...args.patch };
596
- const mergedGraph = { nodes: nodeList.map((node) => (node.nodeCode === args.nodeCode ? mergedNode : node)), ...(Array.isArray(routes) ? { routes } : {}) };
597
- return executeRuleSaveWrite(session, { schemaCode: args.schemaCode, ruleCode: args.ruleCode, name: String(record.name ?? args.ruleCode), nodeGraph: mergedGraph, ...(args.publish === true ? { publish: true } : {}), ...(args.customTrigger === true ? { customTrigger: true } : {}) });
719
+ const base = await loadRuleNodePatchGraph(session, args);
720
+ return executeRuleSaveWrite(session, { schemaCode: args.schemaCode, ruleCode: args.ruleCode, name: base.ruleName, nodeGraph: base.mergedGraph, ...(args.publish === true ? { publish: true } : {}), ...(args.customTrigger === true ? { customTrigger: true } : {}) });
721
+ },
722
+ // r73 #1(GitLab #40):dry-run 此前走 write.ts 通用 dry-run(只出 plan),不跑
723
+ // 图 lint——非法 patch(如 CREATE 节点 originatorValue 置空)dry-run 过、真写
724
+ // policy-refused。dryRunPayload 与真写共用同一读法与同一 lint:dry-run 回
725
+ // 「能写/不能写」的同一答案,而不是只报 wouldChange。
726
+ dryRunPayload: async (session, args) => {
727
+ const base = await loadRuleNodePatchGraph(session, args);
728
+ // name 校验与真写同源(真写在 executeRuleSaveWrite 里再跑一次同一函数;
729
+ // name 取存量行,预置触发行在函数内部跳过)。
730
+ assertRuleNamePlatformAcceptable(args.ruleCode, base.ruleName);
731
+ const linted = await lintRuleGraphForWrite(session, { schemaCode: args.schemaCode, ruleCode: args.ruleCode, nodeGraph: base.mergedGraph, ...(args.customTrigger === true ? { customTrigger: true } : {}) }, { validationRefusalMessage: "nodeGraph 未过出门前校验(dry lint,与真写同门);按 validation 逐项修正" });
732
+ return {
733
+ nodeCode: args.nodeCode,
734
+ patchedKeys: Object.keys(args.patch),
735
+ // 本次 dry-run 覆盖的是**全图** lint(patch 合并进存量图后整图过门),
736
+ // 不是只验 patch 本身。
737
+ lintScope: "fullGraph",
738
+ validation: linted.blockers,
739
+ };
598
740
  },
599
741
  rollback: businessRuleRollbackSpec("rule.node.update"),
600
742
  });
@@ -241,6 +241,24 @@ function isSystemFieldCode(code) {
241
241
  const value = String(code ?? "");
242
242
  return SYSTEM_FIELD_CODES.has(value) || value === "parentId" || value === "sortKey";
243
243
  }
244
+ /**
245
+ * 线上 #40 第 8 条(2026-11-17):field.list 只有 code/type/typeName/name,
246
+ * 无法判断字段何时被删除/改名(探针只能用业务数据的时间反推)。
247
+ * 平台读面(bizproperty/list)在不同版本带回的时间列名不一致——
248
+ * 有就逐行透传(createdTime/modifiedTime 等),没有就不塞键(缺键≠null),
249
+ * 由回执 hint 说明本环境下「没有」而不是让 agent 猜。线上 #40 的 8.6.41 实测
250
+ * 不回时间列;1.1.25 真机实测**回 createdTime**(此前是 OMC 投影把键丢了,
251
+ * 不是平台没有)——所以两个方向都必须实现:有则透传、无则说明。
252
+ */
253
+ const FIELD_TIMESTAMP_KEYS = ["createdTime", "modifiedTime", "createTime", "updateTime", "createdAt", "updatedAt", "gmtCreate", "gmtModified"];
254
+ function pickFieldTimestamps(row) {
255
+ const picked = {};
256
+ for (const key of FIELD_TIMESTAMP_KEYS) {
257
+ if (row[key] !== undefined && row[key] !== null)
258
+ picked[key] = row[key];
259
+ }
260
+ return picked;
261
+ }
244
262
  /**
245
263
  * r17 (2026-10-25, live + decompiled A/B): a FORMULA field CANNOT aggregate its
246
264
  * own model's child table. `BizPropertyManagerImpl.publishFormula` rewrites
@@ -354,6 +372,8 @@ export function registerFieldLane(tools) {
354
372
  const system = isSystemFieldCode(fieldCode);
355
373
  return {
356
374
  code: fieldCode,
375
+ // #40-8:平台带回的字段时间戳逐行透传(键存在才给)。
376
+ ...pickFieldTimestamps(row),
357
377
  name: row.name,
358
378
  // r61 a-F9:行级发布态(双面比对)——true=已出现在发布面;false=仅草稿。
359
379
  // 面级 `face` 是查询面选择器,与此行级键不同义。
@@ -421,6 +441,8 @@ export function registerFieldLane(tools) {
421
441
  const businessCodes = Array.isArray(subColumns) ? subColumns.filter((column) => column.system !== true).map((column) => column.code) : undefined;
422
442
  return {
423
443
  code: field.code,
444
+ // #40-8:压缩面同样透传字段时间戳(有才给)。
445
+ ...pickFieldTimestamps(field),
424
446
  type: field.type,
425
447
  ...(field.typeName !== undefined ? { typeName: field.typeName } : {}),
426
448
  ...(field.name !== undefined ? { name: field.name } : {}),
@@ -453,6 +475,13 @@ export function registerFieldLane(tools) {
453
475
  // r61 a-F9:行级 `published`(true/false)是双面比对出的**字段发布态**;
454
476
  // `face` 只是本次查询的面选择器——两键不同义,别再拿 face 推断发布态。
455
477
  publishedNote: "行级 published=该字段是否已出现在发布面(双面比对);face=本次查询面(draft/published),不是字段发布态",
478
+ // 线上 #40 第 8 条:平台列表面不带时间戳时如实说「本环境没有」,
479
+ // 别让 agent 以为「没显示=可再查一层」而反复试错。
480
+ ...(mapped.some((field) => FIELD_TIMESTAMP_KEYS.some((key) => Object.prototype.hasOwnProperty.call(field, key)))
481
+ ? {}
482
+ : {
483
+ timestampNote: "字段时间戳:本环境 bizproperty/list 未返回 createdTime/modifiedTime——无法回答「字段何时被删除/改名」。需要近似时序用业务数据的 createdTime 分界,或 .omc/journal(写回执带时间)。平台带回时间列时会逐行透传(1.1.25 实测回 createdTime;线上 #40-8 的 8.6.41 实测不回),本提示自动消失",
484
+ }),
456
485
  ...(selector.length > 0 ? { selected: selector } : {}),
457
486
  ...(args.all !== true ? { businessOnly: true } : {}),
458
487
  fields: projected,
@@ -511,6 +540,8 @@ export function registerFieldLane(tools) {
511
540
  });
512
541
  return {
513
542
  code: field.code,
543
+ // #40-8:压缩面同样透传字段时间戳(有才给)。
544
+ ...pickFieldTimestamps(field),
514
545
  type: field.type,
515
546
  ...(field.typeName !== undefined ? { typeName: field.typeName } : {}),
516
547
  ...(field.name !== undefined ? { name: field.name } : {}),
@@ -17,7 +17,7 @@ export const LIST_VIEW_WIRE = Object.freeze({
17
17
  configureActions: "actions -> queryActions [{actionCode,name,icon,queryActionType,systemAction,serviceCode,serviceMethod,customService,associationCode,associationType,sortKey}]; queryActionType QueryActionType numeric QUERY(1)/ADD(2)/.../BATCH_SUBMIT(23); associationType QueryActionRelativeType numeric BIZSHEET(0)/WORKFLOW(1); associationCode/associationType are the JSON names of the DTO fields relativeCode/queryActionRelativeType (@JsonProperty); omitted leaves the existing actions untouched, provided MERGES into the effective set by actionCode (live 2026-09-17: query/update replaces-then-re-adds the submitted list, so a merge keeps the platform's built-in 新增/删除/导入/导出 and updates a matching actionCode — replaceActions:true restores the authoritative full set, defaultActions:true re-seeds the platform default set); query/get auto-injects default actions (qr_code/batch_print/batch_update/import_attachment/export_attachment/batch_submit) and query/update resets sortKey to i+1",
18
18
  configurePresentation: "presentation -> queryPresentation {clientType,htmlJson,actionsJson,columnsJson,queryViewDataSource,schemaRelations,options}; htmlJson/actionsJson/columnsJson JSON strings are decoded once before render-shape validation (html element tagName+attrs, action actionCode/name/icon, column propertyCode/propertyType); invalid input refuses with listview-presentation-render-invalid before wire and is never double-encoded; clientType is forced to PC by query/update; schemaRelations is platform-derived from the queryColumns tree (resolveRelations) and overwrites your input; a non-empty htmlJson updates the environment record, which query/delete cleans up; omitted leaves the existing presentation untouched (the read-face object must be echoed, because saveBizQueryDetail removes every presentation whose clientType matches before re-adding), provided replaces it",
19
19
  configureButtons: "buttons -> customButtons [{code,name,useLocation,bindAction,operateType,showPermCode,showPermType,hint,targetCode,targetObjCode,description,actionConfig}]; actionConfig is fail-closed for rendering: SCRIPT requires scriptData, BUSINESS_RULE/FLOW requires targetCode, ADD_DATA/FORM requires expanded schemaCodeVal/formListData/configureList; invalid input refuses before wire; readback includes buttonsRenderCompat; sent as the query/update body customButtonJson JSON array string; BizButtonFacadeImpl.addBizButtonList(String,...) runs only when customButtonJson is a JSON array, then batchDeleteByTrigger over the schema and its published child-table codes and re-adds (so provided replaces every button under the QUERY trigger, while omitted/absent customButtonJson changes nothing); triggerType is forced to QUERY, triggerCode to the view code, schemaCode backfilled, sortKey reset to the array index; name/code/useLocation/bindAction/operateType are required; bindAction ButtonBindAction name LIST(1)/FORM(2)/ADD_DATA(3)/FLOW(4)/BUSINESS_RULE(5)/SCRIPT(6)/CUSTOM_PAGE(7)/WORKFLOW_CENTER_PAGE(8)/FRONT_EVENT(9)/AGENT(10); useLocation ButtonUseLocation name LIST(1)/FORM(2)/ROW(3); operateType ButtonOperateType name WITH_VIEW(1)/WITH_OUT_VIEW(2); showPermType ButtonShowPermType name BIND_SYS_BUTTON(1)/BIND_BUSINESS_RULE(2)/BIND_FRONT_EVENT_BUTTON(3); duplicate code fails BIZ_QUERY_ACTION_CODE_EXIST; query/get returns customButtons[] (non-admin users are filtered by the permission combination); ModelManagementFacadeImpl.removeBizQuery deletes QUERY buttons for the schema and its child tables on query/delete",
20
- buttonsActionConfig: "ticket 75: an ADD_DATA/FORM button's model/form target binding lives in actionConfig — schemaCodeVal (target model object {code,id:<app-tree node id>,name,type:'BizModel',appCode,appName,published}) + formListData[] (target forms, sheetType 0 默认表单 only evidenced) + configureList[] (data assignments; isConst is STRING 'true'/'false', operator key is OptionType capital O, only 'Eq' evidenced, constant-value key not evidenced/unimplemented; currentDataItem/targetDataItem are array-wrapped inline field copies) — while targetCode/targetObjCode are measured always-null and NOT consumed for these bind actions (refused as listview-button-target-ineffective; FLOW keeps them); high-level button params targetModel/targetForm/configureList expand into that shape from authoritative readback (app tree node, bizsheet/get, published field rows) and fail closed (listview-button-target-unresolved) before any query/update",
20
+ buttonsActionConfig: "ticket 75: an ADD_DATA/FORM button's model/form target binding lives in actionConfig — schemaCodeVal (target model object {code,id:<app-tree node id>,name,type:'BizModel',appCode,appName,published}) + formListData[] (target forms, sheetType 0 默认表单 only evidenced) + configureList[] (data assignments; isConst is STRING 'true'/'false'; constant assignment uses isConst:'true' + currentDataInput:<value> — r73 live 8.6.41 evidence, dynamic row reads currentDataInput:null; operator key is OptionType capital O, 'Eq' evidences both kinds; currentDataItem/targetDataItem are array-wrapped inline field copies and may be passed back as-is on round-trip) — while targetCode/targetObjCode are measured always-null and NOT consumed for these bind actions (refused as listview-button-target-ineffective; FLOW keeps them); high-level button params targetModel/targetForm/configureList expand into that shape from authoritative readback (app tree node, bizsheet/get, published field rows) and fail closed (listview-button-target-unresolved) before any query/update",
21
21
  configureOptions: "options -> the query header BizQueryModel.options String column (h_biz_query.options TEXT), parsed by the platform as BizQueryOption {pagingSetting:{pageSize,showTotal}, listViewModeSetting:{mode,canSwitch}} (8.6.26 defaultOption = pageSize 20 / showTotal true / mode \"spreadsheet\" / canSwitch false); a raw JSON string is sent verbatim, an object is JSON-stringified; rowColorSetting has no 8.6.26 class so the object form refuses unknown keys; BizQueryController.update sets publish=TRUE before updateBizQuery, so after the first configure only the name/options-diff branch (ModelManagementFacadeImpl:1966-1973) persists options: an omitted body key (null) would overwrite a non-null stored value, so omitted must echo the read-face options (the tool spreads query/get) while provided replaces the whole string; BizQueryFacadeImpl.getBizQuery copies options from the entity on readback (no controller parse); BizObjectFacadeImpl.getShowTotal reads pagingSetting.showTotal (so pagingSetting must not be null)",
22
22
  configurePresentationType: "presentationType -> the query header BizQueryHeaderModel.queryPresentationType QueryPresentationType enum; sent as the name LIST/BOARD/CALENDAR/GANTT (@JsonValue getIndex() whose index equals the name, @JsonCreator get(String) parses); updateBizQuery always assigns it (:1955, not gated by publish or any diff), so an omitted body key (null) would overwrite a stored type and the tool must echo the read-face value (query/get inherits it via BeanUtils.copyProperties at BizQueryFacadeImpl:346); gantt -> queryGanttModel BizQueryGanttModel {queryId,schemaCode,startTimePropertyCode,endTimePropertyCode,progressPropertyCode,titlePropertyCode,preDependencyPropertyCode,endDependencyPropertyCode,levelPropertyCode,milepostCode,sortKey,configJson,liableManCode,statusCode,defaultPrecision}; saveBizQueryDetail only swaps the gantt when the submitted model is non-null (:178-183), so an omitted gantt leaves the stored one untouched; when presentationType is GANTT the controller requires the gantt with non-null startTimePropertyCode/endTimePropertyCode/titlePropertyCode (validateNotEmptyGantt :1121-1136); updateBizQuery forces levelPropertyCode=parentId for TREE models (:1999-2001) and saveBizQueryDetail backfills queryId (:179-181); addBizQuery allows at most one GANTT view per schema (BIZ_QUERY_GANTT_EXIST :1787)",
23
23
  configureLayer: "queryLayer -> BizQueryModel.queryLayer List<BizQueryLayer> (name,layerType,fieldCode,displayField[],layerFieldList[{schemaCode,schemaName,fieldCode,fieldName,displayField[],children[]}]); a real JSON array (not a String column), sent as an array; multiTableHeaderConfig -> BizQueryModel.multiTableHeaderConfig String (HeaderConfig[] JSON {type,name,field,propertyType,children[]} parsed by EasyExcelUtils/DefaultDataIEFileOperateServiceImpl via JSONObject.parseArray); a raw JSON string is sent verbatim, an array is JSON-stringified; saveBizQueryDetail assigns both unconditionally (:184-186, unlike the gantt non-null guard), so an omitted key would overwrite the stored value and the tool must echo the read-face values (BizQueryFacadeImpl.getBizQuery always carries them: queryLayer from the detail config or null, multiTableHeaderConfig from the config or \"\", :283-293/344-345); provided replaces the whole value. NOTE: \"按字段分组\" (field grouping) is NOT a proven capability on this surface — queryLayer is a passthrough (no schema/enum validation) and every real 8.6.26 view read back an empty queryLayer, so layerType semantics/grouping behavior are UNVERIFIED; do not guess-write queryLayer to satisfy a grouping requirement (2026-10-06 sandbox: agent correctly refused to fabricate it).",
@@ -122,11 +122,11 @@ export const LIST_VIEW_LANE_CONTRACT = Object.freeze({
122
122
  }),
123
123
  "listview.create": Object.freeze({
124
124
  scope: LIST_VIEW_SCOPE,
125
- description: "创建自定义列表视图(query/create,强制 LIST/showOnPc/unpublished 默认)。本工具只收 schemaCode/name/code——**列配置不在这里**:建完后用 `listview.configure` 的 fieldCodes 配列(不要把 fieldCodes 传给 create)。**业务展示的默认入口就是自定义视图**:平台在 model.create 时自动生成的默认视图(code = schemaCode,系统自带)**不作为业务展示用**——列别在默认视图上堆、也别带系统字段;按需求建自定义视图(listview.create 命名业务视图),列**只用业务字段**,筛选条件**按需求选少数几个**(不要照搬全部字段/默认条件)。readback 见 get_header。",
125
+ description: "创建自定义列表视图(query/create,强制 LIST/showOnPc/unpublished 默认)。本工具只收 schemaCode/name/code——**列配置不在这里**:建完后用 `listview.configure` 的 fieldCodes 配列(不要把 fieldCodes 传给 create)。**默认视图可配置**:code=schemaCode 的默认视图同样可 listview.configure,日常配列直接用;仅确需第二个视图时才用本工具。改视图影响用户。readback 见 get_header。",
126
126
  }),
127
127
  "listview.configure": Object.freeze({
128
128
  scope: LIST_VIEW_SCOPE,
129
- description: "(**列汇总**:数值列 `sumType` wire 为整数——0=不统计/1=求和/2=平均/3=最小/4=最大/5=计数,写进 presentation.columnsJson 的列对象,8.6.26 反编译 SumType 实证)配置列表视图。**code 语义(与配方 configure-default-list 同口径,r60a-F13 真机对齐 2026-11-13)**:省略 `code`(或 code=schemaCode)= 配置**默认视图**——默认视图在 model.create 时由平台自动生成、是正规的配置对象,日常配列/排序就用它,**不要先 listview.create**(那会多出一个自定义视图);`listview.create` 只在确实需要**第二个**视图时使用,此时 listview.configure 带 code 指向它。在既有(默认)列表视图上配置列、排序、查询条件、行/列表按钮、呈现、自定义按钮、视图头扩展选项与视图类型:读回 query,按 `fieldCodes` 追加缺失列或**原地修正**已存在列的 name/propertyType/displayFormat/visible(不再跳过既有列),置为可见;数值列 displayFormat 由字段 0 基 `options.scale` 推导(0=整数,1=1位,2=2位,3=3位…8=8位;实测 scale 2 → displayFormat 3 = 两位小数)、日期列由 `options.format` 推导(1/2/3/4),回显 `columns` 为完整列对象并给出 `added`/`updated`;`sorts`→querySorts(direction ASC/DESC)、`conditions`→queryConditions(**比较符是 `filterType`(QueryFilterType 字符串枚举 Eq/NotEq/…;别名 operator/op;省略时按 propertyType 取平台默认)**、displayType/choiceType/options 字符串解码;写后条件回读等价校验给出 conditionReadback)、`actions`→queryActions(queryActionType QUERY(1)…BATCH_SUBMIT(23)、associationType BIZSHEET(0)/WORKFLOW(1))、`presentation`→queryPresentation(htmlJson/actionsJson/columnsJson/queryViewDataSource/schemaRelations/options 均为 JSON 字符串,合法 JSON 读回解码)、`buttons`→customButtons(写面 customButtonJson JSON 数组字符串;bindAction/useLocation/operateType/showPermType 以枚举名发送;triggerType 强制 QUERY、triggerCode=视图 code、sortKey 按数组位,缺省回传读面 customButtons 有效集;ADD_DATA/FORM 目标绑定走 actionConfig——schemaCodeVal+formListData+configureList,targetCode/targetObjCode 对其无效会被拒;高层参数 targetModel/targetForm/configureList 从读回元数据展开,未解析即 listview-button-target-unresolved 零副作用拒)、`options`→视图头 BizQueryOption(`pagingSetting`{pageSize,showTotal} 分页、`listViewModeSetting`{mode,canSwitch} 列表模式,缺省回传读面有效 options、提供时整体替换,rowColorSetting 无 8.6.26 类证据故对象形态拒绝)与 `presentationType`→QueryPresentationType(LIST/BOARD/CALENDAR/GANTT,缺省回传读面有效值;GANTT 必须同时提供 `gantt`→queryGanttModel 且 startTimePropertyCode/endTimePropertyCode/titlePropertyCode 非空,缺省不触碰既有 gantt)与 `queryLayer`→层级展示(BizQueryLayer[] 数组原样发送)及 `multiTableHeaderConfig`→多级表头(HeaderConfig[] JSON 字符串;缺省回传读面有效值、提供时整体替换)省略时不触碰既有值,提供时整体替换并经出门前 dry-lint;`query/update` 后回读(`query/get` 自动注入的默认动作、平台 sortKey 重排与 schemaRelations 派生需还原)。`code` 省略时用默认视图(=schemaCode)。`queryConditionMap` 为只读派生(query/get 带 formCode 子表条件时才出现),非配置输入。**发布语义**:`query/update` 自动置 publish=TRUE——视图无草稿/发布两态、无需独立发布步骤(与表单/规则的 draft→publish 不同)。**依赖顺序**:视图与表单脚手架都依赖**已发布字段**,规范顺序 model.create → field.create → field.publish(模型级)→ form.draft → form.publish →(需要第二视图时 listview.create)→ listview.configure → rule.save → rule.enable → workflow。",
129
+ description: "(**列汇总**:数值列 `sumType` wire 为整数——0=不统计/1=求和/2=平均/3=最小/4=最大/5=计数,写进 presentation.columnsJson 的列对象,8.6.26 反编译 SumType 实证)配置列表视图。**code 语义(与配方 configure-default-list 同口径,r60a-F13 真机对齐 2026-11-13;r73 #6 真机对齐 2026-11-17)**:省略 `code`(或 code=schemaCode)= 配置**默认视图**——默认视图 code = 模型 code,同样可 configure(8.6.41 实测),日常配列就用它,**不要先 listview.create**(会多一个视图);改默认视图影响所有用户`listview.create` 只在确实需要**第二个**视图时使用,此时 listview.configure 带 code 指向它。在既有(默认)列表视图上配置列、排序、查询条件、行/列表按钮、呈现、自定义按钮、视图头扩展选项与视图类型:读回 query,按 `fieldCodes` 追加缺失列或**原地修正**已存在列的 name/propertyType/displayFormat/visible(不再跳过既有列),置为可见;数值列 displayFormat 由字段 0 基 `options.scale` 推导(0=整数,1=1位,2=2位,3=3位…8=8位;实测 scale 2 → displayFormat 3 = 两位小数)、日期列由 `options.format` 推导(1/2/3/4),回显 `columns` 为完整列对象并给出 `added`/`updated`;`sorts`→querySorts(direction ASC/DESC)、`conditions`→queryConditions(**比较符是 `filterType`(QueryFilterType 字符串枚举 Eq/NotEq/…;别名 operator/op;省略时按 propertyType 取平台默认)**、displayType/choiceType/options 字符串解码;写后条件回读等价校验给出 conditionReadback)、`actions`→queryActions(queryActionType QUERY(1)…BATCH_SUBMIT(23)、associationType BIZSHEET(0)/WORKFLOW(1))、`presentation`→queryPresentation(htmlJson/actionsJson/columnsJson/queryViewDataSource/schemaRelations/options 均为 JSON 字符串,合法 JSON 读回解码)、`buttons`→customButtons(写面 customButtonJson JSON 数组字符串;bindAction/useLocation/operateType/showPermType 以枚举名发送;triggerType 强制 QUERY、triggerCode=视图 code、sortKey 按数组位,缺省回传读面 customButtons 有效集;ADD_DATA/FORM 目标绑定走 actionConfig——schemaCodeVal+formListData+configureList,targetCode/targetObjCode 对其无效会被拒;高层参数 targetModel/targetForm/configureList 从读回元数据展开,未解析即 listview-button-target-unresolved 零副作用拒)、`options`→视图头 BizQueryOption(`pagingSetting`{pageSize,showTotal} 分页、`listViewModeSetting`{mode,canSwitch} 列表模式,缺省回传读面有效 options、提供时整体替换,rowColorSetting 无 8.6.26 类证据故对象形态拒绝)与 `presentationType`→QueryPresentationType(LIST/BOARD/CALENDAR/GANTT,缺省回传读面有效值;GANTT 必须同时提供 `gantt`→queryGanttModel 且 startTimePropertyCode/endTimePropertyCode/titlePropertyCode 非空,缺省不触碰既有 gantt)与 `queryLayer`→层级展示(BizQueryLayer[] 数组原样发送)及 `multiTableHeaderConfig`→多级表头(HeaderConfig[] JSON 字符串;缺省回传读面有效值、提供时整体替换)省略时不触碰既有值,提供时整体替换并经出门前 dry-lint;`query/update` 后回读(`query/get` 自动注入的默认动作、平台 sortKey 重排与 schemaRelations 派生需还原)。`code` 省略时用默认视图(=schemaCode)。`queryConditionMap` 为只读派生(query/get 带 formCode 子表条件时才出现),非配置输入。**发布语义**:`query/update` 自动置 publish=TRUE——视图无草稿/发布两态、无需独立发布步骤(与表单/规则的 draft→publish 不同)。**依赖顺序**:视图与表单脚手架都依赖**已发布字段**,规范顺序 model.create → field.create → field.publish(模型级)→ form.draft → form.publish →(需要第二视图时 listview.create)→ listview.configure → rule.save → rule.enable → workflow。",
130
130
  }),
131
131
  "listview.delete": Object.freeze({
132
132
  scope: LIST_VIEW_SCOPE,
@@ -208,10 +208,16 @@ const buttonConfigureListArg = z
208
208
  .object({
209
209
  currentDataItemId: z.string().min(1).optional().describe("源字段 code(当前视图模型上的字段);缺失由 dry-lint 拒绝(listview-buttons-invalid)"),
210
210
  targetDataItemId: z.string().min(1).optional().describe("目标字段 code(targetModel 上的字段);缺失由 dry-lint 拒绝(listview-buttons-invalid)"),
211
- isConst: z.string().optional().describe('常量开关是字符串 "true"/"false";仅 "false" 已取证(常量赋值键名未取证,未实现)'),
212
- OptionType: z.string().optional().describe("赋值算子(注意大写 O);仅 Eq 已取证"),
211
+ isConst: z.string().optional().describe('常量开关(字符串 "true"/"false"):"true" 表示常量赋值,必须同时给 currentDataInput'),
212
+ OptionType: z.string().optional().describe("赋值算子(注意大写 O);缺省 Eq"),
213
+ currentDataInput: z.string().optional().describe('常量赋值的值(isConst:"true" 时必填;读面同名字段,r73 真机取证)'),
214
+ // 读→写回灌(线上 #40 #5):listview.get 的条目带 targetDataItem/currentDataItem
215
+ // 内联副本。原样回传时这两个键在此显式声明(工具不消费,只避免 schema 面把
216
+ // 它们标成 additionalProperties:false 诱导调用方手工裁剪丢掉 currentDataInput)。
217
+ targetDataItem: z.unknown().optional().describe("读面内联副本;回灌原样带回即可"),
218
+ currentDataItem: z.unknown().optional().describe("读面内联副本;回灌原样带回即可"),
213
219
  })
214
- .describe("actionConfig.configureList[] 数据赋值条目;字段对象内联副本由工具从发布面读回展开");
220
+ .describe("actionConfig.configureList[] 数据赋值条目。读→写映射:currentDataItemId/targetDataItemId(字段 code,必填)、isConst(\"true\"=常量赋值)、currentDataInput(常量值,isConst=true 必填)、OptionType(缺省 Eq);targetDataItem/currentDataItem 是读面内联副本,回灌时原样带回即可");
215
221
  export const listViewButtonArg = z
216
222
  .object({
217
223
  code: z.string().min(1),
@@ -219,12 +225,12 @@ export const listViewButtonArg = z
219
225
  useLocation: buttonUseLocationArg,
220
226
  bindAction: buttonBindActionArg,
221
227
  operateType: buttonOperateTypeArg,
222
- showPermCode: z.string().optional(),
223
- showPermType: buttonShowPermTypeArg.optional(),
224
- hint: z.string().optional(),
225
- targetCode: z.string().optional(),
226
- targetObjCode: z.string().optional(),
227
- description: z.string().optional(),
228
+ showPermCode: z.string().nullable().optional().describe("读面 null 可回灌"),
229
+ showPermType: buttonShowPermTypeArg.nullable().optional(),
230
+ hint: z.string().nullable().optional(),
231
+ targetCode: z.string().nullable().optional().describe("FLOW=流程 code;ADD_DATA/FORM 读面 null(可回灌)"),
232
+ targetObjCode: z.string().nullable().optional(),
233
+ description: z.string().nullable().optional(),
228
234
  targetModel: z.string().min(1).optional().describe("ADD_DATA/FORM 目标模型 code;工具读回应用树节点内联展开成 actionConfig.schemaCodeVal(targetCode/targetObjCode 对这两类按钮无效——实测恒 null 不参与)"),
229
235
  targetForm: z.string().min(1).optional().describe("ADD_DATA/FORM 目标表单 code;缺省用目标模型的默认表单;展开成 actionConfig.formListData"),
230
236
  configureList: z.array(buttonConfigureListArg).optional().describe("ADD_DATA 数据赋值;展开成 actionConfig.configureList(含 isConst:\"false\"、OptionType:\"Eq\" 与字段内联副本)"),
@@ -564,7 +570,7 @@ export function assertListViewConfigureShape(args) {
564
570
  if (typeof entry.operateType !== "string" || !(entry.operateType in BUTTON_OPERATE_TYPE.index)) {
565
571
  throw new ToolRefusalError({ status: "refused", blocker: "listview-buttons-invalid", message: `buttons operateType must be WITH_VIEW or WITH_OUT_VIEW (got ${String(entry.operateType)})` });
566
572
  }
567
- if (entry.showPermType !== undefined && (typeof entry.showPermType !== "string" || !(entry.showPermType in BUTTON_SHOW_PERM_TYPE.index))) {
573
+ if (entry.showPermType !== undefined && entry.showPermType !== null && (typeof entry.showPermType !== "string" || !(entry.showPermType in BUTTON_SHOW_PERM_TYPE.index))) {
568
574
  throw new ToolRefusalError({ status: "refused", blocker: "listview-buttons-invalid", message: `buttons showPermType must be a ButtonShowPermType name (got ${String(entry.showPermType)})` });
569
575
  }
570
576
  if (entry.actionConfig !== undefined && typeof entry.actionConfig !== "string" && (typeof entry.actionConfig !== "object" || entry.actionConfig === null || Array.isArray(entry.actionConfig))) {
@@ -574,7 +580,7 @@ export function assertListViewConfigureShape(args) {
574
580
  // (schemaCodeVal + formListData + configureList); targetCode/targetObjCode
575
581
  // are measured always-null and NOT consumed for these bind actions.
576
582
  if (entry.bindAction === "ADD_DATA" || entry.bindAction === "FORM") {
577
- if (entry.targetCode !== undefined || entry.targetObjCode !== undefined) {
583
+ if ((entry.targetCode !== undefined && entry.targetCode !== null) || (entry.targetObjCode !== undefined && entry.targetObjCode !== null)) {
578
584
  throw new ToolRefusalError({
579
585
  status: "refused",
580
586
  blocker: "listview-button-target-ineffective",
@@ -630,8 +636,11 @@ export function assertListViewConfigureShape(args) {
630
636
  if (typeof assignment.currentDataItemId !== "string" || assignment.currentDataItemId.length === 0 || typeof assignment.targetDataItemId !== "string" || assignment.targetDataItemId.length === 0) {
631
637
  throw new ToolRefusalError({ status: "refused", blocker: "listview-buttons-invalid", message: `buttons ${String(entry.code)}:configureList 每条需要 currentDataItemId + targetDataItemId(字段 code)` });
632
638
  }
633
- if (assignment.isConst !== undefined && assignment.isConst !== "false") {
634
- throw new ToolRefusalError({ status: "refused", blocker: "listview-buttons-invalid", message: `buttons ${String(entry.code)}:configureList.isConst 仅 "false" 已取证(字符串);常量赋值的值键名未取证,未实现` });
639
+ if (assignment.isConst !== undefined && assignment.isConst !== "true" && assignment.isConst !== "false") {
640
+ throw new ToolRefusalError({ status: "refused", blocker: "listview-buttons-invalid", message: `buttons ${String(entry.code)}:configureList.isConst 只接受字符串 "true"/"false"` });
641
+ }
642
+ if (assignment.isConst === "true" && (typeof assignment.currentDataInput !== "string" || assignment.currentDataInput === "")) {
643
+ throw new ToolRefusalError({ status: "refused", blocker: "listview-buttons-invalid", message: `buttons ${String(entry.code)}:configureList 常量赋值(isConst:"true")必须给 currentDataInput(常量值)` });
635
644
  }
636
645
  if (assignment.OptionType !== undefined && assignment.OptionType !== "Eq") {
637
646
  throw new ToolRefusalError({ status: "refused", blocker: "listview-buttons-invalid", message: `buttons ${String(entry.code)}:configureList.OptionType(注意大写 O)仅 "Eq" 已取证` });
@@ -989,17 +998,17 @@ export function normalizeButtons(buttons, schemaCode, triggerCode) {
989
998
  operateType: button.operateType,
990
999
  sortKey: index,
991
1000
  };
992
- if (button.showPermCode !== undefined)
1001
+ if (button.showPermCode !== undefined && button.showPermCode !== null)
993
1002
  row.showPermCode = button.showPermCode;
994
- if (button.showPermType !== undefined)
1003
+ if (button.showPermType !== undefined && button.showPermType !== null)
995
1004
  row.showPermType = button.showPermType;
996
- if (button.hint !== undefined)
1005
+ if (button.hint !== undefined && button.hint !== null)
997
1006
  row.hint = button.hint;
998
- if (button.targetCode !== undefined)
1007
+ if (button.targetCode !== undefined && button.targetCode !== null)
999
1008
  row.targetCode = button.targetCode;
1000
- if (button.targetObjCode !== undefined)
1009
+ if (button.targetObjCode !== undefined && button.targetObjCode !== null)
1001
1010
  row.targetObjCode = button.targetObjCode;
1002
- if (button.description !== undefined)
1011
+ if (button.description !== undefined && button.description !== null)
1003
1012
  row.description = button.description;
1004
1013
  // BizButtonModel.actionConfig is a non-null String on the render path. The
1005
1014
  // list runtime does `"string"==typeof a ? JSON.parse(a) : a`, then for