@stalfh233/omc-cli 0.6.84 → 0.6.86

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.
Files changed (40) hide show
  1. package/README.md +6 -3
  2. package/coverage/m1-coverage-manifest-v1.json +28 -0
  3. package/dist/batch-call.js +1 -0
  4. package/dist/call.js +4 -1
  5. package/dist/capability-overview.js +4 -4
  6. package/dist/cli.js +21 -20
  7. package/dist/concurrency.js +165 -0
  8. package/dist/duration.js +73 -0
  9. package/dist/goal-routes.js +26 -1
  10. package/dist/governed-execution.js +5 -0
  11. package/dist/graph.js +5 -26
  12. package/dist/intent/capabilities/bizservice.js +178 -89
  13. package/dist/intent/capabilities/datarule.js +1 -1
  14. package/dist/intent/cli.js +1 -1
  15. package/dist/intent/compiler.js +1 -0
  16. package/dist/intent/plan-apply.js +5 -1
  17. package/dist/intent/schema.js +1 -1
  18. package/dist/journal.js +14 -1
  19. package/dist/lanes/apply-changes.js +49 -1
  20. package/dist/lanes/businessrule.js +63 -34
  21. package/dist/lanes/config-diff.js +477 -0
  22. package/dist/lanes/form.js +2 -2
  23. package/dist/lanes/runtime-data-contract.js +1 -1
  24. package/dist/lanes/runtime-data.js +43 -8
  25. package/dist/lanes/workflow-contract.js +17 -0
  26. package/dist/lanes/workflow-coverage.js +11 -0
  27. package/dist/lanes/workflow.js +47 -22
  28. package/dist/package.js +5 -2
  29. package/dist/read-shapes.js +9 -2
  30. package/dist/recipes/b2-registration.js +1 -1
  31. package/dist/rollback-spec.js +130 -32
  32. package/dist/rollback.js +67 -6
  33. package/dist/script.js +1 -0
  34. package/dist/tool-search.js +3 -0
  35. package/dist/tools.js +9 -0
  36. package/dist/write-audit.js +43 -0
  37. package/dist/write.js +10 -1
  38. package/docs/omc-introduction.md +3 -2
  39. package/package.json +3 -3
  40. package/skills/omc-capabilities.md +3 -2
@@ -9,6 +9,7 @@ import { assertRuleNamePlatformAcceptable, executeRuleSaveWrite, lintRuleGraphFo
9
9
  import { defineTool, isRequiredAlternativePlaceholder, ToolInputError, ToolRefusalError } from "../tool-types.js";
10
10
  import { resolveRuleRowId } from "../identity.js";
11
11
  import { extractDataRuleEdges, extractReferenceEdges } from "../graph.js";
12
+ import { DEFAULT_SCAN_CONCURRENCY, mapWithConcurrency } from "../concurrency.js";
12
13
  import { scanModelWorkflowBindings } from "./workflow.js";
13
14
  import { wireCall, wireCallWith404Fallback, wireRows } from "../wire.js";
14
15
  import { readModelRecord } from "../model-record.js";
@@ -928,22 +929,23 @@ export function registerBusinessRuleLane(tools) {
928
929
  // 流程 = 该模型不可能绑定,如实跳过(scanned.withoutWorkflow 计数)。
929
930
  if (args.kind === "rule") {
930
931
  const wantedRule = String(args.code);
931
- const ruleHits = [];
932
932
  let scannedWorkflows = 0;
933
933
  let withoutWorkflow = 0;
934
934
  let readFailures = 0;
935
- for (const schemaCode of scoped) {
936
- let face;
937
- try {
938
- face = await scanModelWorkflowBindings(session, schemaCode);
939
- }
940
- catch {
935
+ // R88 提案 #2:模型级并发(同 workflow.list 的窗口与限流策略);命中行
936
+ // 按 scoped 原序重组,与串行基线逐字段一致。
937
+ const scan = await mapWithConcurrency(scoped, DEFAULT_SCAN_CONCURRENCY, (schemaCode) => scanModelWorkflowBindings(session, schemaCode));
938
+ const ruleHits = [];
939
+ scan.outcomes.forEach((outcome, index) => {
940
+ if (!outcome.ok) {
941
941
  readFailures += 1; // 单模型读失败不中断整轮扫描
942
- continue;
942
+ return;
943
943
  }
944
+ const face = outcome.value;
945
+ const schemaCode = scoped[index];
944
946
  if (face === null) {
945
947
  withoutWorkflow += 1;
946
- continue;
948
+ return;
947
949
  }
948
950
  scannedWorkflows += 1;
949
951
  for (const binding of face.ruleBindings)
@@ -952,13 +954,16 @@ export function registerBusinessRuleLane(tools) {
952
954
  for (const binding of face.nodeRuleBindings)
953
955
  if (binding.ruleCodes.includes(wantedRule))
954
956
  ruleHits.push({ schemaCode, workflowCode: face.workflowCode, activityCode: binding.activityCode, nodeEvent: binding.nodeEvent, ruleCodes: binding.ruleCodes, published: face.published, via: "workflow-bindRule" });
955
- }
957
+ });
956
958
  return {
957
959
  kind: "rule",
958
960
  code: wantedRule,
959
961
  scanned: { models: scoped.length, workflows: scannedWorkflows, withoutWorkflow, ...(readFailures > 0 ? { readFailures } : {}) },
960
962
  matches: ruleHits,
961
- wire: { plan: "1 模型清单 + 每模型 isworkflow(无流程即止)→ 有流程再 getWorkflow + get_published" },
963
+ wire: {
964
+ plan: "1 模型清单 + 每模型 isworkflow(无流程即止)→ 有流程再 getWorkflow + get_published",
965
+ concurrency: scan.stats,
966
+ },
962
967
  coverage: {
963
968
  scanned: ["workflow.get_published:ruleBindings+nodeRuleBindings"],
964
969
  notScanned: [],
@@ -981,16 +986,19 @@ export function registerBusinessRuleLane(tools) {
981
986
  }),
982
987
  };
983
988
  }
984
- const matches = [];
985
- let scannedRules = 0;
986
- let parseFailures = 0;
987
- let scannedDataRules = 0;
988
- let dataRuleReadFailures = 0;
989
- let childRefsSkipped = 0;
990
- for (const schemaCode of scoped) {
989
+ // R88 提案 #2:跨模型扫描并发(默认 4)。每模型的命中与计数在 fn 内本地
990
+ // 收集,返回后按 scoped 原序拼接——与串行基线逐字段一致(matches 顺序、
991
+ // coverage/notScanned 口径、空命中≠没扫完的区分全部不变)。平台读经
992
+ // scan.read:限流类错误一次抖动退避,仍失败把后续窗口降到 2;模型内
993
+ // 各读点的既有容错语义(读失败按无规则面处理/跳过该规则/计
994
+ // dataRuleReadFailures)原样保留。
995
+ const scan = await mapWithConcurrency(scoped, DEFAULT_SCAN_CONCURRENCY, async (schemaCode, _index, throttle) => {
996
+ const model = {
997
+ matches: [], scannedRules: 0, parseFailures: 0, scannedDataRules: 0, dataRuleReadFailures: 0, childRefsSkipped: 0,
998
+ };
991
999
  let rows = [];
992
1000
  try {
993
- rows = wireRows((await wireCall(session, { path: ENDPOINTS.businessRuleListBySchemaCode, query: { schemaCode } })).data);
1001
+ rows = wireRows((await throttle.read(() => wireCall(session, { path: ENDPOINTS.businessRuleListBySchemaCode, query: { schemaCode } }))).data);
994
1002
  }
995
1003
  catch {
996
1004
  // 模型无规则面(读失败/空)按无规则处理,不让单个模型挡住全扫。
@@ -1000,12 +1008,12 @@ export function registerBusinessRuleLane(tools) {
1000
1008
  for (const row of rows) {
1001
1009
  const ruleCode = String(row.code ?? "");
1002
1010
  const ruleId = row.id;
1003
- scannedRules += 1;
1011
+ model.scannedRules += 1;
1004
1012
  if (typeof ruleId !== "string" || ruleId === "")
1005
1013
  continue;
1006
1014
  let record = null;
1007
1015
  try {
1008
- record = (await wireCall(session, { path: ENDPOINTS.businessRuleGet, query: { id: ruleId } })).data;
1016
+ record = (await throttle.read(() => wireCall(session, { path: ENDPOINTS.businessRuleGet, query: { id: ruleId } }))).data;
1009
1017
  }
1010
1018
  catch {
1011
1019
  continue;
@@ -1014,7 +1022,7 @@ export function registerBusinessRuleLane(tools) {
1014
1022
  continue;
1015
1023
  const nodes = decodeJsonColumn(record.node, JSON_COLUMN_NULL_COALESCE);
1016
1024
  if (!Array.isArray(nodes)) {
1017
- parseFailures += 1;
1025
+ model.parseFailures += 1;
1018
1026
  continue;
1019
1027
  }
1020
1028
  // R79 三期 T-C①:条件叶子(filterCondition/BRANCH 出口/route 兜底/定时
@@ -1030,12 +1038,12 @@ export function registerBusinessRuleLane(tools) {
1030
1038
  if (edge.via !== "rule.condition" || edge.code !== wanted)
1031
1039
  continue;
1032
1040
  if (edge.code.includes(".")) {
1033
- childRefsSkipped += 1;
1041
+ model.childRefsSkipped += 1;
1034
1042
  continue;
1035
1043
  }
1036
1044
  if (fieldScope !== undefined && edge.schemaCode !== fieldScope)
1037
1045
  continue;
1038
- matches.push({ schemaCode, ruleCode, nodeCode: edge.nodeCode, nodeType: edge.nodeType, via: "condition-leaf", hostSchemaCode: edge.schemaCode });
1046
+ model.matches.push({ schemaCode, ruleCode, nodeCode: edge.nodeCode, nodeType: edge.nodeType, via: "condition-leaf", hostSchemaCode: edge.schemaCode });
1039
1047
  }
1040
1048
  }
1041
1049
  for (const rawNode of nodes) {
@@ -1044,13 +1052,13 @@ export function registerBusinessRuleLane(tools) {
1044
1052
  const mapping = rawNode.methodMapping;
1045
1053
  if (args.kind === "service") {
1046
1054
  if (nodeType === "BIZ_ACTION" && mapping && String(mapping.serviceCode ?? "") === wanted)
1047
- matches.push({ schemaCode, ruleCode, nodeCode, nodeType, via: "methodMapping.serviceCode" });
1055
+ model.matches.push({ schemaCode, ruleCode, nodeCode, nodeType, via: "methodMapping.serviceCode" });
1048
1056
  }
1049
1057
  else if (args.kind === "model") {
1050
1058
  if (["CREATE", "UPDATE", "DELETE"].includes(nodeType) && String(rawNode.targetObjectCode ?? "") === wanted)
1051
- matches.push({ schemaCode, ruleCode, nodeCode, nodeType, via: "targetObjectCode" });
1059
+ model.matches.push({ schemaCode, ruleCode, nodeCode, nodeType, via: "targetObjectCode" });
1052
1060
  if (mapping && String(mapping.schemaCode ?? "") === wanted)
1053
- matches.push({ schemaCode, ruleCode, nodeCode, nodeType, via: "methodMapping.schemaCode" });
1061
+ model.matches.push({ schemaCode, ruleCode, nodeCode, nodeType, via: "methodMapping.schemaCode" });
1054
1062
  }
1055
1063
  else {
1056
1064
  // dataActions 的 targetDataItem 宿主是 targetObjectCode(跨模型写回),
@@ -1059,11 +1067,11 @@ export function registerBusinessRuleLane(tools) {
1059
1067
  if (["CREATE", "UPDATE", "DELETE"].includes(nodeType) && Array.isArray(rawNode.dataActions)
1060
1068
  && (fieldScope === undefined || actionHost === fieldScope)
1061
1069
  && rawNode.dataActions.some((action) => String(action.targetDataItem ?? "") === wanted))
1062
- matches.push({ schemaCode, ruleCode, nodeCode, nodeType, via: "dataActions.targetDataItem", hostSchemaCode: actionHost, ...(String(rawNode.targetObjectCode ?? "") !== "" ? { targetObjectCode: String(rawNode.targetObjectCode) } : {}) });
1070
+ model.matches.push({ schemaCode, ruleCode, nodeCode, nodeType, via: "dataActions.targetDataItem", hostSchemaCode: actionHost, ...(String(rawNode.targetObjectCode ?? "") !== "" ? { targetObjectCode: String(rawNode.targetObjectCode) } : {}) });
1063
1071
  if (mapping && (fieldScope === undefined || schemaCode === fieldScope)) {
1064
1072
  for (const [key, label] of [["inputMappings", "inputMappings.bizCode"], ["outputMappings", "outputMappings.bizCode"]]) {
1065
1073
  if (Array.isArray(mapping[key]) && mapping[key].some((row2) => String(row2.bizCode ?? "") === wanted && (row2.codeType === undefined || row2.codeType === 1)))
1066
- matches.push({ schemaCode, ruleCode, nodeCode, nodeType, via: label, hostSchemaCode: schemaCode });
1074
+ model.matches.push({ schemaCode, ruleCode, nodeCode, nodeType, via: label, hostSchemaCode: schemaCode });
1067
1075
  }
1068
1076
  }
1069
1077
  }
@@ -1076,20 +1084,20 @@ export function registerBusinessRuleLane(tools) {
1076
1084
  // note 声明;单模型读失败不中断扫描。第一版只认主模型字段(点号引用跳过)。
1077
1085
  if (args.kind === "field") {
1078
1086
  try {
1079
- const dataRuleRows = wireRows((await wireCall(session, { path: ENDPOINTS.dataRuleList, query: { schemaCode } })).data);
1080
- scannedDataRules += dataRuleRows.length;
1087
+ const dataRuleRows = wireRows((await throttle.read(() => wireCall(session, { path: ENDPOINTS.dataRuleList, query: { schemaCode } }))).data);
1088
+ model.scannedDataRules += dataRuleRows.length;
1081
1089
  for (const row of dataRuleRows) {
1082
1090
  const matched = extractDataRuleEdges(schemaCode, row).find((edge) => {
1083
1091
  if (edge.code !== wanted)
1084
1092
  return false;
1085
1093
  if (edge.code.includes(".")) {
1086
- childRefsSkipped += 1;
1094
+ model.childRefsSkipped += 1;
1087
1095
  return false;
1088
1096
  }
1089
1097
  return true;
1090
1098
  });
1091
1099
  if (matched)
1092
- matches.push({
1100
+ model.matches.push({
1093
1101
  schemaCode,
1094
1102
  kind: "datarule",
1095
1103
  ref: String(row.id ?? row.name ?? ""),
@@ -1101,9 +1109,27 @@ export function registerBusinessRuleLane(tools) {
1101
1109
  }
1102
1110
  }
1103
1111
  catch {
1104
- dataRuleReadFailures += 1;
1112
+ model.dataRuleReadFailures += 1;
1105
1113
  }
1106
1114
  }
1115
+ return model;
1116
+ });
1117
+ const matches = [];
1118
+ let scannedRules = 0;
1119
+ let parseFailures = 0;
1120
+ let scannedDataRules = 0;
1121
+ let dataRuleReadFailures = 0;
1122
+ let childRefsSkipped = 0;
1123
+ // 按 scoped 原序拼接(稳定输出,不随并发完成顺序抖动)。
1124
+ for (const outcome of scan.outcomes) {
1125
+ if (!outcome.ok)
1126
+ continue; // fn 内各读点自带容错,这里只防未预见异常
1127
+ matches.push(...outcome.value.matches);
1128
+ scannedRules += outcome.value.scannedRules;
1129
+ parseFailures += outcome.value.parseFailures;
1130
+ scannedDataRules += outcome.value.scannedDataRules;
1131
+ dataRuleReadFailures += outcome.value.dataRuleReadFailures;
1132
+ childRefsSkipped += outcome.value.childRefsSkipped;
1107
1133
  }
1108
1134
  return {
1109
1135
  kind: args.kind,
@@ -1120,6 +1146,9 @@ export function registerBusinessRuleLane(tools) {
1120
1146
  }
1121
1147
  : { models: scoped.length, rules: scannedRules, ...(parseFailures > 0 ? { parseFailures } : {}) },
1122
1148
  matches,
1149
+ // R88 提案 #2:并发窗口如实标注(回执新增面;plan 面本 kind 从未有过,
1150
+ // 不新造散文)。
1151
+ wire: { concurrency: scan.stats },
1123
1152
  // r35a-F4:matches:[] 曾被当成「可安全删除」的依据,而该字段可能**被表单
1124
1153
  // 引用**(form.get draftControlCodes)且出现在流程节点权限里——散文字段
1125
1154
  // 不承担安全契约:结构化声明。R79 三期起 kind=field 的覆盖面扩为