@stalfh233/omc-cli 0.8.14 → 0.8.16
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/artifacts.js +3 -2
- package/dist/cli-output.js +19 -0
- package/dist/cli.js +70 -24
- package/dist/form-support.js +160 -12
- package/dist/human-summary.js +14 -2
- package/dist/intent/cli.js +35 -2
- package/dist/intent/plan-apply.js +19 -5
- package/dist/intent/plan-file.js +38 -0
- package/dist/lanes/environment.js +43 -3
- package/dist/lanes/field-contract.js +1 -1
- package/dist/lanes/field.js +17 -2
- package/dist/lanes/form.js +1 -1
- package/dist/lanes/list-view-contract.js +1 -1
- package/dist/lanes/list-view.js +51 -0
- package/dist/lanes/model-references.js +48 -1
- package/dist/lanes/runtime-data-contract.js +2 -2
- package/dist/lanes/runtime-data.js +222 -43
- package/dist/lanes/workflow.js +176 -16
- package/dist/model-purge.js +90 -46
- package/dist/mojibake.js +69 -0
- package/dist/read-shapes.js +2 -1
- package/dist/recipes/form.js +2 -2
- package/dist/recipes/runtime-data.js +4 -4
- package/dist/residue.js +13 -2
- package/dist/stdout-pipe.js +78 -0
- package/dist/tool-types.js +29 -0
- package/dist/wire-refusal.js +171 -0
- package/dist/write.js +69 -168
- package/package.json +3 -3
- package/skills/omc-capabilities.md +1 -1
- package/skills/omc-glossary.md +22 -0
|
@@ -18,7 +18,8 @@ import { scanPages } from "./runtime-paging.js";
|
|
|
18
18
|
import { dataRuleSubmitContext } from "./datarule.js";
|
|
19
19
|
import { decodeJsonColumn, JSON_COLUMN_NULL_COALESCE } from "../json-column.js";
|
|
20
20
|
import { FIELD_PROPERTY_TYPES, SYSTEM_FIELD_CODES, familyName } from "../field-families.js";
|
|
21
|
-
import { applicationResolutionOf, resolveApplicationScope } from "../support.js";
|
|
21
|
+
import { applicationResolutionOf, isUncertainWireError, resolveApplicationScope } from "../support.js";
|
|
22
|
+
import { refusalFromWireError } from "../wire-refusal.js";
|
|
22
23
|
/** r29b F8: keep ids/itemsPreview through governedRead's compact diet. */
|
|
23
24
|
const DATA_LIST_PREVIEW_LIMIT = 20;
|
|
24
25
|
function dataListItemPreview(items) {
|
|
@@ -3451,7 +3452,7 @@ export function registerRuntimeDataLane(tools) {
|
|
|
3451
3452
|
// 券商 issue 1.3(cpdocs 2026-10-27):更新既有记录的主键契约——平台
|
|
3452
3453
|
// BizObjectModel.getId() 只读 bizObject.data.id;顶层 bizObject.bizObjectId
|
|
3453
3454
|
// 被保存逻辑忽略,errcode:0 但 objectId 是新 id(静默新建孤儿行)。
|
|
3454
|
-
'business-object data keyed by field code
|
|
3455
|
+
'business-object data keyed by field code(关联/人员形状同默认描述)。**单选关联 WORK_SHEET 9=id 串或 `{id}`;MULT_WORK_SHEET 11/人员/组织 50/51 才数组;人员/组织元素 `{id,type,name}`,type 必填**。引擎拥有键(sequenceStatus 等)会被剥离——读改写的 sequenceStatus 不会把行钉回旧状态。新建时子表行缺 sortKey 会按数组下标补 1..n(平台读回按 sortKey ASC;更新既有记录请显式带 sortKey)。mappings 仅门户回填;字典-backed 不校验取值(不存在/已停用码也会落库,要拦请配数据规则)。既有记录更新:主键必须放 formData.id(顶层 bizObject.bizObjectId 被平台忽略会静默新建孤儿行——直调 REST 同理,cpdocs issue §1.3);id 无对应行会被拒(save-update-target-absent),新建请省略 id。'),
|
|
3455
3456
|
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。发起语义阶梯:本参数=发起停在第一节点(行/实例双 DRAFT,首办待办=发起人);到第一个审批节点用 data.submit 三件套;无流程模型用 submit:true 一调完成态;代他人发起(可选发起人)唯一路径=业务规则 CREATE+startWorkflow(完成态发起,不留草稿待办)"),
|
|
3456
3457
|
submit: z.boolean().optional().describe("true=保存后立即直提(无流程模型 DRAFT→COMPLETED,触发 Create 规则);与 workflowCode 互斥。**按业务约定正式数据优先直接 data.submit(无 id=新建并提交一调完成)——本参数是便捷别名,save 的定位是草稿/暂存**"),
|
|
3457
3458
|
allowStaffOnSubmit: z.boolean().optional().describe("submit:true 时显式允许携带人员字段(issue#10:人员字段提交面两种形状都可能 50000,可靠链路是 save 落库后提交时省略;个别平台构建接受提交面携带,自担风险)"),
|
|
@@ -3722,6 +3723,14 @@ export function registerRuntimeDataLane(tools) {
|
|
|
3722
3723
|
: {}),
|
|
3723
3724
|
draftRuleHint: ((saveIsUpdate ? workflowUpdateHint : workflowDraftHint) ?? workflowCheckSkippedHint) ?? "草稿态(DRAFT)保存不触发业务规则——DRAFT 行跳过 Create/Update 分发(DomainServiceImpl.java:240-248);要一调完成态本调用加 submit:true(仅 data.save 有此参数;data.submit 不收);已存草稿直提形状:data.submit {schemaCode, bizObjectId: 本读回的 bizObjectId, formData}(submit 自持久化)",
|
|
3724
3725
|
};
|
|
3726
|
+
// w132 复核:submitRefused 存在时 draftRuleHint 自相矛盾(它还教「加
|
|
3727
|
+
// submit:true / data.submit 直提」)。partial 回执统一省略该键——本次已经
|
|
3728
|
+
// 试过提交,下一步只能从 submitRefused 读,不能再教一遍相同动作。
|
|
3729
|
+
const partialReadback = (submitRefused) => {
|
|
3730
|
+
const rest = { ...plainReadback };
|
|
3731
|
+
delete rest.draftRuleHint;
|
|
3732
|
+
return { ...rest, submitRefused };
|
|
3733
|
+
};
|
|
3725
3734
|
// r18 retro (G3): one-call COMPLETED creation — the agent goal is usually
|
|
3726
3735
|
// "record AND rule effect", not "a draft". Chain the no-flow submit in
|
|
3727
3736
|
// the same governed write (the same sibling execute apply_changes uses).
|
|
@@ -3731,31 +3740,102 @@ export function registerRuntimeDataLane(tools) {
|
|
|
3731
3740
|
// COMPLETED) — the one-call chain's ruleHint would lie. Workflow-
|
|
3732
3741
|
// backed models keep the two-phase chain.
|
|
3733
3742
|
if (publishedWorkflow) {
|
|
3743
|
+
// P1(w132 探针 J):草稿已落库、提交被确定拒收——这是 partial,不是
|
|
3744
|
+
// ok/DELIVERED。旧回执把 submitRefused 埋在 readback 里,顶层仍盖
|
|
3745
|
+
// DELIVERED,调用方只看 status 会以为已提交。保留原 blocker 名(
|
|
3746
|
+
// submit-model-has-workflow)在 submitRefused 里,顶层用自己的
|
|
3747
|
+
// blocker 说明「首段成功、复合目标未完成」。
|
|
3748
|
+
const submitRefused = {
|
|
3749
|
+
blocker: "submit-model-has-workflow",
|
|
3750
|
+
workflowCode: publishedWorkflow,
|
|
3751
|
+
// 更新行不能复用新建语义(「没有流程实例 / 重建草稿 / formData 不要带 id」
|
|
3752
|
+
// 都会让调用方多建一行);按 saveIsUpdate 分路。
|
|
3753
|
+
message: `草稿已保存(bizObjectId=${bizObjectId});${saveIsUpdate ? workflowUpdateHint : workflowDraftHint}(见 describe data.submit --example workflow-backed-data-submit)`,
|
|
3754
|
+
};
|
|
3755
|
+
const nextCommand = saveIsUpdate
|
|
3756
|
+
? `omc call workitem.list --args '{"schemaCode":"${args.schemaCode}"}'`
|
|
3757
|
+
: `omc call data.save --env <env> --args '{"schemaCode":"${args.schemaCode}","workflowCode":"${publishedWorkflow}","formData":{...}}'`;
|
|
3734
3758
|
return {
|
|
3759
|
+
status: "partial",
|
|
3760
|
+
blocker: "submit-refused-after-save",
|
|
3761
|
+
submitRefused,
|
|
3762
|
+
message: `草稿已保存(bizObjectId=${bizObjectId}),提交未完成:模型有已发布流程 ${publishedWorkflow},submit:true 被拒(submit-model-has-workflow)。` +
|
|
3763
|
+
`要提交请走两段式:${saveIsUpdate ? "workitem.list 找现有待办 → data.submit 三件套" : "先用 workflowCode 保存流程草稿取得 workItemId,再 data.submit 三件套"}。`,
|
|
3764
|
+
nextCommand,
|
|
3735
3765
|
performed: { errcode: performed.errcode, bizObjectId, sheetCode, resolvedFrom, submitted: false },
|
|
3736
|
-
readback:
|
|
3737
|
-
...plainReadback,
|
|
3738
|
-
submitRefused: {
|
|
3739
|
-
blocker: "submit-model-has-workflow",
|
|
3740
|
-
workflowCode: publishedWorkflow,
|
|
3741
|
-
// 更新行不能复用新建语义(「没有流程实例 / 重建草稿 / formData 不要带 id」
|
|
3742
|
-
// 都会让调用方多建一行);按 saveIsUpdate 分路。
|
|
3743
|
-
message: `草稿已保存;${saveIsUpdate ? workflowUpdateHint : workflowDraftHint}(见 describe data.submit --example workflow-backed-data-submit)`,
|
|
3744
|
-
},
|
|
3745
|
-
},
|
|
3766
|
+
readback: partialReadback(submitRefused),
|
|
3746
3767
|
};
|
|
3747
3768
|
}
|
|
3748
3769
|
const submitTool = tools.find((entry) => entry.name === "data.submit");
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3770
|
+
// writeExecute 失败是**抛异常**(ToolRefusalError / WireError),不会返回
|
|
3771
|
+
// `{status:...}`——历史返回分支因此不可达,异常会冒到外层 wrote 管线,
|
|
3772
|
+
// 把「草稿已保存」的事实一起丢掉(复核驳回 P1b/P1c)。这里接住异常,
|
|
3773
|
+
// 统一折成 partial + 已落草稿证据;transport/uncertain 也按 partial 报
|
|
3774
|
+
// (submitRefused.outcome:"uncertain"),因为草稿的落库是确定的,只有
|
|
3775
|
+
// 提交结果未知——不回滚、不冒充全部完成。
|
|
3776
|
+
let submitOutcome;
|
|
3777
|
+
try {
|
|
3778
|
+
submitOutcome = submitTool?.writeExecute
|
|
3779
|
+
? (await submitTool.writeExecute(session, { schemaCode: args.schemaCode, bizObjectId, formData: args.formData }))
|
|
3780
|
+
: { status: "error", message: "data.submit 工具不可用" };
|
|
3781
|
+
}
|
|
3782
|
+
catch (error) {
|
|
3783
|
+
// 本地拒绝(ToolRefusalError)永远是确定的拒绝,即便 message 里恰好
|
|
3784
|
+
// 出现 timeout 字样也不能被当成传输不确定。
|
|
3785
|
+
const uncertain = !(error instanceof ToolRefusalError) && isUncertainWireError(error);
|
|
3786
|
+
const failure = error instanceof ToolRefusalError
|
|
3787
|
+
? { ...error.payload }
|
|
3788
|
+
: error instanceof WireError
|
|
3789
|
+
// 复用 governedWrite 的同一张 WireError 翻译表(300004 分叉、
|
|
3790
|
+
// 409200 隐藏字段、40000 双成因、@AdminOnly 等)——不要在这里
|
|
3791
|
+
// 复制一份简化文案,否则 submit-leg 会只剩平台原文。
|
|
3792
|
+
? refusalFromWireError(error)
|
|
3793
|
+
: {
|
|
3794
|
+
status: uncertain ? "uncertain" : "refused",
|
|
3795
|
+
blocker: uncertain ? "submit-outcome-uncertain" : "submit-failed-after-save",
|
|
3796
|
+
message: error instanceof Error ? error.message : String(error),
|
|
3797
|
+
};
|
|
3798
|
+
// uncertain 形态(transport / 401-403)在翻译表里是 refused(那张表
|
|
3799
|
+
// 描述的是「写请求被拒/结果未知」的基线);submit-leg 已知首段草稿
|
|
3800
|
+
// 落库确定、只有提交结果未知——status 与 outcome 必须同时对齐为
|
|
3801
|
+
// uncertain,不能留 status:"refused" 与 outcome 自相矛盾。
|
|
3802
|
+
const submitRefused = uncertain ? { ...failure, status: "uncertain", outcome: "uncertain" } : failure;
|
|
3803
|
+
const refusalMessage = typeof submitRefused.message === "string" && submitRefused.message.length > 0
|
|
3804
|
+
? submitRefused.message
|
|
3805
|
+
: `提交失败(${String(submitRefused.blocker ?? submitRefused.status ?? "?")})`;
|
|
3806
|
+
const transportLabel = error instanceof WireError && error.kind === "http-status"
|
|
3807
|
+
? `服务器返回 HTTP ${error.diagnostic?.httpStatus ?? "异常"} 响应`
|
|
3808
|
+
: "网络传输中断";
|
|
3809
|
+
return {
|
|
3810
|
+
status: "partial",
|
|
3811
|
+
blocker: "submit-refused-after-save",
|
|
3812
|
+
submitRefused,
|
|
3813
|
+
// 自动化只看 status/deliveryState 仍可能把「提交结果未知」读成普通
|
|
3814
|
+
// 拒绝;显式再带一个顶层信号(write.ts 透传)。
|
|
3815
|
+
...(uncertain ? { submitOutcome: "uncertain" } : {}),
|
|
3816
|
+
message: `草稿已保存(bizObjectId=${bizObjectId}),提交未完成:` +
|
|
3817
|
+
(uncertain ? `提交结果未知(${transportLabel})——先 data.load/workitem.list 核对草稿与待办,再决定是否重发` : refusalMessage),
|
|
3818
|
+
nextCommand: typeof submitRefused.nextCommand === "string"
|
|
3819
|
+
? submitRefused.nextCommand
|
|
3820
|
+
: `omc call data.load --env <env> --args '{"schemaCode":"${args.schemaCode}","bizObjectId":"${bizObjectId}"}'`,
|
|
3821
|
+
performed: { errcode: performed.errcode, bizObjectId, sheetCode, resolvedFrom, submitted: false },
|
|
3822
|
+
readback: partialReadback(submitRefused),
|
|
3823
|
+
};
|
|
3824
|
+
}
|
|
3752
3825
|
if ("status" in submitOutcome && typeof submitOutcome.status === "string" && submitOutcome.status !== "ok") {
|
|
3753
|
-
// The save itself
|
|
3754
|
-
//
|
|
3826
|
+
// The save itself landed but the submit did not. This is a partial
|
|
3827
|
+
// composite write — never status ok/DELIVERED (P1, w132 probe J).
|
|
3755
3828
|
const envelope = "envelope" in submitOutcome ? submitOutcome.envelope : submitOutcome;
|
|
3829
|
+
const innerMessage = typeof envelope.message === "string" && envelope.message.length > 0 ? envelope.message : `提交失败(${String(envelope.blocker ?? envelope.status ?? "?")})`;
|
|
3830
|
+
const innerNext = typeof envelope.nextCommand === "string" ? envelope.nextCommand : `omc call data.submit --env <env> --args '{"schemaCode":"${args.schemaCode}","bizObjectId":"${bizObjectId}"}'`;
|
|
3756
3831
|
return {
|
|
3832
|
+
status: "partial",
|
|
3833
|
+
blocker: "submit-refused-after-save",
|
|
3834
|
+
submitRefused: envelope,
|
|
3835
|
+
message: `草稿已保存(bizObjectId=${bizObjectId}),提交未完成:${innerMessage}`,
|
|
3836
|
+
nextCommand: innerNext,
|
|
3757
3837
|
performed: { errcode: performed.errcode, bizObjectId, sheetCode, resolvedFrom, submitted: false },
|
|
3758
|
-
readback:
|
|
3838
|
+
readback: partialReadback(envelope),
|
|
3759
3839
|
};
|
|
3760
3840
|
}
|
|
3761
3841
|
const okOutcome = submitOutcome;
|
|
@@ -3890,7 +3970,11 @@ export function registerRuntimeDataLane(tools) {
|
|
|
3890
3970
|
bizObjectIds: z
|
|
3891
3971
|
.array(z.string().min(1))
|
|
3892
3972
|
.optional()
|
|
3893
|
-
.describe("批量删除多个业务对象 id(单次上限 200;超限写前拒绝并给分块建议):一次工具调用,内部按 id 逐条删并逐条 data.load 读回(deleted[] 逐条给 deleted/absent/noop/skipped
|
|
3973
|
+
.describe("批量删除多个业务对象 id(单次上限 200;超限写前拒绝并给分块建议):一次工具调用,内部按 id 逐条删并逐条 data.load 读回(deleted[] 逐条给 deleted/absent/noop/skipped;删前读不到=target-not-in-schema,默认整批 uncertain)。不按版本拒绝:所有版本都放行;若平台回成功但回读行仍在(1.1.25 已知假成功),回执标 batch-delete-ineffective 并列出 undeletedIds,按 nextCommand 改单条重试。成功判据是 undeletedIds 与 notInSchema 均为空(deletionVerified:true),不是 remainingRows/clean(那只表示整表是否已空)。"),
|
|
3974
|
+
allowAlreadyAbsent: z
|
|
3975
|
+
.boolean()
|
|
3976
|
+
.optional()
|
|
3977
|
+
.describe("默认 false:删前读不到该 id 即回 uncertain + delete-target-not-in-schema(可能 schemaCode 写错/属于别的模型);true 恢复旧幂等 already-absent(清理脚本自担风险)"),
|
|
3894
3978
|
},
|
|
3895
3979
|
dryRunPayload: async (session, args) => {
|
|
3896
3980
|
const ids = args.bizObjectIds && args.bizObjectIds.length > 0 ? args.bizObjectIds : args.bizObjectId ? [args.bizObjectId] : [];
|
|
@@ -3945,16 +4029,37 @@ export function registerRuntimeDataLane(tools) {
|
|
|
3945
4029
|
args.schemaCode +
|
|
3946
4030
|
"\",\"bizObjectId\":\"<items[].id>\"};批量用 bizObjectIds 数组(所有版本都放行,删后逐条回读校验)。",
|
|
3947
4031
|
});
|
|
4032
|
+
// P1(探针 I,0.8.15):删前读不到该 id 不等于「已删干净」。form/load 是
|
|
4033
|
+
// **按 schemaCode 分表**的(BizObjectRepository.loadBizObject 用
|
|
4034
|
+
// ensureBusinessTable(schemaCode) 再反序列化 id;id 属于别的模型时返回
|
|
4035
|
+
// null),所以「读不到」有两种成因:并发已删,或 schemaCode 写错。旧回执
|
|
4036
|
+
// 一律回 status:ok + already-absent,清理者会当成功。默认改为 uncertain;
|
|
4037
|
+
// 只有显式 allowAlreadyAbsent:true(幂等清理脚本)才保留旧语义。
|
|
4038
|
+
const allowAlreadyAbsent = args.allowAlreadyAbsent === true;
|
|
4039
|
+
const precheckTarget = async (bizObjectId) => {
|
|
4040
|
+
try {
|
|
4041
|
+
const before = await loadExistingBizObject(session, args.schemaCode, sheetCode, bizObjectId);
|
|
4042
|
+
return before === null ? { state: "absent" } : { state: "present", before };
|
|
4043
|
+
}
|
|
4044
|
+
catch (error) {
|
|
4045
|
+
// 读面失败不阻断删除(删除本身仍是权威写面):回执标 precheck:"unknown",
|
|
4046
|
+
// 绝不把「没读到」伪造成「不存在」。
|
|
4047
|
+
return { state: "unknown", error: error instanceof Error ? error.message : String(error) };
|
|
4048
|
+
}
|
|
4049
|
+
};
|
|
3948
4050
|
// 批量删除不按版本拦截(版本缺陷用删后回读兜,不做前置黑名单/白名单)。
|
|
3949
4051
|
const deleteOne = async (bizObjectId) => {
|
|
3950
4052
|
// Delete is destructive: probe the authoritative object first so an
|
|
3951
|
-
// absent id is
|
|
3952
|
-
const
|
|
4053
|
+
// absent id is never a blind runtime delete.
|
|
4054
|
+
const pre = await precheckTarget(bizObjectId);
|
|
3953
4055
|
// r31b F12: mirror model.delete — noop/deleted booleans so concurrent
|
|
3954
|
-
// losers are not mistaken for successful deletes
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
4056
|
+
// losers are not mistaken for successful deletes.
|
|
4057
|
+
if (pre.state === "absent") {
|
|
4058
|
+
if (allowAlreadyAbsent)
|
|
4059
|
+
return { bizObjectId, skipped: "already-absent", absent: true, noop: true, deleted: false, alreadyAbsent: true, precheck: "absent" };
|
|
4060
|
+
return { bizObjectId, skipped: "target-not-in-schema", absent: true, noop: true, deleted: false, alreadyAbsent: true, notInSchema: true, precheck: "absent" };
|
|
4061
|
+
}
|
|
4062
|
+
const precheckTags = pre.state === "unknown" ? { precheck: "unknown", precheckError: pre.error } : { precheck: "present" };
|
|
3958
4063
|
let performed;
|
|
3959
4064
|
try {
|
|
3960
4065
|
performed = await wireCall(session, {
|
|
@@ -3964,11 +4069,14 @@ export function registerRuntimeDataLane(tools) {
|
|
|
3964
4069
|
});
|
|
3965
4070
|
}
|
|
3966
4071
|
catch (error) {
|
|
3967
|
-
// L6: 删除调用本身回 304001
|
|
3968
|
-
//
|
|
3969
|
-
//
|
|
3970
|
-
if (error instanceof WireError && error.kind === "business" && error.errcode === RUNTIME_DATA_WIRE.absenceErrcode)
|
|
3971
|
-
|
|
4072
|
+
// L6: 删除调用本身回 304001(业务对象不存在)。删前读到过 → 真并发
|
|
4073
|
+
// already-absent;删前读失败(unknown)→ 仍无法区分「并发删」与
|
|
4074
|
+
// 「schemaCode 写错」,默认按 uncertain 处理。
|
|
4075
|
+
if (error instanceof WireError && error.kind === "business" && error.errcode === RUNTIME_DATA_WIRE.absenceErrcode) {
|
|
4076
|
+
if (pre.state === "unknown" && !allowAlreadyAbsent)
|
|
4077
|
+
return { bizObjectId, skipped: "target-not-in-schema", absent: true, noop: true, deleted: false, alreadyAbsent: true, notInSchema: true, precheck: "unknown", precheckError: pre.error };
|
|
4078
|
+
return { bizObjectId, skipped: "already-absent", absent: true, noop: true, deleted: false, alreadyAbsent: true, ...precheckTags, ...(pre.state === "present" ? { concurrent: true } : {}) };
|
|
4079
|
+
}
|
|
3972
4080
|
throw error;
|
|
3973
4081
|
}
|
|
3974
4082
|
// The absence readback: a missing object surfaces either as an empty
|
|
@@ -3986,10 +4094,39 @@ export function registerRuntimeDataLane(tools) {
|
|
|
3986
4094
|
else
|
|
3987
4095
|
throw error;
|
|
3988
4096
|
}
|
|
3989
|
-
return { bizObjectId, errcode: performed.errcode, absent, deleted: absent === true, noop: false };
|
|
4097
|
+
return { bizObjectId, errcode: performed.errcode, absent, deleted: absent === true, noop: false, ...precheckTags };
|
|
3990
4098
|
};
|
|
3991
4099
|
if (ids.length === 1) {
|
|
3992
4100
|
const one = await deleteOne(ids[0]);
|
|
4101
|
+
if (one.skipped === "target-not-in-schema") {
|
|
4102
|
+
const id = ids[0];
|
|
4103
|
+
return {
|
|
4104
|
+
status: "uncertain",
|
|
4105
|
+
blocker: "delete-target-not-in-schema",
|
|
4106
|
+
retryable: false,
|
|
4107
|
+
nextCommand: `omc call model.list --args '{"allApplications":true}'`,
|
|
4108
|
+
nextAction: "本工具无法判定该 id 属于哪个模型,也无法判定它是否曾经存在。先 model.list 枚举租户全部模型(默认只扫当前应用,跨应用 owner 会漏),再对候选逐个 `data.list {schemaCode:\"<候选>\",all:true}` 后本地按 `items[].id` 匹配(all:true 上限 1000 行,超出会回 resultTruncated:true,需收窄范围或改到门户核对),或到门户/向用户确认归属。命中哪个模型就用那个 schemaCode 重发删除;只有确认是并发已删且需要旧幂等语义时才带 allowAlreadyAbsent:true。不要用当前 schemaCode 的 data.list 未命中来推断已删。",
|
|
4109
|
+
message: `该 id 当前不属于 ${args.schemaCode}:${id}。删前 data.load(schemaCode=${args.schemaCode})读不到它,所以本工具**没有执行删除**(零删除 wire)。` +
|
|
4110
|
+
"「读不到」只证明它不属于此模型:本工具无法判定它的真实归属,也无法判定它是被并发删除还是 schemaCode 写错。先 model.list 取候选模型,再逐个 data.list(或 all:true 本地匹配 id)核对,或到门户/向用户确认;不要据此回执宣称已清理。" +
|
|
4111
|
+
"命中另一个模型就用该 schemaCode 重发;确认是并发已删且需要旧幂等语义时,重发带 allowAlreadyAbsent:true。",
|
|
4112
|
+
performed: { skipped: "target-not-in-schema", noop: true, deleted: false, alreadyAbsent: true, sheetCode, resolvedFrom },
|
|
4113
|
+
readback: {
|
|
4114
|
+
absent: true,
|
|
4115
|
+
deleted: false,
|
|
4116
|
+
noop: true,
|
|
4117
|
+
alreadyAbsent: true,
|
|
4118
|
+
notInSchema: [id],
|
|
4119
|
+
precheck: String(one.precheck ?? "absent"),
|
|
4120
|
+
...(one.precheckError !== undefined ? { precheckError: one.precheckError } : {}),
|
|
4121
|
+
status: "uncertain",
|
|
4122
|
+
blocker: "delete-target-not-in-schema",
|
|
4123
|
+
recoveryHint: "该 id 不属于此模型只说明 schemaCode 可能写错;归属无法由本工具判定——先 model.list 取候选模型再逐个 data.list 核对,或到门户/向用户确认。不要把 absent:true 单独读成「已删除」。",
|
|
4124
|
+
thisRow: { absent: true, deleted: false },
|
|
4125
|
+
thisRowDeleted: false,
|
|
4126
|
+
...(await remainingRows(session, args.schemaCode, sheetCode)),
|
|
4127
|
+
},
|
|
4128
|
+
};
|
|
4129
|
+
}
|
|
3993
4130
|
if (one.skipped === "already-absent") {
|
|
3994
4131
|
return {
|
|
3995
4132
|
performed: { skipped: "already-absent", noop: true, deleted: false, sheetCode, resolvedFrom },
|
|
@@ -3997,6 +4134,15 @@ export function registerRuntimeDataLane(tools) {
|
|
|
3997
4134
|
absent: true,
|
|
3998
4135
|
deleted: false,
|
|
3999
4136
|
noop: true,
|
|
4137
|
+
alreadyAbsent: true,
|
|
4138
|
+
...(allowAlreadyAbsent
|
|
4139
|
+
? {
|
|
4140
|
+
allowAlreadyAbsent: true,
|
|
4141
|
+
riskNote: "allowAlreadyAbsent:true 恢复了旧幂等语义:读不到就当作已删。若 schemaCode 写错,本回执会误报清理完成——它不证明该 id 曾属于此模型;清理脚本请自行保证 schemaCode 正确。",
|
|
4142
|
+
}
|
|
4143
|
+
: {}),
|
|
4144
|
+
...(one.precheck !== undefined ? { precheck: one.precheck } : {}),
|
|
4145
|
+
...(one.concurrent === true ? { concurrent: true } : {}),
|
|
4000
4146
|
recoveryHint: "若另一进程刚刚删除,这是正常并发结果(already-absent),不是 id 拿错。否则:真实 id 必须取自 data.list 的 items[].id;工作流中心/门户页面回显的 id 会脱敏。",
|
|
4001
4147
|
thisRow: { absent: true, deleted: false },
|
|
4002
4148
|
thisRowDeleted: true,
|
|
@@ -4006,7 +4152,7 @@ export function registerRuntimeDataLane(tools) {
|
|
|
4006
4152
|
}
|
|
4007
4153
|
return {
|
|
4008
4154
|
performed: { errcode: one.errcode, deleted: one.deleted === true, noop: false, sheetCode, resolvedFrom },
|
|
4009
|
-
readback: { absent: one.absent, deleted: one.deleted === true, thisRowDeleted: one.deleted === true, thisRow: { absent: one.absent, deleted: one.deleted === true }, ...(await remainingRows(session, args.schemaCode, sheetCode)) },
|
|
4155
|
+
readback: { absent: one.absent, deleted: one.deleted === true, ...(one.precheck !== undefined ? { precheck: one.precheck } : {}), ...(one.precheckError !== undefined ? { precheckError: one.precheckError, precheckNote: "删前读面失败(不是「不存在」);删除仍已执行,以删后回读为准。" } : {}), thisRowDeleted: one.deleted === true, thisRow: { absent: one.absent, deleted: one.deleted === true }, ...(await remainingRows(session, args.schemaCode, sheetCode)) },
|
|
4010
4156
|
};
|
|
4011
4157
|
}
|
|
4012
4158
|
const deleted = [];
|
|
@@ -4014,12 +4160,18 @@ export function registerRuntimeDataLane(tools) {
|
|
|
4014
4160
|
deleted.push(await deleteOne(id));
|
|
4015
4161
|
const deletedCount = deleted.filter((entry) => entry.deleted === true).length;
|
|
4016
4162
|
const alreadyAbsentCount = deleted.filter((entry) => entry.skipped === "already-absent").length;
|
|
4163
|
+
// P1(探针 I):删前读不到的 id 单独成列——它们没进删除 wire,也**不能**算
|
|
4164
|
+
// 成 deleted,更不能把整批判 ok。名字叫 notInSchema 而不是 already-absent:
|
|
4165
|
+
// form/load 按 schemaCode 分表,读不到只说明「不属于 <schemaCode>」,可能是
|
|
4166
|
+
// 并发已删,也可能 schemaCode 写错(id 实际在另一个模型)。
|
|
4167
|
+
const notInSchema = deleted.filter((entry) => entry.skipped === "target-not-in-schema").map((entry) => String(entry.bizObjectId));
|
|
4017
4168
|
// 运行时兜底(主防线,取代版本门槛):平台回「成功」不算数,删后按 id
|
|
4018
|
-
// 集合回读才算数。`deleted:false` 且不是 already-absent =
|
|
4019
|
-
//
|
|
4020
|
-
//
|
|
4169
|
+
// 集合回读才算数。`deleted:false` 且不是 already-absent/not-in-schema = 平台
|
|
4170
|
+
// 说删了但行还在(1.1.25 已知假成功)。代价:每条 id 一次 form/load 回读
|
|
4171
|
+
// (deleteOne 内),这是识别假成功的唯一可靠方式——平台批量返回恒为
|
|
4172
|
+
// Boolean.TRUE / 计数。
|
|
4021
4173
|
const undeletedIds = deleted
|
|
4022
|
-
.filter((entry) => entry.deleted !== true && entry.skipped !== "already-absent")
|
|
4174
|
+
.filter((entry) => entry.deleted !== true && entry.skipped !== "already-absent" && entry.skipped !== "target-not-in-schema")
|
|
4023
4175
|
.map((entry) => String(entry.bizObjectId));
|
|
4024
4176
|
const batchDeleteIneffective = undeletedIds.length > 0
|
|
4025
4177
|
? {
|
|
@@ -4038,21 +4190,48 @@ export function registerRuntimeDataLane(tools) {
|
|
|
4038
4190
|
// deletionVerified/undeletedIds;「整表是否还在」看 modelRowsRemaining/modelClean
|
|
4039
4191
|
// (失败时 absent:false 仍由共享写门降级 WRITE_UNVERIFIED)。
|
|
4040
4192
|
const residue = await remainingRows(session, args.schemaCode, sheetCode);
|
|
4193
|
+
// 默认口径(P1):有 notInSchema 就不回 ok——未见过的 id 不能算已删,也不能
|
|
4194
|
+
// 让 absent/deletionVerified 只凭「读不到」为 true。allowAlreadyAbsent:true
|
|
4195
|
+
// 时这些条目走 old already-absent 分支,notInSchema 为空、整批照旧可 ok。
|
|
4196
|
+
const uncertain = notInSchema.length > 0;
|
|
4041
4197
|
return {
|
|
4198
|
+
...(uncertain
|
|
4199
|
+
? {
|
|
4200
|
+
status: "uncertain",
|
|
4201
|
+
blocker: "delete-target-not-in-schema",
|
|
4202
|
+
retryable: false,
|
|
4203
|
+
nextCommand: `omc call model.list --args '{"allApplications":true}'`,
|
|
4204
|
+
nextAction: "本工具无法判定这些 id 属于哪个模型。先 model.list 枚举租户全部模型(默认只扫当前应用,跨应用 owner 会漏),再对候选逐个 `data.list {schemaCode:\"<候选>\",all:true}` 后本地按 `items[].id` 匹配(all:true 上限 1000 行,超出会回 resultTruncated:true,需收窄范围或改到门户核对),或到门户/向用户确认。命中哪个模型就用那个 schemaCode 重发;只有确认是并发已删且需要旧幂等语义时才带 allowAlreadyAbsent:true。已 deleted 的条目不要重发;不要用当前 schemaCode 的 data.list 未命中来推断已删。",
|
|
4205
|
+
message: `批量删除里有 ${notInSchema.length} 个 id 当前不属于 ${args.schemaCode}:${notInSchema.join("、")}。本工具**没有对它们发删除**,也不把它们算作 deleted。` +
|
|
4206
|
+
`其余 ${deletedCount} 条已真删并回读缺席。「读不到」只证明这些 id 不属于此模型——本工具无法判定其真实归属,也无法判定是并发删除还是 schemaCode 写错;` +
|
|
4207
|
+
"先 model.list 取候选模型,再逐个 data.list(或 all:true 本地匹配 id)核对,或到门户/向用户确认。命中另一个模型就用该 schemaCode 重发;确认是并发已删且需要旧幂等语义时重发带 allowAlreadyAbsent:true。",
|
|
4208
|
+
}
|
|
4209
|
+
: {}),
|
|
4042
4210
|
performed: { sheetCode, resolvedFrom },
|
|
4043
4211
|
readback: {
|
|
4044
|
-
absent
|
|
4212
|
+
// absent 是「整批目标都属于该 schema 且都不在了」的结论;notInSchema
|
|
4213
|
+
// 让这个结论无法建立,所以不能再只凭读不到就 true。
|
|
4214
|
+
absent: batchDeleteIneffective === undefined && notInSchema.length === 0 && deleted.every((entry) => entry.absent === true),
|
|
4045
4215
|
count: deleted.length,
|
|
4046
4216
|
deletedCount,
|
|
4047
4217
|
alreadyAbsentCount,
|
|
4218
|
+
...(allowAlreadyAbsent
|
|
4219
|
+
? {
|
|
4220
|
+
allowAlreadyAbsent: true,
|
|
4221
|
+
riskNote: "allowAlreadyAbsent:true 恢复了旧幂等语义:读不到的 id 一律当作已删。若 schemaCode 写错,本回执会误报整批清理完成——alreadyAbsentCount 里的 id 未证明曾属于此模型。",
|
|
4222
|
+
}
|
|
4223
|
+
: {}),
|
|
4224
|
+
...(notInSchema.length > 0 ? { notInSchemaCount: notInSchema.length, notInSchema } : {}),
|
|
4048
4225
|
...(undeletedIds.length > 0 ? { undeletedIds } : {}),
|
|
4049
4226
|
deleted,
|
|
4050
4227
|
...(batchDeleteIneffective ? { batchDeleteIneffective } : {}),
|
|
4051
|
-
//
|
|
4052
|
-
//
|
|
4053
|
-
//
|
|
4054
|
-
|
|
4055
|
-
|
|
4228
|
+
// 批量删除的成功判据只有「逐条回读都没了,且请求的 id 本来就在这个模型里」。
|
|
4229
|
+
// remainingRows/clean 是整表状态(为「清空模型」场景保留),删一部分时
|
|
4230
|
+
// clean:false 很常见,不能读成删除失败。新键 modelRowsRemaining/modelClean
|
|
4231
|
+
// 同值,旧键标 deprecated。
|
|
4232
|
+
deletionVerified: batchDeleteIneffective === undefined && notInSchema.length === 0,
|
|
4233
|
+
...(uncertain ? { status: "uncertain", blocker: "delete-target-not-in-schema" } : {}),
|
|
4234
|
+
successCriterion: "undeletedIds 与 notInSchema 均为空且 deletionVerified:true(逐条 form/load 回读);remainingRows/clean 只表示整表是否已空,不用于判批量删除成败",
|
|
4056
4235
|
...residue,
|
|
4057
4236
|
...(typeof residue.remainingRows === "number" ? { modelRowsRemaining: residue.remainingRows } : {}),
|
|
4058
4237
|
...(typeof residue.clean === "boolean" ? { modelClean: residue.clean } : {}),
|
|
@@ -4060,7 +4239,7 @@ export function registerRuntimeDataLane(tools) {
|
|
|
4060
4239
|
remainingRows: "整表剩余行数;仅「清空模型」场景有意义,批量删除判据请用 undeletedIds/deletionVerified",
|
|
4061
4240
|
clean: "整表是否已空;删一部分时 clean:false 不代表删除失败",
|
|
4062
4241
|
},
|
|
4063
|
-
batchNote: "count=请求条数,deletedCount=真删条数,alreadyAbsentCount=删前就不存在的条数,undeletedIds=回读仍在、需要单条重试的 id;deleted[] 逐条给 bizObjectId/errcode/absent/deleted/noop/skipped。成功判据=undeletedIds 为空(deletionVerified:true),不是 remainingRows/clean。平台批量接口(removeBizObjects / runtime/query/delete_data,2.1.5 亦然)只回 Boolean/计数,无法区分「已删」「本来不存在」「假成功」,所以以本工具的逐条回读为准。",
|
|
4242
|
+
batchNote: "count=请求条数,deletedCount=真删条数,alreadyAbsentCount=删前就不存在的条数,undeletedIds=回读仍在、需要单条重试的 id;deleted[] 逐条给 bizObjectId/errcode/absent/deleted/noop/skipped。成功判据=undeletedIds 为空且 notInSchema 为空(deletionVerified:true),不是 remainingRows/clean。平台批量接口(removeBizObjects / runtime/query/delete_data,2.1.5 亦然)只回 Boolean/计数,无法区分「已删」「本来不存在」「假成功」,所以以本工具的逐条回读为准。",
|
|
4064
4243
|
},
|
|
4065
4244
|
};
|
|
4066
4245
|
},
|