@stalfh233/omc-cli 0.6.69 → 0.6.71

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/cli.js CHANGED
@@ -24,7 +24,7 @@ import { beginWriteFace, configureOutput, endWriteFace, humanSummary, maybeWarnM
24
24
  import { beginUsage, completeUsage, currentUsageArgsDigest, ensureProjectIgnore, priorIdenticalSuccess, recordUsageOutput, usageReport } from "./usage-log.js";
25
25
  import { artifactFetchHint, artifactRoot, boundResult, emitInvalid, emitResult, emitThrown, emitTransportResult, outputBudget, readArtifact, withTransport, } from "./command-transport.js";
26
26
  import { CLI_DEFAULT_OUTPUT_BYTES, assertSafeOutputPath, pruneArtifacts } from "./artifacts.js";
27
- import { artifactPathMissHint, nullProjectionHint, partialPathMissHint, projectJsonPath, projectJsonPathFanout, projectResultExtract } from "./path-projection.js";
27
+ import { artifactPathMissHint, nullProjectionHint, partialPathMissHint, pathMissDidYouMean, projectJsonPath, projectJsonPathFanout, projectResultExtract, shapeOf, SHAPE_MAX_DEPTH } from "./path-projection.js";
28
28
  import { basename, join, resolve } from "node:path";
29
29
  import { existsSync, readFileSync, writeFileSync, chmodSync } from "node:fs";
30
30
  import { buildToolRegistry } from "./tools.js";
@@ -944,12 +944,12 @@ function projectArtifactPath(value, path) {
944
944
  if (!path.includes("[]")) {
945
945
  const projected = projectJsonPath(value, path);
946
946
  return projected.missed
947
- ? { missed: true, ...(projected.at !== undefined ? { at: projected.at } : {}), ...(projected.available !== undefined ? { available: projected.available } : {}) }
947
+ ? { missed: true, ...(projected.at !== undefined ? { at: projected.at } : {}), ...(projected.available !== undefined ? { available: projected.available } : {}), ...(projected.availableAll !== undefined ? { availableAll: projected.availableAll } : {}), ...(projected.availableTruncated !== undefined ? { availableTruncated: projected.availableTruncated } : {}) }
948
948
  : { missed: false, content: projected.value ?? null };
949
949
  }
950
950
  const fanout = projectJsonPathFanout(value, path);
951
951
  return fanout.missed
952
- ? { missed: true, ...(fanout.at !== undefined ? { at: fanout.at } : {}), ...(fanout.available !== undefined ? { available: fanout.available } : {}) }
952
+ ? { missed: true, ...(fanout.at !== undefined ? { at: fanout.at } : {}), ...(fanout.available !== undefined ? { available: fanout.available } : {}), ...(fanout.availableAll !== undefined ? { availableAll: fanout.availableAll } : {}), ...(fanout.availableTruncated !== undefined ? { availableTruncated: fanout.availableTruncated } : {}) }
953
953
  : { missed: false, content: fanout.values, mapped: fanout.values.length, ...(fanout.missedEntries > 0 ? { missedEntries: fanout.missedEntries } : {}), nullEntries: fanout.nullEntries };
954
954
  }
955
955
  /** Preserve source completeness/count facts on every artifact projection. */
@@ -1009,8 +1009,21 @@ function extractArtifactGetOutFlag(argv) {
1009
1009
  }
1010
1010
  return undefined;
1011
1011
  }
1012
+ /** artifact 面 pathMiss 的 didYouMean/截断计数附加字段(r75:与 call 面一致)。 */
1013
+ function artifactMissExtras(projected) {
1014
+ const didYouMean = pathMissDidYouMean(projected.at, projected.available, projected.availableAll);
1015
+ return {
1016
+ ...(projected.availableTruncated !== undefined ? { availableTruncated: projected.availableTruncated } : {}),
1017
+ ...(didYouMean !== undefined ? { didYouMean } : {}),
1018
+ };
1019
+ }
1012
1020
  async function cmdArtifactGet(id, transport, options = {}) {
1013
1021
  try {
1022
+ if (options.depth !== undefined && (!Number.isInteger(options.depth) || options.depth < 1 || options.depth > SHAPE_MAX_DEPTH)) {
1023
+ const parsed = errorEnvelope(new Error(`--depth 必须是 1-${SHAPE_MAX_DEPTH} 的整数(默认 2;再深就成了正文复刻,字节失控)`), "artifact-depth-invalid", CLI_EXIT_CODES.invalidInput, transport.request);
1024
+ writeEnvelope(parsed.envelope);
1025
+ return parsed.exitCode;
1026
+ }
1014
1027
  const artifact = readArtifact(artifactRoot(), id);
1015
1028
  let content;
1016
1029
  try {
@@ -1043,6 +1056,35 @@ async function cmdArtifactGet(id, transport, options = {}) {
1043
1056
  // command instead, which is the portable way to reach the body.
1044
1057
  if (options.pathOnly)
1045
1058
  return emitTransportResult({ status: "ok", artifactId: id, sha256: artifact.sha256, fetch: artifactFetchHint(id) }, transport);
1059
+ // r75 调查C:`--shape [path]` 回执形状先验——深度受限骨架(默认 2,--depth 可
1060
+ // 到 4)。--summary 是预算事实(多大/会不会截断),--shape 是导航图(嵌套骨架
1061
+ // 到哪层有哪些键);>8KB 默认 outline 与本分支共用同一份 shapeOf(单一真相源,
1062
+ // 防 r25「两面雷同」复发)。显式 --shape 优先于 --summary/--keys/--jq。
1063
+ if (options.shape !== undefined) {
1064
+ const depth = options.depth ?? 2;
1065
+ if (typeof options.shape === "string" && options.shape.trim() !== "") {
1066
+ // `--shape <path>`:在命中的子树上出骨架(同 --jq 的路径 DSL,含 [] 与 [code=X])。
1067
+ const projected = projectArtifactPath(artifact.content.toString("utf8") === "" ? undefined : content, options.shape);
1068
+ if (projected.missed) {
1069
+ return emitTransportResult({ status: "ok", artifactId: id, sha256: artifact.sha256, ...artifactProjectionMetadata(content), path: options.shape, content: null, pathMiss: true, missedAt: projected.at, available: projected.available, ...artifactMissExtras(projected), unanswered: true, hint: artifactPathMissHint(projected.at) }, transport);
1070
+ }
1071
+ return emitTransportResult({ status: "ok", artifactId: id, sha256: artifact.sha256, bytes: artifact.content.length, path: options.shape, depth, shape: shapeOf(projected.content, depth), fetch: artifactFetchHint(id) }, transport);
1072
+ }
1073
+ // 裸 `--shape`:整棵根的骨架。<8KB 的产物正本默认整体内联,骨架无增益——
1074
+ // 明确劝退(r38 模式:别为已经免费的东西花第二轮)。
1075
+ const smallBody = artifact.content.length <= ARTIFACT_INLINE_CEILING_BYTES;
1076
+ return emitTransportResult({
1077
+ status: "ok",
1078
+ artifactId: id,
1079
+ sha256: artifact.sha256,
1080
+ bytes: artifact.content.length,
1081
+ depth,
1082
+ shape: shapeOf(content, depth),
1083
+ ...(smallBody
1084
+ ? { shapeNote: `产物 ${artifact.content.length}B 未超过内联上限 ${ARTIFACT_INLINE_CEILING_BYTES}B:默认 get 本就整体内联正文,--shape 无增益;直接取正文或 --jq <path> 定向取值`, defaultCommand: `omc artifact get ${id}` }
1085
+ : { fetch: artifactFetchHint(id) }),
1086
+ }, transport);
1087
+ }
1046
1088
  // `--summary` / `--keys` (round 4): inspect a large artifact without pulling
1047
1089
  // its whole body. Reproduced benchmark: agents fetched 30–75 KB workflow
1048
1090
  // bodies just to look at the node list.
@@ -1067,7 +1109,7 @@ async function cmdArtifactGet(id, transport, options = {}) {
1067
1109
  // 一层 `projection:{path,content}`——`artifact get --jq` 与 `--summary --jq`
1068
1110
  // 因此同形(顶层 path/content),换读面不用重新探根键。
1069
1111
  return emitTransportResult(projected.missed
1070
- ? { status: "ok", artifactId: id, sha256: artifact.sha256, bytes: artifact.content.length, ...artifactProjectionMetadata(content), keys, path: options.jq, content: null, projections: [{ path: options.jq, content: null, pathMiss: true, missedAt: projected.at, available: projected.available }], pathMiss: true, missedAt: projected.at, available: projected.available, unanswered: true, hint: artifactPathMissHint(projected.at) }
1112
+ ? { status: "ok", artifactId: id, sha256: artifact.sha256, bytes: artifact.content.length, ...artifactProjectionMetadata(content), keys, path: options.jq, content: null, projections: [{ path: options.jq, content: null, pathMiss: true, missedAt: projected.at, available: projected.available, ...artifactMissExtras(projected) }], pathMiss: true, missedAt: projected.at, available: projected.available, ...artifactMissExtras(projected), unanswered: true, hint: artifactPathMissHint(projected.at) }
1071
1113
  : {
1072
1114
  status: "ok",
1073
1115
  artifactId: id,
@@ -1119,14 +1161,14 @@ async function cmdArtifactGet(id, transport, options = {}) {
1119
1161
  const projections = jqPaths.map((path) => {
1120
1162
  const projected = projectArtifactPath(artifactContent, path);
1121
1163
  return projected.missed
1122
- ? { path, content: null, pathMiss: true, missedAt: projected.at, available: projected.available }
1164
+ ? { path, content: null, pathMiss: true, missedAt: projected.at, available: projected.available, ...artifactMissExtras(projected) }
1123
1165
  : { path, content: projected.content ?? null, ...(projected.mapped !== undefined ? { mapped: projected.mapped } : {}), ...(projected.missedEntries !== undefined ? { missedEntries: projected.missedEntries } : {}), ...(projected.nullEntries !== undefined && projected.nullEntries > 0 ? { nullEntries: projected.nullEntries } : {}), ...(artifactNullHint(projected.content, projected.nullEntries) !== undefined ? { hint: artifactNullHint(projected.content, projected.nullEntries) } : {}) };
1124
1166
  });
1125
1167
  return emitTransportResult({ status: "ok", artifactId: id, sha256: artifact.sha256, ...artifactProjectionMetadata(content), projections, ...(projections.some((entry) => entry.pathMiss) ? { unanswered: true, hint: partialPathMissHint() } : {}) }, transport);
1126
1168
  }
1127
1169
  const projected = projectArtifactPath(artifactContent, options.jq);
1128
1170
  return emitTransportResult(projected.missed
1129
- ? { status: "ok", artifactId: id, sha256: artifact.sha256, ...artifactProjectionMetadata(content), path: options.jq, content: null, pathMiss: true, missedAt: projected.at, available: projected.available, unanswered: true, hint: artifactPathMissHint(projected.at) }
1171
+ ? { status: "ok", artifactId: id, sha256: artifact.sha256, ...artifactProjectionMetadata(content), path: options.jq, content: null, pathMiss: true, missedAt: projected.at, available: projected.available, ...artifactMissExtras(projected), unanswered: true, hint: artifactPathMissHint(projected.at) }
1130
1172
  : { status: "ok", artifactId: id, sha256: artifact.sha256, ...artifactProjectionMetadata(content), path: options.jq, projections: [{ path: options.jq, content: projected.content ?? null, ...(projected.mapped !== undefined ? { mapped: projected.mapped } : {}), ...(projected.missedEntries !== undefined ? { missedEntries: projected.missedEntries } : {}), ...(projected.nullEntries !== undefined && projected.nullEntries > 0 ? { nullEntries: projected.nullEntries } : {}) }], ...(projected.mapped !== undefined ? { mapped: projected.mapped } : {}), ...(projected.missedEntries !== undefined ? { missedEntries: projected.missedEntries } : {}), ...(projected.nullEntries !== undefined && projected.nullEntries > 0 ? { nullEntries: projected.nullEntries } : {}), ...(artifactNullHint(projected.content, projected.nullEntries) !== undefined ? { hint: artifactNullHint(projected.content, projected.nullEntries) } : {}) }, transport);
1131
1173
  }
1132
1174
  // r6-onboarding 2026-10-21: 47 artifact fetches, 0 used a projection; the 10
@@ -1136,26 +1178,22 @@ async function cmdArtifactGet(id, transport, options = {}) {
1136
1178
  // advisory and did not change behaviour.
1137
1179
  //
1138
1180
  // 0.4.80: shape first, the same rule as `omc help`. Above the inline ceiling
1139
- // the default is the outline (top-level keys + their sizes) plus runnable
1140
- // projections; `--full` returns the whole body exactly as before. Explicit
1141
- // projections (--summary/--keys/--jq/--path-only) are handled above and are
1181
+ // the default is the depth-2 skeleton (same shapeOf as `--shape`; r75 调查C:
1182
+ // 两面共用一份实现——顶层键表请走 --summary,此处不再第二张雷同面);
1183
+ // `--full` returns the whole body exactly as before. Explicit projections
1184
+ // (--shape/--summary/--keys/--jq/--path-only) are handled above and are
1142
1185
  // never affected.
1143
1186
  if (options.full !== true && artifact.content.length > ARTIFACT_INLINE_CEILING_BYTES) {
1144
- const record = content && typeof content === "object" && !Array.isArray(content) ? content : undefined;
1145
- const keys = record
1146
- ? Object.entries(record)
1147
- .map(([key, value]) => ({ key, bytes: Buffer.byteLength(JSON.stringify(value) ?? "null", "utf8"), kind: Array.isArray(value) ? `array[${value.length}]` : value === null ? "null" : typeof value }))
1148
- .sort((left, right) => right.bytes - left.bytes)
1149
- : [];
1187
+ const depth = options.depth ?? 2;
1150
1188
  return emitTransportResult({
1151
1189
  status: "ok",
1152
1190
  artifactId: id,
1153
1191
  sha256: artifact.sha256,
1154
1192
  bytes: artifact.content.length,
1155
1193
  outline: true,
1156
- ...(record ? { keys } : { kind: typeof content }),
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 限额)。`,
1158
- keysCommand: keys.length > 0 ? `omc artifact get ${id} --keys ${keys.slice(0, 3).map((entry) => entry.key).join(",")}` : `omc artifact get ${id} --summary`,
1194
+ depth,
1195
+ shape: shapeOf(content, depth),
1196
+ hint: `正文 ${Math.round(artifact.content.length / 1024)}KB 超过内联上限 ${ARTIFACT_INLINE_CEILING_BYTES}B,默认只回深度 ${depth} 骨架(键/类型/数组长度/示例值)。加深:--depth ≤${SHAPE_MAX_DEPTH};子树骨架:--shape <path>;要某几个键:--keys <a,b>;要某个路径:--jq '<path>'(支持 .rules[code=Create].name 这类数组选择器);确实需要整包:--full,或 --out <配置根内路径> 整包落盘(不走 stdout 限额)。`,
1159
1197
  fullCommand: `omc artifact get ${id} --full`,
1160
1198
  }, transport);
1161
1199
  }
@@ -1912,7 +1950,7 @@ async function cmdGraphPull(environment, concurrency, transport, path, applicati
1912
1950
  scope: data.meta.scope,
1913
1951
  coverage: { applicationCodes: data.meta.coverage.applicationCodes, ...(data.meta.coverage.tenantApplications ? { tenantApplications: data.meta.coverage.tenantApplications } : {}) },
1914
1952
  freshness: data.gaps.length === 0 ? "complete" : "partial",
1915
- scanned: { models: data.scanned.models, rules: data.scanned.rules, datarules: data.scanned.datarules, views: data.scanned.views, ...(data.scanned.parseFailures > 0 ? { parseFailures: data.scanned.parseFailures } : {}) },
1953
+ scanned: { models: data.scanned.models, rules: data.scanned.rules, datarules: data.scanned.datarules, views: data.scanned.views, workflows: data.scanned.workflows, forms: data.scanned.forms, ...(data.scanned.parseFailures > 0 ? { parseFailures: data.scanned.parseFailures } : {}) },
1916
1954
  edges: edgesByKind,
1917
1955
  ...(data.gaps.length > 0 ? { gaps: { count: data.gaps.length, byKind: gapsByKind } } : {}),
1918
1956
  dbBytes: data.dbBytes,
@@ -2885,7 +2923,7 @@ async function main() {
2885
2923
  console.error(`已清理 ${result.removed} 个读回产物,释放 ${formatBytes(result.freedBytes)};保留 ${result.kept} 个(${formatBytes(result.keptBytes)})`);
2886
2924
  commandExitCode = CLI_EXIT_CODES.ok;
2887
2925
  });
2888
- 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) => {
2926
+ 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("--shape [path]", "回执形状先验:深度受限骨架(键/类型/数组长度/≤40 字符示例值),一次看全嵌套路径图再 --jq;裸 --shape = 整棵根,--shape <path> = 命中子树(同 --jq 的路径 DSL);与 >8KB 默认 outline 同一实现").option("--depth <n>", "骨架深度 1-4(默认 2;--shape 与 >8KB 默认 outline 消费)").option("--summary").option("--keys [a,b]").option("--full", "整包返回正文(默认:正文超过 8KB 时只回深度 2 骨架 outline,按需 --shape/--jq/--keys 定向取值)").option("--out <path>", "把 artifact 原始正文全量写到配置根内文件(0600;写文件不走 stdout 限额,大对象一次落盘备份;回执只给 {out,bytes,sha256} 不回正文)").option("--max-output-bytes <bytes>").action(async (id, options) => {
2889
2927
  // A bare `--jq`/`--keys` is a key-inventory request, not a missing argument:
2890
2928
  // commander's "argument missing" (invalid-input + retry) is a dead end the
2891
2929
  // caller cannot fix without already knowing the flag takes a value (r11
@@ -2899,8 +2937,17 @@ async function main() {
2899
2937
  ...(typeof options.extract === "string" ? [options.extract] : []),
2900
2938
  ];
2901
2939
  const bareJq = options.jq === true;
2902
- 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,
2903
- pureKeys: (options.keys === true || bareJq) && options.summary !== true, ...(typeof options.keys === "string" ? { keys: options.keys } : {}), full: options.full === true, ...(artifactGetOutPath !== undefined ? { out: artifactGetOutPath } : {}) }));
2940
+ // r75:显式 --shape 优先于 --summary/--keys/--jq(形状先验在取值之前)。
2941
+ const depthValue = options.depth === undefined ? undefined : Number(options.depth);
2942
+ const shapeValue = options.shape === true ? true : typeof options.shape === "string" ? options.shape : undefined;
2943
+ commandExitCode = await withTransport(options, request, (transport) => cmdArtifactGet(id, transport, {
2944
+ ...(jqPaths.length > 0 ? { jq: jqPaths.join(",") } : {}),
2945
+ pathOnly: options.pathOnly === true,
2946
+ ...(shapeValue !== undefined ? { shape: shapeValue } : {}),
2947
+ ...(depthValue !== undefined ? { depth: depthValue } : {}),
2948
+ summary: options.summary === true || options.keys === true || bareJq,
2949
+ pureKeys: (options.keys === true || bareJq) && options.summary !== true, ...(typeof options.keys === "string" ? { keys: options.keys } : {}), full: options.full === true, ...(artifactGetOutPath !== undefined ? { out: artifactGetOutPath } : {})
2950
+ }));
2904
2951
  });
2905
2952
  command.command("bench").option("--live-sample").option("--env <environment>").action(async (options) => { commandExitCode = await cmdBench([...(options.liveSample ? ["--live-sample"] : []), ...(options.env ? ["--env", options.env] : [])]); });
2906
2953
  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)); });
@@ -85,17 +85,18 @@ export function boundResult(result, budget) {
85
85
  }
86
86
  /** The retrieval command an agent should run for a spilled/compacted readback. */
87
87
  export function artifactFetchHint(artifactId) {
88
- // Summary-first: the complex benchmark showed agents pulling 43–75 KB bodies
89
- // raw. `--summary` shows the key/size map so they fetch only what they need.
90
- // Kept terse on purpose: this line rides EVERY write and every spilled read
91
- // (2026-09-25 cost pass — the parenthetical prose was 80 B of the 133 B).
88
+ // Shape-first: the complex benchmark showed agents pulling 43–75 KB bodies
89
+ // raw. r75 调查C:--shape(深度 2 嵌套骨架)一次给全路径图,深层键不再靠
90
+ // pathMiss 逐层猜;--jq 仍是指名取值的那一跳。Kept terse on purpose: this
91
+ // line rides EVERY write and every spilled read (2026-09-25 cost pass — the
92
+ // parenthetical prose was 80 B of the 133 B).
92
93
  //
93
94
  // GitLab #18 P0-1: the old wording said `原调用加 --extract <path> /
94
95
  // --extract-keys`, which reads as an `artifact get` option — `artifact get`
95
- // has NO --extract (only --jq/--keys/--summary/--path-only/--full), so a
96
- // caller following it always died on `unknown option '--extract'`. Name the
97
- // owning face explicitly; the flags stay the same, just correctly routed.
98
- return `omc artifact get ${artifactId} --summary(再 --keys/--jq);或回到产生它的那次 omc call 加 --extract <path> / --extract-keys(artifact get 没有 --extract,那里同义的是 --jq)`;
96
+ // has NO --extract (only --jq/--keys/--shape/--summary/--path-only/--full),
97
+ // so a caller following it always died on `unknown option '--extract'`. Name
98
+ // the owning face explicitly; the flags stay the same, just correctly routed.
99
+ return `omc artifact get ${artifactId} --shape(深度 2 嵌套骨架;--shape <path> 可切子树;取值用 --jq <path>);或回到产生它的那次 omc call 加 --extract <path> / --extract-keys(artifact get 没有 --extract,那里同义的是 --jq)`;
99
100
  }
100
101
  /** Replace local paths with a redaction marker (never leak the host layout). */
101
102
  function sanitizePaths(value) {
package/dist/discovery.js CHANGED
@@ -555,6 +555,12 @@ export function describeTool(registry, name) {
555
555
  // 撞上之前没有任何发现面说过"写是环境级串行"——describe 的 params 里没有 wait
556
556
  // (它是 omc call 的 CLI 开关,不在工具 schema),capability notes 是空的。
557
557
  ...(tool.kind === "write" ? { writeLock: "写锁=环境级串行:并发写后到的回 write-lock-held(不排队,勿 shell 重试);CLI 可 --wait <ms> 排队" } : {}),
558
+ // R75-B(2026-11-18):写工具的 dry-run 到底覆盖到哪一层——full=与真写同门、
559
+ // partial=部分门、plan=只回 plan。回执里同样的 lintScope/unchecked 字段落地,
560
+ // 调用方在跑 dry-run 前就能知道「绿灯」意味着什么。
561
+ // 默认面只给一句话(full/partial/plan);未跑门类在 dry-run 回执的 unchecked
562
+ // 里给全。默认 describe 有 1,950B 天花板(data.submit 已贴边),详情不进默认面。
563
+ ...(tool.kind === "write" && tool.lintScope !== undefined ? { dryRunCoverage: tool.lintScope } : {}),
558
564
  };
559
565
  }
560
566
  /** Clamp to `limit` characters, ellipsis included — never cut mid-grapheme. */
package/dist/graph.js CHANGED
@@ -5,7 +5,7 @@ import { joinConfigRoot } from "./command-transport.js";
5
5
  import { decodeJsonColumn, JSON_COLUMN_NULL_COALESCE } from "./json-column.js";
6
6
  import { ENDPOINTS } from "./endpoints.js";
7
7
  import { applicationResolutionOf, flattenTreeRows, resolveApplicationScope, sha256 } from "./support.js";
8
- import { wireCall, wireRows } from "./wire.js";
8
+ import { wireCall, wireRows, WireError } from "./wire.js";
9
9
  import { walkConditionLeaves } from "./lanes/rule-graph.js";
10
10
  /**
11
11
  * `node:sqlite` must stay OUT of the CLI's startup module graph: a static
@@ -35,7 +35,9 @@ function nodeSqlite() {
35
35
  * - edges are api-fact only, extracted with rule.references' matching
36
36
  * semantics (service/model/field) plus, since r72g, rule CONDITION leaves
37
37
  * (via rule.condition — the online face's blind spot; see
38
- * extractReferenceEdges);
38
+ * extractReferenceEdges) and, since r75, workflow route conditions + field
39
+ * permissions (published template face) and default-slot form controls
40
+ * (extractWorkflowEdges / extractFormEdges);
39
41
  * - fail-closed completeness: every swallowed read/parse failure is a recorded
40
42
  * gap; a zero-hit answer over a gapped index never claims "no references";
41
43
  * - derived locator, never authority: results are candidate pointers; plan /
@@ -51,7 +53,11 @@ function nodeSqlite() {
51
53
  */
52
54
  // r72g(2026-11-17):规则条件叶子入边(via rule.condition)——v7 索引没有这类
53
55
  // 边,若不升版,旧库会在新覆盖声明下静默漏答「谁的条件引用了字段 X」。
54
- export const GRAPH_SCHEMA_VERSION = "8";
56
+ // r75(2026-11-18):workflow 路由条件(workflow.condition)+ 字段权限
57
+ //(workflow.permissions / .sub)+ form 控件(form.controls)三面入边——同样的
58
+ // 先例:v8 库没有这三类边,不升版则旧库在新覆盖声明下静默漏答「删字段断流程/
59
+ // 表单」。schema 9 强制重拉。
60
+ export const GRAPH_SCHEMA_VERSION = "9";
55
61
  const STALE_LOCK_MS = 15 * 60 * 1000;
56
62
  export const DEFAULT_PULL_CONCURRENCY = 16;
57
63
  export const MAX_PULL_CONCURRENCY = 32;
@@ -438,6 +444,110 @@ export function extractListViewEdges(schemaCode, viewCode, model) {
438
444
  push(condition.propertyCode, "listview.conditions");
439
445
  return edges;
440
446
  }
447
+ /**
448
+ * r75:workflow 路由条件的条件叶 walker。叶子键是 `currentDataItem`——与
449
+ * businessrule 条件叶的 `currentSchemaDataItem`/`targetSchemaDataItem` 是**不同
450
+ * 的键**(r75 真机证据),`walkConditionLeaves` 的 isLeaf 判定不认识这种叶子,
451
+ * 不能复用。组形状是 `[[leaf,…],…]`(组间 AND);空组 `[]` 自然零叶。叶子只认
452
+ * currentDataItem 侧(左=字段、右=字面量;未观察到 target 侧字段——遇到未来
453
+ * 新形态如实漏,不猜)。
454
+ */
455
+ function walkWorkflowConditionLeaves(container, visit) {
456
+ if (Array.isArray(container)) {
457
+ for (const entry of container)
458
+ walkWorkflowConditionLeaves(entry, visit);
459
+ return;
460
+ }
461
+ if (container !== null && typeof container === "object") {
462
+ const record = container;
463
+ if (typeof record.currentDataItem === "string" && record.currentDataItem !== "")
464
+ visit(record);
465
+ }
466
+ }
467
+ /**
468
+ * r75(2026-11-18,调查 A):workflow 面(已发布模板)入边——路由条件
469
+ *(`data.rules[].ruleConditionGroup` 叶子)+ 字段权限
470
+ *(`activities[].propertyPermissions[]` 与 `subPropertyPermissions[]`)。
471
+ *
472
+ * 宿主模型 = `data.schemaCode`(发布模板顶层自带,r75 真机 9/9 全带;缺失时
473
+ * 回退调用方传入的模型码)。`ruleCode` 列承载 workflowCode(与 datarule/listview
474
+ * 借 nodeCode 的惯例不同:流程码在查询面就是「引用者」身份)。权限行全量入边
475
+ *(含全 false 默认行)——删除字段时它们同样是存储引用;子表列权限的
476
+ * nodeCode 带 `activityCode!父码` 消歧(子表列码可能与主表字段同名)。
477
+ */
478
+ export function extractWorkflowEdges(schemaCode, workflowCode, data) {
479
+ const host = typeof data.schemaCode === "string" && data.schemaCode !== "" ? data.schemaCode : schemaCode;
480
+ const edges = [];
481
+ const seen = new Set();
482
+ const push = (code, nodeCode, via) => {
483
+ if (typeof code !== "string" || code === "")
484
+ return;
485
+ const dedupeKey = `${via}/${nodeCode}/${code}`;
486
+ if (seen.has(dedupeKey))
487
+ return;
488
+ seen.add(dedupeKey);
489
+ edges.push({ kind: "field", code, schemaCode: host, ruleCode: workflowCode, nodeCode, nodeType: via === "workflow.condition" ? "workflow-condition" : "workflow-permission", via });
490
+ };
491
+ for (const route of Array.isArray(data.rules) ? data.rules : []) {
492
+ const routeCode = `${String(route.preActivityCode ?? "")}->${String(route.postActivityCode ?? "")}`;
493
+ walkWorkflowConditionLeaves(route.ruleConditionGroup, (leaf) => push(leaf.currentDataItem, routeCode, "workflow.condition"));
494
+ }
495
+ for (const activity of Array.isArray(data.activities) ? data.activities : []) {
496
+ const activityCode = String(activity.activityCode ?? "");
497
+ if (activityCode === "")
498
+ continue;
499
+ for (const permission of Array.isArray(activity.propertyPermissions) ? activity.propertyPermissions : []) {
500
+ push(permission.propertyCode, activityCode, "workflow.permissions");
501
+ for (const sub of Array.isArray(permission.subPropertyPermissions) ? permission.subPropertyPermissions : [])
502
+ push(sub.propertyCode, `${activityCode}!${String(permission.propertyCode ?? "")}`, "workflow.permissions.sub");
503
+ }
504
+ }
505
+ return edges;
506
+ }
507
+ /**
508
+ * r75:form 面(默认表单槽)入边——`draftAttributesJson`/`publishedAttributesJson`
509
+ * 双面并集(一面有即有)。字段绑定控件的 key == 字段 code,但 attributes 里还
510
+ * 有 Title/Group 等非数据控件(固定 type,码不在字段表)——只发「码在该模型
511
+ * fieldList(draft∪published)里」的控件,滤掉噪声。子表控件的 `columns[].key`
512
+ * 是子模型字段码,不在本模型 fieldList 里(fields 表本就无子表列,与 datarule/
513
+ * workflow 子表语义一致),结构上即数据绑定,不按 fieldList 过滤;nodeCode 带
514
+ * `sheetCode!父控件码` 消歧(子表列码可能与主表字段同名)。
515
+ */
516
+ export function extractFormEdges(schemaCode, sheet, knownFieldCodes) {
517
+ const sheetCode = typeof sheet.sheetCode === "string" && sheet.sheetCode !== "" ? sheet.sheetCode : schemaCode;
518
+ const edges = [];
519
+ const seen = new Set();
520
+ const push = (code, nodeCode) => {
521
+ if (code === "" || seen.has(`${nodeCode}/${code}`))
522
+ return;
523
+ seen.add(`${nodeCode}/${code}`);
524
+ edges.push({ kind: "field", code, schemaCode, ruleCode: "", nodeCode, nodeType: "form-control", via: "form.controls" });
525
+ };
526
+ for (const face of [sheet.draftAttributesJson, sheet.publishedAttributesJson]) {
527
+ if (typeof face !== "string" || face.trim() === "")
528
+ continue;
529
+ let controls = {};
530
+ try {
531
+ const parsed = JSON.parse(face);
532
+ if (parsed !== null && typeof parsed === "object" && !Array.isArray(parsed))
533
+ controls = parsed;
534
+ }
535
+ catch {
536
+ continue; // 该面 JSON 损坏:另一面仍可用,损坏面不产边也不撒谎
537
+ }
538
+ for (const [key, control] of Object.entries(controls)) {
539
+ if (knownFieldCodes.has(key))
540
+ push(key, sheetCode);
541
+ const record = control;
542
+ if (record !== null && typeof record === "object" && Array.isArray(record.columns))
543
+ for (const column of record.columns) {
544
+ if (typeof column.key === "string")
545
+ push(column.key, `${sheetCode}!${key}`);
546
+ }
547
+ }
548
+ }
549
+ return edges;
550
+ }
441
551
  /**
442
552
  * The full pull walk, PIPELINED: one shared bounded worker pool executes both
443
553
  * task kinds — per-model face reads (rule.list + dataruleList) and per-rule
@@ -486,6 +596,14 @@ export async function pullRuleGraph(session, concurrency = DEFAULT_PULL_CONCURRE
486
596
  gaps.push({ kind: "field-list", ref: schemaCode, note: error instanceof Error ? error.message : String(error) });
487
597
  }
488
598
  }));
599
+ // r75:form 控件边按「码在该模型 fieldList 里」过滤——这里是已知字段的按模型
600
+ // 索引(fields 收集在上面 await 完成,此时已齐)。
601
+ const knownFields = new Map();
602
+ for (const field of fields) {
603
+ const codes = knownFields.get(field.schemaCode) ?? new Set();
604
+ codes.add(field.code);
605
+ knownFields.set(field.schemaCode, codes);
606
+ }
489
607
  try {
490
608
  await wireCall(session, { path: ENDPOINTS.bizServiceCategoryList });
491
609
  const rows = wireRows((await wireCall(session, { path: ENDPOINTS.bizServiceListByCategoryId, query: { categoryId: "" } })).data);
@@ -503,6 +621,8 @@ export async function pullRuleGraph(session, concurrency = DEFAULT_PULL_CONCURRE
503
621
  let parseFailures = 0;
504
622
  let dataruleCount = 0;
505
623
  let viewCount = 0;
624
+ let workflowCount = 0;
625
+ let formCount = 0;
506
626
  // --- shared scheduler: bounded starts, dynamic task submission ---
507
627
  class Semaphore {
508
628
  // Handoff semantics: a released slot is handed DIRECTLY to the head
@@ -592,6 +712,51 @@ export async function pullRuleGraph(session, concurrency = DEFAULT_PULL_CONCURRE
592
712
  catch (error) {
593
713
  gaps.push({ kind: "listview-list", ref: schemaCode, note: error instanceof Error ? error.message : String(error) });
594
714
  }
715
+ // r75:workflow 面(路由条件 + 字段权限)。isworkflow=false 是「该模型没有
716
+ // 流程」的缺席信号,不是缺口;401001 同理(与 lanes/workflow.ts 的
717
+ // isWorkflowAbsent 同语义——该函数未导出,这里局部判定)。读失败记
718
+ // workflow-read gap,不静默。
719
+ try {
720
+ if ((await wireCall(session, { path: ENDPOINTS.workflowIsWorkflow, query: { schemaCode } })).data === true) {
721
+ const linked = (await wireCall(session, { path: ENDPOINTS.workflowGetBySchema, query: { schemaCode } })).data;
722
+ const workflowCode = linked !== null && typeof linked.workflowCode === "string" && linked.workflowCode !== "" ? linked.workflowCode : "";
723
+ if (workflowCode === "") {
724
+ gaps.push({ kind: "workflow-read", ref: schemaCode, note: "isworkflow=true 但 getWorkflow 未返回 workflowCode" });
725
+ }
726
+ else {
727
+ // 只读发布面(运行时生效面);未发布流程该端点回草稿形态,照常入边
728
+ //(发布标记不阻断采集,草稿独有差异不追——见 r75 调查报告)。
729
+ let published = null;
730
+ try {
731
+ published = (await wireCall(session, { path: ENDPOINTS.workflowGetPublished, query: { workflowCode } })).data;
732
+ }
733
+ catch (error) {
734
+ if (!(error instanceof WireError && error.kind === "business" && error.errcode === 401001))
735
+ throw error;
736
+ }
737
+ if (published !== null) {
738
+ workflowCount += 1;
739
+ edges.push(...extractWorkflowEdges(schemaCode, workflowCode, published).map((edge) => ({ ...edge, applicationCode })));
740
+ }
741
+ }
742
+ }
743
+ }
744
+ catch (error) {
745
+ gaps.push({ kind: "workflow-read", ref: schemaCode, note: error instanceof Error ? error.message : String(error) });
746
+ }
747
+ // r75:form 面(默认表单槽,sheetCode=schemaCode)。bizsheet/get 对「还没有
748
+ // 表单」的模型回 data:null——缺席不是缺口。多表单模型的其它槽位
749
+ //(sheetCode≠schemaCode)无清单端点,只扫默认槽(GRAPH_COVERAGE.note 声明)。
750
+ try {
751
+ const sheet = (await wireCall(session, { path: ENDPOINTS.sheetGet, query: { schemaCode, sheetCode: schemaCode } })).data;
752
+ if (sheet !== null) {
753
+ formCount += 1;
754
+ edges.push(...extractFormEdges(schemaCode, sheet, knownFields.get(schemaCode) ?? new Set()).map((edge) => ({ ...edge, applicationCode })));
755
+ }
756
+ }
757
+ catch (error) {
758
+ gaps.push({ kind: "form-read", ref: schemaCode, note: error instanceof Error ? error.message : String(error) });
759
+ }
595
760
  listMs += Date.now() - faceStart;
596
761
  if (!ruleListOk)
597
762
  return;
@@ -701,7 +866,7 @@ export async function pullRuleGraph(session, concurrency = DEFAULT_PULL_CONCURRE
701
866
  fields: fields.sort((a, b) => `${a.schemaCode}/${a.code}`.localeCompare(`${b.schemaCode}/${b.code}`)),
702
867
  services: services.sort((a, b) => a.code.localeCompare(b.code)),
703
868
  gaps,
704
- scanned: { models: schemaCodes.length, rules: rules.length, datarules: dataruleCount, views: viewCount, parseFailures },
869
+ scanned: { models: schemaCodes.length, rules: rules.length, datarules: dataruleCount, views: viewCount, workflows: workflowCount, forms: formCount, parseFailures },
705
870
  timings: { listMs, readMs, totalMs: Date.now() - totalStart },
706
871
  };
707
872
  }
@@ -796,7 +961,7 @@ export async function publishGraphPull(session, concurrency = DEFAULT_PULL_CONCU
796
961
  fields: parts.flatMap((part) => part.fields),
797
962
  services: parts.flatMap((part) => part.services),
798
963
  gaps: parts.flatMap((part) => part.gaps),
799
- scanned: parts.reduce((sum, part) => ({ models: sum.models + part.scanned.models, rules: sum.rules + part.scanned.rules, datarules: sum.datarules + part.scanned.datarules, views: sum.views + part.scanned.views, parseFailures: sum.parseFailures + part.scanned.parseFailures }), { models: 0, rules: 0, datarules: 0, views: 0, parseFailures: 0 }),
964
+ scanned: parts.reduce((sum, part) => ({ models: sum.models + part.scanned.models, rules: sum.rules + part.scanned.rules, datarules: sum.datarules + part.scanned.datarules, views: sum.views + part.scanned.views, workflows: sum.workflows + part.scanned.workflows, forms: sum.forms + part.scanned.forms, parseFailures: sum.parseFailures + part.scanned.parseFailures }), { models: 0, rules: 0, datarules: 0, views: 0, workflows: 0, forms: 0, parseFailures: 0 }),
800
965
  timings: { listMs: parts.reduce((n, part) => n + part.timings.listMs, 0), readMs: parts.reduce((n, part) => n + part.timings.readMs, 0), totalMs: parts.reduce((n, part) => n + part.timings.totalMs, 0) },
801
966
  };
802
967
  const staging = `${dbPath}.staging-${process.pid}`;
@@ -1006,19 +1171,21 @@ export const GRAPH_COVERAGE = Object.freeze({
1006
1171
  // r72g(2026-11-17):businessrule 面从「结构引用」扩到「条件叶子」——规则
1007
1172
  // nodeGraph 各条件容器(filterCondition/targetConditionGroups/
1008
1173
  // exitConditionGroups/dataCondition/…)+ 定时规则 schedulerSetting.
1009
- // filterConditionGroups 的字段引用以 rule.condition 边入索引;schema 升到
1010
- // 8 强制旧库重拉,避免旧索引在新声明下静默漏答。
1011
- scanned: Object.freeze(["businessrule", "datarule", "listview"]),
1012
- notScanned: Object.freeze(["form", "workflow.permissions", "workflow.bindings", "onlinejs"]),
1013
- answerable: Object.freeze(["businessrule", "datarule", "listview"]),
1174
+ // filterConditionGroups 的字段引用以 rule.condition 边入索引。
1175
+ // r75(2026-11-18):workflow 路由条件(workflow.condition 边)+ 字段权限
1176
+ //(workflow.permissions / workflow.permissions.sub 边)+ form 控件
1177
+ //(form.controls 边,默认表单槽)入索引,schema 升到 9 强制旧库重拉。
1178
+ // workflow.bindings(规则绑定,需扩 rule kind,跨面改动留二期)与 onlinejs
1179
+ //(任意 JS 表达式的字符串引用,无法证伪)仍在 notScanned。
1180
+ scanned: Object.freeze(["businessrule", "datarule", "listview", "form", "workflow.condition", "workflow.permissions"]),
1181
+ notScanned: Object.freeze(["workflow.bindings", "onlinejs"]),
1182
+ answerable: Object.freeze(["businessrule", "datarule", "listview", "form", "workflow.condition", "workflow.permissions"]),
1014
1183
  mustCheckManually: Object.freeze([
1015
- { surface: "form", why: "表单控件关联未扫描,可能仍引用目标字段", how: "omc call form.get --args '{\"schemaCode\":\"<x>\"}'" },
1016
- { surface: "workflow.permissions", why: "流程权限未扫描,无法判断谁能发起/操作(workflow.get 不存在:读已发布面用 get_published)", how: "omc call workflow.get_published --args '{\"workflowCode\":\"<x>\"}'" },
1017
1184
  { surface: "workflow.bindings", why: "流程规则绑定未扫描,规则删除可能留下绑定(workflow.get 不存在:草稿/已发布分别用 get_draft/get_published)", how: "omc call workflow.get_published --args '{\"workflowCode\":\"<x>\"}'" },
1018
1185
  { surface: "onlinejs", why: "在线 JS 可能通过字符串引用字段", how: "omc call onlinejs.get --args '{\"schemaCode\":\"<x>\"}'" },
1019
1186
  ]),
1020
- note: "零命中/全零 totals 只代表 scanned 面没有命中;notScanned 面(尤其 form 与 workflow.permissions)未扫描,不可据此判定可安全删除或无影响",
1021
- crossFace: "在线对照面:`omc call rule.references`(实时,仅 businessrule,不含条件叶子);本索引(离线快照,businessrule+datarule+listview,且含规则条件叶子 rule.condition 边)——条件里的字段引用离线一次可答,在线面要 rule.get 逐条看",
1187
+ note: "零命中/全零 totals 只代表 scanned 面没有命中;notScanned 面(workflow.bindings 与 onlinejs)未扫描,不可据此判定可安全删除或无影响。form 面只扫默认表单槽(sheetCode=schemaCode),多表单模型的其它槽位未扫;workflow 只读已发布端点 get_published(未发布流程回草稿形态,照常入边);流程条件叶子只认 currentDataItem 裸码(未观察到子表/跨模型限定形态,遇到新形态会如实漏)",
1188
+ crossFace: "在线对照面:`omc call rule.references`(实时,仅 businessrule,不含条件叶子);本索引(离线快照,businessrule+datarule+listview+form+workflow.condition+workflow.permissions,且含规则条件叶子 rule.condition 边)——条件/表单控件/流程权限里的字段引用离线一次可答;在线面对 workflow/form 没有快查工具(逐条 workflow.get_published / form.get 才能答),离线索引是这两个面的唯一快查面",
1022
1189
  });
1023
1190
  /**
1024
1191
  * Zero-hit disambiguation (2026-10-31 capability-test friction, hit twice in
@@ -1162,7 +1329,7 @@ export function queryGraphReferences(kind, rawCode, selector = {}) {
1162
1329
  ? {
1163
1330
  note: (gapped
1164
1331
  ? "零命中,但索引存在扫描缺口——不可作为「无引用」证明;先 omc graph pull 重建再查"
1165
- : `零命中=仅 scanned 面(规则/数据规则/视图)没有引用它;本索引覆盖应用:${summary.coverage.applicationCodes.join("、") || "(未知)"},不代表其他应用没有引用;form(表单控件)与 workflow.permissions 未扫描,见 coverage.notScanned——不可据此判定可安全删除`) +
1332
+ : `零命中=scanned 面(规则/数据规则/视图/表单/流程)没有引用它;本索引覆盖应用:${summary.coverage.applicationCodes.join("、") || "(未知)"},不代表其他应用没有引用;workflow.bindings 与 onlinejs 未扫描,见 coverage.notScanned——不可据此判定可安全删除`) +
1166
1333
  (zeroHitKindHint(db, kind, code, "references") ?? "") +
1167
1334
  (kind === "field" && scoped === null ? unresolvedScopedCodeNote(rawCode) ?? "" : ""),
1168
1335
  }
@@ -1329,7 +1496,7 @@ export function searchGraphRules(term, limit = 20, offset = 0, selector = {}) {
1329
1496
  matches: entityMatches,
1330
1497
  index: summary,
1331
1498
  ...(scoped !== null ? { resolvedScope: { schemaCode: scoped.schemaCode, code: scoped.code } } : {}),
1332
- coverage: { scanned: ["rule.code", "rule.name", "model.code", "model.name", "field.code", "field.name", "service.code", "service.name"], notScanned: ["rule.body", "form", "workflow.permissions"], answerable: ["rule.code", "rule.name", "model.code", "model.name", "field.code", "field.name", "service.code", "service.name"], mustCheckManually: [{ surface: "rule.body", why: "规则体未检索", how: "omc call rule.list --args '{\"schemaCode\":\"<x>\"}'" }, { surface: "form", why: "表单控件未扫描", how: "omc call form.get --args '{\"schemaCode\":\"<x>\"}'" }, { surface: "workflow.permissions", why: "流程权限未扫描", how: "omc call workflow.get --args '{\"schemaCode\":\"<x>\"}'" }], note: "检索覆盖规则与实体的 code/name;规则体、表单与流程权限未扫描" },
1499
+ coverage: { scanned: ["rule.code", "rule.name", "model.code", "model.name", "field.code", "field.name", "service.code", "service.name"], notScanned: ["rule.body", "workflow.bindings", "onlinejs"], answerable: ["rule.code", "rule.name", "model.code", "model.name", "field.code", "field.name", "service.code", "service.name"], mustCheckManually: [{ surface: "rule.body", why: "规则体未检索", how: "omc call rule.list --args '{\"schemaCode\":\"<x>\"}'" }, { surface: "workflow.bindings", why: "流程规则绑定未扫描,规则删除可能留下绑定", how: "omc call workflow.get_published --args '{\"workflowCode\":\"<x>\"}'" }, { surface: "onlinejs", why: "在线 JS 可能通过字符串引用字段", how: "omc call onlinejs.get --args '{\"schemaCode\":\"<x>\"}'" }], note: "检索覆盖规则与实体的 code/name;规则体、流程规则绑定与在线 JS 未检索(表单控件/流程条件与权限里的字段引用已入索引,走 references/impact)" },
1333
1500
  ...(term.trim() !== "" && !/^[A-Za-z][A-Za-z0-9_.-]*$/.test(term.trim()) ? { note: "疑似业务词;本工具同时检索实体 name/code 与规则 code/name,引用明细请使用匹配到的 code 再查 references/impact" } : {}),
1334
1501
  ...(matches.length === 0 && entityMatches.model.total === 0 && entityMatches.field.total === 0 && entityMatches.service.total === 0
1335
1502
  ? {
@@ -1368,7 +1535,7 @@ export function impactGraph(kind, rawCode, selector = {}) {
1368
1535
  const schemaPredicate = scoped ? " AND schema_code = ?" : "";
1369
1536
  const schemaParams = scoped ? [scoped.schemaCode] : [];
1370
1537
  const hop1 = db
1371
- .prepare(`SELECT DISTINCT schema_code, rule_code FROM edges WHERE kind = ? AND code = ?${schemaPredicate} AND node_type NOT IN ('datarule', 'listview') ORDER BY schema_code, rule_code LIMIT 51`)
1538
+ .prepare(`SELECT DISTINCT schema_code, rule_code FROM edges WHERE kind = ? AND code = ?${schemaPredicate} AND node_type NOT IN ('datarule', 'listview', 'workflow-condition', 'workflow-permission', 'form-control') ORDER BY schema_code, rule_code LIMIT 51`)
1372
1539
  .all(kind, code, ...schemaParams);
1373
1540
  const dataruleHits = db
1374
1541
  .prepare(`SELECT DISTINCT schema_code, node_code AS targets, via FROM edges WHERE kind = ? AND code = ?${schemaPredicate} AND node_type = 'datarule' ORDER BY schema_code, node_code, via LIMIT 21`)
@@ -1376,8 +1543,16 @@ export function impactGraph(kind, rawCode, selector = {}) {
1376
1543
  const listViewHits = db
1377
1544
  .prepare(`SELECT DISTINCT schema_code, node_code AS view_code, via FROM edges WHERE kind = ? AND code = ?${schemaPredicate} AND node_type = 'listview' ORDER BY schema_code, node_code, via LIMIT 21`)
1378
1545
  .all(kind, code, ...schemaParams);
1546
+ // r75:workflow/form 独立命中桶(与 datarule/listview 平级,20 条上限)——
1547
+ // 不分桶则这两面的边会混进 hop1「规则」列表且在 rules 表查无名字。
1548
+ const workflowHits = db
1549
+ .prepare(`SELECT DISTINCT schema_code, rule_code, node_code, node_type, via FROM edges WHERE kind = ? AND code = ?${schemaPredicate} AND node_type IN ('workflow-condition', 'workflow-permission') ORDER BY schema_code, rule_code, node_code, node_type, via LIMIT 21`)
1550
+ .all(kind, code, ...schemaParams);
1551
+ const formHits = db
1552
+ .prepare(`SELECT DISTINCT schema_code, node_code AS sheet_code, via FROM edges WHERE kind = ? AND code = ?${schemaPredicate} AND node_type = 'form-control' ORDER BY schema_code, node_code, via LIMIT 21`)
1553
+ .all(kind, code, ...schemaParams);
1379
1554
  const capped = hop1.length > 50;
1380
- const refsFor = db.prepare("SELECT kind, code, via FROM edges WHERE schema_code = ? AND rule_code = ? AND node_type <> 'datarule' ORDER BY kind, code, via");
1555
+ const refsFor = db.prepare("SELECT kind, code, via FROM edges WHERE schema_code = ? AND rule_code = ? AND node_type NOT IN ('datarule', 'listview', 'workflow-condition', 'workflow-permission', 'form-control') ORDER BY kind, code, via");
1381
1556
  const ruleName = db.prepare("SELECT name FROM rules WHERE schema_code = ? AND rule_code = ?");
1382
1557
  const services = new Set();
1383
1558
  const models = new Set();
@@ -1416,21 +1591,23 @@ export function impactGraph(kind, rawCode, selector = {}) {
1416
1591
  rules,
1417
1592
  datarules: dataruleHits.slice(0, 20).map((hit) => ({ schemaCode: hit.schema_code, targets: hit.targets ?? "", via: hit.via })),
1418
1593
  listviews: listViewHits.slice(0, 20).map((hit) => ({ schemaCode: hit.schema_code, viewCode: hit.view_code ?? "", via: hit.via })),
1419
- totals: { rules: hop1.length, datarules: dataruleHits.length, listviews: listViewHits.length, touchedServices: services.size, touchedModels: models.size, touchedFields: fields.size },
1594
+ workflows: workflowHits.slice(0, 20).map((hit) => ({ schemaCode: hit.schema_code, workflowCode: hit.rule_code, nodeCode: hit.node_code ?? "", nodeType: hit.node_type ?? "", via: hit.via })),
1595
+ forms: formHits.slice(0, 20).map((hit) => ({ schemaCode: hit.schema_code, sheetCode: hit.sheet_code ?? "", via: hit.via })),
1596
+ totals: { rules: hop1.length, datarules: dataruleHits.length, listviews: listViewHits.length, workflows: workflowHits.length, forms: formHits.length, touchedServices: services.size, touchedModels: models.size, touchedFields: fields.size },
1420
1597
  index: summary,
1421
1598
  coverage: GRAPH_COVERAGE,
1422
1599
  ...(scoped !== null ? { resolvedScope: { schemaCode: scoped.schemaCode, code: scoped.code } } : {}),
1423
- ...(hop1.length === 0 && dataruleHits.length === 0 && listViewHits.length === 0
1600
+ ...(hop1.length === 0 && dataruleHits.length === 0 && listViewHits.length === 0 && workflowHits.length === 0 && formHits.length === 0
1424
1601
  ? {
1425
1602
  note: (gapped
1426
1603
  ? "零命中,但索引存在扫描缺口——不可作为「无影响」证明;先 omc graph pull 重建再查"
1427
- : "零命中=仅 scanned 面(规则/数据规则/视图)没有影响;form(表单控件)与 workflow.permissions 未扫描,见 coverage.notScanned——不可据此判定「删除无影响」") +
1604
+ : "零命中=scanned 面(规则/数据规则/视图/表单/流程)没有影响;workflow.bindings 与 onlinejs 未扫描,见 coverage.notScanned——不可据此判定「删除无影响」") +
1428
1605
  (zeroHitKindHint(db, kind, code, "impact") ?? "") +
1429
1606
  (kind === "field" && scoped === null ? unresolvedScopedCodeNote(rawCode) ?? "" : ""),
1430
1607
  }
1431
1608
  : {}),
1432
- ...(capped || dataruleHits.length > 20 || listViewHits.length > 20
1433
- ? { truncated: true, note: `命中超过上限已截断(规则 50/实际 ${hop1.length},数据规则 20/实际 ${dataruleHits.length},视图 20/实际 ${listViewHits.length});完整规则清单用 references` }
1609
+ ...(capped || dataruleHits.length > 20 || listViewHits.length > 20 || workflowHits.length > 20 || formHits.length > 20
1610
+ ? { truncated: true, note: `命中超过上限已截断(规则 50/实际 ${hop1.length},数据规则 20/实际 ${dataruleHits.length},视图 20/实际 ${listViewHits.length},流程 20/实际 ${workflowHits.length},表单 20/实际 ${formHits.length});完整规则清单用 references` }
1434
1611
  : {}),
1435
1612
  ...(gapped ? { gapWarning: `索引有 ${summary.gaps.count} 个扫描缺口(${Object.entries(summary.gaps.byKind).map(([k, v]) => `${k}:${v}`).join(", ")});影响面可能不完整` } : {}),
1436
1613
  };
@@ -52,6 +52,10 @@ export function registerApplyChangesLane(tools) {
52
52
  confirmProduction: confirmProductionArg,
53
53
  dryRun: z.boolean().optional().describe("true = 只返回整包预览(plan/actions + planFingerprint),零环境写入"),
54
54
  },
55
+ // R75-B:dry-run 逐项跑 writePreflight(纯参数门),但各步的 session-aware
56
+ // lint 尚未在批量预览里执行——如实声明,不能读成「整批可执行」。
57
+ lintScope: "partial",
58
+ lintUnchecked: ["batch-step-session-lint", "local-write-gates", "platform-side-validation", "post-write-readback"],
55
59
  handler: async (ctx, args) => {
56
60
  const changes = args.changes;
57
61
  // ---- 1. Structural validation (zero wire calls) --------------------