@stalfh233/omc-cli 0.6.87 → 0.6.89
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/cli.js +44 -11
- package/dist/endpoints.js +14 -0
- package/dist/intent/capabilities/bizservice.js +7 -82
- package/dist/lanes/b2-registration.js +97 -4
- package/dist/lanes/businessrule-contract.js +3 -3
- package/dist/lanes/businessrule.js +403 -9
- package/dist/lanes/online-js.js +1 -1
- package/dist/lanes/runtime-data-contract.js +5 -1
- package/dist/lanes/runtime-data.js +253 -27
- package/dist/method-references.js +134 -0
- package/dist/path-projection.js +120 -37
- package/dist/read-shapes.js +28 -2
- package/dist/tool-types.js +5 -0
- package/package.json +3 -3
- package/skills/omc-refusals.md +1 -0
package/dist/cli.js
CHANGED
|
@@ -26,7 +26,7 @@ import { artifactFetchHint, artifactRoot, boundResult, emitInvalid, emitResult,
|
|
|
26
26
|
import { CLI_DEFAULT_OUTPUT_BYTES, assertSafeOutputPath, pruneArtifacts } from "./artifacts.js";
|
|
27
27
|
import { sessionAccountForEnvironment } from "./session-account.js";
|
|
28
28
|
import { closeWritableWindow, openWritableWindow, parseWritableTtl, sweepWritableWindowsAtStartup, validateWritableReason, writableWindowStatus, WRITABLE_WINDOW_DEFAULT_TTL_MINUTES, WRITABLE_WINDOW_LOG, WRITABLE_WINDOW_MAX_TTL_MINUTES, WritableWindowInputError } from "./writable-window.js";
|
|
29
|
-
import { artifactPathMissHint, nullProjectionHint, partialPathMissHint, pathMissCopyableHint, pathMissDidYouMean, projectJsonPath, projectJsonPathFanout, projectResultExtract, shapeOf, SHAPE_MAX_DEPTH, unwrapSinglePathProjection } from "./path-projection.js";
|
|
29
|
+
import { artifactPathMissHint, nullProjectionHint, PATH_MISS_HELP_REF, partialPathMissHint, pathMissCopyableHint, pathMissCopyablePaths, pathMissCrossFaceCorrection, pathMissDidYouMean, projectJsonPath, projectJsonPathFanout, projectResultExtract, shapeOf, SHAPE_MAX_DEPTH, unwrapSinglePathProjection } from "./path-projection.js";
|
|
30
30
|
import { basename, join, resolve } from "node:path";
|
|
31
31
|
import { existsSync, readFileSync, writeFileSync, chmodSync } from "node:fs";
|
|
32
32
|
import { buildToolRegistry } from "./tools.js";
|
|
@@ -493,7 +493,7 @@ async function cmdBatchCall(store, toolName, rawList, options) {
|
|
|
493
493
|
.flatMap((path) => path.split(",")).map((path) => path.trim()).filter(Boolean);
|
|
494
494
|
const preflightKeys = options.args.includes("--extract-keys") || options.args.includes("--keys") || options.args.some((token, index) => token === "--jq" && (options.args[index + 1] === undefined || options.args[index + 1].startsWith("--")));
|
|
495
495
|
if (preflightPaths.length > 0 || preflightKeys) {
|
|
496
|
-
const projected = projectResultExtract(result, preflightPaths, preflightKeys);
|
|
496
|
+
const projected = projectResultExtract(result, preflightPaths, preflightKeys, { tool: toolName, ...(options.environment !== undefined ? { environment: options.environment } : {}) });
|
|
497
497
|
if (projected !== undefined)
|
|
498
498
|
result = projected;
|
|
499
499
|
}
|
|
@@ -764,7 +764,15 @@ async function cmdCall(store, args) {
|
|
|
764
764
|
blocker: "tool-input-unknown-keys",
|
|
765
765
|
tool: toolName,
|
|
766
766
|
unknownKeys: otherUnknown,
|
|
767
|
+
// F1(retro 22,ticket 138):与写面同款机器字段——被拒键 + 合法键全集
|
|
768
|
+
// 成对给出;nextCommand 指向「最接近的合法键」的参数面(而非整份
|
|
769
|
+
// describe),脚本可零解析消费。
|
|
770
|
+
expectedKeys: [...schemaKeys],
|
|
767
771
|
suggestions,
|
|
772
|
+
// 有拼写近邻时直达该参数的 describe;否则退回整份参数表。
|
|
773
|
+
...(suggestions.some((entry) => entry.closest !== undefined)
|
|
774
|
+
? { nextCommand: `omc describe ${toolName} --param ${suggestions.find((entry) => entry.closest !== undefined).closest}` }
|
|
775
|
+
: { nextCommand: `omc describe ${toolName}` }),
|
|
768
776
|
message: `读面不接受未知键(与写面对齐):${pairs.join("、")}。` +
|
|
769
777
|
`改用合法键后重试;确需宽松忽略传 lenientArgs:true。参数表:omc describe ${toolName}`,
|
|
770
778
|
};
|
|
@@ -847,7 +855,14 @@ async function cmdCall(store, args) {
|
|
|
847
855
|
let unwrappedBody;
|
|
848
856
|
let resultMeta;
|
|
849
857
|
if (extractPaths.length > 0 || extractKeys) {
|
|
850
|
-
|
|
858
|
+
// F1(retro 22,ticket 138):把调用上下文交给投影层——pathMiss 能推导出
|
|
859
|
+
// correctPath 时,拼一条含 --env/--args/--jq 的完整可复制命令(nextCommand)。
|
|
860
|
+
// args 用调用方**原始** JSON(未归一化),>500B 时投影层放弃拼命令(不截断造假)。
|
|
861
|
+
const projected = projectResultExtract(result, extractPaths, extractKeys, {
|
|
862
|
+
tool: toolName,
|
|
863
|
+
...(environment !== undefined && environment.length > 0 ? { environment } : {}),
|
|
864
|
+
argsJson: rawArgs !== undefined ? rawArgs : JSON.stringify(parsedArgs),
|
|
865
|
+
});
|
|
851
866
|
if (projected !== undefined)
|
|
852
867
|
result = projected;
|
|
853
868
|
// Projected reads are represented by extract[] (and rows[] for multi-path).
|
|
@@ -1015,7 +1030,24 @@ function projectArtifactPath(value, path) {
|
|
|
1015
1030
|
const fanout = projectJsonPathFanout(value, path);
|
|
1016
1031
|
return fanout.missed
|
|
1017
1032
|
? { missed: true, ...(fanout.at !== undefined ? { at: fanout.at } : {}), ...(fanout.available !== undefined ? { available: fanout.available } : {}), ...(fanout.availableAll !== undefined ? { availableAll: fanout.availableAll } : {}), ...(fanout.availableTruncated !== undefined ? { availableTruncated: fanout.availableTruncated } : {}) }
|
|
1018
|
-
: { missed: false, content: fanout.values, mapped: fanout.values.length, ...(fanout.missedEntries > 0 ? { missedEntries: fanout.missedEntries } : {}), nullEntries: fanout.nullEntries };
|
|
1033
|
+
: { missed: false, content: fanout.values, mapped: fanout.values.length, ...(fanout.missedEntries > 0 ? { missedEntries: fanout.missedEntries } : {}), nullEntries: fanout.nullEntries, nonNullEntries: fanout.nonNullEntries };
|
|
1034
|
+
}
|
|
1035
|
+
/**
|
|
1036
|
+
* F1/F2(retro 21/22,ticket 138):artifact 面 pathMiss 的机器可读纠错面——
|
|
1037
|
+
* `correctPath`(已验证可解析)+ `helpRef`(教程指针)+ 可整段复制的重跑命令。
|
|
1038
|
+
* 与 call 面(projectResultExtract)同一套推导(拼写近似走 didYouMean 字段,
|
|
1039
|
+
* 这里只补跨面改写与同名键两条**全路径**推导),推导不出就全部缺席(不编造)。
|
|
1040
|
+
*/
|
|
1041
|
+
function artifactMissCorrection(content, path, at, artifactId) {
|
|
1042
|
+
const correction = pathMissCrossFaceCorrection(content, path, at) ?? (() => {
|
|
1043
|
+
const copyable = pathMissCopyablePaths(content, path, at, 1);
|
|
1044
|
+
return copyable.length > 0 ? { correctPath: copyable[0] } : undefined;
|
|
1045
|
+
})();
|
|
1046
|
+
return {
|
|
1047
|
+
...(correction !== undefined ? { correctPath: correction.correctPath } : {}),
|
|
1048
|
+
helpRef: PATH_MISS_HELP_REF,
|
|
1049
|
+
...(correction !== undefined ? { nextCommand: `omc artifact get ${artifactId} --jq '${correction.correctPath.replace(/'/g, "'\\''")}'` } : {}),
|
|
1050
|
+
};
|
|
1019
1051
|
}
|
|
1020
1052
|
/** Preserve source completeness/count facts on every artifact projection. */
|
|
1021
1053
|
function artifactProjectionMetadata(value) {
|
|
@@ -1140,7 +1172,7 @@ async function cmdArtifactGet(id, transport, options = {}) {
|
|
|
1140
1172
|
// `--shape <path>`:在命中的子树上出骨架(同 --jq 的路径 DSL,含 [] 与 [code=X])。
|
|
1141
1173
|
const projected = projectArtifactPath(artifact.content.toString("utf8") === "" ? undefined : content, options.shape);
|
|
1142
1174
|
if (projected.missed) {
|
|
1143
|
-
return emitTransportResult({ status: "ok", artifactId: id, sha256: artifact.sha256, ...artifactProjectionMetadata(content), path: options.shape, content: null, pathMiss: true, missedAt: projected.at, available: projected.available, ...artifactMissExtras(projected), unanswered: true, hint: artifactPathMissHint(projected.at, pathMissCopyableHint(content, options.shape, projected.at)) }, transport);
|
|
1175
|
+
return emitTransportResult({ status: "ok", artifactId: id, sha256: artifact.sha256, ...artifactProjectionMetadata(content), path: options.shape, content: null, pathMiss: true, missedAt: projected.at, available: projected.available, ...artifactMissExtras(projected), unanswered: true, ...artifactMissCorrection(content, options.shape, projected.at, id), hint: artifactPathMissHint(projected.at, pathMissCopyableHint(content, options.shape, projected.at)) }, transport);
|
|
1144
1176
|
}
|
|
1145
1177
|
return emitTransportResult({ status: "ok", artifactId: id, sha256: artifact.sha256, bytes: artifact.content.length, path: options.shape, depth, shape: shapeOf(projected.content, depth), fetch: artifactFetchHint(id) }, transport);
|
|
1146
1178
|
}
|
|
@@ -1183,7 +1215,7 @@ async function cmdArtifactGet(id, transport, options = {}) {
|
|
|
1183
1215
|
// 一层 `projection:{path,content}`——`artifact get --jq` 与 `--summary --jq`
|
|
1184
1216
|
// 因此同形(顶层 path/content),换读面不用重新探根键。
|
|
1185
1217
|
return emitTransportResult(projected.missed
|
|
1186
|
-
? { status: "ok", artifactId: id, sha256: artifact.sha256, bytes: artifact.content.length, ...artifactProjectionMetadata(content), keys, path: options.jq, content: null, projections: [{ path: options.jq, content: null, pathMiss: true, missedAt: projected.at, available: projected.available, ...artifactMissExtras(projected) }], pathMiss: true, missedAt: projected.at, available: projected.available, ...artifactMissExtras(projected), unanswered: true, hint: artifactPathMissHint(projected.at, pathMissCopyableHint(content, options.jq, projected.at)) }
|
|
1218
|
+
? { status: "ok", artifactId: id, sha256: artifact.sha256, bytes: artifact.content.length, ...artifactProjectionMetadata(content), keys, path: options.jq, content: null, projections: [{ path: options.jq, content: null, pathMiss: true, missedAt: projected.at, available: projected.available, ...artifactMissExtras(projected) }], pathMiss: true, missedAt: projected.at, available: projected.available, ...artifactMissExtras(projected), unanswered: true, ...artifactMissCorrection(content, options.jq, projected.at, id), hint: artifactPathMissHint(projected.at, pathMissCopyableHint(content, options.jq, projected.at)) }
|
|
1187
1219
|
: {
|
|
1188
1220
|
status: "ok",
|
|
1189
1221
|
artifactId: id,
|
|
@@ -1192,9 +1224,10 @@ async function cmdArtifactGet(id, transport, options = {}) {
|
|
|
1192
1224
|
...artifactProjectionMetadata(content),
|
|
1193
1225
|
keys,
|
|
1194
1226
|
path: options.jq,
|
|
1195
|
-
projections: [{ path: options.jq, content: projected.content ?? null, ...(projected.mapped !== undefined ? { mapped: projected.mapped } : {}), ...(projected.missedEntries !== undefined ? { missedEntries: projected.missedEntries } : {}), ...(projected.nullEntries !== undefined && projected.nullEntries > 0 ? { nullEntries: projected.nullEntries } : {}) }],
|
|
1227
|
+
projections: [{ path: options.jq, content: projected.content ?? null, ...(projected.mapped !== undefined ? { mapped: projected.mapped } : {}), ...(projected.missedEntries !== undefined ? { missedEntries: projected.missedEntries } : {}), ...(projected.nullEntries !== undefined && projected.nullEntries > 0 ? { nullEntries: projected.nullEntries } : {}), ...(projected.nonNullEntries !== undefined ? { nonNullEntries: projected.nonNullEntries } : {}) }],
|
|
1196
1228
|
...(projected.mapped !== undefined ? { mapped: projected.mapped } : {}),
|
|
1197
1229
|
...(projected.nullEntries !== undefined && projected.nullEntries > 0 ? { nullEntries: projected.nullEntries } : {}),
|
|
1230
|
+
...(projected.nonNullEntries !== undefined ? { nonNullEntries: projected.nonNullEntries } : {}),
|
|
1198
1231
|
...(projected.missedEntries !== undefined ? { missedEntries: projected.missedEntries } : {}),
|
|
1199
1232
|
...(artifactNullHint(projected.content, projected.nullEntries) !== undefined ? { hint: artifactNullHint(projected.content, projected.nullEntries) } : {}),
|
|
1200
1233
|
}, transport);
|
|
@@ -1235,15 +1268,15 @@ async function cmdArtifactGet(id, transport, options = {}) {
|
|
|
1235
1268
|
const projections = jqPaths.map((path) => {
|
|
1236
1269
|
const projected = projectArtifactPath(artifactContent, path);
|
|
1237
1270
|
return projected.missed
|
|
1238
|
-
? { path, content: null, pathMiss: true, missedAt: projected.at, available: projected.available, ...artifactMissExtras(projected) }
|
|
1239
|
-
: { path, content: projected.content ?? null, ...(projected.mapped !== undefined ? { mapped: projected.mapped } : {}), ...(projected.missedEntries !== undefined ? { missedEntries: projected.missedEntries } : {}), ...(projected.nullEntries !== undefined && projected.nullEntries > 0 ? { nullEntries: projected.nullEntries } : {}), ...(artifactNullHint(projected.content, projected.nullEntries) !== undefined ? { hint: artifactNullHint(projected.content, projected.nullEntries) } : {}) };
|
|
1271
|
+
? { path, content: null, pathMiss: true, missedAt: projected.at, available: projected.available, ...artifactMissExtras(projected), ...artifactMissCorrection(artifactContent, path, projected.at, id) }
|
|
1272
|
+
: { path, content: projected.content ?? null, ...(projected.mapped !== undefined ? { mapped: projected.mapped } : {}), ...(projected.missedEntries !== undefined ? { missedEntries: projected.missedEntries } : {}), ...(projected.nullEntries !== undefined && projected.nullEntries > 0 ? { nullEntries: projected.nullEntries } : {}), ...(projected.nonNullEntries !== undefined ? { nonNullEntries: projected.nonNullEntries } : {}), ...(artifactNullHint(projected.content, projected.nullEntries) !== undefined ? { hint: artifactNullHint(projected.content, projected.nullEntries) } : {}) };
|
|
1240
1273
|
});
|
|
1241
1274
|
return emitTransportResult({ status: "ok", artifactId: id, sha256: artifact.sha256, ...artifactProjectionMetadata(content), projections, ...(projections.some((entry) => entry.pathMiss) ? { unanswered: true, hint: partialPathMissHint() } : {}) }, transport);
|
|
1242
1275
|
}
|
|
1243
1276
|
const projected = projectArtifactPath(artifactContent, options.jq);
|
|
1244
1277
|
return emitTransportResult(projected.missed
|
|
1245
|
-
? { status: "ok", artifactId: id, sha256: artifact.sha256, ...artifactProjectionMetadata(content), path: options.jq, content: null, pathMiss: true, missedAt: projected.at, available: projected.available, ...artifactMissExtras(projected), unanswered: true, hint: artifactPathMissHint(projected.at, pathMissCopyableHint(artifactContent, options.jq, projected.at)) }
|
|
1246
|
-
: { status: "ok", artifactId: id, sha256: artifact.sha256, ...artifactProjectionMetadata(content), path: options.jq, projections: [{ path: options.jq, content: projected.content ?? null, ...(projected.mapped !== undefined ? { mapped: projected.mapped } : {}), ...(projected.missedEntries !== undefined ? { missedEntries: projected.missedEntries } : {}), ...(projected.nullEntries !== undefined && projected.nullEntries > 0 ? { nullEntries: projected.nullEntries } : {}) }], ...(projected.mapped !== undefined ? { mapped: projected.mapped } : {}), ...(projected.missedEntries !== undefined ? { missedEntries: projected.missedEntries } : {}), ...(projected.nullEntries !== undefined && projected.nullEntries > 0 ? { nullEntries: projected.nullEntries } : {}), ...(artifactNullHint(projected.content, projected.nullEntries) !== undefined ? { hint: artifactNullHint(projected.content, projected.nullEntries) } : {}) }, transport);
|
|
1278
|
+
? { status: "ok", artifactId: id, sha256: artifact.sha256, ...artifactProjectionMetadata(content), path: options.jq, content: null, pathMiss: true, missedAt: projected.at, available: projected.available, ...artifactMissExtras(projected), unanswered: true, ...artifactMissCorrection(artifactContent, options.jq, projected.at, id), hint: artifactPathMissHint(projected.at, pathMissCopyableHint(artifactContent, options.jq, projected.at)) }
|
|
1279
|
+
: { status: "ok", artifactId: id, sha256: artifact.sha256, ...artifactProjectionMetadata(content), path: options.jq, projections: [{ path: options.jq, content: projected.content ?? null, ...(projected.mapped !== undefined ? { mapped: projected.mapped } : {}), ...(projected.missedEntries !== undefined ? { missedEntries: projected.missedEntries } : {}), ...(projected.nullEntries !== undefined && projected.nullEntries > 0 ? { nullEntries: projected.nullEntries } : {}), ...(projected.nonNullEntries !== undefined ? { nonNullEntries: projected.nonNullEntries } : {}) }], ...(projected.mapped !== undefined ? { mapped: projected.mapped } : {}), ...(projected.missedEntries !== undefined ? { missedEntries: projected.missedEntries } : {}), ...(projected.nullEntries !== undefined && projected.nullEntries > 0 ? { nullEntries: projected.nullEntries } : {}), ...(projected.nonNullEntries !== undefined ? { nonNullEntries: projected.nonNullEntries } : {}), ...(artifactNullHint(projected.content, projected.nullEntries) !== undefined ? { hint: artifactNullHint(projected.content, projected.nullEntries) } : {}) }, transport);
|
|
1247
1280
|
}
|
|
1248
1281
|
// r6-onboarding 2026-10-21: 47 artifact fetches, 0 used a projection; the 10
|
|
1249
1282
|
// large ones (up to 55 KB) pulled whole workflow templates just to read one
|
package/dist/endpoints.js
CHANGED
|
@@ -172,6 +172,20 @@ export const ENDPOINTS = {
|
|
|
172
172
|
dataRuleDelete: "/api/api/app/bizdatarule/delete",
|
|
173
173
|
runtimeFormSave: "/api/api/runtime/form/save",
|
|
174
174
|
runtimeFormLoad: "/api/api/runtime/form/load",
|
|
175
|
+
/**
|
|
176
|
+
* 子表专用查询面(filter + 列投影 + 分页 + 服务端总数)。
|
|
177
|
+
* FormRuntimeController.list_child
|
|
178
|
+
* (cloudpivot-engine-8.6.26/.../runtime/FormRuntimeController.java:1901-1928)
|
|
179
|
+
* 校验 schemaCode/childSchemaCode/bizObjectId 后走
|
|
180
|
+
* BizObjectFacadeImpl.queryChildBizObjects
|
|
181
|
+
* (cloudpivot-bizdata-8.6.26/.../bizobject/BizObjectFacadeImpl.java:7594-7639),
|
|
182
|
+
* 强制 AND parentId=bizObjectId,回 PageVO<Map<String,Object>>
|
|
183
|
+
* (content 是扁平行 map,不是 query/list 的 {bizObjectId,data} 包装)。
|
|
184
|
+
* 坑:QueryDataVO.getSize() 在 size 为空/0 时返回 Integer.MAX_VALUE
|
|
185
|
+
* (cloudpivot-engine-8.6.26/.../view/runtime/QueryDataVO.java:186-191)——
|
|
186
|
+
* 调用方**必须显式传 size**,否则退化成全量。
|
|
187
|
+
*/
|
|
188
|
+
runtimeFormListChild: "/api/api/runtime/form/list_child",
|
|
175
189
|
runtimeFormReplayToken: "/api/api/runtime/form/getReplayToken",
|
|
176
190
|
runtimeQueryList: "/api/api/runtime/query/list",
|
|
177
191
|
/** 平台服务端聚合(QueryRuntimeController.sum,POST /runtime/query/sum;数值/公式列,ALL_DATA)。 */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ENDPOINTS } from "../../endpoints.js";
|
|
2
2
|
import { assertBizServiceAdapterWhitelisted, compileMethodConfigPlain, compileParameterFace, compileServiceConfig, normalizeMethodConfigReadback, normalizeParameterFaceReadback } from "../../bizservice-config.js";
|
|
3
|
+
import { countMethodMapping, methodReferencedCoreMessage, methodReferenceIdentity, scanMethodReferenceSites } from "../../method-references.js";
|
|
3
4
|
import { wireCall, wireRows, WireError } from "../../wire.js";
|
|
4
5
|
import { refuse } from "../capability.js";
|
|
5
6
|
import { sameValue } from "../compare.js";
|
|
@@ -163,92 +164,19 @@ function serviceFromRow(service, adapterCode, rowsByCode, declared) {
|
|
|
163
164
|
} : {}),
|
|
164
165
|
};
|
|
165
166
|
}
|
|
166
|
-
/** Platform reference count (F12)
|
|
167
|
+
/** Platform reference count (F12) — shared with `method.delete` (src/method-references.ts). */
|
|
167
168
|
async function countMapping(session, serviceCode, methodCode) {
|
|
168
|
-
|
|
169
|
-
path: ENDPOINTS.bizMethodCountMapping,
|
|
170
|
-
query: { serviceCode, ...(methodCode !== undefined ? { serviceMethodCode: methodCode } : {}) },
|
|
171
|
-
});
|
|
172
|
-
const value = response.data;
|
|
173
|
-
if (typeof value === "number" && Number.isFinite(value))
|
|
174
|
-
return value;
|
|
175
|
-
const parsed = Number(value);
|
|
176
|
-
return Number.isFinite(parsed) ? parsed : 0;
|
|
177
|
-
}
|
|
178
|
-
/** Cap the identity scan: only DECLARED-ABSENT methods that the platform already counts get here. */
|
|
179
|
-
const REFERENCE_SCAN_MODELS = 25;
|
|
180
|
-
const REFERENCE_SCAN_RULES = 50;
|
|
181
|
-
const REFERENCE_SITES_RETURNED = 8;
|
|
182
|
-
function mappedNodeCodes(nodeColumn, serviceCode, methodCode) {
|
|
183
|
-
const decoded = decodeColumn(nodeColumn);
|
|
184
|
-
if (!Array.isArray(decoded))
|
|
185
|
-
return [];
|
|
186
|
-
const nodeCodes = [];
|
|
187
|
-
for (const entry of decoded) {
|
|
188
|
-
if (!entry || typeof entry !== "object" || Array.isArray(entry))
|
|
189
|
-
continue;
|
|
190
|
-
const node = entry;
|
|
191
|
-
const mapping = node.methodMapping;
|
|
192
|
-
if (!mapping || typeof mapping !== "object" || Array.isArray(mapping))
|
|
193
|
-
continue;
|
|
194
|
-
const mapped = mapping;
|
|
195
|
-
if (String(mapped.serviceCode ?? "") !== serviceCode || String(mapped.serviceMethodCode ?? "") !== methodCode)
|
|
196
|
-
continue;
|
|
197
|
-
const nodeCode = String(node.nodeCode ?? "");
|
|
198
|
-
if (nodeCode !== "")
|
|
199
|
-
nodeCodes.push(nodeCode);
|
|
200
|
-
}
|
|
201
|
-
return nodeCodes;
|
|
169
|
+
return countMethodMapping(session, serviceCode, methodCode);
|
|
202
170
|
}
|
|
203
171
|
/**
|
|
204
172
|
* Readable identity of a reference (ruleCode/nodeCode) for the method-delete
|
|
205
173
|
* warning. `count_mapping` is the authoritative count; this is only the label —
|
|
206
174
|
* every read is best-effort and a failure degrades to a pointer at
|
|
207
|
-
* `rule.references kind=service`, never to a wrong claim.
|
|
175
|
+
* `rule.references kind=service`, never to a wrong claim. The scan itself lives
|
|
176
|
+
* in the shared module so `method.delete` and intent never drift apart.
|
|
208
177
|
*/
|
|
209
178
|
async function referenceSitesOf(session, serviceCode, methodCode) {
|
|
210
|
-
|
|
211
|
-
try {
|
|
212
|
-
const rows = wireRows((await wireCall(session, {
|
|
213
|
-
path: ENDPOINTS.bizServiceMethodViewReference,
|
|
214
|
-
query: { serviceCode, serviceMethodCode: methodCode },
|
|
215
|
-
})).data);
|
|
216
|
-
schemaCodes = [...new Set(rows.map((row) => String(row.schemaCode ?? "")).filter((code) => code !== ""))].slice(0, REFERENCE_SCAN_MODELS);
|
|
217
|
-
}
|
|
218
|
-
catch {
|
|
219
|
-
return [];
|
|
220
|
-
}
|
|
221
|
-
const sites = [];
|
|
222
|
-
for (const schemaCode of schemaCodes) {
|
|
223
|
-
let rules = [];
|
|
224
|
-
try {
|
|
225
|
-
rules = wireRows((await wireCall(session, { path: ENDPOINTS.businessRuleListBySchemaCode, query: { schemaCode } })).data);
|
|
226
|
-
}
|
|
227
|
-
catch {
|
|
228
|
-
continue;
|
|
229
|
-
}
|
|
230
|
-
for (const rule of rules.slice(0, REFERENCE_SCAN_RULES)) {
|
|
231
|
-
const ruleCode = String(rule.code ?? "");
|
|
232
|
-
const id = rule.id;
|
|
233
|
-
if (ruleCode === "" || typeof id !== "string" || id === "")
|
|
234
|
-
continue;
|
|
235
|
-
let record = null;
|
|
236
|
-
try {
|
|
237
|
-
record = (await wireCall(session, { path: ENDPOINTS.businessRuleGet, query: { id } })).data;
|
|
238
|
-
}
|
|
239
|
-
catch {
|
|
240
|
-
continue;
|
|
241
|
-
}
|
|
242
|
-
if (!record)
|
|
243
|
-
continue;
|
|
244
|
-
for (const nodeCode of mappedNodeCodes(record.node, serviceCode, methodCode)) {
|
|
245
|
-
sites.push({ schemaCode, ruleCode, nodeCode });
|
|
246
|
-
if (sites.length >= REFERENCE_SITES_RETURNED)
|
|
247
|
-
return sites;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
return sites;
|
|
179
|
+
return (await scanMethodReferenceSites(session, serviceCode, methodCode)).sites;
|
|
252
180
|
}
|
|
253
181
|
function validateServiceNode(serviceNode, index, draft, validation) {
|
|
254
182
|
const base = `services[${index}]`;
|
|
@@ -638,10 +566,7 @@ function liveMethodOf(service, declared, methodCode) {
|
|
|
638
566
|
function methodReferencedWarning(serviceCode, methodCode, liveMethod) {
|
|
639
567
|
const count = liveMethod.referenceCount ?? 0;
|
|
640
568
|
const sites = liveMethod.referenceSites ?? [];
|
|
641
|
-
|
|
642
|
-
? `;引用点:${sites.slice(0, 3).map((site) => `${site.schemaCode}/${site.ruleCode}#${site.nodeCode}`).join("、")}${sites.length > 3 ? ` 等 ${sites.length} 处` : ""}`
|
|
643
|
-
: `;定位:omc call rule.references --args '{"kind":"service","code":"${serviceCode}"}'`;
|
|
644
|
-
return `业务方法 ${serviceCode}/${methodCode} 仍被 ${count} 条规则映射引用——平台删除会回 500108「业务方法已绑定默认方法,不可删除」(BizServiceMethodController.java:248-281),apply 会在该步原样失败且不删任何东西。先解绑引用规则(rule.save 去掉对应 BIZ_ACTION 节点)并 apply,再删方法${identity}`;
|
|
569
|
+
return methodReferencedCoreMessage(serviceCode, methodCode, count) + methodReferenceIdentity(sites, serviceCode);
|
|
645
570
|
}
|
|
646
571
|
/** Attach method-level reference counts (+ readable sites) to declared-absent methods of a present service. */
|
|
647
572
|
async function withMethodReferences(session, entry, declared, absentCodes) {
|
|
@@ -7,6 +7,7 @@ import { capabilityArg, environmentArg } from "../args.js";
|
|
|
7
7
|
import { governedRead } from "../read.js";
|
|
8
8
|
import { writeTool } from "../write.js";
|
|
9
9
|
import { decodeJsonColumn as decodeSharedJsonColumn, JSON_COLUMN_NULL_COALESCE } from "../json-column.js";
|
|
10
|
+
import { countMethodMapping, methodReferencedCoreMessage, methodReferenceIdentity, scanMethodReferenceSites } from "../method-references.js";
|
|
10
11
|
import { defineTool, ToolRefusalError } from "../tool-types.js";
|
|
11
12
|
import { wireCall, wireRows, wireDownloadBuffer, wireUploadFile, WireError } from "../wire.js";
|
|
12
13
|
import { parameterFaceCovers, serviceStatusSegment } from "../service-support.js";
|
|
@@ -803,10 +804,39 @@ export function registerB2Lane(tools) {
|
|
|
803
804
|
serviceStatus: serviceStatusSegment({ operation: "method.delete", serviceCode: args.serviceCode, methodCode: args.methodCode, servicePresent, methodPresent: false }),
|
|
804
805
|
};
|
|
805
806
|
// A referenced method answers 500108 业务方法已绑定默认方法,不可删除
|
|
806
|
-
// (BizServiceMethodController.java:
|
|
807
|
-
//
|
|
808
|
-
//
|
|
809
|
-
|
|
807
|
+
// (BizServiceMethodController.java:248-281). The writeLint pre-check makes
|
|
808
|
+
// that refusal local (zero writes, references + two confirmed options);
|
|
809
|
+
// this catch is the RACE fallback: something got bound between the lint
|
|
810
|
+
// and the delete, or h_biz_method_mapping kept a residue. Only the count
|
|
811
|
+
// is re-read here — never the rule scan.
|
|
812
|
+
let performed;
|
|
813
|
+
try {
|
|
814
|
+
performed = await wireCall(session, { path: ENDPOINTS.bizServiceMethodDelete, method: "POST", query: { id } });
|
|
815
|
+
}
|
|
816
|
+
catch (error) {
|
|
817
|
+
if (!(error instanceof WireError) || error.errcode !== 500108)
|
|
818
|
+
throw error;
|
|
819
|
+
let count;
|
|
820
|
+
try {
|
|
821
|
+
count = await countMethodMapping(session, args.serviceCode, args.methodCode);
|
|
822
|
+
}
|
|
823
|
+
catch {
|
|
824
|
+
count = undefined;
|
|
825
|
+
}
|
|
826
|
+
throw new ToolRefusalError({
|
|
827
|
+
status: "refused",
|
|
828
|
+
blocker: "method-referenced",
|
|
829
|
+
errcode: 500108,
|
|
830
|
+
serviceCode: args.serviceCode,
|
|
831
|
+
methodCode: args.methodCode,
|
|
832
|
+
...(count !== undefined
|
|
833
|
+
? { referenceCount: count }
|
|
834
|
+
: { referenceCountNote: "count_mapping 在 500108 之后重读失败:方法级引用计数未知(平台 500108 仍是权威删除门)" }),
|
|
835
|
+
message: `${methodReferencedCoreMessage(args.serviceCode, args.methodCode, count ?? 0)}(预检计数为 0,但平台仍返回 500108:竞态或 h_biz_method_mapping 残留)`,
|
|
836
|
+
doNot: "不要自行解绑规则、不要改调度生效时间后再删方法;解绑属于高危写入,必须用户确认",
|
|
837
|
+
nextCommand: `omc call rule.references --args '{"kind":"service","code":"${args.serviceCode}"}'`,
|
|
838
|
+
});
|
|
839
|
+
}
|
|
810
840
|
const afterRows = wireRows((await wireCall(session, { path: ENDPOINTS.bizServiceMethodList, query: { serviceCode: args.serviceCode, filterFlag: "false" } })).data);
|
|
811
841
|
const after = afterRows.find((row) => row.code === args.methodCode);
|
|
812
842
|
return {
|
|
@@ -815,6 +845,69 @@ export function registerB2Lane(tools) {
|
|
|
815
845
|
serviceStatus: serviceStatusSegment({ operation: "method.delete", serviceCode: args.serviceCode, methodCode: args.methodCode, servicePresent, methodPresent: after != null }),
|
|
816
846
|
};
|
|
817
847
|
},
|
|
848
|
+
// Ticket 01 (2026-11-20): the 500108 refusal must be LOCAL and actionable.
|
|
849
|
+
// F5 showed the bare platform error pushing an agent to unbind production
|
|
850
|
+
// rules by itself (rule.save minus the BIZ_ACTION node → change the
|
|
851
|
+
// scheduler time → delete again). This lint runs on BOTH the dry-run and
|
|
852
|
+
// the real path (write.ts shares it), reads the platform's authoritative
|
|
853
|
+
// count, and refuses with references + coverage + two non-automatic
|
|
854
|
+
// options. A missing method stays idempotent (execute's ok-absent branch),
|
|
855
|
+
// and a failed count read degrades to the platform 500108 gate.
|
|
856
|
+
writeLint: async (session, args) => {
|
|
857
|
+
const rows = wireRows((await wireCall(session, { path: ENDPOINTS.bizServiceMethodList, query: { serviceCode: args.serviceCode, filterFlag: "false" } })).data);
|
|
858
|
+
if (!rows.some((row) => row.code === args.methodCode))
|
|
859
|
+
return;
|
|
860
|
+
let count;
|
|
861
|
+
try {
|
|
862
|
+
count = await countMethodMapping(session, args.serviceCode, args.methodCode);
|
|
863
|
+
}
|
|
864
|
+
catch {
|
|
865
|
+
return;
|
|
866
|
+
}
|
|
867
|
+
if (count <= 0)
|
|
868
|
+
return;
|
|
869
|
+
const { sites, coverage } = await scanMethodReferenceSites(session, args.serviceCode, args.methodCode);
|
|
870
|
+
const readFirst = sites.length > 0
|
|
871
|
+
? sites.map((site) => `omc call rule.get --args '{"schemaCode":"${site.schemaCode}","ruleCode":"${site.ruleCode}"}'`)
|
|
872
|
+
: [`omc call rule.references --args '{"kind":"service","code":"${args.serviceCode}"}'`];
|
|
873
|
+
throw new ToolRefusalError({
|
|
874
|
+
status: "refused",
|
|
875
|
+
blocker: "method-referenced",
|
|
876
|
+
serviceCode: args.serviceCode,
|
|
877
|
+
methodCode: args.methodCode,
|
|
878
|
+
referenceCount: count,
|
|
879
|
+
references: sites,
|
|
880
|
+
coverage,
|
|
881
|
+
...(sites.length === 0
|
|
882
|
+
? { scanNote: `本次扫描未命中引用点(count_mapping 计数 ${count} > 0)——零命中不代表无引用;可能来自未扫到的应用或非规则引用` }
|
|
883
|
+
: {}),
|
|
884
|
+
platformErrcode: 500108,
|
|
885
|
+
message: methodReferencedCoreMessage(args.serviceCode, args.methodCode, count) + methodReferenceIdentity(sites, args.serviceCode),
|
|
886
|
+
doNot: "不要自行解绑规则、不要改调度生效时间后再删方法;解绑属于高危写入,必须用户确认",
|
|
887
|
+
options: [
|
|
888
|
+
{
|
|
889
|
+
id: "read-only",
|
|
890
|
+
destructive: false,
|
|
891
|
+
summary: "保留方法,先不动规则;本次未删除、未改任何配置",
|
|
892
|
+
},
|
|
893
|
+
{
|
|
894
|
+
id: "unlink",
|
|
895
|
+
destructive: true,
|
|
896
|
+
requiresConfirmation: true,
|
|
897
|
+
summary: "先解绑引用规则里的 BIZ_ACTION 节点,再删方法(需用户明确确认)",
|
|
898
|
+
readFirst,
|
|
899
|
+
steps: [
|
|
900
|
+
"用 rule.get 读回完整 nodeGraph(保留其余节点、routes、schedulerSetting 等全部字段)",
|
|
901
|
+
`只在图里去掉 methodMapping 指向 ${args.serviceCode}/${args.methodCode} 的 BIZ_ACTION 节点`,
|
|
902
|
+
"omc call rule.save --args '<去掉该节点后的完整图>'(平台会铸新规则 id;未声明的节点逐字节保留)",
|
|
903
|
+
"重新调用 method.delete",
|
|
904
|
+
],
|
|
905
|
+
note: "本工具不会自动解绑;解绑是独立的高危写入,必须由用户确认后另行执行",
|
|
906
|
+
},
|
|
907
|
+
],
|
|
908
|
+
nextCommand: `omc call rule.references --args '{"kind":"service","code":"${args.serviceCode}"}'`,
|
|
909
|
+
});
|
|
910
|
+
},
|
|
818
911
|
rollback: b2ServiceRollbackSpec("method.delete"),
|
|
819
912
|
});
|
|
820
913
|
tools.push(defineTool({
|
|
@@ -168,7 +168,7 @@ export const BUSINESSRULE_LANE_CONTRACT = Object.freeze({
|
|
|
168
168
|
// 295,400B,HEAD 4c524b83 实测 295,331 仅余 69B——加对照句即红门)。对照
|
|
169
169
|
// 教学住 read-shapes 的 notes[0](默认 describe 面即回,不进 tools/list);
|
|
170
170
|
// MCP 面的同款对照由 omc_graph_explore 的 description 承担。
|
|
171
|
-
description: "跨规则引用检索:一次调用替代 agent 逐 schema×ruleCode 全平台枚举 rule.get(删服务/模型/字段/规则前的影响面)。kind=service 查 BIZ_ACTION 的 methodMapping.serviceCode;kind=model 查 CREATE/UPDATE/DELETE 的 targetObjectCode 与 methodMapping.schemaCode(删模型前的影响面);kind=field 查 dataActions.targetDataItem、inputMappings/outputMappings 的 bizCode、规则条件叶子(filterCondition/BRANCH 出口等,只认主模型字段)与 datarule(propertyCodes + options 文本;字段 code 跨模型不唯一,建议配 schemaCodes 限范围);kind=rule 查流程事件绑定(flow 级 handler 与节点级 nodeEvent 的 bizActions
|
|
171
|
+
description: "跨规则引用检索:一次调用替代 agent 逐 schema×ruleCode 全平台枚举 rule.get(删服务/模型/字段/规则前的影响面)。kind=service 查 BIZ_ACTION 的 methodMapping.serviceCode;kind=model 查 CREATE/UPDATE/DELETE 的 targetObjectCode 与 methodMapping.schemaCode(删模型前的影响面);kind=field 查 dataActions.targetDataItem、inputMappings/outputMappings 的 bizCode、规则条件叶子(filterCondition/BRANCH 出口等,只认主模型字段)与 datarule(propertyCodes + options 文本;字段 code 跨模型不唯一,建议配 schemaCodes 限范围);kind=rule 查流程事件绑定(flow 级 handler 与节点级 nodeEvent 的 bizActions,按模型枚举流程面)。kind:\"trigger\" 按 schemaCode 列全触发点(流程三面/表单按钮/规则/预置事件/在线 JS)。实现为客户端聚合(应用树模型清单→逐模型 rule.list/rule.get 或 get_published),输出只回命中行;各 kind 的覆盖面与协议局限见回执 coverage。",
|
|
172
172
|
}),
|
|
173
173
|
"rule.save": Object.freeze({
|
|
174
174
|
scope: "dead-state CRUD conditional node graphs",
|
|
@@ -176,7 +176,7 @@ export const BUSINESSRULE_LANE_CONTRACT = Object.freeze({
|
|
|
176
176
|
}),
|
|
177
177
|
"rule.node.update": Object.freeze({
|
|
178
178
|
scope: "dead-state CRUD conditional node graphs",
|
|
179
|
-
description: "精确改一个节点:按 schemaCode+ruleCode 读当前图,把 patch 浅合并到 nodeCode 对应的节点,再走与 rule.save 相同的保存 seam(所有图门禁与读回一致)。用来改一个分支阈值/条件/动作而不必重发整图。nodeCode/nodeType 不可改(平台按 nodeCode 连路由、节点类型不可变);改完默认只存草稿,生效仍需 rule.enable(publish:true 可顺带发布)。",
|
|
179
|
+
description: "精确改一个节点:按 schemaCode+ruleCode 读当前图,把 patch 浅合并到 nodeCode 对应的节点,再走与 rule.save 相同的保存 seam(所有图门禁与读回一致)。用来改一个分支阈值/条件/动作而不必重发整图。mapping 面可只改一条映射(按稳定标识唯一定位,命中≠1 即拒绝)。nodeCode/nodeType 不可改(平台按 nodeCode 连路由、节点类型不可变);改完默认只存草稿,生效仍需 rule.enable(publish:true 可顺带发布)。",
|
|
180
180
|
}),
|
|
181
181
|
}),
|
|
182
182
|
});
|
|
@@ -188,7 +188,7 @@ export function assertBusinessRuleContract() {
|
|
|
188
188
|
if (!String(BUSINESSRULE_LANE_CONTRACT.wire.compatibilityMatrix).includes("CREATE -> dictionary-backed selection"))
|
|
189
189
|
throw new Error("businessrule contract must expose the evidence-backed compatibility matrix");
|
|
190
190
|
assertDescriptionCarries(BUSINESSRULE_LANE_CONTRACT, "rule.get", ["inputParam", "node/route", "nodeDigests", "ruleCodes"]);
|
|
191
|
-
assertDescriptionCarries(BUSINESSRULE_LANE_CONTRACT, "rule.node.update", ["schemaCode", "ruleCode", "nodeCode", "patch", "rule.save", "rule.enable"]);
|
|
191
|
+
assertDescriptionCarries(BUSINESSRULE_LANE_CONTRACT, "rule.node.update", ["schemaCode", "ruleCode", "nodeCode", "patch", "mapping", "rule.save", "rule.enable"]);
|
|
192
192
|
assertDescriptionCarries({ tools: { "rule.nodeGraph": { scope: "node graph", description: ruleNodeGraphDescription() } } }, "rule.nodeGraph", [
|
|
193
193
|
"inputParam",
|
|
194
194
|
"_input",
|