@stalfh233/omc-cli 0.8.5 → 0.8.7
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/coverage/m1-coverage-manifest-v1.json +1 -0
- package/dist/approval-flow.js +49 -4
- package/dist/batch-call.js +21 -4
- package/dist/bench/scenario.js +1 -1
- package/dist/cli-stdout.js +1 -0
- package/dist/cli.js +84 -3
- package/dist/code-rules.js +144 -8
- package/dist/config-store.js +15 -1
- package/dist/coverage.js +2 -1
- package/dist/discovery.js +8 -2
- package/dist/endpoints.js +10 -0
- package/dist/form-layout.js +79 -0
- package/dist/form-support.js +65 -1
- package/dist/goal-routes.js +35 -5
- package/dist/graph.js +38 -3
- package/dist/human-summary.js +38 -2
- package/dist/intent/capabilities/field.js +1 -1
- package/dist/lanes/field-contract.js +4 -0
- package/dist/lanes/field-coverage.js +1 -0
- package/dist/lanes/field.js +20 -2
- package/dist/lanes/form-contract.js +1 -1
- package/dist/lanes/form.js +25 -3
- package/dist/lanes/list-view.js +21 -11
- package/dist/lanes/model-contract.js +2 -2
- package/dist/lanes/model-references.js +172 -0
- package/dist/lanes/model.js +226 -129
- package/dist/lanes/runtime-data-contract.js +3 -3
- package/dist/lanes/runtime-data.js +64 -8
- package/dist/lanes/workflow.js +91 -1
- package/dist/model-purge.js +1 -1
- package/dist/model-scaffold.js +6 -3
- package/dist/recipes/form.js +33 -6
- package/dist/recipes/runtime-data.js +1 -1
- package/dist/reserved.js +28 -0
- package/dist/residue.js +1 -1
- package/dist/tool-types.js +1 -0
- package/dist/version-family-gaps.js +33 -6
- package/dist/write.js +46 -8
- package/package.json +3 -3
- package/skills/omc-business-configuration.md +7 -0
- package/skills/omc-capabilities.md +1 -1
- package/skills/omc-playbook.md +5 -0
- package/skills/omc-refusals.md +4 -2
- package/skills/omc-start-here.md +1 -1
- package/skills/omc-tool-selection.md +2 -0
- package/skills/omc-write-hazards.md +3 -0
package/dist/lanes/model.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { ENDPOINTS } from "../endpoints.js";
|
|
3
|
-
import { assertFieldFamilyAllowed, assertSelectionChoicesAllowed, choicesArg, fieldOptionsArg, nameI18nJson, propertyTypeArg,
|
|
3
|
+
import { assertFieldFamilyAllowed, assertSelectionChoicesAllowed, choicesArg, fieldOptionsArg, nameI18nJson, propertyTypeArg, relativeCodeArg, SYSTEM_FIELD_CODES, subFieldArg, } from "../field-families.js";
|
|
4
4
|
import { modelSchemaCodes, lintFieldCreateWrite } from "./field.js";
|
|
5
5
|
import { fieldChangeWireBody, prepareFieldChange, sameFieldChange } from "../field-change.js";
|
|
6
6
|
import { executeFormDraftWrite, executeFormPublishWrite } from "../form-support.js";
|
|
7
7
|
import { mapBounded } from "../support.js";
|
|
8
|
-
import { validateBusinessCode } from "../code-rules.js";
|
|
8
|
+
import { validateBusinessCode, validateFieldEntryCodes } from "../code-rules.js";
|
|
9
9
|
import { writeSummary } from "../human-summary.js";
|
|
10
10
|
import { capabilityArg, environmentArg } from "../args.js";
|
|
11
11
|
import { governedRead, withoutReadbackCache } from "../read.js";
|
|
@@ -18,6 +18,7 @@ import { defineTool, ToolInputError, ToolRefusalError } from "../tool-types.js";
|
|
|
18
18
|
import { wireCall, wireRows, WireError } from "../wire.js";
|
|
19
19
|
import { assertTreeSelectionOptions } from "../field-tree-options.js";
|
|
20
20
|
import { readModelRecord } from "../model-record.js";
|
|
21
|
+
import { inboundModelReferences, inboundReferenceRefusal } from "./model-references.js";
|
|
21
22
|
import { MODEL_CREATE_BODY_DEFAULTS, MODEL_LANE_CONTRACT } from "./model-contract.js";
|
|
22
23
|
import { flattenFolders } from "./folder.js";
|
|
23
24
|
const MODEL_LANE = MODEL_LANE_CONTRACT.lane;
|
|
@@ -788,6 +789,94 @@ export function registerModelLane(tools) {
|
|
|
788
789
|
summary: `即将创建模型 ${args.name ?? args.code}(${args.code})${args.modelType === "TREE" ? ",树型" : ",列表型"}${applicationCode ? `(应用 ${applicationCode})` : ""}`,
|
|
789
790
|
};
|
|
790
791
|
}
|
|
792
|
+
/** Default total wait for the platform's async delete task (== 8.6.26 physically_delete). */
|
|
793
|
+
const DELETE_TASK_DEFAULT_BUDGET_MS = 60_000;
|
|
794
|
+
/** Test/ops override for how long model.delete waits on the delete-history task. */
|
|
795
|
+
function deleteTaskBudgetMs() {
|
|
796
|
+
const raw = Number(process.env["OMC_MODEL_DELETE_TASK_BUDGET_MS"] ?? DELETE_TASK_DEFAULT_BUDGET_MS);
|
|
797
|
+
return Number.isFinite(raw) && raw >= 0 ? raw : DELETE_TASK_DEFAULT_BUDGET_MS;
|
|
798
|
+
}
|
|
799
|
+
/**
|
|
800
|
+
* Read the platform task behind physically_delete.
|
|
801
|
+
*
|
|
802
|
+
* `getDeleteHistory` (8.6.26 AppPackageController.java:1460-1476 /
|
|
803
|
+
* 2.1.5 :1369-1378) returns AppDeleteHistoryModel; the async worker writes
|
|
804
|
+
* TaskStatus.END on success and TaskStatus.FAIL + message on the caught
|
|
805
|
+
* exception (AppIntegrationFacadeImpl.java:1343-1355). That message is the only
|
|
806
|
+
* place the real refusal reason exists — the sync face always answers errcode 0.
|
|
807
|
+
*/
|
|
808
|
+
async function readDeleteTaskSnapshot(session, taskId) {
|
|
809
|
+
const data = (await wireCall(session, { path: ENDPOINTS.appPackageDeleteHistory, query: { taskId } })).data;
|
|
810
|
+
const record = data !== null && typeof data === "object" ? data : {};
|
|
811
|
+
const raw = typeof record.taskStatus === "string" ? record.taskStatus : "";
|
|
812
|
+
const taskStatus = raw === "END" || raw === "FAIL" ? raw : "RUN";
|
|
813
|
+
const message = typeof record.message === "string" && record.message.length > 0 ? record.message : undefined;
|
|
814
|
+
return { taskStatus, ...(message !== undefined ? { message } : {}) };
|
|
815
|
+
}
|
|
816
|
+
/**
|
|
817
|
+
* Bounded wait: poll the delete task (when the platform returned a taskId) AND
|
|
818
|
+
* the authoritative model record. Never unbounded — an endlessly RUN task (the
|
|
819
|
+
* child-table self-reference bug) now ends as `deleteTask.taskStatus:"RUN"` after
|
|
820
|
+
* the budget instead of an endless "级联中".
|
|
821
|
+
*/
|
|
822
|
+
async function waitForModelDelete(session, options) {
|
|
823
|
+
const budgetMs = options.budgetMs ?? deleteTaskBudgetMs();
|
|
824
|
+
const startedAt = Date.now();
|
|
825
|
+
let absent = false;
|
|
826
|
+
let task;
|
|
827
|
+
let delay = 1000;
|
|
828
|
+
let polls = 0;
|
|
829
|
+
let historyBroken = false;
|
|
830
|
+
for (;;) {
|
|
831
|
+
polls += 1;
|
|
832
|
+
if (!absent)
|
|
833
|
+
absent = await options.readAbsent();
|
|
834
|
+
let terminal = false;
|
|
835
|
+
let historyUnavailable = false;
|
|
836
|
+
if (options.taskId !== undefined && !historyBroken) {
|
|
837
|
+
try {
|
|
838
|
+
const snapshot = await readDeleteTaskSnapshot(session, options.taskId);
|
|
839
|
+
terminal = snapshot.taskStatus === "END" || snapshot.taskStatus === "FAIL";
|
|
840
|
+
task = {
|
|
841
|
+
taskId: options.taskId,
|
|
842
|
+
taskStatus: snapshot.taskStatus,
|
|
843
|
+
...(snapshot.message !== undefined ? { message: snapshot.message } : {}),
|
|
844
|
+
waitedMs: Date.now() - startedAt,
|
|
845
|
+
polls,
|
|
846
|
+
budgetMs,
|
|
847
|
+
};
|
|
848
|
+
}
|
|
849
|
+
catch (error) {
|
|
850
|
+
// The history face is an addition; a build without it must not turn a
|
|
851
|
+
// delete into an error — fall back to the record face (still bounded).
|
|
852
|
+
historyUnavailable = true;
|
|
853
|
+
historyBroken = true;
|
|
854
|
+
task = {
|
|
855
|
+
taskId: options.taskId,
|
|
856
|
+
taskStatus: "RUN",
|
|
857
|
+
waitedMs: Date.now() - startedAt,
|
|
858
|
+
polls,
|
|
859
|
+
budgetMs,
|
|
860
|
+
historyUnavailable: true,
|
|
861
|
+
historyError: error instanceof Error ? error.message : String(error),
|
|
862
|
+
};
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
if (terminal)
|
|
866
|
+
break;
|
|
867
|
+
if (absent && (options.taskId === undefined || historyUnavailable || historyBroken))
|
|
868
|
+
break;
|
|
869
|
+
const elapsed = Date.now() - startedAt;
|
|
870
|
+
if (elapsed >= budgetMs) {
|
|
871
|
+
if (task !== undefined && task.historyUnavailable !== true)
|
|
872
|
+
task.budgetExhausted = true;
|
|
873
|
+
break;
|
|
874
|
+
}
|
|
875
|
+
await new Promise((resolve) => setTimeout(resolve, Math.max(1, Math.min(delay, budgetMs - elapsed))));
|
|
876
|
+
delay = Math.min(delay * 2, 4000);
|
|
877
|
+
}
|
|
878
|
+
return { absent, ...(task !== undefined ? { task } : {}) };
|
|
879
|
+
}
|
|
791
880
|
/** model.delete writeTool extra arg: a session-aware dry-run that scans inbound references (no write). */
|
|
792
881
|
async function modelDeleteDryRun(session, args) {
|
|
793
882
|
const record = await (async () => {
|
|
@@ -803,42 +892,34 @@ export function registerModelLane(tools) {
|
|
|
803
892
|
if (record === null)
|
|
804
893
|
return { wouldChange: false, absent: true, mayBeReferenced: false, reason: "model-already-absent" };
|
|
805
894
|
const resolved = await resolveModelTreeNode(session, args.schemaCode, args.applicationCode);
|
|
806
|
-
const
|
|
807
|
-
|
|
808
|
-
|
|
895
|
+
const references = await inboundModelReferences(session, [args.schemaCode], resolved.treeRows);
|
|
896
|
+
// Legacy dry-run shape: one row per referencing model with flat field codes
|
|
897
|
+
// (pinned by r3); the richer per-reference rows ride along as inboundReferences.
|
|
809
898
|
const referencing = [];
|
|
810
|
-
for (const
|
|
811
|
-
const
|
|
812
|
-
for (const
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
if (typeof code === "string" && !fields.includes(code))
|
|
818
|
-
fields.push(code);
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
|
-
if (fields.length > 0)
|
|
822
|
-
referencing.push({ schemaCode: sibling.schemaCode, fields });
|
|
899
|
+
for (const reference of references) {
|
|
900
|
+
const row = referencing.find((entry) => entry.schemaCode === reference.schemaCode) ?? { schemaCode: reference.schemaCode, fields: [] };
|
|
901
|
+
for (const field of reference.fields)
|
|
902
|
+
if (!row.fields.includes(field.code))
|
|
903
|
+
row.fields.push(field.code);
|
|
904
|
+
if (!referencing.includes(row))
|
|
905
|
+
referencing.push(row);
|
|
823
906
|
}
|
|
824
907
|
const nodeResolved = resolved.node !== undefined;
|
|
825
908
|
return {
|
|
826
909
|
// The dry-run now performs the same inbound-reference scan the executor
|
|
827
910
|
// does, so "wouldChange:true" is never contradicted by a later refusal
|
|
828
911
|
// (dogfood R3). `mayBeReferenced` is the honest preview.
|
|
829
|
-
wouldChange: !nodeResolved ||
|
|
830
|
-
mayBeReferenced:
|
|
912
|
+
wouldChange: !nodeResolved || references.length === 0,
|
|
913
|
+
mayBeReferenced: references.length > 0,
|
|
914
|
+
...(references.length > 0 ? inboundReferenceRefusal(args.schemaCode, references) : {}),
|
|
831
915
|
referencingModels: referencing,
|
|
916
|
+
inboundReferences: references,
|
|
832
917
|
treeNodeResolved: nodeResolved,
|
|
833
918
|
applicationCode: resolved.applicationCode,
|
|
834
919
|
// r28g F30:plan 以前只报对外引用,不说本模型内部从属资源会被级联清掉。
|
|
835
920
|
// 计数走轻量读面;失败不挡 dry-run(仍给定性 cascadeNote)。
|
|
836
921
|
cascadeNote: "删除模型会级联清掉其字段/表单/列表视图/字段级数据规则/业务规则(含平台预置触发行)及运行数据;其它模型对本模型的关联字段不会自动拆——见 mayBeReferenced/referencingModels。预置规则在幻影 schema 上 list 会重灌,故删前勿对已删 schemaCode 再 rule.list。",
|
|
837
|
-
...(
|
|
838
|
-
? { blocker: "model-referenced-by", nextAction: "先删引用方模型或先删其关联字段,再删本模型(依赖倒序)" }
|
|
839
|
-
: !nodeResolved
|
|
840
|
-
? { blocker: "model-application-unresolved", nextAction: "显式传 applicationCode 或先 discover_environment 确认归属应用" }
|
|
841
|
-
: {}),
|
|
922
|
+
...(references.length > 0 ? {} : nodeResolved ? {} : { blocker: "model-application-unresolved", nextAction: "显式传 applicationCode 或先 discover_environment 确认归属应用" }),
|
|
842
923
|
};
|
|
843
924
|
}
|
|
844
925
|
writeTool({
|
|
@@ -913,7 +994,7 @@ export function registerModelLane(tools) {
|
|
|
913
994
|
message: `${args.schemaCode} 的业务模型记录仍在(bizmodels/get_all 持续返回),但应用树里没有它的节点(AppFunction)。` +
|
|
914
995
|
`**这是平台侧的不可删状态**:physically_delete 用 AppFunction id 定位,而平台 removeBizModel 找不到 AppFunction 行时抛 APP_FUNCTION_MODEL_NOTEXIST——本工具不猜测 id(传业务记录 id 只会得到 601003 业务模型不存在),因此无法通过 physically_delete 删除。` +
|
|
915
996
|
`已连续复查 4 次、间隔约 1s,记录仍在,因此不是读缓存滞后。` +
|
|
916
|
-
|
|
997
|
+
`已知成因:删除级联被中断(级联是平台异步任务、时长不定,中途失败会留下「记录在、节点没了」的残骸)。` +
|
|
917
998
|
`可行出路(按代价排序):① 用平台「回收站 → 物理删除」清理该残留(apppackage/physically_deleteAll 同一路径);` +
|
|
918
999
|
`② 换一个未占用的 schema code 继续(r11/r12 探针均采用此法);` +
|
|
919
1000
|
`③ 若你有平台数据库权限,删除 h_biz_schema/h_biz_property/h_biz_sheet 对应行并重启 launcher 清缓存——但这是维护者操作,不在工具权限内。` +
|
|
@@ -922,39 +1003,19 @@ export function registerModelLane(tools) {
|
|
|
922
1003
|
}
|
|
923
1004
|
const targetId = node.id;
|
|
924
1005
|
const treeRowList = resolved.treeRows.length > 0 ? resolved.treeRows : await treeRows();
|
|
925
|
-
// Ticket 23
|
|
926
|
-
//
|
|
927
|
-
//
|
|
928
|
-
//
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
const
|
|
933
|
-
|
|
934
|
-
const referencedFields = [];
|
|
935
|
-
for (const isPublish of ["false", "true"]) {
|
|
936
|
-
const listed = await wireCall(session, { path: ENDPOINTS.fieldList, query: { schemaCode: sibling.schemaCode, isPublish } });
|
|
937
|
-
for (const row of wireRows(listed.data)) {
|
|
938
|
-
if (relationTargetOf(row) !== args.schemaCode)
|
|
939
|
-
continue;
|
|
940
|
-
const code = row.code ?? row.propertyCode;
|
|
941
|
-
if (typeof code === "string" && !referencedFields.some((field) => field.code === code)) {
|
|
942
|
-
referencedFields.push({ code, type: row.type ?? row.propertyType });
|
|
943
|
-
}
|
|
944
|
-
}
|
|
945
|
-
}
|
|
946
|
-
if (referencedFields.length > 0)
|
|
947
|
-
referencingModels.push({ schemaCode: sibling.schemaCode, name: sibling.name, fields: referencedFields });
|
|
948
|
-
}
|
|
949
|
-
if (referencingModels.length > 0) {
|
|
1006
|
+
// Ticket 23 + 0.8.7 P0: the platform's inbound-reference gate is
|
|
1007
|
+
// getAllAppFunctionsByRelativedCodeNeedFilterDeleted (WORK_SHEET only,
|
|
1008
|
+
// direct self-relation excluded, child-table columns resolved back to
|
|
1009
|
+
// their PARENT model). That resolution is why a parent whose own
|
|
1010
|
+
// child-table column points at itself (a) is not filtered out and
|
|
1011
|
+
// (b) makes the async delete thread recurse forever (task stays RUN).
|
|
1012
|
+
// Refuse before any write with the exact unlink commands.
|
|
1013
|
+
const inboundReferences = await inboundModelReferences(session, [args.schemaCode], treeRowList);
|
|
1014
|
+
if (inboundReferences.length > 0) {
|
|
950
1015
|
throw new ToolRefusalError({
|
|
951
1016
|
status: "refused",
|
|
952
|
-
blocker: "model-referenced-by",
|
|
953
1017
|
schemaCode: args.schemaCode,
|
|
954
|
-
|
|
955
|
-
deletionOrder: [...referencingModels.map((model) => model.schemaCode), args.schemaCode],
|
|
956
|
-
nextCommand: `omc call model.delete --args '${JSON.stringify({ schemaCode: referencingModels[0].schemaCode })}'`,
|
|
957
|
-
message: `${args.schemaCode} 被模型 ${referencingModels.map((model) => model.schemaCode).join("、")} 的关联字段引用,不能删除(服务端 deleteFunctions 的异步拒绝已提前到调用时)。依赖倒序清理:先删引用方模型(或先删其关联字段),再删被引用模型;引用方物理删除的逐列异步级联需 40-60s,完成后再删本模型。`,
|
|
1018
|
+
...inboundReferenceRefusal(args.schemaCode, inboundReferences),
|
|
958
1019
|
});
|
|
959
1020
|
}
|
|
960
1021
|
// Model deletion CASCADES the workflow template away but leaves
|
|
@@ -968,31 +1029,43 @@ export function registerModelLane(tools) {
|
|
|
968
1029
|
method: "POST",
|
|
969
1030
|
body: [{ id: targetId, code: args.schemaCode, type: "BizModel" }],
|
|
970
1031
|
});
|
|
971
|
-
//
|
|
972
|
-
//
|
|
973
|
-
//
|
|
974
|
-
//
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
1032
|
+
// F7(0.8.6):physically_delete 返回的是 AppDeleteHistoryModel,含平台
|
|
1033
|
+
// 后台任务的 taskId(AppDeleteHistoryModel.java:28),此前被丢弃。平台
|
|
1034
|
+
// 没有 taskId 查询端点(不新增工具),但把它留在回执里可供人工/维护者
|
|
1035
|
+
// 对账删除历史;判定仍以记录面 absent + 应用树为准。
|
|
1036
|
+
const deleteHistory = (performed.data ?? {});
|
|
1037
|
+
const taskId = typeof deleteHistory.taskId === "string" && deleteHistory.taskId.length > 0 ? deleteHistory.taskId : undefined;
|
|
1038
|
+
// Both the model record and the app-tree node are eventually consistent.
|
|
1039
|
+
// The platform answers as soon as the async task is queued; the cascade
|
|
1040
|
+
// duration is NOT bounded (measured >4min on a live probe). Poll the
|
|
1041
|
+
// authoritative record face AND the platform delete-history task (which
|
|
1042
|
+
// carries the real FAIL reason) within one bounded budget.
|
|
1043
|
+
const wait = await waitForModelDelete(session, {
|
|
1044
|
+
...(taskId !== undefined ? { taskId } : {}),
|
|
1045
|
+
readAbsent: async () => (await readRecord()) === null,
|
|
1046
|
+
});
|
|
1047
|
+
const absent = wait.absent;
|
|
1048
|
+
const deleteTask = wait.task;
|
|
1049
|
+
const taskFailed = deleteTask?.taskStatus === "FAIL";
|
|
982
1050
|
const treeNodePending = (await treeRows()).some((row) => row.type === "BizModel" && row.code === args.schemaCode);
|
|
983
1051
|
// r63(a-F9):absent:true 与 treeNodePending:true 曾并排出现——「记录没了但
|
|
984
1052
|
// 树上还在」是不是没删干净?给一句显式清零判据,别让探针自己猜组合语义。
|
|
985
|
-
const cleanVerdict =
|
|
986
|
-
? "
|
|
987
|
-
: absent && treeNodePending
|
|
988
|
-
? "
|
|
989
|
-
:
|
|
1053
|
+
const cleanVerdict = taskFailed
|
|
1054
|
+
? "未删除:平台删除任务失败(真因见 deleteTask.message;记录面 absent 只说明还没删,不代表成功)"
|
|
1055
|
+
: absent && !treeNodePending
|
|
1056
|
+
? "已删干净(判据:bizmodels 记录 absent=true 且应用树无该 BizModel 节点)"
|
|
1057
|
+
: absent && treeNodePending
|
|
1058
|
+
? "记录已删、树节点残留——级联仍在拆或残留需 model-purge;稍后复核 model.delete(幂等)"
|
|
1059
|
+
: deleteTask?.taskStatus === "RUN"
|
|
1060
|
+
? `尚未删净:平台删除任务仍在运行(taskStatus=RUN,已等 ${Math.round(deleteTask.waitedMs / 1000)}s/预算 ${Math.round(deleteTask.budgetMs / 1000)}s,taskId=${deleteTask.taskId}),稍后重跑 model.delete 复核`
|
|
1061
|
+
: "尚未删净:记录还在(级联进行中),稍后重跑 model.delete 复核";
|
|
990
1062
|
return {
|
|
991
|
-
performed: { errcode: performed.errcode, deletedId: targetId, applicationCode },
|
|
1063
|
+
performed: { errcode: performed.errcode, deletedId: targetId, applicationCode, ...(taskId !== undefined ? { taskId } : {}) },
|
|
992
1064
|
readback: {
|
|
993
1065
|
absent,
|
|
994
1066
|
treeNodePending,
|
|
995
1067
|
cleanVerdict,
|
|
1068
|
+
...(deleteTask !== undefined ? { deleteTask } : {}),
|
|
996
1069
|
...(liveWorkflows.length > 0
|
|
997
1070
|
? {
|
|
998
1071
|
workflowWarning: {
|
|
@@ -1005,12 +1078,23 @@ export function registerModelLane(tools) {
|
|
|
1005
1078
|
},
|
|
1006
1079
|
}
|
|
1007
1080
|
: {}),
|
|
1008
|
-
...(
|
|
1009
|
-
? {
|
|
1010
|
-
|
|
1011
|
-
nextAction: "
|
|
1012
|
-
|
|
1013
|
-
|
|
1081
|
+
...(taskFailed
|
|
1082
|
+
? {
|
|
1083
|
+
blocker: "model-delete-task-failed",
|
|
1084
|
+
nextAction: `平台删除任务失败,模型未删除。真因(平台原文):${deleteTask?.message ?? "平台未返回 message"}。按原文拆掉引用(field.delete → field.publish)或清理残留后重试 model.delete。`,
|
|
1085
|
+
nextCommand: `omc call model.delete --args '${JSON.stringify({ schemaCode: args.schemaCode })}'`,
|
|
1086
|
+
recheckCommand: `omc call model.delete --args '{"schemaCode":"${args.schemaCode}","dryRun":true}'`,
|
|
1087
|
+
}
|
|
1088
|
+
: absent
|
|
1089
|
+
? {}
|
|
1090
|
+
: {
|
|
1091
|
+
nextAction: "wait-and-recheck",
|
|
1092
|
+
nextCommand: `omc call model.list --args '${JSON.stringify({ filter: args.schemaCode })}'`,
|
|
1093
|
+
recheckCommand: `omc residue ${args.schemaCode}`,
|
|
1094
|
+
note: deleteTask?.taskStatus === "RUN"
|
|
1095
|
+
? `平台删除任务仍在运行(taskStatus=RUN,taskId=${deleteTask.taskId}),已等 ${Math.round(deleteTask.waitedMs / 1000)}s(预算 ${Math.round(deleteTask.budgetMs / 1000)}s)——不是失败,也不是已删除。用 GET ${ENDPOINTS.appPackageDeleteHistory}?taskId=${deleteTask.taskId} 复核任务结果,或稍后重跑 model.delete(幂等,already-absent 短路)。`
|
|
1096
|
+
: "平台 physically_delete 是异步任务:建删除历史后立即返回,级联时长不定(8.6.26 实测可超过 4 分钟),absent:false 表示删除尚未完成,不是失败。以记录面 absent=true 且应用树无该节点为准;用 nextCommand/recheckCommand 复核,稍后重跑 model.delete(幂等,already-absent 短路)。若刚删除引用方模型,其级联可能仍在拆除关联列,必须等它完成后再删本模型。",
|
|
1097
|
+
}),
|
|
1014
1098
|
},
|
|
1015
1099
|
};
|
|
1016
1100
|
},
|
|
@@ -1064,44 +1148,33 @@ export function registerModelLane(tools) {
|
|
|
1064
1148
|
});
|
|
1065
1149
|
}
|
|
1066
1150
|
const treeRowList = resolvedTrees;
|
|
1067
|
-
// Per-target inbound-reference precheck (
|
|
1068
|
-
//
|
|
1069
|
-
//
|
|
1151
|
+
// Per-target inbound-reference precheck (platform criterion, shared with
|
|
1152
|
+
// model.delete/dry-run). Siblings INSIDE the batch are being deleted
|
|
1153
|
+
// together and therefore do not block; a model's own child-table column
|
|
1154
|
+
// pointing at itself does (platform recursion → task never ends), so self
|
|
1155
|
+
// references are never ignored.
|
|
1070
1156
|
const batchSet = new Set(targets);
|
|
1071
|
-
const
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
const
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
const hits = hitsByTarget.get(target) ?? [];
|
|
1087
|
-
if (!hits.some((field) => field.code === code))
|
|
1088
|
-
hits.push({ code, type: row.type ?? row.propertyType });
|
|
1089
|
-
hitsByTarget.set(target, hits);
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
1092
|
-
for (const [target, fields] of hitsByTarget) {
|
|
1093
|
-
const blocked = blockedTargets.find((entry) => entry.schemaCode === target) ?? { schemaCode: target, referencingModels: [] };
|
|
1094
|
-
blocked.referencingModels.push({ schemaCode: sibling.schemaCode, name: sibling.name, fields });
|
|
1095
|
-
if (!blockedTargets.includes(blocked))
|
|
1096
|
-
blockedTargets.push(blocked);
|
|
1097
|
-
}
|
|
1098
|
-
}
|
|
1099
|
-
if (blockedTargets.length > 0) {
|
|
1157
|
+
const references = await inboundModelReferences(session, targets, treeRowList, {
|
|
1158
|
+
ignoreReferencing: batchSet,
|
|
1159
|
+
skipReading: new Set(alreadyAbsent),
|
|
1160
|
+
});
|
|
1161
|
+
if (references.length > 0) {
|
|
1162
|
+
const blockedTargets = [...new Set(references.map((reference) => reference.referenced))].map((schemaCode) => {
|
|
1163
|
+
const refusal = inboundReferenceRefusal(schemaCode, references.filter((reference) => reference.referenced === schemaCode));
|
|
1164
|
+
return {
|
|
1165
|
+
schemaCode,
|
|
1166
|
+
referencingModels: refusal.referencingModels,
|
|
1167
|
+
inboundReferences: refusal.inboundReferences,
|
|
1168
|
+
deletionSteps: refusal.deletionSteps,
|
|
1169
|
+
nextCommand: refusal.nextCommand,
|
|
1170
|
+
};
|
|
1171
|
+
});
|
|
1100
1172
|
throw new ToolRefusalError({
|
|
1101
1173
|
status: "refused",
|
|
1102
1174
|
blocker: "model-referenced-by",
|
|
1103
1175
|
blockedTargets,
|
|
1104
|
-
|
|
1176
|
+
inboundReferences: references,
|
|
1177
|
+
message: `批量删除被拒(零副作用):${blockedTargets.map((blocked) => `${blocked.schemaCode} 被模型 ${blocked.referencingModels.map((model) => model.schemaCode).join("、")} 的关联字段引用(含子表列自引用,详见 blockedTargets[].inboundReferences)`).join(";")}。依赖倒序清理:把引用方模型一并纳入 schemaCodes(或先删其关联字段);引用方物理删除是平台异步任务、时长不定,完成后再删被引用模型。子表列指向自身体时平台删除线程会无限递归,必须先删该列再删模型。`,
|
|
1105
1178
|
});
|
|
1106
1179
|
}
|
|
1107
1180
|
return { targets, alreadyAbsent, entries, treeRowList, appsToScan, applicationCode };
|
|
@@ -1133,20 +1206,27 @@ export function registerModelLane(tools) {
|
|
|
1133
1206
|
method: "POST",
|
|
1134
1207
|
body: entries,
|
|
1135
1208
|
});
|
|
1136
|
-
//
|
|
1137
|
-
//
|
|
1138
|
-
|
|
1209
|
+
// F7(0.8.6):批量入口同样丢弃了平台回执里的 taskId(AppDeleteHistoryModel);
|
|
1210
|
+
// 把它留在回执里,判定仍以 perCode.absent 为准。
|
|
1211
|
+
const deleteHistory = (performed.data ?? {});
|
|
1212
|
+
const taskId = typeof deleteHistory.taskId === "string" && deleteHistory.taskId.length > 0 ? deleteHistory.taskId : undefined;
|
|
1213
|
+
// Per-model absence polling + the platform delete-history task (same
|
|
1214
|
+
// task id for the whole batch). Bounded: a FAIL surfaces the platform
|
|
1215
|
+
// message; a still-RUN task is reported as RUN after the budget.
|
|
1139
1216
|
const absentSet = new Set();
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1217
|
+
const wait = await waitForModelDelete(session, {
|
|
1218
|
+
...(taskId !== undefined ? { taskId } : {}),
|
|
1219
|
+
readAbsent: async () => {
|
|
1220
|
+
for (const entry of entries) {
|
|
1221
|
+
if (absentSet.has(entry.code))
|
|
1222
|
+
continue;
|
|
1223
|
+
if ((await readRecord(entry.code)) === null)
|
|
1224
|
+
absentSet.add(entry.code);
|
|
1225
|
+
}
|
|
1226
|
+
return absentSet.size >= entries.length;
|
|
1227
|
+
},
|
|
1228
|
+
});
|
|
1229
|
+
const deleteTask = wait.task;
|
|
1150
1230
|
const afterTree = (await Promise.all([...appsToScan]
|
|
1151
1231
|
.filter((appCode) => appCode)
|
|
1152
1232
|
.map(async (appCode) => flattenTreeRows(wireRows((await wireCall(session, { path: ENDPOINTS.applicationTree, query: { appCode } })).data))))).flat();
|
|
@@ -1158,15 +1238,32 @@ export function registerModelLane(tools) {
|
|
|
1158
1238
|
}
|
|
1159
1239
|
const absent = absentSet.has(code);
|
|
1160
1240
|
const treeNodePending = afterTree.some((row) => row.type === "BizModel" && row.code === code);
|
|
1161
|
-
perCode[code] = absent ? { absent, ...(treeNodePending ? { treeNodePending } : {}) } : { absent, treeNodePending, nextAction: "wait-and-recheck", note: "
|
|
1241
|
+
perCode[code] = absent ? { absent, ...(treeNodePending ? { treeNodePending } : {}) } : { absent, treeNodePending, nextAction: "wait-and-recheck", nextCommand: `omc call model.list --args '${JSON.stringify({ filter: code })}'`, note: "平台物理删除是异步任务,级联时长不定:absent:false 表示该模型的删除尚未完成,不是失败。稍后重跑 model.deleteMany(幂等,already-absent 短路)复核。" };
|
|
1162
1242
|
}
|
|
1163
1243
|
const allAbsent = targets.every((code) => perCode[code]?.absent === true);
|
|
1244
|
+
const pendingCodes = targets.filter((code) => perCode[code]?.absent === false);
|
|
1245
|
+
const taskFailed = deleteTask?.taskStatus === "FAIL";
|
|
1164
1246
|
return {
|
|
1165
|
-
performed: { errcode: performed.errcode, deletedIds: entries.map((entry) => entry.id), alreadyAbsent, requested: targets, applicationCode },
|
|
1247
|
+
performed: { errcode: performed.errcode, deletedIds: entries.map((entry) => entry.id), alreadyAbsent, requested: targets, applicationCode, ...(taskId !== undefined ? { taskId } : {}) },
|
|
1166
1248
|
readback: {
|
|
1167
1249
|
perCode,
|
|
1168
1250
|
allAbsent,
|
|
1169
|
-
...(
|
|
1251
|
+
...(deleteTask !== undefined ? { deleteTask } : {}),
|
|
1252
|
+
...(taskFailed
|
|
1253
|
+
? {
|
|
1254
|
+
blocker: "model-delete-task-failed",
|
|
1255
|
+
nextAction: `平台删除任务失败,本批未删除。真因(平台原文):${deleteTask?.message ?? "平台未返回 message"}。按原文拆掉引用(field.delete → field.publish)后重试 model.deleteMany。`,
|
|
1256
|
+
nextCommand: `omc call model.deleteMany --args '${JSON.stringify({ schemaCodes: pendingCodes.length > 0 ? pendingCodes : targets })}'`,
|
|
1257
|
+
}
|
|
1258
|
+
: allAbsent
|
|
1259
|
+
? {}
|
|
1260
|
+
: {
|
|
1261
|
+
nextAction: "wait-and-recheck",
|
|
1262
|
+
nextCommand: `omc residue ${pendingCodes[0] ?? targets[0]}`,
|
|
1263
|
+
note: deleteTask?.taskStatus === "RUN"
|
|
1264
|
+
? `平台删除任务仍在运行(taskStatus=RUN,taskId=${deleteTask.taskId}),已等 ${Math.round(deleteTask.waitedMs / 1000)}s(预算 ${Math.round(deleteTask.budgetMs / 1000)}s);用 GET ${ENDPOINTS.appPackageDeleteHistory}?taskId=${deleteTask.taskId} 复核,或稍后重跑(幂等)。`
|
|
1265
|
+
: "部分模型仍在异步级联中;按 perCode 逐项查看,稍后重跑(幂等)。",
|
|
1266
|
+
}),
|
|
1170
1267
|
},
|
|
1171
1268
|
};
|
|
1172
1269
|
},
|
|
@@ -1470,7 +1567,7 @@ export function registerModelLane(tools) {
|
|
|
1470
1567
|
const entries = fieldEntriesOf(args);
|
|
1471
1568
|
const violations = [
|
|
1472
1569
|
...validateBusinessCode(args.code, { kind: "model" }),
|
|
1473
|
-
...entries.flatMap((entry) =>
|
|
1570
|
+
...entries.flatMap((entry) => validateFieldEntryCodes(entry)),
|
|
1474
1571
|
];
|
|
1475
1572
|
if (violations.length > 0)
|
|
1476
1573
|
throw new ToolRefusalError({ status: "refused", blocker: "business-code-invalid", message: "code 未过出门前校验;按 validation 修正(长度/风格/保留字)", validation: violations });
|
|
@@ -5,7 +5,7 @@ export { RUNTIME_DATA_WIRE, RUNTIME_QUERY_OPERATORS, ENGINE_OWNED_KEYS, SUBMIT_S
|
|
|
5
5
|
import { RUNTIME_DATA_WIRE } from "omc-core/wire-facts";
|
|
6
6
|
export function dataListDescription() {
|
|
7
7
|
const wire = RUNTIME_DATA_WIRE;
|
|
8
|
-
return `按简化过滤 DSL 查询业务对象(runtime/query/list);DSL 在 CLI 内翻译为平台 queryCondition(${wire.dslShape}),并按发布字段元数据为每个条件注入 propertyType(未知过滤字段将被拒绝,可用 rawCondition 逃生);响应行在 items[],业务字段在 items[].fields.<code>(不是 rows[],也不是 item 顶层——--jq 常用 items[].fields.sku);空模型返回空列表;未配列的自定义字段投影为 null——这是显示面缺列配置、不是数据缺失(data.load 有值),显式选列在结果中全为 null 而发布字段元数据显示其存在时,readback 追加 projectionHint(先用 listview.configure 配置该模型的默认视图列,或用 data.load
|
|
8
|
+
return `按简化过滤 DSL 查询业务对象(runtime/query/list);DSL 在 CLI 内翻译为平台 queryCondition(${wire.dslShape}),并按发布字段元数据为每个条件注入 propertyType(未知过滤字段将被拒绝,可用 rawCondition 逃生);响应行在 items[],业务字段在 items[].fields.<code>(不是 rows[],也不是 item 顶层——--jq 常用 items[].fields.sku);空模型返回空列表;未配列的自定义字段投影为 null——这是显示面缺列配置、不是数据缺失(data.load 有值),显式选列在结果中全为 null 而发布字段元数据显示其存在时,readback 追加 projectionHint(先用 listview.configure 配置该模型的默认视图列,或用 data.load 读单条权威值)。键缺席=字段不存在;键在值 null=未投影或真空值(见 projectionHint.unprojected);逐行未投影看 items[].unprojected(nullSemantics 说明两者都不是「字段不存在」)。`;
|
|
9
9
|
}
|
|
10
10
|
export function dataAggregateDescription() {
|
|
11
11
|
return `临时计数与数值聚合(纯读)。count:runtime/query/list size:1 读 totalElements(服务端精确、不受 cap 影响;带 filter +1 field.list)。sum/avg/min/max:field 必填且已发布 propertyType=2(NUMERICAL);无 GET_LIST 改源时优先 /sum ALL_DATA(coverage.mode=server-aggregate,全量精确),否则/失败/键不符回退本地折叠(strategyFallback;size:200 翻页至 cap 1000,null 不进聚合、avg=sum/非 null 行数,nonNullCount=0→value:null)。complete 看 rowsScanned>=total,否则 missingCount+capNotice,绝不外推。groupBy 单列:count 值域可枚举(options/字典)→值域×count(V+3 wire),分桶并发窗口 4(限流退化 2,见 wire.concurrency),桶序稳定;按 count 降序取 topN(默认 10/上限 20),截断给 truncatedBuckets/bucketsTruncatedCount,null 单列 nullBucket;不可枚举或数值指标→本地扫描(coverage.mode=paged-local-scan/local-scan),数值桶 {key,count,nonNullCount,value} 按 value 降序、并列按 key,null 行进 nullBucket。filter.draftPolicy:count+groupBy 默认 includeDrafts:false 注入 sequenceStatus≠DRAFT;数值指标不默认排除;count 省略=平台默认(无条件含草稿、带条件排草稿);显式 false 强制排除。边界:临时问句用本工具;持久图表/看板用 report.chartdata,视图汇总列用 sumType,写时计算用 datarule type2。子表计数/求和用 child(主表 schemaCode + childSchemaCode/bizObjectId)。`;
|
|
@@ -41,7 +41,7 @@ export function dataSubmitDescription() {
|
|
|
41
41
|
const wire = RUNTIME_DATA_WIRE;
|
|
42
42
|
return describeTool(`M2 runtime data SUBMIT (runtime/form/submit, WorkItemSubmitVO).`, [
|
|
43
43
|
"Distinct from data.save: data.save persists as DRAFT; data.submit advances the record to COMPLETED (no workflow) or drives the workflow instance.",
|
|
44
|
-
"
|
|
44
|
+
"**省略 `formData` 的两条合法面**:审批提交(带 workItemId)平台使用已存业务数据;**已有草稿直提(带 bizObjectId、无 workItemId)也合法**——载荷按 data.load 读回行合并(省略 ≡ 传 {},平台 mergeObject 覆盖;给了则覆盖读回值)。只有**新建**(无 bizObjectId、无 workItemId)必须给 formData。审批提交不要携带子表数组。",
|
|
45
45
|
`就地语义:${wire.submitInPlace};无流程 readback 必须确认 objectId 与传入 bizObjectId 相同;无 bizObjectId 的 workflowCode 新建单 → PROCESSING + workflowInstanceId,无流程 → 该行 COMPLETED。`,
|
|
46
46
|
`既有草稿发起流程的唯一支持形状是两段式:先 data.save 带 workflowCode 暂存(saveWorkflow→startWorkflow(finishStart=FALSE);getReplayToken 门、sequenceStatus 与返回形状见 data.save 的 workflowCode 段),再以返回的 workItemId 提交(带流程模型提交**必须**带 bizObjectId+workflowInstanceId+workItemId 三元——只带 bizObjectId 会答「流程实例无待办」、只缺 workItemId 会 50000;完整形状见 omc describe data.submit --example workflow-backed-data-submit,待办查询用 workitem.list)。`,
|
|
47
47
|
`仅无 workflowCode/workItemId/workflowInstanceId 且无 bizObjectId 时保留 save→submit 便捷链(新建记录);只要存在 workItemId 或 workflowInstanceId 就 fail-closed 拒绝(blocker submit-biz-object-id-required),零 runtime/form/submit wire。`,
|
|
@@ -154,7 +154,7 @@ function desc(lead) {
|
|
|
154
154
|
}
|
|
155
155
|
export function assertRuntimeDataContract() {
|
|
156
156
|
assertLaneContract(RUNTIME_DATA_LANE_CONTRACT);
|
|
157
|
-
assertDescriptionCarries(RUNTIME_DATA_LANE_CONTRACT, "data.list", ["queryCondition", "propertyType", "rawCondition", "projectionHint", "listview.configure", "data.load", "items[].fields"]);
|
|
157
|
+
assertDescriptionCarries(RUNTIME_DATA_LANE_CONTRACT, "data.list", ["queryCondition", "propertyType", "rawCondition", "projectionHint", "listview.configure", "data.load", "items[].fields", "items[].unprojected", "nullSemantics", "键缺席", "未投影或真空值"]);
|
|
158
158
|
assertDescriptionCarries(RUNTIME_DATA_LANE_CONTRACT, "data.aggregate", ["totalElements", "groupBy", "local-scan", "cap 1000", "draftPolicy", "report.chartdata", "sum", "avg", "NUMERICAL", "nonNullCount"]);
|
|
159
159
|
assertDescriptionCarries(RUNTIME_DATA_LANE_CONTRACT, "data.save", ["bizObjectId", "sheetCode", "bizsheet/get", "workflowCode", "sequenceStatus", "workItem", "propertyType 9", "50000", "mappings", "rowStatus", "DRAFT", "submit:true", "CHILD_TABLE"]);
|
|
160
160
|
assertDescriptionCarries(RUNTIME_DATA_LANE_CONTRACT, "data.update", ["runtime/form/save", "bizObjectId", "COMPLETED", "304001", "form/load", "rowStatus", "child-rows-upsert"]);
|