@stalfh233/omc-cli 0.6.67 → 0.6.68

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/call.js CHANGED
@@ -122,11 +122,22 @@ export async function runToolCall(toolName, options = {}) {
122
122
  // dictionary.delete) must not read as an OMC gap: name the real recovery
123
123
  // path and the documented absence instead of only the nearest tools.
124
124
  const absence = absencePointer(toolName);
125
+ // 线上 #40 第 10 条(2026-11-17):`workflow.get` 不是平台缺席,而是 OMC
126
+ // 读面按状态拆成两个工具——「工具不存在」的候选列表看着像拼写错误,
127
+ // 调用方会先怀疑自己再试一遍。直接点名拆分事实与两条命令。
128
+ const SPLIT_FACES = {
129
+ "workflow.get": {
130
+ faces: ["workflow.get_draft", "workflow.get_published"],
131
+ note: "workflow.get 不存在:读面按状态拆分——草稿用 workflow.get_draft,已发布用 workflow.get_published(两面字段不同,不要拿草稿面推断线上形状)",
132
+ },
133
+ };
134
+ const split = SPLIT_FACES[toolName];
125
135
  const result = {
126
136
  status: "unknown-tool",
127
137
  tool: toolName,
138
+ ...(split ? { splitFaces: split.faces, note: split.note, nextCommand: `omc call ${split.faces[split.faces.length - 1]} --args '{"workflowCode":"<流程 code>"}'` } : {}),
128
139
  ...(candidates.length > 0 ? { candidates } : {}),
129
- ...(didYouMean.length > 0 ? { didYouMean, nextCommand: `omc describe ${didYouMean[0]}` } : {}),
140
+ ...(!split && didYouMean.length > 0 ? { didYouMean, nextCommand: `omc describe ${didYouMean[0]}` } : {}),
130
141
  ...(byText.length > 0 ? { didYouMeanByText: byText } : {}),
131
142
  ...(absence ? { platformAbsence: absence.replace(/^;/, "") } : {}),
132
143
  // 跨族/表意不清时,「猜名字」本身就不该是路径——用目标路由一步到位。
@@ -157,6 +157,15 @@ export function requestId() {
157
157
  * (`business-rule-branch-conditional`) no matter WHICH lint code fired, so a
158
158
  * QUERY-shape failure sent the caller to a BRANCH example (2 wasted calls, 0
159
159
  * benefit). Route by the first code's prefix and only fall back to the example.
160
+ *
161
+ * r73 P1 (issue #40 §9): the remaining lie was `rule-graph-create*` as a whole
162
+ * pointing at the CROSS-MODEL recipe — a same-model CREATE node missing
163
+ * `originatorValue` (or an illegal `originatorValueType` /
164
+ * `childTriggerConditionType`) is a "what value goes in this node key" error,
165
+ * not a cross-model shape error; the cross-model example sent the caller
166
+ * hunting graph shapes while the fix was one node key. Those three codes route
167
+ * to the nodeGraph param page (node-key reference); the lint message itself
168
+ * carries the DYNAMIC/FIXED fill recipe.
160
169
  */
161
170
  export function ruleGraphRecovery(validation) {
162
171
  if (!Array.isArray(validation))
@@ -174,6 +183,8 @@ export function ruleGraphRecovery(validation) {
174
183
  return "omc compute --help";
175
184
  if (first.startsWith("rule-graph-assign-"))
176
185
  return "omc describe rule.save --param nodeGraph";
186
+ if (first === "rule-graph-create-originator" || first === "rule-graph-create-originator-value" || first === "rule-graph-child-trigger-condition-type")
187
+ return "omc describe rule.save --param nodeGraph";
177
188
  if (first.startsWith("rule-graph-preset-system-node") || first === "rule-graph-system-node")
178
189
  return "omc describe rule.save --example standard-business-rule-graph";
179
190
  if (first.startsWith("rule-graph-branch") || first.startsWith("rule-graph-condition-"))
package/dist/cli.js CHANGED
@@ -26,7 +26,7 @@ import { artifactFetchHint, artifactRoot, boundResult, emitInvalid, emitResult,
26
26
  import { CLI_DEFAULT_OUTPUT_BYTES, assertSafeOutputPath, pruneArtifacts } from "./artifacts.js";
27
27
  import { artifactPathMissHint, nullProjectionHint, partialPathMissHint, projectJsonPath, projectJsonPathFanout, projectResultExtract } from "./path-projection.js";
28
28
  import { basename, join, resolve } from "node:path";
29
- import { existsSync, readFileSync, writeFileSync } from "node:fs";
29
+ import { existsSync, readFileSync, writeFileSync, chmodSync } from "node:fs";
30
30
  import { buildToolRegistry } from "./tools.js";
31
31
  import { acquireWriteLock, writeLockHeldFace } from "./write-lock.js";
32
32
  import { cmdCompute } from "./compute.js";
@@ -980,6 +980,35 @@ function formatBytes(bytes) {
980
980
  return `${(bytes / 1024).toFixed(1)}KB`;
981
981
  return `${(bytes / 1024 / 1024).toFixed(1)}MB`;
982
982
  }
983
+ /**
984
+ * r73 #7(GitLab #40 P1):从 `omc artifact get <id> --out <path>` 的 argv 里截出
985
+ * `--out` 并原地摘除那两个 token,让 configureOutput / stripOutputFlags 的全局
986
+ * 信封重定向语义不再吃掉它。只对 `artifact get` 子命令生效;缺值/flag 形值与
987
+ * configureOutput 同规则拒绝(invalid-input)。返回截得的路径,未出现则 undefined。
988
+ */
989
+ function extractArtifactGetOutFlag(argv) {
990
+ const tokens = argv.slice(2);
991
+ if (tokens[0] !== "artifact" || tokens[1] !== "get")
992
+ return undefined;
993
+ for (let index = 2; index < argv.length; index += 1) {
994
+ const token = argv[index];
995
+ if (token === "--out") {
996
+ const value = argv[index + 1];
997
+ if (value === undefined || value.startsWith("--"))
998
+ throw new Error("--out requires a file path");
999
+ argv.splice(index, 2);
1000
+ return value;
1001
+ }
1002
+ if (token.startsWith("--out=")) {
1003
+ const value = token.slice("--out=".length);
1004
+ if (value.length === 0)
1005
+ throw new Error("--out requires a file path");
1006
+ argv.splice(index, 1);
1007
+ return value;
1008
+ }
1009
+ }
1010
+ return undefined;
1011
+ }
983
1012
  async function cmdArtifactGet(id, transport, options = {}) {
984
1013
  try {
985
1014
  const artifact = readArtifact(artifactRoot(), id);
@@ -990,6 +1019,25 @@ async function cmdArtifactGet(id, transport, options = {}) {
990
1019
  catch {
991
1020
  content = artifact.content.toString("utf8");
992
1021
  }
1022
+ // r73 #7(GitLab #40 P1,2026-11-17):`--out <配置根内路径>` 把 artifact 原始
1023
+ // 正文**全量落盘**——写文件不走 stdout 限额,`--full` 被上限卡死(fullRejected)
1024
+ // 的大对象(实测 589KB 视图 artifact)此前只能拆 key 取、易漏。这里写的是已过
1025
+ // sha256 校验的原文字节;回执只给 {out,bytes,sha256},stdout 不回正文。
1026
+ if (options.out !== undefined) {
1027
+ let outPath;
1028
+ try {
1029
+ outPath = assertSafeOutputPath(intentConfigRoot(), options.out, "artifact output file");
1030
+ }
1031
+ catch (error) {
1032
+ const detail = error instanceof Error ? error.message : String(error);
1033
+ const parsed = errorEnvelope(new Error(`artifact get --out 落盘被拒:${detail}。--out 按配置根(OMC_CONFIG_HOME)解析,只允许配置根内的常规文件路径(父目录须已存在)`), "artifact-out-refused", CLI_EXIT_CODES.invalidInput, transport.request);
1034
+ writeEnvelope(parsed.envelope);
1035
+ return parsed.exitCode;
1036
+ }
1037
+ writeFileSync(outPath, artifact.content, { mode: 0o600 });
1038
+ chmodSync(outPath, 0o600);
1039
+ return emitTransportResult({ status: "ok", artifactId: id, sha256: artifact.sha256, bytes: artifact.content.length, out: options.out, mode: "0600" }, transport);
1040
+ }
993
1041
  // `--path-only` deliberately does NOT return the local path: the Agent-facing
994
1042
  // CLI contract forbids exposing local filesystem paths. It returns the fetch
995
1043
  // command instead, which is the portable way to reach the body.
@@ -1106,7 +1154,7 @@ async function cmdArtifactGet(id, transport, options = {}) {
1106
1154
  bytes: artifact.content.length,
1107
1155
  outline: true,
1108
1156
  ...(record ? { keys } : { kind: typeof content }),
1109
- hint: `正文 ${Math.round(artifact.content.length / 1024)}KB 超过内联上限 ${ARTIFACT_INLINE_CEILING_BYTES}B,本次只回形状(顶层键 + 体积)。要某几个键:--keys <a,b>;要某个路径:--jq '<path>'(支持 .rules[code=Create].name 这类数组选择器);确实需要整包:--full。`,
1157
+ hint: `正文 ${Math.round(artifact.content.length / 1024)}KB 超过内联上限 ${ARTIFACT_INLINE_CEILING_BYTES}B,本次只回形状(顶层键 + 体积)。要某几个键:--keys <a,b>;要某个路径:--jq '<path>'(支持 .rules[code=Create].name 这类数组选择器);确实需要整包:--full,或 --out <配置根内路径> 整包落盘(不走 stdout 限额)。`,
1110
1158
  keysCommand: keys.length > 0 ? `omc artifact get ${id} --keys ${keys.slice(0, 3).map((entry) => entry.key).join(",")}` : `omc artifact get ${id} --summary`,
1111
1159
  fullCommand: `omc artifact get ${id} --full`,
1112
1160
  }, transport);
@@ -1136,8 +1184,9 @@ async function cmdArtifactGet(id, transport, options = {}) {
1136
1184
  reason: `整包 ${Math.round(artifact.content.length / 1024)}KB 超过本通道输出上限 ${transport.maxOutputBytes}B;--full 无法一次返回,再跑一次结果相同`,
1137
1185
  ...(keys.length > 0 ? { keysCommand: `omc artifact get ${id} --keys ${keys.join(",")}`, sampledKeys: keys } : {}),
1138
1186
  jqCommand: `omc artifact get ${id} --jq '<path>'`,
1187
+ outCommand: `omc artifact get ${id} --out <配置根内文件路径>(整包落盘,不走 stdout 限额,适合一次性备份)`,
1139
1188
  raiseCeilingCommand: `omc artifact get ${id} --full --max-output-bytes ${Math.max(artifact.content.length + 1024, transport.maxOutputBytes * 2)}`,
1140
- hint: "二选一:用 --jq/--keys 取你真正需要的那部分(推荐),或显式抬高 --max-output-bytes",
1189
+ hint: "三选一:用 --jq/--keys 取你真正需要的那部分(推荐),整包落盘备份用 --out <配置根内路径>(写文件不受 stdout 限额),或显式抬高 --max-output-bytes",
1141
1190
  }, transport);
1142
1191
  }
1143
1192
  return emitTransportResult(result, transport);
@@ -2352,6 +2401,9 @@ function joinSplitFlagValues(raw, flags) {
2352
2401
  let lastHelpChunk = "";
2353
2402
  async function main() {
2354
2403
  let commandExitCode = 0;
2404
+ // r73 #7:artifact get 的 --out 值(在 configureOutput 之前截获,见下)。全局
2405
+ // 其它命令的 --out 语义不变(stdout 信封重定向)。
2406
+ let artifactGetOutPath;
2355
2407
  // stderr is the diagnostics stream: apply the same Windows code-page policy
2356
2408
  // as stdout before ANY message is written (banner, doctor, refusals).
2357
2409
  installCodePageSafeStderr();
@@ -2374,6 +2426,11 @@ async function main() {
2374
2426
  }
2375
2427
  };
2376
2428
  try {
2429
+ // r73 #7(GitLab #40 P1):`artifact get <id> --out <配置根内路径>` 是**产物正文
2430
+ // 落盘**语义。`--out` 同时是全局 stdout 信封重定向 flag(configureOutput 在
2431
+ // commander 之前消费它),artifact get 场景必须先行截走,否则正文永远到不了
2432
+ // 文件、全局通道只会把小信封写进目标文件。
2433
+ artifactGetOutPath = extractArtifactGetOutFlag(argv);
2377
2434
  configureOutput(argv);
2378
2435
  }
2379
2436
  catch (error) {
@@ -2820,20 +2877,22 @@ async function main() {
2820
2877
  console.error(`已清理 ${result.removed} 个读回产物,释放 ${formatBytes(result.freedBytes)};保留 ${result.kept} 个(${formatBytes(result.keptBytes)})`);
2821
2878
  commandExitCode = CLI_EXIT_CODES.ok;
2822
2879
  });
2823
- artifactCommand.command("get <id>").addOption(new Option("--jq [path]", "路径选择器(非 jq);支持 [] 映射与逗号多路径;裸 --jq 列顶层键").argParser((value, previous = []) => [...previous, value]).default([])).option("--extract <path>", "同 --jq(与 omc call 的 --extract 同名,省一次命名切换)").option("--path-only").option("--summary").option("--keys [a,b]").option("--full", "整包返回正文(默认:正文超过 8KB 时只回形状 outline + fetch,按需 --jq/--keys 定向取值)").option("--max-output-bytes <bytes>").action(async (id, options) => {
2880
+ artifactCommand.command("get <id>").addOption(new Option("--jq [path]", "路径选择器(非 jq);支持 [] 映射与逗号多路径;裸 --jq 列顶层键").argParser((value, previous = []) => [...previous, value]).default([])).option("--extract <path>", "同 --jq(与 omc call 的 --extract 同名,省一次命名切换)").option("--path-only").option("--summary").option("--keys [a,b]").option("--full", "整包返回正文(默认:正文超过 8KB 时只回形状 outline + fetch,按需 --jq/--keys 定向取值)").option("--out <path>", "把 artifact 原始正文全量写到配置根内文件(0600;写文件不走 stdout 限额,大对象一次落盘备份;回执只给 {out,bytes,sha256} 不回正文)").option("--max-output-bytes <bytes>").action(async (id, options) => {
2824
2881
  // A bare `--jq`/`--keys` is a key-inventory request, not a missing argument:
2825
2882
  // commander's "argument missing" (invalid-input + retry) is a dead end the
2826
2883
  // caller cannot fix without already knowing the flag takes a value (r11
2827
2884
  // burned six rounds on `artifact get <id> --jq` before trying `--summary`).
2828
2885
  // --extract 是 --jq 的同义别名(r28h F3)。
2829
2886
  // 重复 --jq 的多路径合并为逗号路径透传(r34c-F8:此前静默只留最后一个)。
2887
+ // r73 #7:--out 在 configureOutput 之前被 extractArtifactGetOutFlag 截获
2888
+ //(commander 永远收不到它),这里读的是 main() 截下的值。
2830
2889
  const jqPaths = [
2831
2890
  ...(Array.isArray(options.jq) ? options.jq.filter((v) => typeof v === "string") : []),
2832
2891
  ...(typeof options.extract === "string" ? [options.extract] : []),
2833
2892
  ];
2834
2893
  const bareJq = options.jq === true;
2835
2894
  commandExitCode = await withTransport(options, request, (transport) => cmdArtifactGet(id, transport, { ...(jqPaths.length > 0 ? { jq: jqPaths.join(",") } : {}), pathOnly: options.pathOnly === true, summary: options.summary === true || options.keys === true || bareJq,
2836
- pureKeys: (options.keys === true || bareJq) && options.summary !== true, ...(typeof options.keys === "string" ? { keys: options.keys } : {}), full: options.full === true }));
2895
+ pureKeys: (options.keys === true || bareJq) && options.summary !== true, ...(typeof options.keys === "string" ? { keys: options.keys } : {}), full: options.full === true, ...(artifactGetOutPath !== undefined ? { out: artifactGetOutPath } : {}) }));
2837
2896
  });
2838
2897
  command.command("bench").option("--live-sample").option("--env <environment>").action(async (options) => { commandExitCode = await cmdBench([...(options.liveSample ? ["--live-sample"] : []), ...(options.env ? ["--env", options.env] : [])]); });
2839
2898
  command.command("residue <prefix>").description("跨面前缀残留扫描(model 全租户/folder/custompage;默认 deep 再查命中模型的 rule/datarule/onlinejs)——收尾「删净」一次证明,clean:true 即零残留。清理入口:omc model-purge --code <schemaCode>(按依赖倒序,默认 dry-run)。只读零写入;report 面暂停维护未扫描").option("--env <environment>", "环境名(默认按 cwd 的 .omc-env 解析)").option("--apps <codes>", "all(默认,全租户)或逗号分隔应用码").option("--no-deep", "只扫 model/folder/custompage,不深查命中模型").option("--all-faces", "列出全部应用×面(含 count:0;默认只回非零面+byFace/userResidues 紧凑形)").option("--max-output-bytes <bytes>").addOption(new Option("--jq [path]", "--jq 不是 jq,仅路径选择器(与 call --jq 同 DSL;可逗号多路径;裸 --jq 列顶层键)").argParser((value, previous = []) => [...previous, value]).default([])).action(async (prefix, options) => { commandExitCode = await withTransport(options, request, (transport) => cmdResidue(prefix, { env: options.env, apps: options.apps, ...(options.deep === false ? { noDeep: true } : {}), ...(options.allFaces ? { allFaces: true } : {}), ...(options.jq !== undefined ? { jq: options.jq } : {}) }, transport)); });
package/dist/graph.js CHANGED
@@ -334,8 +334,16 @@ export function extractReferenceEdges(schemaCode, ruleCode, nodes, routes = [],
334
334
  if (["CREATE", "UPDATE", "DELETE"].includes(String(node.nodeType ?? ""))) {
335
335
  push("model", String(node.targetObjectCode ?? ""), node, "targetObjectCode");
336
336
  if (Array.isArray(node.dataActions))
337
- for (const action of node.dataActions)
337
+ for (const action of node.dataActions) {
338
338
  push("field", String(action.targetDataItem ?? ""), node, "dataActions.targetDataItem");
339
+ // r73(r72g 报告遗留的相邻盲区):DYNAMIC 赋值的来源字段
340
+ // (currentDataItemValue)与 EXPRESSION value 里的 `{字段}` 模板同样是
341
+ // 配置里的字段引用——只入承载模型侧(来源就是本行字段),不改变既有
342
+ // targetDataItem 的归属语义。
343
+ push("field", String(action.currentDataItemValue ?? ""), node, "dataActions.currentDataItemValue");
344
+ for (const token of conditionValueTokens(action.value))
345
+ push("field", token, node, "dataActions.value-token");
346
+ }
339
347
  }
340
348
  if (mapping) {
341
349
  push("model", String(mapping.schemaCode ?? ""), node, "methodMapping.schemaCode");
@@ -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 };
@@ -233,12 +249,58 @@ 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]);
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
+ }
242
304
  const wanted = args.code;
243
305
  const matches = [];
244
306
  let scannedRules = 0;
@@ -312,7 +374,12 @@ export function registerBusinessRuleLane(tools) {
312
374
  notScanned: ["datarule", "form", "workflow.permissions", "workflow.bindings", "onlinejs", "listview"],
313
375
  note: "matches:[] 只代表 businessrule 面零命中;datarule/form/流程权限/视图等未扫描(离线 graph references 覆盖更广,见其 coverage),不可据此判定可安全删除",
314
376
  },
315
- ...(scope !== undefined ? { applicationResolution: applicationResolutionOf(scope) } : {}),
377
+ // r73 #3:app-scope 路径回显 applicationResolution(含 mode/models:扫了
378
+ // 哪个应用、共几个模型)。显式 schemaCodes 路径维持原形状(无
379
+ // applicationResolution/hint——显式范围自带出处,provenance 契约不变)。
380
+ ...(args.schemaCodes === undefined && scope !== undefined
381
+ ? { applicationResolution: { ...applicationResolutionOf(scope), mode: scanMode, models: scoped.length } }
382
+ : {}),
316
383
  ...(matches.length === 0
317
384
  ? {
318
385
  note: "零命中=" +
@@ -320,7 +387,7 @@ export function registerBusinessRuleLane(tools) {
320
387
  ? `仅扫描了 schemaCodes 收窄的 ${scoped.length} 个模型(${scoped.slice(0, 5).join(", ")}${scoped.length > 5 ? "…" : ""})——引用常发生在**其他**模型上;要全平台结论请去掉 schemaCodes`
321
388
  : "全平台没有规则引用它") +
322
389
  "。范围: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, "引用") } : {}),
390
+ ...(args.schemaCodes === undefined && scope !== undefined ? { hint: applicationScopeHint(scope, "引用") } : {}),
324
391
  }
325
392
  : {
326
393
  // r31(2026-10-31):影响评估场景 agent 已路由到本工具——在必经之路
@@ -419,6 +486,7 @@ export function registerBusinessRuleLane(tools) {
419
486
  // dry-lint,把"已启用但运行时会被静默跳过/UI 独有算子/选项 key 撞车"
420
487
  // 等语义隐患以 semanticFindings 暴露——"可读不可验"到此为止。
421
488
  let semanticFindings;
489
+ let roundTrip;
422
490
  try {
423
491
  const { validateRuleNodeGraph } = await import("./rule-graph.js");
424
492
  // r45 I5 误报根因:体检重建图只带 nodes/routes,把行级 schedulerSetting
@@ -437,6 +505,23 @@ export function registerBusinessRuleLane(tools) {
437
505
  message: finding.message,
438
506
  }));
439
507
  }
508
+ // r73 #2(GitLab #40,8.6.41 实测):roundTrip = 整图原样回存的显式判定。
509
+ // safe:true 也是显式键(不是缺键)——agent 要能区分「判定过、可回存」与
510
+ // 「没判定」。与 full/keys 选择器无关:它是回执顶层键,与 nodes 并列。
511
+ const hazards = findings.filter((finding) => finding.severity !== "warning");
512
+ roundTrip = hazards.length === 0
513
+ ? { safe: true }
514
+ : {
515
+ safe: false,
516
+ gaps: hazards.map((finding) => ({
517
+ code: finding.code,
518
+ ...(finding.nodeCode !== undefined ? { nodeCode: finding.nodeCode } : {}),
519
+ ...(finding.key !== undefined ? { key: finding.key } : {}),
520
+ message: finding.message,
521
+ fix: roundTripFixOf(finding.code),
522
+ })),
523
+ hint: RULE_ROUND_TRIP_HINT,
524
+ };
440
525
  }
441
526
  catch {
442
527
  // 体检失败不破坏读回本身
@@ -468,6 +553,8 @@ export function registerBusinessRuleLane(tools) {
468
553
  schedulerSetting: parse(record.schedulerSetting),
469
554
  renderCompat,
470
555
  ...(semanticFindings ? { semanticFindings } : {}),
556
+ // r73 #2:roundTrip 是显式判定键(safe:true 也在),不是缺键
557
+ ...(roundTrip ? { roundTrip } : {}),
471
558
  ...(staleRow ? { staleRow, effectiveId, staleRowMessage, staleId: true, latestId: effectiveId, note: staleNote } : {}),
472
559
  };
473
560
  if (args.withRuntime === true) {
@@ -521,6 +608,9 @@ export function registerBusinessRuleLane(tools) {
521
608
  ? payload.schedulerSetting.dataSourceType
522
609
  : undefined,
523
610
  ...(payload.statusLag ? { statusLag: payload.statusLag, statusNote: payload.statusNote } : {}),
611
+ // r73 #2:summary 面同样带 roundTrip 显式判定(不内联正文也要能回答
612
+ // 「这张图能不能原样回存」)。
613
+ ...(roundTrip ? { roundTrip } : {}),
524
614
  // #39 摩擦 E:summary 面也要带 stale 提示——持旧 id 的调用方常只看
525
615
  // summary,漏掉 stale 会把旧图当成「改了没生效」。
526
616
  ...(staleRow ? { staleId: true, latestId: effectiveId, note: staleNote } : {}),
@@ -559,6 +649,33 @@ export function registerBusinessRuleLane(tools) {
559
649
  // (so every graph gate + readback is identical). Platform constraints honoured:
560
650
  // `nodeCode`/`nodeType` are immutable (routes reference nodeCode; the platform
561
651
  // cannot retype a node), so the patch may not change them.
652
+ //
653
+ // r73 #1(GitLab #40,8.6.41 实测):execute 与 dryRunPayload 共用同一个
654
+ // 读法/合并法(loadRuleNodePatchGraph)——dry-run 读存量行 → 浅合并 patch →
655
+ // 全图 lint(lintRuleGraphForWrite,与真写同门)。读失败(规则/节点不存在、
656
+ // 不可变键)按 execute 同款 refusal 抛出,绝不静默放行。
657
+ const loadRuleNodePatchGraph = async (session, args) => {
658
+ const id = await resolveRuleRowId(session, args.schemaCode, args.ruleCode);
659
+ if (!id)
660
+ throw new ToolRefusalError({ status: "refused", blocker: "rule-absent", message: `规则 ${args.schemaCode}.${args.ruleCode} 不存在;拒绝 node patch` });
661
+ const record = (await wireCall(session, { path: ENDPOINTS.businessRuleGet, query: { id } })).data;
662
+ if (!record)
663
+ throw new ToolRefusalError({ status: "refused", blocker: "rule-absent", message: `规则 ${args.schemaCode}.${args.ruleCode}(id ${id})读回为空` });
664
+ for (const key of ["nodeCode", "nodeType"])
665
+ if (key in args.patch)
666
+ throw new ToolRefusalError({ status: "refused", blocker: "rule-node-immutable-key", message: `node patch 不允许改 ${key}(平台按 nodeCode 连接路由、节点类型不可变);要改名/改型请整图 rule.save` });
667
+ // node/route are SEPARATE JSON-string columns (see rule.get): `node` is the
668
+ // nodes array, `route` the routes array — not one {nodes,routes} object.
669
+ const nodes = decodeJsonColumn(record.node, JSON_COLUMN_NULL_COALESCE);
670
+ const routes = decodeJsonColumn(record.route, JSON_COLUMN_NULL_COALESCE);
671
+ const nodeList = Array.isArray(nodes) ? nodes : [];
672
+ const target = nodeList.find((node) => node.nodeCode === args.nodeCode);
673
+ if (!target)
674
+ throw new ToolRefusalError({ status: "refused", blocker: "rule-node-absent", message: `现有图中没有 nodeCode=${args.nodeCode};用 rule.get schemaCode+ruleCode 查看 nodeCode` });
675
+ const mergedNode = { ...target, ...args.patch };
676
+ const mergedGraph = { nodes: nodeList.map((node) => (node.nodeCode === args.nodeCode ? mergedNode : node)), ...(Array.isArray(routes) ? { routes } : {}) };
677
+ return { id, record, mergedGraph, ruleName: String(record.name ?? args.ruleCode) };
678
+ };
562
679
  writeTool({
563
680
  tools,
564
681
  name: "rule.node.update",
@@ -575,26 +692,27 @@ export function registerBusinessRuleLane(tools) {
575
692
  customTrigger: z.boolean().optional(),
576
693
  },
577
694
  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 } : {}) });
695
+ const base = await loadRuleNodePatchGraph(session, args);
696
+ 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 } : {}) });
697
+ },
698
+ // r73 #1(GitLab #40):dry-run 此前走 write.ts 通用 dry-run(只出 plan),不跑
699
+ // 图 lint——非法 patch(如 CREATE 节点 originatorValue 置空)dry-run 过、真写
700
+ // policy-refused。dryRunPayload 与真写共用同一读法与同一 lint:dry-run 回
701
+ // 「能写/不能写」的同一答案,而不是只报 wouldChange。
702
+ dryRunPayload: async (session, args) => {
703
+ const base = await loadRuleNodePatchGraph(session, args);
704
+ // name 校验与真写同源(真写在 executeRuleSaveWrite 里再跑一次同一函数;
705
+ // name 取存量行,预置触发行在函数内部跳过)。
706
+ assertRuleNamePlatformAcceptable(args.ruleCode, base.ruleName);
707
+ const linted = await lintRuleGraphForWrite(session, { schemaCode: args.schemaCode, ruleCode: args.ruleCode, nodeGraph: base.mergedGraph, ...(args.customTrigger === true ? { customTrigger: true } : {}) }, { validationRefusalMessage: "nodeGraph 未过出门前校验(dry lint,与真写同门);按 validation 逐项修正" });
708
+ return {
709
+ nodeCode: args.nodeCode,
710
+ patchedKeys: Object.keys(args.patch),
711
+ // 本次 dry-run 覆盖的是**全图** lint(patch 合并进存量图后整图过门),
712
+ // 不是只验 patch 本身。
713
+ lintScope: "fullGraph",
714
+ validation: linted.blockers,
715
+ };
598
716
  },
599
717
  rollback: businessRuleRollbackSpec("rule.node.update"),
600
718
  });
@@ -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 } : {}),
@@ -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,
@@ -254,6 +254,51 @@ export function filterDefaultSystemColumns(columns, hideDefaultSystemFields) {
254
254
  return [...columns];
255
255
  return columns.filter((column) => typeof column.propertyCode !== "string" || !SYSTEM_FIELD_CODES.has(column.propertyCode));
256
256
  }
257
+ /**
258
+ * r73 #5(GitLab #40 P1,CloudPivot 8.6.41 实测):listview FLOW 按钮读写不对称。
259
+ * 写面 buttons[].targetCode(FLOW 必填)被展开进
260
+ * actionConfig.WorkflowListData[0].workflowCode(见 expandButtonActionConfigs);
261
+ * 读面 button.targetCode 恒为 null,真值只在 actionConfig(可能是 JSON 字符串或
262
+ * 对象;PowerShell ConvertFrom-Json 会把单元素数组展开成单个对象——两种形状都收)。
263
+ * workflowCode 可能 ≠ 模型 code(如 case_delay_apply 的流程 code 是
264
+ * case_delay_apply_flow)。读面统一从这里回填 targetCode 并带来源标注。
265
+ */
266
+ export const FLOW_TARGET_CODE_SOURCE = "actionConfig.WorkflowListData[0].workflowCode";
267
+ export function flowWorkflowCodeFromActionConfig(rawConfig) {
268
+ let parsed;
269
+ if (typeof rawConfig === "string" && rawConfig.trim() !== "") {
270
+ try {
271
+ const value = JSON.parse(rawConfig);
272
+ if (value !== null && typeof value === "object" && !Array.isArray(value))
273
+ parsed = value;
274
+ }
275
+ catch {
276
+ parsed = undefined;
277
+ }
278
+ }
279
+ else if (rawConfig !== null && typeof rawConfig === "object" && !Array.isArray(rawConfig)) {
280
+ parsed = rawConfig;
281
+ }
282
+ const list = parsed?.WorkflowListData;
283
+ // 数组是 wire 真形;单对象是 PowerShell 展开形(8.6.41 实测)——都取 [0].workflowCode。
284
+ const entries = Array.isArray(list) ? list : list !== null && typeof list === "object" && !Array.isArray(list) ? [list] : [];
285
+ for (const entry of entries) {
286
+ if (entry !== null && typeof entry === "object" && !Array.isArray(entry)) {
287
+ const code = entry.workflowCode;
288
+ if (typeof code === "string" && code.length > 0)
289
+ return code;
290
+ }
291
+ }
292
+ return null;
293
+ }
294
+ /** FLOW 回填判定:bindAction=FLOW 且行上的 targetCode 不是非空字符串时,从 actionConfig 反解。 */
295
+ function flowTargetBackfill(button) {
296
+ if (button.bindAction !== "FLOW")
297
+ return null;
298
+ if (typeof button.targetCode === "string" && button.targetCode.length > 0)
299
+ return null;
300
+ return flowWorkflowCodeFromActionConfig(button.actionConfig);
301
+ }
257
302
  /**
258
303
  * Decode a BizButtonModel row's `actionConfig` (stored as a JSON STRING) and
259
304
  * pull out the script source. Everything else is passed through so the caller
@@ -277,13 +322,16 @@ export function decodeButtonScript(input) {
277
322
  parsed = rawConfig;
278
323
  }
279
324
  const script = typeof parsed?.scriptData === "string" ? parsed.scriptData : undefined;
325
+ // r73 #5:FLOW 读面回填——targetCode 恒 null 时从 actionConfig 取真值并标注来源。
326
+ const flowBackfill = flowTargetBackfill(button);
280
327
  return {
281
328
  code: button.code ?? null,
282
329
  name: button.name ?? null,
283
330
  useLocation: button.useLocation ?? null,
284
331
  bindAction: button.bindAction ?? null,
285
332
  operateType: button.operateType ?? null,
286
- targetCode: button.targetCode ?? null,
333
+ targetCode: (typeof button.targetCode === "string" && button.targetCode.length > 0 ? button.targetCode : flowBackfill) ?? null,
334
+ ...(flowBackfill !== null ? { targetCodeSource: FLOW_TARGET_CODE_SOURCE } : {}),
287
335
  ...(script !== undefined
288
336
  ? {
289
337
  scriptData: script,
@@ -312,7 +360,7 @@ export function registerListViewLane(tools) {
312
360
  schemaCode: z.string().min(1),
313
361
  code: z.string().optional().describe("视图 code;省略时用默认视图(=schemaCode)"),
314
362
  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"),
363
+ 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
364
  buttonCode: z.string().min(1).optional().describe("只返回这一个按钮的脚本(与 buttons 同效但更省输出);不存在时报 button-absent 并列出可用 code"),
317
365
  capability: capabilityArg,
318
366
  },
@@ -377,13 +425,21 @@ export function registerListViewLane(tools) {
377
425
  buttonCodes: readArray(model, "customButtons").map((button) => button.code).filter((value) => typeof value === "string"),
378
426
  buttonBindings: readArray(model, "customButtons")
379
427
  .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
- })),
428
+ .map((button) => {
429
+ // r73 #5:紧凑面同样回填 FLOW 的 targetCode(写面必填、读面恒 null 的不对称在这里收口)。
430
+ const flowBackfill = flowTargetBackfill(button);
431
+ return {
432
+ code: button.code,
433
+ ...(button.bindAction !== undefined ? { bindAction: button.bindAction } : {}),
434
+ ...(typeof button.targetCode === "string" && button.targetCode.length > 0
435
+ ? { targetCode: button.targetCode }
436
+ : flowBackfill !== null
437
+ ? { targetCode: flowBackfill, targetCodeSource: FLOW_TARGET_CODE_SOURCE }
438
+ : {}),
439
+ ...(button.targetModel !== undefined ? { targetModel: button.targetModel } : {}),
440
+ ...(button.targetForm !== undefined ? { targetForm: button.targetForm } : {}),
441
+ };
442
+ }),
387
443
  // Button scripts live in h_biz_button.actionConfig (a JSON STRING)
388
444
  // whose `scriptData` holds the source for bindAction=SCRIPT. Surfacing
389
445
  // them here removes the "listview.get → artifact → JSON.parse →
@@ -940,8 +996,14 @@ export function registerListViewLane(tools) {
940
996
  }
941
997
  if (Array.isArray(afterModel.customButtons)) {
942
998
  const buttons = readArray(afterModel, "customButtons");
999
+ // r73 #5:configure 读回同样回填 FLOW targetCode(与 listview.get 读面同规则,
1000
+ // 两面对同一配置给同一个答案)。
943
1001
  readback.buttons = buttons
944
- .map(decodeButtonRow)
1002
+ .map((button) => {
1003
+ const decoded = decodeButtonRow(button);
1004
+ const flowBackfill = flowTargetBackfill(button);
1005
+ return flowBackfill !== null ? { ...decoded, targetCode: flowBackfill, targetCodeSource: FLOW_TARGET_CODE_SOURCE } : decoded;
1006
+ })
945
1007
  .sort((a, b) => Number(a.sortKey ?? 0) - Number(b.sortKey ?? 0));
946
1008
  if (args.buttonScripts !== undefined) {
947
1009
  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,17 @@ 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"] }),
117
128
  });
118
129
  /**
119
130
  * 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.68",
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.68",
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.68"
78
78
  }
79
79
  }