@stalfh233/omc-cli 0.6.64 → 0.6.66

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.
@@ -82,6 +82,9 @@ const SURFACES = [
82
82
  description: "表单发布链:draft-first 布局、发布、publishedHtmlJson 绑定读回。",
83
83
  operations: ["get", "draft", "publish"],
84
84
  intent: { level: "partial", note: "draft/publish 已声明式;get 为读回面。" },
85
+ // 券商 issue 1.1(cpdocs 2026-10-27):子表控件的条件不在字段面——能力面
86
+ // 说清走法,agents 从 capabilities 进入(而非 next)时也能拿到同一条路由。
87
+ notes: "子表控件(type 201)的显示/只读条件(displayFormula/readonlyFormula)不在字段面(field.update 必拒,只管子表列):form.get(controls:true) 读 draftAttributesJson 定位控件 → form.draft 改 → form.publish。",
85
88
  },
86
89
  {
87
90
  id: "listview",
package/dist/cli.js CHANGED
@@ -7,7 +7,7 @@ import { createInterface } from "node:readline/promises";
7
7
  import { stdin, argv } from "node:process";
8
8
  import { createRequire } from "node:module";
9
9
  import { Command, CommanderError, Option } from "commander";
10
- import { ConfigStore, defaultPaths, removedProfileKeys } from "./config-store.js";
10
+ import { ConfigStore, defaultPaths, removedProfileKeys, resolveMainCheckout } from "./config-store.js";
11
11
  import { loadCoverageManifest, versionFamilyNotice } from "./coverage.js";
12
12
  import { redactText } from "./redact.js";
13
13
  import { readArgsFile, readStdinArgs, runToolCall, toolsByTextIntent, validateAgentPaths } from "./call.js";
@@ -613,7 +613,7 @@ async function cmdCall(store, args) {
613
613
  if (rawArgs === "-")
614
614
  parsedArgs = readStdinArgs();
615
615
  else if (argsFile)
616
- parsedArgs = readArgsFile(argsFile, resolve(process.env.OMC_CONFIG_HOME ?? process.cwd()));
616
+ parsedArgs = readArgsFile(argsFile, resolve(process.env.OMC_CONFIG_HOME ?? resolveMainCheckout(process.cwd())));
617
617
  else if (rawArgs) {
618
618
  parsedArgs = JSON.parse(rawArgs);
619
619
  if (parsedArgs === null || typeof parsedArgs !== "object" || Array.isArray(parsedArgs))
@@ -626,7 +626,9 @@ async function cmdCall(store, args) {
626
626
  // r10 F9: an out-of-root `--args-file` was reported under "--args 必须是
627
627
  // 合法 JSON", which points the reader at the wrong flag. Name the real
628
628
  // cause (and the configuration root) when the failure came from the file.
629
- const configRoot = resolve(process.env.OMC_CONFIG_HOME ?? process.cwd());
629
+ // 线上 #39-D:args-file 配置根与 .omc-envs 同源——worktree 下回退主检出
630
+ // (git 结构锚定),.scratch 参数文件不再因 worktree 被迫挪位置。
631
+ const configRoot = resolve(process.env.OMC_CONFIG_HOME ?? resolveMainCheckout(process.cwd()));
630
632
  // 1.1 of issue 2026-10-23: the old hint told the caller to write a TEMP file
631
633
  // while the validator only accepts paths under the config root — the two
632
634
  // instructions contradicted each other and neither named the root. Offer a
@@ -1,7 +1,38 @@
1
1
  import { existsSync, readFileSync, copyFileSync, chmodSync, mkdirSync, statSync } from "node:fs";
2
2
  import { dirname, join, resolve } from "node:path";
3
3
  import { homedir } from "node:os";
4
+ import { spawnSync } from "node:child_process";
4
5
  import { sync as writeFileAtomicSync } from "write-file-atomic";
6
+ /**
7
+ * 线上 #39 摩擦 D(詹记真机 2026-11-16):git worktree 下环境准入失效——`.omc-envs`
8
+ * 白名单绑定「当前目录」,同一仓库每开一个 worktree 就丢一次准入。回退解析:worktree 的
9
+ * `.git` 是指向主仓的指针文件,`git rev-parse --git-common-dir` 回主仓 `.git`,其父目录
10
+ * 即主检出。**git 结构锚定**(不是任意向上爬目录):仅当 cwd 的 .git 缺席或为指针文件、
11
+ * 且解析出的主检出 ≠ cwd 时才回退——白名单语义不变(同一 git 仓库 = 同一项目)。
12
+ */
13
+ export function resolveMainCheckout(projectDir = process.cwd()) {
14
+ const cwd = resolve(projectDir);
15
+ const dotGit = join(cwd, ".git");
16
+ if (!existsSync(dotGit))
17
+ return cwd; // 非 git 目录:不猜
18
+ try {
19
+ const stat = statSync(dotGit);
20
+ if (stat.isDirectory())
21
+ return cwd; // 主检出本身:无需回退
22
+ // .git 是文件(worktree 指针)——用 git 解析主仓
23
+ const r = spawnSync("git", ["rev-parse", "--git-common-dir"], { cwd, encoding: "utf8", timeout: 5_000 });
24
+ if (r.status === 0 && typeof r.stdout === "string") {
25
+ const commonDir = resolve(cwd, r.stdout.trim());
26
+ const mainCheckout = dirname(commonDir);
27
+ if (mainCheckout !== cwd && existsSync(join(mainCheckout, ".git")))
28
+ return mainCheckout;
29
+ }
30
+ }
31
+ catch {
32
+ // git 不可用/超时:按无回退处理
33
+ }
34
+ return cwd;
35
+ }
5
36
  /**
6
37
  * Removed governance keys. This is a development branch: seeing one of these in
7
38
  * an operator's omc.config.json is an error to be fixed, never silently ignored
@@ -160,15 +191,36 @@ export class ConfigStore {
160
191
  return [...names];
161
192
  }
162
193
  readProjectEnvBinding() {
163
- if (!existsSync(this.paths.projectEnvPath))
164
- return undefined;
165
- const name = readFileSync(this.paths.projectEnvPath, "utf8").trim();
166
- return name || undefined;
194
+ if (existsSync(this.paths.projectEnvPath)) {
195
+ const name = readFileSync(this.paths.projectEnvPath, "utf8").trim();
196
+ if (name)
197
+ return name;
198
+ }
199
+ // 线上 #39-D:worktree 下回退主检出的 .omc-env(cwd 无绑定或空时)。
200
+ const main = join(resolveMainCheckout(dirname(this.paths.projectEnvPath)), ".omc-env");
201
+ if (main !== this.paths.projectEnvPath && existsSync(main)) {
202
+ const name = readFileSync(main, "utf8").trim();
203
+ if (name)
204
+ return name;
205
+ }
206
+ return undefined;
167
207
  }
168
208
  readProjectEnvsFile() {
169
- if (!existsSync(this.paths.projectEnvsPath))
209
+ const fromCwd = this.readEnvsFrom(this.paths.projectEnvsPath);
210
+ if (fromCwd.length > 0)
211
+ return fromCwd;
212
+ // 线上 #39-D:worktree 丢环境准入——cwd 的 .omc-envs 不存在/为空时,回退同一
213
+ // git 仓库主检出的白名单(git 结构锚定,见 resolveMainCheckout)。显式本地文件
214
+ // 优先(worktree 里 omc env allow 写的是 cwd,语义保持)。
215
+ const main = join(resolveMainCheckout(dirname(this.paths.projectEnvsPath)), ".omc-envs");
216
+ if (main !== this.paths.projectEnvsPath)
217
+ return this.readEnvsFrom(main);
218
+ return [];
219
+ }
220
+ readEnvsFrom(path) {
221
+ if (!existsSync(path))
170
222
  return [];
171
- return readFileSync(this.paths.projectEnvsPath, "utf8")
223
+ return readFileSync(path, "utf8")
172
224
  .split(/\r?\n/u)
173
225
  .map((line) => line.replace(/#.*$/u, "").trim())
174
226
  .filter((line) => line !== "");
@@ -174,7 +174,13 @@ export function prepareFieldUpdate(input) {
174
174
  blocker: "child-table-update-unsupported",
175
175
  schemaCode: input.schemaCode,
176
176
  propertyCode: input.code,
177
- message: `子表字段 ${input.schemaCode}.${input.code} 不接受 options/choices/subFields。子表列就是 schemaCode=${input.code} 上的普通字段:增列用 field.create --args '{"schemaCode":"${input.code}","code":"<子列>",...}',改列/删列用 field.update/field.delete(同 schemaCode),改完对父模型 field.publish 即发布`,
177
+ // 券商 issue 1.1(cpdocs 2026-10-27):拒收文案此前只讲「子表**列**怎么改」,
178
+ // 没讲「子表**控件**(type 201)的显示/只读条件怎么改」——可行路径是表单
179
+ // attributes(form.draft 的 draftAttributesJson),不是字段面。调用方传的
180
+ // options 正是条件键时,第一句就指对路,别让他再撞一次。
181
+ message: `子表字段 ${input.schemaCode}.${input.code} 不接受 options/choices/subFields。子表列就是 schemaCode=${input.code} 上的普通字段:增列用 field.create --args '{"schemaCode":"${input.code}","code":"<子列>",...}',改列/删列用 field.update/field.delete(同 schemaCode),改完对父模型 field.publish 即发布。${input.options !== undefined && ["displayFormula", "readonlyFormula", "requiredFormula"].some((key) => key in input.options)
182
+ ? `你传的 options 是子表控件(type 201)的显示/只读条件——它不在字段面(此处必拒):form.get(controls:true) 读 draftAttributesJson 定位控件 → form.draft 改该控件条件 → form.publish(cpdocs issue 2026-10-27 §1.1)`
183
+ : `改子表控件(type 201)的显示/只读条件(displayFormula/readonlyFormula)也不在字段面:form.get(controls:true) → form.draft(draftAttributesJson)→ form.publish(cpdocs issue 2026-10-27 §1.1)`}`,
178
184
  });
179
185
  const currentOptions = decodeJsonObjectColumn(input.base.options, { invalid: "throw", array: "accept", object: "accept" }) ?? {};
180
186
  const rebuiltOptions = isChildTable
@@ -834,20 +834,21 @@ export function refuseEmptyCallerLayout(args) {
834
834
  }
835
835
  /**
836
836
  * Form-toolbar buttons are a THREE-LAYER configuration (live 2026-10-23, 1.1.25
837
- * + backend source):
838
- * 1. `bizsheet.options.customButtonJson` (a STRINGIFIED JSON array) is the
839
- * authoring face — `ModelManagementFacadeImpl.publishBizForm:1022` turns it
837
+ * + backend source; shape corrected by GitLab #38, live 8.6.26 2026-11-16):
838
+ * 1. `bizsheet.options.customButtonJson` — a JSON ARRAY with each entry's
839
+ * `actionConfig` as an OBJECT (the designer's own save shape) — is the
840
+ * authoring face; `ModelManagementFacadeImpl.publishBizForm:1022` turns it
840
841
  * into `h_biz_button` rows with `triggerType=FORM`, `triggerCode=<formCode>`
841
- * at publish time.
842
+ * at publish time. The pre-r72 CLI wrote a STRINGIFIED array (double JSON
843
+ * encoding); the platform stores that string verbatim in the JSON column
844
+ * and the form page then silently drops every button (#38: designer-shaped
845
+ * columns render, stringified ones never do — version drift vs the 1.1.25
846
+ * fastjson refusal, which is why the string form was ever written).
842
847
  * 2. Those rows are what `ActionPermissionHandler` reads
843
848
  * (`getByTriggerTypeAndCode(FORM, bizCode)`).
844
849
  * 3. Whether a button shows at a given node is filtered by the workflow
845
850
  * activity's `buttonPermission.customBtns[].enabled` (the designer's
846
851
  * 「表单操作」 checkboxes) plus `showPermCode`.
847
- *
848
- * `customButtonJson` MUST stay a string inside the options JSON — passing the
849
- * array inline makes the platform answer 50000 (fastjson
850
- * "syntax error, position at 0, name customButtonJson").
851
852
  */
852
853
  export const FORM_BUTTON_LOCATIONS = Object.freeze(["FORM", "ROW", "LIST"]);
853
854
  const FORM_BUTTON_BIND_ACTIONS = new Set([
@@ -906,6 +907,17 @@ export function validateFormButtons(buttons, tool) {
906
907
  if ((bindAction === "BUSINESS_RULE" || bindAction === "FLOW") && (typeof button.targetCode !== "string" || button.targetCode === ""))
907
908
  throw new ToolRefusalError({ status: "refused", blocker: "form-buttons-invalid", message: `${tool}: buttons[${index}] ${bindAction} 需要 targetCode` });
908
909
  }
910
+ // actionConfig rides inside options.customButtonJson as a JSON OBJECT —
911
+ // the designer's own shape (live #38, 8.6.26). The old code serialized it
912
+ // once (the h_biz_button.actionConfig WIRE column is a String), but on the
913
+ // stored-options face a stringified actionConfig inside a stringified
914
+ // customButtonJson is exactly the double encoding that made the form page
915
+ // silently drop every button. A stringified blob from a legacy readback is
916
+ // unwrapped to the object; a corrupt one refuses.
917
+ if (rawConfig !== undefined && rawConfig !== null && (Array.isArray(rawConfig) || typeof rawConfig !== "object") && typeof rawConfig !== "string")
918
+ throw new ToolRefusalError({ status: "refused", blocker: "form-buttons-invalid", message: `${tool}: buttons[${index}].actionConfig 必须是对象(或其 JSON 字符串)` });
919
+ if (rawConfig !== undefined && typeof rawConfig === "string" && rawConfig.trim() !== "" && config === undefined && scriptShorthand === undefined)
920
+ throw new ToolRefusalError({ status: "refused", blocker: "form-buttons-invalid", message: `${tool}: buttons[${index}].actionConfig 不是合法 JSON 对象(解析失败)` });
909
921
  return {
910
922
  ...button,
911
923
  code,
@@ -913,13 +925,9 @@ export function validateFormButtons(buttons, tool) {
913
925
  useLocation,
914
926
  bindAction,
915
927
  operateType,
916
- // actionConfig is a String column: serialize exactly once (double
917
- // encoding breaks the renderer). `script` merges into scriptData.
918
- ...(scriptShorthand !== undefined
919
- ? { actionConfig: JSON.stringify({ ...(config ?? {}), scriptData: scriptShorthand }) }
920
- : button.actionConfig !== undefined && typeof button.actionConfig !== "string"
921
- ? { actionConfig: JSON.stringify(button.actionConfig) }
922
- : {}),
928
+ ...(config !== undefined || scriptShorthand !== undefined
929
+ ? { actionConfig: { ...(config ?? {}), ...(scriptShorthand !== undefined ? { scriptData: scriptShorthand } : {}) } }
930
+ : {}),
923
931
  sortKey: typeof button.sortKey === "number" ? button.sortKey : index,
924
932
  };
925
933
  });
@@ -1019,28 +1027,77 @@ export function mergeFormOptionsWithButtons(existingOptions, input, tool) {
1019
1027
  else if (rawConfig !== null && typeof rawConfig === "object" && !Array.isArray(rawConfig)) {
1020
1028
  config = { ...rawConfig };
1021
1029
  }
1022
- byCode.set(patch.code, { ...current, actionConfig: JSON.stringify({ ...config, scriptData: patch.script }) });
1030
+ byCode.set(patch.code, { ...current, actionConfig: { ...config, scriptData: patch.script } });
1023
1031
  }
1024
1032
  final = [...byCode.values()].map((button, index) => ({ ...button, sortKey: typeof button.sortKey === "number" ? button.sortKey : index }));
1025
1033
  }
1026
1034
  if (removeCodes.length > 0 && mode === "replace")
1027
1035
  throw new ToolRefusalError({ status: "refused", blocker: "form-buttons-invalid", message: `${tool}: removeButtonCodes 只用于 buttonsMode:"merge"(replace 已用新列表整体替换)` });
1028
- options.customButtonJson = JSON.stringify(final);
1036
+ // #38: the column rides `options` as a JSON ARRAY (designer shape) — the
1037
+ // options column itself is serialized once for the wire, so an extra
1038
+ // JSON.stringify here is double encoding the platform stores verbatim and
1039
+ // the form page then drops every button. Legacy dirty entries (a
1040
+ // stringified actionConfig inside an ARRAY-form rewrite of a stringified
1041
+ // column) are unwrapped on the way through, so ANY button write heals the
1042
+ // whole list.
1043
+ options.customButtonJson = final.map(unwrapButtonActionConfig);
1029
1044
  return JSON.stringify(options);
1030
1045
  }
1031
- /** The caller's buttons from a READ face (parsed array, or null when absent). */
1032
- export function readFormButtons(options) {
1033
- const record = decodeOptionsColumn(options);
1034
- const raw = record.customButtonJson;
1035
- if (typeof raw !== "string" || raw === "")
1036
- return null;
1046
+ /** #38: a stored legacy button may carry a STRINGIFIED actionConfig (the old
1047
+ * CLI write shape). Unwrap it to the object form so a rewrite heals it; a
1048
+ * corrupt blob is passed through untouched for the readback lint to name. */
1049
+ function unwrapButtonActionConfig(button) {
1050
+ const rawConfig = button.actionConfig;
1051
+ if (typeof rawConfig !== "string" || rawConfig.trim() === "")
1052
+ return button;
1037
1053
  try {
1038
- const parsed = JSON.parse(raw);
1039
- return Array.isArray(parsed) ? parsed : null;
1054
+ const parsed = JSON.parse(rawConfig);
1055
+ if (parsed !== null && typeof parsed === "object" && !Array.isArray(parsed))
1056
+ return { ...button, actionConfig: parsed };
1040
1057
  }
1041
1058
  catch {
1042
- return null;
1059
+ // corrupt blob: leave verbatim — form.get/readback shape lint names it
1060
+ }
1061
+ return button;
1062
+ }
1063
+ export function customButtonJsonStoredShape(options) {
1064
+ const record = decodeOptionsColumn(options);
1065
+ const raw = record.customButtonJson;
1066
+ if (raw === null || raw === undefined || raw === "")
1067
+ return "absent";
1068
+ if (Array.isArray(raw))
1069
+ return "array";
1070
+ if (typeof raw === "string") {
1071
+ try {
1072
+ return Array.isArray(JSON.parse(raw)) ? "string" : "absent";
1073
+ }
1074
+ catch {
1075
+ return "absent";
1076
+ }
1077
+ }
1078
+ return "absent";
1079
+ }
1080
+ export const CUSTOM_BUTTON_JSON_STRING_SHAPE_WARNING = "customButtonJson 被存为字符串(双重编码)——前端按钮不渲染,设计器形状=数组+actionConfig 对象(线上 #38);用 form.draft/form.publish 重写 buttons 即自愈";
1081
+ /** The caller's buttons from a READ face (parsed array, or null when absent).
1082
+ * #39/#38: decodes BOTH stored forms — the designer's ARRAY (authoritative;
1083
+ * the read face used to be blind to it and answered null while the store
1084
+ * held real buttons) and the legacy stringified one (dirty stores must read
1085
+ * back too, flagged by customButtonJsonStoredShape). */
1086
+ export function readFormButtons(options) {
1087
+ const record = decodeOptionsColumn(options);
1088
+ const raw = record.customButtonJson;
1089
+ let parsed = raw;
1090
+ if (typeof raw === "string") {
1091
+ if (raw === "")
1092
+ return null;
1093
+ try {
1094
+ parsed = JSON.parse(raw);
1095
+ }
1096
+ catch {
1097
+ return null;
1098
+ }
1043
1099
  }
1100
+ return Array.isArray(parsed) ? parsed : null;
1044
1101
  }
1045
1102
  export async function executeFormDraftWrite(session, args) {
1046
1103
  // 兼容别名:`fieldCodes:["items.category"]` 等价于
@@ -1430,6 +1487,9 @@ export async function executeFormDraftWrite(session, args) {
1430
1487
  readback: {
1431
1488
  hasDraft: sheet.existDraft === true || typeof sheet.draftViewJson === "string",
1432
1489
  ...(formButtons !== null ? { formButtons, formButtonCodes: formButtons.map((button) => String(button.code ?? "")) } : {}),
1490
+ // #38 shape lint: the readback must never echo "configured" while the
1491
+ // stored column is the stringified form the form page refuses to render.
1492
+ ...(customButtonJsonStoredShape(sheet.options) === "string" ? { formButtonsShapeWarning: CUSTOM_BUTTON_JSON_STRING_SHAPE_WARNING } : {}),
1433
1493
  ...(mergedOptions !== undefined ? { customButtonJsonWritten: true } : {}),
1434
1494
  ...(roundTripFaces.size > 0
1435
1495
  ? {
@@ -1666,6 +1726,8 @@ export async function executeFormPublishWrite(session, args) {
1666
1726
  formButtonNote: "按钮已写入 options.customButtonJson,本次 publish 已生成 h_biz_button(triggerType=FORM);表单页是否显示还取决于流程节点 buttonPermission.customBtns[].enabled(设计器「表单操作」勾选)",
1667
1727
  }
1668
1728
  : {}),
1729
+ // #38 shape lint — same guard as the form.draft readback.
1730
+ ...(customButtonJsonStoredShape(sheet.options) === "string" ? { formButtonsShapeWarning: CUSTOM_BUTTON_JSON_STRING_SHAPE_WARNING } : {}),
1669
1731
  },
1670
1732
  };
1671
1733
  }
@@ -340,7 +340,7 @@ export function registerBusinessRuleLane(tools) {
340
340
  description: RULE_TOOLS["rule.get"].description,
341
341
  inputSchema: {
342
342
  environment: environmentArg,
343
- id: z.string().min(1).optional().describe("规则记录 id(历史版本行可能指向旧图);也可改用 schemaCode + ruleCode 业务键定位"),
343
+ id: z.string().min(1).optional().describe("规则记录 id——更新会铸新 ID,旧 id 读到旧图(回执标 staleId/latestId);当前生效行用 schemaCode + ruleCode 定位"),
344
344
  schemaCode: z.string().min(1).optional().describe("业务键定位:模型 code(与 ruleCode 同传,免去先 rule.list 取 id)"),
345
345
  ruleCode: z.string().min(1).optional().describe("业务键定位:规则 code(如 Create/Update/自定义),与 schemaCode 同传"),
346
346
  full: z.boolean().optional().describe("返回原始存储图(含确定性布局 x/y/width/height 与路由 points);默认返回语义图,确定性布局已投影去掉(可直接重存,保存时会重新生成布局)"),
@@ -392,6 +392,10 @@ export function registerBusinessRuleLane(tools) {
392
392
  // Ticket 109 — stale-row detection: same-code saves mint NEW record
393
393
  // ids while old ids stay readable (historical graphs). Reading by a
394
394
  // superseded id shows an OLD graph; flag it and pin the effective id.
395
+ // Online #39 (friction E) sharpens the receipt: the frontend holding
396
+ // the old id renders the old graph and reads as "the change didn't
397
+ // take" — so the flag set also carries the issue-shaped trio
398
+ // (staleId/latestId/note) next to the ticket-109 names.
395
399
  let staleRow = false;
396
400
  let effectiveId;
397
401
  let staleRowMessage;
@@ -409,6 +413,7 @@ export function registerBusinessRuleLane(tools) {
409
413
  // the list face being unreachable must not break the row readback
410
414
  }
411
415
  }
416
+ const staleNote = "该 ID 非当前生效行——rule.save 更新会生成新记录 ID,旧 ID 仍可读旧图;用 latestId 或按 ruleCode 读";
412
417
  const projected = projectRuleGraph(parse(record.node), routes, args.full === true);
413
418
  // 存量体检(2026-10-16 中冶反馈):读回不只给结构,还跑一次写面同源的
414
419
  // dry-lint,把"已启用但运行时会被静默跳过/UI 独有算子/选项 key 撞车"
@@ -463,7 +468,7 @@ export function registerBusinessRuleLane(tools) {
463
468
  schedulerSetting: parse(record.schedulerSetting),
464
469
  renderCompat,
465
470
  ...(semanticFindings ? { semanticFindings } : {}),
466
- ...(staleRow ? { staleRow, effectiveId, staleRowMessage } : {}),
471
+ ...(staleRow ? { staleRow, effectiveId, staleRowMessage, staleId: true, latestId: effectiveId, note: staleNote } : {}),
467
472
  };
468
473
  if (args.withRuntime === true) {
469
474
  const coding = record.developmentMode === 1 || record.developmentMode === "1" || record.developmentMode === "CODING";
@@ -516,6 +521,9 @@ export function registerBusinessRuleLane(tools) {
516
521
  ? payload.schedulerSetting.dataSourceType
517
522
  : undefined,
518
523
  ...(payload.statusLag ? { statusLag: payload.statusLag, statusNote: payload.statusNote } : {}),
524
+ // #39 摩擦 E:summary 面也要带 stale 提示——持旧 id 的调用方常只看
525
+ // summary,漏掉 stale 会把旧图当成「改了没生效」。
526
+ ...(staleRow ? { staleId: true, latestId: effectiveId, note: staleNote } : {}),
519
527
  };
520
528
  }
521
529
  if (args.keys !== undefined) {
@@ -74,7 +74,14 @@ const recordSchema = z.object({
74
74
  sortKey: z.number().int().default(0),
75
75
  initialUsed: z.boolean().optional(),
76
76
  }).passthrough();
77
- const recordsArg = z.array(recordSchema.extend({ children: z.array(recordSchema).optional() })).optional();
77
+ // cpdocs issue 2026-10-30(pwsh-ergonomics)附带项:平台 save 是**增量 upsert**,
78
+ // records 只新增/更新提交的条目——`records:[]` 是空操作、不会清空既有记录
79
+ // (平台无字典/字典项删除端点;清空意图走 dictionary.status 逐条停用)。
80
+ // 写进参数 describe,别让「ok:true」被读成「已清空」。
81
+ const recordsArg = z
82
+ .array(recordSchema.extend({ children: z.array(recordSchema).optional() }))
83
+ .optional()
84
+ .describe("增量 upsert:只写提交的条目;records:[] 不清空既有记录(无字典删除端点,停用用 dictionary.status)");
78
85
  function normalizeRecord(record, dictionaryId, parentId) {
79
86
  const children = Array.isArray(record.children) ? record.children.map((child) => normalizeRecord(child, dictionaryId, String(record.id ?? parentId ?? "") || null)) : undefined;
80
87
  return {
@@ -339,6 +339,10 @@ export function registerFieldLane(tools) {
339
339
  // 不必再跑 published:true 交叉核对。
340
340
  const publishedCodes = new Set(wireRows((await wireCall(session, { path: ENDPOINTS.fieldList, query: { schemaCode: args.schemaCode, isPublish: "true" } })).data)
341
341
  .map((row) => String(row.code ?? row.propertyCode)));
342
+ // 券商 issue 1.4(cpdocs 2026-10-27)补充:双面比对已经拉过发布面,
343
+ // 空清单时顺手数出「发布面有几个业务字段」——把 hint 从「三种可能」
344
+ // 收敛成一句可执行的判定(有 N 个 → 加 published:true 就能看到)。
345
+ const publishedBusinessCount = [...publishedCodes].filter((code) => !isSystemFieldCode(code)).length;
342
346
  const mapped = rows.map((row) => {
343
347
  const type = Number(row.type ?? row.propertyType);
344
348
  const typeLabel = fieldTypeLabel(row.type ?? row.propertyType);
@@ -453,13 +457,18 @@ export function registerFieldLane(tools) {
453
457
  ...(args.all !== true ? { businessOnly: true } : {}),
454
458
  fields: projected,
455
459
  // 券商 issue 1.4(2026-10-27):默认面空清单曾被误读成「模型没有字段」。
456
- // 空清单要自己解释三种可能,别让 agent 二次试错。
460
+ // 空清单要自己解释三种可能,别让 agent 二次试错;发布面(published:true)
461
+ // 查空时文案要换——再说「字段可能都在 published 面」就是在指一条已走过的路。
457
462
  ...(detailed
458
463
  ? {}
459
464
  : {
460
465
  inventory: true,
461
466
  hint: projected.length === 0
462
- ? "字段详情(options/subSchema)用 code/fields 选择器或 full:true。当前 draft 面没有业务字段——字段可能都在 published 面(published:true)、尚未创建,或只有系统字段(all:true 核对)"
467
+ ? args.published === true
468
+ ? "发布面没有业务字段——可能尚未发布(先 published:false 看草稿面)、尚未创建,或只有系统字段(all:true 核对)。字段详情(options/subSchema)用 code/fields 选择器或 full:true"
469
+ : publishedBusinessCount > 0
470
+ ? `字段详情(options/subSchema)用 code/fields 选择器或 full:true。当前 draft 面没有业务字段,但发布面有 ${publishedBusinessCount} 个业务字段——加 published:true 查看`
471
+ : "字段详情(options/subSchema)用 code/fields 选择器或 full:true。当前 draft 面没有业务字段——字段可能都在 published 面(published:true)、尚未创建,或只有系统字段(all:true 核对)"
463
472
  : "字段详情(options/subSchema)用 code/fields 选择器或 full:true",
464
473
  }),
465
474
  };
@@ -15,12 +15,12 @@ export const FORM_WIRE = Object.freeze({
15
15
  publishAlreadyPublished: "published:true with force!==true skips as already-published",
16
16
  forceRepublish: "onlinejs.compose passes force:true so it can re-promote after a prior publish",
17
17
  emptyLayoutGuard: "ticket 74: the platform designer's Save is NOT lossless — it clears draftViewJson to \"[]\" and draftAttributesJson to \"{}\"; form.draft refuses CALLER-PROVIDED empty layouts (blocker form-empty-layout, zero wire, escape allowEmptyLayout:true) and form.publish refuses to promote a draft with fewer controls than the published face (blocker form-publish-degrade, escape allowDegrade:true); the recovery path is the form version history (/api/api/app/bizsheet/history/list) — fetch the intact version's view/attributes originals and rewrite the draft before publishing",
18
- formButtons: "form toolbar buttons are a three-layer configuration (live 2026-10-23, 1.1.25): (1) bizsheet.options.customButtonJson — a STRINGIFIED JSON array — is the authoring face; ModelManagementFacadeImpl.publishBizForm:1022 turns it into h_biz_button rows with triggerType=FORM, triggerCode=<formCode> at publish; (2) those rows are what ActionPermissionHandler.getByTriggerTypeAndCode(FORM, bizCode) reads; (3) whether a button shows at a node is filtered by the workflow activity's buttonPermission.customBtns[].enabled (the designer 表单操作 checkboxes) plus showPermCode; the execute face is POST /api/api/runtime/form/executeCustomButton {bizButtonModel, bizObjectList:[<full bizObject>], reacquireDataFromDb:true} — NOT the list-button launcher path with ids[]",
18
+ formButtons: "form toolbar buttons are a three-layer configuration (live 2026-10-23, 1.1.25; shape corrected by GitLab #38 live 8.6.26 2026-11-16): (1) bizsheet.options.customButtonJson — a JSON ARRAY with each entry's actionConfig as an OBJECT (the designer's save shape; a STRINGIFIED array is double encoding the platform stores verbatim and the form page then silently drops every button — the pre-r72 CLI form, now unwrapped+healed on every write and linted via shapeWarning in readbacks) — is the authoring face; ModelManagementFacadeImpl.publishBizForm:1022 turns it into h_biz_button rows with triggerType=FORM, triggerCode=<formCode> at publish; (2) those rows are what ActionPermissionHandler.getByTriggerTypeAndCode(FORM, bizCode) reads; (3) whether a button shows at a node is filtered by the workflow activity's buttonPermission.customBtns[].enabled (the designer 表单操作 checkboxes) plus showPermCode; the execute face is POST /api/api/runtime/form/executeCustomButton {bizButtonModel, bizObjectList:[<full bizObject>], reacquireDataFromDb:true} — NOT the list-button launcher path with ids[]",
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
  });
21
- const FORM_GET_DESCRIPTION = '读取默认表单(bizsheet/get)的发布状态与控件清单(紧凑默认)。**发布态以返回的 `published` / `existDraft` 布尔为准**(`published:true`=已发布;`published:false,existDraft:true`=只有草稿,**未发布**)——不要用 `publishedControlCodes` 是否非空来推断(草稿字段会让它非空,误判为已发布)。**每个模型交付前其默认表单必须 `published:true`**:用 `configure_form` 或 `form.draft(rebuild:true)`+`form.publish` 发布,并逐模型 `form.get` 核对。`full:true` 还返回 `options` 与解析后的 `customButtonJson`(表单工具栏按钮)。传 `controls:["code",…]` 只取指定控件的 options(如关联控件的 mappings);传 `full:true` 才返回 draft/published 的完整 view/attributes/html/actions JSON(actions 列为设计器保存/发布的表单级按钮动作)。体积大,仅在需要整体布局时用。';
22
- 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`;**要到 form.publish 才生成 h_biz_button(triggerType=FORM)**,且表单页是否显示还取决于流程节点 `buttonPermission.customBtns[].enabled`(设计器「表单操作」勾选)。`useLocation` 用 FORM/ROW/LIST,表单工具栏按钮用 FORM。 **表单控件属性(含关联填充 mappings)从字段行派生**:改关联映射的事实源在字段 options.mappings(field.update → field.publish),直接改这里的控件映射会被平台按字段重算覆盖(真机 2026-10-14 实证);字段发布后如需刷新已发布表单的控件映射,用本工具 rebuild:false 重存(保留现有布局与在线JS)再 form.publish。";
23
- 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` 必须是**字符串化数组**(对象会 50000 syntax error);表单页是否显示再由流程节点 `buttonPermission.customBtns[].enabled` 过滤。";
21
+ const FORM_GET_DESCRIPTION = '读取默认表单(bizsheet/get)的发布状态与控件清单(紧凑默认)。**发布态以返回的 `published` / `existDraft` 布尔为准**(`published:true`=已发布;`published:false,existDraft:true`=只有草稿,**未发布**)——不要用 `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 列为设计器保存/发布的表单级按钮动作)。体积大,仅在需要整体布局时用。';
22
+ 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。 **表单控件属性(含关联填充 mappings)从字段行派生**:改关联映射的事实源在字段 options.mappings(field.update → field.publish),直接改这里的控件映射会被平台按字段重算覆盖(真机 2026-10-14 实证);字段发布后如需刷新已发布表单的控件映射,用本工具 rebuild:false 重存(保留现有布局与在线JS)再 form.publish。";
23
+ 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` 过滤。";
24
24
  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`(launcher/domain_service_runtime/<schema>/<rule> + ids[])**——同一绑定规则在 rule.run 面已验证可用(r28b 实证),不要在 executeCustomButton 上反复重试。";
25
25
  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).";
26
26
  export const FORM_LANE_CONTRACT = Object.freeze({
@@ -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, readFormButtons, readFormOrNull, refuseEmptyCallerLayout, validateHtmlRender } from "../form-support.js";
4
+ import { executeFormDraftWrite, executeFormPublishWrite, executeFormRunButtonWrite, readFormButtons, readFormOrNull, refuseEmptyCallerLayout, validateHtmlRender, customButtonJsonStoredShape, CUSTOM_BUTTON_JSON_STRING_SHAPE_WARNING } 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";
@@ -158,7 +158,14 @@ export function registerFormLane(tools) {
158
158
  // used to drop `options`, so a read→write round trip could never
159
159
  // carry the buttons back.
160
160
  options: sheet.options ?? null,
161
+ // #39 (GitLab, live 8.6.26): the authoritative button read. This
162
+ // projection used to decode ONLY the legacy stringified form, so a
163
+ // designer-authored ARRAY came back null while the store held real
164
+ // buttons — the read face was blind to them. readFormButtons now
165
+ // decodes both; a dirty stringified column is parsed AND flagged
166
+ // instead of silently echoed as "configured".
161
167
  customButtonJson: readFormButtons(sheet.options),
168
+ ...(customButtonJsonStoredShape(sheet.options) === "string" ? { customButtonJsonShapeWarning: CUSTOM_BUTTON_JSON_STRING_SHAPE_WARNING } : {}),
162
169
  // Ticket 109 — render compatibility: the Online JS panel resolves
163
170
  // generateCodeType(e) whose first line is `if(!e||!e.tagName)
164
171
  // return ""` and then does o[type].push(...) (54286.fbbb415f.js)
@@ -304,7 +311,7 @@ export function registerFormLane(tools) {
304
311
  buttons: z
305
312
  .array(z.record(z.unknown()))
306
313
  .optional()
307
- .describe("表单工具栏按钮(写进 biz_sheet.options.customButtonJson;publish 时才生成 h_biz_button(triggerType=FORM))。每条至少 code/name/bindAction/operateType,useLocation 默认 FORM"),
314
+ .describe("表单工具栏按钮(写进 biz_sheet.options.customButtonJson;publish 时才生成 h_biz_button(triggerType=FORM))。每条至少 code/name/bindAction/operateType,useLocation 默认 FORM;新建还需 triggerCode/triggerType/showPermCode/showPermType + name_i18n(JSON 串形)+ addviewType,缺则平台 40000(#38 实证);code 语义化"),
308
315
  customButtonJson: z.string().optional().describe("buttons 的原样 JSON 数组字符串(与 buttons 互斥;用于把 form.get 读回值直接回写)"),
309
316
  buttonsMode: z.enum(["merge", "replace"]).optional().describe("默认 merge:按 code 增量 upsert(改一个按钮不必重发全表);replace:整表替换"),
310
317
  removeButtonCodes: z.array(z.string().min(1)).optional().describe("要删除的按钮 code(仅 merge 模式)"),
@@ -15,7 +15,7 @@ export const PROGRAMMING_WIRE = Object.freeze({
15
15
  sourceIdentity: "源码主键 code = schemaCode + ruleCode + \"Handler\"(SourceUtil.getBusinessRuleSourceCode)。未保存草稿时 get_source 仍返回内存骨架:按规则类型选模板(Create/Update/Delete/Load/Cancel/Available/GetList → <ruleCode>HandlerTemplate,其余 → CustomizedHandlerTemplate),version=null 即未落库草稿。",
16
16
  storage: "单表 h_source_code:草稿行固定 version=0(published=false),保存是**无条件覆盖 content**,平台无乐观锁/CAS(originalVersion 无比较逻辑);publish 另插 published=true、version=maxPublished+1 的新行,草稿行不动。运行时正式执行读 published 最新版(BusinessLauncher.buildReleaseRequest → getLatestPublishedSourceByCode),调试读草稿(version=0)。publish 内容没有 wire 读取端点。",
17
17
  publishFlow: "publish 服务端内部:saveDraftSource → 强制 compile(失败 → PROGRAMMING_COMPILE_FAILED)→ facade.publish 插新版本行 → 若 codeType=BUSINESS_RULE 则把规则置 DevelopmentMode.CODING(=1)、enabled=true 并发布规则(ProgrammingController.publishBusinessRule)。因此 publish 载荷**必须携带 businessRule 整模型**(工具内用 businessrule/list_by_schemacode 按 code 补齐)。",
18
- compile: "POST /compile body {code, content};服务端 convertSourceCode → 编辑器租户缓存 updateSourceCode(内存副作用)→ compileFile → CompileFileResult{success, errors[]}。编译是规则可运行的最低门槛:运行时每次执行都重新编译,坏源码会让该规则的每次业务执行失败。",
18
+ compile: "POST /compile body {code, content};服务端 convertSourceCode → 编辑器租户缓存 updateSourceCode(内存副作用)→ compileFile → CompileFileResult{success, errors[]}。编译是规则可运行的最低门槛:运行时每次执行都重新编译,坏源码会让该规则的每次业务执行失败。已知分歧(线上 GitLab #34,2026-11-13 双复现):compile 面绿 ≠ 运行可用——catch(Throwable) 与 try 块内赋值的局部变量在 compile 面通过、运行期 AppBox javac(lombok processor)失败(rule.run 50000「在线编码执行异常」);compile/save 回执带 precompileWarnings 增量警告与 divergenceCaveat,闭环验证 = publish 后 rule.run 一次。",
19
19
  templateGuard: "平台预置代码模板,包路径/类名/继承关系不得修改(改了规则无法运行)。工具 preflight:content 若声明 class 名必须等于 code 主键;若声明 package 必须是平台模板包——8.6.26 为 com.authine.cloudpivot.engine.service.bizrule.handler,live 8.7(AI-Platform 1.1.25) 为 com.authine.cloudpivot.engine.sourcecode.handler(真机冒烟实证),两者都接受,其它拒绝。",
20
20
  boundary: "startDebugging/debug/complete/go_definition 是 WEB-IDE 专用(调试为 attach 式:DebugVo 无合成载荷,debugId 只是随机 UUID,断点靠真实业务事件触发),不包裹。SPI/SERVICE 两类源码的写入面在 8.6.26 未开放(get_source 直接拒绝非 BUSINESS_RULE),v1 只做业务规则。",
21
21
  authority: "权限:ProgrammingController 无 @RequireAdmin / isAdmin 判断(AdminPermissionInterceptor 只看类级注解),普通已登录用户即可调用;CLI 标准会话无需额外管理员前置。",
@@ -76,7 +76,7 @@ export const PROGRAMMING_LANE_CONTRACT = Object.freeze({
76
76
  }),
77
77
  "programming.compile": Object.freeze({
78
78
  scope: PROGRAMMING_SCOPE,
79
- description: "远程编译检查(POST compile,body {code,content}):返回 CompileFileResult{success, errors}。编译是规则可运行的最低门槛(运行时每次执行都重新编译)。只读(唯一副作用是平台编辑器租户内存缓存)。",
79
+ description: "远程编译检查(POST compile)——compile 通过≠运行可用:compile 检查器与运行期 AppBox javac(lombok processor)规则有已知差异(catch Throwable/局部变量初始化,线上 #34),命中回 precompileWarnings/divergenceCaveat,闭环验证 = publish 后 rule.run 一次。body {code,content} 回 CompileFileResult{success, errors};编译是运行门槛(运行时每次执行都重新编译)。只读(唯一副作用是编辑器租户内存缓存)。",
80
80
  }),
81
81
  "programming.save": Object.freeze({
82
82
  scope: PROGRAMMING_SCOPE,
@@ -105,6 +105,10 @@ export function assertProgrammingContract() {
105
105
  if (!PROGRAMMING_WIRE.templateGuard.includes("com.authine.cloudpivot.engine.sourcecode.handler"))
106
106
  throw new Error("programming contract must pin the live 8.7 template package");
107
107
  assertDescriptionCarries(PROGRAMMING_LANE_CONTRACT, "programming.get", ["get_source", "Handler", "模板"]);
108
+ // 线上 #34:compile 教学(「≠运行可用」+ 闭环路径)钉在描述里,防回归静默丢失。
109
+ assertDescriptionCarries(PROGRAMMING_LANE_CONTRACT, "programming.compile", ["≠运行可用", "rule.run"]);
110
+ if (!PROGRAMMING_WIRE.compile.includes("#34"))
111
+ throw new Error("programming contract must pin the compile/runtime javac divergence (线上 #34)");
108
112
  assertDescriptionCarries(PROGRAMMING_LANE_CONTRACT, "programming.save", ["saveSourceCode", "com.authine.cloudpivot.engine.service.bizrule.handler", "sourcecode.handler", "Handler"]);
109
113
  assertDescriptionCarries(PROGRAMMING_LANE_CONTRACT, "programming.publish", ["compile", "businessRule", "CODING"]);
110
114
  assertDescriptionCarries(PROGRAMMING_LANE_CONTRACT, "programming.schemas", ["list_schemas_by_appcode"]);
@@ -180,6 +180,42 @@ export function presentCompileErrors(raw) {
180
180
  },
181
181
  };
182
182
  }
183
+ /**
184
+ * 线上 GitLab #34(2026-11-13 真机双复现,AI-Platform v1.1.25 / OMC 0.6.39):
185
+ * `programming.compile` 回 `{success:true, userErrors:[]}`,但运行期 javac
186
+ * (AppBoxFactory.precompile,带 lombok processor)编译失败——rule.run 回 50000
187
+ * 「在线编码执行异常」,真错只在容器 log_error.log。两类**普通写法**已复现:
188
+ * 1. catch(Throwable) —— 运行期「incompatible types: java.lang.Throwable cannot
189
+ * be converted to java.lang.Exception」(运行期要求 catch(Exception));
190
+ * 2. try 块内赋值的局部变量(`String x; try { x="a"; ... }`)—— 运行期
191
+ * 「变量x没有进行初始化」(definite-assignment 判定分歧;静态检测太贵不做,
192
+ * 靠 compile 成功回执的 divergenceCaveat 教学)。
193
+ * 本函数是**增量警告**(正则 lint,不引 javac 依赖):不改 success 透传——compile
194
+ * 面真实结果保真,警告只标注「compile 绿 ≠ 运行可用」的已知模式。
195
+ */
196
+ const CATCH_THROWABLE_RE = /\bcatch\s*\(\s*Throwable\b/;
197
+ /** 已知「compile 面绿、运行期 AppBox javac 红」的源码模式(线上 #34)。 */
198
+ export function precompileWarningsOf(content) {
199
+ const warnings = [];
200
+ const lines = content.split(/\r?\n/);
201
+ for (let index = 0; index < lines.length; index += 1) {
202
+ const text = lines[index];
203
+ const trimmed = text.trimStart();
204
+ // 注释行(//、/*、* 开头)不告警——lint 是建议性警告,误报会稀释信噪比。
205
+ if (trimmed.startsWith("//") || trimmed.startsWith("/*") || trimmed.startsWith("*"))
206
+ continue;
207
+ if (CATCH_THROWABLE_RE.test(text)) {
208
+ warnings.push({
209
+ pattern: "catch-throwable",
210
+ line: index + 1,
211
+ message: "运行期 AppBox javac 要求 catch(Exception):catch(Throwable) 会在 compile 面通过但运行期编译失败(incompatible types: java.lang.Throwable cannot be converted to java.lang.Exception;线上 #34 复现1)",
212
+ });
213
+ }
214
+ }
215
+ return warnings;
216
+ }
217
+ /** compile 成功回执的分歧 caveat(线上 #34):compile 绿不等于运行可用。 */
218
+ const COMPILE_RUNTIME_DIVERGENCE_NOTE = "compile 通过≠运行可用:compile 检查器与运行期 AppBox javac(lombok processor)规则有已知差异(catch Throwable / try 块内赋值的局部变量初始化判定,线上 #34);闭环验证 = publish 后 rule.run 一次。";
183
219
  async function compileSource(session, code, content) {
184
220
  const response = await wireCall(session, { path: ENDPOINTS.programmingCompile, method: "POST", body: { code, content } });
185
221
  const result = asRecord(response.data) ?? {};
@@ -397,6 +433,9 @@ export function registerProgrammingLane(tools) {
397
433
  return { status: "refused", blocker: "programming-content-required", message: "没有可编译的源码:传 content,或先 programming.save 落库草稿。" };
398
434
  const result = await compileSource(session, code, content);
399
435
  const presented = result.presented;
436
+ // 线上 #34:compile 面绿 ≠ 运行可用。源码静态预检(已知分歧模式)在回执
437
+ // 组装前跑一遍,命中即给增量警告;success 照实透传(保真)。
438
+ const warnings = precompileWarningsOf(content);
400
439
  return {
401
440
  schemaCode: args.schemaCode,
402
441
  businessRuleCode: args.businessRuleCode,
@@ -409,7 +448,11 @@ export function registerProgrammingLane(tools) {
409
448
  : presented.errors,
410
449
  platformErrors: presented.platformErrors,
411
450
  userErrors: presented.userErrors,
451
+ ...(warnings.length > 0 ? { precompileWarnings: warnings } : {}),
412
452
  evidenceHint: "compile 回执只在本命令 stdout,不落 journal/artifact;对照实验需留证请重定向到文件(> file.json)",
453
+ // 线上 #34:成功回执必须教学「compile 通过 ≠ 运行可用」——真错只在
454
+ // 运行期 javac(rule.run 50000)与容器 log_error.log 里才显形。
455
+ ...(result.success ? { divergenceCaveat: COMPILE_RUNTIME_DIVERGENCE_NOTE } : {}),
413
456
  ...(result.diagnostics.platformCompilerDegraded ? { platformCompilerDegraded: true, platformCompilerNote: result.diagnostics.platformCompilerNote } : {}),
414
457
  ...(result.success
415
458
  ? {}
@@ -474,6 +517,9 @@ export function registerProgrammingLane(tools) {
474
517
  const saved = asRecord(response.data);
475
518
  const readback = await readSource(session, { schemaCode: args.schemaCode, businessRuleCode: args.businessRuleCode, code });
476
519
  const readbackContent = typeof readback.model?.content === "string" ? readback.model.content : null;
520
+ // 线上 #34:save 面同样拿得到源码 content——同一份静态预检在保存回执里给
521
+ // 增量警告(不改 performed 结果;草稿照常落库)。
522
+ const warnings = precompileWarningsOf(args.content);
477
523
  return {
478
524
  performed: { errcode: 0, code, version: saved?.version ?? null, contentSha256: sha256(args.content), contentBytes: Buffer.byteLength(args.content, "utf8") },
479
525
  readback: {
@@ -483,6 +529,7 @@ export function registerProgrammingLane(tools) {
483
529
  contentMatches: readbackContent === args.content,
484
530
  contentSha256: readbackContent === null ? null : sha256(readbackContent),
485
531
  published: readback.model?.published === true,
532
+ ...(warnings.length > 0 ? { precompileWarnings: warnings } : {}),
486
533
  note: "草稿保存不改变运行时——生效需 programming.publish。",
487
534
  },
488
535
  };
@@ -1355,6 +1355,21 @@ export function validateMethodMapping(mapping, nodeCode) {
1355
1355
  if (typeof m[key] !== "string" || !m[key].trim())
1356
1356
  blockers.push({ code: "rule-graph-bizaction-mapping-key", nodeCode, key: `methodMapping.${key}`, message: `methodMapping.${key} 必须是非空字符串(8.6.26 BizMethodMappingModel;serviceCode+serviceMethodCode 是存在性校验对)` });
1357
1357
  }
1358
+ // 线上 #38(摩擦 B,詹记 8.6.26 真机):创建链 methodMapping 缺 serviceName/
1359
+ // serviceMethodName/methodCode 时平台按非空列落库失败,rule.save 回 40000
1360
+ // 「调用数据库发生异常」(照最小示例形状必炸;对照已成功规则补齐三键后一次
1361
+ // 成功)。只 warning 不拒——平台版本可能有差异,存量读回图也可能天然缺这三键
1362
+ // (透传语义不动),提示补齐而不是阻断。
1363
+ const nameSlotKeys = ["serviceName", "serviceMethodName", "methodCode"];
1364
+ const missingNameSlotKeys = nameSlotKeys.filter((key) => typeof m[key] !== "string" || !m[key].trim());
1365
+ if (missingNameSlotKeys.length > 0)
1366
+ blockers.push({
1367
+ code: "rule-graph-bizaction-mapping-names-missing",
1368
+ nodeCode,
1369
+ key: `methodMapping.${missingNameSlotKeys.join("/")}`,
1370
+ severity: "warning",
1371
+ message: `methodMapping 缺 ${missingNameSlotKeys.join("/")}——8.6.26 创建链按非空列落库,缺这些键时平台回 40000「调用数据库发生异常」(线上 #38 实证:补齐后一次成功)。对照 rule.get 读回的成功规则补齐;平台版本可能有差异,故仅提示不拦截`,
1372
+ });
1358
1373
  const mappingArrays = [["inputMappings", m.inputMappings], ["outputMappings", m.outputMappings]];
1359
1374
  for (const [listKey, list] of mappingArrays) {
1360
1375
  if (list === undefined)
@@ -1650,7 +1650,11 @@ export function registerRuntimeDataLane(tools) {
1650
1650
  inputSchema: {
1651
1651
  schemaCode: z.string().min(1),
1652
1652
  sheetCode: z.string().optional(),
1653
- formData: runtimeFormDataArg.describe('business-object data keyed by field code(关联/人员形状同默认描述)。mappings 仅门户回填;字典-backed 不校验取值(不存在/已停用码也会落库,要拦请配数据规则)。'),
1653
+ formData: runtimeFormDataArg.describe(
1654
+ // 券商 issue 1.3(cpdocs 2026-10-27):更新既有记录的主键契约——平台
1655
+ // BizObjectModel.getId() 只读 bizObject.data.id;顶层 bizObject.bizObjectId
1656
+ // 被保存逻辑忽略,errcode:0 但 objectId 是新 id(静默新建孤儿行)。
1657
+ 'business-object data keyed by field code(关联/人员形状同默认描述)。mappings 仅门户回填;字典-backed 不校验取值(不存在/已停用码也会落库,要拦请配数据规则)。既有记录更新:主键必须放 formData.id(顶层 bizObject.bizObjectId 被平台忽略会静默新建孤儿行——直调 REST 同理,cpdocs issue 2026-10-27 §1.3);id 无对应行会被拒(save-update-target-absent),新建请省略 id。'),
1654
1658
  workflowCode: z.string().optional().describe("portal draft-save shape: create the row AND a DRAFT workflow instance + start workItem (finishStart=FALSE); submit later via data.submit with the returned workItemId. formData must NOT carry an id — in-place workflow start has no REST surface in 8.6.26。发起语义阶梯(r68s 真机取证):本参数=发起停在第一节点(行/实例双 DRAFT,首办待办=发起人);到第一个审批节点用 data.submit 三件套;无流程模型用 submit:true 一调完成态;代他人发起(可选发起人)唯一路径=业务规则 CREATE+startWorkflow(完成态发起,不留草稿待办)"),
1655
1659
  submit: z.boolean().optional().describe("true=保存后立即直提(无流程模型 DRAFT→COMPLETED,触发 Create 规则);与 workflowCode 互斥。**按业务约定正式数据优先直接 data.submit(无 id=新建并提交一调完成)——本参数是便捷别名,save 的定位是草稿/暂存**"),
1656
1660
  allowStaffOnSubmit: z.boolean().optional().describe("submit:true 时显式允许携带人员字段(issue#10:人员字段提交面两种形状都可能 50000,可靠链路是 save 落库后提交时省略;个别平台构建接受提交面携带,自担风险)"),
@@ -1670,7 +1674,11 @@ export function registerRuntimeDataLane(tools) {
1670
1674
  });
1671
1675
  const { sheetCode, resolvedFrom } = await resolveFormSheetCode(session, { schemaCode: args.schemaCode, sheetCode: args.sheetCode });
1672
1676
  const rawSaveData = args.formData;
1673
- const saveIsUpdate = typeof rawSaveData.id === "string" && rawSaveData.id.trim().length > 0;
1677
+ // 券商 issue 1.3(cpdocs 2026-10-27):formData.id = 更新语义(平台
1678
+ // BizObjectModel.getId() 只读 data.id)。捕获原始 id 供写前存在性校验与
1679
+ // 写后孤儿判据(返回 objectId ≠ 传入 id = 平台没按更新处理)使用。
1680
+ const saveSuppliedId = typeof rawSaveData.id === "string" ? rawSaveData.id.trim() : "";
1681
+ const saveIsUpdate = saveSuppliedId.length > 0;
1674
1682
  const prepared = await prepareRuntimeFormData(session, args.schemaCode, rawSaveData, { isUpdate: saveIsUpdate });
1675
1683
  const formData = prepared.formData;
1676
1684
  const writeDiagnostics = { ...ignoredNullDiagnostic(formData), ...unknownFieldDiagnostic(formData, prepared.fieldCodes, prepared.childCodes, prepared.schemaLoaded) };
@@ -1779,6 +1787,26 @@ export function registerRuntimeDataLane(tools) {
1779
1787
  readback: { ...application, ...writeDiagnostics, authoritative: projectReadbackRecord(normalizeLoadedRecord((readbackData ?? {})), args), sequenceStatus, expectedSequenceStatus: "DRAFT" },
1780
1788
  };
1781
1789
  }
1790
+ // 券商 issue 1.3(cpdocs 2026-10-27):带 formData.id 的 save 是更新语义;
1791
+ // 平台对**不存在的 id** 不报错而是退回 createBizObject 静默新建(fake/live
1792
+ // 一致,loadExistingBizObject 的注释即此判据)。data.update/data.submit 已有
1793
+ // 同族写前校验(update-target-absent / submit-target-absent),data.save 是
1794
+ // 最后一块没有闸的写面——孤儿行就是这么来的,fail-closed。
1795
+ if (saveIsUpdate) {
1796
+ const existingById = await loadExistingBizObject(session, args.schemaCode, sheetCode, saveSuppliedId);
1797
+ if (!existingById) {
1798
+ throw new ToolRefusalError({
1799
+ status: "refused",
1800
+ blocker: "save-update-target-absent",
1801
+ schemaCode: args.schemaCode,
1802
+ bizObjectId: saveSuppliedId,
1803
+ sheetCode,
1804
+ nextCommand: `omc call data.list --args '${JSON.stringify({ schemaCode: args.schemaCode })}'`,
1805
+ message: `formData.id=${saveSuppliedId} 指向的记录不存在,已拒(平台对未知 id 会静默新建孤儿行而不是更新——返回的新 objectId 就是判据,cpdocs issue 2026-10-27 §1.3)。` +
1806
+ `要更新:data.list 找到正确 id(或改用 data.update,其 bizObjectId 在顶层参数位、写前同样校验存在);要新建:省略 formData.id。`,
1807
+ });
1808
+ }
1809
+ }
1782
1810
  let performed;
1783
1811
  try {
1784
1812
  performed = await runtimeWriteWithAppMapping(session, args.schemaCode, 50000, "data.save 运行时写稳定失败(50000)", () => wireCall(session, {
@@ -1815,6 +1843,19 @@ export function registerRuntimeDataLane(tools) {
1815
1843
  authoritative: projectReadbackRecord(savedRecord, args),
1816
1844
  ...(savedEmptyFields.length > 0 ? { readbackWarning: readbackWarningFor(savedEmptyFields, "data.save") } : {}),
1817
1845
  ...(dataWarnings.length > 0 ? { warnings: dataWarnings } : {}),
1846
+ // 券商 issue 1.3(cpdocs 2026-10-27):写前校验(save-update-target-absent)
1847
+ // 之后的第二道防线——返回 objectId ≠ 传入 formData.id 就是平台没按更新处理
1848
+ // (静默新建孤儿行的真机判据),如实报警而不是回一个"成功"。
1849
+ ...(saveIsUpdate && typeof bizObjectId === "string" && bizObjectId !== saveSuppliedId
1850
+ ? {
1851
+ orphanWarning: {
1852
+ criterion: "返回 objectId ≠ formData.id",
1853
+ suppliedId: saveSuppliedId,
1854
+ returnedId: bizObjectId,
1855
+ message: `平台没有按 formData.id 更新而是新建了行(返回 ${bizObjectId} ≠ 传入 ${saveSuppliedId})——疑似孤儿数据,请 data.list 核对并清理(cpdocs issue 2026-10-27 §1.3)`,
1856
+ },
1857
+ }
1858
+ : {}),
1818
1859
  draftRuleHint: workflowDraftHint ?? "草稿态(DRAFT)保存不触发业务规则——DRAFT 行跳过 Create/Update 分发(DomainServiceImpl.java:240-248);要一调完成态本调用加 submit:true(仅 data.save 有此参数;data.submit 不收);已存草稿直提形状:data.submit {schemaCode, bizObjectId: 本读回的 bizObjectId, formData}(submit 自持久化)",
1819
1860
  };
1820
1861
  // r18 retro (G3): one-call COMPLETED creation — the agent goal is usually
@@ -1879,7 +1920,11 @@ export function registerRuntimeDataLane(tools) {
1879
1920
  schemaCode: z.string().min(1),
1880
1921
  sheetCode: z.string().optional(),
1881
1922
  bizObjectId: z.string().min(1).describe("id of the EXISTING record to edit; the tool refuses when it is absent (never silently inserts)"),
1882
- formData: runtimeFormDataArg.describe("fields to change, keyed by field code; the platform merges them onto the stored record, so omitted fields keep their value (patch semantics)"),
1923
+ formData: runtimeFormDataArg.describe(
1924
+ // 券商 issue 1.3(cpdocs 2026-10-27):把主键契约写进参数面——OMC 工具
1925
+ // 收顶层 bizObjectId 并由工具写入 data.id;直调 REST 时主键必须自己放
1926
+ // data.id,放 bizObject.bizObjectId 会被忽略并静默新建孤儿行。
1927
+ "fields to change, keyed by field code; the platform merges them onto the stored record, so omitted fields keep their value (patch semantics). 更新主键由顶层 bizObjectId 携带,工具写入 data.id——平台只读 data.id(直调 REST 更新时主键也必须在 data.id,放 bizObject.bizObjectId 会被忽略并静默新建孤儿行,cpdocs issue 2026-10-27 §1.3)"),
1883
1928
  ...readbackProjectionArgs,
1884
1929
  },
1885
1930
  execute: async (session, args) => {
@@ -130,8 +130,11 @@ const READ_SHAPES = {
130
130
  ],
131
131
  },
132
132
  "form.get": {
133
- keys: ["present", "published", "publishedControlCodes", "draftControlCodes"],
134
- notes: ["控件清单键是 publishedControlCodes/draftControlCodes,不是 controls"],
133
+ keys: ["present", "published", "publishedControlCodes", "draftControlCodes", "formButtonCodes?", "formButtons?", "customButtonJson?(full)", "customButtonJsonShapeWarning?"],
134
+ notes: [
135
+ "控件清单键是 publishedControlCodes/draftControlCodes,不是 controls",
136
+ "表单按钮读 formButtonCodes/formButtons;full:true 另带 customButtonJson 数组原样(库里是字符串脏形时给 customButtonJsonShapeWarning——线上 #38 前端按钮不渲染,重写 buttons 自愈)",
137
+ ],
135
138
  },
136
139
  "listview.get": {
137
140
  keys: ["present", "published", "lifecycle", "columns[]"],
@@ -464,7 +464,7 @@ const ruleBizactionInvokeService = Object.freeze({
464
464
  nodeGraph: {
465
465
  nodes: [
466
466
  { nodeCode: "Start", nodeName: "开始", nodeType: "START" },
467
- { nodeCode: "A1", nodeName: "调用服务并回写", nodeType: "BIZ_ACTION", inputParam: "_input", methodMapping: { schemaCode: model, serviceCode: "<svc>", serviceMethodCode: "<method>", inputMappings: [{ serviceMethodParameterCode: "<in_code>", codeType: 1, bizCode: "<src_field>", required: true }], outputMappings: [{ serviceMethodParameterCode: "<out_code>", codeType: 1, bizCode: "<dst_field>" }] } },
467
+ { nodeCode: "A1", nodeName: "调用服务并回写", nodeType: "BIZ_ACTION", inputParam: "_input", methodMapping: { schemaCode: model, serviceCode: "<svc>", serviceName: "<服务名>", serviceMethodCode: "<method>", serviceMethodName: "<方法名>", methodCode: "<注册槽>", inputMappings: [{ serviceMethodParameterCode: "<in_code>", codeType: 1, bizCode: "<src_field>", required: true }], outputMappings: [{ serviceMethodParameterCode: "<out_code>", codeType: 1, bizCode: "<dst_field>" }] } },
468
468
  { nodeCode: "End", nodeName: "结束", nodeType: "END" },
469
469
  ],
470
470
  routes: [
@@ -481,6 +481,7 @@ const ruleBizactionInvokeService = Object.freeze({
481
481
  ],
482
482
  conditionalRequirements: [
483
483
  "**系统节点由工具注入**——本 recipe 只写 Start→BIZ_ACTION→End;工具注入 SYSTEM_CREATE 并排在 BIZ_ACTION 之后(ASSIGN/BIZ_ACTION 必须在系统节点前)。",
484
+ "methodMapping 必带 serviceName/serviceMethodName/methodCode(缺则 40000,#38 实证)",
484
485
  "**出参回写三前提(r28b 8 组实验定案,缺一出参恒 null 且节点日志仍 successful)**:① 响应 JSON 根级平铺出参键(信封嵌套如 {data:{...}} 静默不回写)② 挂预置 Create/Update 规则上下文(自定义规则/rule.run 不回写业务字段)③ 用 data.submit/data.update 触发(data.save 存草稿不触发)。回写是否成功只认 data.load 读字段,不认调用日志。",
485
486
  "codeType:1 = 映射模型字段(bizCode=字段 code);codeType:0 = 常量(bizCode=常量值);serviceMethodParameterCode 必须与方法声明的参数 code 逐字一致",
486
487
  "**接口响应必须在 JSON 根级**返回与出参 code 同名的键——嵌套在信封里(如 {data:{level}})会静默映射不上(p7 实测;r28b 8 组实验全因信封端点失败,换平铺端点后 4 组一次全过)",
@@ -219,6 +219,20 @@ export function refusalRecovery(blocker, payload, options = {}) {
219
219
  fixFirst: "处置三选一:① 换一个 code 重建(最快,不动回收站);② 门户「回收站」里物理删除该条目后原 code 可用;③ 保留残留用现名(先 report.get 核对 treeVisibility)。不要反复重试同 code——回收站不清空它就一直占。",
220
220
  };
221
221
  }
222
+ // 线上 #38(摩擦 B):40000「调用数据库发生异常」的引导曾单向判「平台侧故障,勿
223
+ // 改参数硬重试」——真机(詹记 8.6.26)两次实证反向成因:创建类写入缺非空列时平台
224
+ // 同样回 40000(rule.save 的 methodMapping 缺 serviceName/serviceMethodName/methodCode;
225
+ // form.draft/publish 的 button 缺 triggerCode/triggerType/showPermCode/showPermType——h_biz_button
226
+ // 的 NOT NULL 列)。照「勿改参数」引导原地打转;正确动作=对照已成功配置补齐字段。
227
+ // runtime-write-db-exception(运行面 40000)自带公式字段诊断教学,不在此重复。
228
+ if (blocker !== "runtime-write-db-exception" && (Number(payload.errcode) === 40000 || /调用数据库发生异常/.test(text0))) {
229
+ return {
230
+ whatWentWrong: "平台回 40000「调用数据库发生异常」——无明细掩码,有两种常见成因,先分叉再动手",
231
+ fixFirst: "① 真·平台故障(DB/ORM 层)→ 稍后重试同一请求,持续复现查平台日志;" +
232
+ "② **创建类写入缺非空列**(线上 #38 实证)——rule.save 的 methodMapping 缺 serviceName/serviceMethodName/methodCode;form.draft/form.publish 的 button 缺 triggerCode/triggerType/showPermCode/showPermType(h_biz_button 非空列)。照 recipe 最小示例形状新建必炸②:先 rule.get/form.get 读一条已成功落库的同族配置,对照补齐这些字段后一次成功。",
233
+ doNot: "不要只按「平台故障勿改参数」原地重试——成因②下同参数永远 40000;也不要不分叉就盲改参数——成因①下改了也没用",
234
+ };
235
+ }
222
236
  // r19 p14: the report BI boundary is matched from the wire path in the
223
237
  // message/detail, so both refused and frozen (uncertain) envelopes teach it.
224
238
  if (mentionsDashboardChannel(payload)) {
package/dist/support.js CHANGED
@@ -102,6 +102,11 @@ export async function resolveApplicationScope(session, requested) {
102
102
  * The echo payload for a scan-style read: `source` says why this application,
103
103
  * `applicationCount` says how many the tenant has (fallback case only), so a
104
104
  * zero result can never be mistaken for tenant-wide absence.
105
+ *
106
+ * cpdocs issue 2026-10-30(pwsh-ergonomics)P1:`source=first-tenant-application`
107
+ * 且租户应用数>1 时附 `scannedApplications: "1 / total: N"`——`count:0` 被读成
108
+ * 「不存在」的高危场景,结构化键比散文 hint 更难被忽略(词表与
109
+ * discover_environment 同源:explicit|configured|first-tenant-application)。
105
110
  */
106
111
  export function applicationResolutionOf(scope) {
107
112
  return {
@@ -109,6 +114,9 @@ export function applicationResolutionOf(scope) {
109
114
  source: scope.source,
110
115
  ...(scope.requested !== null ? { requested: scope.requested } : {}),
111
116
  ...(scope.applicationCount !== undefined ? { applicationCount: scope.applicationCount } : {}),
117
+ ...(scope.source === "first-tenant-application" && (scope.applicationCount ?? 1) > 1
118
+ ? { scannedApplications: `1 / total: ${scope.applicationCount}` }
119
+ : {}),
112
120
  };
113
121
  }
114
122
  /** One-line nudge appended to a zero-result scan read; names the real scope of the answer. */
package/dist/write.js CHANGED
@@ -118,16 +118,21 @@ async function governedWrite(ctx, tool, args, execute, dryRunPayload, readOnlyEs
118
118
  message: `${error.message}——这是平台 ORM 的对象状态错误(Serializer.update/delete 要求实体先被装载),不是入参或规则图的形状问题。` +
119
119
  "同一份入参再保存一次通常即恢复。持续复现就换行:rule.delete 后重建(rule.save 会铸新记录),或用 rule.get 读回完整行再 rule.node.update 改一处——不要继续重试同一份 payload。",
120
120
  };
121
- // r30a F10:errcode 40000「调用数据库发生异常」是平台侧故障,不是入参形状问题。
122
- // 标 platform-fault,避免脚本把原样透出的业务码当成「改参数再试」。
121
+ // r30a F10:errcode 40000「调用数据库发生异常」曾单向判「平台侧故障,勿改参数」。
122
+ // 线上 #38(摩擦 B,詹记 8.6.26)实证反向成因:创建类写入缺非空列时平台同样
123
+ // 回 40000(rule.save 的 methodMapping 缺 serviceName/serviceMethodName/methodCode;
124
+ // form.draft/publish 的 button 缺 triggerCode/triggerType/showPermCode/showPermType),
125
+ // 照「勿改参数硬重试」引导原地打转。引导必须双向:先分叉成因再动手。
123
126
  if (error.errcode === 40000 || /调用数据库发生异常/.test(error.message))
124
127
  return {
125
128
  status: "refused",
126
129
  blocker: `wire-${error.kind}`,
127
130
  errcode: error.errcode,
128
131
  "platform-fault": true,
129
- message: `${error.message}——这是平台侧异常(errcode ${error.errcode}),不是入参形状问题;勿改参数硬重试,稍后重试或查平台日志。`,
130
- nextAction: "稍后重试同一请求;持续复现请查平台 DB/ORM 日志,不要把 40000 当参数错误",
132
+ message: `${error.message}——40000「调用数据库发生异常」是无明细掩码,两种常见成因(线上 #38 实证):` +
133
+ "① 真·平台故障(DB/ORM 层,重试/查平台日志);" +
134
+ "② 创建类写入缺非空列——rule.save 的 methodMapping 缺 serviceName/serviceMethodName/methodCode、form.draft/publish 的 button 缺 triggerCode/triggerType/showPermCode/showPermType 时同样回 40000(照 recipe 最小示例形状新建必炸;对照已成功落库的同族配置补齐字段后一次成功)。",
135
+ nextAction: "先分叉:本次是照示例新建/改配置吗?是→按成因②对照一条已成功配置(rule.get/form.get 读回)补齐非空列字段再重试;否→按成因①稍后重试同一请求,持续复现查平台 DB/ORM 日志",
131
136
  ...(error.diagnostic ? { diagnostic: error.diagnostic } : {}),
132
137
  };
133
138
  return { status: "refused", blocker: `wire-${error.kind}`, errcode: error.errcode, message: error.message, ...(error.diagnostic ? { diagnostic: error.diagnostic } : {}) };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stalfh233/omc-cli",
3
- "version": "0.6.64",
3
+ "version": "0.6.66",
4
4
  "description": "CloudPivot 8.6 configuration capability CLI — governed, fail-closed, coverage-manifest bounded.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -56,7 +56,7 @@
56
56
  },
57
57
  "dependencies": {
58
58
  "commander": "14.0.3",
59
- "omc-core": "0.6.64",
59
+ "omc-core": "0.6.66",
60
60
  "proper-lockfile": "4.1.2",
61
61
  "write-file-atomic": "6.0.0",
62
62
  "zod": "^3.23.8",
@@ -74,6 +74,6 @@
74
74
  "directory": "packages/omc-cli"
75
75
  },
76
76
  "optionalDependencies": {
77
- "@stalfh233/omc-fake-platform": "0.6.64"
77
+ "@stalfh233/omc-fake-platform": "0.6.66"
78
78
  }
79
79
  }
@@ -42,9 +42,10 @@ handle 返回值,可当轻量后端 API(见 §5.1 调用面;8.6.26 反编
42
42
 
43
43
  先按 cpdocs 的落点判据定「配置 / 二开」;判到二开时,再用上表在两种 Java 落点间选。
44
44
 
45
- 手工路径(人不用 CLI 时):IDEA 写 → 粘贴设计器「在线编码」界面 save/publish;本地保留
46
- `.omc-programming/` 同构副本进 git 作回滚依据(published 无 wire 读取端点);平台无乐观锁,
47
- 多端编辑漂移时以平台草稿为准重拉。
45
+ 手工路径(人不用 CLI 时):入口两条——设计器新建规则时选「编码」模式,或图形化编辑中
46
+ 「切换模式」转编码(官方 6.x 口径);IDEA 写 → 粘贴设计器「在线编码」界面 save/publish;
47
+ 本地保留 `.omc-programming/` 同构副本进 git 作回滚依据(published 无 wire 读取端点);
48
+ 平台无乐观锁,多端编辑漂移时以平台草稿为准重拉。
48
49
 
49
50
  ## 0.1 在线编码的能力边界(实测,1.1.25)
50
51
 
@@ -77,7 +78,9 @@ handle 返回值,可当轻量后端 API(见 §5.1 调用面;8.6.26 反编
77
78
  所以用 Java 8 之后的语法时,错误里会先出现一坨 Lombok 异常,真正的
78
79
  `cannot find symbol` 排在后面。**看错误先看最后一条**,别被 Lombok 噪音带偏。
79
80
  Lombok 的代码生成也**不可用**(`@Data` 生成的方法找不到),老老实实手写 getter/setter
80
- 和 `LoggerFactory.getLogger(...)`。
81
+ 和 `LoggerFactory.getLogger(...)`。注意这套行为是 **compile 检查器**一侧的;运行期
82
+ AppBox javac 带的 lombok processor 是另一套,两套规则有差异——compile 绿 ≠ 运行可编
83
+ (见下「compile 通过 ≠ 运行可用」)。
81
84
 
82
85
  ### 可用依赖
83
86
 
@@ -92,7 +95,23 @@ Lombok 的代码生成也**不可用**(`@Data` 生成的方法找不到),
92
95
 
93
96
  **别按平台的「补全白名单」写代码**:白名单列了 `engine.api.*` / `engine.domain.*` /
94
97
  `engine.service.*`,但**白名单 ≠ javac 类路径**——白名单里很多类实际编不过。以
95
- `engine.open.*` 为准,拿不准就先 `programming.compile` 试一次(只读,不落库)。
98
+ `engine.open.*` 为准,拿不准就先 `programming.compile` 试一次(只读,不落库)——但它
99
+ 只能证伪、不能证实:**compile 通过 ≠ 运行可用**,见下节。
100
+
101
+ ### compile 通过 ≠ 运行可用(两套编译器;#34 真机双复现 2026-11-13,1.1.25)
102
+
103
+ `programming.compile` 的检查器与**运行期 AppBox javac(带 lombok processor)是两套编译器**,
104
+ 规则有已知差异:compile 回 `success:true`,运行期照样编译失败——`rule.run` 只回 50000
105
+ 「在线编码执行异常」,**真错只在 `<launcher>/logs/log_error.log`**。已知假阴性两类(普通
106
+ 写法,双复现):
107
+
108
+ | 写法(compile 绿) | 运行期真错 | 改法 |
109
+ |---|---|---|
110
+ | `catch (Throwable t)` | `incompatible types: java.lang.Throwable cannot be converted to java.lang.Exception` | 用 `catch (Exception e)` |
111
+ | try 块内赋值的局部变量 | `IllegalStateException: [<变量名>没有进行初始化]` | 变量声明处初始化 |
112
+
113
+ 所以 compile 只能**证伪**(报错 = 一定不可用),不能证实;**闭环验证 = publish 后
114
+ `rule.run` 真跑一次**,回 50000 就去 `<launcher>/logs/log_error.log` 查真错。
96
115
 
97
116
  ### 运行时约束
98
117
 
@@ -139,7 +158,9 @@ Lombok 的代码生成也**不可用**(`@Data` 生成的方法找不到),
139
158
  内存泄漏(见上方生命周期表)。
140
159
 
141
160
  适用判据:有状态 / 要容器 / 多 bean 协作的逻辑沉到扩展包 bean;字段改写、跨模型编排、
142
- 触发时机留在线编码。纯无状态工具方法连 bean 都不用——直接 import 扩展包静态工具类即可。
161
+ 触发时机留在线编码。纯无状态工具方法连 bean 都不用——直接 import 扩展包静态工具类即可;
162
+ redis/mq 等中间件客户端同理(官方 6.x 口径:中间件操作经本地工具类 = 融合路径的应用,
163
+ 规则里只调用,不在规则里建连/注册)。
143
164
 
144
165
  ### 类路径统一模型(8.6.26 反编译 + 真机启动参数 2026-11-10)
145
166
 
@@ -165,10 +186,11 @@ import;但 launcher 自身的嵌套 BOOT-INF lib 对直接 import 仍不可见
165
186
  - 你负责**产出可部署的 jar + 源码 + 单测**,并说清「这个类已经在代码里、但需要部署后才可用」。
166
187
  - **部署与重启不要自己做**:这是运维动作,会让别人正在用的系统中断。停下来,向需求方/运维说明
167
188
  「需要部署这个 jar 并重启 launcher 才生效」,等他们给窗口。
168
- - 判断某个扩展类当前是否**已生效**,别猜:写进 handler 走一次 `programming.compile`
169
- **你没法列举已部署的类**:CLI 没有「列出 extensions 内容」的读面(`extensions/` 在远端容器里,
170
- agent 侧看不到)。判断某个类能不能用只有一条路——写进 handler,`programming.compile` 试一次
171
- (只读、不落库):成功即可用,`errors[]` 里报 `package ... does not exist` 即不可用。
189
+ - **你没法列举已部署的类**:CLI 没有「列出 extensions 内容」的读面(`extensions/` 在远端
190
+ 容器里,agent 侧看不到)。判断某个扩展类能不能用只有一条路——写进 handler,
191
+ `programming.compile` 试一次(只读、不落库):`errors[]` 报 `package ... does not exist`
192
+ 即不可用(证伪有效);compile 绿只说明**类路径可达**,≠ 运行可用(两套编译器,见 §0.1
193
+ 「compile 通过 ≠ 运行可用」)——最终以 publish 后真跑一次为准。
172
194
 
173
195
  **类路径是启动时快照,不是「目录里有就能用」**(真机对照实验 2026-11-11,r53):
174
196
  `loader.path` 在 webapi 进程**启动时**解析成类路径快照,之后新放进目录的 jar **连编译都看不见**——
@@ -191,7 +213,7 @@ agent 侧看不到)。判断某个类能不能用只有一条路——写进 h
191
213
  ```bash
192
214
  # 1) 读模板(未落库时平台按规则类型生成;不传 code 自动推导主键)
193
215
  omc call programming.get --env <env> --args '{"schemaCode":"contract","businessRuleCode":"Update"}'
194
- # 2) 编译检查(先编译,再保存——错误定位最省事)
216
+ # 2) 编译检查(先编译,再保存——错误定位最省事;通过 ≠ 运行可用,见 §0.1)
195
217
  omc call programming.compile --env <env> --args '{"schemaCode":"contract","businessRuleCode":"Update","content":"...java..."}'
196
218
  # 3) 存草稿(不影响运行时)
197
219
  omc call programming.save --env <env> --args-file save.json
@@ -249,7 +271,8 @@ cleanup:
249
271
 
250
272
  流水:compile 门禁 → publish(内容未变可跳过)→ 触发(`data.*`;`custom` 用 `rule.run`)
251
273
  → `data.list` 断言 → 只清理自己种的行 → 报告 `verdict`。编译失败/触发异常(带 Java
252
- errmsg)/断言失败都会进报告,agent 据此改码重跑。
274
+ errmsg)/断言失败都会进报告,agent 据此改码重跑。compile 门禁是**必要非充分**(检查器有
275
+ 已知假阴性,见 §0.1),publish 后的触发一步不可省。
253
276
 
254
277
  ### 触发前提:DRAFT 不执行规则
255
278
 
@@ -286,7 +309,8 @@ cpdocs 提供**平台知识与规范**,本 CLI 提供**执行面**。已安装
286
309
  `compile` → `apply --publish` → `programming test` 断言 → (跨模型/对外接口才升到二开扩展包)**。
287
310
 
288
311
  在线编码里能用什么依赖、什么语法、什么必须退回扩展包——见 [§0.1 能力边界](#01-在线编码的能力边界实测-1125)。
289
- 拿不准某个类能不能用,先 `programming.compile` 试一次(只读不落库),比猜快。
312
+ 拿不准某个类能不能用,先 `programming.compile` 试一次(只读不落库),比猜快——但 compile
313
+ 绿 ≠ 运行可用,能否真跑以 publish 后 `rule.run` 一次为准(假阴性清单见 §0.1)。
290
314
 
291
315
  ## 5. 典型 handler 骨架(已验证可编译可运行)
292
316
 
@@ -334,6 +358,10 @@ public class <schema><rule>Handler extends BaseHandler {
334
358
  }
335
359
  ```
336
360
 
361
+ Request 语义(官方 6.x 文档):`Context` 目前仅 `userId`;
362
+ `request.getData().getBizObject()` 在**自定义按钮未选数据时返回 null**——骨架里对
363
+ `current` 判空就是为它,别假设 BizObject 必有值。
364
+
337
365
  ### 三个必踩的骨架陷阱(真机 1.1.25,2026-11-12 r57)
338
366
 
339
367
  **① `createBizObject` 返回 `String`(新行 id),不是 `BizObject`**
@@ -502,6 +530,7 @@ mkdir -p "$LAUNCHER/inject_code_dir" && chown <容器用户uid>:<gid> "$LAUNCHER
502
530
  |---|---|---|
503
531
  | publish 回 `PROGRAMMING_COMPILE_FAILED` | 编译失败 | `programming.compile` 看 errors;注意类名/包名/括号 |
504
532
  | 规则执行 50000 | 运行时编译/注入失败 | 先看 `log_error.log`;常见是 `inject_code_dir` 权限 |
533
+ | compile 回 `success:true` 但执行 50000「在线编码执行异常」 | **compile 检查器 ≠ 运行期 AppBox javac(带 lombok processor)**,已知假阴性:`catch (Throwable)`、try 块内初始化的局部变量 | 真错去 `<launcher>/logs/log_error.log`;写法改 `catch (Exception)`、变量声明处初始化;闭环验证 = publish 后 `rule.run` 一次(#34 真机双复现 2026-11-13,见 §0.1) |
505
534
  | `programming.schemas` 空 | 平台只列**已有编码规则**的模型 | 用 `rule.list` 找规则,`adopt`/`get` 起模板 |
506
535
  | `list_source_by_schemacode` 报源码不存在 | 任一规则缺草稿会整列失败 | 用 `programming.get` 逐条读(未落库回模板) |
507
536
  | apply 报 `remote-ahead` | 别人改过远端草稿 | 先 `pull`,再改再 apply |