@stalfh233/omc-cli 0.6.85 → 0.6.87
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/README.md +3 -2
- package/dist/batch-executor.js +236 -0
- package/dist/capability-overview.js +2 -2
- package/dist/cli.js +21 -3
- package/dist/discovery.js +50 -1
- package/dist/endpoints.js +16 -0
- package/dist/goal-plan.js +12 -0
- package/dist/goal-routes.js +20 -1
- package/dist/intent/capabilities/bizservice.js +507 -108
- package/dist/intent/cli.js +1 -1
- package/dist/intent/compiler.js +11 -4
- package/dist/intent/plan-apply.js +22 -5
- package/dist/intent/plan-file.js +1 -0
- package/dist/intent/readback.js +78 -1
- package/dist/intent/schema.js +1 -1
- package/dist/lanes/apply-changes.js +134 -252
- package/dist/lanes/b2-registration.js +61 -5
- package/dist/lanes/businessrule.js +8 -3
- package/dist/lanes/config-diff.js +9 -0
- package/dist/lanes/rule-lifecycle.js +37 -4
- package/dist/lanes/runtime-data-contract.js +2 -1
- package/dist/lanes/runtime-data.js +344 -107
- package/dist/lanes/runtime-paging.js +100 -0
- package/dist/package.js +8 -2
- package/dist/read-shapes.js +29 -10
- package/dist/recipes/b2-registration.js +1 -1
- package/dist/rollback.js +71 -20
- package/dist/rule-support.js +43 -1
- package/dist/service-support.js +57 -0
- package/dist/surface-ref.js +37 -0
- package/dist/write.js +5 -1
- package/docs/omc-introduction.md +1 -0
- package/package.json +3 -3
- package/skills/omc-capabilities.md +1 -0
|
@@ -1,35 +1,12 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { randomUUID } from "node:crypto";
|
|
3
|
-
import { basename } from "node:path";
|
|
4
2
|
import { confirmProductionArg, environmentArg, WRITE_PROTOCOL } from "../args.js";
|
|
5
3
|
import { executePackage } from "../package.js";
|
|
6
4
|
import { plannableArgs } from "../plan.js";
|
|
7
|
-
import { isUncertainWireError, wireErrorKind, writeArtifact } from "../support.js";
|
|
8
5
|
import { defineTool, parseToolInput, ToolInputError, ToolRefusalError } from "../tool-types.js";
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
* Ticket 58: the batch time budget. `startedAt` is the execution start (ms
|
|
14
|
-
* epoch); `budgetMs` undefined means no budget. Exported so the arithmetic is
|
|
15
|
-
* pinned by a unit test instead of a timing-sensitive S1 test.
|
|
16
|
-
*/
|
|
17
|
-
export function batchBudgetExceeded(startedAt, budgetMs, now) {
|
|
18
|
-
if (budgetMs === undefined)
|
|
19
|
-
return false;
|
|
20
|
-
return now - startedAt >= budgetMs;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* The default whole-batch time budget (8 minutes), applied when the caller
|
|
24
|
-
* omits `totalTimeoutMs`. It MUST stay safely below the CLI's own call timeout:
|
|
25
|
-
* the omc CLI caps `--timeout-ms` at 600000 ms (10 min), and the 2026-09-14
|
|
26
|
-
* `eq_repair_record` incident was exactly the failure mode of a batch that
|
|
27
|
-
* outlives its caller — the caller abandoned at its timeout while the batch
|
|
28
|
-
* kept executing, and the agent's retry became a second writer in the same
|
|
29
|
-
* environment. Stopping at a bounded budget returns a clean `uncertain` +
|
|
30
|
-
* progressFile + resumeFromIndex while the caller is still listening.
|
|
31
|
-
*/
|
|
32
|
-
export const DEFAULT_BATCH_BUDGET_MS = 8 * 60 * 1000;
|
|
6
|
+
import { appendBatchAuditLine, executeGovernedBatch } from "../batch-executor.js";
|
|
7
|
+
// Ticket 58 的预算算术/缺省值自 B1 起住在共享执行器里;此处 re-export 保持
|
|
8
|
+
// 既有测试导入路径(apply-changes-progress.test)不变。
|
|
9
|
+
export { batchBudgetExceeded, DEFAULT_BATCH_BUDGET_MS } from "../batch-executor.js";
|
|
33
10
|
function refuseBatch(blocker, message, extra = {}) {
|
|
34
11
|
return { status: "refused", blocker, message, ...extra };
|
|
35
12
|
}
|
|
@@ -59,240 +36,145 @@ export function registerApplyChangesLane(tools) {
|
|
|
59
36
|
// lint 尚未在批量预览里执行——如实声明,不能读成「整批可执行」。
|
|
60
37
|
lintScope: "partial",
|
|
61
38
|
lintUnchecked: ["batch-step-session-lint", "local-write-gates", "platform-side-validation", "post-write-readback"],
|
|
62
|
-
handler: async (ctx, args) =>
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
envelope: {
|
|
150
|
-
blocker: "batch-timeout-budget",
|
|
151
|
-
frozen: true,
|
|
152
|
-
budgetMs,
|
|
153
|
-
message: `已达整批预算 ${budgetMs}ms,在第 ${index + 1} 步(${change.tool})前停止;已完成 ${steps.length} 项(其效果真实存在)。先读 progressFile 与只读发现确认进度,再决定是否续跑——绝不盲重试`,
|
|
154
|
-
summary: `${args.summary ? `${args.summary};` : ""}批量达预算停止于第 ${index + 1} 步前,已完成 ${steps.length} 项`,
|
|
155
|
-
progressFile,
|
|
156
|
-
// Ticket 81: structured recovery semantics — a timeout is NOT
|
|
157
|
-
// failure; the server may have completed everything.
|
|
158
|
-
nextAction: {
|
|
159
|
-
rule: "read-back-first",
|
|
160
|
-
steps: [
|
|
161
|
-
"读 progressFile:拿到已完成步骤清单(其效果真实存在于环境)",
|
|
162
|
-
"用只读发现核对每一步的权威面(discover_environment / 对应 lane 的 list/get 读回;写工具的 already-present/already-published 短路可安全复用)",
|
|
163
|
-
`仅对缺失步骤重新组包:从 failedStep.index=${index} 起,剔除读回确认已生效的项`,
|
|
164
|
-
],
|
|
165
|
-
forbidden: "盲目整批重试——已完成步骤会重复执行或触发重复码拒绝(如 listview.create 303002)",
|
|
166
|
-
resumeFromIndex: index,
|
|
167
|
-
},
|
|
168
|
-
},
|
|
169
|
-
};
|
|
170
|
-
return stop;
|
|
171
|
-
}
|
|
172
|
-
try {
|
|
173
|
-
const outcome = await target.writeExecute(session, change.args);
|
|
174
|
-
// A step-chain write (field.update cascadeRepublish) may RETURN a
|
|
175
|
-
// mid-chain stop instead of throwing: surface it as this batch's
|
|
176
|
-
// stop with the inner chain preserved for audit.
|
|
177
|
-
if ("status" in outcome) {
|
|
178
|
-
const progressFile = recordProgress("STOPPED", steps.length);
|
|
179
|
-
const cascadeStop = {
|
|
180
|
-
status: outcome.status,
|
|
181
|
-
steps,
|
|
182
|
-
failedStep: { index, tool: change.tool },
|
|
183
|
-
envelope: { ...outcome.envelope, message: `${String(outcome.envelope.message ?? "步骤失败")}(第 ${index + 1} 步 ${change.tool} 的内部级联中途停止)`, progressFile },
|
|
184
|
-
};
|
|
185
|
-
return cascadeStop;
|
|
186
|
-
}
|
|
187
|
-
steps.push({ step: change.tool, index, status: "ok", performed: outcome.performed, readback: outcome.readback, ...(outcome.steps !== undefined ? { chainSteps: outcome.steps } : {}) });
|
|
188
|
-
recordProgress("RUNNING", index + 1);
|
|
189
|
-
}
|
|
190
|
-
catch (error) {
|
|
191
|
-
const failedStep = { index, tool: change.tool };
|
|
192
|
-
if (isUncertainWireError(error)) {
|
|
193
|
-
// Per-step transport/timeout: uncertain, frozen — never success.
|
|
194
|
-
const progressFile = recordProgress("STOPPED", steps.length);
|
|
195
|
-
const stop = {
|
|
196
|
-
status: "uncertain",
|
|
197
|
-
steps,
|
|
198
|
-
failedStep,
|
|
199
|
-
envelope: {
|
|
200
|
-
frozen: true,
|
|
201
|
-
reason: `wire-transport:${wireErrorKind(error)}`,
|
|
202
|
-
detail: error.message,
|
|
203
|
-
message: `第 ${index + 1} 步(${change.tool})传输中断,写入结果无法判定;已冻结——先重新发现再决定重试,绝不假定为成功`,
|
|
204
|
-
summary: `${args.summary ? `${args.summary};` : ""}批量在第 ${index + 1} 步(${change.tool})中断,已完成 ${steps.length} 项,结果不确定`,
|
|
205
|
-
progressFile,
|
|
206
|
-
// Ticket 81: the interrupted step itself may have taken
|
|
207
|
-
// effect server-side — read back before any retry.
|
|
208
|
-
nextAction: {
|
|
209
|
-
rule: "read-back-first",
|
|
210
|
-
steps: [
|
|
211
|
-
"读 progressFile:拿到已完成步骤清单(其效果真实存在于环境)",
|
|
212
|
-
`先核对第 ${index + 1} 步(${change.tool})本身是否已生效——超时≠失败,服务端可能已写入`,
|
|
213
|
-
"用只读发现核对每一步的权威面,仅对缺失步骤重新组包执行",
|
|
214
|
-
],
|
|
215
|
-
forbidden: "盲目整批重试或假定中断步骤失败——重复执行会撞重复码(如 listview.create 303002)",
|
|
216
|
-
resumeFromIndex: index,
|
|
217
|
-
},
|
|
218
|
-
},
|
|
219
|
-
};
|
|
220
|
-
return stop;
|
|
221
|
-
}
|
|
222
|
-
const envelope = error instanceof ToolRefusalError
|
|
223
|
-
? { ...error.payload }
|
|
224
|
-
: error instanceof WireError
|
|
225
|
-
? { blocker: `wire-${error.kind}`, errcode: error.errcode, message: error.message }
|
|
226
|
-
: { blocker: "apply-changes-step-failed", message: error.message };
|
|
227
|
-
const progressFile = recordProgress("STOPPED", steps.length);
|
|
228
|
-
const stop = {
|
|
229
|
-
status: "refused",
|
|
230
|
-
steps,
|
|
231
|
-
failedStep,
|
|
232
|
-
envelope: {
|
|
233
|
-
...envelope,
|
|
234
|
-
message: `${typeof envelope.message === "string" ? envelope.message : "步骤失败"};批量在第 ${index + 1} 步(${change.tool})停止,后续步骤未执行;已完成步骤见 steps(其效果真实存在,需要善后时按 steps 清单处理)`,
|
|
235
|
-
summary: `${args.summary ? `${args.summary};` : ""}批量在第 ${index + 1} 步(${change.tool})停止,已完成 ${steps.length} 项`,
|
|
236
|
-
progressFile,
|
|
237
|
-
},
|
|
238
|
-
};
|
|
239
|
-
return stop;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
const executedTools = [...new Set(normalizedChanges.map((change) => change.tool))];
|
|
243
|
-
const progressFile = recordProgress("DONE", steps.length);
|
|
39
|
+
handler: async (ctx, args) => executeChangesBatch(ctx, args, siblings),
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* B1:apply_changes 工具面与 `intent apply` 共享的批执行管线(intent 只保留
|
|
44
|
+
* 自己的门:plan 完整性、baseline drift、最终读回、写锁——见
|
|
45
|
+
* src/intent/plan-apply.ts)。`siblings` 是完整工具注册表(工具面传 tools
|
|
46
|
+
* 数组闭包;intent 传 buildToolRegistry(),同一注册表)。
|
|
47
|
+
*/
|
|
48
|
+
export async function executeChangesBatch(ctx, args, siblings) {
|
|
49
|
+
const changes = args.changes;
|
|
50
|
+
// ---- 1. Structural validation (zero wire calls) --------------------
|
|
51
|
+
if (!Array.isArray(changes) || changes.length === 0)
|
|
52
|
+
return refuseBatch("apply-changes-invalid", "changes 必须是非空数组(每项 { tool, args })");
|
|
53
|
+
const targets = new Map();
|
|
54
|
+
const normalizedChanges = [];
|
|
55
|
+
for (const change of changes) {
|
|
56
|
+
if (!(change.tool && typeof change.tool === "string"))
|
|
57
|
+
return refuseBatch("apply-changes-invalid", "changes 每项必须包含 tool");
|
|
58
|
+
if (!targets.has(change.tool)) {
|
|
59
|
+
const target = siblings.find((tool) => tool.name === change.tool);
|
|
60
|
+
if (!target)
|
|
61
|
+
return refuseBatch("apply-changes-unknown-tool", `changes 引用了不存在的工具 ${change.tool}`, { tool: change.tool });
|
|
62
|
+
if (target.kind !== "write")
|
|
63
|
+
return refuseBatch("apply-changes-tool-not-writable", `${change.tool} 不是写工具(changes 只接受写操作)`, { tool: change.tool });
|
|
64
|
+
if (target.layer !== "low" || !target.writeExecute)
|
|
65
|
+
return refuseBatch("apply-changes-tool-not-atomic", `${change.tool} 是高层预设(已是单调用包);changes 只接受低层原子写工具`, { tool: change.tool });
|
|
66
|
+
if (!target.lane || !target.scope)
|
|
67
|
+
return refuseBatch("apply-changes-tool-not-atomic", `${change.tool} 缺少 lane/scope 声明,无法通过覆盖门`, { tool: change.tool });
|
|
68
|
+
targets.set(change.tool, target);
|
|
69
|
+
}
|
|
70
|
+
try {
|
|
71
|
+
normalizedChanges.push({ tool: change.tool, args: parseToolInput(targets.get(change.tool), change.args) });
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
if (error instanceof ToolInputError)
|
|
75
|
+
return { ...error.payload, failedBeforeApproval: true, changeTool: change.tool };
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// ---- 2. Semantic gates BEFORE the write permission gate (dry) ------
|
|
80
|
+
try {
|
|
81
|
+
for (const change of normalizedChanges)
|
|
82
|
+
targets.get(change.tool).writePreflight?.(change.args);
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
if (error instanceof ToolRefusalError)
|
|
86
|
+
return { ...error.payload, failedBeforeApproval: true };
|
|
87
|
+
throw error;
|
|
88
|
+
}
|
|
89
|
+
// ---- 3. One plan, one fingerprint, per-action coverage ------------
|
|
90
|
+
const toolPhrase = (list) => {
|
|
91
|
+
const counts = new Map();
|
|
92
|
+
for (const change of list)
|
|
93
|
+
counts.set(change.tool, (counts.get(change.tool) ?? 0) + 1);
|
|
94
|
+
return [...counts.entries()].map(([tool, count]) => (count > 1 ? `${tool}×${count}` : tool)).join("、");
|
|
95
|
+
};
|
|
96
|
+
const plan = {
|
|
97
|
+
environment: "",
|
|
98
|
+
environmentFingerprint: "",
|
|
99
|
+
summary: args.summary ?? `即将按序执行 ${normalizedChanges.length} 项变更(${toolPhrase(normalizedChanges)})`,
|
|
100
|
+
actions: normalizedChanges.map((change) => ({ tool: change.tool, args: plannableArgs(change.tool, change.args) })),
|
|
101
|
+
};
|
|
102
|
+
const coverage = {
|
|
103
|
+
perAction: normalizedChanges.map((change) => {
|
|
104
|
+
const target = targets.get(change.tool);
|
|
105
|
+
return { lane: target.lane, scope: target.scope };
|
|
106
|
+
}),
|
|
107
|
+
};
|
|
108
|
+
const batchResult = await executePackage(ctx, plan, coverage, args, async (session) => {
|
|
109
|
+
// B1:串行/首败/超时冻结/progressFile 的状态机在共享执行器里;本面只
|
|
110
|
+
// 负责「怎么执行一步」(writeExecute 直调,保留各 lane 的权威读回与
|
|
111
|
+
// step 级 journal/before 快照)和回执投影(字段形状与 Ticket 46/58 一致)。
|
|
112
|
+
const executed = await executeGovernedBatch({
|
|
113
|
+
changes: normalizedChanges,
|
|
114
|
+
mode: "apply_changes",
|
|
115
|
+
timeoutMs: args.totalTimeoutMs,
|
|
116
|
+
progress: { ctx, summary: plan.summary },
|
|
117
|
+
summary: typeof args.summary === "string" ? args.summary : undefined,
|
|
118
|
+
runTool: async (change, index) => {
|
|
119
|
+
const target = targets.get(change.tool);
|
|
120
|
+
const outcome = await target.writeExecute(session, change.args);
|
|
121
|
+
// A step-chain write (field.update cascadeRepublish) may RETURN a
|
|
122
|
+
// mid-chain stop instead of throwing: the executor surfaces it as
|
|
123
|
+
// this batch's stop with the inner chain preserved for audit.
|
|
124
|
+
if ("status" in outcome)
|
|
125
|
+
return { kind: "stop", status: outcome.status, envelope: outcome.envelope };
|
|
244
126
|
return {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
127
|
+
kind: "ok",
|
|
128
|
+
step: {
|
|
129
|
+
step: change.tool,
|
|
130
|
+
index,
|
|
131
|
+
status: "ok",
|
|
132
|
+
performed: outcome.performed,
|
|
133
|
+
readback: outcome.readback,
|
|
134
|
+
...(outcome.steps !== undefined ? { chainSteps: outcome.steps } : {}),
|
|
135
|
+
},
|
|
248
136
|
};
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
137
|
+
},
|
|
138
|
+
});
|
|
139
|
+
if (executed.kind === "stop")
|
|
140
|
+
return executed.outcome;
|
|
141
|
+
return {
|
|
142
|
+
steps: executed.steps,
|
|
143
|
+
readback: {
|
|
144
|
+
stepCount: executed.steps.length,
|
|
145
|
+
tools: executed.stepTools,
|
|
146
|
+
allStepsOk: executed.steps.every((step) => step.status === "ok"),
|
|
147
|
+
...(executed.progressFile !== undefined ? { progressFile: executed.progressFile } : {}),
|
|
148
|
+
},
|
|
149
|
+
summary: args.summary ?? `已按序完成 ${executed.steps.length} 项变更(${toolPhrase(changes)})`,
|
|
150
|
+
};
|
|
151
|
+
});
|
|
152
|
+
// R88 #3 审计面:批量写此前在 journal 里完全不可见(intent apply 也是
|
|
153
|
+
// 经本工具执行的),多人共用一台机器时「谁用哪份意图改了什么、为什么」
|
|
154
|
+
// 无处可查。这里只落**一条**批量审计行(与 configure_* 复合写同口径):
|
|
155
|
+
// 逐步 before 快照并未捕获,所以 rollbackable:false,绝不假装能整包回滚。
|
|
156
|
+
if (batchResult.status === "ok" && batchResult.deliveryState === "DELIVERED")
|
|
157
|
+
await recordBatchJournal(ctx, args, batchResult);
|
|
158
|
+
return batchResult;
|
|
259
159
|
}
|
|
260
160
|
/** One honest journal line per delivered batch (audit only, not a rollback unit). */
|
|
261
161
|
async function recordBatchJournal(ctx, args, result) {
|
|
262
162
|
const steps = Array.isArray(result.steps) ? result.steps : [];
|
|
263
163
|
if (steps.length === 0)
|
|
264
164
|
return;
|
|
265
|
-
const tools = [...new Set(steps.map((step) => String(step.step ?? "?")))];
|
|
266
|
-
const target = `batch:${tools.slice(0, 3).join("+")}${tools.length > 3 ? `+${tools.length - 3}` : ""}`;
|
|
267
165
|
const readback = (result.readback ?? {});
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
v: 1,
|
|
281
|
-
environment,
|
|
282
|
-
environmentFingerprint,
|
|
283
|
-
tool: "apply_changes",
|
|
284
|
-
target,
|
|
285
|
-
beforeSha: null,
|
|
286
|
-
rollbackable: false,
|
|
287
|
-
note: `批量审计行(${steps.length} 步:${tools.slice(0, 6).join("、")}${summary !== undefined ? `;${summary}` : ""}):逐步 before 快照未捕获,不能整包回滚;逐项恢复请用对应单工具写面重做`,
|
|
288
|
-
...journalAudit(ctx.sessions.config(), environment, ctx.writeAudit?.reason),
|
|
289
|
-
artifactFile: progressFile ?? `${target.replace(/[^\w.-]+/gu, "_")}.batch.json`,
|
|
290
|
-
artifactId: progressFile !== undefined ? basename(progressFile) : "apply_changes-batch",
|
|
291
|
-
artifactSha: typeof result.artifactFingerprint === "string" ? result.artifactFingerprint : "batch",
|
|
166
|
+
// B1:批量审计行的构造/措辞/字段统一在共享执行器模块(rollback.apply 也用
|
|
167
|
+
// 同一实现);此处只保留 W11C 的落行时机——executePackage 判定 DELIVERED
|
|
168
|
+
// 之后(artifactFingerprint 已可用),回执本身不加字段。
|
|
169
|
+
await appendBatchAuditLine({
|
|
170
|
+
ctx,
|
|
171
|
+
mode: "apply_changes",
|
|
172
|
+
environmentArg: args.environment,
|
|
173
|
+
reason: ctx.writeAudit?.reason,
|
|
174
|
+
steps,
|
|
175
|
+
summary: typeof result.summary === "string" ? result.summary : undefined,
|
|
176
|
+
progressFile: typeof readback.progressFile === "string" ? readback.progressFile : undefined,
|
|
177
|
+
fingerprint: typeof result.artifactFingerprint === "string" ? result.artifactFingerprint : undefined,
|
|
292
178
|
});
|
|
293
|
-
// The receipt is deliberately NOT extended (byte-for-byte stable for eval
|
|
294
|
-
// baselines): the audit line is discoverable with
|
|
295
|
-
// `omc rollback list --tool apply_changes`.
|
|
296
|
-
void entry;
|
|
297
179
|
}
|
|
298
180
|
//# sourceMappingURL=apply-changes.js.map
|
|
@@ -9,6 +9,7 @@ import { writeTool } from "../write.js";
|
|
|
9
9
|
import { decodeJsonColumn as decodeSharedJsonColumn, JSON_COLUMN_NULL_COALESCE } from "../json-column.js";
|
|
10
10
|
import { defineTool, ToolRefusalError } from "../tool-types.js";
|
|
11
11
|
import { wireCall, wireRows, wireDownloadBuffer, wireUploadFile, WireError } from "../wire.js";
|
|
12
|
+
import { parameterFaceCovers, serviceStatusSegment } from "../service-support.js";
|
|
12
13
|
import { ZipFormatError, readZipEntries, zipEntryByBasename } from "../zip.js";
|
|
13
14
|
import { B2_LANE_CONTRACT } from "./b2-registration-contract.js";
|
|
14
15
|
import { BIZSERVICE_WRITE_ADAPTERS, assertBizServiceAdapterWhitelisted, assertStructuredConfig, compileMethodConfigPlain, compileParameterFace, compileServiceConfig, maskServiceConfigSecrets, normalizeMethodConfigReadback, normalizeParameterFaceReadback, parseIeManifest, iePackageSummary, } from "../bizservice-config.js";
|
|
@@ -229,6 +230,22 @@ function dbConnPoolCodeOf(serviceConfig) {
|
|
|
229
230
|
function isServiceAbsent(error) {
|
|
230
231
|
return error instanceof WireError && error.kind === "business" && error.errcode === 500001;
|
|
231
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* A5:方法面回执要能回答「服务还在吗」——list_by_service_code 对「服务没了」
|
|
235
|
+
* 与「服务存在但没有方法」都给空列表,只有 get_by_code 能区分(absent 读失败
|
|
236
|
+
* 按不存在处理,与 service.get 同口径)。
|
|
237
|
+
*/
|
|
238
|
+
async function serviceRowPresent(session, serviceCode) {
|
|
239
|
+
try {
|
|
240
|
+
const row = (await wireCall(session, { path: ENDPOINTS.bizServiceGetByCode, query: { serviceCode } })).data;
|
|
241
|
+
return row != null;
|
|
242
|
+
}
|
|
243
|
+
catch (error) {
|
|
244
|
+
if (isServiceAbsent(error))
|
|
245
|
+
return false;
|
|
246
|
+
throw error;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
232
249
|
/**
|
|
233
250
|
* Rollback specs (round 17): BIZSERVICE faces split by the secret boundary —
|
|
234
251
|
* service.update replays its PLAINTEXT configJson as serviceConfig;
|
|
@@ -599,6 +616,12 @@ export function registerB2Lane(tools) {
|
|
|
599
616
|
inParams: args.detail === true ? codeList(inputFace) : Array.isArray(inputFace) ? inputFace.length : 0,
|
|
600
617
|
outParams: args.detail === true ? codeList(outputFace) : Array.isArray(outputFace) ? outputFace.length : 0,
|
|
601
618
|
configKeys: configRecord ? Object.keys(configRecord) : [],
|
|
619
|
+
// F14(r89 真机钉死 2026-11-20):filterFlag=false 的回执**带** referenced——
|
|
620
|
+
// BizServiceMethodController.listByServiceCode 两分支都查 bizMethodMappings
|
|
621
|
+
// 并 setReferenced(true)(模型缺省 Boolean.FALSE,BizServiceMethodModel.java:44,53)。
|
|
622
|
+
// 真机:crm_receipt_service/writebackTotal 被 crm_receipt.Create 节点 A1 映射,
|
|
623
|
+
// service.get(同一 wire)读回 referenced:true。此前注释/测试声称不算——已更正。
|
|
624
|
+
referenced: row.referenced === true,
|
|
602
625
|
};
|
|
603
626
|
});
|
|
604
627
|
const keyword = args.keyword?.trim().toLowerCase();
|
|
@@ -612,7 +635,7 @@ export function registerB2Lane(tools) {
|
|
|
612
635
|
methodsCount: methods.length,
|
|
613
636
|
...(keyword !== undefined && keyword !== "" ? { keyword: args.keyword, totalBeforeFilter: all.length } : {}),
|
|
614
637
|
columnNote: "url 是运行时真相(configJson.url);name 是人工显示名,语义可能与 url 相反(实证 name=「统一入口」而 url 指旧接口)",
|
|
615
|
-
referencedNote: "
|
|
638
|
+
referencedNote: "referenced=平台 bizMethodMapping 引用标记(filterFlag=false 也置位,BizServiceMethodController.listByServiceCode 两分支同源)——只覆盖规则图方法映射,不含流程/表单引用;删方法前用 rule.references kind=service 复核(命中行带 serviceMethodCode)",
|
|
616
639
|
methods,
|
|
617
640
|
};
|
|
618
641
|
}, {
|
|
@@ -680,8 +703,13 @@ export function registerB2Lane(tools) {
|
|
|
680
703
|
});
|
|
681
704
|
const afterRows = wireRows((await wireCall(session, { path: ENDPOINTS.bizServiceMethodList, query: { serviceCode: args.serviceCode, filterFlag: "false" } })).data);
|
|
682
705
|
const after = afterRows.find((row) => row.code === args.methodCode);
|
|
706
|
+
// A5:声明过的参数面必须在读回面上可见(平台注入参数不算漂移)。
|
|
707
|
+
const faceDeclared = args.methodInputParameters !== undefined || args.methodOutputParameters !== undefined;
|
|
708
|
+
const faceVerified = after != null && faceDeclared
|
|
709
|
+
&& (args.methodInputParameters === undefined || parameterFaceCovers(after.inputParametersJson, args.methodInputParameters))
|
|
710
|
+
&& (args.methodOutputParameters === undefined || parameterFaceCovers(after.outputParametersJson, args.methodOutputParameters));
|
|
683
711
|
// r28f F4:与 method.get 共用参数面解码(position + bizPropertyType → 名字)。
|
|
684
|
-
return { performed: { errcode: performed.errcode }, readback: { methodCode: args.methodCode, methodPresent: after != null, nameMatches: args.name === undefined || after?.name === args.name, configMatches: methodConfigPlain === undefined || after?.configJson === methodConfigPlain, inputParameters: normalizeParameterFaceReadback(adapterCode, decodeJsonColumn(after?.inputParametersJson)), outputParameters: normalizeParameterFaceReadback(adapterCode, decodeJsonColumn(after?.outputParametersJson)), mappingNote: "规则映射直接用这里的参数 code(bizPropertyType 供类型对账),不必再 service.get" } };
|
|
712
|
+
return { performed: { errcode: performed.errcode }, readback: { methodCode: args.methodCode, methodPresent: after != null, nameMatches: args.name === undefined || after?.name === args.name, configMatches: methodConfigPlain === undefined || after?.configJson === methodConfigPlain, inputParameters: normalizeParameterFaceReadback(adapterCode, decodeJsonColumn(after?.inputParametersJson)), outputParameters: normalizeParameterFaceReadback(adapterCode, decodeJsonColumn(after?.outputParametersJson)), mappingNote: "规则映射直接用这里的参数 code(bizPropertyType 供类型对账),不必再 service.get" }, serviceStatus: serviceStatusSegment({ operation: "method.update", serviceCode: args.serviceCode, methodCode: args.methodCode, servicePresent: true, methodPresent: after != null, ...(faceDeclared ? { parameterFaceVerified: faceVerified } : {}) }) };
|
|
685
713
|
},
|
|
686
714
|
preflight: (args) => {
|
|
687
715
|
assertStructuredConfig(args.methodConfig, "methodConfig");
|
|
@@ -739,8 +767,13 @@ export function registerB2Lane(tools) {
|
|
|
739
767
|
});
|
|
740
768
|
const afterRows = wireRows((await wireCall(session, { path: ENDPOINTS.bizServiceMethodList, query: { serviceCode: args.serviceCode, filterFlag: "false" } })).data);
|
|
741
769
|
const after = afterRows.find((row) => row.code === args.methodCode);
|
|
770
|
+
// A5:声明过的参数面必须在读回面上可见(平台注入参数不算漂移)。
|
|
771
|
+
const faceDeclared = args.methodInputParameters !== undefined || args.methodOutputParameters !== undefined;
|
|
772
|
+
const faceVerified = after != null && faceDeclared
|
|
773
|
+
&& (args.methodInputParameters === undefined || parameterFaceCovers(after.inputParametersJson, args.methodInputParameters))
|
|
774
|
+
&& (args.methodOutputParameters === undefined || parameterFaceCovers(after.outputParametersJson, args.methodOutputParameters));
|
|
742
775
|
// r28f F4:与 method.get 共用参数面解码(position + bizPropertyType → 名字)。
|
|
743
|
-
return { performed: { errcode: performed.errcode }, readback: { methodCode: args.methodCode, methodPresent: after != null, nameMatches: after?.name === args.name, configMatches: methodConfigPlain === undefined || after?.configJson === methodConfigPlain, inputParameters: normalizeParameterFaceReadback(adapterCode, decodeJsonColumn(after?.inputParametersJson)), outputParameters: normalizeParameterFaceReadback(adapterCode, decodeJsonColumn(after?.outputParametersJson)), mappingNote: "规则映射直接用这里的参数 code(bizPropertyType 供类型对账),不必再 service.get" } };
|
|
776
|
+
return { performed: { errcode: performed.errcode }, readback: { methodCode: args.methodCode, methodPresent: after != null, nameMatches: after?.name === args.name, configMatches: methodConfigPlain === undefined || after?.configJson === methodConfigPlain, inputParameters: normalizeParameterFaceReadback(adapterCode, decodeJsonColumn(after?.inputParametersJson)), outputParameters: normalizeParameterFaceReadback(adapterCode, decodeJsonColumn(after?.outputParametersJson)), mappingNote: "规则映射直接用这里的参数 code(bizPropertyType 供类型对账),不必再 service.get" }, serviceStatus: serviceStatusSegment({ operation: "method.create", serviceCode: args.serviceCode, methodCode: args.methodCode, servicePresent: true, methodPresent: after != null, ...(faceDeclared ? { parameterFaceVerified: faceVerified } : {}) }) };
|
|
744
777
|
},
|
|
745
778
|
preflight: (args) => {
|
|
746
779
|
assertStructuredConfig(args.methodConfig, "methodConfig");
|
|
@@ -759,11 +792,16 @@ export function registerB2Lane(tools) {
|
|
|
759
792
|
// Id resolution mirrors service.delete: the delete endpoint keys on the
|
|
760
793
|
// row id (query, comma-separated on the platform face — this tool stays
|
|
761
794
|
// single-target), resolved via list_by_service_code + method code.
|
|
795
|
+
const servicePresent = await serviceRowPresent(session, args.serviceCode);
|
|
762
796
|
const rows = wireRows((await wireCall(session, { path: ENDPOINTS.bizServiceMethodList, query: { serviceCode: args.serviceCode, filterFlag: "false" } })).data);
|
|
763
797
|
const current = rows.find((row) => row.code === args.methodCode);
|
|
764
798
|
const id = current?.id;
|
|
765
799
|
if (typeof id !== "string" || !id)
|
|
766
|
-
return {
|
|
800
|
+
return {
|
|
801
|
+
performed: { errcode: 0 },
|
|
802
|
+
readback: { absent: true, note: "method already absent" },
|
|
803
|
+
serviceStatus: serviceStatusSegment({ operation: "method.delete", serviceCode: args.serviceCode, methodCode: args.methodCode, servicePresent, methodPresent: false }),
|
|
804
|
+
};
|
|
767
805
|
// A referenced method answers 500108 业务方法已绑定默认方法,不可删除
|
|
768
806
|
// (BizServiceMethodController.java:246-272) — governedWrite surfaces the
|
|
769
807
|
// platform refusal verbatim with errcode + message; the rule and its
|
|
@@ -771,7 +809,11 @@ export function registerB2Lane(tools) {
|
|
|
771
809
|
const performed = await wireCall(session, { path: ENDPOINTS.bizServiceMethodDelete, method: "POST", query: { id } });
|
|
772
810
|
const afterRows = wireRows((await wireCall(session, { path: ENDPOINTS.bizServiceMethodList, query: { serviceCode: args.serviceCode, filterFlag: "false" } })).data);
|
|
773
811
|
const after = afterRows.find((row) => row.code === args.methodCode);
|
|
774
|
-
return {
|
|
812
|
+
return {
|
|
813
|
+
performed: { errcode: performed.errcode },
|
|
814
|
+
readback: { absent: after == null, ...(after ? { method: after } : {}) },
|
|
815
|
+
serviceStatus: serviceStatusSegment({ operation: "method.delete", serviceCode: args.serviceCode, methodCode: args.methodCode, servicePresent, methodPresent: after != null }),
|
|
816
|
+
};
|
|
775
817
|
},
|
|
776
818
|
rollback: b2ServiceRollbackSpec("method.delete"),
|
|
777
819
|
});
|
|
@@ -1236,6 +1278,11 @@ export function registerB2Lane(tools) {
|
|
|
1236
1278
|
const methodRow = args.methodName ? methodRows.find((row) => row.code === args.methodName) : undefined;
|
|
1237
1279
|
// r28f F4:与 method.get 共用 decode 面(position + bizPropertyType → 名字)。
|
|
1238
1280
|
const readbackAdapter = adapterCodeOf(readback.data ?? undefined) || adapterCode;
|
|
1281
|
+
// A5:与 method.create/update 同一 serviceStatus 形状(旧 readback 键不动)。
|
|
1282
|
+
const faceDeclared = args.methodInputParameters !== undefined || args.methodOutputParameters !== undefined;
|
|
1283
|
+
const faceVerified = methodRow !== undefined && faceDeclared
|
|
1284
|
+
&& (args.methodInputParameters === undefined || parameterFaceCovers(methodRow.inputParametersJson, args.methodInputParameters))
|
|
1285
|
+
&& (args.methodOutputParameters === undefined || parameterFaceCovers(methodRow.outputParametersJson, args.methodOutputParameters));
|
|
1239
1286
|
return {
|
|
1240
1287
|
performed: { errcode: performed.errcode },
|
|
1241
1288
|
readback: {
|
|
@@ -1252,6 +1299,13 @@ export function registerB2Lane(tools) {
|
|
|
1252
1299
|
}
|
|
1253
1300
|
: {}),
|
|
1254
1301
|
},
|
|
1302
|
+
serviceStatus: serviceStatusSegment({
|
|
1303
|
+
operation: "register",
|
|
1304
|
+
serviceCode: args.serviceCode,
|
|
1305
|
+
servicePresent: readback.data != null,
|
|
1306
|
+
...(args.methodName !== undefined ? { methodCode: args.methodName, methodPresent: registered === true } : {}),
|
|
1307
|
+
...(faceDeclared ? { parameterFaceVerified: faceVerified } : {}),
|
|
1308
|
+
}),
|
|
1255
1309
|
};
|
|
1256
1310
|
},
|
|
1257
1311
|
preflight: (args) => {
|
|
@@ -1376,6 +1430,8 @@ export function registerB2Lane(tools) {
|
|
|
1376
1430
|
return {
|
|
1377
1431
|
performed: { errcode: performed.errcode },
|
|
1378
1432
|
readback: { servicePresent: after != null, nameMatches, configMatches, ...(configPreserved !== undefined ? { configPreserved } : {}), ...(adapterCode ? { adapterCode } : {}) },
|
|
1433
|
+
// A5:与 register 同一 serviceStatus 形状;service 级操作不带 method 键。
|
|
1434
|
+
serviceStatus: serviceStatusSegment({ operation: "update", serviceCode: args.serviceCode, servicePresent: after != null }),
|
|
1379
1435
|
};
|
|
1380
1436
|
},
|
|
1381
1437
|
preflight: (args) => {
|
|
@@ -838,7 +838,7 @@ export function registerBusinessRuleLane(tools) {
|
|
|
838
838
|
description: RULE_TOOLS["rule.references"].description,
|
|
839
839
|
inputSchema: {
|
|
840
840
|
environment: environmentArg,
|
|
841
|
-
kind: z.enum(["service", "model", "field", "rule"]).describe("按什么找引用:service=BIZ_ACTION methodMapping.serviceCode
|
|
841
|
+
kind: z.enum(["service", "model", "field", "rule"]).describe("按什么找引用:service=BIZ_ACTION methodMapping.serviceCode(service 行带 serviceMethodCode);model=CREATE/UPDATE/DELETE targetObjectCode 与 methodMapping.schemaCode;field=dataActions.targetDataItem、映射 bizCode、规则条件叶子与 datarule;rule=流程事件绑定的规则码(flow 级 handler + 节点级 nodeEvent,扫应用内模型的流程面)"),
|
|
842
842
|
code: z.string().min(1).describe("要查引用的编码(服务/模型/字段 code);kind=field 可用 schemaCode.field 消歧"),
|
|
843
843
|
schemaCodes: z.union([z.array(z.string().min(1)), z.string()]).optional().describe("只扫这些模型(省 wire 读);省略=全平台模型"),
|
|
844
844
|
capability: capabilityArg,
|
|
@@ -1052,7 +1052,10 @@ export function registerBusinessRuleLane(tools) {
|
|
|
1052
1052
|
const mapping = rawNode.methodMapping;
|
|
1053
1053
|
if (args.kind === "service") {
|
|
1054
1054
|
if (nodeType === "BIZ_ACTION" && mapping && String(mapping.serviceCode ?? "") === wanted)
|
|
1055
|
-
|
|
1055
|
+
// C1(r89 契约层):方法级精度——命中行带 methodMapping.serviceMethodCode
|
|
1056
|
+
//(平台键名,BizMethodMappingModel.getServiceMethodCode;真机实证 rule.get
|
|
1057
|
+
// 的 methodMapping 同键)。查「哪个方法被引用」不再需要逐条 rule.get 对图。
|
|
1058
|
+
model.matches.push({ schemaCode, ruleCode, nodeCode, nodeType, via: "methodMapping.serviceCode", ...(String(mapping.serviceMethodCode ?? "") !== "" ? { serviceMethodCode: String(mapping.serviceMethodCode) } : {}) });
|
|
1056
1059
|
}
|
|
1057
1060
|
else if (args.kind === "model") {
|
|
1058
1061
|
if (["CREATE", "UPDATE", "DELETE"].includes(nodeType) && String(rawNode.targetObjectCode ?? "") === wanted)
|
|
@@ -1540,7 +1543,9 @@ export function registerBusinessRuleLane(tools) {
|
|
|
1540
1543
|
},
|
|
1541
1544
|
execute: async (session, args) => {
|
|
1542
1545
|
const base = await loadRuleNodePatchGraph(session, args);
|
|
1543
|
-
|
|
1546
|
+
// A4:patch 入口的统一状态段——operation:"patch" + target.nodeCode(图仍是
|
|
1547
|
+
// 整图重存,graph.saved:true 报的是全图,与 rule.save 同构)。
|
|
1548
|
+
return executeRuleSaveWrite(session, { schemaCode: args.schemaCode, ruleCode: args.ruleCode, name: base.ruleName, nodeGraph: base.mergedGraph, ...(args.publish === true ? { publish: true } : {}), ...(args.customTrigger === true ? { customTrigger: true } : {}) }, { operation: "patch", nodeCode: args.nodeCode });
|
|
1544
1549
|
},
|
|
1545
1550
|
// r73 #1(GitLab #40):dry-run 此前走 write.ts 通用 dry-run(只出 plan),不跑
|
|
1546
1551
|
// 图 lint——非法 patch(如 CREATE 节点 originatorValue 置空)dry-run 过、真写
|