@stalfh233/omc-cli 0.8.37 → 0.8.39

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/field-add.js CHANGED
@@ -7,6 +7,10 @@
7
7
  *
8
8
  * 语义(与 model-scaffold 同族约定):
9
9
  * - **幂等**:字段已存在(duplicate)→ 记 skipped 继续(补建场景不该整批失败)。
10
+ * - **每个子调用独立 requestId**:命令级 requestId 只作 base,写/读子调用按
11
+ * `base:步骤:序号` 派生(见 `subRequestId`)。同 id 不同参数会被幂等门拒绝
12
+ * (argsDigestChanged),多字段必败;派生后多字段全成功,且同一 base 重跑时
13
+ * 已完成的子调用命中 replay(不重复建字段)。
10
14
  * - **不猜**:--fields 每项原样透传给 field.create(只补 schemaCode)。
11
15
  * - **失败不发布**:有真失败默认停在发布前(--force-publish 强发)。
12
16
  * - **列表增量**:listview.configure 默认合并语义(保留既有列/条件),只把新字段
@@ -20,6 +24,20 @@ import { writeEnvelope } from "./cli-output.js";
20
24
  import { assertSafeInputPath } from "./artifacts.js";
21
25
  import { readFileSync } from "node:fs";
22
26
  import { resolve } from "node:path";
27
+ /**
28
+ * 子调用 requestId 派生(w53 P1):`requestId` 是「(id, 参数指纹) 组合键」,
29
+ * 同一条命令里的预检与 N 个字段写、N 行演示数据**参数各不相同**,共用一个 id 会
30
+ * 让第 2 个子调用撞 `argsDigestChanged`(真机:2 字段 → created:1/failed:1 partial)。
31
+ *
32
+ * 派生规则:`${base}:${label}:${index}`(index 从 1 起;无序号步骤省略)。
33
+ * - **唯一**:同一命令内每个写/读子调用一个 id;
34
+ * - **稳定**:同一 base + 同一命令形状 → 同一派生 id,重跑时已完成的子调用命中
35
+ * 本地 replay(同 id 同指纹 → no-op),不会重复建字段;
36
+ * - **可读**:label 说明是哪一步,request.status 排障时一眼看出。
37
+ */
38
+ function subRequestId(base, label, index) {
39
+ return index === undefined ? `${base}:${label}` : `${base}:${label}:${index}`;
40
+ }
23
41
  /**
24
42
  * 模型级发布的爆炸半径:读出该模型草稿面里「不是本次要建的」字段。
25
43
  *
@@ -34,7 +52,8 @@ async function listOtherDraftFields(schemaCode, ownCodes, opts) {
34
52
  const callFieldList = async (published) => {
35
53
  const outcome = await runToolCall("field.list", {
36
54
  args: { schemaCode, published },
37
- requestId: opts.requestId,
55
+ // 读面不产生写产物,但同样按子调用派生,避免与写步骤共用 id 造成排障歧义。
56
+ requestId: subRequestId(opts.requestId, published ? "read:published" : "read:draft"),
38
57
  ...(opts.environment !== undefined ? { environment: opts.environment } : {}),
39
58
  ...(opts.context !== undefined ? { context: opts.context } : {}),
40
59
  print: () => undefined,
@@ -68,10 +87,14 @@ async function listOtherDraftFields(schemaCode, ownCodes, opts) {
68
87
  async function expandDictShorthand(fields, environment, contextForTest, request) {
69
88
  const problems = [];
70
89
  const expanded = [];
90
+ // 字典展开是只读链(dictionary.list + records ×N)。按子调用派生 id:虽是读面,
91
+ // 但同一条命令里多次用同一个 id 会让 request.status/journal 无法区分。
92
+ let readSeq = 0;
71
93
  const call = async (tool, args) => {
94
+ readSeq += 1;
72
95
  const outcome = await runToolCall(tool, {
73
96
  args,
74
- requestId: request,
97
+ requestId: subRequestId(request, `dict-read:${tool}`, readSeq),
75
98
  ...(environment !== undefined ? { environment } : {}),
76
99
  ...(contextForTest !== undefined ? { context: contextForTest } : {}),
77
100
  print: () => undefined,
@@ -145,8 +168,10 @@ export function validateFields(schemaCode, fields) {
145
168
  problems.push("--schema 必填");
146
169
  return problems;
147
170
  }
148
- export async function cmdFieldAdd(args, contextForTest) {
149
- const request = requestId();
171
+ export async function cmdFieldAdd(args, contextForTest, requestOverride) {
172
+ // `requestOverride` 是测试缝(不暴露 CLI flag):给同一 base 重放子调用,
173
+ // 验证「同一 base → 同一派生 id → 已完成子调用命中 replay」。
174
+ const request = requestOverride ?? requestId();
150
175
  const flag = (name) => argvValue(args, name);
151
176
  const schemaCode = flag("--schema") ?? flag("--schema-code") ?? flag("--code");
152
177
  const fieldsFile = flag("--fields-file");
@@ -249,10 +274,10 @@ export async function cmdFieldAdd(args, contextForTest) {
249
274
  };
250
275
  // 零 wire 形状预检(与 model-scaffold 同层防线):dry-run 走本地能力门。
251
276
  const preflightProblems = [];
252
- for (const field of fields) {
277
+ for (const [index, field] of fields.entries()) {
253
278
  const probe = await runToolCall("field.create", {
254
279
  args: { schemaCode, ...field },
255
- requestId: request,
280
+ requestId: subRequestId(request, "preflight:field-create", index + 1),
256
281
  dryRun: true,
257
282
  ...(environment !== undefined ? { environment } : {}),
258
283
  ...(contextForTest !== undefined ? { context: contextForTest } : {}),
@@ -315,10 +340,12 @@ export async function cmdFieldAdd(args, contextForTest) {
315
340
  }
316
341
  const steps = [];
317
342
  const lastSummaries = [];
318
- const call = async (tool, toolArgs) => {
343
+ // w53 P1:每个子调用一个派生 requestId(`subRequestId`)。此前共用命令级 id,
344
+ // 第二个 `field.create`(参数不同)被幂等门判成 argsDigestChanged → partial。
345
+ const call = async (tool, toolArgs, index) => {
319
346
  const outcome = await runToolCall(tool, {
320
347
  args: toolArgs,
321
- requestId: request,
348
+ requestId: subRequestId(request, tool, index),
322
349
  ...(environment !== undefined ? { environment } : {}),
323
350
  ...(contextForTest !== undefined ? { context: contextForTest } : {}),
324
351
  print: () => undefined,
@@ -332,8 +359,8 @@ export async function cmdFieldAdd(args, contextForTest) {
332
359
  // 1) 建字段:duplicate 记 skipped,其余失败继续跑完(一次看全)。
333
360
  const failedFields = [];
334
361
  const createdCodes = [];
335
- for (const field of fields) {
336
- const outcome = await call("field.create", { schemaCode, ...field });
362
+ for (const [index, field] of fields.entries()) {
363
+ const outcome = await call("field.create", { schemaCode, ...field }, index + 1);
337
364
  const message = String(outcome.result.message ?? "");
338
365
  if (outcome.ok) {
339
366
  steps.push({ step: "field.create", status: "ok", detail: { schemaCode, code: String(field.code) } });
@@ -410,7 +437,7 @@ export async function cmdFieldAdd(args, contextForTest) {
410
437
  }
411
438
  // 演示数据(--demo-rows):逐行 data.submit;失败记 failed 不阻断(行级独立)。
412
439
  for (const [index, row] of (demoRows ?? []).entries()) {
413
- const submitted = await call("data.submit", { schemaCode, formData: row });
440
+ const submitted = await call("data.submit", { schemaCode, formData: row }, index + 1);
414
441
  const readback = submitted.ok ? (submitted.result.readback ?? {}) : {};
415
442
  steps.push({
416
443
  step: "data.submit",
@@ -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 手动翻页。`
@@ -774,11 +774,14 @@ export function childSortKeyOutOfRangeWarnings(formData, childCodes, existingRec
774
774
  return warnings;
775
775
  }
776
776
  /**
777
- * Advisory only (issue #100): the platform mirrors every RADIO(12)/DROPDOWN(14)
778
- * value into a `<field>_key` companion column through
779
- * `OptionKeySupportImpl.getValueKeyMap` (8.6.26 :164-183). OMC does not write
780
- * the companion key; it only tells the caller when a hand-built payload has a
781
- * value without one (or a key that disagrees with the readable snapshot).
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).
782
785
  */
783
786
  export function optionKeyWarnings(meta, formData, row = 1) {
784
787
  if (!meta)
@@ -819,7 +822,7 @@ export function optionKeyWarnings(meta, formData, row = 1) {
819
822
  suppliedKey: String(suppliedKey),
820
823
  expectedKey: suggested,
821
824
  optionSource: map.source,
822
- message: `字段 ${code} 的值 "${String(value)}" 对应的 ${keyCode} 应为 "${suggested}",实际传了 "${String(suppliedKey)}"(按${map.source === "snapshot" ? "字典快照" : "自定义选项"}推导);平台写面会重算该伴生键,OMC 仅提示`,
825
+ message: `字段 ${code} 的值 "${String(value)}" 与伴生键 ${keyCode} 不匹配:按${map.source === "snapshot" ? "字典快照" : "自定义选项"}推导应为 "${suggested}",实际传了 "${String(suppliedKey)}"。8.6 平台保存时可能重算该键;2.1.5 实测走 Facade 直接写入时不会自动重算,会保留传入的错误 key(2.1.7 待采样)。请显式写正确的 ${keyCode},不要依赖平台补偿。`,
823
826
  });
824
827
  }
825
828
  }
@@ -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],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stalfh233/omc-cli",
3
- "version": "0.8.37",
3
+ "version": "0.8.39",
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.37",
61
+ "omc-core": "0.8.39",
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.37"
79
+ "@stalfh233/omc-fake-platform": "0.8.39"
80
80
  }
81
81
  }
@@ -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`