@stalfh233/omc-cli 0.4.97 → 0.4.99
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/capability-overview.js +6 -1
- package/dist/compute.js +20 -1
- package/dist/field-families.js +37 -0
- package/dist/goal-routes.js +12 -1
- package/dist/lanes/field.js +54 -0
- package/dist/lanes/runtime-data-contract.js +1 -1
- package/dist/lanes/runtime-data.js +133 -22
- package/dist/model-scaffold.js +41 -38
- package/dist/recipes/field.js +3 -2
- package/dist/recipes/runtime-data.js +3 -1
- package/package.json +3 -3
- package/skills/omc-business-configuration.md +2 -1
- package/skills/omc-refusals.md +8 -0
- package/skills/omc-write-hazards.md +17 -0
|
@@ -231,7 +231,12 @@ export const CAPABILITY_CUES = Object.freeze({
|
|
|
231
231
|
onlinejs: ["在线js", "脚本", "联动", "onload", "onvalidate"],
|
|
232
232
|
bizservice: ["集成", "接口", "服务", "回调", "对接", "外部系统", "datasql", "restful"],
|
|
233
233
|
report: ["报表", "图表", "看板", "bi", "dashboard"],
|
|
234
|
-
|
|
234
|
+
// r18 (2026-10-26): "造数据 / 造测试单据 / 录数据" is the RUN-DATA capability, but
|
|
235
|
+
// the goal usually also says 子表/明细 (field cues) — without these compound
|
|
236
|
+
// cues the router sent the probe to `field` in read mode (write:false), so it
|
|
237
|
+
// never reached data.submit. Compound (not bare 数据) to avoid stealing
|
|
238
|
+
// ordinary model/field asks that merely mention data.
|
|
239
|
+
data: ["运行数据", "提交数据", "保存记录", "查记录", "造数据", "测试数据", "测试单据", "造单据", "造单", "录数据", "填数据", "模拟数据", "业务数据", "造几条", "造两张", "造几张", "验数据"],
|
|
235
240
|
});
|
|
236
241
|
/**
|
|
237
242
|
* Boundary cues — authored alongside CAPABILITY_CUES (same runtime authority).
|
package/dist/compute.js
CHANGED
|
@@ -212,8 +212,27 @@ export async function cmdCompute(args) {
|
|
|
212
212
|
// data.save / data.submit / data.update never refresh the target field, no
|
|
213
213
|
// matter how correct the formula is. Say so in the receipt instead of letting
|
|
214
214
|
// the caller believe the write took effect (r12 believed it; r16 disproved it).
|
|
215
|
+
// r18: the dry-run receipt showed only an optionsSummary hash, so the probe
|
|
216
|
+
// could not tell whether `{items.qty} * {items.price}` means per-row or
|
|
217
|
+
// aggregate-after-multiply — a semantic difference that changes the answer.
|
|
218
|
+
// Echo the exact compiled formula (and its editor twin) on the dry-run face.
|
|
219
|
+
const compiled = !apply
|
|
220
|
+
? (() => {
|
|
221
|
+
const stitch = createArgs.options?.shortTextStitch;
|
|
222
|
+
if (typeof stitch !== "string")
|
|
223
|
+
return undefined;
|
|
224
|
+
try {
|
|
225
|
+
const parsed = JSON.parse(stitch);
|
|
226
|
+
return { formula: parsed.formula ?? null, editorText: parsed.editorText ?? null, editorMark: parsed.editorMark ?? null };
|
|
227
|
+
}
|
|
228
|
+
catch {
|
|
229
|
+
return undefined;
|
|
230
|
+
}
|
|
231
|
+
})()
|
|
232
|
+
: undefined;
|
|
215
233
|
const withWarning = apply && classified.status === "ok" ? { ...result, ...computeExecutionNotice() } : result;
|
|
216
|
-
|
|
234
|
+
const withCompiled = compiled ? { ...withWarning, compiledFormula: compiled } : withWarning;
|
|
235
|
+
writeEnvelope(envelope(classified.status, withCompiled, request, classified.error));
|
|
217
236
|
return exitCode;
|
|
218
237
|
}
|
|
219
238
|
//# sourceMappingURL=compute.js.map
|
package/dist/field-families.js
CHANGED
|
@@ -954,6 +954,43 @@ export function assertFieldOptionsAllowed(type, options, schemaCode) {
|
|
|
954
954
|
const agg = parseOptionsObject(config.aggregation);
|
|
955
955
|
if (!agg || !isNonEmptyString(agg.schemaCode) || !isNonEmptyString(agg.dataItemCode) || !isNonEmptyString(agg.formula))
|
|
956
956
|
refuseFieldOptions("AGGREGATION aggregation is missing schemaCode/dataItemCode/formula", 'rejected: aggregation 形状 {schemaCode:"<目标模型schemaCode>", dataItemCode:"<目标字段code>", formula:"SUM({<目标模型>.<字段>})", calculateType:"SUM", queryConditions:[[…]]}(FormulaProcessor.executeMainAggregation + AggregationFormula)');
|
|
957
|
+
// r18b (2026-10-26 live): LARGE/SMALL take a position argument and the
|
|
958
|
+
// platform evaluates the FORMULA, so `LARGE({col})` (no k) throws
|
|
959
|
+
// NumberFormatException internally and the target write answers 50000.
|
|
960
|
+
const calcType = typeof agg.calculateType === "string" ? agg.calculateType.toUpperCase() : "";
|
|
961
|
+
if (["LARGE", "SMALL"].includes(calcType) && !/(LARGE|SMALL)\s*\(\s*[^,()]+\s*,/.test(String(agg.formula)))
|
|
962
|
+
throw new ToolRefusalError({
|
|
963
|
+
status: "refused",
|
|
964
|
+
blocker: "aggregation-large-missing-k",
|
|
965
|
+
schemaCode: schemaCode ?? null,
|
|
966
|
+
calculateType: calcType,
|
|
967
|
+
formula: String(agg.formula),
|
|
968
|
+
message: `${calcType} 必须带位置参数 k:写成 ${calcType}({<来源模型>.<数值列>},<k>)(k=1 是最大/最小)。` +
|
|
969
|
+
`缺 k 时平台内部抛 NumberFormatException(日志可见),目标模型写入一律 50000(r18b 真机)。` +
|
|
970
|
+
`真机验证:LARGE({src.amt},2) 对 10/30/20 返回 20;SMALL({src.amt},1) 返回 10。`,
|
|
971
|
+
});
|
|
972
|
+
// UNION concatenates DISTINCT text values ("去重后拼接文本"), so a numeric
|
|
973
|
+
// resultType makes the aggregation parse text as a number and the write
|
|
974
|
+
// 50000s. Text result types: SHORT_TEXT(0) / LONG_TEXT(1).
|
|
975
|
+
if (calcType === "UNION" && ![0, 1].includes(Number(agg.resultType ?? 2)))
|
|
976
|
+
throw new ToolRefusalError({
|
|
977
|
+
status: "refused",
|
|
978
|
+
blocker: "aggregation-union-result-type",
|
|
979
|
+
schemaCode: schemaCode ?? null,
|
|
980
|
+
resultType: Number(agg.resultType ?? 2),
|
|
981
|
+
message: `UNION 是「去重后拼接文本」,resultType 必须是文本类型(0=SHORT_TEXT / 1=LONG_TEXT;顶层 formulaConfig.resultType 决定)。` +
|
|
982
|
+
`用数值 resultType 时平台把拼接结果按数字解析 → NumberFormatException → 目标写入 50000(r18b 真机:resultType:2 失败,0 成功,读回 "P1")。`,
|
|
983
|
+
});
|
|
984
|
+
if (String(agg.dataItemCode).includes("."))
|
|
985
|
+
throw new ToolRefusalError({
|
|
986
|
+
status: "refused",
|
|
987
|
+
blocker: "aggregation-data-item-not-scalar",
|
|
988
|
+
schemaCode: schemaCode ?? null,
|
|
989
|
+
dataItemCode: String(agg.dataItemCode),
|
|
990
|
+
message: `聚合数据项 ${String(agg.dataItemCode)} 带点号:平台只接受**来源模型的主表标量列 code**(不带 schema 前缀)。` +
|
|
991
|
+
`写成 <子表>.<子列> 会在 field.publish 回 309004「使用的聚合数据项不存在」(r18 真机)。` +
|
|
992
|
+
`要汇总子表列:先在来源主模型上物化一个数值字段(门户计算规则或写入方维护),再聚合那个标量列。`,
|
|
993
|
+
});
|
|
957
994
|
if (schemaCode !== undefined && aggregationTargetsOwnSchema(schemaCode, String(agg.schemaCode)))
|
|
958
995
|
throw new ToolRefusalError({
|
|
959
996
|
status: "refused",
|
package/dist/goal-routes.js
CHANGED
|
@@ -13,7 +13,7 @@ import { listSkills, readSkillSection } from "./skills.js";
|
|
|
13
13
|
const SCOUT_CUES = ["能不能", "能不能够", "能否", "是否支持", "支持吗", "支持不支持", "可不可以", "有没有办法", "有没有可能", "怎么实现", "如何实现", "怎么写", "怎么配置"];
|
|
14
14
|
const MODIFY_CUES = ["修改", "调整", "更新", "重命名", "改名", "编辑", "删除", "去掉", "移除", "改为", "改成"];
|
|
15
15
|
const READ_CUES = ["查看", "读回", "盘点", "现状", "列出", "有哪些", "有没有", "检查", "审计", "导出", "只读", "看看", "看下", "查一下", "查询一下", "查一查", "梳理", "清点", "给我一份", "哪些", "是什么", "是否", "是否正确", "现有", "已有"];
|
|
16
|
-
const BUILD_CUES = ["新建", "创建", "搭建", "从零", "从无到有", "做", "建", "加", "实现", "生成", "新增", "保存", "启用", "录入", "添加"];
|
|
16
|
+
const BUILD_CUES = ["新建", "创建", "搭建", "从零", "从无到有", "做", "建", "加", "实现", "生成", "新增", "保存", "启用", "录入", "添加", "造", "填报", "打卡", "录"];
|
|
17
17
|
/** Whole-application asks — a single-model atom is the wrong shape for these. */
|
|
18
18
|
const WHOLE_APP_CUES = ["应用", "系统", "整套", "从零", "从无到有", "端到端", "一条龙", "一整套", "业务应用", "平台"];
|
|
19
19
|
function looksWholePackage(goal, capabilityCount) {
|
|
@@ -122,6 +122,10 @@ function capabilityScores(registry, goal) {
|
|
|
122
122
|
const DEFAULT_LADDER_RECIPES = {
|
|
123
123
|
businessrule: { tool: "rule.save", recipe: "business-rule-branch-conditional" },
|
|
124
124
|
datarule: { tool: "datarule.create", recipe: "field-compute-rule" },
|
|
125
|
+
// r18: a "造数据 / 录测试单据" ask reached the `data` capability but had no
|
|
126
|
+
// runnable shape — the probe had to fetch `describe data.submit --example`
|
|
127
|
+
// itself. These lane defaults give every ladder step a copyable command.
|
|
128
|
+
data: { tool: "data.submit", recipe: "plain-data-submit" },
|
|
125
129
|
};
|
|
126
130
|
function defaultRecipeFor(registry, capabilityId, lane) {
|
|
127
131
|
const wanted = DEFAULT_LADDER_RECIPES[capabilityId];
|
|
@@ -609,6 +613,13 @@ export function goalRoute(registry, goal) {
|
|
|
609
613
|
route: {
|
|
610
614
|
...(whole ? { primary: "intent", atomicSupplement } : { ladder }),
|
|
611
615
|
...routeReads(readSections),
|
|
616
|
+
// r18: when a step already carries a goal-matched recipe, the generic
|
|
617
|
+
// first section ("3. Draft template") is noise — the probe read it and
|
|
618
|
+
// got nothing. Say that the recipe command is the answer and the
|
|
619
|
+
// sections are only a fallback.
|
|
620
|
+
...(ladder.some((step) => step.recipe)
|
|
621
|
+
? { readHint: "已命中配方:先跑 firstCommands 里的 `omc describe … --example …` 取形状;下面的 readSections 只是补充,不必先读(确实需要时用 `omc help <topic> --section \"<节>\"`,按 readMore 逐节补)。" }
|
|
622
|
+
: {}),
|
|
612
623
|
// Each ladder step already carried a runnable recipe command, but it sat
|
|
613
624
|
// buried at `ladder[i].recipe.command` behind a readiness line — r14's
|
|
614
625
|
// probe reported "ladder 本身没给可直接跑的命令" and hand-built the rule
|
package/dist/lanes/field.js
CHANGED
|
@@ -141,6 +141,21 @@ function assertNameI18nArg(nameI18n) {
|
|
|
141
141
|
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
|
|
142
142
|
refuse("JSON 解析结果不是对象");
|
|
143
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* r18 (2026-10-26 live): aggregating a CHILD-TABLE schema (`schemaCode:"items"`)
|
|
146
|
+
* publishes fine but makes the TARGET model unwritable — every data.submit /
|
|
147
|
+
* data.update answers `40000 调用数据库发生异常` with no detail (the probe spent
|
|
148
|
+
* ~40 calls bisecting it). The child schema also has no parent-document column,
|
|
149
|
+
* so matching by the parent's document number can never work: even when the
|
|
150
|
+
* write goes through the value is always 0.
|
|
151
|
+
*
|
|
152
|
+
* Child schemas are recognizable from their field list: they alone carry the
|
|
153
|
+
* system columns `parentId`(子表业务对象父类ID)and `sortKey`(子表排序号).
|
|
154
|
+
*/
|
|
155
|
+
function childSchemaCodes(rows) {
|
|
156
|
+
const codes = new Set(rows.map((row) => String(row.code ?? row.propertyCode ?? "")));
|
|
157
|
+
return codes.has("parentId") && codes.has("sortKey");
|
|
158
|
+
}
|
|
144
159
|
/**
|
|
145
160
|
* r17 (2026-10-25, live + decompiled A/B): a FORMULA field CANNOT aggregate its
|
|
146
161
|
* own model's child table. `BizPropertyManagerImpl.publishFormula` rewrites
|
|
@@ -184,6 +199,43 @@ function assertNoSelfSchemaAggregation(args, published) {
|
|
|
184
199
|
message: aggregationSelfSchemaMessage(target, args.schemaCode),
|
|
185
200
|
});
|
|
186
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* The async half of the aggregation gate: a FOREIGN child schema cannot be
|
|
204
|
+
* detected syntactically, so read the target's field list once (only for
|
|
205
|
+
* AGGREGATION) and refuse when it carries the child-schema system columns.
|
|
206
|
+
*/
|
|
207
|
+
async function assertNoChildSchemaAggregation(session, schemaCode, propertyType, options) {
|
|
208
|
+
const resolved = typeof propertyType === "number" ? propertyType : FIELD_PROPERTY_TYPES[String(propertyType)];
|
|
209
|
+
if (resolved !== FIELD_PROPERTY_TYPES.FORMULA)
|
|
210
|
+
return;
|
|
211
|
+
const config = decodeJsonObjectColumn(options.formulaConfig, { invalid: "undefined", array: "reject", object: "reject" });
|
|
212
|
+
if (!config || config.formulaType !== "AGGREGATION" || typeof config.aggregation !== "string")
|
|
213
|
+
return;
|
|
214
|
+
const agg = decodeJsonObjectColumn(config.aggregation, { invalid: "undefined", array: "reject", object: "reject" });
|
|
215
|
+
const target = typeof agg?.schemaCode === "string" ? agg.schemaCode.trim() : "";
|
|
216
|
+
if (!target)
|
|
217
|
+
return;
|
|
218
|
+
let rows;
|
|
219
|
+
try {
|
|
220
|
+
rows = wireRows((await wireCall(session, { path: ENDPOINTS.fieldList, query: { schemaCode: target, isPublish: "true" } })).data);
|
|
221
|
+
}
|
|
222
|
+
catch {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
if (!childSchemaCodes(rows))
|
|
226
|
+
return;
|
|
227
|
+
throw new ToolRefusalError({
|
|
228
|
+
status: "refused",
|
|
229
|
+
blocker: "aggregation-target-is-child-schema",
|
|
230
|
+
schemaCode,
|
|
231
|
+
aggregationSchemaCode: target,
|
|
232
|
+
message: `聚合目标 ${target} 是**子表 schema**(字段清单里带 parentId/sortKey 系统列)。` +
|
|
233
|
+
`平台允许发布,但目标模型从此**整个不可写**:data.submit/data.update 一律回 40000「调用数据库发生异常」且无明细(r18 真机,二分 40 次调用才定位)。` +
|
|
234
|
+
`而且子表 schema 没有父单单号列,按父单匹配恒为 0——即使不报错也算不出值。` +
|
|
235
|
+
`正确做法:聚合**来源模型的主表标量列**。需要子表合计时,先在来源主模型物化一个数值字段` +
|
|
236
|
+
`(门户计算规则 / 写入方维护),再用 AGGREGATION 聚合该标量。配方:omc describe field.create --example formula-aggregation-cross-model。`,
|
|
237
|
+
});
|
|
238
|
+
}
|
|
187
239
|
export function registerFieldLane(tools) {
|
|
188
240
|
tools.push(defineTool({
|
|
189
241
|
name: "field.list",
|
|
@@ -344,6 +396,7 @@ export function registerFieldLane(tools) {
|
|
|
344
396
|
// One seam owns field-change normalization, every reproduced gate, and the
|
|
345
397
|
// wire body (src/field-change.ts), so configure_model and intent share it.
|
|
346
398
|
assertNoSelfSchemaAggregation(args, published);
|
|
399
|
+
await assertNoChildSchemaAggregation(session, args.schemaCode, args.propertyType, args.options ?? {});
|
|
347
400
|
const prepared = prepareFieldChange(args);
|
|
348
401
|
let performed;
|
|
349
402
|
try {
|
|
@@ -437,6 +490,7 @@ async function runFieldUpdate(session, args) {
|
|
|
437
490
|
.then((response) => wireRows(response.data))
|
|
438
491
|
.catch(() => []);
|
|
439
492
|
assertNoSelfSchemaAggregation({ schemaCode: args.schemaCode, propertyType: record.type ?? record.propertyType, options: args.options }, publishedRows);
|
|
493
|
+
await assertNoChildSchemaAggregation(session, args.schemaCode, record.type ?? record.propertyType, args.options);
|
|
440
494
|
}
|
|
441
495
|
const update = {
|
|
442
496
|
schemaCode: args.schemaCode,
|
|
@@ -40,7 +40,7 @@ export function dataSubmitDescription() {
|
|
|
40
40
|
`就地语义:${wire.submitInPlace};无流程 readback 必须确认 objectId 与传入 bizObjectId 相同;无 bizObjectId 的 workflowCode 新建单 → PROCESSING + workflowInstanceId,无流程 → 该行 COMPLETED。`,
|
|
41
41
|
`既有草稿发起流程的唯一支持形状是两段式:先 data.save 带 workflowCode 暂存(${wire.workflowDraftSave}),再以返回的 workItemId 提交。`,
|
|
42
42
|
`仅无 workflowCode/workItemId/workflowInstanceId 且无 bizObjectId 时保留 save→submit 便捷链(新建记录);只要存在 workItemId 或 workflowInstanceId 就 fail-closed 拒绝(blocker submit-biz-object-id-required),零 runtime/form/submit wire。`,
|
|
43
|
-
`formType 自动判定:无任何 workflowCode/workItemId/workflowInstanceId 时**先按模型自动判定**——GET workflow/isworkflow?schemaCode=true 则用 workflow/getWorkflow 解析已发布流程码并**发起流程**(formType="${wire.formTypeWorkflow}",自动先 GET getReplayToken 注入 replayToken,否则 ${wire.replayTokenErrcode} 频繁重复提交);模型无流程 → "${wire.formTypeNoWorkflow}"(无流程提交,走 live 已证链 ${wire.submitChain};单发新建对象会 ${wire.typeCastErrcode},bizObject 勿带字符串 status)或 workItemId+workflowInstanceId(审批待办,agree
|
|
43
|
+
`formType 自动判定:无任何 workflowCode/workItemId/workflowInstanceId 时**先按模型自动判定**——GET workflow/isworkflow?schemaCode=true 则用 workflow/getWorkflow 解析已发布流程码并**发起流程**(formType="${wire.formTypeWorkflow}",自动先 GET getReplayToken 注入 replayToken,否则 ${wire.replayTokenErrcode} 频繁重复提交);模型无流程 → "${wire.formTypeNoWorkflow}"(无流程提交,走 live 已证链 ${wire.submitChain};单发新建对象会 ${wire.typeCastErrcode},bizObject 勿带字符串 status)或 workItemId+workflowInstanceId(审批待办,agree **顶层**通过/驳回(approval 对象里放 agree 会被静默忽略并按通过处理),**必须带 bizObjectId 指向在途单据**,否则引擎 NPE ${wire.approvalNpeErrcode})→ "${wire.formTypeWorkflow}"。即「无流程直接提交、有流程发起流程」,不再把有流程模型的新建数据落成游离 sheet 行。`,
|
|
44
44
|
"根因提示(环境相关,ticket 78 观测):**某些环境**里模型所在应用未发布时运行时提交稳定 50000,工具会反推并拒 app-not-published。该根因非普遍规律(见 data.save 的同条提示与 docs/issues/omc-cli-findings-2026-09-19.md B17)——遇 50000 先只读核对再判断。",
|
|
45
45
|
"Pass `sheetCode` explicitly when the model has multiple sheets; otherwise the default-form sheetCode is resolved from bizsheet/get.",
|
|
46
46
|
`计算字段:${wire.formulaFieldNote}`,
|
|
@@ -598,6 +598,65 @@ export function assertRuntimeFieldValueShapes(meta, formData, childCodes, contex
|
|
|
598
598
|
}
|
|
599
599
|
}
|
|
600
600
|
}
|
|
601
|
+
/**
|
|
602
|
+
* r18 (2026-10-26 live): `errcode 40000 调用数据库发生异常` carries NO detail and
|
|
603
|
+
* `omc-refusals` had nothing for it. A probe burned ~40 calls bisecting it:
|
|
604
|
+
* the cause was an AGGREGATION field whose `schemaCode` pointed at a CHILD-TABLE
|
|
605
|
+
* schema — publish succeeds, then every write on that model 40000s. A FORMULA
|
|
606
|
+
* field whose config cannot serialize does the same.
|
|
607
|
+
*
|
|
608
|
+
* Metadata is read ONLY on failure (zero cost on the success path). The refusal
|
|
609
|
+
* names the model's FORMULA/AGGREGATION fields so the caller bisects the right
|
|
610
|
+
* thing instead of guessing at forms/permissions.
|
|
611
|
+
*/
|
|
612
|
+
async function diagnoseDbException(session, schemaCode, error) {
|
|
613
|
+
// Non-40000 errors fall through untouched (callers keep their own branches).
|
|
614
|
+
if (!(error instanceof WireError && error.kind === "business" && error.errcode === 40000))
|
|
615
|
+
return false;
|
|
616
|
+
let rows = [];
|
|
617
|
+
try {
|
|
618
|
+
rows = wireRows((await wireCall(session, { path: ENDPOINTS.fieldList, query: { schemaCode, isPublish: "true" } })).data);
|
|
619
|
+
}
|
|
620
|
+
catch {
|
|
621
|
+
// metadata unavailable: still explain what 40000 means
|
|
622
|
+
}
|
|
623
|
+
const formulaFields = [];
|
|
624
|
+
for (const row of rows) {
|
|
625
|
+
if (Number(row.propertyType ?? row.type) !== 100)
|
|
626
|
+
continue;
|
|
627
|
+
let formulaType;
|
|
628
|
+
let aggregationSchemaCode;
|
|
629
|
+
if (typeof row.options === "string" && row.options) {
|
|
630
|
+
try {
|
|
631
|
+
const options = JSON.parse(row.options);
|
|
632
|
+
const config = typeof options.formulaConfig === "string" ? JSON.parse(options.formulaConfig) : undefined;
|
|
633
|
+
if (typeof config?.formulaType === "string")
|
|
634
|
+
formulaType = config.formulaType;
|
|
635
|
+
if (typeof config?.aggregation === "string") {
|
|
636
|
+
const agg = JSON.parse(config.aggregation);
|
|
637
|
+
if (typeof agg.schemaCode === "string")
|
|
638
|
+
aggregationSchemaCode = agg.schemaCode;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
catch {
|
|
642
|
+
formulaType = "unparsable-formulaConfig";
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
formulaFields.push({ code: String(row.code ?? row.propertyCode ?? ""), ...(formulaType ? { formulaType } : {}), ...(aggregationSchemaCode ? { aggregationSchemaCode } : {}) });
|
|
646
|
+
}
|
|
647
|
+
throw new ToolRefusalError({
|
|
648
|
+
status: "refused",
|
|
649
|
+
blocker: "runtime-write-db-exception",
|
|
650
|
+
schemaCode,
|
|
651
|
+
errcode: 40000,
|
|
652
|
+
formulaFields,
|
|
653
|
+
message: `平台回 40000「调用数据库发生异常」——这是**无明细的掩码**,不是表单/权限问题(r18 真机)。` +
|
|
654
|
+
`本模型上的公式字段:${formulaFields.length > 0 ? formulaFields.map((field) => `${field.code}(${field.formulaType ?? "?"}${field.aggregationSchemaCode ? `→${field.aggregationSchemaCode}` : ""})`).join("、") : "(读不到 field.list,或没有 FORMULA 字段)"}。` +
|
|
655
|
+
`最常见原因:**AGGREGATION 字段的 schemaCode 指向子表 schema** —— 平台允许发布,但该模型从此整个不可写。` +
|
|
656
|
+
`其次是 FORMULA 的 formulaConfig 无法序列化。` +
|
|
657
|
+
`定位:依次禁用/删除可疑公式字段再写一次(可逆);形状见 omc describe field.create --example formula-aggregation-cross-model。`,
|
|
658
|
+
});
|
|
659
|
+
}
|
|
601
660
|
/** Runtime business-object data keyed by field code. */
|
|
602
661
|
export function registerRuntimeDataLane(tools) {
|
|
603
662
|
tools.push(defineTool({
|
|
@@ -949,15 +1008,22 @@ export function registerRuntimeDataLane(tools) {
|
|
|
949
1008
|
// isStartWf branch runs verifyReplay; the instance is DRAFT only when
|
|
950
1009
|
// data carries sequenceStatus DRAFT (an empty default builds PROCESSING).
|
|
951
1010
|
const replayToken = await getReplayToken(session);
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
1011
|
+
let performed;
|
|
1012
|
+
try {
|
|
1013
|
+
performed = await runtimeWriteWithAppMapping(session, args.schemaCode, 50000, "data.save 运行时写稳定失败(50000)", () => wireCall(session, {
|
|
1014
|
+
path: ENDPOINTS.runtimeFormSave,
|
|
1015
|
+
method: "POST",
|
|
1016
|
+
body: {
|
|
1017
|
+
workflowCode: args.workflowCode,
|
|
1018
|
+
...(replayToken ? { replayToken } : {}),
|
|
1019
|
+
bizObject: { schemaCode: args.schemaCode, sheetCode, data: { ...formData, id: objectId, sequenceStatus: "DRAFT" } },
|
|
1020
|
+
},
|
|
1021
|
+
}), formData, args.workflowCode);
|
|
1022
|
+
}
|
|
1023
|
+
catch (error) {
|
|
1024
|
+
await diagnoseDbException(session, args.schemaCode, error);
|
|
1025
|
+
throw error;
|
|
1026
|
+
}
|
|
961
1027
|
const vo = (performed.data ?? {});
|
|
962
1028
|
const returnedId = typeof vo.objectId === "string" && vo.objectId ? vo.objectId : typeof vo.bizObjectId === "string" && vo.bizObjectId ? vo.bizObjectId : objectId;
|
|
963
1029
|
const workflowInstanceId = typeof vo.workflowInstanceId === "string" ? vo.workflowInstanceId : null;
|
|
@@ -992,11 +1058,18 @@ export function registerRuntimeDataLane(tools) {
|
|
|
992
1058
|
readback: { authoritative: projectReadbackRecord(normalizeLoadedRecord((readbackData ?? {})), args), sequenceStatus, expectedSequenceStatus: "DRAFT" },
|
|
993
1059
|
};
|
|
994
1060
|
}
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1061
|
+
let performed;
|
|
1062
|
+
try {
|
|
1063
|
+
performed = await runtimeWriteWithAppMapping(session, args.schemaCode, 50000, "data.save 运行时写稳定失败(50000)", () => wireCall(session, {
|
|
1064
|
+
path: ENDPOINTS.runtimeFormSave,
|
|
1065
|
+
method: "POST",
|
|
1066
|
+
body: { bizObject: { schemaCode: args.schemaCode, sheetCode, data: formData } },
|
|
1067
|
+
}), formData);
|
|
1068
|
+
}
|
|
1069
|
+
catch (error) {
|
|
1070
|
+
await diagnoseDbException(session, args.schemaCode, error);
|
|
1071
|
+
throw error;
|
|
1072
|
+
}
|
|
1000
1073
|
const bizObjectId = performed.data?.bizObjectId ?? performed.data?.objectId ?? performed.data;
|
|
1001
1074
|
let readbackData = null;
|
|
1002
1075
|
if (typeof bizObjectId === "string" && bizObjectId) {
|
|
@@ -1090,14 +1163,21 @@ export function registerRuntimeDataLane(tools) {
|
|
|
1090
1163
|
});
|
|
1091
1164
|
}
|
|
1092
1165
|
const formData = (await prepareRuntimeFormData(session, args.schemaCode, args.formData, { isUpdate: true })).formData;
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1166
|
+
let performed;
|
|
1167
|
+
try {
|
|
1168
|
+
performed = await wireCall(session, {
|
|
1169
|
+
path: ENDPOINTS.runtimeFormSave,
|
|
1170
|
+
method: "POST",
|
|
1171
|
+
// Live-proven shape: BizObjectModel.getId() reads data["id"], so the
|
|
1172
|
+
// target id MUST travel inside `data`; a top-level bizObject.id is
|
|
1173
|
+
// ignored and the platform silently creates a new row.
|
|
1174
|
+
body: { bizObject: { schemaCode: args.schemaCode, sheetCode, data: { ...formData, id: args.bizObjectId } } },
|
|
1175
|
+
});
|
|
1176
|
+
}
|
|
1177
|
+
catch (error) {
|
|
1178
|
+
await diagnoseDbException(session, args.schemaCode, error);
|
|
1179
|
+
throw error;
|
|
1180
|
+
}
|
|
1101
1181
|
const performedData = (performed.data ?? {});
|
|
1102
1182
|
const returnedId = typeof performedData.objectId === "string" ? performedData.objectId : typeof performedData.bizObjectId === "string" ? performedData.bizObjectId : args.bizObjectId;
|
|
1103
1183
|
const readbackData = await loadExistingBizObject(session, args.schemaCode, sheetCode, returnedId);
|
|
@@ -1210,6 +1290,27 @@ export function registerRuntimeDataLane(tools) {
|
|
|
1210
1290
|
`而错误里不会说是哪一个。要么给出真实 id,要么整个省略该键(省略 ≠ 传空串)。`,
|
|
1211
1291
|
});
|
|
1212
1292
|
const hasWorkItem = typeof args.workItemId === "string" && args.workItemId.trim().length > 0;
|
|
1293
|
+
// r18b: pure shape check — run before any read/wire so a wrong-result
|
|
1294
|
+
// payload never costs a round trip.
|
|
1295
|
+
if (args.approval && typeof args.approval === "object") {
|
|
1296
|
+
const misplaced = args.approval;
|
|
1297
|
+
if (misplaced.agree !== undefined)
|
|
1298
|
+
throw new ToolRefusalError({
|
|
1299
|
+
status: "refused",
|
|
1300
|
+
blocker: "submit-approval-agree-misplaced",
|
|
1301
|
+
schemaCode: args.schemaCode,
|
|
1302
|
+
message: `approval.agree 不生效:平台只读**顶层** agree(true=通过 / false=驳回)。approval 对象里放 agree 会被**静默忽略并按通过处理**` +
|
|
1303
|
+
`(r18b 真机:approval:{agree:false} 仍写入 result=APPROVE 并把流程走完)。改成顶层参数 {"agree":false,...}。`,
|
|
1304
|
+
});
|
|
1305
|
+
if (misplaced.opinion !== undefined)
|
|
1306
|
+
throw new ToolRefusalError({
|
|
1307
|
+
status: "refused",
|
|
1308
|
+
blocker: "submit-approval-opinion-misplaced",
|
|
1309
|
+
schemaCode: args.schemaCode,
|
|
1310
|
+
message: `approval.opinion 不是平台键,会被静默丢弃(r18b 真机:意见不进 h_biz_comment,content 为 NULL)。` +
|
|
1311
|
+
`审批意见(BizCommentModel)用 **approval.content**;附件 approval.resources;下一步审批人 approval.relUsers。`,
|
|
1312
|
+
});
|
|
1313
|
+
}
|
|
1213
1314
|
const hasInstance = typeof args.workflowInstanceId === "string" && args.workflowInstanceId.trim().length > 0;
|
|
1214
1315
|
const targetObjectId = typeof args.bizObjectId === "string" && args.bizObjectId.trim() ? args.bizObjectId.trim() : null;
|
|
1215
1316
|
if ((hasWorkItem || hasInstance) && !targetObjectId) {
|
|
@@ -1424,6 +1525,7 @@ export function registerRuntimeDataLane(tools) {
|
|
|
1424
1525
|
}), undefined, hasWorkflowCode ? explicitWorkflowCode : undefined);
|
|
1425
1526
|
}
|
|
1426
1527
|
catch (error) {
|
|
1528
|
+
await diagnoseDbException(session, args.schemaCode, error);
|
|
1427
1529
|
// r16 P4: 100005 is SYS_REPLAY_ERROR「频繁重复提交!」(ErrorCode.java:68 —
|
|
1428
1530
|
// the same numeric code as TEST_CONNECTION_FAIL, so only the text
|
|
1429
1531
|
// separates them). The platform rate-limits per WORK ITEM, so a different
|
|
@@ -1607,6 +1709,15 @@ export function registerRuntimeDataLane(tools) {
|
|
|
1607
1709
|
// SEPARATE concern from server-side business rules (which DO run on
|
|
1608
1710
|
// submit) — name that so `portalRulesExecuted:false` is not misread as
|
|
1609
1711
|
// "no rule ran" (dogfood R2).
|
|
1712
|
+
// r18b: an approval submit that omits `agree` is treated as APPROVE by
|
|
1713
|
+
// the platform (`agree: args.agree !== false`). That default is right
|
|
1714
|
+
// for the portal button, but for an API caller "I forgot the flag" and
|
|
1715
|
+
// "I approve" must not look identical in the receipt.
|
|
1716
|
+
...(hasWorkItem && args.agree === undefined
|
|
1717
|
+
? {
|
|
1718
|
+
approvalNote: "本次是审批提交但未传 agree——平台按**通过**处理(顶层 agree 缺省 true)。要驳回必须显式 agree:false;approval.agree 不生效。",
|
|
1719
|
+
}
|
|
1720
|
+
: {}),
|
|
1610
1721
|
portalRulesExecuted: false,
|
|
1611
1722
|
portalRulesNote: "portalRulesExecuted 只指门户客户端的必填/控件校验未在 REST 提交时执行;服务端业务规则(含流程 end 规则)照常运行。",
|
|
1612
1723
|
requiredFields: validation.requiredFields,
|
package/dist/model-scaffold.js
CHANGED
|
@@ -108,11 +108,50 @@ export async function cmdModelScaffold(args) {
|
|
|
108
108
|
...(environment !== undefined ? { environment } : {}),
|
|
109
109
|
};
|
|
110
110
|
const plan = describeScaffoldPlan(options);
|
|
111
|
+
// r18: run the field-family preflight even in DRY-RUN. It is zero-wire
|
|
112
|
+
// (`field.create --dry-run` runs only the local capability gate), and the
|
|
113
|
+
// probe's first attempt — NUMERICAL without options.scale — passed the old
|
|
114
|
+
// plan-only dry-run and would have half-built a model on --apply.
|
|
115
|
+
const preflightProblems = [];
|
|
116
|
+
const preflightTargets = [
|
|
117
|
+
...fields.filter((field) => scaffoldChildrenOf(field).length === 0),
|
|
118
|
+
...fields.filter((field) => scaffoldChildrenOf(field).length > 0),
|
|
119
|
+
];
|
|
120
|
+
{
|
|
121
|
+
for (const field of preflightTargets) {
|
|
122
|
+
const probe = await runToolCall("field.create", {
|
|
123
|
+
args: scaffoldFieldArgs(code, field),
|
|
124
|
+
requestId: request,
|
|
125
|
+
dryRun: true,
|
|
126
|
+
...(environment !== undefined ? { environment } : {}),
|
|
127
|
+
print: () => undefined,
|
|
128
|
+
});
|
|
129
|
+
const status = String(probe.result.status ?? "ok");
|
|
130
|
+
if (probe.exitCode !== 0 || (status !== "dry-run" && status !== "ok")) {
|
|
131
|
+
preflightProblems.push({ code: field.code, message: refusalText(probe.result) });
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (preflightProblems.length > 0) {
|
|
135
|
+
writeEnvelope(envelope("error", {
|
|
136
|
+
status: "refused",
|
|
137
|
+
blocker: "scaffold-preflight-failed",
|
|
138
|
+
model: code,
|
|
139
|
+
written: false,
|
|
140
|
+
failed: preflightProblems.length,
|
|
141
|
+
preflightProblems,
|
|
142
|
+
message: `有 ${preflightProblems.length} 个字段的预检没过,**尚未写入任何东西**。` +
|
|
143
|
+
`按 message 改 --fields 后重跑(常见:NUMERICAL 缺 options.scale、文本/数值字段用了自定义键名)。` +
|
|
144
|
+
`--fields 的每一项就是 field.create 的参数(形状见 omc describe field.create),子表列用 subFields(childFields 是别名)。`,
|
|
145
|
+
}, request, { code: "policy-refused", message: "字段形状预检未通过(未写入)", retryable: false }));
|
|
146
|
+
return CLI_EXIT_CODES.policyRefused;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
111
149
|
if (!apply) {
|
|
112
150
|
writeEnvelope(envelope("ok", {
|
|
113
151
|
status: "dry-run",
|
|
114
152
|
...plan,
|
|
115
|
-
|
|
153
|
+
preflight: { checked: fields.length, passed: true },
|
|
154
|
+
note: "dry-run 只列计划;已对每个字段跑过本地形状预检(零 wire)。--apply 依次执行 建模型 → 建字段 → 建子列 → 发布字段 → 发布表单。",
|
|
116
155
|
}, request));
|
|
117
156
|
return CLI_EXIT_CODES.ok;
|
|
118
157
|
}
|
|
@@ -138,43 +177,7 @@ export async function cmdModelScaffold(args) {
|
|
|
138
177
|
return { ok: outcome.exitCode === 0, result };
|
|
139
178
|
};
|
|
140
179
|
const lastSummaries = [];
|
|
141
|
-
// 0)
|
|
142
|
-
// r13 真机:`NUMERICAL` 少 options.scale 时,前两个字段已经建好了才在第 3 个
|
|
143
|
-
// 报错,留下一个半成品模型要手工清。半成品比慢一点贵得多。
|
|
144
|
-
// 子列不在这里校验:它们的目标 schema(子表)此刻还不存在,dry-run 会误报。
|
|
145
|
-
const preflightTargets = [
|
|
146
|
-
...fields.filter((field) => scaffoldChildrenOf(field).length === 0),
|
|
147
|
-
...fields.filter((field) => scaffoldChildrenOf(field).length > 0),
|
|
148
|
-
];
|
|
149
|
-
const preflightProblems = [];
|
|
150
|
-
for (const field of preflightTargets) {
|
|
151
|
-
const probe = await runToolCall("field.create", {
|
|
152
|
-
args: scaffoldFieldArgs(code, field),
|
|
153
|
-
requestId: request,
|
|
154
|
-
dryRun: true,
|
|
155
|
-
...(environment !== undefined ? { environment } : {}),
|
|
156
|
-
print: () => undefined,
|
|
157
|
-
});
|
|
158
|
-
const status = String(probe.result.status ?? "ok");
|
|
159
|
-
if (probe.exitCode !== 0 || (status !== "dry-run" && status !== "ok")) {
|
|
160
|
-
preflightProblems.push({ code: field.code, message: refusalText(probe.result) });
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
if (preflightProblems.length > 0) {
|
|
164
|
-
const result = {
|
|
165
|
-
status: "refused",
|
|
166
|
-
blocker: "scaffold-preflight-failed",
|
|
167
|
-
model: code,
|
|
168
|
-
// Nothing was written — that is the point.
|
|
169
|
-
written: false,
|
|
170
|
-
failed: preflightProblems.length,
|
|
171
|
-
preflightProblems,
|
|
172
|
-
message: `有 ${preflightProblems.length} 个字段的 dry-run 预检没过,**尚未写入任何东西**。` +
|
|
173
|
-
`按下面的 message 改 --fields 后重跑(常见:NUMERICAL 缺 options.scale、SELECTION/RADIO 缺 choices、CHILD_TABLE 缺 subFields)。`,
|
|
174
|
-
};
|
|
175
|
-
writeEnvelope(envelope("refused", result, request, { code: "policy-refused", message: String(result.message), retryable: false }));
|
|
176
|
-
return CLI_EXIT_CODES.policyRefused;
|
|
177
|
-
}
|
|
180
|
+
// 0) 字段形状预检已在上面的 dry-run 分支前完成(零 wire);这里只记录。
|
|
178
181
|
steps.push({ step: "preflight", status: "ok", detail: { checked: preflightTargets.length, wrote: false } });
|
|
179
182
|
// 1) 模型:已存在是常态(补建场景),不是失败。
|
|
180
183
|
const created = await call("model.create", {
|
package/dist/recipes/field.js
CHANGED
|
@@ -253,12 +253,13 @@ const formulaAggregationCrossModel = Object.freeze({
|
|
|
253
253
|
preconditions: [
|
|
254
254
|
"**只能汇总「别的模型」**:同模型(含自己的子表)聚合在 field.publish 必抛 305003(平台 publishFormula 把相对码改写成子表父模型 = 本模型,checkCycleOfAggregation:1032 判成环)。工具已写前拒绝 `aggregation-self-schema-cycle`。",
|
|
255
255
|
"目标字段用 FORMULA(100)(不是普通字段 + 计算规则——type2 计算规则在 REST 路径永不执行)。",
|
|
256
|
-
"`schemaCode` 是被汇总的**来源模型**;`dataItemCode`
|
|
256
|
+
"`schemaCode` 是被汇总的**来源模型**;`dataItemCode` 是来源模型的**主表标量列**(不带 schema 前缀);`queryConditions` **不能为空**,否则反向过滤器为空、找不到要回算的目标行(真机:空条件时 recalc 日志照常打印但目标字段恒为 0)。",
|
|
257
|
+
"**不要指向子表 schema**(r18 2026-10-26 真机):`schemaCode:\"<子表>\"` 能发布,但目标模型从此**整个不可写** —— `data.submit`/`data.update` 一律回 40000「调用数据库发生异常」且无明细;而且子表 schema 没有父单单号列,按父单匹配恒为 0。`dataItemCode` 写成 `<子表>.<子列>` 则在 publish 直接 309004「使用的聚合数据项不存在」。要汇总子表:先在来源**主模型**上物化一个数值字段(门户计算规则或写入方维护),再聚合该标量。OMC 已写前拒绝 `aggregation-target-is-child-schema` / `aggregation-data-item-not-scalar`。",
|
|
257
258
|
],
|
|
258
259
|
conditionalRequirements: [
|
|
259
260
|
"**DYNAMIC 条件的两个 code 分属两侧,写反了就静默 0**:`propertyCode` = **来源模型**的字段(这里是 r17_c.nm),`currentPropertyCode` = **目标模型**的字段(这里是 r17_d.srcNo)。语义 = 「来源行的 nm 等于本目标行的 srcNo」。",
|
|
260
261
|
"`propertyType`/`currentPropertyType` 是 BizPropertyType 的**整数码**(0=SHORT_TEXT 2=NUMERICAL 9=WORK_SHEET…),`operatorType` 是 OperatorType 的**整数码**(1=EQ 6=ITEQ 9=IS_NULL 10=IS_NOT_NULL…)。写名字会被 ObjectMapperUtils 抛 json processing exception 并掩码成 305003;工具会自动转码。",
|
|
261
|
-
"`calculateType` 是**字符串**(SUM/COUNT/COUNTIF/SUMIF/AVG/MAX/MIN
|
|
262
|
+
"`calculateType` 是**字符串**(SUM/COUNT/COUNTIF/SUMIF/AVG/MAX/MIN/**LARGE/SMALL/UNION**),不是枚举 code。r18b 真机三种特殊算法:LARGE/SMALL **必须带位置参数** `LARGE({<来源>.<列>},2)`(缺 k → 平台 NumberFormatException → 目标写入 50000);**UNION 是文本拼接**,顶层 `resultType` 必须是 0/LONG_TEXT=1(写 2 会 50000,读回是去重串,如单号本身);SUM/AVG/MAX/MIN/COUNT 用 resultType:2。",
|
|
262
263
|
"发布后平台会**自动生成一条 t100 CALCULATE_RULE 镜像行**(h_biz_data_rule,propertyCode=字段 code),它是回算触发的前置条件,别手动删。",
|
|
263
264
|
"**回算时机(r17b 2026-10-26 真机完整行为图谱)**:① 目标行**自己 submit** 时镜像规则一定算(最可靠,不依赖事件);② 来源行 submit/update/delete 触发 `RollUpEventListener`→`FormulaPropertySupport` 事件回算——FIXED+DYNAMIC 混用、多组 OR、COUNTIF/MAX、子表行级条件(propertyCode 带 `.`)都验证过,DELETE 也会回算;③ ⚠️ 事件回算**只在目标模型发布后的几分钟内可靠**,之后静默停止(源端数据变了目标字段不更新、无报错)——重新 `field.publish --force` 目标模型即可恢复。定时巡检/对账场景务必重发或依赖目标行写入路径。",
|
|
264
265
|
],
|
|
@@ -48,7 +48,9 @@ const workflowSubmit = Object.freeze({
|
|
|
48
48
|
tool: "data.submit",
|
|
49
49
|
args: { environment, schemaCode: model, workflowCode: "<workflow.code>", bizObjectId: "<data.save.performed.bizObjectId>", workflowInstanceId: "<data.save.performed.workflowInstanceId>", workItemId: "<data.save.performed.workItemId>", formData: { name: "recipe draft" } },
|
|
50
50
|
preconditions: ["同一 recipe 的 data.save 已成功并读回 DRAFT;workflowInstanceId/workItemId/bizObjectId 均非空"],
|
|
51
|
-
conditionalRequirements: [
|
|
51
|
+
conditionalRequirements: [
|
|
52
|
+
"workItemId 或 workflowInstanceId 出现时必须传 bizObjectId;身份只能复制 data.save 的 authoritative readback",
|
|
53
|
+
],
|
|
52
54
|
priorToolReferences: [
|
|
53
55
|
{ tool: "data.save", args: { environment, schemaCode: model, workflowCode: "<workflow.code>", formData: { name: "recipe draft" } }, purpose: "提供三个环境生成的提交身份" },
|
|
54
56
|
{ tool: "workitem.list", args: { environment }, purpose: "当 data.save 未直接返回 workItemId 时按 workflowInstanceId 解析待办" },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stalfh233/omc-cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.99",
|
|
4
4
|
"description": "CloudPivot 8.6 configuration capability CLI — governed, fail-closed, coverage-manifest bounded.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
"access": "public"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@stalfh233/omc-fake-platform": "0.4.
|
|
53
|
+
"@stalfh233/omc-fake-platform": "0.4.99",
|
|
54
54
|
"commander": "14.0.3",
|
|
55
|
-
"omc-core": "0.4.
|
|
55
|
+
"omc-core": "0.4.99",
|
|
56
56
|
"proper-lockfile": "4.1.2",
|
|
57
57
|
"write-file-atomic": "6.0.0",
|
|
58
58
|
"zod": "^3.23.8",
|
|
@@ -154,8 +154,9 @@ rules:
|
|
|
154
154
|
- **「聚合计算」是字段能力,不是规则节点**:FORMULA(计算公式)字段的 `options.formulaConfig.formulaType="AGGREGATION"` 就是 UI 里的「配置方式 → 聚合计算」。**只能汇总另一个模型**(跨模型),**同模型/自己的子表会 305003**(`field.publish` 时 `publishFormula` 把相对码改写成子表父模型 = 本模型,`checkCycleOfAggregation:1032` 判成环;工具已写前拒绝 `aggregation-self-schema-cycle`)。可直接抄 `omc describe field.create --example formula-aggregation-cross-model`。形状:
|
|
155
155
|
`options = {persistent:true, formulaConfig: JSON字符串({resultType:2, formulaType:"AGGREGATION", aggregation: JSON字符串({schemaCode:"<来源模型>", dataItemCode:"<来源列>", calculateType:"SUM", formula:"SUM({<来源模型>.<列>})", queryConditions:[[{propertyCode:"<来源模型字段>", currentPropertyCode:"<目标模型字段>", operatorType:1, valueType:"DYNAMIC"}]]})})}`。
|
|
156
156
|
- **`queryConditions` 不能为空**:它是反向过滤器的唯一输入,空数组时回算日志照打但目标字段恒 0(r17 实测)。
|
|
157
|
+
- **聚合目标必须是来源主表的标量列**(r18 2026-10-26 真机):`aggregation.schemaCode` 指向**子表 schema** 时能发布,但目标模型从此整个不可写(`data.submit`/`data.update` 全回 40000 无明细),且子表无父单单号列、匹配恒 0;`dataItemCode` 写 `<子表>.<子列>` 则 publish 回 309004。要子表合计:先在来源主模型物化一个数值字段,再聚合该标量。
|
|
157
158
|
- **DYNAMIC 条件的两个 code 分属两侧,写反了静默 0**:`propertyCode` = 来源模型字段,`currentPropertyCode` = 目标模型字段;语义「来源行的 X 等于本目标行的 Y」。
|
|
158
|
-
- **`propertyType`/`currentPropertyType`(BizPropertyType)与 `operatorType`(OperatorType)必须写整数**——两者都是 `@JsonCreator get(int)`:propertyType 0=SHORT_TEXT 2=NUMERICAL 3=DATE 9=WORK_SHEET…;operatorType 1=EQ 2=NEQ 3=GT 4=IT(小于)5=GTEQ 6=ITEQ(小于等于)9=IS_NULL 10=IS_NOT_NULL…。写名字会被 `ObjectMapperUtils` 抛 json processing exception,再被死循环校验掩码成 305003(工具接受名字并自动转码)。`calculateType` 相反,是**字符串**(SUM/COUNT/COUNTIF/SUMIF/AVG/MAX/MIN/LARGE/SMALL/UNION
|
|
159
|
+
- **`propertyType`/`currentPropertyType`(BizPropertyType)与 `operatorType`(OperatorType)必须写整数**——两者都是 `@JsonCreator get(int)`:propertyType 0=SHORT_TEXT 2=NUMERICAL 3=DATE 9=WORK_SHEET…;operatorType 1=EQ 2=NEQ 3=GT 4=IT(小于)5=GTEQ 6=ITEQ(小于等于)9=IS_NULL 10=IS_NOT_NULL…。写名字会被 `ObjectMapperUtils` 抛 json processing exception,再被死循环校验掩码成 305003(工具接受名字并自动转码)。`calculateType` 相反,是**字符串**(SUM/COUNT/COUNTIF/SUMIF/AVG/MAX/MIN/LARGE/SMALL/UNION);LARGE/SMALL 必须带 k(`LARGE({来源.列},2)`),UNION 是文本拼接、resultType 必须是 0/1。
|
|
159
160
|
- **回算时机(r17b 2026-10-26 完整行为图谱)**:① 目标行**自己 submit** 时镜像规则一定算(最可靠);② 来源行 submit/update/**delete** 触发 `RollUpEventListener`→`FormulaPropertySupport` 事件回算(FIXED+DYNAMIC 混用、多组 OR、COUNTIF/MAX、子表行级条件都验过);③ ⚠️ 事件回算**只在目标模型发布后几分钟内可靠**,之后静默停止(无报错)——`field.publish --force` 目标模型恢复。发布后平台自动生成 t100 `CALCULATE_RULE` 镜像行,别删。r17 真机:目标行 srcNo=C1、来源 C1 行 amt=100 → 读 100;再提交一条 C1/amt=5 → 读 105。
|
|
160
161
|
- **普通数值字段 + 计算规则(type2)不能替代**:REST 路径永不执行(`CalculateHandler.java:50` 的 `forceExecuteCalculateRule` 从不置真),门户里才算。
|
|
161
162
|
- **DYNAMIC 来源不要写点号**:`dataActions` 的 `currentDataItemValue` 写 `items.sealNo` 会被引擎当成**子表列集合**(DatasetImpl),标量目标收到集合 → 运行期 `submit/update` 报 50000(`WorkSheetBizField.fillClientContent: Incorrect value type`)。单跳关联字段直接写字段 code(引擎取 `.id`);子表列只能用于公式/聚合。`rule.save` 已写前拒绝(`rule-graph-create-dynamic-source-is-child-collection`)。
|
package/skills/omc-refusals.md
CHANGED
|
@@ -62,6 +62,14 @@ condition/expression/query shape is off. Compare against
|
|
|
62
62
|
`omc describe <tool> --example …` and the node-graph prose, then re-save.
|
|
63
63
|
Escalate to 二开 **only** for a real `capability-out-of-coverage` (§2).
|
|
64
64
|
|
|
65
|
+
`40000 调用数据库发生异常` is the **most opaque** shape code — no detail at all.
|
|
66
|
+
Line up the model's field-level config first: an `AGGREGATION` FORMULA field whose
|
|
67
|
+
`aggregation.schemaCode` points at a **child-table schema** publishes fine and then
|
|
68
|
+
makes every `data.submit`/`data.update` on that model 40000 (r18 2026-10-26 live;
|
|
69
|
+
bisect by deleting/disabling the suspect formula field, which is reversible).
|
|
70
|
+
`omc` now answers `runtime-write-db-exception` and lists the model's formula
|
|
71
|
+
fields; the fix is to aggregate a MAIN-table scalar column instead.
|
|
72
|
+
|
|
65
73
|
## 4. Readback mismatch — the write landed but does not match
|
|
66
74
|
|
|
67
75
|
`*-readback-failed`, `*-readback-mismatch`, `cleanup-absence-readback`,
|
|
@@ -97,6 +97,16 @@ omc call field.publish --env local --args '{"schemaCode":"expense"}'
|
|
|
97
97
|
|
|
98
98
|
- **同一 `<env>` 的写调用必须串行发起**:`write-lock-held` 不只在"并行重放失败请求"时出现,也会在**并行发起两个无关写**时触发(实测:并行两条 `dictionary.save`、并行 `field.update`+`field.publish` 各失败一次)。读可并行,写不要。
|
|
99
99
|
|
|
100
|
+
## 审批提交的真实形状(r18b 2026-10-26 真机,1.1.25)
|
|
101
|
+
|
|
102
|
+
| 参数 | 位置 | 语义 |
|
|
103
|
+
|---|---|---|
|
|
104
|
+
| `agree` | **顶层** | true=通过 / false=驳回;**缺省=true**(驳回后实例仍 PROCESSING,别当成功) |
|
|
105
|
+
| `approval.content` / `relUsers` / `resources` | approval 对象 | 意见 / 下一步审批人 / 附件 |
|
|
106
|
+
| `approval.agree`、`approval.opinion` | — | **静默忽略**(真机:agree:false 仍 APPROVE 且走完流程;opinion 不落库)。OMC 已写前拒绝 |
|
|
107
|
+
|
|
108
|
+
链:`data.save`(draft→workItemId) → `data.submit`(顶层 agree) → 下一级待办。验收看 `sequenceStatus`。
|
|
109
|
+
|
|
100
110
|
## 计算规则(datarule)的取值时机
|
|
101
111
|
|
|
102
112
|
- **字段计算规则(`datarule.create` `dataRuleType:2`)在 REST 路径上不会执行、也不会回填**(r17 2026-10-25 复核,AI-Platform 1.1.25):
|
|
@@ -112,6 +122,13 @@ omc call field.publish --env local --args '{"schemaCode":"expense"}'
|
|
|
112
122
|
**回算可靠性(重要)**:① 目标行**自己 submit** 时镜像规则一定算(最可靠);② 来源行 submit/update/delete 的事件回算**只在目标模型发布后几分钟内可靠**,之后静默停止(无报错,源变了目标不更新)——重新 `field.publish --force` 目标模型恢复。验收:发布后立刻改来源行并读目标字段;长期对账别依赖事件回算。
|
|
113
123
|
- **同模型(含自己的子表)聚合不可用**:`field.publish` 必抛 305003 —— `publishFormula` 把相对码改写成子表父模型(= 本模型),
|
|
114
124
|
`checkCycleOfAggregation:1032` 判成环。与 payload 无关,8.6.26 与 1.1.25 代码相同。OMC 已写前拒绝 `aggregation-self-schema-cycle`。
|
|
125
|
+
- **聚合必须指向来源主表的标量列**(r18/r18b 真机):`schemaCode` 指向**子表 schema** 能发布,但目标模型从此整个不可写
|
|
126
|
+
(写入一律 `40000`,无明细),且子表无父单单号列、匹配恒 0;`dataItemCode` 写 `<子表>.<子列>` 则 publish 回 309004。
|
|
127
|
+
要子表合计:先在来源主表物化一个数值字段,再聚合该标量。写前拒绝:`aggregation-target-is-child-schema` / `aggregation-data-item-not-scalar`。
|
|
128
|
+
- **`40000` 无明细时**先怀疑字段级配置(上面的聚合、公式序列化),用「删/禁一个公式字段再写一次」二分,别从表单/权限查。
|
|
129
|
+
OMC 会转成 `runtime-write-db-exception` 并列出该模型的公式字段。
|
|
130
|
+
- **`LARGE/SMALL` 必须带 k**:`LARGE({来源.列},2)`(缺 k → NumberFormatException → 写入 50000);
|
|
131
|
+
**`UNION` 是文本拼接**,顶层 `resultType` 必须 0/1(写 2 会 50000)。拒绝:`aggregation-large-missing-k` / `aggregation-union-result-type`。
|
|
115
132
|
- **区别:`FORMULA`(计算公式,`propertyType:100`)字段的 EXPRESSION 模式仍只在前端算** —— API 写入不回填。
|
|
116
133
|
|
|
117
134
|
## 规则与业务集成
|