@stalfh233/omc-cli 0.8.38 → 0.8.40

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.
@@ -7,7 +7,7 @@ import { buildToolRegistry } from "./tools.js";
7
7
  import { parseToolInput, ToolInputError } from "./tool-types.js";
8
8
  import { projectResultExtract, unwrapSinglePathProjection } from "./path-projection.js";
9
9
  import { writeCoordinator, WriteLockConflictError } from "./write-coordinator.js";
10
- import { argvValues, withUnknownEnvironmentRecovery } from "./call-input.js";
10
+ import { argvValues, lockRetryArgs, withUnknownEnvironmentRecovery } from "./call-input.js";
11
11
  function resolvedDefaultEnvironment(store) {
12
12
  try {
13
13
  return store.resolveEnvironment(undefined).name;
@@ -46,8 +46,19 @@ export async function executeCall(store, parsed) {
46
46
  // before write admission, so it must not contend for the cross-process lock.
47
47
  if (toolKind === "write" && !dryRun) {
48
48
  const lockTarget = environment ?? resolvedDefaultEnvironment(store);
49
+ // F3(w57 探针 AB):锁冲突回执的 nextCommand 要能直接复制执行——把本次
50
+ // 参数按安全规则带过去(文件/stdin 原样引用,inline 仅在不含凭据且 ≤500B
51
+ // 时内联,否则占位并在回执披露)。
52
+ const retryArgs = lockRetryArgs({ ...(rawArgs !== undefined ? { rawArgs } : {}), ...(argsFile !== undefined ? { argsFile } : {}), parsedArgs });
49
53
  try {
50
- result = await writeCoordinator.run({ environment: lockTarget, tool: toolName, waitMs, mode: "single" }, (lease) => callTool(lease));
54
+ result = await writeCoordinator.run({
55
+ environment: lockTarget,
56
+ tool: toolName,
57
+ waitMs,
58
+ mode: "single",
59
+ ...(retryArgs.nextArgs !== undefined ? { nextArgs: retryArgs.nextArgs } : {}),
60
+ ...(retryArgs.omitted !== undefined ? { nextCommandArgsOmitted: retryArgs.omitted } : {}),
61
+ }, (lease) => callTool(lease));
51
62
  }
52
63
  catch (error) {
53
64
  if (!(error instanceof WriteLockConflictError))
@@ -182,6 +182,71 @@ function withoutEnvironmentCommand(input) {
182
182
  return `omc call ${input.tool} --args -`;
183
183
  return `omc call ${input.tool}`;
184
184
  }
185
+ /**
186
+ * F3(w57 探针 AB):`write-lock-held` 的 `nextCommand` 必须是**可直接复制执行**
187
+ * 的同一次调用。参数按安全优先回填,绝不把凭据写进回执:
188
+ * - `--args-file <path>` 单引号 shell-safe 引用(不展开文件内容;含空格/单引号
189
+ * 的路径复制后仍是同一条命令);
190
+ * - `--args -` 原样保留(stdin);
191
+ * - inline `--args`:序列化 ≤500B 且递归键名不含凭据词才内联,否则回占位符
192
+ * 并让回执标 `nextCommandArgsOmitted:"sensitive-or-large"`。
193
+ */
194
+ const SENSITIVE_ARG_KEY = /password|passwd|secret|token|credential|authorization|apikey|accesskey|privatekey/i;
195
+ /** 键名先去掉非字母数字再匹配,覆盖 api_key / access-key / private.key 等变体。 */
196
+ function isSensitiveArgKey(key) {
197
+ return SENSITIVE_ARG_KEY.test(key.replace(/[^a-z0-9]/gi, ""));
198
+ }
199
+ /** 与 inline `--args` 相同的单引号转义,供 `--args-file <path>` 复用。 */
200
+ function shellSingleQuote(value) {
201
+ return `'${value.replace(/'/g, "'\\''")}'`;
202
+ }
203
+ function sensitiveArgKeyIn(value, seen) {
204
+ if (value === null || typeof value !== "object")
205
+ return undefined;
206
+ if (seen.has(value))
207
+ return undefined;
208
+ seen.add(value);
209
+ if (Array.isArray(value)) {
210
+ for (const item of value) {
211
+ const hit = sensitiveArgKeyIn(item, seen);
212
+ if (hit !== undefined)
213
+ return hit;
214
+ }
215
+ return undefined;
216
+ }
217
+ for (const [key, child] of Object.entries(value)) {
218
+ if (isSensitiveArgKey(key))
219
+ return key;
220
+ const hit = sensitiveArgKeyIn(child, seen);
221
+ if (hit !== undefined)
222
+ return hit;
223
+ }
224
+ return undefined;
225
+ }
226
+ export function lockRetryArgs(input) {
227
+ if (input.argsFile !== undefined)
228
+ return { nextArgs: `--args-file ${shellSingleQuote(input.argsFile)}` };
229
+ if (input.rawArgs === "-")
230
+ return { nextArgs: "--args -" };
231
+ if (input.rawArgs === undefined)
232
+ return {};
233
+ let inline;
234
+ try {
235
+ const parsed = JSON.parse(input.rawArgs);
236
+ if (parsed !== null && typeof parsed === "object" && !Array.isArray(parsed))
237
+ inline = parsed;
238
+ }
239
+ catch {
240
+ // 非法 JSON 在写面准入前就被拒,不会走到取锁这一步。
241
+ }
242
+ if (inline === undefined)
243
+ return {};
244
+ const serialized = JSON.stringify(inline);
245
+ if (serialized.length <= 500 && sensitiveArgKeyIn(inline, new Set()) === undefined) {
246
+ return { nextArgs: `--args ${shellSingleQuote(serialized)}` };
247
+ }
248
+ return { nextArgs: "--args '<本次参数>'", omitted: "sensitive-or-large" };
249
+ }
185
250
  /** 给 `unknown environment` 错误补一条「去掉 --env 重跑」的可复制命令。 */
186
251
  export function withUnknownEnvironmentRecovery(result, input) {
187
252
  if (result.status !== "error" || typeof result.message !== "string")
@@ -316,7 +316,10 @@ function phraseOf(tool, args, outcome) {
316
316
  return `保存数据(模型 ${schemaCode ?? "?"})——更新既有行,不创建/改动流程实例;流程模型上保存的直提标志会被拒,推进该行用 workitem.list → data.submit 三件套(不要为触发规则/推进流程再 data.save)${nameNote}${rulesNote}`;
317
317
  }
318
318
  if (workflowInstanceNote !== undefined) {
319
- return `保存数据(模型 ${schemaCode ?? "?"})——普通草稿、无流程实例,不能提交;要可提交请用 data.save 带 workflowCode:"${workflowInstanceNote.workflowCode ?? "<wf>"}" 重建流程草稿(formData 不要带 id)${nameNote}${rulesNote}`;
319
+ // F5(w57 探针 AB):保存是成功的;这行是「无实例」信息,不是失败。
320
+ // phase:"done" 会自动加「已」前缀,所以这里写「保存为普通草稿」,
321
+ // 最终 stderr 首句是「已保存为普通草稿(模型 X)」。
322
+ return `保存为普通草稿(模型 ${schemaCode ?? "?"})——无流程实例(本次未带 workflowCode),之后不能直接 data.submit;如需可提交,用 data.save 带 workflowCode:"${workflowInstanceNote.workflowCode ?? "<wf>"}" 重建流程草稿(formData 不要带 id)${nameNote}${rulesNote}`;
320
323
  }
321
324
  if (workflowCheckSkipped !== undefined) {
322
325
  // 更新行不能再劝 data.save workflowCode(会多建一行)——只指复核面 + 现有待办。
@@ -727,7 +727,13 @@ async function readRuleListBody(session, schemaCode, options) {
727
727
  // #77.2:显式 withDraft 才额外读 app 面 DRAFT 行(与 rule.get 同源);
728
728
  // 默认路径零额外 wire、零新增键。DRAFT 面在规则数 <7 时会补建预置——见
729
729
  // RULE_WITH_DRAFT_NOTE,只有显式开关才付出这个代价。
730
- const draftRows = options.withDraft
730
+ // F4(探针 AB P2,0.8.40):读 DRAFT 面是**写副作用**。published 清单只含
731
+ // 「有 enabled DRAFT」的行,rows.length>=7 ⇒ DRAFT>=7 ⇒ 必不补建;<7 只是
732
+ // 可能补建。零额外 wire 的单边判据:<7 且未显式 ensurePresets 时不发 app 面,
733
+ // 回 published 行 + wouldCreatePresets 让调用方 opt-in(误报最多多一轮)。
734
+ const presetFillGuard = options.withDraft === true && options.ensurePresets !== true && rows.length < 7;
735
+ const draftRead = options.withDraft === true && !presetFillGuard;
736
+ const draftRows = draftRead
731
737
  ? wireRows((await wireCall(session, { path: ENDPOINTS.businessRuleListBySchemaCode, query: { schemaCode } })).data)
732
738
  : undefined;
733
739
  const draftByCode = new Map();
@@ -791,9 +797,26 @@ async function readRuleListBody(session, schemaCode, options) {
791
797
  // schemaCodes[] 跨模型面的 models[] 元素缺该键,与 read-shapes「同形」承诺不符)。
792
798
  rulesCount: entries.length,
793
799
  // r28g F18:list 投影的是 PUBLISH 行;运行时可执行性以 rule.get / rule.enable.verified 为准。
794
- source: options.withDraft ? "published-list+draft" : "published-list",
795
- ...(options.withDraft
796
- ? { draftFace: "app/businessrule/list_by_schemacode", draftRowsCount: draftRows?.length ?? 0, draftNote: RULE_WITH_DRAFT_NOTE }
800
+ source: draftRead ? "published-list+draft" : "published-list",
801
+ ...(presetFillGuard
802
+ ? {
803
+ draftFaceSkipped: "preset-fill-guard",
804
+ wouldCreatePresets: {
805
+ publishedRules: rows.length,
806
+ threshold: 7,
807
+ reason: "published 清单只含有 enabled DRAFT 的行;<7 时 app DRAFT 面可能补建 7 条预置(写副作用)——先不发 app 面,确认接受后加 ensurePresets:true",
808
+ nextCommand: `omc call rule.list --env <env> --args '${JSON.stringify({ schemaCode, withDraft: true, ensurePresets: true })}'`,
809
+ },
810
+ draftNote: "withDraft 已请求但未读 DRAFT 面:published 清单 <7 行,app 面读可能触发平台补建 7 条预置(BusinessRuleFacadeImpl.listViewsBySchemaCode → checkAndFillDefaultBusinessRule,写副作用)。确认接受补建后加 ensurePresets:true 重跑。",
811
+ }
812
+ : {}),
813
+ ...(draftRead
814
+ ? {
815
+ draftFace: "app/businessrule/list_by_schemacode",
816
+ draftRowsCount: draftRows?.length ?? 0,
817
+ draftNote: RULE_WITH_DRAFT_NOTE,
818
+ ...(options.ensurePresets === true ? { presetFillConfirmed: true } : {}),
819
+ }
797
820
  : {}),
798
821
  executableHint: "rules[].enabled/status 来自 PUBLISH 投影;运行时判定读 DRAFT(rule.get 的 enabled+ruleStatus,或 rule.enable 回执的 executable/verified)。不要仅凭本面判定可 rule.run。",
799
822
  ...(statusLag
@@ -842,8 +865,8 @@ async function readRuleListBody(session, schemaCode, options) {
842
865
  // ticket-80's update-mode readback teaches following the same-code
843
866
  // latestPublished row — keep the flag on the default face (5 B).
844
867
  ...(row?.latestPublished !== undefined ? { latestPublished: row.latestPublished } : {}),
845
- ...(options.withDraft ? draftFaceOf(entry) : {}),
846
- ...(options.withDraft && row === undefined ? { draftOnly: true } : {}),
868
+ ...(draftRead ? draftFaceOf(entry) : {}),
869
+ ...(draftRead && row === undefined ? { draftOnly: true } : {}),
847
870
  ...(fullRows
848
871
  ? {
849
872
  id: record.id,
@@ -1315,7 +1338,8 @@ export function registerBusinessRuleLane(tools) {
1315
1338
  onlyCustom: z.boolean().optional().describe("只回自建规则(defaultRule!==true)——读面收窄,省 token"),
1316
1339
  full: z.boolean().optional().describe("行内联完整字段(id/createdTime/creator/…)并跳过 detailFile 外置"),
1317
1340
  withMappings: z.boolean().optional().describe("true=规则附 mappings 摘要(服务/方法/入出参计数)"),
1318
- withDraft: z.boolean().optional().describe("true=额外读 DRAFT 面(app/businessrule/list_by_schemacode,+1 wire)并按 code 合并:逐行 publishEnabled/draftEnabled/draftStatus/executable/executableBasis,含禁用/未发布草稿行;规则<7 条时平台可能补建 7 条预置(回执 draftNote 披露)。默认 false 不变"),
1341
+ withDraft: z.boolean().optional().describe("**写副作用**:读 app DRAFT 面(+1 wire),规则<7 时平台补建 7 条预置;默认先跳过(回 wouldCreatePresets),ensurePresets:true 才接受。逐行 publishEnabled/draftEnabled/draftStatus/executable/executableBasis,含禁用/未发布草稿行"),
1342
+ ensurePresets: z.boolean().optional().describe("真正读 DRAFT 面前确认允许平台补建 7 条预置"),
1319
1343
  capability: capabilityArg,
1320
1344
  },
1321
1345
  handler: async (ctx, args, self) => governedRead(ctx, self, args, async (session) => {
@@ -1330,7 +1354,7 @@ export function registerBusinessRuleLane(tools) {
1330
1354
  const schemaCodes = ruleSchemaCodesOf(args.schemaCodes, "rule.list");
1331
1355
  const models = [];
1332
1356
  const failed = [];
1333
- const options = { onlyCustom: args.onlyCustom === true, full: args.full === true, withMappings: args.withMappings === true, withDraft: args.withDraft === true };
1357
+ const options = { onlyCustom: args.onlyCustom === true, full: args.full === true, withMappings: args.withMappings === true, withDraft: args.withDraft === true, ensurePresets: args.ensurePresets === true };
1334
1358
  let firstError;
1335
1359
  let rulesCount = 0;
1336
1360
  // r83:三句提示(executableHint/statusNote/presetHint)逐模型逐字相同,
@@ -1383,7 +1407,7 @@ export function registerBusinessRuleLane(tools) {
1383
1407
  }
1384
1408
  if (singleSchemaCode === undefined)
1385
1409
  throw new ToolInputError({ status: "error", blocker: "tool-input-invalid", tool: "rule.list", message: "需要 schemaCode(单个模型)或 schemaCodes(跨模型清单)" });
1386
- return readRuleListBody(session, singleSchemaCode, { onlyCustom: args.onlyCustom === true, full: args.full === true, withMappings: args.withMappings === true, withDraft: args.withDraft === true });
1410
+ return readRuleListBody(session, singleSchemaCode, { onlyCustom: args.onlyCustom === true, full: args.full === true, withMappings: args.withMappings === true, withDraft: args.withDraft === true, ensurePresets: args.ensurePresets === true });
1387
1411
  }, { full: args.full === true, target: `rule.list:${args.schemaCodes !== undefined ? `schemaCodes:${args.schemaCodes.join(",")}` : args.schemaCode}` }),
1388
1412
  }));
1389
1413
  tools.push(defineTool({
@@ -272,7 +272,7 @@ export const FIELD_LANE_CONTRACT = Object.freeze({
272
272
  controlEmissionPolicy: "ticket 101: controls PHONE(24)/PHOTO(10) are blocked for creation (no BizPropertyType maps to them — BizPropertyType.java:27-54); Tab(500) is a layout container (DataModelInitUtils.java:61-75 recurses panels, never a field); CreatedDeptId(102) is a system-field projection (DefaultPropertyType.java:18-21 → DEPARTMENT_SELECTOR 60, BizMainSystemPropertyRegistry.java:88-101); the scaffold SKIPS any field type without a control mapping — unknown/blocked control types are never auto-created (fail-closed)",
273
273
  fieldRowDefaultPolicy: "ticket 108 determination (live 8.6.26 write+read 2026-09-15 + fwb 8.6.39 readback): the 2026-09-14 key unions are MULTI-FIELD UNIONS of designer rows, not per-field required keys — the platform accepts-and-persists minimal rows, so the minimal default + caller passthrough is the INTENTIONAL boundary. Selection families 12/13/14/15 MUST-FIXED to omit dictionaryData (designer rows carry none; live proves the platform merely accepts the extra key — omc_mcp_t108dd readback carried it only because we sent it). Families 0/1/2/9/11/17 keep the designer-carried {dictionaryData:\"\"}; DATE(3) keeps required format (BizObjectFacadeImpl.java:2949); ATTACHMENT(6) stays intentionally empty (system rows often have no options)",
274
274
  orgSelectorFieldRowOptions: "org-selector families STAFF_SELECTOR / STAFF_MULTI_SELECTOR / DEPARTMENT_SELECTOR / DEPARTMENT_MULTI_SELECTOR (5/50/51/60/61): the field-row options are a publish-safe shape observed on the yst/fwb publish face (2656 rows) — null or {defaultValue, mappings, virtualField[, noRepeat]}; single-select defaultValue \"\" and multi-select []; deptVisible/multi are FORM-CONTROL discriminator keys (read from control.options via disposeUpdateType/updateSelectionType) and never appear on the field row",
275
- relationMappingsSource: "`options.mappings` 形如 `[{source:<关联目标字段/父模型字段>,target:<本模型字段>}]`(裸 code),是关联填充的事实源(字段行,不是表单控件:改控件映射会被重算覆盖,live 2026-10-14 中冶)。Update chain: field.update with the full options (change only mappings, keep queryCode/displayField/schemaCode/conditions… as-is) → field.publish → form.draft rebuild:false (keeps the existing layout and any online JS) → form.publish → readback. Do NOT use cascadeRepublish on a form that already carries a custom layout or online JS — it re-scaffolds the default form. 子表关联列取主表字段的完整配方:`omc describe field.create --example child-map-fill`",
275
+ relationMappingsSource: "`options.mappings` 形如 `[{source:<关联目标字段/父模型字段>,target:<本模型字段>}]`(裸 code),是关联填充的事实源(字段行,不是表单控件:改控件映射会被重算覆盖,live 2026-10-14 中冶)。Update chain: field.update with the full options (change only mappings, keep queryCode/displayField/schemaCode/conditions… as-is) → field.publish → form.draft rebuild:false (keeps the existing layout and any online JS) → form.publish → readback. Do NOT use cascadeRepublish on a form that already carries a custom layout or online JS — it re-scaffolds the default form. 子表关联列取主表字段是**两个字段**(先建并发布快照标量列,再建关联列);完整配方:`omc describe field.create --example child-map-fill`",
276
276
  propertyEmptyReadback: "propertyEmpty overrides the data-model not-null declaration; false reopens a field the platform previously created wrongly (required/readonly belong to the form and workflow nodes). bizproperty/list rows do NOT carry propertyEmpty, so readback.propertyEmpty appears only when the draft face returns it — the CLI never fabricates it; readback.committed lists what actually went on the wire",
277
277
  listFace: "field.list default face inlines code/name/type(+typeName)/conditions signal/shapeWarning only; the whole choices package is not inlined (a selection field measured ~500B/row) — verify options/subSchema with the code/fields selectors or full:true",
278
278
  }),
@@ -328,7 +328,25 @@ async function assertRelationOptionsFields(session, schemaCode, propertyType, re
328
328
  : side === "target"
329
329
  ? `target=${mappedTarget || "(空)"} 不是本模型 ${schemaCode} 的发布面字段(target 只用本模型字段 code,不带前缀)。本模型候选:${targetCandidates.join("、") || "(无)"}`
330
330
  : `source=${source || "(空)"} 不在${linkedHint}的发布面字段里;target=${mappedTarget || "(空)"} 不在本模型 ${schemaCode} 的发布面字段里。关联侧候选:${linkedCodes.join("、") || "(无)"};本模型候选:${targetCandidates.join("、") || "(无)"}`;
331
- throw new ToolRefusalError({ status: "refused", blocker: "relation-mapping-field-not-found", side, schemaCode, relationTarget: target, ...(mainTableCode ? { mainTableCode } : {}), ...(targetParentCode ? { relationParentCode: targetParentCode } : {}), mappingIndex: index, source, targetField: mappedTarget, sourceCandidates: linkedCodes, targetCandidates, message: `关联映射第 ${index + 1} 行字段不存在:${detail}。请使用发布面业务字段 code;确认关联面用 omc call field.list --args '{"schemaCode":"<模型code>","published":true}'。` });
331
+ // F1(探针 AB P2,0.8.40):target 不存在时,消息必须给出「这是两个字段」
332
+ // 的可执行恢复——先建并发布快照标量列,再建关联列。父模型 code 不可硬编
333
+ // (子表关联目标可能与字段所在模型无关),field.publish 用占位符让平台/调用
334
+ // 方解析。source-only 缺口不涉及快照列,保持原提示不加 recovery。
335
+ const snapshotType = sourceField?.type !== undefined ? propertyTypeName(sourceField.type) : "<与 source 同族的标量类型>";
336
+ const fieldListHint = side === "source"
337
+ ? `确认关联面 ${target} 的发布面字段用 omc call field.list --args '${JSON.stringify({ schemaCode: target, published: true })}'`
338
+ : side === "target"
339
+ ? `确认本模型 ${schemaCode} 的发布面字段用 omc call field.list --args '${JSON.stringify({ schemaCode, published: true })}'`
340
+ : `确认关联面 ${target} 用 omc call field.list --args '${JSON.stringify({ schemaCode: target, published: true })}',本模型 ${schemaCode} 用 omc call field.list --args '${JSON.stringify({ schemaCode, published: true })}'`;
341
+ const targetRecovery = side === "source"
342
+ ? undefined
343
+ : [
344
+ { code: "create-snapshot-scalar", action: `先在本模型(子表)${schemaCode} 用 field.create 建快照标量列 code=${mappedTarget || "(空)"}、propertyType=${snapshotType}(与 source 同族的标量);关联/子表/附件等字段不能当快照标量。` },
345
+ { code: "publish-then-retry", action: `field.publish 用拥有该子表的父模型 code(子表 code 会被 300004 拒,回执会给父模型):omc call field.publish --env <env> --args '{"schemaCode":"<父模型>"}';发布后重试本命令。` },
346
+ { code: "read-example", action: "omc describe field.create --example child-map-fill" },
347
+ ];
348
+ const twoFieldNote = side === "source" ? "" : "子表取主表是**两个字段**:先建并发布快照标量列,再建关联列。";
349
+ throw new ToolRefusalError({ status: "refused", blocker: "relation-mapping-field-not-found", side, schemaCode, relationTarget: target, ...(mainTableCode ? { mainTableCode } : {}), ...(targetParentCode ? { relationParentCode: targetParentCode } : {}), mappingIndex: index, source, targetField: mappedTarget, sourceCandidates: linkedCodes, targetCandidates, ...(targetRecovery ? { recovery: targetRecovery } : {}), ...(targetRecovery ? { nextCommand: `omc call field.create --env <env> --args '${JSON.stringify({ schemaCode, code: mappedTarget || "<target>", name: mappedTarget || "<target>", propertyType: sourceField?.type !== undefined ? propertyTypeName(sourceField.type) : "<与 source 同族的标量类型>" })}'`, nextCommandNote: "模板命令:<env>/<父模型> 等占位符需替换后执行;snapshot 的 options.scale 等按字段族补齐" } : {}), message: `关联映射第 ${index + 1} 行字段不存在:${detail}。请使用发布面业务字段 code;${fieldListHint}。${twoFieldNote}` });
332
350
  }
333
351
  // r52:类型兼容门。设计器 filterCondition(admin/js/17170.93392489.js)是产品承认的
334
352
  // 可映射不变量,但它只活在下拉框里——保存、导入、field.create 全都绕过;平台后端
@@ -147,6 +147,98 @@ function parseActionEntries(face) {
147
147
  .filter((code) => typeof code === "string" && code !== "");
148
148
  return { count: rows.length, codes };
149
149
  }
150
+ /**
151
+ * F7(issue #109):`app/bizsheet/get` 的 50000 是平台 SERVER_ERROR 兜底
152
+ * (`ResultEnum.java:16`;`GlobalExceptionHandler.java:151-167` 把未分类
153
+ * RuntimeException/Exception 统一映射成 50000/服务异常),不是字段数阈值,
154
+ * 也没有字段级明细。CLI 此前只透传成 `wire-business`,调用方拿不到「下一步」。
155
+ *
156
+ * 只读兜底:`runtime/form/get_biz_sheet`(`FormRuntimeController.java:2206-2243`)
157
+ * 返回**同一个 BizFormModel**,但跳过_checkBizForm/errorMsgList/initSubTip,
158
+ * 因此不执行表单校验、不带 version。写面(form.draft/form.publish 的
159
+ * readFormOrNull)保持硬失败——写前的服务端校验不能省。
160
+ */
161
+ const FORM_SERVER_ERROR_ERRCODE = 50000;
162
+ const FORM_RUNTIME_SHEET_PATH = "/api/api/runtime/form/get_biz_sheet";
163
+ /** 2KB 截断(按 UTF-8 字节,落在字符边界上)。 */
164
+ function truncateUtf8(value, maxBytes) {
165
+ const bytes = Buffer.from(value, "utf8");
166
+ if (bytes.length <= maxBytes)
167
+ return { text: value, truncated: false };
168
+ let end = maxBytes;
169
+ while (end > 0 && (bytes[end] & 0xc0) === 0x80)
170
+ end -= 1;
171
+ return { text: bytes.subarray(0, end).toString("utf8"), truncated: true };
172
+ }
173
+ /**
174
+ * 平台 50000 的统一结构化拒绝(form.get / form.list 共用决策树)。
175
+ * 回执键是答案而不是教程:原因候选 + 明确披露(换投影不绕过)+ 两条可复制命令。
176
+ */
177
+ function formServerErrorRefusal(input) {
178
+ const env = input.environment !== undefined && input.environment !== "" ? input.environment : "<env>";
179
+ return {
180
+ status: "refused",
181
+ blocker: input.blocker,
182
+ errcode: input.errcode,
183
+ schemaCode: input.schemaCode,
184
+ ...(input.sheetCode !== undefined ? { sheetCode: input.sheetCode } : {}),
185
+ platformMessage: input.platformMessage,
186
+ ...(input.platformData !== undefined ? { platformData: input.platformData } : {}),
187
+ ...(input.platformDataTruncated === true ? { platformDataTruncated: true } : {}),
188
+ likelyCause: "platform-server-error",
189
+ candidateCauses: [
190
+ "表单行数据损坏:sortKey/createdTime 为 null(平台排序/取最新行时的 NPE)",
191
+ "应用函数或 schema 缺失:bizsheet 行还在,但 app function / bizschema 已不存在",
192
+ "initSubTip / 序列化失败:表单历史或 JSON 列无法反序列化",
193
+ "规模/资源:字段或控件数过大导致服务端超时/内存不足(待真机采样确认;不是已知阈值)",
194
+ ],
195
+ disclosure: "平台 50000 是 SERVER_ERROR 兜底,没有字段级明细;full/controls/artifact 只改回执投影、不改 wire,换读法不会绕过它。",
196
+ nextCommands: [
197
+ `omc call form.list --env ${env} --args '{"schemaCode":"${input.schemaCode}","detail":false}'`,
198
+ `omc call field.list --env ${env} --args '{"schemaCode":"${input.schemaCode}","published":true}'`,
199
+ ],
200
+ nextAction: "先跑 nextCommands[0](form.list,detail:false)看是否所有表单共享同一个 50000;再按清单逐 sheetCode 重试 form.get;仍 50000 就查 launcher log_error.log 与浏览器网络面板截图,按 candidateCauses 逐条排除——不要靠 full/controls 反复重试。",
201
+ message: `${input.surface} 返回 errcode ${input.errcode}(平台 SERVER_ERROR 兜底,不是字段数阈值):这是平台服务端错误,不是参数形状问题。先 form.list 区分共享排序问题,再逐 sheetCode 重试;仍 50000 查 launcher 日志/浏览器网络面板截图。`,
202
+ ...(input.fallback !== undefined ? { fallback: input.fallback } : {}),
203
+ };
204
+ }
205
+ /**
206
+ * 只读兜底读:runtime/get_biz_sheet 与 bizsheet/get 返回同一 BizFormModel 行。
207
+ * null / 非对象 / 50000 / PRINT_TEMPLATE 都不算成功(PRINT_TEMPLATE 的
208
+ * settingPrint 槽位语义在 runtime 面不完整,明确排除)。
209
+ */
210
+ async function readRuntimeFormSheet(session, schemaCode, sheetCode) {
211
+ try {
212
+ const result = await wireCall(session, { path: FORM_RUNTIME_SHEET_PATH, query: { schemaCode, sheetCode } });
213
+ const data = result.data;
214
+ if (data === null || data === undefined || typeof data !== "object" || Array.isArray(data))
215
+ return { outcome: "null" };
216
+ const sheet = data;
217
+ if (Number(sheet.formType) === 2 || sheet.formType === "PRINT_TEMPLATE")
218
+ return { outcome: "print-template" };
219
+ return { outcome: "ok", sheet };
220
+ }
221
+ catch (error) {
222
+ if (error instanceof WireError)
223
+ return { outcome: "failed", error };
224
+ throw error;
225
+ }
226
+ }
227
+ /** 成功降级面共用的元数据(必须让读者知道这是降级、少了哪些校验)。 */
228
+ function degradedFormReadMeta(platformError, platformData, platformDataTruncated) {
229
+ return {
230
+ source: "runtime/form/get_biz_sheet",
231
+ degraded: true,
232
+ degradedReason: "bizsheet/get 返回 50000(平台 SERVER_ERROR 兜底);改用 runtime/form/get_biz_sheet 读同一 BizFormModel 行",
233
+ platformError: {
234
+ errcode: FORM_SERVER_ERROR_ERRCODE,
235
+ message: platformError.message,
236
+ ...(platformData !== undefined ? { platformData } : {}),
237
+ ...(platformDataTruncated === true ? { platformDataTruncated: true } : {}),
238
+ },
239
+ degradedNote: "降级只读面:平台未执行 checkBizForm/errorMsgList/initSubTip(不含 version),也不含 PRINT_TEMPLATE 槽位;form.draft/form.publish 等写工具不会使用此兜底(仍会硬失败)。",
240
+ };
241
+ }
150
242
  /**
151
243
  * `--full` 的小体量布局摘要(控件码 + 行分组)。只在**加起来很小**时才给:
152
244
  * 目的本来是"省一次默认面往返",一旦它自己变大就成了新的负担。
@@ -195,7 +287,43 @@ export function registerFormLane(tools) {
195
287
  const sheetCode = resolveSheetCode(args.schemaCode, args.sheetCode);
196
288
  // issue 04:缺失表单统一回 present:false + hint(与 onlinejs.get 同形)。
197
289
  // 裸 wireCall 会把 302024 变成工具错误、把「没有这个表单」读成「没有按钮」。
198
- const sheet = await readFormOrNull(session, args.schemaCode, sheetCode);
290
+ let sheet;
291
+ let degraded;
292
+ try {
293
+ sheet = await readFormOrNull(session, args.schemaCode, sheetCode);
294
+ }
295
+ catch (error) {
296
+ if (!(error instanceof WireError) || error.errcode !== FORM_SERVER_ERROR_ERRCODE)
297
+ throw error;
298
+ // F7:50000 是平台兜底错误。先试只读兜底(同 BizFormModel 行),
299
+ // 失败/null/PRINT_TEMPLATE 才回结构化拒绝。写面不走这条路径。
300
+ const payload = typeof error.payload === "string" && error.payload.trim() !== "" ? truncateUtf8(error.payload, 2048) : undefined;
301
+ const fallback = await readRuntimeFormSheet(session, args.schemaCode, sheetCode);
302
+ const fallbackRef = {
303
+ source: "runtime/form/get_biz_sheet",
304
+ attempted: true,
305
+ outcome: fallback.outcome,
306
+ ...(fallback.outcome === "print-template" ? { reason: "PRINT_TEMPLATE 的 settingPrint 槽位语义在 runtime 面不完整,明确不走兜底" } : {}),
307
+ ...(fallback.outcome === "failed" && fallback.error !== undefined
308
+ ? { errcode: fallback.error.errcode, message: fallback.error.message }
309
+ : {}),
310
+ };
311
+ if (fallback.outcome !== "ok") {
312
+ return formServerErrorRefusal({
313
+ blocker: "form-get-server-error",
314
+ surface: "bizsheet/get",
315
+ schemaCode: args.schemaCode,
316
+ sheetCode,
317
+ ...(args.environment !== undefined ? { environment: args.environment } : {}),
318
+ errcode: FORM_SERVER_ERROR_ERRCODE,
319
+ platformMessage: error.message,
320
+ ...(payload !== undefined ? { platformData: payload.text, platformDataTruncated: payload.truncated } : {}),
321
+ fallback: fallbackRef,
322
+ });
323
+ }
324
+ sheet = fallback.sheet;
325
+ degraded = degradedFormReadMeta(error, payload?.text, payload?.truncated);
326
+ }
199
327
  if (!sheet) {
200
328
  return {
201
329
  schemaCode: args.schemaCode,
@@ -273,6 +401,9 @@ export function registerFormLane(tools) {
273
401
  flagNote: "平台布尔与内容不一致:顶层 published/existDraft 已按 faces 内容面结论给出(内容优先);platformFlags 保留 bizsheet/get 原始标记位供排查(会滞后)。以 faces/effectiveFace 为准:published*Json 内容才是运行时面,旗标不拿来做结论。",
274
402
  }
275
403
  : {}),
404
+ // F7:50000 后的只读兜底。放 base 里,full/controls/默认面与 compact
405
+ // 都同形;写工具不会走到这里(readFormOrNull 保持硬失败)。
406
+ ...(degraded ?? {}),
276
407
  };
277
408
  if (args.full === true)
278
409
  return {
@@ -394,7 +525,7 @@ export function registerFormLane(tools) {
394
525
  // `platformFlagsCount:2`,平台原文恰好在降载时丢失。
395
526
  // issue #57:decorations 是**证据行集**(key/type/html/row),压成码表就
396
527
  // 丢掉了「用户加了什么描述块」这个答案;payload 已按 1800B 自限。
397
- const KEEP = new Set(["draftControls", "publishedControls", "customButtonJson", "options", "formButtons", "formButtonCodes", "platformFlags", "childColumnLocator", "decorations"]);
528
+ const KEEP = new Set(["draftControls", "publishedControls", "customButtonJson", "options", "formButtons", "formButtonCodes", "platformFlags", "childColumnLocator", "decorations", "platformError"]);
398
529
  // r28e F4 暴露的潜在 bug:handler 已经交过 `*Codes`/`*Count`/`*Omitted`
399
530
  // 这类**已压缩**的键,若再走数组分支会被二次加后缀
400
531
  // (`publishedControlCodes` → `publishedControlCodesCodes`),字段直接消失。
@@ -472,6 +603,21 @@ export function registerFormLane(tools) {
472
603
  // 版本族没有 /list:只能验证默认槽。明确标注是推断,不伪装成清单。
473
604
  sheetListUnavailable = true;
474
605
  }
606
+ else if (error instanceof WireError && error.errcode === FORM_SERVER_ERROR_ERRCODE) {
607
+ // F5:与 form.get 共用同一张决策树。50000 是平台兜底错误,
608
+ // 不折成空清单(空清单会被读成「这个模型没有表单」)。
609
+ const payload = typeof error.payload === "string" && error.payload.trim() !== "" ? truncateUtf8(error.payload, 2048) : undefined;
610
+ return formServerErrorRefusal({
611
+ blocker: "form-list-server-error",
612
+ surface: "bizsheet/list",
613
+ schemaCode: args.schemaCode,
614
+ ...(args.environment !== undefined ? { environment: args.environment } : {}),
615
+ errcode: FORM_SERVER_ERROR_ERRCODE,
616
+ platformMessage: error.message,
617
+ ...(payload !== undefined ? { platformData: payload.text, platformDataTruncated: payload.truncated } : {}),
618
+ fallback: { source: "runtime/form/get_biz_sheet", attempted: false, reason: "form.list 是清单面;runtime 只回单张表单,不能替代清单" },
619
+ });
620
+ }
475
621
  else
476
622
  throw error;
477
623
  }
@@ -9,10 +9,25 @@ import { WireError, wireCall, wireRows } from "../../wire.js";
9
9
  import { ENDPOINTS } from "../../endpoints.js";
10
10
  import { choiceCodesFromFieldOptions, parseOptions } from "./field-options.js";
11
11
  import { closestMatch } from "../../closest-match.js";
12
- import { familyName } from "../../field-families.js";
12
+ import { SYSTEM_FIELD_CODES, familyName } from "../../field-families.js";
13
13
  import { extractBizObjectPage } from "./shapes.js";
14
14
  import { scanPages } from "../runtime-paging.js";
15
15
  import { DEFAULT_SCAN_CONCURRENCY, isThrottleClassError, mapWithConcurrency } from "../../concurrency.js";
16
+ /**
17
+ * F3(#109):groupBy 的已发布元数据校验只认 field.list(isPublish:true),但
18
+ * 系统列(DefaultPropertyType)不在业务字段清单里,必须放行——否则
19
+ * `groupBy:"sequenceStatus"` 会被误拒。`version`/`parentId`/`sortKey` 也是
20
+ * DefaultPropertyType 的默认属性(不在 shared 的 SYSTEM_FIELD_CODES 里)。
21
+ */
22
+ const AGGREGATE_SYSTEM_GROUP_CODES = new Set([...SYSTEM_FIELD_CODES, "version", "parentId", "sortKey"]);
23
+ /**
24
+ * 平台 query/list 默认 `display=false` 时 SELECT 列集 = 列表视图 queryColumns
25
+ * (BizObjectFacadeImpl.handleQueryColumn:4155-4190,8.6.26)。视图外的业务列
26
+ * 在行对象上是「键在、值 null」——本地扫描会把它们误读成「数据全空」。
27
+ * APPEND(2) 把 customDisplayColumns 追加到视图列(同函数 4186-4193),是唯一
28
+ * 不改变视图配置就能读到目标列的 wire 形状。
29
+ */
30
+ const AGGREGATE_QUERY_DISPLAY_APPEND = 2;
16
31
  export function registerDataAggregate(tools) {
17
32
  tools.push(defineTool({
18
33
  name: "data.aggregate",
@@ -148,6 +163,31 @@ export function registerDataAggregate(tools) {
148
163
  return published;
149
164
  };
150
165
  const fieldListNext = `omc call field.list --env <env> --args '{"schemaCode":"${metaSchemaCode}","published":true}'`;
166
+ // F3(#109):groupBy 列拼错时不再静默退化成本地扫描(全 null 被读成
167
+ // 「数据全空」)。有元数据证据就零 wire 拒绝;读不到元数据(meta=null)
168
+ // 时保留扫描路径,由回执的 groupByColumnMissing 诚实披露。
169
+ const aggregateGroupByRejection = (groupBy, meta) => {
170
+ if (groupBy === undefined || meta === null)
171
+ return undefined;
172
+ if (meta.has(groupBy) || AGGREGATE_SYSTEM_GROUP_CODES.has(groupBy))
173
+ return undefined;
174
+ const catalog = [...meta].map(([code, info]) => ({ code, ...(info.name !== undefined ? { name: info.name } : {}), type: info.type }));
175
+ const didYouMean = closestMatch(groupBy, catalog.map((row) => row.code));
176
+ return {
177
+ status: "refused",
178
+ blocker: "aggregate-groupby-field-unresolved",
179
+ schemaCode: args.schemaCode,
180
+ ...(child !== undefined ? { childSchemaCode: child.childSchemaCode } : {}),
181
+ groupBy,
182
+ publishedFields: catalog.slice(0, AGGREGATE_FIELD_SAMPLE_LIMIT),
183
+ publishedFieldsTotal: catalog.length,
184
+ ...(didYouMean !== undefined ? { didYouMean: { [groupBy]: didYouMean } } : {}),
185
+ message: `groupBy 字段不在已发布元数据里:${groupBy}(本地分组要用已发布字段 code 或系统列,不做猜测)` +
186
+ (didYouMean !== undefined ? `;是否想写 ${didYouMean}` : "") +
187
+ (catalog.length === 0 ? ";该模型当前没有已发布字段" : `;已发布字段共 ${catalog.length} 个,code/名称见 publishedFields(仅列前 ${Math.min(catalog.length, AGGREGATE_FIELD_SAMPLE_LIMIT)} 个,其余用 field.list 查)`),
188
+ nextCommand: fieldListNext,
189
+ };
190
+ };
151
191
  // 数值指标:field 必须已发布且 NUMERICAL(2)——fail closed,不做类型猜测。
152
192
  if (numeric) {
153
193
  const target = args.field;
@@ -205,6 +245,9 @@ export function registerDataAggregate(tools) {
205
245
  : {}),
206
246
  };
207
247
  }
248
+ const groupByRejection = aggregateGroupByRejection(args.groupBy, meta);
249
+ if (groupByRejection !== undefined)
250
+ return groupByRejection;
208
251
  }
209
252
  // Only a USER DSL filter needs published metadata; the injected draft
210
253
  // leaf (sequenceStatus) has a platform-fixed propertyType.
@@ -340,7 +383,13 @@ export function registerDataAggregate(tools) {
340
383
  mode: "local-scan-child",
341
384
  coverage: { complete, pageSize, maxPages, truncated },
342
385
  child: { childSchemaCode: child.childSchemaCode, bizObjectId: child.bizObjectId },
343
- ...(value === null ? { note: "no numeric values in scanned child rows" } : {}),
386
+ ...(value === null
387
+ ? {
388
+ note: count > 0 && nonNullCount === 0
389
+ ? `扫描到 ${count} 行但非空数值为 0:不是「没有数据」——${target} 可能不在子表投影列(columns 已请求目标列;仍为空则可能是权限)或该列确实全为空;先用 data.load 核对单条真值。`
390
+ : "no numeric values in scanned child rows",
391
+ }
392
+ : {}),
344
393
  filter: childDraftFilter,
345
394
  ...(complete ? {} : { capNotice }),
346
395
  ...(readFailure !== undefined ? { partial: true, readFailure } : {}),
@@ -350,15 +399,25 @@ export function registerDataAggregate(tools) {
350
399
  },
351
400
  };
352
401
  }
353
- const queryBody = (size, page) => ({
402
+ const queryBody = (size, page, projected) => ({
354
403
  schemaCode: args.schemaCode,
355
- queryCode: args.schemaCode,
404
+ // M1(与 data.list 同口径):省略 queryCode = 平台解析默认视图
405
+ // (BizObjectFacadeImpl.getQueryCodeFromQuery:5805-5822,showOnPc 优先)。
406
+ // 旧版硬塞 queryCode=schemaCode 会在没有同名视图时把请求打成
407
+ // 303001/空视图,和 data.list 的行为不一致。
356
408
  filters: [],
357
409
  mobile: false,
358
410
  page,
359
411
  size,
360
412
  queryVersion: 1,
361
413
  showTotal: true,
414
+ // F3(#109):本地扫描必须把目标列追加进 SELECT。平台 query/list 默认
415
+ // display=false 只取视图列(BizObjectFacadeImpl.handleQueryColumn:4155-4190),
416
+ // 视图外的 groupBy/数值列会一律回 null。APPEND(2) = 视图列 ∪
417
+ // customDisplayColumns(同函数 4186-4193),不动视图配置。
418
+ ...(projected !== undefined && projected.length > 0
419
+ ? { options: { queryDisplayType: AGGREGATE_QUERY_DISPLAY_APPEND, customDisplayColumns: [...new Set(projected)] } }
420
+ : {}),
362
421
  ...(condition !== undefined ? { queryCondition: condition } : {}),
363
422
  });
364
423
  const countAt = async (extraLeaf) => {
@@ -375,6 +434,8 @@ export function registerDataAggregate(tools) {
375
434
  if (numeric) {
376
435
  const target = args.field;
377
436
  const groupBy = args.groupBy;
437
+ // F3(#109):APPEND 目标列 = 数值列 +(可选)分组列。
438
+ const projection = groupBy === undefined ? [target] : [target, groupBy];
378
439
  const emptyAcc = () => ({ count: 0, nonNullCount: 0, sum: 0, min: Number.POSITIVE_INFINITY, max: Number.NEGATIVE_INFINITY });
379
440
  const overall = emptyAcc();
380
441
  const nullBucket = emptyAcc();
@@ -382,7 +443,7 @@ export function registerDataAggregate(tools) {
382
443
  const numericMetric = metric;
383
444
  // D5:首页探针同时给出 total(是否值得走 /sum)和本地扫描的首页行
384
445
  // (回退零额外读)。只有「无 groupBy + total 已知且 > 一页」才考虑 /sum。
385
- const probe = await wireCall(session, { path: ENDPOINTS.runtimeQueryList, method: "POST", body: queryBody(AGGREGATE_PAGE_SIZE, 0) });
446
+ const probe = await wireCall(session, { path: ENDPOINTS.runtimeQueryList, method: "POST", body: queryBody(AGGREGATE_PAGE_SIZE, 0, projection) });
386
447
  const probePage = extractBizObjectPage(probe.data);
387
448
  let strategyFallback;
388
449
  let guardCalls = 0;
@@ -404,7 +465,13 @@ export function registerDataAggregate(tools) {
404
465
  count: total,
405
466
  nonNullCount,
406
467
  nullCount: Math.max(0, total - nonNullCount),
407
- ...(sum.value === null ? { note: "no numeric values in matched rows" } : {}),
468
+ ...(sum.value === null
469
+ ? {
470
+ note: total > 0 && nonNullCount === 0
471
+ ? `查询命中 ${total} 行但非空数值为 0:不是「没有数据」——${target} 在库里的值可能确实全为空(服务端聚合不经过视图投影);先 data.load 核对单条真值,再决定是否改口径。`
472
+ : "no numeric values in matched rows",
473
+ }
474
+ : {}),
408
475
  coverage: { mode: "server-aggregate", rowsScanned: 0, cap: null, complete: true },
409
476
  filter: draftFilter,
410
477
  wire: {
@@ -428,7 +495,7 @@ export function registerDataAggregate(tools) {
428
495
  fetchPage: async (pageIndex) => {
429
496
  if (pageIndex === 0)
430
497
  return { totalKnown: probePage.totalKnown, total: probePage.total, content: probePage.content };
431
- const response = await wireCall(session, { path: ENDPOINTS.runtimeQueryList, method: "POST", body: queryBody(AGGREGATE_PAGE_SIZE, pageIndex) });
498
+ const response = await wireCall(session, { path: ENDPOINTS.runtimeQueryList, method: "POST", body: queryBody(AGGREGATE_PAGE_SIZE, pageIndex, projection) });
432
499
  const pageData = extractBizObjectPage(response.data);
433
500
  return { totalKnown: pageData.totalKnown, total: pageData.total, content: pageData.content };
434
501
  },
@@ -493,7 +560,13 @@ export function registerDataAggregate(tools) {
493
560
  count: overall.count,
494
561
  nonNullCount: overall.nonNullCount,
495
562
  nullCount: overall.count - overall.nonNullCount,
496
- ...(value === null ? { note: "no numeric values in scanned rows" } : {}),
563
+ ...(value === null
564
+ ? {
565
+ note: overall.count > 0
566
+ ? `扫描到 ${overall.count} 行但非空数值为 0:不是「没有数据」——${target} 可能不在列表视图投影列(平台 query/list 默认只取视图列;也可能被权限屏蔽),或该列在已扫行里确实全为空。用 data.load 核对单条真值;要把该列纳入扫描,把 ${target} 加进列表视图后重跑。`
567
+ : "no rows matched the query (count=0)",
568
+ }
569
+ : {}),
497
570
  coverage,
498
571
  filter: draftFilter,
499
572
  ...(complete ? {} : { capNotice }),
@@ -511,6 +584,19 @@ export function registerDataAggregate(tools) {
511
584
  return right.value - left.value || left.key.localeCompare(right.key);
512
585
  });
513
586
  const shown = ranked.slice(0, topN);
587
+ // F3(#109):桶全空且所有行都落在 null 桶——不是「数据全空」,而是
588
+ // groupBy 列没被投影(视图列/权限)的典型形状。诚实点名,给核对命令。
589
+ const groupByColumnMissing = buckets.size === 0 && overall.count > 0 && nullBucket.count === overall.count
590
+ ? {
591
+ groupBy,
592
+ total,
593
+ rowsScanned,
594
+ nullBucketCount: nullBucket.count,
595
+ message: `groupBy 列 ${groupBy} 在扫描到的 ${rowsScanned} 行里全部为空:平台 query/list 默认只返回列表视图列(也可能被权限屏蔽),该列很可能不在投影里——这不等于「数据全空」。把 ${groupBy} 加进列表视图(listview.configure)后重跑,或先用 data.load 核对单条真值。`,
596
+ nextCommand: `omc call data.list --env <env> --args '{"schemaCode":"${args.schemaCode}","size":1}'`,
597
+ verifyCommand: `omc call data.load --env <env> --args '{"schemaCode":"${args.schemaCode}","bizObjectId":"<data.list 的 row.bizObjectId>"}'`,
598
+ }
599
+ : undefined;
514
600
  return {
515
601
  schemaCode: args.schemaCode,
516
602
  metric,
@@ -523,6 +609,7 @@ export function registerDataAggregate(tools) {
523
609
  bucketsTruncatedCount: ranked.length - shown.length,
524
610
  coverage,
525
611
  filter: draftFilter,
612
+ ...(groupByColumnMissing !== undefined ? { groupByColumnMissing } : {}),
526
613
  ...(complete ? {} : { capNotice }),
527
614
  ...(strategyFallback !== undefined ? { strategyFallback } : {}),
528
615
  wire,
@@ -541,15 +628,19 @@ export function registerDataAggregate(tools) {
541
628
  };
542
629
  }
543
630
  // 2/3) groupBy:值域可枚举 → 值域×count;否则 1 列投影本地扫描。
631
+ const groupByColumn = args.groupBy;
544
632
  const meta = await fieldMeta();
545
- const groupField = meta?.get(args.groupBy);
633
+ const groupByRejection = aggregateGroupByRejection(groupByColumn, meta);
634
+ if (groupByRejection !== undefined)
635
+ return groupByRejection;
636
+ const groupField = meta?.get(groupByColumn);
546
637
  const rawCodes = groupField?.choiceCodes ?? [];
547
638
  // 0.6.87 D4:重复 choiceCodes 会让同一值域被 count 两次,U+null 之和超过
548
639
  // base total(负 unaccounted)。按输入序去重并显式告警,不静默重复计。
549
640
  const codes = [...new Set(rawCodes)];
550
641
  const shapeWarnings = [];
551
642
  if (codes.length !== rawCodes.length)
552
- shapeWarnings.push(`choiceCodes-duplicate: groupBy ${args.groupBy} 的选项/字典码有 ${rawCodes.length - codes.length} 个重复(${rawCodes.length}→${codes.length}),已去重;否则同一值域会被重复计数`);
643
+ shapeWarnings.push(`choiceCodes-duplicate: groupBy ${groupByColumn} 的选项/字典码有 ${rawCodes.length - codes.length} 个重复(${rawCodes.length}→${codes.length}),已去重;否则同一值域会被重复计数`);
553
644
  if (groupField && Number.isInteger(groupField.type) && codes.length > 0) {
554
645
  // R88 S1:值域×count 扇出(base + 每值域 Eq + IsNull)彼此独立,走有界
555
646
  // 并发(窗口 4)。fieldMeta() 已在前一行完成,绝不进并发窗口(metaCalls
@@ -624,14 +715,14 @@ export function registerDataAggregate(tools) {
624
715
  cap: AGGREGATE_CAP,
625
716
  pageSize: AGGREGATE_PAGE_SIZE,
626
717
  fetchPage: async (pageIndex) => {
627
- const response = await wireCall(session, { path: ENDPOINTS.runtimeQueryList, method: "POST", body: queryBody(AGGREGATE_PAGE_SIZE, pageIndex) });
718
+ const response = await wireCall(session, { path: ENDPOINTS.runtimeQueryList, method: "POST", body: queryBody(AGGREGATE_PAGE_SIZE, pageIndex, [groupByColumn]) });
628
719
  const pageData = extractBizObjectPage(response.data);
629
720
  return { totalKnown: pageData.totalKnown, total: pageData.total, content: pageData.content };
630
721
  },
631
722
  });
632
723
  for (const row of scan.rows) {
633
724
  const data = row.data && typeof row.data === "object" ? row.data : row;
634
- const raw = data[args.groupBy];
725
+ const raw = data[groupByColumn];
635
726
  if (raw === null || raw === undefined)
636
727
  nullCount += 1;
637
728
  else {
@@ -644,6 +735,20 @@ export function registerDataAggregate(tools) {
644
735
  const complete = scan.complete;
645
736
  const allBuckets = [...counts].map(([key, count]) => ({ key, count })).sort((left, right) => right.count - left.count || left.key.localeCompare(right.key));
646
737
  const shown = allBuckets.slice(0, topN);
738
+ // F3(#109):桶全空且扫描到的行全部落 null 桶——典型形状是 groupBy 列
739
+ // 没被投影(视图列/权限),不是「数据全空」。即使 total 未知(未翻到
740
+ // 全集),只要所有已扫行都为 null 也点名,避免把假空当结论。
741
+ const groupByColumnMissing = allBuckets.length === 0 && rowsScanned > 0 && (nullCount === total || nullCount === rowsScanned)
742
+ ? {
743
+ groupBy: groupByColumn,
744
+ total,
745
+ rowsScanned,
746
+ nullBucketCount: nullCount,
747
+ message: `groupBy 列 ${groupByColumn} 在扫描到的 ${rowsScanned} 行里全部为空:平台 query/list 默认只返回列表视图列(也可能被权限屏蔽),该列很可能不在投影里——这不等于「数据全空」。把 ${groupByColumn} 加进列表视图(listview.configure)后重跑,或先用 data.load 核对单条真值。`,
748
+ nextCommand: `omc call data.list --env <env> --args '{"schemaCode":"${args.schemaCode}","size":1}'`,
749
+ verifyCommand: `omc call data.load --env <env> --args '{"schemaCode":"${args.schemaCode}","bizObjectId":"<data.list 的 row.bizObjectId>"}'`,
750
+ }
751
+ : undefined;
647
752
  return {
648
753
  schemaCode: args.schemaCode,
649
754
  metric: "count",
@@ -661,6 +766,7 @@ export function registerDataAggregate(tools) {
661
766
  ...(total === null ? {} : { missingCount: Math.max(0, total - rowsScanned) }),
662
767
  },
663
768
  filter: draftFilter,
769
+ ...(groupByColumnMissing !== undefined ? { groupByColumnMissing } : {}),
664
770
  ...(complete ? {} : {
665
771
  capNotice: total !== null
666
772
  ? `值域非可枚举:已扫前 ${rowsScanned}/${total} 行,桶只覆盖已扫部分(complete:false,非全集)。要全集:filters 按日期/业务键 gte/lt 分片重跑,或 page/size 手动翻页。`
@@ -110,7 +110,8 @@ export function registerDataSave(tools) {
110
110
  const prepared = await prepareRuntimeFormData(session, args.schemaCode, rawSaveData, { isUpdate: saveIsUpdate, assignChildSortKeys: !saveIsUpdate });
111
111
  const formData = prepared.formData;
112
112
  const writeDiagnostics = { ...ignoredNullDiagnostic(formData), ...unknownFieldDiagnostic(formData, prepared.fieldCodes, prepared.childCodes, prepared.schemaLoaded) };
113
- // issue #100:选择字段的伴生 `<f>_key` 只做写前告警(平台会重算,OMC 不代写)。
113
+ // issue #100:选择字段的伴生 `<f>_key` 只做写前告警(2.1.5 普通 form/save 不反推该键、
114
+ // 缺键通常保持空;OMC 不代写;8.6 是否反推需真机复核)。
114
115
  // 复用 prepare 已读的 field.list(meta),成功路径零新增 wire。
115
116
  const optionWarnings = optionKeyWarnings(prepared.meta, formData);
116
117
  // issue#9 C1 + issue#10 勘误:提交面(submit:true / data.submit)的人员字段
@@ -341,9 +342,12 @@ export function registerDataSave(tools) {
341
342
  // submit:true 时已有 submitRefused,抑制本键避免同现两个 blocker 名。
342
343
  const workflowInstanceNote = publishedWorkflow && !saveIsUpdate && args.submit !== true
343
344
  ? {
344
- blocker: "plain-save-no-workflow-instance",
345
+ // F5(w57 探针 AB):保存本身是成功的——这不是 blocker,只是「以后
346
+ // 不能直接提交」的信息。用 code/severity 表述,避免调用方读成失败。
347
+ code: "plain-save-no-workflow-instance",
348
+ severity: "info",
345
349
  workflowCode: publishedWorkflow,
346
- message: `本行是普通草稿、没有流程实例(本次 data.save 未带 workflowCode),之后无法 data.submit——submit 面会回 submit-existing-workflow-unsupported:` +
350
+ message: `已保存为普通草稿、没有流程实例(本次 data.save 未带 workflowCode),之后无法 data.submit——submit 面会回 submit-existing-workflow-unsupported:` +
347
351
  `8.6.26 没有 REST in-place 流程发起(submitWorkflowByWorkflowCode → createAndGetBizObject INSERT → 40000 duplicate primary key)。` +
348
352
  `要可提交请重新建流程草稿:data.save {schemaCode:"${args.schemaCode}", workflowCode:"${publishedWorkflow}", formData:{...}}(formData 不要带 id),再从回执 performed 取 bizObjectId/workItemId/workflowInstanceId。`,
349
353
  nextCommand: `omc call data.save --env <env> --args '{"schemaCode":"${args.schemaCode}","workflowCode":"${publishedWorkflow}","formData":{...}}'`,
@@ -774,14 +774,17 @@ export function childSortKeyOutOfRangeWarnings(formData, childCodes, existingRec
774
774
  return warnings;
775
775
  }
776
776
  /**
777
- * Advisory only (issue #100): 8.6 mirrors every RADIO(12)/DROPDOWN(14) value into
778
- * a `<field>_key` companion column through
779
- * `OptionKeySupportImpl.getValueKeyMap` (8.6.26 :164-183). 2.1.5 live (w53,
780
- * 2026-12-05) does NOT recompute that key on a Facade write — a supplied wrong
781
- * key is persisted as-is (save readback + data.load both returned the wrong
782
- * key). OMC never writes the companion key; it only tells the caller when a
783
- * hand-built payload has a value without one (or a key that disagrees with the
784
- * readable snapshot).
777
+ * Advisory only (issue #100): 8.6 *may* mirror a RADIO(12)/DROPDOWN(14) value into
778
+ * a `<field>_key` companion column via
779
+ * `OptionKeySupportImpl.getValueKeyMap`/`setOptionsKey` (8.6.26 :164-183), but
780
+ * that path is only called by rule assignment / workflow child instances / import
781
+ * — NOT by the ordinary form/save facade. 2.1.5 live (w53, 2026-12-05):
782
+ * `BizObjectManagerImpl.insertBizObject/updateBizObject` has no companion-key write,
783
+ * so a missing key usually stays empty; a supplied wrong key is persisted as-is
784
+ * (save readback + data.load both returned it). OMC never writes the companion key;
785
+ * the warning only tells the caller when a hand-built payload has a value without
786
+ * one (or a key that disagrees with the readable snapshot), so a key-based filter
787
+ * can opt to supply it explicitly.
785
788
  */
786
789
  export function optionKeyWarnings(meta, formData, row = 1) {
787
790
  if (!meta)
@@ -806,9 +809,10 @@ export function optionKeyWarnings(meta, formData, row = 1) {
806
809
  keyField: keyCode,
807
810
  value: String(value),
808
811
  optionSource: map.source,
812
+ usuallyNoAction: true,
809
813
  ...(suggested !== undefined ? { suggestedKey: suggested } : {}),
810
- message: `字段 ${code} 传了值 "${String(value)}" 但没有伴生键 ${keyCode}。平台写面会按选项集反推并补写该键(OptionKeySupportImpl);` +
811
- `本工具**不代写**。${suggested !== undefined ? `按当前${map.source === "snapshot" ? "字典快照" : "自定义选项"}可推出 ${keyCode}="${suggested}",需要就显式带上。` : map.source === "unresolved" ? `选项来源(businessModel)无法离线解析,本次给不出建议键。` : ""}`.trim(),
814
+ message: `字段 ${code} 传了值 "${String(value)}" 但没有伴生键 ${keyCode}。通常无需处理:2.1.5 普通 form/save 不反推该键(CLI 不代写),缺键列通常保持空;8.6 是否反推需真机复核。` +
815
+ `${suggested !== undefined ? `按当前${map.source === "snapshot" ? "字典快照" : "自定义选项"}可推出 ${keyCode}="${suggested}";若后续按 key 筛选/规则比较,显式带 ${keyCode}。` : map.source === "unresolved" ? `选项来源(businessModel)无法离线解析,本次给不出建议键。` : ""}`.trim(),
812
816
  });
813
817
  continue;
814
818
  }
@@ -839,6 +839,8 @@ const REFUSAL_DIAGNOSTIC_KEYS = new Set([
839
839
  "blocker",
840
840
  "message",
841
841
  "nextCommand",
842
+ // F3(w57):锁冲突参数被安全省略时的披露键,属诊断面而非载荷。
843
+ "nextCommandArgsOmitted",
842
844
  "nextAction",
843
845
  "errcode",
844
846
  "platformErrcode",
@@ -72,6 +72,9 @@ const ALWAYS_INLINE_KEYS = new Map([
72
72
  ["notScanned", 2000],
73
73
  ["note", 1200],
74
74
  ["scanNote", 1200],
75
+ // F3(#109):groupBy 全 null 的判别信号 + 核对命令必须在 compact 下活着;
76
+ // 被折成 {count,sha256,omitted} 后就只剩「空桶」,agent 仍会读成「数据全空」。
77
+ ["groupByColumnMissing", 2000],
75
78
  ["doNot", 600],
76
79
  ["scanned", 600],
77
80
  ["coverage", 1200],
@@ -85,6 +88,9 @@ const ALWAYS_INLINE_KEYS = new Map([
85
88
  // #77.2:withDraft 的「app 面会补建 7 条预置」披露是教学键——compact 折叠
86
89
  // 成 {length,sha256,omitted} 后,调用方看不到自己多出来的预置行是怎么来的。
87
90
  ["draftNote", 1200],
91
+ // F4(探针 AB P2):DRAFT 面补建预置的 opt-in 判据 + 可复制命令必须活到 compact;
92
+ // 折叠成 {count,sha256,omitted} 后调用方会以为 `withDraft` 已读完 DRAFT 面。
93
+ ["wouldCreatePresets", 1200],
88
94
  ]);
89
95
  /** Config-inventory keys that compact to a code list (not a bare count). */
90
96
  const CODE_LIST_KEYS = new Set(["fields", "columns", "conditions", "sorts", "datarules", "buttons", "views", "sheets"]);
@@ -178,12 +178,12 @@ const READ_SHAPES = {
178
178
  ],
179
179
  },
180
180
  "rule.list": {
181
- keys: ["rules:array<{code,name,enabled,status,ruleVersion,defaultRule,preset,mappings?,mappingsUnavailable?,publishEnabled?,draftEnabled?,draftStatus?,executable?,executableBasis?,draftOnly?}>", "rulesCount", "modelPresent", "source", "executableHint", "draftFace?/draftRowsCount?/draftNote?", "mappingsWireNote?", "schemaCodes?/modelsCount?/models?/partial?/failed?/absentModels?"],
181
+ keys: ["rules:array<{code,name,enabled,status,ruleVersion,defaultRule,preset,mappings?,mappingsUnavailable?,publishEnabled?,draftEnabled?,draftStatus?,executable?,executableBasis?,draftOnly?}>", "rulesCount", "modelPresent", "source", "executableHint", "draftFace?/draftRowsCount?/draftNote?", "draftFaceSkipped?/wouldCreatePresets?/presetFillConfirmed?", "mappingsWireNote?", "schemaCodes?/modelsCount?/models?/partial?/failed?/absentModels?"],
182
182
  notes: [
183
183
  "入参/他面叫 ruleCode,本面返回 rules[].code",
184
184
  "source=published-list:enabled/status 来自 PUBLISH 投影;可执行性看 rule.get / rule.enable.verified",
185
- "withDraft:true 追加 app DRAFT 面(+1 wire,规则<7 时平台可能补建 7 条预置;回执 draftNote 披露):逐行 publishEnabled/draftEnabled/draftStatus/executable/executableBasis,并补入 PUBLISH 清单看不到的禁用/草稿行(draftOnly:true,enabled/status 为 null)。executable 按平台 getExecutableBySchemaCodeAndCode:DEFAULT 需 DRAFT enabled=true、status!=DISABLED、至少 1 条 latestPublished;CODING/DECISION 只要求 DRAFT 存在",
186
- "modelPresent:false 时未发 list(避免幻影 schema 补建 7 条预置)",
185
+ "withDraft:true 时 published 清单 <7 且未传 ensurePresets:true → 默认跳过 app DRAFT 面(写副作用门):回 draftFaceSkipped:\"preset-fill-guard\" + wouldCreatePresets;ensurePresets:true 才真正读 DRAFT 面(+1 wire)并回 presetFillConfirmed:true,≥7 时不需要该确认。DRAFT 面逐行 publishEnabled/draftEnabled/draftStatus/executable/executableBasis,并补入 PUBLISH 清单看不到的禁用/草稿行(draftOnly:true,enabled/status 为 null)。executable 按平台 getExecutableBySchemaCodeAndCode:DEFAULT 需 DRAFT enabled=true、status!=DISABLED、至少 1 条 latestPublished;CODING/DECISION 只要求 DRAFT 存在",
186
+ "modelPresent:false 时未发 list(避免幻影 schema 补建预置)",
187
187
  "withMappings:true 时每行带 mappings[]={nodeCode,serviceCode,serviceMethodCode,inputCount,outputCount}(摘要,正文 inputMappings/outputMappings 用 rule.get);行里读不到图 → mappingsUnavailable:true(≠没有映射)",
188
188
  "schemaCodes[] 跨模型清单:models[] 每元素与单模型回执同形(含 modelPresent:false/rulesCount;三句提示抬到顶层 crossModelNotes,逐模型相同不重复),失败汇总在 failed[](partial:true);上限 20 个模型",
189
189
  ],
@@ -135,7 +135,7 @@ const numericPercent = Object.freeze({
135
135
  ],
136
136
  conditionalRequirements: [
137
137
  "`options.format` 必须是平台常量:百分比 `ratio`(20%)/`ratio.tenths`(20.0%)/`ratio.percentile`(20.00%),普通数字 `integer/tenths/percentile…`,货币 `RMB./dollar./euro./HK.` 前缀,`none`=裸值;`percentile` 是两位小数**不是**百分比。全表见 `omc contract field-families` 的 numericalFormat。",
138
- "`scale` 与小数据对齐(两位百分比 = `scale:2`+`ratio.percentile`);只写 scale 门户显示 `2,000.00` 普通数字。别名 percent/currency/¥ 由 CLI 归一为常量再落库;**别绕过 CLI 把 `percent` 写进字段行**——平台字面读不懂,门户跌回裸值(真机 r64b:format:\"percent\" → `0.5`)。",
138
+ "`scale` 与小数据对齐(两位百分比 = `scale:2`+`ratio.percentile`);只写 scale 门户显示 `2,000.00` 普通数字。别名 percent/currency/¥ 由 CLI 归一为常量再落库;**别绕过 CLI 把 `percent` 写进字段行**——平台读不懂,门户跌回裸值(r64b:format:\"percent\"→`0.5`)。",
139
139
  "生效:字段行 format 优先于表单控件,`field.publish` 即生效(无需重建表单);列表另是一套列枚举。",
140
140
  ],
141
141
  priorToolReferences: [
@@ -253,7 +253,7 @@ const childTable = Object.freeze({
253
253
  */
254
254
  const childTableParentFieldFill = Object.freeze({
255
255
  id: "child-map-fill",
256
- title: "子表取主表",
256
+ title: "子表取主表(快照标量列 + 关联列,两个字段)",
257
257
  aliases: ["取主表", "关联填充"],
258
258
  status: "requires-prior-readback",
259
259
  tool: "field.create",
@@ -272,20 +272,22 @@ const childTableParentFieldFill = Object.freeze({
272
272
  },
273
273
  },
274
274
  preconditions: [
275
+ "**这是两个字段**:先在子表 schemaCode 建并发布快照标量列(code=target、propertyType=与 source 同族的标量;关联/子表/附件不能当快照标量),再建 WORK_SHEET 关联列。",
275
276
  "**子表子 schema code = 父模型 CHILD_TABLE(8) 字段的 code**(父字段 code 为 `items` 时 schemaCode 就是 `items`),不是 `<model>_items` 约定名:`omc call field.list --args '{\"schemaCode\":\"<父模型>\"}'` 找 type:8 字段的 code;同一口径见 `omc contract field-families` 的 `childTableSubSchema`。**任务书要 `<model>_items` 时,直接把父字段 code 命名成 `<model>_items`**;平台不接受另起 subSchemaCode,`field.create` 回执的 childSchema 会回显实际 schemaCode。",
276
- "子表 code 全局唯一;先建并发布快照标量列,再建关联列。",
277
+ "子表 code 全局唯一。",
277
278
  "**发布用父模型 code**:`field.publish {\"schemaCode\":\"<父模型>\"}`——子表 code 会被拒(300004 → `field-publish-child-schema`);模型级一次发全部草稿字段,子表列随父模型发。",
278
279
  ],
279
280
  conditionalRequirements: [
280
281
  "映射只在门户选值时回填:CLI data.save(/api/runtime/form/save)不跑 options.mappings,快照列需调用方自填;配置正确性以字段行 options.mappings 为准。",
281
- "schemaCode 填子表(=父字段 code),发布填父模型 code——两者不是同一个 code,别互相套用。",
282
282
  "关联列必须带 relativeCode(=options.schemaCode=主模型);source=主模型字段、target=本子表列,均裸 code。",
283
283
  "关联列不能是 CHILD_TABLE/OCR/ELECTRONIC_SIGN/MULT_WORK_SHEET/RELEVANCE_DATA/FORMULA。",
284
284
  ],
285
285
  priorToolReferences: [],
286
286
  dryRun: { supported: true, command: `omc call field.create --env ${environment} --dry-run --args '<args>'`, notes: "" },
287
287
  expectedReadback: { readback: { fieldPresent: true }, next: ["field.publish {schemaCode:<父模型>}", "field.get 读回 options.mappings"] },
288
- refusalRecovery: [{ code: "relation-mapping-field-not-found", action: "source 用主模型字段、target 用本子表列,均裸 code" }],
288
+ refusalRecovery: [
289
+ { code: "relation-mapping-field-not-found", action: "两个字段两步走:① 子表 schemaCode 先建并发布快照标量列(code=target、propertyType=与 source 同族的标量;field.publish 用父模型 code);② 再建关联列。source 用主模型字段、target 用本子表列,均裸 code。示例 `omc describe field.create --example child-map-fill`" },
290
+ ],
289
291
  requiresEnvironmentDerivedIds: true,
290
292
  });
291
293
  const businessModelDropdown = Object.freeze({
@@ -315,7 +317,7 @@ const businessModelDropdown = Object.freeze({
315
317
  "来源模型的显示字段已 field.publish 并已 form.publish(未发布字段不可作为下拉来源)",
316
318
  ],
317
319
  conditionalRequirements: [
318
- "sheetDataItem 指向来源模型上真正承载业务值的字段;**不要用系统字段 name** —— 它是平台自动生成的数据标题(人名+模型名+时间),下拉项会显示这串标题而不是业务值",
320
+ "sheetDataItem 指向来源模型上真正承载业务值的字段;**不要用系统字段 name**——它是自动生成的数据标题(人名+模型名+时间),下拉项会显示标题而非业务值",
319
321
  "orderByFields/orderType 可选,用于下拉项排序;conditions 可选,用于过滤来源行",
320
322
  ],
321
323
  priorToolReferences: [
@@ -360,17 +362,17 @@ const formulaAggregationCrossModel = Object.freeze({
360
362
  },
361
363
  },
362
364
  preconditions: [
363
- "**只能汇总「别的模型」**:同模型(含自己的子表)聚合在 field.publish 必抛 305003(平台 publishFormula 把相对码改写成子表父模型 = 本模型,checkCycleOfAggregation:1032 判成环);工具拒 `aggregation-self-schema-cycle`。",
365
+ "**只能汇总「别的模型」**:同模型(含自己的子表)聚合在 field.publish 必抛 305003(publishFormula 把相对码改写成子表父模型,checkCycleOfAggregation 判成环);工具拒 `aggregation-self-schema-cycle`。",
364
366
  "目标字段用 FORMULA(100)(不是普通字段 + 计算规则——type2 计算规则在 REST 路径永不执行)。",
365
367
  "`schemaCode` 是被汇总的**来源模型**;`dataItemCode` 是来源模型的**主表标量列**(不带 schema 前缀);`queryConditions` **不能为空**,否则反向过滤器为空、找不到要回算的目标行(真机:空条件时 recalc 日志照常打印但目标字段恒为 0)。",
366
- "**不要指向子表 schema**(r18 2026-10-26 真机):`schemaCode:\"<子表>\"` 能发布,但目标模型从此**整个不可写** —— `data.submit`/`data.update` 一律回 40000「调用数据库发生异常」且无明细;而且子表 schema 没有父单单号列,按父单匹配恒为 0。`dataItemCode` 写成 `<子表>.<子列>` 则在 publish 直接 309004「使用的聚合数据项不存在」。要汇总子表:先在来源**主模型**上物化一个数值字段(门户计算规则或写入方维护),再聚合该标量。OMC 已写前拒绝 `aggregation-target-is-child-schema` / `aggregation-data-item-not-scalar`。",
368
+ "**不要指向子表 schema**(r18 真机):`schemaCode:\"<子表>\"` 能发布,但目标模型从此**整个不可写** —— `data.submit`/`data.update` 一律回 40000「调用数据库发生异常」且无明细;而且子表 schema 没有父单单号列,按父单匹配恒为 0。`dataItemCode` 写成 `<子表>.<子列>` 则在 publish 直接 309004「使用的聚合数据项不存在」。要汇总子表:先在来源**主模型**上物化一个数值字段(门户计算规则或写入方维护),再聚合该标量。OMC 已写前拒绝 `aggregation-target-is-child-schema` / `aggregation-data-item-not-scalar`。",
367
369
  ],
368
370
  conditionalRequirements: [
369
371
  "**DYNAMIC 条件的两个 code 分属两侧,写反了就静默 0**:`propertyCode` = **来源模型**的字段(这里是 r17_c.nm),`currentPropertyCode` = **目标模型**的字段(这里是 r17_d.srcNo)。语义 = 「来源行的 nm 等于本目标行的 srcNo」。",
370
372
  "`propertyType`/`currentPropertyType` 是 BizPropertyType 的**整数码**(0=SHORT_TEXT 2=NUMERICAL 9=WORK_SHEET…),`operatorType` 是 OperatorType 的**整数码**(1=EQ 6=ITEQ 9=IS_NULL 10=IS_NOT_NULL…)。写名字会被 ObjectMapperUtils 抛 json processing exception 并掩码成 305003;工具会自动转码。",
371
373
  "`calculateType` 是**字符串**(SUM/COUNT/COUNTIF/SUMIF/AVG/MAX/MIN/**LARGE/SMALL/UNION/PRODUCT**),不是枚举 code。2.1.5 新增 `PRODUCT`(累乘;8.6 无)。r18b 真机三种特殊算法:LARGE/SMALL **必须带位置参数** `LARGE({<来源>.<列>},2)`(缺 k → 平台 NumberFormatException → 目标写入 50000);**UNION 是文本拼接**,顶层 `resultType` 必须是 0/LONG_TEXT=1(写 2 会 50000,读回是去重串,如单号本身);SUM/AVG/MAX/MIN/COUNT 用 resultType:2。",
372
- "发布后平台会**自动生成一条 t100 CALCULATE_RULE 镜像行**(h_biz_data_rule,propertyCode=字段 code),它是回算触发的前置条件,别手动删。",
373
- "**回算时机(r17b 2026-10-26 真机完整行为图谱)**:① 目标行**自己 submit** 时镜像规则一定算(最可靠,不依赖事件);② 来源行 submit/update/delete 触发 `RollUpEventListener`→`FormulaPropertySupport` 事件回算——FIXED+DYNAMIC 混用、多组 OR、COUNTIF/MAX、子表行级条件(propertyCode 带 `.`)都验证过,DELETE 也会回算;③ ⚠️ 事件回算**只在目标模型发布后的几分钟内可靠**,之后静默停止(源端数据变了目标字段不更新、无报错)——重新 `field.publish --force` 目标模型即可恢复。定时巡检/对账场景务必重发或依赖目标行写入路径。",
374
+ "发布后平台**自动生成 t100 CALCULATE_RULE 镜像行**(h_biz_data_rule,propertyCode=字段 code),它是回算触发的前置条件,别手动删。",
375
+ "**回算时机(r17b 真机图谱)**:① 目标行**自己 submit** 时镜像规则一定算;② 来源行 submit/update/delete 触发 `RollUpEventListener`→`FormulaPropertySupport` 事件回算——FIXED+DYNAMIC 混用、多组 OR、COUNTIF/MAX、子表行级条件(propertyCode 带 `.`)都验证过,DELETE 也会回算;③ ⚠️ 事件回算**只在目标模型发布后的几分钟内可靠**,之后静默停止(源端数据变了目标字段不更新、无报错)——重新 `field.publish --force` 目标模型即可恢复。定时巡检/对账场景务必重发或依赖目标行写入路径。",
374
376
  ],
375
377
  priorToolReferences: [
376
378
  { tool: "field.list", args: { environment, schemaCode: "r17_c", published: true }, purpose: "确认来源模型与其列已发布,取 dataItemCode 与 DYNAMIC 条件的 propertyCode" },
@@ -457,12 +459,12 @@ const externalLookupModel = Object.freeze({
457
459
  },
458
460
  preconditions: [
459
461
  "映射模型已建且字段与接口返回字段一一对应(如 qcc_company: company_name/credit_code)",
460
- "数据段已通:接口数据已能落进映射模型表(见 conditionalRequirements 第 1 条的三个已验证组合)",
462
+ "数据段已通:接口数据能落进映射模型表(见 conditionalRequirements 第 1 条)",
461
463
  ],
462
464
  conditionalRequirements: [
463
- "**数据段首选(平台标准模式)**:映射模型的 GetList/Load 规则挂 BIZ_ACTION 实时调接口(接口方法配 frontEndExtensionEnable:true)——门户关联控件**打开即触发**前端查询链→GetList 规则→BIZ_ACTION 实时调外部接口(引擎日志 bizBusService.invoke + 外部网关日志双侧铁证)。**验证必须走门户填表;data.list 不反映此链**(r29 曾误判)。配置侧三个收尾点:① WORK_SHEET 字段必须带 relativeCode(仅 options.schemaCode 发布表单会 301015 关联业务模型为空);② GetList 规则的 BIZ_ACTION 入参映射要接前端搜索词(实测未配词时 invoke 参数为空 {});③ 出参→列表行的映射配完候选才回显(未配时弹窗 Total 0 但接口已调)。「下拉框形态(输关键字回车查询)」是表单 attributes 层的控件形态设置,默认弹窗形态。备选(不需要实时时):预置 Create/Update 规则落映射表 / TIMING 定时同步。图内「BIZ_ACTION→CREATE 落表→再查」回环在 1.1.25 不可表达,不要走这条岔路。",
465
+ "**数据段首选(平台标准模式)**:映射模型的 GetList/Load 规则挂 BIZ_ACTION 实时调接口(接口方法配 frontEndExtensionEnable:true)——门户关联控件**打开即触发**前端查询链→GetList 规则→BIZ_ACTION 实时调外部接口(引擎日志 bizBusService.invoke + 外部网关日志双侧铁证)。**验证必须走门户填表;data.list 不反映此链**。配置侧三个收尾点:① WORK_SHEET 字段必须带 relativeCode(仅 options.schemaCode 发布表单会 301015 关联业务模型为空);② GetList 规则的 BIZ_ACTION 入参映射要接前端搜索词(实测未配词时 invoke 参数为空 {});③ 出参→列表行的映射配完候选才回显(未配时弹窗 Total 0 但接口已调)。备选(不需要实时时):预置 Create/Update 规则落映射表 / TIMING 定时同步。图内「BIZ_ACTION→CREATE 落表→再查」回环在 1.1.25 不可表达,不要走这条岔路。",
464
466
  "**表单段是平台原生能力**:关联单选指向映射模型后,门户上输入关键字回车即查映射表、选中即 mappings 带出——前台填表时映射自然出现,无需按钮/脚本。",
465
- "下拉框形态在 form.draft 控件层配置;映射表要有数据下拉才有选项。",
467
+ "「下拉框形态(输关键字回车查询)」是表单 attributes 层控件形态(默认弹窗),在 form.draft 配置;映射表要有数据下拉才有选项。",
466
468
  "**关联填充映射的事实源是字段行 `options.mappings`**:改表单控件属性里的 mappings 会被平台按字段重算覆盖、回读不生效(真机 2026-10-14 中冶实证)。改映射走 `field.update` 按完整 options 提交(只改 mappings,其余键 queryCode/displayField/schemaCode/conditions… 原值保留)→ `field.publish` → `form.draft`(**rebuild:false**,保留现有布局与已挂在线JS)重存 → `form.publish` → 回读核对。**别用 cascadeRepublish 刷已带布局/在线JS 的表单**(会 rebuild 脚手架)。",
467
469
  ],
468
470
  priorToolReferences: [
@@ -475,7 +477,7 @@ const externalLookupModel = Object.freeze({
475
477
  { code: "field-family-options-invalid", action: "WORK_SHEET options 必带 schemaCode/queryCode/displayField;mappings 用数组或 JSON 字符串均可(CLI 就地归一)" },
476
478
  ...commonRecovery,
477
479
  ],
478
- notes: "r29 终轮定案:此模式是「外部数据填表带出」的平台正解;按钮触发回写是下策(多一次交互且体验差)。映射模型数据段的三个组合全部基于已验证的出参回写三前提(平铺端点/预置规则上下文/data 触发)。",
480
+ notes: "r29 定案:此模式是「外部数据填表带出」的平台正解;按钮触发回写是下策(多一次交互)。数据段三组合基于出参回写三前提。",
479
481
  requiresEnvironmentDerivedIds: true,
480
482
  });
481
483
  export const FIELD_METADATA = Object.freeze({
@@ -43,9 +43,10 @@ const basicDraftSave = Object.freeze({
43
43
  "formData 只放标量字段,不带 id(带 id 是更新既有记录的语义)",
44
44
  ],
45
45
  conditionalRequirements: [
46
- "纯草稿保存:不带 workflowCode / submit——行落为 DRAFT,不推进流程,也不触发 Create/Update 规则(DRAFT 行跳过规则分发)",
46
+ "纯草稿保存:不带 workflowCode/submit——行落为 DRAFT,不推进流程、不触发 Create/Update 规则(DRAFT 跳过分发)",
47
47
  "子表数组、关联/人员字段形状、流程草稿走 `omc describe data.save --example workflow-backed-data-save`;正式数据一调完成态用 data.submit",
48
48
  "关联字段(WORK_SHEET)在 formData 里写 `\"<relationField>\":\"<bizObjectId>\"`(`{id}` 也接受);子表行内关联列同理;人员/组织字段写数组 `[{id,type,name}]`。",
49
+ "选择字段伴生 `<code>_key`:OMC 不代写,2.1.5 普通保存不反推(缺键常空,optionKeyMissing 通常无需处理);按 key 筛选/规则比较带 suggestedKey。",
49
50
  ],
50
51
  priorToolReferences: [
51
52
  { tool: "model.list", args: { environment }, purpose: "确认 schemaCode(models[].schemaCode)" },
@@ -13,6 +13,11 @@ export class WriteLockConflictError extends Error {
13
13
  * face, `intent apply` ships the minimal owner/recovery face, and `rollback
14
14
  * apply` ships rollbackOf/waitMs/lockOwner. Freezing them here keeps the
15
15
  * per-face shapes while moving the decision to one place.
16
+ *
17
+ * F3(w57 探针 AB):single 面的 `nextCommand` 现在带本次调用的参数段
18
+ * (`nextArgs`,由 `lockRetryArgs` 安全生成)——旧命令丢了 `--args`,复制执行
19
+ * 会变成空参数调用。batch/intent/rollback 的冻结形状不变(batch 用
20
+ * `--args-list`,无法用单条 `--args` 表达)。
16
21
  */
17
22
  export function writeLockConflictReceipt(request, refused) {
18
23
  if (request.mode === "rollback") {
@@ -56,12 +61,16 @@ export function writeLockConflictReceipt(request, refused) {
56
61
  batch: true,
57
62
  };
58
63
  }
64
+ // F3(w57):single 面把本次参数带进 nextCommand,拒绝回执才是可执行命令;
65
+ // batch/intent/rollback 的三份冻结回执不变。
59
66
  return writeLockHeldFace({
60
67
  environment: request.environment,
61
68
  owner: refused.owner,
62
69
  recovery: refused.recovery,
63
70
  refusedTool: request.tool,
64
71
  waitMs: request.waitMs > 0 ? request.waitMs : 30_000,
72
+ ...(request.nextArgs !== undefined ? { nextArgs: request.nextArgs } : {}),
73
+ ...(request.nextCommandArgsOmitted !== undefined ? { nextCommandArgsOmitted: request.nextCommandArgsOmitted } : {}),
65
74
  });
66
75
  }
67
76
  /** The frozen human line per face (`rollback apply` never printed one). */
@@ -172,6 +172,7 @@ export function staleLockPresent(environment) {
172
172
  export function writeLockHeldFace(options) {
173
173
  const wait = Math.max(1_000, options.waitMs && options.waitMs > 0 ? options.waitMs : 30_000);
174
174
  const tool = options.refusedTool && options.refusedTool.length > 0 ? options.refusedTool : "<tool>";
175
+ const argsSegment = options.nextArgs !== undefined ? ` ${options.nextArgs}` : "";
175
176
  const lockOwnerFace = options.owner
176
177
  ? {
177
178
  tool: options.owner.tool ?? options.owner.command,
@@ -188,7 +189,8 @@ export function writeLockHeldFace(options) {
188
189
  retryable: true,
189
190
  owner: options.owner,
190
191
  lockOwner: lockOwnerFace,
191
- nextCommand: `omc call ${tool} --env ${options.environment} --wait ${wait}`,
192
+ nextCommand: `omc call ${tool} --env ${options.environment}${argsSegment} --wait ${wait}`,
193
+ ...(options.nextCommandArgsOmitted !== undefined ? { nextCommandArgsOmitted: options.nextCommandArgsOmitted } : {}),
192
194
  note: "不要写 shell 重试循环;用 --wait 排队",
193
195
  message: `another process holds the write lock for environment ${options.environment}(retryable:true;用 --wait 排队,不要写 shell 重试循环)`,
194
196
  recovery: options.recovery,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stalfh233/omc-cli",
3
- "version": "0.8.38",
3
+ "version": "0.8.40",
4
4
  "description": "CloudPivot 8.6 configuration capability CLI — governed, fail-closed, coverage-manifest bounded.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -58,7 +58,7 @@
58
58
  },
59
59
  "dependencies": {
60
60
  "commander": "14.0.3",
61
- "omc-core": "0.8.38",
61
+ "omc-core": "0.8.40",
62
62
  "proper-lockfile": "4.1.2",
63
63
  "write-file-atomic": "6.0.0",
64
64
  "zod": "^3.23.8",
@@ -76,6 +76,6 @@
76
76
  "directory": "packages/omc-cli"
77
77
  },
78
78
  "optionalDependencies": {
79
- "@stalfh233/omc-fake-platform": "0.8.38"
79
+ "@stalfh233/omc-fake-platform": "0.8.40"
80
80
  }
81
81
  }
@@ -5,7 +5,7 @@ description: 中文 CloudPivot 业务配置 runbook。用于把模型、字段
5
5
 
6
6
  # CloudPivot 业务配置 Runbook
7
7
 
8
- 本技能讲业务需求如何落成配置包;底层 wire 形状和白屏陷阱见 `omc-write-hazards`。
8
+ 本技能讲业务需求如何落成配置包;底层 wire 与白屏陷阱见 `omc-write-hazards`。
9
9
 
10
10
  ## 入口
11
11
 
@@ -23,7 +23,7 @@ omc help omc-five-piece-flow
23
23
 
24
24
  ## 需求五维
25
25
 
26
- 把需求拆成五个维度(注意:这是**需求维度**,不同于 `omc-five-piece-flow` 的"五件套"执行五阶段):
26
+ 按五个需求维度拆:
27
27
 
28
28
  1. **模型**:主对象、应用、业务 code。
29
29
  2. **字段**:类型、选项、关联目标、模型可空性。
@@ -40,7 +40,7 @@ omc help omc-five-piece-flow
40
40
  3. 取得用户明确确认;确认前不写环境。
41
41
  4. 需求包含运行行为时,用 CLI 真实触发;测试数据的保留/清理要写进草稿。
42
42
 
43
- 完成标准:每项资源有 readback;每个运行写入有 delivery 状态;每个映射字段都有目标值;失败步骤、已完成步骤和清理动作可追踪。
43
+ 完成标准:每项资源有 readback;每个运行写入有 delivery 状态;每个映射字段都有目标值;步骤与清理动作可追踪。
44
44
 
45
45
  ## 模型与字段
46
46
 
@@ -49,8 +49,8 @@ omc help omc-five-piece-flow
49
49
  - **code 长度平台硬限**:模型 code ≤26 字符、字段 code ≤28(`business-code-invalid` 出门校验;长业务名先起短 code,长名放 name)。
50
50
  - 模型层字段默认可空;必填、只读、可见性在表单和流程节点配置。
51
51
  - `propertyEmpty` 默认 `false`,不要把业务必填硬编码在数据模型。
52
- - **`<code>_key` 孪生列(单选/字典,8.6/2.1 同形)**:运行面成对存 `<code>`(显示值)与 `<code>_key`(字典 key),列表开 `displayBackupColumns` 才加进列集;**过滤用原字段名 + key 值**(不是显示值),否则静默 0 条(2.1.5 `BizObject.java:59`/`BizObjectFacadeImpl.java:1857`;8.6.26 `:83`/`:4182`)。
53
- - 关联单选优先读目标模型已发布字段,明确显示字段;无映射不要写空数组字符串。
52
+ - **`<code>_key` 孪生列(单选/字典,8.6/2.1 同形)**:运行面成对存 `<code>`(显示值)与 `<code>_key`(字典 key),列表需 `displayBackupColumns` 才可见;**过滤用原字段名 + key 值**(不是显示值),否则静默 0 条(2.1.5 `BizObject.java:59`/`BizObjectFacadeImpl.java:1857`;8.6.26 `:83`/`:4182`)。写入侧 OMC 不代写,2.1.5 普通保存不反推,按键筛选显式带 suggestedKey。
53
+ - 关联单选优先读目标模型已发布字段并明确显示字段;无映射勿写空数组串。
54
54
 
55
55
  ## 子表
56
56
 
@@ -212,6 +212,8 @@ only the section for the capability you need —
212
212
  - **能做哪些事**:业务记录列出、加载、保存、更新、删除、提交(工作流)、临时计数/分组统计。
213
213
  - **工具**:`data.list`、`data.aggregate`、`data.load`、`data.save`、`data.update`、`data.delete`、`data.submit`
214
214
  - **聚合/分组/计数(10 秒答案)**:计数/分组计数直接用 `data.aggregate`(`metric:"count"`)——无 groupBy 读服务端 `total`(精确、1 wire);`groupBy` 值域可枚举时按「值域×count」给各桶(V+3 wire)+ null 桶;自由文本/高基数退化为本地扫描(cap 1000,`coverage.complete:false` + `capNotice`,**不外推行数**)。手工原语仍是 `data.list size:1 + filter` 只读 `total`;跨模型汇总/定时聚合才涉及 report 章节或字段计算(datarule type2 / formula 聚合),**不要**为「数一下条数」引入 report(r60c-F11 真机 2026-11-13:统计问句的正路一句话就该给全)。
215
+ - **读面口径**:`data.list` 的 `page` **从 0 开始**(越界回 `pageOutOfRange:true` + 合法区间 hint,不是「没有数据」)。`items` 超过 10 行**且**原生回执 >2048B 时外置:此时才出现 `ids`(本页全部 id)与 `itemsPreview`,`items` 变成 `{externalized:true,count}` 指针;完整行用 `detailArtifactId` 取回(CLI 没有 `detailFile` 这个键)。
216
+ - **视图列口径**:`data.aggregate` 的本地扫描只看**列表视图列**。非视图列需要先把字段加进视图(`listview.configure`)或逐条 `data.load`;工具已自动把 groupBy/数值列按 APPEND 投影追加(`options.queryDisplayType:2`),仍全空时看 `groupByColumnMissing`(那是「未投影/权限」的判别信号,不是「数据全空」)。
215
217
  - **recipe**:
216
218
  - `omc describe data.save --example workflow-backed-data-save`
217
219
  - `omc describe data.submit --example workflow-backed-data-submit`(有流程)
@@ -75,15 +75,14 @@ Model present + form published yet submit says `300004 数据模型不存在`? O
75
75
  rule-node exception in disguise (r44b): `rulelog.search {schemaCode,includeNodes:true}`
76
76
  → `EXCEPTION`/`ROLLBACK` nodes → `rule.get` the changed rule; disable/delete it to
77
77
  isolate. Never recreate a healthy model.
78
- Rule out the child-schema case first: a child column's `schemaCode` is the parent
79
- model's CHILD_TABLE(8) **field code** (`items`, never `<model>_items`);
80
- `field.list <父模型>` → `type:8` field's code. Then the rulelog branch below.
78
+ Rule out child schema first: a child column's `schemaCode` is the parent's
79
+ CHILD_TABLE(8) **field code** (`items`, never `<model>_items`); `field.list` →
80
+ `type:8` field code. Then the rulelog branch below.
81
81
  Line up the model's field-level config first: an `AGGREGATION` FORMULA field whose
82
- `aggregation.schemaCode` points at a **child-table schema** publishes fine and then
83
- makes every `data.submit`/`data.update` on that model 40000 (r18 2026-10-26 live;
84
- bisect by deleting/disabling the suspect formula field, which is reversible).
85
- `omc` now answers `runtime-write-db-exception` and lists the model's formula
86
- fields; the fix is to aggregate a MAIN-table scalar column instead.
82
+ `aggregation.schemaCode` targets a **child-table schema** publishes fine, then makes
83
+ every `data.submit`/`data.update` return 40000 (r18 2026-10-26 live;
84
+ `runtime-write-db-exception` lists the model's formula fields). Bisect by
85
+ disabling the suspect field; aggregate a MAIN-table scalar column instead.
87
86
 
88
87
  ### 3c. Workflow validate `401013` — duplicate / conflicting edge
89
88
 
@@ -97,10 +96,8 @@ condition edges that the platform treats as a duplicate. Fix:
97
96
  3. Copy `omc describe workflow.update --example workflow-conditional-two-level-approval`
98
97
  for the fork-then-join shape (金额>阈值两级 / 否则一级).
99
98
 
100
- Related: `workflow.validate` currently does **not** warn about dead-end graphs
101
- (a node with only conditional outbounds and no else — r31c F23). That check
102
- belongs in `src/lanes/workflow.ts` (forbidden for this change set); rely on the
103
- recipe's else edge until it lands.
99
+ `workflow.validate` does not warn about dead-end graphs (a node with only
100
+ conditional outbounds and no else — r31c F23); rely on the recipe's else edge.
104
101
 
105
102
  ## 4. Readback mismatch — the write landed but does not match
106
103
 
@@ -125,8 +122,7 @@ approved draft, and decide with the human. A second write may duplicate.
125
122
  ## 6. Idempotency & replay
126
123
 
127
124
  - First write with a new `requestId` returns `idempotency.replay:"none"` (no
128
- `duplicate` key). Constants live in code as `IDEMPOTENCY_REPLAY` /
129
- `IDEMPOTENCY_DUPLICATE` — do not invent parallel spellings.
125
+ `duplicate` key).
130
126
  - A repeated `requestId` with **identical** args returns
131
127
  `replay:"already-completed"` + `duplicate:"same-request-replay-no-op"` (or
132
128
  `already-absent-no-op` / `already-published-no-op` for delete/publish) — the
@@ -144,8 +140,8 @@ approved draft, and decide with the human. A second write may duplicate.
144
140
  ## 7. Transport uncertainty — outcome unknown
145
141
 
146
142
  `status:"uncertain"` with `frozen:true` (`cli-timeout`, `batch-timeout-budget`,
147
- `wire-transport:*`). The write **may** be in flight. On `cli-timeout` the
148
- envelope carries `retryable:false`, `lockHeldBy` / `retryAfter`, and a pasteable
143
+ `wire-transport:*`). The write **may** be in flight. On `cli-timeout`:
144
+ `retryable:false`, `lockHeldBy` / `retryAfter`, and a pasteable
149
145
  `nextCommand` for `omc call request.status --env <env> --args '{"requestId":"..."}'`.
150
146
 
151
147
  1. Run that `request.status` (or read back the affected resource by business key).
@@ -186,6 +182,15 @@ Approval actions default to the session endpoint (`/api/api/runtime/workflow/*`)
186
182
  `channel:"openapi"` requires the `openapi` authority and a portal token gets
187
183
  `401` — that is a channel mismatch, not a business refusal.
188
184
 
185
+ ### 8c. `form.get` / `form.list` 50000
186
+
187
+ Platform SERVER_ERROR fallback, **not** a field threshold. Order: `form.list`
188
+ (detail:false) → `field.list` (published:true) → retry `form.get` per `sheetCode`
189
+ → launcher log/network panel. `form.get` falls back to read-only
190
+ `runtime/form/get_biz_sheet` (`degraded:true` + `degradedNote`: no
191
+ checkBizForm/version or PRINT_TEMPLATE); `full:false`/`controls` only change the
192
+ projection, never the wire. Writes never use it (still hard-fail).
193
+
189
194
  ## 9. Input / target
190
195
 
191
196
  - `tool-input-invalid` — schema violation (exit 10); fix the arguments.
@@ -194,13 +199,13 @@ Approval actions default to the session endpoint (`/api/api/runtime/workflow/*`)
194
199
 
195
200
  ## 9b. 权限拒绝(40009 / 发起白名单 / 管理员绕过)
196
201
 
197
- - `40009` / `workflow-start-permission-denied` — 「流程发起权限不足」。三个同码原因:
198
- ① 发起人没命中 `h_workflow_permission`(部门/祖先/角色/本人);② 流程未发布;
199
- ③ 发起人部门记录丢了(`getRootDeptId` 空 → 白名单短路)。先
200
- `omc call workflow.permissions` 看配置行,再 `workflow.get_published` 看是否已发布。
201
- - **管理员绕过**:平台 `h_perm_admin` 的 ADMIN/SYS_MNG(= `login().administrator`,
202
- **不是**登录 API 的 `isAdmin`)会绕过发起白名单。`data.submit` 成功时若
203
- `actor.isAdmin=true` 且带 `bypassReason:"platform-admin bypasses start-permission whitelist"`,
202
+ - `40009` / `workflow-start-permission-denied` — 发起权限不足。同码三因:
203
+ ① 未命中 `h_workflow_permission`(部门/祖先/角色/本人);② 流程未发布;
204
+ ③ 发起人部门记录丢失(`getRootDeptId` 空)。先 `workflow.permissions` 看配置行,再
205
+ `workflow.get_published` 看是否已发布。
206
+ - **管理员绕过**:`h_perm_admin` 的 ADMIN/SYS_MNG(= `login().administrator`,
207
+ **不是**登录 API 的 `isAdmin`)会跳过发起白名单;`data.submit` 带
208
+ `bypassReason:"platform-admin bypasses start-permission whitelist"` 时
204
209
  **配置成功 ≠ 对普通用户生效**。
205
210
  - **怎么验证真生效**:用**非管理员**账号另建环境(`omc setup`)再
206
211
  `data.submit`;或看 `workflow.permissions` 的 `effectiveFor.reason`。不要用管理员
@@ -222,4 +227,4 @@ Approval actions default to the session endpoint (`/api/api/runtime/workflow/*`)
222
227
  - 多列:`--jq "a.b,c.d"` 或重复 `--jq`(结果在 `projections[]`);**不支持** `|` 与对象构造
223
228
  - miss 回 `pathMiss`+`missedAt`+`available`(`--extract` 另置 `unanswered`):未命中≠空值
224
229
  - `mapped`=命中数,`nullEntries`=其中 null 数;相等时看同次 `data.list` 的 `projectionHint` 或 `data.load`
225
- - miss 机器字段:`correctPath`+`nextCommand`(能验证才给)、`helpRef`;`resultMeta.locator` 给 `items[].fields.<code>`↔`data.<code>`(行键↔`bizObjectId`)对照;`nonNullEntries`=mapped 中非 null 数;`projectionHint` 有 `queryColumns` 证据才给 `projectedFields`/`unprojected`,否则 `projectionKnown:false`
230
+ - miss 机器字段:`correctPath`+`nextCommand`(能验证才给)、`helpRef`;`resultMeta.locator` 给 `items[].fields.<code>`↔`data.<code>` 对照;`nonNullEntries`=映射中非 null 数;`projectionHint` 有 `queryColumns` 证据才给 `projectedFields`/`unprojected`,否则 `projectionKnown:false`