@stalfh233/omc-cli 0.8.35 → 0.8.36

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/lanes/app.js CHANGED
@@ -288,6 +288,22 @@ function appRollbackSpec(toolName) {
288
288
  function isFallbackGroup(group) {
289
289
  return String(group?.code ?? "").toLowerCase() === "all";
290
290
  }
291
+ /**
292
+ * issue #65:`app.list` 的内联投影只回 20 条,且外置档没有「怎么取全」的指路。
293
+ *
294
+ * 平台端点没有分页参数:`GET /api/app/apppackage/list` 一次返回该用户可见的
295
+ * **全部**应用(8.6.26 `AppPackageController.list:725-738`,只接 `getUserId()`,
296
+ * 无 Pageable;`list_all` 也是全量)。所以「全量」不是服务端翻页,而是
297
+ * **客户端内联上限**:`all:true` 抬到 500 条,仍超出时用 offset 续取。
298
+ * `applicationsCount` 始终是租户全集条数,截断多少由 `omittedCount` 说明。
299
+ */
300
+ const APP_LIST_INLINE_LIMIT = 20;
301
+ const APP_LIST_ALL_LIMIT = 500;
302
+ /** 回执里的可复制命令:环境名安全时用真名,否则用 `<env>` 占位。 */
303
+ function appListNextCommand(args, next) {
304
+ const environment = typeof args.environment === "string" && /^[^\s'"]+$/.test(args.environment) ? args.environment : "<env>";
305
+ return `omc call app.list --env ${environment} --args '${JSON.stringify(next)}'`;
306
+ }
291
307
  export function registerAppLane(tools) {
292
308
  tools.push(defineTool({
293
309
  name: "app.list",
@@ -297,7 +313,13 @@ export function registerAppLane(tools) {
297
313
  lane: APP_LANE,
298
314
  scope: APP_TOOLS["app.list"].scope,
299
315
  description: APP_TOOLS["app.list"].description,
300
- inputSchema: { environment: environmentArg, capability: capabilityArg },
316
+ inputSchema: {
317
+ environment: environmentArg,
318
+ capability: capabilityArg,
319
+ all: z.boolean().optional().describe("true = 内联整个清单(客户端上限 500;平台无分页,一次全量)。默认档仍只回 20 条;超出给 omittedCount+nextCommand"),
320
+ limit: z.number().int().min(1).max(APP_LIST_ALL_LIMIT).optional().describe("内联条数 1..500(默认 20;all:true 默认 500),不是平台分页"),
321
+ offset: z.number().int().min(0).optional().describe("内联起点(默认 0),配合 limit 翻页;applicationsCount 仍是全集"),
322
+ },
301
323
  handler: async (ctx, args, self) => governedRead(ctx, self, args, async (session) => {
302
324
  const rows = wireRows((await wireCall(session, { path: ENDPOINTS.applicationList, query: {} })).data);
303
325
  // B3(0.8.4 真机):旧实现是 `Promise.all` **无界**扇出——每个应用一条
@@ -340,16 +362,35 @@ export function registerAppLane(tools) {
340
362
  : {}),
341
363
  };
342
364
  }, {
343
- target: "app.list",
344
- compact: (result) => {
365
+ // issue #65:调用参数现在会改变回执(all/limit/offset),读回缓存键必须跟着变,
366
+ // 否则同一环境先跑默认档再跑 all:true 会命中 `unchanged:true` 拿到旧的 20 条。
367
+ // 无参数时键仍是旧的 "app.list"(产物哈希/黄金样本不动)。
368
+ target: `app.list${args.all === true ? ":all" : ""}${args.limit !== undefined ? `:limit=${args.limit}` : ""}${args.offset !== undefined ? `:offset=${args.offset}` : ""}`,
369
+ compact: (result, _session, args) => {
345
370
  const apps = Array.isArray(result.applications) ? result.applications : [];
371
+ const offset = typeof args.offset === "number" ? args.offset : 0;
372
+ const limit = typeof args.limit === "number" ? args.limit : args.all === true ? APP_LIST_ALL_LIMIT : APP_LIST_INLINE_LIMIT;
373
+ const page = apps.slice(offset, offset + limit);
374
+ const omittedCount = apps.length - page.length;
375
+ const hasMoreAfterPage = offset + page.length < apps.length;
376
+ // 还有未内联的行时给可复制的续取命令:默认档先建议 all:true;
377
+ // 显式 all/limit/offset 档则用 offset 续页。
378
+ const nextArgs = args.all === true || args.limit !== undefined || offset > 0
379
+ ? { offset: offset + page.length, limit }
380
+ : { all: true };
346
381
  return {
347
382
  applicationsCount: apps.length,
348
- omitted: true,
349
- applications: apps.slice(0, 20),
383
+ omitted: omittedCount > 0,
384
+ applications: page,
385
+ ...(omittedCount > 0
386
+ ? {
387
+ omittedCount,
388
+ ...(hasMoreAfterPage ? { nextCommand: appListNextCommand(args, nextArgs) } : {}),
389
+ tablesHint: `applications 只内联了 ${page.length}/${apps.length} 条(omittedCount=${omittedCount});全集仍可用 --jq applications[].code 或 artifact get 取回${hasMoreAfterPage ? ",或按 nextCommand 续取" : ""}。`,
390
+ }
391
+ : {}),
350
392
  // B3:部分失败是结论本身(哪个应用读不到),diet 不得吞掉。
351
393
  ...(result.applicationsFailed !== undefined ? { applicationsFailed: result.applicationsFailed, failed: result.failed, partial: true, hint: result.hint } : {}),
352
- tablesHint: "applications 已截断内联前 20 条(omitted:true);全集在 detailArtifactId,用 --jq applications[].code 或 artifact get 取回。",
353
394
  };
354
395
  },
355
396
  }),
@@ -724,7 +724,12 @@ async function readRuleListBody(session, schemaCode, options) {
724
724
  ? {}
725
725
  : {
726
726
  customCount: rows.filter((row) => row.defaultRule !== true).length,
727
- presetHint: "默认含平台预置触发行(preset:true,如 Available/Cancel/Create/Delete/GetList/Load/Update);判定「有没有人写过规则」看 customCount(=0 即全是预置),或直接 onlyCustom:true",
727
+ // F5(探针 AA,0.8.36):2.1.5 新建模型本面 **0 行**(预置行尚未物化/
728
+ // 发布;8.6 建模即建)。旧文案无条件说「默认含平台预置触发行」,在 0
729
+ // 行面上自相矛盾,会被读成「没有触发器」。
730
+ presetHint: visible.length === 0
731
+ ? "本面 0 条:平台尚未物化/发布预置行(2.1.5 新建模型为空,8.6 建模即建);不要据此判定没有触发器——用 rule.references kind:\"trigger\" 看真实触发点"
732
+ : "默认含平台预置触发行(preset:true,如 Available/Cancel/Create/Delete/GetList/Load/Update);判定「有没有人写过规则」看 customCount(=0 即全是预置),或直接 onlyCustom:true",
728
733
  }),
729
734
  ...(endpointFamily ? { endpointFamily } : {}),
730
735
  ...(mappingFace
@@ -1231,18 +1236,16 @@ export function registerBusinessRuleLane(tools) {
1231
1236
  // r83:三句提示(executableHint/statusNote/presetHint)逐模型逐字相同,
1232
1237
  // 跨模型面把它们抬到顶层一次(crossModelNotes),否则 3 模型就顶破 2048
1233
1238
  // 内联上限、整面被 compact(models 退码表)。statusLag 旗标仍逐模型保留。
1239
+ // F5(探针 AA,0.8.36):presetHint 现在随「本面是否 0 行」而变——**只有
1240
+ // 所有模型都存在且内容全等才抬**;否则保留逐模型(否则 0 行模型的「0 条」
1241
+ // 文案会被 8.6 模型抬走的通用文案覆盖,结论错)。
1234
1242
  const hoisted = {};
1235
1243
  const HOIST_KEYS = ["executableHint", "statusNote", "presetHint"];
1244
+ const bodies = [];
1236
1245
  for (const schemaCode of schemaCodes) {
1237
1246
  try {
1238
1247
  const body = await readRuleListBody(session, schemaCode, options);
1239
- for (const key of HOIST_KEYS) {
1240
- if (body[key] !== undefined) {
1241
- hoisted[key] = body[key];
1242
- delete body[key];
1243
- }
1244
- }
1245
- models.push(body);
1248
+ bodies.push(body);
1246
1249
  rulesCount += Array.isArray(body.rules) ? body.rules.length : 0;
1247
1250
  }
1248
1251
  catch (error) {
@@ -1250,6 +1253,19 @@ export function registerBusinessRuleLane(tools) {
1250
1253
  failed.push({ schemaCode, code: null, message: error.message });
1251
1254
  }
1252
1255
  }
1256
+ if (bodies.length > 0) {
1257
+ for (const key of HOIST_KEYS) {
1258
+ if (!bodies.every((body) => body[key] !== undefined))
1259
+ continue;
1260
+ const first = JSON.stringify(bodies[0][key]);
1261
+ if (!bodies.every((body) => JSON.stringify(body[key]) === first))
1262
+ continue;
1263
+ hoisted[key] = bodies[0][key];
1264
+ for (const body of bodies)
1265
+ delete body[key];
1266
+ }
1267
+ models.push(...bodies);
1268
+ }
1253
1269
  // 全部模型都读失败 → 上抛首个错误:auth/网络问题不能被读成「部分成功」。
1254
1270
  if (models.length === 0 && firstError !== undefined)
1255
1271
  throw firstError;
@@ -19,9 +19,9 @@ export const FORM_WIRE = Object.freeze({
19
19
  actionsColumns: "ticket 100: draftActionsJson/publishedActionsJson are REAL bizsheet columns (BizForm.java:95-100 @SerializableField; BizFormModel.java:59-62 serialized by bizsheet/get) — the designer writes draftActionsJson on save and both faces on publish (frontend-dist/admin/js/4280.cfa75764.js offsets 193538/185347); form.get full:true surfaces them; publish promotes draftActionsJson → publishedActionsJson",
20
20
  sheetListFace: "form.list: GET /api/api/app/bizsheet/list?schemaCode= (BizFormController.java:137-152 → ModelManagementFacadeImpl.getBizForms:481-488) answers the BizFormHeaderModel HEADER projection only — code, name, schemaCode, published, formType, sortKey, icon. formType is the INTEGER index (@JsonValue getIndex(), BizFormType.java:45-48): 0 DEFAULT_SHEET / 1 CUSTOMIZE_SHEET / 2 PRINT_TEMPLATE — decoded to the name with formTypeIndex kept (ADR 0002). existDraft/buttonCount/hasCustomScript are NOT on this face, so the default read never fabricates them: detail:true pays 1+N bizsheet/get for the content-derived faces. published is the same platform flag bit (r79-04): publish→draft leaves it false while the content is intact — the flag is reported as-is, content judgement needs detail:true. HTTP 404 means the version family has no /list endpoint: the tool answers sheetListUnavailable:true + the default slot only, never a fabricated list; a 601003 业务模型不存在 refusal is modelPresent:false (zero retries)",
21
21
  });
22
- const FORM_GET_DESCRIPTION = '读取默认表单(bizsheet/get)的发布状态与控件清单(紧凑默认)。**`published`/`existDraft` 是内容面结论**(`published:true`=已发布;`published:false,existDraft:true`=只有草稿,**未发布**);平台 `bizsheet/get` 标记位见 `platformFlags`。`form.list` 的 `published` 仍为平台旗标,两者语义不同。不要用 `publishedControlCodes` 是否非空来推断(草稿字段会让它非空,误判为已发布)。**每个模型交付前其默认表单必须 `published:true`**:用 `configure_form` 或 `form.draft(rebuild:true)`+`form.publish` 发布,并逐模型 `form.get` 核对。`full:true` 还返回 `options` 与 `customButtonJson`(表单工具栏按钮,数组原样;库里是字符串脏形时附 `customButtonJsonShapeWarning`——线上 #38 前端按钮不渲染)。传 `controls:["code",…]` 只取指定控件的 options(如关联控件的 mappings);传 `full:true` 才返回 draft/published 的完整 view/attributes/html/actions JSON(actions 列为设计器保存/发布的表单级按钮动作)。体积大,仅在需要整体布局时用。';
23
- const FORM_DRAFT_DESCRIPTION = "Save the default-form DRAFT (bizsheet/update). Reads the current sheet, merges the caller's explicit draftViewJson/draftAttributesJson (or preserves the existing draft); when both are absent on a fresh default form, composes the designer-standard scaffold from the model's published fields. A redundant field (relation-mapping carry-through target) always stays bound; with no workflow it is hidden in the design (options.visible=false), with a workflow it stays visible for per-node propertyPermissions. Pass `draftHtmlJson` to thread custom online-script HTML through. Empty-layout guard: explicitly passing \"[]\"/\"{}\" view/attributes is refused (form-empty-layout) — the platform designer's Save is NOT lossless and clears drafts to exactly that shape; escape with allowEmptyLayout:true, and recover cleared drafts from the form version history (/api/api/app/bizsheet/history/list). **读回原样回写**:从 `form.get` 取回的 view/attributes 直接回传时加 `fromReadback:true`——工具会与已存草稿/发布面逐字比对,一致才放行(平台自身布局可能含子表列行/系统行默认宽度),被改动过的面照常按 validation 拒绝。**表单工具栏按钮**:`buttons`(数组)或 `customButtonJson`(原样字符串)写进 `biz_sheet.options.customButtonJson`(**数组+actionConfig 对象**,设计器同形——线上 #38:字符串形=双重编码,前端按钮不渲染,重写即自愈);**要到 form.publish 才生成 h_biz_button(triggerType=FORM)**,且表单页是否显示还取决于流程节点 `buttonPermission.customBtns[].enabled`(设计器「表单操作」勾选)。`useLocation` 用 FORM/ROW/LIST,表单工具栏按钮用 FORM。字段发布后如需刷新已发布表单的控件映射,用本工具 rebuild:false 重存(保留现有布局与在线JS)再 form.publish。**改既有表单勿整表重写**:先 `form.get full:true` 取 `publishedAttributesJson` 作基线、只改 rows/span;只写业务字段会丢系统控件并撞 form-publish-degrade。";
24
- const FORM_PUBLISH_DESCRIPTION = "Publish the default form (bizsheet/publish, proven shape: draft*Json promoted to published*Json verbatim) with published-face readback. **不影响在线 JS**:本工具只提拔布局草稿;改 JS 请用 onlinejs.compose(它自己会连同整张表单一起发布,不必再调本工具)。 Degrade guard: refuses to promote a draft carrying FEWER controls than the published face (form-publish-degrade) — the designer's Save clears drafts non-losslessly; recover via the form version history (/api/api/app/bizsheet/history/list) and rewrite the draft first, or pass allowDegrade:true to force the reduction. rebuild:true is the one-call refresh: discard the existing draft, re-scaffold from the published fields (non-structural control options preserved), then force-promote — use it after a field shape change. **表单工具栏按钮**:传 `buttons`(或 `customButtonJson`)→ 写进 `options.customButtonJson` 并在本次 publish 生成 `h_biz_button(triggerType=FORM, triggerCode=<formCode>)`(平台 `publishBizForm:1022`);`options.customButtonJson` 以**数组**写入(条目 `actionConfig` 为对象,设计器同形——线上 #38:字符串形=双重编码,前端按钮不渲染,回执给 formButtonsShapeWarning);表单页是否显示再由流程节点 `buttonPermission.customBtns[].enabled` 过滤。";
22
+ const FORM_GET_DESCRIPTION = '读取默认表单(bizsheet/get)的发布状态与控件清单(紧凑默认)。**`published`/`existDraft` 是内容面结论**(`published:true`=已发布;`published:false,existDraft:true`=只有草稿,**未发布**);平台 `bizsheet/get` 标记位见 `platformFlags`。`form.list` 的 `published` 仍为平台旗标,两者语义不同。不要用 `publishedControlCodes` 是否非空来推断(草稿字段会让它非空,误判为已发布)。**每个模型交付前其默认表单必须 `published:true`**:用 `configure_form` 或 `form.draft(rebuild:true)`+`form.publish` 发布,并逐模型 `form.get` 核对。`full:true` 还返回 `options` 与 `customButtonJson`(表单工具栏按钮,数组原样;字符串脏形附 `customButtonJsonShapeWarning`——#38 前端不渲染)。传 `controls:["code",…]` 只取指定控件的 options(如关联控件的 mappings);传 `full:true` 才返回 draft/published 的完整 view/attributes/html/actions JSON(actions 列为设计器保存/发布的表单级按钮动作)。体积大,仅在需要整体布局时用。非字段控件(200/202/203)见 `decorations`(2.1.5 验存储/发布/读回;门户渲染未验,需 8.1.108/真页采样)。';
23
+ const FORM_DRAFT_DESCRIPTION = "Save the default-form DRAFT (bizsheet/update). Reads the current sheet, merges the caller's explicit draftViewJson/draftAttributesJson (or preserves the existing draft); when both are absent on a fresh default form, composes the designer-standard scaffold from the model's published fields. A redundant field (relation-mapping carry-through target) always stays bound; with no workflow it is hidden in the design (options.visible=false), with a workflow it stays visible for per-node propertyPermissions. Pass `draftHtmlJson` to thread custom online-script HTML through. Empty-layout guard: explicitly passing \"[]\"/\"{}\" view/attributes is refused (form-empty-layout) — the platform designer's Save is NOT lossless and clears drafts to exactly that shape; escape with allowEmptyLayout:true, and recover cleared drafts from the form version history (/api/api/app/bizsheet/history/list). **读回原样回写**:从 `form.get` 取回的 view/attributes 直接回传时加 `fromReadback:true`——工具会与已存草稿/发布面逐字比对,一致才放行(平台自身布局可能含子表列行/系统行默认宽度),被改动过的面照常按 validation 拒绝。**表单工具栏按钮**:`buttons`(数组)或 `customButtonJson`(原样字符串)写进 `biz_sheet.options.customButtonJson`(**数组+actionConfig 对象**;字符串形=双重编码,前端按钮不渲染);`h_biz_button(triggerType=FORM)` 要到 form.publish 才生成,表单页显示还看流程节点 `buttonPermission.customBtns[].enabled`。`useLocation` 用 FORM/ROW/LIST。字段发布后如需刷新已发布表单的控件映射,用本工具 rebuild:false 重存(保留现有布局与在线JS)再 form.publish。**改既有表单勿整表重写**:先 `form.get full:true` 取 `publishedAttributesJson` 作基线、只改 rows/span;只写业务字段会丢系统控件并撞 form-publish-degrade。**描述块/分组标题**(控件 200/202/203,非字段)用 `decorations` 增量加(202 的 `html` 写 options.name;2.1.5 验存储/发布/读回;门户渲染未验,需 8.1.108/真页采样);rebuild 保留 202 描述块,额外 200/203 实例 fail-closed 列 `losing`。";
24
+ const FORM_PUBLISH_DESCRIPTION = "Publish the default form (bizsheet/publish, proven shape: draft*Json promoted to published*Json verbatim) with published-face readback. **不影响在线 JS**:本工具只提拔布局草稿;改 JS 请用 onlinejs.compose(它自己会连同整张表单一起发布,不必再调本工具)。 Degrade guard: refuses to promote a draft carrying FEWER controls than the published face (form-publish-degrade) — the designer's Save clears drafts non-losslessly; recover via the form version history (/api/api/app/bizsheet/history/list) and rewrite the draft first, or pass allowDegrade:true to force the reduction. rebuild:true is the one-call refresh: discard the existing draft, re-scaffold from the published fields (non-structural control options preserved; 202 描述块原样保留,额外 200/203 实例 fail-closed 列于 losing), then force-promote — use it after a field shape change. **表单工具栏按钮**:传 `buttons`(或 `customButtonJson`)→ 写进 `options.customButtonJson` 并在本次 publish 生成 `h_biz_button(triggerType=FORM, triggerCode=<formCode>)`(平台 `publishBizForm:1022`);`options.customButtonJson` 以**数组**写入(条目 `actionConfig` 为对象,设计器同形——线上 #38:字符串形=双重编码,前端按钮不渲染,回执给 formButtonsShapeWarning);表单页是否显示再由流程节点 `buttonPermission.customBtns[].enabled` 过滤。";
25
25
  const FORM_RUN_BUTTON_DESCRIPTION = "执行表单工具栏按钮(平台同款面:`POST /api/api/runtime/form/executeCustomButton`,body `{bizButtonModel, bizObjectList:[<完整业务对象>], reacquireDataFromDb:true}`)。**与列表行按钮不同**:列表按钮发 `launcher/domain_service_runtime/<schema>/<rule>` + `ids[]`(用 `rule.run`),表单按钮带**整条记录**,不能互换。按钮来源 `GET /api/api/system/getCustomButtons`(只列 triggerType=FORM 的 h_biz_button)。前提:按钮已由 `form.publish` 的 `buttons`/`customButtonJson` 生成。返回是执行结果信封,规则副作用用 `data.load` 另读;被规则 UPDATE 的目标行须是 COMPLETED(引擎查不到 DRAFT)。`302045` = 数据被占用。**`10005` 换等价面 `rule.run`(见 contract form),勿反复重试。**";
26
26
  const CONFIGURE_FORM_DESCRIPTION = "High-level: bind fields into the default form and publish it (form.draft → form.publish), subject to the write permission gate. Delegates to the proven form.draft scaffold + form.publish paths so the real empty-form layout (and any caller-supplied draftHtmlJson) is persisted and promoted — never bypasses with a shortcut body. `sheetCode` is optional: omitted means the model's default sheet (sheetCode = schemaCode).";
27
27
  const FORM_LIST_DESCRIPTION = "列出模型的多张表单(`/api/api/app/bizsheet/list?schemaCode=`,header-only 投影):每行 `sheetCode`/`name`/`formType`(整数索引解码为名字,另带 formTypeIndex)/`published`。默认只发 1 次 wire;`detail:true` 才逐面 `bizsheet/get`(上限 maxSheets=12,超出回 partial+omittedSheets)补 existDraft/controlCount/buttonCount/publishedActionCount/hasCustomScript/faces。**默认面不伪造这些内容推导键,也不改旗标**:`published` 是平台旗标位(publish→draft 后它为 false 而内容俱在),判「有没有发布面内容」用 detail:true 的 faces。业务模型不存在 → modelPresent:false;该版本族无 /list 端点(HTTP 404)→ sheetListUnavailable:true + 只回默认槽(明确标注是推断,不是清单)。`defaultSheetCode` 由清单推导(formType=DEFAULT_SHEET 且 sheetCode===schemaCode),权威仍是 form.get 的显式 sheetCode。";
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { ENDPOINTS } from "../endpoints.js";
3
3
  import { decodeButtonScript } from "./list-view.js";
4
- import { executeFormDraftWrite, executeFormPublishWrite, executeFormRunButtonWrite, lintFormPublishReadOnly, lintFormControlTypes, readFormButtons, readFormOrNull, refuseEmptyCallerLayout, validateHtmlRender, customButtonJsonStoredShape, CUSTOM_BUTTON_JSON_STRING_SHAPE_WARNING, FORM_FLAG_AUTHORITY_NOTE, compareFormFaces, resolveEffectiveFormFace, composeFormLayoutDraft, assertLayoutRequestConflicts } from "../form-support.js";
4
+ import { executeFormDraftWrite, executeFormPublishWrite, executeFormRunButtonWrite, lintFormPublishReadOnly, lintFormControlTypes, readFormButtons, readFormOrNull, refuseEmptyCallerLayout, validateHtmlRender, customButtonJsonStoredShape, CUSTOM_BUTTON_JSON_STRING_SHAPE_WARNING, FORM_FLAG_AUTHORITY_NOTE, compareFormFaces, resolveEffectiveFormFace, composeFormLayoutDraft, composeFormDecorationsDraft, assertLayoutRequestConflicts, assertDecorationRequestConflicts, summarizeFormDecorations } from "../form-support.js";
5
5
  import { capabilityArg, environmentArg } from "../args.js";
6
6
  import { governedRead } from "../read.js";
7
7
  import { writeTool } from "../write.js";
@@ -229,6 +229,12 @@ export function registerFormLane(tools) {
229
229
  // F5(0.8.20):子表列 locator(发布面优先,草稿面兜底)。
230
230
  const childColumnLocator = childColumnLocatorOf(sheet.publishedAttributesJson, "publishedAttributesJson")
231
231
  ?? childColumnLocatorOf(sheet.draftAttributesJson, "draftAttributesJson");
232
+ // issue #57:非字段控件(200 分组标题 / 202 描述说明 / 203 表单标题)单列,
233
+ // 免掉「整包 diff 才能看出用户在设计器加了什么」。优先草稿面(正在编辑的
234
+ // 那一面),草稿为空才退回发布面;正文(HTML)有界内联,超预算只给
235
+ // htmlPresent + htmlBytes。
236
+ const decorationFace = draftPresent ? "draft" : "published";
237
+ const decorationSummary = summarizeFormDecorations(decorationFace === "draft" ? sheet.draftAttributesJson : sheet.publishedAttributesJson, decorationFace === "draft" ? sheet.draftViewJson : sheet.publishedViewJson);
232
238
  const faceSync = compareFormFaces(sheet, { draftPresent, publishedPresent });
233
239
  const faceVerdict = resolveEffectiveFormFace({
234
240
  draftPresent,
@@ -256,6 +262,11 @@ export function registerFormLane(tools) {
256
262
  ...(faceSync.inSync === false ? { differingFaces: faceSync.differingFaces } : {}),
257
263
  },
258
264
  ...(childColumnLocator !== undefined ? { childColumnLocator } : {}),
265
+ // 非字段控件摘要(恒回数组,0 也给):空数组 = 这面确实没有布局控件,
266
+ // 不是「没读到」。写面是 form.draft {decorations}。
267
+ decorations: decorationSummary.decorations,
268
+ decorationsFace: decorationFace,
269
+ ...(decorationSummary.note !== undefined ? { decorationsNote: decorationSummary.note } : {}),
259
270
  ...(flagMismatch
260
271
  ? {
261
272
  flagMismatch: true,
@@ -381,7 +392,9 @@ export function registerFormLane(tools) {
381
392
  compact: (result) => {
382
393
  // 探针 L F7:platformFlags 只有两个布尔,compact 若不保留会被压成
383
394
  // `platformFlagsCount:2`,平台原文恰好在降载时丢失。
384
- const KEEP = new Set(["draftControls", "publishedControls", "customButtonJson", "options", "formButtons", "formButtonCodes", "platformFlags", "childColumnLocator"]);
395
+ // issue #57:decorations 是**证据行集**(key/type/html/row),压成码表就
396
+ // 丢掉了「用户加了什么描述块」这个答案;payload 已按 1800B 自限。
397
+ const KEEP = new Set(["draftControls", "publishedControls", "customButtonJson", "options", "formButtons", "formButtonCodes", "platformFlags", "childColumnLocator", "decorations"]);
385
398
  // r28e F4 暴露的潜在 bug:handler 已经交过 `*Codes`/`*Count`/`*Omitted`
386
399
  // 这类**已压缩**的键,若再走数组分支会被二次加后缀
387
400
  // (`publishedControlCodes` → `publishedControlCodesCodes`),字段直接消失。
@@ -611,15 +624,26 @@ export function registerFormLane(tools) {
611
624
  writeTool({
612
625
  tools,
613
626
  name: "form.draft",
614
- search: { intents: ["改表单布局", "调表单布局", "表单拖字段", "存表单草稿", "表单加控件"] },
627
+ search: { intents: ["改表单布局", "调表单布局", "表单拖字段", "存表单草稿", "表单加控件", "表单描述块", "描述说明", "富文本说明", "红色提示文字"] },
615
628
  lane: FORM_LANE,
616
629
  scope: FORM_TOOLS["form.draft"].scope,
617
630
  description: FORM_TOOLS["form.draft"].description,
618
631
  inputSchema: {
619
632
  schemaCode: z.string().min(1),
620
633
  sheetCode: z.string().min(1).optional().describe("表单槽位码;省略时默认 = schemaCode(模型码即默认表单槽位)"),
621
- draftViewJson: z.string().optional().describe("行分组:JSON 二维字符串数组 `[[\"codeA\",\"codeB\"],[\"codeC\"]]`——**一行几个 code 就是几列**(不是改 span 来改列数);末行只放一个 code 即整宽。每个 code 必须同时出现在 draftAttributesJson 里。现成样例:`omc describe form.draft --example two-column-layout`"),
622
- draftAttributesJson: z.string().optional().describe("控件表:JSON 对象 `{ \"codeA\": { key:\"codeA\", type: <表单控件类型号>, options:{ name:\"显示名\", span: 12 } } }`。**控件 type 是表单控件枚举,不是字段 propertyType**(80=关联单选/201=子表…);错枚举拒 `form-control-type-mismatch`。`span` 是 24 栅格宽度:两列各 span:12、整宽 span:24(须与 draftViewJson 行分组自洽)。样例:`omc describe form.draft --example two-column-layout`"),
634
+ draftViewJson: z.string().optional().describe("行分组:JSON 二维字符串数组 `[[\"a\",\"b\"],[\"c\"]]`——**一行几个 code 就是几列**(不是靠 span);每个 code 必须同时出现在 draftAttributesJson。样例 `omc describe form.draft --example two-column-layout`"),
635
+ draftAttributesJson: z.string().optional().describe("控件表 `{code:{key,type,options:{name,span}}}`。**type 是表单控件枚举,不是字段 propertyType**(80=关联单选/201=子表…),错枚举拒 `form-control-type-mismatch`;span 是 24 栅格(两列 12/整宽 24,须与行分组自洽)。非字段控件 200/202/203 勿手拼,用 decorations"),
636
+ decorations: z
637
+ .array(z.object({
638
+ key: z.string().min(1).optional().describe("省略=自动生成 Description<序号>;带 key 命中既有布局控件=改它(其余 options 原样保留)"),
639
+ type: z.number().int().optional().describe("200 分组标题 / 202 描述说明(默认)/ 203 表单标题;已有控件不可原地改类型"),
640
+ html: z.string().optional().describe("202 的正文 HTML,写进 options.name(设计器同形,按 innerHTML 渲染)"),
641
+ name: z.string().optional().describe("200/203 的纯文本名;202 也可用它代替 html"),
642
+ span: z.number().int().positive().optional().describe("24 栅格宽度,∈6/8/12/16/18/24;插入已有行省略时用剩余宽度"),
643
+ row: z.number().int().positive().optional().describe("插入行,1-based;省略=末尾追加一行(span 默认 24)"),
644
+ }))
645
+ .optional()
646
+ .describe("增量加/改布局控件 200/202/203(202 的 html 写 options.name);与 draftViewJson/draftAttributesJson/layout/rebuild/fieldCodes/childColumns 互斥。样例 `omc describe form.draft --example form-description-block`"),
623
647
  layout: z
624
648
  .object({
625
649
  rows: z.array(z.array(z.string().min(1)).min(1)).min(1),
@@ -627,34 +651,35 @@ export function registerFormLane(tools) {
627
651
  includeSystem: z.boolean().optional(),
628
652
  })
629
653
  .optional()
630
- .describe("增量布局(推荐):{rows:[[\"a\",\"b\"],[\"c\"]],spans?:{a:12},includeSystem?}。以当前草稿为基线(草稿为空时退回已发布),只改 rows 行分组与这些控件 span,**不必回传整包 attrs**;未列入 rows 的控件保留原行,系统控件须 includeSystem:true 才动。与 draftViewJson/draftAttributesJson/rebuild/fieldCodes/childColumns/refreshFromFields/fromReadback 互斥"),
631
- allowTypeMismatch: z.boolean().optional().describe("放行控件 type 与字段 propertyType 不匹配(默认拒 form-control-type-mismatch;仅平台模板明确要求特殊控件时用)"),
654
+ .describe("增量布局(推荐):{rows:[[\"a\",\"b\"],[\"c\"]],spans?:{a:12},includeSystem?}。以当前草稿为基线(空则退回已发布),只改行分组与 span,**不必回传整包 attrs**;未列入 rows 的控件保留原行,系统控件须 includeSystem:true。与 draftViewJson/draftAttributesJson/rebuild/fieldCodes/childColumns/refreshFromFields/fromReadback/decorations 互斥"),
655
+ allowTypeMismatch: z.boolean().optional().describe("放行控件 type 与 propertyType 不匹配(默认拒 form-control-type-mismatch;仅平台模板要求时用)"),
632
656
  draftHtmlJson: z.string().optional(),
633
657
  fieldCodes: z.array(z.string().min(1)).optional().describe("脚手架绑定的已发布字段(按此顺序);由 configure_form/intent 显式传入。子表列写「父字段.子列」等价于 childColumns"),
634
658
  childColumns: z
635
659
  .array(z.object({ parent: z.string().min(1), fieldCodes: z.array(z.string().min(1)) }))
636
660
  .optional()
637
- .describe("把子表列绑进**已有** Sheet201 控件的 columns(issue #24):[{parent:\"items\",fieldCodes:[\"category\"]}]。只追加列,不动其它控件/布局行;无已存布局时退回 scaffold"),
661
+ .describe("把子表列绑进**已有** Sheet201 控件的 columns:`[{parent:\"items\",fieldCodes:[\"category\"]}]`。只追加列,不动其它控件/布局行;无已存布局时退回 scaffold"),
638
662
  rebuild: z.boolean().optional().describe("true 时丢弃现有草稿布局,按已发布字段重新生成(新增字段/子表要用它;默认保留现有草稿)"),
639
663
  refreshFromFields: z.boolean().optional().describe("true 时不重建布局,仅按当前已发布字段 options 刷新现有控件派生配置"),
640
- fromReadback: z.boolean().optional().describe("true = 本次 draftViewJson/draftAttributesJson 来自 form.get 的**逐字未改动**原文(平台自身布局可能含子表列行/系统行超宽,逐字回写放行)。语义是「回写」不是「我读过」:读过之后改过一个字符就不再是回读,会被拒(去掉本参数按普通写面校验)。只加子表列请用 configure_form 的 childColumns"),
664
+ fromReadback: z.boolean().optional().describe("true = draftViewJson/draftAttributesJson 是 form.get 的**逐字未改动**原文(平台自身布局的超宽行放行)。改过一字符就不是回读,会被拒;只加子表列用 childColumns"),
641
665
  allowEmptyLayout: z.boolean().optional().describe("显式放行空布局(\"[]\"/\"{}\")写入;默认拒绝(form-empty-layout),防设计器 Save 清空后照写丢控件"),
642
666
  buttons: z
643
667
  .array(z.record(z.unknown()))
644
668
  .optional()
645
- .describe("表单工具栏按钮(写进 biz_sheet.options.customButtonJson;publish 时才生成 h_biz_button(triggerType=FORM))。每条必填键见 contract form 的 formButtons;code 语义化"),
669
+ .describe("表单工具栏按钮(写进 options.customButtonJson;publish 时才生成 h_biz_button(triggerType=FORM))。必填键见 contract form 的 formButtons"),
646
670
  customButtonJson: z.string().optional().describe("buttons 的原样 JSON 数组字符串(与 buttons 互斥;用于把 form.get 读回值直接回写)"),
647
- buttonsMode: z.enum(["merge", "replace"]).optional().describe("默认 merge:按 code 增量 upsert(改一个按钮不必重发全表);replace:整表替换"),
671
+ buttonsMode: z.enum(["merge", "replace"]).optional().describe("默认 merge:按 code 增量 upsert;replace:整表替换"),
648
672
  removeButtonCodes: z.array(z.string().min(1)).optional().describe("要删除的按钮 code(仅 merge 模式)"),
649
- buttonScripts: z.array(z.object({ code: z.string().min(1), script: z.string() })).optional().describe("直接改已有表单按钮的脚本(actionConfig.scriptData),按 code 逐字替换;未知 code 拒绝。不必重发整表"),
673
+ buttonScripts: z.array(z.object({ code: z.string().min(1), script: z.string() })).optional().describe("直接改已有按钮脚本(actionConfig.scriptData),按 code 逐字替换;未知 code 拒绝"),
650
674
  },
651
675
  execute: async (session, args) => executeFormDraftWrite(session, { ...args, sheetCode: resolveSheetCode(args.schemaCode, args.sheetCode) }),
652
676
  preflight: (args) => {
653
677
  // Zero-wire refusal (ticket 74): fires in semanticGate BEFORE the
654
678
  // governed pipeline — including the rollback before-capture read.
655
679
  const resolved = { ...args, sheetCode: resolveSheetCode(args.schemaCode, args.sheetCode) };
656
- // layout 是增量面,与整包布局/重建参数互斥:纯参数门,零 wire。
680
+ // layout / decorations 是增量面,与整包布局/重建参数互斥:纯参数门,零 wire。
657
681
  assertLayoutRequestConflicts(resolved);
682
+ assertDecorationRequestConflicts(resolved);
658
683
  refuseEmptyCallerLayout(resolved);
659
684
  },
660
685
  // R75-B seam: dry-run 与真写共用这一个 session 只读 lint(dry-run 直接跑它)。
@@ -672,6 +697,14 @@ export function registerFormLane(tools) {
672
697
  });
673
698
  return { layout: composed.receipt, ...(composed.warnings.length > 0 ? { layoutWarnings: composed.warnings } : {}) };
674
699
  }
700
+ if (args.decorations !== undefined) {
701
+ const composed = await composeFormDecorationsDraft(session, {
702
+ schemaCode: args.schemaCode,
703
+ sheetCode: resolveSheetCode(args.schemaCode, args.sheetCode),
704
+ decorations: args.decorations,
705
+ });
706
+ return { decorations: composed.receipt, ...(composed.warnings.length > 0 ? { decorationWarnings: composed.warnings } : {}) };
707
+ }
675
708
  if (args.fromReadback === true)
676
709
  return { controlTypeCheck: "skipped-fromReadback" };
677
710
  const lint = await lintFormControlTypes(session, {
@@ -731,7 +764,7 @@ export function registerFormLane(tools) {
731
764
  customButtonJson: z.string().optional().describe("buttons 的原样 JSON 数组字符串(与 buttons 互斥)"),
732
765
  buttonsMode: z.enum(["merge", "replace"]).optional().describe("默认 merge:按 code 增量 upsert;replace:整表替换"),
733
766
  removeButtonCodes: z.array(z.string().min(1)).optional().describe("要删除的按钮 code(仅 merge 模式)"),
734
- buttonScripts: z.array(z.object({ code: z.string().min(1), script: z.string() })).optional().describe("直接改已有表单按钮的脚本(actionConfig.scriptData),按 code 逐字替换;未知 code 拒绝。不必重发整表"),
767
+ buttonScripts: z.array(z.object({ code: z.string().min(1), script: z.string() })).optional().describe("直接改已有按钮脚本(actionConfig.scriptData),按 code 逐字替换;未知 code 拒绝"),
735
768
  },
736
769
  execute: async (session, args) => executeFormPublishWrite(session, { ...args, sheetCode: resolveSheetCode(args.schemaCode, args.sheetCode) }),
737
770
  // R75-B 续:降级守卫(草稿控件数 < 发布面)此前只在真写里——空/残草稿的
@@ -3,7 +3,7 @@ import { RUNTIME_LANE, RUNTIME_TOOLS } from "./lane.js";
3
3
  import { z } from "zod";
4
4
  import { RUNTIME_DATA_WIRE, runtimeFormDataArg } from "../runtime-data-contract.js";
5
5
  import { projectReadbackRecord, readbackProjectionArgs } from "./shapes.js";
6
- import { DATA_TITLE_NOTE, childRowsNotDeletedWarnings, childTableMappingHits, diagnoseDbException, extractSequenceStatus, ignoredNullDiagnostic, loadExistingBizObject, loadPublishedFieldMeta, mappingRuntimeNoteFor, mappingSnapshotGapFor, nameOverwrittenNoteOf, normalizeLoadedRecord, prepareRuntimeFormData, readbackEmptyFields, readbackWarningFor, resolveFormSheetCode, resolvePublishedWorkflowCodeForNote, runtimeDataWarnings, staffFieldsPresent, staffStringShapeViolations, stripEngineOwnedKeys, unknownFieldDiagnostic } from "./write-support.js";
6
+ import { DATA_TITLE_NOTE, childRowsNotDeletedWarnings, childTableMappingHits, diagnoseDbException, extractSequenceStatus, fieldWriteMismatches, ignoredNullDiagnostic, loadExistingBizObject, loadPublishedFieldMeta, mappingRuntimeNoteFor, mappingSnapshotGapFor, nameOverwrittenNoteOf, normalizeLoadedRecord, prepareRuntimeFormData, readbackEmptyFields, readbackWarningFor, resolveFormSheetCode, resolvePublishedWorkflowCodeForNote, runtimeDataWarnings, staffFieldsPresent, staffStringShapeViolations, stripEngineOwnedKeys, unknownFieldDiagnostic } from "./write-support.js";
7
7
  import { applicationResolutionOf, isUncertainWireError, resolveApplicationScope } from "../../support.js";
8
8
  import { ToolRefusalError } from "../../tool-types.js";
9
9
  import { randomUUID } from "node:crypto";
@@ -12,7 +12,7 @@ import { runtimeWriteWithAppMapping } from "../../runtime-support.js";
12
12
  import { WireError, wireCall } from "../../wire.js";
13
13
  import { ENDPOINTS } from "../../endpoints.js";
14
14
  import { refusalFromWireError } from "../../wire-refusal.js";
15
- import { dataRuleSaveNotExecutedMessage, portalOnlyDataRules } from "./submission.js";
15
+ import { dataRuleSaveNotExecutedMessage, portalOnlyDataRules, NODE_FIELD_PERMISSION_WRITE_NOTE } from "./submission.js";
16
16
  /**
17
17
  * F1(探针 Z,0.8.34):普通 data.save / data.update 的写回执要披露「门户条件
18
18
  * 数据规则本次未执行」。复用 data.submit 已用的 portalOnlyDataRules 扫描(一次
@@ -297,6 +297,9 @@ export function registerDataSave(tools) {
297
297
  // F8(w63):显式传了 name 却被平台「数据标题」覆盖 → 回执点名(不改写入行为)。
298
298
  const nameOverwrittenNote = nameOverwrittenNoteOf(rawSaveData.name, savedRecord?.name);
299
299
  const savedEmptyFields = readbackEmptyFields(formData, savedRecord);
300
+ // issue #65:只有「带 id 的更新」做字段级对账。新建行的 `name` 被数据标题
301
+ // 覆盖是平台正常语义(另有 nameOverwrittenNote),不能因此把新建立案降级。
302
+ const savedWriteMismatches = saveIsUpdate ? fieldWriteMismatches(formData, savedRecord) : [];
300
303
  const dataWarnings = await runtimeDataWarnings(session, args.schemaCode, sheetCode, formData, 1);
301
304
  // F2(w112 探针 H):本段只在**未带 workflowCode** 的普通 save 上到达
302
305
  // (带 workflowCode 的流程草稿在上面的分支已 return)——所以这里至多付
@@ -354,14 +357,19 @@ export function registerDataSave(tools) {
354
357
  const dataRuleExecution = args.submit === true
355
358
  ? {}
356
359
  : await saveWriteDataRulesReadback(session, args.schemaCode, saveIsUpdate && extractSequenceStatus(existingSaveTarget) !== "DRAFT" ? "update" : "draft");
360
+ // F6(探针 AA,0.8.36):带 id 的 save 命中流程中的行时,节点字段权限只是
361
+ // 门户读面膜——REST 普通更新不校验,formData 照常落库。静态文案,零 wire。
362
+ const nodeFieldPermissionNote = saveIsUpdate && extractSequenceStatus(existingSaveTarget) === "PROCESSING" ? NODE_FIELD_PERMISSION_WRITE_NOTE : undefined;
357
363
  const plainReadback = {
358
364
  ...application,
359
365
  ...writeDiagnostics,
360
366
  ...(mappingRuntimeNote !== undefined ? { mappingRuntimeNote } : {}),
361
367
  ...(mappingSnapshotGap !== undefined ? { mappingSnapshotGap } : {}),
362
368
  ...(nameOverwrittenNote !== undefined ? { nameOverwrittenNote } : {}),
369
+ ...(nodeFieldPermissionNote !== undefined ? { nodeFieldPermissionNote } : {}),
363
370
  ...dataRuleExecution,
364
371
  authoritative: projectReadbackRecord(savedRecord, args),
372
+ ...(savedWriteMismatches.length > 0 ? { fieldWriteMismatch: savedWriteMismatches } : {}),
365
373
  ...(savedEmptyFields.length > 0 ? { readbackWarning: readbackWarningFor(savedEmptyFields, "data.save") } : {}),
366
374
  ...(dataWarnings.length > 0 ? { warnings: dataWarnings } : {}),
367
375
  // F2(w112 探针 H):有已发布流程的模型 + 未带 workflowCode = 没有流程实例的
@@ -583,9 +591,15 @@ export function registerDataUpdate(tools) {
583
591
  const sequenceStatus = extractSequenceStatus(readbackData);
584
592
  const updatedRecord = normalizeLoadedRecord(readbackData);
585
593
  const updatedEmptyFields = readbackEmptyFields(formData, updatedRecord);
594
+ // issue #65:读回非空但与请求不同(平台静默忽略/自动生成)→ 字段级对账。
595
+ // 读失败(updatedRecord=null)时返回空数组,不阻断写入。
596
+ const writeMismatches = fieldWriteMismatches(formData, updatedRecord);
586
597
  // F1(探针 Z):更新面条件规则同样不执行(服务端只做空值必填/重复);
587
598
  // DRAFT 目标行走 insert 语义文案,非 DRAFT 走 update 语义文案。
588
599
  const dataRuleExecution = await saveWriteDataRulesReadback(session, args.schemaCode, extractSequenceStatus(existing) === "DRAFT" ? "draft" : "update");
600
+ // F6(探针 AA,0.8.36):目标行在流程中时,节点 editable/visible 只是门户
601
+ // form/load 读面膜,REST 普通更新不校验——静态文案,零 wire。
602
+ const nodeFieldPermissionNote = extractSequenceStatus(existing) === "PROCESSING" ? NODE_FIELD_PERMISSION_WRITE_NOTE : undefined;
589
603
  return {
590
604
  performed: { errcode: performed.errcode, bizObjectId: returnedId, sheetCode, resolvedFrom },
591
605
  // Flat record contract (ticket 17): live FormLoadVO normalizes to the
@@ -594,7 +608,9 @@ export function registerDataUpdate(tools) {
594
608
  readback: {
595
609
  authoritative: projectReadbackRecord(updatedRecord, args),
596
610
  ...writeDiagnostics,
611
+ ...(writeMismatches.length > 0 ? { fieldWriteMismatch: writeMismatches } : {}),
597
612
  sequenceStatus,
613
+ ...(nodeFieldPermissionNote !== undefined ? { nodeFieldPermissionNote } : {}),
598
614
  ...dataRuleExecution,
599
615
  ...(updatedEmptyFields.length > 0 ? { readbackWarning: readbackWarningFor(updatedEmptyFields, "data.update") } : {}),
600
616
  ...(omitWarnings.length > 0 ? { warnings: omitWarnings } : {}),
@@ -512,8 +512,29 @@ export function compactRuntimeValue(value) {
512
512
  return compactRuntimeRecord(value);
513
513
  return value;
514
514
  }
515
+ /**
516
+ * F8(探针 AA,0.8.36):子表行的审计列默认折叠。平台 list_child 的默认列
517
+ * (`DefaultSubPropertyType.java`)无条件带 `id/parentId/sortKey/modifier/
518
+ * modifiedTime/version`,真机行另有 `sequenceNo/createdTime`——每行 5–7 个与
519
+ * 「改这一行」无关的键,一次 20 行子表读回就多几百字节。默认只留:
520
+ * `id`(改既有行)、`sortKey`(更新排序)、`name`(关联显示),业务列一律保留;
521
+ * `full:true` 仍走未压缩原文(compactRuntimeRecord 根本不进那条路径)。
522
+ *
523
+ * 只对**数组里的对象**(子表行)生效。形状证据必须是 `parentId` **且**(`sortKey`
524
+ * 或 `sequenceNo`):真实 list_child 行三者齐备;只看 `sortKey`/`sequenceNo` 会把
525
+ * 恰好带同名字段的**父记录**也当子行(把 parentId 之外 4 个键静默剥掉)。
526
+ * 人员/多选数组([{id,type,name}])不会被误剥;父记录只有同时命中子行三键才会,
527
+ * 而那意味着它本身就是子行。`full:true` 仍走未压缩原文,不受此判定影响。
528
+ */
529
+ export const CHILD_ROW_AUDIT_KEYS = new Set(["sequenceNo", "createdTime", "modifiedTime", "version", "parentId"]);
530
+ function isChildRowShape(record) {
531
+ if (record.parentId === undefined || record.parentId === null)
532
+ return false;
533
+ return record.sortKey !== undefined || record.sequenceNo !== undefined;
534
+ }
515
535
  export function compactRuntimeRecord(record) {
516
536
  const compact = {};
537
+ const childRow = isChildRowShape(record);
517
538
  for (const [key, value] of Object.entries(record)) {
518
539
  if (key.endsWith("_"))
519
540
  continue;
@@ -524,6 +545,8 @@ export function compactRuntimeRecord(record) {
524
545
  continue;
525
546
  if (RUNTIME_ENGINE_RECORD_KEYS.has(key))
526
547
  continue;
548
+ if (childRow && CHILD_ROW_AUDIT_KEYS.has(key))
549
+ continue;
527
550
  compact[key] = compactRuntimeValue(value);
528
551
  }
529
552
  return compact;
@@ -25,6 +25,15 @@ export const DATA_SUBMIT_RUN_MODE_SUPPORTED = new Set([]);
25
25
  * 而 form/load 会写 OPEN_FORM 审计——下一版再评估。
26
26
  */
27
27
  export const NODE_FIELD_PERMISSION_NOTE = "审批节点的 editable/visible 只作用于门户加载面(form/load 的读面膜);REST submit 不校验这些节点权限,formData 里的新值会照常落库。平台在提交面只校验 hidden/重复(checkType5),发起节点只校验必填(受 isCheckPropertyEmpty 控制)——不要以为「节点设了只读」就等于 REST 提交被拦。";
28
+ /**
29
+ * F6(探针 AA,0.8.36):**普通写面**(data.update / 带 id 的 data.save)在目标行
30
+ * 处于流程中(PROCESSING)时给同一事实:节点字段权限只是门户 form/load 读面膜,
31
+ * REST 普通更新不校验(同 NODE_FIELD_PERMISSION_NOTE 的平台证据:
32
+ * `AppPermissionValidator.java:210-224` 流程表单直接 return;
33
+ * `AbstractLoadPermissionService.java:172,295-304` 只在加载面套用节点权限)。
34
+ * 文案是静态的——不新增任何 wire。
35
+ */
36
+ export const NODE_FIELD_PERMISSION_WRITE_NOTE = "目标行处于流程中(sequenceStatus=PROCESSING):审批节点的 editable/visible 只作用于门户 form/load 的读面膜;REST 普通更新(data.update / 带 id 的 data.save)不校验节点字段权限,formData 的改动照常落库。要核对哪些字段在某节点只读,读 workflow.get_published 的 activities[].propertyPermissions。";
28
37
  export function assertSupportedRunMode(runMode) {
29
38
  if (runMode === undefined || runMode === null)
30
39
  return;
@@ -399,6 +408,17 @@ export function registerDataSubmit(tools) {
399
408
  message: "只传 workflowInstanceId 不够:平台 formType=1 的提交必须带 workItemId(审批现有待办)或 workflowCode(发起流程),否则稳定回 100002「参数 workflowInstanceId、workItemId 或 workflowCode 为空」。先 workitem.list 取待办 id,再带 workItemId 提交。",
400
409
  });
401
410
  },
411
+ // F6(探针 AA,0.8.36):dry-run 也说清「审批提交带 formData 时 REST 不校验
412
+ // 节点字段权限」。纯形状判定,零读、零 wire——与真写回执的
413
+ // nodeFieldPermissionNote 同源(同一常量)。
414
+ dryRunPayload: async (_session, args) => {
415
+ const hasWorkItem = typeof args.workItemId === "string" && args.workItemId.trim().length > 0;
416
+ const formData = (args.formData ?? {});
417
+ return {
418
+ ...(hasWorkItem && Object.keys(formData).length > 0 ? { nodeFieldPermissionNote: NODE_FIELD_PERMISSION_NOTE } : {}),
419
+ summary: `计划提交 ${args.schemaCode}`,
420
+ };
421
+ },
402
422
  execute: async (session, args) => {
403
423
  assertSupportedRunMode(args.runMode);
404
424
  // r13 #5: an EMPTY STRING was forwarded verbatim, so the platform answered
@@ -388,6 +388,118 @@ export function readbackEmptyFields(formData, record) {
388
388
  .filter(([key, value]) => value !== null && value !== undefined && (source[key] === null || source[key] === undefined))
389
389
  .map(([key]) => key);
390
390
  }
391
+ function datePrefix(value) {
392
+ if (typeof value !== "string")
393
+ return undefined;
394
+ const match = /^(\d{4}-\d{2}-\d{2})(?:[T\s].*)?$/.exec(value.trim());
395
+ return match?.[1];
396
+ }
397
+ /** 只有「无前导零的规范数字串」才做数值归一,避免把 `007`/长编码当数字。 */
398
+ function canonicalNumber(value) {
399
+ const trimmed = value.trim();
400
+ if (!/^-?(?:0|[1-9]\d*)(?:\.\d+)?$/.test(trimmed))
401
+ return undefined;
402
+ return String(Number(trimmed));
403
+ }
404
+ /** 关联/人员/组织:写侧可能是 id 串或 `{id,...}`,读回常是对象。 */
405
+ function relationIdentity(value) {
406
+ if (value === null || typeof value !== "object" || Array.isArray(value))
407
+ return undefined;
408
+ const row = value;
409
+ const id = row.id ?? row.bizObjectId ?? row.objectId;
410
+ if (typeof id === "string" && id)
411
+ return id;
412
+ const display = row.displayCode ?? row.code;
413
+ return typeof display === "string" && display ? display : undefined;
414
+ }
415
+ function booleanValue(value) {
416
+ if (value === true || value === 1 || value === "1" || value === "true")
417
+ return true;
418
+ if (value === false || value === 0 || value === "0" || value === "false")
419
+ return false;
420
+ return undefined;
421
+ }
422
+ function fieldValueMatches(requested, stored) {
423
+ if (requested === stored)
424
+ return true;
425
+ // 关联对象 ↔ id 串 / 读回对象。
426
+ if (requested !== null && typeof requested === "object") {
427
+ const requestedId = relationIdentity(requested);
428
+ if (requestedId === undefined)
429
+ return false;
430
+ const storedId = relationIdentity(stored);
431
+ if (storedId !== undefined)
432
+ return requestedId === storedId;
433
+ return typeof stored === "string" && stored.trim() === requestedId;
434
+ }
435
+ if (stored !== null && typeof stored === "object") {
436
+ const storedId = relationIdentity(stored);
437
+ return storedId !== undefined && typeof requested === "string" && requested.trim() === storedId;
438
+ }
439
+ // 布尔:平台常按 0/1 或 "true"/"false" 落库。
440
+ if (typeof requested === "boolean" || typeof stored === "boolean") {
441
+ const left = booleanValue(requested);
442
+ const right = booleanValue(stored);
443
+ return left !== undefined && right !== undefined && left === right;
444
+ }
445
+ // 日期:写 "2026-12-02",读回 "2026-12-02 00:00:00" —— 按前 10 位比。
446
+ const requestedDate = datePrefix(requested);
447
+ const storedDate = datePrefix(stored);
448
+ if (requestedDate !== undefined && storedDate !== undefined)
449
+ return requestedDate === storedDate;
450
+ // 数字:number 与数字串互认(42 / "42" / "42.0")。
451
+ if (typeof requested === "number" || typeof stored === "number") {
452
+ const left = typeof requested === "number" ? requested : typeof requested === "string" ? Number(requested) : Number.NaN;
453
+ const right = typeof stored === "number" ? stored : typeof stored === "string" ? Number(stored) : Number.NaN;
454
+ if (!Number.isNaN(left) && !Number.isNaN(right))
455
+ return left === right;
456
+ }
457
+ if (typeof requested === "string" && typeof stored === "string") {
458
+ const left = requested.trim();
459
+ const right = stored.trim();
460
+ if (left === right)
461
+ return true;
462
+ const leftNumber = canonicalNumber(left);
463
+ const rightNumber = canonicalNumber(right);
464
+ return leftNumber !== undefined && rightNumber !== undefined && leftNumber === rightNumber;
465
+ }
466
+ return false;
467
+ }
468
+ export function fieldWriteMismatches(formData, record) {
469
+ if (record === null || typeof record !== "object" || Array.isArray(record))
470
+ return [];
471
+ const source = record;
472
+ const mismatches = [];
473
+ for (const [field, requested] of Object.entries(formData)) {
474
+ if (field === "id")
475
+ continue;
476
+ // `name` 是系统列但在数据面可写(数据标题规则会覆盖它)——它正是 issue #65
477
+ // 的现场,所以这里不能走 `submittedBusinessFields`(那份表把 name 当系统键滤掉)。
478
+ if (RUNTIME_SYSTEM_FIELD_CODES.has(field) && field !== "name")
479
+ continue;
480
+ if (field.endsWith("_") || field.endsWith("_key"))
481
+ continue;
482
+ if (requested === null || requested === undefined)
483
+ continue;
484
+ // 子表数组/多值不在此面(读回形状不同,且另有 childRowsNotDeletedWarnings)。
485
+ if (Array.isArray(requested))
486
+ continue;
487
+ const stored = source[field];
488
+ if (stored === null || stored === undefined)
489
+ continue;
490
+ // 多选关联写侧是分号串、读回是数组:形状不可直接对账,跳过(宁漏报不误报)。
491
+ if (Array.isArray(stored))
492
+ continue;
493
+ // 只能比对「标量 ↔ 标量」或「关联对象 ↔ 关联对象/id 串」;无身份的对象形状跳过。
494
+ if (requested !== null && typeof requested === "object" && relationIdentity(requested) === undefined)
495
+ continue;
496
+ if (stored !== null && typeof stored === "object" && relationIdentity(stored) === undefined)
497
+ continue;
498
+ if (!fieldValueMatches(requested, stored))
499
+ mismatches.push({ field, requested, stored });
500
+ }
501
+ return mismatches;
502
+ }
391
503
  export function readbackWarningFor(emptyFields, toolName) {
392
504
  if (emptyFields.length === 0)
393
505
  return undefined;