@stalfh233/omc-cli 0.8.35 → 0.8.37

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.
@@ -25,6 +25,15 @@ export const DATA_SUBMIT_RUN_MODE_SUPPORTED = new Set([]);
25
25
  * 而 form/load 会写 OPEN_FORM 审计——下一版再评估。
26
26
  */
27
27
  export const NODE_FIELD_PERMISSION_NOTE = "审批节点的 editable/visible 只作用于门户加载面(form/load 的读面膜);REST submit 不校验这些节点权限,formData 里的新值会照常落库。平台在提交面只校验 hidden/重复(checkType5),发起节点只校验必填(受 isCheckPropertyEmpty 控制)——不要以为「节点设了只读」就等于 REST 提交被拦。";
28
+ /**
29
+ * F6(探针 AA,0.8.36):**普通写面**(data.update / 带 id 的 data.save)在目标行
30
+ * 处于流程中(PROCESSING)时给同一事实:节点字段权限只是门户 form/load 读面膜,
31
+ * REST 普通更新不校验(同 NODE_FIELD_PERMISSION_NOTE 的平台证据:
32
+ * `AppPermissionValidator.java:210-224` 流程表单直接 return;
33
+ * `AbstractLoadPermissionService.java:172,295-304` 只在加载面套用节点权限)。
34
+ * 文案是静态的——不新增任何 wire。
35
+ */
36
+ export const NODE_FIELD_PERMISSION_WRITE_NOTE = "目标行处于流程中(sequenceStatus=PROCESSING):审批节点的 editable/visible 只作用于门户 form/load 的读面膜;REST 普通更新(data.update / 带 id 的 data.save)不校验节点字段权限,formData 的改动照常落库。要核对哪些字段在某节点只读,读 workflow.get_published 的 activities[].propertyPermissions。";
28
37
  export function assertSupportedRunMode(runMode) {
29
38
  if (runMode === undefined || runMode === null)
30
39
  return;
@@ -62,6 +71,109 @@ export function projectApprovalReadback(record, submittedKeys) {
62
71
  projected[key] = compactRuntimeValue(source[key]);
63
72
  return projected;
64
73
  }
74
+ /**
75
+ * 参与者 → 当前用户。精确 `person.id === actor.userId` 优先;id 不可比时
76
+ * 才降级按显示名匹配(各读面拼写不一致:`participantors[].id/userId`、
77
+ * `name/userName`,真机也见过只回显示名)。降级结果要能在回执里看出来。
78
+ */
79
+ export function matchParticipantToActor(person, actor) {
80
+ if (actor.userId !== null && actor.userId !== "") {
81
+ if (person.id === actor.userId)
82
+ return "id";
83
+ }
84
+ if (actor.name !== null && actor.name !== "") {
85
+ if (person.name === actor.name)
86
+ return "name";
87
+ // 有的读面把 id 塞在 name、把 name 塞在 id(或只回其中一个)。
88
+ if (person.id === actor.name)
89
+ return "name";
90
+ }
91
+ if (actor.userId !== null && actor.userId !== "") {
92
+ if (person.name === actor.userId)
93
+ return "name";
94
+ }
95
+ return null;
96
+ }
97
+ /** @deprecated 保留布尔包装(既有调用方/测试);需要 match 依据用 {@link matchParticipantToActor}。 */
98
+ export function participantIsActor(person, actor) {
99
+ return matchParticipantToActor(person, actor) !== null;
100
+ }
101
+ /**
102
+ * 无(本页可见)待办时的唯一判据:
103
+ * - 有激活节点 → 参与人含当前用户 = `pending-yours`(**不报** not-yours),
104
+ * 否则 `pending-elsewhere`;
105
+ * - 无激活节点 → 实例已结束(APPROVED/COMPLETED/TOPPING_OFF)= `finished`
106
+ * (行状态滞后,**不报** no-next);异常态 = `exception`;其余 = `no-next`。
107
+ */
108
+ export function classifyFlowFollowup(input) {
109
+ const first = input.activeActivities[0];
110
+ if (first !== undefined) {
111
+ let match = null;
112
+ for (const person of first.participants) {
113
+ match = matchParticipantToActor(person, input.actor);
114
+ if (match !== null)
115
+ break;
116
+ }
117
+ return { kind: match !== null ? "pending-yours" : "pending-elsewhere", activity: first, ...(match !== null ? { match } : {}) };
118
+ }
119
+ if (isFinishedInstanceStatus(input.instanceStatus))
120
+ return { kind: "finished" };
121
+ if (input.instanceStatus !== null && /EXCEPTION|ERROR|CANCEL/i.test(input.instanceStatus))
122
+ return { kind: "exception" };
123
+ return { kind: "no-next" };
124
+ }
125
+ /** 有界翻页上限(第 0..2 页,每页 200)。 */
126
+ export const FLOW_PENDING_MAX_PAGES = 3;
127
+ /**
128
+ * 本实例的待办:schemaCode 收窄 + 有界翻页(≤3 页)。找到即停。
129
+ *
130
+ * `search_workitems` 只回当前登录人的待办,但服务端没有 workflowInstanceId
131
+ * 过滤(ListWorkItemSearchVO 无该字段),实例匹配在客户端做;因此必须先按
132
+ * schemaCode 收窄,否则跨模型的 200 条会淹没本人待办。
133
+ */
134
+ export async function searchPendingForInstance(session, instanceId, schemaCode) {
135
+ const items = [];
136
+ let pages = 0;
137
+ let totalPages = 0;
138
+ for (let page = 0; page < FLOW_PENDING_MAX_PAGES; page += 1) {
139
+ const result = await searchWorkItems(session, { instanceId, schemaCode, page, size: 200 });
140
+ pages += 1;
141
+ totalPages = result.totalPages ?? 0;
142
+ items.push(...result.items);
143
+ if (result.items.length > 0)
144
+ break;
145
+ if (page + 1 >= totalPages)
146
+ break;
147
+ }
148
+ return { items, pages, totalPages };
149
+ }
150
+ /** `list_workflow_instance_activity` → 激活节点(status=1),参与者去重截 10。 */
151
+ export async function readActiveFlowActivities(session, instanceId) {
152
+ const rows = await listInstanceActivities(session, instanceId);
153
+ return rows
154
+ .filter((row) => row.status === 1 || row.status === "1")
155
+ .map((row) => {
156
+ const participants = Array.isArray(row.participantors) ? row.participantors : [];
157
+ const seen = new Set();
158
+ const people = [];
159
+ for (const person of participants) {
160
+ const name = wireString(person.name) ?? wireString(person.userName) ?? null;
161
+ const id = wireString(person.id) ?? wireString(person.userId) ?? null;
162
+ const key = `${id ?? ""}#${name ?? ""}`;
163
+ if (seen.has(key))
164
+ continue;
165
+ seen.add(key);
166
+ people.push({ name, id });
167
+ if (people.length >= 10)
168
+ break;
169
+ }
170
+ return {
171
+ activityCode: wireString(row.activityCode),
172
+ activityName: wireString(row.activityName),
173
+ participants: people,
174
+ };
175
+ });
176
+ }
65
177
  export async function readSubmitLanding(session, schemaCode, workflowInstanceId,
66
178
  /** 调用方已给 bizObjectId 时不必反查(少一次读)。 */
67
179
  knownBizObjectId = null) {
@@ -399,6 +511,17 @@ export function registerDataSubmit(tools) {
399
511
  message: "只传 workflowInstanceId 不够:平台 formType=1 的提交必须带 workItemId(审批现有待办)或 workflowCode(发起流程),否则稳定回 100002「参数 workflowInstanceId、workItemId 或 workflowCode 为空」。先 workitem.list 取待办 id,再带 workItemId 提交。",
400
512
  });
401
513
  },
514
+ // F6(探针 AA,0.8.36):dry-run 也说清「审批提交带 formData 时 REST 不校验
515
+ // 节点字段权限」。纯形状判定,零读、零 wire——与真写回执的
516
+ // nodeFieldPermissionNote 同源(同一常量)。
517
+ dryRunPayload: async (_session, args) => {
518
+ const hasWorkItem = typeof args.workItemId === "string" && args.workItemId.trim().length > 0;
519
+ const formData = (args.formData ?? {});
520
+ return {
521
+ ...(hasWorkItem && Object.keys(formData).length > 0 ? { nodeFieldPermissionNote: NODE_FIELD_PERMISSION_NOTE } : {}),
522
+ summary: `计划提交 ${args.schemaCode}`,
523
+ };
524
+ },
402
525
  execute: async (session, args) => {
403
526
  assertSupportedRunMode(args.runMode);
404
527
  // r13 #5: an EMPTY STRING was forwarded verbatim, so the platform answered
@@ -712,7 +835,7 @@ export function registerDataSubmit(tools) {
712
835
  path: ENDPOINTS.runtimeFormSubmit,
713
836
  method: "POST",
714
837
  body: payload,
715
- }), undefined, hasWorkflowCode ? explicitWorkflowCode : undefined);
838
+ }), formData, hasWorkflowCode ? explicitWorkflowCode : undefined);
716
839
  try {
717
840
  performed = await submitOnce();
718
841
  }
@@ -849,6 +972,9 @@ export function registerDataSubmit(tools) {
849
972
  }
850
973
  }
851
974
  const performedData = (performed.data ?? {});
975
+ // #77.4:flow 读回要用「当前用户」判别待办归属——提前解析一次,与下方
976
+ // 发起权限 bypass 判定复用(原本也会调,不增加 wire)。
977
+ let actor = await resolvePermissionActor(session);
852
978
  let readback = {
853
979
  formType,
854
980
  ...(submitMappingRuntimeNote !== undefined ? { mappingRuntimeNote: submitMappingRuntimeNote } : {}),
@@ -1033,38 +1159,105 @@ export function registerDataSubmit(tools) {
1033
1159
  if (hasWorkItem)
1034
1160
  readback.decision = rejected ? "REJECT" : startNodeSubmit ? "SUBMIT" : "APPROVE";
1035
1161
  if (hasWorkflow && effectiveInstanceId && sequenceStatus !== "COMPLETED") {
1162
+ // 顶层恒带四键:先落默认值,下面读到证据再覆盖(读面失败也不缺键)。
1163
+ readback.instanceStatus = null;
1164
+ readback.activeCount = null;
1165
+ readback.activeCountNote = "节点读面未读取:activeCount 未知(null 不是 0)";
1166
+ readback.nextWorkItemCount = 0;
1167
+ readback.nextParticipants = [];
1036
1168
  try {
1037
- const pending = await searchWorkItems(session, { instanceId: effectiveInstanceId });
1038
- const nextWorkItems = pending.items.slice(0, 5).map((item) => ({
1169
+ const mapPending = (rows) => rows.slice(0, 5).map((item) => ({
1039
1170
  workItemId: wireString(item.id),
1040
1171
  activityCode: wireString(item.activityCode),
1041
1172
  activityName: wireString(item.activityName),
1042
1173
  state: wireString(item.state),
1043
1174
  }));
1044
- // r29c F5: searchWorkItems 只回**当前登录人**待办;下一节点审批人不是
1045
- // 你时 pending 为空 ≠ 没生成待办。用 listInstanceActivities 区分。
1175
+ // 1) 本实例待办:schemaCode 收窄 + 有界翻页(旧实现只取第 0 页/200 条,
1176
+ // 跨模型待办一多就把本人待办挤掉,于是「没找到」被误报为 not-yours)。
1177
+ const pending = await searchPendingForInstance(session, effectiveInstanceId, args.schemaCode);
1178
+ let nextWorkItems = mapPending(pending.items);
1179
+ let nextWorkItemCount = pending.items.length;
1180
+ // 2) 激活节点:activeCount / participants 的真相。即使有待办也读一次,
1181
+ // 让回执顶层恒带 activeCount / nextParticipants。
1046
1182
  let activeActivities = [];
1047
- if (nextWorkItems.length === 0 && sequenceStatus === "PROCESSING") {
1048
- try {
1049
- const rows = await listInstanceActivities(session, effectiveInstanceId);
1050
- activeActivities = rows
1051
- .filter((row) => row.status === 1 || row.status === "1")
1052
- .map((row) => {
1053
- const participants = Array.isArray(row.participantors) ? row.participantors : [];
1054
- return {
1055
- activityCode: wireString(row.activityCode),
1056
- activityName: wireString(row.activityName),
1057
- participants: participants.slice(0, 10).map((person) => ({
1058
- name: wireString(person.name) ?? wireString(person.userName) ?? null,
1059
- id: wireString(person.id) ?? wireString(person.userId) ?? null,
1060
- })),
1061
- };
1062
- });
1063
- }
1064
- catch {
1065
- // best-effort
1183
+ let activitiesRead = false;
1184
+ try {
1185
+ activeActivities = await readActiveFlowActivities(session, effectiveInstanceId);
1186
+ activitiesRead = true;
1187
+ }
1188
+ catch {
1189
+ // best-effort:读不到不阻塞主回执(activeCount 回 null,不回 0)
1190
+ }
1191
+ // 3) 实例头:终态(APPROVED/COMPLETED/TOPPING_OFF)与异常态的判据。
1192
+ let instanceStatus = null;
1193
+ try {
1194
+ const header = await getInstanceBaseInfo(session, effectiveInstanceId);
1195
+ instanceStatus = header ? wireString(header.status) : null;
1196
+ }
1197
+ catch {
1198
+ instanceStatus = null; // best-effort:读不到不猜
1199
+ }
1200
+ let classification = classifyFlowFollowup({ activeActivities, instanceStatus, actor });
1201
+ // 4) 无待办、无激活节点、也无终态/异常证据:一次有界复读(400ms×2,
1202
+ // 总 deadline ≤1.5s),给异步派发/状态回写留时间;仍无才报 no-next。
1203
+ if (nextWorkItems.length === 0 && classification.kind === "no-next") {
1204
+ const deadline = Date.now() + 1500;
1205
+ for (let attempt = 0; attempt < 2; attempt += 1) {
1206
+ const remaining = deadline - Date.now();
1207
+ if (remaining <= 0)
1208
+ break;
1209
+ await new Promise((resolve) => setTimeout(resolve, Math.min(400, remaining)));
1210
+ try {
1211
+ const again = await searchPendingForInstance(session, effectiveInstanceId, args.schemaCode);
1212
+ if (again.items.length > 0) {
1213
+ nextWorkItems = mapPending(again.items);
1214
+ nextWorkItemCount = again.items.length;
1215
+ try {
1216
+ activeActivities = await readActiveFlowActivities(session, effectiveInstanceId);
1217
+ activitiesRead = true;
1218
+ }
1219
+ catch {
1220
+ // best-effort:节点读面失败时 activeCount 回 null
1221
+ }
1222
+ break;
1223
+ }
1224
+ activeActivities = await readActiveFlowActivities(session, effectiveInstanceId).catch(() => activeActivities);
1225
+ activitiesRead = true;
1226
+ const header = await getInstanceBaseInfo(session, effectiveInstanceId);
1227
+ if (header)
1228
+ instanceStatus = wireString(header.status) ?? instanceStatus;
1229
+ classification = classifyFlowFollowup({ activeActivities, instanceStatus, actor });
1230
+ if (classification.kind !== "no-next")
1231
+ break;
1232
+ }
1233
+ catch {
1234
+ break; // 复读失败保持原判,不做第三次
1235
+ }
1066
1236
  }
1067
1237
  }
1238
+ // 顶层恒带四键:无证据 → null/0/[],不伪造。
1239
+ const workItemPeople = pending.items.slice(0, 10).map((item) => ({
1240
+ name: wireString(item.participantName) ?? wireString(item.participant) ?? null,
1241
+ id: wireString(item.participantId) ?? wireString(item.participant) ?? null,
1242
+ }));
1243
+ readback.instanceStatus = instanceStatus;
1244
+ // activeCount 只数**激活节点**;待办数另用 nextWorkItemCount。
1245
+ if (activitiesRead) {
1246
+ readback.activeCount = activeActivities.length;
1247
+ delete readback.activeCountNote;
1248
+ }
1249
+ else {
1250
+ readback.activeCount = null;
1251
+ }
1252
+ readback.nextWorkItemCount = nextWorkItemCount;
1253
+ readback.nextParticipants =
1254
+ (activeActivities[0]?.participants.length ?? 0) > 0
1255
+ ? activeActivities[0].participants.slice(0, 10)
1256
+ : workItemPeople;
1257
+ // 行状态可能滞后于实例终态:flow 分支仍会跑(行 ≠ COMPLETED),
1258
+ // 但「已结束」以实例头为准。
1259
+ const rowProcessing = sequenceStatus === "PROCESSING";
1260
+ const instanceRunning = instanceStatus !== null && /PROCESSING|RUNNING|ACTIVE|PAUSE/i.test(instanceStatus);
1068
1261
  if (nextWorkItems.length > 0) {
1069
1262
  readback.nextWorkItems = nextWorkItems;
1070
1263
  if (readback.workItemId === null)
@@ -1093,66 +1286,78 @@ export function registerDataSubmit(tools) {
1093
1286
  };
1094
1287
  }
1095
1288
  }
1096
- else if (sequenceStatus === "PROCESSING" && activeActivities.length > 0) {
1097
- const first = activeActivities[0];
1289
+ else if (classification.kind === "finished") {
1290
+ // 实例已结束(APPROVED/COMPLETED/TOPPING_OFF)但行状态还停在
1291
+ // PROCESSING:这是状态回写滞后,**不是**「流程没生成待办」。
1292
+ readback.workItemState = "none-flow-completed";
1293
+ readback.flowCompleted = true;
1294
+ readback.rowStatusLag = sequenceStatus !== "COMPLETED";
1295
+ }
1296
+ else if ((classification.kind === "pending-yours" || classification.kind === "pending-elsewhere") && (rowProcessing || instanceRunning)) {
1297
+ const first = classification.activity;
1098
1298
  const holderNames = first.participants
1099
1299
  .map((person) => person.name ?? person.id)
1100
1300
  .filter((value) => typeof value === "string" && value.length > 0);
1101
1301
  const holders = holderNames.length > 0 ? holderNames.join("、") : "(参与人未回显)";
1102
- // r62a-F7:主键同步——「待办在别处」从 flowWarning 文案提升为主键判别值。
1103
- readback.workItemState = "pending-elsewhere";
1302
+ const mine = classification.kind === "pending-yours";
1303
+ // r62a-F7:主键同步——待办归属从 flowWarning 文案提升为主键判别值。
1304
+ readback.workItemState = mine ? "pending-yours-not-listed" : "pending-elsewhere";
1305
+ // 精确 id 匹配优先;name 只是降级,回执明示匹配依据。
1306
+ if (mine && classification.match !== undefined)
1307
+ readback.participantMatch = classification.match;
1104
1308
  if (rejected) {
1105
1309
  readback.returnedTo = { activityCode: first.activityCode, activityName: first.activityName };
1106
1310
  readback.nextSubmit = {
1107
1311
  schemaCode: args.schemaCode,
1108
1312
  workflowInstanceId: effectiveInstanceId,
1109
1313
  bizObjectId: objectId,
1110
- note: `已退回 ${first.activityName ?? first.activityCode ?? "上一节点"}(当前登录人看不到该待办;持有人:${holders})。`,
1314
+ note: mine
1315
+ ? `已退回 ${first.activityName ?? first.activityCode ?? "上一节点"}(待办在你名下,但待办列表本次未列出)。`
1316
+ : `已退回 ${first.activityName ?? first.activityCode ?? "上一节点"}(当前登录人看不到该待办;持有人:${holders})。`,
1111
1317
  };
1112
1318
  }
1319
+ if (mine) {
1320
+ // 参与者就是当前登录人:待办列表没列出来只可能是异步/分页/过滤面
1321
+ // 尚未跟上——给可复制的核对命令,但**绝不**再报「不在你名下」。
1322
+ readback.pendingHint = `下一节点「${first.activityName ?? first.activityCode ?? "?"}」的参与人就是当前登录人,待办列表本次未列出。用 workitem.list 核对(schemaCode + status:PENDING)后再 data.submit。`;
1323
+ }
1324
+ else {
1325
+ readback.flowWarning = {
1326
+ code: "flow-next-workitem-not-yours",
1327
+ message: `提交成功,下一节点已激活:${first.activityName ?? first.activityCode ?? "?"},但待办不在当前登录人名下(持有人:${holders})。这不是「没生成待办」。`,
1328
+ activityCode: first.activityCode,
1329
+ activityName: first.activityName,
1330
+ participants: first.participants,
1331
+ workItemState: "pending-elsewhere",
1332
+ checks: [
1333
+ `omc call workflow.instanceActivity --args '{"workflowInstanceId":"${effectiveInstanceId}"}'`,
1334
+ `omc call workitem.list --args '{"workflowInstanceId":"${effectiveInstanceId}","participant":"<持有人 id>"}'`,
1335
+ "要用该参与人账号另建环境(omc setup 建一个该账号的环境)再 data.submit,或临时把节点参与人改成发起人",
1336
+ ],
1337
+ };
1338
+ }
1339
+ }
1340
+ else if (classification.kind === "exception" && rowProcessing) {
1113
1341
  readback.flowWarning = {
1114
- code: "flow-next-workitem-not-yours",
1115
- message: `提交成功,下一节点已激活:${first.activityName ?? first.activityCode ?? "?"},但待办不在当前登录人名下(持有人:${holders})。这不是「没生成待办」。`,
1116
- activityCode: first.activityCode,
1117
- activityName: first.activityName,
1118
- participants: first.participants,
1119
- // r62a-F7:主键 workItemState 同步改写——探针读主键就能判「在别处」,
1120
- // 不必解析 warning 文案。
1121
- workItemState: "pending-elsewhere",
1342
+ code: "flow-instance-exception",
1343
+ instanceStatus,
1344
+ message: `提交成功(errCode 0、行状态 PROCESSING),但流程实例状态 ${instanceStatus}——流程没有走完就停了。这不是等待审批,是异常停滞(最常见:审批参与人/角色解析为空,无审批人可派待办)。`,
1122
1345
  checks: [
1123
- `omc call workflow.instanceActivity --args '{"workflowInstanceId":"${effectiveInstanceId}"}'`,
1124
- `omc call workitem.list --args '{"workflowInstanceId":"${effectiveInstanceId}","participant":"<持有人 id>"}'`,
1125
- "要用该参与人账号另建环境(omc setup 建一个该账号的环境)再 data.submit,或临时把节点参与人改成发起人",
1346
+ `omc call workflow.instanceActivity --args '{"workflowInstanceId":"${effectiveInstanceId}"}'(看每个节点的 status 与 participants;无 status=1 即停住)`,
1347
+ "容器日志搜 GetParticipantInfo error / CustomParticipleMethod{...} -> []",
1348
+ "参与人优先用参与者对象数组(角色 id);内置函数只认 FindUserByRole(org, roleCode[, order])",
1126
1349
  ],
1127
1350
  };
1128
1351
  }
1129
- else if (sequenceStatus === "PROCESSING") {
1130
- // r4-training 2026-10-20: an unresolvable participant (role with no
1131
- // members, member not attached to the originator's department, or a
1132
- // participant function that is not registered) makes the engine
1133
- // create NO next work item while the submit still answers errCode 0.
1134
- // Without this line the caller cannot tell "flow advanced" from
1135
- // "flow silently stalled" — surface it instead of staying quiet.
1136
- // 仅 activeCount=0 才保留 flow-no-next-workitem(勿再说「参与人解析为空」
1137
- // 当其实有 active 节点——那是 F5 误报根因)。
1138
- // r68 链2-D2(真机实证):行状态 PROCESSING(绿)但实例头是 EXCEPTION——
1139
- // warning 只说「停在 PROCESSING」会让 agent 把异常当等待。best-effort
1140
- // 点名实例状态,异常态换更重的文案。
1141
- let instanceStatus = null;
1142
- try {
1143
- const header = await getInstanceBaseInfo(session, effectiveInstanceId);
1144
- instanceStatus = header ? wireString(header.status) : null;
1145
- }
1146
- catch {
1147
- instanceStatus = null; // best-effort:读不到不阻塞主回执
1148
- }
1149
- const instanceBroken = instanceStatus !== null && /EXCEPTION|ERROR|CANCEL/i.test(instanceStatus);
1352
+ else if (rowProcessing || instanceRunning) {
1353
+ // r4-training 2026-10-20 / #77.4:有界复读后仍无待办、无激活节点、
1354
+ // 实例也不是终态/异常态 → 才说「没生成待办」,且标 provisional
1355
+ // (异步可能还在路上)。
1150
1356
  readback.flowWarning = {
1151
- code: instanceBroken ? "flow-instance-exception" : "flow-no-next-workitem",
1357
+ code: "flow-no-next-workitem",
1358
+ provisional: true,
1152
1359
  ...(instanceStatus !== null ? { instanceStatus } : {}),
1153
- message: instanceBroken
1154
- ? `提交成功(errCode 0、行状态 PROCESSING),但流程实例状态 ${instanceStatus}——流程没有走完就停了。这不是等待审批,是异常停滞(最常见:审批参与人/角色解析为空,无审批人可派待办)。`
1155
- : "提交成功但该实例没有任何激活节点(activeCount=0),流程停在 PROCESSING。常见原因:审批参与人解析失败导致未创建下一节点,或引擎异常。",
1360
+ message: "提交成功但该实例没有任何激活节点(activeCount=0),流程停在 PROCESSING,且 800ms 内两次复读仍无变化(provisional)。常见原因:审批参与人解析失败导致未创建下一节点,或引擎异常。",
1156
1361
  checks: [
1157
1362
  `omc call workflow.instanceActivity --args '{"workflowInstanceId":"${effectiveInstanceId}"}'(看每个节点的 status 与 participants;无 status=1 即停住)`,
1158
1363
  "容器日志搜 GetParticipantInfo error / CustomParticipleMethod{...} -> []",
@@ -1165,6 +1370,13 @@ export function registerDataSubmit(tools) {
1165
1370
  // best-effort
1166
1371
  }
1167
1372
  }
1373
+ else if (hasWorkflow && effectiveInstanceId) {
1374
+ // 行已 COMPLETED:流程已走完,不再查待办/节点,但顶层四键仍恒带。
1375
+ readback.instanceStatus = null;
1376
+ readback.activeCount = 0;
1377
+ readback.nextWorkItemCount = 0;
1378
+ readback.nextParticipants = [];
1379
+ }
1168
1380
  }
1169
1381
  // r29c F10: 仅审批提交(有 workItemId)才输出 approvalNote;发起提交改成「已发起」。
1170
1382
  const startNote = !hasWorkItem && hasWorkflow && typeof readback.workflowInstanceId === "string"
@@ -1180,7 +1392,6 @@ export function registerDataSubmit(tools) {
1180
1392
  // r30d F5/F7: name the operator + whether this start succeeded only because
1181
1393
  // a platform admin bypassed the start-permission whitelist. Without this,
1182
1394
  // "config didn't take effect" and "admin bypass" are indistinguishable.
1183
- let actor = await resolvePermissionActor(session);
1184
1395
  let permissionBypass;
1185
1396
  const startedWorkflow = !hasWorkItem && (autoStarted || hasWorkflowCode) && typeof (readback.workflowInstanceId ?? explicitWorkflowCode) === "string";
1186
1397
  if (startedWorkflow && actor.isAdmin) {