@stalfh233/omc-cli 0.6.84 → 0.6.86
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 +6 -3
- package/coverage/m1-coverage-manifest-v1.json +28 -0
- package/dist/batch-call.js +1 -0
- package/dist/call.js +4 -1
- package/dist/capability-overview.js +4 -4
- package/dist/cli.js +21 -20
- package/dist/concurrency.js +165 -0
- package/dist/duration.js +73 -0
- package/dist/goal-routes.js +26 -1
- package/dist/governed-execution.js +5 -0
- package/dist/graph.js +5 -26
- package/dist/intent/capabilities/bizservice.js +178 -89
- package/dist/intent/capabilities/datarule.js +1 -1
- package/dist/intent/cli.js +1 -1
- package/dist/intent/compiler.js +1 -0
- package/dist/intent/plan-apply.js +5 -1
- package/dist/intent/schema.js +1 -1
- package/dist/journal.js +14 -1
- package/dist/lanes/apply-changes.js +49 -1
- package/dist/lanes/businessrule.js +63 -34
- package/dist/lanes/config-diff.js +477 -0
- package/dist/lanes/form.js +2 -2
- package/dist/lanes/runtime-data-contract.js +1 -1
- package/dist/lanes/runtime-data.js +43 -8
- package/dist/lanes/workflow-contract.js +17 -0
- package/dist/lanes/workflow-coverage.js +11 -0
- package/dist/lanes/workflow.js +47 -22
- package/dist/package.js +5 -2
- package/dist/read-shapes.js +9 -2
- package/dist/recipes/b2-registration.js +1 -1
- package/dist/rollback-spec.js +130 -32
- package/dist/rollback.js +67 -6
- package/dist/script.js +1 -0
- package/dist/tool-search.js +3 -0
- package/dist/tools.js +9 -0
- package/dist/write-audit.js +43 -0
- package/dist/write.js +10 -1
- package/docs/omc-introduction.md +3 -2
- package/package.json +3 -3
- package/skills/omc-capabilities.md +3 -2
|
@@ -6,20 +6,42 @@ import { sameValue } from "../compare.js";
|
|
|
6
6
|
import { isScalarString, pushError } from "../validation.js";
|
|
7
7
|
import { toPlain } from "../yaml.js";
|
|
8
8
|
import { errorDetail } from "../../tool-types.js";
|
|
9
|
-
const SERVICE_KEYS = new Set(["code", "name", "adapterCode", "serviceCategoryId", "serviceConfig", "method"]);
|
|
9
|
+
const SERVICE_KEYS = new Set(["code", "name", "adapterCode", "serviceCategoryId", "serviceConfig", "method", "methods"]);
|
|
10
10
|
const METHOD_KEYS = new Set(["code", "name", "methodConfig", "inputParameters", "outputParameters"]);
|
|
11
11
|
function configError(error) {
|
|
12
12
|
return errorDetail(error);
|
|
13
13
|
}
|
|
14
|
+
/** Every method declaration a service carries (legacy `method` or `methods[]`). */
|
|
15
|
+
function declaredMethods(service) {
|
|
16
|
+
if (service.methods !== undefined)
|
|
17
|
+
return service.methods;
|
|
18
|
+
return service.method ? [service.method] : [];
|
|
19
|
+
}
|
|
14
20
|
function compileService(service) {
|
|
15
21
|
assertBizServiceAdapterWhitelisted(service.adapterCode);
|
|
16
22
|
const serviceConfig = compileServiceConfig(service.adapterCode, service.serviceConfig);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
// Offline adapter/config/parameter-face validation for EVERY declared method
|
|
24
|
+
// (the write tools re-run the same compile, this catches it before any wire).
|
|
25
|
+
for (const method of declaredMethods(service)) {
|
|
26
|
+
if (method.methodConfig !== undefined)
|
|
27
|
+
compileMethodConfigPlain(service.adapterCode, method.methodConfig);
|
|
28
|
+
if (method.inputParameters !== undefined)
|
|
29
|
+
compileParameterFace(service.adapterCode, method.inputParameters, "methodInputParameters");
|
|
30
|
+
if (method.outputParameters !== undefined)
|
|
31
|
+
compileParameterFace(service.adapterCode, method.outputParameters, "methodOutputParameters");
|
|
32
|
+
}
|
|
33
|
+
return { serviceConfig };
|
|
34
|
+
}
|
|
35
|
+
/** Exact `method.create`/`method.update` args for one declared method (plaintext config; the tool AES-encrypts). */
|
|
36
|
+
function methodArgs(service, method) {
|
|
37
|
+
return {
|
|
38
|
+
serviceCode: service.code,
|
|
39
|
+
methodCode: method.code,
|
|
40
|
+
name: method.name,
|
|
41
|
+
...(method.methodConfig !== undefined ? { methodConfig: method.methodConfig } : {}),
|
|
42
|
+
...(method.inputParameters !== undefined ? { methodInputParameters: method.inputParameters } : {}),
|
|
43
|
+
...(method.outputParameters !== undefined ? { methodOutputParameters: method.outputParameters } : {}),
|
|
44
|
+
};
|
|
23
45
|
}
|
|
24
46
|
function serviceArgs(service) {
|
|
25
47
|
compileService(service);
|
|
@@ -55,32 +77,59 @@ function expectedParameterFace(adapterCode, parameters, label) {
|
|
|
55
77
|
return undefined;
|
|
56
78
|
return normalizeParameterFaceReadback(adapterCode, JSON.parse(compileParameterFace(adapterCode, parameters, label)));
|
|
57
79
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
80
|
+
/**
|
|
81
|
+
* Parameter-face equivalence. An undeclared face, a platform `null`, and a
|
|
82
|
+
* stored EMPTY face (`[]`) all mean "no parameters": the real platform persists
|
|
83
|
+
* `inputParametersJson`/`outputParametersJson` as `[]` even when the intent
|
|
84
|
+
* declares none, while the fake answers `null` — comparing them raw produced
|
|
85
|
+
* phantom `method-mismatch` on live apply (W12A acceptance). A NON-EMPTY stored
|
|
86
|
+
* face still fails against an undeclared one.
|
|
87
|
+
*/
|
|
88
|
+
function sameParameterFace(live, expected) {
|
|
89
|
+
const empty = (value) => (value === undefined || value === null || (Array.isArray(value) && value.length === 0) ? [] : value);
|
|
90
|
+
return sameValue(empty(live), empty(expected));
|
|
91
|
+
}
|
|
92
|
+
function decodeColumn(value) {
|
|
93
|
+
if (typeof value !== "string")
|
|
94
|
+
return value;
|
|
95
|
+
try {
|
|
96
|
+
return JSON.parse(value);
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
return value;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function methodFaceFromRow(method, adapterCode) {
|
|
103
|
+
return {
|
|
70
104
|
code: String(method.code ?? ""),
|
|
71
105
|
present: true,
|
|
72
106
|
name: typeof method.name === "string" ? method.name : null,
|
|
73
|
-
methodConfig: normalizeMethodConfigReadback(adapterCode,
|
|
74
|
-
inputParameters: normalizeParameterFaceReadback(adapterCode,
|
|
75
|
-
outputParameters: normalizeParameterFaceReadback(adapterCode,
|
|
76
|
-
}
|
|
107
|
+
methodConfig: normalizeMethodConfigReadback(adapterCode, decodeColumn(method.configJson)),
|
|
108
|
+
inputParameters: normalizeParameterFaceReadback(adapterCode, decodeColumn(method.inputParametersJson)),
|
|
109
|
+
outputParameters: normalizeParameterFaceReadback(adapterCode, decodeColumn(method.outputParametersJson)),
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Project the service row + declared methods. The legacy `method` slice keeps
|
|
114
|
+
* its historical shape (the key is OMITTED when the method is absent) so old
|
|
115
|
+
* plans/readbacks stay byte-identical; `methods[]` rows are always present so
|
|
116
|
+
* the planner/readback can name every declared-but-missing code.
|
|
117
|
+
*/
|
|
118
|
+
function serviceFromRow(service, adapterCode, rowsByCode, declared) {
|
|
119
|
+
const legacyRow = declared.method ? rowsByCode.get(declared.method.code) : undefined;
|
|
77
120
|
return {
|
|
78
121
|
code: String(service?.code ?? ""),
|
|
79
122
|
present: service !== null,
|
|
80
123
|
name: typeof service?.name === "string" ? service.name : null,
|
|
81
124
|
adapterCode: typeof service?.adapterCode === "string" ? service.adapterCode : null,
|
|
82
|
-
serviceConfig:
|
|
83
|
-
...(
|
|
125
|
+
serviceConfig: decodeColumn(service?.configJson),
|
|
126
|
+
...(legacyRow ? { method: methodFaceFromRow(legacyRow, adapterCode) } : {}),
|
|
127
|
+
...(declared.methods !== undefined ? {
|
|
128
|
+
methods: declared.methods.map((method) => {
|
|
129
|
+
const row = rowsByCode.get(method.code);
|
|
130
|
+
return row ? methodFaceFromRow(row, adapterCode) : { code: method.code, present: false, name: null };
|
|
131
|
+
}),
|
|
132
|
+
} : {}),
|
|
84
133
|
};
|
|
85
134
|
}
|
|
86
135
|
function validateServiceNode(serviceNode, index, draft, validation) {
|
|
@@ -95,6 +144,7 @@ function validateServiceNode(serviceNode, index, draft, validation) {
|
|
|
95
144
|
const categoryNode = value("serviceCategoryId");
|
|
96
145
|
const configNode = value("serviceConfig");
|
|
97
146
|
const methodNode = value("method");
|
|
147
|
+
const methodsNode = value("methods");
|
|
98
148
|
if (!isScalarString(codeNode) || codeNode.value.trim().length === 0)
|
|
99
149
|
pushError(validation, "intent-service-code-invalid", "service.code 必须是非空字符串", `${base}.code`, "value");
|
|
100
150
|
if (!isScalarString(nameNode) || nameNode.value.trim().length === 0)
|
|
@@ -107,57 +157,84 @@ function validateServiceNode(serviceNode, index, draft, validation) {
|
|
|
107
157
|
pushError(validation, "intent-service-config-invalid", "service.serviceConfig 必须是映射", `${base}.serviceConfig`, "value");
|
|
108
158
|
if (methodNode !== undefined && methodNode.kind !== "map")
|
|
109
159
|
pushError(validation, "intent-service-method-invalid", "service.method 必须是映射", `${base}.method`, "value");
|
|
160
|
+
if (methodsNode !== undefined && methodsNode.kind !== "seq")
|
|
161
|
+
pushError(validation, "intent-service-methods-invalid", "service.methods 必须是列表", `${base}.methods`, "value");
|
|
162
|
+
if (methodNode !== undefined && methodsNode !== undefined)
|
|
163
|
+
pushError(validation, "intent-service-method-both", "service.method 与 service.methods 互斥:单方法(methodName==code)用 method,多方法或给既有服务加方法用 methods", `${base}.methods`, "value");
|
|
110
164
|
if (!isScalarString(codeNode) || !isScalarString(nameNode) || !isScalarString(adapterNode) || !isScalarString(categoryNode) || configNode?.kind !== "map")
|
|
111
165
|
return;
|
|
112
166
|
const serviceConfig = toPlain(configNode);
|
|
167
|
+
/** Parse one method map; `legacy` enforces the service.register name==code constraint. */
|
|
168
|
+
const parseMethod = (map, path, legacy) => {
|
|
169
|
+
for (const entry of map.entries)
|
|
170
|
+
if (!METHOD_KEYS.has(entry.key))
|
|
171
|
+
pushError(validation, "intent-key-unknown", `${path} 不支持键 "${entry.key}"`, `${path}.${entry.key}`);
|
|
172
|
+
const methodValue = (key) => map.entries.find((entry) => entry.key === key)?.value;
|
|
173
|
+
const methodCode = methodValue("code");
|
|
174
|
+
const methodName = methodValue("name");
|
|
175
|
+
const methodConfig = methodValue("methodConfig");
|
|
176
|
+
const input = methodValue("inputParameters");
|
|
177
|
+
const output = methodValue("outputParameters");
|
|
178
|
+
if (!isScalarString(methodCode) || methodCode.value.trim().length === 0)
|
|
179
|
+
pushError(validation, "intent-method-code-invalid", `${path}.code 必须是非空字符串`, `${path}.code`, "value");
|
|
180
|
+
if (!isScalarString(methodName) || methodName.value.trim().length === 0)
|
|
181
|
+
pushError(validation, "intent-method-name-invalid", `${path}.name 必须是非空字符串`, `${path}.name`, "value");
|
|
182
|
+
if (methodConfig !== undefined && methodConfig.kind !== "map")
|
|
183
|
+
pushError(validation, "intent-method-config-invalid", `${path}.methodConfig 必须是映射`, `${path}.methodConfig`, "value");
|
|
184
|
+
if (input !== undefined && input.kind !== "seq")
|
|
185
|
+
pushError(validation, "intent-method-input-invalid", `${path}.inputParameters 必须是列表`, `${path}.inputParameters`, "value");
|
|
186
|
+
if (output !== undefined && output.kind !== "seq")
|
|
187
|
+
pushError(validation, "intent-method-output-invalid", `${path}.outputParameters 必须是列表`, `${path}.outputParameters`, "value");
|
|
188
|
+
if (!isScalarString(methodCode) || !isScalarString(methodName))
|
|
189
|
+
return undefined;
|
|
190
|
+
if (legacy && methodCode.value.trim() !== methodName.value.trim())
|
|
191
|
+
pushError(validation, "intent-method-name-code-mismatch", "当前 service.register 面 methodName 同时作为方法 code/name;method.name 必须等于 method.code(多方法且 name≠code 用 methods[])", `${path}.name`, "value");
|
|
192
|
+
return {
|
|
193
|
+
code: methodCode.value.trim(),
|
|
194
|
+
name: methodName.value.trim(),
|
|
195
|
+
...(methodConfig?.kind === "map" ? { methodConfig: toPlain(methodConfig) } : {}),
|
|
196
|
+
...(input?.kind === "seq" ? { inputParameters: input.items.map((item) => toPlain(item)) } : {}),
|
|
197
|
+
...(output?.kind === "seq" ? { outputParameters: output.items.map((item) => toPlain(item)) } : {}),
|
|
198
|
+
};
|
|
199
|
+
};
|
|
113
200
|
let method;
|
|
201
|
+
let methods;
|
|
114
202
|
try {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
if (
|
|
135
|
-
|
|
136
|
-
if (isScalarString(methodCode) && isScalarString(methodName)) {
|
|
137
|
-
if (methodCode.value.trim() !== methodName.value.trim())
|
|
138
|
-
pushError(validation, "intent-method-name-code-mismatch", "当前 service.register 面 methodName 同时作为方法 code/name;method.name 必须等于 method.code", `${base}.method.name`, "value");
|
|
139
|
-
method = {
|
|
140
|
-
code: methodCode.value.trim(),
|
|
141
|
-
name: methodName.value.trim(),
|
|
142
|
-
...(methodConfig?.kind === "map" ? { methodConfig: toPlain(methodConfig) } : {}),
|
|
143
|
-
...(input?.kind === "seq" ? { inputParameters: input.items.map((item) => toPlain(item)) } : {}),
|
|
144
|
-
...(output?.kind === "seq" ? { outputParameters: output.items.map((item) => toPlain(item)) } : {}),
|
|
145
|
-
};
|
|
146
|
-
}
|
|
203
|
+
if (methodNode?.kind === "map")
|
|
204
|
+
method = parseMethod(methodNode, `${base}.method`, true);
|
|
205
|
+
if (methodsNode?.kind === "seq") {
|
|
206
|
+
const seenCodes = new Set();
|
|
207
|
+
const parsed = [];
|
|
208
|
+
methodsNode.items.forEach((item, methodIndex) => {
|
|
209
|
+
const path = `${base}.methods[${methodIndex}]`;
|
|
210
|
+
if (item.kind !== "map") {
|
|
211
|
+
pushError(validation, "intent-service-method-invalid", "service.methods 每项必须是映射", path, "value");
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
const parsedMethod = parseMethod(item, path, false);
|
|
215
|
+
if (!parsedMethod)
|
|
216
|
+
return;
|
|
217
|
+
if (seenCodes.has(parsedMethod.code))
|
|
218
|
+
pushError(validation, "intent-method-code-duplicate", `service.methods 内方法 code 重复:${parsedMethod.code}`, `${path}.code`, "value");
|
|
219
|
+
seenCodes.add(parsedMethod.code);
|
|
220
|
+
parsed.push(parsedMethod);
|
|
221
|
+
});
|
|
222
|
+
if (parsed.length > 0)
|
|
223
|
+
methods = parsed;
|
|
147
224
|
}
|
|
148
|
-
compileService({ code: codeNode.value.trim(), name: nameNode.value.trim(), adapterCode: adapterNode.value.trim(), serviceCategoryId: categoryNode.value.trim(), serviceConfig, ...(method ? { method } : {}) });
|
|
225
|
+
compileService({ code: codeNode.value.trim(), name: nameNode.value.trim(), adapterCode: adapterNode.value.trim(), serviceCategoryId: categoryNode.value.trim(), serviceConfig, ...(method ? { method } : {}), ...(methods ? { methods } : {}) });
|
|
149
226
|
}
|
|
150
227
|
catch (error) {
|
|
151
228
|
pushError(validation, "intent-service-config-unsupported", configError(error), base, "value");
|
|
152
229
|
return;
|
|
153
230
|
}
|
|
154
|
-
draft.services.push({ code: codeNode.value.trim(), name: nameNode.value.trim(), adapterCode: adapterNode.value.trim(), serviceCategoryId: categoryNode.value.trim(), serviceConfig, ...(method ? { method } : {}) });
|
|
231
|
+
draft.services.push({ code: codeNode.value.trim(), name: nameNode.value.trim(), adapterCode: adapterNode.value.trim(), serviceCategoryId: categoryNode.value.trim(), serviceConfig, ...(method ? { method } : {}), ...(methods ? { methods } : {}) });
|
|
155
232
|
}
|
|
156
233
|
export const bizserviceCapability = {
|
|
157
234
|
id: "bizservice",
|
|
158
235
|
title: "业务集成",
|
|
159
236
|
requires: [],
|
|
160
|
-
operations: ["register"],
|
|
237
|
+
operations: ["register", "method.create", "method.update"],
|
|
161
238
|
validateRoot(tree, draft, validation) {
|
|
162
239
|
const servicesNode = tree.entries.find((entry) => entry.key === "services")?.value;
|
|
163
240
|
if (servicesNode === undefined || (servicesNode.kind === "scalar" && servicesNode.value === null))
|
|
@@ -197,12 +274,17 @@ export const bizserviceCapability = {
|
|
|
197
274
|
result.push({ code: service.code, present: false, name: null, adapterCode: null });
|
|
198
275
|
continue;
|
|
199
276
|
}
|
|
200
|
-
|
|
201
|
-
|
|
277
|
+
// One method-list read covers every declared method (legacy `method` or
|
|
278
|
+
// `methods[]`); `filterFlag:false` keeps platform-injected parameters raw.
|
|
279
|
+
const wanted = declaredMethods(service);
|
|
280
|
+
const rowsByCode = new Map();
|
|
281
|
+
if (wanted.length > 0) {
|
|
202
282
|
const rows = wireRows((await wireCall(session, { path: ENDPOINTS.bizServiceMethodList, query: { serviceCode: service.code, filterFlag: "false" } })).data);
|
|
203
|
-
|
|
283
|
+
for (const candidate of rows)
|
|
284
|
+
if (typeof candidate.code === "string")
|
|
285
|
+
rowsByCode.set(candidate.code, candidate);
|
|
204
286
|
}
|
|
205
|
-
result.push(serviceFromRow(row,
|
|
287
|
+
result.push(serviceFromRow(row, String(row.adapterCode ?? service.adapterCode), rowsByCode, service));
|
|
206
288
|
}
|
|
207
289
|
return result;
|
|
208
290
|
},
|
|
@@ -214,7 +296,12 @@ export const bizserviceCapability = {
|
|
|
214
296
|
const args = serviceArgs(service);
|
|
215
297
|
const resource = `service:${service.code}`;
|
|
216
298
|
if (!live?.present) {
|
|
299
|
+
// A brand-new service: `method` rides the legacy service.register payload
|
|
300
|
+
// (methodName==code), while `methods[]` registers the service alone and
|
|
301
|
+
// adds each method through method.create after it exists.
|
|
217
302
|
emit.change("service.register", args, resource, "service-absent");
|
|
303
|
+
for (const method of service.methods ?? [])
|
|
304
|
+
emit.change("method.create", methodArgs(service, method), `method:${service.code}.${method.code}`, "method-absent");
|
|
218
305
|
continue;
|
|
219
306
|
}
|
|
220
307
|
// An existing service is patched, not recreated. adapterCode is fixed at
|
|
@@ -226,25 +313,23 @@ export const bizserviceCapability = {
|
|
|
226
313
|
emit.change("service.update", { serviceCode: service.code, name: service.name, serviceConfig: service.serviceConfig }, resource, "service-drift");
|
|
227
314
|
else
|
|
228
315
|
emit.skip(resource, "service-present");
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
else
|
|
247
|
-
emit.skip(methodResource, "method-present");
|
|
316
|
+
// Every declared method is ensured present: absent -> method.create, drift
|
|
317
|
+
// -> method.update, converged -> skip. This is what lets an existing
|
|
318
|
+
// service receive new methods declaratively.
|
|
319
|
+
for (const method of declaredMethods(service)) {
|
|
320
|
+
const methodResource = `method:${service.code}.${method.code}`;
|
|
321
|
+
const liveMethod = service.methods !== undefined
|
|
322
|
+
? live.methods?.find((entry) => entry.code === method.code)
|
|
323
|
+
: live.method;
|
|
324
|
+
if (!liveMethod?.present) {
|
|
325
|
+
emit.change("method.create", methodArgs(service, method), methodResource, "method-absent");
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
if (liveMethod.name !== method.name || !sameValue(liveMethod.methodConfig, expectedMethodConfig(service.adapterCode, method.methodConfig)) || !sameParameterFace(liveMethod.inputParameters, expectedParameterFace(service.adapterCode, method.inputParameters, "methodInputParameters")) || !sameParameterFace(liveMethod.outputParameters, expectedParameterFace(service.adapterCode, method.outputParameters, "methodOutputParameters")))
|
|
329
|
+
emit.change("method.update", methodArgs(service, method), methodResource, "method-drift");
|
|
330
|
+
else
|
|
331
|
+
emit.skip(methodResource, "method-present");
|
|
332
|
+
}
|
|
248
333
|
}
|
|
249
334
|
},
|
|
250
335
|
decodeRoot(baseline, live) {
|
|
@@ -261,12 +346,16 @@ export const bizserviceCapability = {
|
|
|
261
346
|
}
|
|
262
347
|
if (current.name !== service.name || current.adapterCode !== service.adapterCode || !sameValue(current.serviceConfig, service.serviceConfig))
|
|
263
348
|
emit.difference("service-mismatch", resource, `业务服务 ${service.code} 的名称/适配器/configJson 不等价`);
|
|
264
|
-
|
|
265
|
-
const method =
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
emit.difference("method-
|
|
349
|
+
for (const declared of declaredMethods(service)) {
|
|
350
|
+
const method = service.methods !== undefined
|
|
351
|
+
? current.methods?.find((entry) => entry.code === declared.code)
|
|
352
|
+
: current.method;
|
|
353
|
+
if (!method?.present) {
|
|
354
|
+
emit.difference("method-missing", `method:${service.code}.${declared.code}`, `业务方法 ${service.code}/${declared.code} 不存在`);
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
if (method.name !== declared.name || !sameValue(method.methodConfig, expectedMethodConfig(service.adapterCode, declared.methodConfig)) || !sameParameterFace(method.inputParameters, expectedParameterFace(service.adapterCode, declared.inputParameters, "methodInputParameters")) || !sameParameterFace(method.outputParameters, expectedParameterFace(service.adapterCode, declared.outputParameters, "methodOutputParameters")))
|
|
358
|
+
emit.difference("method-mismatch", `method:${service.code}.${declared.code}`, `业务方法 ${service.code}/${declared.code} 不等价`);
|
|
270
359
|
}
|
|
271
360
|
}
|
|
272
361
|
},
|
|
@@ -60,7 +60,7 @@ export const dataruleCapability = {
|
|
|
60
60
|
id: "datarule",
|
|
61
61
|
title: "字段级控件规则",
|
|
62
62
|
requires: ["field"],
|
|
63
|
-
operations: ["create", "update"],
|
|
63
|
+
operations: ["create", "update", "delete"],
|
|
64
64
|
validate(node, draft, ctx) {
|
|
65
65
|
const rulesNode = node.entries.find((entry) => entry.key === "datarules")?.value;
|
|
66
66
|
if (rulesNode === undefined || (rulesNode.kind === "scalar" && rulesNode.value === null))
|
package/dist/intent/cli.js
CHANGED
|
@@ -43,7 +43,7 @@ export function intentCapabilityBlock() {
|
|
|
43
43
|
declarativeCapabilities: { model: "partial", field: "partial", businessrule: "partial", datarule: "partial", workflow: "partial", onlinejs: "partial", bizservice: "partial", report: "partial" },
|
|
44
44
|
absence: "models[].absent:true deletes a whole model; fields[]/listview/datarules[] take absent:true too. Only declared-absent resources are deleted; riskClass becomes destructive and plan.cleanup lists them.",
|
|
45
45
|
workflowBindings: "models[].workflow.bindRules: [{handler: start|cancel|activate|end, ruleCodes:[...]}] ensures the rules are bound (workflow.bindRule MERGES; undeclared bindings are ignored).",
|
|
46
|
-
servicesNote: "top-level services[] registers a
|
|
46
|
+
servicesNote: "top-level services[] registers or patches a service. method (single, name==code, rides service.register) and methods[] (multiple, name may differ from code; missing methods planned as method.create, drift as method.update) are mutually exclusive.",
|
|
47
47
|
reportsNote: "top-level reports[] creates/configures a report page + BI dashboard (global/attributes/charts); charts diff by uuid, removeUnlistedCharts:true deletes undeclared charts. Only declared reports are touched.",
|
|
48
48
|
applyVerification: {
|
|
49
49
|
default: "on",
|
package/dist/intent/compiler.js
CHANGED
|
@@ -53,6 +53,7 @@ export function compileIntent(intent, baseline) {
|
|
|
53
53
|
service: service.code,
|
|
54
54
|
adapterCode: service.adapterCode,
|
|
55
55
|
...(service.method ? { methodCode: service.method.code } : {}),
|
|
56
|
+
...(service.methods ? { methodCodes: service.methods.map((method) => method.code) } : {}),
|
|
56
57
|
}));
|
|
57
58
|
const expectedReports = (intent.reports ?? []).map((report) => ({
|
|
58
59
|
report: report.code,
|
|
@@ -561,7 +561,11 @@ export async function applyIntent(planPath, options, ports) {
|
|
|
561
561
|
const summary = `intent apply ${planId}:${changes.length} 项变更(${[...toolCounts.entries()].map(([tool, count]) => (count > 1 ? `${tool}×${count}` : tool)).join("、")})`;
|
|
562
562
|
let result;
|
|
563
563
|
try {
|
|
564
|
-
|
|
564
|
+
// R88 #3:--reason 随上下文进本批次的写审计面(apply_changes 落一条批量
|
|
565
|
+
// 审计行时读取),不是工具入参、不进 schema。逐步写本身不产生 journal 行
|
|
566
|
+
// (无 before 快照),所以审计只到「谁用哪份意图、为什么」这一层。
|
|
567
|
+
const auditContext = options.reason === undefined ? context : { ...context, writeAudit: { reason: options.reason } };
|
|
568
|
+
result = (await applyChanges.handler(auditContext, parseToolInput(applyChanges, {
|
|
565
569
|
changes,
|
|
566
570
|
environment: plan.environment,
|
|
567
571
|
summary,
|
package/dist/intent/schema.js
CHANGED
|
@@ -164,7 +164,7 @@ export function intentSchemaBlock() {
|
|
|
164
164
|
conditionOperators: INTENT_CONDITION_OPERATORS,
|
|
165
165
|
workflow: { required: ["code", "name", "publish"], optional: ["template", "bindRules"], note: "bindRules [{handler: start|cancel|activate|end, ruleCodes:[...]}];流程事件只绑自定义规则" },
|
|
166
166
|
onlinejs: { required: ["source", "publish"], optional: ["sheetCode", "replace"], note: "replace:true 覆盖;merge 时 source 只给生命周期片段,不能是完整 (function(form){...})" },
|
|
167
|
-
services: { required: ["code", "name", "adapterCode", "serviceCategoryId", "serviceConfig"], optional: ["method"], note: "
|
|
167
|
+
services: { required: ["code", "name", "adapterCode", "serviceCategoryId", "serviceConfig"], optional: ["method", "methods"], note: "method 与 methods 互斥:method 是单方法(name==code,随 service.register);methods[] 是多方法/给既有服务加方法(name 可不同于 code,缺失 plan method.create、漂移 plan method.update)。自定义/INTERNAL 适配器走二开扩展包导入,不在声明式写面" },
|
|
168
168
|
examples: RUNNABLE_EXAMPLES.map((example) => ({ id: example.id, title: example.title })),
|
|
169
169
|
exampleHint: "取可运行 YAML:omc describe intent --example <id>",
|
|
170
170
|
versionNotice: "intent 只覆盖声明式子集(capabilities 的 intent: partial);未覆盖面用 omc call 补齐。",
|
package/dist/journal.js
CHANGED
|
@@ -13,7 +13,20 @@ import { invalidateProjectCard } from "./project-card.js";
|
|
|
13
13
|
*
|
|
14
14
|
* Local-machine boundary (deliberate, v1): the journal and the before
|
|
15
15
|
* snapshots inside artifacts stay on the machine that performed the writes;
|
|
16
|
-
* teaching says so. A fresh machine has no rollback history.
|
|
16
|
+
* teaching says so. A fresh machine has no rollback history. This is also the
|
|
17
|
+
* audit boundary: one `.omc/journal/<env>.ndjson` per PROJECT directory, so a
|
|
18
|
+
* team sharing one machine sees each other's writes only inside that project,
|
|
19
|
+
* and no global daemon/secret store is introduced. `omc rollback list` is the
|
|
20
|
+
* query face — there is deliberately no second `omc audit` truth source.
|
|
21
|
+
*
|
|
22
|
+
* Concurrency boundary (known, deliberate): `seq = lineCount + 1` is not
|
|
23
|
+
* atomic across processes. Concurrent writes to the same environment are
|
|
24
|
+
* serialized by the environment write lock (write-lock.ts) around the tool
|
|
25
|
+
* call, so a racing pair is refused rather than interleaved; two DIFFERENT
|
|
26
|
+
* projects writing the same environment have separate journal files and
|
|
27
|
+
* separate locks. A duplicated seq from an external writer (hand-edited file)
|
|
28
|
+
* is tolerated: `rollback plan <seq>` resolves the first match and `ts` still
|
|
29
|
+
* orders the timeline. Do not add a global lock for a local append-only file.
|
|
17
30
|
*/
|
|
18
31
|
function journalRoot(artifactsDir) {
|
|
19
32
|
return join(resolve(artifactsDir), "..", "journal");
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
|
+
import { basename } from "node:path";
|
|
3
4
|
import { confirmProductionArg, environmentArg, WRITE_PROTOCOL } from "../args.js";
|
|
4
5
|
import { executePackage } from "../package.js";
|
|
5
6
|
import { plannableArgs } from "../plan.js";
|
|
6
7
|
import { isUncertainWireError, wireErrorKind, writeArtifact } from "../support.js";
|
|
7
8
|
import { defineTool, parseToolInput, ToolInputError, ToolRefusalError } from "../tool-types.js";
|
|
9
|
+
import { appendJournalEntry } from "../journal.js";
|
|
10
|
+
import { journalAudit } from "../write-audit.js";
|
|
8
11
|
import { WireError } from "../wire.js";
|
|
9
12
|
/**
|
|
10
13
|
* Ticket 58: the batch time budget. `startedAt` is the execution start (ms
|
|
@@ -116,7 +119,7 @@ export function registerApplyChangesLane(tools) {
|
|
|
116
119
|
return { lane: target.lane, scope: target.scope };
|
|
117
120
|
}),
|
|
118
121
|
};
|
|
119
|
-
|
|
122
|
+
const batchResult = await executePackage(ctx, plan, coverage, args, async (session) => {
|
|
120
123
|
const steps = [];
|
|
121
124
|
// Ticket 58: a recoverable handle for a long batch. Every step appends
|
|
122
125
|
// to one progress artifact, so a client-side timeout or a killed
|
|
@@ -244,7 +247,52 @@ export function registerApplyChangesLane(tools) {
|
|
|
244
247
|
summary: args.summary ?? `已按序完成 ${steps.length} 项变更(${toolPhrase(changes)})`,
|
|
245
248
|
};
|
|
246
249
|
});
|
|
250
|
+
// R88 #3 审计面:批量写此前在 journal 里完全不可见(intent apply 也是
|
|
251
|
+
// 经本工具执行的),多人共用一台机器时「谁用哪份意图改了什么、为什么」
|
|
252
|
+
// 无处可查。这里只落**一条**批量审计行(与 configure_* 复合写同口径):
|
|
253
|
+
// 逐步 before 快照并未捕获,所以 rollbackable:false,绝不假装能整包回滚。
|
|
254
|
+
if (batchResult.status === "ok" && batchResult.deliveryState === "DELIVERED")
|
|
255
|
+
await recordBatchJournal(ctx, args, batchResult);
|
|
256
|
+
return batchResult;
|
|
247
257
|
},
|
|
248
258
|
}));
|
|
249
259
|
}
|
|
260
|
+
/** One honest journal line per delivered batch (audit only, not a rollback unit). */
|
|
261
|
+
async function recordBatchJournal(ctx, args, result) {
|
|
262
|
+
const steps = Array.isArray(result.steps) ? result.steps : [];
|
|
263
|
+
if (steps.length === 0)
|
|
264
|
+
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
|
+
const readback = (result.readback ?? {});
|
|
268
|
+
const progressFile = typeof readback.progressFile === "string" ? readback.progressFile : undefined;
|
|
269
|
+
const summary = typeof result.summary === "string" ? result.summary : undefined;
|
|
270
|
+
let environment = typeof args.environment === "string" && args.environment.length > 0 ? args.environment : "local";
|
|
271
|
+
let environmentFingerprint = "batch";
|
|
272
|
+
try {
|
|
273
|
+
// The batch itself established this session: a cache hit, never a second login.
|
|
274
|
+
const session = await ctx.sessions.session(args.environment);
|
|
275
|
+
environment = session.environmentName;
|
|
276
|
+
environmentFingerprint = session.environmentFingerprint();
|
|
277
|
+
}
|
|
278
|
+
catch { /* journal still useful with the raw env name */ }
|
|
279
|
+
const entry = appendJournalEntry(ctx.artifactsDir, {
|
|
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",
|
|
292
|
+
});
|
|
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
|
+
}
|
|
250
298
|
//# sourceMappingURL=apply-changes.js.map
|