@stalfh233/omc-cli 0.8.36 → 0.8.38
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/endpoints.js +16 -0
- package/dist/field-add.js +38 -11
- package/dist/lanes/businessrule.js +144 -44
- package/dist/lanes/rule-lifecycle-contract.js +5 -4
- package/dist/lanes/rule-lifecycle.js +136 -3
- package/dist/lanes/runtime-data/date-format.js +47 -0
- package/dist/lanes/runtime-data/field-options.js +58 -0
- package/dist/lanes/runtime-data/record-write.js +30 -5
- package/dist/lanes/runtime-data/submission.js +257 -66
- package/dist/lanes/runtime-data/write-support.js +128 -46
- package/dist/lanes/workflow/template-fetch.js +94 -11
- package/dist/lanes/workflow/template-read.js +30 -11
- package/dist/lanes/workflow-contract.js +1 -1
- package/dist/read-projection.js +17 -0
- package/dist/read-shapes.js +4 -3
- package/dist/read.js +9 -1
- package/dist/recipes/runtime-data.js +3 -3
- package/dist/runtime-support.js +98 -20
- package/dist/tools.js +18 -0
- package/dist/wire.js +119 -11
- package/dist/write.js +66 -5
- package/package.json +3 -3
package/dist/endpoints.js
CHANGED
|
@@ -4,6 +4,14 @@
|
|
|
4
4
|
* invented surfaces.
|
|
5
5
|
*/
|
|
6
6
|
export const ENDPOINTS = {
|
|
7
|
+
/**
|
|
8
|
+
* 存活动探针(匿名只读)。`PublicController` `@RequestMapping("/public")` +
|
|
9
|
+
* `@GetMapping("/healthz")` → `data:"ok"`;gateway 挂 `/api` 前缀。
|
|
10
|
+
* 8.6.26: decompiled-full/launcher-8.6.26/.../PublicController.java:97,191;
|
|
11
|
+
* 2.1.5: decompiled-full/launcher-2.1.5/.../PublicController.java:180。
|
|
12
|
+
* 用于区分「平台进程在线、只是网关路由未命中」与「平台本身不可用」。
|
|
13
|
+
*/
|
|
14
|
+
publicHealthz: "/api/public/healthz",
|
|
7
15
|
applicationList: "/api/api/app/apppackage/list",
|
|
8
16
|
applicationGroupList: "/api/api/app/apppackage/list_all_group",
|
|
9
17
|
applicationGet: "/api/api/app/apppackage/get",
|
|
@@ -271,6 +279,14 @@ export const ENDPOINTS = {
|
|
|
271
279
|
programmingPublish: "/api/api/programming/publish",
|
|
272
280
|
workflowCreate: "/api/api/workflow/create",
|
|
273
281
|
workflowGetHeader: "/api/api/workflow/get_header",
|
|
282
|
+
/**
|
|
283
|
+
* 按模型列流程模板头(WorkflowTemplateController.java:842-866,8.6.26
|
|
284
|
+
* `@GetMapping("/list")`,`schemaCode` 必填;`published=FALSE` 时
|
|
285
|
+
* WorkflowTemplateHeaderServiceImpl.java:97-109 返回**全部** header(含草稿),
|
|
286
|
+
* 每行带 workflowCode/published)。一个模型可挂多个流程;平台没有应用级
|
|
287
|
+
* 流程清单端点。
|
|
288
|
+
*/
|
|
289
|
+
workflowList: "/api/api/workflow/list",
|
|
274
290
|
workflowGetDraft: "/api/api/workflow/get_draft",
|
|
275
291
|
workflowIsWorkflow: "/api/api/workflow/isworkflow",
|
|
276
292
|
workflowGetBySchema: "/api/api/workflow/getWorkflow",
|
package/dist/field-add.js
CHANGED
|
@@ -7,6 +7,10 @@
|
|
|
7
7
|
*
|
|
8
8
|
* 语义(与 model-scaffold 同族约定):
|
|
9
9
|
* - **幂等**:字段已存在(duplicate)→ 记 skipped 继续(补建场景不该整批失败)。
|
|
10
|
+
* - **每个子调用独立 requestId**:命令级 requestId 只作 base,写/读子调用按
|
|
11
|
+
* `base:步骤:序号` 派生(见 `subRequestId`)。同 id 不同参数会被幂等门拒绝
|
|
12
|
+
* (argsDigestChanged),多字段必败;派生后多字段全成功,且同一 base 重跑时
|
|
13
|
+
* 已完成的子调用命中 replay(不重复建字段)。
|
|
10
14
|
* - **不猜**:--fields 每项原样透传给 field.create(只补 schemaCode)。
|
|
11
15
|
* - **失败不发布**:有真失败默认停在发布前(--force-publish 强发)。
|
|
12
16
|
* - **列表增量**:listview.configure 默认合并语义(保留既有列/条件),只把新字段
|
|
@@ -20,6 +24,20 @@ import { writeEnvelope } from "./cli-output.js";
|
|
|
20
24
|
import { assertSafeInputPath } from "./artifacts.js";
|
|
21
25
|
import { readFileSync } from "node:fs";
|
|
22
26
|
import { resolve } from "node:path";
|
|
27
|
+
/**
|
|
28
|
+
* 子调用 requestId 派生(w53 P1):`requestId` 是「(id, 参数指纹) 组合键」,
|
|
29
|
+
* 同一条命令里的预检与 N 个字段写、N 行演示数据**参数各不相同**,共用一个 id 会
|
|
30
|
+
* 让第 2 个子调用撞 `argsDigestChanged`(真机:2 字段 → created:1/failed:1 partial)。
|
|
31
|
+
*
|
|
32
|
+
* 派生规则:`${base}:${label}:${index}`(index 从 1 起;无序号步骤省略)。
|
|
33
|
+
* - **唯一**:同一命令内每个写/读子调用一个 id;
|
|
34
|
+
* - **稳定**:同一 base + 同一命令形状 → 同一派生 id,重跑时已完成的子调用命中
|
|
35
|
+
* 本地 replay(同 id 同指纹 → no-op),不会重复建字段;
|
|
36
|
+
* - **可读**:label 说明是哪一步,request.status 排障时一眼看出。
|
|
37
|
+
*/
|
|
38
|
+
function subRequestId(base, label, index) {
|
|
39
|
+
return index === undefined ? `${base}:${label}` : `${base}:${label}:${index}`;
|
|
40
|
+
}
|
|
23
41
|
/**
|
|
24
42
|
* 模型级发布的爆炸半径:读出该模型草稿面里「不是本次要建的」字段。
|
|
25
43
|
*
|
|
@@ -34,7 +52,8 @@ async function listOtherDraftFields(schemaCode, ownCodes, opts) {
|
|
|
34
52
|
const callFieldList = async (published) => {
|
|
35
53
|
const outcome = await runToolCall("field.list", {
|
|
36
54
|
args: { schemaCode, published },
|
|
37
|
-
|
|
55
|
+
// 读面不产生写产物,但同样按子调用派生,避免与写步骤共用 id 造成排障歧义。
|
|
56
|
+
requestId: subRequestId(opts.requestId, published ? "read:published" : "read:draft"),
|
|
38
57
|
...(opts.environment !== undefined ? { environment: opts.environment } : {}),
|
|
39
58
|
...(opts.context !== undefined ? { context: opts.context } : {}),
|
|
40
59
|
print: () => undefined,
|
|
@@ -68,10 +87,14 @@ async function listOtherDraftFields(schemaCode, ownCodes, opts) {
|
|
|
68
87
|
async function expandDictShorthand(fields, environment, contextForTest, request) {
|
|
69
88
|
const problems = [];
|
|
70
89
|
const expanded = [];
|
|
90
|
+
// 字典展开是只读链(dictionary.list + records ×N)。按子调用派生 id:虽是读面,
|
|
91
|
+
// 但同一条命令里多次用同一个 id 会让 request.status/journal 无法区分。
|
|
92
|
+
let readSeq = 0;
|
|
71
93
|
const call = async (tool, args) => {
|
|
94
|
+
readSeq += 1;
|
|
72
95
|
const outcome = await runToolCall(tool, {
|
|
73
96
|
args,
|
|
74
|
-
requestId: request,
|
|
97
|
+
requestId: subRequestId(request, `dict-read:${tool}`, readSeq),
|
|
75
98
|
...(environment !== undefined ? { environment } : {}),
|
|
76
99
|
...(contextForTest !== undefined ? { context: contextForTest } : {}),
|
|
77
100
|
print: () => undefined,
|
|
@@ -145,8 +168,10 @@ export function validateFields(schemaCode, fields) {
|
|
|
145
168
|
problems.push("--schema 必填");
|
|
146
169
|
return problems;
|
|
147
170
|
}
|
|
148
|
-
export async function cmdFieldAdd(args, contextForTest) {
|
|
149
|
-
|
|
171
|
+
export async function cmdFieldAdd(args, contextForTest, requestOverride) {
|
|
172
|
+
// `requestOverride` 是测试缝(不暴露 CLI flag):给同一 base 重放子调用,
|
|
173
|
+
// 验证「同一 base → 同一派生 id → 已完成子调用命中 replay」。
|
|
174
|
+
const request = requestOverride ?? requestId();
|
|
150
175
|
const flag = (name) => argvValue(args, name);
|
|
151
176
|
const schemaCode = flag("--schema") ?? flag("--schema-code") ?? flag("--code");
|
|
152
177
|
const fieldsFile = flag("--fields-file");
|
|
@@ -249,10 +274,10 @@ export async function cmdFieldAdd(args, contextForTest) {
|
|
|
249
274
|
};
|
|
250
275
|
// 零 wire 形状预检(与 model-scaffold 同层防线):dry-run 走本地能力门。
|
|
251
276
|
const preflightProblems = [];
|
|
252
|
-
for (const field of fields) {
|
|
277
|
+
for (const [index, field] of fields.entries()) {
|
|
253
278
|
const probe = await runToolCall("field.create", {
|
|
254
279
|
args: { schemaCode, ...field },
|
|
255
|
-
requestId: request,
|
|
280
|
+
requestId: subRequestId(request, "preflight:field-create", index + 1),
|
|
256
281
|
dryRun: true,
|
|
257
282
|
...(environment !== undefined ? { environment } : {}),
|
|
258
283
|
...(contextForTest !== undefined ? { context: contextForTest } : {}),
|
|
@@ -315,10 +340,12 @@ export async function cmdFieldAdd(args, contextForTest) {
|
|
|
315
340
|
}
|
|
316
341
|
const steps = [];
|
|
317
342
|
const lastSummaries = [];
|
|
318
|
-
|
|
343
|
+
// w53 P1:每个子调用一个派生 requestId(`subRequestId`)。此前共用命令级 id,
|
|
344
|
+
// 第二个 `field.create`(参数不同)被幂等门判成 argsDigestChanged → partial。
|
|
345
|
+
const call = async (tool, toolArgs, index) => {
|
|
319
346
|
const outcome = await runToolCall(tool, {
|
|
320
347
|
args: toolArgs,
|
|
321
|
-
requestId: request,
|
|
348
|
+
requestId: subRequestId(request, tool, index),
|
|
322
349
|
...(environment !== undefined ? { environment } : {}),
|
|
323
350
|
...(contextForTest !== undefined ? { context: contextForTest } : {}),
|
|
324
351
|
print: () => undefined,
|
|
@@ -332,8 +359,8 @@ export async function cmdFieldAdd(args, contextForTest) {
|
|
|
332
359
|
// 1) 建字段:duplicate 记 skipped,其余失败继续跑完(一次看全)。
|
|
333
360
|
const failedFields = [];
|
|
334
361
|
const createdCodes = [];
|
|
335
|
-
for (const field of fields) {
|
|
336
|
-
const outcome = await call("field.create", { schemaCode, ...field });
|
|
362
|
+
for (const [index, field] of fields.entries()) {
|
|
363
|
+
const outcome = await call("field.create", { schemaCode, ...field }, index + 1);
|
|
337
364
|
const message = String(outcome.result.message ?? "");
|
|
338
365
|
if (outcome.ok) {
|
|
339
366
|
steps.push({ step: "field.create", status: "ok", detail: { schemaCode, code: String(field.code) } });
|
|
@@ -410,7 +437,7 @@ export async function cmdFieldAdd(args, contextForTest) {
|
|
|
410
437
|
}
|
|
411
438
|
// 演示数据(--demo-rows):逐行 data.submit;失败记 failed 不阻断(行级独立)。
|
|
412
439
|
for (const [index, row] of (demoRows ?? []).entries()) {
|
|
413
|
-
const submitted = await call("data.submit", { schemaCode, formData: row });
|
|
440
|
+
const submitted = await call("data.submit", { schemaCode, formData: row }, index + 1);
|
|
414
441
|
const readback = submitted.ok ? (submitted.result.readback ?? {}) : {};
|
|
415
442
|
steps.push({
|
|
416
443
|
step: "data.submit",
|
|
@@ -634,6 +634,48 @@ async function readRuleBatchAcrossModels(session, args) {
|
|
|
634
634
|
};
|
|
635
635
|
return body;
|
|
636
636
|
}
|
|
637
|
+
/** 平台 DevelopmentMode:DEFAULT=0(图形编排)、CODING=1、DECISION=2(其余按非 DEFAULT 处理)。 */
|
|
638
|
+
function isDefaultDevelopmentMode(value) {
|
|
639
|
+
if (value === undefined || value === null)
|
|
640
|
+
return true;
|
|
641
|
+
if (typeof value === "number")
|
|
642
|
+
return value === 0;
|
|
643
|
+
const text = String(value).trim().toUpperCase();
|
|
644
|
+
return text === "" || text === "0" || text === "DEFAULT";
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* #77.2:与平台 `BusinessRuleTableImpl.getExecutableBySchemaCodeAndCode:83-103`
|
|
648
|
+
* 同口径——DRAFT 缺失不可执行;非 DEFAULT(CODING/DECISION)平台直接返回 DRAFT
|
|
649
|
+
* (不再看 enabled/status/PUBLISH);DEFAULT 需 DRAFT enabled=true、status 非
|
|
650
|
+
* DISABLED,且至少一条 latestPublished。
|
|
651
|
+
*/
|
|
652
|
+
function ruleExecutableOf(draft, hasPublished) {
|
|
653
|
+
if (draft === undefined)
|
|
654
|
+
return false;
|
|
655
|
+
if (!isDefaultDevelopmentMode(draft.developmentMode))
|
|
656
|
+
return true;
|
|
657
|
+
return draft.enabled === true && String(draft.status ?? "") !== "DISABLED" && hasPublished;
|
|
658
|
+
}
|
|
659
|
+
function ruleExecutableBasisOf(draft, hasPublished) {
|
|
660
|
+
if (draft === undefined)
|
|
661
|
+
return "draft-absent";
|
|
662
|
+
if (!isDefaultDevelopmentMode(draft.developmentMode))
|
|
663
|
+
return "non-default:draft-exists";
|
|
664
|
+
if (draft.enabled !== true)
|
|
665
|
+
return "default:draft-enabled=false";
|
|
666
|
+
if (String(draft.status ?? "") === "DISABLED")
|
|
667
|
+
return "default:draft-status=DISABLED";
|
|
668
|
+
if (!hasPublished)
|
|
669
|
+
return "default:no-latest-published";
|
|
670
|
+
return "default:draft-enabled+status+published";
|
|
671
|
+
}
|
|
672
|
+
/**
|
|
673
|
+
* #77.2:显式 withDraft 才读 app 面 DRAFT 行。该面是
|
|
674
|
+
* `BusinessRuleFacadeImpl.listViewsBySchemaCode:179-186` → `listDraftBySchemaCode`,
|
|
675
|
+
* 与 rule.get 的 id 解析同源;**DRAFT 规则数 < 7 时平台会补建 7 条预置**
|
|
676
|
+
* (同方法 `checkAndFillDefaultBusinessRule`),所以只在显式开关下触发。
|
|
677
|
+
*/
|
|
678
|
+
const RULE_WITH_DRAFT_NOTE = "withDraft 额外读 app/businessrule/list_by_schemacode(DRAFT 行,与 rule.get 同源)。注意:该面在 DRAFT 规则数 <7 时会补建 7 条预置(BusinessRuleFacadeImpl.listViewsBySchemaCode:179-186 → checkAndFillDefaultBusinessRule);显式 withDraft 才触发。executable 按 BusinessRuleTableImpl.getExecutableBySchemaCodeAndCode:83-103:DEFAULT 需 DRAFT enabled=true、status≠DISABLED 且有 latestPublished;CODING/DECISION 只要求 DRAFT 存在。";
|
|
637
679
|
/**
|
|
638
680
|
* r83:单个模型的规则清单体——单模型路径与 `schemaCodes[]` 跨模型路径共用。
|
|
639
681
|
*
|
|
@@ -682,27 +724,77 @@ async function readRuleListBody(session, schemaCode, options) {
|
|
|
682
724
|
// with full:true (the old 14-key row). rule.get resolves by business
|
|
683
725
|
// key (schemaCode+ruleCode), so the row id is rarely needed.
|
|
684
726
|
const fullRows = options.full;
|
|
685
|
-
|
|
686
|
-
|
|
727
|
+
// #77.2:显式 withDraft 才额外读 app 面 DRAFT 行(与 rule.get 同源);
|
|
728
|
+
// 默认路径零额外 wire、零新增键。DRAFT 面在规则数 <7 时会补建预置——见
|
|
729
|
+
// RULE_WITH_DRAFT_NOTE,只有显式开关才付出这个代价。
|
|
730
|
+
const draftRows = options.withDraft
|
|
731
|
+
? wireRows((await wireCall(session, { path: ENDPOINTS.businessRuleListBySchemaCode, query: { schemaCode } })).data)
|
|
732
|
+
: undefined;
|
|
733
|
+
const draftByCode = new Map();
|
|
734
|
+
for (const draft of draftRows ?? [])
|
|
735
|
+
if (typeof draft.code === "string" && draft.code !== "")
|
|
736
|
+
draftByCode.set(draft.code, draft);
|
|
737
|
+
const visiblePublished = options.onlyCustom ? rows.filter((row) => row.defaultRule !== true) : rows;
|
|
738
|
+
const statusLag = visiblePublished.some((row) => row.enabled === true && String(row.status ?? "") !== "ENABLED");
|
|
739
|
+
const publishedCodes = new Set(rows.map((row) => String(row.code ?? "")));
|
|
740
|
+
const entries = visiblePublished.map((row) => {
|
|
741
|
+
const draft = draftByCode.get(String(row.code ?? ""));
|
|
742
|
+
return draft ? { row, draft } : { row };
|
|
743
|
+
});
|
|
744
|
+
for (const draft of draftRows ?? []) {
|
|
745
|
+
const code = String(draft.code ?? "");
|
|
746
|
+
if (code === "" || publishedCodes.has(code))
|
|
747
|
+
continue;
|
|
748
|
+
if (options.onlyCustom && draft.defaultRule === true)
|
|
749
|
+
continue;
|
|
750
|
+
entries.push({ draft });
|
|
751
|
+
}
|
|
752
|
+
const visible = entries.map((entry) => entry.row).filter((row) => row !== undefined);
|
|
687
753
|
// r83:withMappings 只在显式开启时读;默认路径零额外 wire、零新增键。
|
|
688
754
|
const mappingFace = options.withMappings ? await readRuleListMappings(session, visible) : undefined;
|
|
689
|
-
const mappingOf = (
|
|
755
|
+
const mappingOf = (entry) => {
|
|
690
756
|
if (mappingFace === undefined)
|
|
691
757
|
return {};
|
|
692
|
-
|
|
758
|
+
if (entry.row === undefined)
|
|
759
|
+
return { mappingsUnavailable: true };
|
|
760
|
+
const found = mappingFace.byCode.get(typeof entry.row.code === "string" ? entry.row.code : "");
|
|
693
761
|
// 读不到 ≠ 没有映射:显式标注不可用,避免把读取失败当成空映射。
|
|
694
762
|
if (found === undefined || found === null)
|
|
695
763
|
return { mappingsUnavailable: true };
|
|
696
764
|
return { mappings: found };
|
|
697
765
|
};
|
|
766
|
+
const draftFaceOf = (entry) => {
|
|
767
|
+
const { row, draft } = entry;
|
|
768
|
+
if (row === undefined) {
|
|
769
|
+
// 无 PUBLISH 投影:enabled/status 在两个面上都读不到,保持 null(不编造)。
|
|
770
|
+
return {
|
|
771
|
+
publishEnabled: null,
|
|
772
|
+
draftEnabled: draft?.enabled === true,
|
|
773
|
+
draftStatus: draft?.status == null ? null : String(draft.status),
|
|
774
|
+
executable: ruleExecutableOf(draft, false),
|
|
775
|
+
executableBasis: ruleExecutableBasisOf(draft, false),
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
const hasPublished = row.latestPublished === true;
|
|
779
|
+
return {
|
|
780
|
+
publishEnabled: row.enabled === true,
|
|
781
|
+
draftEnabled: draft === undefined ? null : draft.enabled === true,
|
|
782
|
+
draftStatus: draft === undefined ? null : draft.status == null ? null : String(draft.status),
|
|
783
|
+
executable: ruleExecutableOf(draft, hasPublished),
|
|
784
|
+
executableBasis: ruleExecutableBasisOf(draft, hasPublished),
|
|
785
|
+
};
|
|
786
|
+
};
|
|
698
787
|
return {
|
|
699
788
|
schemaCode,
|
|
700
789
|
modelPresent: true,
|
|
701
790
|
// r83:rulesCount 在 handler 层回(此前只有 compact 投影从 rules 派生,导致
|
|
702
791
|
// schemaCodes[] 跨模型面的 models[] 元素缺该键,与 read-shapes「同形」承诺不符)。
|
|
703
|
-
rulesCount:
|
|
792
|
+
rulesCount: entries.length,
|
|
704
793
|
// r28g F18:list 投影的是 PUBLISH 行;运行时可执行性以 rule.get / rule.enable.verified 为准。
|
|
705
|
-
source: "published-list",
|
|
794
|
+
source: options.withDraft ? "published-list+draft" : "published-list",
|
|
795
|
+
...(options.withDraft
|
|
796
|
+
? { draftFace: "app/businessrule/list_by_schemacode", draftRowsCount: draftRows?.length ?? 0, draftNote: RULE_WITH_DRAFT_NOTE }
|
|
797
|
+
: {}),
|
|
706
798
|
executableHint: "rules[].enabled/status 来自 PUBLISH 投影;运行时判定读 DRAFT(rule.get 的 enabled+ruleStatus,或 rule.enable 回执的 executable/verified)。不要仅凭本面判定可 rule.run。",
|
|
707
799
|
...(statusLag
|
|
708
800
|
? {
|
|
@@ -716,18 +808,18 @@ async function readRuleListBody(session, schemaCode, options) {
|
|
|
716
808
|
// 常态化给一句短注(~90B/次),避免把本面 status 当运行时真相。
|
|
717
809
|
statusNote: "本面 status 是 PUBLISH 投影列,与 rule.get 的 ruleStatus 可不同;运行时是否生效以 rule.get/enable 为准",
|
|
718
810
|
}),
|
|
719
|
-
...(options.onlyCustom ? { filtered: { onlyCustom: true, total: rows.length, returned:
|
|
811
|
+
...(options.onlyCustom ? { filtered: { onlyCustom: true, total: rows.length + (entries.length - visiblePublished.length), returned: entries.length } } : {}),
|
|
720
812
|
// r60c-F7(真机复现):默认面把 7 条平台预置触发行一起返回——任何模型都
|
|
721
813
|
// 「有规则」,「哪些模型配了业务规则」会误判成全都有。默认面带上
|
|
722
814
|
// customCount + 一句判定口径;判定自建规则直接 onlyCustom:true。
|
|
723
815
|
...(options.onlyCustom
|
|
724
816
|
? {}
|
|
725
817
|
: {
|
|
726
|
-
customCount:
|
|
818
|
+
customCount: entries.filter((entry) => (entry.row?.defaultRule ?? entry.draft?.defaultRule) !== true).length,
|
|
727
819
|
// F5(探针 AA,0.8.36):2.1.5 新建模型本面 **0 行**(预置行尚未物化/
|
|
728
820
|
// 发布;8.6 建模即建)。旧文案无条件说「默认含平台预置触发行」,在 0
|
|
729
821
|
// 行面上自相矛盾,会被读成「没有触发器」。
|
|
730
|
-
presetHint:
|
|
822
|
+
presetHint: entries.length === 0
|
|
731
823
|
? "本面 0 条:平台尚未物化/发布预置行(2.1.5 新建模型为空,8.6 建模即建);不要据此判定没有触发器——用 rule.references kind:\"trigger\" 看真实触发点"
|
|
732
824
|
: "默认含平台预置触发行(preset:true,如 Available/Cancel/Create/Delete/GetList/Load/Update);判定「有没有人写过规则」看 customCount(=0 即全是预置),或直接 onlyCustom:true",
|
|
733
825
|
}),
|
|
@@ -735,35 +827,42 @@ async function readRuleListBody(session, schemaCode, options) {
|
|
|
735
827
|
...(mappingFace
|
|
736
828
|
? { mappingsWireNote: `mappings 来自规则行 node(摘要:服务/方法/入出参计数;正文在 rule.get)${mappingFace.fallbackReads > 0 ? `;${mappingFace.fallbackReads} 条 list 行缺 node 已回落 businessrule/get(+${mappingFace.fallbackReads} wire)` : ";无回落 get"}` }
|
|
737
829
|
: {}),
|
|
738
|
-
rules:
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
830
|
+
rules: entries.map((entry) => {
|
|
831
|
+
const { row, draft } = entry;
|
|
832
|
+
const record = row ?? draft ?? {};
|
|
833
|
+
const defaultRule = row?.defaultRule ?? draft?.defaultRule;
|
|
834
|
+
return {
|
|
835
|
+
code: record.code,
|
|
836
|
+
name: record.name,
|
|
837
|
+
enabled: row === undefined ? null : row.enabled,
|
|
838
|
+
status: row === undefined ? null : row.status,
|
|
839
|
+
...(row?.enabled === true && String(row.status ?? "") !== "ENABLED" ? { statusLag: true } : {}),
|
|
840
|
+
...(record.ruleVersion !== undefined ? { ruleVersion: record.ruleVersion } : {}),
|
|
841
|
+
...(defaultRule !== undefined ? { defaultRule, preset: defaultRule === true } : {}),
|
|
842
|
+
// ticket-80's update-mode readback teaches following the same-code
|
|
843
|
+
// latestPublished row — keep the flag on the default face (5 B).
|
|
844
|
+
...(row?.latestPublished !== undefined ? { latestPublished: row.latestPublished } : {}),
|
|
845
|
+
...(options.withDraft ? draftFaceOf(entry) : {}),
|
|
846
|
+
...(options.withDraft && row === undefined ? { draftOnly: true } : {}),
|
|
847
|
+
...(fullRows
|
|
848
|
+
? {
|
|
849
|
+
id: record.id,
|
|
850
|
+
schemaCode: record.schemaCode,
|
|
851
|
+
bizRuleType: record.bizRuleType,
|
|
852
|
+
developmentMode: record.developmentMode,
|
|
853
|
+
latestPublished: record.latestPublished,
|
|
854
|
+
templateType: record.templateType,
|
|
855
|
+
createdTime: record.createdTime,
|
|
856
|
+
creator: record.creater ?? record.creator,
|
|
857
|
+
}
|
|
858
|
+
// 内部面(T02b 调度摘要):行 id 让调用方直接读 businessrule/get,
|
|
859
|
+
// 省掉逐条 `resolveRuleRowId` 的二次 list。对外读面形状不变。
|
|
860
|
+
: options.withRowIds === true && typeof record.id === "string" && record.id !== ""
|
|
861
|
+
? { id: record.id }
|
|
862
|
+
: {}),
|
|
863
|
+
...mappingOf(entry),
|
|
864
|
+
};
|
|
865
|
+
}),
|
|
767
866
|
};
|
|
768
867
|
}
|
|
769
868
|
/**
|
|
@@ -1213,9 +1312,10 @@ export function registerBusinessRuleLane(tools) {
|
|
|
1213
1312
|
environment: environmentArg,
|
|
1214
1313
|
schemaCode: z.string().min(1),
|
|
1215
1314
|
schemaCodes: z.array(z.string()).optional().describe("跨模型清单(≤20;失败回 partial+failed)"),
|
|
1216
|
-
onlyCustom: z.boolean().optional().describe("只回自建规则(defaultRule!==true
|
|
1217
|
-
full: z.boolean().optional().describe("行内联完整字段(id/createdTime/creator
|
|
1315
|
+
onlyCustom: z.boolean().optional().describe("只回自建规则(defaultRule!==true)——读面收窄,省 token"),
|
|
1316
|
+
full: z.boolean().optional().describe("行内联完整字段(id/createdTime/creator/…)并跳过 detailFile 外置"),
|
|
1218
1317
|
withMappings: z.boolean().optional().describe("true=规则附 mappings 摘要(服务/方法/入出参计数)"),
|
|
1318
|
+
withDraft: z.boolean().optional().describe("true=额外读 DRAFT 面(app/businessrule/list_by_schemacode,+1 wire)并按 code 合并:逐行 publishEnabled/draftEnabled/draftStatus/executable/executableBasis,含禁用/未发布草稿行;规则<7 条时平台可能补建 7 条预置(回执 draftNote 披露)。默认 false 不变"),
|
|
1219
1319
|
capability: capabilityArg,
|
|
1220
1320
|
},
|
|
1221
1321
|
handler: async (ctx, args, self) => governedRead(ctx, self, args, async (session) => {
|
|
@@ -1230,7 +1330,7 @@ export function registerBusinessRuleLane(tools) {
|
|
|
1230
1330
|
const schemaCodes = ruleSchemaCodesOf(args.schemaCodes, "rule.list");
|
|
1231
1331
|
const models = [];
|
|
1232
1332
|
const failed = [];
|
|
1233
|
-
const options = { onlyCustom: args.onlyCustom === true, full: args.full === true, withMappings: args.withMappings === true };
|
|
1333
|
+
const options = { onlyCustom: args.onlyCustom === true, full: args.full === true, withMappings: args.withMappings === true, withDraft: args.withDraft === true };
|
|
1234
1334
|
let firstError;
|
|
1235
1335
|
let rulesCount = 0;
|
|
1236
1336
|
// r83:三句提示(executableHint/statusNote/presetHint)逐模型逐字相同,
|
|
@@ -1240,7 +1340,7 @@ export function registerBusinessRuleLane(tools) {
|
|
|
1240
1340
|
// 所有模型都存在且内容全等才抬**;否则保留逐模型(否则 0 行模型的「0 条」
|
|
1241
1341
|
// 文案会被 8.6 模型抬走的通用文案覆盖,结论错)。
|
|
1242
1342
|
const hoisted = {};
|
|
1243
|
-
const HOIST_KEYS = ["executableHint", "statusNote", "presetHint"];
|
|
1343
|
+
const HOIST_KEYS = ["executableHint", "statusNote", "presetHint", "draftNote"];
|
|
1244
1344
|
const bodies = [];
|
|
1245
1345
|
for (const schemaCode of schemaCodes) {
|
|
1246
1346
|
try {
|
|
@@ -1283,7 +1383,7 @@ export function registerBusinessRuleLane(tools) {
|
|
|
1283
1383
|
}
|
|
1284
1384
|
if (singleSchemaCode === undefined)
|
|
1285
1385
|
throw new ToolInputError({ status: "error", blocker: "tool-input-invalid", tool: "rule.list", message: "需要 schemaCode(单个模型)或 schemaCodes(跨模型清单)" });
|
|
1286
|
-
return readRuleListBody(session, singleSchemaCode, { onlyCustom: args.onlyCustom === true, full: args.full === true, withMappings: args.withMappings === true });
|
|
1386
|
+
return readRuleListBody(session, singleSchemaCode, { onlyCustom: args.onlyCustom === true, full: args.full === true, withMappings: args.withMappings === true, withDraft: args.withDraft === true });
|
|
1287
1387
|
}, { full: args.full === true, target: `rule.list:${args.schemaCodes !== undefined ? `schemaCodes:${args.schemaCodes.join(",")}` : args.schemaCode}` }),
|
|
1288
1388
|
}));
|
|
1289
1389
|
tools.push(defineTool({
|
|
@@ -1457,7 +1557,7 @@ export function registerBusinessRuleLane(tools) {
|
|
|
1457
1557
|
scanned: { models: scoped.length, workflows: scannedWorkflows, withoutWorkflow, ...(readFailures > 0 ? { readFailures } : {}) },
|
|
1458
1558
|
matches: ruleHits,
|
|
1459
1559
|
wire: {
|
|
1460
|
-
plan: "1 模型清单 + 每模型
|
|
1560
|
+
plan: "1 模型清单 + 每模型 workflow/list(header 含草稿/多流程)→ 有流程再 get_published",
|
|
1461
1561
|
concurrency: scan.stats,
|
|
1462
1562
|
},
|
|
1463
1563
|
coverage: {
|
|
@@ -13,20 +13,20 @@ export const RULE_ENABLE_CHAIN = Object.freeze({
|
|
|
13
13
|
enable: "enable 以 {schemaCode, ruleCode} 翻转 DRAFT 行的启用开关",
|
|
14
14
|
dispatch: "运行时分发读的是 DRAFT 行 enabled + 最新 PUBLISH 内容(getExecutableBySchemaCodeAndCode)",
|
|
15
15
|
conclusion: "只 publish 不 enable 时规则静默不生效",
|
|
16
|
-
readbackRule: "
|
|
16
|
+
readbackRule: "读回以平台 `enabled` 字段为准,勿由 `status` 推断。",
|
|
17
17
|
idempotentErrcode: 550014,
|
|
18
18
|
});
|
|
19
19
|
export const RULE_SCHEMA_GATE = Object.freeze({
|
|
20
20
|
probe: "bizmodels/get_all (GET ?schemaCode) — BizSchemaController.java:615-633, miss answers SCHEMA_NOT_FOUNT_ERR 10011 业务模型不存在",
|
|
21
|
-
reason: "list_by_schemacode 对任意 schemaCode 自动补建 7
|
|
22
|
-
presetDelete: "预置 ruleCode(Create/Update/Delete/GetList/Load/Available/Cancel)删除不可达:list
|
|
21
|
+
reason: "list_by_schemacode 对任意 schemaCode 自动补建 7 条预置并 publish(BusinessRuleFacadeImpl.listViewsBySchemaCode:179-185;不校验模型存在)——幻影 schema 会留下 API 删不掉的预置行,故 rule.save/enable/disable/delete 写前先探模型,缺失即 refused `rule-schema-unresolved`",
|
|
22
|
+
presetDelete: "预置 ruleCode(Create/Update/Delete/GetList/Load/Available/Cancel)删除不可达:list 自动重灌缺失预置,下次 list 复活并增殖版本行——rule.delete 对预置 code 直接 refused `rule-preset-delete-unreachable`",
|
|
23
23
|
});
|
|
24
24
|
export function ruleEnableDescription() {
|
|
25
25
|
const chain = RULE_ENABLE_CHAIN;
|
|
26
26
|
return `启用业务规则(businessrule/publish + businessrule/enable)。两步缺一不可:${chain.publish},${chain.enable}——${chain.dispatch},${chain.conclusion}。${chain.readbackRule}。${RULE_SCHEMA_GATE.reason}。`;
|
|
27
27
|
}
|
|
28
28
|
export function ruleDisableDescription() {
|
|
29
|
-
return `停用业务规则(businessrule/update
|
|
29
|
+
return `停用业务规则(businessrule/update:整行 + \`enabled:false\`)。\`keepEnabled:true\` 改走 businessrule/disable:只置 DRAFT status=DISABLED、enabled 保持 true(仍列在 rule.list,运行时判不可执行)。${RULE_ENABLE_CHAIN.readbackRule}${RULE_SCHEMA_GATE.reason}。`;
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
32
|
* Manual execution of a CUSTOM-trigger rule — the SAME face the portal's
|
|
@@ -50,6 +50,7 @@ export const RULE_LIFECYCLE_LANE_CONTRACT = Object.freeze({
|
|
|
50
50
|
list: "businessRuleListBySchemaCode",
|
|
51
51
|
publish: "businessRulePublish",
|
|
52
52
|
enable: "businessRuleEnable",
|
|
53
|
+
disable: "businessRuleDisable",
|
|
53
54
|
update: "businessRuleUpdate",
|
|
54
55
|
delete: "businessRuleDelete",
|
|
55
56
|
run: "ruleRuntimeExecuteBase",
|
|
@@ -7,7 +7,7 @@ import { executeRuleSaveWrite, ruleNodeGraphArg, assertRuleSchemaExists, explain
|
|
|
7
7
|
import { decodeJsonColumn, JSON_COLUMN_NULL_COALESCE } from "../json-column.js";
|
|
8
8
|
import { ToolRefusalError } from "../tool-types.js";
|
|
9
9
|
import { prepareRuleGraph, validateRuleNodeGraph, PLATFORM_TRIGGER_RULE_CODES } from "./rule-graph.js";
|
|
10
|
-
import { wireCall, wireRows, WireError } from "../wire.js";
|
|
10
|
+
import { wireCall, wireCallWith404Fallback, wireRows, WireError } from "../wire.js";
|
|
11
11
|
import { currentUsageArgsDigest, priorIdenticalSuccess } from "../usage-log.js";
|
|
12
12
|
import { RULE_ENABLE_CHAIN, RULE_LIFECYCLE_LANE_CONTRACT } from "./rule-lifecycle-contract.js";
|
|
13
13
|
/**
|
|
@@ -23,6 +23,127 @@ function ruleRuntimeExecutePath(schemaCode, ruleCode) {
|
|
|
23
23
|
}
|
|
24
24
|
const RULE_LIFECYCLE_LANE = RULE_LIFECYCLE_LANE_CONTRACT.lane;
|
|
25
25
|
const RULE_LIFECYCLE_TOOLS = RULE_LIFECYCLE_LANE_CONTRACT.tools;
|
|
26
|
+
/**
|
|
27
|
+
* #77.3:`rule.disable --keepEnabled` 的逆操作说明。平台 `/enable` 的
|
|
28
|
+
* 投影逆操作(DRAFT status 回 ENABLED)在 CLI 里没有不发布版本的等价端点;
|
|
29
|
+
* rule.enable 会重新 publish 出新 version/id——所以不能拿它当逆操作。
|
|
30
|
+
*/
|
|
31
|
+
const KEEP_ENABLED_ROLLBACK_NOTE = "keepEnabled 只把 DRAFT status 置 DISABLED(enabled 保持 true)。逆操作要把 DRAFT status 置回 ENABLED:rollback 只能还原这一层投影,不能还原 rule version/id;不要用 rule.enable 当逆操作(它会重新 publish,产生新版本/新 id)";
|
|
32
|
+
function isTimingRule(row) {
|
|
33
|
+
// BizRuleType.TIMING_TASK=2(BizRuleType.java:12,@JsonValue 走 int)。
|
|
34
|
+
return row.bizRuleType === 2 || row.bizRuleType === "2" || String(row.bizRuleType ?? "").toUpperCase() === "TIMING_TASK";
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* #77.3:timing 规则由平台 `/disable` → `changeStatus` 置 DRAFT status 并
|
|
38
|
+
* `pauseJob`(BusinessRuleServiceImpl.changeStatus:1068-1081),但最新 PUBLISH
|
|
39
|
+
* 行的 status 仍停在 ENABLED,`rule.list` 会继续报「启用」。这里把最新 PUBLISH
|
|
40
|
+
* 行的 status 镜像成 DISABLED(enabled 不动)——失败不回滚已完成的核心停用,
|
|
41
|
+
* 在 readback.publishMirror 里点名。
|
|
42
|
+
*
|
|
43
|
+
* **需真机采样(2.1.7)**:PUBLISH 行 status 镜像目前只有 fake harness 证据;
|
|
44
|
+
* 真机上 `businessrule/get` 出 PUBLISH 行后回写 `businessrule/update` 是否
|
|
45
|
+
* 逐字保留 templateType/latestPublished、以及 timing 调度器是否只认 DRAFT
|
|
46
|
+
* status,都需要在 2.1.7 真机回放确认(见回执 publishMirror.evidence)。
|
|
47
|
+
*/
|
|
48
|
+
async function mirrorLatestPublishedStatus(session, schemaCode, ruleCode) {
|
|
49
|
+
try {
|
|
50
|
+
const published = wireRows((await wireCallWith404Fallback(session, [
|
|
51
|
+
{ path: ENDPOINTS.runtimeBusinessRuleListBySchemaCode, query: { schemaCode } },
|
|
52
|
+
{ path: ENDPOINTS.businessRuleListBySchemaCode, query: { schemaCode } },
|
|
53
|
+
], () => { })).data).filter((row) => String(row.code ?? "") === ruleCode);
|
|
54
|
+
const latest = published.find((row) => row.latestPublished !== false) ?? published[0];
|
|
55
|
+
if (!latest?.id)
|
|
56
|
+
return { skipped: "no-published-row" };
|
|
57
|
+
if (String(latest.status ?? "") === "DISABLED")
|
|
58
|
+
return { alreadyDisabled: true, id: String(latest.id), pauseJob: "platform-changeStatus" };
|
|
59
|
+
const full = (await wireCall(session, { path: ENDPOINTS.businessRuleGet, query: { id: String(latest.id) } })).data;
|
|
60
|
+
if (!full)
|
|
61
|
+
return { skipped: "published-model-unreadable", id: String(latest.id) };
|
|
62
|
+
await wireCall(session, { path: ENDPOINTS.businessRuleUpdate, method: "POST", body: { ...full, status: "DISABLED" } });
|
|
63
|
+
return { status: "DISABLED", id: String(latest.id), enabled: full.enabled === true, pauseJob: "platform-changeStatus" };
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
return { failed: true, message: error instanceof Error ? error.message : String(error) };
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* #77.3:`rule.disable --keepEnabled`——只停可执行位,不把 enabled 翻 false。
|
|
71
|
+
* 平台 `BusinessRuleController.disable:478-506` 只 changeStatus DRAFT 为
|
|
72
|
+
* DISABLED(BusinessRuleServiceImpl.changeStatus:1068-1081);timing 规则同时
|
|
73
|
+
* pauseJob。enabled 保持 true,所以 `rule.list`(runtime 面按 DRAFT enabled
|
|
74
|
+
* 过滤,BusinessRuleServiceImpl.listPublishedRulesBySchemaCode:155-173)不会
|
|
75
|
+
* 把规则藏掉,而 `getExecutableBySchemaCodeAndCode:83-103` 因 status=DISABLED
|
|
76
|
+
* 判不可执行——正是「还原 enabled=true/status=DISABLED」所需的态。
|
|
77
|
+
*/
|
|
78
|
+
async function disableRuleKeepEnabled(session, args, row) {
|
|
79
|
+
const beforeEnabled = row.enabled === true;
|
|
80
|
+
const alreadyDisabled = String(row.status ?? "") === "DISABLED";
|
|
81
|
+
let performed;
|
|
82
|
+
if (alreadyDisabled) {
|
|
83
|
+
performed = { errcode: 0, alreadyDisabled: true, noop: true };
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
try {
|
|
87
|
+
const response = await wireCall(session, {
|
|
88
|
+
path: ENDPOINTS.businessRuleDisable,
|
|
89
|
+
method: "POST",
|
|
90
|
+
body: { schemaCode: args.schemaCode, ruleCode: args.ruleCode },
|
|
91
|
+
});
|
|
92
|
+
performed = { errcode: response.errcode };
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
// 55035 = BUSINESS_RULE_ALREADY_DISABLED(ErrorCode.java:987):并发/残留时按幂等成功处理。
|
|
96
|
+
if (error instanceof WireError && error.kind === "business" && error.errcode === 55035)
|
|
97
|
+
performed = { errcode: 0, alreadyDisabled: true };
|
|
98
|
+
else
|
|
99
|
+
throw error;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const afterRows = wireRows((await wireCall(session, { path: ENDPOINTS.businessRuleListBySchemaCode, query: { schemaCode: args.schemaCode } })).data);
|
|
103
|
+
const after = afterRows.find((item) => String(item.code ?? "") === args.ruleCode);
|
|
104
|
+
let draft = null;
|
|
105
|
+
try {
|
|
106
|
+
if (after?.id)
|
|
107
|
+
draft = (await wireCall(session, { path: ENDPOINTS.businessRuleGet, query: { id: String(after.id) } })).data;
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
draft = null;
|
|
111
|
+
}
|
|
112
|
+
// bizRuleType 以 get 面为准(部分版本 list 投影不带该列);timing 规则平台
|
|
113
|
+
// 已 pauseJob,这里只补 PUBLISH 行 status 的镜像。
|
|
114
|
+
const publishMirror = isTimingRule(draft ?? row) ? await mirrorLatestPublishedStatus(session, args.schemaCode, args.ruleCode) : undefined;
|
|
115
|
+
const draftEnabled = draft ? draft.enabled === true : after?.enabled === true;
|
|
116
|
+
const draftStatus = draft?.status == null ? (after?.status == null ? null : String(after.status)) : String(draft.status);
|
|
117
|
+
return {
|
|
118
|
+
performed,
|
|
119
|
+
readback: {
|
|
120
|
+
enabled: draftEnabled,
|
|
121
|
+
draftEnabled,
|
|
122
|
+
draftStatus,
|
|
123
|
+
// 本操作不改 enabled:true 表示读回与写前一致(不是「规则仍可执行」)。
|
|
124
|
+
enabledPreserved: draftEnabled === beforeEnabled,
|
|
125
|
+
executable: false,
|
|
126
|
+
executableBasis: "draft-status:disabled",
|
|
127
|
+
// 平台没有不发布版本的 status 逆操作端点:rollback 只能人工把 DRAFT
|
|
128
|
+
// status 置回 ENABLED;rule.enable 会重新 publish(version/id 变)。
|
|
129
|
+
rollbackExecutable: false,
|
|
130
|
+
rollbackReason: KEEP_ENABLED_ROLLBACK_NOTE,
|
|
131
|
+
...(alreadyDisabled ? { alreadyDisabled: true } : {}),
|
|
132
|
+
...(publishMirror
|
|
133
|
+
? {
|
|
134
|
+
publishMirror: {
|
|
135
|
+
...publishMirror,
|
|
136
|
+
evidence: "fake-only",
|
|
137
|
+
evidenceNote: "timing PUBLISH status 镜像目前只有 fake 证据,需真机采样(2.1.7)",
|
|
138
|
+
},
|
|
139
|
+
}
|
|
140
|
+
: {}),
|
|
141
|
+
source: "draft-get+app-list",
|
|
142
|
+
effectHint: "keepEnabled:true 只置 DRAFT status=DISABLED(enabled 保持 true)——rule.list 仍列出该规则,但运行时 getExecutableBySchemaCodeAndCode 判不可执行;恢复启用需把 DRAFT status 置回 ENABLED(rule.enable 会重新 publish,version/id 会变)",
|
|
143
|
+
rollbackNote: KEEP_ENABLED_ROLLBACK_NOTE,
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
}
|
|
26
147
|
function lifecycleRollbackSpec(toolName) {
|
|
27
148
|
return {
|
|
28
149
|
target: (args) => `rule:${String(args.schemaCode ?? "")}/${String(args.ruleCode ?? "")}`,
|
|
@@ -41,8 +162,14 @@ function lifecycleRollbackSpec(toolName) {
|
|
|
41
162
|
return { kind: "calls", calls: [] };
|
|
42
163
|
if (toolName === "rule.enable")
|
|
43
164
|
return { kind: "calls", calls: [{ tool: "rule.disable", args: base }] };
|
|
44
|
-
if (toolName === "rule.disable")
|
|
165
|
+
if (toolName === "rule.disable") {
|
|
166
|
+
// #77.3:keepEnabled 的逆操作不能是 rule.enable(会重新 publish 新版本/id)。
|
|
167
|
+
// 平台也没有「只把 status 置回 ENABLED」的端点 → 显式 irreversible,
|
|
168
|
+
// 不让空 calls 被读成「rollback 可执行」。
|
|
169
|
+
if (args.keepEnabled === true)
|
|
170
|
+
return { kind: "irreversible", reason: KEEP_ENABLED_ROLLBACK_NOTE };
|
|
45
171
|
return { kind: "calls", calls: [{ tool: "rule.enable", args: base }] };
|
|
172
|
+
}
|
|
46
173
|
const row = before;
|
|
47
174
|
return { kind: "calls", calls: [{ tool: "rule.save", args: { ...base, name: String(row.name ?? args.ruleCode), nodeGraph: { nodes: row.node, routes: row.route, schedulerSetting: row.schedulerSetting } } }], notes: ["删除后重建的规则 id/版本不保证一致"] };
|
|
48
175
|
},
|
|
@@ -218,13 +345,19 @@ export function registerRuleLifecycleLane(tools) {
|
|
|
218
345
|
lane: RULE_LIFECYCLE_LANE,
|
|
219
346
|
scope: RULE_LIFECYCLE_TOOLS["rule.disable"].scope,
|
|
220
347
|
description: RULE_LIFECYCLE_TOOLS["rule.disable"].description,
|
|
221
|
-
inputSchema: {
|
|
348
|
+
inputSchema: {
|
|
349
|
+
schemaCode: z.string().min(1),
|
|
350
|
+
ruleCode: z.string().min(1),
|
|
351
|
+
keepEnabled: z.boolean().optional().describe("true=只停可执行位:businessrule/disable 仅置 DRAFT status=DISABLED,enabled 保持 true(规则仍在 rule.list;timing 同时 pauseJob);默认 false 用 update 改 enabled"),
|
|
352
|
+
},
|
|
222
353
|
execute: async (session, args) => {
|
|
223
354
|
await assertRuleSchemaExists(session, args.schemaCode);
|
|
224
355
|
const list = await wireCall(session, { path: ENDPOINTS.businessRuleListBySchemaCode, query: { schemaCode: args.schemaCode } });
|
|
225
356
|
const row = wireRows(list.data).find((item) => item.code === args.ruleCode);
|
|
226
357
|
if (!row?.id)
|
|
227
358
|
throw new WireError("business", `rule ${args.ruleCode} not found for disable`, 302024);
|
|
359
|
+
if (args.keepEnabled === true)
|
|
360
|
+
return disableRuleKeepEnabled(session, args, row);
|
|
228
361
|
// r28g F22/F24 真机(1.1.25,2026-11-05):`businessrule/disable` 只把 DRAFT
|
|
229
362
|
// 行的 status 置 DISABLED,**不翻 enabled**——随后 list 仍报 enabled:true/
|
|
230
363
|
// ENABLED,get 报 enabled:true+ruleStatus:DISABLED+statusLag,enable 误报
|