@stalfh233/omc-cli 0.6.79 → 0.6.81

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.
@@ -6,8 +6,10 @@ 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
8
  import { assertRuleNamePlatformAcceptable, executeRuleSaveWrite, lintRuleGraphForWrite, lintRuleSaveWrite, ruleNodeGraphArg } from "../rule-support.js";
9
- import { defineTool, ToolInputError, ToolRefusalError } from "../tool-types.js";
9
+ import { defineTool, isRequiredAlternativePlaceholder, ToolInputError, ToolRefusalError } from "../tool-types.js";
10
10
  import { resolveRuleRowId } from "../identity.js";
11
+ import { extractDataRuleEdges, extractReferenceEdges } from "../graph.js";
12
+ import { scanModelWorkflowBindings } from "./workflow.js";
11
13
  import { wireCall, wireCallWith404Fallback, wireRows } from "../wire.js";
12
14
  import { readModelRecord } from "../model-record.js";
13
15
  import { BUSINESSRULE_LANE_CONTRACT } from "./businessrule-contract.js";
@@ -224,32 +226,110 @@ function ruleSummaryBody(record, graph, roundTrip) {
224
226
  ...(roundTrip ? { roundTrip } : {}),
225
227
  };
226
228
  }
229
+ /** 规则行的 JSON 字符串列(node/route/schedulerSetting):非串 null 化,坏串原样透传。 */
230
+ const parseRuleColumn = (value) => decodeJsonColumn(value, JSON_COLUMN_NULL_COALESCE);
227
231
  /**
228
- * r79-w2b(issue 06):`ruleCodes[]` 同模型批量摘要。一次
229
- * `list_by_schemacode` 解析全部 id 与 node(8.6.26 的 list 面是完整
230
- * BusinessRuleModel,含 node/route——BusinessRule.getModel():128-156),
231
- * 个别行缺 node 时才对该规则回落一 次 `businessrule/get`。
232
- * 诚实口径:wire 字节没少(list 面把 N 张图一起搬回),少的是往返次数与信封体积。
232
+ * r83(R79 二期):BIZ_ACTION 映射的**摘要级**投影——只留定位与方法/入出参计数。
233
+ *
234
+ * `methodMapping` 完整正文(inputMappings/outputMappings)可达 600B+/节点,
235
+ * `rule.list --withMappings` 是清单面,整包内联会把清单变成整图转储;摘要
236
+ * 回答「哪条规则调了哪个服务方法、几个入参几个出参」,取形状仍走 `rule.get`。
233
237
  */
234
- async function readRuleBatch(session, args) {
235
- const schemaCode = args.schemaCode;
236
- if (!schemaCode)
237
- throw new ToolInputError({
238
- status: "error",
239
- blocker: "tool-input-invalid",
240
- tool: "rule.get",
241
- message: "ruleCodes 批量只在同一 schemaCode 内(跨模型 schemaCodes[] 是二期)——请同时传 schemaCode",
238
+ function ruleMappingDigests(nodes) {
239
+ if (!Array.isArray(nodes))
240
+ return [];
241
+ const digests = [];
242
+ for (const entry of nodes) {
243
+ if (entry === null || typeof entry !== "object" || Array.isArray(entry))
244
+ continue;
245
+ const node = entry;
246
+ const mapping = node.methodMapping;
247
+ if (mapping === null || typeof mapping !== "object" || Array.isArray(mapping))
248
+ continue;
249
+ const m = mapping;
250
+ digests.push({
251
+ nodeCode: node.nodeCode ?? null,
252
+ serviceCode: m.serviceCode ?? null,
253
+ serviceMethodCode: m.serviceMethodCode ?? null,
254
+ inputCount: Array.isArray(m.inputMappings) ? m.inputMappings.length : 0,
255
+ outputCount: Array.isArray(m.outputMappings) ? m.outputMappings.length : 0,
242
256
  });
243
- if (args.summary !== true)
257
+ }
258
+ return digests;
259
+ }
260
+ /**
261
+ * r83:`rule.list --withMappings` 的映射读取。list 行自带 node 时零额外 wire
262
+ * (8.6.26 list 面是完整 BusinessRuleModel);行缺 node 才按 id 回落
263
+ * `businessrule/get`(+1 wire/条),仍读不到则该行标 `mappingsUnavailable`,
264
+ * 绝不把「没读到」写成「没有映射」。
265
+ */
266
+ async function readRuleListMappings(session, rows) {
267
+ const byCode = new Map();
268
+ let fallbackReads = 0;
269
+ for (const row of rows) {
270
+ const code = typeof row.code === "string" ? row.code : "";
271
+ if (code === "")
272
+ continue;
273
+ if (typeof row.node === "string") {
274
+ byCode.set(code, ruleMappingDigests(parseRuleColumn(row.node)));
275
+ continue;
276
+ }
277
+ const id = typeof row.id === "string" && row.id !== "" ? row.id : "";
278
+ if (id === "") {
279
+ byCode.set(code, null);
280
+ continue;
281
+ }
282
+ fallbackReads += 1;
283
+ try {
284
+ const fetched = (await wireCall(session, { path: ENDPOINTS.businessRuleGet, query: { id } })).data;
285
+ byCode.set(code, fetched && typeof fetched.node === "string" ? ruleMappingDigests(parseRuleColumn(fetched.node)) : null);
286
+ }
287
+ catch {
288
+ byCode.set(code, null);
289
+ }
290
+ }
291
+ return { byCode, fallbackReads };
292
+ }
293
+ /** r83:跨模型批量的模型数上限(逐模型 1 探针 + 1 list;超出拒绝并给分批指引)。 */
294
+ const RULE_BATCH_MAX_MODELS = 20;
295
+ /** r83:`schemaCodes[]` 归一(去重/去空)+ 上限门。 */
296
+ function ruleSchemaCodesOf(raw, tool) {
297
+ const unique = [...new Set(raw.map((code) => code.trim()).filter((code) => code !== ""))];
298
+ if (unique.length === 0)
299
+ throw new ToolInputError({ status: "error", blocker: "tool-input-invalid", tool, message: "schemaCodes 为空——至少给一个模型 code" });
300
+ if (unique.length > RULE_BATCH_MAX_MODELS) {
301
+ const chunk = unique.slice(0, RULE_BATCH_MAX_MODELS);
244
302
  throw new ToolInputError({
245
303
  status: "error",
246
- blocker: "rule-batch-requires-summary",
247
- tool: "rule.get",
248
- message: "ruleCodes 批量读必须同时传 summary:true——逐条内联整图(每条约 13KB)的批量正是本工具要消灭的形状",
249
- nextCommand: `omc call rule.get --env <env> --args '{"schemaCode":"${schemaCode}","ruleCodes":[${args.ruleCodes.map((code) => JSON.stringify(code)).join(",")}],"summary":true}'`,
304
+ blocker: "rule-schema-batch-too-large",
305
+ tool,
306
+ message: `schemaCodes 最多 ${RULE_BATCH_MAX_MODELS} 个模型(本次 ${unique.length});超出请分批——回执只覆盖本次传入的模型,不会静默截断`,
307
+ nextCommand: tool === "rule.get"
308
+ ? `omc call rule.get --env <env> --args '{"schemaCodes":${JSON.stringify(chunk)},"ruleCodes":["<ruleCode>"],"summary":true}'(再按余下 ${unique.length - RULE_BATCH_MAX_MODELS} 个模型发下一批)`
309
+ : `omc call rule.list --env <env> --args '{"schemaCodes":${JSON.stringify(chunk)}}'(再按余下 ${unique.length - RULE_BATCH_MAX_MODELS} 个模型发下一批)`,
310
+ batching: { limit: RULE_BATCH_MAX_MODELS, given: unique.length, chunks: Math.ceil(unique.length / RULE_BATCH_MAX_MODELS) },
250
311
  });
251
- const parse = (value) => decodeJsonColumn(value, JSON_COLUMN_NULL_COALESCE);
252
- const rows = wireRows((await wireCall(session, { path: ENDPOINTS.businessRuleListBySchemaCode, query: { schemaCode } })).data);
312
+ }
313
+ return unique;
314
+ }
315
+ /** r83:`ruleCodes` 批量的 summary 门(单模型/跨模型同一句话)。 */
316
+ function requireRuleBatchSummary(summary, nextCommand) {
317
+ if (summary === true)
318
+ return;
319
+ throw new ToolInputError({
320
+ status: "error",
321
+ blocker: "rule-batch-requires-summary",
322
+ tool: "rule.get",
323
+ message: "ruleCodes 批量读必须同时传 summary:true——逐条内联整图(每条约 13KB)的批量正是本工具要消灭的形状",
324
+ nextCommand,
325
+ });
326
+ }
327
+ /**
328
+ * r83:把一个模型的 list 行解析成摘要体(同模型 ruleCodes 批量的内核)。
329
+ * 拆出来是为了让单模型 `readRuleBatch` 与跨模型 `schemaCodes[]` 共用同一套
330
+ * 「缺 node 回落 get / 单条缺失不连坐」的读取语义,而不是两份实现。
331
+ */
332
+ async function summarizeRuleRows(session, rows, ruleCodes) {
253
333
  const byCode = new Map();
254
334
  for (const row of rows)
255
335
  if (typeof row.code === "string" && row.code !== "")
@@ -257,16 +337,16 @@ async function readRuleBatch(session, args) {
257
337
  const rules = [];
258
338
  const failed = [];
259
339
  let fallbackReads = 0;
260
- for (const code of args.ruleCodes) {
340
+ for (const code of ruleCodes) {
261
341
  let record = byCode.get(code);
262
342
  // 部分 code 不存在:其余照常,failed 逐条点名(不把「没有这条规则」读成「没有方法映射」)。
263
343
  if (!record) {
264
344
  failed.push({ code, reason: "rule-absent" });
265
345
  continue;
266
346
  }
267
- let nodes = parse(record.node);
268
- let routes = parse(record.route);
269
- let schedulerSetting = parse(record.schedulerSetting);
347
+ let nodes = parseRuleColumn(record.node);
348
+ let routes = parseRuleColumn(record.route);
349
+ let schedulerSetting = parseRuleColumn(record.schedulerSetting);
270
350
  if (typeof record.node !== "string") {
271
351
  // 运行时逐行校验:该版本/该行 list 面没带 node 时回落 get(+1 wire),
272
352
  // 回执 wireNote 会点名;仍读不到图才进 failed。
@@ -282,13 +362,37 @@ async function readRuleBatch(session, args) {
282
362
  continue;
283
363
  }
284
364
  record = fetched;
285
- nodes = parse(fetched.node);
286
- routes = parse(fetched.route);
287
- schedulerSetting = parse(fetched.schedulerSetting);
365
+ nodes = parseRuleColumn(fetched.node);
366
+ routes = parseRuleColumn(fetched.route);
367
+ schedulerSetting = parseRuleColumn(fetched.schedulerSetting);
288
368
  }
289
369
  const lint = await lintRuleGraphFace(record, { nodes, routes, schedulerSetting });
290
370
  rules.push(ruleSummaryBody(record, { nodes, routes, schedulerSetting }, ruleSummaryRoundTrip(lint.roundTrip)));
291
371
  }
372
+ return { rules, failed, fallbackReads };
373
+ }
374
+ /**
375
+ * r79-w2b(issue 06):`ruleCodes[]` 同模型批量摘要。一次
376
+ * `list_by_schemacode` 解析全部 id 与 node(8.6.26 的 list 面是完整
377
+ * BusinessRuleModel,含 node/route——BusinessRule.getModel():128-156),
378
+ * 个别行缺 node 时才对该规则回落一 次 `businessrule/get`。
379
+ * 诚实口径:wire 字节没少(list 面把 N 张图一起搬回),少的是往返次数与信封体积。
380
+ *
381
+ * r83(R79 二期):`schemaCodes[]` 跨模型走 `readRuleBatchAcrossModels`;
382
+ * 单模型路径(本函数)输出形状逐字节不变。
383
+ */
384
+ async function readRuleBatch(session, args) {
385
+ const schemaCode = args.schemaCode;
386
+ if (!schemaCode)
387
+ throw new ToolInputError({
388
+ status: "error",
389
+ blocker: "tool-input-invalid",
390
+ tool: "rule.get",
391
+ message: "ruleCodes 批量缺 schemaCode——单模型用 schemaCode,跨模型用 schemaCodes[]",
392
+ });
393
+ requireRuleBatchSummary(args.summary, `omc call rule.get --env <env> --args '{"schemaCode":"${schemaCode}","ruleCodes":[${args.ruleCodes.map((code) => JSON.stringify(code)).join(",")}],"summary":true}'`);
394
+ const rows = wireRows((await wireCall(session, { path: ENDPOINTS.businessRuleListBySchemaCode, query: { schemaCode } })).data);
395
+ const { rules, failed, fallbackReads } = await summarizeRuleRows(session, rows, args.ruleCodes);
292
396
  // 全部失败/全部不存在 → fail closed(空 ok 会被读成「这些规则没有方法映射」)。
293
397
  if (rules.length === 0)
294
398
  return {
@@ -317,6 +421,206 @@ async function readRuleBatch(session, args) {
317
421
  failed,
318
422
  };
319
423
  }
424
+ /**
425
+ * r83(R79 二期,issue 06 的跨模型一半):`schemaCodes[]` 逐模型批量摘要。
426
+ *
427
+ * - 逐模型先探模型存在:`list_by_schemacode` 对任意 schemaCode 会补建 7 条
428
+ * 预置规则并 publish(r28g F35)——幻影 schema 的预置行 API 删不掉,所以
429
+ * 模型不存在按 601003 口径回 `modelPresent:false` 且**不发 list**。
430
+ * - **部分失败不整单失败**:某模型 list 读失败/规则缺失只进 `failed[]`
431
+ * (`{schemaCode, code, message}`),其余模型照常回;全空才 refused。
432
+ */
433
+ async function readRuleBatchAcrossModels(session, args) {
434
+ const models = [];
435
+ const rules = [];
436
+ const failed = [];
437
+ let listReads = 0;
438
+ let fallbackReads = 0;
439
+ for (const schemaCode of args.schemaCodes) {
440
+ let present;
441
+ try {
442
+ present = (await readModelRecord(session, schemaCode)) !== null;
443
+ }
444
+ catch (error) {
445
+ failed.push({ schemaCode, code: null, reason: "model-probe-failed", message: `模型探针失败:${error.message}` });
446
+ models.push({ schemaCode, modelPresent: null, rulesCount: 0, failedCount: args.ruleCodes.length });
447
+ continue;
448
+ }
449
+ if (!present) {
450
+ for (const code of args.ruleCodes)
451
+ failed.push({ schemaCode, code, reason: "model-absent", message: `模型 ${schemaCode} 不存在(601003 口径 modelPresent:false)——未发规则面请求` });
452
+ models.push({ schemaCode, modelPresent: false, rulesCount: 0, failedCount: args.ruleCodes.length });
453
+ continue;
454
+ }
455
+ let rows;
456
+ try {
457
+ listReads += 1;
458
+ rows = wireRows((await wireCall(session, { path: ENDPOINTS.businessRuleListBySchemaCode, query: { schemaCode } })).data);
459
+ }
460
+ catch (error) {
461
+ for (const code of args.ruleCodes)
462
+ failed.push({ schemaCode, code, reason: "list-failed", message: `模型 ${schemaCode} 的规则清单读失败:${error.message}` });
463
+ models.push({ schemaCode, modelPresent: true, rulesCount: 0, failedCount: args.ruleCodes.length });
464
+ continue;
465
+ }
466
+ const summarized = await summarizeRuleRows(session, rows, args.ruleCodes);
467
+ fallbackReads += summarized.fallbackReads;
468
+ for (const rule of summarized.rules)
469
+ rules.push(rule);
470
+ for (const failure of summarized.failed)
471
+ failed.push({
472
+ schemaCode,
473
+ code: failure.code,
474
+ reason: failure.reason,
475
+ message: failure.reason === "rule-absent" ? `${schemaCode}.${failure.code} 在 list 面不存在` : `${schemaCode}.${failure.code} 的规则图读不到(list 行缺 node 且 get 无图)`,
476
+ });
477
+ models.push({ schemaCode, modelPresent: true, rulesCount: summarized.rules.length, failedCount: summarized.failed.length });
478
+ }
479
+ const body = {
480
+ schemaCodes: args.schemaCodes,
481
+ requestedCount: args.schemaCodes.length * args.ruleCodes.length,
482
+ rulesCount: rules.length,
483
+ partial: failed.length > 0,
484
+ source: "draft-list",
485
+ wireNote: `跨模型批量:${args.schemaCodes.length} 次模型探针 + ${listReads} 次 list_by_schemacode${fallbackReads > 0 ? `;${fallbackReads} 条 list 行缺 node 已回落 businessrule/get(+${fallbackReads} wire)` : ";无回落 get"}`,
486
+ models,
487
+ rules,
488
+ failed,
489
+ };
490
+ if (rules.length === 0)
491
+ return {
492
+ status: "refused",
493
+ blocker: "rule-batch-empty",
494
+ ...body,
495
+ partial: true,
496
+ nextCommand: `omc call rule.list --env <env> --args '{"schemaCodes":${JSON.stringify(args.schemaCodes)}}'`,
497
+ message: "没有一个 ruleCode 读到规则图——空结果不等于「没有方法映射」;先用 rule.list 核对模型与规则 code",
498
+ };
499
+ return body;
500
+ }
501
+ /**
502
+ * r83:单个模型的规则清单体——单模型路径与 `schemaCodes[]` 跨模型路径共用。
503
+ *
504
+ * 回执形状与 r79 的 rule.list 逐字节一致:`withMappings:false`(默认)时连
505
+ * 键都不出现;true 时每行多一条摘要级 `mappings[]`(服务/方法/入出参计数),
506
+ * 正文(inputMappings/outputMappings)仍在 `rule.get`,超阈值照旧外置 artifact
507
+ * (governedRead 的 2048B 读门)。
508
+ */
509
+ async function readRuleListBody(session, schemaCode, options) {
510
+ // r28g F35/F36:list_by_schemacode 对任意 schemaCode 会补建 7 条预置并
511
+ // publish。从未存在的模型一旦被 list,就留下 API 删不掉的预置行。
512
+ // 写前 gate(assertRuleSchemaExists)已拦;读面也必须先探,不存在则
513
+ // 直接回 modelPresent:false + rules:[],**不发 list 请求**。
514
+ const modelRecord = await readModelRecord(session, schemaCode);
515
+ if (modelRecord === null) {
516
+ // r62b-F2(P1-5):带近名候选 + 可转发问句(plan 面 needs-decision 的
517
+ // call 面同款)——探针此前得自己翻 model.list 编问句。
518
+ const suggested = await suggestModelNames(session, schemaCode);
519
+ return {
520
+ schemaCode,
521
+ modelPresent: false,
522
+ rules: [],
523
+ rulesCount: 0,
524
+ ...(suggested !== null
525
+ ? {
526
+ suggestedModels: suggested,
527
+ needsDecision: `未找到「${schemaCode}」,是否指 ${suggested.map((model) => `${model.code}(${model.name ?? model.code})`).join(" / ")}?`,
528
+ }
529
+ : {}),
530
+ hint: "模型不存在(bizmodels/get_all 空)——未发 rule.list 请求(避免补建 7 条不可删预置);判定模型面用 model.inspect",
531
+ };
532
+ }
533
+ // 版本族备选(2026-11-03 issue A1):8.6 锚点走 runtime 面;8.1 族
534
+ // runtime 端点缺席(404)时下探 app 面 `businessrule/list_by_schemacode`。
535
+ // 仅 404 下探,401/500/业务码拒绝原样上抛。rule.save / rule.enable 的
536
+ // 读回本就走 app 面,两族都可用。下探发生时在结果里标注命中的端点族,
537
+ // 让调用方能看见自己不在锚点路径上(排查兼容问题时的关键信号)。
538
+ let endpointFamily = null;
539
+ const rows = wireRows((await wireCallWith404Fallback(session, [
540
+ { path: ENDPOINTS.runtimeBusinessRuleListBySchemaCode, query: { schemaCode } },
541
+ { path: ENDPOINTS.businessRuleListBySchemaCode, query: { schemaCode } },
542
+ ], (failed, next) => { endpointFamily = { used: next.path, reason: `${failed.path} HTTP 404(端点在本版本族缺席,已下探)` }; })).data);
543
+ // N2 (r10 noise pass): the default row is the inventory face —
544
+ // code/name/state/publish-version/is-preset. The audit columns
545
+ // (id/createdTime/creator/developmentMode/templateType/…) only ride
546
+ // with full:true (the old 14-key row). rule.get resolves by business
547
+ // key (schemaCode+ruleCode), so the row id is rarely needed.
548
+ const fullRows = options.full;
549
+ const visible = options.onlyCustom ? rows.filter((row) => row.defaultRule !== true) : rows;
550
+ const statusLag = visible.some((row) => row.enabled === true && String(row.status ?? "") !== "ENABLED");
551
+ // r83:withMappings 只在显式开启时读;默认路径零额外 wire、零新增键。
552
+ const mappingFace = options.withMappings ? await readRuleListMappings(session, visible) : undefined;
553
+ const mappingOf = (row) => {
554
+ if (mappingFace === undefined)
555
+ return {};
556
+ const found = mappingFace.byCode.get(typeof row.code === "string" ? row.code : "");
557
+ // 读不到 ≠ 没有映射:显式标注不可用,避免把读取失败当成空映射。
558
+ if (found === undefined || found === null)
559
+ return { mappingsUnavailable: true };
560
+ return { mappings: found };
561
+ };
562
+ return {
563
+ schemaCode,
564
+ modelPresent: true,
565
+ // r83:rulesCount 在 handler 层回(此前只有 compact 投影从 rules 派生,导致
566
+ // schemaCodes[] 跨模型面的 models[] 元素缺该键,与 read-shapes「同形」承诺不符)。
567
+ rulesCount: visible.length,
568
+ // r28g F18:list 投影的是 PUBLISH 行;运行时可执行性以 rule.get / rule.enable.verified 为准。
569
+ source: "published-list",
570
+ executableHint: "rules[].enabled/status 来自 PUBLISH 投影;运行时判定读 DRAFT(rule.get 的 enabled+ruleStatus,或 rule.enable 回执的 executable/verified)。不要仅凭本面判定可 rule.run。",
571
+ ...(statusLag
572
+ ? {
573
+ statusLag: true,
574
+ statusNote: "本面 status 是 PUBLISH 投影列,与 rule.get 的 ruleStatus 可不同;检测到 enabled=true 而 status 非 ENABLED 的滞后行——enabled=true 才是分发真相,运行时以 rule.get/enable 复核",
575
+ }
576
+ : {
577
+ // r35a-F7(真机 2026-11-06):`status` 与 rule.get 的 `ruleStatus` 是
578
+ // **不同 wire 列**,可一个 ENABLED 一个 DISABLED(探针实测
579
+ // list status=ENABLED/ruleVersion=1 vs get ruleStatus=DISABLED/0)。
580
+ // 常态化给一句短注(~90B/次),避免把本面 status 当运行时真相。
581
+ statusNote: "本面 status 是 PUBLISH 投影列,与 rule.get 的 ruleStatus 可不同;运行时是否生效以 rule.get/enable 为准",
582
+ }),
583
+ ...(options.onlyCustom ? { filtered: { onlyCustom: true, total: rows.length, returned: visible.length } } : {}),
584
+ // r60c-F7(真机复现):默认面把 7 条平台预置触发行一起返回——任何模型都
585
+ // 「有规则」,「哪些模型配了业务规则」会误判成全都有。默认面带上
586
+ // customCount + 一句判定口径;判定自建规则直接 onlyCustom:true。
587
+ ...(options.onlyCustom
588
+ ? {}
589
+ : {
590
+ customCount: rows.filter((row) => row.defaultRule !== true).length,
591
+ presetHint: "默认含平台预置触发行(preset:true,如 Available/Cancel/Create/Delete/GetList/Load/Update);判定「有没有人写过规则」看 customCount(=0 即全是预置),或直接 onlyCustom:true",
592
+ }),
593
+ ...(endpointFamily ? { endpointFamily } : {}),
594
+ ...(mappingFace
595
+ ? { mappingsWireNote: `mappings 来自规则行 node(摘要:服务/方法/入出参计数;正文在 rule.get)${mappingFace.fallbackReads > 0 ? `;${mappingFace.fallbackReads} 条 list 行缺 node 已回落 businessrule/get(+${mappingFace.fallbackReads} wire)` : ";无回落 get"}` }
596
+ : {}),
597
+ rules: visible.map((row) => ({
598
+ code: row.code,
599
+ name: row.name,
600
+ enabled: row.enabled,
601
+ status: row.status,
602
+ ...(row.enabled === true && String(row.status ?? "") !== "ENABLED" ? { statusLag: true } : {}),
603
+ ...(row.ruleVersion !== undefined ? { ruleVersion: row.ruleVersion } : {}),
604
+ ...(row.defaultRule !== undefined ? { defaultRule: row.defaultRule, preset: row.defaultRule === true } : {}),
605
+ // ticket-80's update-mode readback teaches following the same-code
606
+ // latestPublished row — keep the flag on the default face (5 B).
607
+ ...(row.latestPublished !== undefined ? { latestPublished: row.latestPublished } : {}),
608
+ ...(fullRows
609
+ ? {
610
+ id: row.id,
611
+ schemaCode: row.schemaCode,
612
+ bizRuleType: row.bizRuleType,
613
+ developmentMode: row.developmentMode,
614
+ latestPublished: row.latestPublished,
615
+ templateType: row.templateType,
616
+ createdTime: row.createdTime,
617
+ creator: row.creater ?? row.creator,
618
+ }
619
+ : {}),
620
+ ...mappingOf(row),
621
+ })),
622
+ };
623
+ }
320
624
  export function registerBusinessRuleLane(tools) {
321
625
  tools.push(defineTool({
322
626
  name: "rule.list",
@@ -329,107 +633,68 @@ export function registerBusinessRuleLane(tools) {
329
633
  inputSchema: {
330
634
  environment: environmentArg,
331
635
  schemaCode: z.string().min(1),
636
+ schemaCodes: z.array(z.string()).optional().describe("跨模型清单(≤20;失败回 partial+failed)"),
332
637
  onlyCustom: z.boolean().optional().describe("只回自建规则(defaultRule!==true),滤掉平台预置触发行——读面收窄,省 token"),
333
638
  full: z.boolean().optional().describe("行内联完整字段(id/createdTime/creator/…,并跳过 detailFile 外置);默认行只有 code/name/enabled/status/ruleVersion/defaultRule/latestPublished"),
639
+ withMappings: z.boolean().optional().describe("true=规则附 mappings 摘要(服务/方法/入出参计数)"),
334
640
  capability: capabilityArg,
335
641
  },
336
642
  handler: async (ctx, args, self) => governedRead(ctx, self, args, async (session) => {
337
- // r28g F35/F36:list_by_schemacode 对任意 schemaCode 会补建 7 条预置并
338
- // publish。从未存在的模型一旦被 list,就留下 API 删不掉的预置行。
339
- // 写前 gate(assertRuleSchemaExists)已拦;读面也必须先探,不存在则
340
- // 直接回 modelPresent:false + rules:[],**不发 list 请求**。
341
- const modelRecord = await readModelRecord(session, args.schemaCode);
342
- if (modelRecord === null) {
343
- // r62b-F2(P1-5):带近名候选 + 可转发问句(plan 面 needs-decision 的
344
- // call 面同款)——探针此前得自己翻 model.list 编问句。
345
- const suggested = await suggestModelNames(session, args.schemaCode);
346
- return {
347
- schemaCode: args.schemaCode,
348
- modelPresent: false,
349
- rules: [],
350
- rulesCount: 0,
351
- ...(suggested !== null
352
- ? {
353
- suggestedModels: suggested,
354
- needsDecision: `未找到「${args.schemaCode}」,是否指 ${suggested.map((model) => `${model.code}(${model.name ?? model.code})`).join(" / ")}?`,
643
+ // r83(R79 二期):跨模型清单。逐模型读、部分失败不整单失败;模型不存在
644
+ // 按 601003 口径回 modelPresent:false(readRuleListBody 的探针保证不发 list)。
645
+ // schemaCode 的必填面靠 tool-types 的 required-alternatives 占位保持稳定:
646
+ // 只传 schemaCodes[] 时占位值出现,这里把它当「没传 schemaCode」。
647
+ const singleSchemaCode = isRequiredAlternativePlaceholder(args.schemaCode) ? undefined : args.schemaCode;
648
+ if (args.schemaCodes !== undefined) {
649
+ if (singleSchemaCode !== undefined)
650
+ throw new ToolInputError({ status: "error", blocker: "tool-input-invalid", tool: "rule.list", message: "schemaCode 与 schemaCodes 互斥——单模型用 schemaCode,跨模型用 schemaCodes[]" });
651
+ const schemaCodes = ruleSchemaCodesOf(args.schemaCodes, "rule.list");
652
+ const models = [];
653
+ const failed = [];
654
+ const options = { onlyCustom: args.onlyCustom === true, full: args.full === true, withMappings: args.withMappings === true };
655
+ let firstError;
656
+ let rulesCount = 0;
657
+ // r83:三句提示(executableHint/statusNote/presetHint)逐模型逐字相同,
658
+ // 跨模型面把它们抬到顶层一次(crossModelNotes),否则 3 模型就顶破 2048
659
+ // 内联上限、整面被 compact(models 退码表)。statusLag 旗标仍逐模型保留。
660
+ const hoisted = {};
661
+ const HOIST_KEYS = ["executableHint", "statusNote", "presetHint"];
662
+ for (const schemaCode of schemaCodes) {
663
+ try {
664
+ const body = await readRuleListBody(session, schemaCode, options);
665
+ for (const key of HOIST_KEYS) {
666
+ if (body[key] !== undefined) {
667
+ hoisted[key] = body[key];
668
+ delete body[key];
669
+ }
355
670
  }
356
- : {}),
357
- hint: "模型不存在(bizmodels/get_all 空)——未发 rule.list 请求(避免补建 7 条不可删预置);判定模型面用 model.inspect",
358
- };
359
- }
360
- // 版本族备选(2026-11-03 issue A1):8.6 锚点走 runtime 面;8.1 族
361
- // runtime 端点缺席(404)时下探 app 面 `businessrule/list_by_schemacode`。
362
- // 仅 404 下探,401/500/业务码拒绝原样上抛。rule.save / rule.enable 的
363
- // 读回本就走 app 面,两族都可用。下探发生时在结果里标注命中的端点族,
364
- // 让调用方能看见自己不在锚点路径上(排查兼容问题时的关键信号)。
365
- let endpointFamily = null;
366
- const rows = wireRows((await wireCallWith404Fallback(session, [
367
- { path: ENDPOINTS.runtimeBusinessRuleListBySchemaCode, query: { schemaCode: args.schemaCode } },
368
- { path: ENDPOINTS.businessRuleListBySchemaCode, query: { schemaCode: args.schemaCode } },
369
- ], (failed, next) => { endpointFamily = { used: next.path, reason: `${failed.path} HTTP 404(端点在本版本族缺席,已下探)` }; })).data);
370
- // N2 (r10 noise pass): the default row is the inventory face —
371
- // code/name/state/publish-version/is-preset. The audit columns
372
- // (id/createdTime/creator/developmentMode/templateType/…) only ride
373
- // with full:true (the old 14-key row). rule.get resolves by business
374
- // key (schemaCode+ruleCode), so the row id is rarely needed.
375
- const fullRows = args.full === true;
376
- const visible = args.onlyCustom === true ? rows.filter((row) => row.defaultRule !== true) : rows;
377
- const statusLag = visible.some((row) => row.enabled === true && String(row.status ?? "") !== "ENABLED");
378
- return {
379
- schemaCode: args.schemaCode,
380
- modelPresent: true,
381
- // r28g F18:list 投影的是 PUBLISH 行;运行时可执行性以 rule.get / rule.enable.verified 为准。
382
- source: "published-list",
383
- executableHint: "rules[].enabled/status 来自 PUBLISH 投影;运行时判定读 DRAFT(rule.get 的 enabled+ruleStatus,或 rule.enable 回执的 executable/verified)。不要仅凭本面判定可 rule.run。",
384
- ...(statusLag
385
- ? {
386
- statusLag: true,
387
- statusNote: "本面 status 是 PUBLISH 投影列,与 rule.get 的 ruleStatus 可不同;检测到 enabled=true 而 status 非 ENABLED 的滞后行——enabled=true 才是分发真相,运行时以 rule.get/enable 复核",
671
+ models.push(body);
672
+ rulesCount += Array.isArray(body.rules) ? body.rules.length : 0;
388
673
  }
389
- : {
390
- // r35a-F7(真机 2026-11-06):`status` 与 rule.get 的 `ruleStatus` 是
391
- // **不同 wire 列**,可一个 ENABLED 一个 DISABLED(探针实测
392
- // list status=ENABLED/ruleVersion=1 vs get ruleStatus=DISABLED/0)。
393
- // 常态化给一句短注(~90B/次),避免把本面 status 当运行时真相。
394
- statusNote: "本面 status 是 PUBLISH 投影列,与 rule.get 的 ruleStatus 可不同;运行时是否生效以 rule.get/enable 为准",
395
- }),
396
- ...(args.onlyCustom === true ? { filtered: { onlyCustom: true, total: rows.length, returned: visible.length } } : {}),
397
- // r60c-F7(真机复现):默认面把 7 条平台预置触发行一起返回——任何模型都
398
- // 「有规则」,「哪些模型配了业务规则」会误判成全都有。默认面带上
399
- // customCount + 一句判定口径;判定自建规则直接 onlyCustom:true。
400
- ...(args.onlyCustom !== true
401
- ? {
402
- customCount: rows.filter((row) => row.defaultRule !== true).length,
403
- presetHint: "默认含平台预置触发行(preset:true,如 Available/Cancel/Create/Delete/GetList/Load/Update);判定「有没有人写过规则」看 customCount(=0 即全是预置),或直接 onlyCustom:true",
674
+ catch (error) {
675
+ firstError ??= error;
676
+ failed.push({ schemaCode, code: null, message: error.message });
404
677
  }
405
- : {}),
406
- ...(endpointFamily ? { endpointFamily } : {}),
407
- rules: visible.map((row) => ({
408
- code: row.code,
409
- name: row.name,
410
- enabled: row.enabled,
411
- status: row.status,
412
- ...(row.enabled === true && String(row.status ?? "") !== "ENABLED" ? { statusLag: true } : {}),
413
- ...(row.ruleVersion !== undefined ? { ruleVersion: row.ruleVersion } : {}),
414
- ...(row.defaultRule !== undefined ? { defaultRule: row.defaultRule, preset: row.defaultRule === true } : {}),
415
- // ticket-80's update-mode readback teaches following the same-code
416
- // latestPublished row — keep the flag on the default face (5 B).
417
- ...(row.latestPublished !== undefined ? { latestPublished: row.latestPublished } : {}),
418
- ...(fullRows
419
- ? {
420
- id: row.id,
421
- schemaCode: row.schemaCode,
422
- bizRuleType: row.bizRuleType,
423
- developmentMode: row.developmentMode,
424
- latestPublished: row.latestPublished,
425
- templateType: row.templateType,
426
- createdTime: row.createdTime,
427
- creator: row.creater ?? row.creator,
428
- }
429
- : {}),
430
- })),
431
- };
432
- }, { full: args.full === true, target: `rule.list:${args.schemaCode}` }),
678
+ }
679
+ // 全部模型都读失败 → 上抛首个错误:auth/网络问题不能被读成「部分成功」。
680
+ if (models.length === 0 && firstError !== undefined)
681
+ throw firstError;
682
+ const absentModels = models.filter((model) => model.modelPresent === false).map((model) => String(model.schemaCode));
683
+ return {
684
+ schemaCodes,
685
+ modelsCount: models.length,
686
+ rulesCount,
687
+ ...(Object.keys(hoisted).length > 0 ? { crossModelNotes: hoisted } : {}),
688
+ partial: failed.length > 0,
689
+ ...(absentModels.length > 0 ? { absentModels } : {}),
690
+ models,
691
+ failed,
692
+ };
693
+ }
694
+ if (singleSchemaCode === undefined)
695
+ throw new ToolInputError({ status: "error", blocker: "tool-input-invalid", tool: "rule.list", message: "需要 schemaCode(单个模型)或 schemaCodes(跨模型清单)" });
696
+ return readRuleListBody(session, singleSchemaCode, { onlyCustom: args.onlyCustom === true, full: args.full === true, withMappings: args.withMappings === true });
697
+ }, { full: args.full === true, target: `rule.list:${args.schemaCodes !== undefined ? `schemaCodes:${args.schemaCodes.join(",")}` : args.schemaCode}` }),
433
698
  }));
434
699
  tools.push(defineTool({
435
700
  name: "rule.references",
@@ -441,7 +706,7 @@ export function registerBusinessRuleLane(tools) {
441
706
  description: RULE_TOOLS["rule.references"].description,
442
707
  inputSchema: {
443
708
  environment: environmentArg,
444
- kind: z.enum(["service", "model", "field"]).describe("按什么找引用:service=BIZ_ACTION methodMapping.serviceCode;model=CREATE/UPDATE/DELETE targetObjectCode 与 methodMapping.schemaCode;field=dataActions.targetDataItem 与映射 bizCode"),
709
+ kind: z.enum(["service", "model", "field", "rule"]).describe("按什么找引用:service=BIZ_ACTION methodMapping.serviceCode;model=CREATE/UPDATE/DELETE targetObjectCode 与 methodMapping.schemaCode;field=dataActions.targetDataItem、映射 bizCode、规则条件叶子与 datarule;rule=流程事件绑定的规则码(flow 级 handler + 节点级 nodeEvent,扫应用内模型的流程面)"),
445
710
  code: z.string().min(1).describe("要查引用的编码(服务/模型/字段 code);kind=field 可用 schemaCode.field 消歧"),
446
711
  schemaCodes: z.union([z.array(z.string().min(1)), z.string()]).optional().describe("只扫这些模型(省 wire 读);省略=全平台模型"),
447
712
  capability: capabilityArg,
@@ -524,16 +789,82 @@ export function registerBusinessRuleLane(tools) {
524
789
  fieldScope = prefix;
525
790
  }
526
791
  }
792
+ // R79 三期 T-B:kind=rule——查一条规则被哪些流程事件绑定。绑定数据住流程
793
+ // 模板(flow 级四 handler + 节点级八事件的 bizActions),与 rule 图无关,
794
+ // 因此本 kind 不走 rule.list/rule.get 扫描,改扫与 workflow.list 同源的
795
+ // 模型→流程面(scanModelWorkflowBindings 复用 get_published 的
796
+ // ruleBindings/nodeRuleBindings 投影,读回面与检索面同一谓词)。模型没有
797
+ // 流程 = 该模型不可能绑定,如实跳过(scanned.withoutWorkflow 计数)。
798
+ if (args.kind === "rule") {
799
+ const wantedRule = String(args.code);
800
+ const ruleHits = [];
801
+ let scannedWorkflows = 0;
802
+ let withoutWorkflow = 0;
803
+ let readFailures = 0;
804
+ for (const schemaCode of scoped) {
805
+ let face;
806
+ try {
807
+ face = await scanModelWorkflowBindings(session, schemaCode);
808
+ }
809
+ catch {
810
+ readFailures += 1; // 单模型读失败不中断整轮扫描
811
+ continue;
812
+ }
813
+ if (face === null) {
814
+ withoutWorkflow += 1;
815
+ continue;
816
+ }
817
+ scannedWorkflows += 1;
818
+ for (const binding of face.ruleBindings)
819
+ if (binding.ruleCodes.includes(wantedRule))
820
+ ruleHits.push({ schemaCode, workflowCode: face.workflowCode, handler: binding.handler, ruleCodes: binding.ruleCodes, published: face.published, via: "workflow-bindRule" });
821
+ for (const binding of face.nodeRuleBindings)
822
+ if (binding.ruleCodes.includes(wantedRule))
823
+ ruleHits.push({ schemaCode, workflowCode: face.workflowCode, activityCode: binding.activityCode, nodeEvent: binding.nodeEvent, ruleCodes: binding.ruleCodes, published: face.published, via: "workflow-bindRule" });
824
+ }
825
+ return {
826
+ kind: "rule",
827
+ code: wantedRule,
828
+ scanned: { models: scoped.length, workflows: scannedWorkflows, withoutWorkflow, ...(readFailures > 0 ? { readFailures } : {}) },
829
+ matches: ruleHits,
830
+ wire: { plan: "1 模型清单 + 每模型 isworkflow(无流程即止)→ 有流程再 getWorkflow + get_published" },
831
+ coverage: {
832
+ scanned: ["workflow.get_published:ruleBindings+nodeRuleBindings"],
833
+ notScanned: [],
834
+ note: "matches:[] = 扫描范围内没有任何流程事件(flow 级四 handler + 节点级八事件)绑定该规则;流程面按 get_published 读回,未发布流程读回草稿形态(命中行的 published:false 标注,不是已发布证据)",
835
+ },
836
+ ...(args.schemaCodes === undefined && scope !== undefined
837
+ ? { applicationResolution: { ...applicationResolutionOf(scope), mode: scanMode, models: scoped.length } }
838
+ : {}),
839
+ ...(ruleHits.length === 0
840
+ ? {
841
+ note: "零命中(流程绑定面)= " +
842
+ (args.schemaCodes !== undefined
843
+ ? `仅扫描了 schemaCodes 收窄的 ${scoped.length} 个模型(${scoped.slice(0, 5).join(", ")}${scoped.length > 5 ? "…" : ""})——绑定常在**其他**模型的流程上;要全平台结论请去掉 schemaCodes`
844
+ : "扫描范围内没有流程事件绑定该规则") +
845
+ "。规则是否存在于规则面用 rule.list;绑定写法用 workflow.bindRule",
846
+ ...(args.schemaCodes === undefined && scope !== undefined ? { hint: applicationScopeHint(scope, "绑定") } : {}),
847
+ }
848
+ : {
849
+ hint: "在线扫描完成;命中行的流程细节(参与人/节点)用 workflow.get_published {workflowCode} 读回;改绑定走 workflow.bindRule(merge 语义,不会清掉其它绑定)",
850
+ }),
851
+ };
852
+ }
527
853
  const matches = [];
528
854
  let scannedRules = 0;
529
855
  let parseFailures = 0;
856
+ let scannedDataRules = 0;
857
+ let dataRuleReadFailures = 0;
858
+ let childRefsSkipped = 0;
530
859
  for (const schemaCode of scoped) {
531
860
  let rows = [];
532
861
  try {
533
862
  rows = wireRows((await wireCall(session, { path: ENDPOINTS.businessRuleListBySchemaCode, query: { schemaCode } })).data);
534
863
  }
535
864
  catch {
536
- continue; // 模型无规则面(读失败/空)按无规则处理,不让单个模型挡住全扫
865
+ // 模型无规则面(读失败/空)按无规则处理,不让单个模型挡住全扫。
866
+ // R79 三期:kind=field 时仍要扫该模型的 datarule 面——不再 continue,
867
+ // 落到循环尾部的 datarule 块。
537
868
  }
538
869
  for (const row of rows) {
539
870
  const ruleCode = String(row.code ?? "");
@@ -555,6 +886,27 @@ export function registerBusinessRuleLane(tools) {
555
886
  parseFailures += 1;
556
887
  continue;
557
888
  }
889
+ // R79 三期 T-C①:条件叶子(filterCondition/BRANCH 出口/route 兜底/定时
890
+ // filterConditionGroups 的 currentSchemaDataItem、targetSchemaDataItem 与
891
+ // value {字段} 模板)。复用 graph 索引的权威抽取器(含宿主归属与日期偏移
892
+ // 噪音过滤),在线/离线两面同一定义——只取 via==="rule.condition" 边,
893
+ // 动作/映射命中仍由下方在线匹配产出(via 不变)。第一版只认主模型字段:
894
+ // 点号引用(子表)不匹配、计入 childRefsSkipped(不静默)。
895
+ if (args.kind === "field") {
896
+ const routes = decodeJsonColumn(record.route, JSON_COLUMN_NULL_COALESCE);
897
+ const schedulerSetting = decodeJsonColumn(record.schedulerSetting, JSON_COLUMN_NULL_COALESCE);
898
+ for (const edge of extractReferenceEdges(schemaCode, ruleCode, nodes, Array.isArray(routes) ? routes : [], schedulerSetting)) {
899
+ if (edge.via !== "rule.condition" || edge.code !== wanted)
900
+ continue;
901
+ if (edge.code.includes(".")) {
902
+ childRefsSkipped += 1;
903
+ continue;
904
+ }
905
+ if (fieldScope !== undefined && edge.schemaCode !== fieldScope)
906
+ continue;
907
+ matches.push({ schemaCode, ruleCode, nodeCode: edge.nodeCode, nodeType: edge.nodeType, via: "condition-leaf", hostSchemaCode: edge.schemaCode });
908
+ }
909
+ }
558
910
  for (const rawNode of nodes) {
559
911
  const nodeCode = String(rawNode.nodeCode ?? "");
560
912
  const nodeType = String(rawNode.nodeType ?? "");
@@ -586,21 +938,72 @@ export function registerBusinessRuleLane(tools) {
586
938
  }
587
939
  }
588
940
  }
941
+ // R79 三期 T-C②:datarule 面(每模型 +1 wire bizdatarule/list)。命中两源:
942
+ // propertyCodes[](权威目标字段绑定)与 options 里的 {字段code} 文本(跨字段
943
+ // 公式/条件引用;matchedBy 区分)。options 是自由文本协议——字面匹配可能漏
944
+ // JSON 形引用({"valueType":"currentModel","value":…}),协议局限在 coverage
945
+ // note 声明;单模型读失败不中断扫描。第一版只认主模型字段(点号引用跳过)。
946
+ if (args.kind === "field") {
947
+ try {
948
+ const dataRuleRows = wireRows((await wireCall(session, { path: ENDPOINTS.dataRuleList, query: { schemaCode } })).data);
949
+ scannedDataRules += dataRuleRows.length;
950
+ for (const row of dataRuleRows) {
951
+ const matched = extractDataRuleEdges(schemaCode, row).find((edge) => {
952
+ if (edge.code !== wanted)
953
+ return false;
954
+ if (edge.code.includes(".")) {
955
+ childRefsSkipped += 1;
956
+ return false;
957
+ }
958
+ return true;
959
+ });
960
+ if (matched)
961
+ matches.push({
962
+ schemaCode,
963
+ kind: "datarule",
964
+ ref: String(row.id ?? row.name ?? ""),
965
+ name: row.name ?? null,
966
+ dataRuleType: row.dataRuleType ?? null,
967
+ matchedBy: matched.via === "datarule.targets" ? "propertyCodes" : "options",
968
+ via: "datarule",
969
+ });
970
+ }
971
+ }
972
+ catch {
973
+ dataRuleReadFailures += 1;
974
+ }
975
+ }
589
976
  }
590
977
  return {
591
978
  kind: args.kind,
592
979
  code: wanted,
593
980
  ...(fieldScope !== undefined ? { requestedCode: rawCode, resolvedScope: { schemaCode: fieldScope, code: wanted } } : {}),
594
- scanned: { models: scoped.length, rules: scannedRules, ...(parseFailures > 0 ? { parseFailures } : {}) },
981
+ scanned: args.kind === "field"
982
+ ? {
983
+ models: scoped.length,
984
+ rules: scannedRules,
985
+ datarules: scannedDataRules,
986
+ ...(parseFailures > 0 ? { parseFailures } : {}),
987
+ ...(dataRuleReadFailures > 0 ? { dataRuleReadFailures } : {}),
988
+ ...(childRefsSkipped > 0 ? { childRefsSkipped } : {}),
989
+ }
990
+ : { models: scoped.length, rules: scannedRules, ...(parseFailures > 0 ? { parseFailures } : {}) },
595
991
  matches,
596
- // r35a-F4(真机 2026-11-06):matches:[] 曾被当成「可安全删除」的依据,
597
- // 而探针实测该字段**被表单引用**(form.get draftControlCodes)且出现在
598
- // 流程节点权限里——本面两者都没扫。散文字段不承担安全契约:结构化声明。
599
- coverage: {
600
- scanned: ["businessrule"],
601
- notScanned: ["datarule", "form", "workflow.permissions", "workflow.bindings", "onlinejs", "listview"],
602
- note: "matches:[] 只代表 businessrule 面零命中;datarule/form/流程权限/视图等未扫描(离线 graph references 覆盖更广,见其 coverage),不可据此判定可安全删除",
603
- },
992
+ // r35a-F4:matches:[] 曾被当成「可安全删除」的依据,而该字段可能**被表单
993
+ // 引用**(form.get draftControlCodes)且出现在流程节点权限里——散文字段
994
+ // 不承担安全契约:结构化声明。R79 三期起 kind=field 的覆盖面扩为
995
+ // 动作/映射 + 条件叶子 + datarule;form/listview/流程字段权限仍不在。
996
+ coverage: args.kind === "field"
997
+ ? {
998
+ scanned: ["businessrule:actions+mappings", "businessrule:condition-leaf", "datarule"],
999
+ notScanned: ["form", "listview", "onlinejs", "workflow.permissions", "子表字段(条件叶/datarule 的点号引用不匹配)"],
1000
+ note: "matches:[] 只代表上述三面零命中;form/listview/流程字段权限/子表字段未扫描(离线 graph references 覆盖更广,见其 coverage),不可据此判定可安全删除。datarule 的 options 是自由文本协议:matchedBy:options 按 {字段code} 字面匹配,可能漏掉 JSON 形引用(如 currentModel 值对象)——命中/零命中涉 datarule 时建议 datarule.list 复核",
1001
+ }
1002
+ : {
1003
+ scanned: ["businessrule"],
1004
+ notScanned: ["form", "workflow.permissions", "workflow.bindings", "onlinejs", "listview"],
1005
+ note: "matches:[] 只代表 businessrule 面零命中;form/流程权限/视图等未扫描(离线 graph references 覆盖更广,见其 coverage),不可据此判定可安全删除",
1006
+ },
604
1007
  // r73 #3:app-scope 路径回显 applicationResolution(含 mode/models:扫了
605
1008
  // 哪个应用、共几个模型)。显式 schemaCodes 路径维持原形状(无
606
1009
  // applicationResolution/hint——显式范围自带出处,provenance 契约不变)。
@@ -609,15 +1012,18 @@ export function registerBusinessRuleLane(tools) {
609
1012
  : {}),
610
1013
  ...(matches.length === 0
611
1014
  ? {
612
- // r73 探针01-P1(2026-11-17):旧首句「零命中=全平台没有规则引用它」与
613
- // 同一载荷的 notScanned(不含条件叶子/datarule/listview)自相矛盾——快读
614
- // 者会直接答「没有规则用它」,而 daily_expiry_scan 的条件正引用该字段。
615
- // 首句先声明「本面」盲区,再给范围与离线替代。
616
- note: "零命中(本在线面仅 businessrule 的 methodMapping/targetObjectCode/dataActions;**不含规则条件叶子/datarule/listview**——条件里的引用用 `graph references field <code>`)= " +
1015
+ // r73 探针01-P1:零命中首句必须先声明「本面」盲区再下结论——快读
1016
+ // 者会直接答「没有规则用它」。R79 三期起条件叶子与 datarule 已入
1017
+ // kind=field 扫描面,首句盲区随之收窄(form/listview/流程字段权限
1018
+ // /子表字段仍在盲区)。
1019
+ note: (args.kind === "field"
1020
+ ? "零命中(本面扫 businessrule 的动作/映射/条件叶子 + datarule 的 propertyCodes/options 文本;**不含 form/listview/流程字段权限/子表字段**)"
1021
+ : "零命中(本在线面仅 businessrule 的 methodMapping/targetObjectCode/dataActions;**不含 form/listview**)") +
1022
+ "= " +
617
1023
  (args.schemaCodes !== undefined
618
1024
  ? `仅扫描了 schemaCodes 收窄的 ${scoped.length} 个模型(${scoped.slice(0, 5).join(", ")}${scoped.length > 5 ? "…" : ""})——引用常发生在**其他**模型上;要全平台结论请去掉 schemaCodes`
619
- : "全平台没有规则引用它") +
620
- "。范围: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>`",
1025
+ : "扫描范围内没有匹配引用") +
1026
+ "。范围:service→methodMapping.serviceCode;model→targetObjectCode/methodMapping.schemaCode;field→dataActions.targetDataItem/映射 bizCode/条件叶子(filterCondition、BRANCH 出口等)/datarule(子表字段不扫)。本工具是在线单点扫描;要离线毫秒级复询、字段级影响面或两跳爆炸半径,先 `omc graph pull --env <env>` 再 `omc graph references|impact <kind> <code>`",
621
1027
  ...(args.schemaCodes === undefined && scope !== undefined ? { hint: applicationScopeHint(scope, "引用") } : {}),
622
1028
  }
623
1029
  : {
@@ -645,10 +1051,28 @@ export function registerBusinessRuleLane(tools) {
645
1051
  keys: z.array(z.string().min(1)).min(1).optional().describe("工具经济(A6):只返回列出的顶层键(identity 键 id/code/schemaCode 恒在)。例 ['schedulerSetting'] 只看调度配置,不内联整图——对照生产规则形状时用"),
646
1052
  summary: z.boolean().optional().describe("工具经济(A6):身份+体量摘要(含 nodeDigests 节点/方法摘要、methodMappingCount、bytesOmitted),不含 nodes/routes 正文——节点摘要在 nodeDigests,不是 nodes"),
647
1053
  ruleCodes: z.array(z.string().min(1)).min(1).max(50).optional().describe("同 schemaCode 批量摘要(≤50;必须同时 summary:true):1 次 list 解析全部 id 与 node,回 rules[] + partial/failed[];全读不到 → refused rule-batch-empty"),
1054
+ schemaCodes: z.array(z.string()).optional().describe("跨模型批量(配 ruleCodes+summary,≤20;失败回 partial+failed)"),
648
1055
  withRuntime: z.boolean().optional().describe("opt-in 聚合运行态:合并规则存在性、可执行性、源码版本与最近日志;默认不增加 wire 读取"),
649
1056
  capability: capabilityArg,
650
1057
  },
651
1058
  handler: async (ctx, args, self) => governedRead(ctx, self, args, async (session) => {
1059
+ // r83(R79 二期):`schemaCodes[]` 跨模型批量——与 rule.references 的
1060
+ // 扫描范围同形(模型 code 数组),必须配 ruleCodes[] + summary:true。
1061
+ if (args.schemaCodes !== undefined) {
1062
+ if (args.schemaCode !== undefined || args.ruleCode !== undefined || args.id !== undefined)
1063
+ throw new ToolInputError({ status: "error", blocker: "tool-input-invalid", tool: "rule.get", message: "schemaCodes 与 schemaCode/ruleCode/id 互斥——跨模型批量只认 schemaCodes+ruleCodes" });
1064
+ if (args.ruleCodes === undefined)
1065
+ throw new ToolInputError({
1066
+ status: "error",
1067
+ blocker: "tool-input-invalid",
1068
+ tool: "rule.get",
1069
+ message: "schemaCodes 跨模型批量必须同时传 ruleCodes[](逐模型一次 list 解析全部图);只要模型清单用 rule.list {schemaCodes}",
1070
+ nextCommand: `omc call rule.get --env <env> --args '{"schemaCodes":["<模型code>",...],"ruleCodes":["Create","Update"],"summary":true}'`,
1071
+ });
1072
+ const schemaCodes = ruleSchemaCodesOf(args.schemaCodes, "rule.get");
1073
+ requireRuleBatchSummary(args.summary, `omc call rule.get --env <env> --args '{"schemaCodes":${JSON.stringify(schemaCodes)},"ruleCodes":[${args.ruleCodes.map((code) => JSON.stringify(code)).join(",")}],"summary":true}'`);
1074
+ return readRuleBatchAcrossModels(session, { schemaCodes, ruleCodes: args.ruleCodes });
1075
+ }
652
1076
  // r79-w2b(issue 06):同工具多主键(ruleCodes[])——不改身份/判定逻辑,
653
1077
  // 只把「一个主键」换成「同一 schemaCode 下的一批主键」。
654
1078
  if (args.ruleCodes !== undefined) {